Changeset 20031
- Timestamp:
- 02/29/2012 01:17:21 AM (8 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/customize-controls.php
r20030 r20031 70 70 <div id="customize-footer" class="customize-section"> 71 71 <?php 72 submit_button( __( 'Refresh' ), 'secondary', 'refresh', false );73 72 submit_button( __( 'Save' ), 'primary', 'save', false ); 74 73 ?> -
trunk/wp-includes/js/customize-controls.dev.js
r19995 r20031 3 3 4 4 api.Previewer = api.Messenger.extend({ 5 refreshBuffer: 250, 6 5 7 /** 6 8 * Requires params: … … 12 14 $.extend( this, options || {} ); 13 15 16 this.loaderUuid = 0; 17 18 /* 19 * Wrap this.refresh to prevent it from hammering the servers: 20 * 21 * If refresh is called once and no other refresh requests are 22 * loading, trigger the request immediately. 23 * 24 * If refresh is called while another refresh request is loading, 25 * debounce the refresh requests: 26 * 1. Stop the loading request (as it is instantly outdated). 27 * 2. Trigger the new request once refresh hasn't been called for 28 * self.refreshBuffer milliseconds. 29 */ 30 this.refresh = (function( self ) { 31 var refresh = self.refresh, 32 callback = function() { 33 timeout = null; 34 refresh.call( self ); 35 }, 36 timeout; 37 38 return function() { 39 if ( typeof timeout !== 'number' ) { 40 if ( self.loading ) { 41 self.loading.remove(); 42 delete self.loading; 43 self.loader(); 44 } else { 45 return callback(); 46 } 47 } 48 49 clearTimeout( timeout ); 50 timeout = setTimeout( callback, self.refreshBuffer ); 51 }; 52 })( this ); 53 14 54 this.iframe = api.ensure( params.iframe ); 15 55 this.form = api.ensure( params.form ); 56 57 this.container = this.iframe.parent(); 16 58 17 59 api.Messenger.prototype.initialize.call( this, params.url, { … … 35 77 this.refresh(); 36 78 }, 79 loader: function() { 80 var self = this, 81 name; 82 83 if ( this.loading ) 84 return this.loading; 85 86 name = this.iframe.prop('name'); 87 88 this.loading = $('<iframe />', { 89 name: name + '-loading-' + this.loaderUuid++ 90 }).appendTo( this.container ); 91 92 this.loading.one( 'load', function() { 93 self.iframe.remove(); 94 self.iframe = self.loading; 95 delete self.loading; 96 self.iframe.prop( 'name', name ); 97 }); 98 99 return this.loading; 100 }, 37 101 refresh: function() { 38 102 this.submit({ 39 target: this. iframe.prop('name'),103 target: this.loader().prop('name'), 40 104 action: this.url() 41 105 }); … … 55 119 56 120 $( function() { 121 if ( ! api.settings ) 122 return; 123 57 124 var previewer, 58 125 controls = $('[name^="' + api.settings.prefix + '"]'); … … 73 140 setting.control.link( setting ); 74 141 setting.link( setting.control ); 142 143 setting.bind( previewer.refresh ); 75 144 }); 76 145 … … 88 157 }); 89 158 90 $('#refresh').click( function() {91 previewer.refresh();92 return false;93 });94 95 159 // Fetch prefixed settings. 96 160 $('[name^="' + api.settings.prefix + '"]').each( function() {
Note: See TracChangeset
for help on using the changeset viewer.