~muffinresearch/ubuntu-start-page/add-rtl-script

« back to all changes in this revision

Viewing changes to www/12.10/index.html.en-gb

  • Committer: Stuart Colville
  • Date: 2012-10-03 22:39:17 UTC
  • Revision ID: stuart.colville@canonical.com-20121003223917-3jvqvcrskveo9tyg
re-generate

Show diffs side-by-side

added added

removed removed

Lines of Context:
202
202
    </div><!-- close search-box -->
203
203
<script type="text/javascript">
204
204
//<![CDATA[
205
 
(function focus_search() {
 
205
(function(){
 
206
    "use strict";
 
207
    var ltrChars = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF',
 
208
        rtlChars = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC',
 
209
        ltrRx = new RegExp('^[^'+rtlChars+']*['+ltrChars+']'),
 
210
        rtlRx = new RegExp('^[^'+ltrChars+']*['+rtlChars+']'),
 
211
        formElm = document.getElementById("sbi"),
 
212
        checkDir = function(formElm){
 
213
            var val = formElm.value;
 
214
            if (ltrRx.test(val)) {
 
215
                formElm.dir = "ltr";
 
216
            } else if (rtlRx.test(val)) {
 
217
                formElm.dir = "rtl";
 
218
            } else {
 
219
                formElm.dir = "";
 
220
            }
 
221
        };
 
222
    formElm.onkeyup = function(){
 
223
        checkDir(this);
 
224
    };
 
225
    formElm.onkeydown = function(){
 
226
        checkDir(this);
 
227
    };
 
228
    formElm.onclick = function(){
 
229
        checkDir(this);
 
230
    };
206
231
    function search_select(e) {
207
232
        if(e.value.length > 0) {
208
233
            e.select();
209
234
        }
210
235
        e.select();
211
236
    }
212
 
 
213
 
    sbi = document.getElementById('sbi');
214
 
    sbi.focus();
215
 
    search_select(sbi);
216
 
})();
 
237
    formElm.focus();
 
238
    search_select(formElm);
 
239
    checkDir(formElm);
 
240
}());
217
241
//]]>
218
242
</script>
219
243
</body>