From 7b302a284b6f3254c94db6407e892d62352c3929 Mon Sep 17 00:00:00 2001 From: "Alexia E. Smith" Date: Wed, 24 Jan 2018 14:14:12 -0600 Subject: [PATCH] 2.4.1 - Switch hash tab switching. Target mobile. Remove deprecated files. --- Tabber.i18n.php | 35 ----------------------------------- Tabber.php | 44 -------------------------------------------- extension.json | 8 ++++++-- js/tabber.js | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 82 deletions(-) delete mode 100644 Tabber.i18n.php delete mode 100644 Tabber.php diff --git a/Tabber.i18n.php b/Tabber.i18n.php deleted file mode 100644 index 0c2be01..0000000 --- a/Tabber.i18n.php +++ /dev/null @@ -1,35 +0,0 @@ - __FILE__, - 'name' => 'Tabber', - 'author' => ['Eric Fortin', 'Alexia E. Smith'], - 'url' => 'https://www.mediawiki.org/wiki/Extension:Tabber', - 'descriptionmsg' => 'tabber-desc', - 'version' => '2.4' -]; -$wgExtensionCredits['parserhook'][] = $credits; - - -/******************************************/ -/* Language Strings, Page Aliases, Hooks */ -/******************************************/ -$extDir = __DIR__.'/'; - -$wgMessagesDirs['Tabber'] = "{$extDir}/i18n"; -$wgExtensionMessagesFiles['Tabber'] = "{$extDir}/Tabber.i18n.php"; - -$wgAutoloadClasses['TabberHooks'] = "{$extDir}/Tabber.hooks.php"; - -$wgHooks['ParserFirstCallInit'][] = 'TabberHooks::onParserFirstCallInit'; - -$wgResourceModules['ext.Tabber'] = [ - 'localBasePath' => __DIR__, - 'remoteExtPath' => 'Tabber', - 'styles' => ['css/tabber.css'], - 'scripts' => ['js/tabber.js'] -]; diff --git a/extension.json b/extension.json index 6d1c37b..1d7107b 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "Tabber", - "version": "2.4", + "version": "2.4.1", "author": [ "Eric Fortin", "Alexia E. Smith" @@ -14,7 +14,7 @@ ] }, "AutoloadClasses": { - "TabberHooks": "/Tabber.hooks.php" + "TabberHooks": "Tabber.hooks.php" }, "ResourceModules": { "ext.Tabber": { @@ -23,6 +23,10 @@ ], "scripts": [ "js/tabber.js" + ], + "targets": [ + "desktop", + "mobile" ] } }, diff --git a/js/tabber.js b/js/tabber.js index b6599a9..216c025 100644 --- a/js/tabber.js +++ b/js/tabber.js @@ -44,12 +44,26 @@ e.preventDefault(); if ( history.pushState ) { history.pushState( null, null, '#' + title ); + switchTab(title); } else { location.hash = '#' + title; } - showContent( title ); } ); + $(window).on('hashchange', function(event) { + switchTab(event); + }); + + function switchTab(event) { + var tab = location.hash.replace('#', ''); + if (!tab.length) { + showContent(tabContent.first().attr('title')); + } + if (nav.find('a[title="'+tab+'"]').length) { + showContent(tab); + } + } + $this.addClass( 'tabberlive' ); } ); };