Ticket #26045: 26045.diff
File 26045.diff, 4.6 KB (added by , 11 years ago) |
---|
-
src/wp-admin/js/theme-install.js
1 /* global ajaxurl, list_args, theme_list_args */ 2 3 var theme_viewer; 4 1 5 /** 2 6 * Theme Browsing 3 7 * … … 28 32 tb_position = function() { 29 33 var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 1040 < width ) ? 1040 : width, adminbar_height = 0; 30 34 31 if ( $('body.admin-bar').length ) 35 if ( $('body.admin-bar').length ) { 32 36 adminbar_height = 28; 37 } 33 38 34 39 if ( tbWindow.size() ) { 35 40 tbWindow.width( W - 50 ).height( H - 45 - adminbar_height ); 36 41 $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height ); 37 42 tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'}); 38 if ( typeof document.body.style.maxWidth != 'undefined' )43 if ( typeof document.body.style.maxWidth !== 'undefined' ) { 39 44 tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'}); 40 }; 45 } 46 } 41 47 }; 42 48 43 49 $(window).resize(function(){ tb_position(); }); … … 49 55 * Displays theme previews on theme install pages. 50 56 */ 51 57 jQuery( function($) { 52 if ( ! window.postMessage )58 if ( ! window.postMessage ) { 53 59 return; 60 } 54 61 55 62 var preview = $('#theme-installer'), 56 63 info = preview.find('.install-theme-info'), … … 86 93 var ThemeViewer; 87 94 88 95 (function($){ 89 ThemeViewer = function( args) {96 ThemeViewer = function() { 90 97 91 98 function init() { 92 99 $( '#filter-click, #mini-filter-click' ).unbind( 'click' ).click( function() { … … 100 107 var count = $( '#filter-box :checked' ).length, 101 108 text = $( '#filter-click' ).text(); 102 109 103 if ( text.indexOf( '(' ) != -1 )110 if ( text.indexOf( '(' ) !== -1 ) { 104 111 text = text.substr( 0, text.indexOf( '(' ) ); 112 } 105 113 106 if ( count == 0 )114 if ( count === 0 ) { 107 115 $( '#filter-click' ).text( text ); 108 else116 } else { 109 117 $( '#filter-click' ).text( text + ' (' + count + ')' ); 118 } 110 119 }); 111 120 112 121 /* $('#filter-box :submit').unbind( 'click' ).click(function() { … … 130 139 init: init 131 140 }; 132 141 133 return api;134 } 142 return api; 143 }; 135 144 })(jQuery); 136 145 137 jQuery( document ).ready( function( $) {146 jQuery( document ).ready( function() { 138 147 theme_viewer = new ThemeViewer(); 139 148 theme_viewer.init(); 140 149 }); … … 169 178 170 179 // Get out early if we don't have the required arguments. 171 180 if ( typeof ajaxurl === 'undefined' || 172 typeof list_args === 'undefined' || 173 typeof theme_list_args === 'undefined' ) { 174 $('.pagination-links').show(); 181 typeof list_args === 'undefined' || 182 typeof theme_list_args === 'undefined' ) { 183 184 $('.pagination-links').show(); 175 185 return; 176 186 } 177 187 … … 189 199 * If there are more pages to query, then start polling to track 190 200 * when user hits the bottom of the current page 191 201 */ 192 if ( theme_list_args.total_pages >= this.nextPage ) 193 this.pollInterval = 194 setInterval( function() {195 return self.poll();196 }, this.scrollPollingDelay );202 if ( theme_list_args.total_pages >= this.nextPage ) { 203 this.pollInterval = setInterval( function() { 204 return self.poll(); 205 }, this.scrollPollingDelay ); 206 } 197 207 }, 198 208 199 209 /** … … 207 217 var bottom = this.$document.scrollTop() + this.$window.innerHeight(); 208 218 209 219 if ( this.querying || 210 ( bottom < this.$outList.height() - this.outListBottomThreshold ) ) 220 ( bottom < this.$outList.height() - this.outListBottomThreshold ) ) { 211 221 return; 222 } 212 223 213 224 this.ajax(); 214 225 }, … … 227 238 return; 228 239 } 229 240 230 if ( this.nextPage > theme_list_args.total_pages ) 241 if ( this.nextPage > theme_list_args.total_pages ) { 231 242 clearInterval( this.pollInterval ); 243 } 232 244 233 if ( this.nextPage <= ( theme_list_args.total_pages + 1 ) ) 245 if ( this.nextPage <= ( theme_list_args.total_pages + 1 ) ) { 234 246 this.$outList.append( results.rows ); 247 } 235 248 }, 236 249 237 250 /** … … 241 254 * @access private 242 255 */ 243 256 ajax: function() { 244 var self = this; 245 246 this.querying = true; 247 248 var query = { 257 var self = this, 258 query = { 249 259 action: 'fetch-list', 250 260 paged: this.nextPage, 251 261 s: theme_list_args.search, … … 256 266 'list_args': list_args 257 267 }; 258 268 269 this.querying = true; 270 259 271 this.$spinner.show(); 260 272 $.getJSON( ajaxurl, query ) 261 273 .done( function( response ) { … … 270 282 setTimeout( function() { self.ajax(); }, self.failedRetryDelay ); 271 283 }); 272 284 } 273 } 285 }; 274 286 275 $(document).ready( function( $) {287 $(document).ready( function() { 276 288 ThemeScroller.init(); 277 289 }); 278 290