Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

custom-nestable.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 'use strict';
  2. $(document).ready(function() {
  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. // activate Nestable for list 1
  13. $('#nestable').nestable({
  14. group: 1
  15. })
  16. .on('change', updateOutput);
  17. // activate Nestable for list 2
  18. $('#nestable2').nestable({
  19. group: 1
  20. })
  21. .on('change', updateOutput);
  22. // activate Nestable for list 2
  23. $('#color-nestable').nestable({
  24. group: 1
  25. })
  26. .on('change', updateOutput);
  27. // output initial serialised data
  28. updateOutput($('#nestable').data('output', $('#nestable-output')));
  29. updateOutput($('#nestable2').data('output', $('#nestable2-output')));
  30. updateOutput($('#color-nestable').data('output', $('#color-nestable-output')));
  31. $('#nestable-menu').on('click', function(e) {
  32. var target = $(e.target),
  33. action = target.data('action');
  34. if (action === 'expand-all') {
  35. $('.dd').nestable('expandAll');
  36. }
  37. if (action === 'collapse-all') {
  38. $('.dd').nestable('collapseAll');
  39. }
  40. });
  41. $('#nestable3').nestable();
  42. });