Changeset 26210
- Timestamp:
- 11/15/2013 02:15:39 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/theme-install.js
r26141 r26210 1 /* global ajaxurl, list_args, theme_list_args */ 2 3 var theme_viewer; 4 1 5 /** 2 6 * Theme Browsing … … 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() ) { … … 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 … … 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'), … … 87 94 88 95 (function($){ 89 ThemeViewer = function( args) {96 ThemeViewer = function() { 90 97 91 98 function init() { … … 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( '(' ) ); 105 106 if ( count == 0 ) 112 } 113 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 … … 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(); … … 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 } … … 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 … … 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(); … … 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 ); 232 233 if ( this.nextPage <= ( theme_list_args.total_pages + 1 ) ) 243 } 244 245 if ( this.nextPage <= ( theme_list_args.total_pages + 1 ) ) { 234 246 this.$outList.append( results.rows ); 247 } 235 248 }, 236 249 … … 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, … … 256 266 'list_args': list_args 257 267 }; 268 269 this.querying = true; 258 270 259 271 this.$spinner.show(); … … 271 283 }); 272 284 } 273 } 274 275 $(document).ready( function( $) {285 }; 286 287 $(document).ready( function() { 276 288 ThemeScroller.init(); 277 289 });
Note: See TracChangeset
for help on using the changeset viewer.