2010-02-20 22:57:43 +01:00
|
|
|
/**
|
|
|
|
* WordPress Administration Custom Navigation
|
|
|
|
* Interface JQuery functions
|
|
|
|
*
|
|
|
|
* @author Jeffikus <pearce.jp@gmail.com>
|
|
|
|
* @version 1.1.0
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
/*
|
|
|
|
* Init Functions
|
|
|
|
*/
|
2010-02-21 00:58:00 +01:00
|
|
|
jQuery(function($)
|
2010-02-20 22:57:43 +01:00
|
|
|
{
|
|
|
|
//Makes dialog box
|
|
|
|
$("#dialog-confirm").dialog({
|
|
|
|
autoOpen: false,
|
|
|
|
resizable: false,
|
|
|
|
height: 210,
|
|
|
|
width: 400,
|
|
|
|
modal: true,
|
|
|
|
buttons: {
|
|
|
|
'Save': function() {
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
titletosave = $('#edittitle').attr('value');
|
|
|
|
linktosave = $('#editlink').attr('value');
|
|
|
|
anchortitletosave = $('#editanchortitle').attr('value');
|
|
|
|
newwindowtosave = $('#editnewwindow').attr('value');
|
|
|
|
desctosave = $('#editdescription').attr('value');
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
$('#title' + $(this).dialog('option', 'itemID')).attr('value',titletosave);
|
|
|
|
$('#linkurl' + $(this).dialog('option', 'itemID')).attr('value',linktosave);
|
|
|
|
$('#anchortitle' + $(this).dialog('option', 'itemID')).attr('value',anchortitletosave);
|
|
|
|
$('#newwindow' + $(this).dialog('option', 'itemID')).attr('value',newwindowtosave);
|
|
|
|
$('#description' + $(this).dialog('option', 'itemID')).attr('value',desctosave);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
$('#menu-' + $(this).dialog('option', 'itemID') + ' > dl > dt > span.title').text(titletosave);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
$('#view' + + $(this).dialog('option', 'itemID')).attr('href', linktosave);
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
$(this).dialog('close');
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
},
|
|
|
|
Cancel: function() {
|
|
|
|
$(this).dialog('close');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
$('#message').animate({ opacity: 1.0 },2000).fadeOut(300, function(){ $(this).remove();});
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
//Add dropzone
|
2010-02-21 01:03:42 +01:00
|
|
|
$('#custom-nav li').prepend('<div class="dropzone"></div>');
|
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
//Make li items draggable
|
|
|
|
$('#custom-nav li').draggable({
|
|
|
|
handle: ' > dl',
|
|
|
|
opacity: .8,
|
|
|
|
addClasses: false,
|
|
|
|
helper: 'clone',
|
|
|
|
zIndex: 100
|
|
|
|
});
|
|
|
|
|
|
|
|
//Make items droppable
|
|
|
|
$('#custom-nav dl, #custom-nav .dropzone').droppable(
|
|
|
|
{
|
|
|
|
accept: '#custom-nav li',
|
|
|
|
tolerance: 'pointer',
|
2010-02-21 01:03:42 +01:00
|
|
|
drop: function(e, ui)
|
2010-02-20 22:57:43 +01:00
|
|
|
{
|
|
|
|
var li = $(this).parent();
|
|
|
|
var child = !$(this).hasClass('dropzone');
|
|
|
|
//Add UL to first child
|
2010-02-21 01:03:42 +01:00
|
|
|
if (child && li.children('ul').length == 0)
|
2010-02-20 22:57:43 +01:00
|
|
|
{
|
|
|
|
li.append('<ul id="sub-menu" />');
|
|
|
|
}
|
|
|
|
//Make it draggable
|
2010-02-21 01:03:42 +01:00
|
|
|
if (child)
|
2010-02-20 22:57:43 +01:00
|
|
|
{
|
|
|
|
li.children('ul').append(ui.draggable);
|
|
|
|
}
|
2010-02-21 01:03:42 +01:00
|
|
|
else
|
2010-02-20 22:57:43 +01:00
|
|
|
{
|
|
|
|
li.before(ui.draggable);
|
|
|
|
}
|
|
|
|
|
|
|
|
li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' });
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
var draggablevalue = ui.draggable.attr('value');
|
|
|
|
var droppablevalue = li.attr('value');
|
2010-02-21 01:03:42 +01:00
|
|
|
li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue);
|
2010-02-20 22:57:43 +01:00
|
|
|
$(this).parent().find("dt").removeAttr('style');
|
|
|
|
$(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-21 01:03:42 +01:00
|
|
|
over: function()
|
2010-02-20 22:57:43 +01:00
|
|
|
{
|
|
|
|
//Add child
|
2010-02-21 01:03:42 +01:00
|
|
|
if ($(this).attr('class') == 'dropzone ui-droppable')
|
2010-02-20 22:57:43 +01:00
|
|
|
{
|
|
|
|
$(this).parent().find("div:first").css('background', 'none').css('height', '50px');
|
|
|
|
}
|
|
|
|
//Add above
|
2010-02-21 01:03:42 +01:00
|
|
|
else if ($(this).attr('class') == 'ui-droppable')
|
2010-02-20 22:57:43 +01:00
|
|
|
{
|
|
|
|
$(this).parent().find("dt:first").css('background', '#d8d8d8');
|
|
|
|
}
|
|
|
|
//do nothing
|
|
|
|
else {
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
}
|
|
|
|
var parentid = $(this).parent().attr('id');
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
},
|
2010-02-21 01:03:42 +01:00
|
|
|
out: function()
|
2010-02-20 22:57:43 +01:00
|
|
|
{
|
|
|
|
$(this).parent().find("dt").removeAttr('style');
|
|
|
|
$(this).parent().find("div:first").removeAttr('style');
|
|
|
|
$(this).filter('.dropzone').css({ borderColor: '' });
|
|
|
|
},
|
|
|
|
deactivate: function()
|
2010-02-21 01:03:42 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
}
|
2010-02-21 01:03:42 +01:00
|
|
|
|
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
});
|
2010-02-21 01:03:42 +01:00
|
|
|
|
|
|
|
//Handle Save Button Clicks
|
2010-02-20 22:57:43 +01:00
|
|
|
$('#save_top').click(function()
|
|
|
|
{
|
|
|
|
updatepostdata();
|
|
|
|
});
|
|
|
|
$('#save_bottom').click(function()
|
|
|
|
{
|
|
|
|
updatepostdata();
|
|
|
|
});
|
2010-02-21 01:03:42 +01:00
|
|
|
|
2010-02-20 22:57:43 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|