Reputation: 81
I am new to web development.........
I have used Metro UI CSS to create this
I am now trying to emulate a Charms Bar.
I want that when the user clicks on theme button a bar should be displayed on the right containing some controls etc. The bar should hide when it loses focus (user clicks outside the bar).
The Charms bar is added using <div class="charms">
I have also added style="display:none;"
so that the bar is not visible on start.
Then I used the following code to show it when the user selects the theme button or text
$(document).click(function(event)
{
var $target = $(event.target);
var target = event.target;
if (!target.id.indexOf("theme")) //if the target id contains "theme" then show charms bar
{
$("div .charms").fadeIn(600)
}
else
{
if (target.id != "charms") //if the charms bar itseff is NOT clicked
$("div .charms").fadeOut(600)
}
});
I don't like this code because when i click a control in the charms bar, it hides the bar itself.
All i need to do is to create a floating bar, that is visible when the user clicks a button, and hides when the user clicks something else.......
Upvotes: 4
Views: 2162