Ignore:
Timestamp:
Jun 22, 2013, 6:44:48 AM (11 years ago)
Author:
rvelices
Message:

feature 2928: fctorize switchBox (now js is loaded async + also apply to the calendar type links on index page)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/themes/default/js/switchbox.js

    r23320 r23437  
    1 function switchBox(link, box) {
    2   jQuery(link).click(function() {
    3     var elt = jQuery(box);
    4     elt.css("left", Math.min( jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
    5       .css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
    6       .toggle();
    7   });
    8   jQuery(box).on("mouseleave click", function() {
    9     jQuery(this).hide();
    10   });
    11 }
     1(function () {
     2        var sbFunc = function(link, box) {
     3                jQuery(link).click(function() {
     4                        var elt = jQuery(box);
     5                        elt.css("left", Math.min( jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
     6                                .css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
     7                                .toggle();
     8                        return false;
     9                });
     10                jQuery(box).on("mouseleave click", function() {
     11                        jQuery(this).hide();
     12                });
     13        };
     14
     15        if (window.SwitchBox) {
     16                for (var i=0; i<SwitchBox.length; i+=2)
     17                        sbFunc(SwitchBox[i], SwitchBox[i+1]);
     18        }
     19
     20        SwitchBox = {
     21                push: sbFunc
     22        }
     23})();
Note: See TracChangeset for help on using the changeset viewer.