Loading rico1 and rico3 files
[infodrom/rico3] / examples / html / LoadRicoClient.js
1 Rico_CONFIG = {\r
2   jsDir: "../../ricoClient/js/",       // directory containing Rico's javascript files\r
3   cssDir: "../../ricoClient/css/",     // directory containing Rico's css files\r
4   imgDir: "../../ricoClient/images/",  // directory containing Rico's image files\r
5   enableLogging: false,    // enable console logging\r
6   grid_striping: true,     // apply row striping to LiveGrids?\r
7   LoadBaseLib: true,       // load base Javascript library (prototype, jQuery, etc) from Rico directory?\r
8   jQuery_theme_path: "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/",\r
9 \r
10   initialize: function(checkQueryString) {\r
11     this.transDir=this.jsDir+"translations/";\r
12     this.baselibsDir=this.jsDir+"baselibs/";\r
13     var theme,lib,aParm,log;\r
14     if (checkQueryString) {\r
15       var s=location.search;\r
16       if (s.charAt(0)=='?') s=s.substr(1);\r
17       var aSearch=s.split(/&/);\r
18       for (var i=0; i<aSearch.length; i++) {\r
19         aParm=aSearch[i].split(/=/);\r
20         switch (aParm[0]) {\r
21           case 'theme': theme=aParm[1]; break;\r
22           case 'lib':   lib=aParm[1]; break;\r
23           case 'log':   this.enableLogging=true; break;\r
24         }\r
25       }\r
26     } else {\r
27       // set your production values here\r
28       lib="proto";    // base library (proto, jquery, moo, dojo, ext, or glow)\r
29       theme="j-ui-lightness";  // jquery themes start with j-, rico themes start with r-\r
30     }\r
31     if (lib) this.LoadLib(lib);\r
32     if (theme) this.LoadTheme(theme);\r
33   },\r
34 \r
35   LoadLib: function(baseLib) {\r
36     var baseFile,adapter;\r
37     switch (baseLib) {\r
38       case "proto":\r
39         baseFile="prototype"\r
40         adapter="2Proto"\r
41         break;\r
42       case "jquery":\r
43         baseFile="jquery"\r
44         adapter="2jQuery"\r
45         break;\r
46       case "moo":\r
47         baseFile="mootools"\r
48         adapter="2Moo"\r
49         break;\r
50       case "dojo":\r
51         baseFile="dojo"\r
52         adapter="2Dojo"\r
53         break;\r
54       case "ext":\r
55         baseFile="ext-core"\r
56         adapter="2Ext"\r
57         break;\r
58       case "glow":\r
59         baseFile="glow.core"\r
60         adapter="2Glow"\r
61         break;\r
62       default:\r
63         return;\r
64     }\r
65     //alert(baseFile+' '+adapter);\r
66     if (this.LoadBaseLib) document.write("<script src='"+this.baselibsDir+baseFile+".js' type='text/javascript'></script>");\r
67     this.requireRicoJS("");\r
68     this.requireRicoJS(adapter);\r
69     document.write("<script src='"+this.transDir+"ricoLocale_en.js' type='text/javascript'></script>");\r
70     this.requireRicoCSS("rico");\r
71     this.requireRicoJS("UI");\r
72   },\r
73 \r
74   // set theme\r
75   // "j-ui-lightness" for a Themeroller theme\r
76   // "r-greenHdg" for a native Rico theme\r
77   LoadTheme: function(theme) {\r
78     var prefix=theme.charAt(0);\r
79     theme=theme.substr(2);\r
80     switch (prefix) {\r
81       case 'j':\r
82         this.requireRicoJS("Themeroller");\r
83         document.write("<link type='text/css' rel='stylesheet' href='"+this.cssDir+"jquery-base/ui.base.css'>");\r
84         document.write("<link type='text/css' rel='Stylesheet' href='"+this.jQuery_theme_path+theme+"/jquery-ui.css'>");\r
85         break;\r
86       case 'r':\r
87         this.requireRicoCSS(theme);\r
88         break;\r
89     }\r
90     if (this.grid_striping) document.write("<link type='text/css' rel='stylesheet' href='"+this.cssDir+"striping/"+theme+".css' />");\r
91   },\r
92 \r
93   requireRicoJS: function(filename) {\r
94     document.write("<script src='"+this.jsDir+"rico"+filename+".js' type='text/javascript'></script>\n");\r
95   },\r
96 \r
97   requireRicoCSS: function(filename) {\r
98     document.write("<link href='"+this.cssDir+filename+".css' type='text/css' rel='stylesheet'>\n");\r
99   }\r
100 \r
101 }\r
102 \r
103 Rico_CONFIG.initialize(true);  // load settings from QueryString? true for demo, false for production\r