WordPress/wp-includes/js/customize-base.min.js

1 line
7.7 KiB
JavaScript
Raw Normal View History

window.wp=window.wp||{},function(t,o){var s,i,h={},r=Array.prototype.slice;s=function(){},i=function(t,e,n){var i;return i=e&&e.hasOwnProperty("constructor")?e.constructor:function(){return t.apply(this,arguments)},o.extend(i,t),s.prototype=t.prototype,i.prototype=new s,e&&o.extend(i.prototype,e),n&&o.extend(i,n),(i.prototype.constructor=i).__super__=t.prototype,i},h.Class=function(t,e,n){var i,s=arguments;return t&&e&&h.Class.applicator===t&&(s=e,o.extend(this,n||{})),(i=this).instance&&(i=function(){return i.instance.apply(i,arguments)},o.extend(i,this)),i.initialize.apply(i,s),i},h.Class.extend=function(t,e){var n=i(this,t,e);return n.extend=this.extend,n},h.Class.applicator={},h.Class.prototype.initialize=function(){},h.Class.prototype.extended=function(t){for(var e=this;void 0!==e.constructor;){if(e.constructor===t)return!0;if(void 0===e.constructor.__super__)return!1;e=e.constructor.__super__}return!1},h.Events={trigger:function(t){return this.topics&&this.topics[t]&&this.topics[t].fireWith(this,r.call(arguments,1)),this},bind:function(t){return this.topics=this.topics||{},this.topics[t]=this.topics[t]||o.Callbacks(),this.topics[t].add.apply(this.topics[t],r.call(arguments,1)),this},unbind:function(t){return this.topics&&this.topics[t]&&this.topics[t].remove.apply(this.topics[t],r.call(arguments,1)),this}},h.Value=h.Class.extend({initialize:function(t,e){this._value=t,this.callbacks=o.Callbacks(),this._dirty=!1,o.extend(this,e||{}),this.set=o.proxy(this.set,this)},instance:function(){return arguments.length?this.set.apply(this,arguments):this.get()},get:function(){return this._value},set:function(t){var e=this._value;return t=this._setter.apply(this,arguments),null===(t=this.validate(t))||_.isEqual(e,t)||(this._value=t,this._dirty=!0,this.callbacks.fireWith(this,[t,e])),this},_setter:function(t){return t},setter:function(t){var e=this.get();return this._setter=t,this._value=null,this.set(e),this},resetSetter:function(){return this._setter=this.constructor.prototype._setter,this.set(this.get()),this},validate:function(t){return t},bind:function(){return this.callbacks.add.apply(this.callbacks,arguments),this},unbind:function(){return this.callbacks.remove.apply(this.callbacks,arguments),this},link:function(){var t=this.set;return o.each(arguments,function(){this.bind(t)}),this},unlink:function(){var t=this.set;return o.each(arguments,function(){this.unbind(t)}),this},sync:function(){var t=this;return o.each(arguments,function(){t.link(this),this.link(t)}),this},unsync:function(){var t=this;return o.each(arguments,function(){t.unlink(this),this.unlink(t)}),this}}),h.Values=h.Class.extend({defaultConstructor:h.Value,initialize:function(t){o.extend(this,t||{}),this._value={},this._deferreds={}},instance:function(t){return 1===arguments.length?this.value(t):this.when.apply(this,arguments)},value:function(t){return this._value[t]},has:function(t){return void 0!==this._value[t]},add:function(t,e){var n,i,s=this;if("string"==typeof t)n=t,i=e;else{if("string"!=typeof t.id)throw new Error("Unknown key");n=t.id,i=t}return s.has(n)?s.value(n):((s._value[n]=i).parent=s,i.extended(h.Value)&&i.bind(s._change),s.trigger("add",i),s._deferreds[n]&&s._deferreds[n].resolve(),s._value[n])},create:function(t){return this.add(t,new this.defaultConstructor(h.Class.applicator,r.call(arguments,1)))},each:function(n,i){i=void 0===i?this:i,o.each(this._value,function(t,e){n.call(i,e,t)})},remove:function(t){var e=this.value(t);e&&(this.trigger("remove",e),e.extended(h.Value)&&e.unbind(this._change),delete e.parent),delete this._value[t],delete this._deferreds[t],e&&this.trigger("removed",e)},when:function(){var e=this,n=r.call(arguments),i=o.Deferred();return o.isFunction(n[n.length-1])&&i.done(n.pop()),o.when.apply(o,o.map(n,function(t){if(!e.has(t))return e._deferreds[t]=e._deferreds[t]||o.Deferred()})).done(function(){var t=o.map(n,function(t){return e(t)});t.length===n.length?i.resolveWith(e,t):e.when.apply(e,n).done(function(){i.resolveWith(e,t)})}),i.promise()},_change:function(){this.parent.trigger("change",this)}}),o.extend(h.Values.