PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/www/reference/examples/index-new.html

http://github.com/JxLib/JxLib
HTML | 301 lines | 282 code | 19 blank | 0 comment | 0 complexity | 7fc086da6545db363ea5747152916908 MD5 | raw file
Possible License(s): GPL-2.0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>JX Example</title>
  5. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  6. <script type="text/javascript" src="lib/mootools-core.js"></script>
  7. <script type="text/javascript" src="lib/mootools-more.js"></script>
  8. <script type="text/javascript" src="lib/jxlib.standalone.uncompressed.js"></script>
  9. <script src="js/locale.js" type="text/javascript" charset="utf-8"></script>
  10. <script src="js/tests.js" type="text/javascript" charset="utf-8"></script>
  11. <script type="text/javascript">
  12. window.addEvent('load', function() {
  13. //Change this to toggle debug mode.
  14. Jx.debug = true;
  15. console.log(Jx.debug);
  16. var mainSplitter = new Jx.Splitter('splitMain', {
  17. containerOptions: [{resizeWithWindow: true,width: 200},{resizeWithWindow: true}]
  18. });
  19. mainSplitter.elements[0].set('id','splitMainLeft');
  20. var mainTabs = new Jx.TabBox({
  21. parent: mainSplitter.elements[1]
  22. }).add(new Jx.Tab({
  23. label : {set:'Examples',key:'navigation',value:'About'},
  24. // adding custom class 'tabContentExample' to add/remove the background grid on every tab opened
  25. contentTemplate : '<div class="tabContent tabContentExample"></div>',
  26. contentURL : 'about.html'
  27. }));
  28. // open last open example from cookie ?
  29. var lastExample = Cookie.read('JxExamples.CurrentExample');
  30. lastExample = lastExample && lastExample.contains(",") ? lastExample.split(",") : false;
  31. if(lastExample) {
  32. /*
  33. var lastTab = new Jx.Tab({
  34. label : {set:'Examples',key:'navigation',value:lastExample[1]},
  35. contentURL : lastExample[0],
  36. activeTabClass : 'tabContentActive tabContentActiveExamples',
  37. close : true,
  38. // setting this to active slows down the page load a bit...
  39. active : false,
  40. cacheContent: true,
  41. loadOnDemand: true
  42. });
  43. // event on content loaded to load the scripts
  44. lastTab.addEvents({
  45. 'contentLoaded': function() {
  46. // COMMENT:
  47. // somehow the custom event is fired too soon so the examples don't find a tabContentActiveExamples class..
  48. this.content.fireEvent('loadAjax');
  49. },
  50. 'down': function() {
  51. Cookie.write('JxExamples.CurrentExample', [this.options.contentURL,this.options.label.value]);
  52. },
  53. 'close': function() {
  54. if(this.tabSet.tabs.length == 1) {
  55. Cookie.write('JxExamples.CurrentExample', false);
  56. }
  57. }
  58. });
  59. mainTabs.add(lastTab);
  60. */
  61. }
  62. // custom function to find out if a tab is already loaded
  63. mainTabs.hasTabByURL = function(url) {
  64. var t = this.tabSet.tabs,
  65. i = t.length;
  66. while(i--) {
  67. if(t[i].options.contentURL == url) {
  68. return t[i];
  69. }
  70. }
  71. return false;
  72. }
  73. var mainTree = new Jx.Tree({
  74. parent: mainSplitter.elements[0],
  75. select: true,
  76. onClick: function(el) {
  77. el = $jx(el);
  78. if (el instanceof Jx.Tree.Item) {
  79. openTab(el);
  80. }
  81. }});
  82. var items = {
  83. 'Jx-Examples': [
  84. {'About':'about.html'},
  85. {'Page-Layout' : [
  86. {'Layout' :'layout.html'},
  87. {'Splitter' : 'splitter.html'},
  88. {'Splitter-Integrated' : 'splitter_advanced.html'},
  89. {'Container-Managers': [
  90. {'Container' : 'container.html'},
  91. {'Column-layout': 'columns.html'}
  92. ]}
  93. ]},
  94. {'Panels-and-Dialogs' : [
  95. {'Panel' :'panel.html'},
  96. {'Panel-Set' : 'panelset.html'},
  97. {'Panels-Integrated' : 'panel_advanced.html'},
  98. {'Dialog' : 'dialog.html'},
  99. {'Dialogs-Integrated' : 'dialog_advanced.html'}
  100. //{'File-Upload-Panel' : 'file_upload.html' }
  101. ]},
  102. {'Lists' : [
  103. {'Grid' : 'grid.html'},
  104. //{'Paginated-Grid' : 'paging-grid.html'},
  105. {'Grid-Inline-Editor' : 'grid_editor.html'},
  106. {'Tree' : 'tree.html'},
  107. {'List-View' : 'list.html'}
  108. ]},
  109. {'Bars-and-Buttons' : [
  110. {'Toolbar' :'toolbar.html'},
  111. {'Buttons' : [
  112. {'Basic' : 'button.html'},
  113. {'Flyouts' : 'flyout.html'},
  114. {'Flyouts-Integrated' : 'flyout_advanced.html'},
  115. {'Multi' : 'multi.html'},
  116. {'Color' : 'color.html'}
  117. ]},
  118. {'Tabs':[
  119. {'Tabs' : 'tab.html'},
  120. {'Tab-Set' : 'tab_set.html'},
  121. {'Tabs-Integrated' : 'tab_box_advanced.html'}
  122. ]},
  123. {'Menus': [
  124. {'Menu-button' : 'menu.html'},
  125. {'Menu-bar' : 'menu_bar.html'},
  126. {'Context-Menu' : 'menu_context.html'}
  127. ]}
  128. ]},
  129. {'Extras' : [
  130. {'Forms' : 'forms.html'},
  131. {'Notification' : 'notification.html'},
  132. {'Custom-Scrollbars' : 'custom_scrollbars.html'},
  133. {'Progress-Bar' : 'progressbar.html'},
  134. {'Slider' : 'slider.html'},
  135. {'Editor' : 'editor.html'}
  136. ]},
  137. {'Adaptors' : [
  138. {'Tree-adaptor': 'tree_adaptors.html'},
  139. {'Combo-adaptor': 'adaptor_combo.html' }
  140. ]}
  141. ]
  142. };
  143. var openExamples = [];
  144. function openTab(item) {
  145. var i = item.options.label.value,
  146. v = item.options.contentURL;
  147. item.setBusy(true);
  148. var tabExists = mainTabs.hasTabByURL(v);
  149. if(!tabExists) {
  150. openExamples.push(v);
  151. var newTab = new Jx.Tab({
  152. label : {set:'Examples',key:'navigation',value:i},
  153. contentURL : v,
  154. activeTabClass : 'tabContentActive tabContentActiveExamples',
  155. // adding custom class 'tabContentExample' to add/remove the background grid on every tab opened
  156. contentTemplate : '<div class="tabContent tabContentExample"></div>',
  157. close : true,
  158. active : true,
  159. cacheContent : true
  160. });
  161. // event on content loaded to load the scripts
  162. newTab.addEvents({
  163. 'contentLoaded': function() {
  164. newTab.content.fireEvent('loadAjax');
  165. item.setBusy(false);
  166. var tagsTmp = this.req.response.text.getTags('script', true),
  167. tags = [],
  168. headlines = newTab.content.getElements('h2');
  169. tagsTmp.each(function(t) {
  170. // COMMENT: any other better 'regex' test for the script ? :)
  171. if(t.test('id=')) {
  172. t = t.split("\n");
  173. t.pop(); // clear first script line with id
  174. t.shift(); // clear last script line
  175. tags.push(t.join("\n"));
  176. }
  177. });
  178. beautifyDemoScripts(headlines, tags);
  179. makeLinksForApi(newTab.content.getElements('a'));
  180. },
  181. // anything we can do when the content load fails? shouldn't happen on the examples page ;)
  182. 'contentLoadFailed': function() {
  183. //item.setBusy(false);
  184. },
  185. // if a script error occurs, the waiting icon won't stop, here we stop it when the tab is closed
  186. 'close': function() {
  187. item.setBusy(false)
  188. if(this.tabSet.tabs.length == 1) {
  189. Cookie.write('JxExamples.CurrentExample', false);
  190. }
  191. },
  192. 'down': function() {
  193. Cookie.write('JxExamples.CurrentExample', [v,i]);
  194. }
  195. });
  196. mainTabs.tabSet.addEvents({
  197. 'tabChange':function(tabSet, tab) {
  198. // select the element on the tree to the left when the tab is activated? :)
  199. //window.console ? console.log(mainTree.findChild([tab.options.label])) : false;
  200. }
  201. });
  202. mainTabs.add(newTab);
  203. log(i + " loaded");
  204. }else{
  205. tabExists.clicked();
  206. item.setBusy(false);
  207. }
  208. Cookie.write('JxExamples.CurrentExample', [v,i]);
  209. }
  210. var makeTreeItem = function(o, tree) {
  211. for (var i in o) {
  212. var v = o[i];
  213. if (v instanceof Array) {
  214. var folder = new Jx.Tree.Folder({label: {set:'Examples',key:'navigation',value:i}, open: true});
  215. tree.add(folder);
  216. for (var j=0; j<v.length; j++) {
  217. makeTreeItem(v[j], folder);
  218. }
  219. } else {
  220. var item = new Jx.Tree.Item({
  221. label: {set:'Examples',key:'navigation',value:i},
  222. contentURL : v,
  223. active : lastExample[0] == v ? true : false
  224. });
  225. item.options.contextMenu = new Jx.Menu.Context(item.domA, {reference:item}).add(
  226. new Jx.Menu.Item({
  227. label : {set:'Examples',key:'navigation',value:'new-window'},
  228. onClick : function(ev) {
  229. window.open(item.options.contentURL, item.getText(item.options.label));
  230. }
  231. })
  232. );
  233. tree.add(item);
  234. }
  235. }
  236. };
  237. makeTreeItem(items, mainTree);
  238. //console.log(mainTree);
  239. /*
  240. var mainContextMenu = new Jx.Menu.Context(mainTree);
  241. mainContextMenu.add(
  242. new Jx.Menu.Item({
  243. label : {set:'Examples',key:'navigation',value:'new-window'},
  244. onClick : function(a,b,c) {
  245. console.log(a,b,c)
  246. }
  247. })
  248. );
  249. */
  250. if (Browser.ie && Browser.ie4) {
  251. new Asset.css('../../lib/themes/crispin/ie6.css', { rel: 'stylesheet' });
  252. }
  253. if (Browser.ie && Browser.ie5) {
  254. new Asset.css('../../lib/themes/crispin/ie7.css', { rel: 'stylesheet' });
  255. }
  256. });
  257. </script>
  258. <style type="text/css">
  259. #splitMain { height: 600px !important; }
  260. #splitMainLeft { overflow: auto; }
  261. </style>
  262. </head>
  263. <body>
  264. <h1>JxLib Examples</h1>
  265. <br />
  266. <div id="splitMain" class="splitterBox" ></div>
  267. <div id="failure" style="display:none">
  268. <br />
  269. <h2>Failure :(</h2>
  270. </div>
  271. <script type="text/javascript">
  272. var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." :
  273. "http://www.");
  274. document.write(unescape("%3Cscript src='" + gaJsHost +
  275. "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  276. </script>
  277. <script type="text/javascript">
  278. var pageTracker = _gat._getTracker("UA-124914-7");
  279. pageTracker._trackPageview();
  280. </script>
  281. </body>
  282. </html>