r101075 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101074‎ | r101075 | r101076 >
Date:22:35, 27 October 2011
Author:foxtrott
Status:deferred (Comments)
Tags:
Comment:
followup r101069: CSS and free text work
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/skins/SemanticForms.css (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/SemanticForms.php
@@ -231,7 +231,7 @@
232232 ),
233233 'ext.semanticforms.wikieditor' => $sfgResourceTemplate + array(
234234 'scripts' => 'libs/SF_wikieditor.js',
235 -// 'styles' => 'skins/SF_wikieditor.css', // no styles necessary?
 235+ 'styles' => 'skins/SF_wikieditor.css',
236236 'dependencies' => array('jquery.wikiEditor'),
237237 ),
238238 );
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php
@@ -29,6 +29,9 @@
3030 }
3131
3232 public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
 33+
 34+ global $wgOut;
 35+
3336 // If 'no autocomplete' was specified, print a regular
3437 // textarea instead.
3538 if ( array_key_exists( 'no autocomplete', $other_args ) &&
@@ -41,11 +44,29 @@
4245
4346 list( $autocompleteSettings, $remoteDataType, $delimiter ) = SFTextWithAutocompleteInput::setAutocompleteValues( $other_args );
4447
45 - $className = ( $is_mandatory ) ? 'autocompleteInput mandatoryField' : 'autocompleteInput createboxInput';
 48+ $input_id = 'input_' . $sfgFieldNum;
 49+
 50+ if ( array_key_exists( 'wikieditor', $other_args ) &&
 51+ in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) ) {
 52+
 53+ $wgOut->addModules( 'ext.semanticforms.wikieditor' );
 54+
 55+ $jstext = <<<JAVASCRIPT
 56+jQuery(function(){ jQuery('#$input_id').SemanticForms_registerInputInit( ext.wikieditor.init, null ); });
 57+JAVASCRIPT;
 58+
 59+ // write JS code directly to the page's code
 60+ $wgOut->addScript( '<script type="text/javascript">' . $jstext . '</script>' );
 61+
 62+ $className = "wikieditor ";
 63+ } else {
 64+ $className = "";
 65+ }
 66+
 67+ $className .= ( $is_mandatory ) ? 'autocompleteInput mandatoryField' : 'autocompleteInput createboxInput';
4668 if ( array_key_exists( 'class', $other_args ) ) {
4769 $className .= ' ' . $other_args['class'];
4870 }
49 - $input_id = 'input_' . $sfgFieldNum;
5071
5172 if ( array_key_exists( 'rows', $other_args ) ) {
5273 $rows = $other_args['rows'];
@@ -117,20 +138,6 @@
118139 }
119140 $text = "\n" . Xml::tags( 'span', array( 'class' => $spanClass ), $text );
120141
121 -
122 - if ( array_key_exists( 'wikieditor', $other_args ) &&
123 - array_search( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) !== FALSE ) {
124 -
125 - $wgOut->addModules( 'ext.semanticforms.wikieditor' );
126 -
127 - $jstext = <<<JAVASCRIPT
128 -jQuery(function(){ jQuery('#input_$sfgFieldNum').SemanticForms_registerInputInit( ext.wikieditor.init, null ); });
129 -JAVASCRIPT;
130 -
131 - // write JS code directly to the page's code
132 - $wgOut->addScript( '<script type="text/javascript">' . $jstext . '</script>' );
133 - }
134 -
135142 return $text;
136143 }
137144
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php
@@ -29,15 +29,34 @@
3030 }
3131
3232 public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
 33+
3334 global $wgOut;
3435 global $sfgTabIndex, $sfgFieldNum;
3536
36 - $className = ( $is_mandatory ) ? 'mandatoryField' : 'createboxInput';
 37+ // Use a special ID for the free text field, for FCK's needs.
 38+ $input_id = $input_name == 'free_text' ? 'free_text' : "input_$sfgFieldNum";
 39+
 40+ if ( array_key_exists( 'wikieditor', $other_args ) &&
 41+ in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) ) {
 42+
 43+ $wgOut->addModules( 'ext.semanticforms.wikieditor' );
 44+
 45+ $jstext = <<<JAVASCRIPT
 46+jQuery(function(){ jQuery('#$input_id').SemanticForms_registerInputInit( ext.wikieditor.init, null ); });
 47+JAVASCRIPT;
 48+
 49+ // write JS code directly to the page's code
 50+ $wgOut->addScript( '<script type="text/javascript">' . $jstext . '</script>' );
 51+
 52+ $className = "wikieditor ";
 53+ } else {
 54+ $className = "";
 55+ }
 56+
 57+ $className .= ( $is_mandatory ) ? 'mandatoryField' : 'createboxInput';
3758 if ( array_key_exists( 'class', $other_args ) ) {
3859 $className .= " " . $other_args['class'];
3960 }
40 - // Use a special ID for the free text field, for FCK's needs.
41 - $input_id = $input_name == 'free_text' ? 'free_text' : "input_$sfgFieldNum";
4261
4362 if ( array_key_exists( 'rows', $other_args ) ) {
4463 $rows = $other_args['rows'];
@@ -101,19 +120,6 @@
102121 }
103122 $text = Xml::tags( 'span', array( 'class' => $spanClass ), $text );
104123
105 - if ( array_key_exists( 'wikieditor', $other_args ) &&
106 - array_search( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) !== FALSE ) {
107 -
108 - $wgOut->addModules( 'ext.semanticforms.wikieditor' );
109 -
110 - $jstext = <<<JAVASCRIPT
111 -jQuery(function(){ jQuery('#input_$sfgFieldNum').SemanticForms_registerInputInit( ext.wikieditor.init, null ); });
112 -JAVASCRIPT;
113 -
114 - // write JS code directly to the page's code
115 - $wgOut->addScript( '<script type="text/javascript">' . $jstext . '</script>' );
116 - }
117 -
118124 return $text;
119125 }
120126
Index: trunk/extensions/SemanticForms/skins/SemanticForms.css
@@ -4,7 +4,7 @@
55
66 /* Override "width: 100%" setting in standard MediaWiki skins */
77 textarea.createboxInput {
8 - width: auto;
 8+/* width: auto;*/
99 }
1010 textarea.mandatoryField {
1111 width: auto;
@@ -134,7 +134,7 @@
135135 .autoGrow {
136136 overflow: hidden;
137137 height: auto;
138 - width: 326px;
 138+/* width: 326px;*/
139139 }
140140
141141 /* Override some jQuery UI settings */

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101069provide wikieditor for textareas...foxtrott21:52, 27 October 2011

Comments

#Comment by Nikerabbit (talk | contribs)   07:33, 28 October 2011

I see some code duplication here. Can it be refactored?

#Comment by F.trott (talk | contribs)   19:18, 28 October 2011

Most probably. Only it is out of the scope of the current change, I just worked with what I found. I'll put a TODO in the code.