http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89884
Revision: 89884 Author: salvatoreingala Date: 2011-06-11 15:56:07 +0000 (Sat, 11 Jun 2011) Log Message: ----------- - Added modules/ext.gadgets.preferences.css for dialog styling - Small improvements in code quality Modified Paths: -------------- branches/salvatoreingala/Gadgets/Gadgets.i18n.php branches/salvatoreingala/Gadgets/Gadgets.php branches/salvatoreingala/Gadgets/Gadgets_body.php branches/salvatoreingala/Gadgets/modules/ext.gadgets.preferences.js branches/salvatoreingala/Gadgets/modules/jquery.formBuilder.js Added Paths: ----------- branches/salvatoreingala/Gadgets/modules/ext.gadgets.preferences.css Property Changed: ---------------- branches/salvatoreingala/Gadgets/ branches/salvatoreingala/Gadgets/Gadgets_body.php Property changes on: branches/salvatoreingala/Gadgets ___________________________________________________________________ Modified: svn:mergeinfo - /trunk/extensions/Gadgets:88253-89450 + /trunk/extensions/Gadgets:88253-89658 Modified: branches/salvatoreingala/Gadgets/Gadgets.i18n.php =================================================================== --- branches/salvatoreingala/Gadgets/Gadgets.i18n.php 2011-06-11 14:35:41 UTC (rev 89883) +++ branches/salvatoreingala/Gadgets/Gadgets.i18n.php 2011-06-11 15:56:07 UTC (rev 89884) @@ -45,6 +45,8 @@ 'gadgets-export-download' => 'Download', 'gadgets-configure' => 'Configure', 'gadgets-configuration-of' => 'Configuration of $1', + 'gadgets-prefs-save' => 'Save', + 'gadgets-prefs-cancel' => 'Cancel', 'gadgets-unexpected-error' => 'An unexpected error occurred. Please check your connection. If the problems persists, please contact the developers.', 'gadgets-save-success' => 'Settings saved successfully.', 'gadgets-save-failed' => 'Failed to save settings. If the problems persists, please contact the developers.', @@ -152,6 +154,7 @@ ); /** Arabic (العربية) + * @author Aiman titi * @author Meno25 * @author OsamaK */ @@ -170,7 +173,11 @@ 'gadgets-pagetext' => 'بالأسفل قائمة بالإضافات الخاصة التي يمكن أن يقوم المستخدمون بتفعيلها على [[Special:Preferences|صفحة تفضيلاتهم]]، معرفة بواسطة [[MediaWiki:Gadgets-definition|التعريفات]]. هذا العرض يوفر دخولا سهلا لصفحات رسائل النظام التي تعرف وصف وكود كل إضافة.', 'gadgets-uses' => 'تستخدم', + 'gadgets-required-rights' => 'يتطلب {{PLURAL:$2|$1 حق|الحقوق التالية: $1}}.', + 'gadgets-default' => 'تمكين الجميع بشكل افتراضي.', 'gadgets-export' => 'صدّر', + 'gadgets-export-title' => 'أداة تصدير', + 'gadgets-not-found' => 'الأداة "$1" لم يتم العثور عليها.', 'gadgets-export-download' => 'نزّل', ); Modified: branches/salvatoreingala/Gadgets/Gadgets.php =================================================================== --- branches/salvatoreingala/Gadgets/Gadgets.php 2011-06-11 14:35:41 UTC (rev 89883) +++ branches/salvatoreingala/Gadgets/Gadgets.php 2011-06-11 15:56:07 UTC (rev 89884) @@ -82,13 +82,14 @@ $wgResourceModules['ext.gadgets.preferences'] = array( 'scripts' => array( 'ext.gadgets.preferences.js' ), + 'styles' => array( 'ext.gadgets.preferences.css' ), 'dependencies' => array( 'jquery', 'jquery.json', 'jquery.ui.dialog', 'jquery.formBuilder', 'mediawiki.htmlform', 'ext.gadgets' ), 'messages' => array( - 'gadgets-configure', 'gadgets-configuration-of', 'gadgets-unexpected-error', - 'gadgets-save-success', 'gadgets-save-failed' + 'gadgets-configure', 'gadgets-configuration-of', 'gadgets-prefs-save', 'gadgets-prefs-cancel', + 'gadgets-unexpected-error', 'gadgets-save-success', 'gadgets-save-failed' ), 'localBasePath' => $dir . 'modules/', 'remoteExtPath' => 'Gadgets/modules' Modified: branches/salvatoreingala/Gadgets/Gadgets_body.php =================================================================== --- branches/salvatoreingala/Gadgets/Gadgets_body.php 2011-06-11 14:35:41 UTC (rev 89883) +++ branches/salvatoreingala/Gadgets/Gadgets_body.php 2011-06-11 15:56:07 UTC (rev 89884) @@ -919,10 +919,7 @@ return true; case 'select': $values = array_values( $prefDescription['options'] ); - if ( !in_array( $pref, $values, true ) ) { - return false; - } - return true; + return in_array( $pref, $values, true ); default: return false; //unexisting type } @@ -1158,3 +1155,4 @@ } } + Property changes on: branches/salvatoreingala/Gadgets/Gadgets_body.php ___________________________________________________________________ Modified: svn:mergeinfo - /branches/Gadgets-work/Gadgets_body.php:73145-76526 /branches/wmf/1.17wmf1/extensions/Gadgets/Gadgets_body.php:81884 /trunk/extensions/Gadgets/Gadgets_body.php:88253-89450 + /branches/Gadgets-work/Gadgets_body.php:73145-76526 /branches/wmf/1.17wmf1/extensions/Gadgets/Gadgets_body.php:81884 /trunk/extensions/Gadgets/Gadgets_body.php:88253-89658 Added: branches/salvatoreingala/Gadgets/modules/ext.gadgets.preferences.css =================================================================== --- branches/salvatoreingala/Gadgets/modules/ext.gadgets.preferences.css (rev 0) +++ branches/salvatoreingala/Gadgets/modules/ext.gadgets.preferences.css 2011-06-11 15:56:07 UTC (rev 89884) @@ -0,0 +1,10 @@ +/* + * Styles for gadget's preference setting dialogs. + */ + +#mw-gadgets-prefsDialog label { + display: block; + float: left; + width: 250px; +} + Property changes on: branches/salvatoreingala/Gadgets/modules/ext.gadgets.preferences.css ___________________________________________________________________ Added: svn:eol-style + native Modified: branches/salvatoreingala/Gadgets/modules/ext.gadgets.preferences.js =================================================================== --- branches/salvatoreingala/Gadgets/modules/ext.gadgets.preferences.js 2011-06-11 14:35:41 UTC (rev 89883) +++ branches/salvatoreingala/Gadgets/modules/ext.gadgets.preferences.js 2011-06-11 15:56:07 UTC (rev 89884) @@ -63,6 +63,7 @@ return false; //prevent form submission } ); + $( dialogBody ).attr( 'id', 'mw-gadgets-prefsDialog' ); $( dialogBody ).dialog( { modal: true, @@ -72,21 +73,26 @@ close: function() { $( this ).dialog( 'destroy' ).empty(); //completely destroy on close }, - buttons: { + buttons: [ //TODO: add a "Restore defaults" button - - "Save": function() { - var isValid = $( dialogBody ).formBuilder( 'validate' ); - - if ( isValid ) { - var values = $( dialogBody ).formBuilder( 'getValues' ); - saveConfig( $( this ), gadget, values ); + { + text: mw.msg( 'gadgets-prefs-save' ), + click: function() { + var isValid = $( dialogBody ).formBuilder( 'validate' ); + + if ( isValid ) { + var values = $( dialogBody ).formBuilder( 'getValues' ); + saveConfig( $( this ), gadget, values ); + } } }, - "Cancel": function() { - $( this ).dialog( "close" ); + { + text: mw.msg( 'gadgets-prefs-cancel' ), + click: function() { + $( this ).dialog( "close" ); + } } - } + ] } ); }, error: function( response ) { Modified: branches/salvatoreingala/Gadgets/modules/jquery.formBuilder.js =================================================================== --- branches/salvatoreingala/Gadgets/modules/jquery.formBuilder.js 2011-06-11 14:35:41 UTC (rev 89883) +++ branches/salvatoreingala/Gadgets/modules/jquery.formBuilder.js 2011-06-11 15:56:07 UTC (rev 89884) @@ -92,7 +92,7 @@ rules: {}, messages: {} }; - } + }; //A field with just a label LabelField.prototype = object( EmptyField.prototype ); @@ -128,7 +128,7 @@ BooleanField.prototype.getValue = function() { return this.$c.is( ':checked' ); - } + }; //A field with a textbox @@ -181,7 +181,7 @@ }; return settings; - } + }; NumberField.prototype = object( LabelField.prototype ); @@ -240,7 +240,7 @@ }; return settings; - } + }; SelectField.prototype = object( LabelField.prototype ); @@ -268,14 +268,14 @@ $.error( "desc.value is not in the list of possible values" ); } - var i = $.inArray( desc.value, values ) + var i = $.inArray( desc.value, values ); $select.val( i ).attr( 'selected', 'selected' ); this.$p.append( $select ); } SelectField.prototype.getValue = function() { - var i = parseInt( this.$select.val() ); + var i = parseInt( this.$select.val(), 10 ); return this.values[i]; }; @@ -310,11 +310,9 @@ return null; } - var $form = $( '<form/>' ); - var fields = []; - var settings = {} //validator settings + var settings = {}; //validator settings for ( var fieldName in description.fields ) { if ( description.fields.hasOwnProperty( fieldName )) { @@ -328,8 +326,9 @@ return null; } + var f; try { - var f = new FieldConstructor( fieldName, field ); + f = new FieldConstructor( fieldName, field ); } catch ( e ) { mw.log( e ); return null; //constructor failed, wrong syntax in field description _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs