MediaWiki:NoImageLightbox/code.js

/** * @fileOverview NoImageLightbox * http://dev.wikia.com/wiki/NoImageLightbox/code.js * - Kills image lightbox so that clicking an image takes you to the File: * - Videos use the same LightboxLoader.handleClick method that images do, *    so if that method is deleted, then videos can no longer be played, *    but this version uses a trick/hack to make sure that if a video is *     clicked, then the LightboxLoader.handleClick is still called properly * - Available under Creative Commons Attribution-Share Alike License 3.0 * @author User:Mathmagician */ $(function {    if ("oasis" != skin && "wikia" != skin) return;    var clickedVideo = false;    function killImageLightbox {        // hack to not kill lightbox for videos        if (window.LightboxLoader && !LightboxLoader.handleClickOverride) {            LightboxLoader.handleClickOverride = LightboxLoader.handleClick;            LightboxLoader.handleClick = function  {                if (clickedVideo) {                    clickedVideo = false;                    LightboxLoader.handleClickOverride.apply(this, arguments);                }            };        }    }    // playing it safe...    killImageLightbox;    setTimeout(killImageLightbox, 2000);    setTimeout(killImageLightbox, 5000);    setTimeout(killImageLightbox, 8000);    // hack to not kill lightbox for videos    $('a[data-video-name]').click(function  { clickedVideo = true; console.log('clickedVideo == true'); });   // href to File: page    $('a[data-image-name]')    .each(function  { var $this = $(this); var e = encodeURIComponent($this.attr('data-image-name').replace(/ /g, '_')); $this.attr('href', '/wiki/File:' + e); }); });