Index: trunk/extensions/SemanticForms/SemanticForms.php |
— | — | @@ -235,10 +235,9 @@ |
236 | 236 | 'scripts' => 'libs/SF_wikieditor.js', |
237 | 237 | 'styles' => 'skins/SF_wikieditor.css', |
238 | 238 | 'dependencies' => array( |
239 | | - 'jquery.wikiEditor', |
240 | 239 | 'jquery.wikiEditor.toolbar', |
241 | 240 | 'jquery.wikiEditor.toolbar.config', |
242 | | - |
| 241 | + |
243 | 242 | ), |
244 | 243 | ), |
245 | 244 | ); |
— | — | @@ -303,7 +302,7 @@ |
304 | 303 | # ## |
305 | 304 | # Extend the edit form from the internal EditPage class rather than using a |
306 | 305 | # special page and hacking things up. |
307 | | -# |
| 306 | +# |
308 | 307 | # @note This is experimental and requires updates to EditPage which I have only |
309 | 308 | # added into MediaWiki 1.14a |
310 | 309 | # ## |
— | — | @@ -338,7 +337,7 @@ |
339 | 338 | # Page properties, used for the API |
340 | 339 | # ## |
341 | 340 | $wgPageProps['formdefinition'] = 'Definition of the semantic form used on the page'; |
342 | | - |
| 341 | + |
343 | 342 | # ## |
344 | 343 | # Global variables for Javascript |
345 | 344 | # ## |
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php |
— | — | @@ -48,35 +48,24 @@ |
49 | 49 | |
50 | 50 | $input_id = 'input_' . $sfgFieldNum; |
51 | 51 | |
52 | | - static $hasRun = false; |
53 | | - |
54 | 52 | if ( array_key_exists( 'wikieditor', $other_args ) && |
55 | | - method_exists($wgOut, 'getResourceLoader') && |
56 | | - in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) ) { |
57 | 53 | |
58 | | - if ( !$hasRun ) { |
59 | | - |
60 | | - $hasRun = true; |
| 54 | + method_exists( $wgOut, 'getResourceLoader' ) && |
| 55 | + in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) && |
61 | 56 | |
62 | | - // one time initialization |
63 | | - WikiEditorHooks::editPageShowEditFormInitial( $this ); |
64 | | - $wgOut->addModules( 'ext.semanticforms.wikieditor' ); |
65 | | - } |
| 57 | + class_exists( 'WikiEditorHooks' ) && |
| 58 | + WikiEditorHooks::isEnabled( 'toolbar' ) ) { |
66 | 59 | |
| 60 | + |
| 61 | + $wgOut->addModules( 'ext.semanticforms.wikieditor' ); |
| 62 | + |
67 | 63 | $jstext = <<<JAVASCRIPT |
68 | | -if ( window.mediaWiki ) { |
69 | | - mediaWiki.loader.using( |
70 | | - [ 'ext.semanticforms.wikieditor', 'jquery.wikiEditor.toolbar.config' ], |
71 | | - function(){ |
72 | | - jQuery('#$input_id').SemanticForms_registerInputInit( ext.wikieditor.init, null ); |
73 | | - } |
74 | | - ); |
75 | | -} |
| 64 | + jQuery( jQuery('#$input_id').SemanticForms_registerInputInit( ext.wikieditor.init, null ) ); |
76 | 65 | JAVASCRIPT; |
77 | 66 | |
78 | 67 | // write JS code directly to the page's code |
79 | 68 | $wgOut->addScript( Html::inlineScript( $jstext ) ); |
80 | | - |
| 69 | + |
81 | 70 | $className = "wikieditor "; |
82 | 71 | } else { |
83 | 72 | $className = ""; |
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * File holding the SFTextAreaInput class |
5 | 6 | * |
— | — | @@ -12,59 +13,49 @@ |
13 | 14 | * @ingroup SFFormInput |
14 | 15 | */ |
15 | 16 | class SFTextAreaInput extends SFFormInput { |
| 17 | + |
16 | 18 | public static function getName() { |
17 | 19 | return 'textarea'; |
18 | 20 | } |
19 | 21 | |
20 | 22 | public static function getDefaultPropTypes() { |
21 | | - return array( '_txt' => array(), '_cod' => array() ); |
| 23 | + return array('_txt' => array(), '_cod' => array()); |
22 | 24 | } |
23 | 25 | |
24 | 26 | public static function getOtherPropTypesHandled() { |
25 | | - return array( '_wpg', '_str' ); |
| 27 | + return array('_wpg', '_str'); |
26 | 28 | } |
27 | 29 | |
28 | 30 | public static function getOtherPropTypeListsHandled() { |
29 | | - return array( '_wpg', '_str' ); |
| 31 | + return array('_wpg', '_str'); |
30 | 32 | } |
31 | 33 | |
32 | 34 | public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
33 | | - |
| 35 | + |
34 | 36 | global $wgOut; |
35 | 37 | global $sfgTabIndex, $sfgFieldNum; |
36 | 38 | |
37 | 39 | // Use a special ID for the free text field, for FCK's needs. |
38 | 40 | $input_id = $input_name == 'free_text' ? 'free_text' : "input_$sfgFieldNum"; |
39 | 41 | |
40 | | - static $hasRun = false; |
41 | | - |
42 | 42 | if ( array_key_exists( 'wikieditor', $other_args ) && |
43 | | - method_exists($wgOut, 'getResourceLoader') && |
44 | | - in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) ) { |
45 | | - |
46 | | - if ( !$hasRun ) { |
47 | | - |
48 | | - $hasRun = true; |
| 43 | + |
| 44 | + method_exists( $wgOut, 'getResourceLoader' ) && |
| 45 | + in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) && |
49 | 46 | |
50 | | - // one time initialization |
51 | | - WikiEditorHooks::editPageShowEditFormInitial( $this ); |
52 | | - $wgOut->addModules( 'ext.semanticforms.wikieditor' ); |
53 | | - } |
| 47 | + class_exists( 'WikiEditorHooks' ) && |
| 48 | + WikiEditorHooks::isEnabled( 'toolbar' ) ) { |
54 | 49 | |
| 50 | + |
| 51 | + $wgOut->addModules( 'ext.semanticforms.wikieditor' ); |
| 52 | + |
55 | 53 | $jstext = <<<JAVASCRIPT |
56 | | -if ( window.mediaWiki ) { |
57 | | - mediaWiki.loader.using( |
58 | | - [ 'ext.semanticforms.wikieditor', 'jquery.wikiEditor.toolbar.config' ], |
59 | | - function(){ |
60 | | - jQuery('#$input_id').SemanticForms_registerInputInit( ext.wikieditor.init, null ); |
61 | | - } |
62 | | - ); |
63 | | -} |
| 54 | + jQuery( jQuery('#$input_id').SemanticForms_registerInputInit( ext.wikieditor.init, null ) ); |
64 | 55 | JAVASCRIPT; |
65 | 56 | |
66 | 57 | // write JS code directly to the page's code |
67 | 58 | $wgOut->addScript( Html::inlineScript( $jstext ) ); |
68 | | - |
| 59 | + |
69 | 60 | $className = "wikieditor "; |
70 | 61 | } else { |
71 | 62 | $className = ""; |
— | — | @@ -135,7 +126,7 @@ |
136 | 127 | if ( $is_mandatory ) { |
137 | 128 | $spanClass .= ' mandatoryFieldSpan'; |
138 | 129 | } |
139 | | - $text = Xml::tags( 'span', array( 'class' => $spanClass ), $text ); |
| 130 | + $text = Xml::tags( 'span', array('class' => $spanClass), $text ); |
140 | 131 | |
141 | 132 | return $text; |
142 | 133 | } |
— | — | @@ -180,11 +171,8 @@ |
181 | 172 | */ |
182 | 173 | public function getHtmlText() { |
183 | 174 | return self::getHTML( |
184 | | - $this->mCurrentValue, |
185 | | - $this->mInputName, |
186 | | - $this->mIsMandatory, |
187 | | - $this->mIsDisabled, |
188 | | - $mOtherArgs |
| 175 | + $this->mCurrentValue, $this->mInputName, $this->mIsMandatory, $this->mIsDisabled, $mOtherArgs |
189 | 176 | ); |
190 | 177 | } |
| 178 | + |
191 | 179 | } |
Index: trunk/extensions/SemanticForms/libs/SF_wikieditor.js |
— | — | @@ -22,23 +22,25 @@ |
23 | 23 | // setup(); |
24 | 24 | // } |
25 | 25 | |
26 | | - jQuery( document ).ready( function() { |
27 | | - if ( jQuery.wikiEditor.isSupported( jQuery.wikiEditor.modules.toolbar ) ) { |
| 26 | + if ( window.mediaWiki ) { |
| 27 | + mediaWiki.loader.using( 'ext.semanticforms.wikieditor', function(){ |
| 28 | + if ( jQuery.wikiEditor.isSupported( jQuery.wikiEditor.modules.toolbar ) ) { |
28 | 29 | |
29 | | - if (jQuery.wikiEditor.modules.toolbar.config !== undefined ) { |
30 | | - jQuery( '#' + input_id ).wikiEditor( 'addModule', jQuery.wikiEditor.modules.toolbar.config.getDefaultConfig() ); |
31 | | - } else { |
32 | | - |
33 | | - // TODO: this is nasty. Take it out if at all possible. |
34 | | - var timeout = setTimeout(function () { |
35 | 30 | if (jQuery.wikiEditor.modules.toolbar.config !== undefined ) { |
36 | 31 | jQuery( '#' + input_id ).wikiEditor( 'addModule', jQuery.wikiEditor.modules.toolbar.config.getDefaultConfig() ); |
37 | | - clearTimeout(timeout); |
38 | | - } |
39 | | - }, 1000); |
40 | | - } |
41 | | - } |
42 | | - }); |
| 32 | + } else { |
| 33 | + |
| 34 | + // TODO: this is nasty. Take it out if at all possible. |
| 35 | + var timeout = setTimeout(function () { |
| 36 | + if (jQuery.wikiEditor.modules.toolbar.config !== undefined ) { |
| 37 | + jQuery( '#' + input_id ).wikiEditor( 'addModule', jQuery.wikiEditor.modules.toolbar.config.getDefaultConfig() ); |
| 38 | + clearTimeout(timeout); |
| 39 | + } |
| 40 | + }, 1000); |
| 41 | + } |
| 42 | + } |
| 43 | + } ) |
| 44 | + } |
43 | 45 | } |
44 | 46 | |
45 | 47 | }; |