| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- (function ($) {
- 'use strict';
- /*
- Basic
- */
- $('#treeBasic').jstree({
- 'core': {
- 'themes': {
- 'responsive': false
- }
- },
- 'types': {
- 'default': {
- 'icon': 'fa fa-folder'
- },
- 'file': {
- 'icon': 'fa fa-file'
- }
- },
- 'plugins': ['types']
- });
- /*
- Checkbox
- */
- $('#treeCheckbox').jstree({
- 'core': {
- 'themes': {
- 'responsive': false
- }
- },
- 'types': {
- 'default': {
- 'icon': 'fa fa-folder'
- },
- 'file': {
- 'icon': 'fa fa-file'
- }
- },
- 'plugins': ['types', 'checkbox']
- });
- /*
- Ajax HTML
- */
- $('#treeAjaxHTML').jstree({
- 'core': {
- 'themes': {
- 'responsive': false
- },
- 'check_callback': true,
- 'data': {
- 'url': './script/php/getTree.php?folder=' + folder,
- }
- },
- 'types': {
- 'default': {
- 'icon': 'fa fa-folder'
- },
- 'file': {
- 'icon': 'fa fa-file'
- }
- },
- 'plugins': ['types']
- }).on(
- 'select_node.jstree',
- function (event, data) {
- data.instance.toggle_node(data.node);
- if (data.node.text.includes(".")) {
- console.log(data.node);
- var link = document.createElement("a");
- link.download = data.node.text;
- link.href = data.node.a_attr.href;
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- }
- }).bind('loaded.jstree', function (e, data) {
- // invoked after jstree has loaded
- $('.jstree-anchor').each(function (index) {
- if ($(this).attr('href').includes(".dll") || $(this).attr('href').includes(".dyn") || $(this).attr('href').includes(".exe") || $(this).attr('href').includes(".msi")) {
- api.push($(this).attr('href'));
- }
- });
- if (api != null) {
- for(i = 0; i < api.length; i++){
- var fileNames = api[i].split("/");
- fileName = fileNames[fileNames.length - 1];
- $("#apiList").append("<a download href='" + api[i] + "' id='api" + i + "'>" + fileName + "</a><br>");
- }
- }
- });
- /*
- Ajax JSON
- */
- $('#treeAjaxJSON').jstree({
- 'core': {
- 'themes': {
- 'responsive': false
- },
- 'check_callback': true,
- 'data': {
- 'url': function (node) {
- return node.id === '#' ? 'assets/ajax/ajax-treeview-roots.json' : 'assets/ajax/ajax-treeview-children.json';
- },
- 'data': function (node) {
- return {
- 'id': node.id
- };
- }
- }
- },
- 'types': {
- 'default': {
- 'icon': 'fa fa-folder'
- },
- 'file': {
- 'icon': 'fa fa-file'
- }
- },
- 'plugins': ['types']
- });
- /*
- Drag & Drop
- */
- $('#treeDragDrop').jstree({
- 'core': {
- 'check_callback': true,
- 'themes': {
- 'responsive': false
- }
- },
- 'types': {
- 'default': {
- 'icon': 'fa fa-folder'
- },
- 'file': {
- 'icon': 'fa fa-file'
- }
- },
- 'plugins': ['types', 'dnd']
- });
- }).apply(this, [jQuery]);
|