From cbbb0a4ed1d024433f8832a998a43046e007f42c Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Fri, 8 Jul 2011 15:19:38 +0100 Subject: [PATCH] cleaned the dropdown code a lot --- static/js/ace2_inner.js | 3 ++ static/js/pad_editbar.js | 91 +++++++++++++++++++--------------------- 2 files changed, 45 insertions(+), 49 deletions(-) diff --git a/static/js/ace2_inner.js b/static/js/ace2_inner.js index 69fce950b..afafcec72 100644 --- a/static/js/ace2_inner.js +++ b/static/js/ace2_inner.js @@ -3464,6 +3464,9 @@ function OUTER(gscope) function handleClick(evt) { + //hide the dropdowns + window.top.padeditbar.toogleDropDown("none"); + inCallStack("handleClick", function() { idleWorkTimer.atMost(200); diff --git a/static/js/pad_editbar.js b/static/js/pad_editbar.js index 27753eec2..3a61d1af3 100644 --- a/static/js/pad_editbar.js +++ b/static/js/pad_editbar.js @@ -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('
Embed code:
'); - $('#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('
Embed code:
'); + 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