2 _testCommon.js - a simple module to be included in dijit test pages to allow
3 for easy switching between the many many points of the test-matrix.
5 in your test browser, provides a way to switch between available themes,
6 and optionally enable RTL (right to left) mode, and/or dijit_a11y (high-
7 constrast/image off emulation) ... probably not a genuine test for a11y.
9 usage: on any dijit test_* page, press ctrl-f9 to popup links.
11 there are currently (2 themes * 4 tests) * (10 variations of supported browsers)
12 not including testing individual locale-strings
14 you should not be using this in a production enviroment. include
15 your css and set your classes manually. for test purposes only ...
20 var theme = false; var testMode;
21 if(window.location.href.indexOf("?") > -1){
22 var str = window.location.href.substr(window.location.href.indexOf("?")+1).split(/#/);
23 var ary = str[0].split(/&/);
24 for(var i=0; i<ary.length; i++){
25 var split = ary[i].split(/=/),
30 // locale string | null
31 dojo.config.locale = locale = value;
35 document.getElementsByTagName("html")[0].dir = value;
38 // tundra | soria | noir | squid | nihilo | null
42 if(value){ testMode = "dijit_a11y"; }
47 // always include the default theme files:
48 if(!theme){ theme = dojo.config.defaultTestTheme || 'tundra'; }
49 var themeCss = d.moduleUrl("dijit.themes",theme+"/"+theme+".css");
50 var themeCssRtl = d.moduleUrl("dijit.themes",theme+"/"+theme+"_rtl.css");
51 document.write('<link rel="stylesheet" type="text/css" href="'+themeCss+'"/>');
52 document.write('<link rel="stylesheet" type="text/css" href="'+themeCssRtl+'"/>');
54 if(dojo.config.parseOnLoad){
55 dojo.config.parseOnLoad = false;
56 dojo.config._deferParsing = true;
59 d.addOnLoad(function(){
62 if(!d.hasClass(d.body(),theme)){ d.addClass(d.body(),theme); }
63 if(testMode){ d.addClass(d.body(),testMode); }
65 // test-link matrix code:
66 var node = document.createElement('div');
67 node.id = "testNodeDialog";
68 d.addClass(node,"dijitTestNodeDialog");
69 d.body().appendChild(node);
71 _populateTestDialog(node);
73 d.connect(document,"onkeypress", function _testNodeShow(/* Event */evt){
74 var key = (evt.charCode == d.keys.SPACE ? d.keys.SPACE : evt.keyCode);
75 if(evt.ctrlKey && (key == d.keys.F9)){ // F9 is generic enough?
76 d.style('testNodeDialog',"top",(dijit.getViewport().t + 4) +"px");
77 d.toggleClass('testNodeDialog',"dijitTestNodeShowing");
81 if(dojo.config._deferParsing){ d.parser.parse(d.body()); }
85 var _populateTestDialog = function(/* DomNode */node){
86 // pseudo-function to populate our test-martix-link pop-up
87 var base = window.location.pathname;
89 var themes = ["tundra",/*"noir", */ "soria", "nihilo" /* ,"squid" */ ];
90 str += "<b>Tests:</b><br><table>";
91 d.forEach(themes,function(t){
92 str += '<tr><td><a hr'+'ef="'+base+'?theme='+t+'">'+t+'</'+'a></td>'+
93 '<td><a hr'+'ef="'+base+'?theme='+t+'&dir=rtl">rtl</'+'a></td>'+
94 '<td><a hr'+'ef="'+base+'?theme='+t+'&a11y=true">a11y</'+'a></td>'+
95 '<td><a hr'+'ef="'+base+'?theme='+t+'&a11y=true&dir=rtl">a11y+rtl</'+'a></td>'+
96 // too many potential locales to list, use &locale=[lang] to set
99 str += '<tr><td colspan="4">jump to: <a hr'+'ef="'+(d.moduleUrl("dijit.themes","themeTester.html"))+'">themeTester</'+'a></td></tr>';
100 str += '<tr><td colspan="4">or: <a hr'+'ef="'+(d.moduleUrl("dijit.tests"))+'">tests folder</'+'a></td></tr>';
101 node.innerHTML = str + "</table>";