User:Lizzyrun15/chat.css

/* QuickDiff - quickly view any diff link */ /*jslint browser, single */ /*global window, jQuery, mediaWiki, require */ (function ($, mw) {   'use strict';    // double-run protection    if (window.quickDiffLoaded) {        return;    }    window.quickDiffLoaded = true;    var msg = {        en: {            error: 'Something went wrong while getting the page at “%url”.',            loading: 'Loading…',            title: 'Changes: %pagename'        }    };    // use user language, with English as fallback    msg = $.extend(msg.en, msg[mw.config.get('wgUserLanguage')]);    var currentModal = null;    var uiModalFactory = null;    function showModal(content, title) {        if (uiModalFactory) {            uiModalFactory.createComponent({ vars: { content: content, id: 'quickdiff-modal', size: 'large', title: title },               confirmCloseModal: function  { currentModal = null; return true; }           }, function (modal) { modal.$content.addClass('WikiaArticle'); // better Oasis styling currentModal = modal; modal.show; });       } else {            require(['wikia.ui.factory'], function (uiFactory) { uiFactory.init('modal').then(function (uiModal) {                   uiModalFactory = uiModal;                    showModal(content, title);                }); });       }    }    function updateModal(content, title) {        if (!currentModal) {            title = title || msg.loading;            showModal(content, msg.title.replace('%pagename', title));        } else {            if (typeof title === 'string') {                currentModal.setTitle(msg.title.replace('%pagename', title));            }            currentModal.setContent(content);        }    }    function loadDiff(url) {        updateModal(' ');        // add 'action=render' and 'diffonly' params to save some bytes on each request        url.extend({ action: 'render', diffonly: '1' });       var urlString = url.toString;        $.get(urlString).always(function (content) { if (typeof content === 'string' && $(content).hasClass('diff')) { var title = $(content).find('#mw-diff-ntitle1 > strong > a').attr('title'); mw.loader.using('mediawiki.action.history.diff', function {                    updateModal(content, title);                }); return; }           updateModal(msg.error.replace('%url', urlString)); });   }    function init {        mw.util.addCSS( '#quickdiff-modal {' + 'padding: 0;' +         // remove footer padding '}' +           '#quickdiff-modal > footer {' + 'display: none;' +      // hide footer '}' +           '#quickdiff-modal > section {' + 'font-size: 13px;' +    // better MonoBook font styling 'line-height: 21px;' + 'overflow: auto;' +     // set to visible on .WikiaArticle in message wall / forum namespaces 'position: relative;' + // prevents throbber showing over title '}'       );        // attach to body for compatibility with ajax-loaded content        // also, one attached event handler is better than hundreds!        $(document.body).on('click.quickdiff', 'a', function (event) { var url = new mw.Uri(event.currentTarget.href); if (               url.host === location.hostname &&  // same domain                url.query.diff &&  // has diff param                !url.fragment      // no fragment (prevents triggering by section links on diff pages)            ) { event.preventDefault; loadDiff(url); }       });    }    $(init); }(jQuery, mediaWiki));