2010-02-20 22:57:43 +01:00
|
|
|
/**
|
|
|
|
* WordPress Administration Custom Navigation
|
2010-02-28 00:06:56 +01:00
|
|
|
* Interface $ functions
|
2010-02-20 22:57:43 +01:00
|
|
|
*
|
2010-02-28 00:06:56 +01:00
|
|
|
* @version 2.0.0
|
2010-02-20 22:57:43 +01:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
/**
|
2010-02-20 22:57:43 +01:00
|
|
|
* Init Functions
|
2010-02-28 00:06:56 +01:00
|
|
|
*/
|
|
|
|
jQuery(document).ready(function($){
|
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
wp_drag_and_drop();
|
|
|
|
|
|
|
|
wp_update_post_data();
|
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
// Handle Save Button Clicks
|
|
|
|
$('#save_menu').click(function(){
|
2010-02-28 21:00:49 +01:00
|
|
|
return wp_update_post_data();
|
2010-02-28 00:06:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Clear the quick search textbox
|
|
|
|
$('.quick-search').click(function(){
|
|
|
|
$(this).attr( 'value', '' );
|
|
|
|
});
|
|
|
|
|
|
|
|
// Quick Search submit
|
|
|
|
$('.quick-search-submit').click(function(){
|
|
|
|
$(this).siblings('.quick-search').search();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Edit menu item
|
|
|
|
$('#menu-container .item-edit').click(function(){
|
2010-02-28 21:00:49 +01:00
|
|
|
return wp_edit_menu_item( $(this).attr('value') );
|
2010-02-28 00:06:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Delete menu item
|
|
|
|
$('#menu-container .item-delete').live( 'click', function(){
|
2010-02-28 21:00:49 +01:00
|
|
|
return wp_remove_menu_item( $(this).attr('value') );
|
2010-02-28 00:06:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Update menu item settings (thickbox)
|
|
|
|
$('#update-menu-item').click(function(){
|
|
|
|
wp_update_menu_item();
|
|
|
|
tb_remove();
|
|
|
|
|
|
|
|
// Give feedback to the user
|
|
|
|
var id = $('#edit-item-id').val();
|
|
|
|
$('#menu-' + id + ' dt:first').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Close thickbox
|
|
|
|
$('#cancel-save').click(function(){
|
2010-02-28 21:00:49 +01:00
|
|
|
return tb_remove();
|
2010-02-28 00:06:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Show All Button
|
|
|
|
$('.show-all').click(function(){
|
|
|
|
$(this).offsetParent().find('#add-buttons-actions').attr( 'style','margin-bottom: 10px;' );
|
|
|
|
$(this).offsetParent().find('.list-wrap').css( 'display','block' );
|
|
|
|
$(this).siblings('.quick-search').attr( 'value', '' );
|
2010-02-28 21:00:49 +01:00
|
|
|
$(this).offsetParent().find('.list-wrap li').css( 'display', 'block' );
|
2010-02-28 00:06:56 +01:00
|
|
|
$(this).hide();
|
|
|
|
$(this).siblings('.hide-all').show();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Hide All Button
|
|
|
|
$('.hide-all').click(function(){
|
|
|
|
$(this).offsetParent().find('#add-buttons-actions').attr( 'style','margin-bottom: 0px;' );
|
|
|
|
$(this).offsetParent().find('.list-wrap').css( 'display','none' );
|
|
|
|
$(this).siblings('.quick-search').attr( 'value', 'Search' );
|
2010-02-28 21:00:49 +01:00
|
|
|
$(this).offsetParent().find('.list-wrap li').css( 'display', 'none' );
|
2010-02-28 00:06:56 +01:00
|
|
|
$(this).hide();
|
|
|
|
$(this).siblings('.show-all').show();
|
|
|
|
});
|
2010-03-12 22:57:52 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
// Add menu item to queue
|
|
|
|
$('.list input').click(function(){
|
2010-03-12 22:57:52 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
var item_type = jQuery(this).parent().siblings('.item-type').val();
|
|
|
|
var item_title = jQuery(this).parent().siblings('.item-title').val();
|
|
|
|
var item_url = jQuery(this).parent().siblings('.item-url').val();
|
2010-03-10 21:27:42 +01:00
|
|
|
var item_id = jQuery(this).parent().siblings('.item-dbid').val();
|
|
|
|
var item_parent_id = jQuery(this).parent().siblings('.item-parent').val();
|
2010-02-28 21:00:49 +01:00
|
|
|
var item_description = jQuery(this).parent().siblings('.item-description').val();
|
|
|
|
|
|
|
|
return wp_update_queue( $(this), item_type, item_title, item_url, item_id, item_parent_id, item_description );
|
|
|
|
});
|
2010-03-12 22:57:52 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
// Add queued menu items into the menu
|
|
|
|
$('.enqueue a').click(function(){
|
2010-02-28 21:00:49 +01:00
|
|
|
return wp_add_queued_items_to_menu(this);
|
2010-02-28 00:06:56 +01:00
|
|
|
});
|
2010-03-12 22:57:52 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
// Create the link, add it to the menu + available links section
|
|
|
|
$('#add-custom-link .add-to-menu a').click(function(){
|
|
|
|
var link_url = $(this).offsetParent().find('#menu-item-url').val();
|
|
|
|
var link_name = $(this).offsetParent().find('#menu-item-name').val();
|
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
wp_add_queued_items_to_menu( this );
|
2010-02-28 00:06:56 +01:00
|
|
|
|
|
|
|
// Don't save the link if it was left with it's default settings
|
|
|
|
if ( 'http://' == link_url || 'Menu Item' == link_name )
|
|
|
|
return;
|
2010-03-12 22:57:52 +01:00
|
|
|
|
|
|
|
// and update the Menu with the new link
|
|
|
|
wp_add_item_to_menu( 'custom', link_name, link_url, 0, 0, '' );
|
2010-02-28 00:06:56 +01:00
|
|
|
});
|
|
|
|
});
|