updates
[webos-internals:djcin7s-modifications.git] / mojo / mojo-russian-layout-for-hardware-keyboard.patch
1 diff --git a/usr/lib/luna/system/luna-applauncher/app/controllers/global-search-assistant.js b/usr/lib/luna/system/luna-applauncher/app/controllers/global-search-assistant.js
2 index b9db2c2..3a55132 100644
3 --- a/usr/lib/luna/system/luna-applauncher/app/controllers/global-search-assistant.js
4 +++ b/usr/lib/luna/system/luna-applauncher/app/controllers/global-search-assistant.js
5 @@ -324,7 +324,7 @@ GlobalSearchAssistant = Class.create({
6                 }
7                 
8                 // try to handle the very first key event
9 -               var s;
10 +               var s=/^\w+$/;
11                 if (Mojo.Char.isPrintableChar(event.keyCode, true) && !event.ctrlKey) {
12                         s = String.fromCharCode(event.keyCode);
13                 }
14 @@ -332,7 +332,10 @@ GlobalSearchAssistant = Class.create({
15                 if (s && this.searchTerm.length==0 && this.searchPressHoldTerm.length==0) {
16                         // first valid key press event
17                         this.activate(s);
18 -                       this.updateSearchTerm(s, true);
19 +                       if(!s.test(str))
20 +                               this.updateSearchTerm(s, true);
21 +                       else
22 +                               this.updateSearchTerm(" ", true);
23                         
24                         // we manually updated the search field
25                         event.preventDefault();
26 diff --git a/usr/palm/frameworks/mojo/mojo.js b/usr/palm/frameworks/mojo/mojo.js
27 index ef37357..0b6dbbc 100644
28 --- a/usr/palm/frameworks/mojo/mojo.js
29 +++ b/usr/palm/frameworks/mojo/mojo.js
30 @@ -1,4 +1,3 @@
31 -/*jslint evil: true */
32  /*--------------------------------------------------------------------------
33  *  Mojo JavaScript framework, version 1.0
34  *  Copyright 2009 Palm, Inc.  All rights reserved.
35 @@ -7,6 +6,108 @@
36  * @name mojo.js
37  * @fileOverview This file has functions related to documenting the Mojo Framework.
38  */
39 +//Cyrillic input. Version 0.7
40 +//there are used some parts of code from JustInput project.
41 +       window.rp=new Array();
42 +       window.rp['a']='а';
43 +       window.rp['b']='б';
44 +       window.rp['c']='ц';
45 +       window.rp['d']='д';
46 +       window.rp['e']='е';
47 +       window.rp['f']='ф';
48 +       window.rp['g']='г';
49 +       window.rp['h']='х';
50 +       window.rp['i']='и';
51 +       window.rp['j']='й';
52 +       window.rp['k']='к';
53 +       window.rp['l']='л';
54 +       window.rp['m']='м';
55 +       window.rp['n']='н';
56 +       window.rp['o']='о';
57 +       window.rp['p']='п';
58 +       window.rp['q']='ь';
59 +       window.rp['r']='р';
60 +       window.rp['s']='с';
61 +       window.rp['t']='т';
62 +       window.rp['u']='у';
63 +       window.rp['v']='в';
64 +       window.rp['w']='щ';
65 +       window.rp['x']='х';
66 +       window.rp['y']='ы';
67 +       window.rp['z']='з';
68 +       window.rp['\'']='ъ';
69 +
70 +       window.rp['A']='А';
71 +       window.rp['B']='Б';
72 +       window.rp['C']='Ц';
73 +       window.rp['D']='Д';
74 +       window.rp['E']='Е';
75 +       window.rp['F']='Ф';
76 +       window.rp['G']='Г';
77 +       window.rp['H']='Х';
78 +       window.rp['I']='И';
79 +       window.rp['J']='Й';
80 +       window.rp['K']='К';
81 +       window.rp['L']='Л';
82 +       window.rp['M']='М';
83 +       window.rp['N']='Н';
84 +       window.rp['O']='О';
85 +       window.rp['P']='П';
86 +       window.rp['Q']='Ь';
87 +       window.rp['R']='Р';
88 +       window.rp['S']='С';
89 +       window.rp['T']='Т';
90 +       window.rp['U']='У';
91 +       window.rp['V']='В';
92 +       window.rp['W']='Щ';
93 +       window.rp['X']='Х';
94 +       window.rp['Y']='Ы';
95 +       window.rp['Z']='З';
96 +
97 +       //groups
98 +       window.rp['цх']='ч';
99 +       window.rp['Цх']='Ч';
100 +       window.rp['цХ']='Ч';
101 +       window.rp['ЦХ']='Ч';
102 +       window.rp['сх']='ш';
103 +       window.rp['Сх']='Ш';
104 +       window.rp['СХ']='Ш';
105 +       window.rp['сХ']='Ш';
106 +       window.rp['йа']='я';
107 +       window.rp['ЙА']='Я';
108 +       window.rp['Йа']='Я';
109 +       window.rp['йА']='Я';
110 +       window.rp['ЙЕ']='Э';
111 +       window.rp['Йе']='Э';
112 +       window.rp['йе']='э';
113 +       window.rp['йЕ']='Э';
114 +       window.rp['зх']='ж';
115 +       window.rp['Зх']='Ж';
116 +       window.rp['ЗХ']='Ж';
117 +       window.rp['зХ']='Ж';
118 +       window.rp['гх']='ж';
119 +       window.rp['Гх']='Ж';
120 +       window.rp['ГХ']='Ж';
121 +       window.rp['гХ']='Ж';
122 +       window.rp['йо']='ё';
123 +       window.rp['Йо']='Ё';
124 +       window.rp['ЙО']='Ё';
125 +       window.rp['йО']='Ё';
126 +       window.rp['йу']='ю';
127 +       window.rp['Йу']='Ю';
128 +       window.rp['ЙУ']='Ю';
129 +       window.rp['йУ']='Ю';
130 +       window.rp['ыо']='йо';
131 +       window.rp['Ыо']='Йо';
132 +       window.rp['ЫО']='ЙО';
133 +       window.rp['ыО']='йО';
134 +       window.rp['ыа']='я';
135 +       window.rp['Ыа']='Я';
136 +       window.rp['ЫА']='Я';
137 +       window.rp['ыА']='я';
138 +
139 +       window.kblayout="en";
140 +       window.prevchar="";
141  
142  // if there's an appropriately named Prototype loader global, then we're running in an environment with
143  // prototype built-in and should initialize it to copy it into the global object. 
144 @@ -189,3 +290,161 @@ if((Mojo.Version.use === 'trunk' || parseInt(Mojo.Version.use,10) >= 135 )) {
145                 window.PalmSystem.stagePreparing();
146         }
147  }
148 +var timePress = 0;
149 +document.onkeydown = function(event) {
150 +       if (event.keyCode == 17)
151 +       {
152 +               if (timePress == 0)
153 +               {
154 +                       timePress++;
155 +                       setTimeout(cleanTimer, 500);
156 +               }
157 +               else
158 +               {
159 +                       window.prevchar="";
160 +                       window.prevcharen="";
161 +                       if(window.kblayout=="en")
162 +                       {
163 +                               var t=document.getElementsByTagName("BODY")[0];
164 +                               var div=document.createElement("div");
165 +                               div.style.position="fixed";
166 +                               div.id="kblayoutdiv";
167 +                               div.style.display="block";
168 +                               div.style.top="80%";
169 +                               div.style.left="90%";
170 +                               div.style.width="24px";
171 +                               div.style.height="20px";
172 +                               div.style.border="2px solid gray";
173 +                               div.style.background="green";
174 +                               div.style.zIndex="255";
175 +                               div.style.opacity=0.6;
176 +                               div.style.webkitBorderRadius="3px";
177 +                               div.innerHTML="<div style=\"margin-top:-5px;\">Ru</div>";
178 +                               t.appendChild(div);
179 +                               window.kblayout="ru";
180 +                       }
181 +                       else
182 +                       {
183 +                               var t=document.getElementById("kblayoutdiv");
184 +                               t.parentNode.removeChild(t);
185 +                               window.kblayout="en";
186 +                       }
187 +               }
188 +       }
189 +       if(window.kblayout=="en")return;
190 +       if(event.target.tagName!="OBJECT")return;
191 +       if((event.keyCode!=39) && (event.keyCode<65 || event.keyCode>90))
192 +       {
193 +               if(window.prevchar)
194 +               {
195 +                       event.target.insertStringAtCursor(window.prevchar);
196 +                       window.prevchar="";
197 +               }
198 +       return;
199 +       }
200 +       var o=event.target;
201 +       var k=String.fromCharCode(event.keyCode);
202 +       var ch = window.rp[k] ? window.rp[k] : k;
203 +       if(!event.shiftKey)
204 +       {
205 +               ch=ch.toLowerCase();
206 +       }
207 +       if(window.prevchar)
208 +       {
209 +               var prev=window.prevchar;
210 +               if(window.rp[prev+ch])
211 +               {
212 +                       ch=window.rp[prev+ch];
213 +                       window.prevchar="";
214 +               }
215 +               else
216 +               {
217 +                       if(ch=="й" || ch=="Й" || ch=="ц" || ch=="Ц" ||
218 +                               ch=="с" || ch=="С" || ch=="з" || ch=="З" ||
219 +                               ch=="ы" || ch=="Ы" || ch=="г" || ch=="Г")
220 +                       {
221 +                               window.prevchar=ch;
222 +                               ch=prev;
223 +                       }
224 +                       else
225 +                       {
226 +                               ch=prev+ch;
227 +                               window.prevchar="";
228 +                       }
229 +               }
230 +       }
231 +       else
232 +       {
233 +       if(ch=="й" || ch=="Й" || ch=="ц" || ch=="Ц" ||
234 +               ch=="с" || ch=="С" || ch=="з" || ch=="З" ||
235 +               ch=="ы" || ch=="Ы" || ch=="г" || ch=="Г")
236 +               {
237 +                       window.prevchar=ch;
238 +                       event.preventDefault();
239 +                       return;
240 +               }
241 +       }
242 +       event.target.insertStringAtCursor(ch);
243 +       event.preventDefault();
244 +       
245 +}
246 +document.onkeypress = function(event) {
247 +
248 +if(window.kblayout=="en")return;
249 +var o=event.target;
250 +var str="";
251 +
252 +//if key is not a letter, return;
253 +if((event.keyCode!=39) && (event.keyCode<65 || event.keyCode>122))
254 +{
255 +       window.prevchar="";
256 +       return;
257 +}
258 +
259 +if(o.tagName=="INPUT" || o.tagName=="TEXTAREA" || o.tagName=="DIV")
260 +{
261 +       var o=event.target;
262 +       var k=String.fromCharCode(event.keyCode);
263 +       var ch = window.rp[k] ? window.rp[k] : k;
264 +
265 +       if(window.prevchar)
266 +       {
267 +               var prev=window.prevchar;
268 +               if(window.rp[prev+ch])
269 +               {
270 +                       ch=window.rp[prev+ch];
271 +                       window.prevchar="";
272 +                       document.execCommand("delete", true, 1);
273 +               }
274 +               else
275 +               {
276 +                       if(ch=="й" || ch=="Й" || ch=="ц" || ch=="Ц" ||
277 +                               ch=="с" || ch=="С" || ch=="з" || ch=="З" ||
278 +                               ch=="ы" || ch=="Ы" || ch=="г" || ch=="Г")
279 +                       {
280 +                               window.prevchar=ch;
281 +                               ch=prev;
282 +                       }
283 +                       else
284 +                       {
285 +                               window.prevchar="";
286 +                       }
287 +               }
288 +       }
289 +       else
290 +       {
291 +       if(ch=="й" || ch=="Й" || ch=="ц" || ch=="Ц" ||
292 +               ch=="с" || ch=="С" || ch=="з" || ch=="З" ||
293 +               ch=="ы" || ch=="Ы" || ch=="г" || ch=="Г")
294 +               {
295 +                       window.prevchar=ch;
296 +               }
297 +       }
298 +       document.execCommand("insertText", true, ch);
299 +       event.preventDefault();
300 +}
301 +}
302 +
303 +function cleanTimer() {
304 +       timePress = 0;
305 +}