Difference between revisions of "MediaWiki:Mobile.js"

From Larnitech wiki page
Jump to navigation Jump to search
m (1 revision imported)
Line 18: Line 18:
 
   mw.log.warn('addPortletLink is deprecated on desktop and never implemented on mobile', 'More information on https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)#addPortletLink');
 
   mw.log.warn('addPortletLink is deprecated on desktop and never implemented on mobile', 'More information on https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)#addPortletLink');
 
}
 
}
 +
 +
var timer = setInterval(function() {
 +
      if ($('.menu ul:first').length) {
 +
          console.log("mobile menu exists");
 +
          clearInterval(timer);
 +
          $('.menu ul:first').after(
 +
                '<ul class="level1"> \
 +
                      <li> \
 +
                      <a href="#" \
 +
                            class="mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-watchlist"> \
 +
                      <span>Dropdown Links</span> \
 +
                      </a> \
 +
                      </li> \
 +
                      <ul class ="level2"> \
 +
                          <li> \
 +
                          <a href="http://wiki2.larnitech.com/index.php/How_to_do" \
 +
                                class="mw-ui-icon mw-ui-icon-before"> \
 +
                          <span>How to do</span> \
 +
                          </a> \
 +
                          </li> \
 +
                          <li> \
 +
                          <a href="http://wiki2.larnitech.com/index.php/Din-rail" \
 +
                                class="mw-ui-icon mw-ui-icon-before"> \
 +
                          <span>Din rail devices</span> \
 +
                          </a> \
 +
                          </li> \
 +
                          <li> \
 +
                          <a href="http://wiki2.larnitech.com/index.php/box" \
 +
                                class="mw-ui-icon mw-ui-icon-before"> \
 +
                          <span>Box devices</span> \
 +
                          </a> \
 +
                          </li> \
 +
                          <li> \
 +
                          <a href="http://wiki2.larnitech.com/index.php/app" \
 +
                                class="mw-ui-icon mw-ui-icon-before"> \
 +
                          <span>Application</span> \
 +
                          </a> \
 +
                          </li> \
 +
                          <li> \
 +
                          <a href="http://wiki2.larnitech.com/index.php/xml" \
 +
                                class="mw-ui-icon mw-ui-icon-before"> \
 +
                          <span>Xml</span> \
 +
                          </a> \
 +
                          </li> \
 +
                      </ul> \
 +
                </ul> \
 +
                <ul> \
 +
                      <li> \
 +
                      <a href="/wiki/Second_Link" \
 +
                            class="mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-watchlist"> \
 +
                      <span>Second Link</span> \
 +
                      </a> \
 +
                      </li> \
 +
                </ul>'
 +
            );
 +
            $(".menu").find(".level2").hide(); // hide level2 until level1 is clicked
 +
            $(".level1").click(function(event){
 +
                $(this).find(".level2").slideToggle(500);
 +
            }); // if level1 is clicked, dropdown level2
 +
      }
 +
  }, 100); // check every 100ms

Revision as of 08:58, 20 July 2021

/* All JavaScript here will be loaded for users of the mobile site */
/* Note, there is no corresponding User:Username/mobile.js; however users may use User:Username/minerva.js */
// This script should be removed when all usages of `importScript` have been removed on English Wikipedia.
// importScript is deprecated on desktop, and removed on mobile.
// This was added on 25th January 2021. We can remove it at the end of February, and review whether the offending scripts have been fixed.
function  importScript(name) {
/* - Disabled pending additional discussion
  var $notification = $('<span>').html('An attempt to load a <a>user script</a> has failed. Please see JavaScript console for more information.');
  $notification.find('a').attr('href', '/w/index.php?title=' + name );
  mw.notify($notification);
*/
  mw.log.warn('importScript is deprecated on desktop and never implemented on mobile', 'More information on https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)#importScript');
}
function  importStylesheet(name) {
  mw.log.warn('importStylesheet is deprecated on desktop and never implemented on mobile', 'More information on https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)#importStylesheet');
}
function  addPortletLink() {
  mw.log.warn('addPortletLink is deprecated on desktop and never implemented on mobile', 'More information on https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)#addPortletLink');
}

var timer = setInterval(function() {
       if ($('.menu ul:first').length) {
           console.log("mobile menu exists");
           clearInterval(timer);
           $('.menu ul:first').after(
                 '<ul class="level1"> \
                      <li> \
                      <a href="#" \
                            class="mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-watchlist"> \
                      <span>Dropdown Links</span> \
                      </a> \
                      </li> \
                      <ul class ="level2"> \
                           <li> \
                           <a href="http://wiki2.larnitech.com/index.php/How_to_do" \
                                 class="mw-ui-icon mw-ui-icon-before"> \
                           <span>How to do</span> \
                           </a> \
                           </li> \
                           <li> \
                           <a href="http://wiki2.larnitech.com/index.php/Din-rail" \
                                 class="mw-ui-icon mw-ui-icon-before"> \
                           <span>Din rail devices</span> \
                           </a> \
                           </li> \
                           <li> \
                           <a href="http://wiki2.larnitech.com/index.php/box" \
                                 class="mw-ui-icon mw-ui-icon-before"> \
                           <span>Box devices</span> \
                           </a> \
                           </li> \
                           <li> \
                           <a href="http://wiki2.larnitech.com/index.php/app" \
                                 class="mw-ui-icon mw-ui-icon-before"> \
                           <span>Application</span> \
                           </a> \
                           </li> \
                           <li> \
                           <a href="http://wiki2.larnitech.com/index.php/xml" \
                                 class="mw-ui-icon mw-ui-icon-before"> \
                           <span>Xml</span> \
                           </a> \
                           </li> \
                      </ul> \
                 </ul> \
                 <ul> \
                      <li> \
                      <a href="/wiki/Second_Link" \
                            class="mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-watchlist"> \
                      <span>Second Link</span> \
                      </a> \
                      </li> \
                 </ul>'
            );
            $(".menu").find(".level2").hide(); // hide level2 until level1 is clicked
            $(".level1").click(function(event){ 
                 $(this).find(".level2").slideToggle(500);
            }); // if level1 is clicked, dropdown level2
       }
  }, 100); // check every 100ms