]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/customize-base.js
WordPress 4.2-scripts
[autoinstalls/wordpress.git] / wp-includes / js / customize-base.js
index 6c41b40c43d52c2e7e8730d9170f46d1dd928c77..2e0ab1957857d7f8affe21369455b31d5625d751 100644 (file)
@@ -158,6 +158,7 @@ window.wp = window.wp || {};
                initialize: function( initial, options ) {
                        this._value = initial; // @todo: potentially change this to a this.set() call.
                        this.callbacks = $.Callbacks();
+                       this._dirty = false;
 
                        $.extend( this, options || {} );
 
@@ -183,10 +184,12 @@ window.wp = window.wp || {};
                        to = this.validate( to );
 
                        // Bail if the sanitized value is null or unchanged.
-                       if ( null === to || this._value === to )
+                       if ( null === to || _.isEqual( from, to ) ) {
                                return this;
+                       }
 
                        this._value = to;
+                       this._dirty = true;
 
                        this.callbacks.fireWith( this, [ to, from ] );
 
@@ -423,10 +426,14 @@ window.wp = window.wp || {};
 
                                if ( this.element.is('input') ) {
                                        type = this.element.prop('type');
-                                       if ( api.Element.synchronizer[ type ] )
+                                       if ( api.Element.synchronizer[ type ] ) {
                                                synchronizer = api.Element.synchronizer[ type ];
-                                       if ( 'text' === type || 'password' === type )
+                                       }
+                                       if ( 'text' === type || 'password' === type ) {
                                                this.events += ' keyup';
+                                       } else if ( 'range' === type ) {
+                                               this.events += ' input propertychange';
+                                       }
                                } else if ( this.element.is('textarea') ) {
                                        this.events += ' keyup';
                                }
@@ -531,11 +538,34 @@ window.wp = window.wp || {};
 
                        this.add( 'channel', params.channel );
                        this.add( 'url', params.url || '' );
-                       this.add( 'targetWindow', params.targetWindow || defaultTarget );
                        this.add( 'origin', this.url() ).link( this.url ).setter( function( to ) {
                                return to.replace( /([^:]+:\/\/[^\/]+).*/, '$1' );
                        });
 
+                       // first add with no value
+                       this.add( 'targetWindow', null );
+                       // This avoids SecurityErrors when setting a window object in x-origin iframe'd scenarios.
+                       this.targetWindow.set = function( to ) {
+                               var from = this._value;
+
+                               to = this._setter.apply( this, arguments );
+                               to = this.validate( to );
+
+                               if ( null === to || from === to ) {
+                                       return this;
+                               }
+
+                               this._value = to;
+                               this._dirty = true;
+
+                               this.callbacks.fireWith( this, [ to, from ] );
+
+                               return this;
+                       };
+                       // now set it
+                       this.targetWindow( params.targetWindow || defaultTarget );
+
+
                        // Since we want jQuery to treat the receive function as unique
                        // to this instance, we give the function a new guid.
                        //