MediaWiki:Modal/demo.js

/** * Demo for the Modal library. */ require(['wikia.window', 'jquery', 'mw'], function(window, $, mw) {   var ModalDemo = {        loading: 2,        modal: function(modal) {            this.modal = modal;            this.load;        },        ui: function(ui) {            this.ui = ui;            this.load;        },        load: function {            if (--this.loading === 0) {                this.modals = {};                if (mw.util.$content) {                    this.content(mw.util.$content);                }                mw.hook('wikipage.content')                    .add($.proxy(this.content, this));            }        },        content: function($content) {            $('span[data-modal-demo]:not(.loaded)')                .each($.proxy(this.each, this));        },        each: function {            var $this = $(this),                modal = $this.data('modal-demo'),                func = this[modal + 'Modal']; $this.addClass('loaded'); if (typeof func !== 'function') { console.warn('Invalid modal demo!', modal); return; }           $this.click($.proxy(this.click, this)); },       click: function { this.modals[$(this).data('modal-demo')] }   };    importArticles({        type: 'script',        articles: [            'u:dev:MediaWiki:UI-js/code.js',            'u:dev:MediaWiki:Modal.js'        ]    }); mw.hook('dev.modal').add($.proxy(ModalDemo.modal, ModalDemo)); mw.hook('dev.ui').add($.proxy(ModalDemo.ui, ModalDemo)); });