| | |
| | |
| | |
| | |
| | |
| | (function( exports, $ ){ |
| | var api = wp.customize, |
| | debounce, |
| | currentHistoryState = {}; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | ( function( history ) { |
| | var injectUrlWithState; |
| |
|
| | if ( ! history.replaceState ) { |
| | return; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | injectUrlWithState = function( url ) { |
| | var urlParser, oldQueryParams, newQueryParams; |
| | urlParser = document.createElement( 'a' ); |
| | urlParser.href = url; |
| | oldQueryParams = api.utils.parseQueryString( location.search.substr( 1 ) ); |
| | newQueryParams = api.utils.parseQueryString( urlParser.search.substr( 1 ) ); |
| |
|
| | newQueryParams.customize_changeset_uuid = oldQueryParams.customize_changeset_uuid; |
| | if ( oldQueryParams.customize_autosaved ) { |
| | newQueryParams.customize_autosaved = 'on'; |
| | } |
| | if ( oldQueryParams.customize_theme ) { |
| | newQueryParams.customize_theme = oldQueryParams.customize_theme; |
| | } |
| | if ( oldQueryParams.customize_messenger_channel ) { |
| | newQueryParams.customize_messenger_channel = oldQueryParams.customize_messenger_channel; |
| | } |
| | urlParser.search = $.param( newQueryParams ); |
| | return urlParser.href; |
| | }; |
| |
|
| | history.replaceState = ( function( nativeReplaceState ) { |
| | return function historyReplaceState( data, title, url ) { |
| | currentHistoryState = data; |
| | return nativeReplaceState.call( history, data, title, 'string' === typeof url && url.length > 0 ? injectUrlWithState( url ) : url ); |
| | }; |
| | } )( history.replaceState ); |
| |
|
| | history.pushState = ( function( nativePushState ) { |
| | return function historyPushState( data, title, url ) { |
| | currentHistoryState = data; |
| | return nativePushState.call( history, data, title, 'string' === typeof url && url.length > 0 ? injectUrlWithState( url ) : url ); |
| | }; |
| | } )( history.pushState ); |
| |
|
| | window.addEventListener( 'popstate', function( event ) { |
| | currentHistoryState = event.state; |
| | } ); |
| |
|
| | }( history ) ); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | debounce = function( fn, delay, context ) { |
| | var timeout; |
| | return function() { |
| | var args = arguments; |
| |
|
| | context = context || this; |
| |
|
| | clearTimeout( timeout ); |
| | timeout = setTimeout( function() { |
| | timeout = null; |
| | fn.apply( context, args ); |
| | }, delay ); |
| | }; |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | api.Preview = api.Messenger.extend({ |
| | |
| | |
| | |
| | |
| | initialize: function( params, options ) { |
| | var preview = this, urlParser = document.createElement( 'a' ); |
| |
|
| | api.Messenger.prototype.initialize.call( preview, params, options ); |
| |
|
| | urlParser.href = preview.origin(); |
| | preview.add( 'scheme', urlParser.protocol.replace( /:$/, '' ) ); |
| |
|
| | preview.body = $( document.body ); |
| | preview.window = $( window ); |
| |
|
| | if ( api.settings.channel ) { |
| |
|
| | |
| | preview.body.on( 'click.preview', 'a', function( event ) { |
| | preview.handleLinkClick( event ); |
| | } ); |
| | preview.body.on( 'submit.preview', 'form', function( event ) { |
| | preview.handleFormSubmit( event ); |
| | } ); |
| |
|
| | preview.window.on( 'scroll.preview', debounce( function() { |
| | preview.send( 'scroll', preview.window.scrollTop() ); |
| | }, 200 ) ); |
| |
|
| | preview.bind( 'scroll', function( distance ) { |
| | preview.window.scrollTop( distance ); |
| | }); |
| | } |
| | }, |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | handleLinkClick: function( event ) { |
| | var preview = this, link, isInternalJumpLink; |
| | link = $( event.target ).closest( 'a' ); |
| |
|
| | |
| | if ( _.isUndefined( link.attr( 'href' ) ) ) { |
| | return; |
| | } |
| |
|
| | |
| | isInternalJumpLink = ( '#' === link.attr( 'href' ).substr( 0, 1 ) ); |
| | if ( isInternalJumpLink || ! /^https?:$/.test( link.prop( 'protocol' ) ) ) { |
| | return; |
| | } |
| |
|
| | |
| | if ( ! api.isLinkPreviewable( link[0] ) ) { |
| | wp.a11y.speak( api.settings.l10n.linkUnpreviewable ); |
| | event.preventDefault(); |
| | return; |
| | } |
| |
|
| | |
| | event.preventDefault(); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | if ( event.shiftKey ) { |
| | return; |
| | } |
| |
|
| | |
| | preview.send( 'url', link.prop( 'href' ) ); |
| | }, |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | handleFormSubmit: function( event ) { |
| | var preview = this, urlParser, form; |
| | urlParser = document.createElement( 'a' ); |
| | form = $( event.target ); |
| | urlParser.href = form.prop( 'action' ); |
| |
|
| | |
| | if ( 'GET' !== form.prop( 'method' ).toUpperCase() || ! api.isLinkPreviewable( urlParser ) ) { |
| | wp.a11y.speak( api.settings.l10n.formUnpreviewable ); |
| | event.preventDefault(); |
| | return; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | if ( ! event.isDefaultPrevented() ) { |
| | if ( urlParser.search.length > 1 ) { |
| | urlParser.search += '&'; |
| | } |
| | urlParser.search += form.serialize(); |
| | preview.send( 'url', urlParser.href ); |
| | } |
| |
|
| | |
| | event.preventDefault(); |
| | } |
| | }); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | api.addLinkPreviewing = function addLinkPreviewing() { |
| | var linkSelectors = 'a[href], area[href]'; |
| |
|
| | |
| | $( document.body ).find( linkSelectors ).each( function() { |
| | api.prepareLinkPreview( this ); |
| | } ); |
| |
|
| | |
| | if ( 'undefined' !== typeof MutationObserver ) { |
| | api.mutationObserver = new MutationObserver( function( mutations ) { |
| | _.each( mutations, function( mutation ) { |
| | $( mutation.target ).find( linkSelectors ).each( function() { |
| | api.prepareLinkPreview( this ); |
| | } ); |
| | } ); |
| | } ); |
| | api.mutationObserver.observe( document.documentElement, { |
| | childList: true, |
| | subtree: true |
| | } ); |
| | } else { |
| |
|
| | |
| | $( document.documentElement ).on( 'click focus mouseover', linkSelectors, function() { |
| | api.prepareLinkPreview( this ); |
| | } ); |
| | } |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | api.isLinkPreviewable = function isLinkPreviewable( element, options ) { |
| | var matchesAllowedUrl, parsedAllowedUrl, args, elementHost; |
| |
|
| | args = _.extend( {}, { allowAdminAjax: false }, options || {} ); |
| |
|
| | if ( 'javascript:' === element.protocol ) { |
| | return true; |
| | } |
| |
|
| | |
| | if ( 'https:' !== element.protocol && 'http:' !== element.protocol ) { |
| | return false; |
| | } |
| |
|
| | elementHost = element.host.replace( /:(80|443)$/, '' ); |
| | parsedAllowedUrl = document.createElement( 'a' ); |
| | matchesAllowedUrl = ! _.isUndefined( _.find( api.settings.url.allowed, function( allowedUrl ) { |
| | parsedAllowedUrl.href = allowedUrl; |
| | return parsedAllowedUrl.protocol === element.protocol && parsedAllowedUrl.host.replace( /:(80|443)$/, '' ) === elementHost && 0 === element.pathname.indexOf( parsedAllowedUrl.pathname.replace( /\/$/, '' ) ); |
| | } ) ); |
| | if ( ! matchesAllowedUrl ) { |
| | return false; |
| | } |
| |
|
| | |
| | if ( /\/wp-(login|signup)\.php$/.test( element.pathname ) ) { |
| | return false; |
| | } |
| |
|
| | |
| | if ( /\/wp-admin\/admin-ajax\.php$/.test( element.pathname ) ) { |
| | return args.allowAdminAjax; |
| | } |
| |
|
| | |
| | if ( /\/wp-(admin|includes|content)(\/|$)/.test( element.pathname ) ) { |
| | return false; |
| | } |
| |
|
| | return true; |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | api.prepareLinkPreview = function prepareLinkPreview( element ) { |
| | var queryParams, $element = $( element ); |
| |
|
| | |
| | if ( ! element.hasAttribute( 'href' ) ) { |
| | return; |
| | } |
| |
|
| | |
| | if ( $element.closest( '#wpadminbar' ).length ) { |
| | return; |
| | } |
| |
|
| | |
| | if ( '#' === $element.attr( 'href' ).substr( 0, 1 ) || ! /^https?:$/.test( element.protocol ) ) { |
| | return; |
| | } |
| |
|
| | |
| | if ( api.settings.channel && 'https' === api.preview.scheme.get() && 'http:' === element.protocol && -1 !== api.settings.url.allowedHosts.indexOf( element.host ) ) { |
| | element.protocol = 'https:'; |
| | } |
| |
|
| | |
| | if ( $element.hasClass( 'wp-playlist-caption' ) ) { |
| | return; |
| | } |
| |
|
| | if ( ! api.isLinkPreviewable( element ) ) { |
| |
|
| | |
| | if ( api.settings.channel ) { |
| | $element.addClass( 'customize-unpreviewable' ); |
| | } |
| | return; |
| | } |
| | $element.removeClass( 'customize-unpreviewable' ); |
| |
|
| | queryParams = api.utils.parseQueryString( element.search.substring( 1 ) ); |
| | queryParams.customize_changeset_uuid = api.settings.changeset.uuid; |
| | if ( api.settings.changeset.autosaved ) { |
| | queryParams.customize_autosaved = 'on'; |
| | } |
| | if ( ! api.settings.theme.active ) { |
| | queryParams.customize_theme = api.settings.theme.stylesheet; |
| | } |
| | if ( api.settings.channel ) { |
| | queryParams.customize_messenger_channel = api.settings.channel; |
| | } |
| | element.search = $.param( queryParams ); |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | api.addRequestPreviewing = function addRequestPreviewing() { |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | var prefilterAjax = function( options, originalOptions, xhr ) { |
| | var urlParser, queryParams, requestMethod, dirtyValues = {}; |
| | urlParser = document.createElement( 'a' ); |
| | urlParser.href = options.url; |
| |
|
| | |
| | if ( ! api.isLinkPreviewable( urlParser, { allowAdminAjax: true } ) ) { |
| | return; |
| | } |
| | queryParams = api.utils.parseQueryString( urlParser.search.substring( 1 ) ); |
| |
|
| | |
| | api.each( function( setting ) { |
| | if ( setting._dirty ) { |
| | dirtyValues[ setting.id ] = setting.get(); |
| | } |
| | } ); |
| |
|
| | if ( ! _.isEmpty( dirtyValues ) ) { |
| | requestMethod = options.type.toUpperCase(); |
| |
|
| | |
| | if ( 'POST' !== requestMethod ) { |
| | xhr.setRequestHeader( 'X-HTTP-Method-Override', requestMethod ); |
| | queryParams._method = requestMethod; |
| | options.type = 'POST'; |
| | } |
| |
|
| | |
| | if ( options.data ) { |
| | options.data += '&'; |
| | } else { |
| | options.data = ''; |
| | } |
| | options.data += $.param( { |
| | customized: JSON.stringify( dirtyValues ) |
| | } ); |
| | } |
| |
|
| | |
| | queryParams.customize_changeset_uuid = api.settings.changeset.uuid; |
| | if ( api.settings.changeset.autosaved ) { |
| | queryParams.customize_autosaved = 'on'; |
| | } |
| | if ( ! api.settings.theme.active ) { |
| | queryParams.customize_theme = api.settings.theme.stylesheet; |
| | } |
| |
|
| | |
| | queryParams.customize_preview_nonce = api.settings.nonce.preview; |
| |
|
| | urlParser.search = $.param( queryParams ); |
| | options.url = urlParser.href; |
| | }; |
| |
|
| | $.ajaxPrefilter( prefilterAjax ); |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | api.addFormPreviewing = function addFormPreviewing() { |
| |
|
| | |
| | $( document.body ).find( 'form' ).each( function() { |
| | api.prepareFormPreview( this ); |
| | } ); |
| |
|
| | |
| | if ( 'undefined' !== typeof MutationObserver ) { |
| | api.mutationObserver = new MutationObserver( function( mutations ) { |
| | _.each( mutations, function( mutation ) { |
| | $( mutation.target ).find( 'form' ).each( function() { |
| | api.prepareFormPreview( this ); |
| | } ); |
| | } ); |
| | } ); |
| | api.mutationObserver.observe( document.documentElement, { |
| | childList: true, |
| | subtree: true |
| | } ); |
| | } |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | api.prepareFormPreview = function prepareFormPreview( form ) { |
| | var urlParser, stateParams = {}; |
| |
|
| | if ( ! form.action ) { |
| | form.action = location.href; |
| | } |
| |
|
| | urlParser = document.createElement( 'a' ); |
| | urlParser.href = form.action; |
| |
|
| | |
| | if ( api.settings.channel && 'https' === api.preview.scheme.get() && 'http:' === urlParser.protocol && -1 !== api.settings.url.allowedHosts.indexOf( urlParser.host ) ) { |
| | urlParser.protocol = 'https:'; |
| | form.action = urlParser.href; |
| | } |
| |
|
| | if ( 'GET' !== form.method.toUpperCase() || ! api.isLinkPreviewable( urlParser ) ) { |
| |
|
| | |
| | if ( api.settings.channel ) { |
| | $( form ).addClass( 'customize-unpreviewable' ); |
| | } |
| | return; |
| | } |
| | $( form ).removeClass( 'customize-unpreviewable' ); |
| |
|
| | stateParams.customize_changeset_uuid = api.settings.changeset.uuid; |
| | if ( api.settings.changeset.autosaved ) { |
| | stateParams.customize_autosaved = 'on'; |
| | } |
| | if ( ! api.settings.theme.active ) { |
| | stateParams.customize_theme = api.settings.theme.stylesheet; |
| | } |
| | if ( api.settings.channel ) { |
| | stateParams.customize_messenger_channel = api.settings.channel; |
| | } |
| |
|
| | _.each( stateParams, function( value, name ) { |
| | var input = $( form ).find( 'input[name="' + name + '"]' ); |
| | if ( input.length ) { |
| | input.val( value ); |
| | } else { |
| | $( form ).prepend( $( '<input>', { |
| | type: 'hidden', |
| | name: name, |
| | value: value |
| | } ) ); |
| | } |
| | } ); |
| |
|
| | |
| | if ( api.settings.channel ) { |
| | form.target = '_self'; |
| | } |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | api.keepAliveCurrentUrl = ( function() { |
| | var previousPathName = location.pathname, |
| | previousQueryString = location.search.substr( 1 ), |
| | previousQueryParams = null, |
| | stateQueryParams = [ 'customize_theme', 'customize_changeset_uuid', 'customize_messenger_channel', 'customize_autosaved' ]; |
| |
|
| | return function keepAliveCurrentUrl() { |
| | var urlParser, currentQueryParams; |
| |
|
| | |
| | if ( previousQueryString === location.search.substr( 1 ) && previousPathName === location.pathname ) { |
| | api.preview.send( 'keep-alive' ); |
| | return; |
| | } |
| |
|
| | urlParser = document.createElement( 'a' ); |
| | if ( null === previousQueryParams ) { |
| | urlParser.search = previousQueryString; |
| | previousQueryParams = api.utils.parseQueryString( previousQueryString ); |
| | _.each( stateQueryParams, function( name ) { |
| | delete previousQueryParams[ name ]; |
| | } ); |
| | } |
| |
|
| | |
| | urlParser.href = location.href; |
| | currentQueryParams = api.utils.parseQueryString( urlParser.search.substr( 1 ) ); |
| | _.each( stateQueryParams, function( name ) { |
| | delete currentQueryParams[ name ]; |
| | } ); |
| |
|
| | if ( previousPathName !== location.pathname || ! _.isEqual( previousQueryParams, currentQueryParams ) ) { |
| | urlParser.search = $.param( currentQueryParams ); |
| | urlParser.hash = ''; |
| | api.settings.url.self = urlParser.href; |
| | api.preview.send( 'ready', { |
| | currentUrl: api.settings.url.self, |
| | activePanels: api.settings.activePanels, |
| | activeSections: api.settings.activeSections, |
| | activeControls: api.settings.activeControls, |
| | settingValidities: api.settings.settingValidities |
| | } ); |
| | } else { |
| | api.preview.send( 'keep-alive' ); |
| | } |
| | previousQueryParams = currentQueryParams; |
| | previousQueryString = location.search.substr( 1 ); |
| | previousPathName = location.pathname; |
| | }; |
| | } )(); |
| |
|
| | api.settingPreviewHandlers = { |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | custom_logo: function( attachmentId ) { |
| | $( 'body' ).toggleClass( 'wp-custom-logo', !! attachmentId ); |
| | }, |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | custom_css: function( value ) { |
| | $( '#wp-custom-css' ).text( value ); |
| | }, |
| |
|
| | |
| | |
| | |
| | |
| | |
| | background: function() { |
| | var css = '', settings = {}; |
| |
|
| | _.each( ['color', 'image', 'preset', 'position_x', 'position_y', 'size', 'repeat', 'attachment'], function( prop ) { |
| | settings[ prop ] = api( 'background_' + prop ); |
| | } ); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | $( document.body ).toggleClass( 'custom-background', !! ( settings.color() || settings.image() ) ); |
| |
|
| | if ( settings.color() ) { |
| | css += 'background-color: ' + settings.color() + ';'; |
| | } |
| |
|
| | if ( settings.image() ) { |
| | css += 'background-image: url("' + settings.image() + '");'; |
| | css += 'background-size: ' + settings.size() + ';'; |
| | css += 'background-position: ' + settings.position_x() + ' ' + settings.position_y() + ';'; |
| | css += 'background-repeat: ' + settings.repeat() + ';'; |
| | css += 'background-attachment: ' + settings.attachment() + ';'; |
| | } |
| |
|
| | $( '#custom-background-css' ).text( 'body.custom-background { ' + css + ' }' ); |
| | } |
| | }; |
| |
|
| | $( function() { |
| | var bg, setValue, handleUpdatedChangesetUuid; |
| |
|
| | api.settings = window._wpCustomizeSettings; |
| | if ( ! api.settings ) { |
| | return; |
| | } |
| |
|
| | api.preview = new api.Preview({ |
| | url: window.location.href, |
| | channel: api.settings.channel |
| | }); |
| |
|
| | api.addLinkPreviewing(); |
| | api.addRequestPreviewing(); |
| | api.addFormPreviewing(); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | setValue = function( id, value, createDirty ) { |
| | var setting = api( id ); |
| | if ( setting ) { |
| | setting.set( value ); |
| | } else { |
| | createDirty = createDirty || false; |
| | setting = api.create( id, value, { |
| | id: id |
| | } ); |
| |
|
| | |
| | if ( createDirty ) { |
| | setting._dirty = true; |
| | } |
| | } |
| | }; |
| |
|
| | api.preview.bind( 'settings', function( values ) { |
| | $.each( values, setValue ); |
| | }); |
| |
|
| | api.preview.trigger( 'settings', api.settings.values ); |
| |
|
| | $.each( api.settings._dirty, function( i, id ) { |
| | var setting = api( id ); |
| | if ( setting ) { |
| | setting._dirty = true; |
| | } |
| | } ); |
| |
|
| | api.preview.bind( 'setting', function( args ) { |
| | var createDirty = true; |
| | setValue.apply( null, args.concat( createDirty ) ); |
| | }); |
| |
|
| | api.preview.bind( 'sync', function( events ) { |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | if ( events.settings && events['settings-modified-while-loading'] ) { |
| | _.each( _.keys( events.settings ), function( syncedSettingId ) { |
| | if ( api.has( syncedSettingId ) && ! events['settings-modified-while-loading'][ syncedSettingId ] ) { |
| | delete events.settings[ syncedSettingId ]; |
| | } |
| | } ); |
| | } |
| |
|
| | $.each( events, function( event, args ) { |
| | api.preview.trigger( event, args ); |
| | }); |
| | api.preview.send( 'synced' ); |
| | }); |
| |
|
| | api.preview.bind( 'active', function() { |
| | api.preview.send( 'nonce', api.settings.nonce ); |
| |
|
| | api.preview.send( 'documentTitle', document.title ); |
| |
|
| | |
| | api.preview.send( 'scroll', $( window ).scrollTop() ); |
| | }); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | handleUpdatedChangesetUuid = function( uuid ) { |
| | api.settings.changeset.uuid = uuid; |
| |
|
| | |
| | $( document.body ).find( 'a[href], area[href]' ).each( function() { |
| | api.prepareLinkPreview( this ); |
| | } ); |
| | $( document.body ).find( 'form' ).each( function() { |
| | api.prepareFormPreview( this ); |
| | } ); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | if ( history.replaceState ) { |
| | history.replaceState( currentHistoryState, '', location.href ); |
| | } |
| | }; |
| |
|
| | api.preview.bind( 'changeset-uuid', handleUpdatedChangesetUuid ); |
| |
|
| | api.preview.bind( 'saved', function( response ) { |
| | if ( response.next_changeset_uuid ) { |
| | handleUpdatedChangesetUuid( response.next_changeset_uuid ); |
| | } |
| | api.trigger( 'saved', response ); |
| | } ); |
| |
|
| | |
| | api.preview.bind( 'autosaving', function() { |
| | if ( api.settings.changeset.autosaved ) { |
| | return; |
| | } |
| |
|
| | api.settings.changeset.autosaved = true; |
| |
|
| | $( document.body ).find( 'a[href], area[href]' ).each( function() { |
| | api.prepareLinkPreview( this ); |
| | } ); |
| | $( document.body ).find( 'form' ).each( function() { |
| | api.prepareFormPreview( this ); |
| | } ); |
| | if ( history.replaceState ) { |
| | history.replaceState( currentHistoryState, '', location.href ); |
| | } |
| | } ); |
| |
|
| | |
| | |
| | |
| | |
| | api.preview.bind( 'changeset-saved', function( data ) { |
| | _.each( data.saved_changeset_values, function( value, settingId ) { |
| | var setting = api( settingId ); |
| | if ( setting && _.isEqual( setting.get(), value ) ) { |
| | setting._dirty = false; |
| | } |
| | } ); |
| | } ); |
| |
|
| | api.preview.bind( 'nonce-refresh', function( nonce ) { |
| | $.extend( api.settings.nonce, nonce ); |
| | } ); |
| |
|
| | |
| | |
| | |
| | |
| | api.preview.send( 'ready', { |
| | currentUrl: api.settings.url.self, |
| | activePanels: api.settings.activePanels, |
| | activeSections: api.settings.activeSections, |
| | activeControls: api.settings.activeControls, |
| | settingValidities: api.settings.settingValidities |
| | } ); |
| |
|
| | |
| | setInterval( api.keepAliveCurrentUrl, api.settings.timeouts.keepAliveSend ); |
| |
|
| | |
| | api.preview.bind( 'loading-initiated', function () { |
| | $( 'body' ).addClass( 'wp-customizer-unloading' ); |
| | }); |
| | api.preview.bind( 'loading-failed', function () { |
| | $( 'body' ).removeClass( 'wp-customizer-unloading' ); |
| | }); |
| |
|
| | |
| | bg = $.map( ['color', 'image', 'preset', 'position_x', 'position_y', 'size', 'repeat', 'attachment'], function( prop ) { |
| | return 'background_' + prop; |
| | } ); |
| |
|
| | api.when.apply( api, bg ).done( function() { |
| | $.each( arguments, function() { |
| | this.bind( api.settingPreviewHandlers.background ); |
| | }); |
| | }); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | api( 'custom_logo', function ( setting ) { |
| | api.settingPreviewHandlers.custom_logo.call( setting, setting.get() ); |
| | setting.bind( api.settingPreviewHandlers.custom_logo ); |
| | } ); |
| |
|
| | api( 'custom_css[' + api.settings.theme.stylesheet + ']', function( setting ) { |
| | setting.bind( api.settingPreviewHandlers.custom_css ); |
| | } ); |
| |
|
| | api.trigger( 'preview-ready' ); |
| | }); |
| |
|
| | })( wp, jQuery ); |
| |
|