Make WordPress Core

Changeset 21033


Ignore:
Timestamp:
06/08/2012 10:59:48 PM (13 years ago)
Author:
koopersmith
Message:

Theme Customizer: Separate message url from preview url in customizer JS Previewer and PreviewFrame objects. fixes #20892.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/customize-controls.dev.js

    r21031 r21033  
    302302            api.Messenger.prototype.initialize.call( this, params, options );
    303303
     304            this.add( 'previewUrl', params.previewUrl );
     305
    304306            this.bind( 'ready', function() {
    305307                ready = true;
     
    311313            params.query = $.extend( params.query || {}, { customize_messenger_channel: this.channel() });
    312314
    313             this.request = $.ajax( this.url(), {
     315            this.request = $.ajax( this.previewUrl(), {
    314316                type: 'POST',
    315317                data: params.query,
     
    330332                // Check if the location response header differs from the current URL.
    331333                // If so, the request was redirected; try loading the requested page.
    332                 if ( location && location != self.url() ) {
     334                if ( location && location != self.previewUrl() ) {
    333335                    deferred.rejectWith( self, [ 'redirect', location ] );
    334336                    return;
     
    411413        /**
    412414         * Requires params:
    413          *  - container - a selector or jQuery element
    414          *  - url      - the URL of preview frame
     415         *  - container  - a selector or jQuery element
     416         *  - previewUrl - the URL of preview frame
    415417         */
    416418        initialize: function( params, options ) {
     
    458460            this.allowedUrls = params.allowedUrls;
    459461
    460             url = params.url;
    461             delete params.url;
     462            params.url = window.location.href;
    462463
    463464            api.Messenger.prototype.initialize.call( this, params );
    464 
    465             // We're dynamically generating the iframe, so the origin is set
    466             // to the current window's location, not the url's.
    467             this.origin.unlink( this.url ).set( window.location.href );
    468465
    469466            this.add( 'scheme', this.origin() ).link( this.origin ).setter( function( to ) {
     
    480477            // ssl certs.
    481478
    482             this.url.setter( function( to ) {
     479            this.add( 'previewUrl', params.previewUrl ).setter( function( to ) {
    483480                var result;
    484481
     
    505502            });
    506503
    507             // Set the url.
    508             this.url( url );
    509 
    510504            // Refresh the preview when the URL is changed (but not yet).
    511             this.url.bind( this.refresh );
     505            this.previewUrl.bind( this.refresh );
    512506
    513507            this.scroll = 0;
     
    517511
    518512            // Update the URL when the iframe sends a URL message.
    519             this.bind( 'url', this.url );
     513            this.bind( 'url', this.previewUrl );
    520514        },
    521515
     
    535529
    536530            this.loading = new api.PreviewFrame({
    537                 url:       this.url(),
    538                 query:     this.query() || {},
    539                 previewer: this
     531                url:        this.url(),
     532                previewUrl: this.previewUrl(),
     533                query:      this.query() || {},
     534                previewer:  this
    540535            });
    541536
     
    543538                // 'this' is the loading frame
    544539                this.bind( 'synced', function() {
    545                     if ( self.iframe )
    546                         self.iframe.destroy();
    547                     self.iframe = this;
     540                    if ( self.preview )
     541                        self.preview.destroy();
     542                    self.preview = this;
    548543                    delete self.loading;
    549544
     
    560555            this.loading.fail( function( reason, location ) {
    561556                if ( 'redirect' === reason && location )
    562                     self.url( location );
     557                    self.previewUrl( location );
    563558
    564559                if ( 'logged out' === reason ) {
    565                     if ( self.iframe ) {
    566                         self.iframe.destroy();
    567                         delete self.iframe;
     560                    if ( self.preview ) {
     561                        self.preview.destroy();
     562                        delete self.preview;
    568563                    }
    569564
     
    649644            container:   '#customize-preview',
    650645            form:        '#customize-controls',
    651             url:         api.settings.url.preview,
     646            previewUrl:  api.settings.url.preview,
    652647            allowedUrls: api.settings.url.allowed
    653648        }, {
     
    681676                    // Check if the user is logged out.
    682677                    if ( '0' === response ) {
    683                         self.iframe.iframe.hide();
     678                        self.preview.iframe.hide();
    684679                        self.login().done( function() {
    685680                            self.save();
    686                             self.iframe.iframe.show();
     681                            self.preview.iframe.show();
    687682                        });
    688683                        return;
     
    718713
    719714        // Check if preview url is valid and load the preview frame.
    720         if ( previewer.url() )
     715        if ( previewer.previewUrl() )
    721716            previewer.refresh();
    722717        else
    723             previewer.url( api.settings.url.home );
     718            previewer.previewUrl( api.settings.url.home );
    724719
    725720        // Save and activated states
  • trunk/wp-includes/js/customize-base.dev.js

    r21029 r21033  
    193193
    194194        setter: function( callback ) {
     195            var from = this.get();
    195196            this._setter = callback;
    196             this.set( this.get() );
     197            // Temporarily clear value so setter can decide if it's valid.
     198            this._value = null;
     199            this.set( from );
    197200            return this;
    198201        },
Note: See TracChangeset for help on using the changeset viewer.