-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
828 lines (625 loc) · 32.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta name="keywords" content="jquery,treefy,tree,arvore,list,unordered,collapse,expand" />
<meta name="description" content="jQuery Treefy - A Tree Plugin" />
<title>jQuery Treefy - A Tree Plugin</title>
<!-- This CSS does not belong to the plugin. -->
<link type="text/css" rel="stylesheet" href="doc/css/stylesheet.css"/>
<link type="text/css" rel="stylesheet" href="css/jquery.treefy.css"/>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.treefy.min.js"></script>
<script type="text/javascript">
// This code does not belong to the plugin. See the example code at the bottom of this page.
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-194992347-14']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="header">
<div id="title">
<a href="http://wbotelhos.com/treefy">jQuery Treefy - A Tree Plugin</a>
<span id="version">(current version: 0.1.0)</span>
</div>
<div id="menu">
<a href="http://github.com/downloads/wbotelhos/treefy/jquery.treefy-0.1.0.zip" target="_blank">Download</a> |
<a href="http://github.com/wbotelhos/treefy" target="_blank">Github</a> |
<a href="http://www.wbotelhos.com/treefy/changelog.md" target="_blank">Change Log</a> |
<a href="http://www.wbotelhos.com/treefy/README.md" target="_blank">Readme</a> |
<a href="http://www.wbotelhos.com/2012/04/11/jquery-treefy-a-tree-plugin" target="_blank">Article</a> |
<a href="http://www.opensource.org/licenses/mit-license.php" target="_blank">License</a> |
<a href="http://www.wbotelhos.com/2012/04/11/jquery-treefy-a-tree-plugin#comments" target="_blank" style="color: #2C8CBD;">Doubt</a> |
<a href="http://www.wbotelhos.com/lab" target="_blank" style="color: #000;">yLab</a>
</div>
<a id="coffee" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=X8HEP2878NDEG&item_name=jQuery%20Treefy" target="_blank">buy me a coffee</a>
<div class="description">jQuery <strong>Treefy</strong> jQuery Treefy is a plugin that transforms an unordered list into an expandable and collapsable tree.</div>
</div>
<div id="content">
<div class="session-first">Example:</div>
<div id="tree"></div>
<div class="session">JSON:</div>
<div class="source">
{<br />
  "tree": [<br />
    { "text": "Ruby", "icon": "star", <span class="highlight">"checkbox": { "id": "ruby", "name": "languages[]", "value": "1", "class": "special" }</span> },<br />
    { "text": "Java", "link": "http://wbotelhos.com.br", "target": "_blank", <span class="highlight">"checkbox": { "id": "java", "name": "language[]", "value": "2" }</span> },<br />
    { "text": "NoSQL", "state": "opened", <span class="highlight">"checkbox": { "id": "nosql", "name": "language[]", "value": "3" }</span>, <b>"children"</b>: [<br />
        { "text": "Neo4j", <span class="highlight">"checkbox": { "id": "neo4j", "name": "language[]", "value": "4" }</span> },<br />
        { "text": "Document", <span class="highlight">"checkbox": { "id": "document", "name": "language[]", "value": "5" }</span>, <b>"children"</b>: [<br />
            { "text": "MongoDB", <span class="highlight">"checkbox": { "id": "mongodb", "name": "language[]", "value": "6", "checked": true }</span> },<br />
            { "text": "CouchDB", <span class="highlight">"checkbox": { "id": "couchdb", "name": "language[]", "value": "7" }</span> }<br />
          ]<br />
        },<br />
        { "text": "Relational", <span class="highlight">"checkbox": { "id": "relational", "name": "language[]", "value": "8", "disabled": true }</span> }<br />
      ]<br />
    }<br />
  ]<br />
}<br /><br />
</div>
<div class="comment">
+ tree: the root of the JSON;<br />
+ text: the text of each item of the tree;<br />
+ icon: the icon putted on the left side of the text;<br />
- link: the url of the text;<br />
   + target: target of the link;<br />
   + when this options is present the text is converted to a link.<br />
