tests are no longer failing :)

This commit is contained in:
DadaMonad
2015-02-23 13:20:39 +00:00
parent 2e9f8f6d03
commit f189ae11b0
21 changed files with 510 additions and 852 deletions

View File

@@ -301,7 +301,10 @@ module.exports = ()->
type: "Insert"
val: ()->
@content
if @content? and @content.getCustomType?
@content.getCustomType()
else
@content
#
# set content to null and other stuff

View File

@@ -42,7 +42,7 @@ module.exports = ()->
else
rep = content
@retrieveSub(name).replace rep
@
@getCustomType()
else if name?
prop = @_map[name]
if prop? and not prop.isContentDeleted()
@@ -172,7 +172,7 @@ module.exports = ()->
result = []
while o isnt @end
if not o.is_deleted
result.push o
result.push o.val()
o = o.next_cl
result
@@ -243,6 +243,8 @@ module.exports = ()->
(new ops.Insert null, content, undefined, left, right).execute()
else
for c in content
if c? and c._name? and c._getModel?
c = c._getModel(@custom_types, @operations)
tmp = (new ops.Insert null, c, undefined, left, right).execute()
left = tmp
@
@@ -317,7 +319,7 @@ module.exports = ()->
# @param {Delimiter} end Reference or Object.
constructor: (custom_type, @event_properties, @event_this, uid, beginning, end)->
if not @event_properties['object']?
@event_properties['object'] = @event_this
@event_properties['object'] = @event_this.getCustomType()
super custom_type, uid, beginning, end
type: "ReplaceManager"
@@ -439,7 +441,7 @@ module.exports = ()->
if @next_cl.type is "Delimiter" and @prev_cl.type isnt "Delimiter"
# this replaces another Replaceable
if not @is_deleted # When this is received from the HB, this could already be deleted!
old_value = @prev_cl.content
old_value = @prev_cl.val()
@parent.callEventDecorator [
type: "update"
changedBy: @uid.creator
@@ -462,7 +464,7 @@ module.exports = ()->
@parent.callEventDecorator [
type: "delete"
changedBy: o.uid.creator
oldValue: @content
oldValue: @val()
]
#

View File

@@ -0,0 +1,70 @@
class YList
#
# @private
# @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.
#
constructor: (list)->
if not list?
@_list = []
else if list.constructor is Array
@_list = list
else
throw new Error "Y.List expects an Array as a parameter"
_name: "List"
_getModel: (types, ops)->
if not @_model?
@_model = new ops.ListManager(@).execute()
@insert 0, @_list
delete @_list
@_model
_setModel: (@_model)->
delete @_list
val: ()->
@_model.val.apply @_model, arguments
observe: ()->
@_model.observe.apply @_model, arguments
@
unobserve: ()->
@_model.unobserve.apply @_model, arguments
@
#
# Inserts a Array into the list.
#
# @return {ListManager Type} This String object.
#
insert: (position, content)->
if typeof position isnt "number"
throw new Error "Y.List.insert expects a Number as the first parameter!"
@_model.insert position, content
@
delete: (position, length)->
@_model.delete position, length
@
if window?
if window.Y?
window.Y.List = YList
else
throw new Error "You must first import Y!"
if module?
module.exports = YList

View File

@@ -24,6 +24,11 @@ class YObject
observe: (f)->
@_model.observe f
@
unobserve: (f)->
@_model.unobserve f
@
#
# @overload val()
@@ -57,6 +62,7 @@ class YObject
delete: (name)->
@_model.delete(name)
@
if window?
if window.Y?

View File

@@ -1,6 +1,5 @@
#
# Handles a String-like data structures with support for insert/delete at a word-position.
# @note Currently, only Text is supported!
#
class YText
@@ -59,7 +58,7 @@ class YText
if content.constructor isnt String
throw new Error "Y.String.insert expects a String as the second parameter!"
if typeof position isnt "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 = @_model.getOperationByPosition position
# the (i-1)th character. e.g. "abc" the 1th character is "a"

View File

@@ -37,4 +37,3 @@ if window?
window.Y = createY
createY.Object = require "./Types/Object"
createY.Text = require "./Types/Text"