Difference between revisions of "MediaWiki:Mobile.js"
Jump to navigation
Jump to search
Ghanashyam (talk | contribs) |
Ghanashyam (talk | contribs) |
||
| Line 12: | Line 12: | ||
location.replace( mw.config.get( 'wgServer') + $(".page-heading").next().attr( "href" ) ); | location.replace( mw.config.get( 'wgServer') + $(".page-heading").next().attr( "href" ) ); | ||
} | } | ||
| + | }); | ||
| + | |||
| + | |||
| + | /* Rahul Js Code */ | ||
| + | |||
| + | var _object='<div class="_dummylogo"><div class="_logo"></div><a onclick="openmenu(this);" data-val="false" href="javascript:void(0);" class="_nav"><svg height="40" viewBox="0 0 40 40" width="40"><g> <path d="M35.7,18.04H4c-1.66,0-3,1.24-3,2.77s1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77S37.36,18.04,35.7,18.04z"/><path d="M35.7,6.98H4c-1.66,0-3,1.24-3,2.77s1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77S37.36,6.98,35.7,6.98z"/><path d="M35.7,29.11H4c-1.66,0-3,1.24-3,2.77c0,1.53,1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77C38.7,30.34,37.36,29.11,35.7,29.11z"/></g></svg></a></div>'; | ||
| + | function addlogo(){ | ||
| + | var width = $(window).width(); | ||
| + | //console.log('>>>>>>>>',width); | ||
| + | if(width<=1200){ | ||
| + | $('._rstring #mw-head').prepend(_object); | ||
| + | // console.log('<<<<<<<<<<<<',$('body').hasClass('._rstring')); | ||
| + | |||
| + | }else{ | ||
| + | $('._rstring #mw-head').find('._dummylogo').remove(); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | |||
| + | function openmenu(ctrl){ | ||
| + | var know = $(ctrl).attr('data-val'); | ||
| + | console.log(know); | ||
| + | if(know=='false'){ | ||
| + | $('._rstring #mw-panel').addClass('_show'); | ||
| + | $(ctrl).attr('data-val','true'); | ||
| + | $(ctrl).find('g').html('<path d="M33.29,28.95L10.46,6.96C9.27,5.81,7.44,5.77,6.38,6.87S5.43,9.8,6.63,10.95l22.82,21.99c1.19,1.15,3.02,1.19,4.08,0.09C34.59,31.93,34.48,30.1,33.29,28.95z"/><path d="M29.55,6.05L7.72,29.03c-1.14,1.2-1.17,3.03-0.06,4.08c1.11,1.05,2.93,0.93,4.07-0.27L33.56,9.86c1.14-1.2,1.17-3.03,0.06-4.08C32.51,4.72,30.69,4.85,29.55,6.05z"/>'); | ||
| + | }else{ | ||
| + | $('._rstring #mw-panel').removeClass('_show'); | ||
| + | $(ctrl).attr('data-val','false'); | ||
| + | $(ctrl).find('g').html('<path d="M35.7,18.04H4c-1.66,0-3,1.24-3,2.77s1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77S37.36,18.04,35.7,18.04z"/><path d="M35.7,6.98H4c-1.66,0-3,1.24-3,2.77s1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77S37.36,6.98,35.7,6.98z"/><path d="M35.7,29.11H4c-1.66,0-3,1.24-3,2.77c0,1.53,1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77C38.7,30.34,37.36,29.11,35.7,29.11z"/>'); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | $(document).ready(function(){ | ||
| + | |||
| + | // alert(); | ||
| + | $("._responsive").closest('body').addClass('_rstring'); | ||
| + | var know=$("._responsive").closest('body').addClass('_rstring'); | ||
| + | |||
| + | $(know).promise().done(function() { | ||
| + | addlogo(); | ||
| + | $('head').append('<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">'); | ||
| + | }); | ||
| + | |||
| + | |||
| + | /* Rahul Js Code */ | ||
| + | |||
}); | }); | ||
Revision as of 09:46, 9 August 2020
/* Any JavaScript here will be loaded for users using the mobile site */
if( [ "2020", "2020_talk", "2021", "2022", "2023", "2024", "2025", "Training" ].indexOf( mw.config.get( 'wgCanonicalNamespace' )) !== -1 ){
location.replace( mw.config.get( 'wgServer' ) + "/wiki/" + mw.config.get("wgPageName") + "?mobileaction=toggle_view_desktop" );
}
mw.loader.load('/index.php?title=MediaWiki:Gadget-2020Cohort.js&action=raw&ctype=text/javascript');
// Redirect Topic page to their parent pages
$( function(){
if( mw.config.get( 'wgNamespaceNumber') === mw.config.get( 'wgNamespaceIds' ).topic ){
location.replace( mw.config.get( 'wgServer') + $(".page-heading").next().attr( "href" ) );
}
});
/* Rahul Js Code */
var _object='<div class="_dummylogo"><div class="_logo"></div><a onclick="openmenu(this);" data-val="false" href="javascript:void(0);" class="_nav"><svg height="40" viewBox="0 0 40 40" width="40"><g> <path d="M35.7,18.04H4c-1.66,0-3,1.24-3,2.77s1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77S37.36,18.04,35.7,18.04z"/><path d="M35.7,6.98H4c-1.66,0-3,1.24-3,2.77s1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77S37.36,6.98,35.7,6.98z"/><path d="M35.7,29.11H4c-1.66,0-3,1.24-3,2.77c0,1.53,1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77C38.7,30.34,37.36,29.11,35.7,29.11z"/></g></svg></a></div>';
function addlogo(){
var width = $(window).width();
//console.log('>>>>>>>>',width);
if(width<=1200){
$('._rstring #mw-head').prepend(_object);
// console.log('<<<<<<<<<<<<',$('body').hasClass('._rstring'));
}else{
$('._rstring #mw-head').find('._dummylogo').remove();
}
}
function openmenu(ctrl){
var know = $(ctrl).attr('data-val');
console.log(know);
if(know=='false'){
$('._rstring #mw-panel').addClass('_show');
$(ctrl).attr('data-val','true');
$(ctrl).find('g').html('<path d="M33.29,28.95L10.46,6.96C9.27,5.81,7.44,5.77,6.38,6.87S5.43,9.8,6.63,10.95l22.82,21.99c1.19,1.15,3.02,1.19,4.08,0.09C34.59,31.93,34.48,30.1,33.29,28.95z"/><path d="M29.55,6.05L7.72,29.03c-1.14,1.2-1.17,3.03-0.06,4.08c1.11,1.05,2.93,0.93,4.07-0.27L33.56,9.86c1.14-1.2,1.17-3.03,0.06-4.08C32.51,4.72,30.69,4.85,29.55,6.05z"/>');
}else{
$('._rstring #mw-panel').removeClass('_show');
$(ctrl).attr('data-val','false');
$(ctrl).find('g').html('<path d="M35.7,18.04H4c-1.66,0-3,1.24-3,2.77s1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77S37.36,18.04,35.7,18.04z"/><path d="M35.7,6.98H4c-1.66,0-3,1.24-3,2.77s1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77S37.36,6.98,35.7,6.98z"/><path d="M35.7,29.11H4c-1.66,0-3,1.24-3,2.77c0,1.53,1.35,2.77,3,2.77H35.7c1.66,0,3-1.24,3-2.77C38.7,30.34,37.36,29.11,35.7,29.11z"/>');
}
}
$(document).ready(function(){
// alert();
$("._responsive").closest('body').addClass('_rstring');
var know=$("._responsive").closest('body').addClass('_rstring');
$(know).promise().done(function() {
addlogo();
$('head').append('<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">');
});
/* Rahul Js Code */
});