source: OpenRLabs-Git/deploy/rlabs-docker/web2py-rlabs/applications/admin/static/js/web2py_bootstrap.js

main
Last change on this file was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100755
File size: 1.5 KB
Line 
1// this code improves bootstrap menus and adds dropdown support
2jQuery(function(){
3  jQuery('.nav>li>a').each(function(){
4    if(jQuery(this).parent().find('ul').length)
5      jQuery(this).attr({'class':'dropdown-toggle','data-toggle':'dropdown'}).append('<b class="caret"></b>');
6  });
7  jQuery('.nav li li').each(function(){
8    if(jQuery(this).find('ul').length)
9      jQuery(this).addClass('dropdown-submenu');
10  });
11  function adjust_height_of_collapsed_nav() {
12        var cn = jQuery('div.collapse');
13        if (cn.get(0)) {
14            var cnh = cn.get(0).style.height;
15            if (cnh>'0px'){
16                cn.css('height','auto');
17            }
18        }
19  }
20  function hoverMenu(){
21    jQuery('ul.nav a.dropdown-toggle').parent().hover(function(){
22        adjust_height_of_collapsed_nav();
23        var mi = jQuery(this).addClass('open');
24        mi.children('.dropdown-menu').stop(true, true).delay(200).fadeIn(400);
25    }, function(){
26        var mi = jQuery(this);
27        mi.children('.dropdown-menu').stop(true, true).delay(200).fadeOut(function(){mi.removeClass('open')});
28    });
29  }
30  hoverMenu(); // first page load
31  jQuery(window).resize(hoverMenu); // on resize event
32  jQuery('ul.nav li.dropdown a').click(function(){
33    if(jQuery(this).attr("target")){
34        window.open(
35            jQuery(this).attr('href'),
36            jQuery(this).attr('target') // <- This is what makes it open in a new window.
37        );
38    } else {
39        window.location=jQuery(this).attr('href');
40    }
41  });
42});
Note: See TracBrowser for help on using the repository browser.