source: Dev/trunk/src/client/dojox/mobile/bidi/common.js @ 529

Last change on this file since 529 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.8 KB
Line 
1define(["dojo/_base/array", "dijit/_BidiSupport"], function(array, _BidiSupport){
2
3                // module:
4                //              bidi/common
5                // summary:
6                //              Module contains functions to support text direction, that can be set independent to GUI direction.
7                // description:
8                //              Unicode control characters (UCC) used to control text direction.
9
10                common = {};
11                common.enforceTextDirWithUcc = function(text, textDir){
12                        // summary:
13                        //              Wraps by UCC (Unicode control characters) displayed text according to textDir.
14                        // text:
15                        //              The text to be wrapped.
16                        // textDir:
17                        //              Text direction.
18                        // description:
19                        //              There's a dir problem with some HTML elements. For some Android browsers Hebrew text is displayed right to left also
20                        //              when dir is set to LTR.
21                        //              Therefore the only solution is to use UCC to display the text in correct orientation.
22                        if(textDir){
23                                textDir = (textDir === "auto") ? _BidiSupport.prototype._checkContextual(text) : textDir;
24                                return ((textDir === "rtl") ? common.MARK.RLE : common.MARK.LRE) + text + common.MARK.PDF;
25                        }
26                        return text;
27                };
28
29                common.removeUCCFromText = function(text){
30                        // summary:
31                        //              Removes UCC from input string.
32                        // text:
33                        //              The text to be stripped from UCC.
34                        if (!text){
35                                return text;
36                        }
37                        return text.replace(/\u202A|\u202B|\u202C/g,"");
38                };
39
40                common.setTextDirForButtons = function(widget){
41                        // summary:
42                        //              Sets textDir property to children.
43                        // widget:
44                        //              parent widget
45                        var children = widget.getChildren();
46                        if (children && widget.textDir){
47                                array.forEach(children, function(ch){
48                                        ch.set("textDir", widget.textDir);
49                                }, widget);
50                        }
51                };
52
53                // UCC - constants that will be used by bidi support.
54                common.MARK = {
55                        LRE : '\u202A',
56                        RLE : '\u202B',
57                        PDF : '\u202C'
58                };
59
60                return common;
61});
Note: See TracBrowser for help on using the repository browser.