diff options
author | Peter 'Pita' Martischka <petermartischka@googlemail.com> | 2011-07-08 15:19:38 +0100 |
---|---|---|
committer | Peter 'Pita' Martischka <petermartischka@googlemail.com> | 2011-07-08 15:19:38 +0100 |
commit | cbbb0a4ed1d024433f8832a998a43046e007f42c (patch) | |
tree | 5e79caf97130217c360c4699502c7644d0b83303 /static/js/pad_editbar.js | |
parent | 271ee1776b6900d90d138d6770fe288768162ca1 (diff) | |
download | etherpad-lite-cbbb0a4ed1d024433f8832a998a43046e007f42c.zip |
cleaned the dropdown code a lot
Diffstat (limited to 'static/js/pad_editbar.js')
-rw-r--r-- | static/js/pad_editbar.js | 91 |
1 files changed, 42 insertions, 49 deletions
diff --git a/static/js/pad_editbar.js b/static/js/pad_editbar.js index 27753eec..3a61d1af 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('<div id="embedcode">Embed code:<input id="embedinput" type="text" value="<iframe src="' + padurl + '" 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="' + padurl + '" 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") |