From 27d811a1737e64f3aa26361337297b8a9f2b5b03 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Thu, 12 May 2016 15:58:53 -0700 Subject: [PATCH] Rewrite createPopup with template for better readability Change-Id: If646623ba4ebf5dfac2a94c73b6f053131739767 --- Popups.hooks.php | 3 ++ resources/ext.popups.renderer.article.js | 60 +++++++++--------------- resources/popup.mustache | 12 +++++ 3 files changed, 38 insertions(+), 37 deletions(-) create mode 100644 resources/popup.mustache diff --git a/Popups.hooks.php b/Popups.hooks.php index 8663a905b..8af73dade 100644 --- a/Popups.hooks.php +++ b/Popups.hooks.php @@ -76,6 +76,9 @@ class PopupsHooks { 'resources/ext.popups.disablenavpop.js', 'resources/ext.popups.settings.js', ), + 'templates' => array( + 'popup.mustache' => 'resources/popup.mustache', + ), 'styles' => array( 'resources/ext.popups.animation.less', 'resources/ext.popups.settings.less', diff --git a/resources/ext.popups.renderer.article.js b/resources/ext.popups.renderer.article.js index d0aa1c48e..67e52e2e5 100644 --- a/resources/ext.popups.renderer.article.js +++ b/resources/ext.popups.renderer.article.js @@ -115,51 +115,37 @@ * @return {jQuery} */ article.createPopup = function ( page, href ) { - var $div, - $contentbox = $( '' ) - .attr( { - href: href, - lang: page.pagelanguagehtmlcode, - dir: page.pagelanguagedir - } ) - .addClass( 'mwe-popups-extract' ) - .append( - article.getProcessedElements( page.extract, page.title ) - ), + var $div, hasThumbnail, thumbnail = page.thumbnail, tall = thumbnail && thumbnail.height > thumbnail.width, $thumbnail = article.createThumbnail( thumbnail, tall ), timestamp = new Date( page.revisions[ 0 ].timestamp ), timediff = new Date() - timestamp, - oneDay = 1000 * 60 * 60 * 24, - timestampclass = ( timediff < oneDay ) ? - 'mwe-popups-timestamp-recent' : - 'mwe-popups-timestamp-older', - $settingsImage = $( '' ).addClass( 'mwe-popups-icon mwe-popups-settings-icon' ), - $footer = $( '