r75192 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75191‎ | r75192 | r75193 >
Date:15:27, 22 October 2010
Author:yaron
Status:deferred
Tags:
Comment:
Added handling for ResourceLoader, removed special handling for IE and comboboxes (no longer needed?)
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -102,12 +102,86 @@
103103 }
104104
105105 /**
 106+ * Defines all the ResourceLoader modules needed for SF Javascript
 107+ * and CSS
 108+ */
 109+ static function registerModules( $resourceLoader ) {
 110+ global $sfgPartialPath, $smwgScriptPath;
 111+
 112+ $resourceLoader->register(
 113+ array(
 114+ 'semanticforms.main' =>
 115+ new ResourceLoaderFileModule(
 116+ array(
 117+ 'scripts' =>
 118+ "$sfgPartialPath/libs/SemanticForms.js",
 119+ 'styles' =>
 120+ array(
 121+ "$sfgPartialPath/skins/SemanticForms.css",
 122+ "$sfgPartialPath/skins/SF_jquery_ui_overrides.css",
 123+ ),
 124+ )
 125+ ),
 126+ 'semanticforms.fancybox' =>
 127+ new ResourceLoaderFileModule(
 128+ array(
 129+ 'scripts' =>
 130+ "$sfgPartialPath/libs/jquery.fancybox-1.3.1.js",
 131+ 'styles' =>
 132+ "$sfgPartialPath/skins/jquery.fancybox-1.3.1.css",
 133+ )
 134+ ),
 135+ 'semanticforms.autogrow' =>
 136+ new ResourceLoaderFileModule(
 137+ array(
 138+ 'scripts' =>
 139+ "$sfgPartialPath/libs/SF_autogrow.js",
 140+ )
 141+ ),
 142+ 'semanticforms.smw_utilities' =>
 143+ new ResourceLoaderFileModule(
 144+ array(
 145+ 'scripts' =>
 146+ // no $smwgPartialPath variable exists yet
 147+ "/extensions/SemanticMediaWiki/skins/SMW_tooltip.js",
 148+ "/extension/SemanticMediaWiki/skins/SMW_sorttable.js",
 149+ )
 150+ ),
 151+ )
 152+ );
 153+
 154+ return true;
 155+ }
 156+
 157+ /**
 158+ * Uses the ResourceLoader (available with MediaWiki 1.17 and higher)
 159+ * to load all the necessary JS and CSS files for Semantic Forms.
 160+ */
 161+ static function loadJavascriptAndCSS() {
 162+ global $wgOut;
 163+ $wgOut->addModules( 'jquery' );
 164+ $wgOut->addModules( 'jquery.ui.autocomplete' );
 165+ $wgOut->addModules( 'jquery.ui.button' );
 166+ $wgOut->addModules( 'semanticforms.main' );
 167+ $wgOut->addModules( 'semanticforms.fancybox' );
 168+ $wgOut->addModules( 'semanticforms.autogrow' );
 169+ $wgOut->addModules( 'semanticforms.smw_utilities' );
 170+ global $sfgFancyBoxIncluded;
 171+ $sfgFancyBoxIncluded = true;
 172+ }
 173+
 174+ /**
106175 * Includes the necessary Javascript and CSS files for the form
107176 * to display and work correctly
108177 *
109178 * Accepts an optional Parser instance, or uses $wgOut if omitted.
110179 */
111180 static function addJavascriptAndCSS( $parser = NULL ) {
 181+ // MW 1.17 +
 182+ if ( class_exists( 'ResourceLoader' ) ) {
 183+ self::loadJavascriptAndCSS();
 184+ return;
 185+ }
112186 global $wgOut, $sfgScriptPath, $smwgScriptPath, $wgScriptPath, $wgFCKEditorDir, $wgJsMimeType, $sfgUseFormEditPage;
113187 global $smwgJQueryIncluded, $smwgJQUIAutoIncluded;
114188 // jQuery and jQuery UI are used so often in forms, we might as
@@ -134,7 +208,6 @@
135209 else
136210 $wgOut->addLink( $link );
137211 }
138 - $wgOut->addStyle( "$sfgScriptPath/skins/SF_IEfixes.css", 'screen', 'IE' );
139212
140213 $scripts = array();
141214 if ( !$sfgUseFormEditPage )
@@ -160,6 +233,7 @@
161234 $script = "<script type=\"$wgJsMimeType\" src=\"$js\"></script>\n";
162235 $parser->getOutput()->addHeadItem( $script );
163236 } else {
 237+ global $wgOut;
164238 $wgOut->addScriptFile( $js );
165239 }
166240 }

Status & tagging log