added XMPP example, fixed bug in TextType binding to textfield
This commit is contained in:
@@ -210,14 +210,7 @@
|
||||
}
|
||||
Insert.__super__.applyDelete.call(this, garbagecollect);
|
||||
if (callLater) {
|
||||
this.parent.callEvent([
|
||||
{
|
||||
type: "insert",
|
||||
position: this.getPosition(),
|
||||
object: this.parent,
|
||||
changed_by: o.uid.creator
|
||||
}
|
||||
]);
|
||||
this.callOperationSpecificDeleteEvents(o);
|
||||
}
|
||||
if ((_ref = this.next_cl) != null ? _ref.isDeleted() : void 0) {
|
||||
return this.next_cl.applyDelete();
|
||||
@@ -299,24 +292,36 @@
|
||||
}
|
||||
this.setParent(this.prev_cl.getParent());
|
||||
Insert.__super__.execute.apply(this, arguments);
|
||||
this.callOperationSpecificEvents();
|
||||
this.callOperationSpecificInsertEvents();
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
Insert.prototype.callOperationSpecificEvents = function() {
|
||||
Insert.prototype.callOperationSpecificInsertEvents = function() {
|
||||
var _ref;
|
||||
return (_ref = this.parent) != null ? _ref.callEvent([
|
||||
{
|
||||
type: "insert",
|
||||
position: this.getPosition(),
|
||||
object: this.parent,
|
||||
changed_by: this.uid.creator,
|
||||
changedBy: this.uid.creator,
|
||||
value: this.content
|
||||
}
|
||||
]) : void 0;
|
||||
};
|
||||
|
||||
Insert.prototype.callOperationSpecificDeleteEvents = function(o) {
|
||||
return this.parent.callEvent([
|
||||
{
|
||||
type: "delete",
|
||||
position: this.getPosition(),
|
||||
object: this.parent,
|
||||
length: 1,
|
||||
changedBy: o.uid.creator
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
Insert.prototype.getPosition = function() {
|
||||
var position, prev;
|
||||
position = 0;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -103,7 +103,7 @@
|
||||
_results = [];
|
||||
for (_i = 0, _len = events.length; _i < _len; _i++) {
|
||||
event = events[_i];
|
||||
if ((event.changed_by == null) && (event.type === "add" || (event.type = "update"))) {
|
||||
if ((event.changedBy == null) && (event.type === "add" || (event.type = "update"))) {
|
||||
_results.push(that.val(event.name, event.object[event.name]));
|
||||
} else {
|
||||
_results.push(void 0);
|
||||
@@ -128,7 +128,7 @@
|
||||
type: 'update',
|
||||
name: event.name,
|
||||
oldValue: oldVal,
|
||||
changed_by: event.changed_by
|
||||
changedBy: event.changedBy
|
||||
}));
|
||||
} else {
|
||||
notifier.performChange('add', function() {
|
||||
@@ -139,7 +139,7 @@
|
||||
type: 'add',
|
||||
name: event.name,
|
||||
oldValue: oldVal,
|
||||
changed_by: event.changed_by
|
||||
changedBy: event.changedBy
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -35,40 +35,50 @@
|
||||
};
|
||||
|
||||
MapManager.prototype.val = function(name, content) {
|
||||
var o, obj, qqq, result, x, _ref, _ref1;
|
||||
var o, obj, prop, result, _ref;
|
||||
if (content != null) {
|
||||
if (this.map[name] == null) {
|
||||
(new AddName(void 0, this, name)).execute();
|
||||
}
|
||||
if (this.map[name] === null) {
|
||||
qqq = this;
|
||||
x = new AddName(void 0, this, name);
|
||||
x.execute();
|
||||
}
|
||||
this.map[name].replace(content);
|
||||
return this;
|
||||
} else if (name != null) {
|
||||
obj = (_ref = this.map[name]) != null ? _ref.val() : void 0;
|
||||
if (obj instanceof types.ImmutableObject) {
|
||||
return obj.val();
|
||||
prop = this.map[name];
|
||||
if ((prop != null) && !prop.isContentDeleted()) {
|
||||
obj = prop.val();
|
||||
if (obj instanceof types.ImmutableObject) {
|
||||
return obj.val();
|
||||
} else {
|
||||
return obj;
|
||||
}
|
||||
} else {
|
||||
return obj;
|
||||
return void 0;
|
||||
}
|
||||
} else {
|
||||
result = {};
|
||||
_ref1 = this.map;
|
||||
for (name in _ref1) {
|
||||
o = _ref1[name];
|
||||
obj = o.val();
|
||||
if (obj instanceof types.ImmutableObject || obj instanceof MapManager) {
|
||||
obj = obj.val();
|
||||
_ref = this.map;
|
||||
for (name in _ref) {
|
||||
o = _ref[name];
|
||||
if (!o.isContentDeleted()) {
|
||||
obj = o.val();
|
||||
if (obj instanceof types.ImmutableObject) {
|
||||
obj = obj.val();
|
||||
}
|
||||
result[name] = obj;
|
||||
}
|
||||
result[name] = obj;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
MapManager.prototype["delete"] = function(name) {
|
||||
var _ref;
|
||||
if ((_ref = this.map[name]) != null) {
|
||||
_ref.deleteContent();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
return MapManager;
|
||||
|
||||
})(types.Operation);
|
||||
@@ -221,9 +231,12 @@
|
||||
ReplaceManager = (function(_super) {
|
||||
__extends(ReplaceManager, _super);
|
||||
|
||||
function ReplaceManager(event_porperties, event_this, uid, beginning, end, prev, next, origin) {
|
||||
this.event_porperties = event_porperties;
|
||||
function ReplaceManager(event_properties, event_this, uid, beginning, end, prev, next, origin) {
|
||||
this.event_properties = event_properties;
|
||||
this.event_this = event_this;
|
||||
if (this.event_properties['object'] == null) {
|
||||
this.event_properties['object'] = this.event_this;
|
||||
}
|
||||
ReplaceManager.__super__.constructor.call(this, uid, beginning, end, prev, next, origin);
|
||||
}
|
||||
|
||||
@@ -253,11 +266,11 @@
|
||||
ReplaceManager.prototype.callEventDecorator = function(events) {
|
||||
var event, name, prop, _i, _len, _ref;
|
||||
if (!this.isDeleted()) {
|
||||
_ref = this.event_porperties;
|
||||
for (name in _ref) {
|
||||
prop = _ref[name];
|
||||
for (_i = 0, _len = events.length; _i < _len; _i++) {
|
||||
event = events[_i];
|
||||
for (_i = 0, _len = events.length; _i < _len; _i++) {
|
||||
event = events[_i];
|
||||
_ref = this.event_properties;
|
||||
for (name in _ref) {
|
||||
prop = _ref[name];
|
||||
event[name] = prop;
|
||||
}
|
||||
}
|
||||
@@ -267,9 +280,18 @@
|
||||
};
|
||||
|
||||
ReplaceManager.prototype.replace = function(content, replaceable_uid) {
|
||||
var o;
|
||||
var o, relp;
|
||||
o = this.getLastOperation();
|
||||
(new Replaceable(content, this, replaceable_uid, o, o.next_cl)).execute();
|
||||
relp = (new Replaceable(content, this, replaceable_uid, o, o.next_cl)).execute();
|
||||
return void 0;
|
||||
};
|
||||
|
||||
ReplaceManager.prototype.isContentDeleted = function() {
|
||||
return this.getLastOperation().isDeleted();
|
||||
};
|
||||
|
||||
ReplaceManager.prototype.deleteContent = function() {
|
||||
(new types.Delete(void 0, this.getLastOperation().uid)).execute();
|
||||
return void 0;
|
||||
};
|
||||
|
||||
@@ -324,6 +346,8 @@
|
||||
};
|
||||
|
||||
Replaceable.prototype.applyDelete = function() {
|
||||
var res;
|
||||
res = Replaceable.__super__.applyDelete.apply(this, arguments);
|
||||
if (this.content != null) {
|
||||
if (this.next_cl.type !== "Delimiter") {
|
||||
this.content.deleteAllObservers();
|
||||
@@ -332,38 +356,50 @@
|
||||
this.content.dontSync();
|
||||
}
|
||||
this.content = null;
|
||||
return Replaceable.__super__.applyDelete.apply(this, arguments);
|
||||
return res;
|
||||
};
|
||||
|
||||
Replaceable.prototype.cleanup = function() {
|
||||
return Replaceable.__super__.cleanup.apply(this, arguments);
|
||||
};
|
||||
|
||||
Replaceable.prototype.callOperationSpecificEvents = function() {
|
||||
Replaceable.prototype.callOperationSpecificInsertEvents = function() {
|
||||
var old_value;
|
||||
if (this.next_cl.type === "Delimiter" && this.prev_cl.type !== "Delimiter") {
|
||||
old_value = this.prev_cl.content;
|
||||
this.prev_cl.applyDelete();
|
||||
this.parent.callEventDecorator([
|
||||
{
|
||||
type: "update",
|
||||
changed_by: this.uid.creator,
|
||||
changedBy: this.uid.creator,
|
||||
oldValue: old_value
|
||||
}
|
||||
]);
|
||||
this.prev_cl.applyDelete();
|
||||
} else if (this.next_cl.type !== "Delimiter") {
|
||||
this.applyDelete();
|
||||
} else {
|
||||
this.parent.callEventDecorator([
|
||||
{
|
||||
type: "add",
|
||||
changed_by: this.uid.creator
|
||||
changedBy: this.uid.creator
|
||||
}
|
||||
]);
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
|
||||
Replaceable.prototype.callOperationSpecificDeleteEvents = function(o) {
|
||||
if (this.next_cl.type === "Delimiter") {
|
||||
return this.parent.callEventDecorator([
|
||||
{
|
||||
type: "delete",
|
||||
changedBy: o.uid.creator,
|
||||
oldValue: this.content
|
||||
}
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
Replaceable.prototype._encode = function() {
|
||||
var json, _ref;
|
||||
json = {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -197,37 +197,44 @@
|
||||
var word;
|
||||
word = this;
|
||||
textfield.value = this.val();
|
||||
this.on("insert", function(event, op) {
|
||||
var fix, left, o_pos, right;
|
||||
o_pos = op.getPosition();
|
||||
fix = function(cursor) {
|
||||
if (cursor <= o_pos) {
|
||||
return cursor;
|
||||
this.observe(function(events) {
|
||||
var event, fix, left, o_pos, right, _i, _len, _results;
|
||||
_results = [];
|
||||
for (_i = 0, _len = events.length; _i < _len; _i++) {
|
||||
event = events[_i];
|
||||
if (event.type === "insert") {
|
||||
o_pos = event.position;
|
||||
fix = function(cursor) {
|
||||
if (cursor <= o_pos) {
|
||||
return cursor;
|
||||
} else {
|
||||
cursor += 1;
|
||||
return cursor;
|
||||
}
|
||||
};
|
||||
left = fix(textfield.selectionStart);
|
||||
right = fix(textfield.selectionEnd);
|
||||
textfield.value = word.val();
|
||||
_results.push(textfield.setSelectionRange(left, right));
|
||||
} else if (event.type === "delete") {
|
||||
o_pos = event.position;
|
||||
fix = function(cursor) {
|
||||
if (cursor < o_pos) {
|
||||
return cursor;
|
||||
} else {
|
||||
cursor -= 1;
|
||||
return cursor;
|
||||
}
|
||||
};
|
||||
left = fix(textfield.selectionStart);
|
||||
right = fix(textfield.selectionEnd);
|
||||
textfield.value = word.val();
|
||||
_results.push(textfield.setSelectionRange(left, right));
|
||||
} else {
|
||||
cursor += 1;
|
||||
return cursor;
|
||||
_results.push(void 0);
|
||||
}
|
||||
};
|
||||
left = fix(textfield.selectionStart);
|
||||
right = fix(textfield.selectionEnd);
|
||||
textfield.value = word.val();
|
||||
return textfield.setSelectionRange(left, right);
|
||||
});
|
||||
this.on("delete", function(event, op) {
|
||||
var fix, left, o_pos, right;
|
||||
o_pos = op.getPosition();
|
||||
fix = function(cursor) {
|
||||
if (cursor < o_pos) {
|
||||
return cursor;
|
||||
} else {
|
||||
cursor -= 1;
|
||||
return cursor;
|
||||
}
|
||||
};
|
||||
left = fix(textfield.selectionStart);
|
||||
right = fix(textfield.selectionEnd);
|
||||
textfield.value = word.val();
|
||||
return textfield.setSelectionRange(left, right);
|
||||
}
|
||||
return _results;
|
||||
});
|
||||
textfield.onkeypress = function(event) {
|
||||
var char, diff, new_pos, pos;
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user