r53383 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53382‎ | r53383 | r53384 >
Date:22:49, 16 July 2009
Author:tparscal
Status:ok (Comments)
Tags:
Comment:
Fixed loading order problems which caused UsabilityInitiativeHooks::addJs to be called too late. Added SimpleSearch which enhances the simplified search for Vector.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/SimpleSearch (added) (history)
  • /trunk/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.hooks.php (added) (history)
  • /trunk/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.i18n.php (added) (history)
  • /trunk/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.js (added) (history)
  • /trunk/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.php (added) (history)
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.php (modified) (history)

Diff [purge]

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 @@
4545 dirname( __FILE__ ) . "/UsabilityInitiative.i18n.php";
4646
4747 // 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 @@
2929 * AjaxAddScript hook
3030 * Adds scripts
3131 */
32 - public static function addJs( $out ) {
 32+ public static function addResources( $out ) {
3333 global $wgScriptPath, $wgJsMimeType;
3434 global $wgUsabilityInitiativeCoesxistWithMvEmbed;
3535
@@ -79,20 +79,7 @@
8080 "loadGM({{$messagesList}});"
8181 )
8282 );
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;
9383
94 - if ( !self::$doOutput )
95 - return true;
96 -
9784 // Loops over each style
9885 foreach ( self::$styles as $style ) {
9986 // Add css for various styles

Follow-up revisions

RevisionCommit summaryAuthorDate
r53450Per r53383 add UI-SimpleSearch to translatewikiraymond16:49, 18 July 2009

Comments

#Comment by Trevor Parscal (WMF) (talk | contribs)   20:39, 21 July 2009

When applying this change, make sure you update your LocalSettings.php file to use the new way of including this extension. This new way, is to simple include the sub-extension directly like so...

require_once( "$IP/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php" ); require_once( "$IP/extensions/UsabilityInitiative/EditWarning/EditWarning.php" );

Status & tagging log