libreqda 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CHANGELOG.md +481 -0
- libreqda-1.2.0.dist-info/LICENSE.txt +28 -0
- libreqda-1.2.0.dist-info/METADATA +131 -0
- libreqda-1.2.0.dist-info/RECORD +255 -0
- libreqda-1.2.0.dist-info/WHEEL +4 -0
- libreqda-1.2.0.dist-info/entry_points.txt +4 -0
- scripts/babelrc +8 -0
- scripts/dist/LICENSE.txt +33 -0
- scripts/dist/RELEASE.txt +23 -0
- scripts/dist/macos/libreqda.icns +0 -0
- scripts/dist/macos/macos.spec +43 -0
- scripts/dist/macos/plist.patch +10 -0
- scripts/dist/macos/taguette.icns +0 -0
- scripts/dist/macos/taguette_console_wrapper +4 -0
- scripts/dist/macos.sh +32 -0
- scripts/dist/pyinstaller_entrypoint.py +19 -0
- scripts/dist/windows/windows-installer.iss +51 -0
- scripts/dist/windows/windows.spec +39 -0
- scripts/edugain/worker_update_edugain_idps.py +89 -0
- scripts/edugain/worker_update_edugain_idps.sh +9 -0
- scripts/make_password_reset_link.py +56 -0
- scripts/make_theme.py +99 -0
- scripts/new_db_revision.sh +8 -0
- scripts/register_user.py +76 -0
- scripts/update_pot.sh +33 -0
- scripts/update_translations.sh +17 -0
- scripts/validate.py +140 -0
- scripts/wipe_and_disable_user.py +90 -0
- taguette/__init__.py +13 -0
- taguette/access_control.py +145 -0
- taguette/convert.py +623 -0
- taguette/database/__init__.py +177 -0
- taguette/database/base.py +9 -0
- taguette/database/copy.py +433 -0
- taguette/database/models.py +920 -0
- taguette/demodata.py +688 -0
- taguette/export.py +500 -0
- taguette/extract.py +287 -0
- taguette/import_codebook.py +110 -0
- taguette/l10n/de_DE/LC_MESSAGES/taguette_javascript.mo +0 -0
- taguette/l10n/de_DE/LC_MESSAGES/taguette_main.mo +0 -0
- taguette/l10n/el_EL/LC_MESSAGES/taguette_javascript.mo +0 -0
- taguette/l10n/el_GR/LC_MESSAGES/taguette_javascript.mo +0 -0
- taguette/l10n/el_GR/LC_MESSAGES/taguette_main.mo +0 -0
- taguette/l10n/en_US/LC_MESSAGES/taguette_javascript.mo +0 -0
- taguette/l10n/en_US/LC_MESSAGES/taguette_main.mo +0 -0
- taguette/l10n/es_ES/LC_MESSAGES/taguette_javascript.mo +0 -0
- taguette/l10n/es_ES/LC_MESSAGES/taguette_main.mo +0 -0
- taguette/l10n/fr_FR/LC_MESSAGES/taguette_javascript.mo +0 -0
- taguette/l10n/fr_FR/LC_MESSAGES/taguette_main.mo +0 -0
- taguette/l10n/id_ID/LC_MESSAGES/taguette_javascript.mo +0 -0
- taguette/l10n/id_ID/LC_MESSAGES/taguette_main.mo +0 -0
- taguette/l10n/it_IT/LC_MESSAGES/taguette_javascript.mo +0 -0
- taguette/l10n/it_IT/LC_MESSAGES/taguette_main.mo +0 -0
- taguette/l10n/nl_NL/LC_MESSAGES/taguette_javascript.mo +0 -0
- taguette/l10n/nl_NL/LC_MESSAGES/taguette_main.mo +0 -0
- taguette/l10n/pt_PT/LC_MESSAGES/taguette_javascript.mo +0 -0
- taguette/l10n/pt_PT/LC_MESSAGES/taguette_main.mo +0 -0
- taguette/l10n/sv_SE/LC_MESSAGES/taguette_javascript.mo +0 -0
- taguette/l10n/sv_SE/LC_MESSAGES/taguette_main.mo +0 -0
- taguette/loki_handler.py +107 -0
- taguette/main.py +649 -0
- taguette/migrations/env.py +72 -0
- taguette/migrations/script.py.mako +24 -0
- taguette/migrations/versions/09c662cd9483_make_documents_filename_not_null.py +39 -0
- taguette/migrations/versions/1b29e68900c1_add_user_roles.py +55 -0
- taguette/migrations/versions/1b96a606551d_update_user_to_have_a_display_name.py +34 -0
- taguette/migrations/versions/2467bab602b7_add_color_column_to_tags_table.py +33 -0
- taguette/migrations/versions/382db36f20f4_add_user_disabled.py +66 -0
- taguette/migrations/versions/43d6c240309d_remove_document_groups.py +81 -0
- taguette/migrations/versions/447d636f72c5_cascades.py +40 -0
- taguette/migrations/versions/491de2dc7cd7_add_indexes.py +51 -0
- taguette/migrations/versions/4c55b3b3ff30_user_login_length.py +58 -0
- taguette/migrations/versions/61a4abcc8769_user_with_parent_for_permissions.py +40 -0
- taguette/migrations/versions/6489b5f9cfb5_increase_password_hash_size.py +34 -0
- taguette/migrations/versions/679f625e6e6a_fix_unique_tags.py +59 -0
- taguette/migrations/versions/77c4543a5b9b_add_parent_id_column_to_collection_table.py +41 -0
- taguette/migrations/versions/7c94b7a31e69_add_is_archived_column_to_projets.py +39 -0
- taguette/migrations/versions/7f56de97e3c8_change_edugain_displayname_length.py +42 -0
- taguette/migrations/versions/807c0cc0ecf6_remove_invalid_hltags.py +43 -0
- taguette/migrations/versions/80b1cc9d4c22_add_user_email.py +35 -0
- taguette/migrations/versions/91ade71ccf4d_add_user_language.py +28 -0
- taguette/migrations/versions/955db2e523d1_add_collections_tables_and_associations_.py +60 -0
- taguette/migrations/versions/a1b2c3d4e5f6_add_user_hide_code_counts.py +28 -0
- taguette/migrations/versions/b23f3b7a638e_add_user_password_change_date.py +36 -0
- taguette/migrations/versions/b7c1e2d3f4a5_add_project_compact_layout.py +28 -0
- taguette/migrations/versions/bc8e0e0677e9_rename_command_fields.py +126 -0
- taguette/migrations/versions/bce44849c2f2_lowercase_logins.py +96 -0
- taguette/migrations/versions/ca076140922f_update_user_for_external_logins.py +32 -0
- taguette/migrations/versions/d86c45d7aa8a_add_document_direction.py +127 -0
- taguette/migrations/versions/db5e31a0233d_remove_blank_highlights.py +88 -0
- taguette/migrations/versions/dd37d9027a24_unique_tags.py +68 -0
- taguette/migrations/versions/de678cef2a94_add_project_id_to_collections_and_.py +41 -0
- taguette/migrations/versions/e459991d960e_add_table_edugainidps.py +39 -0
- taguette/migrations/versions/e4cf92942271_add_index.py +29 -0
- taguette/migrations/versions/e4e090a5b511_remove_commands_document_id_fk.py +38 -0
- taguette/migrations/versions/e9a9f1c77971_add_favorite_column_to_document.py +32 -0
- taguette/migrations/versions/ecb4065de575_don_t_use_server_default_now_timezone_.py +44 -0
- taguette/migrations/versions/fbdc29566f62_edugain_fix_field_type.py +42 -0
- taguette/migrations/versions/fdc6eb54b034_add_parent_id_column_to_tags_table.py +31 -0
- taguette/static/README.md +34 -0
- taguette/static/alt_templates/.gitkeep +0 -0
- taguette/static/assets/test/logos/monsters-university-logo.png +0 -0
- taguette/static/css/custom.css +1696 -0
- taguette/static/css/fa-all.min.css +5 -0
- taguette/static/css/themed.css +3 -0
- taguette/static/css/themed.css.map +25 -0
- taguette/static/css/vendor/bootstrap-treeview.min.css +1 -0
- taguette/static/css/vendor/bootstrap.min.css +6 -0
- taguette/static/css/vendor/font/context-menu-icons.eot +0 -0
- taguette/static/css/vendor/font/context-menu-icons.ttf +0 -0
- taguette/static/css/vendor/font/context-menu-icons.woff +0 -0
- taguette/static/css/vendor/font/context-menu-icons.woff2 +0 -0
- taguette/static/css/vendor/hierarchy-select.min.css +1 -0
- taguette/static/css/vendor/introjs.min.css +2 -0
- taguette/static/css/vendor/jquery.contextMenu.min.css +16 -0
- taguette/static/favicon.ico +0 -0
- taguette/static/js/codebook-viz.js +428 -0
- taguette/static/js/collection/context-menu.js +180 -0
- taguette/static/js/collection/hierarchy-select.js +71 -0
- taguette/static/js/collection/manager.js +217 -0
- taguette/static/js/document/context-menu.js +92 -0
- taguette/static/js/document/custom-select.js +82 -0
- taguette/static/js/document/manager.js +943 -0
- taguette/static/js/document/treeview.js +593 -0
- taguette/static/js/highlight/README.md +18 -0
- taguette/static/js/highlight/crud.js +119 -0
- taguette/static/js/highlight/extracts.js +497 -0
- taguette/static/js/highlight/loader.js +109 -0
- taguette/static/js/highlight/renderer.js +405 -0
- taguette/static/js/login.js +15 -0
- taguette/static/js/permissions.js +153 -0
- taguette/static/js/polling-event.js +145 -0
- taguette/static/js/project/intro.js +524 -0
- taguette/static/js/project/manager.js +0 -0
- taguette/static/js/project/search.js +124 -0
- taguette/static/js/tag/context-menu.js +133 -0
- taguette/static/js/tag/explore-codes.js +400 -0
- taguette/static/js/tag/hierarchy-select.js +69 -0
- taguette/static/js/tag/manager.js +545 -0
- taguette/static/js/tag/treeview.js +613 -0
- taguette/static/js/taguette.js +1790 -0
- taguette/static/js/utilities.js +714 -0
- taguette/static/js/vendor/bootstrap-treeview-custum.js +421 -0
- taguette/static/js/vendor/bootstrap-treeview-custum.min.js +1 -0
- taguette/static/js/vendor/bootstrap-treeview-default.min.js +1 -0
- taguette/static/js/vendor/bootstrap.bundle.min.js +7 -0
- taguette/static/js/vendor/bootstrap.bundle.min.js.map +1 -0
- taguette/static/js/vendor/hierarchy-select.min.js +1 -0
- taguette/static/js/vendor/introjs.min.js +17 -0
- taguette/static/js/vendor/jquery-3.7.1.js +2 -0
- taguette/static/js/vendor/jquery.contextMenu.min.js +2 -0
- taguette/static/libreqda.ico +0 -0
- taguette/static/logo-h.png +0 -0
- taguette/static/logo.png +0 -0
- taguette/static/logo_blanc.png +0 -0
- taguette/static/missing.png +0 -0
- taguette/static/robots.txt +2 -0
- taguette/static/scss/components/_badge.scss +42 -0
- taguette/static/scss/components/_button.scss +169 -0
- taguette/static/scss/components/_checkbox.scss +40 -0
- taguette/static/scss/components/_context_menu.scss +28 -0
- taguette/static/scss/components/_custom_select.scss +150 -0
- taguette/static/scss/components/_dropdown.scss +43 -0
- taguette/static/scss/components/_form.scss +54 -0
- taguette/static/scss/components/_modal.scss +57 -0
- taguette/static/scss/components/_project_card.scss +163 -0
- taguette/static/scss/components/_tag.scss +308 -0
- taguette/static/scss/components/_treeview.scss +76 -0
- taguette/static/scss/custom.scss +809 -0
- taguette/static/scss/layout/_credits.scss +62 -0
- taguette/static/scss/layout/_footer.scss +6 -0
- taguette/static/scss/layout/_navigation.scss +165 -0
- taguette/static/scss/layout/_sidebar.scss +37 -0
- taguette/static/scss/themes/default/_variables.scss +103 -0
- taguette/static/scss/themes/default/theme.css +3 -0
- taguette/static/scss/themes/default/theme.css.map +26 -0
- taguette/static/scss/themes/default/theme.scss +4 -0
- taguette/static/webfonts/BadScript-OFL.txt +94 -0
- taguette/static/webfonts/BadScript.ttf +0 -0
- taguette/static/webfonts/Montserrat-Light.ttf +0 -0
- taguette/static/webfonts/Montserrat-OFL.txt +93 -0
- taguette/static/webfonts/fa-brands-400.eot +0 -0
- taguette/static/webfonts/fa-brands-400.svg +1184 -0
- taguette/static/webfonts/fa-brands-400.ttf +0 -0
- taguette/static/webfonts/fa-brands-400.woff +0 -0
- taguette/static/webfonts/fa-brands-400.woff2 +0 -0
- taguette/static/webfonts/fa-regular-400.eot +0 -0
- taguette/static/webfonts/fa-regular-400.svg +467 -0
- taguette/static/webfonts/fa-regular-400.ttf +0 -0
- taguette/static/webfonts/fa-regular-400.woff +0 -0
- taguette/static/webfonts/fa-regular-400.woff2 +0 -0
- taguette/static/webfonts/fa-solid-900.eot +0 -0
- taguette/static/webfonts/fa-solid-900.svg +2618 -0
- taguette/static/webfonts/fa-solid-900.ttf +0 -0
- taguette/static/webfonts/fa-solid-900.woff +0 -0
- taguette/static/webfonts/fa-solid-900.woff2 +0 -0
- taguette/templates/alt_templates/.gitkeep +0 -0
- taguette/templates/archived_projects.html +50 -0
- taguette/templates/auth/account.html +74 -0
- taguette/templates/auth/cilogon.login.html +89 -0
- taguette/templates/auth/email_reset_password.html +5 -0
- taguette/templates/auth/external_account.html +60 -0
- taguette/templates/auth/login.html +144 -0
- taguette/templates/auth/reset_password.html +27 -0
- taguette/templates/auth/token_needed.html +7 -0
- taguette/templates/base.html +209 -0
- taguette/templates/bug_report.html +158 -0
- taguette/templates/cookies_prompt.html +15 -0
- taguette/templates/downloads.html +127 -0
- taguette/templates/email_bug_report.txt +9 -0
- taguette/templates/email_reset_password.txt +5 -0
- taguette/templates/error.html +8 -0
- taguette/templates/export_codebook.html +20 -0
- taguette/templates/export_document.html +20 -0
- taguette/templates/export_highlights.html +47 -0
- taguette/templates/index.html +347 -0
- taguette/templates/maintenance.html +8 -0
- taguette/templates/messages.js +74 -0
- taguette/templates/modal/change_document.html +68 -0
- taguette/templates/modal/create_collection.html +100 -0
- taguette/templates/modal/create_document.html +84 -0
- taguette/templates/modal/create_highlight.html +38 -0
- taguette/templates/modal/create_tag.html +73 -0
- taguette/templates/modal/explore_codes.html +58 -0
- taguette/templates/modal/manage_collaborators.html +44 -0
- taguette/templates/modal/merge_tag.html +49 -0
- taguette/templates/new_password.html +32 -0
- taguette/templates/partials/alert.html +16 -0
- taguette/templates/partials/codebook_viz_modal.html +34 -0
- taguette/templates/partials/confirm.html +17 -0
- taguette/templates/partials/document_toolbar.html +37 -0
- taguette/templates/partials/hlinfo.html +13 -0
- taguette/templates/partials/project_card.html +44 -0
- taguette/templates/partials/project_card_archived.html +41 -0
- taguette/templates/partials/project_sidebar.html +99 -0
- taguette/templates/partials/spinner.html +11 -0
- taguette/templates/permissions.html +54 -0
- taguette/templates/project.html +288 -0
- taguette/templates/project_delete.html +17 -0
- taguette/templates/project_import.html +122 -0
- taguette/templates/project_import_codebook.html +34 -0
- taguette/templates/project_import_codebook_confirm.html +49 -0
- taguette/templates/project_new.html +31 -0
- taguette/templates/tos.html +8 -0
- taguette/templates/trans.js +7 -0
- taguette/templates/welcome.html +15 -0
- taguette/utils.py +177 -0
- taguette/validate.py +141 -0
- taguette/version_check.py +102 -0
- taguette/web/__init__.py +252 -0
- taguette/web/api.py +1835 -0
- taguette/web/base.py +864 -0
- taguette/web/export.py +338 -0
- taguette/web/views.py +1618 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
! function(h, t, e, n) {
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
function i(e, t) {
|
|
5
|
+
return this.$element = h(e), this.elementId = e.id, this.styleId = this.elementId + "-style", this.init(t), {
|
|
6
|
+
options: this.options,
|
|
7
|
+
init: h.proxy(this.init, this),
|
|
8
|
+
remove: h.proxy(this.remove, this),
|
|
9
|
+
getNode: h.proxy(this.getNode, this),
|
|
10
|
+
getParent: h.proxy(this.getParent, this),
|
|
11
|
+
getSiblings: h.proxy(this.getSiblings, this),
|
|
12
|
+
getSelected: h.proxy(this.getSelected, this),
|
|
13
|
+
getUnselected: h.proxy(this.getUnselected, this),
|
|
14
|
+
getExpanded: h.proxy(this.getExpanded, this),
|
|
15
|
+
getCollapsed: h.proxy(this.getCollapsed, this),
|
|
16
|
+
getChecked: h.proxy(this.getChecked, this),
|
|
17
|
+
getUnchecked: h.proxy(this.getUnchecked, this),
|
|
18
|
+
getDisabled: h.proxy(this.getDisabled, this),
|
|
19
|
+
getEnabled: h.proxy(this.getEnabled, this),
|
|
20
|
+
selectNode: h.proxy(this.selectNode, this),
|
|
21
|
+
unselectNode: h.proxy(this.unselectNode, this),
|
|
22
|
+
toggleNodeSelected: h.proxy(this.toggleNodeSelected, this),
|
|
23
|
+
collapseAll: h.proxy(this.collapseAll, this),
|
|
24
|
+
collapseNode: h.proxy(this.collapseNode, this),
|
|
25
|
+
expandAll: h.proxy(this.expandAll, this),
|
|
26
|
+
expandNode: h.proxy(this.expandNode, this),
|
|
27
|
+
toggleNodeExpanded: h.proxy(this.toggleNodeExpanded, this),
|
|
28
|
+
revealNode: h.proxy(this.revealNode, this),
|
|
29
|
+
checkAll: h.proxy(this.checkAll, this),
|
|
30
|
+
checkNode: h.proxy(this.checkNode, this),
|
|
31
|
+
uncheckAll: h.proxy(this.uncheckAll, this),
|
|
32
|
+
uncheckNode: h.proxy(this.uncheckNode, this),
|
|
33
|
+
toggleNodeChecked: h.proxy(this.toggleNodeChecked, this),
|
|
34
|
+
disableAll: h.proxy(this.disableAll, this),
|
|
35
|
+
disableNode: h.proxy(this.disableNode, this),
|
|
36
|
+
enableAll: h.proxy(this.enableAll, this),
|
|
37
|
+
enableNode: h.proxy(this.enableNode, this),
|
|
38
|
+
toggleNodeDisabled: h.proxy(this.toggleNodeDisabled, this),
|
|
39
|
+
search: h.proxy(this.search, this),
|
|
40
|
+
clearSearch: h.proxy(this.clearSearch, this)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function d(e) {
|
|
45
|
+
t.console && t.console.error(e)
|
|
46
|
+
}
|
|
47
|
+
let r = "treeview",
|
|
48
|
+
l = {};
|
|
49
|
+
l.settings = {
|
|
50
|
+
injectStyle: !0,
|
|
51
|
+
levels: 2,
|
|
52
|
+
expandIcon: "fa fa-chevron-right",
|
|
53
|
+
collapseIcon: "fa fa-chevron-down",
|
|
54
|
+
emptyIcon: "fa",
|
|
55
|
+
nodeIcon: "",
|
|
56
|
+
selectedIcon: "",
|
|
57
|
+
checkedIcon: "fa fa-check-circle-o",
|
|
58
|
+
uncheckedIcon: "fa fa-circle-thin",
|
|
59
|
+
color: n,
|
|
60
|
+
backColor: n,
|
|
61
|
+
borderColor: n,
|
|
62
|
+
onhoverColor: "#F5F5F5",
|
|
63
|
+
selectedColor: "#005A20",
|
|
64
|
+
selectedBackColor: "#EDEFE9",
|
|
65
|
+
searchResultColor: "#D9534F",
|
|
66
|
+
searchResultBackColor: n,
|
|
67
|
+
enableLinks: !1,
|
|
68
|
+
enableIndent: !0,
|
|
69
|
+
highlightSelected: !0,
|
|
70
|
+
highlightSearchResults: !0,
|
|
71
|
+
showBorder: !0,
|
|
72
|
+
showIcon: !0,
|
|
73
|
+
showCheckbox: !1,
|
|
74
|
+
showTags: !1,
|
|
75
|
+
multiSelect: !1,
|
|
76
|
+
customizeNode: null, // New parameter
|
|
77
|
+
addVerticalLine: null,
|
|
78
|
+
customizeBadges: null,
|
|
79
|
+
customContent: false,
|
|
80
|
+
nodeContentSelector: 'span',
|
|
81
|
+
nodeContentAttributes: {},
|
|
82
|
+
onNodeChecked: n,
|
|
83
|
+
onNodeCollapsed: n,
|
|
84
|
+
onNodeDisabled: n,
|
|
85
|
+
onNodeEnabled: n,
|
|
86
|
+
onNodeExpanded: n,
|
|
87
|
+
onNodeSelected: n,
|
|
88
|
+
onNodeUnchecked: n,
|
|
89
|
+
onNodeUnselected: n,
|
|
90
|
+
onSearchComplete: n,
|
|
91
|
+
onSearchCleared: n
|
|
92
|
+
}, l.options = {
|
|
93
|
+
silent: !1,
|
|
94
|
+
ignoreChildren: !1
|
|
95
|
+
}, l.searchOptions = {
|
|
96
|
+
ignoreCase: !0,
|
|
97
|
+
exactMatch: !1,
|
|
98
|
+
revealResults: !0
|
|
99
|
+
}, i.prototype.init = function(e) {
|
|
100
|
+
this.tree = [], this.nodes = [], e.data && ("string" == typeof e.data && (e.data = h.parseJSON(e.data)), this.tree = h.extend(!0, [], e.data), delete e.data), this.options = h.extend({}, l.settings, e), this.destroy(), this.subscribeEvents(), this.setInitialStates({
|
|
101
|
+
nodes: this.tree
|
|
102
|
+
}, 0), this.render()
|
|
103
|
+
}, i.prototype.remove = function() {
|
|
104
|
+
this.destroy(), h.removeData(this, r), h("#" + this.styleId).remove()
|
|
105
|
+
}, i.prototype.destroy = function() {
|
|
106
|
+
this.initialized && (this.$wrapper.remove(), this.$wrapper = null, this.unsubscribeEvents(), this.initialized = !1)
|
|
107
|
+
}, i.prototype.unsubscribeEvents = function() {
|
|
108
|
+
this.$element.off("click"), this.$element.off("nodeChecked"), this.$element.off("nodeCollapsed"), this.$element.off("nodeDisabled"), this.$element.off("nodeEnabled"), this.$element.off("nodeExpanded"), this.$element.off("nodeSelected"), this.$element.off("nodeUnchecked"), this.$element.off("nodeUnselected"), this.$element.off("searchComplete"), this.$element.off("searchCleared")
|
|
109
|
+
}, i.prototype.subscribeEvents = function() {
|
|
110
|
+
this.unsubscribeEvents(), this.$element.on("click", h.proxy(this.clickHandler, this)), "function" == typeof this.options.onNodeChecked && this.$element.on("nodeChecked", this.options.onNodeChecked), "function" == typeof this.options.onNodeCollapsed && this.$element.on("nodeCollapsed", this.options.onNodeCollapsed), "function" == typeof this.options.onNodeDisabled && this.$element.on("nodeDisabled", this.options.onNodeDisabled), "function" == typeof this.options.onNodeEnabled && this.$element.on("nodeEnabled", this.options.onNodeEnabled), "function" == typeof this.options.onNodeExpanded && this.$element.on("nodeExpanded", this.options.onNodeExpanded), "function" == typeof this.options.onNodeSelected && this.$element.on("nodeSelected", this.options.onNodeSelected), "function" == typeof this.options.onNodeUnchecked && this.$element.on("nodeUnchecked", this.options.onNodeUnchecked), "function" == typeof this.options.onNodeUnselected && this.$element.on("nodeUnselected", this.options.onNodeUnselected), "function" == typeof this.options.onSearchComplete && this.$element.on("searchComplete", this.options.onSearchComplete), "function" == typeof this.options.onSearchCleared && this.$element.on("searchCleared", this.options.onSearchCleared)
|
|
111
|
+
}, i.prototype.setInitialStates = function(e, n) {
|
|
112
|
+
if (e.nodes) {
|
|
113
|
+
n += 1;
|
|
114
|
+
let o = e,
|
|
115
|
+
s = this;
|
|
116
|
+
h.each(e.nodes, function(e, t) {
|
|
117
|
+
t.nodeId = s.nodes.length, t.parentId = o.nodeId, t.hasOwnProperty("selectable") || (t.selectable = !1), t.state = t.state || {}, t.state.hasOwnProperty("checked") || (t.state.checked = !1), t.state.hasOwnProperty("disabled") || (t.state.disabled = !1), t.state.hasOwnProperty("expanded") || (!t.state.disabled && n < s.options.levels && t.nodes && 0 < t.nodes.length ? t.state.expanded = !0 : t.state.expanded = !1), t.state.hasOwnProperty("selected") || (t.state.selected = !1), s.nodes.push(t), t.nodes && s.setInitialStates(t, n)
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
}, i.prototype.clickHandler = function(t) {
|
|
121
|
+
this.options.enableLinks || t.preventDefault();
|
|
122
|
+
let o = h(t.target);
|
|
123
|
+
t = this.findNode(o);
|
|
124
|
+
if (t && !t.state.disabled) {
|
|
125
|
+
let e = o.attr("class") ? o.attr("class").split(" ") : []; - 1 !== e.indexOf("expand-icon") ? this.toggleExpandedState(t, l.options) : -1 !== e.indexOf("check-icon") ? this.toggleCheckedState(t, l.options) : t.selectable ? this.toggleSelectedState(t, l.options) : this.toggleExpandedState(t, l.options), this.render()
|
|
126
|
+
}
|
|
127
|
+
}, i.prototype.findNode = function(e) {
|
|
128
|
+
e = e.closest("li.list-group-item").attr("data-nodeid"), e = this.nodes[e];
|
|
129
|
+
return e || console.log("Error: node does not exist"), e
|
|
130
|
+
}, i.prototype.toggleExpandedState = function(e, t) {
|
|
131
|
+
e && this.setExpandedState(e, !e.state.expanded, t)
|
|
132
|
+
}, i.prototype.setExpandedState = function(e, t, o) {
|
|
133
|
+
t !== e.state.expanded && (t && e.nodes ? (e.state.expanded = !0, o.silent || this.$element.trigger("nodeExpanded", h.extend(!0, {}, e))) : t || (e.state.expanded = !1, o.silent || this.$element.trigger("nodeCollapsed", h.extend(!0, {}, e)), e.nodes && !o.ignoreChildren && h.each(e.nodes, h.proxy(function(e, t) {
|
|
134
|
+
this.setExpandedState(t, !1, o)
|
|
135
|
+
}, this))))
|
|
136
|
+
}, i.prototype.toggleSelectedState = function(e, t) {
|
|
137
|
+
e && this.setSelectedState(e, !e.state.selected, t)
|
|
138
|
+
}, i.prototype.setSelectedState = function(e, t, o) {
|
|
139
|
+
t !== e.state.selected && (t ? (this.options.multiSelect || h.each(this.findNodes("true", "g", "state.selected"), h.proxy(function(e, t) {
|
|
140
|
+
this.setSelectedState(t, !1, o)
|
|
141
|
+
}, this)), e.state.selected = !0, o.silent || this.$element.trigger("nodeSelected", h.extend(!0, {}, e))) : (e.state.selected = !1, o.silent || this.$element.trigger("nodeUnselected", h.extend(!0, {}, e))))
|
|
142
|
+
}, i.prototype.toggleCheckedState = function(e, t) {
|
|
143
|
+
e && this.setCheckedState(e, !e.state.checked, t)
|
|
144
|
+
}, i.prototype.setCheckedState = function(e, t, o) {
|
|
145
|
+
t !== e.state.checked && (t ? (e.state.checked = !0, o.silent || this.$element.trigger("nodeChecked", h.extend(!0, {}, e))) : (e.state.checked = !1, o.silent || this.$element.trigger("nodeUnchecked", h.extend(!0, {}, e))))
|
|
146
|
+
}, i.prototype.setDisabledState = function(e, t, o) {
|
|
147
|
+
t !== e.state.disabled && (t ? (e.state.disabled = !0, this.setExpandedState(e, !1, o), this.setSelectedState(e, !1, o), this.setCheckedState(e, !1, o), o.silent || this.$element.trigger("nodeDisabled", h.extend(!0, {}, e))) : (e.state.disabled = !1, o.silent || this.$element.trigger("nodeEnabled", h.extend(!0, {}, e))))
|
|
148
|
+
}, i.prototype.render = function() {
|
|
149
|
+
this.initialized || (this.$element.addClass(r), this.$wrapper = h(this.template.list), this.injectStyle(), this.initialized = !0), this.$element.empty().append(this.$wrapper.empty()), this.buildTree(this.tree, 0)
|
|
150
|
+
}, i.prototype.buildTree = function(e, r) {
|
|
151
|
+
if (e) {
|
|
152
|
+
r += 1;
|
|
153
|
+
let d = this;
|
|
154
|
+
h.each(e, function(e, t) {
|
|
155
|
+
let o = h(d.template.itemWrapper)
|
|
156
|
+
.addClass("node-" + d.elementId)
|
|
157
|
+
.addClass(t.state.checked ? "node-checked" : "")
|
|
158
|
+
.addClass(t.state.disabled ? "node-disabled" : "")
|
|
159
|
+
.addClass(t.state.selected ? "node-selected" : "")
|
|
160
|
+
.addClass(t.searchResult ? "search-result" : "")
|
|
161
|
+
.attr("data-nodeid", t.nodeId)
|
|
162
|
+
.attr("style", d.buildStyleOverride(t)),
|
|
163
|
+
s = h(d.template.itemLeftElem),
|
|
164
|
+
n = h(d.template.itemRightElem);
|
|
165
|
+
|
|
166
|
+
//enable node customization if defined
|
|
167
|
+
if (typeof d.options.customizeNode === 'function') {
|
|
168
|
+
d.options.customizeNode(o, t, d);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
o.append(s).append(n);
|
|
172
|
+
|
|
173
|
+
if (d.options.enableIndent) {
|
|
174
|
+
for (let e = 0; e < r - 1; e++) s.append(d.template.indent);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (t.nodes && t.nodes.length > 0) {
|
|
178
|
+
let i = ["expand-icon"];
|
|
179
|
+
i.push(t.state.expanded ? d.options.collapseIcon : d.options.expandIcon);
|
|
180
|
+
s.append(h(d.template.icon).addClass(i.join(" ")));
|
|
181
|
+
|
|
182
|
+
if (d.options.showIcon) {
|
|
183
|
+
let e = ["node-icon"];
|
|
184
|
+
e.push(t.icon || d.options.nodeIcon);
|
|
185
|
+
if (t.state.selected) {
|
|
186
|
+
e.pop();
|
|
187
|
+
e.push(t.selectedIcon || d.options.selectedIcon || t.icon || d.options.nodeIcon);
|
|
188
|
+
}
|
|
189
|
+
s.append(h(d.template.icon).addClass(e.join(" ")));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (d.options.showCheckbox) {
|
|
194
|
+
let e = ["check-icon"];
|
|
195
|
+
e.push(t.state.checked ? d.options.checkedIcon : d.options.uncheckedIcon);
|
|
196
|
+
s.append(h(d.template.icon).addClass(e.join(" ")));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Handle custom node content
|
|
200
|
+
let nodeContent;
|
|
201
|
+
if (d.options.customContent) {
|
|
202
|
+
nodeContent = h('<' + d.options.nodeContentSelector + '>', d.options.nodeContentAttributes);
|
|
203
|
+
|
|
204
|
+
if (d.options.enableLinks) {
|
|
205
|
+
nodeContent.attr("href", t.href);
|
|
206
|
+
}
|
|
207
|
+
nodeContent.append(t.text);
|
|
208
|
+
} else {
|
|
209
|
+
nodeContent = t.text;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Add content to the node, considering the enableLinks option
|
|
213
|
+
if (d.options.enableLinks) {
|
|
214
|
+
s.append(h(d.template.link).attr("href", t.href).append(nodeContent));
|
|
215
|
+
} else {
|
|
216
|
+
s.append(nodeContent);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Call the function to add a vertical line if defined
|
|
220
|
+
if (typeof d.options.addVerticalLine === 'function') {
|
|
221
|
+
d.options.addVerticalLine(s, t, d);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Custom badge handling
|
|
225
|
+
if (d.options.showTags && t.tags) {
|
|
226
|
+
n.empty();
|
|
227
|
+
if (typeof d.options.customizeBadges === 'function') {
|
|
228
|
+
d.options.customizeBadges(n, t, d);
|
|
229
|
+
} else {
|
|
230
|
+
h.each(t.tags, function(e, tag) {
|
|
231
|
+
n.append(h(d.template.badge).append(tag));
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
d.$wrapper.append(o);
|
|
237
|
+
if (t.nodes && t.state.expanded && !t.state.disabled) {
|
|
238
|
+
return d.buildTree(t.nodes, r);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}, i.prototype.buildStyleOverride = function(e) {
|
|
243
|
+
if (e.state.disabled) return "";
|
|
244
|
+
let t = e.color,
|
|
245
|
+
o = e.backColor;
|
|
246
|
+
return this.options.highlightSelected && e.state.selected && (this.options.selectedColor && (t = this.options.selectedColor), this.options.selectedBackColor && (o = this.options.selectedBackColor)), this.options.highlightSearchResults && e.searchResult && !e.state.disabled && (this.options.searchResultColor && (t = this.options.searchResultColor), this.options.searchResultBackColor && (o = this.options.searchResultBackColor)), "color:" + t + ";background-color:" + o + ";"
|
|
247
|
+
}, i.prototype.injectStyle = function() {
|
|
248
|
+
this.options.injectStyle && !e.getElementById(this.styleId) && h('<style type="text/css" id="' + this.styleId + '"> ' + this.buildStyle() + " </style>").appendTo("head")
|
|
249
|
+
}, i.prototype.buildStyle = function() {
|
|
250
|
+
let e = ".node-" + this.elementId + "{";
|
|
251
|
+
return this.options.color && (e += "color:" + this.options.color + ";"), this.options.backColor && (e += "background-color:" + this.options.backColor + ";"), this.options.showBorder ? this.options.borderColor && (e += "border:1px solid " + this.options.borderColor + ";") : e += "border:none;", e += "}", this.options.onhoverColor && (e += ".node-" + this.elementId + ":not(.node-disabled):hover{background-color:" + this.options.onhoverColor + ";}"), this.css + e
|
|
252
|
+
}, i.prototype.template = {
|
|
253
|
+
list: '<ul class="list-group"></ul>',
|
|
254
|
+
itemWrapper: '<li class="list-group-item d-flex justify-content-between align-items-start"></li>',
|
|
255
|
+
itemLeftElem: '<div class="w-100"></div>',
|
|
256
|
+
itemRightElem: "<div></div>",
|
|
257
|
+
indent: '<span class="mx-2"></span>',
|
|
258
|
+
icon: '<span class="icon"></span>',
|
|
259
|
+
link: '<a class="w-75" href="#" style="display:inline-block; color:inherit; text-decoration:none;"></a>',
|
|
260
|
+
badge: '<span class="ms-1 badge bg-primary rounded-pill"></span>'
|
|
261
|
+
}, i.prototype.css = ".treeview .list-group-item{cursor:pointer}.treeview span.icon{width:12px;margin-right:5px}.treeview .node-disabled{color:silver;cursor:not-allowed}", i.prototype.getNode = function(e) {
|
|
262
|
+
return this.nodes[e]
|
|
263
|
+
}, i.prototype.getParent = function(e) {
|
|
264
|
+
e = this.identifyNode(e);
|
|
265
|
+
return this.nodes[e.parentId]
|
|
266
|
+
}, i.prototype.getSiblings = function(e) {
|
|
267
|
+
let t = this.identifyNode(e);
|
|
268
|
+
e = this.getParent(t);
|
|
269
|
+
let o = e ? e.nodes : this.tree;
|
|
270
|
+
return o.filter(function(e) {
|
|
271
|
+
return e.nodeId !== t.nodeId
|
|
272
|
+
})
|
|
273
|
+
}, i.prototype.getSelected = function() {
|
|
274
|
+
return this.findNodes("true", "g", "state.selected")
|
|
275
|
+
}, i.prototype.getUnselected = function() {
|
|
276
|
+
return this.findNodes("false", "g", "state.selected")
|
|
277
|
+
}, i.prototype.getExpanded = function() {
|
|
278
|
+
return this.findNodes("true", "g", "state.expanded")
|
|
279
|
+
}, i.prototype.getCollapsed = function() {
|
|
280
|
+
return this.findNodes("false", "g", "state.expanded")
|
|
281
|
+
}, i.prototype.getChecked = function() {
|
|
282
|
+
return this.findNodes("true", "g", "state.checked")
|
|
283
|
+
}, i.prototype.getUnchecked = function() {
|
|
284
|
+
return this.findNodes("false", "g", "state.checked")
|
|
285
|
+
}, i.prototype.getDisabled = function() {
|
|
286
|
+
return this.findNodes("true", "g", "state.disabled")
|
|
287
|
+
}, i.prototype.getEnabled = function() {
|
|
288
|
+
return this.findNodes("false", "g", "state.disabled")
|
|
289
|
+
}, i.prototype.selectNode = function(e, t) {
|
|
290
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
291
|
+
this.setSelectedState(e, !0, t)
|
|
292
|
+
}, this)), this.render()
|
|
293
|
+
}, i.prototype.unselectNode = function(e, t) {
|
|
294
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
295
|
+
this.setSelectedState(e, !1, t)
|
|
296
|
+
}, this)), this.render()
|
|
297
|
+
}, i.prototype.toggleNodeSelected = function(e, t) {
|
|
298
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
299
|
+
this.toggleSelectedState(e, t)
|
|
300
|
+
}, this)), this.render()
|
|
301
|
+
}, i.prototype.collapseAll = function(e) {
|
|
302
|
+
var t = this.findNodes("true", "g", "state.expanded");
|
|
303
|
+
this.forEachIdentifier(t, e, h.proxy(function(e, t) {
|
|
304
|
+
this.setExpandedState(e, !1, t)
|
|
305
|
+
}, this)), this.render()
|
|
306
|
+
}, i.prototype.collapseNode = function(e, t) {
|
|
307
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
308
|
+
this.setExpandedState(e, !1, t)
|
|
309
|
+
}, this)), this.render()
|
|
310
|
+
}, i.prototype.expandAll = function(e) {
|
|
311
|
+
var t;
|
|
312
|
+
(e = h.extend({}, l.options, e)) && e.levels ? this.expandLevels(this.tree, e.levels, e) : (t = this.findNodes("false", "g", "state.expanded"), this.forEachIdentifier(t, e, h.proxy(function(e, t) {
|
|
313
|
+
this.setExpandedState(e, !0, t)
|
|
314
|
+
}, this))), this.render()
|
|
315
|
+
}, i.prototype.expandNode = function(e, t) {
|
|
316
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
317
|
+
this.setExpandedState(e, !0, t), e.nodes && t && t.levels && this.expandLevels(e.nodes, t.levels - 1, t)
|
|
318
|
+
}, this)), this.render()
|
|
319
|
+
}, i.prototype.expandLevels = function(e, o, s) {
|
|
320
|
+
s = h.extend({}, l.options, s), h.each(e, h.proxy(function(e, t) {
|
|
321
|
+
this.setExpandedState(t, 0 < o, s), t.nodes && this.expandLevels(t.nodes, o - 1, s)
|
|
322
|
+
}, this))
|
|
323
|
+
}, i.prototype.revealNode = function(e, t) {
|
|
324
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
325
|
+
let o = this.getParent(e);
|
|
326
|
+
for (; o;) this.setExpandedState(o, !0, t), o = this.getParent(o)
|
|
327
|
+
}, this)), this.render()
|
|
328
|
+
}, i.prototype.toggleNodeExpanded = function(e, t) {
|
|
329
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
330
|
+
this.toggleExpandedState(e, t)
|
|
331
|
+
}, this)), this.render()
|
|
332
|
+
}, i.prototype.checkAll = function(e) {
|
|
333
|
+
var t = this.findNodes("false", "g", "state.checked");
|
|
334
|
+
this.forEachIdentifier(t, e, h.proxy(function(e, t) {
|
|
335
|
+
this.setCheckedState(e, !0, t)
|
|
336
|
+
}, this)), this.render()
|
|
337
|
+
}, i.prototype.checkNode = function(e, t) {
|
|
338
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
339
|
+
this.setCheckedState(e, !0, t)
|
|
340
|
+
}, this)), this.render()
|
|
341
|
+
}, i.prototype.uncheckAll = function(e) {
|
|
342
|
+
var t = this.findNodes("true", "g", "state.checked");
|
|
343
|
+
this.forEachIdentifier(t, e, h.proxy(function(e, t) {
|
|
344
|
+
this.setCheckedState(e, !1, t)
|
|
345
|
+
}, this)), this.render()
|
|
346
|
+
}, i.prototype.uncheckNode = function(e, t) {
|
|
347
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
348
|
+
this.setCheckedState(e, !1, t)
|
|
349
|
+
}, this)), this.render()
|
|
350
|
+
}, i.prototype.toggleNodeChecked = function(e, t) {
|
|
351
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
352
|
+
this.toggleCheckedState(e, t)
|
|
353
|
+
}, this)), this.render()
|
|
354
|
+
}, i.prototype.disableAll = function(e) {
|
|
355
|
+
var t = this.findNodes("false", "g", "state.disabled");
|
|
356
|
+
this.forEachIdentifier(t, e, h.proxy(function(e, t) {
|
|
357
|
+
this.setDisabledState(e, !0, t)
|
|
358
|
+
}, this)), this.render()
|
|
359
|
+
}, i.prototype.disableNode = function(e, t) {
|
|
360
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
361
|
+
this.setDisabledState(e, !0, t)
|
|
362
|
+
}, this)), this.render()
|
|
363
|
+
}, i.prototype.enableAll = function(e) {
|
|
364
|
+
var t = this.findNodes("true", "g", "state.disabled");
|
|
365
|
+
this.forEachIdentifier(t, e, h.proxy(function(e, t) {
|
|
366
|
+
this.setDisabledState(e, !1, t)
|
|
367
|
+
}, this)), this.render()
|
|
368
|
+
}, i.prototype.enableNode = function(e, t) {
|
|
369
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
370
|
+
this.setDisabledState(e, !1, t)
|
|
371
|
+
}, this)), this.render()
|
|
372
|
+
}, i.prototype.toggleNodeDisabled = function(e, t) {
|
|
373
|
+
this.forEachIdentifier(e, t, h.proxy(function(e, t) {
|
|
374
|
+
this.setDisabledState(e, !e.state.disabled, t)
|
|
375
|
+
}, this)), this.render()
|
|
376
|
+
}, i.prototype.forEachIdentifier = function(e, o, s) {
|
|
377
|
+
o = h.extend({}, l.options, o), e instanceof Array || (e = [e]), h.each(e, h.proxy(function(e, t) {
|
|
378
|
+
s(this.identifyNode(t), o)
|
|
379
|
+
}, this))
|
|
380
|
+
}, i.prototype.identifyNode = function(e) {
|
|
381
|
+
return "number" == typeof e ? this.nodes[e] : e
|
|
382
|
+
}, i.prototype.search = function(t, o) {
|
|
383
|
+
o = h.extend({}, l.searchOptions, o), this.clearSearch({
|
|
384
|
+
render: !1
|
|
385
|
+
});
|
|
386
|
+
let s = [];
|
|
387
|
+
if (t && 0 < t.length) {
|
|
388
|
+
o.exactMatch && (t = "^" + t + "$");
|
|
389
|
+
let e = "g";
|
|
390
|
+
o.ignoreCase && (e += "i"), s = this.findNodes(t, e), h.each(s, function(e, t) {
|
|
391
|
+
t.searchResult = !0
|
|
392
|
+
})
|
|
393
|
+
}
|
|
394
|
+
return o.revealResults ? this.revealNode(s) : this.render(), this.$element.trigger("searchComplete", h.extend(!0, {}, s)), s
|
|
395
|
+
}, i.prototype.clearSearch = function(e) {
|
|
396
|
+
e = h.extend({}, {
|
|
397
|
+
render: !0
|
|
398
|
+
}, e);
|
|
399
|
+
var t = h.each(this.findNodes("true", "g", "searchResult"), function(e, t) {
|
|
400
|
+
t.searchResult = !1
|
|
401
|
+
});
|
|
402
|
+
e.render && this.render(), this.$element.trigger("searchCleared", h.extend(!0, {}, t))
|
|
403
|
+
}, i.prototype.findNodes = function(o, s, n) {
|
|
404
|
+
s = s || "g", n = n || "text";
|
|
405
|
+
let i = this;
|
|
406
|
+
return h.grep(this.nodes, function(e) {
|
|
407
|
+
let t = i.getNodeValue(e, n);
|
|
408
|
+
if ("string" == typeof t) return t.match(new RegExp(o, s))
|
|
409
|
+
})
|
|
410
|
+
}, i.prototype.getNodeValue = function(e, t) {
|
|
411
|
+
var o, s = t.indexOf(".");
|
|
412
|
+
return 0 < s ? (o = e[t.substring(0, s)], s = t.substring(s + 1, t.length), this.getNodeValue(o, s)) : e.hasOwnProperty(t) ? e[t].toString() : n
|
|
413
|
+
};
|
|
414
|
+
h.fn[r] = function(t, o) {
|
|
415
|
+
let s;
|
|
416
|
+
return this.each(function() {
|
|
417
|
+
let e = h.data(this, r);
|
|
418
|
+
"string" == typeof t ? e ? h.isFunction(e[t]) && "_" !== t.charAt(0) ? (o instanceof Array || (o = [o]), s = e[t].apply(e, o)) : d("No such method : " + t) : d("Not initialized, can not call method : " + t) : "boolean" == typeof t ? s = e : h.data(this, r, new i(this, h.extend(!0, {}, t)))
|
|
419
|
+
}), s || this
|
|
420
|
+
}
|
|
421
|
+
}(jQuery, window, document);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t,o,s){"use strict";function n(t,o){return this.$element=e(t),this.elementId=t.id,this.styleId=this.elementId+"-style",this.init(o),{options:this.options,init:e.proxy(this.init,this),remove:e.proxy(this.remove,this),getNode:e.proxy(this.getNode,this),getParent:e.proxy(this.getParent,this),getSiblings:e.proxy(this.getSiblings,this),getSelected:e.proxy(this.getSelected,this),getUnselected:e.proxy(this.getUnselected,this),getExpanded:e.proxy(this.getExpanded,this),getCollapsed:e.proxy(this.getCollapsed,this),getChecked:e.proxy(this.getChecked,this),getUnchecked:e.proxy(this.getUnchecked,this),getDisabled:e.proxy(this.getDisabled,this),getEnabled:e.proxy(this.getEnabled,this),selectNode:e.proxy(this.selectNode,this),unselectNode:e.proxy(this.unselectNode,this),toggleNodeSelected:e.proxy(this.toggleNodeSelected,this),collapseAll:e.proxy(this.collapseAll,this),collapseNode:e.proxy(this.collapseNode,this),expandAll:e.proxy(this.expandAll,this),expandNode:e.proxy(this.expandNode,this),toggleNodeExpanded:e.proxy(this.toggleNodeExpanded,this),revealNode:e.proxy(this.revealNode,this),checkAll:e.proxy(this.checkAll,this),checkNode:e.proxy(this.checkNode,this),uncheckAll:e.proxy(this.uncheckAll,this),uncheckNode:e.proxy(this.uncheckNode,this),toggleNodeChecked:e.proxy(this.toggleNodeChecked,this),disableAll:e.proxy(this.disableAll,this),disableNode:e.proxy(this.disableNode,this),enableAll:e.proxy(this.enableAll,this),enableNode:e.proxy(this.enableNode,this),toggleNodeDisabled:e.proxy(this.toggleNodeDisabled,this),search:e.proxy(this.search,this),clearSearch:e.proxy(this.clearSearch,this)}}function i(e){t.console&&t.console.error(e)}let d="treeview",r={};r.settings={injectStyle:!0,levels:2,expandIcon:"fa fa-chevron-right",collapseIcon:"fa fa-chevron-down",emptyIcon:"fa",nodeIcon:"",selectedIcon:"",checkedIcon:"fa fa-check-circle-o",uncheckedIcon:"fa fa-circle-thin",color:s,backColor:s,borderColor:s,onhoverColor:"#F5F5F5",selectedColor:"#005A20",selectedBackColor:"#EDEFE9",searchResultColor:"#D9534F",searchResultBackColor:s,enableLinks:!1,enableIndent:!0,highlightSelected:!0,highlightSearchResults:!0,showBorder:!0,showIcon:!0,showCheckbox:!1,showTags:!1,multiSelect:!1,customizeNode:null,addVerticalLine:null,customizeBadges:null,customContent:!1,nodeContentSelector:"span",nodeContentAttributes:{},onNodeChecked:s,onNodeCollapsed:s,onNodeDisabled:s,onNodeEnabled:s,onNodeExpanded:s,onNodeSelected:s,onNodeUnchecked:s,onNodeUnselected:s,onSearchComplete:s,onSearchCleared:s},r.options={silent:!1,ignoreChildren:!1},r.searchOptions={ignoreCase:!0,exactMatch:!1,revealResults:!0},n.prototype.init=function(t){this.tree=[],this.nodes=[],t.data&&("string"==typeof t.data&&(t.data=e.parseJSON(t.data)),this.tree=e.extend(!0,[],t.data),delete t.data),this.options=e.extend({},r.settings,t),this.destroy(),this.subscribeEvents(),this.setInitialStates({nodes:this.tree},0),this.render()},n.prototype.remove=function(){this.destroy(),e.removeData(this,d),e("#"+this.styleId).remove()},n.prototype.destroy=function(){this.initialized&&(this.$wrapper.remove(),this.$wrapper=null,this.unsubscribeEvents(),this.initialized=!1)},n.prototype.unsubscribeEvents=function(){this.$element.off("click"),this.$element.off("nodeChecked"),this.$element.off("nodeCollapsed"),this.$element.off("nodeDisabled"),this.$element.off("nodeEnabled"),this.$element.off("nodeExpanded"),this.$element.off("nodeSelected"),this.$element.off("nodeUnchecked"),this.$element.off("nodeUnselected"),this.$element.off("searchComplete"),this.$element.off("searchCleared")},n.prototype.subscribeEvents=function(){this.unsubscribeEvents(),this.$element.on("click",e.proxy(this.clickHandler,this)),"function"==typeof this.options.onNodeChecked&&this.$element.on("nodeChecked",this.options.onNodeChecked),"function"==typeof this.options.onNodeCollapsed&&this.$element.on("nodeCollapsed",this.options.onNodeCollapsed),"function"==typeof this.options.onNodeDisabled&&this.$element.on("nodeDisabled",this.options.onNodeDisabled),"function"==typeof this.options.onNodeEnabled&&this.$element.on("nodeEnabled",this.options.onNodeEnabled),"function"==typeof this.options.onNodeExpanded&&this.$element.on("nodeExpanded",this.options.onNodeExpanded),"function"==typeof this.options.onNodeSelected&&this.$element.on("nodeSelected",this.options.onNodeSelected),"function"==typeof this.options.onNodeUnchecked&&this.$element.on("nodeUnchecked",this.options.onNodeUnchecked),"function"==typeof this.options.onNodeUnselected&&this.$element.on("nodeUnselected",this.options.onNodeUnselected),"function"==typeof this.options.onSearchComplete&&this.$element.on("searchComplete",this.options.onSearchComplete),"function"==typeof this.options.onSearchCleared&&this.$element.on("searchCleared",this.options.onSearchCleared)},n.prototype.setInitialStates=function(t,o){if(t.nodes){o+=1;let s=t,n=this;e.each(t.nodes,function(e,t){t.nodeId=n.nodes.length,t.parentId=s.nodeId,t.hasOwnProperty("selectable")||(t.selectable=!1),t.state=t.state||{},t.state.hasOwnProperty("checked")||(t.state.checked=!1),t.state.hasOwnProperty("disabled")||(t.state.disabled=!1),t.state.hasOwnProperty("expanded")||(!t.state.disabled&&o<n.options.levels&&t.nodes&&0<t.nodes.length?t.state.expanded=!0:t.state.expanded=!1),t.state.hasOwnProperty("selected")||(t.state.selected=!1),n.nodes.push(t),t.nodes&&n.setInitialStates(t,o)})}},n.prototype.clickHandler=function(t){this.options.enableLinks||t.preventDefault();let o=e(t.target);if((t=this.findNode(o))&&!t.state.disabled){let s=o.attr("class")?o.attr("class").split(" "):[];-1!==s.indexOf("expand-icon")?this.toggleExpandedState(t,r.options):-1!==s.indexOf("check-icon")?this.toggleCheckedState(t,r.options):t.selectable?this.toggleSelectedState(t,r.options):this.toggleExpandedState(t,r.options),this.render()}},n.prototype.findNode=function(e){return e=e.closest("li.list-group-item").attr("data-nodeid"),(e=this.nodes[e])||console.log("Error: node does not exist"),e},n.prototype.toggleExpandedState=function(e,t){e&&this.setExpandedState(e,!e.state.expanded,t)},n.prototype.setExpandedState=function(t,o,s){o!==t.state.expanded&&(o&&t.nodes?(t.state.expanded=!0,s.silent||this.$element.trigger("nodeExpanded",e.extend(!0,{},t))):o||(t.state.expanded=!1,s.silent||this.$element.trigger("nodeCollapsed",e.extend(!0,{},t)),t.nodes&&!s.ignoreChildren&&e.each(t.nodes,e.proxy(function(e,t){this.setExpandedState(t,!1,s)},this))))},n.prototype.toggleSelectedState=function(e,t){e&&this.setSelectedState(e,!e.state.selected,t)},n.prototype.setSelectedState=function(t,o,s){o!==t.state.selected&&(o?(this.options.multiSelect||e.each(this.findNodes("true","g","state.selected"),e.proxy(function(e,t){this.setSelectedState(t,!1,s)},this)),t.state.selected=!0,s.silent||this.$element.trigger("nodeSelected",e.extend(!0,{},t))):(t.state.selected=!1,s.silent||this.$element.trigger("nodeUnselected",e.extend(!0,{},t))))},n.prototype.toggleCheckedState=function(e,t){e&&this.setCheckedState(e,!e.state.checked,t)},n.prototype.setCheckedState=function(t,o,s){o!==t.state.checked&&(o?(t.state.checked=!0,s.silent||this.$element.trigger("nodeChecked",e.extend(!0,{},t))):(t.state.checked=!1,s.silent||this.$element.trigger("nodeUnchecked",e.extend(!0,{},t))))},n.prototype.setDisabledState=function(t,o,s){o!==t.state.disabled&&(o?(t.state.disabled=!0,this.setExpandedState(t,!1,s),this.setSelectedState(t,!1,s),this.setCheckedState(t,!1,s),s.silent||this.$element.trigger("nodeDisabled",e.extend(!0,{},t))):(t.state.disabled=!1,s.silent||this.$element.trigger("nodeEnabled",e.extend(!0,{},t))))},n.prototype.render=function(){this.initialized||(this.$element.addClass(d),this.$wrapper=e(this.template.list),this.injectStyle(),this.initialized=!0),this.$element.empty().append(this.$wrapper.empty()),this.buildTree(this.tree,0)},n.prototype.buildTree=function(t,o){if(t){o+=1;let s=this;e.each(t,function(t,n){let i=e(s.template.itemWrapper).addClass("node-"+s.elementId).addClass(n.state.checked?"node-checked":"").addClass(n.state.disabled?"node-disabled":"").addClass(n.state.selected?"node-selected":"").addClass(n.searchResult?"search-result":"").attr("data-nodeid",n.nodeId).attr("style",s.buildStyleOverride(n)),d=e(s.template.itemLeftElem),r=e(s.template.itemRightElem);if("function"==typeof s.options.customizeNode&&s.options.customizeNode(i,n,s),i.append(d).append(r),s.options.enableIndent)for(let l=0;l<o-1;l++)d.append(s.template.indent);if(n.nodes&&n.nodes.length>0){let a=["expand-icon"];if(a.push(n.state.expanded?s.options.collapseIcon:s.options.expandIcon),d.append(e(s.template.icon).addClass(a.join(" "))),s.options.showIcon){let h=["node-icon"];h.push(n.icon||s.options.nodeIcon),n.state.selected&&(h.pop(),h.push(n.selectedIcon||s.options.selectedIcon||n.icon||s.options.nodeIcon)),d.append(e(s.template.icon).addClass(h.join(" ")))}}if(s.options.showCheckbox){let c=["check-icon"];c.push(n.state.checked?s.options.checkedIcon:s.options.uncheckedIcon),d.append(e(s.template.icon).addClass(c.join(" ")))}let p;if(s.options.customContent?(p=e("<"+s.options.nodeContentSelector+">",s.options.nodeContentAttributes),s.options.enableLinks&&p.attr("href",n.href),p.append(n.text)):p=n.text,s.options.enableLinks?d.append(e(s.template.link).attr("href",n.href).append(p)):d.append(p),"function"==typeof s.options.addVerticalLine&&s.options.addVerticalLine(d,n,s),s.options.showTags&&n.tags&&(r.empty(),"function"==typeof s.options.customizeBadges?s.options.customizeBadges(r,n,s):e.each(n.tags,function(t,o){r.append(e(s.template.badge).append(o))})),s.$wrapper.append(i),n.nodes&&n.state.expanded&&!n.state.disabled)return s.buildTree(n.nodes,o)})}},n.prototype.buildStyleOverride=function(e){if(e.state.disabled)return"";let t=e.color,o=e.backColor;return this.options.highlightSelected&&e.state.selected&&(this.options.selectedColor&&(t=this.options.selectedColor),this.options.selectedBackColor&&(o=this.options.selectedBackColor)),this.options.highlightSearchResults&&e.searchResult&&!e.state.disabled&&(this.options.searchResultColor&&(t=this.options.searchResultColor),this.options.searchResultBackColor&&(o=this.options.searchResultBackColor)),"color:"+t+";background-color:"+o+";"},n.prototype.injectStyle=function(){this.options.injectStyle&&!o.getElementById(this.styleId)&&e('<style type="text/css" id="'+this.styleId+'"> '+this.buildStyle()+" </style>").appendTo("head")},n.prototype.buildStyle=function(){let e=".node-"+this.elementId+"{";return this.options.color&&(e+="color:"+this.options.color+";"),this.options.backColor&&(e+="background-color:"+this.options.backColor+";"),this.options.showBorder?this.options.borderColor&&(e+="border:1px solid "+this.options.borderColor+";"):e+="border:none;",e+="}",this.options.onhoverColor&&(e+=".node-"+this.elementId+":not(.node-disabled):hover{background-color:"+this.options.onhoverColor+";}"),this.css+e},n.prototype.template={list:'<ul class="list-group"></ul>',itemWrapper:'<li class="list-group-item d-flex justify-content-between align-items-start"></li>',itemLeftElem:'<div class="w-100"></div>',itemRightElem:"<div></div>",indent:'<span class="mx-2"></span>',icon:'<span class="icon"></span>',link:'<a class="w-75" href="#" style="display:inline-block; color:inherit; text-decoration:none;"></a>',badge:'<span class="ms-1 badge bg-primary rounded-pill"></span>'},n.prototype.css=".treeview .list-group-item{cursor:pointer}.treeview span.icon{width:12px;margin-right:5px}.treeview .node-disabled{color:silver;cursor:not-allowed}",n.prototype.getNode=function(e){return this.nodes[e]},n.prototype.getParent=function(e){return e=this.identifyNode(e),this.nodes[e.parentId]},n.prototype.getSiblings=function(e){let t=this.identifyNode(e);return((e=this.getParent(t))?e.nodes:this.tree).filter(function(e){return e.nodeId!==t.nodeId})},n.prototype.getSelected=function(){return this.findNodes("true","g","state.selected")},n.prototype.getUnselected=function(){return this.findNodes("false","g","state.selected")},n.prototype.getExpanded=function(){return this.findNodes("true","g","state.expanded")},n.prototype.getCollapsed=function(){return this.findNodes("false","g","state.expanded")},n.prototype.getChecked=function(){return this.findNodes("true","g","state.checked")},n.prototype.getUnchecked=function(){return this.findNodes("false","g","state.checked")},n.prototype.getDisabled=function(){return this.findNodes("true","g","state.disabled")},n.prototype.getEnabled=function(){return this.findNodes("false","g","state.disabled")},n.prototype.selectNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setSelectedState(e,!0,t)},this)),this.render()},n.prototype.unselectNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setSelectedState(e,!1,t)},this)),this.render()},n.prototype.toggleNodeSelected=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.toggleSelectedState(e,t)},this)),this.render()},n.prototype.collapseAll=function(t){var o=this.findNodes("true","g","state.expanded");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setExpandedState(e,!1,t)},this)),this.render()},n.prototype.collapseNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setExpandedState(e,!1,t)},this)),this.render()},n.prototype.expandAll=function(t){var o;(t=e.extend({},r.options,t))&&t.levels?this.expandLevels(this.tree,t.levels,t):(o=this.findNodes("false","g","state.expanded"),this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setExpandedState(e,!0,t)},this))),this.render()},n.prototype.expandNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setExpandedState(e,!0,t),e.nodes&&t&&t.levels&&this.expandLevels(e.nodes,t.levels-1,t)},this)),this.render()},n.prototype.expandLevels=function(t,o,s){s=e.extend({},r.options,s),e.each(t,e.proxy(function(e,t){this.setExpandedState(t,0<o,s),t.nodes&&this.expandLevels(t.nodes,o-1,s)},this))},n.prototype.revealNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){let o=this.getParent(e);for(;o;)this.setExpandedState(o,!0,t),o=this.getParent(o)},this)),this.render()},n.prototype.toggleNodeExpanded=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.toggleExpandedState(e,t)},this)),this.render()},n.prototype.checkAll=function(t){var o=this.findNodes("false","g","state.checked");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setCheckedState(e,!0,t)},this)),this.render()},n.prototype.checkNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setCheckedState(e,!0,t)},this)),this.render()},n.prototype.uncheckAll=function(t){var o=this.findNodes("true","g","state.checked");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setCheckedState(e,!1,t)},this)),this.render()},n.prototype.uncheckNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setCheckedState(e,!1,t)},this)),this.render()},n.prototype.toggleNodeChecked=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.toggleCheckedState(e,t)},this)),this.render()},n.prototype.disableAll=function(t){var o=this.findNodes("false","g","state.disabled");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setDisabledState(e,!0,t)},this)),this.render()},n.prototype.disableNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setDisabledState(e,!0,t)},this)),this.render()},n.prototype.enableAll=function(t){var o=this.findNodes("true","g","state.disabled");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setDisabledState(e,!1,t)},this)),this.render()},n.prototype.enableNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setDisabledState(e,!1,t)},this)),this.render()},n.prototype.toggleNodeDisabled=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setDisabledState(e,!e.state.disabled,t)},this)),this.render()},n.prototype.forEachIdentifier=function(t,o,s){o=e.extend({},r.options,o),t instanceof Array||(t=[t]),e.each(t,e.proxy(function(e,t){s(this.identifyNode(t),o)},this))},n.prototype.identifyNode=function(e){return"number"==typeof e?this.nodes[e]:e},n.prototype.search=function(t,o){o=e.extend({},r.searchOptions,o),this.clearSearch({render:!1});let s=[];if(t&&0<t.length){o.exactMatch&&(t="^"+t+"$");let n="g";o.ignoreCase&&(n+="i"),s=this.findNodes(t,n),e.each(s,function(e,t){t.searchResult=!0})}return o.revealResults?this.revealNode(s):this.render(),this.$element.trigger("searchComplete",e.extend(!0,{},s)),s},n.prototype.clearSearch=function(t){t=e.extend({},{render:!0},t);var o=e.each(this.findNodes("true","g","searchResult"),function(e,t){t.searchResult=!1});t.render&&this.render(),this.$element.trigger("searchCleared",e.extend(!0,{},o))},n.prototype.findNodes=function(t,o,s){o=o||"g",s=s||"text";let n=this;return e.grep(this.nodes,function(e){let i=n.getNodeValue(e,s);if("string"==typeof i)return i.match(RegExp(t,o))})},n.prototype.getNodeValue=function(e,t){var o,n=t.indexOf(".");return 0<n?(o=e[t.substring(0,n)],n=t.substring(n+1,t.length),this.getNodeValue(o,n)):e.hasOwnProperty(t)?e[t].toString():s},e.fn[d]=function(t,o){let s;return this.each(function(){let r=e.data(this,d);"string"==typeof t?r?e.isFunction(r[t])&&"_"!==t.charAt(0)?(o instanceof Array||(o=[o]),s=r[t].apply(r,o)):i("No such method : "+t):i("Not initialized, can not call method : "+t):"boolean"==typeof t?s=r:e.data(this,d,new n(this,e.extend(!0,{},t)))}),s||this}}(jQuery,window,document);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(h,t,e,n){"use strict";function i(e,t){return this.$element=h(e),this.elementId=e.id,this.styleId=this.elementId+"-style",this.init(t),{options:this.options,init:h.proxy(this.init,this),remove:h.proxy(this.remove,this),getNode:h.proxy(this.getNode,this),getParent:h.proxy(this.getParent,this),getSiblings:h.proxy(this.getSiblings,this),getSelected:h.proxy(this.getSelected,this),getUnselected:h.proxy(this.getUnselected,this),getExpanded:h.proxy(this.getExpanded,this),getCollapsed:h.proxy(this.getCollapsed,this),getChecked:h.proxy(this.getChecked,this),getUnchecked:h.proxy(this.getUnchecked,this),getDisabled:h.proxy(this.getDisabled,this),getEnabled:h.proxy(this.getEnabled,this),selectNode:h.proxy(this.selectNode,this),unselectNode:h.proxy(this.unselectNode,this),toggleNodeSelected:h.proxy(this.toggleNodeSelected,this),collapseAll:h.proxy(this.collapseAll,this),collapseNode:h.proxy(this.collapseNode,this),expandAll:h.proxy(this.expandAll,this),expandNode:h.proxy(this.expandNode,this),toggleNodeExpanded:h.proxy(this.toggleNodeExpanded,this),revealNode:h.proxy(this.revealNode,this),checkAll:h.proxy(this.checkAll,this),checkNode:h.proxy(this.checkNode,this),uncheckAll:h.proxy(this.uncheckAll,this),uncheckNode:h.proxy(this.uncheckNode,this),toggleNodeChecked:h.proxy(this.toggleNodeChecked,this),disableAll:h.proxy(this.disableAll,this),disableNode:h.proxy(this.disableNode,this),enableAll:h.proxy(this.enableAll,this),enableNode:h.proxy(this.enableNode,this),toggleNodeDisabled:h.proxy(this.toggleNodeDisabled,this),search:h.proxy(this.search,this),clearSearch:h.proxy(this.clearSearch,this)}}function d(e){t.console&&t.console.error(e)}let r="treeview",l={};l.settings={injectStyle:!0,levels:2,expandIcon:"fa fa-chevron-right",collapseIcon:"fa fa-chevron-down",emptyIcon:"fa",nodeIcon:"",selectedIcon:"",checkedIcon:"fa fa-check-circle-o",uncheckedIcon:"fa fa-circle-thin",color:n,backColor:n,borderColor:n,onhoverColor:"#F5F5F5",selectedColor:"#3498DB",selectedBackColor:"#E7F2FF",searchResultColor:"#D9534F",searchResultBackColor:n,enableLinks:!1,enableIndent:!0,highlightSelected:!0,highlightSearchResults:!0,showBorder:!0,showIcon:!0,showCheckbox:!1,showTags:!1,multiSelect:!1,onNodeChecked:n,onNodeCollapsed:n,onNodeDisabled:n,onNodeEnabled:n,onNodeExpanded:n,onNodeSelected:n,onNodeUnchecked:n,onNodeUnselected:n,onSearchComplete:n,onSearchCleared:n},l.options={silent:!1,ignoreChildren:!1},l.searchOptions={ignoreCase:!0,exactMatch:!1,revealResults:!0},i.prototype.init=function(e){this.tree=[],this.nodes=[],e.data&&("string"==typeof e.data&&(e.data=h.parseJSON(e.data)),this.tree=h.extend(!0,[],e.data),delete e.data),this.options=h.extend({},l.settings,e),this.destroy(),this.subscribeEvents(),this.setInitialStates({nodes:this.tree},0),this.render()},i.prototype.remove=function(){this.destroy(),h.removeData(this,r),h("#"+this.styleId).remove()},i.prototype.destroy=function(){this.initialized&&(this.$wrapper.remove(),this.$wrapper=null,this.unsubscribeEvents(),this.initialized=!1)},i.prototype.unsubscribeEvents=function(){this.$element.off("click"),this.$element.off("nodeChecked"),this.$element.off("nodeCollapsed"),this.$element.off("nodeDisabled"),this.$element.off("nodeEnabled"),this.$element.off("nodeExpanded"),this.$element.off("nodeSelected"),this.$element.off("nodeUnchecked"),this.$element.off("nodeUnselected"),this.$element.off("searchComplete"),this.$element.off("searchCleared")},i.prototype.subscribeEvents=function(){this.unsubscribeEvents(),this.$element.on("click",h.proxy(this.clickHandler,this)),"function"==typeof this.options.onNodeChecked&&this.$element.on("nodeChecked",this.options.onNodeChecked),"function"==typeof this.options.onNodeCollapsed&&this.$element.on("nodeCollapsed",this.options.onNodeCollapsed),"function"==typeof this.options.onNodeDisabled&&this.$element.on("nodeDisabled",this.options.onNodeDisabled),"function"==typeof this.options.onNodeEnabled&&this.$element.on("nodeEnabled",this.options.onNodeEnabled),"function"==typeof this.options.onNodeExpanded&&this.$element.on("nodeExpanded",this.options.onNodeExpanded),"function"==typeof this.options.onNodeSelected&&this.$element.on("nodeSelected",this.options.onNodeSelected),"function"==typeof this.options.onNodeUnchecked&&this.$element.on("nodeUnchecked",this.options.onNodeUnchecked),"function"==typeof this.options.onNodeUnselected&&this.$element.on("nodeUnselected",this.options.onNodeUnselected),"function"==typeof this.options.onSearchComplete&&this.$element.on("searchComplete",this.options.onSearchComplete),"function"==typeof this.options.onSearchCleared&&this.$element.on("searchCleared",this.options.onSearchCleared)},i.prototype.setInitialStates=function(e,n){if(e.nodes){n+=1;let o=e,s=this;h.each(e.nodes,function(e,t){t.nodeId=s.nodes.length,t.parentId=o.nodeId,t.hasOwnProperty("selectable")||(t.selectable=!1),t.state=t.state||{},t.state.hasOwnProperty("checked")||(t.state.checked=!1),t.state.hasOwnProperty("disabled")||(t.state.disabled=!1),t.state.hasOwnProperty("expanded")||(!t.state.disabled&&n<s.options.levels&&t.nodes&&0<t.nodes.length?t.state.expanded=!0:t.state.expanded=!1),t.state.hasOwnProperty("selected")||(t.state.selected=!1),s.nodes.push(t),t.nodes&&s.setInitialStates(t,n)})}},i.prototype.clickHandler=function(t){this.options.enableLinks||t.preventDefault();let o=h(t.target);t=this.findNode(o);if(t&&!t.state.disabled){let e=o.attr("class")?o.attr("class").split(" "):[];-1!==e.indexOf("expand-icon")?this.toggleExpandedState(t,l.options):-1!==e.indexOf("check-icon")?this.toggleCheckedState(t,l.options):t.selectable?this.toggleSelectedState(t,l.options):this.toggleExpandedState(t,l.options),this.render()}},i.prototype.findNode=function(e){e=e.closest("li.list-group-item").attr("data-nodeid"),e=this.nodes[e];return e||console.log("Error: node does not exist"),e},i.prototype.toggleExpandedState=function(e,t){e&&this.setExpandedState(e,!e.state.expanded,t)},i.prototype.setExpandedState=function(e,t,o){t!==e.state.expanded&&(t&&e.nodes?(e.state.expanded=!0,o.silent||this.$element.trigger("nodeExpanded",h.extend(!0,{},e))):t||(e.state.expanded=!1,o.silent||this.$element.trigger("nodeCollapsed",h.extend(!0,{},e)),e.nodes&&!o.ignoreChildren&&h.each(e.nodes,h.proxy(function(e,t){this.setExpandedState(t,!1,o)},this))))},i.prototype.toggleSelectedState=function(e,t){e&&this.setSelectedState(e,!e.state.selected,t)},i.prototype.setSelectedState=function(e,t,o){t!==e.state.selected&&(t?(this.options.multiSelect||h.each(this.findNodes("true","g","state.selected"),h.proxy(function(e,t){this.setSelectedState(t,!1,o)},this)),e.state.selected=!0,o.silent||this.$element.trigger("nodeSelected",h.extend(!0,{},e))):(e.state.selected=!1,o.silent||this.$element.trigger("nodeUnselected",h.extend(!0,{},e))))},i.prototype.toggleCheckedState=function(e,t){e&&this.setCheckedState(e,!e.state.checked,t)},i.prototype.setCheckedState=function(e,t,o){t!==e.state.checked&&(t?(e.state.checked=!0,o.silent||this.$element.trigger("nodeChecked",h.extend(!0,{},e))):(e.state.checked=!1,o.silent||this.$element.trigger("nodeUnchecked",h.extend(!0,{},e))))},i.prototype.setDisabledState=function(e,t,o){t!==e.state.disabled&&(t?(e.state.disabled=!0,this.setExpandedState(e,!1,o),this.setSelectedState(e,!1,o),this.setCheckedState(e,!1,o),o.silent||this.$element.trigger("nodeDisabled",h.extend(!0,{},e))):(e.state.disabled=!1,o.silent||this.$element.trigger("nodeEnabled",h.extend(!0,{},e))))},i.prototype.render=function(){this.initialized||(this.$element.addClass(r),this.$wrapper=h(this.template.list),this.injectStyle(),this.initialized=!0),this.$element.empty().append(this.$wrapper.empty()),this.buildTree(this.tree,0)},i.prototype.buildTree=function(e,r){if(e){r+=1;let d=this;h.each(e,function(e,t){let o=h(d.template.itemWrapper).addClass("node-"+d.elementId).addClass(t.state.checked?"node-checked":"").addClass(t.state.disabled?"node-disabled":"").addClass(t.state.selected?"node-selected":"").addClass(t.searchResult?"search-result":"").attr("data-nodeid",t.nodeId).attr("style",d.buildStyleOverride(t)),s=h(d.template.itemLeftElem),n=h(d.template.itemRightElem);if(o.append(s),o.append(n),d.options.enableIndent)for(let e=0;e<r-1;e++)s.append(d.template.indent);let i=[];if(t.nodes?(i.push("expand-icon"),t.state.expanded?i.push(d.options.collapseIcon):i.push(d.options.expandIcon)):i.push(d.options.emptyIcon),s.append(h(d.template.icon).addClass(i.join(" "))),d.options.showIcon){let e=["node-icon"];e.push(t.icon||d.options.nodeIcon),t.state.selected&&(e.pop(),e.push(t.selectedIcon||d.options.selectedIcon||t.icon||d.options.nodeIcon)),s.append(h(d.template.icon).addClass(e.join(" ")))}if(d.options.showCheckbox){let e=["check-icon"];t.state.checked?e.push(d.options.checkedIcon):e.push(d.options.uncheckedIcon),s.append(h(d.template.icon).addClass(e.join(" ")))}if(d.options.enableLinks?s.append(h(d.template.link).attr("href",t.href).append(t.text)):s.append(t.text),d.options.showTags&&t.tags&&h.each(t.tags,function(e,t){n.append(h(d.template.badge).append(t))}),d.$wrapper.append(o),t.nodes&&t.state.expanded&&!t.state.disabled)return d.buildTree(t.nodes,r)})}},i.prototype.buildStyleOverride=function(e){if(e.state.disabled)return"";let t=e.color,o=e.backColor;return this.options.highlightSelected&&e.state.selected&&(this.options.selectedColor&&(t=this.options.selectedColor),this.options.selectedBackColor&&(o=this.options.selectedBackColor)),this.options.highlightSearchResults&&e.searchResult&&!e.state.disabled&&(this.options.searchResultColor&&(t=this.options.searchResultColor),this.options.searchResultBackColor&&(o=this.options.searchResultBackColor)),"color:"+t+";background-color:"+o+";"},i.prototype.injectStyle=function(){this.options.injectStyle&&!e.getElementById(this.styleId)&&h('<style type="text/css" id="'+this.styleId+'"> '+this.buildStyle()+" </style>").appendTo("head")},i.prototype.buildStyle=function(){let e=".node-"+this.elementId+"{";return this.options.color&&(e+="color:"+this.options.color+";"),this.options.backColor&&(e+="background-color:"+this.options.backColor+";"),this.options.showBorder?this.options.borderColor&&(e+="border:1px solid "+this.options.borderColor+";"):e+="border:none;",e+="}",this.options.onhoverColor&&(e+=".node-"+this.elementId+":not(.node-disabled):hover{background-color:"+this.options.onhoverColor+";}"),this.css+e},i.prototype.template={list:'<ul class="list-group"></ul>',itemWrapper:'<li class="list-group-item d-flex justify-content-between align-items-start"></li>',itemLeftElem:'<div class="w-100"></div>',itemRightElem:"<div></div>",indent:'<span class="mx-2"></span>',icon:'<span class="icon"></span>',link:'<a class="w-75" href="#" style="display:inline-block; color:inherit; text-decoration:none;"></a>',badge:'<span class="ms-1 badge bg-primary rounded-pill"></span>'},i.prototype.css=".treeview .list-group-item{cursor:pointer}.treeview span.icon{width:12px;margin-right:5px}.treeview .node-disabled{color:silver;cursor:not-allowed}",i.prototype.getNode=function(e){return this.nodes[e]},i.prototype.getParent=function(e){e=this.identifyNode(e);return this.nodes[e.parentId]},i.prototype.getSiblings=function(e){let t=this.identifyNode(e);e=this.getParent(t);let o=e?e.nodes:this.tree;return o.filter(function(e){return e.nodeId!==t.nodeId})},i.prototype.getSelected=function(){return this.findNodes("true","g","state.selected")},i.prototype.getUnselected=function(){return this.findNodes("false","g","state.selected")},i.prototype.getExpanded=function(){return this.findNodes("true","g","state.expanded")},i.prototype.getCollapsed=function(){return this.findNodes("false","g","state.expanded")},i.prototype.getChecked=function(){return this.findNodes("true","g","state.checked")},i.prototype.getUnchecked=function(){return this.findNodes("false","g","state.checked")},i.prototype.getDisabled=function(){return this.findNodes("true","g","state.disabled")},i.prototype.getEnabled=function(){return this.findNodes("false","g","state.disabled")},i.prototype.selectNode=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.setSelectedState(e,!0,t)},this)),this.render()},i.prototype.unselectNode=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.setSelectedState(e,!1,t)},this)),this.render()},i.prototype.toggleNodeSelected=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.toggleSelectedState(e,t)},this)),this.render()},i.prototype.collapseAll=function(e){var t=this.findNodes("true","g","state.expanded");this.forEachIdentifier(t,e,h.proxy(function(e,t){this.setExpandedState(e,!1,t)},this)),this.render()},i.prototype.collapseNode=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.setExpandedState(e,!1,t)},this)),this.render()},i.prototype.expandAll=function(e){var t;(e=h.extend({},l.options,e))&&e.levels?this.expandLevels(this.tree,e.levels,e):(t=this.findNodes("false","g","state.expanded"),this.forEachIdentifier(t,e,h.proxy(function(e,t){this.setExpandedState(e,!0,t)},this))),this.render()},i.prototype.expandNode=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.setExpandedState(e,!0,t),e.nodes&&t&&t.levels&&this.expandLevels(e.nodes,t.levels-1,t)},this)),this.render()},i.prototype.expandLevels=function(e,o,s){s=h.extend({},l.options,s),h.each(e,h.proxy(function(e,t){this.setExpandedState(t,0<o,s),t.nodes&&this.expandLevels(t.nodes,o-1,s)},this))},i.prototype.revealNode=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){let o=this.getParent(e);for(;o;)this.setExpandedState(o,!0,t),o=this.getParent(o)},this)),this.render()},i.prototype.toggleNodeExpanded=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.toggleExpandedState(e,t)},this)),this.render()},i.prototype.checkAll=function(e){var t=this.findNodes("false","g","state.checked");this.forEachIdentifier(t,e,h.proxy(function(e,t){this.setCheckedState(e,!0,t)},this)),this.render()},i.prototype.checkNode=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.setCheckedState(e,!0,t)},this)),this.render()},i.prototype.uncheckAll=function(e){var t=this.findNodes("true","g","state.checked");this.forEachIdentifier(t,e,h.proxy(function(e,t){this.setCheckedState(e,!1,t)},this)),this.render()},i.prototype.uncheckNode=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.setCheckedState(e,!1,t)},this)),this.render()},i.prototype.toggleNodeChecked=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.toggleCheckedState(e,t)},this)),this.render()},i.prototype.disableAll=function(e){var t=this.findNodes("false","g","state.disabled");this.forEachIdentifier(t,e,h.proxy(function(e,t){this.setDisabledState(e,!0,t)},this)),this.render()},i.prototype.disableNode=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.setDisabledState(e,!0,t)},this)),this.render()},i.prototype.enableAll=function(e){var t=this.findNodes("true","g","state.disabled");this.forEachIdentifier(t,e,h.proxy(function(e,t){this.setDisabledState(e,!1,t)},this)),this.render()},i.prototype.enableNode=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.setDisabledState(e,!1,t)},this)),this.render()},i.prototype.toggleNodeDisabled=function(e,t){this.forEachIdentifier(e,t,h.proxy(function(e,t){this.setDisabledState(e,!e.state.disabled,t)},this)),this.render()},i.prototype.forEachIdentifier=function(e,o,s){o=h.extend({},l.options,o),e instanceof Array||(e=[e]),h.each(e,h.proxy(function(e,t){s(this.identifyNode(t),o)},this))},i.prototype.identifyNode=function(e){return"number"==typeof e?this.nodes[e]:e},i.prototype.search=function(t,o){o=h.extend({},l.searchOptions,o),this.clearSearch({render:!1});let s=[];if(t&&0<t.length){o.exactMatch&&(t="^"+t+"$");let e="g";o.ignoreCase&&(e+="i"),s=this.findNodes(t,e),h.each(s,function(e,t){t.searchResult=!0})}return o.revealResults?this.revealNode(s):this.render(),this.$element.trigger("searchComplete",h.extend(!0,{},s)),s},i.prototype.clearSearch=function(e){e=h.extend({},{render:!0},e);var t=h.each(this.findNodes("true","g","searchResult"),function(e,t){t.searchResult=!1});e.render&&this.render(),this.$element.trigger("searchCleared",h.extend(!0,{},t))},i.prototype.findNodes=function(o,s,n){s=s||"g",n=n||"text";let i=this;return h.grep(this.nodes,function(e){let t=i.getNodeValue(e,n);if("string"==typeof t)return t.match(new RegExp(o,s))})},i.prototype.getNodeValue=function(e,t){var o,s=t.indexOf(".");return 0<s?(o=e[t.substring(0,s)],s=t.substring(s+1,t.length),this.getNodeValue(o,s)):e.hasOwnProperty(t)?e[t].toString():n};h.fn[r]=function(t,o){let s;return this.each(function(){let e=h.data(this,r);"string"==typeof t?e?h.isFunction(e[t])&&"_"!==t.charAt(0)?(o instanceof Array||(o=[o]),s=e[t].apply(e,o)):d("No such method : "+t):d("Not initialized, can not call method : "+t):"boolean"==typeof t?s=e:h.data(this,r,new i(this,h.extend(!0,{},t)))}),s||this}}(jQuery,window,document);
|