Difference between revisions of "User:Lexar/Main Page/Template:Benjas/Page.js"
m |
m |
||
(14 intermediate revisions by the same user not shown) | |||
Line 33: | Line 33: | ||
}); | }); | ||
mainMenu.append('<li>\ | mainMenu.append('<li>\ | ||
− | <h3><span>'+th.children('h3').text()+' <img src="/w/images/d/d9/User_Lexar_black-arrow.png" /></span></h3>\ | + | <h3><span>'+th.children('h3').text()+' <img src="/w/images/d/d9/User_Lexar_black-arrow.png" id="main-menu-no-hover" /><img src="/w/images/3/34/User_Lexar_white-arrow.png" id="main-menu-hover" /></span></h3>\ |
<ul>\ | <ul>\ | ||
'+listBuilder+'\ | '+listBuilder+'\ | ||
Line 42: | Line 42: | ||
}); | }); | ||
}, | }, | ||
− | + | closeMenus:function(classless){ | |
− | + | for(i=0;i < classless.length;i++) { | |
− | + | classless[i].removeClass('down out gone open'); | |
− | } | + | } |
− | |||
− | |||
− | |||
− | |||
− | |||
}, | }, | ||
− | menuButtonClick:function(mainMenu, | + | menuButtonClick:function(mainMenu,th) { |
− | + | th.toggleClass('active'); | |
mainMenu.toggleClass('down'); | mainMenu.toggleClass('down'); | ||
mainMenu.find('ul').removeClass('open'); | mainMenu.find('ul').removeClass('open'); | ||
mainMenu.find('li h3').removeClass('down'); | mainMenu.find('li h3').removeClass('down'); | ||
− | |||
− | |||
− | |||
}, | }, | ||
− | + | openSearchBar:function(menuSearch,th) { | |
− | + | menuSearch.toggleClass('out'); | |
− | + | $('#simpleSearch').css('width',(($('#mobile-menu').width()*65)/100)+'px'); | |
− | + | th.toggleClass('out'); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
}, | }, | ||
− | + | openMenu:function(Menu,th) { | |
− | + | Menu.toggleClass('down'); | |
− | + | th.toggleClass('down'); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
}, | }, | ||
menu:function(){ | menu:function(){ | ||
Line 100: | Line 74: | ||
mobileMenuButton.click(function(){ | mobileMenuButton.click(function(){ | ||
− | ResponsiveJS.menuButtonClick( | + | ResponsiveJS.menuButtonClick(mainMenu,$(this)); |
− | + | ||
− | + | ResponsiveJS.closeMenus([pageMenu,pageList,accountMenu,accountList,menuSearch,openSearch]); | |
− | + | ||
− | ); | + | //pageMenu.removeClass('down out gone open') |
+ | pageMenu.delay(400).show(0); | ||
+ | //pageList.removeClass('down out gone open'); | ||
+ | //accountMenu.removeClass('down out gone open') | ||
+ | accountMenu.delay(400).show(0); | ||
+ | //accountList.removeClass('down out gone open'); | ||
+ | //menuSearch.removeClass('down out gone open'); | ||
+ | //openSearch.removeClass('down out gone open'); | ||
}); | }); | ||
− | $(document).on('click', | + | $(document).on('click','#mobile-ul-main li h3',function(){ |
$('#mobile-ul-main ul').removeClass('open'); | $('#mobile-ul-main ul').removeClass('open'); | ||
$('#mobile-ul-main li h3').removeClass('down'); | $('#mobile-ul-main li h3').removeClass('down'); | ||
$(this).toggleClass('down').next('ul').addClass('open'); | $(this).toggleClass('down').next('ul').addClass('open'); | ||
}); | }); | ||
+ | |||
openSearch.click(function(){ | openSearch.click(function(){ | ||
− | ResponsiveJS. | + | ResponsiveJS.openSearchBar(menuSearch,$(this)); |
− | + | pageMenu.toggleClass('gone'); | |
− | [ | + | accountMenu.toggleClass('gone'); |
− | + | if(pageMenu.hasClass('gone')) { | |
− | ); | + | pageMenu.hide(); |
+ | accountMenu.hide(); | ||
+ | } | ||
+ | else { | ||
+ | pageMenu.delay(400).show(0); | ||
+ | accountMenu.delay(400).show(0); | ||
+ | } | ||
+ | |||
+ | ResponsiveJS.closeMenus([pageList,accountList,mainMenu,mainMenu.find('ul'),mainMenu.find('li h3')]); | ||
+ | |||
+ | mobileMenuButton.removeClass('active'); | ||
}); | }); | ||
pageMenu.click(function(){ | pageMenu.click(function(){ | ||
− | + | ResponsiveJS.openMenu(pageList,$(this)); | |
− | + | ||
− | + | ResponsiveJS.closeMenus([accountMenu,accountList,mainMenu,mainMenu.find('ul'),mainMenu.find('li h3')]); | |
− | + | ||
− | ); | + | mobileMenuButton.removeClass('active'); |
}); | }); | ||
accountMenu.click(function(){ | accountMenu.click(function(){ | ||
− | + | ResponsiveJS.openMenu(accountList,$(this)); | |
− | + | ||
− | + | ResponsiveJS.closeMenus([pageMenu,pageList,mainMenu,mainMenu.find('ul'),mainMenu.find('li h3')]); | |
− | + | ||
− | ); | + | mobileMenuButton.removeClass('active'); |
}); | }); | ||
}, | }, |
Latest revision as of 12:00, 3 November 2014
var ResponsiveJS = { populateAccount:function(accountList){ $('#mw-head #p-personal > ul > li').each(function(){ var th = $(this); accountList.append('<li><span>' + th.html() + '</span></li>'); }); $('#mw-head #p-personal > ul > li').each(function(){ var th = $(this); accountList.append('<li><span>' + th.html() + '</span></li>'); }); }, populatePage:function(pageList){ $('#left-navigation ul li').each(function(){ var th = $(this); pageList.append('<li'+(th.hasClass('selected')?' class="selected"':'')+'>'+th.html()+'</li>'); }); $($('#right-navigation #p-cactions .menu ul li').get().reverse()).each(function(){ var th = $(this); pageList.append('<li class="f-right'+(th.hasClass('selected')?' selected':'')+'">'+th.html()+'</li>'); }); $($('#right-navigation #p-views ul li').get().reverse()).each(function(){ var th = $(this); pageList.append('<li class="f-right'+(th.hasClass('selected')?' selected':'')+'">'+th.html()+'</li>'); }); }, populateNav:function(mainMenu){ $('#mw-panel .portal:not(#p-Languages)').each(function(){ var th = $(this), listBuilder = ''; th.find('div ul li').each(function(){ var thi = $(this); listBuilder += '<li>'+thi.html()+'</li>'; }); mainMenu.append('<li>\ <h3><span>'+th.children('h3').text()+' <img src="/w/images/d/d9/User_Lexar_black-arrow.png" id="main-menu-no-hover" /><img src="/w/images/3/34/User_Lexar_white-arrow.png" id="main-menu-hover" /></span></h3>\ <ul>\ '+listBuilder+'\ <li class="clearing"></li>\ </ul>\ <div class="clearing"></div>\ </li>'); }); }, closeMenus:function(classless){ for(i=0;i < classless.length;i++) { classless[i].removeClass('down out gone open'); } }, menuButtonClick:function(mainMenu,th) { th.toggleClass('active'); mainMenu.toggleClass('down'); mainMenu.find('ul').removeClass('open'); mainMenu.find('li h3').removeClass('down'); }, openSearchBar:function(menuSearch,th) { menuSearch.toggleClass('out'); $('#simpleSearch').css('width',(($('#mobile-menu').width()*65)/100)+'px'); th.toggleClass('out'); }, openMenu:function(Menu,th) { Menu.toggleClass('down'); th.toggleClass('down'); }, menu:function(){ var mobileMenu = $(this), mobileMenuButton = mobileMenu.find('.mobile-menu-button'), pageMenu = mobileMenu.find('#page-menu'), accountMenu = mobileMenu.find('#account-menu'), accountList = mobileMenu.find('#account-list'), pageList = mobileMenu.find('#tab-menu'), menuSearch = mobileMenu.find('#p-search'), openSearch = mobileMenu.find('#search-expand'), mainMenu = mobileMenu.find('#mobile-ul-main'); ResponsiveJS.populateAccount(accountList); ResponsiveJS.populatePage(pageList); $('#right-navigation #p-search #searchform').clone().appendTo(menuSearch); ResponsiveJS.populateNav(mainMenu); mobileMenuButton.click(function(){ ResponsiveJS.menuButtonClick(mainMenu,$(this)); ResponsiveJS.closeMenus([pageMenu,pageList,accountMenu,accountList,menuSearch,openSearch]); //pageMenu.removeClass('down out gone open') pageMenu.delay(400).show(0); //pageList.removeClass('down out gone open'); //accountMenu.removeClass('down out gone open') accountMenu.delay(400).show(0); //accountList.removeClass('down out gone open'); //menuSearch.removeClass('down out gone open'); //openSearch.removeClass('down out gone open'); }); $(document).on('click','#mobile-ul-main li h3',function(){ $('#mobile-ul-main ul').removeClass('open'); $('#mobile-ul-main li h3').removeClass('down'); $(this).toggleClass('down').next('ul').addClass('open'); }); openSearch.click(function(){ ResponsiveJS.openSearchBar(menuSearch,$(this)); pageMenu.toggleClass('gone'); accountMenu.toggleClass('gone'); if(pageMenu.hasClass('gone')) { pageMenu.hide(); accountMenu.hide(); } else { pageMenu.delay(400).show(0); accountMenu.delay(400).show(0); } ResponsiveJS.closeMenus([pageList,accountList,mainMenu,mainMenu.find('ul'),mainMenu.find('li h3')]); mobileMenuButton.removeClass('active'); }); pageMenu.click(function(){ ResponsiveJS.openMenu(pageList,$(this)); ResponsiveJS.closeMenus([accountMenu,accountList,mainMenu,mainMenu.find('ul'),mainMenu.find('li h3')]); mobileMenuButton.removeClass('active'); }); accountMenu.click(function(){ ResponsiveJS.openMenu(accountList,$(this)); ResponsiveJS.closeMenus([pageMenu,pageList,mainMenu,mainMenu.find('ul'),mainMenu.find('li h3')]); mobileMenuButton.removeClass('active'); }); }, init:function() { $('head').prepend('<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>'); $('#mw-content-text').addClass('main-area'); $('#right-navigation ul li').addClass('collapsible'); $('#mobile-menu').each(ResponsiveJS.menu); } }; $(ResponsiveJS.init);