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

« back to all changes in this revision

Viewing changes to www/12.10/Yahoo/index.html.he

  • 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:
170
170
    </div><!-- close search-box -->
171
171
<script type="text/javascript">
172
172
//<![CDATA[
173
 
(function focus_search() {
 
173
(function(){
 
174
    "use strict";
 
175
    var ltrChars = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF',
 
176
        rtlChars = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC',
 
177
        ltrRx = new RegExp('^[^'+rtlChars+']*['+ltrChars+']'),
 
178
        rtlRx = new RegExp('^[^'+ltrChars+']*['+rtlChars+']'),
 
179
        formElm = document.getElementById("sbi"),
 
180
        checkDir = function(formElm){
 
181
            var val = formElm.value;
 
182
            if (ltrRx.test(val)) {
 
183
                formElm.dir = "ltr";
 
184
            } else if (rtlRx.test(val)) {
 
185
                formElm.dir = "rtl";
 
186
            } else {
 
187
                formElm.dir = "";
 
188
            }
 
189
        };
 
190
    formElm.onkeyup = function(){
 
191
        checkDir(this);
 
192
    };
 
193
    formElm.onkeydown = function(){
 
194
        checkDir(this);
 
195
    };
 
196
    formElm.onclick = function(){
 
197
        checkDir(this);
 
198
    };
174
199
    function search_select(e) {
175
200
        if(e.value.length > 0) {
176
201
            e.select();
177
202
        }
178
203
        e.select();
179
204
    }
180
 
    sbi = document.getElementById('sbi');
181
 
    sbi.focus();
182
 
    search_select(sbi);
183
 
})();
 
205
    formElm.focus();
 
206
    search_select(formElm);
 
207
    checkDir(formElm);
 
208
}());
184
209
//]]>
185
210
</script>
186
211
</body>