WordPress/wp-admin/js/customize-controls.min.js

1 line
42 KiB
JavaScript
Raw Normal View History

!function(m){var i,e,t,f=wp.customize;f.Setting=f.Value.extend({initialize:function(e,t,n){f.Value.prototype.initialize.call(this,t,n),this.id=e,this.transport=this.transport||"refresh",this._dirty=n.dirty||!1,this.bind(this.preview)},preview:function(){switch(this.transport){case"refresh":return this.previewer.refresh();case"postMessage":return this.previewer.send("setting",[this.id,this()])}}}),f.utils={},f.utils.bubbleChildValueChanges=function(n,e){m.each(e,function(e,t){n[t].bind(function(e,t){n.parent&&e!==t&&n.parent.trigger("change",n)})})},e=function(e){var t,n=this,i=function(){var e=n.extended(f.Panel)&&n.expanded&&n.expanded()?n.container.find("ul.control-panel-content"):n.extended(f.Section)&&n.expanded&&n.expanded()?n.container.find("ul.accordion-section-content"):n.container;e.find("input, select, textarea, button, object, a[href], [tabindex]").filter(":visible").first().focus()};(e=e||{}).completeCallback?(t=e.completeCallback,e.completeCallback=function(){i(),t()}):e.completeCallback=i,n.expand?n.expand(e):e.completeCallback()},f.utils.prioritySort=function(e,t){return e.priority()===t.priority()&&"number"==typeof e.params.instanceNumber&&"number"==typeof t.params.instanceNumber?e.params.instanceNumber-t.params.instanceNumber:e.priority()-t.priority()},f.utils.isKeydownButNotEnterEvent=function(e){return"keydown"===e.type&&13!==e.which},f.utils.areElementListsEqual=function(e,t){return e.length===t.length&&-1===_.indexOf(_.map(_.zip(e,t),function(e){return m(e[0]).is(e[1])}),!1)},i=f.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:m.noop},defaultExpandedArguments:{duration:"fast",completeCallback:m.noop},containerType:"container",defaults:{title:"",description:"",priority:100,type:"default",content:null,active:!0,instanceNumber:null},initialize:function(e,t){var n=this;n.id=e,(t=t||{}).params=_.defaults(t.params||{},n.defaults),m.extend(n,t),n.templateSelector="customize-"+n.containerType+"-"+n.params.type,n.container=m(n.params.content),0===n.container.length&&(n.container=m(n.getContainer())),n.deferred={embedded:new m.Deferred},n.priority=new f.Value,n.active=new f.Value,n.activeArgumentsQueue=[],n.expanded=new f.Value,n.expandedArgumentsQueue=[],n.active.bind(function(e){var t=n.activeArgumentsQueue.shift(),t=m.extend({},n.defaultActiveArguments,t);e=e&&n.isContextuallyActive(),n.onChangeActive(e,t)}),n.expanded.bind(function(e){var t=n.expandedArgumentsQueue.shift(),t=m.extend({},n.defaultExpandedArguments,t);n.onChangeExpanded(e,t)}),n.deferred.embedded.done(function(){n.attachEvents()}),f.utils.bubbleChildValueChanges(n,["priority","active"]),n.priority.set(n.params.priority),n.active.set(n.params.active),n.expanded.set(!1)},ready:function(){},_children:function(t,e){var n=this,i=[];return f[e].each(function(e){e[t].get()===n.id&&i.push(e)}),i.sort(f.utils.prioritySort),i},isContextuallyActive:function(){throw new Error("Container.isContextuallyActive() must be overridden in a subclass.")},onChangeActive:function(e,t){var n,i,o=this;t.unchanged?t.completeCallback&&t.completeCallback():(n="resolved"===f.previewer.deferred.active.state()?t.duration:0,o.extended(f.Panel)&&(f.panel.each(function(e){e!==o&&e.expanded()&&(i=e,n=0)}),e||_.each(o.sections(),function(e){e.collapse({duration:0})})),m.contains(document,o.container[0])?e?o.container.stop(!0,!0).slideDown(n,t.completeCallback):o.expanded()?o.collapse({duration:n,completeCallback:function(){o.container.stop(!0,!0).slideUp(n,t.completeCallback)}}):o.container.stop(!0,!0).slideUp(n,t.completeCallback):(o.container.toggle(e),t.completeCallback&&t.completeCallback()),i&&i._recalculateTopMargin())},_toggleActive:function(e,t){return t=t||{},e&&this.active.get()||!e&&!this.active.get()?(t.unchanged=!0,this.onChangeActive(this.active.get(),t),!1):(t.unchanged=!1,this.activeArgumentsQueue.push(t),this.active.set(e),!0)},activate:function(e){return this._toggleActive(!0,e)},deactivate:function(e){return this._toggleActive(!1,e)},onChangeExpanded:function(){throw new Error("Must override with subclass.")},_toggleExpanded:function(