r96102 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96101‎ | r96102 | r96103 >
Date:15:29, 2 September 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Renamed files to to match naming conventions
Modified paths:
  • /trunk/extensions/Translate/Translate.css (deleted) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/js/ext.translate.css (added) (history)
  • /trunk/extensions/Translate/js/ext.translate.quickedit.js (added) (history)
  • /trunk/extensions/Translate/js/quickedit.js (deleted) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.css
@@ -1,62 +0,0 @@
2 -.mw-translate-fuzzy {
3 - background-color: #FDD;
4 -}
5 -
6 -.mw-translate-page-info {
7 - font-size: x-small;
8 - text-align: center;
9 - direction: ltr;
10 -}
11 -
12 -.mw-translate-definition-preview {
13 - font-family: monospace;
14 - background-color: #F3F3FF;
15 - border: 1px solid black;
16 -}
17 -
18 -.mw-pt-languages table {
19 - direction: ltr;
20 - border: 1px solid rgb(170, 170, 170);
21 - background: rgb(246, 249, 237) none repeat scroll 0% 0%;
22 - border-collapse: collapse;
23 - line-height: 1.2;
24 - width: 100%;
25 -}
26 -
27 -.mw-pt-languages-label {
28 - border-right: 1px solid rgb(170, 170, 170);
29 - padding: 0.5em;
30 - background: rgb(238, 243, 226) none repeat scroll 0% 0%;
31 - width: 200px;
32 -}
33 -
34 -.mw-pt-languages-list {
35 - padding: 0.5em;
36 -}
37 -
38 -.mw-tpt-sp-legend {
39 - font-weight: bold;
40 -}
41 -
42 -.mw-tpt-sp-content {
43 - font-size: small;
44 - padding-left: 2em;
45 - padding-right: 2em;
46 - padding-bottom: 2ex;
47 -}
48 -
49 -/* First Steps '*/
50 -#translate-fs-signup {
51 - display: block;
52 - margin: 1em;
53 - font-weight: bold;
54 - font-size: 200%;
55 -}
56 -
57 -#translate-fs-signup a {
58 - border: 2px dotted gray;
59 - border-radius: 10px;
60 - -moz-border-radius: 10px;
61 - -webkit-border-radius: 10px;
62 - background-color: #D1E231 !important;
63 -}
\ No newline at end of file
Index: trunk/extensions/Translate/js/quickedit.js
@@ -1,202 +0,0 @@
2 -/**
3 - * JavaScript that implements the Ajax translation interface, which was at the
4 - * time of writing this probably the biggest usability problem in the extension.
5 - * Most importantly, it speeds up translating and keeps the list of translatable
6 - * messages open. It also allows multiple translation dialogs, for doing quick
7 - * updates to other messages or documentation, or translating multiple languages
8 - * simultaneously together with the "In other languages" display included in
9 - * translation helpers and implemented by utils/TranslationhHelpers.php.
10 - * The form itself is implemented by utils/TranslationEditPage.php, which is
11 - * called from Special:Translate/editpage?page=Namespace:pagename.
12 - *
13 - * TODO list:
14 - * * On succesful save, update the MessageTable display too.
15 - * * Autoload ui classes
16 - * * Instead of hc'd onscript, give them a class and use necessary triggers
17 - *
18 - * @author Niklas Laxström
19 - * @copyright Copyright © 2009-2011 Niklas Laxström
20 - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
21 - */
22 -
23 -(function($) {
24 -
25 -function MessageCheckUpdater( callback ) {
26 -
27 - this.act = function() {
28 - callback();
29 - delete this.timeoutID;
30 - };
31 -
32 - this.setup = function() {
33 - this.cancel();
34 - var self = this;
35 - this.timeoutID = window.setTimeout( self.act, 1000 );
36 - };
37 -
38 - this.cancel = function() {
39 - if ( typeof this.timeoutID === 'number' ) {
40 - window.clearTimeout( this.timeoutID );
41 - delete this.timeoutID;
42 - }
43 - };
44 -}
45 -
46 -function trlVpWidth() {
47 - return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
48 -}
49 -
50 -function addAccessKeys(dialog) {
51 - $( '[accesskey=a], [accesskey=s], [accesskey=d], [accesskey=h]' ).each(
52 - function( i ) {
53 - $(this).removeAttr( 'accesskey' );
54 - }
55 - );
56 - dialog.find( '.mw-translate-save' ).attr( 'accesskey', 'a' ).attr( 'title', '[' + tooltipAccessKeyPrefix + 'a]' );
57 - dialog.find( '.mw-translate-next' ).attr( 'accesskey', 's' ).attr( 'title', '[' + tooltipAccessKeyPrefix + 's]' );
58 - dialog.find( '.mw-translate-skip' ).attr( 'accesskey', 'd' ).attr( 'title', '[' + tooltipAccessKeyPrefix + 'd]' );
59 - dialog.find( '.mw-translate-history' ).attr( 'accesskey', 'h' ).attr( 'title', '[' + tooltipAccessKeyPrefix + 'h]' );
60 -}
61 -
62 -var dialogwidth = false;
63 -
64 -window.trlOpenJsEdit = function( page, group ) {
65 - var url = wgScript + '?title=Special:Translate/editpage&suggestions=async&page=$1&loadgroup=$2';
66 - url = url.replace( '$1', encodeURIComponent( page ) ).replace( '$2', encodeURIComponent( group ) );
67 - var id = 'jsedit' + page.replace( /[^a-zA-Z0-9_]/g, '_' );
68 -
69 - var dialog = $( '#' + id );
70 - if ( dialog.size() > 0 ) {
71 - dialog.dialog( 'option', 'position', 'top' );
72 - dialog.dialog( 'open' );
73 - return false;
74 - }
75 -
76 - $( '<div/>' ).attr( 'id', id ).appendTo( $( 'body' ) );
77 - dialog = $( '#' + id );
78 -
79 - var spinner = $( '<div/>' ).attr( 'class', 'mw-ajax-loader' );
80 - dialog.html( $( '<div/>' ).attr( 'class', 'mw-ajax-dialog' ).html( spinner ) );
81 -
82 - dialog.load(url, false, function() {
83 - var form = $( '#' + id + ' form' );
84 -
85 - form.hide().slideDown();
86 -
87 - // Enable the collapsible element
88 - var $identical = $( '.mw-identical-title' );
89 - if ( $.isFunction( $identical.makeCollapsible ) ) {
90 - $identical.makeCollapsible();
91 - }
92 -
93 - form.find( '.mw-translate-next' ).click( function() {
94 - trlLoadNext( page );
95 - } );
96 -
97 - form.find( '.mw-translate-skip' ).click( function() {
98 - trlLoadNext( page );
99 - dialog.dialog( 'close' );
100 - return false;
101 - } );
102 -
103 - form.find( '.mw-translate-history' ).click( function() {
104 - window.open( wgServer + wgScript + '?action=history&title=' + form.find( 'input[name=title]' ).val() );
105 - return false;
106 - } );
107 -
108 - form.find( '.mw-translate-support' ).click( function() {
109 - // Can use .data() only with 1.4.3 or newer
110 - window.open( $(this).attr('data-load-url') );
111 - return false;
112 - } );
113 -
114 - form.find( 'input#summary' ).focus( function() {
115 - $(this).css('width', '85%');
116 - });
117 -
118 - var textarea = form.find( '.mw-translate-edit-area' );
119 - textarea.css( 'display', 'block' );
120 - textarea.autoResize({extraSpace: 15, limit: 200}).trigger( 'change' );
121 - textarea.focus();
122 -
123 - if ( form.find( '.mw-translate-messagechecks' ) ) {
124 - var checker = new MessageCheckUpdater( function() {
125 - var url = wgScript + '?title=Special:Translate/editpage&suggestions=checks&page=$1&loadgroup=$2';
126 - url = url.replace( '$1', encodeURIComponent( page ) ).replace( '$2', encodeURIComponent( group ) );
127 - $.post( url, { translation: textarea.val() }, function( mydata ) {
128 - form.find( '.mw-translate-messagechecks' ).replaceWith( mydata );
129 - } );
130 - } );
131 -
132 - textarea.keyup( function() {
133 - checker.setup();
134 - } );
135 - }
136 -
137 - addAccessKeys( form );
138 - var b = null;
139 - b = form.find( '.mw-translate-save' );
140 - b.val( b.val() + ' (a)' );
141 - b = form.find( '.mw-translate-next' );
142 - b.val( b.val() + ' (s)' );
143 - b = form.find( '.mw-translate-skip' );
144 - b.val( b.val() + ' (d)' );
145 - b = form.find( '.mw-translate-history' );
146 - b.val( b.val() + ' (h)' );
147 -
148 - form.ajaxForm( {
149 - dataType: 'json',
150 - success: function(json) {
151 - if ( json.error ) {
152 - alert( json.error.info + ' (' + json.error.code +')' );
153 - } else if ( json.edit.result === 'Failure' ) {
154 - alert( mw.msg( 'translate-js-save-failed' ) );
155 - } else if ( json.edit.result === 'Success' ) {
156 - dialog.dialog( 'close' );
157 - } else {
158 - alert( mw.msg( 'translate-js-save-failed' ) );
159 - }
160 - }
161 - } );
162 - } );
163 -
164 - dialog.dialog( {
165 - bgiframe: true,
166 - width: dialogwidth ? dialogwidth : parseInt( trlVpWidth()*0.8, 10 ),
167 - title: page,
168 - position: 'top',
169 - resize: function(event, ui) {
170 - $( '#' + id + ' textarea' ).width( '100%' );
171 - },
172 - resizeStop: function(event, ui) {
173 - dialogwidth = $( '#' + id ).width();
174 - },
175 - focus: function(event, ui) {
176 - addAccessKeys( dialog );
177 - },
178 - close: function(event, ui) {
179 - addAccessKeys( $([]) );
180 - }
181 - } );
182 -
183 - return false;
184 -}
185 -
186 -function trlLoadNext( title ) {
187 - var page = title.replace( /[^:]+:/, '' );
188 - var namespace = title.replace( /:.*/, '' );
189 - var found = false;
190 - for ( var key in trlKeys ) {
191 - if ( !trlKeys.hasOwnProperty(key) ) { continue; }
192 - var value = trlKeys[key];
193 - if (found) {
194 - return trlOpenJsEdit( namespace + ':' + value );
195 - } else if( page === value ) {
196 - found = true;
197 - }
198 - }
199 - alert( mw.msg( 'translate-js-nonext' ) );
200 - return;
201 -}
202 -
203 -})(jQuery);
\ No newline at end of file
Index: trunk/extensions/Translate/js/ext.translate.css
@@ -0,0 +1,62 @@
 2+.mw-translate-fuzzy {
 3+ background-color: #FDD;
 4+}
 5+
 6+.mw-translate-page-info {
 7+ font-size: x-small;
 8+ text-align: center;
 9+ direction: ltr;
 10+}
 11+
 12+.mw-translate-definition-preview {
 13+ font-family: monospace;
 14+ background-color: #F3F3FF;
 15+ border: 1px solid black;
 16+}
 17+
 18+.mw-pt-languages table {
 19+ direction: ltr;
 20+ border: 1px solid rgb(170, 170, 170);
 21+ background: rgb(246, 249, 237) none repeat scroll 0% 0%;
 22+ border-collapse: collapse;
 23+ line-height: 1.2;
 24+ width: 100%;
 25+}
 26+
 27+.mw-pt-languages-label {
 28+ border-right: 1px solid rgb(170, 170, 170);
 29+ padding: 0.5em;
 30+ background: rgb(238, 243, 226) none repeat scroll 0% 0%;
 31+ width: 200px;
 32+}
 33+
 34+.mw-pt-languages-list {
 35+ padding: 0.5em;
 36+}
 37+
 38+.mw-tpt-sp-legend {
 39+ font-weight: bold;
 40+}
 41+
 42+.mw-tpt-sp-content {
 43+ font-size: small;
 44+ padding-left: 2em;
 45+ padding-right: 2em;
 46+ padding-bottom: 2ex;
 47+}
 48+
 49+/* First Steps '*/
 50+#translate-fs-signup {
 51+ display: block;
 52+ margin: 1em;
 53+ font-weight: bold;
 54+ font-size: 200%;
 55+}
 56+
 57+#translate-fs-signup a {
 58+ border: 2px dotted gray;
 59+ border-radius: 10px;
 60+ -moz-border-radius: 10px;
 61+ -webkit-border-radius: 10px;
 62+ background-color: #D1E231 !important;
 63+}
