aboutsummaryrefslogtreecommitdiff
path: root/node_modules
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules')
-rwxr-xr-xnode_modules/montage/core/event/binding.js134
1 files changed, 56 insertions, 78 deletions
diff --git a/node_modules/montage/core/event/binding.js b/node_modules/montage/core/event/binding.js
index 4206e1c2..4091fe6a 100755
--- a/node_modules/montage/core/event/binding.js
+++ b/node_modules/montage/core/event/binding.js
@@ -5,13 +5,13 @@
5 </copyright> */ 5 </copyright> */
6 6
7/** 7/**
8 @module montage/core/event/binding 8 @module montage/core/event/binding
9 @requires montage/core/core 9 @requires montage/core/core
10 @requires montage/core/event/mutable-event 10 @requires montage/core/event/mutable-event
11 @requires montage/core/serializer 11 @requires montage/core/serializer
12 @requires montage/core/deserializer 12 @requires montage/core/deserializer
13 @requires montage/core/event/event-manager 13 @requires montage/core/event/event-manager
14*/ 14 */
15 15
16var Montage = require("montage").Montage, 16var Montage = require("montage").Montage,
17 ChangeNotification = require("core/change-notification").ChangeNotification, 17 ChangeNotification = require("core/change-notification").ChangeNotification,
@@ -23,14 +23,14 @@ var Montage = require("montage").Montage,
23 UNDERSCORE = "_"; 23 UNDERSCORE = "_";
24 24
25/** 25/**
26 @class module:montage/core/event/binding.ChangeEventDispatchingArray 26 @class module:montage/core/event/binding.ChangeEventDispatchingArray
27*/ 27 */
28var ChangeEventDispatchingArray = exports.ChangeEventDispatchingArray = []; 28var ChangeEventDispatchingArray = exports.ChangeEventDispatchingArray = [];
29 29
30/** 30/**
31 @class module:montage/core/event/binding.PropertyChangeBindingListener 31 @class module:montage/core/event/binding.PropertyChangeBindingListener
32 @extends module:montage/core/core.Montage 32 @extends module:montage/core/core.Montage
33*/ 33 */
34var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Object.create(Montage, /** module:montage/core/event/binding.PropertyChangeBindingListener# */ { 34var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Object.create(Montage, /** module:montage/core/event/binding.PropertyChangeBindingListener# */ {
35 35
36 useCapture: {value:false, writable: true}, 36 useCapture: {value:false, writable: true},
@@ -86,11 +86,11 @@ var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Obje
86 value:function (notification) { 86 value:function (notification) {
87 87
88 var bindingOriginTriggeredChange, 88 var bindingOriginTriggeredChange,
89 // Left 89 // Left
90 bindingOrigin = this.bindingOrigin, 90 bindingOrigin = this.bindingOrigin,
91 bindingOriginPropertyPath = this.bindingPropertyPath, 91 bindingOriginPropertyPath = this.bindingPropertyPath,
92 bindingOriginValue = bindingOrigin.getProperty(bindingOriginPropertyPath), 92 bindingOriginValue = bindingOrigin.getProperty(bindingOriginPropertyPath),
93 // Right 93 // Right
94 boundObject = this.target, 94 boundObject = this.target,
95 boundObjectPropertyPath = this.targetPropertyPath, 95 boundObjectPropertyPath = this.targetPropertyPath,
96 boundObjectValue; 96 boundObjectValue;
@@ -162,14 +162,14 @@ var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Obje
162}); 162});
163 163
164/** 164/**
165 @function external:Object#propertyChangeBindingListener 165 @function external:Object#propertyChangeBindingListener
166 @param {string} type The event type to listen for. 166 @param {string} type The event type to listen for.
167 @param {function} listener The event listener object. 167 @param {function} listener The event listener object.
168 @param {boolean} useCapture Specifies whether to listen for the property change during the capture or bubble event phases. 168 @param {boolean} useCapture Specifies whether to listen for the property change during the capture or bubble event phases.
169 @param {object} bindingOrigin The source of the binding. 169 @param {object} bindingOrigin The source of the binding.
170 @param {string} bindingPropertyPath The key path of the property on the source object. 170 @param {string} bindingPropertyPath The key path of the property on the source object.
171 @param {object} bindingDescriptor A property descriptor object that specifies the bound object and the bound object property path. 171 @param {object} bindingDescriptor A property descriptor object that specifies the bound object and the bound object property path.
172*/ 172 */
173Object.defineProperty(Object.prototype, "propertyChangeBindingListener", { 173Object.defineProperty(Object.prototype, "propertyChangeBindingListener", {
174 value: function(type, listener, useCapture, atSignIndex, bindingOrigin, bindingPropertyPath, bindingDescriptor) { 174 value: function(type, listener, useCapture, atSignIndex, bindingOrigin, bindingPropertyPath, bindingDescriptor) {
175 175
@@ -203,41 +203,41 @@ Object.defineProperty(Object.prototype, "propertyChangeBindingListener", {
203 Binding descriptor keys 203 Binding descriptor keys
204 @class module:montage/core/event/binding.BindingDescriptor 204 @class module:montage/core/event/binding.BindingDescriptor
205 @extends module:montage/core/core.Montage 205 @extends module:montage/core/core.Montage
206*/ 206 */
207var BindingDescriptor = exports.BindingDescriptor = Montage.create(Montage, /** @lends module:montage/core/event/binding.BindingDescriptor */ { 207var BindingDescriptor = exports.BindingDescriptor = Montage.create(Montage, /** @lends module:montage/core/event/binding.BindingDescriptor */ {
208 208
209/** 209 /**
210 The object sourceObject will be bound to 210 The object sourceObject will be bound to
211*/ 211 */
212 boundObject: { 212 boundObject: {
213 enumerable: false, 213 enumerable: false,
214 serializable: true, 214 serializable: true,
215 value: null 215 value: null
216 }, 216 },
217 217
218/** 218 /**
219 219
220 The key path of boundObject which sourceObject's sourceObjectBindingPath is bound to 220 The key path of boundObject which sourceObject's sourceObjectBindingPath is bound to
221 221
222*/ 222 */
223 boundObjectPropertyPath: { 223 boundObjectPropertyPath: {
224 enumerable: false, 224 enumerable: false,
225 serializable: true, 225 serializable: true,
226 value: null 226 value: null
227 }, 227 },
228 228
229/** 229 /**
230 Specifies whether the source Object will push value back to it's boundObject's boundObjectPropertyPath or not. Default is false. 230 Specifies whether the source Object will push value back to it's boundObject's boundObjectPropertyPath or not. Default is false.
231*/ 231 */
232 oneway: { 232 oneway: {
233 enumerable: false, 233 enumerable: false,
234 serializable: true, 234 serializable: true,
235 value: null 235 value: null
236 }, 236 },
237 237
238/** 238 /**
239 If true, PropertyChangeBindingListener will buffer the value until it's told to execute binding. Setting this value to false allows for some runtime optimizations.deferred. Default is false, binding values propagate immediately. 239 If true, PropertyChangeBindingListener will buffer the value until it's told to execute binding. Setting this value to false allows for some runtime optimizations.deferred. Default is false, binding values propagate immediately.
240*/ 240 */
241 deferred: { 241 deferred: {
242 enumerable: false, 242 enumerable: false,
243 serializable: true, 243 serializable: true,
@@ -257,31 +257,9 @@ var BindingDescriptor = exports.BindingDescriptor = Montage.create(Montage, /**
257}); 257});
258 258
259Serializer.defineSerializationUnit("bindings", function(object) { 259Serializer.defineSerializationUnit("bindings", function(object) {
260 var bindingDescriptors = object._bindingDescriptors, 260 var bindingDescriptors = object._bindingDescriptors;
261 bindingDescriptorsCopy;
262
263 // TODO: Hacked this function to create copy of object literal
264 // TODO: Remove when montage finds out how to identify object literals
265 // TODO: in a different way
266 function cloneObject(object, level) {
267 var clone = {};
268
269 for (var key in object) {
270 if (level > 0) {
271 clone[key] = cloneObject(object[key], level - 1);
272 } else {
273 clone[key] = object[key];
274 }
275 }
276
277 return clone;
278 }
279 261
280 if (bindingDescriptors) { 262 if (bindingDescriptors) {
281 if (Object.getPrototypeOf(bindingDescriptors) !== Object.prototype) {
282 bindingDescriptors = cloneObject(bindingDescriptors , 1);
283 }
284
285 return bindingDescriptors; 263 return bindingDescriptors;
286 } 264 }
287}); 265});
@@ -320,12 +298,12 @@ Deserializer.defineDeserializationUnit("bindings", function(object, bindings, de
320}); 298});
321 299
322/** 300/**
323 @function external:Object.defineBinding 301 @function external:Object.defineBinding
324 @param {object} sourceObject The source object of the data binding. This object establishes the binding between itself and the "bound object" specified by the <code>bindingDescriptor</code> parameter. 302 @param {object} sourceObject The source object of the data binding. This object establishes the binding between itself and the "bound object" specified by the <code>bindingDescriptor</code> parameter.
325 @param {string} sourceObjectPropertyBindingPath The key path to the source object's property that is being bound. 303 @param {string} sourceObjectPropertyBindingPath The key path to the source object's property that is being bound.
326 @param {object} bindingDescriptor An object that describes the bound object, the bound object's property path, and other properties. 304 @param {object} bindingDescriptor An object that describes the bound object, the bound object's property path, and other properties.
327 @see [BindingDescriptor object]{@link module:montage/core/event/binding#BindingDescriptor} 305 @see [BindingDescriptor object]{@link module:montage/core/event/binding#BindingDescriptor}
328*/ 306 */
329Object.defineProperty(Object, "defineBinding", {value: function(sourceObject, sourceObjectPropertyBindingPath, bindingDescriptor) { 307Object.defineProperty(Object, "defineBinding", {value: function(sourceObject, sourceObjectPropertyBindingPath, bindingDescriptor) {
330 var _bindingDescriptors = sourceObject._bindingDescriptors, 308 var _bindingDescriptors = sourceObject._bindingDescriptors,
331 oneway = typeof bindingDescriptor.oneway === "undefined" ? false : bindingDescriptor.oneway, 309 oneway = typeof bindingDescriptor.oneway === "undefined" ? false : bindingDescriptor.oneway,
@@ -442,11 +420,11 @@ Object.defineProperty(Object.prototype, "_deserializeProperty_bindingDescriptors
442}); 420});
443 421
444/** 422/**
445 Deletes a single binding on the specified object. 423 Deletes a single binding on the specified object.
446 @function external:Object.deleteBinding 424 @function external:Object.deleteBinding
447 @param {object} sourceObject The source object that defined the binding. 425 @param {object} sourceObject The source object that defined the binding.
448 @param {string} sourceObjectPropertyBindingPath The key path to the bound object's bound property. 426 @param {string} sourceObjectPropertyBindingPath The key path to the bound object's bound property.
449*/ 427 */
450Object.defineProperty(Object, "deleteBinding", {value: function(sourceObject, sourceObjectPropertyBindingPath) { 428Object.defineProperty(Object, "deleteBinding", {value: function(sourceObject, sourceObjectPropertyBindingPath) {
451