aboutsummaryrefslogtreecommitdiffstats
path: root/themes/default/js/switchbox.js
blob: b20f82d506d0940fb24aec0f1624115797ff436b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(function () {
	var sbFunc = function(link, box) {
		jQuery(link).click(function() {
			var elt = jQuery(box);
			elt.css("left", Math.min( jQuery(this).position().left, jQuery(window).width() - elt.outerWidth(true) - 5))
				.css("top", jQuery(this).position().top + jQuery(this).outerHeight(true))
				.toggle();
			return false;
		});
		jQuery(box).on("mouseleave click", function() {
			jQuery(this).hide();
		});
	};

	if (window.SwitchBox) {
		for (var i=0; i<SwitchBox.length; i+=2)
			sbFunc(SwitchBox[i], SwitchBox[i+1]);
	}

	SwitchBox = {
		push: sbFunc
	}
})();