From 4565558afff6fb07db3b5165042e028f467ac41b Mon Sep 17 00:00:00 2001 From: Armen Kesablyan Date: Thu, 21 Jun 2012 15:46:26 -0700 Subject: Binding View :Requested Changes for Pull Request Signed-off-by: Armen Kesablyan --- node_modules/montage/core/event/binding.js | 134 ++++++++++++----------------- 1 file changed, 56 insertions(+), 78 deletions(-) (limited to 'node_modules') 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 @@ */ /** - @module montage/core/event/binding - @requires montage/core/core - @requires montage/core/event/mutable-event - @requires montage/core/serializer - @requires montage/core/deserializer - @requires montage/core/event/event-manager -*/ + @module montage/core/event/binding + @requires montage/core/core + @requires montage/core/event/mutable-event + @requires montage/core/serializer + @requires montage/core/deserializer + @requires montage/core/event/event-manager + */ var Montage = require("montage").Montage, ChangeNotification = require("core/change-notification").ChangeNotification, @@ -23,14 +23,14 @@ var Montage = require("montage").Montage, UNDERSCORE = "_"; /** - @class module:montage/core/event/binding.ChangeEventDispatchingArray -*/ + @class module:montage/core/event/binding.ChangeEventDispatchingArray + */ var ChangeEventDispatchingArray = exports.ChangeEventDispatchingArray = []; /** - @class module:montage/core/event/binding.PropertyChangeBindingListener - @extends module:montage/core/core.Montage -*/ + @class module:montage/core/event/binding.PropertyChangeBindingListener + @extends module:montage/core/core.Montage + */ var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Object.create(Montage, /** module:montage/core/event/binding.PropertyChangeBindingListener# */ { useCapture: {value:false, writable: true}, @@ -86,11 +86,11 @@ var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Obje value:function (notification) { var bindingOriginTriggeredChange, - // Left + // Left bindingOrigin = this.bindingOrigin, bindingOriginPropertyPath = this.bindingPropertyPath, bindingOriginValue = bindingOrigin.getProperty(bindingOriginPropertyPath), - // Right + // Right boundObject = this.target, boundObjectPropertyPath = this.targetPropertyPath, boundObjectValue; @@ -162,14 +162,14 @@ var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Obje }); /** - @function external:Object#propertyChangeBindingListener - @param {string} type The event type to listen for. - @param {function} listener The event listener object. - @param {boolean} useCapture Specifies whether to listen for the property change during the capture or bubble event phases. - @param {object} bindingOrigin The source of the binding. - @param {string} bindingPropertyPath The key path of the property on the source object. - @param {object} bindingDescriptor A property descriptor object that specifies the bound object and the bound object property path. -*/ + @function external:Object#propertyChangeBindingListener + @param {string} type The event type to listen for. + @param {function} listener The event listener object. + @param {boolean} useCapture Specifies whether to listen for the property change during the capture or bubble event phases. + @param {object} bindingOrigin The source of the binding. + @param {string} bindingPropertyPath The key path of the property on the source object. + @param {object} bindingDescriptor A property descriptor object that specifies the bound object and the bound object property path. + */ Object.defineProperty(Object.prototype, "propertyChangeBindingListener", { value: function(type, listener, useCapture, atSignIndex, bindingOrigin, bindingPropertyPath, bindingDescriptor) { @@ -203,41 +203,41 @@ Object.defineProperty(Object.prototype, "propertyChangeBindingListener", { Binding descriptor keys @class module:montage/core/event/binding.BindingDescriptor @extends module:montage/core/core.Montage -*/ + */ var BindingDescriptor = exports.BindingDescriptor = Montage.create(Montage, /** @lends module:montage/core/event/binding.BindingDescriptor */ { -/** - The object sourceObject will be bound to -*/ + /** + The object sourceObject will be bound to + */ boundObject: { enumerable: false, serializable: true, value: null }, -/** + /** - The key path of boundObject which sourceObject's sourceObjectBindingPath is bound to + The key path of boundObject which sourceObject's sourceObjectBindingPath is bound to -*/ + */ boundObjectPropertyPath: { enumerable: false, serializable: true, value: null }, -/** - Specifies whether the source Object will push value back to it's boundObject's boundObjectPropertyPath or not. Default is false. -*/ + /** + Specifies whether the source Object will push value back to it's boundObject's boundObjectPropertyPath or not. Default is false. + */ oneway: { enumerable: false, serializable: true, value: null }, -/** + /** 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. -*/ + */ deferred: { enumerable: false, serializable: true, @@ -257,31 +257,9 @@ var BindingDescriptor = exports.BindingDescriptor = Montage.create(Montage, /** }); Serializer.defineSerializationUnit("bindings", function(object) { - var bindingDescriptors = object._bindingDescriptors, - bindingDescriptorsCopy; - - // TODO: Hacked this function to create copy of object literal - // TODO: Remove when montage finds out how to identify object literals - // TODO: in a different way - function cloneObject(object, level) { - var clone = {}; - - for (var key in object) { - if (level > 0) { - clone[key] = cloneObject(object[key], level - 1); - } else { - clone[key] = object[key]; - } - } - - return clone; - } + var bindingDescriptors = object._bindingDescriptors; if (bindingDescriptors) { - if (Object.getPrototypeOf(bindingDescriptors) !== Object.prototype) { - bindingDescriptors = cloneObject(bindingDescriptors , 1); - } - return bindingDescriptors; } }); @@ -320,12 +298,12 @@ Deserializer.defineDeserializationUnit("bindings", function(object, bindings, de }); /** - @function external:Object.defineBinding - @param {object} sourceObject The source object of the data binding. This object establishes the binding between itself and the "bound object" specified by the bindingDescriptor parameter. - @param {string} sourceObjectPropertyBindingPath The key path to the source object's property that is being bound. - @param {object} bindingDescriptor An object that describes the bound object, the bound object's property path, and other properties. - @see [BindingDescriptor object]{@link module:montage/core/event/binding#BindingDescriptor} -*/ + @function external:Object.defineBinding + @param {object} sourceObject The source object of the data binding. This object establishes the binding between itself and the "bound object" specified by the bindingDescriptor parameter. + @param {string} sourceObjectPropertyBindingPath The key path to the source object's property that is being bound. + @param {object} bindingDescriptor An object that describes the bound object, the bound object's property path, and other properties. + @see [BindingDescriptor object]{@link module:montage/core/event/binding#BindingDescriptor} + */ Object.defineProperty(Object, "defineBinding", {value: function(sourceObject, sourceObjectPropertyBindingPath, bindingDescriptor) { var _bindingDescriptors = sourceObject._bindingDescriptors, oneway = typeof bindingDescriptor.oneway === "undefined" ? false : bindingDescriptor.oneway, @@ -442,11 +420,11 @@ Object.defineProperty(Object.prototype, "_deserializeProperty_bindingDescriptors }); /** - Deletes a single binding on the specified object. - @function external:Object.deleteBinding - @param {object} sourceObject The source object that defined the binding. - @param {string} sourceObjectPropertyBindingPath The key path to the bound object's bound property. -*/ + Deletes a single binding on the specified object. + @function external:Object.deleteBinding + @param {object} sourceObject The source object that defined the binding. + @param {string} sourceObjectPropertyBindingPath The key path to the bound object's bound property. + */ Object.defineProperty(Object, "deleteBinding", {value: function(sourceObject, sourceObjectPropertyBindingPath) { var _bindingDescriptors = sourceObject._bindingDescriptors, bindingDescriptor, @@ -470,10 +448,10 @@ Object.defineProperty(Object, "deleteBinding", {value: function(sourceObject, so }}); /** - Deletes all bindings on the specified object. - @function external:Object.deleteBindings - @param {object} object The object to delete bindings from. -*/ + Deletes all bindings on the specified object. + @function external:Object.deleteBindings + @param {object} object The object to delete bindings from. + */ Object.defineProperty(Object, "deleteBindings", {value: function(object) { var bindingDescriptors = object._bindingDescriptors; @@ -512,17 +490,17 @@ Object.defineProperty(Object, "applyBindingsDeferredValues", {value: function(ob Montage.defineProperty(Object.prototype, "_bindingsDisabled", {enumerable: false, value: null}); /** - Temporarily disables bindings on the specified object. To re-enable bindings, call [Object.enableBindings()]{@link external:Object.enableBindings}. - @function external:Object.disableBindings -*/ + Temporarily disables bindings on the specified object. To re-enable bindings, call [Object.enableBindings()]{@link external:Object.enableBindings}. + @function external:Object.disableBindings + */ Object.defineProperty(Object, "disableBindings", {value: function(object) { object._bindingsDisabled = true; }}); /** - Re-enables data binding on the object after being disabled with [Object.disableBindings()]{@link external:Object.disableBindings}, applying any deferred bindings that were queued during the interval. - @function external:Object#enableBindings -*/ + Re-enables data binding on the object after being disabled with [Object.disableBindings()]{@link external:Object.disableBindings}, applying any deferred bindings that were queued during the interval. + @function external:Object#enableBindings + */ Object.defineProperty(Object, "enableBindings", {value: function(object) { object._bindingsDisabled = false; Object.applyBindingsDeferredValues(object, true); -- cgit v1.2.3