Index: trunk/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.i18n.php |
— | — | @@ -0,0 +1,18 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation for Usability Initiative SimpleSearch extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Trevor Parscal |
| 14 | + */ |
| 15 | +$messages['en'] = array( |
| 16 | + 'simplesearch' => 'Simple Search', |
| 17 | + 'simplesearch-desc' => 'Adds extra functionality to the Vector\'s simplified search.', |
| 18 | + 'simplesearch-search' => 'Search', |
| 19 | +); |
Index: trunk/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.php |
— | — | @@ -0,0 +1,48 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Usability Initiative SimpleSearch extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * |
| 9 | + * This file contains the include file for the SimpleSearch portion of the |
| 10 | + * UsabilityInitiative extension of MediaWiki. |
| 11 | + * |
| 12 | + * Usage: Include the following line in your LocalSettings.php |
| 13 | + * require_once( "$IP/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.php" ); |
| 14 | + * |
| 15 | + * @author Trevor Parscal <tparscal@wikimedia.org> |
| 16 | + * @license GPL v2 or later |
| 17 | + * @version 0.1.1 |
| 18 | + */ |
| 19 | + |
| 20 | +/* Configuration */ |
| 21 | + |
| 22 | +// Bump the version number every time you change any of the .css/.js files |
| 23 | +$wgSimpleSearchStyleVersion = 3; |
| 24 | + |
| 25 | +/* Setup */ |
| 26 | + |
| 27 | +// Credits |
| 28 | +$wgExtensionCredits['other'][] = array( |
| 29 | + 'path' => __FILE__, |
| 30 | + 'name' => 'SimpleSearch', |
| 31 | + 'author' => 'Trevor Parscal', |
| 32 | + 'version' => '0.1.1', |
| 33 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SimpleSearch', |
| 34 | + 'descriptionmsg' => 'simplesearch-desc', |
| 35 | +); |
| 36 | + |
| 37 | +// Includes parent extension |
| 38 | +require_once( dirname( dirname( __FILE__ ) ) . "/UsabilityInitiative.php" ); |
| 39 | + |
| 40 | +// Adds Autoload Classes |
| 41 | +$wgAutoloadClasses['SimpleSearchHooks'] = |
| 42 | + dirname( __FILE__ ) . '/SimpleSearch.hooks.php'; |
| 43 | + |
| 44 | +// Adds Internationalized Messages |
| 45 | +$wgExtensionMessagesFiles['SimpleSearch'] = |
| 46 | + dirname( __FILE__ ) . '/SimpleSearch.i18n.php'; |
| 47 | + |
| 48 | +// Registers Hooks |
| 49 | +$wgHooks['AjaxAddScript'][] = 'SimpleSearchHooks::initialize'; |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.hooks.php |
— | — | @@ -0,0 +1,35 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Hooks for Usability Initiative SimpleSearch extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +class SimpleSearchHooks { |
| 11 | + |
| 12 | + /* Static Functions */ |
| 13 | + |
| 14 | + /** |
| 15 | + * AjaxAddScript hook |
| 16 | + * Initializes the component |
| 17 | + */ |
| 18 | + public static function initialize( $out ) { |
| 19 | + global $wgEditWarningStyleVersion, $wgRequest; |
| 20 | + |
| 21 | + UsabilityInitiativeHooks::initialize(); |
| 22 | + // Adds script to document |
| 23 | + UsabilityInitiativeHooks::addScript( |
| 24 | + 'SimpleSearch/SimpleSearch.js', $wgSimpleSearchStyleVersion |
| 25 | + ); |
| 26 | + // Internationalization |
| 27 | + wfLoadExtensionMessages( 'SimpleSearch' ); |
| 28 | + // Adds messages to page |
| 29 | + UsabilityInitiativeHooks::addMessages( |
| 30 | + array( 'simplesearch-search' ) |
| 31 | + ); |
| 32 | + |
| 33 | + // Continue |
| 34 | + return true; |
| 35 | + } |
| 36 | +} |
Index: trunk/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.js |
— | — | @@ -0,0 +1,37 @@ |
| 2 | +/* JavaScript for SimpleSearch extension */ |
| 3 | + |
| 4 | +$( document ).ready( function() { |
| 5 | + // Only use this function in conjuction with the Vector skin |
| 6 | + if( skin != 'vector' ) |
| 7 | + return; |
| 8 | + |
| 9 | + // Adds form submission handler |
| 10 | + $( 'div#simpleSearch > input#searchInput' ) |
| 11 | + .each( function() { |
| 12 | + $( '<label>' + gM( 'simplesearch-search' ) + '</label>' ) |
| 13 | + .css({ |
| 14 | + 'display': 'none', |
| 15 | + 'position' : 'absolute', |
| 16 | + 'left': 0, |
| 17 | + 'bottom': 0, |
| 18 | + 'padding': '0.25em', |
| 19 | + 'color': '#999999', |
| 20 | + 'cursor': 'text' |
| 21 | + }) |
| 22 | + .click( function() { |
| 23 | + $(this).parent().find( 'input#searchInput' ).focus(); |
| 24 | + }) |
| 25 | + .appendTo( $(this).parent() ); |
| 26 | + if ( $(this).val() == '' ) { |
| 27 | + $(this).parent().find( 'label' ).show(); |
| 28 | + } |
| 29 | + }) |
| 30 | + .focus( function() { |
| 31 | + $(this).parent().find( 'label' ).hide(); |
| 32 | + }) |
| 33 | + .blur( function() { |
| 34 | + if ( $(this).val() == '' ) { |
| 35 | + $(this).parent().find( 'label' ).show(); |
| 36 | + } |
| 37 | + }); |
| 38 | +}); |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.php |
— | — | @@ -44,5 +44,4 @@ |
45 | 45 | dirname( __FILE__ ) . "/UsabilityInitiative.i18n.php"; |
46 | 46 | |
47 | 47 | // Registers Hooks |
48 | | -$wgHooks['AjaxAddScript'][] = 'UsabilityInitiativeHooks::addJs'; |
49 | | -$wgHooks['BeforePageDisplay'][] = 'UsabilityInitiativeHooks::addCss'; |
| 48 | +$wgHooks['BeforePageDisplay'][] = 'UsabilityInitiativeHooks::addResources'; |
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | * AjaxAddScript hook |
30 | 30 | * Adds scripts |
31 | 31 | */ |
32 | | - public static function addJs( $out ) { |
| 32 | + public static function addResources( $out ) { |
33 | 33 | global $wgScriptPath, $wgJsMimeType; |
34 | 34 | global $wgUsabilityInitiativeCoesxistWithMvEmbed; |
35 | 35 | |
— | — | @@ -79,20 +79,7 @@ |
80 | 80 | "loadGM({{$messagesList}});" |
81 | 81 | ) |
82 | 82 | ); |
83 | | - // Continue |
84 | | - return true; |
85 | | - } |
86 | | - |
87 | | - /** |
88 | | - * BeforePageDisplay hook |
89 | | - * Adds styles |
90 | | - */ |
91 | | - public static function addCss( $out ) { |
92 | | - global $wgScriptPath, $wgJsMimeType; |
93 | 83 | |
94 | | - if ( !self::$doOutput ) |
95 | | - return true; |
96 | | - |
97 | 84 | // Loops over each style |
98 | 85 | foreach ( self::$styles as $style ) { |
99 | 86 | // Add css for various styles |