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

1 line
2.5 KiB
JavaScript

window.wp=window.wp||{},function(t){var o,s=wp.customize;t.extend(t.support,{history:!(!window.history||!history.pushState),hashchange:"onhashchange"in window&&(void 0===document.documentMode||7<document.documentMode)}),o=t.extend({},s.Events,{initialize:function(){this.body=t(document.body),o.settings&&t.support.postMessage&&(t.support.cors||!o.settings.isCrossDomain)&&(this.window=t(window),this.element=t('<div id="customize-container" />').appendTo(this.body),this.bind("open",this.overlay.show),this.bind("close",this.overlay.hide),t("#wpbody").on("click",".load-customize",function(e){e.preventDefault(),o.link=t(this),o.open(o.link.attr("href"))}),t.support.history&&this.window.on("popstate",o.popstate),t.support.hashchange&&(this.window.on("hashchange",o.hashchange),this.window.triggerHandler("hashchange")))},popstate:function(e){e=e.originalEvent.state;e&&e.customize?o.open(e.customize):o.active&&o.close()},hashchange:function(e){var i=window.location.toString().split("#")[1];i&&0===i.indexOf("wp_customize=on")&&o.open(o.settings.url+"?"+i),i||t.support.history||o.close()},open:function(e){var i;if(!this.active){if(o.settings.browser.mobile)return window.location=e;this.active=!0,this.body.addClass("customize-loading"),this.iframe=t("<iframe />",{src:e}).appendTo(this.element),this.iframe.one("load",this.loaded),this.messenger=new s.Messenger({url:e,channel:"loader",targetWindow:this.iframe[0].contentWindow}),this.messenger.bind("ready",function(){o.messenger.send("back")}),this.messenger.bind("close",function(){t.support.history?history.back():t.support.hashchange?window.location.hash="":o.close()}),this.messenger.bind("activated",function(e){e&&(window.location=e)}),i=e.split("?")[1],t.support.history&&window.location.href!==e?history.pushState({customize:e},"",e):!t.support.history&&t.support.hashchange&&i&&(window.location.hash="wp_customize=on&"+i),this.trigger("open")}},opened:function(){o.body.addClass("customize-active full-overlay-active")},close:function(){this.active&&(this.active=!1,this.trigger("close"),this.link&&this.link.focus())},closed:function(){o.iframe.remove(),o.messenger.destroy(),o.iframe=null,o.messenger=null,o.body.removeClass("customize-active full-overlay-active").removeClass("customize-loading")},loaded:function(){o.body.removeClass("customize-loading")},overlay:{show:function(){this.element.fadeIn(200,o.opened)},hide:function(){this.element.fadeOut(200,o.closed)}}}),t(function(){o.settings=_wpCustomizeLoaderSettings,o.initialize()}),s.Loader=o}((wp,jQuery));