Changeset 14740
- Timestamp:
- 05/19/2010 08:44:28 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/js/nav-menu.dev.js
r14725 r14740 12 12 13 13 (function($) { 14 14 15 15 var api = wpNavMenu = { 16 16 17 17 options : { 18 18 menuItemDepthPerLevel : 30, // Do not use directly. Use depthToPx and pxToDepth instead. 19 19 globalMaxDepth : 11 20 20 }, 21 21 22 22 menuList : undefined, // Set in init. 23 23 targetList : undefined, // Set in init. … … 29 29 30 30 this.jQueryExtensions(); 31 31 32 32 this.attachMenuEditListeners(); 33 33 34 34 this.setupInputWithDefaultTitle(); 35 35 this.attachAddMenuItemListeners(); … … 48 48 this.initTabManager(); 49 49 }, 50 50 51 51 jQueryExtensions : function() { 52 52 // jQuery extensions … … 172 172 173 173 transport = ui.item.children('.menu-item-transport'); 174 174 175 175 // Set depths. currentDepth must be set before children are located. 176 176 originalDepth = ui.item.menuItemDepth(); 177 177 updateCurrentDepth(ui, originalDepth); 178 178 179 179 // Attach child elements to parent 180 180 // Skip the placeholder … … 202 202 width -= 2; // Subtract 2 for borders 203 203 ui.placeholder.width(width); 204 204 205 205 // Update the list of menu items. 206 206 tempHolder = ui.placeholder.next(); … … 210 210 ui.item.after( ui.placeholder ); // reattach the placeholder. 211 211 tempHolder.css('margin-top', 0); // reset the margin 212 212 213 213 // Now that the element is complete, we can update... 214 214 updateSharedVars(ui); … … 219 219 // Return child elements to the list 220 220 children = transport.children().insertAfter(ui.item); 221 221 222 222 // Update depth classes 223 223 if( depthChange != 0 ) { … … 247 247 if( depth != currentDepth ) 248 248 updateCurrentDepth(ui, depth); 249 249 250 250 // If we overlap the next element, manually shift downwards 251 251 if( nextThreshold && offset.top + helperHeight > nextThreshold ) { … … 259 259 function updateSharedVars(ui) { 260 260 var depth; 261 261 262 262 prev = ui.placeholder.prev(); 263 263 next = ui.placeholder.next(); … … 332 332 attachAddMenuItemListeners : function() { 333 333 var form = $('#nav-menu-meta'); 334 334 335 335 form.find('.add-to-menu input').click(function(){ 336 336 $(this).trigger('wp-add-menu-item', [api.addMenuItemToBottom]); … … 344 344 }); 345 345 }, 346 346 347 347 attachThemeLocationsListeners : function() { 348 348 var loc = $('#nav-menu-theme-locations'), … … 360 360 }); 361 361 }, 362 362 363 363 attachQuickSearchListeners : function() { 364 364 var searchTimer; 365 365 366 366 $('.quick-search').keypress(function(e){ 367 367 var t = $(this); 368 368 369 369 if( 13 == e.which ) { 370 370 api.updateQuickSearchResults( t ); 371 371 return false; 372 372 } 373 373 374 374 if( searchTimer ) clearTimeout(searchTimer); 375 375 376 376 searchTimer = setTimeout(function(){ 377 377 api.updateQuickSearchResults( t ); … … 379 379 }).attr('autocomplete','off'); 380 380 }, 381 381 382 382 updateQuickSearchResults : function(input) { 383 383 var panel, params, 384 384 minSearchLength = 2, 385 385 q = input.val(); 386 386 387 387 if( q.length < minSearchLength ) return; 388 388 389 389 panel = input.parents('.tabs-panel'); 390 390 params = { … … 403 403 }); 404 404 }, 405 405 406 406 addCustomLink : function( processMethod ) { 407 407 var url = $('#custom-menu-item-url').val(), 408 408 label = $('#custom-menu-item-name').val(); 409 409 410 410 processMethod = processMethod || api.addMenuItemToBottom; 411 411 412 412 if ( '' == url || 'http://' == url ) 413 413 return false; 414 414 415 415 // Show the ajax spinner 416 416 $('.customlinkdiv img.waiting').show(); … … 423 423 }); 424 424 }, 425 425 426 426 addLinkToMenu : function(url, label, processMethod, callback) { 427 427 processMethod = processMethod || api.addMenuItemToBottom; 428 428 callback = callback || function(){}; 429 429 430 430 api.addItemToMenu({ 431 431 '-1': { … … 436 436 }, processMethod, callback); 437 437 }, 438 438 439 439 addItemToMenu : function(menuItem, processMethod, callback) { 440 440 var menu = $('#menu').val(), 441 441 nonce = $('#menu-settings-column-nonce').val(); 442 442 443 443 processMethod = processMethod || function(){}; 444 444 callback = callback || function(){}; 445 445 446 446 params = { 447 447 'action': 'add-menu-item', … … 450 450 'menu-item': menuItem 451 451 }; 452 452 453 453 $.post( ajaxurl, params, function(menuMarkup) { 454 454 processMethod(menuMarkup, params); … … 466 466 $(menuMarkup).hideAdvancedMenuItemFields().appendTo( api.targetList ); 467 467 }, 468 468 469 469 addMenuItemToTop : function( menuMarkup, req ) { 470 470 $(menuMarkup).hideAdvancedMenuItemFields().prependTo( api.targetList ); 471 471 }, 472 472 473 473 attachHomeLinkListener : function() { 474 474 $('.add-home-link', '.customlinkdiv').click(function(e) { … … 482 482 var selectAreaMatch, activePanel, panelId, wrapper, items, 483 483 target = $(e.target); 484 484 485 485 if ( target.hasClass('nav-tab-link') ) { 486 486 panelId = /#(.*)$/.exec(e.target.href); … … 489 489 else 490 490 return false; 491 491 492 492 wrapper = target.parents('.inside').first(); 493 493 494 494 // upon changing tabs, we want to uncheck all checkboxes 495 495 $('input', wrapper).removeAttr('checked'); 496 496 497 497 $('.tabs-panel-active', wrapper).removeClass('tabs-panel-active').addClass('tabs-panel-inactive'); 498 498 $('#' + panelId, wrapper).removeClass('tabs-panel-inactive').addClass('tabs-panel-active'); … … 707 707 items = resp.match(/<li>.*<\/li>/g); 708 708 709 if( ! items ) { 709 if( ! items ) { 710 710 $('.categorychecklist', panel).html( '<li><p>' + navMenuL10n.noResultsFound + '</p></li>' ); 711 711 $('img.waiting', panel).hide();
Note: See TracChangeset
for help on using the changeset viewer.