From 1565a1d3c94c50add49beb8619998e907903fe85 Mon Sep 17 00:00:00 2001 From: Prateek Saxena Date: Tue, 11 Aug 2015 19:15:24 +0530 Subject: [PATCH] Move the article renderer in to the renderers property To allow multiple renderers (for different types of content) to be defined. Change-Id: I50320646e26f36a0a2bc425c82ccc58912840f84 --- resources/ext.popups.renderer.article.js | 2 +- resources/ext.popups.renderer.js | 8 +++++++- tests/qunit/ext.popups.renderer.article.test.js | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/resources/ext.popups.renderer.article.js b/resources/ext.popups.renderer.article.js index 5be74c816..3c7fdea91 100644 --- a/resources/ext.popups.renderer.article.js +++ b/resources/ext.popups.renderer.article.js @@ -558,6 +558,6 @@ } }; - mw.popups.render.article = article; + mw.popups.render.renderers.article = article; } ) ( jQuery, mediaWiki ); diff --git a/resources/ext.popups.renderer.js b/resources/ext.popups.renderer.js index bfcd0c44d..fdf758be1 100644 --- a/resources/ext.popups.renderer.js +++ b/resources/ext.popups.renderer.js @@ -54,6 +54,12 @@ */ mw.popups.render.currentRequest = undefined; + /** + * Object to store all renderers + * @property {Object} renderers + */ + mw.popups.render.renderers = {}; + /** * Close all other popups and render the new one from the cache * or by finding and calling the correct renderer @@ -104,7 +110,7 @@ .done( function () { // TODO: check for link type and call correct renderer // There is only one popup type right now so it isn't necessary - var cachePopup = mw.popups.render.article.init( link ); + var cachePopup = mw.popups.render.renderers.article.init( link ); mw.popups.render.openTimer = mw.popups.render.wait( mw.popups.render.POPUP_DELAY - mw.popups.render.API_DELAY ); diff --git a/tests/qunit/ext.popups.renderer.article.test.js b/tests/qunit/ext.popups.renderer.article.test.js index 6c735f077..342ac1aae 100644 --- a/tests/qunit/ext.popups.renderer.article.test.js +++ b/tests/qunit/ext.popups.renderer.article.test.js @@ -1,13 +1,13 @@ ( function ( $, mw ) { - QUnit.module( 'ext.popups.renderer.article', QUnit.newMwEnvironment() ); + QUnit.module( 'ext.popups.renderer.renderers.article', QUnit.newMwEnvironment() ); QUnit.test( 'render.article.getProcessedElements', function ( assert ) { QUnit.expect( 13 ); function test ( extract, title, expected, msg ) { var $div = $( '
' ).append( - mw.popups.render.article.getProcessedElements( extract, title ) + mw.popups.render.renderers.article.getProcessedElements( extract, title ) ); assert.equal( $div.html(), expected, msg ); }