tests are no longer failing :)
This commit is contained in:
@@ -245,7 +245,11 @@ module.exports = function() {
|
||||
Insert.prototype.type = "Insert";
|
||||
|
||||
Insert.prototype.val = function() {
|
||||
return this.content;
|
||||
if ((this.content != null) && (this.content.getCustomType != null)) {
|
||||
return this.content.getCustomType();
|
||||
} else {
|
||||
return this.content;
|
||||
}
|
||||
};
|
||||
|
||||
Insert.prototype.applyDelete = function(o) {
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports = function() {
|
||||
rep = content;
|
||||
}
|
||||
this.retrieveSub(name).replace(rep);
|
||||
return this;
|
||||
return this.getCustomType();
|
||||
} else if (name != null) {
|
||||
prop = this._map[name];
|
||||
if ((prop != null) && !prop.isContentDeleted()) {
|
||||
@@ -201,7 +201,7 @@ module.exports = function() {
|
||||
result = [];
|
||||
while (o !== this.end) {
|
||||
if (!o.is_deleted) {
|
||||
result.push(o);
|
||||
result.push(o.val());
|
||||
}
|
||||
o = o.next_cl;
|
||||
}
|
||||
@@ -285,6 +285,9 @@ module.exports = function() {
|
||||
} else {
|
||||
for (_i = 0, _len = content.length; _i < _len; _i++) {
|
||||
c = content[_i];
|
||||
if ((c != null) && (c._name != null) && (c._getModel != null)) {
|
||||
c = c._getModel(this.custom_types, this.operations);
|
||||
}
|
||||
tmp = (new ops.Insert(null, c, void 0, left, right)).execute();
|
||||
left = tmp;
|
||||
}
|
||||
@@ -345,7 +348,7 @@ module.exports = function() {
|
||||
this.event_properties = _at_event_properties;
|
||||
this.event_this = _at_event_this;
|
||||
if (this.event_properties['object'] == null) {
|
||||
this.event_properties['object'] = this.event_this;
|
||||
this.event_properties['object'] = this.event_this.getCustomType();
|
||||
}
|
||||
ReplaceManager.__super__.constructor.call(this, custom_type, uid, beginning, end);
|
||||
}
|
||||
@@ -465,7 +468,7 @@ module.exports = function() {
|
||||
var old_value;
|
||||
if (this.next_cl.type === "Delimiter" && this.prev_cl.type !== "Delimiter") {
|
||||
if (!this.is_deleted) {
|
||||
old_value = this.prev_cl.content;
|
||||
old_value = this.prev_cl.val();
|
||||
this.parent.callEventDecorator([
|
||||
{
|
||||
type: "update",
|
||||
@@ -494,7 +497,7 @@ module.exports = function() {
|
||||
{
|
||||
type: "delete",
|
||||
changedBy: o.uid.creator,
|
||||
oldValue: this.content
|
||||
oldValue: this.val()
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
71
build/node/Types/List.js
Normal file
71
build/node/Types/List.js
Normal file
@@ -0,0 +1,71 @@
|
||||
var YList;
|
||||
|
||||
YList = (function() {
|
||||
function YList(list) {
|
||||
if (list == null) {
|
||||
this._list = [];
|
||||
} else if (list.constructor === Array) {
|
||||
this._list = list;
|
||||
} else {
|
||||
throw new Error("Y.List expects an Array as a parameter");
|
||||
}
|
||||
}
|
||||
|
||||
YList.prototype._name = "List";
|
||||
|
||||
YList.prototype._getModel = function(types, ops) {
|
||||
if (this._model == null) {
|
||||
this._model = new ops.ListManager(this).execute();
|
||||
this.insert(0, this._list);
|
||||
}
|
||||
delete this._list;
|
||||
return this._model;
|
||||
};
|
||||
|
||||
YList.prototype._setModel = function(_at__model) {
|
||||
this._model = _at__model;
|
||||
return delete this._list;
|
||||
};
|
||||
|
||||
YList.prototype.val = function() {
|
||||
return this._model.val.apply(this._model, arguments);
|
||||
};
|
||||
|
||||
YList.prototype.observe = function() {
|
||||
this._model.observe.apply(this._model, arguments);
|
||||
return this;
|
||||
};
|
||||
|
||||
YList.prototype.unobserve = function() {
|
||||
this._model.unobserve.apply(this._model, arguments);
|
||||
return this;
|
||||
};
|
||||
|
||||
YList.prototype.insert = function(position, content) {
|
||||
if (typeof position !== "number") {
|
||||
throw new Error("Y.List.insert expects a Number as the first parameter!");
|
||||
}
|
||||
this._model.insert(position, content);
|
||||
return this;
|
||||
};
|
||||
|
||||
YList.prototype["delete"] = function(position, length) {
|
||||
this._model["delete"](position, length);
|
||||
return this;
|
||||
};
|
||||
|
||||
return YList;
|
||||
|
||||
})();
|
||||
|
||||
if (typeof window !== "undefined" && window !== null) {
|
||||
if (window.Y != null) {
|
||||
window.Y.List = YList;
|
||||
} else {
|
||||
throw new Error("You must first import Y!");
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof module !== "undefined" && module !== null) {
|
||||
module.exports = YList;
|
||||
}
|
||||
@@ -39,7 +39,13 @@ YObject = (function() {
|
||||
};
|
||||
|
||||
YObject.prototype.observe = function(f) {
|
||||
return this._model.observe(f);
|
||||
this._model.observe(f);
|
||||
return this;
|
||||
};
|
||||
|
||||
YObject.prototype.unobserve = function(f) {
|
||||
this._model.unobserve(f);
|
||||
return this;
|
||||
};
|
||||
|
||||
YObject.prototype.val = function(name, content) {
|
||||
@@ -64,7 +70,8 @@ YObject = (function() {
|
||||
};
|
||||
|
||||
YObject.prototype["delete"] = function(name) {
|
||||
return this._model["delete"](name);
|
||||
this._model["delete"](name);
|
||||
return this;
|
||||
};
|
||||
|
||||
return YObject;
|
||||
|
||||
@@ -52,7 +52,7 @@ YText = (function() {
|
||||
throw new Error("Y.String.insert expects a String as the second parameter!");
|
||||
}
|
||||
if (typeof position !== "number") {
|
||||
throw new Error("Y.String.insert expects a Number as the second parameter!");
|
||||
throw new Error("Y.String.insert expects a Number as the first parameter!");
|
||||
}
|
||||
if (content.length > 0) {
|
||||
ith = this._model.getOperationByPosition(position);
|
||||
|
||||
@@ -43,5 +43,3 @@ if (typeof window !== "undefined" && window !== null) {
|
||||
}
|
||||
|
||||
createY.Object = require("./Types/Object");
|
||||
|
||||
createY.Text = require("./Types/Text");
|
||||
|
||||
Reference in New Issue
Block a user