User:Dorumin/chat.js

// Speedo you owe me a boat // Scope limiting and double-run protection var conf = mw.config.get([       'wgCanonicalSpecialPageName',        'wgUserName'    ]); if (       (window.dev || {}).hasOwnProperty('mobilechat') ||        conf.wgCanonicalSpecialPageName !== 'Chat'    ) { return; }   (window.dev = window.dev || {}).mobilechat = {}; /**    * Main MessageBlocker class. * @class mc    */ var mc = {}; /**    * Script initialiser * @method init * @returns {Boolean} true */   mc.init = function { mc.modules.forEach(function(m) { mc[m].init; }); $.when.apply(mc.modules.map(function(m) { return mc[m].$executed; })).then(function {           $.extend(window.dev.mobilechat, mc);            mw.hook('dev.mc').fire(window.dev.mc);        }); return true; };   /**     * Mobile chat views controller * @member {Object} views */   mc.views = { /**        * Views initialiser * @method init */       init: function { $(document.head).append(mc.views.vpt); mw.hook('dev.colors').add(function(c) {               mw.util.addCSS(mc.views.cssvars(c.wikia));            }); $(importArticle(mc.views.style)).load(function {               mc.views.$executed.resolve;                                }); },       /**         * CSS variables generator * @member {Object} params */       cssvars: function(w) { return ':root { ' + Object.keys(w).map(function(p) {               return '--color-' + p + ': ' + w[p] + ';';            }).join(' ') + ' }'; },       /**         * Stylesheet import parameters * @method style */       style: { type: 'style', article: 'u:dev:MediaWiki:MobileChat.css' },       /**         * Meta viewport for responsive design * @member {String} vpt */       vpt: mw.html.element('meta', {            name: 'viewport',            content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'        }), /**        * View load event (jQuery promise) * @member {Object} $executed */       $executed: $.Deferred };   /**     * Mobile chat interface controller * @member {Object} menu */   mc.ui = { /**        * Chat interface initialiser * @method init */       init: function { $(document.body).on('click',               '.Chat > ul > li',                mc.ui.menu__on            ); mc.ui.$executed.resolve; },       /**         * Chat menu activator * @method menu__on * @param {Object} e jQuery event data */       menu__on: function(e) { var u = $(e.target).closest('li').data('user'), v = $(mainRoom.model.users.findByName(u).view.el); if (conf.wgUserName !== u) { $(document.body) .addClass('mc-menu-is-active') .on('click', mc.ui.menu__off); mainRoom.mainListClick({ 'name': u, 'target': v }); }       },        /**         * Chat menu deactivator * @method menu__off * @param {Object} e jQuery event data */       menu__off: function(e) { if (!$(e.target).closest('#UserStatsMenu').length) { $(document.body) .removeClass('mc-menu-is-active') .off('click', mc.ui.menu__off); }       },        /**         * UI load event (jQuery promise) * @member {Object} $executed */       $executed: $.Deferred };   /**     * Module registry * @member {Array} modules */   mc.modules = Object.keys(mc).filter(function(m) {        return typeof mc[m].init === 'function';    }); // Script bootloader mw.hook('dev.colors').add(mc.init); /**    * Script dependencies * @member {Array.} scripts */   mc.scripts = importArticles({        type: 'script',        articles: 'u:dev:Colors/code.js'    }); }(window, mediaWiki, jQuery));
 * (function (window, mw, $) {