r101895 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101894‎ | r101895 | r101896 >
Date:22:17, 3 November 2011
Author:foxtrott
Status:deferred (Comments)
Tags:
Comment:
enabling dialogs and hidesig for wikieditor
Modified paths:
  • /trunk/extensions/SemanticForms/SemanticForms.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/libs/SF_wikieditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/SemanticForms.php
@@ -232,13 +232,8 @@
233233 'dependencies' => array( 'jquery' ),
234234 ),
235235 'ext.semanticforms.wikieditor' => $sfgResourceTemplate + array(
236 - 'scripts' => 'libs/SF_wikieditor.js',
237 - 'styles' => 'skins/SF_wikieditor.css',
238 - 'dependencies' => array(
239 - 'jquery.wikiEditor.toolbar',
240 - 'jquery.wikiEditor.toolbar.config',
241 -
242 - ),
 236+ 'scripts' => 'libs/SF_wikieditor.js',
 237+ 'styles' => 'skins/SF_wikieditor.css',
243238 ),
244239 );
245240 }
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php
@@ -50,14 +50,15 @@
5151
5252 if ( array_key_exists( 'editor', $other_args ) &&
5353 $other_args['editor'] == 'wikieditor' &&
54 -
 54+
5555 method_exists( $wgOut, 'getResourceLoader' ) &&
5656 in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) &&
 57+
 58+ class_exists( 'WikiEditorHooks' ) ) {
5759
58 - class_exists( 'WikiEditorHooks' ) &&
59 - WikiEditorHooks::isEnabled( 'toolbar' ) ) {
 60+ // load modules for all enabled features
 61+ WikiEditorHooks::editPageShowEditFormInitial( $this );
6062
61 -
6263 $wgOut->addModules( 'ext.semanticforms.wikieditor' );
6364
6465 $jstext = <<<JAVASCRIPT
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php
@@ -19,15 +19,15 @@
2020 }
2121
2222 public static function getDefaultPropTypes() {
23 - return array( '_txt' => array(), '_cod' => array() );
 23+ return array('_txt' => array(), '_cod' => array());
2424 }
2525
2626 public static function getOtherPropTypesHandled() {
27 - return array( '_wpg', '_str' );
 27+ return array('_wpg', '_str');
2828 }
2929
3030 public static function getOtherPropTypeListsHandled() {
31 - return array( '_wpg', '_str' );
 31+ return array('_wpg', '_str');
3232 }
3333
3434 public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
@@ -40,14 +40,15 @@
4141
4242 if ( array_key_exists( 'editor', $other_args ) &&
4343 $other_args['editor'] == 'wikieditor' &&
44 -
 44+
4545 method_exists( $wgOut, 'getResourceLoader' ) &&
4646 in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) &&
 47+
 48+ class_exists( 'WikiEditorHooks' ) ) {
4749
48 - class_exists( 'WikiEditorHooks' ) &&
49 - WikiEditorHooks::isEnabled( 'toolbar' ) ) {
 50+ // load modules for all enabled features
 51+ WikiEditorHooks::editPageShowEditFormInitial( $this );
5052
51 -
5253 $wgOut->addModules( 'ext.semanticforms.wikieditor' );
5354
5455 $jstext = <<<JAVASCRIPT
@@ -127,7 +128,7 @@
128129 if ( $is_mandatory ) {
129130 $spanClass .= ' mandatoryFieldSpan';
130131 }
131 - $text = Xml::tags( 'span', array( 'class' => $spanClass ), $text );
 132+ $text = Xml::tags( 'span', array('class' => $spanClass), $text );
132133
133134 return $text;
134135 }
@@ -171,15 +172,10 @@
172173 * Returns the HTML code to be included in the output page for this input.
173174 */
174175 public function getHtmlText() {
175 -
 176+
176177 return self::getHTML(
177 - $this->mCurrentValue,
178 - $this->mInputName,
179 - $this->mIsMandatory,
180 - $this->mIsDisabled,
181 - $this->mOtherArgs
 178+ $this->mCurrentValue, $this->mInputName, $this->mIsMandatory, $this->mIsDisabled, $this->mOtherArgs
182179 );
183 -
184180 }
185181
186182 }
Index: trunk/extensions/SemanticForms/libs/SF_wikieditor.js
@@ -5,41 +5,55 @@
66
77 window.ext.wikieditor = new function(){
88
9 - // var config;
10 - // var isSetUp = false;
11 - //
12 - // // common setup for all editor instances
13 - // function setup () {
14 - // config = jQuery.wikiEditor.modules.toolbar.config.getDefaultConfig();
15 - // config.toolbar.advanced.groups.insert.tools.table.filters = ['textarea:not(#wpTextbox1):not(.toolbar-dialogs)'];
16 - // }
17 -
189 // initialize the wikieditor on the specified element
1910 this.init = function init ( input_id, params ) {
2011
21 - // if ( !isSetUp ) {
22 - // isSetUp = true;
23 - // setup();
24 - // }
25 -
2612 if ( window.mediaWiki ) {
2713 mediaWiki.loader.using( 'ext.semanticforms.wikieditor', function(){
 14+
 15+ var input = jQuery( '#' + input_id );
 16+
 17+ // load toolbar
 18+ mediaWiki.loader.using( ['jquery.wikiEditor.toolbar', 'jquery.wikiEditor.toolbar.config'] , function(){
2819 if ( jQuery.wikiEditor.isSupported( jQuery.wikiEditor.modules.toolbar ) ) {
29 -
30 - if (jQuery.wikiEditor.modules.toolbar.config !== undefined ) {
31 - jQuery( '#' + input_id ).wikiEditor( 'addModule', jQuery.wikiEditor.modules.toolbar.config.getDefaultConfig() );
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);
 20+
 21+ input.wikiEditor( 'addModule', jQuery.wikiEditor.modules.toolbar.config.getDefaultConfig() );
 22+
 23+ // hide sig if required
 24+ if ( wgWikiEditorEnabledModules && wgWikiEditorEnabledModules['hidesig'] == true ) {
 25+ input.wikiEditor( 'removeFromToolbar', {
 26+ 'section': 'main',
 27+ 'group': 'insert',
 28+ 'tool': 'signature'
 29+ } );
4130 }
 31+
4232 }
43 - } )
 33+ });
 34+
 35+ // load dialogs
 36+ mediaWiki.loader.using( ['jquery.wikiEditor.dialogs', 'jquery.wikiEditor.dialogs.config'] , function(){
 37+ if ( jQuery.wikiEditor.isSupported( jQuery.wikiEditor.modules.dialogs ) ) {
 38+
 39+ jQuery.wikiEditor.modules.dialogs.config.replaceIcons( input );
 40+ input.wikiEditor( 'addModule', $.wikiEditor.modules.dialogs.config.getDefaultConfig() );
 41+
 42+ }
 43+ });
 44+
 45+ // load toc
 46+ // TODO: Can this be enabled? Should it?
 47+// mediaWiki.loader.using( ['jquery.wikiEditor.toc' ] , function(){
 48+// if ( jQuery.wikiEditor.isSupported( jQuery.wikiEditor.modules.toc ) ) {
 49+//
 50+// input.wikiEditor( 'addModule', 'toc' );
 51+//
 52+// }
 53+// });
 54+
 55+
 56+
 57+ } );
4458 }
4559 }
4660

Comments

#Comment by Nikerabbit (talk | contribs)   11:23, 4 November 2011

Looks fine excluding the unrelated whitespace changes.