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

2 lines
10 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
(r=>{var s,i,a,o,c,n,u,l,d,h=wp.customize,p={};(i=history).replaceState&&(c=function(e){var t,n=document.createElement("a");return n.href=e,e=h.utils.parseQueryString(location.search.substr(1)),(t=h.utils.parseQueryString(n.search.substr(1))).customize_changeset_uuid=e.customize_changeset_uuid,e.customize_autosaved&&(t.customize_autosaved="on"),e.customize_theme&&(t.customize_theme=e.customize_theme),e.customize_messenger_channel&&(t.customize_messenger_channel=e.customize_messenger_channel),n.search=r.param(t),n.href},i.replaceState=(a=i.replaceState,function(e,t,n){return p=e,a.call(i,e,t,"string"==typeof n&&0<n.length?c(n):n)}),i.pushState=(o=i.pushState,function(e,t,n){return p=e,o.call(i,e,t,"string"==typeof n&&0<n.length?c(n):n)}),window.addEventListener("popstate",function(e){p=e.state})),s=function(t,n,i){var s;return function(){var e=arguments;i=i||this,clearTimeout(s),s=setTimeout(function(){s=null,t.apply(i,e)},n)}},h.Preview=h.Messenger.extend({initialize:function(e,t){var n=this,i=document.createElement("a");h.Messenger.prototype.initialize.call(n,e,t),i.href=n.origin(),n.add("scheme",i.protocol.replace(/:$/,"")),n.body=r(document.body),n.window=r(window),h.settings.channel&&(n.body.on("click.preview","a",function(e){n.handleLinkClick(e)}),n.body.on("submit.preview","form",function(e){n.handleFormSubmit(e)}),n.window.on("scroll.preview",s(function(){n.send("scroll",n.window.scrollTop())},200)),n.bind("scroll",function(e){n.window.scrollTop(e)}))},handleLinkClick:function(e){var t=r(e.target).closest("a");_.isUndefined(t.attr("href"))||"#"!==t.attr("href").substr(0,1)&&/^https?:$/.test(t.prop("protocol"))&&(h.isLinkPreviewable(t[0])?(e.preventDefault(),e.shiftKey||this.send("url",t.prop("href"))):(wp.a11y.speak(h.settings.l10n.linkUnpreviewable),e.preventDefault()))},handleFormSubmit:function(e){var t=document.createElement("a"),n=r(e.target);t.href=n.prop("action"),"GET"===n.prop("method").toUpperCase()&&h.isLinkPreviewable(t)?e.isDefaultPrevented()||(1<t.search.length&&(t.search+="&"),t.search+=n.serialize(),this.send("url",t.href)):wp.a11y.speak(h.settings.l10n.formUnpreviewable),e.preventDefault()}}),h.addLinkPreviewing=function(){var t="a[href], area[href]";r(document.body).find(t).each(function(){h.prepareLinkPreview(this)}),"undefined"!=typeof MutationObserver?(h.mutationObserver=new MutationObserver(function(e){_.each(e,function(e){r(e.target).find(t).each(function(){h.prepareLinkPreview(this)})})}),h.mutationObserver.observe(document.documentElement,{childList:!0,subtree:!0})):r(document.documentElement).on("click focus mouseover",t,function(){h.prepareLinkPreview(this)})},h.isLinkPreviewable=function(t,e){var n,i,e=_.extend({},{allowAdminAjax:!1},e||{});return"javascript:"===t.protocol||("https:"===t.protocol||"http:"===t.protocol)&&(i=t.host.replace(/:(80|443)$/,""),n=document.createElement("a"),!_.isUndefined(_.find(h.settings.url.allowed,function(e){return n.href=e,n.protocol===t.protocol&&n.host.replace(/:(80|443)$/,"")===i&&0===t.pathname.indexOf(n.pathname.replace(/\/$/,""))})))&&!/\/wp-(login|signup)\.php$/.test(t.pathname)&&(/\/wp-admin\/admin-ajax\.php$/.test(t.pathname)?e.allowAdminAjax:!/\/wp-(admin|includes|content)(\/|$)/.test(t.pathname))},h.prepareLinkPreview=function(e){var t,n=r(e);e.hasAttribute("href")&&!n.closest("#wpadminbar").length&&"#"!==n.attr("href").substr(0,1)&&/^https?:$/.test(e.protocol)&&(h.settings.channel&&"https"===h.preview.scheme.get()&&"http:"===e.protocol&&-1!==h.settings.url.allowedHosts.indexOf(e.host)&&(e.protocol="https:"),n.hasClass("wp-playlist-caption")||(h.isLinkPreviewable(e)?(n.removeClass("customize-unpreviewable"),(t=h.utils.parseQueryString(e.search.substring(1))).customize_changeset_uuid=h.settings.changeset.uuid,h.settings.changeset.autosaved&&(t.customize_autosaved="on"),h.settings.theme.active||(t.customize_theme=h.settings.theme.stylesheet),h.settings.channel&&(t.customize_messenger_channel=h.settings.channel),e.search=r.param(t)):h.settings.channel&&n.addClass("customize-unpreviewable")))},h.addRequestPreviewing=function(){r.ajaxPrefilter(fun