Ticket #13220: 13220.select.all.1.patch
File 13220.select.all.1.patch, 2.8 KB (added by , 14 years ago) |
---|
-
wp-admin/js/nav-menu.dev.js
146 146 }); 147 147 }); 148 148 }, 149 selectItem : function() { 150 return this.each(function(){ 151 $(this).addClass('selected-menu-item') 152 .next().children('input').attr('checked','checked'); 153 }); 154 }, 155 deselectItem : function() { 156 return this.each(function(){ 157 $(this).removeClass('selected-menu-item') 158 .next().children('input').removeAttr('checked'); 159 }); 160 }, 161 toggleItem : function() { 162 return this.each(function(){ 163 var t = $(this); 164 if( t.hasClass('selected-menu-item') ) 165 t.deselectItem(); 166 else 167 t.selectItem(); 168 }); 169 } 149 170 }); 150 171 151 172 return { … … 309 330 }, 310 331 311 332 initAddMenuItemDraggables : function() { 312 $.fn.extend({313 checkItem : function() {314 return this.each(function(){315 $(this).addClass('selected-menu-item')316 .next().children('input').attr('checked','checked');317 });318 },319 uncheckItem : function() {320 return this.each(function(){321 $(this).removeClass('selected-menu-item')322 .next().children('input').removeAttr('checked');323 });324 },325 toggleItem : function() {326 return this.each(function(){327 var t = $(this);328 if( t.hasClass('selected-menu-item') )329 t.uncheckItem();330 else331 t.checkItem();332 });333 }334 });335 336 333 var menuItems = $('.potential-menu-item'); 337 334 menuItems.click(function(e){ 338 335 $(this).toggleItem(); … … 348 345 items; 349 346 350 347 // Make sure the item we're dragging is selected. 351 item. checkItem();348 item.selectItem(); 352 349 // Set us to be the ajax target 353 350 targetList = target.children('.menu-item-transport'); 354 351 // Get all checked elements and assemble selected items. … … 375 372 stop: function(e, ui) { 376 373 // Reset the targetList and unselect the menu items 377 374 targetList = menuList; 378 menuItems.filter('.selected-menu-item'). uncheckItem();375 menuItems.filter('.selected-menu-item').deselectItem(); 379 376 } 380 377 }); 381 378 }, … … 553 550 554 551 return false; 555 552 } else if ( e.target && e.target.className && -1 != e.target.className.indexOf('select-all') ) { 556 var selectAreaMatch = /#(.*)$/.exec(e.target.href) ;553 var selectAreaMatch = /#(.*)$/.exec(e.target.href), items; 557 554 if ( selectAreaMatch && selectAreaMatch[1] ) { 558 $('#' + selectAreaMatch[1] + ' .tabs-panel-active input[type=checkbox]').attr('checked', 'checked'); 555 items = $('#' + selectAreaMatch[1] + ' .tabs-panel-active .potential-menu-item'); 556 if( items.length === items.filter('.selected-menu-item').length ) 557 items.deselectItem(); 558 else 559 items.selectItem(); 559 560 return false; 560 561 } 561 562 }