- checkbox:<br />
   + id: the field's ID;<br />
   + name: the field's name;<br />
   + value: the field's value;<br />
   + class: the field's class.<br />
   - checked: decide if the checkbox will be checked or not:<br />
      + you can use: checked="checked", checked=true or just checked="".<br />
   - disabled: decide if the checkbox will be disabled or not:<br />
      + you can use: disabled="disabled", disabled=true or just disabled="".<br />
- children: a node of the tree with other items;<br />
   + state: the state of the folder: opened or closed;<br />
   + when the children is present it treat as a folder.<br />
</div>
<div class="session">Script:</div>
<div class="source">
$('#tree').treefy({<br />
    checkbox : true,<br />
    url      : 'http://mockr.me/treefy'<br />
});
</div>
<div class="session">HTML:</div>
<div class="source">
<div id="tree"></div>
</div>
<div class="session">Options:</div>
<div class="session-option">always: <span>undefined / using undefined jQuery will consider it as: undefined</span></div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">always : function(jqXHR, textStatus) {<br />
    alert('Successfully completed!');<br />
  },</span><br />
  url    : '/treefy'<br />
});
</div>
<div class="comment">Function executed when the tree finish the request.</div>
<div class="comment-personal">Explanation: you can stop a loading message when request finish.</div>
<hr />
<div class="session-option">checkbox: <span>false</span></div>
<img src="doc/img/checkbox.png" alt="checkbox" height="77" width="136" class="session-image" />
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">checkbox : true</span>,<br />
  url      : '/treefy'<br />
});
</div>
<div class="comment">Enables the checkbox on the side of each element.</div>
<div class="comment-personal">
Explanation:<br />
- You put a checkbox on the side of each elment of the tree to be possible check it;<br />
- Different from current plugins, Treefy generates real checkboxes, not a div with an image of the checkbox;<br />
- You can customize all part of checkbox using the 'checkbox' element of JSON, or build it manually.
</div>
<hr />
<div class="session-option">checkDown: <span>true</span></div>
<div id="checkDown" class="example"></div>
<img src="doc/img/checkDown.png" alt="checkDown" height="152" width="179" class="session-image" />
<div class="source">
$('#tree').treefy({<br />
  checkbox  : true,<br />
  <span class="highlight">checkDown : false</span><br />
  url       : '/treefy',<br />
});
</div>
<div class="comment">Check all children when a folder is checked.</div>
<div class="comment-personal">
Explanation:<br />
- The most common thing is check a folder to check all children, then let it on;<br />
- If you wants just check the folder, but not the children just turn it off;<br />
- This cover just the check option, not the uncheck.<br />
</div>
<hr />
<div class="session-option">checkedClass: <span>'treefy-checked'</span></div>
<img src="doc/img/checkedClass.png" alt="checkedClass" height="29" width="116" class="session-image" />
<div class="source">
<span class="highlight">.treefy-on { background: url('checked.png'); }</span>
</div>
<div class="source">
$('#tree').treefy({<br />
  url          : '/treefy',<br />
  <span class="highlight">checkedClass : 'on'</span><br />
});
</div>
<div class="comment">Class with background used as icon on checked values.</div>
<div class="comment-personal">
Explanation:<br />
- You can change the background icon with one you like;<br />
- The prefix 'treefy-' is preppended automatically to avoid conflicts.
</div>
<hr />
<div class="session-option">checkUp: <span>true</span></div>
<div id="checkUp" class="example"></div>
<img src="doc/img/checkUp.png" alt="checkUp" height="97" width="177" class="session-image" />
<div class="source">
$('#tree').treefy({<br />
  checkbox : true,<br />
  <span class="highlight">checkUp  : false,</span><br />
  url      : '/treefy'<br />
});
</div>
<div class="comment">Check all parents folder.</div>
<div class="comment-personal">
Explanation:<br />
- If a checkbox is a child, then if it is checked you parent is partial checked or full checked;<br />
- If the parent has just one child, the parent is full checked, otherwise partial;<br />
- You can disable this option to avoid check the parents if it represents some value and you don't want send it.<br />
</div>
<hr />
<div class="session-option">data: <span>undefined</span></div>
<div id="data" class="example"></div>
<div class="source">
<span class="highlight">var json = '{ "tree": [ { "text": "Java" }, { "text": "Ruby" } ] }'</span>
</div>
<div class="source">
$('#tree').treefy({<br />
  url  : '/treefy',<br />
  <span class="highlight">data : json</span><br />
});
</div>
<div class="comment">A JSON data passed to Treefy manually.</div>
<div class="comment-personal">
Explanation:<br />
- You can build your own JSON and pass it to the Treefy;<br />
- Maybe you wants manipulate the JSON that cames from an ajax request and then pass it.<br />
</div>
<hr />
<div class="session-option">dataType: <span>'json' / using undefined jQuery will consider it as: Intelligent Guess (xml, json, script, or html)</span></div>
<div class="source">
$('#tree').treefy({<br />
  url      : '/treefy',<br />
  <span class="highlight">dataType : 'xml'</span><br />
});
</div>
<div class="comment">The data type of the ajax request.</div>
<div class="comment-personal">Explanation: you can receive the data as XML. * For now just JSON is supported!</div>
<hr />
<div class="session-option">disabledCheckedClass: <span>'treefy-disabled-checked'</span></div>
<img src="doc/img/disabledCheckedClass.png" alt="disabledCheckedClass" height="32" width="132" class="session-image" />
<div class="source">
<span class="highlight">.treefy-checked-off { background: url('checked-off.png'); }</span>
</div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">disabledCheckedClass : 'checked-off',</span><br />
  url                  : '/treefy'<br />
});
</div>
<div class="comment">Class with background used as icon on checkbox is checked but disabled.</div>
<div class="comment-personal">
Explanation:<br />
- You can have a checkbox checked, but it can be disabled, then choose an icon for it.
</div>
<hr />
<div class="session-option">disabledClass: <span>'treefy-disabled'</span></div>
<img src="doc/img/disabledClass.png" alt="disabledClass" height="48" width="138" class="session-image" />
<div class="source">
<span class="highlight">.treefy-unchecked-off { background: url('unchecked-off.png'); }</span>
</div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">disabledClass : 'unchecked-off',</span><br />
  url           : '/treefy'<br />
});
</div>
<div class="comment">Class with background used as icon on checkbox is disabled.</div>
<div class="comment-personal">
Explanation:<br />
- You can have a checkbox unchecked and disabled, then choose an icon for it;<br />
- This is the read-only state.<br />
</div>
<hr />
<div class="session-option">disableFolder: <span>true</span></div>
<img src="doc/img/disableFolder.png" alt="disableFolder" height="71" width="740" class="session-image" />
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">disableFolder : false,</span><br />
  url           : '/treefy'<br />
});
</div>
<div class="comment">Enables sending the value of items that are folders.</div>
<div class="comment-personal">
Explanation:<br />
- By default the value setted on folder item is not submited, because it is disabled internally;<br />
- Its happen because normally, the folder is just a grouper of other items;<br />
- If your folder represents a value for your logic, then disable this option.<br />
</div>
<hr />
<div class="session-option">done: <span>undefined / using undefined jQuery will consider it as: undefined</span></div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">done : function(data, textStatus, jqXHR) {<br />
    alert('Successfully loaded!');<br />
  },</span><br />
  url  : '/treefy'<br />
});
</div>
<div class="comment">Function executed when the tree loads successfully.</div>
<div class="comment-personal">Explanation: you can get the data returned from request and display a success message.</div>
<hr />
<div class="session-option">fail: <span>undefined / using undefined jQuery will consider it as: undefined</span></div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">fail : function(jqXHR, textStatus, errorThrown) {<br />
    alert('Some thing is wrong!');<br />
  },</span><br />
  url  : '/treefy'<br />
});
</div>
<div class="comment">Function executed when occurs an error.</div>
<div class="comment-personal">Explanation: you can recover an error and display it, or take a workaround decision.</div>
<hr />
<div class="session-option">icon: <span>true</span></div>
<img src="doc/img/icon.png" alt="icon" height="31" width="104" class="session-image" />
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">icon : false</span><br />
  url  : '/treefy'<br />
});
</div>
<div class="comment">Enables the display of icons next to each item.</div>
<div class="comment-personal">
Explanation:<br />
- All item of the tree can has an icon to a better explanation about the item;<br />
- You can disable it to take of the item;<br />
- This option just defined if the icon will be presented, not the name of icon.
</div>
<hr />
<div class="session-option">jsonp: <span>undefined / using undefined jQuery will consider it as: no effect.</span></div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">jsonp : true</span>,<br />
  url   : '/treefy'<br />
});
</div>
<div class="comment">Override the callback function name in a jsonp request.</div>
<div class="comment-personal">Explanation: you can override the callback name. jQuery 1.5+ you can set it to false to avoid append of "?callback" or "=?" and set the name using jsonpCallback option.</div>
<hr />
<div class="session-option">jsonpCallback: <span>undefined / using undefined jQuery will consider it as: random value</span></div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">jsonpCallback : 'MyCallbackName'</span>,<br />
  url           : '/treefy'<br />
});
</div>
<div class="comment">Specify the callback function name for a JSONP request.</div>
<div class="comment-personal">
Explanation:<br />
- You can change the name of callback manually;<br />
- Using static name you can have a better browser caching;<br />
- But it is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling
</div>
<hr />
<div class="session-option">childrenName: <span>'children'</span></div>
<div class="source">
{ "tree": [ { "text": "NoSQL", "state": "opened", <span class="highlight">"node"</span>: [ { "text": "MongoDB" } ] } ] }
</div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">childrenName : 'node'</span>,<br />
  url          : '/treefy'<br />
});
</div>
<div class="comment">Name of the node that represents the children.</div>
<div class="comment-personal">Explanation: if you prefer to change the name because of an API parse os something.</div>
<hr />
<div class="session-option">params: <span>{}</span></div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">params : { 'language': 'pt_BR', 'status': 1 }</span>,<br />
  url    : '/treefy'<br />
});
</div>
<div class="source">
...&language=pt_BR&status=1
</div>
<div class="comment">A hash of parameters to be added to the query string.</div>
<div class="comment-personal">Explanation: you can pass extra parameter to filter your search.</div>
<hr />
<div class="session-option">partial: <span>true</span></div>
<div id="partial" class="example"></div>
<img src="doc/img/partial.png" alt="partial" height="156" width="185" class="session-image" />
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">partial : false</span>,<br />
  url     : '/treefy'<br />
});
</div>
<div class="comment">Enables the partial icon of the folder.</div>
<div class="comment-personal">
Explanation:<br />
- If you have more then one children and check just one, then the folder should be with partial icon;<br />
- When you disable this option the folder always will be full checked instead partial.<br />
</div>
<hr />
<div class="session-option">partialClass: <span>'treefy-partial'</span></div>
<img src="doc/img/partialClass.png" alt="partialClass" height="157" width="182" class="session-image" />
<div class="source">
<span class="highlight">.treefy-half { background: url('half.png'); }</span>
</div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">partialClass : 'half'</span>,<br />
  url          : '/treefy'<br />
});
</div>
<div class="comment">Class with background used as icon on checkbox is disabled.</div>
<div class="comment-personal">
Explanation:<br />
- You can have a checkbox unchecked and disabled, then choose an icon for it;<br />
- This is the read-only state.<br />
</div>
<hr />
<div class="session-option">type: <span>'get'</span></div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">type : 'post'</span>,<br />
  url  : '/treefy'<br />
});
</div>
<div class="comment">Type of the HTTP request.</div>
<div class="comment-personal">Explanation: you can change the verb to get, post, delete or put, but it is a search, then it is recommended that you use the default get.</div>
<hr />
<div class="session-option">uncheckDown: <span>true</span></div>
<div id="uncheckDown" class="example"></div>
<img src="doc/img/uncheckDown.png" alt="uncheckDown" height="151" width="177" class="session-image" />
<div class="source">
$('#tree').treefy({<br />
  checkbox  : true,<br />
  <span class="highlight">uncheckDown : false</span><br />
  url       : '/treefy',<br />
});
</div>
<div class="comment">Uncheck all children when a folder is unchecked.</div>
<div class="comment-personal">
Explanation:<br />
- When you uncheck a folder, normally you want uncheck all children;<br />
- Maybe you want to foce the user uncheck one by one, but it is not good at all.<br />
</div>
<hr />
<div class="session-option">uncheckUp: <span>true</span></div>
<div id="uncheckUp" class="example"></div>
<img src="doc/img/uncheckUp.png" alt="uncheckUp" height="149" width="181" class="session-image" />
<div class="source">
$('#tree').treefy({<br />
  checkbox  : true,<br />
  <span class="highlight">uncheckUp : false</span><br />
  url       : '/treefy',<br />
});
</div>
<div class="comment">Uncheck all parents folder when a child is check.</div>
<div class="comment-personal">
Explanation:<br />
- If a checkbox is the last checked child, then if it is unchecked the parent is unchecked too;<br />
- If the parent represents a value by it self, maybe you don't wan unchecked it too.<br />
</div>
<hr />
<div class="session-option">uncheckedClass: <span>'treefy-unchecked'</span></div>
<img src="doc/img/uncheckedClass.png" alt="uncheckedClass" height="45" width="126" class="session-image" />
<div class="source">
<span class="highlight">.treefy-normal { background: url('normal.png'); }</span>
</div>
<div class="source">
$('#tree').treefy({<br />
  <span class="highlight">uncheckedClass : 'normal',</span><br />
  url            : '/treefy'<br />
});
</div>
<div class="comment">Class with background used as icon on checkbox unchecked.</div>
<div class="comment-personal">Explanation: the first state of checkbox is unchecked, and it is the image of it.<br />
</div>
<hr />
<div class="session-option">url: <span>undefined</span></div>
<div class="source">
$('#tree').treefy({<br />
  url: '/user/treefy'<br />
});
</div>
<div class="comment">URL to request the data.</div>
<div class="comment-personal">Explanation: you can change the URL to receive your data. Don't forget to prepend the context of your application.</div>
<div id="manual-demo" class="session">Manual build:</div>
<div id="manual">
<ul class="treefy">
<li>
<span>
<span class="treefy-empty"></span>
<label for="ruby" class="treefy-unchecked"></label>
<input id="ruby" type="checkbox" />
<span class="treefy-star"></span>
<a href="javascript:void(0);">Ruby</a>
</span>
</li>
<li>
<span class="treefy-closed">
<span class="treefy-flick"></span>
<label for="nosql" class="treefy-unchecked"></label>
<input id="nosql" type="checkbox" />
<span class="treefy-folder"></span>
<a href="javascript:void(0);">NoSQL</a>
</span>
<ul>
<li>
<span>
<span class="treefy-empty"></span>
<label for="mongodb" class="treefy-unchecked"></label>
<input id="mongodb" type="checkbox" />
<span class="treefy-file"></span>
<a href="javascript:void(0);">MongoDB</a>
</span>
</li>
</ul>
</li>
</ul>
</div>
<div class="source">
$('#tree').treefy();<br /><br />
<div id="tree"><br />
   <ul class="treefy"><br />
      <li><br />
         <span><br />
            <span class="treefy-empty"></span><br />
            <label for="ruby" class="treefy-unchecked"></label><br />
            <input id="ruby" type="checkbox" /><br />
            <span class="treefy-star"></span><br />
            <a href="javascript:void(0);">Ruby</a><br />
         </span><br />
      </li><br />
      <li><br />
         <span class="treefy-closed"><br />
            <span class="treefy-flick"></span><br />
            <label for="nosql" class="treefy-unchecked"></label><br />
            <input id="nosql" type="checkbox" /><br />
            <span class="treefy-folder"></span><br />
            <a href="javascript:void(0);">NoSQL</a><br />
         </span><br /><br />
         <ul><br />
            <li><br />
               <span><br />
                  <span class="treefy-empty"></span><br />
                  <label for="mongodb" class="treefy-unchecked"></label><br />
                  <input id="mongodb" type="checkbox" /><br />
                  <span class="treefy-file"></span><br />
                  <a href="javascript:void(0);">MongoDB</a><br />
               </span><br />
            </li><br />
         </ul><br />
      </li><br />
   </ul><br />
