cleaned the dropdown code a lot

pull/35/head
Peter 'Pita' Martischka 2011-07-08 15:19:38 +01:00
parent 271ee1776b
commit cbbb0a4ed1
2 changed files with 45 additions and 49 deletions

View File

@ -3464,6 +3464,9 @@ function OUTER(gscope)
function handleClick(evt)
{
//hide the dropdowns
window.top.padeditbar.toogleDropDown("none");
inCallStack("handleClick", function()
{
idleWorkTimer.atMost(200);

View File

@ -94,59 +94,17 @@ var padeditbar = (function()
{
if (self.isEnabled())
{
if (cmd == 'showusers')
if(cmd == "showusers")
{
// show users shows the current users on teh pad
// get current height
var editbarheight = $('#users').css('display');
if (editbarheight == "none")
{
// increase the size of the editbar
//$('#editbar').animate({height:'72px'});
//$('#editorcontainerbox').animate({top:'72px'});
$('#embed').slideUp("fast");
$('#users').slideDown("fast");
}
else
{
// increase the size of the editbar
//$('#editbar').animate({height:'36px'});
//$('#editorcontainerbox').animate({top:'36px'});
$('#users').slideUp("fast");
}
self.toogleDropDown("users");
}
if (cmd == 'embed')
else if (cmd == 'embed')
{
// embed shows the embed link
// get current height
var editbarheight = $('#embed').css('display');
if (editbarheight == "none")
{
// increase the size of the editbar
//$('#editbar').animate({height:'72px'});
$('#editorcontainerbox').animate(
{
top: '72px'
});
// get the pad url
padurl = document.location;
// change the div contents to include the pad url in an input box
$('#embed').html('<div id="embedcode">Embed code:<input id="embedinput" type="text" value="<iframe src=&quot;' + padurl + '&quot; width=500 height=400>"</iframe></div>');
$('#users').slideUp("fast");
$('#embed').slideDown("fast");
}
else
{
// increase the size of the editbar
//$('#editbar').animate({height:'36px'});
$('#editorcontainerbox').animate(
{
top: '36px'
});
$('#embed').hide();
}
var padurl = document.location;
$('#embed').html('<div id="embedcode">Embed code:<input id="embedinput" type="text" value="<iframe src=&quot;' + padurl + '&quot; width=500 height=400>"</iframe></div>');
self.toogleDropDown("embed");
}
if (cmd == 'save')
else if (cmd == 'save')
{
padsavedrevs.saveNow();
}
@ -189,6 +147,41 @@ var padeditbar = (function()
}
padeditor.ace.focus();
},
toogleDropDown: function(moduleName)
{
var modules = ["embed", "users"];
//hide all modules
if(moduleName == "none")
{
for(var i=0;i<modules.length;i++)
{
var module = $("#" + modules[i]);
if(module.css('display') != "none")
{
module.slideUp("fast");
}
}
}
else
{
//hide all modules that are not selected and show the selected one
for(var i=0;i<modules.length;i++)
{
var module = $("#" + modules[i]);
if(module.css('display') != "none")
{
module.slideUp("fast");
}
else if(modules[i]==moduleName)
{
module.slideDown("fast");
}
}
}
},
setSyncStatus: function(status)
{
if (status == "syncing")