Jdlrobson has uploaded a new change for review. https://gerrit.wikimedia.org/r/237705
Change subject: Last modified code no longer needs to be loaded in head ...................................................................... Last modified code no longer needs to be loaded in head (Merge after 30 days as passed to allow cached pages to catch up) Change-Id: I872d283f6ab1b8763787581f50c0935b945dbc1c --- M includes/Resources.php M resources/mobile.head/init.js M resources/skins.minerva.scripts/init.js 3 files changed, 61 insertions(+), 57 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/05/237705/1 diff --git a/includes/Resources.php b/includes/Resources.php index 0a5cc17..74c9466 100644 --- a/includes/Resources.php +++ b/includes/Resources.php @@ -1685,7 +1685,6 @@ // This JavaScript is loaded at the top of the page so be cautious what you put in it. 'mobile.head' => $wgMFResourceFileModuleBoilerplate + array( 'dependencies' => array( - 'mobile.modifiedBar', 'mobile.mainMenu', 'mobile.browser', // 'mobile.oo' rather than 'mobile.modules' is need because lastEdited/init.js listens @@ -1698,16 +1697,6 @@ ), 'scripts' => array( 'resources/mobile.head/init.js', - ), - 'messages' => array( - // lastEdited.js - 'mobile-frontend-last-modified-with-user-seconds', - 'mobile-frontend-last-modified-with-user-minutes', - 'mobile-frontend-last-modified-with-user-hours', - 'mobile-frontend-last-modified-with-user-days', - 'mobile-frontend-last-modified-with-user-months', - 'mobile-frontend-last-modified-with-user-years', - 'mobile-frontend-last-modified-with-user-just-now', ), 'position' => 'top', ), @@ -1726,6 +1715,17 @@ 'mobile.references', 'mobile.redirect', 'mobile.betaoptin', + 'mobile.modifiedBar', + ), + 'messages' => array( + // lastEdited.js + 'mobile-frontend-last-modified-with-user-seconds', + 'mobile-frontend-last-modified-with-user-minutes', + 'mobile-frontend-last-modified-with-user-hours', + 'mobile-frontend-last-modified-with-user-days', + 'mobile-frontend-last-modified-with-user-months', + 'mobile-frontend-last-modified-with-user-years', + 'mobile-frontend-last-modified-with-user-just-now', ), 'scripts' => array( 'resources/skins.minerva.scripts/init.js', diff --git a/resources/mobile.head/init.js b/resources/mobile.head/init.js index fff935e..a816547 100644 --- a/resources/mobile.head/init.js +++ b/resources/mobile.head/init.js @@ -1,52 +1,10 @@ ( function ( M, $ ) { - var time = M.require( 'modules/lastEdited/time' ), + var MainMenu = M.require( 'MainMenu' ), mainMenu = new MainMenu( { // FIXME: remove #mw-mf-main-menu-button when cache clears activator: '#mw-mf-main-menu-button, .header .main-menu-button' } ); - - /** - * Initialisation function for last modified module. - * - * Enhances #mw-mf-last-modified element - * to show a human friendly date in seconds, minutes, hours, days - * months or years - * @ignore - */ - function initHistoryLink( $lastModifiedLink ) { - var delta, historyUrl, msg, - ts, username, gender; - - $lastModifiedLink = $lastModifiedLink || $( '#mw-mf-last-modified a' ); - historyUrl = $lastModifiedLink.attr( 'href' ); - ts = $lastModifiedLink.data( 'timestamp' ); - username = $lastModifiedLink.data( 'user-name' ) || false; - gender = $lastModifiedLink.data( 'user-gender' ); - - if ( ts ) { - delta = time.getTimeAgoDelta( parseInt( ts, 10 ) ); - if ( time.isRecent( delta ) ) { - $lastModifiedLink.closest( '.last-modified-bar' ).addClass( 'active' ); - } - msg = time.getLastModifiedMessage( ts, username, gender, historyUrl ); - $lastModifiedLink.replaceWith( msg ); - } - } - - /** - * Initialisation function for last modified module. - * - * Enhances #mw-mf-last-modified element - * to show a human friendly date in seconds, minutes, hours, days - * months or years - * @ignore - */ - function initModifiedInfo() { - $( '.modified-enhancement' ).each( function () { - initHistoryLink( $( this ) ); - } ); - } // bind events M.define( 'mainMenu', mainMenu ); @@ -56,12 +14,9 @@ } ); $( function () { - // Update anything else that needs enhancing (e.g. watchlist) - initModifiedInfo(); if ( !$( '#mw-mf-page-left' ).find( '.menu' ).length ) { mainMenu.appendTo( '#mw-mf-page-left' ); } - initHistoryLink(); } ); }( mw.mobileFrontend, jQuery ) ); diff --git a/resources/skins.minerva.scripts/init.js b/resources/skins.minerva.scripts/init.js index 847c5b8..13cc039 100644 --- a/resources/skins.minerva.scripts/init.js +++ b/resources/skins.minerva.scripts/init.js @@ -1,5 +1,6 @@ ( function ( M, $ ) { var inSample, inStable, + time = M.require( 'modules/lastEdited/time' ), settings = M.require( 'settings' ), token = settings.get( 'mobile-betaoptin-token' ), BetaOptinPanel = M.require( 'mobile.betaoptin/BetaOptinPanel' ), @@ -134,4 +135,52 @@ mw.track( 'minerva.betaoptin', { isPanelShown: betaOptinPanel !== undefined } ); + + /** + * Initialisation function for last modified module. + * + * Enhances an element representing a time + * to show a human friendly date in seconds, minutes, hours, days + * months or years + * @ignore + * @param {JQuery.Object} [$lastModifiedLink] + */ + function initHistoryLink( $lastModifiedLink ) { + var delta, historyUrl, msg, + ts, username, gender; + + historyUrl = $lastModifiedLink.attr( 'href' ); + ts = $lastModifiedLink.data( 'timestamp' ); + username = $lastModifiedLink.data( 'user-name' ) || false; + gender = $lastModifiedLink.data( 'user-gender' ); + + if ( ts ) { + delta = time.getTimeAgoDelta( parseInt( ts, 10 ) ); + if ( time.isRecent( delta ) ) { + $lastModifiedLink.closest( '.last-modified-bar' ).addClass( 'active' ); + } + msg = time.getLastModifiedMessage( ts, username, gender, historyUrl ); + $lastModifiedLink.replaceWith( msg ); + } + } + + /** + * Initialisation function for last modified times + * + * Enhances .modified-enhancement element + * to show a human friendly date in seconds, minutes, hours, days + * months or years + * @ignore + */ + function initModifiedInfo() { + $( '.modified-enhancement' ).each( function () { + initHistoryLink( $( this ) ); + } ); + } + + $( function () { + // Update anything else that needs enhancing (e.g. watchlist) + initModifiedInfo(); + initHistoryLink( $( '#mw-mf-last-modified a' ) ); + } ); }( mw.mobileFrontend, jQuery ) ); -- To view, visit https://gerrit.wikimedia.org/r/237705 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I872d283f6ab1b8763787581f50c0935b945dbc1c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits