Merge pull request #679 from 0ip/highl_mod

Tidy up wobbly button highlighting code
This commit is contained in:
John McLear 2012-04-29 08:10:52 -07:00
commit f6bdbddfcc
3 changed files with 11 additions and 14 deletions

View file

@ -1402,7 +1402,7 @@ input[type=checkbox] {
float: left; float: left;
width: 50%; width: 50%;
} }
#settingsmenu, #settings,
#importexport, #importexport,
#embed { #embed {
position: absolute; position: absolute;
@ -1546,7 +1546,7 @@ input[type=checkbox] {
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
} }
#settingsmenu, #settings,
#importexport, #importexport,
#embed { #embed {
left: 0; left: 0;

View file

@ -119,7 +119,7 @@ var padeditbar = (function()
} }
else if (cmd == 'settings') else if (cmd == 'settings')
{ {
self.toogleDropDown("settingsmenu"); self.toogleDropDown("settings");
} }
else if (cmd == 'embed') else if (cmd == 'embed')
{ {
@ -177,12 +177,11 @@ var padeditbar = (function()
}, },
toogleDropDown: function(moduleName) toogleDropDown: function(moduleName)
{ {
var modules = ["settingsmenu", "importexport", "embed", "users"]; var modules = ["settings", "importexport", "embed", "users"];
//hide all modules // hide all modules and remove highlighting of all buttons
if(moduleName == "none") if(moduleName == "none")
{ {
$(".toolbar ul.menu_right li").removeClass("selected");
for(var i=0;i<modules.length;i++) for(var i=0;i<modules.length;i++)
{ {
//skip the userlist //skip the userlist
@ -193,29 +192,27 @@ var padeditbar = (function()
if(module.css('display') != "none") if(module.css('display') != "none")
{ {
$("#" + modules[i] + "link").removeClass("selected");
module.slideUp("fast"); module.slideUp("fast");
} }
} }
} }
else else
{ {
var nth_child = indexOf(modules, moduleName) + 1; // hide all modules that are not selected and remove highlighting
if (nth_child > 0 && nth_child <= (modules.length-1)) { // respectively add highlighting to the corresponding button
$(".toolbar ul.menu_right li:not(:nth-child(" + nth_child + "))").removeClass("selected");
$(".toolbar ul.menu_right li:nth-child(" + nth_child + ")").toggleClass("selected");
}
if(modules[modules.length-1] === moduleName) $(".toolbar ul.menu_right li").removeClass("selected");
//hide all modules that are not selected and show the selected one
for(var i=0;i<modules.length;i++) for(var i=0;i<modules.length;i++)
{ {
var module = $("#" + modules[i]); var module = $("#" + modules[i]);
if(module.css('display') != "none") if(module.css('display') != "none")
{ {
$("#" + modules[i] + "link").removeClass("selected");
module.slideUp("fast"); module.slideUp("fast");
} }
else if(modules[i]==moduleName) else if(modules[i]==moduleName)
{ {
$("#" + modules[i] + "link").addClass("selected");
module.slideDown("fast"); module.slideDown("fast");
} }
} }

View file

@ -113,7 +113,7 @@
<div id="editorloadingbox">Loading...</div> <div id="editorloadingbox">Loading...</div>
</div> </div>
<div id="settingsmenu" class="popup"> <div id="settings" class="popup">
<h1>Pad settings</h1> <h1>Pad settings</h1>
<div class="column"> <div class="column">
<h2>My view</h2> <h2>My view</h2>