Difference between revisions of "MediaWiki:Mobile.js"
Jump to navigation
Jump to search
Ghanashyam (talk | contribs) |
Ghanashyam (talk | contribs) Tags: Mobile web edit, Mobile edit |
||
| Line 45: | Line 45: | ||
} | } | ||
} | } | ||
| + | |||
| + | |||
| + | var _leftnav= [ | ||
| + | {name:"Your Mission",link:"https://universityinnovation.org/wiki/2020:Training/Your_Mission"}, | ||
| + | {name:"Session 0",link:"https://universityinnovation.org/wiki/2020:Training/Session_0_(Orientation)"}, | ||
| + | {name:"Session 1",link:"https://universityinnovation.org/wiki/2020:Training/Your_Mission"}, | ||
| + | ] | ||
| + | |||
| + | var _html='<ul class="_setnav">'; | ||
| + | for(let item of _leftnav){ | ||
| + | |||
| + | _html +='<li> <a href="'+item.link+'">'+item.name+'</a> </li>'; | ||
| + | |||
| + | } | ||
| + | _html +='</ul>'; | ||
| + | |||
$(document).ready(function(){ | $(document).ready(function(){ | ||
| + | |||
// alert(); | // alert(); | ||
| Line 53: | Line 70: | ||
$(know).promise().done(function() { | $(know).promise().done(function() { | ||
| + | |||
| + | $('_rstring .menu.view-border-box').append(_html); | ||
// addlogo(); | // addlogo(); | ||
// $('head').append('<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">'); | // $('head').append('<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">'); | ||
Revision as of 08:07, 12 August 2020
/* Any JavaScript here will be loaded for users using the mobile site */
if( [ "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"/>');
}
}
var _leftnav= [
{name:"Your Mission",link:"https://universityinnovation.org/wiki/2020:Training/Your_Mission"},
{name:"Session 0",link:"https://universityinnovation.org/wiki/2020:Training/Session_0_(Orientation)"},
{name:"Session 1",link:"https://universityinnovation.org/wiki/2020:Training/Your_Mission"},
]
var _html='<ul class="_setnav">';
for(let item of _leftnav){
_html +='<li> <a href="'+item.link+'">'+item.name+'</a> </li>';
}
_html +='</ul>';
$(document).ready(function(){
// alert();
$("._responsive").closest('body').addClass('_rstring');
var know=$("._responsive").closest('body').addClass('_rstring');
$(know).promise().done(function() {
$('_rstring .menu.view-border-box').append(_html);
// addlogo();
// $('head').append('<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">');
});
/* Rahul Js Code */
});