smartinstaller/doc/templates/scripts/narrow.js
branchADM
changeset 48 364021cecc90
equal deleted inserted replaced
47:3f419852be07 48:364021cecc90
       
     1 var narrowInit = function() {
       
     2   /* TODO:
       
     3   Could probably be more efficient, not hardcoding each element to be created
       
     4   */
       
     5   // 1: Create search form
       
     6   var narrowSearch = $('<div id="narrowsearch"></div>');
       
     7   var searchform = $("#qtdocsearch");
       
     8   narrowSearch.append(searchform);
       
     9   $("#qtdocheader .content .qtref").after(narrowSearch);
       
    10 
       
    11   // 2: Create dropdowns
       
    12   var narrowmenu = $('<ul id="narrowmenu" class="sf-menu"></ul>');
       
    13 
       
    14   // Lookup
       
    15   var lookuptext = $("#lookup h2").attr("title");
       
    16   $("#lookup ul").removeAttr("id");
       
    17   $("#lookup ul li").removeAttr("class");
       
    18   $("#lookup ul li").removeAttr("style");
       
    19   var lookupul = $("#lookup ul");
       
    20   var lookuplist = $('<li></li>');
       
    21   var lookuplink = $('<a href="#"></a>');
       
    22   lookuplink.append(lookuptext);
       
    23   lookuplist.append(lookuplink);
       
    24   lookuplist.append(lookupul);
       
    25   narrowmenu.append(lookuplist);
       
    26 
       
    27   // Topics
       
    28   var topicstext = $("#topics h2").attr("title");
       
    29   $("#topics ul").removeAttr("id");
       
    30   $("#topics ul li").removeAttr("class");
       
    31   $("#topics ul li").removeAttr("style");
       
    32   var topicsul = $("#topics ul");
       
    33   var topicslist = $('<li></li>');
       
    34   var topicslink = $('<a href="#"></a>');
       
    35   topicslink.append(topicstext);
       
    36   topicslist.append(topicslink);
       
    37   topicslist.append(topicsul);
       
    38   narrowmenu.append(topicslist);
       
    39 
       
    40   // Examples
       
    41   var examplestext = $("#examples h2").attr("title");
       
    42   $("#examples ul").removeAttr("id");
       
    43   $("#examples ul li").removeAttr("class");
       
    44   $("#examples ul li").removeAttr("style");
       
    45   var examplesul = $("#examples ul");
       
    46   var exampleslist = $('<li></li>');
       
    47   var exampleslink = $('<a href="#"></a>');
       
    48   exampleslink.append(examplestext);
       
    49   exampleslist.append(exampleslink);
       
    50   exampleslist.append(examplesul);
       
    51   narrowmenu.append(exampleslist);
       
    52 
       
    53   $("#shortCut").after(narrowmenu);
       
    54   $('ul#narrowmenu').superfish({
       
    55     delay: 100,
       
    56     autoArrows: false,
       
    57     disableHI: true
       
    58   });
       
    59 }
       
    60 
       
    61 $(document).ready(function(){
       
    62   if ($('body').hasClass('narrow')) {
       
    63     narrowInit();
       
    64   }
       
    65 });
       
    66 
       
    67 $(window).bind('resize', function () {
       
    68   if($(window).width()<600) {
       
    69     $('body').addClass('narrow');
       
    70 
       
    71     if ($("#narrowsearch").length == 0) {
       
    72       narrowInit();
       
    73     }
       
    74   }
       
    75   else {
       
    76     $('body').removeClass('narrow');
       
    77   }
       
    78 });