2010-02-20 22:57:43 +01:00
|
|
|
/**
|
|
|
|
* WordPress Administration Custom Navigation
|
|
|
|
* Interface JS functions
|
|
|
|
*
|
|
|
|
* @version 1.1.0
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
/**
|
|
|
|
* Adds a link to the available links section
|
|
|
|
*
|
|
|
|
* @param object e - An object recieved via ajax
|
|
|
|
*/
|
|
|
|
function wp_update_links_list(e) {
|
|
|
|
var link = '<li><dl><dt><label class="item-title"><input type="checkbox" id="link-'+ e.link_id +'" name="'+ e.link_name +'" value="'+ e.link_url +'" />'+ e.link_name +'</label></dt></dl></li>';
|
|
|
|
|
|
|
|
// Prepend the link to the available links section
|
|
|
|
jQuery('#available-links .list').prepend( link );
|
|
|
|
|
|
|
|
// Give feedback to the user
|
|
|
|
jQuery('#available-links .list #link-' + e.link_id).parent().animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
|
|
|
|
}
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
/**
|
|
|
|
* Populate the thickbox window with the selected menu items
|
|
|
|
*
|
2010-02-20 22:57:43 +01:00
|
|
|
* @param int o - the id of the menu li to edit.
|
2010-02-28 00:06:56 +01:00
|
|
|
*/
|
|
|
|
function wp_edit_menu_item( id ) {
|
2010-02-28 21:00:49 +01:00
|
|
|
var itemType = jQuery('#item-type' + id).val();
|
2010-02-28 00:06:56 +01:00
|
|
|
var itemTitle = jQuery('#item-title' + id).val();
|
|
|
|
var itemURL = jQuery('#item-url' + id).val();
|
|
|
|
var itemAttrTitle = jQuery('#item-attr-title' + id).val();
|
|
|
|
var itemTarget = jQuery('#item-target' + id).val();
|
|
|
|
var itemDesc = jQuery('#item-description' + id).val();
|
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
// Disable the ability to edit the url for page and category items
|
|
|
|
if ( 'page' == itemType || 'category' == itemType )
|
|
|
|
jQuery( '#edit-item-url' ).attr('disabled', 'disabled' );
|
2010-02-28 00:06:56 +01:00
|
|
|
|
|
|
|
// Populate the fields for thickbox
|
|
|
|
jQuery( '#edit-item-id' ).val(id);
|
|
|
|
jQuery( '#edit-item-title' ).val(itemTitle);
|
|
|
|
jQuery( '#edit-item-url' ).val(itemURL);
|
|
|
|
jQuery( '#edit-item-attr-title' ).val(itemAttrTitle);
|
|
|
|
jQuery( '#edit-item-target' ).val(itemTarget);
|
|
|
|
jQuery( "#edit-item-target option[value='" + itemTarget + "']" ).attr('selected', 'selected');
|
|
|
|
jQuery( '#edit-item-description' ).val(itemDesc);
|
2010-02-20 22:57:43 +01:00
|
|
|
};
|
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
/**
|
|
|
|
* Update the values for the menu item being editing
|
|
|
|
*/
|
|
|
|
function wp_update_menu_item() {
|
|
|
|
var id = jQuery('#edit-item-id').val();
|
|
|
|
var itemTitle = jQuery('#edit-item-title').val();
|
|
|
|
var itemURL = jQuery('#edit-item-url').val();
|
|
|
|
var itemAttrTitle = jQuery('#edit-item-attr-title').val();
|
|
|
|
var itemTarget = jQuery('#edit-item-target').val();
|
|
|
|
var itemDesc = jQuery('#edit-item-description').val();
|
|
|
|
|
|
|
|
// update menu item settings
|
|
|
|
jQuery('#menu-' + id).find('.item-title:first').html(itemTitle);
|
|
|
|
jQuery('#item-title' + id).val(itemTitle);
|
|
|
|
jQuery('#item-url' + id).val(itemURL);
|
|
|
|
jQuery('#item-attr-title' + id).val(itemAttrTitle);
|
|
|
|
jQuery('#item-target' + id).val(itemTarget);
|
|
|
|
jQuery('#item-description' + id).val(itemDesc);
|
|
|
|
}
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
/**
|
|
|
|
* Removes a menu item from current menu
|
|
|
|
*
|
|
|
|
* @param int o - the id of the menu li to remove.
|
|
|
|
*/
|
|
|
|
function wp_remove_menu_item( o ) {
|
|
|
|
var todelete = document.getElementById('menu-' + o);
|
|
|
|
|
|
|
|
if ( todelete ) {
|
|
|
|
// Give some feedback to the user
|
|
|
|
jQuery( todelete ).find('dt').each(function(){
|
|
|
|
jQuery(this).animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { jQuery(this).parent().parent().remove() } } );
|
|
|
|
});
|
|
|
|
|
|
|
|
wp_update_post_data();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
/**
|
|
|
|
* Prepares menu items for POST
|
|
|
|
*/
|
|
|
|
function wp_update_post_data() {
|
2010-02-20 22:57:43 +01:00
|
|
|
var i = 0;
|
2010-02-28 00:06:56 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery('.menu li').each(function(i) {
|
2010-02-20 22:57:43 +01:00
|
|
|
i = i + 1;
|
2010-02-21 00:58:00 +01:00
|
|
|
var j = jQuery(this).attr('value');
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery(this).find('#item-position' + j).attr('value', i);
|
2010-02-21 00:58:00 +01:00
|
|
|
jQuery(this).attr('id','menu-' + i);
|
|
|
|
jQuery(this).attr('value', i);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery(this).find('#item-dbid' + j).attr('name','item-dbid' + i);
|
|
|
|
jQuery(this).find('#item-dbid' + j).attr('id','item-dbid' + i);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery(this).find('#item-postmenu' + j).attr('name','item-postmenu' + i);
|
|
|
|
jQuery(this).find('#item-postmenu' + j).attr('id','item-postmenu' + i);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
var p = jQuery(this).find('#item-parent' + j).parent().parent().parent().attr('value');
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery(this).find('#item-parent' + j).attr('name','item-parent' + i);
|
|
|
|
jQuery(this).find('#item-parent' + j).attr('id','item-parent' + i);
|
2010-02-28 00:06:56 +01:00
|
|
|
|
|
|
|
if (p) {
|
|
|
|
// Do nothing
|
|
|
|
} else {
|
|
|
|
// reset p to be top level
|
|
|
|
p = 0;
|
|
|
|
}
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery(this).find('#item-parent' + j).attr('value', p);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
jQuery(this).find('#item-title' + j).attr('name','item-title' + i);
|
|
|
|
jQuery(this).find('#item-title' + j).attr('id','item-title' + i);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
jQuery(this).find('#item-url' + j).attr('name','item-url' + i);
|
|
|
|
jQuery(this).find('#item-url' + j).attr('id','item-url' + i);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
jQuery(this).find('#item-description' + j).attr('name','item-description' + i);
|
|
|
|
jQuery(this).find('#item-description' + j).attr('id','item-description' + i);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
jQuery(this).find('#item-attr-title' + j).attr('name','item-attr-title' + i);
|
|
|
|
jQuery(this).find('#item-attr-title' + j).attr('id','item-attr-title' + i);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
jQuery(this).find('#item-target' + j).attr('name','item-target' + i);
|
|
|
|
jQuery(this).find('#item-target' + j).attr('id','item-target' + i);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery(this).find('#item-position' + j).attr('name', 'item-position' + i);
|
|
|
|
jQuery(this).find('#item-position' + j).attr('id', 'item-position' + i);
|
2010-02-20 22:57:43 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery(this).find('#item-type' + j).attr('name', 'item-type' + i);
|
|
|
|
jQuery(this).find('#item-type' + j).attr('id', 'item-type' + i);
|
2010-02-20 22:57:43 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
jQuery('#li-count').attr( 'value', i );
|
2010-02-20 22:57:43 +01:00
|
|
|
});
|
2010-02-28 00:06:56 +01:00
|
|
|
};
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
/**
|
|
|
|
* Adds the item to the menu
|
|
|
|
*
|
|
|
|
* @param string id - The menu item's id
|
|
|
|
* @param string additemtype - Page, Category, or Custom.
|
|
|
|
* @param string itemtext - menu text.
|
|
|
|
* @param string itemurl - url of the menu.
|
|
|
|
* @param int itemid - menu id.
|
|
|
|
* @param int itemparentid - default 0.
|
|
|
|
* @param string itemdescription - the description of the menu item.
|
|
|
|
*/
|
2010-02-28 21:00:49 +01:00
|
|
|
function wp_add_item_to_menu( item_type, item_title, item_url, item_id, item_parent_id, item_description ) {
|
2010-02-28 00:06:56 +01:00
|
|
|
var randomnumber = wp_get_unique_menu_id();
|
|
|
|
|
|
|
|
// Adds the item in the queue
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery('.menu').append('<li id="menu-' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + item_title + '</span><span class="item-controls"><span class="item-type">' + item_type + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onClick="wp_edit_menu_item('+ randomnumber +')" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'">Delete</a></span></dt></dl><input type="hidden" name="item-postmenu' + randomnumber + '" id="item-postmenu' + randomnumber + '" value="' + item_id + '" /><input type="hidden" name="item-parent' + randomnumber + '" id="item-parent' + randomnumber + '" value="' + item_parent_id + '" /><input type="hidden" name="item-title' + randomnumber + '" id="item-title' + randomnumber + '" value="' + item_title + '" /><input type="hidden" name="item-url' + randomnumber + '" id="item-url' + randomnumber + '" value="' + item_url + '" /><input type="hidden" name="item-description' + randomnumber + '" id="item-description' + randomnumber + '" value="' + item_description + '" /><input type="hidden" name="item-position' + randomnumber + '" id="item-position' + randomnumber + '" value="' + randomnumber + '" /><input type="hidden" name="item-type' + randomnumber + '" id="item-type' + randomnumber + '" value="' + item_type + '" /><input type="hidden" name="item-attr-title' + randomnumber + '" id="item-attr-title' + randomnumber + '" value="' + item_title + '" /><input type="hidden" name="item-target' + randomnumber + '" id="item-target' + randomnumber + '" value="0" /></li>');
|
2010-02-28 00:06:56 +01:00
|
|
|
|
|
|
|
// Give some feedback to the user
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery( '.menu #menu-' + randomnumber + ' dt:first' ).animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
|
2010-02-28 00:06:56 +01:00
|
|
|
|
|
|
|
// Enable drag-n-drop
|
|
|
|
wp_drag_and_drop();
|
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
wp_update_post_data();
|
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
// Reload thickbox
|
|
|
|
tb_init('a.thickbox, area.thickbox, input.thickbox');
|
2010-02-21 01:03:42 +01:00
|
|
|
};
|
2010-02-20 22:57:43 +01:00
|
|
|
|
|
|
|
/*
|
2010-02-28 00:06:56 +01:00
|
|
|
* Queues items in perperation for appendToList
|
|
|
|
*
|
2010-02-28 21:00:49 +01:00
|
|
|
* @param string type - Page, Category, or Custom.
|
|
|
|
* @param string link - menu text.
|
|
|
|
* @param string url - url of the menu.
|
|
|
|
* @param int id - menu id.
|
|
|
|
* @param int parent_id - default 0.
|
|
|
|
* @param string description - the description of the menu item.
|
2010-02-21 01:03:42 +01:00
|
|
|
*/
|
2010-02-28 21:00:49 +01:00
|
|
|
function wp_update_queue( e, item_type, item_title, item_url, item_id, item_parent_id, item_description ) {
|
2010-02-28 00:06:56 +01:00
|
|
|
var randomnumber = wp_get_unique_menu_id();
|
2010-02-28 21:00:49 +01:00
|
|
|
var menu_item_id = jQuery(e).attr('id');
|
|
|
|
|
|
|
|
if ( jQuery(e).attr('checked') ) {
|
2010-02-28 00:06:56 +01:00
|
|
|
// Add menu item to the queue
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery('#queue').append('<li id="menu-' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + item_title + '</span><span class="item-controls"><span class="item-type">' + item_type + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onClick="wp_edit_menu_item('+ randomnumber +')" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'">Delete</a></span></dt></dl><input type="hidden" name="item-postmenu' + randomnumber + '" id="item-postmenu' + randomnumber + '" value="' + item_id + '" /><input type="hidden" name="item-parent' + randomnumber + '" id="item-parent' + randomnumber + '" value="' + item_parent_id + '" /><input type="hidden" name="item-title' + randomnumber + '" id="item-title' + randomnumber + '" value="' + item_title + '" /><input type="hidden" name="item-url' + randomnumber + '" id="item-url' + randomnumber + '" value="' + item_url + '" /><input type="hidden" name="item-description' + randomnumber + '" id="item-description' + randomnumber + '" value="' + item_description + '" /><input type="hidden" name="item-position' + randomnumber + '" id="item-position' + randomnumber + '" value="' + randomnumber + '" /><input type="hidden" name="item-type' + randomnumber + '" id="item-type' + randomnumber + '" value="' + item_type + '" /><input type="hidden" name="item-attr-title' + randomnumber + '" id="item-attr-title' + randomnumber + '" value="' + item_title + '" /><input type="hidden" name="item-target' + randomnumber + '" id="item-target' + randomnumber + '" value="0" /><input type="hidden" name="item-id' + randomnumber + '" id="item-id' + randomnumber + '" value="'+ menu_item_id +'" /></li>');
|
2010-02-28 00:06:56 +01:00
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
} else {
|
|
|
|
// Remove the item from the queue
|
|
|
|
if ( menu_item_id == jQuery('#queue li input[name^="item-id"]' ).val() ) {
|
|
|
|
jQuery('#queue li input[name^="item-id"]' ).parent().remove()
|
2010-02-28 00:06:56 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
/**
|
|
|
|
* Grabs items from the queue and adds them to the menu.
|
|
|
|
*
|
|
|
|
* @param string button - a reference of the button that was clicked
|
|
|
|
*/
|
|
|
|
function wp_add_queued_items_to_menu( button ) {
|
|
|
|
// Grab items in queue
|
|
|
|
var items = jQuery('#queue').children();
|
|
|
|
|
|
|
|
// Empty Queue
|
|
|
|
jQuery('#queue').empty();
|
|
|
|
|
|
|
|
// Appends HTML to the menu
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery('.menu').append( items );
|
2010-02-28 00:06:56 +01:00
|
|
|
|
|
|
|
// Give some feedback to the user
|
|
|
|
jQuery(items).each(function(){
|
|
|
|
jQuery(this).find('dt').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Uncheck the checkboxes in the list
|
|
|
|
jQuery(button).offsetParent().find('.list-container input').attr('checked', false);
|
|
|
|
|
|
|
|
wp_update_post_data();
|
|
|
|
|
|
|
|
// Enable drag-n-drop
|
|
|
|
wp_drag_and_drop();
|
|
|
|
|
|
|
|
// Reload thickbox
|
|
|
|
tb_init('a.thickbox, area.thickbox, input.thickbox');
|
|
|
|
};
|
2010-02-20 22:57:43 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
/**
|
|
|
|
* Allow the items in the Menu to be dragged and dropped.
|
|
|
|
*/
|
|
|
|
function wp_drag_and_drop() {
|
2010-02-28 21:00:49 +01:00
|
|
|
// Make sure all li's have dropzones
|
|
|
|
jQuery('.menu li').each(function(){
|
|
|
|
if ( !jQuery(this).children('.dropzone').attr('class') ) {
|
|
|
|
jQuery(this).prepend('<div class="dropzone"></div>');
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
// make menu item draggable
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery('.menu li').draggable({
|
2010-02-20 22:57:43 +01:00
|
|
|
handle: ' > dl',
|
|
|
|
opacity: .8,
|
|
|
|
addClasses: false,
|
|
|
|
helper: 'clone',
|
2010-02-28 21:00:49 +01:00
|
|
|
zIndex: 100,
|
2010-02-20 22:57:43 +01:00
|
|
|
});
|
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
// make menu item droppable
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery('.menu li dl, .menu li .dropzone').droppable({
|
|
|
|
accept: '.menu li',
|
2010-02-20 22:57:43 +01:00
|
|
|
tolerance: 'pointer',
|
2010-02-28 00:06:56 +01:00
|
|
|
drop: function(e, ui) {
|
2010-02-21 00:58:00 +01:00
|
|
|
var li = jQuery(this).parent();
|
|
|
|
var child = !jQuery(this).hasClass('dropzone');
|
2010-02-28 00:06:56 +01:00
|
|
|
|
|
|
|
// Append UL to first child
|
|
|
|
if ( child && li.children('ul').length == 0 ) {
|
2010-02-28 21:00:49 +01:00
|
|
|
li.append( '<ul class="sub-menu" />' );
|
2010-02-20 22:57:43 +01:00
|
|
|
}
|
2010-02-28 00:06:56 +01:00
|
|
|
// Make it draggable
|
|
|
|
if ( child ) {
|
|
|
|
li.children('ul').append( ui.draggable );
|
|
|
|
} else {
|
|
|
|
li.before( ui.draggable );
|
2010-02-20 22:57:43 +01:00
|
|
|
}
|
2010-02-21 01:03:42 +01:00
|
|
|
|
|
|
|
li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' });
|
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
var draggablevalue = ui.draggable.attr('value');
|
2010-02-28 00:06:56 +01:00
|
|
|
var droppablevalue = li.attr('value');
|
|
|
|
|
|
|
|
li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue);
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery(this).parent().find('dt').removeAttr('style');
|
|
|
|
jQuery(this).parent().find('div:first').removeAttr('style');
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
},
|
2010-02-28 00:06:56 +01:00
|
|
|
over: function() {
|
|
|
|
// Add child
|
|
|
|
if ( jQuery(this).attr('class') == 'dropzone ui-droppable' ) {
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery(this).parent().find('div:first').css('background', 'none').css('height', '50px');
|
2010-02-20 22:57:43 +01:00
|
|
|
}
|
2010-02-28 00:06:56 +01:00
|
|
|
// Add above
|
|
|
|
else if ( jQuery(this).attr('class') == 'ui-droppable' ) {
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery(this).parent().find('dt:first').css('background', '#d8d8d8');
|
2010-02-28 00:06:56 +01:00
|
|
|
} else {
|
|
|
|
// do nothing
|
2010-02-20 22:57:43 +01:00
|
|
|
}
|
2010-02-21 00:58:00 +01:00
|
|
|
var parentid = jQuery(this).parent().attr('id');
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
},
|
2010-02-28 00:06:56 +01:00
|
|
|
out: function() {
|
2010-02-28 21:00:49 +01:00
|
|
|
jQuery(this).parent().find('dt').removeAttr('style');
|
|
|
|
jQuery(this).parent().find('div:first').removeAttr('style');
|
2010-02-21 00:58:00 +01:00
|
|
|
jQuery(this).filter('.dropzone').css({ borderColor: '' });
|
2010-02-20 22:57:43 +01:00
|
|
|
}
|
2010-02-28 00:06:56 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2010-02-20 22:57:43 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
/**
|
|
|
|
* Gets a unique number based on how many items are in the menu
|
|
|
|
*/
|
|
|
|
function wp_get_unique_menu_id() {
|
2010-02-28 21:00:49 +01:00
|
|
|
var count = jQuery('.menu li').length + 1;
|
2010-02-28 00:06:56 +01:00
|
|
|
var randomnumber = count;
|
|
|
|
var validatetest = 0;
|
|
|
|
|
|
|
|
try {
|
|
|
|
var test = document.getElementById( 'menu-' + randomnumber.toString() ).value;
|
|
|
|
}
|
|
|
|
catch ( err ) {
|
|
|
|
validatetest = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( validatetest == 0 ) {
|
|
|
|
randomnumber = randomnumber + 1;
|
|
|
|
try {
|
|
|
|
var test2 = document.getElementById( 'menu-' + randomnumber.toString() ).value;
|
|
|
|
}
|
|
|
|
catch ( err ) {
|
|
|
|
validatetest = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return randomnumber;
|
|
|
|
}
|