Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | var UINestable = function () { |
| 2 | |||
| 3 | var updateOutput = function (e) { |
||
| 4 | var list = e.length ? e : $(e.target), |
||
| 5 | output = list.data('output'); |
||
| 6 | if (window.JSON) { |
||
| 7 | output.val(window.JSON.stringify(list.nestable('serialize'))); //, null, 2)); |
||
| 8 | } else { |
||
| 9 | output.val('JSON browser support required for this demo.'); |
||
| 10 | } |
||
| 11 | }; |
||
| 12 | |||
| 13 | |||
| 14 | return { |
||
| 15 | //main function to initiate the module |
||
| 16 | init: function () { |
||
| 17 | |||
| 18 | // activate Nestable for list 1 |
||
| 19 | $('#nestable_list_1').nestable({ |
||
| 20 | group: 1 |
||
| 21 | }) |
||
| 22 | .on('change', updateOutput); |
||
| 23 | |||
| 24 | // activate Nestable for list 2 |
||
| 25 | $('#nestable_list_2').nestable({ |
||
| 26 | group: 1 |
||
| 27 | }) |
||
| 28 | .on('change', updateOutput); |
||
| 29 | |||
| 30 | // output initial serialised data |
||
| 31 | updateOutput($('#nestable_list_1').data('output', $('#nestable_list_1_output'))); |
||
| 32 | updateOutput($('#nestable_list_2').data('output', $('#nestable_list_2_output'))); |
||
| 33 | |||
| 34 | $('#nestable_list_menu').on('click', function (e) { |
||
| 35 | var target = $(e.target), |
||
| 36 | action = target.data('action'); |
||
| 37 | if (action === 'expand-all') { |
||
| 38 | $('.dd').nestable('expandAll'); |
||
| 39 | } |
||
| 40 | if (action === 'collapse-all') { |
||
| 41 | $('.dd').nestable('collapseAll'); |
||
| 42 | } |
||
| 43 | }); |
||
| 44 | |||
| 45 | $('#nestable_list_3').nestable(); |
||
| 46 | |||
| 47 | } |
||
| 48 | |||
| 49 | }; |
||
| 50 | |||
| 51 | }(); |