\ No newline at end of file
Property changes on: trunk/extensions/Translate/js/ext.translate.css
___________________________________________________________________
Added: svn:eol-style
164 + native
Index: trunk/extensions/Translate/js/ext.translate.quickedit.js
@@ -0,0 +1,202 @@
 2+/**
 3+ * JavaScript that implements the Ajax translation interface, which was at the
 4+ * time of writing this probably the biggest usability problem in the extension.
 5+ * Most importantly, it speeds up translating and keeps the list of translatable
 6+ * messages open. It also allows multiple translation dialogs, for doing quick
 7+ * updates to other messages or documentation, or translating multiple languages
 8+ * simultaneously together with the "In other languages" display included in
 9+ * translation helpers and implemented by utils/TranslationhHelpers.php.
 10+ * The form itself is implemented by utils/TranslationEditPage.php, which is
 11+ * called from Special:Translate/editpage?page=Namespace:pagename.
 12+ *
 13+ * TODO list:
 14+ * * On succesful save, update the MessageTable display too.
 15+ * * Autoload ui classes
 16+ * * Instead of hc'd onscript, give them a class and use necessary triggers
 17+ *
 18+ * @author Niklas Laxström
 19+ * @copyright Copyright © 2009-2011 Niklas Laxström
 20+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 21+ */
 22+
 23+(function($) {
 24+
 25+function MessageCheckUpdater( callback ) {
 26+
 27+ this.act = function() {
 28+ callback();
 29+ delete this.timeoutID;
 30+ };
 31+
 32+ this.setup = function() {
 33+ this.cancel();
 34+ var self = this;
 35+ this.timeoutID = window.setTimeout( self.act, 1000 );
 36+ };
 37+
 38+ this.cancel = function() {
 39+ if ( typeof this.timeoutID === 'number' ) {
 40+ window.clearTimeout( this.timeoutID );
 41+ delete this.timeoutID;
 42+ }
 43+ };
 44+}
 45+
 46+function trlVpWidth() {
 47+ return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
 48+}
 49+
 50+function addAccessKeys(dialog) {
 51+ $( '[accesskey=a], [accesskey=s], [accesskey=d], [accesskey=h]' ).each(
 52+ function( i ) {
 53+ $(this).removeAttr( 'accesskey' );
 54+ }
 55+ );
 56+ dialog.find( '.mw-translate-save' ).attr( 'accesskey', 'a' ).attr( 'title', '[' + tooltipAccessKeyPrefix + 'a]' );
 57+ dialog.find( '.mw-translate-next' ).attr( 'accesskey', 's' ).attr( 'title', '[' + tooltipAccessKeyPrefix + 's]' );
 58+ dialog.find( '.mw-translate-skip' ).attr( 'accesskey', 'd' ).attr( 'title', '[' + tooltipAccessKeyPrefix + 'd]' );
 59+ dialog.find( '.mw-translate-history' ).attr( 'accesskey', 'h' ).attr( 'title', '[' + tooltipAccessKeyPrefix + 'h]' );
 60+}
 61+
 62+var dialogwidth = false;
 63+
 64+window.trlOpenJsEdit = function( page, group ) {
 65+ var url = wgScript + '?title=Special:Translate/editpage&suggestions=async&page=$1&loadgroup=$2';
 66+ url = url.replace( '$1', encodeURIComponent( page ) ).replace( '$2', encodeURIComponent( group ) );
 67+ var id = 'jsedit' + page.replace( /[^a-zA-Z0-9_]/g, '_' );
 68+
 69+ var dialog = $( '#' + id );
 70+ if ( dialog.size() > 0 ) {
 71+ dialog.dialog( 'option', 'position', 'top' );
 72+ dialog.dialog( 'open' );
 73+ return false;
 74+ }
 75+
 76+ $( '<div/>' ).attr( 'id', id ).appendTo( $( 'body' ) );
 77+ dialog = $( '#' + id );
 78+
 79+ var spinner = $( '<div/>' ).attr( 'class', 'mw-ajax-loader' );
 80+ dialog.html( $( '<div/>' ).attr( 'class', 'mw-ajax-dialog' ).html( spinner ) );
 81+
 82+ dialog.load(url, false, function() {
 83+ var form = $( '#' + id + ' form' );
 84+
 85+ form.hide().slideDown();
 86+
 87+ // Enable the collapsible element
 88+ var $identical = $( '.mw-identical-title' );
 89+ if ( $.isFunction( $identical.makeCollapsible ) ) {
 90+ $identical.makeCollapsible();
 91+ }
 92+
 93+ form.find( '.mw-translate-next' ).click( function() {
 94+ trlLoadNext( page );
 95+ } );
 96+
 97+ form.find( '.mw-translate-skip' ).click( function() {
 98+ trlLoadNext( page );
 99+ dialog.dialog( 'close' );
 100+ return false;
 101+ } );
 102+
 103+ form.find( '.mw-translate-history' ).click( function() {
 104+ window.open( wgServer + wgScript + '?action=history&title=' + form.find( 'input[name=title]' ).val() );
 105+ return false;
 106+ } );
 107+
 108+ form.find( '.mw-translate-support' ).click( function() {
 109+ // Can use .data() only with 1.4.3 or newer
 110+ window.open( $(this).attr('data-load-url') );
 111+ return false;
 112+ } );
 113+
 114+ form.find( 'input#summary' ).focus( function() {
 115+ $(this).css('width', '85%');
 116+ });
 117+
 118+ var textarea = form.find( '.mw-translate-edit-area' );
 119+ textarea.css( 'display', 'block' );
 120+ textarea.autoResize({extraSpace: 15, limit: 200}).trigger( 'change' );
 121+ textarea.focus();
 122+
 123+ if ( form.find( '.mw-translate-messagechecks' ) ) {
 124+ var checker = new MessageCheckUpdater( function() {
 125+ var url = wgScript + '?title=Special:Translate/editpage&suggestions=checks&page=$1&loadgroup=$2';
 126+ url = url.replace( '$1', encodeURIComponent( page ) ).replace( '$2', encodeURIComponent( group ) );
 127+ $.post( url, { translation: textarea.val() }, function( mydata ) {
 128+ form.find( '.mw-translate-messagechecks' ).replaceWith( mydata );
 129+ } );
 130+ } );
 131+
 132+ textarea.keyup( function() {
 133+ checker.setup();
 134+ } );
 135+ }
 136+
 137+ addAccessKeys( form );
 138+ var b = null;
 139+ b = form.find( '.mw-translate-save' );
 140+ b.val( b.val() + ' (a)' );
 141+ b = form.find( '.mw-translate-next' );
 142+ b.val( b.val() + ' (s)' );
 143+ b = form.find( '.mw-translate-skip' );
 144+ b.val( b.val() + ' (d)' );
 145+ b = form.find( '.mw-translate-history' );
 146+ b.val( b.val() + ' (h)' );
 147+
 148+ form.ajaxForm( {
 149+ dataType: 'json',
 150+ success: function(json) {
 151+ if ( json.error ) {
 152+ alert( json.error.info + ' (' + json.error.code +')' );
 153+ } else if ( json.edit.result === 'Failure' ) {
 154+ alert( mw.msg( 'translate-js-save-failed' ) );
 155+ } else if ( json.edit.result === 'Success' ) {
 156+ dialog.dialog( 'close' );
 157+ } else {
 158+ alert( mw.msg( 'translate-js-save-failed' ) );
 159+ }
 160+ }
 161+ } );
 162+ } );
 163+
 164+ dialog.dialog( {
 165+ bgiframe: true,
 166+ width: dialogwidth ? dialogwidth : parseInt( trlVpWidth()*0.8, 10 ),
 167+ title: page,
 168+ position: 'top',
 169+ resize: function(event, ui) {
 170+ $( '#' + id + ' textarea' ).width( '100%' );
 171+ },
 172+ resizeStop: function(event, ui) {
 173+ dialogwidth = $( '#' + id ).width();
 174+ },
 175+ focus: function(event, ui) {
 176+ addAccessKeys( dialog );
 177+ },
 178+ close: function(event, ui) {
 179+ addAccessKeys( $([]) );
 180+ }
 181+ } );
 182+
 183+ return false;
 184+}
 185+
 186+function trlLoadNext( title ) {
 187+ var page = title.replace( /[^:]+:/, '' );
 188+ var namespace = title.replace( /:.*/, '' );
 189+ var found = false;
 190+ for ( var key in trlKeys ) {
 191+ if ( !trlKeys.hasOwnProperty(key) ) { continue; }
 192+ var value = trlKeys[key];
 193+ if (found) {
 194+ return trlOpenJsEdit( namespace + ':' + value );
 195+ } else if( page === value ) {
 196+ found = true;
 197+ }
 198+ }
 199+ alert( mw.msg( 'translate-js-nonext' ) );
 200+ return;
 201+}
 202+
 203+})(jQuery);
\ No newline at end of file
Property changes on: trunk/extensions/Translate/js/ext.translate.quickedit.js
___________________________________________________________________
Added: svn:eol-style
1204 + native
Index: trunk/extensions/Translate/Translate.php
@@ -131,7 +131,7 @@
132132
133133 // Client-side resource modules
134134 $wgResourceModules['ext.translate'] = array(
135 - 'styles' => 'Translate.css',
 135+ 'styles' => 'js/ext.translate.css',
136136 ) + $resourcePaths;
137137
138138 $wgResourceModules['ext.translate.special.languagestats'] = array(
@@ -141,7 +141,7 @@
142142 ) + $resourcePaths;
143143
144144 $wgResourceModules['ext.translate.quickedit'] = array(
145 - 'scripts' => 'js/quickedit.js',
 145+ 'scripts' => 'js/ext.translate.quickedit.js',
146146 'styles' => 'js/ext.translate.quickedit.css',
147147 'messages' => array( 'translate-js-nonext', 'translate-js-save-failed' ),
148148 'dependencies' => array(

Status & tagging log