aboutsummaryrefslogtreecommitdiffstats
path: root/themes/default/js/switchbox.js
blob: 6b1e8f2ddc1298832ce1e66fdcff8f554a67b45c (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]);
	}

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