wp/wp-includes/js/customize-base.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 21 48c4eec2b7e6
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
   110 	 *
   110 	 *
   111 	 * @param object protoProps  Properties to apply to the prototype.
   111 	 * @param object protoProps  Properties to apply to the prototype.
   112 	 * @param object staticProps Properties to apply directly to the class.
   112 	 * @param object staticProps Properties to apply directly to the class.
   113 	 * @return child The subclass.
   113 	 * @return child The subclass.
   114 	 */
   114 	 */
   115 	api.Class.extend = function( protoProps, classProps ) {
   115 	api.Class.extend = function( protoProps, staticProps ) {
   116 		var child = inherits( this, protoProps, classProps );
   116 		var child = inherits( this, protoProps, staticProps );
   117 		child.extend = this.extend;
   117 		child.extend = this.extend;
   118 		return child;
   118 		return child;
   119 	};
   119 	};
   120 
   120 
   121 	api.Class.applicator = {};
   121 	api.Class.applicator = {};
   195 			this.callbacks = $.Callbacks();
   195 			this.callbacks = $.Callbacks();
   196 			this._dirty = false;
   196 			this._dirty = false;
   197 
   197 
   198 			$.extend( this, options || {} );
   198 			$.extend( this, options || {} );
   199 
   199 
   200 			this.set = $.proxy( this.set, this );
   200 			this.set = this.set.bind( this );
   201 		},
   201 		},
   202 
   202 
   203 		/*
   203 		/*
   204 		 * Magic. Returns a function that will become the instance.
   204 		 * Magic. Returns a function that will become the instance.
   205 		 * Set to null to prevent the instance from extending a function.
   205 		 * Set to null to prevent the instance from extending a function.
   499 			var self = this,
   499 			var self = this,
   500 				ids  = slice.call( arguments ),
   500 				ids  = slice.call( arguments ),
   501 				dfd  = $.Deferred();
   501 				dfd  = $.Deferred();
   502 
   502 
   503 			// If the last argument is a callback, bind it to .done().
   503 			// If the last argument is a callback, bind it to .done().
   504 			if ( $.isFunction( ids[ ids.length - 1 ] ) ) {
   504 			if ( typeof ids[ ids.length - 1 ] === 'function' ) {
   505 				dfd.done( ids.pop() );
   505 				dfd.done( ids.pop() );
   506 			}
   506 			}
   507 
   507 
   508 			/*
   508 			/*
   509 			 * Create a stack of deferred objects for each item that is not
   509 			 * Create a stack of deferred objects for each item that is not
   607 			this.refresh = function() {
   607 			this.refresh = function() {
   608 				self.set( refresh.call( self ) );
   608 				self.set( refresh.call( self ) );
   609 			};
   609 			};
   610 
   610 
   611 			this.bind( this.update );
   611 			this.bind( this.update );
   612 			this.element.bind( this.events, this.refresh );
   612 			this.element.on( this.events, this.refresh );
   613 		},
   613 		},
   614 
   614 
   615 		find: function( selector ) {
   615 		find: function( selector ) {
   616 			return $( selector, this.element );
   616 			return $( selector, this.element );
   617 		},
   617 		},
   732 			 * to this instance, we give the function a new guid.
   732 			 * to this instance, we give the function a new guid.
   733 			 *
   733 			 *
   734 			 * This will prevent every Messenger's receive function from being
   734 			 * This will prevent every Messenger's receive function from being
   735 			 * unbound when calling $.off( 'message', this.receive );
   735 			 * unbound when calling $.off( 'message', this.receive );
   736 			 */
   736 			 */
   737 			this.receive = $.proxy( this.receive, this );
   737 			this.receive = this.receive.bind( this );
   738 			this.receive.guid = $.guid++;
   738 			this.receive.guid = $.guid++;
   739 
   739 
   740 			$( window ).on( 'message', this.receive );
   740 			$( window ).on( 'message', this.receive );
   741 		},
   741 		},
   742 
   742