Ticket #10021: 10021.3.diff
File 10021.3.diff, 17.4 KB (added by , 12 years ago) |
---|
-
wp-admin/js/common.dev.js
4 4 adminMenu = { 5 5 6 6 init : function() { 7 $('#adminmenu 8 if ( $(this).siblings(' .wp-submenu').length )9 $(this).click(function(){ adminMenu.toggle( $(this).siblings(' .wp-submenu') ); });7 $('#adminmenu').find('div.wp-menu-toggle').each( function() { 8 if ( $(this).siblings('div.wp-submenu').length ) 9 $(this).click(function(){ adminMenu.toggle( $(this).siblings('div.wp-submenu') ); }); 10 10 else 11 11 $(this).hide(); 12 12 }); 13 13 logScript("$('#adminmenu div.wp-menu-toggle').each"); 14 14 15 this.favorites(); 15 16 logScript("this.favorites();"); 17 16 18 $('a.separator').click(function(){ 17 19 if ( $('body').hasClass('folded') ) { 18 20 adminMenu.fold(1); … … 23 25 } 24 26 return false; 25 27 }); 26 28 logScript("$('a.separator').click"); 29 27 30 if ( $('body').hasClass('folded') ) { 28 31 this.fold(); 29 32 } 33 logScript("$('body').hasClass('folded')"); 34 30 35 this.restoreMenuState(); 36 logScript("this.restoreMenuState();"); 31 37 }, 32 38 33 39 restoreMenuState : function() { 34 $('#adminmenu 40 $('#adminmenu').find('li.wp-has-submenu').each(function(i, e) { 35 41 var v = getUserSetting( 'm'+i ); 36 42 if ( $(e).hasClass('wp-has-current-submenu') ) return true; // leave the current parent open 37 43 … … 44 50 45 51 el['slideToggle'](150, function(){el.css('display','');}).parent().toggleClass( 'wp-menu-open' ); 46 52 47 $('#adminmenu 53 $('#adminmenu').find('li.wp-has-submenu').each(function(i, e) { 48 54 var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c'; 49 55 setUserSetting( 'm'+i, v ); 50 56 }); … … 55 61 fold : function(off) { 56 62 if (off) { 57 63 $('body').removeClass('folded'); 58 $('#adminmenu 64 $('#adminmenu').find('li.wp-has-submenu').unbind(); 59 65 } else { 60 66 $('body').addClass('folded'); 61 $('#adminmenu 67 $('#adminmenu').find('li.wp-has-submenu').hoverIntent({ 62 68 over: function(e){ 63 69 var m, b, h, o, f; 64 m = $(this).find(' .wp-submenu');70 m = $(this).find('div.wp-submenu'); 65 71 b = m.parent().offset().top + m.height() + 1; // Bottom offset of the menu 66 72 h = $('#wpwrap').height(); // Height of the entire page 67 73 o = 60 + b - h; … … 76 82 } 77 83 m.addClass('sub-open'); 78 84 }, 79 out: function(){ $(this).find(' .wp-submenu').removeClass('sub-open').css({'marginTop':''}); },85 out: function(){ $(this).find('div.wp-submenu').removeClass('sub-open').css({'marginTop':''}); }, 80 86 timeout: 220, 81 87 sensitivity: 8, 82 88 interval: 100 … … 93 99 } 94 100 }; 95 101 96 $(document).ready(function(){ adminMenu.init();});102 $(document).ready(function(){logScript('adminMenu.init()');adminMenu.init();logScript('end adminMenu.init()');}); 97 103 98 104 // show/hide/save table columns 99 105 columns = { 100 106 init : function() { 101 $(' .hide-column-tog').click( function() {107 $('input.hide-column-tog').click( function() { 102 108 var column = $(this).val(), show = $(this).attr('checked'); 103 109 if ( show ) { 104 110 $('.column-' + column).show(); … … 120 126 } 121 127 } 122 128 123 $(document).ready(function(){ columns.init();});129 $(document).ready(function(){logScript('columns.init()');columns.init();logScript('end columns.init()');}); 124 130 125 131 })(jQuery); 126 132 … … 140 146 } 141 147 }; 142 148 143 jQuery(document).ready( function($) { 149 jQuery(document).ready( function($) {logScript('commons.ready()'); 144 150 var lastClicked = false, checks, first, last, checked; 145 151 146 152 // pulse 147 153 $('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300); 154 logScript("$('.fade').animate"); 148 155 149 156 // Move .updated and .error alert boxes 150 $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2'); 151 $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first'); 157 $('div.wrap').find('h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2'); 158 logScript("$('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2');"); 159 160 $('div.updated, div.error').not('.below-h2').insertAfter($('div.wrap').find('h2:first')); 161 logScript("$('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first');"); 152 162 153 163 // show warnings 154 164 $('#doaction, #doaction2').click(function(){ … … 156 166 return showNotice.warn(); 157 167 } 158 168 }); 169 logScript("$('#doaction, #doaction2').click"); 159 170 160 171 // screen settings tab 161 172 $('#show-settings-link').click(function () { … … 174 185 }); 175 186 return false; 176 187 }); 188 logScript("$('#show-settings-link').click"); 177 189 178 190 // help tab 179 191 $('#contextual-help-link').click(function () { … … 192 204 }); 193 205 return false; 194 206 }); 207 logScript("$('#contextual-help-link').click"); 208 195 209 $('#contextual-help-link-wrap, #screen-options-link-wrap').show(); 210 logScript("$('#contextual-help-link-wrap, #screen-options-link-wrap').show();"); 196 211 197 212 // check all checkboxes 198 $( 'table:visible tbody .check-column :checkbox').click( function(e) {213 $('table:visible').children('tbody').children().children('.check-column').find('input:checkbox').click( function(e) { 199 214 if ( 'undefined' == e.shiftKey ) { return true; } 200 215 if ( e.shiftKey ) { 201 216 if ( !lastClicked ) { return true; } 202 checks = $( lastClicked ).parents( 'form:first' ).find( ' :checkbox' );217 checks = $( lastClicked ).parents( 'form:first' ).find( 'input:checkbox' ); 203 218 first = checks.index( lastClicked ); 204 219 last = checks.index( this ); 205 220 checked = $(this).attr('checked'); … … 215 230 lastClicked = this; 216 231 return true; 217 232 } ); 218 $( 'thead :checkbox, tfoot :checkbox' ).click( function(e) { 233 logScript("$( 'table:visible tbody .check-column :checkbox' ).click"); 234 235 $('thead, tfoot').find('input:checkbox').click( function(e) { 219 236 var c = $(this).attr('checked'), kbtoggle = 'undefined' == typeof toggleWithKeyboard ? false : toggleWithKeyboard, toggle = e.shiftKey || kbtoggle; 220 237 221 238 222 $(this).parents( 'form:first' ).find( 'table tbody:visible' ).find( '.check-column:checkbox' ).attr( 'checked', function() {239 $(this).parents( 'form:first' ).find( 'table' ).children( 'tbody:visible' ).children().children('.check-column').find( 'input:checkbox' ).attr( 'checked', function() { 223 240 if ( $(this).parents('tr').is(':hidden') ) 224 241 return ''; 225 242 if ( toggle ) … … 228 245 return 'checked'; 229 246 return ''; 230 247 }); 231 $(this).parents( 'form:first' ).find( 'table thead:visible, table tfoot:visible').find( '.check-column:checkbox' ).attr( 'checked', function() {248 $(this).parents( 'form:first' ).find('table').children( 'thead:visible, tfoot:visible').children().children('.check-column').find( 'input:checkbox' ).attr( 'checked', function() { 232 249 if ( toggle ) 233 250 return ''; 234 251 else if (c) … … 236 253 return ''; 237 254 }); 238 255 }); 256 logScript("$( 'thead :checkbox, tfoot :checkbox' ).click"); 257 239 258 $('#default-password-nag-no').click( function() { 240 259 setUserSetting('default_password_nag', 'hide'); 241 260 $('div.default-password-nag').hide(); 242 261 return false; 243 262 }); 263 logScript("$('#default-password-nag-no').click"); 244 264 245 265 logScript('end commons.ready()'); 246 266 }); 247 267 248 jQuery(document).ready( function($){ 249 var turboNag = $(' .turbo-nag');268 jQuery(document).ready( function($){logScript('turbo.ready()'); 269 var turboNag = $('span.turbo-nag'); 250 270 251 271 if ( !turboNag.length || ('undefined' != typeof(google) && google.gears) ) 252 272 return; … … 263 283 } 264 284 265 285 turboNag.show(); 266 286 logScript('end turbo.ready()'); 267 287 }); -
wp-admin/js/utils.dev.js
164 164 165 165 return wpCookies.getHash('wp-settings-' + userSettings.uid) || {}; 166 166 } 167 168 169 function logScript(stop) { 170 if ( !window.d ) 171 window.d = new Date(); 172 var d = new Date(); 173 jQuery('body').append('<div>' + ( d.getTime() - window.d.getTime() ) + 'ms -- ' + stop + '</div>'); 174 window.d = d; 175 } 176 No newline at end of file -
wp-admin/js/widgets.dev.js
9 9 if ( $('body').hasClass('widgets_access') ) { 10 10 return; 11 11 } 12 13 $('#widgets-right div.sidebar-name').click(function(){ 14 var c = $(this).siblings('.widgets-sortables'); 12 logScript("$('body').hasClass('widgets_access')"); 13 14 $('#widgets-right').find('div.sidebar-name').click(function(){ 15 var c = $(this).siblings('div.widgets-sortables'); 15 16 if ( c.is(':visible') ) { 16 17 c.sortable('disable'); 17 18 $(this).parent().addClass('closed'); … … 20 21 c.sortable('enable').sortable('refresh'); 21 22 } 22 23 }); 24 logScript("$('#widgets-right div.sidebar-name').click"); 23 25 24 $('#widgets-left 25 if ( $(this).siblings(' .widget-holder').is(':visible') ) {26 $('#widgets-left').find('div.sidebar-name').click(function(){ 27 if ( $(this).siblings('div.widget-holder').is(':visible') ) { 26 28 $(this).parent().addClass('closed'); 27 29 } else { 28 30 $(this).parent().removeClass('closed'); 29 31 } 30 32 }); 33 logScript("$('#widgets-left div.sidebar-name').click"); 31 34 32 $('#widgets-right .widget, #wp_inactive_widgets.widget').each(function(){35 $('#widgets-right, #wp_inactive_widgets').find('div.widget-sortables').children('div.widget').each(function(){ 33 36 wpWidgets.appendTitle(this); 34 37 }); 38 logScript("$('#widgets-right .widget, #wp_inactive_widgets .widget').each"); 35 39 36 40 this.addEvents(); 37 $('.widget-error').parents('.widget').find('a.widget-action').click(); 41 logScript("this.addEvents();"); 42 43 $('.widget-error').parents('div.widget').find('a.widget-action').click(); 44 logScript("$('.widget-error').parents('.widget').find('a.widget-action').click();"); 38 45 39 46 $('#available-widgets').droppable({ 40 47 tolerance: 'pointer', … … 50 57 $('.widget-placeholder').hide(); 51 58 52 59 if ( ui.draggable.hasClass('ui-sortable-helper') ) 53 $('#removing-widget').show().children('span').html( ui.draggable.find(' .widget-titleh4').html() );60 $('#removing-widget').show().children('span').html( ui.draggable.find('div.widget-title').children('h4').html() ); 54 61 }, 55 62 out: function(e,ui) { 56 63 ui.draggable.removeClass('deleting'); … … 58 65 $('#removing-widget').hide().children('span').html(''); 59 66 } 60 67 }); 68 logScript("$('#available-widgets').droppable"); 61 69 62 $('#widget-list 63 connectToSortable: ' .widgets-sortables',64 handle: ' .widget-title',70 $('#widget-list').find('div.widget').draggable({ 71 connectToSortable: 'div.widgets-sortables', 72 handle: 'div.widget-title', 65 73 distance: 2, 66 74 helper: 'clone', 67 75 zIndex: 5, 68 76 containment: 'document', 69 77 start: function(e,ui) { 70 78 wpWidgets.fixWebkit(1); 71 ui.helper.find(' .widget-description').hide();79 ui.helper.find('div.widget-description').hide(); 72 80 }, 73 81 stop: function(e,ui) { 74 82 if ( rem ) … … 77 85 wpWidgets.fixWebkit(); 78 86 } 79 87 }); 80 81 $('.widgets-sortables').sortable({ 88 logScript("$('#widget-list .widget').draggable"); 89 90 $('div.widgets-sortables').sortable({ 82 91 placeholder: 'widget-placeholder', 83 connectWith: '.widgets-sortables', 84 items: '.widget', 85 handle: '.widget-title', 92 items: 'div.widget', 93 handle: 'div.widget-title', 86 94 cursor: 'move', 87 95 distance: 2, 88 96 containment: 'document', 89 97 start: function(e,ui) { 90 98 wpWidgets.fixWebkit(1); 91 ui.item.find(' .widget-inside').hide();99 ui.item.find('div.widget-inside').hide(); 92 100 ui.item.css({'marginLeft':'','width':''}); 93 101 }, 94 102 stop: function(e,ui) { … … 127 135 if ( !$(this).is(':visible') ) 128 136 $(this).sortable('cancel'); 129 137 } 130 }).not(':visible').sortable('disable'); 138 }).sortable('option', 'connectWith', 'div.widgets-sortables').not(':visible').sortable('disable'); 139 logScript("$('.widgets-sortables').sortable"); 140 131 141 wpWidgets.resize(); 142 logScript("wpWidgets.resize();"); 143 132 144 wpWidgets.fixLabels(); 145 logScript("wpWidgets.fixLabels();"); 133 146 }, 134 147 135 148 saveOrder : function(sb) { 136 149 if ( sb ) 137 $('#' + sb).parents(' .widgets-holder-wrap').find('.ajax-feedback').css('visibility', 'visible');150 $('#' + sb).parents('div.widgets-holder-wrap').find('img.ajax-feedback').css('visibility', 'visible'); 138 151 139 152 var a = { 140 153 action: 'widgets-order', … … 142 155 sidebars: [] 143 156 }; 144 157 145 $(' .widgets-sortables').each( function() {158 $('div.widgets-sortables').each( function() { 146 159 a['sidebars[' + $(this).attr('id') + ']'] = $(this).sortable('toArray').join(','); 147 160 }); 148 161 149 162 $.post( ajaxurl, a, function() { 150 $(' .ajax-feedback').css('visibility', 'hidden');163 $('img.ajax-feedback').css('visibility', 'hidden'); 151 164 }); 152 165 this.resize(); 153 166 }, 154 167 155 168 save : function(widget, del, animate, order) { 156 var sb = widget.parents(' .widgets-sortables').attr('id'), data = widget.find('form').serialize(), a;169 var sb = widget.parents('div.widgets-sortables').attr('id'), data = widget.find('form').serialize(), a; 157 170 widget = $(widget); 158 171 widget.find('.ajax-feedback').css('visibility', 'visible'); 159 172 … … 172 185 var id; 173 186 174 187 if ( del ) { 175 if ( !$(' .widget_number', widget).val() ) {176 id = $(' .widget-id', widget).val();177 $('#available-widgets 188 if ( !$('input.widget_number', widget).val() ) { 189 id = $('input.widget-id', widget).val(); 190 $('#available-widgets').find('input.widget-id').each(function(){ 178 191 if ( $(this).val() == id ) 179 $(this).parents(' .widget').show();192 $(this).parents('div.widget').show(); 180 193 }); 181 194 } 182 195 … … 193 206 } else { 194 207 $('.ajax-feedback').css('visibility', 'hidden'); 195 208 if ( r && r.length > 2 ) { 196 $(' .widget-content', widget).html(r);209 $('div.widget-content', widget).html(r); 197 210 wpWidgets.appendTitle(widget); 198 211 wpWidgets.fixLabels(widget); 199 212 } … … 209 222 if ( this.id.indexOf('title') != -1 ) { 210 223 title = $(this).val().replace(/<[^<>]+>/g, '').replace(/</g, '<').replace(/>/g, '>'); 211 224 if ( title ) 212 $(' .widget-title .in-widget-title', widget).html(': ' + title);225 $('div.widget-title', widget).find('span.in-widget-title').html(': ' + title); 213 226 return false; 214 227 } 215 228 }); 216 229 }, 217 230 218 231 resize : function() { 219 $(' .widgets-sortables').not('#wp_inactive_widgets').each(function(){220 var h = 50, H = $(' .widget', this).length;232 $('div.widgets-sortables').not('#wp_inactive_widgets').each(function(){ 233 var h = 50, H = $('div.widget', this).length; 221 234 h = h + parseInt(H * 48, 10); 222 235 $(this).css( 'minHeight', h + 'px' ); 223 236 }); … … 234 247 fixLabels : function(sc) { 235 248 sc = sc || document; 236 249 237 $(' .widget-inside label', sc).each(function(){250 $('textarea', sc).parents('label').each(function(){ 238 251 var f = $(this).attr('for'); 239 252 240 253 if ( f && f == $('input', this).attr('id') ) … … 243 256 }, 244 257 245 258 close : function(widget) { 246 widget.find(' .widget-inside').slideUp('fast', function(){259 widget.find('div.widget-inside').slideUp('fast', function(){ 247 260 widget.css({'width':'','marginLeft':''}); 248 261 }); 249 262 }, 250 263 251 264 addEvents : function(sc) { 252 265 sc = sc || document; 266 253 267 $('a.widget-action', sc).click(function(){ 254 var w = parseInt( $(this).parents(' .widget').find('.widget-width').val(), 10 ), css = {}, inside = $(this).parents('.widget-top').siblings('.widget-inside');268 var w = parseInt( $(this).parents('div.widget').find('input.widget-width').val(), 10 ), css = {}, inside = $(this).parents('div.widget-top').siblings('div.widget-inside'); 255 269 if ( inside.is(':hidden') ) { 256 if ( w > 250 && inside.parents(' .widgets-sortables').length ) {270 if ( w > 250 && inside.parents('div.widgets-sortables').length ) { 257 271 css['width'] = w + 30 + 'px'; 258 if ( inside.parents(' .widget-liquid-right').length )272 if ( inside.parents('div.widget-liquid-right').length ) 259 273 css['marginLeft'] = 235 - w + 'px'; 260 inside.parents(' .widget').css(css);274 inside.parents('div.widget').css(css); 261 275 } 262 276 inside.slideDown('fast'); 263 277 } else { 264 inside.slideUp('fast', function(){ inside.parents(' .widget').css({'width':'','marginLeft':''}); });278 inside.slideUp('fast', function(){ inside.parents('div.widget').css({'width':'','marginLeft':''}); }); 265 279 } 266 280 return false; 267 281 }); 268 $(' .widget-control-save', sc).click(function(){269 wpWidgets.save( $(this).parents(' .widget'), 0, 1, 0 );282 $('input.widget-control-save', sc).click(function(){ 283 wpWidgets.save( $(this).parents('div.widget'), 0, 1, 0 ); 270 284 return false; 271 285 }); 272 $(' .widget-control-remove', sc).click(function(){273 wpWidgets.save( $(this).parents(' .widget'), 1, 1, 0 );286 $('a.widget-control-remove', sc).click(function(){ 287 wpWidgets.save( $(this).parents('div.widget'), 1, 1, 0 ); 274 288 return false; 275 289 }); 276 $(' .widget-control-close', sc).click(function(){277 wpWidgets.close( $(this).parents(' .widget') );290 $('a.widget-control-close', sc).click(function(){ 291 wpWidgets.close( $(this).parents('div.widget') ); 278 292 return false; 279 293 }); 280 294 } 281 295 }; 282 $(document).ready(function(){ wpWidgets.init();});296 $(document).ready(function(){logScript('widgets.init()');wpWidgets.init();logScript('end widgets.init()');}); 283 297 284 298 })(jQuery);