window.saveModule = function() { const name = $(this).val(); const {id, type, lib, module} = $(this).data(); const parentID = $(this).data('parent'); $(this).closest('.tree-item').remove(); if(!name) return; $.ajaxSubmit({ url: $.createLink('tree', 'ajaxCreateModule'), data: { name : name, libID : lib, parentID : parentID, objectID : id, moduleType : module, isUpdate : false, createType : type, } }); } window.addModule = function(id, addType) { const $element = $(`div[data-id='${id}']`).not('div[data-type=annex]'); const {lib, type, module} = $element.data(); let parentID = ['docLib', 'apiLib'].includes(type) ? '0' : $element.data('parent'); let level = $element.closest('.tree-item').attr('z-key-path').split(':').length; if(addType == 'child' && !['docLib', 'apiLib'].includes(type)) parentID = id; if(addType != 'same') level += 1; const style = `style="margin-left: calc(${level} * 12px)"`; const className = addType == 'child' && ['docLib', 'apiLib'].includes(type) ? 'mt-2' : ''; let inputTpl = `