diff --git a/src/wp-includes/js/customize-base.js b/src/wp-includes/js/customize-base.js
index db573b5..6c41b40 100644
|
a
|
b
|
|
| 1 | 1 | window.wp = window.wp || {}; |
| 2 | 2 | |
| 3 | 3 | (function( exports, $ ){ |
| 4 | | var api, extend, ctor, inherits, |
| | 4 | var api = {}, ctor, inherits, |
| 5 | 5 | slice = Array.prototype.slice; |
| 6 | 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 | | |
| 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; |
| 25 | 22 | |
| … |
… |
window.wp = window.wp || {};
|
| 65 | 62 | return 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; |
| 76 | 70 | |
| … |
… |
window.wp = window.wp || {};
|
| 92 | 86 | return magic; |
| 93 | 87 | }; |
| 94 | 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; |
| | 100 | }; |
| | 101 | |
| 95 | 102 | api.Class.applicator = {}; |
| 96 | 103 | |
| 97 | 104 | api.Class.prototype.initialize = function() {}; |
| … |
… |
window.wp = window.wp || {};
|
| 116 | 123 | return false; |
| 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 ) { |
| 127 | 133 | if ( this.topics && this.topics[ id ] ) |
| … |
… |
window.wp = window.wp || {};
|
| 143 | 149 | } |
| 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 ) { |
| 152 | 159 | this._value = initial; // @todo: potentially change this to a this.set() call. |
| … |
… |
window.wp = window.wp || {};
|
| 254 | 261 | } |
| 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, |
| 263 | 273 | |
| … |
… |
window.wp = window.wp || {};
|
| 379 | 389 | |
| 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 ) { |
| 394 | 413 | var self = this, |
| … |
… |
window.wp = window.wp || {};
|
| 442 | 461 | |
| 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 ) { |
| 448 | 467 | this.element[ method ]( to ); |
| … |
… |
window.wp = window.wp || {};
|
| 473 | 492 | } |
| 474 | 493 | }; |
| 475 | 494 | |
| 476 | | /* ===================================================================== |
| 477 | | * Messenger for postMessage. |
| 478 | | * ===================================================================== */ |
| 479 | | |
| 480 | 495 | $.support.postMessage = !! window.postMessage; |
| 481 | 496 | |
| | 497 | /** |
| | 498 | * Messenger for postMessage. |
| | 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 ); |
| 485 | 515 | }, |
| … |
… |
window.wp = window.wp || {};
|
| 570 | 600 | // Add the Events mixin to api.Messenger. |
| 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() { |
| 579 | 606 | var result = {}; |
| … |
… |
window.wp = window.wp || {};
|
| 585 | 612 | return result; |
| 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 ); |
diff --git a/src/wp-includes/js/customize-loader.js b/src/wp-includes/js/customize-loader.js
index 98bb32f..2ee0c0f 100644
|
a
|
b
|
window.wp = window.wp || {};
|
| 10 | 10 | hashchange: ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7) |
| 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 ); |
| 16 | 29 | |
| … |
… |
window.wp = window.wp || {};
|
| 23 | 36 | this.window = $( window ); |
| 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(); |
| 31 | 47 | |
| … |
… |
window.wp = window.wp || {};
|
| 73 | 89 | } |
| 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 | |
| 78 | 99 | if ( this.active ) { |
| … |
… |
window.wp = window.wp || {};
|
| 148 | 169 | } |
| 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 ) { |
| 157 | 184 | return; |
| … |
… |
window.wp = window.wp || {};
|
| 174 | 201 | } |
| 175 | 202 | }, |
| 176 | 203 | |
| | 204 | /** |
| | 205 | * Callback after the customizer has been closed. |
| | 206 | */ |
| 177 | 207 | closed: function() { |
| 178 | 208 | Loader.iframe.remove(); |
| 179 | 209 | Loader.messenger.destroy(); |
| … |
… |
window.wp = window.wp || {};
|
| 184 | 214 | $( window ).off( 'beforeunload', Loader.beforeunload ); |
| 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() { |
| 193 | 229 | this.element.fadeIn( 200, Loader.opened ); |
| … |
… |
window.wp = window.wp || {};
|
| 199 | 235 | } |
| 200 | 236 | }); |
| 201 | 237 | |
| | 238 | // Bootstrap the Loader on document#ready. |
| 202 | 239 | $( function() { |
| 203 | 240 | Loader.settings = _wpCustomizeLoaderSettings; |
| 204 | 241 | Loader.initialize(); |
| 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 ); |