aboutsummaryrefslogtreecommitdiffstats
path: root/themes/default/js/switchbox.js
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2013-06-22 04:44:48 +0000
committerrvelices <rv-github@modusoptimus.com>2013-06-22 04:44:48 +0000
commit0b319ddd456faaced5a300db64b48af60e1dbaec (patch)
tree8f63328554b9f419feefced30aef5e352e20af26 /themes/default/js/switchbox.js
parent6d74171c3c5032b4e1124bccfe59990fb82c2220 (diff)
feature 2928: fctorize switchBox (now js is loaded async + also apply to the calendar type links on index page)
git-svn-id: http://piwigo.org/svn/trunk@23437 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--themes/default/js/switchbox.js34
1 files changed, 23 insertions, 11 deletions
diff --git a/themes/default/js/switchbox.js b/themes/default/js/switchbox.js
index 9e8167a33..4741e7980 100644
--- a/themes/default/js/switchbox.js
+++ b/themes/default/js/switchbox.js
@@ -1,11 +1,23 @@
-function switchBox(link, box) {
- jQuery(link).click(function() {
- var elt = jQuery(box);
- elt.css("left", Math.min( jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
- .css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
- .toggle();
- });
- jQuery(box).on("mouseleave click", function() {
- jQuery(this).hide();
- });
-} \ No newline at end of file
+(function () {
+ var sbFunc = function(link, box) {
+ jQuery(link).click(function() {
+ var elt = jQuery(box);
+ elt.css("left", Math.min( jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
+ .css("top", jQuery(this).offset().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
+ }
+})(); \ No newline at end of file