4_themes.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <!DOCTYPE html
  2. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>jsTree &raquo; Examples </title>
  8. <link rel="stylesheet" type="text/css" href="../media/style.css" />
  9. <link rel="stylesheet" type="text/css" href="darkness/style.css" />
  10. <link rel="shortcut icon" href="../media/favicon.ico" />
  11. <link rel="stylesheet" type="text/css" href="../media/prettify.css" />
  12. <script type="text/javascript" src="../media/prettify.js"></script>
  13. <script type="text/javascript" src="../media/iepngfix_tilebg.js"></script>
  14. <script type="text/javascript">window.onload = function() { prettyPrint(); }</script>
  15. <link rel="stylesheet" type="text/css" href="../../source/tree_component.css" />
  16. <script type="text/javascript" src="../../source/_lib.js"></script>
  17. <script type="text/javascript" src="../../source/tree_component.js"></script>
  18. </head>
  19. <body>
  20. <div id="container">
  21. <div id="head">
  22. <h1>jsTree</h1>
  23. <h2>javascript tree component</h2>
  24. <h3>Examples</h3>
  25. </div>
  26. <div id="sidebar">
  27. <h3 style="margin-top:0;">Documentation</h3>
  28. <ul>
  29. <li class="page_item"><a href="../_documentation/1_files.html" title="Required &amp; optional files">Required &#038; optional files</a></li>
  30. <li class="page_item"><a href="../_documentation/2_creation.html" title="Instance creation">Instance creation</a></li>
  31. <li class="page_item"><a href="../_documentation/3_configuration.html" title="Configuration">Configuration</a></li>
  32. <li class="page_item"><a href="../_documentation/4_data.html" title="Data sources">Data sources</a></li>
  33. <li class="page_item"><a href="../_documentation/5_customize.html" title="Customization">Customization</a></li>
  34. <li class="page_item"><a href="../_documentation/6_output.html" title="Output">Output</a></li>
  35. <li class="page_item"><a href="../_documentation/7_api.html" title="API">API&nbsp;</a></li>
  36. </ul>
  37. <h3>Examples</h3>
  38. <ul>
  39. <li class="page_item"><a href="1_datasources.html" title="Data sources">Data sources</a></li>
  40. <li class="page_item"><a href="2_operations.html" title="Operations">Operations</a></li>
  41. <li class="page_item"><a href="3_callbacks.html" title="Callbacks">Callbacks</a></li>
  42. <li class="page_item current_page_item"><a href="4_themes.html" title="Themes">Themes</a></li>
  43. <li class="page_item"><a href="5_others.html" title="Others">Other examples</a></li>
  44. <li class="page_item important"><a href="7_full.html" title="Full example">Full PHP &amp; mySQL example&nbsp;</a></li>
  45. </ul>
  46. </div>
  47. <div id="data" style="margin-top:-45px;">
  48. <div id="content">
  49. <ul class='nav'>
  50. <li><a href="3_callbacks.html" title="Callbacks">&laquo;&nbsp;Callbacks</a></li>
  51. <li><a href="../index.html">Up to Reference</a></li>
  52. <li><a href="5_others.html" title="Others">Other examples&nbsp;&raquo;</a></li>
  53. </ul>
  54. <h2 style="margin-top:25px;">Themes</h2>
  55. <div class="entry"><div id="documentation">
  56. <p>A small demo of the included themes. The configuration <span class="var">ui</span> object controls various features of visualization - check the documentation for more.</p>
  57. <input type="button" value="switch RTL" onclick="$.tree_focused().container.toggleClass('rtl');" />
  58. <input type="button" value="toggleDots" onclick="$.tree_focused().toggleDots();" style="margin-right:20px;"/>
  59. <input type="button" value="default" onclick="change_theme(this.value)" />
  60. <input type="button" value="apple" onclick="change_theme(this.value)" />
  61. <input type="button" value="classic" onclick="change_theme(this.value)" />
  62. <input type="button" value="checkbox" onclick="change_theme(this.value)" />
  63. <input type="button" value="themeroller" onclick="change_theme(this.value)" />
  64. <div id="demo" class="demo" style="height:200px;"></div>
  65. <div id="sources" class="sources" style="200px;">
  66. <pre style="height:200px;">
  67. // Buttons
  68. $.tree_focused().toggleDots();
  69. change_theme(this.value);
  70. function change_theme(new_theme) {
  71. conf.ui.theme_name = new_theme;
  72. tree1.destroy();
  73. tree1.init($("#demo"), $.extend({},conf));
  74. };
  75. conf = {
  76. // Rest omitted
  77. ui : {
  78. theme_name : "checkbox"
  79. }
  80. };
  81. $(function () {
  82. tree1 = $.tree_create();
  83. tree1.init($("#demo"), $.extend({},conf));
  84. });
  85. </pre>
  86. </div>
  87. <script type="text/javascript">
  88. conf = {
  89. data : {
  90. type : "json",
  91. json : [
  92. { attributes: { id : "pjson4_1" }, data: "Root node 1", children : [
  93. { attributes: { id : "pjson4_2" }, data: { title : "Custom icon" } },
  94. { attributes: { id : "pjson4_3" }, data: "Child node 2" },
  95. { attributes: { id : "pjson4_4" }, data: "Some other child node" }
  96. ]},
  97. { attributes: { id : "pjson4_5" }, data: "Root node 2" }
  98. ]
  99. },
  100. ui : {
  101. theme_name : "checkbox"
  102. },
  103. callback : {
  104. onchange : function (NODE, TREE_OBJ) {
  105. if(TREE_OBJ.settings.ui.theme_name == "checkbox") {
  106. var $this = $(NODE).is("li") ? $(NODE) : $(NODE).parent();
  107. if($this.children("a.unchecked").size() == 0) {
  108. TREE_OBJ.container.find("a").addClass("unchecked");
  109. }
  110. $this.children("a").removeClass("clicked");
  111. if($this.children("a").hasClass("checked")) {
  112. $this.find("li").andSelf().children("a").removeClass("checked").removeClass("undetermined").addClass("unchecked");
  113. var state = 0;
  114. }
  115. else {
  116. $this.find("li").andSelf().children("a").removeClass("unchecked").removeClass("undetermined").addClass("checked");
  117. var state = 1;
  118. }
  119. $this.parents("li").each(function () {
  120. if(state == 1) {
  121. if($(this).find("a.unchecked, a.undetermined").size() - 1 > 0) {
  122. $(this).parents("li").andSelf().children("a").removeClass("unchecked").removeClass("checked").addClass("undetermined");
  123. return false;
  124. }
  125. else $(this).children("a").removeClass("unchecked").removeClass("undetermined").addClass("checked");
  126. }
  127. else {
  128. if($(this).find("a.checked, a.undetermined").size() - 1 > 0) {
  129. $(this).parents("li").andSelf().children("a").removeClass("unchecked").removeClass("checked").addClass("undetermined");
  130. return false;
  131. }
  132. else $(this).children("a").removeClass("checked").removeClass("undetermined").addClass("unchecked");
  133. }
  134. });
  135. }
  136. }
  137. }
  138. };
  139. function change_theme(new_theme) {
  140. conf.ui.theme_name = new_theme;
  141. tree1.destroy();
  142. tree1.init($("#demo"), $.extend({},conf));
  143. };
  144. $(function () {
  145. tree1 = $.tree_create();
  146. tree1.init($("#demo"), $.extend({},conf));
  147. });
  148. </script>
  149. </div></div>
  150. </div>
  151. </div>
  152. </div>
  153. </body>
  154. </html>