Debian Codegraph @

dojox/charting/bidi/widget/Legend.js

raw symbols SCIP
1 define(["dojo/_base/declare", "dojo/dom", "dijit/registry", "dojo/_base/connect", "dojo/_base/array", "dojo/query"],
2 function(declare, dom, widgetManager, hub, arrayUtil, query){
3 // module:
4 // dojox/charting/bidi/widget/Legend
5 function validateTextDir(textDir){
6 return /^(ltr|rtl|auto)$/.test(textDir) ? textDir : null;
7 }
8
9 return declare(null, {
10 postMixInProperties: function(){
11 // summary:
12 // Connect the setter of textDir legend to setTextDir of the chart,
13 // so _setTextDirAttr of the legend will be called after setTextDir of the chart is called.
14 // tags:
15 // private
16
17 // find the chart that is the owner of this legend, use it's
18 // textDir
19 if(!this.chart){
20 if(!this.chartRef){ return; }
21 var chart = widgetManager.byId(this.chartRef);
22 if(!chart){
23 var node = dom.byId(this.chartRef);
24 if(node){
25 chart = widgetManager.byNode(node);
26 }else{
27 return;
28 }
29 }
30 this.textDir = chart.chart.textDir;
31 hub.connect(chart.chart, "setTextDir", this, "_setTextDirAttr");
32
33 }else{
34 this.textDir = this.chart.textDir;
35 hub.connect(this.chart, "setTextDir", this, "_setTextDirAttr");
36
37 }
38 },
39
40 _setTextDirAttr: function(/*String*/ textDir){
41 // summary:
42 // Setter for textDir.
43 // description:
44 // Users shouldn't call this function; they should be calling
45 // set('textDir', value)
46 // tags:
47 // private
48
49 // only if new textDir is different from the old one
50 if(validateTextDir(textDir) != null){
51 if(this.textDir != textDir){
52 this._set("textDir", textDir);
53 // get array of all the labels
54 var legendLabels = query(".dojoxLegendText", this._tr);
55 // for every label calculate it's new dir.
56 arrayUtil.forEach(legendLabels, function(label){
57 label.dir = this.getTextDir(label.innerHTML, label.dir);
58 }, this);
59 }
60 }
61 }
62 });
63 });