</div><br />
</div>
<span class="comment">
- If you want build manually, then you must follow the structure convention.<br />
- Each 'li' is an element on the tree.<br />
- The span inside li keep the information as expand/collapse icon, checkbox, icon and text of the item.<br />
- If the item is a 'folder', then it has a 'flick' span and the states closed or opened declared on the main span.<br />
- For no folder items, it is considered 'file' and has a 'empty' element instead a flick.<br />
- The last item is a link with the text of the element.<br />
- If the item has children, then it will be inside a <ul/> after the span.<br />
</span>
<div id="global-demo" class="session">Changing the settings globally:</div>
<div class="source">
$.fn.catchy.defaults.checkbox = true;<br/>
$.fn.catchy.defaults.icon = false;
</div>
<span class="comment">
- You can change any option mention the scope <b>$.fn.treefy.defaults.</b> + <i>option_name</i>;<br/>
- This setup must be called before you bind the Treefy, of course.
</span>
<div id="function-demo" class="session">Public functions:</div>
<div id="function"></div>
<div class="action-wrapper">
ID: <input id="check-id" type="text" value="ruby" class="action-field" />
<a id="check-action" href="javascript:void(0);" title="check" class="action-link">check</a>
<a id="uncheck-action" href="javascript:void(0);" title="uncheck" class="action-link">uncheck</a>
</div>
<div class="action-wrapper">
ID: <input id="enable-id" type="text" value="ruby" class="action-field" />
<a id="enable-action" href="javascript:void(0);" title="enable" class="action-link">enable</a>
<a id="disable-action" href="javascript:void(0);" title="disable" class="action-link">disable</a>
</div>
<div class="source">$('#ruby').treefy('check', true);</div>
<div class="comment">Check or uncheck the checkbox.</div>
<div class="source">$('#java').treefy('enable', false);</div>
<div class="comment">Disable or enable the checkbox.</div>
</div>
<div id="footer">
<div>© 2012 <a href="http://www.wbotelhos.com/" target="_blank">wbotelhos.com</a></div>
</div>
<script type="text/javascript">
$(function() {
var json = '{ "tree": [ { "text": "Ruby", "icon": "star", "checkbox": { "id": "ruby", "name": "languages[]", "value": "1" } }, { "text": "Java", "checkbox": { "id": "java", "name": "language[]", "value": "2", "link": "http://wbotelhos.com.br", "target": "_blank" } }, { "text": "NoSQL", "state": "opened", "checkbox": { "id": "nosql", "name": "language[]", "value": "3" }, "children": [ { "text": "Neo4j", "checkbox": { "id": "neo4j", "name": "language[]", "value": "4" } }, { "text": "Document", "checkbox": { "id": "document", "name": "language[]", "value": "5" }, "children": [ { "text": "MongoDB", "checkbox": { "id": "mongodb", "name": "language[]", "value": "6", "checked": true } }, { "text": "CouchDB", "checkbox": { "id": "couchdb", "name": "language[]", "value": "7" } } ]}, { "text": "Relational", "checkbox": { "id": "relational", "name": "language[]", "value": "8", "disabled": true } } ]} ] }';
$('#tree').treefy({
checkbox : true,
dataType : 'jsonp',
url : 'http://mockr.me/treefy'
});
$('#checkDown').treefy({
checkbox : true,
checkDown : false,
data : json
});
$('#checkUp').treefy({
checkbox : true,
checkUp : false,
data : json
});
$('#data').treefy({
checkbox : true,
checkUp : false,
data : '{ "tree": [ { "text": "Java" }, { "text": "Ruby" } ] }'
});
$('#partial').treefy({
checkbox : true,
data : json,
partial : false
});
$('#uncheckDown').treefy({
checkbox : true,
data : json,
uncheckDown : false
});
$('#uncheckUp').treefy({
checkbox : true,
data : json,
uncheckUp : false
});
$('#manual').treefy({
checkbox: true
});
$('#function').treefy({
checkbox : true,
data : json
});
$('#check-action').on('click', function() {
var id = $('#check-id').val();
$('#function').find('#' + id).treefy('check', true);
});
$('#uncheck-action').on('click', function() {
var id = $('#check-id').val();
$('#function').find('#' + id).treefy('check', false);
});
$('#enable-action').on('click', function() {
var id = $('#enable-id').val();
$('#function').find('#' + id).treefy('enable', true);
});
$('#disable-action').on('click', function() {
var id = $('#enable-id').val();
$('#function').find('#' + id).treefy('enable', false);
});
});
</script>
</body>
</html>