Index: trunk/extensions/Narayam/ext.narayam.rules.ta99.js |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | ['ணo', '','ண்ட'], |
102 | 102 | ['ஞ\\[', '','ஞ்ச'], |
103 | 103 | ['மj', '','ம்ப'], |
104 | | - |
| 104 | + |
105 | 105 | ['q', '','ஆ'], |
106 | 106 | ['w', '','ஈ'], |
107 | 107 | ['e', '','ஊ'], |
Index: trunk/extensions/Narayam/ext.narayam.rules.si-singlish.js |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * @credits With help from Nishantha Anuruddha (si.wikipedia.org/wiki/user:බිඟුවා) |
7 | 7 | * License: GPLv3 |
8 | 8 | */ |
9 | | - |
| 9 | + |
10 | 10 | // Normal rules |
11 | 11 | var rules = [ |
12 | 12 | ['\\\\([A-Za-z\\>_~\\.0-9])', '\\\\','$1'], |
— | — | @@ -104,4 +104,4 @@ |
105 | 105 | 'lookbackLength': 5, |
106 | 106 | 'keyBufferLength': 2, |
107 | 107 | 'rules': rules |
108 | | -} ); |
| 108 | +} ); |
Index: trunk/extensions/Narayam/ext.narayam.rules.si-wijesekara.js |
— | — | @@ -6,14 +6,14 @@ |
7 | 7 | * http://www.ucsc.lk/ltrl/services/layout/ |
8 | 8 | * License: GPLv3 |
9 | 9 | */ |
10 | | - |
| 10 | + |
11 | 11 | var rules = [ |
12 | 12 | ['`', '', '්ර'], |
13 | 13 | ['~', '', 'ර්'], |
14 | 14 | |
15 | 15 | ['q', '', 'ු'], |
16 | 16 | ['w', '', 'අ'], |
17 | | -['e', '', 'ැ'], |
| 17 | +['e', '', 'ැ'], |
18 | 18 | ['r', '', 'ර'], |
19 | 19 | ['t', '', 'එ'], |
20 | 20 | ['y', '', 'හ'], |
— | — | @@ -95,4 +95,4 @@ |
96 | 96 | 'keyBufferLength': 0, |
97 | 97 | 'rules': rules, |
98 | 98 | 'rules_x': rules_x |
99 | | -} ); |
| 99 | +} ); |
Index: trunk/extensions/Narayam/ext.narayam.core.js |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | ( function( $ ) { |
18 | 18 | $.narayam = new ( function() { |
19 | 19 | /* Private members */ |
20 | | - |
| 20 | + |
21 | 21 | // Reference to this object |
22 | 22 | var that = this; |
23 | 23 | // jQuery array holding all text inputs Narayam applies to |
— | — | @@ -41,9 +41,9 @@ |
42 | 42 | shiftKey: false, |
43 | 43 | key: null |
44 | 44 | }; |
45 | | - |
| 45 | + |
46 | 46 | /* Private functions */ |
47 | | - |
| 47 | + |
48 | 48 | /** |
49 | 49 | * Transliterate a string using the current scheme |
50 | 50 | * @param str String to transliterate |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | // No matches, return the input |
70 | 70 | return str; |
71 | 71 | } |
72 | | - |
| 72 | + |
73 | 73 | /** |
74 | 74 | * Get the n characters in str that immediately precede pos |
75 | 75 | * Example: lastNChars( "foobarbaz", 5, 2 ) == "ba" |
— | — | @@ -87,7 +87,7 @@ |
88 | 88 | return str.substr( pos - n, n); |
89 | 89 | } |
90 | 90 | } |
91 | | - |
| 91 | + |
92 | 92 | /** |
93 | 93 | * Find the point at which a and b diverge, i.e. the first position |
94 | 94 | * at which they don't have matching characters. |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | } |
106 | 106 | return -1; |
107 | 107 | } |
108 | | - |
| 108 | + |
109 | 109 | /** |
110 | 110 | * Check whether a keypress event corresponds to the shortcut key |
111 | 111 | * @param e Event object |
— | — | @@ -116,7 +116,7 @@ |
117 | 117 | e.shiftKey == shortcutKey.shiftKey && |
118 | 118 | String.fromCharCode( e.which ).toLowerCase() == shortcutKey.key.toLowerCase(); |
119 | 119 | } |
120 | | - |
| 120 | + |
121 | 121 | /** |
122 | 122 | * Get a description of the shortcut key, e.g. "Ctrl-M" |
123 | 123 | * @return string |
— | — | @@ -136,7 +136,7 @@ |
137 | 137 | text += shortcutKey.key.toUpperCase(); |
138 | 138 | return text; |
139 | 139 | } |
140 | | - |
| 140 | + |
141 | 141 | /** |
142 | 142 | * Change visual appearance of element (text input, textarea) according |
143 | 143 | * current state of Narayam |
— | — | @@ -150,7 +150,7 @@ |
151 | 151 | $element.removeClass( 'narayam-input' ); |
152 | 152 | } |
153 | 153 | } |
154 | | - |
| 154 | + |
155 | 155 | /** |
156 | 156 | * Keydown event handler. Handles shortcut key presses |
157 | 157 | * @param e Event object |
— | — | @@ -168,7 +168,7 @@ |
169 | 169 | } |
170 | 170 | return true; |
171 | 171 | } |
172 | | - |
| 172 | + |
173 | 173 | /** |
174 | 174 | * Keypress event handler. This is where the real work happens |
175 | 175 | * @param e Event object |
— | — | @@ -177,19 +177,19 @@ |
178 | 178 | if ( !enabled ) { |
179 | 179 | return true; |
180 | 180 | } |
181 | | - |
| 181 | + |
182 | 182 | if ( e.which == 8 ) { // Backspace |
183 | 183 | // Blank the keybuffer |
184 | 184 | $( this ).data( 'narayamKeyBuffer', '' ); |
185 | 185 | return true; |
186 | 186 | } |
187 | | - |
| 187 | + |
188 | 188 | // Leave non-ASCII stuff alone, as well as anything involving |
189 | 189 | // Alt (except for extended keymaps), Ctrl and Meta |
190 | 190 | if ( e.which < 32 || ( e.altKey && !currentScheme.extended_keyboard ) || e.ctrlKey || e.metaKey ) { |
191 | 191 | return true; |
192 | 192 | } |
193 | | - |
| 193 | + |
194 | 194 | var $this = $( this ); |
195 | 195 | var c = String.fromCharCode( e.which ); |
196 | 196 | // Get the current caret position. The user may have selected text to overwrite, |
— | — | @@ -204,7 +204,7 @@ |
205 | 205 | var input = lastNChars( $this.val(), startPos, currentScheme.lookbackLength ) + c; |
206 | 206 | var keyBuffer = $this.data( 'narayamKeyBuffer' ); |
207 | 207 | var replacement = transliterate( input, keyBuffer, e.altKey ); |
208 | | - |
| 208 | + |
209 | 209 | // Update the key buffer |
210 | 210 | keyBuffer += c; |
211 | 211 | if ( keyBuffer.length > currentScheme.keyBufferLength ) { |
— | — | @@ -212,7 +212,7 @@ |
213 | 213 | keyBuffer = keyBuffer.substring( keyBuffer.length - currentScheme.keyBufferLength ); |
214 | 214 | } |
215 | 215 | $this.data( 'narayamKeyBuffer', keyBuffer ); |
216 | | - |
| 216 | + |
217 | 217 | // textSelection() magic is expensive, so we avoid it as much as we can |
218 | 218 | if ( replacement == input ) { |
219 | 219 | return true; |
— | — | @@ -222,7 +222,7 @@ |
223 | 223 | var divergingPos = firstDivergence( input, replacement ); |
224 | 224 | input = input.substring( divergingPos ); |
225 | 225 | replacement = replacement.substring( divergingPos ); |
226 | | - |
| 226 | + |
227 | 227 | // Select and replace the text |
228 | 228 | $this.textSelection( 'setSelection', { |
229 | 229 | 'start': startPos - input.length + 1, |
— | — | @@ -233,11 +233,11 @@ |
234 | 234 | 'replace': true, |
235 | 235 | 'selectPeri': false |
236 | 236 | } ); |
237 | | - |
| 237 | + |
238 | 238 | e.stopPropagation(); |
239 | 239 | return false; |
240 | 240 | } |
241 | | - |
| 241 | + |
242 | 242 | /** |
243 | 243 | * Focus event handler. |
244 | 244 | * @param e Event object |
— | — | @@ -246,7 +246,7 @@ |
247 | 247 | $( this ).data( 'narayamKeyBuffer', '' ); |
248 | 248 | changeVisual( $( this ) ); |
249 | 249 | } |
250 | | - |
| 250 | + |
251 | 251 | /** |
252 | 252 | * Blur event handler. |
253 | 253 | * @param e Event object |
— | — | @@ -254,7 +254,7 @@ |
255 | 255 | function onblur( e ) { |
256 | 256 | $( this ).removeClass( 'narayam-input' ); |
257 | 257 | } |
258 | | - |
| 258 | + |
259 | 259 | /** |
260 | 260 | * Change handler for the scheme dropdown. Updates the current scheme |
261 | 261 | * based on the new selection in the dropdown. |
— | — | @@ -263,7 +263,7 @@ |
264 | 264 | var scheme = $( this ).val(); |
265 | 265 | that.setScheme( scheme ); |
266 | 266 | } |
267 | | - |
| 267 | + |
268 | 268 | /* Public functions */ |
269 | 269 | |
270 | 270 | /** |
— | — | @@ -291,7 +291,7 @@ |
292 | 292 | .bind( 'blur', onblur); |
293 | 293 | } |
294 | 294 | }; |
295 | | - |
| 295 | + |
296 | 296 | /** |
297 | 297 | * Enable Narayam |
298 | 298 | */ |
— | — | @@ -302,7 +302,7 @@ |
303 | 303 | enabled = true; |
304 | 304 | } |
305 | 305 | }; |
306 | | - |
| 306 | + |
307 | 307 | /** |
308 | 308 | * Disable Narayam |
309 | 309 | */ |
— | — | @@ -313,7 +313,7 @@ |
314 | 314 | enabled = false; |
315 | 315 | } |
316 | 316 | }; |
317 | | - |
| 317 | + |
318 | 318 | /** |
319 | 319 | * Toggle the enabled/disabled state |
320 | 320 | */ |
— | — | @@ -324,7 +324,7 @@ |
325 | 325 | that.enable(); |
326 | 326 | } |
327 | 327 | }; |
328 | | - |
| 328 | + |
329 | 329 | /** |
330 | 330 | * Add a transliteration scheme. Schemes whose name is not in |
331 | 331 | * wgNarayamAvailableSchemes will be ignored. |
— | — | @@ -373,7 +373,7 @@ |
374 | 374 | return false; |
375 | 375 | } |
376 | 376 | }; |
377 | | - |
| 377 | + |
378 | 378 | /** |
379 | 379 | * Change the current transliteration scheme |
380 | 380 | * @param name String |
— | — | @@ -385,7 +385,7 @@ |
386 | 386 | $select.val( name ); |
387 | 387 | } |
388 | 388 | }; |
389 | | - |
| 389 | + |
390 | 390 | /** |
391 | 391 | * Set up Narayam. This adds the scheme dropdown, binds the handlers |
392 | 392 | * and initializes the enabled/disabled state and selected scheme |
— | — | @@ -403,18 +403,18 @@ |
404 | 404 | haveSchemes = true; |
405 | 405 | } |
406 | 406 | $select.change( updateSchemeFromSelect ); |
407 | | - |
| 407 | + |
408 | 408 | if ( !haveSchemes ) { |
409 | 409 | // No schemes available, don't show the tool |
410 | 410 | return; |
411 | 411 | } |
412 | | - |
| 412 | + |
413 | 413 | // Build enable/disable checkbox and label |
414 | 414 | var $checkbox = $( '<input type="checkbox" id="narayam-toggle" />' ); |
415 | 415 | $checkbox |
416 | 416 | .attr( 'title', mw.msg( 'narayam-checkbox-tooltip' ) ) |
417 | 417 | .click( that.toggle ); |
418 | | - |
| 418 | + |
419 | 419 | var helppage = mw.msg( 'narayam-help-page' ); |
420 | 420 | var $label = $( '<label for="narayam-toggle" />' ); |
421 | 421 | $label |
— | — | @@ -424,7 +424,7 @@ |
425 | 425 | // Link to the help page |
426 | 426 | $label.wrapInner( $( '<a />' ).attr( 'href', mw.util.wikiGetlink( helppage ) ) ); |
427 | 427 | } |
428 | | - |
| 428 | + |
429 | 429 | var $checkboxAndLabel = $( '<span />' ) |
430 | 430 | .addClass( 'narayam-toggle-wrapper' ) |
431 | 431 | .append( $checkbox ) |
— | — | @@ -433,11 +433,11 @@ |
434 | 434 | .addClass( 'narayam-wrapper' ) |
435 | 435 | .append( $select ) |
436 | 436 | .append( $checkboxAndLabel ); |
437 | | - |
| 437 | + |
438 | 438 | // Put the dropdown and the checkbox at the beginning of the |
439 | 439 | // search form. This seems to be the most reliable way across skins. |
440 | 440 | $( '#searchform' ).prepend( $spanWithEverything ); |
441 | | - |
| 441 | + |
442 | 442 | // Restore state from cookies |
443 | 443 | var savedScheme = $.cookie( 'narayam-scheme' ); |
444 | 444 | if ( savedScheme && savedScheme in schemes ) { |
— | — | @@ -453,9 +453,9 @@ |
454 | 454 | if ( enabledCookie ) { |
455 | 455 | $.cookie( 'narayam-enabled', enabledCookie, { 'path': '/', 'expires': 30 } ); |
456 | 456 | } |
457 | | - |
| 457 | + |
458 | 458 | }; |
459 | | - |
| 459 | + |
460 | 460 | } )(); |
461 | 461 | |
462 | 462 | } )( jQuery ); |
Index: trunk/extensions/Narayam/Narayam.i18n.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * |
6 | 6 | * @addtogroup Extensions |
7 | 7 | * @author Junaid P V <http://junaidpv.in> |
8 | | - * @copyright 2010 Junaid P V |
| 8 | + * @copyright 2010-2011 Junaid P V |
9 | 9 | * @license GNU General Public Licence 3.0 or later |
10 | 10 | */ |
11 | 11 | |
Index: trunk/extensions/Narayam/ext.narayam.rules.ta.js |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | ['ழ்h','h','ழ்ஹ்',], |
13 | 13 | |
14 | 14 | //'(ஸ்ரிi|ஸ்ர்I)', '','', |
15 | | - |
| 15 | + |
16 | 16 | ['([க-ஹ])்a', '','$1'], |
17 | 17 | ['([க-ஹ])(்A|a)', '','$1ா'], |
18 | 18 | ['([க-ஹ])்i', '','$1ி'], |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | ['([க-ஹ])u', '','$1ௌ'], |
28 | 28 | |
29 | 29 | ['([அ-ஹ][ெ-்]?)n', '','$1ன்'], |
30 | | - |
| 30 | + |
31 | 31 | ['அa', '','ஆ'], |
32 | 32 | ['இi', '','ஈ'], |
33 | 33 | ['உu', '','ஊ'], |
— | — | @@ -34,14 +34,14 @@ |
35 | 35 | ['அi', '','ஐ'], |
36 | 36 | ['ஒo', '','ஓ'], |
37 | 37 | ['அu', '','ஔ'], |
38 | | - |
| 38 | + |
39 | 39 | ['(ந்|ன்)g', '','ங்'], |
40 | 40 | ['(ந்|ன்)j', '','ஞ்'], |
41 | 41 | ['ச்h', '','ச்'], |
42 | 42 | ['ழ்h', '','ழ்'], |
43 | 43 | ['ட்h', '','த்'], |
44 | 44 | ['ஸ்h', '','ஷ்'], |
45 | | - |
| 45 | + |
46 | 46 | ['a', '','அ'], |
47 | 47 | ['b', '','ப்'], |
48 | 48 | ['c', '','ச்'], |
Index: trunk/extensions/Narayam/Narayam.hooks.php |
— | — | @@ -1,32 +1,37 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * Hooks for Narayam extension |
6 | 5 | * @file |
7 | 6 | * @ingroup Extensions |
8 | 7 | */ |
| 8 | + |
9 | 9 | class NarayamHooks { |
10 | | - |
11 | 10 | public static function addModules( $out, $skin ) { |
12 | 11 | global $wgUser; |
| 12 | + |
13 | 13 | if ( $wgUser->getOption( 'narayamDisable' ) ) { |
14 | 14 | // User disabled Narayam |
15 | 15 | return true; |
16 | 16 | } |
| 17 | + |
17 | 18 | $schemes = array_values( self::getSchemes () ); |
| 19 | + |
18 | 20 | if ( count( $schemes ) ) { |
19 | 21 | $out->addModules( $schemes ); |
20 | 22 | $out->addModules( 'ext.narayam' ); |
21 | 23 | } |
| 24 | + |
22 | 25 | return true; |
23 | 26 | } |
24 | 27 | |
25 | 28 | public static function addConfig( &$vars ) { |
26 | 29 | global $wgNarayamEnabledByDefault, $wgNarayamShortcutKey, $wgUser; |
| 30 | + |
27 | 31 | if ( $wgUser->getOption( 'narayamDisable' ) ) { |
28 | 32 | // User disabled Narayam |
29 | 33 | return true; |
30 | 34 | } |
| 35 | + |
31 | 36 | $vars['wgNarayamEnabledByDefault'] = $wgNarayamEnabledByDefault; |
32 | 37 | $vars['wgNarayamShortcutKey'] = $wgNarayamShortcutKey; |
33 | 38 | |
— | — | @@ -35,11 +40,14 @@ |
36 | 41 | |
37 | 42 | public static function addVariables( &$vars ) { |
38 | 43 | global $wgUser; |
| 44 | + |
39 | 45 | if ( $wgUser->getOption( 'narayamDisable' ) ) { |
40 | 46 | // User disabled Narayam |
41 | 47 | return true; |
42 | 48 | } |
| 49 | + |
43 | 50 | $vars['wgNarayamAvailableSchemes'] = self::getSchemes(); // Note: scheme names must be keys, not values |
| 51 | + |
44 | 52 | return true; |
45 | 53 | } |
46 | 54 | |
— | — | @@ -49,11 +57,13 @@ |
50 | 58 | */ |
51 | 59 | protected static function getSchemes() { |
52 | 60 | global $wgLanguageCode, $wgLang, $wgNarayamSchemes; |
| 61 | + |
53 | 62 | $userlangCode = $wgLang->getCode(); |
54 | 63 | $contlangSchemes = isset( $wgNarayamSchemes[$wgLanguageCode] ) ? |
55 | 64 | $wgNarayamSchemes[$wgLanguageCode] : array(); |
56 | 65 | $userlangSchemes = isset( $wgNarayamSchemes[$userlangCode] ) ? |
57 | 66 | $wgNarayamSchemes[$userlangCode] : array(); |
| 67 | + |
58 | 68 | return $userlangSchemes + $contlangSchemes; |
59 | 69 | } |
60 | 70 | |
— | — | @@ -64,7 +74,7 @@ |
65 | 75 | 'label-message' => 'narayam-disable-preference', // a system message |
66 | 76 | 'section' => 'editing/advancedediting', // under 'Advanced options' section of 'Editing' tab |
67 | 77 | ); |
| 78 | + |
68 | 79 | return true; |
69 | 80 | } |
70 | | - |
71 | 81 | } |
Index: trunk/extensions/Narayam/ext.narayam.rules.or-inscript.js |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * @date 2011-02-28 |
7 | 7 | * License: GPLv3 |
8 | 8 | */ |
9 | | - |
| 9 | + |
10 | 10 | var rules = [ |
11 | 11 | ['X', '', '\u0B01'], |
12 | 12 | ['x', '', '\u0B02'], |
Index: trunk/extensions/Narayam/Narayam.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * NAME |
6 | 5 | * Narayam |
— | — | @@ -23,11 +22,11 @@ |
24 | 23 | * @copyright Copyright 2010 Junaid P V |
25 | 24 | * @license GPLv3 |
26 | 25 | */ |
| 26 | + |
27 | 27 | if ( !defined( 'MEDIAWIKI' ) ) { |
28 | 28 | exit( 1 ); |
29 | 29 | } |
30 | 30 | |
31 | | - |
32 | 31 | /* Configuration */ |
33 | 32 | |
34 | 33 | // Whether the input method should be active as default or not |
— | — | @@ -91,6 +90,8 @@ |
92 | 91 | |
93 | 92 | /* Setup */ |
94 | 93 | |
| 94 | +$dir = dirname( __FILE__ ); |
| 95 | + |
95 | 96 | // Register extension credits |
96 | 97 | $wgExtensionCredits['other'][] = array( |
97 | 98 | 'path' => __FILE__, |
— | — | @@ -102,7 +103,7 @@ |
103 | 104 | ); |
104 | 105 | |
105 | 106 | // Localization |
106 | | -$wgExtensionMessagesFiles['Narayam'] = dirname( __FILE__ ) . '/Narayam.i18n.php'; |
| 107 | +$wgExtensionMessagesFiles['Narayam'] = $dir . '/Narayam.i18n.php'; |
107 | 108 | |
108 | 109 | // Register hook function |
109 | 110 | $wgHooks['BeforePageDisplay'][] = 'NarayamHooks::addModules'; |
— | — | @@ -111,11 +112,11 @@ |
112 | 113 | $wgHooks['GetPreferences'][] = 'NarayamHooks::addPreference'; |
113 | 114 | |
114 | 115 | // Autoloader |
115 | | -$wgAutoloadClasses['NarayamHooks'] = dirname( __FILE__ ) . '/Narayam.hooks.php'; |
| 116 | +$wgAutoloadClasses['NarayamHooks'] = $dir . '/Narayam.hooks.php'; |
116 | 117 | |
117 | 118 | // ResourceLoader module registration |
118 | 119 | $narayamTpl = array( |
119 | | - 'localBasePath' => dirname( __FILE__ ), |
| 120 | + 'localBasePath' => $dir, |
120 | 121 | 'remoteExtPath' => 'Narayam', |
121 | 122 | ); |
122 | 123 | $wgResourceModules['ext.narayam'] = $narayamTpl + array( |