3 lines
1.7 KiB
JavaScript
3 lines
1.7 KiB
JavaScript
"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var n=0;n<e.length;n++){var a=e[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function _createClass(t,e,n){return e&&_defineProperties(t.prototype,e),n&&_defineProperties(t,n),t}var NestableDemo=function(){function t(){_classCallCheck(this,t),this.init()}return _createClass(t,[{key:"init",value:function(){this.handleNestable()}},{key:"handleNestable",value:function(){var a=this;$("#nestable01").on("change",this.output),$("#nestable02").on("change",this.output),this.getData().done(function(t){var n="";$.each(t,function(t,e){n+=a.buildItem(e)}),$("#nestable03").children().html(n).parent().nestable().on("change",a.output)})}},{key:"getData",value:function(){return $.getJSON("assets/data/nestable.json")}},{key:"buildItem",value:function(t){var n=this,a='<li class="dd-item" data-id="'.concat(t.id,'">\n <div class="dd-handle">\n <span class="drag-indicator"></span>\n <div>').concat(t.text,'</div>\n <div class="dd-nodrag btn-group ml-auto">\n <button class="btn btn-sm btn-secondary">Edit</button>\n <button class="btn btn-sm btn-secondary"><i class="far fa-trash-alt"></i></button>\n </div>\n </div>');return t.children&&(a+='<ol class="dd-list">',$.each(t.children,function(t,e){a+=n.buildItem(e)}),a+="</ol>"),a+="</li>"}},{key:"output",value:function(t){var e=t.length?t:$(t.target);$("#nestableOutput").text(window.JSON.stringify(e.nestable("serialize")))}}]),t}();$(document).on("theme:init",function(){new NestableDemo});
|
|
//# sourceMappingURL=../../sourcemaps/pages/nestable-demo.min.js.map
|