Changeset 29450
- Timestamp:
- 08/08/2014 10:09:46 PM (11 years ago)
- Location:
- trunk/src/wp-includes/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/customize-base.js
r26702 r29450 2 2 3 3 (function( exports, $ ){ 4 var api , extend, ctor, inherits,4 var api = {}, ctor, inherits, 5 5 slice = Array.prototype.slice; 6 7 /* =====================================================================8 * Micro-inheritance - thank you, backbone.js.9 * ===================================================================== */10 11 extend = function( protoProps, classProps ) {12 var child = inherits( this, protoProps, classProps );13 child.extend = this.extend;14 return child;15 };16 6 17 7 // Shared empty constructor function to aid in prototype-chain creation. 18 8 ctor = function() {}; 19 9 20 // Helper function to correctly set up the prototype chain, for subclasses. 21 // Similar to `goog.inherits`, but uses a hash of prototype properties and 22 // class properties to be extended. 10 /** 11 * Helper function to correctly set up the prototype chain, for subclasses. 12 * Similar to `goog.inherits`, but uses a hash of prototype properties and 13 * class properties to be extended. 14 * 15 * @param object parent Parent class constructor to inherit from. 16 * @param object protoProps Properties to apply to the prototype for use as class instance properties. 17 * @param object staticProps Properties to apply directly to the class constructor. 18 * @return child The subclassed constructor. 19 */ 23 20 inherits = function( parent, protoProps, staticProps ) { 24 21 var child; … … 66 63 }; 67 64 68 api = {}; 69 70 /* ===================================================================== 71 * Base class. 72 * ===================================================================== */ 73 65 /** 66 * Base class for object inheritance. 67 */ 74 68 api.Class = function( applicator, argsArray, options ) { 75 69 var magic, args = arguments; … … 91 85 magic.initialize.apply( magic, args ); 92 86 return magic; 87 }; 88 89 /** 90 * Creates a subclass of the class. 91 * 92 * @param object protoProps Properties to apply to the prototype. 93 * @param object staticProps Properties to apply directly to the class. 94 * @return child The subclass. 95 */ 96 api.Class.extend = function( protoProps, classProps ) { 97 var child = inherits( this, protoProps, classProps ); 98 child.extend = this.extend; 99 return child; 93 100 }; 94 101 … … 117 124 }; 118 125 119 api.Class.extend = extend; 120 121 /* ===================================================================== 122 * Events mixin. 123 * ===================================================================== */ 124 126 /** 127 * An events manager object, offering the ability to bind to and trigger events. 128 * 129 * Used as a mixin. 130 */ 125 131 api.Events = { 126 132 trigger: function( id ) { … … 144 150 }; 145 151 146 /* =====================================================================152 /** 147 153 * Observable values that support two-way binding. 148 * ===================================================================== */ 149 154 * 155 * @constuctor 156 */ 150 157 api.Value = api.Class.extend({ 151 158 initialize: function( initial, options ) { … … 255 262 }); 256 263 257 /* =====================================================================264 /** 258 265 * A collection of observable values. 259 * ===================================================================== */ 260 266 * 267 * @constuctor 268 * @augments wp.customize.Class 269 * @mixes wp.customize.Events 270 */ 261 271 api.Values = api.Class.extend({ 262 272 defaultConstructor: api.Value, … … 380 390 $.extend( api.Values.prototype, api.Events ); 381 391 382 /* ===================================================================== 383 * An observable value that syncs with an element.384 * 385 * Handles inputs, selects, and textareas by default.386 * ===================================================================== */387 392 393 /** 394 * Cast a string to a jQuery collection if it isn't already. 395 * 396 * @param {string|jQuery collection} element 397 */ 388 398 api.ensure = function( element ) { 389 399 return typeof element == 'string' ? $( element ) : element; 390 400 }; 391 401 402 /** 403 * An observable value that syncs with an element. 404 * 405 * Handles inputs, selects, and textareas by default. 406 * 407 * @constuctor 408 * @augments wp.customize.Value 409 * @augments wp.customize.Class 410 */ 392 411 api.Element = api.Value.extend({ 393 412 initialize: function( element, options ) { … … 443 462 api.Element.synchronizer = {}; 444 463 445 $.each( [ 'html', 'val' ], function( i , method ) {464 $.each( [ 'html', 'val' ], function( index, method ) { 446 465 api.Element.synchronizer[ method ] = { 447 466 update: function( to ) { … … 474 493 }; 475 494 476 /* ===================================================================== 495 $.support.postMessage = !! window.postMessage; 496 497 /** 477 498 * Messenger for postMessage. 478 * ===================================================================== */ 479 480 $.support.postMessage = !! window.postMessage; 481 499 * 500 * @constuctor 501 * @augments wp.customize.Class 502 * @mixes wp.customize.Events 503 */ 482 504 api.Messenger = api.Class.extend({ 505 /** 506 * Create a new Value. 507 * 508 * @param {string} key Unique identifier. 509 * @param {mixed} initial Initial value. 510 * @param {mixed} options Options hash. Optional. 511 * @return {Value} Class instance of the Value. 512 */ 483 513 add: function( key, initial, options ) { 484 514 return this[ key ] = new api.Value( initial, options ); … … 571 601 $.extend( api.Messenger.prototype, api.Events ); 572 602 573 /* ===================================================================== 574 * Core customize object. 575 * ===================================================================== */ 576 603 // Core customize object. 577 604 api = $.extend( new api.Values(), api ); 578 605 api.get = function() { … … 586 613 }; 587 614 588 // Expose the API to the world.615 // Expose the API publicly on window.wp.customize 589 616 exports.customize = api; 590 617 })( wp, jQuery ); -
trunk/src/wp-includes/js/customize-loader.js
r29025 r29450 11 11 }); 12 12 13 /** 14 * Allows the Customizer to be overlayed on any page. 15 * 16 * By default, any element in the body with the load-customize class will open 17 * the Customizer overlay with the URL specified. 18 * 19 * e.g. <a class="load-customize" href="http://siteurl.com/2014/01/02/post">Open customizer</a> 20 * 21 * @augments wp.customize.Events 22 */ 13 23 Loader = $.extend( {}, api.Events, { 24 /** 25 * Setup the Loader; triggered on document#ready. 26 */ 14 27 initialize: function() { 15 28 this.body = $( document.body ); … … 24 37 this.element = $( '<div id="customize-container" />' ).appendTo( this.body ); 25 38 39 // Bind events for opening and closing the overlay. 26 40 this.bind( 'open', this.overlay.show ); 27 41 this.bind( 'close', this.overlay.hide ); 28 42 43 // Any element in the body with the `load-customize` class opens 44 // the Customizer. 29 45 $('#wpbody').on( 'click', '.load-customize', function( event ) { 30 46 event.preventDefault(); … … 74 90 }, 75 91 92 /** 93 * Open the customizer overlay for a specific URL. 94 * 95 * @param string src URL to load in the Customizer. 96 */ 76 97 open: function( src ) { 77 98 … … 149 170 }, 150 171 172 /** 173 * Callback after the customizer has been opened. 174 */ 151 175 opened: function() { 152 176 Loader.body.addClass( 'customize-active full-overlay-active' ); 153 177 }, 154 178 179 /** 180 * Close the Customizer overlay and return focus to the link that opened it. 181 */ 155 182 close: function() { 156 183 if ( ! this.active ) { … … 175 202 }, 176 203 204 /** 205 * Callback after the customizer has been closed. 206 */ 177 207 closed: function() { 178 208 Loader.iframe.remove(); … … 185 215 }, 186 216 217 /** 218 * Callback for the `load` event on the Customizer iframe. 219 */ 187 220 loaded: function() { 188 221 Loader.body.removeClass('customize-loading'); 189 222 }, 190 223 224 /** 225 * Overlay hide/show utility methods. 226 */ 191 227 overlay: { 192 228 show: function() { … … 200 236 }); 201 237 238 // Bootstrap the Loader on document#ready. 202 239 $( function() { 203 240 Loader.settings = _wpCustomizeLoaderSettings; … … 205 242 }); 206 243 207 // Expose the API to the world.244 // Expose the API publicly on window.wp.customize.Loader 208 245 api.Loader = Loader; 209 246 })( wp, jQuery );
Note: See TracChangeset
for help on using the changeset viewer.