source: trunk/themes/default/js/switchbox.js @ 24612

Last change on this file since 24612 was 24612, checked in by rvelices, 11 years ago

fix switchbox for deeply nested position absolute elements (should use position() instead of offset())

File size: 573 bytes
Line 
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).position().left, jQuery(window).width() - elt.outerWidth(true) - 5))
6                                .css("top", jQuery(this).position().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 TracBrowser for help on using the repository browser.