Index: trunk/extensions/JSBreadCrumbs/css/BreadCrumbs.css |
— | — | @@ -0,0 +1,7 @@ |
| 2 | +/* BreadCrumbs plugin */ |
| 3 | + |
| 4 | +.breadcrumbs { |
| 5 | + position: relative; |
| 6 | + font-size:0.8em; |
| 7 | + top: -15px; |
| 8 | +} |
Property changes on: trunk/extensions/JSBreadCrumbs/css/BreadCrumbs.css |
___________________________________________________________________ |
Name: svn:mime-type |
1 | 9 | + text/plain |
Index: trunk/extensions/JSBreadCrumbs/JSBreadCrumbs.i18n.php |
— | — | @@ -0,0 +1,16 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation file for extension JSBreadCrumbs. |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Ryan Lane |
| 14 | + */ |
| 15 | +$messages['en'] = array( |
| 16 | + 'jsbreadcrumbs-desc' => 'Adds a trail of breadcrumbs below the tab bar.', |
| 17 | +); |
Index: trunk/extensions/JSBreadCrumbs/JSBreadCrumbs.php |
— | — | @@ -0,0 +1,42 @@ |
| 2 | +<?php |
| 3 | +# Copyright (C) 2010 Ryan Lane <http://www.mediawiki.org/wiki/User:Ryan_lane> |
| 4 | +# |
| 5 | +# This program is free software; you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU General Public License as published by |
| 7 | +# the Free Software Foundation; either version 2 of the License, or |
| 8 | +# (at your option) any later version. |
| 9 | +# |
| 10 | +# This program is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +# GNU General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU General Public License along |
| 16 | +# with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | +# http://www.gnu.org/copyleft/gpl.html |
| 19 | + |
| 20 | +$wgJSBreadCrumbsMaxCrumbs = 5; |
| 21 | +$wgJSBreadCrumbsSeparator = "»"; |
| 22 | + |
| 23 | +// Sets Credits |
| 24 | +$wgExtensionCredits['other'][] = array( |
| 25 | + 'path' => __FILE__, |
| 26 | + 'name' => 'JSBreadCrumbs', |
| 27 | + 'author' => 'Ryan Lane', |
| 28 | + 'version' => '0.1', |
| 29 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:JSBreadCrumbs', |
| 30 | + 'descriptionmsg' => 'jsbreadcrumbs-desc', |
| 31 | +); |
| 32 | + |
| 33 | +// Adds Autoload Classes |
| 34 | +$wgAutoloadClasses['JSBreadCrumbsHooks'] = |
| 35 | + dirname( __FILE__ ) . "/JSBreadCrumbs.hooks.php"; |
| 36 | + |
| 37 | +// Adds Internationalized Messages |
| 38 | +$wgExtensionMessagesFiles['JSBreadCrumbs'] = |
| 39 | + dirname( __FILE__ ) . "/JSBreadCrumbs.i18n.php"; |
| 40 | + |
| 41 | +// Registers Hooks |
| 42 | +$wgHooks['BeforePageDisplay'][] = 'JSBreadCrumbsHooks::addResources'; |
| 43 | +$wgHooks['MakeGlobalVariablesScript'][] = 'JSBreadCrumbsHooks::addJSVars'; |
Index: trunk/extensions/JSBreadCrumbs/js/BreadCrumbs.js |
— | — | @@ -0,0 +1,41 @@ |
| 2 | +$j(document).ready( function() { |
| 3 | + // Set defaults if included as a gadget, otherwise they should |
| 4 | + // be defined by the extension. |
| 5 | + if ( typeof wgJSBreadCrumbsMaxCrumbs == "undefined" ) { |
| 6 | + wgJSBreadCrumbsMaxCrumbs = 5; |
| 7 | + } |
| 8 | + if ( typeof wgJSBreadCrumbsSeparator == "undefined" ) { |
| 9 | + wgJSBreadCrumbsSeparator = "»"; |
| 10 | + } |
| 11 | + |
| 12 | + var titleState = ( $j.cookie( 'mwext-bc-title' ) || "" ).split( wgJSBreadCrumbsSeparator ); |
| 13 | + var urlState = ( $j.cookie( 'mwext-bc-url' ) || "" ).split( wgJSBreadCrumbsSeparator ); |
| 14 | + |
| 15 | + if ( titleState.length >= wgJSBreadCrumbsMaxCrumbs ) { |
| 16 | + titleState = titleState.slice( titleState.length - wgJSBreadCrumbsMaxCrumbs ); |
| 17 | + urlState = urlState.slice( urlState.length - wgJSBreadCrumbsMaxCrumbs ); |
| 18 | + } |
| 19 | + |
| 20 | + $j( "#top" ).before( '<span id="mwext-bc" class="noprint plainlinks breadcrumbs"></span>' ); |
| 21 | + var mwextbc = $j( "#mwext-bc" ); |
| 22 | + |
| 23 | + // Remove duplicates |
| 24 | + var matchTitleIndex = $j.inArray( wgPageName, titleState ); |
| 25 | + var matchUrlIndex = $j.inArray( location.pathname + location.search, urlState ); |
| 26 | + if ( matchTitleIndex != -1 && ( matchUrlIndex == matchTitleIndex ) ) { |
| 27 | + titleState.splice( matchTitleIndex, 1 ); |
| 28 | + urlState.splice( matchTitleIndex, 1 ); |
| 29 | + } |
| 30 | + |
| 31 | + for ( var i = 0; i < titleState.length; i++ ) { |
| 32 | + mwextbc.append( '<a href="' + urlState[i] + '">' + titleState[i] + '</a> ' + wgJSBreadCrumbsSeparator + ' ' ); |
| 33 | + } |
| 34 | + |
| 35 | + mwextbc.append( '<a href="' + location.pathname + location.search + '">' + wgPageName + '</a>' ); |
| 36 | + |
| 37 | + titleState.push( wgPageName ); |
| 38 | + urlState.push( location.pathname + location.search ); |
| 39 | + |
| 40 | + $j.cookie( 'mwext-bc-title', titleState.join( wgJSBreadCrumbsSeparator ), { path: '/' } ); |
| 41 | + $j.cookie( 'mwext-bc-url', urlState.join( wgJSBreadCrumbsSeparator ), { path: '/' } ); |
| 42 | +} ); |
Property changes on: trunk/extensions/JSBreadCrumbs/js/BreadCrumbs.js |
___________________________________________________________________ |
Name: svn:mime-type |
1 | 43 | + text/plain |
Index: trunk/extensions/JSBreadCrumbs/JSBreadCrumbs.hooks.php |
— | — | @@ -0,0 +1,27 @@ |
| 2 | +<?php |
| 3 | +class JSBreadCrumbsHooks { |
| 4 | + |
| 5 | + function addResources( $out ) { |
| 6 | + global $wgExtensionAssetsPath; |
| 7 | + |
| 8 | + $out->addScriptFile( "$wgExtensionAssetsPath/JSBreadCrumbs/js/BreadCrumbs.js", 1 ); |
| 9 | + $out->addExtensionStyle( "$wgExtensionAssetsPath/JSBreadCrumbs/css/BreadCrumbs.css?1" ); |
| 10 | + |
| 11 | + return true; |
| 12 | + } |
| 13 | + |
| 14 | + /** |
| 15 | + * MakeGlobalVariablesScript hook |
| 16 | + */ |
| 17 | + public static function addJSVars( $vars ) { |
| 18 | + global $wgJSBreadCrumbsMaxCrumbs, $wgJSBreadCrumbsSeparator; |
| 19 | + |
| 20 | + $variables = array(); |
| 21 | + |
| 22 | + $variables['wgJSBreadCrumbsMaxCrumbs'] = $wgJSBreadCrumbsMaxCrumbs; |
| 23 | + $variables['wgJSBreadCrumbsSeparator'] = $wgJSBreadCrumbsSeparator; |
| 24 | + |
| 25 | + $vars = array_merge( $vars, $variables ); |
| 26 | + return true; |
| 27 | + } |
| 28 | +} |