Difference between revisions of "User:Lexar/Main Page/Template:Benjas/Page.js"
m |
m |
||
Line 57: | Line 57: | ||
Menu.toggleClass('down'); | Menu.toggleClass('down'); | ||
th.toggleClass('down'); | th.toggleClass('down'); | ||
− | } | + | }, |
menu:function(){ | menu:function(){ | ||
var mobileMenu = $(this), mobileMenuButton = mobileMenu.find('.mobile-menu-button'), pageMenu = mobileMenu.find('#page-menu'), | var mobileMenu = $(this), mobileMenuButton = mobileMenu.find('.mobile-menu-button'), pageMenu = mobileMenu.find('#page-menu'), | ||
Line 111: | Line 111: | ||
accountMenu.removeClass('down'); | accountMenu.removeClass('down'); | ||
accountList.removeClass('down'); | accountList.removeClass('down'); | ||
+ | mainMenu.removeClass('down'); | ||
+ | mainMenu.find('ul').removeClass('open'); | ||
+ | mobileMenuButton.removeClass('active'); | ||
+ | mainMenu.find('li h3').removeClass('down'); | ||
+ | }); | ||
+ | accountMenu.click(function(){ | ||
+ | ResponsiveJS.openMenu(accountList,$(this)); | ||
+ | |||
+ | pageMenu.removeClass('down'); | ||
+ | pageList.removeClass('down'); | ||
mainMenu.removeClass('down'); | mainMenu.removeClass('down'); | ||
mainMenu.find('ul').removeClass('open'); | mainMenu.find('ul').removeClass('open'); |
Revision as of 08:23, 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" /></span></h3>\ <ul>\ '+listBuilder+'\ <li class="clearing"></li>\ </ul>\ <div class="clearing"></div>\ </li>'); }); }, 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)); pageMenu.removeClass('down out gone open'); pageList.removeClass('down out gone open').delay(400).show(0); accountMenu.removeClass('down out gone open'); accountList.removeClass('down out gone open').delay(400).show(0); 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); } pageMenu.removeClass('down'); pageList.removeClass('down'); accountMenu.removeClass('down'); accountList.removeClass('down'); mainMenu.removeClass('down'); mainMenu.find('ul').removeClass('open'); mobileMenuButton.removeClass('active'); mainMenu.find('li h3').removeClass('down'); }); pageMenu.click(function(){ ResponsiveJS.openMenu(pageList,$(this)); accountMenu.removeClass('down'); accountList.removeClass('down'); mainMenu.removeClass('down'); mainMenu.find('ul').removeClass('open'); mobileMenuButton.removeClass('active'); mainMenu.find('li h3').removeClass('down'); }); accountMenu.click(function(){ ResponsiveJS.openMenu(accountList,$(this)); pageMenu.removeClass('down'); pageList.removeClass('down'); mainMenu.removeClass('down'); mainMenu.find('ul').removeClass('open'); mobileMenuButton.removeClass('active'); mainMenu.find('li h3').removeClass('down'); }); }, 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);