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