Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- wrap the core with "(function () {})()"
- Loading branch information
1 parent
28528ff
commit 870fc1f
Showing
2 changed files
with
118 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,140 +1,134 @@ | ||
;(function () { | ||
|
||
var __ID__ = 1 | ||
var __ID__ = 1 | ||
|
||
|
||
Joose.Managed.PropertySet.Mutable = new Joose.Proto.Class('Joose.Managed.PropertySet.Mutable', { | ||
|
||
isa : Joose.Managed.PropertySet, | ||
|
||
Joose.Managed.PropertySet.Mutable = new Joose.Proto.Class('Joose.Managed.PropertySet.Mutable', { | ||
|
||
isa : Joose.Managed.PropertySet, | ||
ID : null, | ||
|
||
ID : null, | ||
|
||
derivatives : null, | ||
|
||
opened : null, | ||
|
||
composedFrom : null, | ||
|
||
|
||
initialize : function (props) { | ||
Joose.Managed.PropertySet.Mutable.superClass.initialize.call(this, props) | ||
|
||
//initially opened | ||
this.opened = 1 | ||
this.derivatives = {} | ||
this.ID = __ID__++ | ||
this.composedFrom = [] | ||
}, | ||
|
||
derivatives : null, | ||
|
||
opened : null, | ||
|
||
composedFrom : null, | ||
|
||
|
||
initialize : function (props) { | ||
Joose.Managed.PropertySet.Mutable.superClass.initialize.call(this, props) | ||
|
||
//initially opened | ||
this.opened = 1 | ||
this.derivatives = {} | ||
this.ID = __ID__++ | ||
this.composedFrom = [] | ||
}, | ||
|
||
|
||
addComposeInfo : function () { | ||
this.ensureOpen() | ||
|
||
addComposeInfo : function () { | ||
this.ensureOpen() | ||
Joose.A.each(arguments, function (arg) { | ||
this.composedFrom.push(arg) | ||
|
||
Joose.A.each(arguments, function (arg) { | ||
this.composedFrom.push(arg) | ||
var propSet = arg instanceof Joose.Managed.PropertySet ? arg : arg.propertySet | ||
|
||
var propSet = arg instanceof Joose.Managed.PropertySet ? arg : arg.propertySet | ||
|
||
propSet.derivatives[this.ID] = this | ||
}, this) | ||
}, | ||
|
||
propSet.derivatives[this.ID] = this | ||
}, this) | ||
}, | ||
|
||
|
||
removeComposeInfo : function () { | ||
this.ensureOpen() | ||
|
||
removeComposeInfo : function () { | ||
this.ensureOpen() | ||
Joose.A.each(arguments, function (arg) { | ||
|
||
Joose.A.each(arguments, function (arg) { | ||
|
||
var i = 0 | ||
|
||
while (i < this.composedFrom.length) { | ||
var propSet = this.composedFrom[i] | ||
propSet = propSet instanceof Joose.Managed.PropertySet ? propSet : propSet.propertySet | ||
|
||
if (arg == propSet) { | ||
delete propSet.derivatives[this.ID] | ||
this.composedFrom.splice(i, 1) | ||
} else i++ | ||
} | ||
var i = 0 | ||
|
||
while (i < this.composedFrom.length) { | ||
var propSet = this.composedFrom[i] | ||
propSet = propSet instanceof Joose.Managed.PropertySet ? propSet : propSet.propertySet | ||
|
||
}, this) | ||
}, | ||
|
||
|
||
ensureOpen : function () { | ||
if (!this.opened) throw "Mutation of closed property set: [" + this.name + "]" | ||
}, | ||
|
||
|
||
addProperty : function (name, props) { | ||
this.ensureOpen() | ||
if (arg == propSet) { | ||
delete propSet.derivatives[this.ID] | ||
this.composedFrom.splice(i, 1) | ||
} else i++ | ||
} | ||
|
||
return Joose.Managed.PropertySet.Mutable.superClass.addProperty.call(this, name, props) | ||
}, | ||
|
||
}, this) | ||
}, | ||
|
||
addPropertyObject : function (object) { | ||
this.ensureOpen() | ||
|
||
return Joose.Managed.PropertySet.Mutable.superClass.addPropertyObject.call(this, object) | ||
}, | ||
|
||
ensureOpen : function () { | ||
if (!this.opened) throw "Mutation of closed property set: [" + this.name + "]" | ||
}, | ||
|
||
|
||
addProperty : function (name, props) { | ||
this.ensureOpen() | ||
|
||
return Joose.Managed.PropertySet.Mutable.superClass.addProperty.call(this, name, props) | ||
}, | ||
|
||
|
||
addPropertyObject : function (object) { | ||
this.ensureOpen() | ||
|
||
removeProperty : function (name) { | ||
this.ensureOpen() | ||
|
||
return Joose.Managed.PropertySet.Mutable.superClass.removeProperty.call(this, name) | ||
}, | ||
return Joose.Managed.PropertySet.Mutable.superClass.addPropertyObject.call(this, object) | ||
}, | ||
|
||
|
||
removeProperty : function (name) { | ||
this.ensureOpen() | ||
|
||
return Joose.Managed.PropertySet.Mutable.superClass.removeProperty.call(this, name) | ||
}, | ||
|
||
|
||
composeFrom : function () { | ||
this.ensureOpen() | ||
|
||
composeFrom : function () { | ||
this.ensureOpen() | ||
|
||
return Joose.Managed.PropertySet.Mutable.superClass.composeFrom.apply(this, this.composedFrom) | ||
}, | ||
return Joose.Managed.PropertySet.Mutable.superClass.composeFrom.apply(this, this.composedFrom) | ||
}, | ||
|
||
|
||
open : function () { | ||
this.opened++ | ||
|
||
if (this.opened == 1) { | ||
|
||
open : function () { | ||
this.opened++ | ||
Joose.O.each(this.derivatives, function (propSet) { | ||
propSet.open() | ||
}) | ||
|
||
if (this.opened == 1) { | ||
|
||
Joose.O.each(this.derivatives, function (propSet) { | ||
propSet.open() | ||
}) | ||
|
||
this.deCompose() | ||
} | ||
}, | ||
|
||
this.deCompose() | ||
} | ||
}, | ||
|
||
|
||
close : function () { | ||
if (!this.opened) throw "Unmatched 'close' operation on property set: [" + this.name + "]" | ||
|
||
close : function () { | ||
if (!this.opened) throw "Unmatched 'close' operation on property set: [" + this.name + "]" | ||
if (this.opened == 1) { | ||
this.reCompose() | ||
|
||
if (this.opened == 1) { | ||
this.reCompose() | ||
|
||
Joose.O.each(this.derivatives, function (propSet) { | ||
propSet.close() | ||
}) | ||
} | ||
this.opened-- | ||
}, | ||
|
||
|
||
reCompose : function () { | ||
this.composeFrom() | ||
}, | ||
|
||
|
||
deCompose : function () { | ||
this.eachOwn(function (property, name) { | ||
if (property.definedIn != this) this.removeProperty(name) | ||
}, this) | ||
Joose.O.each(this.derivatives, function (propSet) { | ||
propSet.close() | ||
}) | ||
} | ||
|
||
}).c | ||
this.opened-- | ||
}, | ||
|
||
|
||
})() | ||
|
||
reCompose : function () { | ||
this.composeFrom() | ||
}, | ||
|
||
|
||
deCompose : function () { | ||
this.eachOwn(function (property, name) { | ||
if (property.definedIn != this) this.removeProperty(name) | ||
}, this) | ||
} | ||
|
||
}).c |