.tnl-popup-menu {position:relative; display:inline-block; height: 1em; }
.tnl-popup-menu > a {display:inline-block;}
.tnl-popup-menu > div {display:none; position:absolute; top:0; left:0;}
.tnl-popup-menu > div > div {position:absolute; top:0; left:20px; width: 100px; background-color:white; border: 1px solid black; }
.tnl-popup-widget {position:relative; display:inline-block;}
.tnl-popup-widget > a {display: inline-block;}
.tnl-popup-widget > div {display:none; position:absolute; top:0; left:20px;}
JavaScript
var Truenorth = Truenorth || {};
Truenorth.PopupWidget = function(container) {
var w = $(container);
var a = w.children('a').first();
var p = w.children('div').first()
.addClass('ui-widget ui-helper-reset');
var h = p.children('h1,h2,h3,h4').first()
.addClass('ui-widget-header ui-corner-top');
var c = p.children('div').first()
.addClass('ui-widget-content ui-corner-bottom');
a.click(function(e) {
e.preventDefault();
if(!a.data('popup-widget-content-loaded')) {
var loc = a.attr('href');
if(loc && loc[0] != '#') {
c.load(loc, function() {
a.data('popup-widget-content-loaded', true);
});
}
}
Truenorth.PopupPanel.togglePanel(p, w);
});
};
Truenorth.PopupPanel = function() {
var currentPopups = $();
var hidePanels = function(panels) {
panels.each(function() {
var t = $(this).hide();
var alt = t.data('tnl-popup-altPanel');
if(alt) {alt.show();}
});
currentPopups = currentPopups.not(panels);
};
var togglePanel = function(targetPanel, container, altPanel) {
/// <summary>
/// Toggles the visibility of the given panel.
/// If this causes the panel to close, all open
/// panels inside it will be closed.
/// If this causes the panel to open, all open
/// panels that aren't a parent of this panel
/// will be closed.
/// </summary>
/// <param name="targetPanel" domElement="true">
/// The DOM element to toggle.
/// </param>
/// <param name="altPanel" domElement="true">
/// (optional) A panel that should be visible when
/// the target panel is invisible, and invisible
/// when the target panel is visible.
/// </param>
var tp = $(targetPanel);
var ap = altPanel ?...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.