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();
|
|
|
|
|
2010-03-15 17:26:46 +01:00
|
|
|
// Delete AYS
|
|
|
|
$('#update-nav-menu .deletion').click(function(){
|
|
|
|
if ( confirm( navMenuL10n.warnDelete ) ) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
});
|
2010-02-28 21:00:49 +01:00
|
|
|
|
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
|
|
|
});
|
2010-03-15 17:26:46 +01:00
|
|
|
|
|
|
|
// close postboxes that should be closed
|
|
|
|
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
|
|
|
|
|
|
|
// postboxes setup
|
|
|
|
postboxes.add_postbox_toggles('menus');
|
|
|
|
|
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
|
2010-03-15 17:26:46 +01:00
|
|
|
$('#menu-container .item-delete').live( 'click', function(e){
|
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();
|
2010-03-15 17:26:46 +01:00
|
|
|
return tb_remove();
|
2010-02-28 00:06:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// 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
|
2010-03-15 17:26:46 +01:00
|
|
|
$('.show-all').click(function(e){
|
|
|
|
jQuery(e.currentTarget).parent().siblings('.list-wrap').css( 'display', 'block' );
|
|
|
|
jQuery(e.currentTarget).parent().siblings('.list-wrap').find('li').css( 'display', 'block' );
|
|
|
|
jQuery(e.currentTarget).hide();
|
|
|
|
jQuery(e.currentTarget).siblings('.hide-all').show();
|
2010-02-28 00:06:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Hide All Button
|
2010-03-15 17:26:46 +01:00
|
|
|
$('.hide-all').click(function(e){
|
|
|
|
jQuery(e.currentTarget).parent().siblings('.list-wrap').css( 'display', 'none' );
|
|
|
|
jQuery(e.currentTarget).parent().siblings('.list-wrap').find('li').css( 'display', 'none' );
|
|
|
|
jQuery(e.currentTarget).hide();
|
|
|
|
jQuery(e.currentTarget).siblings('.show-all').show();
|
2010-02-28 21:00:49 +01:00
|
|
|
});
|
2010-03-12 22:57:52 +01:00
|
|
|
|
2010-03-15 17:26:46 +01:00
|
|
|
// Add menu items into the menu
|
|
|
|
$('.add-to-menu').click(function(e){
|
|
|
|
return wp_add_checked_items_to_menu(e.currentTarget);
|
2010-02-28 00:06:56 +01:00
|
|
|
});
|
2010-03-12 22:57:52 +01:00
|
|
|
|
2010-03-15 17:26:46 +01:00
|
|
|
// Create a new link then add it to the menu
|
|
|
|
$('#add-custom-links .add-to-menu a').click(function(e){
|
|
|
|
var link_url = jQuery(e.currentTarget).parent().parent().find('#custom-menu-item-url').val();
|
|
|
|
var link_name = jQuery(e.currentTarget).parent().parent().find('#custom-menu-item-name').val();
|
2010-02-28 00:06:56 +01:00
|
|
|
|
2010-03-15 17:26:46 +01:00
|
|
|
// Add link to menu
|
|
|
|
wp_add_item_to_menu( 0, '', 'custom', navMenuL10n.custom, 0, link_name, link_url, '', '', '_none', '', '' );
|
2010-02-28 00:06:56 +01:00
|
|
|
});
|
|
|
|
});
|