Difference between revisions of "User:Lexar/Main Page/Template:Benjas/Page.js"
m (testing this to convert it) |
m (would help if i could spell) |
||
Line 5: | Line 5: | ||
$('#right-navigation ul li').addClass('collapsible'); | $('#right-navigation ul li').addClass('collapsible'); | ||
} | } | ||
− | } | + | }; |
− | $( | + | $(MobileMenu.init); |
var mobileMenu = $('#mobile-menu'), mobileMenuButton = $('#mobile-menu .mobile-menu-button'), pageMenu = $('#mobile-menu #page-menu'), | var mobileMenu = $('#mobile-menu'), mobileMenuButton = $('#mobile-menu .mobile-menu-button'), pageMenu = $('#mobile-menu #page-menu'), |
Revision as of 04:01, 3 November 2014
var MobileMenu = { 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'); } }; $(MobileMenu.init); var mobileMenu = $('#mobile-menu'), mobileMenuButton = $('#mobile-menu .mobile-menu-button'), pageMenu = $('#mobile-menu #page-menu'), accountMenu = $('#mobile-menu #account-menu'), accountList = $('#mobile-menu #account-list'), pageList = $('#mobile-menu #tab-menu'), menuSearch = $('#mobile-menu #p-search'), openSearch = $('#mobile-menu #search-expand'), mainMenu = $('#mobile-menu #mobile-ul-main'); $('#mw-head #p-personal > ul > li').each(function(){ var th = $(this); accountList.append('<li><span>' + th.html() + '</span></li>'); }); $('#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>'); }); $('#right-navigation #p-search #searchform').clone().appendTo(menuSearch); $('#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>'); }); $(document).on('click','#mobile-ul-main li h3',function(){ mainMenu.find('ul').removeClass('open'); mainMenu.find('li h3').removeClass('down'); $(this).toggleClass('down').next('ul').addClass('open'); }); mobileMenuButton.click(function(){ $(this).toggleClass('active'); mainMenu.toggleClass('down'); mainMenu.find('ul').removeClass('open'); mainMenu.find('li h3').removeClass('down'); pageMenu.removeClass('down'); pageList.removeClass('down'); accountMenu.removeClass('down'); accountList.removeClass('down'); menuSearch.removeClass('out'); openSearch.removeClass('out'); pageMenu.removeClass('gone').delay(400).show(0); accountMenu.removeClass('gone').delay(400).show(0); }); openSearch.click(function(){ menuSearch.toggleClass('out'); mobileMenu.find('#simpleSearch').css('width',(($('#mobile-menu').width()*65)/100)+'px'); $(this).toggleClass('out'); 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('h3').removeClass('down'); }); pageMenu.click(function(){ pageList.toggleClass('down'); $(this).toggleClass('down'); accountMenu.removeClass('down'); accountList.removeClass('down'); mainMenu.removeClass('down'); mainMenu.find('ul').removeClass('open'); mobileMenuButton.removeClass('active'); mainMenu.find('li h3').removeClass('down'); accountMenu.removeClass('gone').delay(400).show(0); }); accountMenu.click(function(){ accountList.toggleClass('down'); $(this).toggleClass('down'); pageMenu.removeClass('down'); pageList.removeClass('down'); mainMenu.removeClass('down'); mainMenu.find('ul').removeClass('open'); mobileMenuButton.removeClass('active'); mainMenu.find('li h3').removeClass('down'); pageMenu.removeClass('gone').delay(400).show(0); });