From ae6a4891e3fd874331dda661572aceb09a49fdb7 Mon Sep 17 00:00:00 2001 From: Nikita Manovich <40690625+nmanovic@users.noreply.github.com> Date: Tue, 23 Apr 2019 10:37:30 +0300 Subject: [PATCH] RESTful API (#389) --- .eslintrc.js | 5 + .vscode/launch.json | 87 +- CHANGELOG.md | 3 +- components/analytics/logstash/logstash.conf | 51 +- cvat/__init__.py | 5 + cvat/apps/authentication/auth.py | 68 + cvat/apps/auto_annotation/model_manager.py | 122 +- .../auto_annotation/js/dashboardPlugin.js | 54 +- cvat/apps/auto_annotation/views.py | 5 +- cvat/apps/dashboard/admin.py | 9 - cvat/apps/dashboard/apps.py | 6 +- cvat/apps/dashboard/models.py | 9 - .../dashboard/js/3rdparty/jstree/jstree.js | 8589 ----------------- .../js/3rdparty/jstree/jstree.min.js | 6 + .../jstree/themes/default-dark/32px.png | Bin 1562 -> 0 bytes .../jstree/themes/default-dark/40px.png | Bin 5717 -> 0 bytes .../jstree/themes/default-dark/style.css | 1152 --- .../jstree/themes/default-dark/throbber.gif | Bin 1720 -> 0 bytes .../3rdparty/jstree/themes/default/32px.png | Bin 3121 -> 5667 bytes .../3rdparty/jstree/themes/default/40px.png | Bin 1880 -> 2218 bytes .../3rdparty/jstree/themes/default/style.css | 1108 --- .../jstree/themes/default/style.min.css | 1 + .../jstree/themes/default/throbber.gif | Bin 1720 -> 1464 bytes .../js/3rdparty/pagination/pagination.css | 1 + .../js/3rdparty/pagination/pagination.min.js | 11 + .../static/dashboard/js/dashboard.js | 1253 ++- .../static/dashboard/js/enginePlugin.js | 7 +- .../dashboard/static/dashboard/stylesheet.css | 2 +- .../templates/dashboard/dashboard.html | 51 +- .../dashboard/templates/dashboard/task.html | 38 - cvat/apps/dashboard/tests.py | 7 - cvat/apps/dashboard/urls.py | 2 +- cvat/apps/dashboard/views.py | 67 +- cvat/apps/dextr_segmentation/dextr.py | 1 - cvat/apps/dextr_segmentation/views.py | 5 +- cvat/apps/documentation/__init__.py | 3 +- .../documentation/js/dashboardPlugin.js | 11 + .../static/documentation/js/shortcuts.js | 15 - cvat/apps/documentation/user_guide.md | 8 +- cvat/apps/engine/__init__.py | 2 + cvat/apps/engine/admin.py | 3 +- cvat/apps/engine/annotation.py | 2922 +++--- cvat/apps/engine/apps.py | 9 +- cvat/apps/engine/log.py | 3 +- .../migrations/0015_db_redesign_20190217.py | 212 + .../0016_attribute_spec_20190217.py | 172 + .../migrations/0017_db_redesign_20190221.py | 915 ++ cvat/apps/engine/migrations/0018_jobcommit.py | 31 + cvat/apps/engine/models.py | 325 +- cvat/apps/engine/serializers.py | 366 + cvat/apps/engine/signals.py | 19 + .../static/engine/js/3rdparty/defiant.js | 882 -- .../static/engine/js/3rdparty/defiant.min.js | 6 + .../static/engine/js/annotationParser.js | 435 +- .../static/engine/js/annotationSaver.js | 402 + .../engine/static/engine/js/annotationUI.js | 884 +- .../engine/js/attributeAnnotationMode.js | 243 +- cvat/apps/engine/static/engine/js/base.js | 271 +- .../apps/engine/static/engine/js/bootstrap.js | 28 +- .../engine/static/engine/js/checkPlatform.js | 5 +- .../static/engine/js/coordinateTranslator.js | 133 +- cvat/apps/engine/static/engine/js/history.js | 11 +- .../engine/static/engine/js/idGenerator.js | 36 - .../engine/static/engine/js/labelsInfo.js | 201 +- cvat/apps/engine/static/engine/js/logger.js | 343 +- cvat/apps/engine/static/engine/js/player.js | 405 +- .../engine/static/engine/js/qunitTests.js | 1108 +-- cvat/apps/engine/static/engine/js/server.js | 36 +- .../engine/static/engine/js/shapeBuffer.js | 41 +- .../static/engine/js/shapeCollection.js | 246 +- .../engine/static/engine/js/shapeCreator.js | 37 +- .../engine/static/engine/js/shapeFilter.js | 59 +- .../engine/static/engine/js/shapeMerger.js | 13 +- .../engine/static/engine/js/shapeSplitter.js | 94 +- cvat/apps/engine/static/engine/js/shapes.js | 172 +- .../engine/static/engine/js/userConfig.js | 294 +- cvat/apps/engine/task.py | 698 +- .../engine/templates/engine/annotation.html | 3 +- cvat/apps/engine/templates/engine/base.html | 1 - cvat/apps/engine/tests.py | 9 - cvat/apps/engine/tests/__init__.py | 0 cvat/apps/engine/tests/test_rest_api.py | 2194 +++++ cvat/apps/engine/urls.py | 52 +- cvat/apps/engine/views.py | 706 +- cvat/apps/git/git.py | 342 +- .../apps/git/static/git/js/dashboardPlugin.js | 449 +- cvat/apps/git/urls.py | 1 + cvat/apps/git/views.py | 27 +- cvat/apps/log_viewer/__init__.py | 2 +- .../static/log_viewer/js/dashboardPlugin.js | 11 + .../static/log_viewer/js/shortcuts.js | 15 - cvat/apps/reid/reid.py | 49 +- cvat/apps/reid/static/reid/js/enginePlugin.js | 168 +- cvat/apps/tf_annotation/__init__.py | 2 +- .../tf_annotation/js/dashboardPlugin.js | 112 + .../static/tf_annotation/js/tf_annotation.js | 134 - cvat/apps/tf_annotation/views.py | 46 +- cvat/requirements/all.txt | 4 + cvat/requirements/base.txt | 17 +- cvat/requirements/testing.txt | 2 + cvat/settings/base.py | 23 + cvat/settings/development.py | 2 + cvat/settings/staging.py | 3 +- cvat/settings/testing.py | 51 + cvat/simpleworker.py | 2 +- cvat/utils/version.py | 59 + tests/karma.conf.js | 3 +- 107 files changed, 10492 insertions(+), 18821 deletions(-) delete mode 100644 cvat/apps/dashboard/admin.py delete mode 100644 cvat/apps/dashboard/models.py delete mode 100644 cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/jstree.js create mode 100644 cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/jstree.min.js delete mode 100644 cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default-dark/32px.png delete mode 100644 cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default-dark/40px.png delete mode 100644 cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default-dark/style.css delete mode 100644 cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default-dark/throbber.gif delete mode 100644 cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/style.css create mode 100644 cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/style.min.css create mode 100644 cvat/apps/dashboard/static/dashboard/js/3rdparty/pagination/pagination.css create mode 100644 cvat/apps/dashboard/static/dashboard/js/3rdparty/pagination/pagination.min.js delete mode 100644 cvat/apps/dashboard/templates/dashboard/task.html delete mode 100644 cvat/apps/dashboard/tests.py create mode 100644 cvat/apps/documentation/static/documentation/js/dashboardPlugin.js delete mode 100644 cvat/apps/documentation/static/documentation/js/shortcuts.js create mode 100644 cvat/apps/engine/migrations/0015_db_redesign_20190217.py create mode 100644 cvat/apps/engine/migrations/0016_attribute_spec_20190217.py create mode 100644 cvat/apps/engine/migrations/0017_db_redesign_20190221.py create mode 100644 cvat/apps/engine/migrations/0018_jobcommit.py create mode 100644 cvat/apps/engine/serializers.py create mode 100644 cvat/apps/engine/signals.py delete mode 100644 cvat/apps/engine/static/engine/js/3rdparty/defiant.js create mode 100644 cvat/apps/engine/static/engine/js/3rdparty/defiant.min.js create mode 100644 cvat/apps/engine/static/engine/js/annotationSaver.js delete mode 100644 cvat/apps/engine/static/engine/js/idGenerator.js delete mode 100644 cvat/apps/engine/tests.py create mode 100644 cvat/apps/engine/tests/__init__.py create mode 100644 cvat/apps/engine/tests/test_rest_api.py create mode 100644 cvat/apps/log_viewer/static/log_viewer/js/dashboardPlugin.js delete mode 100644 cvat/apps/log_viewer/static/log_viewer/js/shortcuts.js create mode 100644 cvat/apps/tf_annotation/static/tf_annotation/js/dashboardPlugin.js delete mode 100644 cvat/apps/tf_annotation/static/tf_annotation/js/tf_annotation.js create mode 100644 cvat/requirements/all.txt create mode 100644 cvat/requirements/testing.txt create mode 100644 cvat/settings/testing.py create mode 100644 cvat/utils/version.py diff --git a/.eslintrc.js b/.eslintrc.js index 8572ce1d3987..48ef698e6cc3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -27,11 +27,16 @@ "airbnb", ], "rules": { + "no-new": [0], + "class-methods-use-this": [0], "no-restricted-properties": [0, { "object": "Math", "property": "pow", }], + "no-param-reassign": [0], "no-underscore-dangle": ["error", { "allowAfterThis": true }], + "no-restricted-syntax": [0, {"selector": "ForOfStatement"}], + "no-continue": [0], "no-unsafe-innerhtml/no-unsafe-innerhtml": 1, // This rule actual for user input data on the node.js environment mainly. "security/detect-object-injection": 0, diff --git a/.vscode/launch.json b/.vscode/launch.json index 745392455fa3..d801374388a2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "version": "0.2.0", "configurations": [ { - "name": "CVAT Server", + "name": "server", "type": "python", "request": "launch", "stopOnEntry": false, @@ -15,19 +15,14 @@ "args": [ "runserver", "--noreload", - "--nothreading", "--insecure", "127.0.0.1:7000" ], - "debugOptions": [ - "RedirectOutput", - "DjangoDebugging" - ], - "cwd": "${workspaceFolder}", - "envFile": "${workspaceFolder}/.env", + "django": true, + "cwd": "${workspaceFolder}" }, { - "name": "CVAT Client", + "name": "client", "type": "chrome", "request": "launch", "url": "http://localhost:7000/", @@ -40,7 +35,7 @@ } }, { - "name": "CVAT RQ - default", + "name": "RQ - default", "type": "python", "request": "launch", "stopOnEntry": false, @@ -53,17 +48,12 @@ "--worker-class", "cvat.simpleworker.SimpleWorker", ], - "debugOptions": [ - "RedirectOutput", - "DjangoDebugging" - ], + "django": true, "cwd": "${workspaceFolder}", - "env": {}, - "envFile": "${workspaceFolder}/.env", - + "env": {} }, { - "name": "CVAT RQ - low", + "name": "RQ - low", "type": "python", "request": "launch", "debugStdLib": true, @@ -76,16 +66,12 @@ "--worker-class", "cvat.simpleworker.SimpleWorker", ], - "debugOptions": [ - "RedirectOutput", - "DjangoDebugging" - ], + "django": true, "cwd": "${workspaceFolder}", - "env": {}, - "envFile": "${workspaceFolder}/.env", + "env": {} }, { - "name": "CVAT git", + "name": "git", "type": "python", "request": "launch", "debugStdLib": true, @@ -95,24 +81,53 @@ "args": [ "update_git_states" ], - "debugOptions": [ - "RedirectOutput", - "DjangoDebugging" + "django": true, + "cwd": "${workspaceFolder}", + "env": {} + }, + { + "name": "migrate", + "type": "python", + "request": "launch", + "debugStdLib": true, + "stopOnEntry": false, + "pythonPath": "${config:python.pythonPath}", + "program": "${workspaceRoot}/manage.py", + "args": [ + "migrate" + ], + "django": true, + "cwd": "${workspaceFolder}", + "env": {} + }, + { + "name": "tests", + "type": "python", + "request": "launch", + "debugStdLib": true, + "stopOnEntry": false, + "pythonPath": "${config:python.pythonPath}", + "program": "${workspaceRoot}/manage.py", + "args": [ + "test", + "--settings", + "cvat.settings.testing", + "cvat/apps/engine", ], + "django": true, "cwd": "${workspaceFolder}", - "env": {}, - "envFile": "${workspaceFolder}/.env", + "env": {} }, ], "compounds": [ { - "name": "CVAT Debugging", + "name": "debugging", "configurations": [ - "CVAT Client", - "CVAT Server", - "CVAT RQ - default", - "CVAT RQ - low", - "CVAT git", + "client", + "server", + "RQ - default", + "RQ - low", + "git", ] } ] diff --git a/CHANGELOG.md b/CHANGELOG.md index 87586550117d..80d87d45c0c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ability to rotate images/video in the client part (Ctrl+R, Shift+Ctrl+R shortcuts) (#305) - The ReID application for automatic bounding box merging has been added (#299) - Keyboard shortcuts to switch next/previous default shape type (box, polygon etc) [Alt + <, Alt + >] (#316) -- Converter for VOC now supports interpolation tracks +- Converter for VOC now supports interpolation tracks +- REST API (/api/v1/*, /api/docs) - Semi-automatic semantic segmentation with the [Deep Extreme Cut](http://www.vision.ee.ethz.ch/~cvlsegmentation/dextr/) work ### Changed diff --git a/components/analytics/logstash/logstash.conf b/components/analytics/logstash/logstash.conf index 34a9a0a30595..34f13a939e6b 100644 --- a/components/analytics/logstash/logstash.conf +++ b/components/analytics/logstash/logstash.conf @@ -10,34 +10,48 @@ filter { # 1. Decode the event from json in 'message' field # 2. Remove unnecessary field from it # 3. Type it as client + + mutate { + rename => { "message" => "source_message" } + } + json { - source => "message" + source => "source_message" } date { - match => ["timestamp", "UNIX", "UNIX_MS"] - remove_field => "timestamp" + match => ["time", "ISO8601"] + remove_field => "time" } - if [event] == "Send exception" { + if [payload] { + ruby { + code => " + event.get('payload').each { |key, value| + event.set(key, value) + } + " + } + } + + if [name] == "Send exception" { aggregate { - task_id => "%{userid}_%{application}_%{message}_%{filename}_%{line}" + task_id => "%{username}_%{message}_%{filename}_%{line}" code => " require 'time' - map['userid'] ||= event.get('userid'); - map['application'] ||= event.get('application'); + map['username'] ||= event.get('username'); map['error'] ||= event.get('message'); map['filename'] ||= event.get('filename'); map['line'] ||= event.get('line'); - map['task'] ||= event.get('task'); - + map['task_id'] ||= event.get('task_id'); + map['job_id'] ||= event.get('job_id'); map['error_count'] ||= 0; map['error_count'] += 1; map['aggregated_stack'] ||= ''; - map['aggregated_stack'] += event.get('stack') + '\n\n\n';" - + map['aggregated_stack'] += event.get('stack') + '\n\n\n'; + " timeout => 3600 timeout_tags => ['aggregated_exception'] push_map_as_event_on_timeout => true @@ -45,12 +59,17 @@ filter { } prune { - blacklist_names => ["level", "host", "logger_name", "message", "path", - "port", "stack_info"] + blacklist_names => ["level", "host", "logger_name", "path", + "port", "stack_info", "payload", "source_message"] } mutate { replace => { "type" => "client" } + copy => { + "job_id" => "task" + "username" => "userid" + "name" => "event" + } } } else if [logger_name] =~ /cvat.server/ { # 1. Remove 'logger_name' field and create 'task' field @@ -58,14 +77,14 @@ filter { # 3. Type it as server if [logger_name] =~ /cvat\.server\.task_[0-9]+/ { mutate { - rename => { "logger_name" => "task" } - gsub => [ "task", "cvat.server.task_", "" ] + rename => { "logger_name" => "task_id" } + gsub => [ "task_id", "cvat.server.task_", "" ] } # Need to split the mutate because otherwise the conversion # doesn't work. mutate { - convert => { "task" => "integer" } + convert => { "task_id" => "integer" } } } diff --git a/cvat/__init__.py b/cvat/__init__.py index d8e62e54b356..8171de4ad254 100644 --- a/cvat/__init__.py +++ b/cvat/__init__.py @@ -3,3 +3,8 @@ # # SPDX-License-Identifier: MIT +from cvat.utils.version import get_version + +VERSION = (0, 4, 0, 'alpha', 0) + +__version__ = get_version(VERSION) diff --git a/cvat/apps/authentication/auth.py b/cvat/apps/authentication/auth.py index 0da83216e8ed..0bb3296e9fea 100644 --- a/cvat/apps/authentication/auth.py +++ b/cvat/apps/authentication/auth.py @@ -4,8 +4,10 @@ import os from django.conf import settings +from django.db.models import Q import rules from . import AUTH_ROLE +from rest_framework.permissions import BasePermission def register_signals(): from django.db.models.signals import post_migrate, post_save @@ -67,6 +69,11 @@ def is_job_annotator(db_user, db_job): return has_rights # AUTH PERMISSIONS RULES +rules.add_perm('engine.role.user', has_user_role) +rules.add_perm('engine.role.admin', has_admin_role) +rules.add_perm('engine.role.annotator', has_annotator_role) +rules.add_perm('engine.role.observer', has_observer_role) + rules.add_perm('engine.task.create', has_admin_role | has_user_role) rules.add_perm('engine.task.access', has_admin_role | has_observer_role | is_task_owner | is_task_annotator) @@ -78,3 +85,64 @@ def is_job_annotator(db_user, db_job): is_job_owner | is_job_annotator) rules.add_perm('engine.job.change', has_admin_role | is_job_owner | is_job_annotator) + +class AdminRolePermission(BasePermission): + # pylint: disable=no-self-use + def has_permission(self, request, view): + return request.user.has_perm("engine.role.admin") + +class UserRolePermission(BasePermission): + # pylint: disable=no-self-use + def has_permission(self, request, view): + return request.user.has_perm("engine.role.user") + +class AnnotatorRolePermission(BasePermission): + # pylint: disable=no-self-use + def has_permission(self, request, view): + return request.user.has_perm("engine.role.annotator") + +class ObserverRolePermission(BasePermission): + # pylint: disable=no-self-use + def has_permission(self, request, view): + return request.user.has_perm("engine.role.observer") + +class TaskCreatePermission(BasePermission): + # pylint: disable=no-self-use + def has_permission(self, request, view): + return request.user.has_perm("engine.task.create") + +class TaskAccessPermission(BasePermission): + # pylint: disable=no-self-use + def has_object_permission(self, request, view, obj): + return request.user.has_perm("engine.task.access", obj) + +class TaskGetQuerySetMixin(object): + def get_queryset(self): + queryset = super().get_queryset() + user = self.request.user + # Don't filter queryset for admin, observer and detail methods + if has_admin_role(user) or has_observer_role(user) or self.detail: + return queryset + else: + return queryset.filter(Q(owner=user) | Q(assignee=user) | + Q(segment__job__assignee=user) | Q(assignee=None)).distinct() + +class TaskChangePermission(BasePermission): + # pylint: disable=no-self-use + def has_object_permission(self, request, view, obj): + return request.user.has_perm("engine.task.change", obj) + +class TaskDeletePermission(BasePermission): + # pylint: disable=no-self-use + def has_object_permission(self, request, view, obj): + return request.user.has_perm("engine.task.delete", obj) + +class JobAccessPermission(BasePermission): + # pylint: disable=no-self-use + def has_object_permission(self, request, view, obj): + return request.user.has_perm("engine.job.access", obj) + +class JobChangePermission(BasePermission): + # pylint: disable=no-self-use + def has_object_permission(self, request, view, obj): + return request.user.has_perm("engine.job.change", obj) diff --git a/cvat/apps/auto_annotation/model_manager.py b/cvat/apps/auto_annotation/model_manager.py index eef95628a59a..a72909b628b4 100644 --- a/cvat/apps/auto_annotation/model_manager.py +++ b/cvat/apps/auto_annotation/model_manager.py @@ -16,7 +16,8 @@ from cvat.apps.engine.log import slogger from cvat.apps.engine.models import Task as TaskModel -from cvat.apps.engine import annotation +from cvat.apps.engine.serializers import LabeledDataSerializer +from cvat.apps.engine.annotation import put_task_data, patch_task_data from .models import AnnotationModel, FrameworkChoice from .model_loader import ModelLoader @@ -208,71 +209,42 @@ def get_image_key(item): image_list.sort(key=get_image_key) return ImageLoader(image_list) -def create_anno_container(): - return { - "boxes": [], - "polygons": [], - "polylines": [], - "points": [], - "box_paths": [], - "polygon_paths": [], - "polyline_paths": [], - "points_paths": [], - } - class Results(): def __init__(self): - self._results = create_anno_container() + self._results = { + "shapes": [], + "tracks": [] + } def add_box(self, xtl, ytl, xbr, ybr, label, frame_number, attributes=None): - self.get_boxes().append({ + self.get_shapes().append({ "label": label, "frame": frame_number, - "xtl": xtl, - "ytl": ytl, - "xbr": xbr, - "ybr": ybr, + "points": [xtl, ytl, xbr, ybr], + "type": "rectangle", "attributes": attributes or {}, }) def add_points(self, points, label, frame_number, attributes=None): - self.get_points().append( - self._create_polyshape(points, label, frame_number, attributes) - ) + points = self._create_polyshape(points, label, frame_number, attributes) + points["type"] = "points" + self.get_shapes().append(points) def add_polygon(self, points, label, frame_number, attributes=None): - self.get_polygons().append( - self._create_polyshape(points, label, frame_number, attributes) - ) + polygon = self._create_polyshape(points, label, frame_number, attributes) + polygon["type"] = "polygon" + self.get_shapes().append(polygon) def add_polyline(self, points, label, frame_number, attributes=None): - self.get_polylines().append( - self._create_polyshape(points, label, frame_number, attributes) - ) - - def get_boxes(self): - return self._results["boxes"] - - def get_polygons(self): - return self._results["polygons"] - - def get_polylines(self): - return self._results["polylines"] - - def get_points(self): - return self._results["points"] - - def get_box_paths(self): - return self._results["box_paths"] - - def get_polygon_paths(self): - return self._results["polygon_paths"] + polyline = self._create_polyshape(points, label, frame_number, attributes) + polyline["type"] = "polyline" + self.get_shapes().append(polyline) - def get_polyline_paths(self): - return self._results["polyline_paths"] + def get_shapes(self): + return self._results["shapes"] - def get_points_paths(self): - return self._results["points_paths"] + def get_tracks(self): + return self._results["tracks"] @staticmethod def _create_polyshape(self, points, label, frame_number, attributes=None): @@ -315,7 +287,7 @@ def process_attributes(shape_attributes, label_attr_spec): return attributes - def add_polyshapes(shapes, target_container): + def add_shapes(shapes, target_container): for shape in shapes: if shape["label"] not in labels_mapping: continue @@ -325,35 +297,18 @@ def add_polyshapes(shapes, target_container): "label_id": db_label, "frame": shape["frame"], "points": shape["points"], + "type": shape["type"], "z_order": 0, - "group_id": 0, + "group": None, "occluded": False, "attributes": process_attributes(shape["attributes"], attribute_spec[db_label]), }) - def add_boxes(boxes, target_container): - for box in boxes: - if box["label"] not in labels_mapping: - continue - - db_label = labels_mapping[box["label"]] - target_container.append({ - "label_id": db_label, - "frame": box["frame"], - "xtl": box["xtl"], - "ytl": box["ytl"], - "xbr": box["xbr"], - "ybr": box["ybr"], - "z_order": 0, - "group_id": 0, - "occluded": False, - "attributes": process_attributes(box["attributes"], attribute_spec[db_label]), - }) - result = { - "create": create_anno_container(), - "update": create_anno_container(), - "delete": create_anno_container(), + "shapes": [], + "tracks": [], + "tags": [], + "version": 0 } data_len = len(data) @@ -375,16 +330,15 @@ def add_boxes(boxes, target_container): frame_counter += 1 if job and update_progress and not update_progress(job, frame_counter * 100 / data_len): return None + processed_detections = _process_detections(detections, convertation_file) - add_boxes(processed_detections.get_boxes(), result["create"]["boxes"]) - add_polyshapes(processed_detections.get_points(), result["create"]["points"]) - add_polyshapes(processed_detections.get_polygons(), result["create"]["polygons"]) - add_polyshapes(processed_detections.get_polylines(), result["create"]["polylines"]) + add_shapes(processed_detections.get_shapes(), result["shapes"]) + return result -def run_inference_thread(tid, model_file, weights_file, labels_mapping, attributes, convertation_file, reset): +def run_inference_thread(tid, model_file, weights_file, labels_mapping, attributes, convertation_file, reset, user): def update_progress(job, progress): job.refresh() if "cancel" in job.meta: @@ -418,9 +372,13 @@ def update_progress(job, progress): slogger.glob.info("auto annotation for task {} canceled by user".format(tid)) return - if reset: - annotation.clear_task(tid) - annotation.save_task(tid, result) + serializer = LabeledDataSerializer(data = result) + if serializer.is_valid(raise_exception=True): + if reset: + put_task_data(tid, user, result) + else: + patch_task_data(tid, user, result, "create") + slogger.glob.info("auto annotation for task {} done".format(tid)) except Exception as e: try: diff --git a/cvat/apps/auto_annotation/static/auto_annotation/js/dashboardPlugin.js b/cvat/apps/auto_annotation/static/auto_annotation/js/dashboardPlugin.js index 82e3a6f21167..2aba511b8468 100644 --- a/cvat/apps/auto_annotation/static/auto_annotation/js/dashboardPlugin.js +++ b/cvat/apps/auto_annotation/static/auto_annotation/js/dashboardPlugin.js @@ -11,8 +11,6 @@ */ window.cvat = window.cvat || {}; -window.cvat.dashboard = window.cvat.dashboard || {}; -window.cvat.dashboard.uiCallbacks = window.cvat.dashboard.uiCallbacks || []; const AutoAnnotationServer = { start(modelId, taskId, data, success, error, progress, check) { @@ -602,7 +600,7 @@ class AutoAnnotationModelRunnerView { this.id = null; this.initButton = initButton; - this.tid = data.taskid; + this.tid = data.id; this.modelsTable.empty(); this.labelsTable.empty(); this.active = null; @@ -617,7 +615,7 @@ class AutoAnnotationModelRunnerView { this.active.style.color = 'darkblue'; this.labelsTable.empty(); - const labels = Object.values(event.data.data.spec.labels); + const labels = event.data.data.labels.map(x => x.name); const intersection = labels.filter(el => event.data.model.labels.indexOf(el) !== -1); intersection.forEach((label) => { const dlSelect = labelsSelect(event.data.model.labels, 'annotatorDlLabelSelector'); @@ -705,47 +703,37 @@ window.cvat.autoAnnotation = { managerButtonId: 'annotatorManagerButton', }; -window.cvat.dashboard.uiCallbacks.push((newElements) => { +window.addEventListener('DOMContentLoaded', () => { window.cvat.autoAnnotation.server = AutoAnnotationServer; window.cvat.autoAnnotation.manager = new AutoAnnotationModelManagerView(); window.cvat.autoAnnotation.runner = new AutoAnnotationModelRunnerView(); - const tids = Array.from(newElements, el => el.id.split('_')[1]); + $('body').append(window.cvat.autoAnnotation.manager.element, window.cvat.autoAnnotation.runner.element); + $(``) + .on('click', () => { + const overlay = showOverlay('The manager are being setup..'); + window.cvat.autoAnnotation.manager.reset().show(); + overlay.remove(); + }).appendTo('#dashboardManageButtons'); +}); + +window.addEventListener('dashboardReady', (event) => { + const elements = $('.dashboardItem'); + const tids = Array.from(elements, el => +el.getAttribute('tid')); window.cvat.autoAnnotation.server.meta(tids, (data) => { window.cvat.autoAnnotation.data = data; - $('body').append(window.cvat.autoAnnotation.manager.element, window.cvat.autoAnnotation.runner.element); - $(``) - .on('click', () => { - const overlay = showOverlay('The manager are being setup..'); - window.cvat.autoAnnotation.manager.reset().show(); - overlay.remove(); - }).appendTo('#dashboardManageButtons'); - - newElements.each((_, element) => { - const elem = $(element); - const tid = +elem.attr('id').split('_')[1]; + + elements.each(function setupDashboardItem() { + const elem = $(this); + const tid = +elem.attr('tid'); const button = $('').addClass('regular dashboardButtonUI'); button[0].setupRun = function setupRun() { const self = $(this); + const taskInfo = event.detail.filter(task => task.id === tid)[0]; self.text('Run Auto Annotation').off('click').on('click', () => { - const overlay = showOverlay('Task date are being recieved from the server..'); - $.ajax({ - url: `/get/task/${tid}`, - dataType: 'json', - success: (responseData) => { - overlay.setMessage('The model runner are being setup..'); - window.cvat.autoAnnotation.runner.reset(responseData, self).show(); - overlay.remove(); - }, - error: (responseData) => { - showMessage(`Can't get task data. Code: ${responseData.status}. Message: ${responseData.responseText || responseData.statusText}`); - }, - complete: () => { - overlay.remove(); - }, - }); + window.cvat.autoAnnotation.runner.reset(taskInfo, self).show(); }); }; diff --git a/cvat/apps/auto_annotation/views.py b/cvat/apps/auto_annotation/views.py index 8d23a755cb80..5bcb10d8236f 100644 --- a/cvat/apps/auto_annotation/views.py +++ b/cvat/apps/auto_annotation/views.py @@ -155,7 +155,7 @@ def get_meta_info(request): job = queue.fetch_job(rq_id) if job is not None: response["run"][tid] = { - "status": job.status, + "status": job.get_status(), "rq_id": rq_id, } @@ -191,7 +191,7 @@ def start_annotation(request, mid, tid): db_labels = db_task.label_set.prefetch_related("attributespec_set").all() db_attributes = {db_label.id: - {db_attr.get_name(): db_attr.id for db_attr in db_label.attributespec_set.all()} for db_label in db_labels} + {db_attr.name: db_attr.id for db_attr in db_label.attributespec_set.all()} for db_label in db_labels} db_labels = {db_label.name:db_label.id for db_label in db_labels} model_labels = {value: key for key, value in load_label_map(labelmap_file).items()} @@ -214,6 +214,7 @@ def start_annotation(request, mid, tid): db_attributes, convertation_file_path, should_reset, + request.user, ), job_id = rq_id, timeout=604800) # 7 days diff --git a/cvat/apps/dashboard/admin.py b/cvat/apps/dashboard/admin.py deleted file mode 100644 index af8dfc47525b..000000000000 --- a/cvat/apps/dashboard/admin.py +++ /dev/null @@ -1,9 +0,0 @@ - -# Copyright (C) 2018 Intel Corporation -# -# SPDX-License-Identifier: MIT - -from django.contrib import admin - -# Register your models here. - diff --git a/cvat/apps/dashboard/apps.py b/cvat/apps/dashboard/apps.py index 73611b409636..963627623751 100644 --- a/cvat/apps/dashboard/apps.py +++ b/cvat/apps/dashboard/apps.py @@ -5,7 +5,9 @@ from django.apps import AppConfig - class DashboardConfig(AppConfig): - name = 'dashboard' + name = 'cvat.apps.dashboard' + def ready(self): + # plugin registration + pass \ No newline at end of file diff --git a/cvat/apps/dashboard/models.py b/cvat/apps/dashboard/models.py deleted file mode 100644 index cdf3b0827bf1..000000000000 --- a/cvat/apps/dashboard/models.py +++ /dev/null @@ -1,9 +0,0 @@ - -# Copyright (C) 2018 Intel Corporation -# -# SPDX-License-Identifier: MIT - -from django.db import models - -# Create your models here. - diff --git a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/jstree.js b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/jstree.js deleted file mode 100644 index aee295e2b313..000000000000 --- a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/jstree.js +++ /dev/null @@ -1,8589 +0,0 @@ -/*globals jQuery, define, module, exports, require, window, document, postMessage */ -(function (factory) { - "use strict"; - if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); - } - else if(typeof module !== 'undefined' && module.exports) { - module.exports = factory(require('jquery')); - } - else { - factory(jQuery); - } -}(function ($, undefined) { - "use strict"; -/*! - * jsTree 3.3.5 - * http://jstree.com/ - * - * Copyright (c) 2014 Ivan Bozhanov (http://vakata.com) - * - * Licensed same as jquery - under the terms of the MIT License - * http://www.opensource.org/licenses/mit-license.php - */ -/*! - * if using jslint please allow for the jQuery global and use following options: - * jslint: loopfunc: true, browser: true, ass: true, bitwise: true, continue: true, nomen: true, plusplus: true, regexp: true, unparam: true, todo: true, white: true - */ -/*jshint -W083 */ - - // prevent another load? maybe there is a better way? - if($.jstree) { - return; - } - - /** - * ### jsTree core functionality - */ - - // internal variables - var instance_counter = 0, - ccp_node = false, - ccp_mode = false, - ccp_inst = false, - themes_loaded = [], - src = $('script:last').attr('src'), - document = window.document; // local variable is always faster to access then a global - - /** - * holds all jstree related functions and variables, including the actual class and methods to create, access and manipulate instances. - * @name $.jstree - */ - $.jstree = { - /** - * specifies the jstree version in use - * @name $.jstree.version - */ - version : '3.3.5', - /** - * holds all the default options used when creating new instances - * @name $.jstree.defaults - */ - defaults : { - /** - * configure which plugins will be active on an instance. Should be an array of strings, where each element is a plugin name. The default is `[]` - * @name $.jstree.defaults.plugins - */ - plugins : [] - }, - /** - * stores all loaded jstree plugins (used internally) - * @name $.jstree.plugins - */ - plugins : {}, - path : src && src.indexOf('/') !== -1 ? src.replace(/\/[^\/]+$/,'') : '', - idregex : /[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g, - root : '#' - }; - - /** - * creates a jstree instance - * @name $.jstree.create(el [, options]) - * @param {DOMElement|jQuery|String} el the element to create the instance on, can be jQuery extended or a selector - * @param {Object} options options for this instance (extends `$.jstree.defaults`) - * @return {jsTree} the new instance - */ - $.jstree.create = function (el, options) { - var tmp = new $.jstree.core(++instance_counter), - opt = options; - options = $.extend(true, {}, $.jstree.defaults, options); - if(opt && opt.plugins) { - options.plugins = opt.plugins; - } - $.each(options.plugins, function (i, k) { - if(i !== 'core') { - tmp = tmp.plugin(k, options[k]); - } - }); - $(el).data('jstree', tmp); - tmp.init(el, options); - return tmp; - }; - /** - * remove all traces of jstree from the DOM and destroy all instances - * @name $.jstree.destroy() - */ - $.jstree.destroy = function () { - $('.jstree:jstree').jstree('destroy'); - $(document).off('.jstree'); - }; - /** - * the jstree class constructor, used only internally - * @private - * @name $.jstree.core(id) - * @param {Number} id this instance's index - */ - $.jstree.core = function (id) { - this._id = id; - this._cnt = 0; - this._wrk = null; - this._data = { - core : { - themes : { - name : false, - dots : false, - icons : false, - ellipsis : false - }, - selected : [], - last_error : {}, - working : false, - worker_queue : [], - focused : null - } - }; - }; - /** - * get a reference to an existing instance - * - * __Examples__ - * - * // provided a container with an ID of "tree", and a nested node with an ID of "branch" - * // all of there will return the same instance - * $.jstree.reference('tree'); - * $.jstree.reference('#tree'); - * $.jstree.reference($('#tree')); - * $.jstree.reference(document.getElementByID('tree')); - * $.jstree.reference('branch'); - * $.jstree.reference('#branch'); - * $.jstree.reference($('#branch')); - * $.jstree.reference(document.getElementByID('branch')); - * - * @name $.jstree.reference(needle) - * @param {DOMElement|jQuery|String} needle - * @return {jsTree|null} the instance or `null` if not found - */ - $.jstree.reference = function (needle) { - var tmp = null, - obj = null; - if(needle && needle.id && (!needle.tagName || !needle.nodeType)) { needle = needle.id; } - - if(!obj || !obj.length) { - try { obj = $(needle); } catch (ignore) { } - } - if(!obj || !obj.length) { - try { obj = $('#' + needle.replace($.jstree.idregex,'\\$&')); } catch (ignore) { } - } - if(obj && obj.length && (obj = obj.closest('.jstree')).length && (obj = obj.data('jstree'))) { - tmp = obj; - } - else { - $('.jstree').each(function () { - var inst = $(this).data('jstree'); - if(inst && inst._model.data[needle]) { - tmp = inst; - return false; - } - }); - } - return tmp; - }; - /** - * Create an instance, get an instance or invoke a command on a instance. - * - * If there is no instance associated with the current node a new one is created and `arg` is used to extend `$.jstree.defaults` for this new instance. There would be no return value (chaining is not broken). - * - * If there is an existing instance and `arg` is a string the command specified by `arg` is executed on the instance, with any additional arguments passed to the function. If the function returns a value it will be returned (chaining could break depending on function). - * - * If there is an existing instance and `arg` is not a string the instance itself is returned (similar to `$.jstree.reference`). - * - * In any other case - nothing is returned and chaining is not broken. - * - * __Examples__ - * - * $('#tree1').jstree(); // creates an instance - * $('#tree2').jstree({ plugins : [] }); // create an instance with some options - * $('#tree1').jstree('open_node', '#branch_1'); // call a method on an existing instance, passing additional arguments - * $('#tree2').jstree(); // get an existing instance (or create an instance) - * $('#tree2').jstree(true); // get an existing instance (will not create new instance) - * $('#branch_1').jstree().select_node('#branch_1'); // get an instance (using a nested element and call a method) - * - * @name $().jstree([arg]) - * @param {String|Object} arg - * @return {Mixed} - */ - $.fn.jstree = function (arg) { - // check for string argument - var is_method = (typeof arg === 'string'), - args = Array.prototype.slice.call(arguments, 1), - result = null; - if(arg === true && !this.length) { return false; } - this.each(function () { - // get the instance (if there is one) and method (if it exists) - var instance = $.jstree.reference(this), - method = is_method && instance ? instance[arg] : null; - // if calling a method, and method is available - execute on the instance - result = is_method && method ? - method.apply(instance, args) : - null; - // if there is no instance and no method is being called - create one - if(!instance && !is_method && (arg === undefined || $.isPlainObject(arg))) { - $.jstree.create(this, arg); - } - // if there is an instance and no method is called - return the instance - if( (instance && !is_method) || arg === true ) { - result = instance || false; - } - // if there was a method call which returned a result - break and return the value - if(result !== null && result !== undefined) { - return false; - } - }); - // if there was a method call with a valid return value - return that, otherwise continue the chain - return result !== null && result !== undefined ? - result : this; - }; - /** - * used to find elements containing an instance - * - * __Examples__ - * - * $('div:jstree').each(function () { - * $(this).jstree('destroy'); - * }); - * - * @name $(':jstree') - * @return {jQuery} - */ - $.expr.pseudos.jstree = $.expr.createPseudo(function(search) { - return function(a) { - return $(a).hasClass('jstree') && - $(a).data('jstree') !== undefined; - }; - }); - - /** - * stores all defaults for the core - * @name $.jstree.defaults.core - */ - $.jstree.defaults.core = { - /** - * data configuration - * - * If left as `false` the HTML inside the jstree container element is used to populate the tree (that should be an unordered list with list items). - * - * You can also pass in a HTML string or a JSON array here. - * - * It is possible to pass in a standard jQuery-like AJAX config and jstree will automatically determine if the response is JSON or HTML and use that to populate the tree. - * In addition to the standard jQuery ajax options here you can suppy functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node is being loaded, the return value of those functions will be used. - * - * The last option is to specify a function, that function will receive the node being loaded as argument and a second param which is a function which should be called with the result. - * - * __Examples__ - * - * // AJAX - * $('#tree').jstree({ - * 'core' : { - * 'data' : { - * 'url' : '/get/children/', - * 'data' : function (node) { - * return { 'id' : node.id }; - * } - * } - * }); - * - * // direct data - * $('#tree').jstree({ - * 'core' : { - * 'data' : [ - * 'Simple root node', - * { - * 'id' : 'node_2', - * 'text' : 'Root node with options', - * 'state' : { 'opened' : true, 'selected' : true }, - * 'children' : [ { 'text' : 'Child 1' }, 'Child 2'] - * } - * ] - * } - * }); - * - * // function - * $('#tree').jstree({ - * 'core' : { - * 'data' : function (obj, callback) { - * callback.call(this, ['Root 1', 'Root 2']); - * } - * }); - * - * @name $.jstree.defaults.core.data - */ - data : false, - /** - * configure the various strings used throughout the tree - * - * You can use an object where the key is the string you need to replace and the value is your replacement. - * Another option is to specify a function which will be called with an argument of the needed string and should return the replacement. - * If left as `false` no replacement is made. - * - * __Examples__ - * - * $('#tree').jstree({ - * 'core' : { - * 'strings' : { - * 'Loading ...' : 'Please wait ...' - * } - * } - * }); - * - * @name $.jstree.defaults.core.strings - */ - strings : false, - /** - * determines what happens when a user tries to modify the structure of the tree - * If left as `false` all operations like create, rename, delete, move or copy are prevented. - * You can set this to `true` to allow all interactions or use a function to have better control. - * - * __Examples__ - * - * $('#tree').jstree({ - * 'core' : { - * 'check_callback' : function (operation, node, node_parent, node_position, more) { - * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node', 'copy_node' or 'edit' - * // in case of 'rename_node' node_position is filled with the new node name - * return operation === 'rename_node' ? true : false; - * } - * } - * }); - * - * @name $.jstree.defaults.core.check_callback - */ - check_callback : false, - /** - * a callback called with a single object parameter in the instance's scope when something goes wrong (operation prevented, ajax failed, etc) - * @name $.jstree.defaults.core.error - */ - error : $.noop, - /** - * the open / close animation duration in milliseconds - set this to `false` to disable the animation (default is `200`) - * @name $.jstree.defaults.core.animation - */ - animation : 200, - /** - * a boolean indicating if multiple nodes can be selected - * @name $.jstree.defaults.core.multiple - */ - multiple : true, - /** - * theme configuration object - * @name $.jstree.defaults.core.themes - */ - themes : { - /** - * the name of the theme to use (if left as `false` the default theme is used) - * @name $.jstree.defaults.core.themes.name - */ - name : false, - /** - * the URL of the theme's CSS file, leave this as `false` if you have manually included the theme CSS (recommended). You can set this to `true` too which will try to autoload the theme. - * @name $.jstree.defaults.core.themes.url - */ - url : false, - /** - * the location of all jstree themes - only used if `url` is set to `true` - * @name $.jstree.defaults.core.themes.dir - */ - dir : false, - /** - * a boolean indicating if connecting dots are shown - * @name $.jstree.defaults.core.themes.dots - */ - dots : true, - /** - * a boolean indicating if node icons are shown - * @name $.jstree.defaults.core.themes.icons - */ - icons : true, - /** - * a boolean indicating if node ellipsis should be shown - this only works with a fixed with on the container - * @name $.jstree.defaults.core.themes.ellipsis - */ - ellipsis : false, - /** - * a boolean indicating if the tree background is striped - * @name $.jstree.defaults.core.themes.stripes - */ - stripes : false, - /** - * a string (or boolean `false`) specifying the theme variant to use (if the theme supports variants) - * @name $.jstree.defaults.core.themes.variant - */ - variant : false, - /** - * a boolean specifying if a reponsive version of the theme should kick in on smaller screens (if the theme supports it). Defaults to `false`. - * @name $.jstree.defaults.core.themes.responsive - */ - responsive : false - }, - /** - * if left as `true` all parents of all selected nodes will be opened once the tree loads (so that all selected nodes are visible to the user) - * @name $.jstree.defaults.core.expand_selected_onload - */ - expand_selected_onload : true, - /** - * if left as `true` web workers will be used to parse incoming JSON data where possible, so that the UI will not be blocked by large requests. Workers are however about 30% slower. Defaults to `true` - * @name $.jstree.defaults.core.worker - */ - worker : true, - /** - * Force node text to plain text (and escape HTML). Defaults to `false` - * @name $.jstree.defaults.core.force_text - */ - force_text : false, - /** - * Should the node should be toggled if the text is double clicked . Defaults to `true` - * @name $.jstree.defaults.core.dblclick_toggle - */ - dblclick_toggle : true, - /** - * Should the loaded nodes be part of the state. Defaults to `false` - * @name $.jstree.defaults.core.loaded_state - */ - loaded_state : false, - /** - * Should the last active node be focused when the tree container is blurred and the focused again. This helps working with screen readers. Defaults to `true` - * @name $.jstree.defaults.core.restore_focus - */ - restore_focus : true, - /** - * Default keyboard shortcuts (an object where each key is the button name or combo - like 'enter', 'ctrl-space', 'p', etc and the value is the function to execute in the instance's scope) - * @name $.jstree.defaults.core.keyboard - */ - keyboard : { - 'ctrl-space': function (e) { - // aria defines space only with Ctrl - e.type = "click"; - $(e.currentTarget).trigger(e); - }, - 'enter': function (e) { - // enter - e.type = "click"; - $(e.currentTarget).trigger(e); - }, - 'left': function (e) { - // left - e.preventDefault(); - if(this.is_open(e.currentTarget)) { - this.close_node(e.currentTarget); - } - else { - var o = this.get_parent(e.currentTarget); - if(o && o.id !== $.jstree.root) { this.get_node(o, true).children('.jstree-anchor').focus(); } - } - }, - 'up': function (e) { - // up - e.preventDefault(); - var o = this.get_prev_dom(e.currentTarget); - if(o && o.length) { o.children('.jstree-anchor').focus(); } - }, - 'right': function (e) { - // right - e.preventDefault(); - if(this.is_closed(e.currentTarget)) { - this.open_node(e.currentTarget, function (o) { this.get_node(o, true).children('.jstree-anchor').focus(); }); - } - else if (this.is_open(e.currentTarget)) { - var o = this.get_node(e.currentTarget, true).children('.jstree-children')[0]; - if(o) { $(this._firstChild(o)).children('.jstree-anchor').focus(); } - } - }, - 'down': function (e) { - // down - e.preventDefault(); - var o = this.get_next_dom(e.currentTarget); - if(o && o.length) { o.children('.jstree-anchor').focus(); } - }, - '*': function (e) { - // aria defines * on numpad as open_all - not very common - this.open_all(); - }, - 'home': function (e) { - // home - e.preventDefault(); - var o = this._firstChild(this.get_container_ul()[0]); - if(o) { $(o).children('.jstree-anchor').filter(':visible').focus(); } - }, - 'end': function (e) { - // end - e.preventDefault(); - this.element.find('.jstree-anchor').filter(':visible').last().focus(); - }, - 'f2': function (e) { - // f2 - safe to include - if check_callback is false it will fail - e.preventDefault(); - this.edit(e.currentTarget); - } - } - }; - $.jstree.core.prototype = { - /** - * used to decorate an instance with a plugin. Used internally. - * @private - * @name plugin(deco [, opts]) - * @param {String} deco the plugin to decorate with - * @param {Object} opts options for the plugin - * @return {jsTree} - */ - plugin : function (deco, opts) { - var Child = $.jstree.plugins[deco]; - if(Child) { - this._data[deco] = {}; - Child.prototype = this; - return new Child(opts, this); - } - return this; - }, - /** - * initialize the instance. Used internally. - * @private - * @name init(el, optons) - * @param {DOMElement|jQuery|String} el the element we are transforming - * @param {Object} options options for this instance - * @trigger init.jstree, loading.jstree, loaded.jstree, ready.jstree, changed.jstree - */ - init : function (el, options) { - this._model = { - data : {}, - changed : [], - force_full_redraw : false, - redraw_timeout : false, - default_state : { - loaded : true, - opened : false, - selected : false, - disabled : false - } - }; - this._model.data[$.jstree.root] = { - id : $.jstree.root, - parent : null, - parents : [], - children : [], - children_d : [], - state : { loaded : false } - }; - - this.element = $(el).addClass('jstree jstree-' + this._id); - this.settings = options; - - this._data.core.ready = false; - this._data.core.loaded = false; - this._data.core.rtl = (this.element.css("direction") === "rtl"); - this.element[this._data.core.rtl ? 'addClass' : 'removeClass']("jstree-rtl"); - this.element.attr('role','tree'); - if(this.settings.core.multiple) { - this.element.attr('aria-multiselectable', true); - } - if(!this.element.attr('tabindex')) { - this.element.attr('tabindex','0'); - } - - this.bind(); - /** - * triggered after all events are bound - * @event - * @name init.jstree - */ - this.trigger("init"); - - this._data.core.original_container_html = this.element.find(" > ul > li").clone(true); - this._data.core.original_container_html - .find("li").addBack() - .contents().filter(function() { - return this.nodeType === 3 && (!this.nodeValue || /^\s+$/.test(this.nodeValue)); - }) - .remove(); - this.element.html("<"+"ul class='jstree-container-ul jstree-children' role='group'><"+"li id='j"+this._id+"_loading' class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='tree-item'><"+"a class='jstree-anchor' href='#'>" + this.get_string("Loading ...") + ""); - this.element.attr('aria-activedescendant','j' + this._id + '_loading'); - this._data.core.li_height = this.get_container_ul().children("li").first().outerHeight() || 24; - this._data.core.node = this._create_prototype_node(); - /** - * triggered after the loading text is shown and before loading starts - * @event - * @name loading.jstree - */ - this.trigger("loading"); - this.load_node($.jstree.root); - }, - /** - * destroy an instance - * @name destroy() - * @param {Boolean} keep_html if not set to `true` the container will be emptied, otherwise the current DOM elements will be kept intact - */ - destroy : function (keep_html) { - /** - * triggered before the tree is destroyed - * @event - * @name destroy.jstree - */ - this.trigger("destroy"); - if(this._wrk) { - try { - window.URL.revokeObjectURL(this._wrk); - this._wrk = null; - } - catch (ignore) { } - } - if(!keep_html) { this.element.empty(); } - this.teardown(); - }, - /** - * Create a prototype node - * @name _create_prototype_node() - * @return {DOMElement} - */ - _create_prototype_node : function () { - var _node = document.createElement('LI'), _temp1, _temp2; - _node.setAttribute('role', 'treeitem'); - _temp1 = document.createElement('I'); - _temp1.className = 'jstree-icon jstree-ocl'; - _temp1.setAttribute('role', 'presentation'); - _node.appendChild(_temp1); - _temp1 = document.createElement('A'); - _temp1.className = 'jstree-anchor'; - _temp1.setAttribute('href','#'); - _temp1.setAttribute('tabindex','-1'); - _temp2 = document.createElement('I'); - _temp2.className = 'jstree-icon jstree-themeicon'; - _temp2.setAttribute('role', 'presentation'); - _temp1.appendChild(_temp2); - _node.appendChild(_temp1); - _temp1 = _temp2 = null; - - return _node; - }, - _kbevent_to_func : function (e) { - var keys = { - 8: "Backspace", 9: "Tab", 13: "Return", 19: "Pause", 27: "Esc", - 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home", - 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "Print", 45: "Insert", - 46: "Delete", 96: "Numpad0", 97: "Numpad1", 98: "Numpad2", 99 : "Numpad3", - 100: "Numpad4", 101: "Numpad5", 102: "Numpad6", 103: "Numpad7", - 104: "Numpad8", 105: "Numpad9", '-13': "NumpadEnter", 112: "F1", - 113: "F2", 114: "F3", 115: "F4", 116: "F5", 117: "F6", 118: "F7", - 119: "F8", 120: "F9", 121: "F10", 122: "F11", 123: "F12", 144: "Numlock", - 145: "Scrolllock", 16: 'Shift', 17: 'Ctrl', 18: 'Alt', - 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5', - 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a', - 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h', - 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o', - 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v', - 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.', - 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`', - 219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*', 173: '-' - }; - var parts = []; - if (e.ctrlKey) { parts.push('ctrl'); } - if (e.altKey) { parts.push('alt'); } - if (e.shiftKey) { parts.push('shift'); } - parts.push(keys[e.which] || e.which); - parts = parts.sort().join('-').toLowerCase(); - - var kb = this.settings.core.keyboard, i, tmp; - for (i in kb) { - if (kb.hasOwnProperty(i)) { - tmp = i; - if (tmp !== '-' && tmp !== '+') { - tmp = tmp.replace('--', '-MINUS').replace('+-', '-MINUS').replace('++', '-PLUS').replace('-+', '-PLUS'); - tmp = tmp.split(/-|\+/).sort().join('-').replace('MINUS', '-').replace('PLUS', '+').toLowerCase(); - } - if (tmp === parts) { - return kb[i]; - } - } - } - return null; - }, - /** - * part of the destroying of an instance. Used internally. - * @private - * @name teardown() - */ - teardown : function () { - this.unbind(); - this.element - .removeClass('jstree') - .removeData('jstree') - .find("[class^='jstree']") - .addBack() - .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); }); - this.element = null; - }, - /** - * bind all events. Used internally. - * @private - * @name bind() - */ - bind : function () { - var word = '', - tout = null, - was_click = 0; - this.element - .on("dblclick.jstree", function (e) { - if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; } - if(document.selection && document.selection.empty) { - document.selection.empty(); - } - else { - if(window.getSelection) { - var sel = window.getSelection(); - try { - sel.removeAllRanges(); - sel.collapse(); - } catch (ignore) { } - } - } - }) - .on("mousedown.jstree", $.proxy(function (e) { - if(e.target === this.element[0]) { - e.preventDefault(); // prevent losing focus when clicking scroll arrows (FF, Chrome) - was_click = +(new Date()); // ie does not allow to prevent losing focus - } - }, this)) - .on("mousedown.jstree", ".jstree-ocl", function (e) { - e.preventDefault(); // prevent any node inside from losing focus when clicking the open/close icon - }) - .on("click.jstree", ".jstree-ocl", $.proxy(function (e) { - this.toggle_node(e.target); - }, this)) - .on("dblclick.jstree", ".jstree-anchor", $.proxy(function (e) { - if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; } - if(this.settings.core.dblclick_toggle) { - this.toggle_node(e.target); - } - }, this)) - .on("click.jstree", ".jstree-anchor", $.proxy(function (e) { - e.preventDefault(); - if(e.currentTarget !== document.activeElement) { $(e.currentTarget).focus(); } - this.activate_node(e.currentTarget, e); - }, this)) - .on('keydown.jstree', '.jstree-anchor', $.proxy(function (e) { - if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; } - if(this._data.core.rtl) { - if(e.which === 37) { e.which = 39; } - else if(e.which === 39) { e.which = 37; } - } - var f = this._kbevent_to_func(e); - if (f) { - var r = f.call(this, e); - if (r === false || r === true) { - return r; - } - } - }, this)) - .on("load_node.jstree", $.proxy(function (e, data) { - if(data.status) { - if(data.node.id === $.jstree.root && !this._data.core.loaded) { - this._data.core.loaded = true; - if(this._firstChild(this.get_container_ul()[0])) { - this.element.attr('aria-activedescendant',this._firstChild(this.get_container_ul()[0]).id); - } - /** - * triggered after the root node is loaded for the first time - * @event - * @name loaded.jstree - */ - this.trigger("loaded"); - } - if(!this._data.core.ready) { - setTimeout($.proxy(function() { - if(this.element && !this.get_container_ul().find('.jstree-loading').length) { - this._data.core.ready = true; - if(this._data.core.selected.length) { - if(this.settings.core.expand_selected_onload) { - var tmp = [], i, j; - for(i = 0, j = this._data.core.selected.length; i < j; i++) { - tmp = tmp.concat(this._model.data[this._data.core.selected[i]].parents); - } - tmp = $.vakata.array_unique(tmp); - for(i = 0, j = tmp.length; i < j; i++) { - this.open_node(tmp[i], false, 0); - } - } - this.trigger('changed', { 'action' : 'ready', 'selected' : this._data.core.selected }); - } - /** - * triggered after all nodes are finished loading - * @event - * @name ready.jstree - */ - this.trigger("ready"); - } - }, this), 0); - } - } - }, this)) - // quick searching when the tree is focused - .on('keypress.jstree', $.proxy(function (e) { - if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; } - if(tout) { clearTimeout(tout); } - tout = setTimeout(function () { - word = ''; - }, 500); - - var chr = String.fromCharCode(e.which).toLowerCase(), - col = this.element.find('.jstree-anchor').filter(':visible'), - ind = col.index(document.activeElement) || 0, - end = false; - word += chr; - - // match for whole word from current node down (including the current node) - if(word.length > 1) { - col.slice(ind).each($.proxy(function (i, v) { - if($(v).text().toLowerCase().indexOf(word) === 0) { - $(v).focus(); - end = true; - return false; - } - }, this)); - if(end) { return; } - - // match for whole word from the beginning of the tree - col.slice(0, ind).each($.proxy(function (i, v) { - if($(v).text().toLowerCase().indexOf(word) === 0) { - $(v).focus(); - end = true; - return false; - } - }, this)); - if(end) { return; } - } - // list nodes that start with that letter (only if word consists of a single char) - if(new RegExp('^' + chr.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '+$').test(word)) { - // search for the next node starting with that letter - col.slice(ind + 1).each($.proxy(function (i, v) { - if($(v).text().toLowerCase().charAt(0) === chr) { - $(v).focus(); - end = true; - return false; - } - }, this)); - if(end) { return; } - - // search from the beginning - col.slice(0, ind + 1).each($.proxy(function (i, v) { - if($(v).text().toLowerCase().charAt(0) === chr) { - $(v).focus(); - end = true; - return false; - } - }, this)); - if(end) { return; } - } - }, this)) - // THEME RELATED - .on("init.jstree", $.proxy(function () { - var s = this.settings.core.themes; - this._data.core.themes.dots = s.dots; - this._data.core.themes.stripes = s.stripes; - this._data.core.themes.icons = s.icons; - this._data.core.themes.ellipsis = s.ellipsis; - this.set_theme(s.name || "default", s.url); - this.set_theme_variant(s.variant); - }, this)) - .on("loading.jstree", $.proxy(function () { - this[ this._data.core.themes.dots ? "show_dots" : "hide_dots" ](); - this[ this._data.core.themes.icons ? "show_icons" : "hide_icons" ](); - this[ this._data.core.themes.stripes ? "show_stripes" : "hide_stripes" ](); - this[ this._data.core.themes.ellipsis ? "show_ellipsis" : "hide_ellipsis" ](); - }, this)) - .on('blur.jstree', '.jstree-anchor', $.proxy(function (e) { - this._data.core.focused = null; - $(e.currentTarget).filter('.jstree-hovered').mouseleave(); - this.element.attr('tabindex', '0'); - }, this)) - .on('focus.jstree', '.jstree-anchor', $.proxy(function (e) { - var tmp = this.get_node(e.currentTarget); - if(tmp && tmp.id) { - this._data.core.focused = tmp.id; - } - this.element.find('.jstree-hovered').not(e.currentTarget).mouseleave(); - $(e.currentTarget).mouseenter(); - this.element.attr('tabindex', '-1'); - }, this)) - .on('focus.jstree', $.proxy(function () { - if(+(new Date()) - was_click > 500 && !this._data.core.focused && this.settings.core.restore_focus) { - was_click = 0; - var act = this.get_node(this.element.attr('aria-activedescendant'), true); - if(act) { - act.find('> .jstree-anchor').focus(); - } - } - }, this)) - .on('mouseenter.jstree', '.jstree-anchor', $.proxy(function (e) { - this.hover_node(e.currentTarget); - }, this)) - .on('mouseleave.jstree', '.jstree-anchor', $.proxy(function (e) { - this.dehover_node(e.currentTarget); - }, this)); - }, - /** - * part of the destroying of an instance. Used internally. - * @private - * @name unbind() - */ - unbind : function () { - this.element.off('.jstree'); - $(document).off('.jstree-' + this._id); - }, - /** - * trigger an event. Used internally. - * @private - * @name trigger(ev [, data]) - * @param {String} ev the name of the event to trigger - * @param {Object} data additional data to pass with the event - */ - trigger : function (ev, data) { - if(!data) { - data = {}; - } - data.instance = this; - this.element.triggerHandler(ev.replace('.jstree','') + '.jstree', data); - }, - /** - * returns the jQuery extended instance container - * @name get_container() - * @return {jQuery} - */ - get_container : function () { - return this.element; - }, - /** - * returns the jQuery extended main UL node inside the instance container. Used internally. - * @private - * @name get_container_ul() - * @return {jQuery} - */ - get_container_ul : function () { - return this.element.children(".jstree-children").first(); - }, - /** - * gets string replacements (localization). Used internally. - * @private - * @name get_string(key) - * @param {String} key - * @return {String} - */ - get_string : function (key) { - var a = this.settings.core.strings; - if($.isFunction(a)) { return a.call(this, key); } - if(a && a[key]) { return a[key]; } - return key; - }, - /** - * gets the first child of a DOM node. Used internally. - * @private - * @name _firstChild(dom) - * @param {DOMElement} dom - * @return {DOMElement} - */ - _firstChild : function (dom) { - dom = dom ? dom.firstChild : null; - while(dom !== null && dom.nodeType !== 1) { - dom = dom.nextSibling; - } - return dom; - }, - /** - * gets the next sibling of a DOM node. Used internally. - * @private - * @name _nextSibling(dom) - * @param {DOMElement} dom - * @return {DOMElement} - */ - _nextSibling : function (dom) { - dom = dom ? dom.nextSibling : null; - while(dom !== null && dom.nodeType !== 1) { - dom = dom.nextSibling; - } - return dom; - }, - /** - * gets the previous sibling of a DOM node. Used internally. - * @private - * @name _previousSibling(dom) - * @param {DOMElement} dom - * @return {DOMElement} - */ - _previousSibling : function (dom) { - dom = dom ? dom.previousSibling : null; - while(dom !== null && dom.nodeType !== 1) { - dom = dom.previousSibling; - } - return dom; - }, - /** - * get the JSON representation of a node (or the actual jQuery extended DOM node) by using any input (child DOM element, ID string, selector, etc) - * @name get_node(obj [, as_dom]) - * @param {mixed} obj - * @param {Boolean} as_dom - * @return {Object|jQuery} - */ - get_node : function (obj, as_dom) { - if(obj && obj.id) { - obj = obj.id; - } - var dom; - try { - if(this._model.data[obj]) { - obj = this._model.data[obj]; - } - else if(typeof obj === "string" && this._model.data[obj.replace(/^#/, '')]) { - obj = this._model.data[obj.replace(/^#/, '')]; - } - else if(typeof obj === "string" && (dom = $('#' + obj.replace($.jstree.idregex,'\\$&'), this.element)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) { - obj = this._model.data[dom.closest('.jstree-node').attr('id')]; - } - else if((dom = $(obj, this.element)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) { - obj = this._model.data[dom.closest('.jstree-node').attr('id')]; - } - else if((dom = $(obj, this.element)).length && dom.hasClass('jstree')) { - obj = this._model.data[$.jstree.root]; - } - else { - return false; - } - - if(as_dom) { - obj = obj.id === $.jstree.root ? this.element : $('#' + obj.id.replace($.jstree.idregex,'\\$&'), this.element); - } - return obj; - } catch (ex) { return false; } - }, - /** - * get the path to a node, either consisting of node texts, or of node IDs, optionally glued together (otherwise an array) - * @name get_path(obj [, glue, ids]) - * @param {mixed} obj the node - * @param {String} glue if you want the path as a string - pass the glue here (for example '/'), if a falsy value is supplied here, an array is returned - * @param {Boolean} ids if set to true build the path using ID, otherwise node text is used - * @return {mixed} - */ - get_path : function (obj, glue, ids) { - obj = obj.parents ? obj : this.get_node(obj); - if(!obj || obj.id === $.jstree.root || !obj.parents) { - return false; - } - var i, j, p = []; - p.push(ids ? obj.id : obj.text); - for(i = 0, j = obj.parents.length; i < j; i++) { - p.push(ids ? obj.parents[i] : this.get_text(obj.parents[i])); - } - p = p.reverse().slice(1); - return glue ? p.join(glue) : p; - }, - /** - * get the next visible node that is below the `obj` node. If `strict` is set to `true` only sibling nodes are returned. - * @name get_next_dom(obj [, strict]) - * @param {mixed} obj - * @param {Boolean} strict - * @return {jQuery} - */ - get_next_dom : function (obj, strict) { - var tmp; - obj = this.get_node(obj, true); - if(obj[0] === this.element[0]) { - tmp = this._firstChild(this.get_container_ul()[0]); - while (tmp && tmp.offsetHeight === 0) { - tmp = this._nextSibling(tmp); - } - return tmp ? $(tmp) : false; - } - if(!obj || !obj.length) { - return false; - } - if(strict) { - tmp = obj[0]; - do { - tmp = this._nextSibling(tmp); - } while (tmp && tmp.offsetHeight === 0); - return tmp ? $(tmp) : false; - } - if(obj.hasClass("jstree-open")) { - tmp = this._firstChild(obj.children('.jstree-children')[0]); - while (tmp && tmp.offsetHeight === 0) { - tmp = this._nextSibling(tmp); - } - if(tmp !== null) { - return $(tmp); - } - } - tmp = obj[0]; - do { - tmp = this._nextSibling(tmp); - } while (tmp && tmp.offsetHeight === 0); - if(tmp !== null) { - return $(tmp); - } - return obj.parentsUntil(".jstree",".jstree-node").nextAll(".jstree-node:visible").first(); - }, - /** - * get the previous visible node that is above the `obj` node. If `strict` is set to `true` only sibling nodes are returned. - * @name get_prev_dom(obj [, strict]) - * @param {mixed} obj - * @param {Boolean} strict - * @return {jQuery} - */ - get_prev_dom : function (obj, strict) { - var tmp; - obj = this.get_node(obj, true); - if(obj[0] === this.element[0]) { - tmp = this.get_container_ul()[0].lastChild; - while (tmp && tmp.offsetHeight === 0) { - tmp = this._previousSibling(tmp); - } - return tmp ? $(tmp) : false; - } - if(!obj || !obj.length) { - return false; - } - if(strict) { - tmp = obj[0]; - do { - tmp = this._previousSibling(tmp); - } while (tmp && tmp.offsetHeight === 0); - return tmp ? $(tmp) : false; - } - tmp = obj[0]; - do { - tmp = this._previousSibling(tmp); - } while (tmp && tmp.offsetHeight === 0); - if(tmp !== null) { - obj = $(tmp); - while(obj.hasClass("jstree-open")) { - obj = obj.children(".jstree-children").first().children(".jstree-node:visible:last"); - } - return obj; - } - tmp = obj[0].parentNode.parentNode; - return tmp && tmp.className && tmp.className.indexOf('jstree-node') !== -1 ? $(tmp) : false; - }, - /** - * get the parent ID of a node - * @name get_parent(obj) - * @param {mixed} obj - * @return {String} - */ - get_parent : function (obj) { - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - return obj.parent; - }, - /** - * get a jQuery collection of all the children of a node (node must be rendered), returns false on error - * @name get_children_dom(obj) - * @param {mixed} obj - * @return {jQuery} - */ - get_children_dom : function (obj) { - obj = this.get_node(obj, true); - if(obj[0] === this.element[0]) { - return this.get_container_ul().children(".jstree-node"); - } - if(!obj || !obj.length) { - return false; - } - return obj.children(".jstree-children").children(".jstree-node"); - }, - /** - * checks if a node has children - * @name is_parent(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_parent : function (obj) { - obj = this.get_node(obj); - return obj && (obj.state.loaded === false || obj.children.length > 0); - }, - /** - * checks if a node is loaded (its children are available) - * @name is_loaded(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_loaded : function (obj) { - obj = this.get_node(obj); - return obj && obj.state.loaded; - }, - /** - * check if a node is currently loading (fetching children) - * @name is_loading(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_loading : function (obj) { - obj = this.get_node(obj); - return obj && obj.state && obj.state.loading; - }, - /** - * check if a node is opened - * @name is_open(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_open : function (obj) { - obj = this.get_node(obj); - return obj && obj.state.opened; - }, - /** - * check if a node is in a closed state - * @name is_closed(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_closed : function (obj) { - obj = this.get_node(obj); - return obj && this.is_parent(obj) && !obj.state.opened; - }, - /** - * check if a node has no children - * @name is_leaf(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_leaf : function (obj) { - return !this.is_parent(obj); - }, - /** - * loads a node (fetches its children using the `core.data` setting). Multiple nodes can be passed to by using an array. - * @name load_node(obj [, callback]) - * @param {mixed} obj - * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives two arguments - the node and a boolean status - * @return {Boolean} - * @trigger load_node.jstree - */ - load_node : function (obj, callback) { - var k, l, i, j, c; - if($.isArray(obj)) { - this._load_nodes(obj.slice(), callback); - return true; - } - obj = this.get_node(obj); - if(!obj) { - if(callback) { callback.call(this, obj, false); } - return false; - } - // if(obj.state.loading) { } // the node is already loading - just wait for it to load and invoke callback? but if called implicitly it should be loaded again? - if(obj.state.loaded) { - obj.state.loaded = false; - for(i = 0, j = obj.parents.length; i < j; i++) { - this._model.data[obj.parents[i]].children_d = $.vakata.array_filter(this._model.data[obj.parents[i]].children_d, function (v) { - return $.inArray(v, obj.children_d) === -1; - }); - } - for(k = 0, l = obj.children_d.length; k < l; k++) { - if(this._model.data[obj.children_d[k]].state.selected) { - c = true; - } - delete this._model.data[obj.children_d[k]]; - } - if (c) { - this._data.core.selected = $.vakata.array_filter(this._data.core.selected, function (v) { - return $.inArray(v, obj.children_d) === -1; - }); - } - obj.children = []; - obj.children_d = []; - if(c) { - this.trigger('changed', { 'action' : 'load_node', 'node' : obj, 'selected' : this._data.core.selected }); - } - } - obj.state.failed = false; - obj.state.loading = true; - this.get_node(obj, true).addClass("jstree-loading").attr('aria-busy',true); - this._load_node(obj, $.proxy(function (status) { - obj = this._model.data[obj.id]; - obj.state.loading = false; - obj.state.loaded = status; - obj.state.failed = !obj.state.loaded; - var dom = this.get_node(obj, true), i = 0, j = 0, m = this._model.data, has_children = false; - for(i = 0, j = obj.children.length; i < j; i++) { - if(m[obj.children[i]] && !m[obj.children[i]].state.hidden) { - has_children = true; - break; - } - } - if(obj.state.loaded && dom && dom.length) { - dom.removeClass('jstree-closed jstree-open jstree-leaf'); - if (!has_children) { - dom.addClass('jstree-leaf'); - } - else { - if (obj.id !== '#') { - dom.addClass(obj.state.opened ? 'jstree-open' : 'jstree-closed'); - } - } - } - dom.removeClass("jstree-loading").attr('aria-busy',false); - /** - * triggered after a node is loaded - * @event - * @name load_node.jstree - * @param {Object} node the node that was loading - * @param {Boolean} status was the node loaded successfully - */ - this.trigger('load_node', { "node" : obj, "status" : status }); - if(callback) { - callback.call(this, obj, status); - } - }, this)); - return true; - }, - /** - * load an array of nodes (will also load unavailable nodes as soon as the appear in the structure). Used internally. - * @private - * @name _load_nodes(nodes [, callback]) - * @param {array} nodes - * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - the array passed to _load_nodes - */ - _load_nodes : function (nodes, callback, is_callback, force_reload) { - var r = true, - c = function () { this._load_nodes(nodes, callback, true); }, - m = this._model.data, i, j, tmp = []; - for(i = 0, j = nodes.length; i < j; i++) { - if(m[nodes[i]] && ( (!m[nodes[i]].state.loaded && !m[nodes[i]].state.failed) || (!is_callback && force_reload) )) { - if(!this.is_loading(nodes[i])) { - this.load_node(nodes[i], c); - } - r = false; - } - } - if(r) { - for(i = 0, j = nodes.length; i < j; i++) { - if(m[nodes[i]] && m[nodes[i]].state.loaded) { - tmp.push(nodes[i]); - } - } - if(callback && !callback.done) { - callback.call(this, tmp); - callback.done = true; - } - } - }, - /** - * loads all unloaded nodes - * @name load_all([obj, callback]) - * @param {mixed} obj the node to load recursively, omit to load all nodes in the tree - * @param {function} callback a function to be executed once loading all the nodes is complete, - * @trigger load_all.jstree - */ - load_all : function (obj, callback) { - if(!obj) { obj = $.jstree.root; } - obj = this.get_node(obj); - if(!obj) { return false; } - var to_load = [], - m = this._model.data, - c = m[obj.id].children_d, - i, j; - if(obj.state && !obj.state.loaded) { - to_load.push(obj.id); - } - for(i = 0, j = c.length; i < j; i++) { - if(m[c[i]] && m[c[i]].state && !m[c[i]].state.loaded) { - to_load.push(c[i]); - } - } - if(to_load.length) { - this._load_nodes(to_load, function () { - this.load_all(obj, callback); - }); - } - else { - /** - * triggered after a load_all call completes - * @event - * @name load_all.jstree - * @param {Object} node the recursively loaded node - */ - if(callback) { callback.call(this, obj); } - this.trigger('load_all', { "node" : obj }); - } - }, - /** - * handles the actual loading of a node. Used only internally. - * @private - * @name _load_node(obj [, callback]) - * @param {mixed} obj - * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - a boolean status - * @return {Boolean} - */ - _load_node : function (obj, callback) { - var s = this.settings.core.data, t; - var notTextOrCommentNode = function notTextOrCommentNode () { - return this.nodeType !== 3 && this.nodeType !== 8; - }; - // use original HTML - if(!s) { - if(obj.id === $.jstree.root) { - return this._append_html_data(obj, this._data.core.original_container_html.clone(true), function (status) { - callback.call(this, status); - }); - } - else { - return callback.call(this, false); - } - // return callback.call(this, obj.id === $.jstree.root ? this._append_html_data(obj, this._data.core.original_container_html.clone(true)) : false); - } - if($.isFunction(s)) { - return s.call(this, obj, $.proxy(function (d) { - if(d === false) { - callback.call(this, false); - } - else { - this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $($.parseHTML(d)).filter(notTextOrCommentNode) : d, function (status) { - callback.call(this, status); - }); - } - // return d === false ? callback.call(this, false) : callback.call(this, this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $(d) : d)); - }, this)); - } - if(typeof s === 'object') { - if(s.url) { - s = $.extend(true, {}, s); - if($.isFunction(s.url)) { - s.url = s.url.call(this, obj); - } - if($.isFunction(s.data)) { - s.data = s.data.call(this, obj); - } - return $.ajax(s) - .done($.proxy(function (d,t,x) { - var type = x.getResponseHeader('Content-Type'); - if((type && type.indexOf('json') !== -1) || typeof d === "object") { - return this._append_json_data(obj, d, function (status) { callback.call(this, status); }); - //return callback.call(this, this._append_json_data(obj, d)); - } - if((type && type.indexOf('html') !== -1) || typeof d === "string") { - return this._append_html_data(obj, $($.parseHTML(d)).filter(notTextOrCommentNode), function (status) { callback.call(this, status); }); - // return callback.call(this, this._append_html_data(obj, $(d))); - } - this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'core', 'id' : 'core_04', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id, 'xhr' : x }) }; - this.settings.core.error.call(this, this._data.core.last_error); - return callback.call(this, false); - }, this)) - .fail($.proxy(function (f) { - this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'core', 'id' : 'core_04', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id, 'xhr' : f }) }; - callback.call(this, false); - this.settings.core.error.call(this, this._data.core.last_error); - }, this)); - } - if ($.isArray(s)) { - t = $.extend(true, [], s); - } else if ($.isPlainObject(s)) { - t = $.extend(true, {}, s); - } else { - t = s; - } - if(obj.id === $.jstree.root) { - return this._append_json_data(obj, t, function (status) { - callback.call(this, status); - }); - } - else { - this._data.core.last_error = { 'error' : 'nodata', 'plugin' : 'core', 'id' : 'core_05', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id }) }; - this.settings.core.error.call(this, this._data.core.last_error); - return callback.call(this, false); - } - //return callback.call(this, (obj.id === $.jstree.root ? this._append_json_data(obj, t) : false) ); - } - if(typeof s === 'string') { - if(obj.id === $.jstree.root) { - return this._append_html_data(obj, $($.parseHTML(s)).filter(notTextOrCommentNode), function (status) { - callback.call(this, status); - }); - } - else { - this._data.core.last_error = { 'error' : 'nodata', 'plugin' : 'core', 'id' : 'core_06', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id }) }; - this.settings.core.error.call(this, this._data.core.last_error); - return callback.call(this, false); - } - //return callback.call(this, (obj.id === $.jstree.root ? this._append_html_data(obj, $(s)) : false) ); - } - return callback.call(this, false); - }, - /** - * adds a node to the list of nodes to redraw. Used only internally. - * @private - * @name _node_changed(obj [, callback]) - * @param {mixed} obj - */ - _node_changed : function (obj) { - obj = this.get_node(obj); - if (obj && $.inArray(obj.id, this._model.changed) === -1) { - this._model.changed.push(obj.id); - } - }, - /** - * appends HTML content to the tree. Used internally. - * @private - * @name _append_html_data(obj, data) - * @param {mixed} obj the node to append to - * @param {String} data the HTML string to parse and append - * @trigger model.jstree, changed.jstree - */ - _append_html_data : function (dom, data, cb) { - dom = this.get_node(dom); - dom.children = []; - dom.children_d = []; - var dat = data.is('ul') ? data.children() : data, - par = dom.id, - chd = [], - dpc = [], - m = this._model.data, - p = m[par], - s = this._data.core.selected.length, - tmp, i, j; - dat.each($.proxy(function (i, v) { - tmp = this._parse_model_from_html($(v), par, p.parents.concat()); - if(tmp) { - chd.push(tmp); - dpc.push(tmp); - if(m[tmp].children_d.length) { - dpc = dpc.concat(m[tmp].children_d); - } - } - }, this)); - p.children = chd; - p.children_d = dpc; - for(i = 0, j = p.parents.length; i < j; i++) { - m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc); - } - /** - * triggered when new data is inserted to the tree model - * @event - * @name model.jstree - * @param {Array} nodes an array of node IDs - * @param {String} parent the parent ID of the nodes - */ - this.trigger('model', { "nodes" : dpc, 'parent' : par }); - if(par !== $.jstree.root) { - this._node_changed(par); - this.redraw(); - } - else { - this.get_container_ul().children('.jstree-initial-node').remove(); - this.redraw(true); - } - if(this._data.core.selected.length !== s) { - this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected }); - } - cb.call(this, true); - }, - /** - * appends JSON content to the tree. Used internally. - * @private - * @name _append_json_data(obj, data) - * @param {mixed} obj the node to append to - * @param {String} data the JSON object to parse and append - * @param {Boolean} force_processing internal param - do not set - * @trigger model.jstree, changed.jstree - */ - _append_json_data : function (dom, data, cb, force_processing) { - if(this.element === null) { return; } - dom = this.get_node(dom); - dom.children = []; - dom.children_d = []; - // *%$@!!! - if(data.d) { - data = data.d; - if(typeof data === "string") { - data = JSON.parse(data); - } - } - if(!$.isArray(data)) { data = [data]; } - var w = null, - args = { - 'df' : this._model.default_state, - 'dat' : data, - 'par' : dom.id, - 'm' : this._model.data, - 't_id' : this._id, - 't_cnt' : this._cnt, - 'sel' : this._data.core.selected - }, - func = function (data, undefined) { - if(data.data) { data = data.data; } - var dat = data.dat, - par = data.par, - chd = [], - dpc = [], - add = [], - df = data.df, - t_id = data.t_id, - t_cnt = data.t_cnt, - m = data.m, - p = m[par], - sel = data.sel, - tmp, i, j, rslt, - parse_flat = function (d, p, ps) { - if(!ps) { ps = []; } - else { ps = ps.concat(); } - if(p) { ps.unshift(p); } - var tid = d.id.toString(), - i, j, c, e, - tmp = { - id : tid, - text : d.text || '', - icon : d.icon !== undefined ? d.icon : true, - parent : p, - parents : ps, - children : d.children || [], - children_d : d.children_d || [], - data : d.data, - state : { }, - li_attr : { id : false }, - a_attr : { href : '#' }, - original : false - }; - for(i in df) { - if(df.hasOwnProperty(i)) { - tmp.state[i] = df[i]; - } - } - if(d && d.data && d.data.jstree && d.data.jstree.icon) { - tmp.icon = d.data.jstree.icon; - } - if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") { - tmp.icon = true; - } - if(d && d.data) { - tmp.data = d.data; - if(d.data.jstree) { - for(i in d.data.jstree) { - if(d.data.jstree.hasOwnProperty(i)) { - tmp.state[i] = d.data.jstree[i]; - } - } - } - } - if(d && typeof d.state === 'object') { - for (i in d.state) { - if(d.state.hasOwnProperty(i)) { - tmp.state[i] = d.state[i]; - } - } - } - if(d && typeof d.li_attr === 'object') { - for (i in d.li_attr) { - if(d.li_attr.hasOwnProperty(i)) { - tmp.li_attr[i] = d.li_attr[i]; - } - } - } - if(!tmp.li_attr.id) { - tmp.li_attr.id = tid; - } - if(d && typeof d.a_attr === 'object') { - for (i in d.a_attr) { - if(d.a_attr.hasOwnProperty(i)) { - tmp.a_attr[i] = d.a_attr[i]; - } - } - } - if(d && d.children && d.children === true) { - tmp.state.loaded = false; - tmp.children = []; - tmp.children_d = []; - } - m[tmp.id] = tmp; - for(i = 0, j = tmp.children.length; i < j; i++) { - c = parse_flat(m[tmp.children[i]], tmp.id, ps); - e = m[c]; - tmp.children_d.push(c); - if(e.children_d.length) { - tmp.children_d = tmp.children_d.concat(e.children_d); - } - } - delete d.data; - delete d.children; - m[tmp.id].original = d; - if(tmp.state.selected) { - add.push(tmp.id); - } - return tmp.id; - }, - parse_nest = function (d, p, ps) { - if(!ps) { ps = []; } - else { ps = ps.concat(); } - if(p) { ps.unshift(p); } - var tid = false, i, j, c, e, tmp; - do { - tid = 'j' + t_id + '_' + (++t_cnt); - } while(m[tid]); - - tmp = { - id : false, - text : typeof d === 'string' ? d : '', - icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true, - parent : p, - parents : ps, - children : [], - children_d : [], - data : null, - state : { }, - li_attr : { id : false }, - a_attr : { href : '#' }, - original : false - }; - for(i in df) { - if(df.hasOwnProperty(i)) { - tmp.state[i] = df[i]; - } - } - if(d && d.id) { tmp.id = d.id.toString(); } - if(d && d.text) { tmp.text = d.text; } - if(d && d.data && d.data.jstree && d.data.jstree.icon) { - tmp.icon = d.data.jstree.icon; - } - if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") { - tmp.icon = true; - } - if(d && d.data) { - tmp.data = d.data; - if(d.data.jstree) { - for(i in d.data.jstree) { - if(d.data.jstree.hasOwnProperty(i)) { - tmp.state[i] = d.data.jstree[i]; - } - } - } - } - if(d && typeof d.state === 'object') { - for (i in d.state) { - if(d.state.hasOwnProperty(i)) { - tmp.state[i] = d.state[i]; - } - } - } - if(d && typeof d.li_attr === 'object') { - for (i in d.li_attr) { - if(d.li_attr.hasOwnProperty(i)) { - tmp.li_attr[i] = d.li_attr[i]; - } - } - } - if(tmp.li_attr.id && !tmp.id) { - tmp.id = tmp.li_attr.id.toString(); - } - if(!tmp.id) { - tmp.id = tid; - } - if(!tmp.li_attr.id) { - tmp.li_attr.id = tmp.id; - } - if(d && typeof d.a_attr === 'object') { - for (i in d.a_attr) { - if(d.a_attr.hasOwnProperty(i)) { - tmp.a_attr[i] = d.a_attr[i]; - } - } - } - if(d && d.children && d.children.length) { - for(i = 0, j = d.children.length; i < j; i++) { - c = parse_nest(d.children[i], tmp.id, ps); - e = m[c]; - tmp.children.push(c); - if(e.children_d.length) { - tmp.children_d = tmp.children_d.concat(e.children_d); - } - } - tmp.children_d = tmp.children_d.concat(tmp.children); - } - if(d && d.children && d.children === true) { - tmp.state.loaded = false; - tmp.children = []; - tmp.children_d = []; - } - delete d.data; - delete d.children; - tmp.original = d; - m[tmp.id] = tmp; - if(tmp.state.selected) { - add.push(tmp.id); - } - return tmp.id; - }; - - if(dat.length && dat[0].id !== undefined && dat[0].parent !== undefined) { - // Flat JSON support (for easy import from DB): - // 1) convert to object (foreach) - for(i = 0, j = dat.length; i < j; i++) { - if(!dat[i].children) { - dat[i].children = []; - } - if(!dat[i].state) { - dat[i].state = {}; - } - m[dat[i].id.toString()] = dat[i]; - } - // 2) populate children (foreach) - for(i = 0, j = dat.length; i < j; i++) { - if (!m[dat[i].parent.toString()]) { - this._data.core.last_error = { 'error' : 'parse', 'plugin' : 'core', 'id' : 'core_07', 'reason' : 'Node with invalid parent', 'data' : JSON.stringify({ 'id' : dat[i].id.toString(), 'parent' : dat[i].parent.toString() }) }; - this.settings.core.error.call(this, this._data.core.last_error); - continue; - } - - m[dat[i].parent.toString()].children.push(dat[i].id.toString()); - // populate parent.children_d - p.children_d.push(dat[i].id.toString()); - } - // 3) normalize && populate parents and children_d with recursion - for(i = 0, j = p.children.length; i < j; i++) { - tmp = parse_flat(m[p.children[i]], par, p.parents.concat()); - dpc.push(tmp); - if(m[tmp].children_d.length) { - dpc = dpc.concat(m[tmp].children_d); - } - } - for(i = 0, j = p.parents.length; i < j; i++) { - m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc); - } - // ?) three_state selection - p.state.selected && t - (if three_state foreach(dat => ch) -> foreach(parents) if(parent.selected) child.selected = true; - rslt = { - 'cnt' : t_cnt, - 'mod' : m, - 'sel' : sel, - 'par' : par, - 'dpc' : dpc, - 'add' : add - }; - } - else { - for(i = 0, j = dat.length; i < j; i++) { - tmp = parse_nest(dat[i], par, p.parents.concat()); - if(tmp) { - chd.push(tmp); - dpc.push(tmp); - if(m[tmp].children_d.length) { - dpc = dpc.concat(m[tmp].children_d); - } - } - } - p.children = chd; - p.children_d = dpc; - for(i = 0, j = p.parents.length; i < j; i++) { - m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc); - } - rslt = { - 'cnt' : t_cnt, - 'mod' : m, - 'sel' : sel, - 'par' : par, - 'dpc' : dpc, - 'add' : add - }; - } - if(typeof window === 'undefined' || typeof window.document === 'undefined') { - postMessage(rslt); - } - else { - return rslt; - } - }, - rslt = function (rslt, worker) { - if(this.element === null) { return; } - this._cnt = rslt.cnt; - var i, m = this._model.data; - for (i in m) { - if (m.hasOwnProperty(i) && m[i].state && m[i].state.loading && rslt.mod[i]) { - rslt.mod[i].state.loading = true; - } - } - this._model.data = rslt.mod; // breaks the reference in load_node - careful - - if(worker) { - var j, a = rslt.add, r = rslt.sel, s = this._data.core.selected.slice(); - m = this._model.data; - // if selection was changed while calculating in worker - if(r.length !== s.length || $.vakata.array_unique(r.concat(s)).length !== r.length) { - // deselect nodes that are no longer selected - for(i = 0, j = r.length; i < j; i++) { - if($.inArray(r[i], a) === -1 && $.inArray(r[i], s) === -1) { - m[r[i]].state.selected = false; - } - } - // select nodes that were selected in the mean time - for(i = 0, j = s.length; i < j; i++) { - if($.inArray(s[i], r) === -1) { - m[s[i]].state.selected = true; - } - } - } - } - if(rslt.add.length) { - this._data.core.selected = this._data.core.selected.concat(rslt.add); - } - - this.trigger('model', { "nodes" : rslt.dpc, 'parent' : rslt.par }); - - if(rslt.par !== $.jstree.root) { - this._node_changed(rslt.par); - this.redraw(); - } - else { - // this.get_container_ul().children('.jstree-initial-node').remove(); - this.redraw(true); - } - if(rslt.add.length) { - this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected }); - } - cb.call(this, true); - }; - if(this.settings.core.worker && window.Blob && window.URL && window.Worker) { - try { - if(this._wrk === null) { - this._wrk = window.URL.createObjectURL( - new window.Blob( - ['self.onmessage = ' + func.toString()], - {type:"text/javascript"} - ) - ); - } - if(!this._data.core.working || force_processing) { - this._data.core.working = true; - w = new window.Worker(this._wrk); - w.onmessage = $.proxy(function (e) { - rslt.call(this, e.data, true); - try { w.terminate(); w = null; } catch(ignore) { } - if(this._data.core.worker_queue.length) { - this._append_json_data.apply(this, this._data.core.worker_queue.shift()); - } - else { - this._data.core.working = false; - } - }, this); - if(!args.par) { - if(this._data.core.worker_queue.length) { - this._append_json_data.apply(this, this._data.core.worker_queue.shift()); - } - else { - this._data.core.working = false; - } - } - else { - w.postMessage(args); - } - } - else { - this._data.core.worker_queue.push([dom, data, cb, true]); - } - } - catch(e) { - rslt.call(this, func(args), false); - if(this._data.core.worker_queue.length) { - this._append_json_data.apply(this, this._data.core.worker_queue.shift()); - } - else { - this._data.core.working = false; - } - } - } - else { - rslt.call(this, func(args), false); - } - }, - /** - * parses a node from a jQuery object and appends them to the in memory tree model. Used internally. - * @private - * @name _parse_model_from_html(d [, p, ps]) - * @param {jQuery} d the jQuery object to parse - * @param {String} p the parent ID - * @param {Array} ps list of all parents - * @return {String} the ID of the object added to the model - */ - _parse_model_from_html : function (d, p, ps) { - if(!ps) { ps = []; } - else { ps = [].concat(ps); } - if(p) { ps.unshift(p); } - var c, e, m = this._model.data, - data = { - id : false, - text : false, - icon : true, - parent : p, - parents : ps, - children : [], - children_d : [], - data : null, - state : { }, - li_attr : { id : false }, - a_attr : { href : '#' }, - original : false - }, i, tmp, tid; - for(i in this._model.default_state) { - if(this._model.default_state.hasOwnProperty(i)) { - data.state[i] = this._model.default_state[i]; - } - } - tmp = $.vakata.attributes(d, true); - $.each(tmp, function (i, v) { - v = $.trim(v); - if(!v.length) { return true; } - data.li_attr[i] = v; - if(i === 'id') { - data.id = v.toString(); - } - }); - tmp = d.children('a').first(); - if(tmp.length) { - tmp = $.vakata.attributes(tmp, true); - $.each(tmp, function (i, v) { - v = $.trim(v); - if(v.length) { - data.a_attr[i] = v; - } - }); - } - tmp = d.children("a").first().length ? d.children("a").first().clone() : d.clone(); - tmp.children("ins, i, ul").remove(); - tmp = tmp.html(); - tmp = $('
').html(tmp); - data.text = this.settings.core.force_text ? tmp.text() : tmp.html(); - tmp = d.data(); - data.data = tmp ? $.extend(true, {}, tmp) : null; - data.state.opened = d.hasClass('jstree-open'); - data.state.selected = d.children('a').hasClass('jstree-clicked'); - data.state.disabled = d.children('a').hasClass('jstree-disabled'); - if(data.data && data.data.jstree) { - for(i in data.data.jstree) { - if(data.data.jstree.hasOwnProperty(i)) { - data.state[i] = data.data.jstree[i]; - } - } - } - tmp = d.children("a").children(".jstree-themeicon"); - if(tmp.length) { - data.icon = tmp.hasClass('jstree-themeicon-hidden') ? false : tmp.attr('rel'); - } - if(data.state.icon !== undefined) { - data.icon = data.state.icon; - } - if(data.icon === undefined || data.icon === null || data.icon === "") { - data.icon = true; - } - tmp = d.children("ul").children("li"); - do { - tid = 'j' + this._id + '_' + (++this._cnt); - } while(m[tid]); - data.id = data.li_attr.id ? data.li_attr.id.toString() : tid; - if(tmp.length) { - tmp.each($.proxy(function (i, v) { - c = this._parse_model_from_html($(v), data.id, ps); - e = this._model.data[c]; - data.children.push(c); - if(e.children_d.length) { - data.children_d = data.children_d.concat(e.children_d); - } - }, this)); - data.children_d = data.children_d.concat(data.children); - } - else { - if(d.hasClass('jstree-closed')) { - data.state.loaded = false; - } - } - if(data.li_attr['class']) { - data.li_attr['class'] = data.li_attr['class'].replace('jstree-closed','').replace('jstree-open',''); - } - if(data.a_attr['class']) { - data.a_attr['class'] = data.a_attr['class'].replace('jstree-clicked','').replace('jstree-disabled',''); - } - m[data.id] = data; - if(data.state.selected) { - this._data.core.selected.push(data.id); - } - return data.id; - }, - /** - * parses a node from a JSON object (used when dealing with flat data, which has no nesting of children, but has id and parent properties) and appends it to the in memory tree model. Used internally. - * @private - * @name _parse_model_from_flat_json(d [, p, ps]) - * @param {Object} d the JSON object to parse - * @param {String} p the parent ID - * @param {Array} ps list of all parents - * @return {String} the ID of the object added to the model - */ - _parse_model_from_flat_json : function (d, p, ps) { - if(!ps) { ps = []; } - else { ps = ps.concat(); } - if(p) { ps.unshift(p); } - var tid = d.id.toString(), - m = this._model.data, - df = this._model.default_state, - i, j, c, e, - tmp = { - id : tid, - text : d.text || '', - icon : d.icon !== undefined ? d.icon : true, - parent : p, - parents : ps, - children : d.children || [], - children_d : d.children_d || [], - data : d.data, - state : { }, - li_attr : { id : false }, - a_attr : { href : '#' }, - original : false - }; - for(i in df) { - if(df.hasOwnProperty(i)) { - tmp.state[i] = df[i]; - } - } - if(d && d.data && d.data.jstree && d.data.jstree.icon) { - tmp.icon = d.data.jstree.icon; - } - if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") { - tmp.icon = true; - } - if(d && d.data) { - tmp.data = d.data; - if(d.data.jstree) { - for(i in d.data.jstree) { - if(d.data.jstree.hasOwnProperty(i)) { - tmp.state[i] = d.data.jstree[i]; - } - } - } - } - if(d && typeof d.state === 'object') { - for (i in d.state) { - if(d.state.hasOwnProperty(i)) { - tmp.state[i] = d.state[i]; - } - } - } - if(d && typeof d.li_attr === 'object') { - for (i in d.li_attr) { - if(d.li_attr.hasOwnProperty(i)) { - tmp.li_attr[i] = d.li_attr[i]; - } - } - } - if(!tmp.li_attr.id) { - tmp.li_attr.id = tid; - } - if(d && typeof d.a_attr === 'object') { - for (i in d.a_attr) { - if(d.a_attr.hasOwnProperty(i)) { - tmp.a_attr[i] = d.a_attr[i]; - } - } - } - if(d && d.children && d.children === true) { - tmp.state.loaded = false; - tmp.children = []; - tmp.children_d = []; - } - m[tmp.id] = tmp; - for(i = 0, j = tmp.children.length; i < j; i++) { - c = this._parse_model_from_flat_json(m[tmp.children[i]], tmp.id, ps); - e = m[c]; - tmp.children_d.push(c); - if(e.children_d.length) { - tmp.children_d = tmp.children_d.concat(e.children_d); - } - } - delete d.data; - delete d.children; - m[tmp.id].original = d; - if(tmp.state.selected) { - this._data.core.selected.push(tmp.id); - } - return tmp.id; - }, - /** - * parses a node from a JSON object and appends it to the in memory tree model. Used internally. - * @private - * @name _parse_model_from_json(d [, p, ps]) - * @param {Object} d the JSON object to parse - * @param {String} p the parent ID - * @param {Array} ps list of all parents - * @return {String} the ID of the object added to the model - */ - _parse_model_from_json : function (d, p, ps) { - if(!ps) { ps = []; } - else { ps = ps.concat(); } - if(p) { ps.unshift(p); } - var tid = false, i, j, c, e, m = this._model.data, df = this._model.default_state, tmp; - do { - tid = 'j' + this._id + '_' + (++this._cnt); - } while(m[tid]); - - tmp = { - id : false, - text : typeof d === 'string' ? d : '', - icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true, - parent : p, - parents : ps, - children : [], - children_d : [], - data : null, - state : { }, - li_attr : { id : false }, - a_attr : { href : '#' }, - original : false - }; - for(i in df) { - if(df.hasOwnProperty(i)) { - tmp.state[i] = df[i]; - } - } - if(d && d.id) { tmp.id = d.id.toString(); } - if(d && d.text) { tmp.text = d.text; } - if(d && d.data && d.data.jstree && d.data.jstree.icon) { - tmp.icon = d.data.jstree.icon; - } - if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") { - tmp.icon = true; - } - if(d && d.data) { - tmp.data = d.data; - if(d.data.jstree) { - for(i in d.data.jstree) { - if(d.data.jstree.hasOwnProperty(i)) { - tmp.state[i] = d.data.jstree[i]; - } - } - } - } - if(d && typeof d.state === 'object') { - for (i in d.state) { - if(d.state.hasOwnProperty(i)) { - tmp.state[i] = d.state[i]; - } - } - } - if(d && typeof d.li_attr === 'object') { - for (i in d.li_attr) { - if(d.li_attr.hasOwnProperty(i)) { - tmp.li_attr[i] = d.li_attr[i]; - } - } - } - if(tmp.li_attr.id && !tmp.id) { - tmp.id = tmp.li_attr.id.toString(); - } - if(!tmp.id) { - tmp.id = tid; - } - if(!tmp.li_attr.id) { - tmp.li_attr.id = tmp.id; - } - if(d && typeof d.a_attr === 'object') { - for (i in d.a_attr) { - if(d.a_attr.hasOwnProperty(i)) { - tmp.a_attr[i] = d.a_attr[i]; - } - } - } - if(d && d.children && d.children.length) { - for(i = 0, j = d.children.length; i < j; i++) { - c = this._parse_model_from_json(d.children[i], tmp.id, ps); - e = m[c]; - tmp.children.push(c); - if(e.children_d.length) { - tmp.children_d = tmp.children_d.concat(e.children_d); - } - } - tmp.children_d = tmp.children_d.concat(tmp.children); - } - if(d && d.children && d.children === true) { - tmp.state.loaded = false; - tmp.children = []; - tmp.children_d = []; - } - delete d.data; - delete d.children; - tmp.original = d; - m[tmp.id] = tmp; - if(tmp.state.selected) { - this._data.core.selected.push(tmp.id); - } - return tmp.id; - }, - /** - * redraws all nodes that need to be redrawn. Used internally. - * @private - * @name _redraw() - * @trigger redraw.jstree - */ - _redraw : function () { - var nodes = this._model.force_full_redraw ? this._model.data[$.jstree.root].children.concat([]) : this._model.changed.concat([]), - f = document.createElement('UL'), tmp, i, j, fe = this._data.core.focused; - for(i = 0, j = nodes.length; i < j; i++) { - tmp = this.redraw_node(nodes[i], true, this._model.force_full_redraw); - if(tmp && this._model.force_full_redraw) { - f.appendChild(tmp); - } - } - if(this._model.force_full_redraw) { - f.className = this.get_container_ul()[0].className; - f.setAttribute('role','group'); - this.element.empty().append(f); - //this.get_container_ul()[0].appendChild(f); - } - if(fe !== null) { - tmp = this.get_node(fe, true); - if(tmp && tmp.length && tmp.children('.jstree-anchor')[0] !== document.activeElement) { - tmp.children('.jstree-anchor').focus(); - } - else { - this._data.core.focused = null; - } - } - this._model.force_full_redraw = false; - this._model.changed = []; - /** - * triggered after nodes are redrawn - * @event - * @name redraw.jstree - * @param {array} nodes the redrawn nodes - */ - this.trigger('redraw', { "nodes" : nodes }); - }, - /** - * redraws all nodes that need to be redrawn or optionally - the whole tree - * @name redraw([full]) - * @param {Boolean} full if set to `true` all nodes are redrawn. - */ - redraw : function (full) { - if(full) { - this._model.force_full_redraw = true; - } - //if(this._model.redraw_timeout) { - // clearTimeout(this._model.redraw_timeout); - //} - //this._model.redraw_timeout = setTimeout($.proxy(this._redraw, this),0); - this._redraw(); - }, - /** - * redraws a single node's children. Used internally. - * @private - * @name draw_children(node) - * @param {mixed} node the node whose children will be redrawn - */ - draw_children : function (node) { - var obj = this.get_node(node), - i = false, - j = false, - k = false, - d = document; - if(!obj) { return false; } - if(obj.id === $.jstree.root) { return this.redraw(true); } - node = this.get_node(node, true); - if(!node || !node.length) { return false; } // TODO: quick toggle - - node.children('.jstree-children').remove(); - node = node[0]; - if(obj.children.length && obj.state.loaded) { - k = d.createElement('UL'); - k.setAttribute('role', 'group'); - k.className = 'jstree-children'; - for(i = 0, j = obj.children.length; i < j; i++) { - k.appendChild(this.redraw_node(obj.children[i], true, true)); - } - node.appendChild(k); - } - }, - /** - * redraws a single node. Used internally. - * @private - * @name redraw_node(node, deep, is_callback, force_render) - * @param {mixed} node the node to redraw - * @param {Boolean} deep should child nodes be redrawn too - * @param {Boolean} is_callback is this a recursion call - * @param {Boolean} force_render should children of closed parents be drawn anyway - */ - redraw_node : function (node, deep, is_callback, force_render) { - var obj = this.get_node(node), - par = false, - ind = false, - old = false, - i = false, - j = false, - k = false, - c = '', - d = document, - m = this._model.data, - f = false, - s = false, - tmp = null, - t = 0, - l = 0, - has_children = false, - last_sibling = false; - if(!obj) { return false; } - if(obj.id === $.jstree.root) { return this.redraw(true); } - deep = deep || obj.children.length === 0; - node = !document.querySelector ? document.getElementById(obj.id) : this.element[0].querySelector('#' + ("0123456789".indexOf(obj.id[0]) !== -1 ? '\\3' + obj.id[0] + ' ' + obj.id.substr(1).replace($.jstree.idregex,'\\$&') : obj.id.replace($.jstree.idregex,'\\$&')) ); //, this.element); - if(!node) { - deep = true; - //node = d.createElement('LI'); - if(!is_callback) { - par = obj.parent !== $.jstree.root ? $('#' + obj.parent.replace($.jstree.idregex,'\\$&'), this.element)[0] : null; - if(par !== null && (!par || !m[obj.parent].state.opened)) { - return false; - } - ind = $.inArray(obj.id, par === null ? m[$.jstree.root].children : m[obj.parent].children); - } - } - else { - node = $(node); - if(!is_callback) { - par = node.parent().parent()[0]; - if(par === this.element[0]) { - par = null; - } - ind = node.index(); - } - // m[obj.id].data = node.data(); // use only node's data, no need to touch jquery storage - if(!deep && obj.children.length && !node.children('.jstree-children').length) { - deep = true; - } - if(!deep) { - old = node.children('.jstree-children')[0]; - } - f = node.children('.jstree-anchor')[0] === document.activeElement; - node.remove(); - //node = d.createElement('LI'); - //node = node[0]; - } - node = this._data.core.node.cloneNode(true); - // node is DOM, deep is boolean - - c = 'jstree-node '; - for(i in obj.li_attr) { - if(obj.li_attr.hasOwnProperty(i)) { - if(i === 'id') { continue; } - if(i !== 'class') { - node.setAttribute(i, obj.li_attr[i]); - } - else { - c += obj.li_attr[i]; - } - } - } - if(!obj.a_attr.id) { - obj.a_attr.id = obj.id + '_anchor'; - } - node.setAttribute('aria-selected', !!obj.state.selected); - node.setAttribute('aria-level', obj.parents.length); - node.setAttribute('aria-labelledby', obj.a_attr.id); - if(obj.state.disabled) { - node.setAttribute('aria-disabled', true); - } - - for(i = 0, j = obj.children.length; i < j; i++) { - if(!m[obj.children[i]].state.hidden) { - has_children = true; - break; - } - } - if(obj.parent !== null && m[obj.parent] && !obj.state.hidden) { - i = $.inArray(obj.id, m[obj.parent].children); - last_sibling = obj.id; - if(i !== -1) { - i++; - for(j = m[obj.parent].children.length; i < j; i++) { - if(!m[m[obj.parent].children[i]].state.hidden) { - last_sibling = m[obj.parent].children[i]; - } - if(last_sibling !== obj.id) { - break; - } - } - } - } - - if(obj.state.hidden) { - c += ' jstree-hidden'; - } - if (obj.state.loading) { - c += ' jstree-loading'; - } - if(obj.state.loaded && !has_children) { - c += ' jstree-leaf'; - } - else { - c += obj.state.opened && obj.state.loaded ? ' jstree-open' : ' jstree-closed'; - node.setAttribute('aria-expanded', (obj.state.opened && obj.state.loaded) ); - } - if(last_sibling === obj.id) { - c += ' jstree-last'; - } - node.id = obj.id; - node.className = c; - c = ( obj.state.selected ? ' jstree-clicked' : '') + ( obj.state.disabled ? ' jstree-disabled' : ''); - for(j in obj.a_attr) { - if(obj.a_attr.hasOwnProperty(j)) { - if(j === 'href' && obj.a_attr[j] === '#') { continue; } - if(j !== 'class') { - node.childNodes[1].setAttribute(j, obj.a_attr[j]); - } - else { - c += ' ' + obj.a_attr[j]; - } - } - } - if(c.length) { - node.childNodes[1].className = 'jstree-anchor ' + c; - } - if((obj.icon && obj.icon !== true) || obj.icon === false) { - if(obj.icon === false) { - node.childNodes[1].childNodes[0].className += ' jstree-themeicon-hidden'; - } - else if(obj.icon.indexOf('/') === -1 && obj.icon.indexOf('.') === -1) { - node.childNodes[1].childNodes[0].className += ' ' + obj.icon + ' jstree-themeicon-custom'; - } - else { - node.childNodes[1].childNodes[0].style.backgroundImage = 'url("'+obj.icon+'")'; - node.childNodes[1].childNodes[0].style.backgroundPosition = 'center center'; - node.childNodes[1].childNodes[0].style.backgroundSize = 'auto'; - node.childNodes[1].childNodes[0].className += ' jstree-themeicon-custom'; - } - } - - if(this.settings.core.force_text) { - node.childNodes[1].appendChild(d.createTextNode(obj.text)); - } - else { - node.childNodes[1].innerHTML += obj.text; - } - - - if(deep && obj.children.length && (obj.state.opened || force_render) && obj.state.loaded) { - k = d.createElement('UL'); - k.setAttribute('role', 'group'); - k.className = 'jstree-children'; - for(i = 0, j = obj.children.length; i < j; i++) { - k.appendChild(this.redraw_node(obj.children[i], deep, true)); - } - node.appendChild(k); - } - if(old) { - node.appendChild(old); - } - if(!is_callback) { - // append back using par / ind - if(!par) { - par = this.element[0]; - } - for(i = 0, j = par.childNodes.length; i < j; i++) { - if(par.childNodes[i] && par.childNodes[i].className && par.childNodes[i].className.indexOf('jstree-children') !== -1) { - tmp = par.childNodes[i]; - break; - } - } - if(!tmp) { - tmp = d.createElement('UL'); - tmp.setAttribute('role', 'group'); - tmp.className = 'jstree-children'; - par.appendChild(tmp); - } - par = tmp; - - if(ind < par.childNodes.length) { - par.insertBefore(node, par.childNodes[ind]); - } - else { - par.appendChild(node); - } - if(f) { - t = this.element[0].scrollTop; - l = this.element[0].scrollLeft; - node.childNodes[1].focus(); - this.element[0].scrollTop = t; - this.element[0].scrollLeft = l; - } - } - if(obj.state.opened && !obj.state.loaded) { - obj.state.opened = false; - setTimeout($.proxy(function () { - this.open_node(obj.id, false, 0); - }, this), 0); - } - return node; - }, - /** - * opens a node, revaling its children. If the node is not loaded it will be loaded and opened once ready. - * @name open_node(obj [, callback, animation]) - * @param {mixed} obj the node to open - * @param {Function} callback a function to execute once the node is opened - * @param {Number} animation the animation duration in milliseconds when opening the node (overrides the `core.animation` setting). Use `false` for no animation. - * @trigger open_node.jstree, after_open.jstree, before_open.jstree - */ - open_node : function (obj, callback, animation) { - var t1, t2, d, t; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.open_node(obj[t1], callback, animation); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - animation = animation === undefined ? this.settings.core.animation : animation; - if(!this.is_closed(obj)) { - if(callback) { - callback.call(this, obj, false); - } - return false; - } - if(!this.is_loaded(obj)) { - if(this.is_loading(obj)) { - return setTimeout($.proxy(function () { - this.open_node(obj, callback, animation); - }, this), 500); - } - this.load_node(obj, function (o, ok) { - return ok ? this.open_node(o, callback, animation) : (callback ? callback.call(this, o, false) : false); - }); - } - else { - d = this.get_node(obj, true); - t = this; - if(d.length) { - if(animation && d.children(".jstree-children").length) { - d.children(".jstree-children").stop(true, true); - } - if(obj.children.length && !this._firstChild(d.children('.jstree-children')[0])) { - this.draw_children(obj); - //d = this.get_node(obj, true); - } - if(!animation) { - this.trigger('before_open', { "node" : obj }); - d[0].className = d[0].className.replace('jstree-closed', 'jstree-open'); - d[0].setAttribute("aria-expanded", true); - } - else { - this.trigger('before_open', { "node" : obj }); - d - .children(".jstree-children").css("display","none").end() - .removeClass("jstree-closed").addClass("jstree-open").attr("aria-expanded", true) - .children(".jstree-children").stop(true, true) - .slideDown(animation, function () { - this.style.display = ""; - if (t.element) { - t.trigger("after_open", { "node" : obj }); - } - }); - } - } - obj.state.opened = true; - if(callback) { - callback.call(this, obj, true); - } - if(!d.length) { - /** - * triggered when a node is about to be opened (if the node is supposed to be in the DOM, it will be, but it won't be visible yet) - * @event - * @name before_open.jstree - * @param {Object} node the opened node - */ - this.trigger('before_open', { "node" : obj }); - } - /** - * triggered when a node is opened (if there is an animation it will not be completed yet) - * @event - * @name open_node.jstree - * @param {Object} node the opened node - */ - this.trigger('open_node', { "node" : obj }); - if(!animation || !d.length) { - /** - * triggered when a node is opened and the animation is complete - * @event - * @name after_open.jstree - * @param {Object} node the opened node - */ - this.trigger("after_open", { "node" : obj }); - } - return true; - } - }, - /** - * opens every parent of a node (node should be loaded) - * @name _open_to(obj) - * @param {mixed} obj the node to reveal - * @private - */ - _open_to : function (obj) { - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - var i, j, p = obj.parents; - for(i = 0, j = p.length; i < j; i+=1) { - if(i !== $.jstree.root) { - this.open_node(p[i], false, 0); - } - } - return $('#' + obj.id.replace($.jstree.idregex,'\\$&'), this.element); - }, - /** - * closes a node, hiding its children - * @name close_node(obj [, animation]) - * @param {mixed} obj the node to close - * @param {Number} animation the animation duration in milliseconds when closing the node (overrides the `core.animation` setting). Use `false` for no animation. - * @trigger close_node.jstree, after_close.jstree - */ - close_node : function (obj, animation) { - var t1, t2, t, d; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.close_node(obj[t1], animation); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - if(this.is_closed(obj)) { - return false; - } - animation = animation === undefined ? this.settings.core.animation : animation; - t = this; - d = this.get_node(obj, true); - - obj.state.opened = false; - /** - * triggered when a node is closed (if there is an animation it will not be complete yet) - * @event - * @name close_node.jstree - * @param {Object} node the closed node - */ - this.trigger('close_node',{ "node" : obj }); - if(!d.length) { - /** - * triggered when a node is closed and the animation is complete - * @event - * @name after_close.jstree - * @param {Object} node the closed node - */ - this.trigger("after_close", { "node" : obj }); - } - else { - if(!animation) { - d[0].className = d[0].className.replace('jstree-open', 'jstree-closed'); - d.attr("aria-expanded", false).children('.jstree-children').remove(); - this.trigger("after_close", { "node" : obj }); - } - else { - d - .children(".jstree-children").attr("style","display:block !important").end() - .removeClass("jstree-open").addClass("jstree-closed").attr("aria-expanded", false) - .children(".jstree-children").stop(true, true).slideUp(animation, function () { - this.style.display = ""; - d.children('.jstree-children').remove(); - if (t.element) { - t.trigger("after_close", { "node" : obj }); - } - }); - } - } - }, - /** - * toggles a node - closing it if it is open, opening it if it is closed - * @name toggle_node(obj) - * @param {mixed} obj the node to toggle - */ - toggle_node : function (obj) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.toggle_node(obj[t1]); - } - return true; - } - if(this.is_closed(obj)) { - return this.open_node(obj); - } - if(this.is_open(obj)) { - return this.close_node(obj); - } - }, - /** - * opens all nodes within a node (or the tree), revaling their children. If the node is not loaded it will be loaded and opened once ready. - * @name open_all([obj, animation, original_obj]) - * @param {mixed} obj the node to open recursively, omit to open all nodes in the tree - * @param {Number} animation the animation duration in milliseconds when opening the nodes, the default is no animation - * @param {jQuery} reference to the node that started the process (internal use) - * @trigger open_all.jstree - */ - open_all : function (obj, animation, original_obj) { - if(!obj) { obj = $.jstree.root; } - obj = this.get_node(obj); - if(!obj) { return false; } - var dom = obj.id === $.jstree.root ? this.get_container_ul() : this.get_node(obj, true), i, j, _this; - if(!dom.length) { - for(i = 0, j = obj.children_d.length; i < j; i++) { - if(this.is_closed(this._model.data[obj.children_d[i]])) { - this._model.data[obj.children_d[i]].state.opened = true; - } - } - return this.trigger('open_all', { "node" : obj }); - } - original_obj = original_obj || dom; - _this = this; - dom = this.is_closed(obj) ? dom.find('.jstree-closed').addBack() : dom.find('.jstree-closed'); - dom.each(function () { - _this.open_node( - this, - function(node, status) { if(status && this.is_parent(node)) { this.open_all(node, animation, original_obj); } }, - animation || 0 - ); - }); - if(original_obj.find('.jstree-closed').length === 0) { - /** - * triggered when an `open_all` call completes - * @event - * @name open_all.jstree - * @param {Object} node the opened node - */ - this.trigger('open_all', { "node" : this.get_node(original_obj) }); - } - }, - /** - * closes all nodes within a node (or the tree), revaling their children - * @name close_all([obj, animation]) - * @param {mixed} obj the node to close recursively, omit to close all nodes in the tree - * @param {Number} animation the animation duration in milliseconds when closing the nodes, the default is no animation - * @trigger close_all.jstree - */ - close_all : function (obj, animation) { - if(!obj) { obj = $.jstree.root; } - obj = this.get_node(obj); - if(!obj) { return false; } - var dom = obj.id === $.jstree.root ? this.get_container_ul() : this.get_node(obj, true), - _this = this, i, j; - if(dom.length) { - dom = this.is_open(obj) ? dom.find('.jstree-open').addBack() : dom.find('.jstree-open'); - $(dom.get().reverse()).each(function () { _this.close_node(this, animation || 0); }); - } - for(i = 0, j = obj.children_d.length; i < j; i++) { - this._model.data[obj.children_d[i]].state.opened = false; - } - /** - * triggered when an `close_all` call completes - * @event - * @name close_all.jstree - * @param {Object} node the closed node - */ - this.trigger('close_all', { "node" : obj }); - }, - /** - * checks if a node is disabled (not selectable) - * @name is_disabled(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_disabled : function (obj) { - obj = this.get_node(obj); - return obj && obj.state && obj.state.disabled; - }, - /** - * enables a node - so that it can be selected - * @name enable_node(obj) - * @param {mixed} obj the node to enable - * @trigger enable_node.jstree - */ - enable_node : function (obj) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.enable_node(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - obj.state.disabled = false; - this.get_node(obj,true).children('.jstree-anchor').removeClass('jstree-disabled').attr('aria-disabled', false); - /** - * triggered when an node is enabled - * @event - * @name enable_node.jstree - * @param {Object} node the enabled node - */ - this.trigger('enable_node', { 'node' : obj }); - }, - /** - * disables a node - so that it can not be selected - * @name disable_node(obj) - * @param {mixed} obj the node to disable - * @trigger disable_node.jstree - */ - disable_node : function (obj) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.disable_node(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - obj.state.disabled = true; - this.get_node(obj,true).children('.jstree-anchor').addClass('jstree-disabled').attr('aria-disabled', true); - /** - * triggered when an node is disabled - * @event - * @name disable_node.jstree - * @param {Object} node the disabled node - */ - this.trigger('disable_node', { 'node' : obj }); - }, - /** - * determines if a node is hidden - * @name is_hidden(obj) - * @param {mixed} obj the node - */ - is_hidden : function (obj) { - obj = this.get_node(obj); - return obj.state.hidden === true; - }, - /** - * hides a node - it is still in the structure but will not be visible - * @name hide_node(obj) - * @param {mixed} obj the node to hide - * @param {Boolean} skip_redraw internal parameter controlling if redraw is called - * @trigger hide_node.jstree - */ - hide_node : function (obj, skip_redraw) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.hide_node(obj[t1], true); - } - if (!skip_redraw) { - this.redraw(); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - if(!obj.state.hidden) { - obj.state.hidden = true; - this._node_changed(obj.parent); - if(!skip_redraw) { - this.redraw(); - } - /** - * triggered when an node is hidden - * @event - * @name hide_node.jstree - * @param {Object} node the hidden node - */ - this.trigger('hide_node', { 'node' : obj }); - } - }, - /** - * shows a node - * @name show_node(obj) - * @param {mixed} obj the node to show - * @param {Boolean} skip_redraw internal parameter controlling if redraw is called - * @trigger show_node.jstree - */ - show_node : function (obj, skip_redraw) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.show_node(obj[t1], true); - } - if (!skip_redraw) { - this.redraw(); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - if(obj.state.hidden) { - obj.state.hidden = false; - this._node_changed(obj.parent); - if(!skip_redraw) { - this.redraw(); - } - /** - * triggered when an node is shown - * @event - * @name show_node.jstree - * @param {Object} node the shown node - */ - this.trigger('show_node', { 'node' : obj }); - } - }, - /** - * hides all nodes - * @name hide_all() - * @trigger hide_all.jstree - */ - hide_all : function (skip_redraw) { - var i, m = this._model.data, ids = []; - for(i in m) { - if(m.hasOwnProperty(i) && i !== $.jstree.root && !m[i].state.hidden) { - m[i].state.hidden = true; - ids.push(i); - } - } - this._model.force_full_redraw = true; - if(!skip_redraw) { - this.redraw(); - } - /** - * triggered when all nodes are hidden - * @event - * @name hide_all.jstree - * @param {Array} nodes the IDs of all hidden nodes - */ - this.trigger('hide_all', { 'nodes' : ids }); - return ids; - }, - /** - * shows all nodes - * @name show_all() - * @trigger show_all.jstree - */ - show_all : function (skip_redraw) { - var i, m = this._model.data, ids = []; - for(i in m) { - if(m.hasOwnProperty(i) && i !== $.jstree.root && m[i].state.hidden) { - m[i].state.hidden = false; - ids.push(i); - } - } - this._model.force_full_redraw = true; - if(!skip_redraw) { - this.redraw(); - } - /** - * triggered when all nodes are shown - * @event - * @name show_all.jstree - * @param {Array} nodes the IDs of all shown nodes - */ - this.trigger('show_all', { 'nodes' : ids }); - return ids; - }, - /** - * called when a node is selected by the user. Used internally. - * @private - * @name activate_node(obj, e) - * @param {mixed} obj the node - * @param {Object} e the related event - * @trigger activate_node.jstree, changed.jstree - */ - activate_node : function (obj, e) { - if(this.is_disabled(obj)) { - return false; - } - if(!e || typeof e !== 'object') { - e = {}; - } - - // ensure last_clicked is still in the DOM, make it fresh (maybe it was moved?) and make sure it is still selected, if not - make last_clicked the last selected node - this._data.core.last_clicked = this._data.core.last_clicked && this._data.core.last_clicked.id !== undefined ? this.get_node(this._data.core.last_clicked.id) : null; - if(this._data.core.last_clicked && !this._data.core.last_clicked.state.selected) { this._data.core.last_clicked = null; } - if(!this._data.core.last_clicked && this._data.core.selected.length) { this._data.core.last_clicked = this.get_node(this._data.core.selected[this._data.core.selected.length - 1]); } - - if(!this.settings.core.multiple || (!e.metaKey && !e.ctrlKey && !e.shiftKey) || (e.shiftKey && (!this._data.core.last_clicked || !this.get_parent(obj) || this.get_parent(obj) !== this._data.core.last_clicked.parent ) )) { - if(!this.settings.core.multiple && (e.metaKey || e.ctrlKey || e.shiftKey) && this.is_selected(obj)) { - this.deselect_node(obj, false, e); - } - else { - this.deselect_all(true); - this.select_node(obj, false, false, e); - this._data.core.last_clicked = this.get_node(obj); - } - } - else { - if(e.shiftKey) { - var o = this.get_node(obj).id, - l = this._data.core.last_clicked.id, - p = this.get_node(this._data.core.last_clicked.parent).children, - c = false, - i, j; - for(i = 0, j = p.length; i < j; i += 1) { - // separate IFs work whem o and l are the same - if(p[i] === o) { - c = !c; - } - if(p[i] === l) { - c = !c; - } - if(!this.is_disabled(p[i]) && (c || p[i] === o || p[i] === l)) { - if (!this.is_hidden(p[i])) { - this.select_node(p[i], true, false, e); - } - } - else { - this.deselect_node(p[i], true, e); - } - } - this.trigger('changed', { 'action' : 'select_node', 'node' : this.get_node(obj), 'selected' : this._data.core.selected, 'event' : e }); - } - else { - if(!this.is_selected(obj)) { - this.select_node(obj, false, false, e); - } - else { - this.deselect_node(obj, false, e); - } - } - } - /** - * triggered when an node is clicked or intercated with by the user - * @event - * @name activate_node.jstree - * @param {Object} node - * @param {Object} event the ooriginal event (if any) which triggered the call (may be an empty object) - */ - this.trigger('activate_node', { 'node' : this.get_node(obj), 'event' : e }); - }, - /** - * applies the hover state on a node, called when a node is hovered by the user. Used internally. - * @private - * @name hover_node(obj) - * @param {mixed} obj - * @trigger hover_node.jstree - */ - hover_node : function (obj) { - obj = this.get_node(obj, true); - if(!obj || !obj.length || obj.children('.jstree-hovered').length) { - return false; - } - var o = this.element.find('.jstree-hovered'), t = this.element; - if(o && o.length) { this.dehover_node(o); } - - obj.children('.jstree-anchor').addClass('jstree-hovered'); - /** - * triggered when an node is hovered - * @event - * @name hover_node.jstree - * @param {Object} node - */ - this.trigger('hover_node', { 'node' : this.get_node(obj) }); - setTimeout(function () { t.attr('aria-activedescendant', obj[0].id); }, 0); - }, - /** - * removes the hover state from a nodecalled when a node is no longer hovered by the user. Used internally. - * @private - * @name dehover_node(obj) - * @param {mixed} obj - * @trigger dehover_node.jstree - */ - dehover_node : function (obj) { - obj = this.get_node(obj, true); - if(!obj || !obj.length || !obj.children('.jstree-hovered').length) { - return false; - } - obj.children('.jstree-anchor').removeClass('jstree-hovered'); - /** - * triggered when an node is no longer hovered - * @event - * @name dehover_node.jstree - * @param {Object} node - */ - this.trigger('dehover_node', { 'node' : this.get_node(obj) }); - }, - /** - * select a node - * @name select_node(obj [, supress_event, prevent_open]) - * @param {mixed} obj an array can be used to select multiple nodes - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @param {Boolean} prevent_open if set to `true` parents of the selected node won't be opened - * @trigger select_node.jstree, changed.jstree - */ - select_node : function (obj, supress_event, prevent_open, e) { - var dom, t1, t2, th; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.select_node(obj[t1], supress_event, prevent_open, e); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - dom = this.get_node(obj, true); - if(!obj.state.selected) { - obj.state.selected = true; - this._data.core.selected.push(obj.id); - if(!prevent_open) { - dom = this._open_to(obj); - } - if(dom && dom.length) { - dom.attr('aria-selected', true).children('.jstree-anchor').addClass('jstree-clicked'); - } - /** - * triggered when an node is selected - * @event - * @name select_node.jstree - * @param {Object} node - * @param {Array} selected the current selection - * @param {Object} event the event (if any) that triggered this select_node - */ - this.trigger('select_node', { 'node' : obj, 'selected' : this._data.core.selected, 'event' : e }); - if(!supress_event) { - /** - * triggered when selection changes - * @event - * @name changed.jstree - * @param {Object} node - * @param {Object} action the action that caused the selection to change - * @param {Array} selected the current selection - * @param {Object} event the event (if any) that triggered this changed event - */ - this.trigger('changed', { 'action' : 'select_node', 'node' : obj, 'selected' : this._data.core.selected, 'event' : e }); - } - } - }, - /** - * deselect a node - * @name deselect_node(obj [, supress_event]) - * @param {mixed} obj an array can be used to deselect multiple nodes - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @trigger deselect_node.jstree, changed.jstree - */ - deselect_node : function (obj, supress_event, e) { - var t1, t2, dom; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.deselect_node(obj[t1], supress_event, e); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - dom = this.get_node(obj, true); - if(obj.state.selected) { - obj.state.selected = false; - this._data.core.selected = $.vakata.array_remove_item(this._data.core.selected, obj.id); - if(dom.length) { - dom.attr('aria-selected', false).children('.jstree-anchor').removeClass('jstree-clicked'); - } - /** - * triggered when an node is deselected - * @event - * @name deselect_node.jstree - * @param {Object} node - * @param {Array} selected the current selection - * @param {Object} event the event (if any) that triggered this deselect_node - */ - this.trigger('deselect_node', { 'node' : obj, 'selected' : this._data.core.selected, 'event' : e }); - if(!supress_event) { - this.trigger('changed', { 'action' : 'deselect_node', 'node' : obj, 'selected' : this._data.core.selected, 'event' : e }); - } - } - }, - /** - * select all nodes in the tree - * @name select_all([supress_event]) - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @trigger select_all.jstree, changed.jstree - */ - select_all : function (supress_event) { - var tmp = this._data.core.selected.concat([]), i, j; - this._data.core.selected = this._model.data[$.jstree.root].children_d.concat(); - for(i = 0, j = this._data.core.selected.length; i < j; i++) { - if(this._model.data[this._data.core.selected[i]]) { - this._model.data[this._data.core.selected[i]].state.selected = true; - } - } - this.redraw(true); - /** - * triggered when all nodes are selected - * @event - * @name select_all.jstree - * @param {Array} selected the current selection - */ - this.trigger('select_all', { 'selected' : this._data.core.selected }); - if(!supress_event) { - this.trigger('changed', { 'action' : 'select_all', 'selected' : this._data.core.selected, 'old_selection' : tmp }); - } - }, - /** - * deselect all selected nodes - * @name deselect_all([supress_event]) - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @trigger deselect_all.jstree, changed.jstree - */ - deselect_all : function (supress_event) { - var tmp = this._data.core.selected.concat([]), i, j; - for(i = 0, j = this._data.core.selected.length; i < j; i++) { - if(this._model.data[this._data.core.selected[i]]) { - this._model.data[this._data.core.selected[i]].state.selected = false; - } - } - this._data.core.selected = []; - this.element.find('.jstree-clicked').removeClass('jstree-clicked').parent().attr('aria-selected', false); - /** - * triggered when all nodes are deselected - * @event - * @name deselect_all.jstree - * @param {Object} node the previous selection - * @param {Array} selected the current selection - */ - this.trigger('deselect_all', { 'selected' : this._data.core.selected, 'node' : tmp }); - if(!supress_event) { - this.trigger('changed', { 'action' : 'deselect_all', 'selected' : this._data.core.selected, 'old_selection' : tmp }); - } - }, - /** - * checks if a node is selected - * @name is_selected(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_selected : function (obj) { - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - return obj.state.selected; - }, - /** - * get an array of all selected nodes - * @name get_selected([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - */ - get_selected : function (full) { - return full ? $.map(this._data.core.selected, $.proxy(function (i) { return this.get_node(i); }, this)) : this._data.core.selected.slice(); - }, - /** - * get an array of all top level selected nodes (ignoring children of selected nodes) - * @name get_top_selected([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - */ - get_top_selected : function (full) { - var tmp = this.get_selected(true), - obj = {}, i, j, k, l; - for(i = 0, j = tmp.length; i < j; i++) { - obj[tmp[i].id] = tmp[i]; - } - for(i = 0, j = tmp.length; i < j; i++) { - for(k = 0, l = tmp[i].children_d.length; k < l; k++) { - if(obj[tmp[i].children_d[k]]) { - delete obj[tmp[i].children_d[k]]; - } - } - } - tmp = []; - for(i in obj) { - if(obj.hasOwnProperty(i)) { - tmp.push(i); - } - } - return full ? $.map(tmp, $.proxy(function (i) { return this.get_node(i); }, this)) : tmp; - }, - /** - * get an array of all bottom level selected nodes (ignoring selected parents) - * @name get_bottom_selected([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - */ - get_bottom_selected : function (full) { - var tmp = this.get_selected(true), - obj = [], i, j; - for(i = 0, j = tmp.length; i < j; i++) { - if(!tmp[i].children.length) { - obj.push(tmp[i].id); - } - } - return full ? $.map(obj, $.proxy(function (i) { return this.get_node(i); }, this)) : obj; - }, - /** - * gets the current state of the tree so that it can be restored later with `set_state(state)`. Used internally. - * @name get_state() - * @private - * @return {Object} - */ - get_state : function () { - var state = { - 'core' : { - 'open' : [], - 'loaded' : [], - 'scroll' : { - 'left' : this.element.scrollLeft(), - 'top' : this.element.scrollTop() - }, - /*! - 'themes' : { - 'name' : this.get_theme(), - 'icons' : this._data.core.themes.icons, - 'dots' : this._data.core.themes.dots - }, - */ - 'selected' : [] - } - }, i; - for(i in this._model.data) { - if(this._model.data.hasOwnProperty(i)) { - if(i !== $.jstree.root) { - if(this._model.data[i].state.loaded && this.settings.core.loaded_state) { - state.core.loaded.push(i); - } - if(this._model.data[i].state.opened) { - state.core.open.push(i); - } - if(this._model.data[i].state.selected) { - state.core.selected.push(i); - } - } - } - } - return state; - }, - /** - * sets the state of the tree. Used internally. - * @name set_state(state [, callback]) - * @private - * @param {Object} state the state to restore. Keep in mind this object is passed by reference and jstree will modify it. - * @param {Function} callback an optional function to execute once the state is restored. - * @trigger set_state.jstree - */ - set_state : function (state, callback) { - if(state) { - if(state.core && state.core.selected && state.core.initial_selection === undefined) { - state.core.initial_selection = this._data.core.selected.concat([]).sort().join(','); - } - if(state.core) { - var res, n, t, _this, i; - if(state.core.loaded) { - if(!this.settings.core.loaded_state || !$.isArray(state.core.loaded) || !state.core.loaded.length) { - delete state.core.loaded; - this.set_state(state, callback); - } - else { - this._load_nodes(state.core.loaded, function (nodes) { - delete state.core.loaded; - this.set_state(state, callback); - }); - } - return false; - } - if(state.core.open) { - if(!$.isArray(state.core.open) || !state.core.open.length) { - delete state.core.open; - this.set_state(state, callback); - } - else { - this._load_nodes(state.core.open, function (nodes) { - this.open_node(nodes, false, 0); - delete state.core.open; - this.set_state(state, callback); - }); - } - return false; - } - if(state.core.scroll) { - if(state.core.scroll && state.core.scroll.left !== undefined) { - this.element.scrollLeft(state.core.scroll.left); - } - if(state.core.scroll && state.core.scroll.top !== undefined) { - this.element.scrollTop(state.core.scroll.top); - } - delete state.core.scroll; - this.set_state(state, callback); - return false; - } - if(state.core.selected) { - _this = this; - if (state.core.initial_selection === undefined || - state.core.initial_selection === this._data.core.selected.concat([]).sort().join(',') - ) { - this.deselect_all(); - $.each(state.core.selected, function (i, v) { - _this.select_node(v, false, true); - }); - } - delete state.core.initial_selection; - delete state.core.selected; - this.set_state(state, callback); - return false; - } - for(i in state) { - if(state.hasOwnProperty(i) && i !== "core" && $.inArray(i, this.settings.plugins) === -1) { - delete state[i]; - } - } - if($.isEmptyObject(state.core)) { - delete state.core; - this.set_state(state, callback); - return false; - } - } - if($.isEmptyObject(state)) { - state = null; - if(callback) { callback.call(this); } - /** - * triggered when a `set_state` call completes - * @event - * @name set_state.jstree - */ - this.trigger('set_state'); - return false; - } - return true; - } - return false; - }, - /** - * refreshes the tree - all nodes are reloaded with calls to `load_node`. - * @name refresh() - * @param {Boolean} skip_loading an option to skip showing the loading indicator - * @param {Mixed} forget_state if set to `true` state will not be reapplied, if set to a function (receiving the current state as argument) the result of that function will be used as state - * @trigger refresh.jstree - */ - refresh : function (skip_loading, forget_state) { - this._data.core.state = forget_state === true ? {} : this.get_state(); - if(forget_state && $.isFunction(forget_state)) { this._data.core.state = forget_state.call(this, this._data.core.state); } - this._cnt = 0; - this._model.data = {}; - this._model.data[$.jstree.root] = { - id : $.jstree.root, - parent : null, - parents : [], - children : [], - children_d : [], - state : { loaded : false } - }; - this._data.core.selected = []; - this._data.core.last_clicked = null; - this._data.core.focused = null; - - var c = this.get_container_ul()[0].className; - if(!skip_loading) { - this.element.html("<"+"ul class='"+c+"' role='group'><"+"li class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='treeitem' id='j"+this._id+"_loading'><"+"a class='jstree-anchor' href='#'>" + this.get_string("Loading ...") + ""); - this.element.attr('aria-activedescendant','j'+this._id+'_loading'); - } - this.load_node($.jstree.root, function (o, s) { - if(s) { - this.get_container_ul()[0].className = c; - if(this._firstChild(this.get_container_ul()[0])) { - this.element.attr('aria-activedescendant',this._firstChild(this.get_container_ul()[0]).id); - } - this.set_state($.extend(true, {}, this._data.core.state), function () { - /** - * triggered when a `refresh` call completes - * @event - * @name refresh.jstree - */ - this.trigger('refresh'); - }); - } - this._data.core.state = null; - }); - }, - /** - * refreshes a node in the tree (reload its children) all opened nodes inside that node are reloaded with calls to `load_node`. - * @name refresh_node(obj) - * @param {mixed} obj the node - * @trigger refresh_node.jstree - */ - refresh_node : function (obj) { - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { return false; } - var opened = [], to_load = [], s = this._data.core.selected.concat([]); - to_load.push(obj.id); - if(obj.state.opened === true) { opened.push(obj.id); } - this.get_node(obj, true).find('.jstree-open').each(function() { to_load.push(this.id); opened.push(this.id); }); - this._load_nodes(to_load, $.proxy(function (nodes) { - this.open_node(opened, false, 0); - this.select_node(s); - /** - * triggered when a node is refreshed - * @event - * @name refresh_node.jstree - * @param {Object} node - the refreshed node - * @param {Array} nodes - an array of the IDs of the nodes that were reloaded - */ - this.trigger('refresh_node', { 'node' : obj, 'nodes' : nodes }); - }, this), false, true); - }, - /** - * set (change) the ID of a node - * @name set_id(obj, id) - * @param {mixed} obj the node - * @param {String} id the new ID - * @return {Boolean} - * @trigger set_id.jstree - */ - set_id : function (obj, id) { - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { return false; } - var i, j, m = this._model.data, old = obj.id; - id = id.toString(); - // update parents (replace current ID with new one in children and children_d) - m[obj.parent].children[$.inArray(obj.id, m[obj.parent].children)] = id; - for(i = 0, j = obj.parents.length; i < j; i++) { - m[obj.parents[i]].children_d[$.inArray(obj.id, m[obj.parents[i]].children_d)] = id; - } - // update children (replace current ID with new one in parent and parents) - for(i = 0, j = obj.children.length; i < j; i++) { - m[obj.children[i]].parent = id; - } - for(i = 0, j = obj.children_d.length; i < j; i++) { - m[obj.children_d[i]].parents[$.inArray(obj.id, m[obj.children_d[i]].parents)] = id; - } - i = $.inArray(obj.id, this._data.core.selected); - if(i !== -1) { this._data.core.selected[i] = id; } - // update model and obj itself (obj.id, this._model.data[KEY]) - i = this.get_node(obj.id, true); - if(i) { - i.attr('id', id); //.children('.jstree-anchor').attr('id', id + '_anchor').end().attr('aria-labelledby', id + '_anchor'); - if(this.element.attr('aria-activedescendant') === obj.id) { - this.element.attr('aria-activedescendant', id); - } - } - delete m[obj.id]; - obj.id = id; - obj.li_attr.id = id; - m[id] = obj; - /** - * triggered when a node id value is changed - * @event - * @name set_id.jstree - * @param {Object} node - * @param {String} old the old id - */ - this.trigger('set_id',{ "node" : obj, "new" : obj.id, "old" : old }); - return true; - }, - /** - * get the text value of a node - * @name get_text(obj) - * @param {mixed} obj the node - * @return {String} - */ - get_text : function (obj) { - obj = this.get_node(obj); - return (!obj || obj.id === $.jstree.root) ? false : obj.text; - }, - /** - * set the text value of a node. Used internally, please use `rename_node(obj, val)`. - * @private - * @name set_text(obj, val) - * @param {mixed} obj the node, you can pass an array to set the text on multiple nodes - * @param {String} val the new text value - * @return {Boolean} - * @trigger set_text.jstree - */ - set_text : function (obj, val) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.set_text(obj[t1], val); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { return false; } - obj.text = val; - if(this.get_node(obj, true).length) { - this.redraw_node(obj.id); - } - /** - * triggered when a node text value is changed - * @event - * @name set_text.jstree - * @param {Object} obj - * @param {String} text the new value - */ - this.trigger('set_text',{ "obj" : obj, "text" : val }); - return true; - }, - /** - * gets a JSON representation of a node (or the whole tree) - * @name get_json([obj, options]) - * @param {mixed} obj - * @param {Object} options - * @param {Boolean} options.no_state do not return state information - * @param {Boolean} options.no_id do not return ID - * @param {Boolean} options.no_children do not include children - * @param {Boolean} options.no_data do not include node data - * @param {Boolean} options.no_li_attr do not include LI attributes - * @param {Boolean} options.no_a_attr do not include A attributes - * @param {Boolean} options.flat return flat JSON instead of nested - * @return {Object} - */ - get_json : function (obj, options, flat) { - obj = this.get_node(obj || $.jstree.root); - if(!obj) { return false; } - if(options && options.flat && !flat) { flat = []; } - var tmp = { - 'id' : obj.id, - 'text' : obj.text, - 'icon' : this.get_icon(obj), - 'li_attr' : $.extend(true, {}, obj.li_attr), - 'a_attr' : $.extend(true, {}, obj.a_attr), - 'state' : {}, - 'data' : options && options.no_data ? false : $.extend(true, $.isArray(obj.data)?[]:{}, obj.data) - //( this.get_node(obj, true).length ? this.get_node(obj, true).data() : obj.data ), - }, i, j; - if(options && options.flat) { - tmp.parent = obj.parent; - } - else { - tmp.children = []; - } - if(!options || !options.no_state) { - for(i in obj.state) { - if(obj.state.hasOwnProperty(i)) { - tmp.state[i] = obj.state[i]; - } - } - } else { - delete tmp.state; - } - if(options && options.no_li_attr) { - delete tmp.li_attr; - } - if(options && options.no_a_attr) { - delete tmp.a_attr; - } - if(options && options.no_id) { - delete tmp.id; - if(tmp.li_attr && tmp.li_attr.id) { - delete tmp.li_attr.id; - } - if(tmp.a_attr && tmp.a_attr.id) { - delete tmp.a_attr.id; - } - } - if(options && options.flat && obj.id !== $.jstree.root) { - flat.push(tmp); - } - if(!options || !options.no_children) { - for(i = 0, j = obj.children.length; i < j; i++) { - if(options && options.flat) { - this.get_json(obj.children[i], options, flat); - } - else { - tmp.children.push(this.get_json(obj.children[i], options)); - } - } - } - return options && options.flat ? flat : (obj.id === $.jstree.root ? tmp.children : tmp); - }, - /** - * create a new node (do not confuse with load_node) - * @name create_node([par, node, pos, callback, is_loaded]) - * @param {mixed} par the parent node (to create a root node use either "#" (string) or `null`) - * @param {mixed} node the data for the new node (a valid JSON object, or a simple string with the name) - * @param {mixed} pos the index at which to insert the node, "first" and "last" are also supported, default is "last" - * @param {Function} callback a function to be called once the node is created - * @param {Boolean} is_loaded internal argument indicating if the parent node was succesfully loaded - * @return {String} the ID of the newly create node - * @trigger model.jstree, create_node.jstree - */ - create_node : function (par, node, pos, callback, is_loaded) { - if(par === null) { par = $.jstree.root; } - par = this.get_node(par); - if(!par) { return false; } - pos = pos === undefined ? "last" : pos; - if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { - return this.load_node(par, function () { this.create_node(par, node, pos, callback, true); }); - } - if(!node) { node = { "text" : this.get_string('New node') }; } - if(typeof node === "string") { - node = { "text" : node }; - } else { - node = $.extend(true, {}, node); - } - if(node.text === undefined) { node.text = this.get_string('New node'); } - var tmp, dpc, i, j; - - if(par.id === $.jstree.root) { - if(pos === "before") { pos = "first"; } - if(pos === "after") { pos = "last"; } - } - switch(pos) { - case "before": - tmp = this.get_node(par.parent); - pos = $.inArray(par.id, tmp.children); - par = tmp; - break; - case "after" : - tmp = this.get_node(par.parent); - pos = $.inArray(par.id, tmp.children) + 1; - par = tmp; - break; - case "inside": - case "first": - pos = 0; - break; - case "last": - pos = par.children.length; - break; - default: - if(!pos) { pos = 0; } - break; - } - if(pos > par.children.length) { pos = par.children.length; } - if(!node.id) { node.id = true; } - if(!this.check("create_node", node, par, pos)) { - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - if(node.id === true) { delete node.id; } - node = this._parse_model_from_json(node, par.id, par.parents.concat()); - if(!node) { return false; } - tmp = this.get_node(node); - dpc = []; - dpc.push(node); - dpc = dpc.concat(tmp.children_d); - this.trigger('model', { "nodes" : dpc, "parent" : par.id }); - - par.children_d = par.children_d.concat(dpc); - for(i = 0, j = par.parents.length; i < j; i++) { - this._model.data[par.parents[i]].children_d = this._model.data[par.parents[i]].children_d.concat(dpc); - } - node = tmp; - tmp = []; - for(i = 0, j = par.children.length; i < j; i++) { - tmp[i >= pos ? i+1 : i] = par.children[i]; - } - tmp[pos] = node.id; - par.children = tmp; - - this.redraw_node(par, true); - /** - * triggered when a node is created - * @event - * @name create_node.jstree - * @param {Object} node - * @param {String} parent the parent's ID - * @param {Number} position the position of the new node among the parent's children - */ - this.trigger('create_node', { "node" : this.get_node(node), "parent" : par.id, "position" : pos }); - if(callback) { callback.call(this, this.get_node(node)); } - return node.id; - }, - /** - * set the text value of a node - * @name rename_node(obj, val) - * @param {mixed} obj the node, you can pass an array to rename multiple nodes to the same name - * @param {String} val the new text value - * @return {Boolean} - * @trigger rename_node.jstree - */ - rename_node : function (obj, val) { - var t1, t2, old; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.rename_node(obj[t1], val); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { return false; } - old = obj.text; - if(!this.check("rename_node", obj, this.get_parent(obj), val)) { - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - this.set_text(obj, val); // .apply(this, Array.prototype.slice.call(arguments)) - /** - * triggered when a node is renamed - * @event - * @name rename_node.jstree - * @param {Object} node - * @param {String} text the new value - * @param {String} old the old value - */ - this.trigger('rename_node', { "node" : obj, "text" : val, "old" : old }); - return true; - }, - /** - * remove a node - * @name delete_node(obj) - * @param {mixed} obj the node, you can pass an array to delete multiple nodes - * @return {Boolean} - * @trigger delete_node.jstree, changed.jstree - */ - delete_node : function (obj) { - var t1, t2, par, pos, tmp, i, j, k, l, c, top, lft; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.delete_node(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { return false; } - par = this.get_node(obj.parent); - pos = $.inArray(obj.id, par.children); - c = false; - if(!this.check("delete_node", obj, par, pos)) { - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - if(pos !== -1) { - par.children = $.vakata.array_remove(par.children, pos); - } - tmp = obj.children_d.concat([]); - tmp.push(obj.id); - for(i = 0, j = obj.parents.length; i < j; i++) { - this._model.data[obj.parents[i]].children_d = $.vakata.array_filter(this._model.data[obj.parents[i]].children_d, function (v) { - return $.inArray(v, tmp) === -1; - }); - } - for(k = 0, l = tmp.length; k < l; k++) { - if(this._model.data[tmp[k]].state.selected) { - c = true; - break; - } - } - if (c) { - this._data.core.selected = $.vakata.array_filter(this._data.core.selected, function (v) { - return $.inArray(v, tmp) === -1; - }); - } - /** - * triggered when a node is deleted - * @event - * @name delete_node.jstree - * @param {Object} node - * @param {String} parent the parent's ID - */ - this.trigger('delete_node', { "node" : obj, "parent" : par.id }); - if(c) { - this.trigger('changed', { 'action' : 'delete_node', 'node' : obj, 'selected' : this._data.core.selected, 'parent' : par.id }); - } - for(k = 0, l = tmp.length; k < l; k++) { - delete this._model.data[tmp[k]]; - } - if($.inArray(this._data.core.focused, tmp) !== -1) { - this._data.core.focused = null; - top = this.element[0].scrollTop; - lft = this.element[0].scrollLeft; - if(par.id === $.jstree.root) { - if (this._model.data[$.jstree.root].children[0]) { - this.get_node(this._model.data[$.jstree.root].children[0], true).children('.jstree-anchor').focus(); - } - } - else { - this.get_node(par, true).children('.jstree-anchor').focus(); - } - this.element[0].scrollTop = top; - this.element[0].scrollLeft = lft; - } - this.redraw_node(par, true); - return true; - }, - /** - * check if an operation is premitted on the tree. Used internally. - * @private - * @name check(chk, obj, par, pos) - * @param {String} chk the operation to check, can be "create_node", "rename_node", "delete_node", "copy_node" or "move_node" - * @param {mixed} obj the node - * @param {mixed} par the parent - * @param {mixed} pos the position to insert at, or if "rename_node" - the new name - * @param {mixed} more some various additional information, for example if a "move_node" operations is triggered by DND this will be the hovered node - * @return {Boolean} - */ - check : function (chk, obj, par, pos, more) { - obj = obj && obj.id ? obj : this.get_node(obj); - par = par && par.id ? par : this.get_node(par); - var tmp = chk.match(/^move_node|copy_node|create_node$/i) ? par : obj, - chc = this.settings.core.check_callback; - if(chk === "move_node" || chk === "copy_node") { - if((!more || !more.is_multi) && (obj.id === par.id || (chk === "move_node" && $.inArray(obj.id, par.children) === pos) || $.inArray(par.id, obj.children_d) !== -1)) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_01', 'reason' : 'Moving parent inside child', 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - return false; - } - } - if(tmp && tmp.data) { tmp = tmp.data; } - if(tmp && tmp.functions && (tmp.functions[chk] === false || tmp.functions[chk] === true)) { - if(tmp.functions[chk] === false) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_02', 'reason' : 'Node data prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - } - return tmp.functions[chk]; - } - if(chc === false || ($.isFunction(chc) && chc.call(this, chk, obj, par, pos, more) === false) || (chc && chc[chk] === false)) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_03', 'reason' : 'User config for core.check_callback prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - return false; - } - return true; - }, - /** - * get the last error - * @name last_error() - * @return {Object} - */ - last_error : function () { - return this._data.core.last_error; - }, - /** - * move a node to a new parent - * @name move_node(obj, par [, pos, callback, is_loaded]) - * @param {mixed} obj the node to move, pass an array to move multiple nodes - * @param {mixed} par the new parent - * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0` - * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position - * @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded - * @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn - * @param {Boolean} instance internal parameter indicating if the node comes from another instance - * @trigger move_node.jstree - */ - move_node : function (obj, par, pos, callback, is_loaded, skip_redraw, origin) { - var t1, t2, old_par, old_pos, new_par, old_ins, is_multi, dpc, tmp, i, j, k, l, p; - - par = this.get_node(par); - pos = pos === undefined ? 0 : pos; - if(!par) { return false; } - if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { - return this.load_node(par, function () { this.move_node(obj, par, pos, callback, true, false, origin); }); - } - - if($.isArray(obj)) { - if(obj.length === 1) { - obj = obj[0]; - } - else { - //obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - if((tmp = this.move_node(obj[t1], par, pos, callback, is_loaded, false, origin))) { - par = tmp; - pos = "after"; - } - } - this.redraw(); - return true; - } - } - obj = obj && obj.id ? obj : this.get_node(obj); - - if(!obj || obj.id === $.jstree.root) { return false; } - - old_par = (obj.parent || $.jstree.root).toString(); - new_par = (!pos.toString().match(/^(before|after)$/) || par.id === $.jstree.root) ? par : this.get_node(par.parent); - old_ins = origin ? origin : (this._model.data[obj.id] ? this : $.jstree.reference(obj.id)); - is_multi = !old_ins || !old_ins._id || (this._id !== old_ins._id); - old_pos = old_ins && old_ins._id && old_par && old_ins._model.data[old_par] && old_ins._model.data[old_par].children ? $.inArray(obj.id, old_ins._model.data[old_par].children) : -1; - if(old_ins && old_ins._id) { - obj = old_ins._model.data[obj.id]; - } - - if(is_multi) { - if((tmp = this.copy_node(obj, par, pos, callback, is_loaded, false, origin))) { - if(old_ins) { old_ins.delete_node(obj); } - return tmp; - } - return false; - } - //var m = this._model.data; - if(par.id === $.jstree.root) { - if(pos === "before") { pos = "first"; } - if(pos === "after") { pos = "last"; } - } - switch(pos) { - case "before": - pos = $.inArray(par.id, new_par.children); - break; - case "after" : - pos = $.inArray(par.id, new_par.children) + 1; - break; - case "inside": - case "first": - pos = 0; - break; - case "last": - pos = new_par.children.length; - break; - default: - if(!pos) { pos = 0; } - break; - } - if(pos > new_par.children.length) { pos = new_par.children.length; } - if(!this.check("move_node", obj, new_par, pos, { 'core' : true, 'origin' : origin, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) { - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - if(obj.parent === new_par.id) { - dpc = new_par.children.concat(); - tmp = $.inArray(obj.id, dpc); - if(tmp !== -1) { - dpc = $.vakata.array_remove(dpc, tmp); - if(pos > tmp) { pos--; } - } - tmp = []; - for(i = 0, j = dpc.length; i < j; i++) { - tmp[i >= pos ? i+1 : i] = dpc[i]; - } - tmp[pos] = obj.id; - new_par.children = tmp; - this._node_changed(new_par.id); - this.redraw(new_par.id === $.jstree.root); - } - else { - // clean old parent and up - tmp = obj.children_d.concat(); - tmp.push(obj.id); - for(i = 0, j = obj.parents.length; i < j; i++) { - dpc = []; - p = old_ins._model.data[obj.parents[i]].children_d; - for(k = 0, l = p.length; k < l; k++) { - if($.inArray(p[k], tmp) === -1) { - dpc.push(p[k]); - } - } - old_ins._model.data[obj.parents[i]].children_d = dpc; - } - old_ins._model.data[old_par].children = $.vakata.array_remove_item(old_ins._model.data[old_par].children, obj.id); - - // insert into new parent and up - for(i = 0, j = new_par.parents.length; i < j; i++) { - this._model.data[new_par.parents[i]].children_d = this._model.data[new_par.parents[i]].children_d.concat(tmp); - } - dpc = []; - for(i = 0, j = new_par.children.length; i < j; i++) { - dpc[i >= pos ? i+1 : i] = new_par.children[i]; - } - dpc[pos] = obj.id; - new_par.children = dpc; - new_par.children_d.push(obj.id); - new_par.children_d = new_par.children_d.concat(obj.children_d); - - // update object - obj.parent = new_par.id; - tmp = new_par.parents.concat(); - tmp.unshift(new_par.id); - p = obj.parents.length; - obj.parents = tmp; - - // update object children - tmp = tmp.concat(); - for(i = 0, j = obj.children_d.length; i < j; i++) { - this._model.data[obj.children_d[i]].parents = this._model.data[obj.children_d[i]].parents.slice(0,p*-1); - Array.prototype.push.apply(this._model.data[obj.children_d[i]].parents, tmp); - } - - if(old_par === $.jstree.root || new_par.id === $.jstree.root) { - this._model.force_full_redraw = true; - } - if(!this._model.force_full_redraw) { - this._node_changed(old_par); - this._node_changed(new_par.id); - } - if(!skip_redraw) { - this.redraw(); - } - } - if(callback) { callback.call(this, obj, new_par, pos); } - /** - * triggered when a node is moved - * @event - * @name move_node.jstree - * @param {Object} node - * @param {String} parent the parent's ID - * @param {Number} position the position of the node among the parent's children - * @param {String} old_parent the old parent of the node - * @param {Number} old_position the old position of the node - * @param {Boolean} is_multi do the node and new parent belong to different instances - * @param {jsTree} old_instance the instance the node came from - * @param {jsTree} new_instance the instance of the new parent - */ - this.trigger('move_node', { "node" : obj, "parent" : new_par.id, "position" : pos, "old_parent" : old_par, "old_position" : old_pos, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id), 'old_instance' : old_ins, 'new_instance' : this }); - return obj.id; - }, - /** - * copy a node to a new parent - * @name copy_node(obj, par [, pos, callback, is_loaded]) - * @param {mixed} obj the node to copy, pass an array to copy multiple nodes - * @param {mixed} par the new parent - * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0` - * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position - * @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded - * @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn - * @param {Boolean} instance internal parameter indicating if the node comes from another instance - * @trigger model.jstree copy_node.jstree - */ - copy_node : function (obj, par, pos, callback, is_loaded, skip_redraw, origin) { - var t1, t2, dpc, tmp, i, j, node, old_par, new_par, old_ins, is_multi; - - par = this.get_node(par); - pos = pos === undefined ? 0 : pos; - if(!par) { return false; } - if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { - return this.load_node(par, function () { this.copy_node(obj, par, pos, callback, true, false, origin); }); - } - - if($.isArray(obj)) { - if(obj.length === 1) { - obj = obj[0]; - } - else { - //obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - if((tmp = this.copy_node(obj[t1], par, pos, callback, is_loaded, true, origin))) { - par = tmp; - pos = "after"; - } - } - this.redraw(); - return true; - } - } - obj = obj && obj.id ? obj : this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { return false; } - - old_par = (obj.parent || $.jstree.root).toString(); - new_par = (!pos.toString().match(/^(before|after)$/) || par.id === $.jstree.root) ? par : this.get_node(par.parent); - old_ins = origin ? origin : (this._model.data[obj.id] ? this : $.jstree.reference(obj.id)); - is_multi = !old_ins || !old_ins._id || (this._id !== old_ins._id); - - if(old_ins && old_ins._id) { - obj = old_ins._model.data[obj.id]; - } - - if(par.id === $.jstree.root) { - if(pos === "before") { pos = "first"; } - if(pos === "after") { pos = "last"; } - } - switch(pos) { - case "before": - pos = $.inArray(par.id, new_par.children); - break; - case "after" : - pos = $.inArray(par.id, new_par.children) + 1; - break; - case "inside": - case "first": - pos = 0; - break; - case "last": - pos = new_par.children.length; - break; - default: - if(!pos) { pos = 0; } - break; - } - if(pos > new_par.children.length) { pos = new_par.children.length; } - if(!this.check("copy_node", obj, new_par, pos, { 'core' : true, 'origin' : origin, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) { - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - node = old_ins ? old_ins.get_json(obj, { no_id : true, no_data : true, no_state : true }) : obj; - if(!node) { return false; } - if(node.id === true) { delete node.id; } - node = this._parse_model_from_json(node, new_par.id, new_par.parents.concat()); - if(!node) { return false; } - tmp = this.get_node(node); - if(obj && obj.state && obj.state.loaded === false) { tmp.state.loaded = false; } - dpc = []; - dpc.push(node); - dpc = dpc.concat(tmp.children_d); - this.trigger('model', { "nodes" : dpc, "parent" : new_par.id }); - - // insert into new parent and up - for(i = 0, j = new_par.parents.length; i < j; i++) { - this._model.data[new_par.parents[i]].children_d = this._model.data[new_par.parents[i]].children_d.concat(dpc); - } - dpc = []; - for(i = 0, j = new_par.children.length; i < j; i++) { - dpc[i >= pos ? i+1 : i] = new_par.children[i]; - } - dpc[pos] = tmp.id; - new_par.children = dpc; - new_par.children_d.push(tmp.id); - new_par.children_d = new_par.children_d.concat(tmp.children_d); - - if(new_par.id === $.jstree.root) { - this._model.force_full_redraw = true; - } - if(!this._model.force_full_redraw) { - this._node_changed(new_par.id); - } - if(!skip_redraw) { - this.redraw(new_par.id === $.jstree.root); - } - if(callback) { callback.call(this, tmp, new_par, pos); } - /** - * triggered when a node is copied - * @event - * @name copy_node.jstree - * @param {Object} node the copied node - * @param {Object} original the original node - * @param {String} parent the parent's ID - * @param {Number} position the position of the node among the parent's children - * @param {String} old_parent the old parent of the node - * @param {Number} old_position the position of the original node - * @param {Boolean} is_multi do the node and new parent belong to different instances - * @param {jsTree} old_instance the instance the node came from - * @param {jsTree} new_instance the instance of the new parent - */ - this.trigger('copy_node', { "node" : tmp, "original" : obj, "parent" : new_par.id, "position" : pos, "old_parent" : old_par, "old_position" : old_ins && old_ins._id && old_par && old_ins._model.data[old_par] && old_ins._model.data[old_par].children ? $.inArray(obj.id, old_ins._model.data[old_par].children) : -1,'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id), 'old_instance' : old_ins, 'new_instance' : this }); - return tmp.id; - }, - /** - * cut a node (a later call to `paste(obj)` would move the node) - * @name cut(obj) - * @param {mixed} obj multiple objects can be passed using an array - * @trigger cut.jstree - */ - cut : function (obj) { - if(!obj) { obj = this._data.core.selected.concat(); } - if(!$.isArray(obj)) { obj = [obj]; } - if(!obj.length) { return false; } - var tmp = [], o, t1, t2; - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - o = this.get_node(obj[t1]); - if(o && o.id && o.id !== $.jstree.root) { tmp.push(o); } - } - if(!tmp.length) { return false; } - ccp_node = tmp; - ccp_inst = this; - ccp_mode = 'move_node'; - /** - * triggered when nodes are added to the buffer for moving - * @event - * @name cut.jstree - * @param {Array} node - */ - this.trigger('cut', { "node" : obj }); - }, - /** - * copy a node (a later call to `paste(obj)` would copy the node) - * @name copy(obj) - * @param {mixed} obj multiple objects can be passed using an array - * @trigger copy.jstree - */ - copy : function (obj) { - if(!obj) { obj = this._data.core.selected.concat(); } - if(!$.isArray(obj)) { obj = [obj]; } - if(!obj.length) { return false; } - var tmp = [], o, t1, t2; - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - o = this.get_node(obj[t1]); - if(o && o.id && o.id !== $.jstree.root) { tmp.push(o); } - } - if(!tmp.length) { return false; } - ccp_node = tmp; - ccp_inst = this; - ccp_mode = 'copy_node'; - /** - * triggered when nodes are added to the buffer for copying - * @event - * @name copy.jstree - * @param {Array} node - */ - this.trigger('copy', { "node" : obj }); - }, - /** - * get the current buffer (any nodes that are waiting for a paste operation) - * @name get_buffer() - * @return {Object} an object consisting of `mode` ("copy_node" or "move_node"), `node` (an array of objects) and `inst` (the instance) - */ - get_buffer : function () { - return { 'mode' : ccp_mode, 'node' : ccp_node, 'inst' : ccp_inst }; - }, - /** - * check if there is something in the buffer to paste - * @name can_paste() - * @return {Boolean} - */ - can_paste : function () { - return ccp_mode !== false && ccp_node !== false; // && ccp_inst._model.data[ccp_node]; - }, - /** - * copy or move the previously cut or copied nodes to a new parent - * @name paste(obj [, pos]) - * @param {mixed} obj the new parent - * @param {mixed} pos the position to insert at (besides integer, "first" and "last" are supported), defaults to integer `0` - * @trigger paste.jstree - */ - paste : function (obj, pos) { - obj = this.get_node(obj); - if(!obj || !ccp_mode || !ccp_mode.match(/^(copy_node|move_node)$/) || !ccp_node) { return false; } - if(this[ccp_mode](ccp_node, obj, pos, false, false, false, ccp_inst)) { - /** - * triggered when paste is invoked - * @event - * @name paste.jstree - * @param {String} parent the ID of the receiving node - * @param {Array} node the nodes in the buffer - * @param {String} mode the performed operation - "copy_node" or "move_node" - */ - this.trigger('paste', { "parent" : obj.id, "node" : ccp_node, "mode" : ccp_mode }); - } - ccp_node = false; - ccp_mode = false; - ccp_inst = false; - }, - /** - * clear the buffer of previously copied or cut nodes - * @name clear_buffer() - * @trigger clear_buffer.jstree - */ - clear_buffer : function () { - ccp_node = false; - ccp_mode = false; - ccp_inst = false; - /** - * triggered when the copy / cut buffer is cleared - * @event - * @name clear_buffer.jstree - */ - this.trigger('clear_buffer'); - }, - /** - * put a node in edit mode (input field to rename the node) - * @name edit(obj [, default_text, callback]) - * @param {mixed} obj - * @param {String} default_text the text to populate the input with (if omitted or set to a non-string value the node's text value is used) - * @param {Function} callback a function to be called once the text box is blurred, it is called in the instance's scope and receives the node, a status parameter (true if the rename is successful, false otherwise) and a boolean indicating if the user cancelled the edit. You can access the node's title using .text - */ - edit : function (obj, default_text, callback) { - var rtl, w, a, s, t, h1, h2, fn, tmp, cancel = false; - obj = this.get_node(obj); - if(!obj) { return false; } - if(!this.check("edit", obj, this.get_parent(obj))) { - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - tmp = obj; - default_text = typeof default_text === 'string' ? default_text : obj.text; - this.set_text(obj, ""); - obj = this._open_to(obj); - tmp.text = default_text; - - rtl = this._data.core.rtl; - w = this.element.width(); - this._data.core.focused = tmp.id; - a = obj.children('.jstree-anchor').focus(); - s = $(''); - /*! - oi = obj.children("i:visible"), - ai = a.children("i:visible"), - w1 = oi.width() * oi.length, - w2 = ai.width() * ai.length, - */ - t = default_text; - h1 = $("<"+"div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo(document.body); - h2 = $("<"+"input />", { - "value" : t, - "class" : "jstree-rename-input", - // "size" : t.length, - "css" : { - "padding" : "0", - "border" : "1px solid silver", - "box-sizing" : "border-box", - "display" : "inline-block", - "height" : (this._data.core.li_height) + "px", - "lineHeight" : (this._data.core.li_height) + "px", - "width" : "150px" // will be set a bit further down - }, - "blur" : $.proxy(function (e) { - e.stopImmediatePropagation(); - e.preventDefault(); - var i = s.children(".jstree-rename-input"), - v = i.val(), - f = this.settings.core.force_text, - nv; - if(v === "") { v = t; } - h1.remove(); - s.replaceWith(a); - s.remove(); - t = f ? t : $('
').append($.parseHTML(t)).html(); - this.set_text(obj, t); - nv = !!this.rename_node(obj, f ? $('
').text(v).text() : $('
').append($.parseHTML(v)).html()); - if(!nv) { - this.set_text(obj, t); // move this up? and fix #483 - } - this._data.core.focused = tmp.id; - setTimeout($.proxy(function () { - var node = this.get_node(tmp.id, true); - if(node.length) { - this._data.core.focused = tmp.id; - node.children('.jstree-anchor').focus(); - } - }, this), 0); - if(callback) { - callback.call(this, tmp, nv, cancel); - } - h2 = null; - }, this), - "keydown" : function (e) { - var key = e.which; - if(key === 27) { - cancel = true; - this.value = t; - } - if(key === 27 || key === 13 || key === 37 || key === 38 || key === 39 || key === 40 || key === 32) { - e.stopImmediatePropagation(); - } - if(key === 27 || key === 13) { - e.preventDefault(); - this.blur(); - } - }, - "click" : function (e) { e.stopImmediatePropagation(); }, - "mousedown" : function (e) { e.stopImmediatePropagation(); }, - "keyup" : function (e) { - h2.width(Math.min(h1.text("pW" + this.value).width(),w)); - }, - "keypress" : function(e) { - if(e.which === 13) { return false; } - } - }); - fn = { - fontFamily : a.css('fontFamily') || '', - fontSize : a.css('fontSize') || '', - fontWeight : a.css('fontWeight') || '', - fontStyle : a.css('fontStyle') || '', - fontStretch : a.css('fontStretch') || '', - fontVariant : a.css('fontVariant') || '', - letterSpacing : a.css('letterSpacing') || '', - wordSpacing : a.css('wordSpacing') || '' - }; - s.attr('class', a.attr('class')).append(a.contents().clone()).append(h2); - a.replaceWith(s); - h1.css(fn); - h2.css(fn).width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select(); - $(document).one('mousedown.jstree touchstart.jstree dnd_start.vakata', function (e) { - if (h2 && e.target !== h2) { - $(h2).blur(); - } - }); - }, - - - /** - * changes the theme - * @name set_theme(theme_name [, theme_url]) - * @param {String} theme_name the name of the new theme to apply - * @param {mixed} theme_url the location of the CSS file for this theme. Omit or set to `false` if you manually included the file. Set to `true` to autoload from the `core.themes.dir` directory. - * @trigger set_theme.jstree - */ - set_theme : function (theme_name, theme_url) { - if(!theme_name) { return false; } - if(theme_url === true) { - var dir = this.settings.core.themes.dir; - if(!dir) { dir = $.jstree.path + '/themes'; } - theme_url = dir + '/' + theme_name + '/style.css'; - } - if(theme_url && $.inArray(theme_url, themes_loaded) === -1) { - $('head').append('<'+'link rel="stylesheet" href="' + theme_url + '" type="text/css" />'); - themes_loaded.push(theme_url); - } - if(this._data.core.themes.name) { - this.element.removeClass('jstree-' + this._data.core.themes.name); - } - this._data.core.themes.name = theme_name; - this.element.addClass('jstree-' + theme_name); - this.element[this.settings.core.themes.responsive ? 'addClass' : 'removeClass' ]('jstree-' + theme_name + '-responsive'); - /** - * triggered when a theme is set - * @event - * @name set_theme.jstree - * @param {String} theme the new theme - */ - this.trigger('set_theme', { 'theme' : theme_name }); - }, - /** - * gets the name of the currently applied theme name - * @name get_theme() - * @return {String} - */ - get_theme : function () { return this._data.core.themes.name; }, - /** - * changes the theme variant (if the theme has variants) - * @name set_theme_variant(variant_name) - * @param {String|Boolean} variant_name the variant to apply (if `false` is used the current variant is removed) - */ - set_theme_variant : function (variant_name) { - if(this._data.core.themes.variant) { - this.element.removeClass('jstree-' + this._data.core.themes.name + '-' + this._data.core.themes.variant); - } - this._data.core.themes.variant = variant_name; - if(variant_name) { - this.element.addClass('jstree-' + this._data.core.themes.name + '-' + this._data.core.themes.variant); - } - }, - /** - * gets the name of the currently applied theme variant - * @name get_theme() - * @return {String} - */ - get_theme_variant : function () { return this._data.core.themes.variant; }, - /** - * shows a striped background on the container (if the theme supports it) - * @name show_stripes() - */ - show_stripes : function () { - this._data.core.themes.stripes = true; - this.get_container_ul().addClass("jstree-striped"); - /** - * triggered when stripes are shown - * @event - * @name show_stripes.jstree - */ - this.trigger('show_stripes'); - }, - /** - * hides the striped background on the container - * @name hide_stripes() - */ - hide_stripes : function () { - this._data.core.themes.stripes = false; - this.get_container_ul().removeClass("jstree-striped"); - /** - * triggered when stripes are hidden - * @event - * @name hide_stripes.jstree - */ - this.trigger('hide_stripes'); - }, - /** - * toggles the striped background on the container - * @name toggle_stripes() - */ - toggle_stripes : function () { if(this._data.core.themes.stripes) { this.hide_stripes(); } else { this.show_stripes(); } }, - /** - * shows the connecting dots (if the theme supports it) - * @name show_dots() - */ - show_dots : function () { - this._data.core.themes.dots = true; - this.get_container_ul().removeClass("jstree-no-dots"); - /** - * triggered when dots are shown - * @event - * @name show_dots.jstree - */ - this.trigger('show_dots'); - }, - /** - * hides the connecting dots - * @name hide_dots() - */ - hide_dots : function () { - this._data.core.themes.dots = false; - this.get_container_ul().addClass("jstree-no-dots"); - /** - * triggered when dots are hidden - * @event - * @name hide_dots.jstree - */ - this.trigger('hide_dots'); - }, - /** - * toggles the connecting dots - * @name toggle_dots() - */ - toggle_dots : function () { if(this._data.core.themes.dots) { this.hide_dots(); } else { this.show_dots(); } }, - /** - * show the node icons - * @name show_icons() - */ - show_icons : function () { - this._data.core.themes.icons = true; - this.get_container_ul().removeClass("jstree-no-icons"); - /** - * triggered when icons are shown - * @event - * @name show_icons.jstree - */ - this.trigger('show_icons'); - }, - /** - * hide the node icons - * @name hide_icons() - */ - hide_icons : function () { - this._data.core.themes.icons = false; - this.get_container_ul().addClass("jstree-no-icons"); - /** - * triggered when icons are hidden - * @event - * @name hide_icons.jstree - */ - this.trigger('hide_icons'); - }, - /** - * toggle the node icons - * @name toggle_icons() - */ - toggle_icons : function () { if(this._data.core.themes.icons) { this.hide_icons(); } else { this.show_icons(); } }, - /** - * show the node ellipsis - * @name show_icons() - */ - show_ellipsis : function () { - this._data.core.themes.ellipsis = true; - this.get_container_ul().addClass("jstree-ellipsis"); - /** - * triggered when ellisis is shown - * @event - * @name show_ellipsis.jstree - */ - this.trigger('show_ellipsis'); - }, - /** - * hide the node ellipsis - * @name hide_ellipsis() - */ - hide_ellipsis : function () { - this._data.core.themes.ellipsis = false; - this.get_container_ul().removeClass("jstree-ellipsis"); - /** - * triggered when ellisis is hidden - * @event - * @name hide_ellipsis.jstree - */ - this.trigger('hide_ellipsis'); - }, - /** - * toggle the node ellipsis - * @name toggle_icons() - */ - toggle_ellipsis : function () { if(this._data.core.themes.ellipsis) { this.hide_ellipsis(); } else { this.show_ellipsis(); } }, - /** - * set the node icon for a node - * @name set_icon(obj, icon) - * @param {mixed} obj - * @param {String} icon the new icon - can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class - */ - set_icon : function (obj, icon) { - var t1, t2, dom, old; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.set_icon(obj[t1], icon); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { return false; } - old = obj.icon; - obj.icon = icon === true || icon === null || icon === undefined || icon === '' ? true : icon; - dom = this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon"); - if(icon === false) { - dom.removeClass('jstree-themeicon-custom ' + old).css("background","").removeAttr("rel"); - this.hide_icon(obj); - } - else if(icon === true || icon === null || icon === undefined || icon === '') { - dom.removeClass('jstree-themeicon-custom ' + old).css("background","").removeAttr("rel"); - if(old === false) { this.show_icon(obj); } - } - else if(icon.indexOf("/") === -1 && icon.indexOf(".") === -1) { - dom.removeClass(old).css("background",""); - dom.addClass(icon + ' jstree-themeicon-custom').attr("rel",icon); - if(old === false) { this.show_icon(obj); } - } - else { - dom.removeClass(old).css("background",""); - dom.addClass('jstree-themeicon-custom').css("background", "url('" + icon + "') center center no-repeat").attr("rel",icon); - if(old === false) { this.show_icon(obj); } - } - return true; - }, - /** - * get the node icon for a node - * @name get_icon(obj) - * @param {mixed} obj - * @return {String} - */ - get_icon : function (obj) { - obj = this.get_node(obj); - return (!obj || obj.id === $.jstree.root) ? false : obj.icon; - }, - /** - * hide the icon on an individual node - * @name hide_icon(obj) - * @param {mixed} obj - */ - hide_icon : function (obj) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.hide_icon(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj === $.jstree.root) { return false; } - obj.icon = false; - this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon").addClass('jstree-themeicon-hidden'); - return true; - }, - /** - * show the icon on an individual node - * @name show_icon(obj) - * @param {mixed} obj - */ - show_icon : function (obj) { - var t1, t2, dom; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.show_icon(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj === $.jstree.root) { return false; } - dom = this.get_node(obj, true); - obj.icon = dom.length ? dom.children(".jstree-anchor").children(".jstree-themeicon").attr('rel') : true; - if(!obj.icon) { obj.icon = true; } - dom.children(".jstree-anchor").children(".jstree-themeicon").removeClass('jstree-themeicon-hidden'); - return true; - } - }; - - // helpers - $.vakata = {}; - // collect attributes - $.vakata.attributes = function(node, with_values) { - node = $(node)[0]; - var attr = with_values ? {} : []; - if(node && node.attributes) { - $.each(node.attributes, function (i, v) { - if($.inArray(v.name.toLowerCase(),['style','contenteditable','hasfocus','tabindex']) !== -1) { return; } - if(v.value !== null && $.trim(v.value) !== '') { - if(with_values) { attr[v.name] = v.value; } - else { attr.push(v.name); } - } - }); - } - return attr; - }; - $.vakata.array_unique = function(array) { - var a = [], i, j, l, o = {}; - for(i = 0, l = array.length; i < l; i++) { - if(o[array[i]] === undefined) { - a.push(array[i]); - o[array[i]] = true; - } - } - return a; - }; - // remove item from array - $.vakata.array_remove = function(array, from) { - array.splice(from, 1); - return array; - //var rest = array.slice((to || from) + 1 || array.length); - //array.length = from < 0 ? array.length + from : from; - //array.push.apply(array, rest); - //return array; - }; - // remove item from array - $.vakata.array_remove_item = function(array, item) { - var tmp = $.inArray(item, array); - return tmp !== -1 ? $.vakata.array_remove(array, tmp) : array; - }; - $.vakata.array_filter = function(c,a,b,d,e) { - if (c.filter) { - return c.filter(a, b); - } - d=[]; - for (e in c) { - if (~~e+''===e+'' && e>=0 && a.call(b,c[e],+e,c)) { - d.push(c[e]); - } - } - return d; - }; - - -/** - * ### Changed plugin - * - * This plugin adds more information to the `changed.jstree` event. The new data is contained in the `changed` event data property, and contains a lists of `selected` and `deselected` nodes. - */ - - $.jstree.plugins.changed = function (options, parent) { - var last = []; - this.trigger = function (ev, data) { - var i, j; - if(!data) { - data = {}; - } - if(ev.replace('.jstree','') === 'changed') { - data.changed = { selected : [], deselected : [] }; - var tmp = {}; - for(i = 0, j = last.length; i < j; i++) { - tmp[last[i]] = 1; - } - for(i = 0, j = data.selected.length; i < j; i++) { - if(!tmp[data.selected[i]]) { - data.changed.selected.push(data.selected[i]); - } - else { - tmp[data.selected[i]] = 2; - } - } - for(i = 0, j = last.length; i < j; i++) { - if(tmp[last[i]] === 1) { - data.changed.deselected.push(last[i]); - } - } - last = data.selected.slice(); - } - /** - * triggered when selection changes (the "changed" plugin enhances the original event with more data) - * @event - * @name changed.jstree - * @param {Object} node - * @param {Object} action the action that caused the selection to change - * @param {Array} selected the current selection - * @param {Object} changed an object containing two properties `selected` and `deselected` - both arrays of node IDs, which were selected or deselected since the last changed event - * @param {Object} event the event (if any) that triggered this changed event - * @plugin changed - */ - parent.trigger.call(this, ev, data); - }; - this.refresh = function (skip_loading, forget_state) { - last = []; - return parent.refresh.apply(this, arguments); - }; - }; - -/** - * ### Checkbox plugin - * - * This plugin renders checkbox icons in front of each node, making multiple selection much easier. - * It also supports tri-state behavior, meaning that if a node has a few of its children checked it will be rendered as undetermined, and state will be propagated up. - */ - - var _i = document.createElement('I'); - _i.className = 'jstree-icon jstree-checkbox'; - _i.setAttribute('role', 'presentation'); - /** - * stores all defaults for the checkbox plugin - * @name $.jstree.defaults.checkbox - * @plugin checkbox - */ - $.jstree.defaults.checkbox = { - /** - * a boolean indicating if checkboxes should be visible (can be changed at a later time using `show_checkboxes()` and `hide_checkboxes`). Defaults to `true`. - * @name $.jstree.defaults.checkbox.visible - * @plugin checkbox - */ - visible : true, - /** - * a boolean indicating if checkboxes should cascade down and have an undetermined state. Defaults to `true`. - * @name $.jstree.defaults.checkbox.three_state - * @plugin checkbox - */ - three_state : true, - /** - * a boolean indicating if clicking anywhere on the node should act as clicking on the checkbox. Defaults to `true`. - * @name $.jstree.defaults.checkbox.whole_node - * @plugin checkbox - */ - whole_node : true, - /** - * a boolean indicating if the selected style of a node should be kept, or removed. Defaults to `true`. - * @name $.jstree.defaults.checkbox.keep_selected_style - * @plugin checkbox - */ - keep_selected_style : true, - /** - * This setting controls how cascading and undetermined nodes are applied. - * If 'up' is in the string - cascading up is enabled, if 'down' is in the string - cascading down is enabled, if 'undetermined' is in the string - undetermined nodes will be used. - * If `three_state` is set to `true` this setting is automatically set to 'up+down+undetermined'. Defaults to ''. - * @name $.jstree.defaults.checkbox.cascade - * @plugin checkbox - */ - cascade : '', - /** - * This setting controls if checkbox are bound to the general tree selection or to an internal array maintained by the checkbox plugin. Defaults to `true`, only set to `false` if you know exactly what you are doing. - * @name $.jstree.defaults.checkbox.tie_selection - * @plugin checkbox - */ - tie_selection : true, - - /** - * This setting controls if cascading down affects disabled checkboxes - * @name $.jstree.defaults.checkbox.cascade_to_disabled - * @plugin checkbox - */ - cascade_to_disabled : true, - - /** - * This setting controls if cascading down affects hidden checkboxes - * @name $.jstree.defaults.checkbox.cascade_to_hidden - * @plugin checkbox - */ - cascade_to_hidden : true - }; - $.jstree.plugins.checkbox = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - this._data.checkbox.uto = false; - this._data.checkbox.selected = []; - if(this.settings.checkbox.three_state) { - this.settings.checkbox.cascade = 'up+down+undetermined'; - } - this.element - .on("init.jstree", $.proxy(function () { - this._data.checkbox.visible = this.settings.checkbox.visible; - if(!this.settings.checkbox.keep_selected_style) { - this.element.addClass('jstree-checkbox-no-clicked'); - } - if(this.settings.checkbox.tie_selection) { - this.element.addClass('jstree-checkbox-selection'); - } - }, this)) - .on("loading.jstree", $.proxy(function () { - this[ this._data.checkbox.visible ? 'show_checkboxes' : 'hide_checkboxes' ](); - }, this)); - if(this.settings.checkbox.cascade.indexOf('undetermined') !== -1) { - this.element - .on('changed.jstree uncheck_node.jstree check_node.jstree uncheck_all.jstree check_all.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree', $.proxy(function () { - // only if undetermined is in setting - if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); } - this._data.checkbox.uto = setTimeout($.proxy(this._undetermined, this), 50); - }, this)); - } - if(!this.settings.checkbox.tie_selection) { - this.element - .on('model.jstree', $.proxy(function (e, data) { - var m = this._model.data, - p = m[data.parent], - dpc = data.nodes, - i, j; - for(i = 0, j = dpc.length; i < j; i++) { - m[dpc[i]].state.checked = m[dpc[i]].state.checked || (m[dpc[i]].original && m[dpc[i]].original.state && m[dpc[i]].original.state.checked); - if(m[dpc[i]].state.checked) { - this._data.checkbox.selected.push(dpc[i]); - } - } - }, this)); - } - if(this.settings.checkbox.cascade.indexOf('up') !== -1 || this.settings.checkbox.cascade.indexOf('down') !== -1) { - this.element - .on('model.jstree', $.proxy(function (e, data) { - var m = this._model.data, - p = m[data.parent], - dpc = data.nodes, - chd = [], - c, i, j, k, l, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection; - - if(s.indexOf('down') !== -1) { - // apply down - if(p.state[ t ? 'selected' : 'checked' ]) { - for(i = 0, j = dpc.length; i < j; i++) { - m[dpc[i]].state[ t ? 'selected' : 'checked' ] = true; - } - - this._data[ t ? 'core' : 'checkbox' ].selected = this._data[ t ? 'core' : 'checkbox' ].selected.concat(dpc); - } - else { - for(i = 0, j = dpc.length; i < j; i++) { - if(m[dpc[i]].state[ t ? 'selected' : 'checked' ]) { - for(k = 0, l = m[dpc[i]].children_d.length; k < l; k++) { - m[m[dpc[i]].children_d[k]].state[ t ? 'selected' : 'checked' ] = true; - } - this._data[ t ? 'core' : 'checkbox' ].selected = this._data[ t ? 'core' : 'checkbox' ].selected.concat(m[dpc[i]].children_d); - } - } - } - } - - if(s.indexOf('up') !== -1) { - // apply up - for(i = 0, j = p.children_d.length; i < j; i++) { - if(!m[p.children_d[i]].children.length) { - chd.push(m[p.children_d[i]].parent); - } - } - chd = $.vakata.array_unique(chd); - for(k = 0, l = chd.length; k < l; k++) { - p = m[chd[k]]; - while(p && p.id !== $.jstree.root) { - c = 0; - for(i = 0, j = p.children.length; i < j; i++) { - c += m[p.children[i]].state[ t ? 'selected' : 'checked' ]; - } - if(c === j) { - p.state[ t ? 'selected' : 'checked' ] = true; - this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id); - tmp = this.get_node(p, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', true).children('.jstree-anchor').addClass( t ? 'jstree-clicked' : 'jstree-checked'); - } - } - else { - break; - } - p = this.get_node(p.parent); - } - } - } - - this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected); - }, this)) - .on(this.settings.checkbox.tie_selection ? 'select_node.jstree' : 'check_node.jstree', $.proxy(function (e, data) { - var self = this, - obj = data.node, - m = this._model.data, - par = this.get_node(obj.parent), - i, j, c, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection, - sel = {}, cur = this._data[ t ? 'core' : 'checkbox' ].selected; - - for (i = 0, j = cur.length; i < j; i++) { - sel[cur[i]] = true; - } - - // apply down - if(s.indexOf('down') !== -1) { - //this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected.concat(obj.children_d)); - var selectedIds = this._cascade_new_checked_state(obj.id, true); - var temp = obj.children_d.concat(obj.id); - for (i = 0, j = temp.length; i < j; i++) { - if (selectedIds.indexOf(temp[i]) > -1) { - sel[temp[i]] = true; - } - else { - delete sel[temp[i]]; - } - } - } - - // apply up - if(s.indexOf('up') !== -1) { - while(par && par.id !== $.jstree.root) { - c = 0; - for(i = 0, j = par.children.length; i < j; i++) { - c += m[par.children[i]].state[ t ? 'selected' : 'checked' ]; - } - if(c === j) { - par.state[ t ? 'selected' : 'checked' ] = true; - sel[par.id] = true; - //this._data[ t ? 'core' : 'checkbox' ].selected.push(par.id); - tmp = this.get_node(par, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - else { - break; - } - par = this.get_node(par.parent); - } - } - - cur = []; - for (i in sel) { - if (sel.hasOwnProperty(i)) { - cur.push(i); - } - } - this._data[ t ? 'core' : 'checkbox' ].selected = cur; - }, this)) - .on(this.settings.checkbox.tie_selection ? 'deselect_all.jstree' : 'uncheck_all.jstree', $.proxy(function (e, data) { - var obj = this.get_node($.jstree.root), - m = this._model.data, - i, j, tmp; - for(i = 0, j = obj.children_d.length; i < j; i++) { - tmp = m[obj.children_d[i]]; - if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) { - tmp.original.state.undetermined = false; - } - } - }, this)) - .on(this.settings.checkbox.tie_selection ? 'deselect_node.jstree' : 'uncheck_node.jstree', $.proxy(function (e, data) { - var self = this, - obj = data.node, - dom = this.get_node(obj, true), - i, j, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection, - cur = this._data[ t ? 'core' : 'checkbox' ].selected, sel = {}, - stillSelectedIds = [], - allIds = obj.children_d.concat(obj.id); - - // apply down - if(s.indexOf('down') !== -1) { - var selectedIds = this._cascade_new_checked_state(obj.id, false); - - cur = cur.filter(function(id) { - return allIds.indexOf(id) === -1 || selectedIds.indexOf(id) > -1; - }); - } - - // only apply up if cascade up is enabled and if this node is not selected - // (if all child nodes are disabled and cascade_to_disabled === false then this node will till be selected). - if(s.indexOf('up') !== -1 && cur.indexOf(obj.id) === -1) { - for(i = 0, j = obj.parents.length; i < j; i++) { - tmp = this._model.data[obj.parents[i]]; - tmp.state[ t ? 'selected' : 'checked' ] = false; - if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) { - tmp.original.state.undetermined = false; - } - tmp = this.get_node(obj.parents[i], true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - - cur = cur.filter(function(id) { - return obj.parents.indexOf(id) === -1; - }); - } - - this._data[ t ? 'core' : 'checkbox' ].selected = cur; - }, this)); - } - if(this.settings.checkbox.cascade.indexOf('up') !== -1) { - this.element - .on('delete_node.jstree', $.proxy(function (e, data) { - // apply up (whole handler) - var p = this.get_node(data.parent), - m = this._model.data, - i, j, c, tmp, t = this.settings.checkbox.tie_selection; - while(p && p.id !== $.jstree.root && !p.state[ t ? 'selected' : 'checked' ]) { - c = 0; - for(i = 0, j = p.children.length; i < j; i++) { - c += m[p.children[i]].state[ t ? 'selected' : 'checked' ]; - } - if(j > 0 && c === j) { - p.state[ t ? 'selected' : 'checked' ] = true; - this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id); - tmp = this.get_node(p, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - else { - break; - } - p = this.get_node(p.parent); - } - }, this)) - .on('move_node.jstree', $.proxy(function (e, data) { - // apply up (whole handler) - var is_multi = data.is_multi, - old_par = data.old_parent, - new_par = this.get_node(data.parent), - m = this._model.data, - p, c, i, j, tmp, t = this.settings.checkbox.tie_selection; - if(!is_multi) { - p = this.get_node(old_par); - while(p && p.id !== $.jstree.root && !p.state[ t ? 'selected' : 'checked' ]) { - c = 0; - for(i = 0, j = p.children.length; i < j; i++) { - c += m[p.children[i]].state[ t ? 'selected' : 'checked' ]; - } - if(j > 0 && c === j) { - p.state[ t ? 'selected' : 'checked' ] = true; - this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id); - tmp = this.get_node(p, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - else { - break; - } - p = this.get_node(p.parent); - } - } - p = new_par; - while(p && p.id !== $.jstree.root) { - c = 0; - for(i = 0, j = p.children.length; i < j; i++) { - c += m[p.children[i]].state[ t ? 'selected' : 'checked' ]; - } - if(c === j) { - if(!p.state[ t ? 'selected' : 'checked' ]) { - p.state[ t ? 'selected' : 'checked' ] = true; - this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id); - tmp = this.get_node(p, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - } - else { - if(p.state[ t ? 'selected' : 'checked' ]) { - p.state[ t ? 'selected' : 'checked' ] = false; - this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_remove_item(this._data[ t ? 'core' : 'checkbox' ].selected, p.id); - tmp = this.get_node(p, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - else { - break; - } - } - p = this.get_node(p.parent); - } - }, this)); - } - }; - /** - * get an array of all nodes whose state is "undetermined" - * @name get_undetermined([full]) - * @param {boolean} full: if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - * @plugin checkbox - */ - this.get_undetermined = function (full) { - if (this.settings.checkbox.cascade.indexOf('undetermined') === -1) { - return []; - } - var i, j, k, l, o = {}, m = this._model.data, t = this.settings.checkbox.tie_selection, s = this._data[ t ? 'core' : 'checkbox' ].selected, p = [], tt = this, r = []; - for(i = 0, j = s.length; i < j; i++) { - if(m[s[i]] && m[s[i]].parents) { - for(k = 0, l = m[s[i]].parents.length; k < l; k++) { - if(o[m[s[i]].parents[k]] !== undefined) { - break; - } - if(m[s[i]].parents[k] !== $.jstree.root) { - o[m[s[i]].parents[k]] = true; - p.push(m[s[i]].parents[k]); - } - } - } - } - // attempt for server side undetermined state - this.element.find('.jstree-closed').not(':has(.jstree-children)') - .each(function () { - var tmp = tt.get_node(this), tmp2; - - if(!tmp) { return; } - - if(!tmp.state.loaded) { - if(tmp.original && tmp.original.state && tmp.original.state.undetermined && tmp.original.state.undetermined === true) { - if(o[tmp.id] === undefined && tmp.id !== $.jstree.root) { - o[tmp.id] = true; - p.push(tmp.id); - } - for(k = 0, l = tmp.parents.length; k < l; k++) { - if(o[tmp.parents[k]] === undefined && tmp.parents[k] !== $.jstree.root) { - o[tmp.parents[k]] = true; - p.push(tmp.parents[k]); - } - } - } - } - else { - for(i = 0, j = tmp.children_d.length; i < j; i++) { - tmp2 = m[tmp.children_d[i]]; - if(!tmp2.state.loaded && tmp2.original && tmp2.original.state && tmp2.original.state.undetermined && tmp2.original.state.undetermined === true) { - if(o[tmp2.id] === undefined && tmp2.id !== $.jstree.root) { - o[tmp2.id] = true; - p.push(tmp2.id); - } - for(k = 0, l = tmp2.parents.length; k < l; k++) { - if(o[tmp2.parents[k]] === undefined && tmp2.parents[k] !== $.jstree.root) { - o[tmp2.parents[k]] = true; - p.push(tmp2.parents[k]); - } - } - } - } - } - }); - for (i = 0, j = p.length; i < j; i++) { - if(!m[p[i]].state[ t ? 'selected' : 'checked' ]) { - r.push(full ? m[p[i]] : p[i]); - } - } - return r; - }; - /** - * set the undetermined state where and if necessary. Used internally. - * @private - * @name _undetermined() - * @plugin checkbox - */ - this._undetermined = function () { - if(this.element === null) { return; } - var p = this.get_undetermined(false), i, j, s; - - this.element.find('.jstree-undetermined').removeClass('jstree-undetermined'); - for (i = 0, j = p.length; i < j; i++) { - s = this.get_node(p[i], true); - if(s && s.length) { - s.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-undetermined'); - } - } - }; - this.redraw_node = function(obj, deep, is_callback, force_render) { - obj = parent.redraw_node.apply(this, arguments); - if(obj) { - var i, j, tmp = null, icon = null; - for(i = 0, j = obj.childNodes.length; i < j; i++) { - if(obj.childNodes[i] && obj.childNodes[i].className && obj.childNodes[i].className.indexOf("jstree-anchor") !== -1) { - tmp = obj.childNodes[i]; - break; - } - } - if(tmp) { - if(!this.settings.checkbox.tie_selection && this._model.data[obj.id].state.checked) { tmp.className += ' jstree-checked'; } - icon = _i.cloneNode(false); - if(this._model.data[obj.id].state.checkbox_disabled) { icon.className += ' jstree-checkbox-disabled'; } - tmp.insertBefore(icon, tmp.childNodes[0]); - } - } - if(!is_callback && this.settings.checkbox.cascade.indexOf('undetermined') !== -1) { - if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); } - this._data.checkbox.uto = setTimeout($.proxy(this._undetermined, this), 50); - } - return obj; - }; - /** - * show the node checkbox icons - * @name show_checkboxes() - * @plugin checkbox - */ - this.show_checkboxes = function () { this._data.core.themes.checkboxes = true; this.get_container_ul().removeClass("jstree-no-checkboxes"); }; - /** - * hide the node checkbox icons - * @name hide_checkboxes() - * @plugin checkbox - */ - this.hide_checkboxes = function () { this._data.core.themes.checkboxes = false; this.get_container_ul().addClass("jstree-no-checkboxes"); }; - /** - * toggle the node icons - * @name toggle_checkboxes() - * @plugin checkbox - */ - this.toggle_checkboxes = function () { if(this._data.core.themes.checkboxes) { this.hide_checkboxes(); } else { this.show_checkboxes(); } }; - /** - * checks if a node is in an undetermined state - * @name is_undetermined(obj) - * @param {mixed} obj - * @return {Boolean} - */ - this.is_undetermined = function (obj) { - obj = this.get_node(obj); - var s = this.settings.checkbox.cascade, i, j, t = this.settings.checkbox.tie_selection, d = this._data[ t ? 'core' : 'checkbox' ].selected, m = this._model.data; - if(!obj || obj.state[ t ? 'selected' : 'checked' ] === true || s.indexOf('undetermined') === -1 || (s.indexOf('down') === -1 && s.indexOf('up') === -1)) { - return false; - } - if(!obj.state.loaded && obj.original.state.undetermined === true) { - return true; - } - for(i = 0, j = obj.children_d.length; i < j; i++) { - if($.inArray(obj.children_d[i], d) !== -1 || (!m[obj.children_d[i]].state.loaded && m[obj.children_d[i]].original.state.undetermined)) { - return true; - } - } - return false; - }; - /** - * disable a node's checkbox - * @name disable_checkbox(obj) - * @param {mixed} obj an array can be used too - * @trigger disable_checkbox.jstree - * @plugin checkbox - */ - this.disable_checkbox = function (obj) { - var t1, t2, dom; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.disable_checkbox(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - dom = this.get_node(obj, true); - if(!obj.state.checkbox_disabled) { - obj.state.checkbox_disabled = true; - if(dom && dom.length) { - dom.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-checkbox-disabled'); - } - /** - * triggered when an node's checkbox is disabled - * @event - * @name disable_checkbox.jstree - * @param {Object} node - * @plugin checkbox - */ - this.trigger('disable_checkbox', { 'node' : obj }); - } - }; - /** - * enable a node's checkbox - * @name disable_checkbox(obj) - * @param {mixed} obj an array can be used too - * @trigger enable_checkbox.jstree - * @plugin checkbox - */ - this.enable_checkbox = function (obj) { - var t1, t2, dom; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.enable_checkbox(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - dom = this.get_node(obj, true); - if(obj.state.checkbox_disabled) { - obj.state.checkbox_disabled = false; - if(dom && dom.length) { - dom.children('.jstree-anchor').children('.jstree-checkbox').removeClass('jstree-checkbox-disabled'); - } - /** - * triggered when an node's checkbox is enabled - * @event - * @name enable_checkbox.jstree - * @param {Object} node - * @plugin checkbox - */ - this.trigger('enable_checkbox', { 'node' : obj }); - } - }; - - this.activate_node = function (obj, e) { - if($(e.target).hasClass('jstree-checkbox-disabled')) { - return false; - } - if(this.settings.checkbox.tie_selection && (this.settings.checkbox.whole_node || $(e.target).hasClass('jstree-checkbox'))) { - e.ctrlKey = true; - } - if(this.settings.checkbox.tie_selection || (!this.settings.checkbox.whole_node && !$(e.target).hasClass('jstree-checkbox'))) { - return parent.activate_node.call(this, obj, e); - } - if(this.is_disabled(obj)) { - return false; - } - if(this.is_checked(obj)) { - this.uncheck_node(obj, e); - } - else { - this.check_node(obj, e); - } - this.trigger('activate_node', { 'node' : this.get_node(obj) }); - }; - - /** - * Cascades checked state to a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants). - * However if these unaffected nodes are already selected their ids will be included in the returned array. - * @private - * @param {string} id the node ID - * @param {bool} checkedState should the nodes be checked or not - * @returns {Array} Array of all node id's (in this tree branch) that are checked. - */ - this._cascade_new_checked_state = function (id, checkedState) { - var self = this; - var t = this.settings.checkbox.tie_selection; - var node = this._model.data[id]; - var selectedNodeIds = []; - var selectedChildrenIds = [], i, j, selectedChildIds; - - if ( - (this.settings.checkbox.cascade_to_disabled || !node.state.disabled) && - (this.settings.checkbox.cascade_to_hidden || !node.state.hidden) - ) { - //First try and check/uncheck the children - if (node.children) { - for (i = 0, j = node.children.length; i < j; i++) { - var childId = node.children[i]; - selectedChildIds = self._cascade_new_checked_state(childId, checkedState); - selectedNodeIds = selectedNodeIds.concat(selectedChildIds); - if (selectedChildIds.indexOf(childId) > -1) { - selectedChildrenIds.push(childId); - } - } - } - - var dom = self.get_node(node, true); - - //A node's state is undetermined if some but not all of it's children are checked/selected . - var undetermined = selectedChildrenIds.length > 0 && selectedChildrenIds.length < node.children.length; - - if(node.original && node.original.state && node.original.state.undetermined) { - node.original.state.undetermined = undetermined; - } - - //If a node is undetermined then remove selected class - if (undetermined) { - node.state[ t ? 'selected' : 'checked' ] = false; - dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - //Otherwise, if the checkedState === true (i.e. the node is being checked now) and all of the node's children are checked (if it has any children), - //check the node and style it correctly. - else if (checkedState && selectedChildrenIds.length === node.children.length) { - node.state[ t ? 'selected' : 'checked' ] = checkedState; - selectedNodeIds.push(node.id); - - dom.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - else { - node.state[ t ? 'selected' : 'checked' ] = false; - dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - else { - selectedChildIds = this.get_checked_descendants(id); - - if (node.state[ t ? 'selected' : 'checked' ]) { - selectedChildIds.push(node.id); - } - - selectedNodeIds = selectedNodeIds.concat(selectedChildIds); - } - - return selectedNodeIds; - }; - - /** - * Gets ids of nodes selected in branch (of tree) specified by id (does not include the node specified by id) - * @name get_checked_descendants(obj) - * @param {string} id the node ID - * @return {Array} array of IDs - * @plugin checkbox - */ - this.get_checked_descendants = function (id) { - var self = this; - var t = self.settings.checkbox.tie_selection; - var node = self._model.data[id]; - - return node.children_d.filter(function(_id) { - return self._model.data[_id].state[ t ? 'selected' : 'checked' ]; - }); - }; - - /** - * check a node (only if tie_selection in checkbox settings is false, otherwise select_node will be called internally) - * @name check_node(obj) - * @param {mixed} obj an array can be used to check multiple nodes - * @trigger check_node.jstree - * @plugin checkbox - */ - this.check_node = function (obj, e) { - if(this.settings.checkbox.tie_selection) { return this.select_node(obj, false, true, e); } - var dom, t1, t2, th; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.check_node(obj[t1], e); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - dom = this.get_node(obj, true); - if(!obj.state.checked) { - obj.state.checked = true; - this._data.checkbox.selected.push(obj.id); - if(dom && dom.length) { - dom.children('.jstree-anchor').addClass('jstree-checked'); - } - /** - * triggered when an node is checked (only if tie_selection in checkbox settings is false) - * @event - * @name check_node.jstree - * @param {Object} node - * @param {Array} selected the current selection - * @param {Object} event the event (if any) that triggered this check_node - * @plugin checkbox - */ - this.trigger('check_node', { 'node' : obj, 'selected' : this._data.checkbox.selected, 'event' : e }); - } - }; - /** - * uncheck a node (only if tie_selection in checkbox settings is false, otherwise deselect_node will be called internally) - * @name uncheck_node(obj) - * @param {mixed} obj an array can be used to uncheck multiple nodes - * @trigger uncheck_node.jstree - * @plugin checkbox - */ - this.uncheck_node = function (obj, e) { - if(this.settings.checkbox.tie_selection) { return this.deselect_node(obj, false, e); } - var t1, t2, dom; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.uncheck_node(obj[t1], e); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { - return false; - } - dom = this.get_node(obj, true); - if(obj.state.checked) { - obj.state.checked = false; - this._data.checkbox.selected = $.vakata.array_remove_item(this._data.checkbox.selected, obj.id); - if(dom.length) { - dom.children('.jstree-anchor').removeClass('jstree-checked'); - } - /** - * triggered when an node is unchecked (only if tie_selection in checkbox settings is false) - * @event - * @name uncheck_node.jstree - * @param {Object} node - * @param {Array} selected the current selection - * @param {Object} event the event (if any) that triggered this uncheck_node - * @plugin checkbox - */ - this.trigger('uncheck_node', { 'node' : obj, 'selected' : this._data.checkbox.selected, 'event' : e }); - } - }; - - /** - * checks all nodes in the tree (only if tie_selection in checkbox settings is false, otherwise select_all will be called internally) - * @name check_all() - * @trigger check_all.jstree, changed.jstree - * @plugin checkbox - */ - this.check_all = function () { - if(this.settings.checkbox.tie_selection) { return this.select_all(); } - var tmp = this._data.checkbox.selected.concat([]), i, j; - this._data.checkbox.selected = this._model.data[$.jstree.root].children_d.concat(); - for(i = 0, j = this._data.checkbox.selected.length; i < j; i++) { - if(this._model.data[this._data.checkbox.selected[i]]) { - this._model.data[this._data.checkbox.selected[i]].state.checked = true; - } - } - this.redraw(true); - /** - * triggered when all nodes are checked (only if tie_selection in checkbox settings is false) - * @event - * @name check_all.jstree - * @param {Array} selected the current selection - * @plugin checkbox - */ - this.trigger('check_all', { 'selected' : this._data.checkbox.selected }); - }; - /** - * uncheck all checked nodes (only if tie_selection in checkbox settings is false, otherwise deselect_all will be called internally) - * @name uncheck_all() - * @trigger uncheck_all.jstree - * @plugin checkbox - */ - this.uncheck_all = function () { - if(this.settings.checkbox.tie_selection) { return this.deselect_all(); } - var tmp = this._data.checkbox.selected.concat([]), i, j; - for(i = 0, j = this._data.checkbox.selected.length; i < j; i++) { - if(this._model.data[this._data.checkbox.selected[i]]) { - this._model.data[this._data.checkbox.selected[i]].state.checked = false; - } - } - this._data.checkbox.selected = []; - this.element.find('.jstree-checked').removeClass('jstree-checked'); - /** - * triggered when all nodes are unchecked (only if tie_selection in checkbox settings is false) - * @event - * @name uncheck_all.jstree - * @param {Object} node the previous selection - * @param {Array} selected the current selection - * @plugin checkbox - */ - this.trigger('uncheck_all', { 'selected' : this._data.checkbox.selected, 'node' : tmp }); - }; - /** - * checks if a node is checked (if tie_selection is on in the settings this function will return the same as is_selected) - * @name is_checked(obj) - * @param {mixed} obj - * @return {Boolean} - * @plugin checkbox - */ - this.is_checked = function (obj) { - if(this.settings.checkbox.tie_selection) { return this.is_selected(obj); } - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { return false; } - return obj.state.checked; - }; - /** - * get an array of all checked nodes (if tie_selection is on in the settings this function will return the same as get_selected) - * @name get_checked([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - * @plugin checkbox - */ - this.get_checked = function (full) { - if(this.settings.checkbox.tie_selection) { return this.get_selected(full); } - return full ? $.map(this._data.checkbox.selected, $.proxy(function (i) { return this.get_node(i); }, this)) : this._data.checkbox.selected; - }; - /** - * get an array of all top level checked nodes (ignoring children of checked nodes) (if tie_selection is on in the settings this function will return the same as get_top_selected) - * @name get_top_checked([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - * @plugin checkbox - */ - this.get_top_checked = function (full) { - if(this.settings.checkbox.tie_selection) { return this.get_top_selected(full); } - var tmp = this.get_checked(true), - obj = {}, i, j, k, l; - for(i = 0, j = tmp.length; i < j; i++) { - obj[tmp[i].id] = tmp[i]; - } - for(i = 0, j = tmp.length; i < j; i++) { - for(k = 0, l = tmp[i].children_d.length; k < l; k++) { - if(obj[tmp[i].children_d[k]]) { - delete obj[tmp[i].children_d[k]]; - } - } - } - tmp = []; - for(i in obj) { - if(obj.hasOwnProperty(i)) { - tmp.push(i); - } - } - return full ? $.map(tmp, $.proxy(function (i) { return this.get_node(i); }, this)) : tmp; - }; - /** - * get an array of all bottom level checked nodes (ignoring selected parents) (if tie_selection is on in the settings this function will return the same as get_bottom_selected) - * @name get_bottom_checked([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - * @plugin checkbox - */ - this.get_bottom_checked = function (full) { - if(this.settings.checkbox.tie_selection) { return this.get_bottom_selected(full); } - var tmp = this.get_checked(true), - obj = [], i, j; - for(i = 0, j = tmp.length; i < j; i++) { - if(!tmp[i].children.length) { - obj.push(tmp[i].id); - } - } - return full ? $.map(obj, $.proxy(function (i) { return this.get_node(i); }, this)) : obj; - }; - this.load_node = function (obj, callback) { - var k, l, i, j, c, tmp; - if(!$.isArray(obj) && !this.settings.checkbox.tie_selection) { - tmp = this.get_node(obj); - if(tmp && tmp.state.loaded) { - for(k = 0, l = tmp.children_d.length; k < l; k++) { - if(this._model.data[tmp.children_d[k]].state.checked) { - c = true; - this._data.checkbox.selected = $.vakata.array_remove_item(this._data.checkbox.selected, tmp.children_d[k]); - } - } - } - } - return parent.load_node.apply(this, arguments); - }; - this.get_state = function () { - var state = parent.get_state.apply(this, arguments); - if(this.settings.checkbox.tie_selection) { return state; } - state.checkbox = this._data.checkbox.selected.slice(); - return state; - }; - this.set_state = function (state, callback) { - var res = parent.set_state.apply(this, arguments); - if(res && state.checkbox) { - if(!this.settings.checkbox.tie_selection) { - this.uncheck_all(); - var _this = this; - $.each(state.checkbox, function (i, v) { - _this.check_node(v); - }); - } - delete state.checkbox; - this.set_state(state, callback); - return false; - } - return res; - }; - this.refresh = function (skip_loading, forget_state) { - if(!this.settings.checkbox.tie_selection) { - this._data.checkbox.selected = []; - } - return parent.refresh.apply(this, arguments); - }; - }; - - // include the checkbox plugin by default - // $.jstree.defaults.plugins.push("checkbox"); - - -/** - * ### Conditionalselect plugin - * - * This plugin allows defining a callback to allow or deny node selection by user input (activate node method). - */ - - /** - * a callback (function) which is invoked in the instance's scope and receives two arguments - the node and the event that triggered the `activate_node` call. Returning false prevents working with the node, returning true allows invoking activate_node. Defaults to returning `true`. - * @name $.jstree.defaults.checkbox.visible - * @plugin checkbox - */ - $.jstree.defaults.conditionalselect = function () { return true; }; - $.jstree.plugins.conditionalselect = function (options, parent) { - // own function - this.activate_node = function (obj, e) { - if(this.settings.conditionalselect.call(this, this.get_node(obj), e)) { - return parent.activate_node.call(this, obj, e); - } - }; - }; - - -/** - * ### Contextmenu plugin - * - * Shows a context menu when a node is right-clicked. - */ - - /** - * stores all defaults for the contextmenu plugin - * @name $.jstree.defaults.contextmenu - * @plugin contextmenu - */ - $.jstree.defaults.contextmenu = { - /** - * a boolean indicating if the node should be selected when the context menu is invoked on it. Defaults to `true`. - * @name $.jstree.defaults.contextmenu.select_node - * @plugin contextmenu - */ - select_node : true, - /** - * a boolean indicating if the menu should be shown aligned with the node. Defaults to `true`, otherwise the mouse coordinates are used. - * @name $.jstree.defaults.contextmenu.show_at_node - * @plugin contextmenu - */ - show_at_node : true, - /** - * an object of actions, or a function that accepts a node and a callback function and calls the callback function with an object of actions available for that node (you can also return the items too). - * - * Each action consists of a key (a unique name) and a value which is an object with the following properties (only label and action are required). Once a menu item is activated the `action` function will be invoked with an object containing the following keys: item - the contextmenu item definition as seen below, reference - the DOM node that was used (the tree node), element - the contextmenu DOM element, position - an object with x/y properties indicating the position of the menu. - * - * * `separator_before` - a boolean indicating if there should be a separator before this item - * * `separator_after` - a boolean indicating if there should be a separator after this item - * * `_disabled` - a boolean indicating if this action should be disabled - * * `label` - a string - the name of the action (could be a function returning a string) - * * `title` - a string - an optional tooltip for the item - * * `action` - a function to be executed if this item is chosen, the function will receive - * * `icon` - a string, can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class - * * `shortcut` - keyCode which will trigger the action if the menu is open (for example `113` for rename, which equals F2) - * * `shortcut_label` - shortcut label (like for example `F2` for rename) - * * `submenu` - an object with the same structure as $.jstree.defaults.contextmenu.items which can be used to create a submenu - each key will be rendered as a separate option in a submenu that will appear once the current item is hovered - * - * @name $.jstree.defaults.contextmenu.items - * @plugin contextmenu - */ - items : function (o, cb) { // Could be an object directly - return { - "create" : { - "separator_before" : false, - "separator_after" : true, - "_disabled" : false, //(this.check("create_node", data.reference, {}, "last")), - "label" : "Create", - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - inst.create_node(obj, {}, "last", function (new_node) { - try { - inst.edit(new_node); - } catch (ex) { - setTimeout(function () { inst.edit(new_node); },0); - } - }); - } - }, - "rename" : { - "separator_before" : false, - "separator_after" : false, - "_disabled" : false, //(this.check("rename_node", data.reference, this.get_parent(data.reference), "")), - "label" : "Rename", - /*! - "shortcut" : 113, - "shortcut_label" : 'F2', - "icon" : "glyphicon glyphicon-leaf", - */ - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - inst.edit(obj); - } - }, - "remove" : { - "separator_before" : false, - "icon" : false, - "separator_after" : false, - "_disabled" : false, //(this.check("delete_node", data.reference, this.get_parent(data.reference), "")), - "label" : "Delete", - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - if(inst.is_selected(obj)) { - inst.delete_node(inst.get_selected()); - } - else { - inst.delete_node(obj); - } - } - }, - "ccp" : { - "separator_before" : true, - "icon" : false, - "separator_after" : false, - "label" : "Edit", - "action" : false, - "submenu" : { - "cut" : { - "separator_before" : false, - "separator_after" : false, - "label" : "Cut", - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - if(inst.is_selected(obj)) { - inst.cut(inst.get_top_selected()); - } - else { - inst.cut(obj); - } - } - }, - "copy" : { - "separator_before" : false, - "icon" : false, - "separator_after" : false, - "label" : "Copy", - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - if(inst.is_selected(obj)) { - inst.copy(inst.get_top_selected()); - } - else { - inst.copy(obj); - } - } - }, - "paste" : { - "separator_before" : false, - "icon" : false, - "_disabled" : function (data) { - return !$.jstree.reference(data.reference).can_paste(); - }, - "separator_after" : false, - "label" : "Paste", - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - inst.paste(obj); - } - } - } - } - }; - } - }; - - $.jstree.plugins.contextmenu = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - - var last_ts = 0, cto = null, ex, ey; - this.element - .on("init.jstree loading.jstree ready.jstree", $.proxy(function () { - this.get_container_ul().addClass('jstree-contextmenu'); - }, this)) - .on("contextmenu.jstree", ".jstree-anchor", $.proxy(function (e, data) { - if (e.target.tagName.toLowerCase() === 'input') { - return; - } - e.preventDefault(); - last_ts = e.ctrlKey ? +new Date() : 0; - if(data || cto) { - last_ts = (+new Date()) + 10000; - } - if(cto) { - clearTimeout(cto); - } - if(!this.is_loading(e.currentTarget)) { - this.show_contextmenu(e.currentTarget, e.pageX, e.pageY, e); - } - }, this)) - .on("click.jstree", ".jstree-anchor", $.proxy(function (e) { - if(this._data.contextmenu.visible && (!last_ts || (+new Date()) - last_ts > 250)) { // work around safari & macOS ctrl+click - $.vakata.context.hide(); - } - last_ts = 0; - }, this)) - .on("touchstart.jstree", ".jstree-anchor", function (e) { - if(!e.originalEvent || !e.originalEvent.changedTouches || !e.originalEvent.changedTouches[0]) { - return; - } - ex = e.originalEvent.changedTouches[0].clientX; - ey = e.originalEvent.changedTouches[0].clientY; - cto = setTimeout(function () { - $(e.currentTarget).trigger('contextmenu', true); - }, 750); - }) - .on('touchmove.vakata.jstree', function (e) { - if(cto && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0] && (Math.abs(ex - e.originalEvent.changedTouches[0].clientX) > 10 || Math.abs(ey - e.originalEvent.changedTouches[0].clientY) > 10)) { - clearTimeout(cto); - $.vakata.context.hide(); - } - }) - .on('touchend.vakata.jstree', function (e) { - if(cto) { - clearTimeout(cto); - } - }); - - /*! - if(!('oncontextmenu' in document.body) && ('ontouchstart' in document.body)) { - var el = null, tm = null; - this.element - .on("touchstart", ".jstree-anchor", function (e) { - el = e.currentTarget; - tm = +new Date(); - $(document).one("touchend", function (e) { - e.target = document.elementFromPoint(e.originalEvent.targetTouches[0].pageX - window.pageXOffset, e.originalEvent.targetTouches[0].pageY - window.pageYOffset); - e.currentTarget = e.target; - tm = ((+(new Date())) - tm); - if(e.target === el && tm > 600 && tm < 1000) { - e.preventDefault(); - $(el).trigger('contextmenu', e); - } - el = null; - tm = null; - }); - }); - } - */ - $(document).on("context_hide.vakata.jstree", $.proxy(function (e, data) { - this._data.contextmenu.visible = false; - $(data.reference).removeClass('jstree-context'); - }, this)); - }; - this.teardown = function () { - if(this._data.contextmenu.visible) { - $.vakata.context.hide(); - } - parent.teardown.call(this); - }; - - /** - * prepare and show the context menu for a node - * @name show_contextmenu(obj [, x, y]) - * @param {mixed} obj the node - * @param {Number} x the x-coordinate relative to the document to show the menu at - * @param {Number} y the y-coordinate relative to the document to show the menu at - * @param {Object} e the event if available that triggered the contextmenu - * @plugin contextmenu - * @trigger show_contextmenu.jstree - */ - this.show_contextmenu = function (obj, x, y, e) { - obj = this.get_node(obj); - if(!obj || obj.id === $.jstree.root) { return false; } - var s = this.settings.contextmenu, - d = this.get_node(obj, true), - a = d.children(".jstree-anchor"), - o = false, - i = false; - if(s.show_at_node || x === undefined || y === undefined) { - o = a.offset(); - x = o.left; - y = o.top + this._data.core.li_height; - } - if(this.settings.contextmenu.select_node && !this.is_selected(obj)) { - this.activate_node(obj, e); - } - - i = s.items; - if($.isFunction(i)) { - i = i.call(this, obj, $.proxy(function (i) { - this._show_contextmenu(obj, x, y, i); - }, this)); - } - if($.isPlainObject(i)) { - this._show_contextmenu(obj, x, y, i); - } - }; - /** - * show the prepared context menu for a node - * @name _show_contextmenu(obj, x, y, i) - * @param {mixed} obj the node - * @param {Number} x the x-coordinate relative to the document to show the menu at - * @param {Number} y the y-coordinate relative to the document to show the menu at - * @param {Number} i the object of items to show - * @plugin contextmenu - * @trigger show_contextmenu.jstree - * @private - */ - this._show_contextmenu = function (obj, x, y, i) { - var d = this.get_node(obj, true), - a = d.children(".jstree-anchor"); - $(document).one("context_show.vakata.jstree", $.proxy(function (e, data) { - var cls = 'jstree-contextmenu jstree-' + this.get_theme() + '-contextmenu'; - $(data.element).addClass(cls); - a.addClass('jstree-context'); - }, this)); - this._data.contextmenu.visible = true; - $.vakata.context.show(a, { 'x' : x, 'y' : y }, i); - /** - * triggered when the contextmenu is shown for a node - * @event - * @name show_contextmenu.jstree - * @param {Object} node the node - * @param {Number} x the x-coordinate of the menu relative to the document - * @param {Number} y the y-coordinate of the menu relative to the document - * @plugin contextmenu - */ - this.trigger('show_contextmenu', { "node" : obj, "x" : x, "y" : y }); - }; - }; - - // contextmenu helper - (function ($) { - var right_to_left = false, - vakata_context = { - element : false, - reference : false, - position_x : 0, - position_y : 0, - items : [], - html : "", - is_visible : false - }; - - $.vakata.context = { - settings : { - hide_onmouseleave : 0, - icons : true - }, - _trigger : function (event_name) { - $(document).triggerHandler("context_" + event_name + ".vakata", { - "reference" : vakata_context.reference, - "element" : vakata_context.element, - "position" : { - "x" : vakata_context.position_x, - "y" : vakata_context.position_y - } - }); - }, - _execute : function (i) { - i = vakata_context.items[i]; - return i && (!i._disabled || ($.isFunction(i._disabled) && !i._disabled({ "item" : i, "reference" : vakata_context.reference, "element" : vakata_context.element }))) && i.action ? i.action.call(null, { - "item" : i, - "reference" : vakata_context.reference, - "element" : vakata_context.element, - "position" : { - "x" : vakata_context.position_x, - "y" : vakata_context.position_y - } - }) : false; - }, - _parse : function (o, is_callback) { - if(!o) { return false; } - if(!is_callback) { - vakata_context.html = ""; - vakata_context.items = []; - } - var str = "", - sep = false, - tmp; - - if(is_callback) { str += "<"+"ul>"; } - $.each(o, function (i, val) { - if(!val) { return true; } - vakata_context.items.push(val); - if(!sep && val.separator_before) { - str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + "> <"+"/a><"+"/li>"; - } - sep = false; - str += "<"+"li class='" + (val._class || "") + (val._disabled === true || ($.isFunction(val._disabled) && val._disabled({ "item" : val, "reference" : vakata_context.reference, "element" : vakata_context.element })) ? " vakata-contextmenu-disabled " : "") + "' "+(val.shortcut?" data-shortcut='"+val.shortcut+"' ":'')+">"; - str += "<"+"a href='#' rel='" + (vakata_context.items.length - 1) + "' " + (val.title ? "title='" + val.title + "'" : "") + ">"; - if($.vakata.context.settings.icons) { - str += "<"+"i "; - if(val.icon) { - if(val.icon.indexOf("/") !== -1 || val.icon.indexOf(".") !== -1) { str += " style='background:url(\"" + val.icon + "\") center center no-repeat' "; } - else { str += " class='" + val.icon + "' "; } - } - str += "><"+"/i><"+"span class='vakata-contextmenu-sep'> <"+"/span>"; - } - str += ($.isFunction(val.label) ? val.label({ "item" : i, "reference" : vakata_context.reference, "element" : vakata_context.element }) : val.label) + (val.shortcut?' '+ (val.shortcut_label || '') +'':'') + "<"+"/a>"; - if(val.submenu) { - tmp = $.vakata.context._parse(val.submenu, true); - if(tmp) { str += tmp; } - } - str += "<"+"/li>"; - if(val.separator_after) { - str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + "> <"+"/a><"+"/li>"; - sep = true; - } - }); - str = str.replace(/
  • <\/li\>$/,""); - if(is_callback) { str += ""; } - /** - * triggered on the document when the contextmenu is parsed (HTML is built) - * @event - * @plugin contextmenu - * @name context_parse.vakata - * @param {jQuery} reference the element that was right clicked - * @param {jQuery} element the DOM element of the menu itself - * @param {Object} position the x & y coordinates of the menu - */ - if(!is_callback) { vakata_context.html = str; $.vakata.context._trigger("parse"); } - return str.length > 10 ? str : false; - }, - _show_submenu : function (o) { - o = $(o); - if(!o.length || !o.children("ul").length) { return; } - var e = o.children("ul"), - xl = o.offset().left, - x = xl + o.outerWidth(), - y = o.offset().top, - w = e.width(), - h = e.height(), - dw = $(window).width() + $(window).scrollLeft(), - dh = $(window).height() + $(window).scrollTop(); - // може да се спести е една проверка - дали няма някой от класовете вече нагоре - if(right_to_left) { - o[x - (w + 10 + o.outerWidth()) < 0 ? "addClass" : "removeClass"]("vakata-context-left"); - } - else { - o[x + w > dw && xl > dw - x ? "addClass" : "removeClass"]("vakata-context-right"); - } - if(y + h + 10 > dh) { - e.css("bottom","-1px"); - } - - //if does not fit - stick it to the side - if (o.hasClass('vakata-context-right')) { - if (xl < w) { - e.css("margin-right", xl - w); - } - } else { - if (dw - x < w) { - e.css("margin-left", dw - x - w); - } - } - - e.show(); - }, - show : function (reference, position, data) { - var o, e, x, y, w, h, dw, dh, cond = true; - if(vakata_context.element && vakata_context.element.length) { - vakata_context.element.width(''); - } - switch(cond) { - case (!position && !reference): - return false; - case (!!position && !!reference): - vakata_context.reference = reference; - vakata_context.position_x = position.x; - vakata_context.position_y = position.y; - break; - case (!position && !!reference): - vakata_context.reference = reference; - o = reference.offset(); - vakata_context.position_x = o.left + reference.outerHeight(); - vakata_context.position_y = o.top; - break; - case (!!position && !reference): - vakata_context.position_x = position.x; - vakata_context.position_y = position.y; - break; - } - if(!!reference && !data && $(reference).data('vakata_contextmenu')) { - data = $(reference).data('vakata_contextmenu'); - } - if($.vakata.context._parse(data)) { - vakata_context.element.html(vakata_context.html); - } - if(vakata_context.items.length) { - vakata_context.element.appendTo(document.body); - e = vakata_context.element; - x = vakata_context.position_x; - y = vakata_context.position_y; - w = e.width(); - h = e.height(); - dw = $(window).width() + $(window).scrollLeft(); - dh = $(window).height() + $(window).scrollTop(); - if(right_to_left) { - x -= (e.outerWidth() - $(reference).outerWidth()); - if(x < $(window).scrollLeft() + 20) { - x = $(window).scrollLeft() + 20; - } - } - if(x + w + 20 > dw) { - x = dw - (w + 20); - } - if(y + h + 20 > dh) { - y = dh - (h + 20); - } - - vakata_context.element - .css({ "left" : x, "top" : y }) - .show() - .find('a').first().focus().parent().addClass("vakata-context-hover"); - vakata_context.is_visible = true; - /** - * triggered on the document when the contextmenu is shown - * @event - * @plugin contextmenu - * @name context_show.vakata - * @param {jQuery} reference the element that was right clicked - * @param {jQuery} element the DOM element of the menu itself - * @param {Object} position the x & y coordinates of the menu - */ - $.vakata.context._trigger("show"); - } - }, - hide : function () { - if(vakata_context.is_visible) { - vakata_context.element.hide().find("ul").hide().end().find(':focus').blur().end().detach(); - vakata_context.is_visible = false; - /** - * triggered on the document when the contextmenu is hidden - * @event - * @plugin contextmenu - * @name context_hide.vakata - * @param {jQuery} reference the element that was right clicked - * @param {jQuery} element the DOM element of the menu itself - * @param {Object} position the x & y coordinates of the menu - */ - $.vakata.context._trigger("hide"); - } - } - }; - $(function () { - right_to_left = $(document.body).css("direction") === "rtl"; - var to = false; - - vakata_context.element = $("
      "); - vakata_context.element - .on("mouseenter", "li", function (e) { - e.stopImmediatePropagation(); - - if($.contains(this, e.relatedTarget)) { - // премахнато заради delegate mouseleave по-долу - // $(this).find(".vakata-context-hover").removeClass("vakata-context-hover"); - return; - } - - if(to) { clearTimeout(to); } - vakata_context.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end(); - - $(this) - .siblings().find("ul").hide().end().end() - .parentsUntil(".vakata-context", "li").addBack().addClass("vakata-context-hover"); - $.vakata.context._show_submenu(this); - }) - // тестово - дали не натоварва? - .on("mouseleave", "li", function (e) { - if($.contains(this, e.relatedTarget)) { return; } - $(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover"); - }) - .on("mouseleave", function (e) { - $(this).find(".vakata-context-hover").removeClass("vakata-context-hover"); - if($.vakata.context.settings.hide_onmouseleave) { - to = setTimeout( - (function (t) { - return function () { $.vakata.context.hide(); }; - }(this)), $.vakata.context.settings.hide_onmouseleave); - } - }) - .on("click", "a", function (e) { - e.preventDefault(); - //}) - //.on("mouseup", "a", function (e) { - if(!$(this).blur().parent().hasClass("vakata-context-disabled") && $.vakata.context._execute($(this).attr("rel")) !== false) { - $.vakata.context.hide(); - } - }) - .on('keydown', 'a', function (e) { - var o = null; - switch(e.which) { - case 13: - case 32: - e.type = "click"; - e.preventDefault(); - $(e.currentTarget).trigger(e); - break; - case 37: - if(vakata_context.is_visible) { - vakata_context.element.find(".vakata-context-hover").last().closest("li").first().find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children('a').focus(); - e.stopImmediatePropagation(); - e.preventDefault(); - } - break; - case 38: - if(vakata_context.is_visible) { - o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first(); - if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last(); } - o.addClass("vakata-context-hover").children('a').focus(); - e.stopImmediatePropagation(); - e.preventDefault(); - } - break; - case 39: - if(vakata_context.is_visible) { - vakata_context.element.find(".vakata-context-hover").last().children("ul").show().children("li:not(.vakata-context-separator)").removeClass("vakata-context-hover").first().addClass("vakata-context-hover").children('a').focus(); - e.stopImmediatePropagation(); - e.preventDefault(); - } - break; - case 40: - if(vakata_context.is_visible) { - o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first(); - if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first(); } - o.addClass("vakata-context-hover").children('a').focus(); - e.stopImmediatePropagation(); - e.preventDefault(); - } - break; - case 27: - $.vakata.context.hide(); - e.preventDefault(); - break; - default: - //console.log(e.which); - break; - } - }) - .on('keydown', function (e) { - e.preventDefault(); - var a = vakata_context.element.find('.vakata-contextmenu-shortcut-' + e.which).parent(); - if(a.parent().not('.vakata-context-disabled')) { - a.click(); - } - }); - - $(document) - .on("mousedown.vakata.jstree", function (e) { - if(vakata_context.is_visible && vakata_context.element[0] !== e.target && !$.contains(vakata_context.element[0], e.target)) { - $.vakata.context.hide(); - } - }) - .on("context_show.vakata.jstree", function (e, data) { - vakata_context.element.find("li:has(ul)").children("a").addClass("vakata-context-parent"); - if(right_to_left) { - vakata_context.element.addClass("vakata-context-rtl").css("direction", "rtl"); - } - // also apply a RTL class? - vakata_context.element.find("ul").hide().end(); - }); - }); - }($)); - // $.jstree.defaults.plugins.push("contextmenu"); - - -/** - * ### Drag'n'drop plugin - * - * Enables dragging and dropping of nodes in the tree, resulting in a move or copy operations. - */ - - /** - * stores all defaults for the drag'n'drop plugin - * @name $.jstree.defaults.dnd - * @plugin dnd - */ - $.jstree.defaults.dnd = { - /** - * a boolean indicating if a copy should be possible while dragging (by pressint the meta key or Ctrl). Defaults to `true`. - * @name $.jstree.defaults.dnd.copy - * @plugin dnd - */ - copy : true, - /** - * a number indicating how long a node should remain hovered while dragging to be opened. Defaults to `500`. - * @name $.jstree.defaults.dnd.open_timeout - * @plugin dnd - */ - open_timeout : 500, - /** - * a function invoked each time a node is about to be dragged, invoked in the tree's scope and receives the nodes about to be dragged as an argument (array) and the event that started the drag - return `false` to prevent dragging - * @name $.jstree.defaults.dnd.is_draggable - * @plugin dnd - */ - is_draggable : true, - /** - * a boolean indicating if checks should constantly be made while the user is dragging the node (as opposed to checking only on drop), default is `true` - * @name $.jstree.defaults.dnd.check_while_dragging - * @plugin dnd - */ - check_while_dragging : true, - /** - * a boolean indicating if nodes from this tree should only be copied with dnd (as opposed to moved), default is `false` - * @name $.jstree.defaults.dnd.always_copy - * @plugin dnd - */ - always_copy : false, - /** - * when dropping a node "inside", this setting indicates the position the node should go to - it can be an integer or a string: "first" (same as 0) or "last", default is `0` - * @name $.jstree.defaults.dnd.inside_pos - * @plugin dnd - */ - inside_pos : 0, - /** - * when starting the drag on a node that is selected this setting controls if all selected nodes are dragged or only the single node, default is `true`, which means all selected nodes are dragged when the drag is started on a selected node - * @name $.jstree.defaults.dnd.drag_selection - * @plugin dnd - */ - drag_selection : true, - /** - * controls whether dnd works on touch devices. If left as boolean true dnd will work the same as in desktop browsers, which in some cases may impair scrolling. If set to boolean false dnd will not work on touch devices. There is a special third option - string "selected" which means only selected nodes can be dragged on touch devices. - * @name $.jstree.defaults.dnd.touch - * @plugin dnd - */ - touch : true, - /** - * controls whether items can be dropped anywhere on the node, not just on the anchor, by default only the node anchor is a valid drop target. Works best with the wholerow plugin. If enabled on mobile depending on the interface it might be hard for the user to cancel the drop, since the whole tree container will be a valid drop target. - * @name $.jstree.defaults.dnd.large_drop_target - * @plugin dnd - */ - large_drop_target : false, - /** - * controls whether a drag can be initiated from any part of the node and not just the text/icon part, works best with the wholerow plugin. Keep in mind it can cause problems with tree scrolling on mobile depending on the interface - in that case set the touch option to "selected". - * @name $.jstree.defaults.dnd.large_drag_target - * @plugin dnd - */ - large_drag_target : false, - /** - * controls whether use HTML5 dnd api instead of classical. That will allow better integration of dnd events with other HTML5 controls. - * @reference http://caniuse.com/#feat=dragndrop - * @name $.jstree.defaults.dnd.use_html5 - * @plugin dnd - */ - use_html5: false - }; - var drg, elm; - // TODO: now check works by checking for each node individually, how about max_children, unique, etc? - $.jstree.plugins.dnd = function (options, parent) { - this.init = function (el, options) { - parent.init.call(this, el, options); - this.settings.dnd.use_html5 = this.settings.dnd.use_html5 && ('draggable' in document.createElement('span')); - }; - this.bind = function () { - parent.bind.call(this); - - this.element - .on(this.settings.dnd.use_html5 ? 'dragstart.jstree' : 'mousedown.jstree touchstart.jstree', this.settings.dnd.large_drag_target ? '.jstree-node' : '.jstree-anchor', $.proxy(function (e) { - if(this.settings.dnd.large_drag_target && $(e.target).closest('.jstree-node')[0] !== e.currentTarget) { - return true; - } - if(e.type === "touchstart" && (!this.settings.dnd.touch || (this.settings.dnd.touch === 'selected' && !$(e.currentTarget).closest('.jstree-node').children('.jstree-anchor').hasClass('jstree-clicked')))) { - return true; - } - var obj = this.get_node(e.target), - mlt = this.is_selected(obj) && this.settings.dnd.drag_selection ? this.get_top_selected().length : 1, - txt = (mlt > 1 ? mlt + ' ' + this.get_string('nodes') : this.get_text(e.currentTarget)); - if(this.settings.core.force_text) { - txt = $.vakata.html.escape(txt); - } - if(obj && obj.id && obj.id !== $.jstree.root && (e.which === 1 || e.type === "touchstart" || e.type === "dragstart") && - (this.settings.dnd.is_draggable === true || ($.isFunction(this.settings.dnd.is_draggable) && this.settings.dnd.is_draggable.call(this, (mlt > 1 ? this.get_top_selected(true) : [obj]), e))) - ) { - drg = { 'jstree' : true, 'origin' : this, 'obj' : this.get_node(obj,true), 'nodes' : mlt > 1 ? this.get_top_selected() : [obj.id] }; - elm = e.currentTarget; - if (this.settings.dnd.use_html5) { - $.vakata.dnd._trigger('start', e, { 'helper': $(), 'element': elm, 'data': drg }); - } else { - this.element.trigger('mousedown.jstree'); - return $.vakata.dnd.start(e, drg, '
      ' + txt + '
      '); - } - } - }, this)); - if (this.settings.dnd.use_html5) { - this.element - .on('dragover.jstree', function (e) { - e.preventDefault(); - $.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg }); - return false; - }) - //.on('dragenter.jstree', this.settings.dnd.large_drop_target ? '.jstree-node' : '.jstree-anchor', $.proxy(function (e) { - // e.preventDefault(); - // $.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg }); - // return false; - // }, this)) - .on('drop.jstree', $.proxy(function (e) { - e.preventDefault(); - $.vakata.dnd._trigger('stop', e, { 'helper': $(), 'element': elm, 'data': drg }); - return false; - }, this)); - } - }; - this.redraw_node = function(obj, deep, callback, force_render) { - obj = parent.redraw_node.apply(this, arguments); - if (obj && this.settings.dnd.use_html5) { - if (this.settings.dnd.large_drag_target) { - obj.setAttribute('draggable', true); - } else { - var i, j, tmp = null; - for(i = 0, j = obj.childNodes.length; i < j; i++) { - if(obj.childNodes[i] && obj.childNodes[i].className && obj.childNodes[i].className.indexOf("jstree-anchor") !== -1) { - tmp = obj.childNodes[i]; - break; - } - } - if(tmp) { - tmp.setAttribute('draggable', true); - } - } - } - return obj; - }; - }; - - $(function() { - // bind only once for all instances - var lastmv = false, - laster = false, - lastev = false, - opento = false, - marker = $('
       
      ').hide(); //.appendTo('body'); - - $(document) - .on('dnd_start.vakata.jstree', function (e, data) { - lastmv = false; - lastev = false; - if(!data || !data.data || !data.data.jstree) { return; } - marker.appendTo(document.body); //.show(); - }) - .on('dnd_move.vakata.jstree', function (e, data) { - var isDifferentNode = data.event.target !== lastev.target; - if(opento) { - if (!data.event || data.event.type !== 'dragover' || isDifferentNode) { - clearTimeout(opento); - } - } - if(!data || !data.data || !data.data.jstree) { return; } - - // if we are hovering the marker image do nothing (can happen on "inside" drags) - if(data.event.target.id && data.event.target.id === 'jstree-marker') { - return; - } - lastev = data.event; - - var ins = $.jstree.reference(data.event.target), - ref = false, - off = false, - rel = false, - tmp, l, t, h, p, i, o, ok, t1, t2, op, ps, pr, ip, tm, is_copy, pn; - // if we are over an instance - if(ins && ins._data && ins._data.dnd) { - marker.attr('class', 'jstree-' + ins.get_theme() + ( ins.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' )); - is_copy = data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))); - data.helper - .children().attr('class', 'jstree-' + ins.get_theme() + ' jstree-' + ins.get_theme() + '-' + ins.get_theme_variant() + ' ' + ( ins.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' )) - .find('.jstree-copy').first()[ is_copy ? 'show' : 'hide' ](); - - // if are hovering the container itself add a new root node - //console.log(data.event); - if( (data.event.target === ins.element[0] || data.event.target === ins.get_container_ul()[0]) && ins.get_container_ul().children().length === 0) { - ok = true; - for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) { - ok = ok && ins.check( (data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey)) ) ? "copy_node" : "move_node"), (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), $.jstree.root, 'last', { 'dnd' : true, 'ref' : ins.get_node($.jstree.root), 'pos' : 'i', 'origin' : data.data.origin, 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) }); - if(!ok) { break; } - } - if(ok) { - lastmv = { 'ins' : ins, 'par' : $.jstree.root, 'pos' : 'last' }; - marker.hide(); - data.helper.find('.jstree-icon').first().removeClass('jstree-er').addClass('jstree-ok'); - if (data.event.originalEvent && data.event.originalEvent.dataTransfer) { - data.event.originalEvent.dataTransfer.dropEffect = is_copy ? 'copy' : 'move'; - } - return; - } - } - else { - // if we are hovering a tree node - ref = ins.settings.dnd.large_drop_target ? $(data.event.target).closest('.jstree-node').children('.jstree-anchor') : $(data.event.target).closest('.jstree-anchor'); - if(ref && ref.length && ref.parent().is('.jstree-closed, .jstree-open, .jstree-leaf')) { - off = ref.offset(); - rel = (data.event.pageY !== undefined ? data.event.pageY : data.event.originalEvent.pageY) - off.top; - h = ref.outerHeight(); - if(rel < h / 3) { - o = ['b', 'i', 'a']; - } - else if(rel > h - h / 3) { - o = ['a', 'i', 'b']; - } - else { - o = rel > h / 2 ? ['i', 'a', 'b'] : ['i', 'b', 'a']; - } - $.each(o, function (j, v) { - switch(v) { - case 'b': - l = off.left - 6; - t = off.top; - p = ins.get_parent(ref); - i = ref.parent().index(); - break; - case 'i': - ip = ins.settings.dnd.inside_pos; - tm = ins.get_node(ref.parent()); - l = off.left - 2; - t = off.top + h / 2 + 1; - p = tm.id; - i = ip === 'first' ? 0 : (ip === 'last' ? tm.children.length : Math.min(ip, tm.children.length)); - break; - case 'a': - l = off.left - 6; - t = off.top + h; - p = ins.get_parent(ref); - i = ref.parent().index() + 1; - break; - } - ok = true; - for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) { - op = data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))) ? "copy_node" : "move_node"; - ps = i; - if(op === "move_node" && v === 'a' && (data.data.origin && data.data.origin === ins) && p === ins.get_parent(data.data.nodes[t1])) { - pr = ins.get_node(p); - if(ps > $.inArray(data.data.nodes[t1], pr.children)) { - ps -= 1; - } - } - ok = ok && ( (ins && ins.settings && ins.settings.dnd && ins.settings.dnd.check_while_dragging === false) || ins.check(op, (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), p, ps, { 'dnd' : true, 'ref' : ins.get_node(ref.parent()), 'pos' : v, 'origin' : data.data.origin, 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) }) ); - if(!ok) { - if(ins && ins.last_error) { laster = ins.last_error(); } - break; - } - } - if(v === 'i' && ref.parent().is('.jstree-closed') && ins.settings.dnd.open_timeout) { - if (!data.event || data.event.type !== 'dragover' || isDifferentNode) { - if (opento) { clearTimeout(opento); } - opento = setTimeout((function (x, z) { return function () { x.open_node(z); }; }(ins, ref)), ins.settings.dnd.open_timeout); - } - } - if(ok) { - pn = ins.get_node(p, true); - if (!pn.hasClass('.jstree-dnd-parent')) { - $('.jstree-dnd-parent').removeClass('jstree-dnd-parent'); - pn.addClass('jstree-dnd-parent'); - } - lastmv = { 'ins' : ins, 'par' : p, 'pos' : v === 'i' && ip === 'last' && i === 0 && !ins.is_loaded(tm) ? 'last' : i }; - marker.css({ 'left' : l + 'px', 'top' : t + 'px' }).show(); - data.helper.find('.jstree-icon').first().removeClass('jstree-er').addClass('jstree-ok'); - if (data.event.originalEvent && data.event.originalEvent.dataTransfer) { - data.event.originalEvent.dataTransfer.dropEffect = is_copy ? 'copy' : 'move'; - } - laster = {}; - o = true; - return false; - } - }); - if(o === true) { return; } - } - } - } - $('.jstree-dnd-parent').removeClass('jstree-dnd-parent'); - lastmv = false; - data.helper.find('.jstree-icon').removeClass('jstree-ok').addClass('jstree-er'); - if (data.event.originalEvent && data.event.originalEvent.dataTransfer) { - data.event.originalEvent.dataTransfer.dropEffect = 'none'; - } - marker.hide(); - }) - .on('dnd_scroll.vakata.jstree', function (e, data) { - if(!data || !data.data || !data.data.jstree) { return; } - marker.hide(); - lastmv = false; - lastev = false; - data.helper.find('.jstree-icon').first().removeClass('jstree-ok').addClass('jstree-er'); - }) - .on('dnd_stop.vakata.jstree', function (e, data) { - $('.jstree-dnd-parent').removeClass('jstree-dnd-parent'); - if(opento) { clearTimeout(opento); } - if(!data || !data.data || !data.data.jstree) { return; } - marker.hide().detach(); - var i, j, nodes = []; - if(lastmv) { - for(i = 0, j = data.data.nodes.length; i < j; i++) { - nodes[i] = data.data.origin ? data.data.origin.get_node(data.data.nodes[i]) : data.data.nodes[i]; - } - lastmv.ins[ data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))) ? 'copy_node' : 'move_node' ](nodes, lastmv.par, lastmv.pos, false, false, false, data.data.origin); - } - else { - i = $(data.event.target).closest('.jstree'); - if(i.length && laster && laster.error && laster.error === 'check') { - i = i.jstree(true); - if(i) { - i.settings.core.error.call(this, laster); - } - } - } - lastev = false; - lastmv = false; - }) - .on('keyup.jstree keydown.jstree', function (e, data) { - data = $.vakata.dnd._get(); - if(data && data.data && data.data.jstree) { - if (e.type === "keyup" && e.which === 27) { - if (opento) { clearTimeout(opento); } - lastmv = false; - laster = false; - lastev = false; - opento = false; - marker.hide().detach(); - $.vakata.dnd._clean(); - } else { - data.helper.find('.jstree-copy').first()[ data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (e.metaKey || e.ctrlKey))) ? 'show' : 'hide' ](); - if(lastev) { - lastev.metaKey = e.metaKey; - lastev.ctrlKey = e.ctrlKey; - $.vakata.dnd._trigger('move', lastev); - } - } - } - }); - }); - - // helpers - (function ($) { - $.vakata.html = { - div : $('
      '), - escape : function (str) { - return $.vakata.html.div.text(str).html(); - }, - strip : function (str) { - return $.vakata.html.div.empty().append($.parseHTML(str)).text(); - } - }; - // private variable - var vakata_dnd = { - element : false, - target : false, - is_down : false, - is_drag : false, - helper : false, - helper_w: 0, - data : false, - init_x : 0, - init_y : 0, - scroll_l: 0, - scroll_t: 0, - scroll_e: false, - scroll_i: false, - is_touch: false - }; - $.vakata.dnd = { - settings : { - scroll_speed : 10, - scroll_proximity : 20, - helper_left : 5, - helper_top : 10, - threshold : 5, - threshold_touch : 10 - }, - _trigger : function (event_name, e, data) { - if (data === undefined) { - data = $.vakata.dnd._get(); - } - data.event = e; - $(document).triggerHandler("dnd_" + event_name + ".vakata", data); - }, - _get : function () { - return { - "data" : vakata_dnd.data, - "element" : vakata_dnd.element, - "helper" : vakata_dnd.helper - }; - }, - _clean : function () { - if(vakata_dnd.helper) { vakata_dnd.helper.remove(); } - if(vakata_dnd.scroll_i) { clearInterval(vakata_dnd.scroll_i); vakata_dnd.scroll_i = false; } - vakata_dnd = { - element : false, - target : false, - is_down : false, - is_drag : false, - helper : false, - helper_w: 0, - data : false, - init_x : 0, - init_y : 0, - scroll_l: 0, - scroll_t: 0, - scroll_e: false, - scroll_i: false, - is_touch: false - }; - $(document).off("mousemove.vakata.jstree touchmove.vakata.jstree", $.vakata.dnd.drag); - $(document).off("mouseup.vakata.jstree touchend.vakata.jstree", $.vakata.dnd.stop); - }, - _scroll : function (init_only) { - if(!vakata_dnd.scroll_e || (!vakata_dnd.scroll_l && !vakata_dnd.scroll_t)) { - if(vakata_dnd.scroll_i) { clearInterval(vakata_dnd.scroll_i); vakata_dnd.scroll_i = false; } - return false; - } - if(!vakata_dnd.scroll_i) { - vakata_dnd.scroll_i = setInterval($.vakata.dnd._scroll, 100); - return false; - } - if(init_only === true) { return false; } - - var i = vakata_dnd.scroll_e.scrollTop(), - j = vakata_dnd.scroll_e.scrollLeft(); - vakata_dnd.scroll_e.scrollTop(i + vakata_dnd.scroll_t * $.vakata.dnd.settings.scroll_speed); - vakata_dnd.scroll_e.scrollLeft(j + vakata_dnd.scroll_l * $.vakata.dnd.settings.scroll_speed); - if(i !== vakata_dnd.scroll_e.scrollTop() || j !== vakata_dnd.scroll_e.scrollLeft()) { - /** - * triggered on the document when a drag causes an element to scroll - * @event - * @plugin dnd - * @name dnd_scroll.vakata - * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start - * @param {DOM} element the DOM element being dragged - * @param {jQuery} helper the helper shown next to the mouse - * @param {jQuery} event the element that is scrolling - */ - $.vakata.dnd._trigger("scroll", vakata_dnd.scroll_e); - } - }, - start : function (e, data, html) { - if(e.type === "touchstart" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) { - e.pageX = e.originalEvent.changedTouches[0].pageX; - e.pageY = e.originalEvent.changedTouches[0].pageY; - e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset); - } - if(vakata_dnd.is_drag) { $.vakata.dnd.stop({}); } - try { - e.currentTarget.unselectable = "on"; - e.currentTarget.onselectstart = function() { return false; }; - if(e.currentTarget.style) { - e.currentTarget.style.touchAction = "none"; - e.currentTarget.style.msTouchAction = "none"; - e.currentTarget.style.MozUserSelect = "none"; - } - } catch(ignore) { } - vakata_dnd.init_x = e.pageX; - vakata_dnd.init_y = e.pageY; - vakata_dnd.data = data; - vakata_dnd.is_down = true; - vakata_dnd.element = e.currentTarget; - vakata_dnd.target = e.target; - vakata_dnd.is_touch = e.type === "touchstart"; - if(html !== false) { - vakata_dnd.helper = $("
      ").html(html).css({ - "display" : "block", - "margin" : "0", - "padding" : "0", - "position" : "absolute", - "top" : "-2000px", - "lineHeight" : "16px", - "zIndex" : "10000" - }); - } - $(document).on("mousemove.vakata.jstree touchmove.vakata.jstree", $.vakata.dnd.drag); - $(document).on("mouseup.vakata.jstree touchend.vakata.jstree", $.vakata.dnd.stop); - return false; - }, - drag : function (e) { - if(e.type === "touchmove" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) { - e.pageX = e.originalEvent.changedTouches[0].pageX; - e.pageY = e.originalEvent.changedTouches[0].pageY; - e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset); - } - if(!vakata_dnd.is_down) { return; } - if(!vakata_dnd.is_drag) { - if( - Math.abs(e.pageX - vakata_dnd.init_x) > (vakata_dnd.is_touch ? $.vakata.dnd.settings.threshold_touch : $.vakata.dnd.settings.threshold) || - Math.abs(e.pageY - vakata_dnd.init_y) > (vakata_dnd.is_touch ? $.vakata.dnd.settings.threshold_touch : $.vakata.dnd.settings.threshold) - ) { - if(vakata_dnd.helper) { - vakata_dnd.helper.appendTo(document.body); - vakata_dnd.helper_w = vakata_dnd.helper.outerWidth(); - } - vakata_dnd.is_drag = true; - $(vakata_dnd.target).one('click.vakata', false); - /** - * triggered on the document when a drag starts - * @event - * @plugin dnd - * @name dnd_start.vakata - * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start - * @param {DOM} element the DOM element being dragged - * @param {jQuery} helper the helper shown next to the mouse - * @param {Object} event the event that caused the start (probably mousemove) - */ - $.vakata.dnd._trigger("start", e); - } - else { return; } - } - - var d = false, w = false, - dh = false, wh = false, - dw = false, ww = false, - dt = false, dl = false, - ht = false, hl = false; - - vakata_dnd.scroll_t = 0; - vakata_dnd.scroll_l = 0; - vakata_dnd.scroll_e = false; - $($(e.target).parentsUntil("body").addBack().get().reverse()) - .filter(function () { - return (/^auto|scroll$/).test($(this).css("overflow")) && - (this.scrollHeight > this.offsetHeight || this.scrollWidth > this.offsetWidth); - }) - .each(function () { - var t = $(this), o = t.offset(); - if(this.scrollHeight > this.offsetHeight) { - if(o.top + t.height() - e.pageY < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = 1; } - if(e.pageY - o.top < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = -1; } - } - if(this.scrollWidth > this.offsetWidth) { - if(o.left + t.width() - e.pageX < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = 1; } - if(e.pageX - o.left < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = -1; } - } - if(vakata_dnd.scroll_t || vakata_dnd.scroll_l) { - vakata_dnd.scroll_e = $(this); - return false; - } - }); - - if(!vakata_dnd.scroll_e) { - d = $(document); w = $(window); - dh = d.height(); wh = w.height(); - dw = d.width(); ww = w.width(); - dt = d.scrollTop(); dl = d.scrollLeft(); - if(dh > wh && e.pageY - dt < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = -1; } - if(dh > wh && wh - (e.pageY - dt) < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = 1; } - if(dw > ww && e.pageX - dl < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = -1; } - if(dw > ww && ww - (e.pageX - dl) < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = 1; } - if(vakata_dnd.scroll_t || vakata_dnd.scroll_l) { - vakata_dnd.scroll_e = d; - } - } - if(vakata_dnd.scroll_e) { $.vakata.dnd._scroll(true); } - - if(vakata_dnd.helper) { - ht = parseInt(e.pageY + $.vakata.dnd.settings.helper_top, 10); - hl = parseInt(e.pageX + $.vakata.dnd.settings.helper_left, 10); - if(dh && ht + 25 > dh) { ht = dh - 50; } - if(dw && hl + vakata_dnd.helper_w > dw) { hl = dw - (vakata_dnd.helper_w + 2); } - vakata_dnd.helper.css({ - left : hl + "px", - top : ht + "px" - }); - } - /** - * triggered on the document when a drag is in progress - * @event - * @plugin dnd - * @name dnd_move.vakata - * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start - * @param {DOM} element the DOM element being dragged - * @param {jQuery} helper the helper shown next to the mouse - * @param {Object} event the event that caused this to trigger (most likely mousemove) - */ - $.vakata.dnd._trigger("move", e); - return false; - }, - stop : function (e) { - if(e.type === "touchend" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) { - e.pageX = e.originalEvent.changedTouches[0].pageX; - e.pageY = e.originalEvent.changedTouches[0].pageY; - e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset); - } - if(vakata_dnd.is_drag) { - /** - * triggered on the document when a drag stops (the dragged element is dropped) - * @event - * @plugin dnd - * @name dnd_stop.vakata - * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start - * @param {DOM} element the DOM element being dragged - * @param {jQuery} helper the helper shown next to the mouse - * @param {Object} event the event that caused the stop - */ - if (e.target !== vakata_dnd.target) { - $(vakata_dnd.target).off('click.vakata'); - } - $.vakata.dnd._trigger("stop", e); - } - else { - if(e.type === "touchend" && e.target === vakata_dnd.target) { - var to = setTimeout(function () { $(e.target).click(); }, 100); - $(e.target).one('click', function() { if(to) { clearTimeout(to); } }); - } - } - $.vakata.dnd._clean(); - return false; - } - }; - }($)); - - // include the dnd plugin by default - // $.jstree.defaults.plugins.push("dnd"); - - -/** - * ### Massload plugin - * - * Adds massload functionality to jsTree, so that multiple nodes can be loaded in a single request (only useful with lazy loading). - */ - - /** - * massload configuration - * - * It is possible to set this to a standard jQuery-like AJAX config. - * In addition to the standard jQuery ajax options here you can supply functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node IDs need to be loaded, the return value of those functions will be used. - * - * You can also set this to a function, that function will receive the node IDs being loaded as argument and a second param which is a function (callback) which should be called with the result. - * - * Both the AJAX and the function approach rely on the same return value - an object where the keys are the node IDs, and the value is the children of that node as an array. - * - * { - * "id1" : [{ "text" : "Child of ID1", "id" : "c1" }, { "text" : "Another child of ID1", "id" : "c2" }], - * "id2" : [{ "text" : "Child of ID2", "id" : "c3" }] - * } - * - * @name $.jstree.defaults.massload - * @plugin massload - */ - $.jstree.defaults.massload = null; - $.jstree.plugins.massload = function (options, parent) { - this.init = function (el, options) { - this._data.massload = {}; - parent.init.call(this, el, options); - }; - this._load_nodes = function (nodes, callback, is_callback, force_reload) { - var s = this.settings.massload, - nodesString = JSON.stringify(nodes), - toLoad = [], - m = this._model.data, - i, j, dom; - if (!is_callback) { - for(i = 0, j = nodes.length; i < j; i++) { - if(!m[nodes[i]] || ( (!m[nodes[i]].state.loaded && !m[nodes[i]].state.failed) || force_reload) ) { - toLoad.push(nodes[i]); - dom = this.get_node(nodes[i], true); - if (dom && dom.length) { - dom.addClass("jstree-loading").attr('aria-busy',true); - } - } - } - this._data.massload = {}; - if (toLoad.length) { - if($.isFunction(s)) { - return s.call(this, toLoad, $.proxy(function (data) { - var i, j; - if(data) { - for(i in data) { - if(data.hasOwnProperty(i)) { - this._data.massload[i] = data[i]; - } - } - } - for(i = 0, j = nodes.length; i < j; i++) { - dom = this.get_node(nodes[i], true); - if (dom && dom.length) { - dom.removeClass("jstree-loading").attr('aria-busy',false); - } - } - parent._load_nodes.call(this, nodes, callback, is_callback, force_reload); - }, this)); - } - if(typeof s === 'object' && s && s.url) { - s = $.extend(true, {}, s); - if($.isFunction(s.url)) { - s.url = s.url.call(this, toLoad); - } - if($.isFunction(s.data)) { - s.data = s.data.call(this, toLoad); - } - return $.ajax(s) - .done($.proxy(function (data,t,x) { - var i, j; - if(data) { - for(i in data) { - if(data.hasOwnProperty(i)) { - this._data.massload[i] = data[i]; - } - } - } - for(i = 0, j = nodes.length; i < j; i++) { - dom = this.get_node(nodes[i], true); - if (dom && dom.length) { - dom.removeClass("jstree-loading").attr('aria-busy',false); - } - } - parent._load_nodes.call(this, nodes, callback, is_callback, force_reload); - }, this)) - .fail($.proxy(function (f) { - parent._load_nodes.call(this, nodes, callback, is_callback, force_reload); - }, this)); - } - } - } - return parent._load_nodes.call(this, nodes, callback, is_callback, force_reload); - }; - this._load_node = function (obj, callback) { - var data = this._data.massload[obj.id], - rslt = null, dom; - if(data) { - rslt = this[typeof data === 'string' ? '_append_html_data' : '_append_json_data']( - obj, - typeof data === 'string' ? $($.parseHTML(data)).filter(function () { return this.nodeType !== 3; }) : data, - function (status) { callback.call(this, status); } - ); - dom = this.get_node(obj.id, true); - if (dom && dom.length) { - dom.removeClass("jstree-loading").attr('aria-busy',false); - } - delete this._data.massload[obj.id]; - return rslt; - } - return parent._load_node.call(this, obj, callback); - }; - }; - -/** - * ### Search plugin - * - * Adds search functionality to jsTree. - */ - - /** - * stores all defaults for the search plugin - * @name $.jstree.defaults.search - * @plugin search - */ - $.jstree.defaults.search = { - /** - * a jQuery-like AJAX config, which jstree uses if a server should be queried for results. - * - * A `str` (which is the search string) parameter will be added with the request, an optional `inside` parameter will be added if the search is limited to a node id. The expected result is a JSON array with nodes that need to be opened so that matching nodes will be revealed. - * Leave this setting as `false` to not query the server. You can also set this to a function, which will be invoked in the instance's scope and receive 3 parameters - the search string, the callback to call with the array of nodes to load, and the optional node ID to limit the search to - * @name $.jstree.defaults.search.ajax - * @plugin search - */ - ajax : false, - /** - * Indicates if the search should be fuzzy or not (should `chnd3` match `child node 3`). Default is `false`. - * @name $.jstree.defaults.search.fuzzy - * @plugin search - */ - fuzzy : false, - /** - * Indicates if the search should be case sensitive. Default is `false`. - * @name $.jstree.defaults.search.case_sensitive - * @plugin search - */ - case_sensitive : false, - /** - * Indicates if the tree should be filtered (by default) to show only matching nodes (keep in mind this can be a heavy on large trees in old browsers). - * This setting can be changed at runtime when calling the search method. Default is `false`. - * @name $.jstree.defaults.search.show_only_matches - * @plugin search - */ - show_only_matches : false, - /** - * Indicates if the children of matched element are shown (when show_only_matches is true) - * This setting can be changed at runtime when calling the search method. Default is `false`. - * @name $.jstree.defaults.search.show_only_matches_children - * @plugin search - */ - show_only_matches_children : false, - /** - * Indicates if all nodes opened to reveal the search result, should be closed when the search is cleared or a new search is performed. Default is `true`. - * @name $.jstree.defaults.search.close_opened_onclear - * @plugin search - */ - close_opened_onclear : true, - /** - * Indicates if only leaf nodes should be included in search results. Default is `false`. - * @name $.jstree.defaults.search.search_leaves_only - * @plugin search - */ - search_leaves_only : false, - /** - * If set to a function it wil be called in the instance's scope with two arguments - search string and node (where node will be every node in the structure, so use with caution). - * If the function returns a truthy value the node will be considered a match (it might not be displayed if search_only_leaves is set to true and the node is not a leaf). Default is `false`. - * @name $.jstree.defaults.search.search_callback - * @plugin search - */ - search_callback : false - }; - - $.jstree.plugins.search = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - - this._data.search.str = ""; - this._data.search.dom = $(); - this._data.search.res = []; - this._data.search.opn = []; - this._data.search.som = false; - this._data.search.smc = false; - this._data.search.hdn = []; - - this.element - .on("search.jstree", $.proxy(function (e, data) { - if(this._data.search.som && data.res.length) { - var m = this._model.data, i, j, p = [], k, l; - for(i = 0, j = data.res.length; i < j; i++) { - if(m[data.res[i]] && !m[data.res[i]].state.hidden) { - p.push(data.res[i]); - p = p.concat(m[data.res[i]].parents); - if(this._data.search.smc) { - for (k = 0, l = m[data.res[i]].children_d.length; k < l; k++) { - if (m[m[data.res[i]].children_d[k]] && !m[m[data.res[i]].children_d[k]].state.hidden) { - p.push(m[data.res[i]].children_d[k]); - } - } - } - } - } - p = $.vakata.array_remove_item($.vakata.array_unique(p), $.jstree.root); - this._data.search.hdn = this.hide_all(true); - this.show_node(p, true); - this.redraw(true); - } - }, this)) - .on("clear_search.jstree", $.proxy(function (e, data) { - if(this._data.search.som && data.res.length) { - this.show_node(this._data.search.hdn, true); - this.redraw(true); - } - }, this)); - }; - /** - * used to search the tree nodes for a given string - * @name search(str [, skip_async]) - * @param {String} str the search string - * @param {Boolean} skip_async if set to true server will not be queried even if configured - * @param {Boolean} show_only_matches if set to true only matching nodes will be shown (keep in mind this can be very slow on large trees or old browsers) - * @param {mixed} inside an optional node to whose children to limit the search - * @param {Boolean} append if set to true the results of this search are appended to the previous search - * @plugin search - * @trigger search.jstree - */ - this.search = function (str, skip_async, show_only_matches, inside, append, show_only_matches_children) { - if(str === false || $.trim(str.toString()) === "") { - return this.clear_search(); - } - inside = this.get_node(inside); - inside = inside && inside.id ? inside.id : null; - str = str.toString(); - var s = this.settings.search, - a = s.ajax ? s.ajax : false, - m = this._model.data, - f = null, - r = [], - p = [], i, j; - if(this._data.search.res.length && !append) { - this.clear_search(); - } - if(show_only_matches === undefined) { - show_only_matches = s.show_only_matches; - } - if(show_only_matches_children === undefined) { - show_only_matches_children = s.show_only_matches_children; - } - if(!skip_async && a !== false) { - if($.isFunction(a)) { - return a.call(this, str, $.proxy(function (d) { - if(d && d.d) { d = d.d; } - this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () { - this.search(str, true, show_only_matches, inside, append, show_only_matches_children); - }); - }, this), inside); - } - else { - a = $.extend({}, a); - if(!a.data) { a.data = {}; } - a.data.str = str; - if(inside) { - a.data.inside = inside; - } - if (this._data.search.lastRequest) { - this._data.search.lastRequest.abort(); - } - this._data.search.lastRequest = $.ajax(a) - .fail($.proxy(function () { - this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'search', 'id' : 'search_01', 'reason' : 'Could not load search parents', 'data' : JSON.stringify(a) }; - this.settings.core.error.call(this, this._data.core.last_error); - }, this)) - .done($.proxy(function (d) { - if(d && d.d) { d = d.d; } - this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () { - this.search(str, true, show_only_matches, inside, append, show_only_matches_children); - }); - }, this)); - return this._data.search.lastRequest; - } - } - if(!append) { - this._data.search.str = str; - this._data.search.dom = $(); - this._data.search.res = []; - this._data.search.opn = []; - this._data.search.som = show_only_matches; - this._data.search.smc = show_only_matches_children; - } - - f = new $.vakata.search(str, true, { caseSensitive : s.case_sensitive, fuzzy : s.fuzzy }); - $.each(m[inside ? inside : $.jstree.root].children_d, function (ii, i) { - var v = m[i]; - if(v.text && !v.state.hidden && (!s.search_leaves_only || (v.state.loaded && v.children.length === 0)) && ( (s.search_callback && s.search_callback.call(this, str, v)) || (!s.search_callback && f.search(v.text).isMatch) ) ) { - r.push(i); - p = p.concat(v.parents); - } - }); - if(r.length) { - p = $.vakata.array_unique(p); - for(i = 0, j = p.length; i < j; i++) { - if(p[i] !== $.jstree.root && m[p[i]] && this.open_node(p[i], null, 0) === true) { - this._data.search.opn.push(p[i]); - } - } - if(!append) { - this._data.search.dom = $(this.element[0].querySelectorAll('#' + $.map(r, function (v) { return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); }).join(', #'))); - this._data.search.res = r; - } - else { - this._data.search.dom = this._data.search.dom.add($(this.element[0].querySelectorAll('#' + $.map(r, function (v) { return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); }).join(', #')))); - this._data.search.res = $.vakata.array_unique(this._data.search.res.concat(r)); - } - this._data.search.dom.children(".jstree-anchor").addClass('jstree-search'); - } - /** - * triggered after search is complete - * @event - * @name search.jstree - * @param {jQuery} nodes a jQuery collection of matching nodes - * @param {String} str the search string - * @param {Array} res a collection of objects represeing the matching nodes - * @plugin search - */ - this.trigger('search', { nodes : this._data.search.dom, str : str, res : this._data.search.res, show_only_matches : show_only_matches }); - }; - /** - * used to clear the last search (removes classes and shows all nodes if filtering is on) - * @name clear_search() - * @plugin search - * @trigger clear_search.jstree - */ - this.clear_search = function () { - if(this.settings.search.close_opened_onclear) { - this.close_node(this._data.search.opn, 0); - } - /** - * triggered after search is complete - * @event - * @name clear_search.jstree - * @param {jQuery} nodes a jQuery collection of matching nodes (the result from the last search) - * @param {String} str the search string (the last search string) - * @param {Array} res a collection of objects represeing the matching nodes (the result from the last search) - * @plugin search - */ - this.trigger('clear_search', { 'nodes' : this._data.search.dom, str : this._data.search.str, res : this._data.search.res }); - if(this._data.search.res.length) { - this._data.search.dom = $(this.element[0].querySelectorAll('#' + $.map(this._data.search.res, function (v) { - return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); - }).join(', #'))); - this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search"); - } - this._data.search.str = ""; - this._data.search.res = []; - this._data.search.opn = []; - this._data.search.dom = $(); - }; - - this.redraw_node = function(obj, deep, callback, force_render) { - obj = parent.redraw_node.apply(this, arguments); - if(obj) { - if($.inArray(obj.id, this._data.search.res) !== -1) { - var i, j, tmp = null; - for(i = 0, j = obj.childNodes.length; i < j; i++) { - if(obj.childNodes[i] && obj.childNodes[i].className && obj.childNodes[i].className.indexOf("jstree-anchor") !== -1) { - tmp = obj.childNodes[i]; - break; - } - } - if(tmp) { - tmp.className += ' jstree-search'; - } - } - } - return obj; - }; - }; - - // helpers - (function ($) { - // from http://kiro.me/projects/fuse.html - $.vakata.search = function(pattern, txt, options) { - options = options || {}; - options = $.extend({}, $.vakata.search.defaults, options); - if(options.fuzzy !== false) { - options.fuzzy = true; - } - pattern = options.caseSensitive ? pattern : pattern.toLowerCase(); - var MATCH_LOCATION = options.location, - MATCH_DISTANCE = options.distance, - MATCH_THRESHOLD = options.threshold, - patternLen = pattern.length, - matchmask, pattern_alphabet, match_bitapScore, search; - if(patternLen > 32) { - options.fuzzy = false; - } - if(options.fuzzy) { - matchmask = 1 << (patternLen - 1); - pattern_alphabet = (function () { - var mask = {}, - i = 0; - for (i = 0; i < patternLen; i++) { - mask[pattern.charAt(i)] = 0; - } - for (i = 0; i < patternLen; i++) { - mask[pattern.charAt(i)] |= 1 << (patternLen - i - 1); - } - return mask; - }()); - match_bitapScore = function (e, x) { - var accuracy = e / patternLen, - proximity = Math.abs(MATCH_LOCATION - x); - if(!MATCH_DISTANCE) { - return proximity ? 1.0 : accuracy; - } - return accuracy + (proximity / MATCH_DISTANCE); - }; - } - search = function (text) { - text = options.caseSensitive ? text : text.toLowerCase(); - if(pattern === text || text.indexOf(pattern) !== -1) { - return { - isMatch: true, - score: 0 - }; - } - if(!options.fuzzy) { - return { - isMatch: false, - score: 1 - }; - } - var i, j, - textLen = text.length, - scoreThreshold = MATCH_THRESHOLD, - bestLoc = text.indexOf(pattern, MATCH_LOCATION), - binMin, binMid, - binMax = patternLen + textLen, - lastRd, start, finish, rd, charMatch, - score = 1, - locations = []; - if (bestLoc !== -1) { - scoreThreshold = Math.min(match_bitapScore(0, bestLoc), scoreThreshold); - bestLoc = text.lastIndexOf(pattern, MATCH_LOCATION + patternLen); - if (bestLoc !== -1) { - scoreThreshold = Math.min(match_bitapScore(0, bestLoc), scoreThreshold); - } - } - bestLoc = -1; - for (i = 0; i < patternLen; i++) { - binMin = 0; - binMid = binMax; - while (binMin < binMid) { - if (match_bitapScore(i, MATCH_LOCATION + binMid) <= scoreThreshold) { - binMin = binMid; - } else { - binMax = binMid; - } - binMid = Math.floor((binMax - binMin) / 2 + binMin); - } - binMax = binMid; - start = Math.max(1, MATCH_LOCATION - binMid + 1); - finish = Math.min(MATCH_LOCATION + binMid, textLen) + patternLen; - rd = new Array(finish + 2); - rd[finish + 1] = (1 << i) - 1; - for (j = finish; j >= start; j--) { - charMatch = pattern_alphabet[text.charAt(j - 1)]; - if (i === 0) { - rd[j] = ((rd[j + 1] << 1) | 1) & charMatch; - } else { - rd[j] = ((rd[j + 1] << 1) | 1) & charMatch | (((lastRd[j + 1] | lastRd[j]) << 1) | 1) | lastRd[j + 1]; - } - if (rd[j] & matchmask) { - score = match_bitapScore(i, j - 1); - if (score <= scoreThreshold) { - scoreThreshold = score; - bestLoc = j - 1; - locations.push(bestLoc); - if (bestLoc > MATCH_LOCATION) { - start = Math.max(1, 2 * MATCH_LOCATION - bestLoc); - } else { - break; - } - } - } - } - if (match_bitapScore(i + 1, MATCH_LOCATION) > scoreThreshold) { - break; - } - lastRd = rd; - } - return { - isMatch: bestLoc >= 0, - score: score - }; - }; - return txt === true ? { 'search' : search } : search(txt); - }; - $.vakata.search.defaults = { - location : 0, - distance : 100, - threshold : 0.6, - fuzzy : false, - caseSensitive : false - }; - }($)); - - // include the search plugin by default - // $.jstree.defaults.plugins.push("search"); - - -/** - * ### Sort plugin - * - * Automatically sorts all siblings in the tree according to a sorting function. - */ - - /** - * the settings function used to sort the nodes. - * It is executed in the tree's context, accepts two nodes as arguments and should return `1` or `-1`. - * @name $.jstree.defaults.sort - * @plugin sort - */ - $.jstree.defaults.sort = function (a, b) { - //return this.get_type(a) === this.get_type(b) ? (this.get_text(a) > this.get_text(b) ? 1 : -1) : this.get_type(a) >= this.get_type(b); - return this.get_text(a) > this.get_text(b) ? 1 : -1; - }; - $.jstree.plugins.sort = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - this.element - .on("model.jstree", $.proxy(function (e, data) { - this.sort(data.parent, true); - }, this)) - .on("rename_node.jstree create_node.jstree", $.proxy(function (e, data) { - this.sort(data.parent || data.node.parent, false); - this.redraw_node(data.parent || data.node.parent, true); - }, this)) - .on("move_node.jstree copy_node.jstree", $.proxy(function (e, data) { - this.sort(data.parent, false); - this.redraw_node(data.parent, true); - }, this)); - }; - /** - * used to sort a node's children - * @private - * @name sort(obj [, deep]) - * @param {mixed} obj the node - * @param {Boolean} deep if set to `true` nodes are sorted recursively. - * @plugin sort - * @trigger search.jstree - */ - this.sort = function (obj, deep) { - var i, j; - obj = this.get_node(obj); - if(obj && obj.children && obj.children.length) { - obj.children.sort($.proxy(this.settings.sort, this)); - if(deep) { - for(i = 0, j = obj.children_d.length; i < j; i++) { - this.sort(obj.children_d[i], false); - } - } - } - }; - }; - - // include the sort plugin by default - // $.jstree.defaults.plugins.push("sort"); - -/** - * ### State plugin - * - * Saves the state of the tree (selected nodes, opened nodes) on the user's computer using available options (localStorage, cookies, etc) - */ - - var to = false; - /** - * stores all defaults for the state plugin - * @name $.jstree.defaults.state - * @plugin state - */ - $.jstree.defaults.state = { - /** - * A string for the key to use when saving the current tree (change if using multiple trees in your project). Defaults to `jstree`. - * @name $.jstree.defaults.state.key - * @plugin state - */ - key : 'jstree', - /** - * A space separated list of events that trigger a state save. Defaults to `changed.jstree open_node.jstree close_node.jstree`. - * @name $.jstree.defaults.state.events - * @plugin state - */ - events : 'changed.jstree open_node.jstree close_node.jstree check_node.jstree uncheck_node.jstree', - /** - * Time in milliseconds after which the state will expire. Defaults to 'false' meaning - no expire. - * @name $.jstree.defaults.state.ttl - * @plugin state - */ - ttl : false, - /** - * A function that will be executed prior to restoring state with one argument - the state object. Can be used to clear unwanted parts of the state. - * @name $.jstree.defaults.state.filter - * @plugin state - */ - filter : false, - /** - * Should loaded nodes be restored (setting this to true means that it is possible that the whole tree will be loaded for some users - use with caution). Defaults to `false` - * @name $.jstree.defaults.state.preserve_loaded - * @plugin state - */ - preserve_loaded : false - }; - $.jstree.plugins.state = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - var bind = $.proxy(function () { - this.element.on(this.settings.state.events, $.proxy(function () { - if(to) { clearTimeout(to); } - to = setTimeout($.proxy(function () { this.save_state(); }, this), 100); - }, this)); - /** - * triggered when the state plugin is finished restoring the state (and immediately after ready if there is no state to restore). - * @event - * @name state_ready.jstree - * @plugin state - */ - this.trigger('state_ready'); - }, this); - this.element - .on("ready.jstree", $.proxy(function (e, data) { - this.element.one("restore_state.jstree", bind); - if(!this.restore_state()) { bind(); } - }, this)); - }; - /** - * save the state - * @name save_state() - * @plugin state - */ - this.save_state = function () { - var tm = this.get_state(); - if (!this.settings.state.preserve_loaded) { - delete tm.core.loaded; - } - var st = { 'state' : tm, 'ttl' : this.settings.state.ttl, 'sec' : +(new Date()) }; - $.vakata.storage.set(this.settings.state.key, JSON.stringify(st)); - }; - /** - * restore the state from the user's computer - * @name restore_state() - * @plugin state - */ - this.restore_state = function () { - var k = $.vakata.storage.get(this.settings.state.key); - if(!!k) { try { k = JSON.parse(k); } catch(ex) { return false; } } - if(!!k && k.ttl && k.sec && +(new Date()) - k.sec > k.ttl) { return false; } - if(!!k && k.state) { k = k.state; } - if(!!k && $.isFunction(this.settings.state.filter)) { k = this.settings.state.filter.call(this, k); } - if(!!k) { - if (!this.settings.state.preserve_loaded) { - delete k.core.loaded; - } - this.element.one("set_state.jstree", function (e, data) { data.instance.trigger('restore_state', { 'state' : $.extend(true, {}, k) }); }); - this.set_state(k); - return true; - } - return false; - }; - /** - * clear the state on the user's computer - * @name clear_state() - * @plugin state - */ - this.clear_state = function () { - return $.vakata.storage.del(this.settings.state.key); - }; - }; - - (function ($, undefined) { - $.vakata.storage = { - // simply specifying the functions in FF throws an error - set : function (key, val) { return window.localStorage.setItem(key, val); }, - get : function (key) { return window.localStorage.getItem(key); }, - del : function (key) { return window.localStorage.removeItem(key); } - }; - }($)); - - // include the state plugin by default - // $.jstree.defaults.plugins.push("state"); - -/** - * ### Types plugin - * - * Makes it possible to add predefined types for groups of nodes, which make it possible to easily control nesting rules and icon for each group. - */ - - /** - * An object storing all types as key value pairs, where the key is the type name and the value is an object that could contain following keys (all optional). - * - * * `max_children` the maximum number of immediate children this node type can have. Do not specify or set to `-1` for unlimited. - * * `max_depth` the maximum number of nesting this node type can have. A value of `1` would mean that the node can have children, but no grandchildren. Do not specify or set to `-1` for unlimited. - * * `valid_children` an array of node type strings, that nodes of this type can have as children. Do not specify or set to `-1` for no limits. - * * `icon` a string - can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class. Omit to use the default icon from your theme. - * * `li_attr` an object of values which will be used to add HTML attributes on the resulting LI DOM node (merged with the node's own data) - * * `a_attr` an object of values which will be used to add HTML attributes on the resulting A DOM node (merged with the node's own data) - * - * There are two predefined types: - * - * * `#` represents the root of the tree, for example `max_children` would control the maximum number of root nodes. - * * `default` represents the default node - any settings here will be applied to all nodes that do not have a type specified. - * - * @name $.jstree.defaults.types - * @plugin types - */ - $.jstree.defaults.types = { - 'default' : {} - }; - $.jstree.defaults.types[$.jstree.root] = {}; - - $.jstree.plugins.types = function (options, parent) { - this.init = function (el, options) { - var i, j; - if(options && options.types && options.types['default']) { - for(i in options.types) { - if(i !== "default" && i !== $.jstree.root && options.types.hasOwnProperty(i)) { - for(j in options.types['default']) { - if(options.types['default'].hasOwnProperty(j) && options.types[i][j] === undefined) { - options.types[i][j] = options.types['default'][j]; - } - } - } - } - } - parent.init.call(this, el, options); - this._model.data[$.jstree.root].type = $.jstree.root; - }; - this.refresh = function (skip_loading, forget_state) { - parent.refresh.call(this, skip_loading, forget_state); - this._model.data[$.jstree.root].type = $.jstree.root; - }; - this.bind = function () { - this.element - .on('model.jstree', $.proxy(function (e, data) { - var m = this._model.data, - dpc = data.nodes, - t = this.settings.types, - i, j, c = 'default', k; - for(i = 0, j = dpc.length; i < j; i++) { - c = 'default'; - if(m[dpc[i]].original && m[dpc[i]].original.type && t[m[dpc[i]].original.type]) { - c = m[dpc[i]].original.type; - } - if(m[dpc[i]].data && m[dpc[i]].data.jstree && m[dpc[i]].data.jstree.type && t[m[dpc[i]].data.jstree.type]) { - c = m[dpc[i]].data.jstree.type; - } - m[dpc[i]].type = c; - if(m[dpc[i]].icon === true && t[c].icon !== undefined) { - m[dpc[i]].icon = t[c].icon; - } - if(t[c].li_attr !== undefined && typeof t[c].li_attr === 'object') { - for (k in t[c].li_attr) { - if (t[c].li_attr.hasOwnProperty(k)) { - if (k === 'id') { - continue; - } - else if (m[dpc[i]].li_attr[k] === undefined) { - m[dpc[i]].li_attr[k] = t[c].li_attr[k]; - } - else if (k === 'class') { - m[dpc[i]].li_attr['class'] = t[c].li_attr['class'] + ' ' + m[dpc[i]].li_attr['class']; - } - } - } - } - if(t[c].a_attr !== undefined && typeof t[c].a_attr === 'object') { - for (k in t[c].a_attr) { - if (t[c].a_attr.hasOwnProperty(k)) { - if (k === 'id') { - continue; - } - else if (m[dpc[i]].a_attr[k] === undefined) { - m[dpc[i]].a_attr[k] = t[c].a_attr[k]; - } - else if (k === 'href' && m[dpc[i]].a_attr[k] === '#') { - m[dpc[i]].a_attr['href'] = t[c].a_attr['href']; - } - else if (k === 'class') { - m[dpc[i]].a_attr['class'] = t[c].a_attr['class'] + ' ' + m[dpc[i]].a_attr['class']; - } - } - } - } - } - m[$.jstree.root].type = $.jstree.root; - }, this)); - parent.bind.call(this); - }; - this.get_json = function (obj, options, flat) { - var i, j, - m = this._model.data, - opt = options ? $.extend(true, {}, options, {no_id:false}) : {}, - tmp = parent.get_json.call(this, obj, opt, flat); - if(tmp === false) { return false; } - if($.isArray(tmp)) { - for(i = 0, j = tmp.length; i < j; i++) { - tmp[i].type = tmp[i].id && m[tmp[i].id] && m[tmp[i].id].type ? m[tmp[i].id].type : "default"; - if(options && options.no_id) { - delete tmp[i].id; - if(tmp[i].li_attr && tmp[i].li_attr.id) { - delete tmp[i].li_attr.id; - } - if(tmp[i].a_attr && tmp[i].a_attr.id) { - delete tmp[i].a_attr.id; - } - } - } - } - else { - tmp.type = tmp.id && m[tmp.id] && m[tmp.id].type ? m[tmp.id].type : "default"; - if(options && options.no_id) { - tmp = this._delete_ids(tmp); - } - } - return tmp; - }; - this._delete_ids = function (tmp) { - if($.isArray(tmp)) { - for(var i = 0, j = tmp.length; i < j; i++) { - tmp[i] = this._delete_ids(tmp[i]); - } - return tmp; - } - delete tmp.id; - if(tmp.li_attr && tmp.li_attr.id) { - delete tmp.li_attr.id; - } - if(tmp.a_attr && tmp.a_attr.id) { - delete tmp.a_attr.id; - } - if(tmp.children && $.isArray(tmp.children)) { - tmp.children = this._delete_ids(tmp.children); - } - return tmp; - }; - this.check = function (chk, obj, par, pos, more) { - if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; } - obj = obj && obj.id ? obj : this.get_node(obj); - par = par && par.id ? par : this.get_node(par); - var m = obj && obj.id ? (more && more.origin ? more.origin : $.jstree.reference(obj.id)) : null, tmp, d, i, j; - m = m && m._model && m._model.data ? m._model.data : null; - switch(chk) { - case "create_node": - case "move_node": - case "copy_node": - if(chk !== 'move_node' || $.inArray(obj.id, par.children) === -1) { - tmp = this.get_rules(par); - if(tmp.max_children !== undefined && tmp.max_children !== -1 && tmp.max_children === par.children.length) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_01', 'reason' : 'max_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - return false; - } - if(tmp.valid_children !== undefined && tmp.valid_children !== -1 && $.inArray((obj.type || 'default'), tmp.valid_children) === -1) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_02', 'reason' : 'valid_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - return false; - } - if(m && obj.children_d && obj.parents) { - d = 0; - for(i = 0, j = obj.children_d.length; i < j; i++) { - d = Math.max(d, m[obj.children_d[i]].parents.length); - } - d = d - obj.parents.length + 1; - } - if(d <= 0 || d === undefined) { d = 1; } - do { - if(tmp.max_depth !== undefined && tmp.max_depth !== -1 && tmp.max_depth < d) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_03', 'reason' : 'max_depth prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - return false; - } - par = this.get_node(par.parent); - tmp = this.get_rules(par); - d++; - } while(par); - } - break; - } - return true; - }; - /** - * used to retrieve the type settings object for a node - * @name get_rules(obj) - * @param {mixed} obj the node to find the rules for - * @return {Object} - * @plugin types - */ - this.get_rules = function (obj) { - obj = this.get_node(obj); - if(!obj) { return false; } - var tmp = this.get_type(obj, true); - if(tmp.max_depth === undefined) { tmp.max_depth = -1; } - if(tmp.max_children === undefined) { tmp.max_children = -1; } - if(tmp.valid_children === undefined) { tmp.valid_children = -1; } - return tmp; - }; - /** - * used to retrieve the type string or settings object for a node - * @name get_type(obj [, rules]) - * @param {mixed} obj the node to find the rules for - * @param {Boolean} rules if set to `true` instead of a string the settings object will be returned - * @return {String|Object} - * @plugin types - */ - this.get_type = function (obj, rules) { - obj = this.get_node(obj); - return (!obj) ? false : ( rules ? $.extend({ 'type' : obj.type }, this.settings.types[obj.type]) : obj.type); - }; - /** - * used to change a node's type - * @name set_type(obj, type) - * @param {mixed} obj the node to change - * @param {String} type the new type - * @plugin types - */ - this.set_type = function (obj, type) { - var m = this._model.data, t, t1, t2, old_type, old_icon, k, d, a; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.set_type(obj[t1], type); - } - return true; - } - t = this.settings.types; - obj = this.get_node(obj); - if(!t[type] || !obj) { return false; } - d = this.get_node(obj, true); - if (d && d.length) { - a = d.children('.jstree-anchor'); - } - old_type = obj.type; - old_icon = this.get_icon(obj); - obj.type = type; - if(old_icon === true || !t[old_type] || (t[old_type].icon !== undefined && old_icon === t[old_type].icon)) { - this.set_icon(obj, t[type].icon !== undefined ? t[type].icon : true); - } - - // remove old type props - if(t[old_type] && t[old_type].li_attr !== undefined && typeof t[old_type].li_attr === 'object') { - for (k in t[old_type].li_attr) { - if (t[old_type].li_attr.hasOwnProperty(k)) { - if (k === 'id') { - continue; - } - else if (k === 'class') { - m[obj.id].li_attr['class'] = (m[obj.id].li_attr['class'] || '').replace(t[old_type].li_attr[k], ''); - if (d) { d.removeClass(t[old_type].li_attr[k]); } - } - else if (m[obj.id].li_attr[k] === t[old_type].li_attr[k]) { - m[obj.id].li_attr[k] = null; - if (d) { d.removeAttr(k); } - } - } - } - } - if(t[old_type] && t[old_type].a_attr !== undefined && typeof t[old_type].a_attr === 'object') { - for (k in t[old_type].a_attr) { - if (t[old_type].a_attr.hasOwnProperty(k)) { - if (k === 'id') { - continue; - } - else if (k === 'class') { - m[obj.id].a_attr['class'] = (m[obj.id].a_attr['class'] || '').replace(t[old_type].a_attr[k], ''); - if (a) { a.removeClass(t[old_type].a_attr[k]); } - } - else if (m[obj.id].a_attr[k] === t[old_type].a_attr[k]) { - if (k === 'href') { - m[obj.id].a_attr[k] = '#'; - if (a) { a.attr('href', '#'); } - } - else { - delete m[obj.id].a_attr[k]; - if (a) { a.removeAttr(k); } - } - } - } - } - } - - // add new props - if(t[type].li_attr !== undefined && typeof t[type].li_attr === 'object') { - for (k in t[type].li_attr) { - if (t[type].li_attr.hasOwnProperty(k)) { - if (k === 'id') { - continue; - } - else if (m[obj.id].li_attr[k] === undefined) { - m[obj.id].li_attr[k] = t[type].li_attr[k]; - if (d) { - if (k === 'class') { - d.addClass(t[type].li_attr[k]); - } - else { - d.attr(k, t[type].li_attr[k]); - } - } - } - else if (k === 'class') { - m[obj.id].li_attr['class'] = t[type].li_attr[k] + ' ' + m[obj.id].li_attr['class']; - if (d) { d.addClass(t[type].li_attr[k]); } - } - } - } - } - if(t[type].a_attr !== undefined && typeof t[type].a_attr === 'object') { - for (k in t[type].a_attr) { - if (t[type].a_attr.hasOwnProperty(k)) { - if (k === 'id') { - continue; - } - else if (m[obj.id].a_attr[k] === undefined) { - m[obj.id].a_attr[k] = t[type].a_attr[k]; - if (a) { - if (k === 'class') { - a.addClass(t[type].a_attr[k]); - } - else { - a.attr(k, t[type].a_attr[k]); - } - } - } - else if (k === 'href' && m[obj.id].a_attr[k] === '#') { - m[obj.id].a_attr['href'] = t[type].a_attr['href']; - if (a) { a.attr('href', t[type].a_attr['href']); } - } - else if (k === 'class') { - m[obj.id].a_attr['class'] = t[type].a_attr['class'] + ' ' + m[obj.id].a_attr['class']; - if (a) { a.addClass(t[type].a_attr[k]); } - } - } - } - } - - return true; - }; - }; - // include the types plugin by default - // $.jstree.defaults.plugins.push("types"); - - -/** - * ### Unique plugin - * - * Enforces that no nodes with the same name can coexist as siblings. - */ - - /** - * stores all defaults for the unique plugin - * @name $.jstree.defaults.unique - * @plugin unique - */ - $.jstree.defaults.unique = { - /** - * Indicates if the comparison should be case sensitive. Default is `false`. - * @name $.jstree.defaults.unique.case_sensitive - * @plugin unique - */ - case_sensitive : false, - /** - * Indicates if white space should be trimmed before the comparison. Default is `false`. - * @name $.jstree.defaults.unique.trim_whitespace - * @plugin unique - */ - trim_whitespace : false, - /** - * A callback executed in the instance's scope when a new node is created and the name is already taken, the two arguments are the conflicting name and the counter. The default will produce results like `New node (2)`. - * @name $.jstree.defaults.unique.duplicate - * @plugin unique - */ - duplicate : function (name, counter) { - return name + ' (' + counter + ')'; - } - }; - - $.jstree.plugins.unique = function (options, parent) { - this.check = function (chk, obj, par, pos, more) { - if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; } - obj = obj && obj.id ? obj : this.get_node(obj); - par = par && par.id ? par : this.get_node(par); - if(!par || !par.children) { return true; } - var n = chk === "rename_node" ? pos : obj.text, - c = [], - s = this.settings.unique.case_sensitive, - w = this.settings.unique.trim_whitespace, - m = this._model.data, i, j, t; - for(i = 0, j = par.children.length; i < j; i++) { - t = m[par.children[i]].text; - if (!s) { - t = t.toLowerCase(); - } - if (w) { - t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); - } - c.push(t); - } - if(!s) { n = n.toLowerCase(); } - if (w) { n = n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); } - switch(chk) { - case "delete_node": - return true; - case "rename_node": - t = obj.text || ''; - if (!s) { - t = t.toLowerCase(); - } - if (w) { - t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); - } - i = ($.inArray(n, c) === -1 || (obj.text && t === n)); - if(!i) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_01', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - } - return i; - case "create_node": - i = ($.inArray(n, c) === -1); - if(!i) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_04', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - } - return i; - case "copy_node": - i = ($.inArray(n, c) === -1); - if(!i) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_02', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - } - return i; - case "move_node": - i = ( (obj.parent === par.id && (!more || !more.is_multi)) || $.inArray(n, c) === -1); - if(!i) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_03', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - } - return i; - } - return true; - }; - this.create_node = function (par, node, pos, callback, is_loaded) { - if(!node || node.text === undefined) { - if(par === null) { - par = $.jstree.root; - } - par = this.get_node(par); - if(!par) { - return parent.create_node.call(this, par, node, pos, callback, is_loaded); - } - pos = pos === undefined ? "last" : pos; - if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { - return parent.create_node.call(this, par, node, pos, callback, is_loaded); - } - if(!node) { node = {}; } - var tmp, n, dpc, i, j, m = this._model.data, s = this.settings.unique.case_sensitive, w = this.settings.unique.trim_whitespace, cb = this.settings.unique.duplicate, t; - n = tmp = this.get_string('New node'); - dpc = []; - for(i = 0, j = par.children.length; i < j; i++) { - t = m[par.children[i]].text; - if (!s) { - t = t.toLowerCase(); - } - if (w) { - t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); - } - dpc.push(t); - } - i = 1; - t = n; - if (!s) { - t = t.toLowerCase(); - } - if (w) { - t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); - } - while($.inArray(t, dpc) !== -1) { - n = cb.call(this, tmp, (++i)).toString(); - t = n; - if (!s) { - t = t.toLowerCase(); - } - if (w) { - t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); - } - } - node.text = n; - } - return parent.create_node.call(this, par, node, pos, callback, is_loaded); - }; - }; - - // include the unique plugin by default - // $.jstree.defaults.plugins.push("unique"); - - -/** - * ### Wholerow plugin - * - * Makes each node appear block level. Making selection easier. May cause slow down for large trees in old browsers. - */ - - var div = document.createElement('DIV'); - div.setAttribute('unselectable','on'); - div.setAttribute('role','presentation'); - div.className = 'jstree-wholerow'; - div.innerHTML = ' '; - $.jstree.plugins.wholerow = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - - this.element - .on('ready.jstree set_state.jstree', $.proxy(function () { - this.hide_dots(); - }, this)) - .on("init.jstree loading.jstree ready.jstree", $.proxy(function () { - //div.style.height = this._data.core.li_height + 'px'; - this.get_container_ul().addClass('jstree-wholerow-ul'); - }, this)) - .on("deselect_all.jstree", $.proxy(function (e, data) { - this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked'); - }, this)) - .on("changed.jstree", $.proxy(function (e, data) { - this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked'); - var tmp = false, i, j; - for(i = 0, j = data.selected.length; i < j; i++) { - tmp = this.get_node(data.selected[i], true); - if(tmp && tmp.length) { - tmp.children('.jstree-wholerow').addClass('jstree-wholerow-clicked'); - } - } - }, this)) - .on("open_node.jstree", $.proxy(function (e, data) { - this.get_node(data.node, true).find('.jstree-clicked').parent().children('.jstree-wholerow').addClass('jstree-wholerow-clicked'); - }, this)) - .on("hover_node.jstree dehover_node.jstree", $.proxy(function (e, data) { - if(e.type === "hover_node" && this.is_disabled(data.node)) { return; } - this.get_node(data.node, true).children('.jstree-wholerow')[e.type === "hover_node"?"addClass":"removeClass"]('jstree-wholerow-hovered'); - }, this)) - .on("contextmenu.jstree", ".jstree-wholerow", $.proxy(function (e) { - if (this._data.contextmenu) { - e.preventDefault(); - var tmp = $.Event('contextmenu', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey, pageX : e.pageX, pageY : e.pageY }); - $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp); - } - }, this)) - /*! - .on("mousedown.jstree touchstart.jstree", ".jstree-wholerow", function (e) { - if(e.target === e.currentTarget) { - var a = $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor"); - e.target = a[0]; - a.trigger(e); - } - }) - */ - .on("click.jstree", ".jstree-wholerow", function (e) { - e.stopImmediatePropagation(); - var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey }); - $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus(); - }) - .on("dblclick.jstree", ".jstree-wholerow", function (e) { - e.stopImmediatePropagation(); - var tmp = $.Event('dblclick', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey }); - $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus(); - }) - .on("click.jstree", ".jstree-leaf > .jstree-ocl", $.proxy(function (e) { - e.stopImmediatePropagation(); - var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey }); - $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus(); - }, this)) - .on("mouseover.jstree", ".jstree-wholerow, .jstree-icon", $.proxy(function (e) { - e.stopImmediatePropagation(); - if(!this.is_disabled(e.currentTarget)) { - this.hover_node(e.currentTarget); - } - return false; - }, this)) - .on("mouseleave.jstree", ".jstree-node", $.proxy(function (e) { - this.dehover_node(e.currentTarget); - }, this)); - }; - this.teardown = function () { - if(this.settings.wholerow) { - this.element.find(".jstree-wholerow").remove(); - } - parent.teardown.call(this); - }; - this.redraw_node = function(obj, deep, callback, force_render) { - obj = parent.redraw_node.apply(this, arguments); - if(obj) { - var tmp = div.cloneNode(true); - //tmp.style.height = this._data.core.li_height + 'px'; - if($.inArray(obj.id, this._data.core.selected) !== -1) { tmp.className += ' jstree-wholerow-clicked'; } - if(this._data.core.focused && this._data.core.focused === obj.id) { tmp.className += ' jstree-wholerow-hovered'; } - obj.insertBefore(tmp, obj.childNodes[0]); - } - return obj; - }; - }; - // include the wholerow plugin by default - // $.jstree.defaults.plugins.push("wholerow"); - if(document.registerElement && Object && Object.create) { - var proto = Object.create(HTMLElement.prototype); - proto.createdCallback = function () { - var c = { core : {}, plugins : [] }, i; - for(i in $.jstree.plugins) { - if($.jstree.plugins.hasOwnProperty(i) && this.attributes[i]) { - c.plugins.push(i); - if(this.getAttribute(i) && JSON.parse(this.getAttribute(i))) { - c[i] = JSON.parse(this.getAttribute(i)); - } - } - } - for(i in $.jstree.defaults.core) { - if($.jstree.defaults.core.hasOwnProperty(i) && this.attributes[i]) { - c.core[i] = JSON.parse(this.getAttribute(i)) || this.getAttribute(i); - } - } - $(this).jstree(c); - }; - // proto.attributeChangedCallback = function (name, previous, value) { }; - try { - document.registerElement("vakata-jstree", { prototype: proto }); - } catch(ignore) { } - } - -})); \ No newline at end of file diff --git a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/jstree.min.js b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/jstree.min.js new file mode 100644 index 000000000000..9221c3384cce --- /dev/null +++ b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/jstree.min.js @@ -0,0 +1,6 @@ +/*! jsTree - v3.3.7 - 2018-11-06 - (MIT) */ +!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a,b){"use strict";if(!a.jstree){var c=0,d=!1,e=!1,f=!1,g=[],h=a("script:last").attr("src"),i=window.document;a.jstree={version:"3.3.7",defaults:{plugins:[]},plugins:{},path:h&&-1!==h.indexOf("/")?h.replace(/\/[^\/]+$/,""):"",idregex:/[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g,root:"#"},a.jstree.create=function(b,d){var e=new a.jstree.core(++c),f=d;return d=a.extend(!0,{},a.jstree.defaults,d),f&&f.plugins&&(d.plugins=f.plugins),a.each(d.plugins,function(a,b){"core"!==a&&(e=e.plugin(b,d[b]))}),a(b).data("jstree",e),e.init(b,d),e},a.jstree.destroy=function(){a(".jstree:jstree").jstree("destroy"),a(i).off(".jstree")},a.jstree.core=function(a){this._id=a,this._cnt=0,this._wrk=null,this._data={core:{themes:{name:!1,dots:!1,icons:!1,ellipsis:!1},selected:[],last_error:{},working:!1,worker_queue:[],focused:null}}},a.jstree.reference=function(b){var c=null,d=null;if(!b||!b.id||b.tagName&&b.nodeType||(b=b.id),!d||!d.length)try{d=a(b)}catch(e){}if(!d||!d.length)try{d=a("#"+b.replace(a.jstree.idregex,"\\$&"))}catch(e){}return d&&d.length&&(d=d.closest(".jstree")).length&&(d=d.data("jstree"))?c=d:a(".jstree").each(function(){var d=a(this).data("jstree");return d&&d._model.data[b]?(c=d,!1):void 0}),c},a.fn.jstree=function(c){var d="string"==typeof c,e=Array.prototype.slice.call(arguments,1),f=null;return c!==!0||this.length?(this.each(function(){var g=a.jstree.reference(this),h=d&&g?g[c]:null;return f=d&&h?h.apply(g,e):null,g||d||c!==b&&!a.isPlainObject(c)||a.jstree.create(this,c),(g&&!d||c===!0)&&(f=g||!1),null!==f&&f!==b?!1:void 0}),null!==f&&f!==b?f:this):!1},a.expr.pseudos.jstree=a.expr.createPseudo(function(c){return function(c){return a(c).hasClass("jstree")&&a(c).data("jstree")!==b}}),a.jstree.defaults.core={data:!1,strings:!1,check_callback:!1,error:a.noop,animation:200,multiple:!0,themes:{name:!1,url:!1,dir:!1,dots:!0,icons:!0,ellipsis:!1,stripes:!1,variant:!1,responsive:!1},expand_selected_onload:!0,worker:!0,force_text:!1,dblclick_toggle:!0,loaded_state:!1,restore_focus:!0,keyboard:{"ctrl-space":function(b){b.type="click",a(b.currentTarget).trigger(b)},enter:function(b){b.type="click",a(b.currentTarget).trigger(b)},left:function(b){if(b.preventDefault(),this.is_open(b.currentTarget))this.close_node(b.currentTarget);else{var c=this.get_parent(b.currentTarget);c&&c.id!==a.jstree.root&&this.get_node(c,!0).children(".jstree-anchor").focus()}},up:function(a){a.preventDefault();var b=this.get_prev_dom(a.currentTarget);b&&b.length&&b.children(".jstree-anchor").focus()},right:function(b){if(b.preventDefault(),this.is_closed(b.currentTarget))this.open_node(b.currentTarget,function(a){this.get_node(a,!0).children(".jstree-anchor").focus()});else if(this.is_open(b.currentTarget)){var c=this.get_node(b.currentTarget,!0).children(".jstree-children")[0];c&&a(this._firstChild(c)).children(".jstree-anchor").focus()}},down:function(a){a.preventDefault();var b=this.get_next_dom(a.currentTarget);b&&b.length&&b.children(".jstree-anchor").focus()},"*":function(a){this.open_all()},home:function(b){b.preventDefault();var c=this._firstChild(this.get_container_ul()[0]);c&&a(c).children(".jstree-anchor").filter(":visible").focus()},end:function(a){a.preventDefault(),this.element.find(".jstree-anchor").filter(":visible").last().focus()},f2:function(a){a.preventDefault(),this.edit(a.currentTarget)}}},a.jstree.core.prototype={plugin:function(b,c){var d=a.jstree.plugins[b];return d?(this._data[b]={},d.prototype=this,new d(c,this)):this},init:function(b,c){this._model={data:{},changed:[],force_full_redraw:!1,redraw_timeout:!1,default_state:{loaded:!0,opened:!1,selected:!1,disabled:!1}},this._model.data[a.jstree.root]={id:a.jstree.root,parent:null,parents:[],children:[],children_d:[],state:{loaded:!1}},this.element=a(b).addClass("jstree jstree-"+this._id),this.settings=c,this._data.core.ready=!1,this._data.core.loaded=!1,this._data.core.rtl="rtl"===this.element.css("direction"),this.element[this._data.core.rtl?"addClass":"removeClass"]("jstree-rtl"),this.element.attr("role","tree"),this.settings.core.multiple&&this.element.attr("aria-multiselectable",!0),this.element.attr("tabindex")||this.element.attr("tabindex","0"),this.bind(),this.trigger("init"),this._data.core.original_container_html=this.element.find(" > ul > li").clone(!0),this._data.core.original_container_html.find("li").addBack().contents().filter(function(){return 3===this.nodeType&&(!this.nodeValue||/^\s+$/.test(this.nodeValue))}).remove(),this.element.html(""),this.element.attr("aria-activedescendant","j"+this._id+"_loading"),this._data.core.li_height=this.get_container_ul().children("li").first().outerHeight()||24,this._data.core.node=this._create_prototype_node(),this.trigger("loading"),this.load_node(a.jstree.root)},destroy:function(a){if(this.trigger("destroy"),this._wrk)try{window.URL.revokeObjectURL(this._wrk),this._wrk=null}catch(b){}a||this.element.empty(),this.teardown()},_create_prototype_node:function(){var a=i.createElement("LI"),b,c;return a.setAttribute("role","treeitem"),b=i.createElement("I"),b.className="jstree-icon jstree-ocl",b.setAttribute("role","presentation"),a.appendChild(b),b=i.createElement("A"),b.className="jstree-anchor",b.setAttribute("href","#"),b.setAttribute("tabindex","-1"),c=i.createElement("I"),c.className="jstree-icon jstree-themeicon",c.setAttribute("role","presentation"),b.appendChild(c),a.appendChild(b),b=c=null,a},_kbevent_to_func:function(a){var b={8:"Backspace",9:"Tab",13:"Return",19:"Pause",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"Print",45:"Insert",46:"Delete",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9","-13":"NumpadEnter",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"Numlock",145:"Scrolllock",16:"Shift",17:"Ctrl",18:"Alt",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",107:"+",109:"-",110:".",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",111:"/",106:"*",173:"-"},c=[];a.ctrlKey&&c.push("ctrl"),a.altKey&&c.push("alt"),a.shiftKey&&c.push("shift"),c.push(b[a.which]||a.which),c=c.sort().join("-").toLowerCase();var d=this.settings.core.keyboard,e,f;for(e in d)if(d.hasOwnProperty(e)&&(f=e,"-"!==f&&"+"!==f&&(f=f.replace("--","-MINUS").replace("+-","-MINUS").replace("++","-PLUS").replace("-+","-PLUS"),f=f.split(/-|\+/).sort().join("-").replace("MINUS","-").replace("PLUS","+").toLowerCase()),f===c))return d[e];return null},teardown:function(){this.unbind(),this.element.removeClass("jstree").removeData("jstree").find("[class^='jstree']").addBack().attr("class",function(){return this.className.replace(/jstree[^ ]*|$/gi,"")}),this.element=null},bind:function(){var b="",c=null,d=0;this.element.on("dblclick.jstree",function(a){if(a.target.tagName&&"input"===a.target.tagName.toLowerCase())return!0;if(i.selection&&i.selection.empty)i.selection.empty();else if(window.getSelection){var b=window.getSelection();try{b.removeAllRanges(),b.collapse()}catch(c){}}}).on("mousedown.jstree",a.proxy(function(a){a.target===this.element[0]&&(a.preventDefault(),d=+new Date)},this)).on("mousedown.jstree",".jstree-ocl",function(a){a.preventDefault()}).on("click.jstree",".jstree-ocl",a.proxy(function(a){this.toggle_node(a.target)},this)).on("dblclick.jstree",".jstree-anchor",a.proxy(function(a){return a.target.tagName&&"input"===a.target.tagName.toLowerCase()?!0:void(this.settings.core.dblclick_toggle&&this.toggle_node(a.target))},this)).on("click.jstree",".jstree-anchor",a.proxy(function(b){b.preventDefault(),b.currentTarget!==i.activeElement&&a(b.currentTarget).focus(),this.activate_node(b.currentTarget,b)},this)).on("keydown.jstree",".jstree-anchor",a.proxy(function(a){if(a.target.tagName&&"input"===a.target.tagName.toLowerCase())return!0;this._data.core.rtl&&(37===a.which?a.which=39:39===a.which&&(a.which=37));var b=this._kbevent_to_func(a);if(b){var c=b.call(this,a);if(c===!1||c===!0)return c}},this)).on("load_node.jstree",a.proxy(function(b,c){c.status&&(c.node.id!==a.jstree.root||this._data.core.loaded||(this._data.core.loaded=!0,this._firstChild(this.get_container_ul()[0])&&this.element.attr("aria-activedescendant",this._firstChild(this.get_container_ul()[0]).id),this.trigger("loaded")),this._data.core.ready||setTimeout(a.proxy(function(){if(this.element&&!this.get_container_ul().find(".jstree-loading").length){if(this._data.core.ready=!0,this._data.core.selected.length){if(this.settings.core.expand_selected_onload){var b=[],c,d;for(c=0,d=this._data.core.selected.length;d>c;c++)b=b.concat(this._model.data[this._data.core.selected[c]].parents);for(b=a.vakata.array_unique(b),c=0,d=b.length;d>c;c++)this.open_node(b[c],!1,0)}this.trigger("changed",{action:"ready",selected:this._data.core.selected})}this.trigger("ready")}},this),0))},this)).on("keypress.jstree",a.proxy(function(d){if(d.target.tagName&&"input"===d.target.tagName.toLowerCase())return!0;c&&clearTimeout(c),c=setTimeout(function(){b=""},500);var e=String.fromCharCode(d.which).toLowerCase(),f=this.element.find(".jstree-anchor").filter(":visible"),g=f.index(i.activeElement)||0,h=!1;if(b+=e,b.length>1){if(f.slice(g).each(a.proxy(function(c,d){return 0===a(d).text().toLowerCase().indexOf(b)?(a(d).focus(),h=!0,!1):void 0},this)),h)return;if(f.slice(0,g).each(a.proxy(function(c,d){return 0===a(d).text().toLowerCase().indexOf(b)?(a(d).focus(),h=!0,!1):void 0},this)),h)return}if(new RegExp("^"+e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")+"+$").test(b)){if(f.slice(g+1).each(a.proxy(function(b,c){return a(c).text().toLowerCase().charAt(0)===e?(a(c).focus(),h=!0,!1):void 0},this)),h)return;if(f.slice(0,g+1).each(a.proxy(function(b,c){return a(c).text().toLowerCase().charAt(0)===e?(a(c).focus(),h=!0,!1):void 0},this)),h)return}},this)).on("init.jstree",a.proxy(function(){var a=this.settings.core.themes;this._data.core.themes.dots=a.dots,this._data.core.themes.stripes=a.stripes,this._data.core.themes.icons=a.icons,this._data.core.themes.ellipsis=a.ellipsis,this.set_theme(a.name||"default",a.url),this.set_theme_variant(a.variant)},this)).on("loading.jstree",a.proxy(function(){this[this._data.core.themes.dots?"show_dots":"hide_dots"](),this[this._data.core.themes.icons?"show_icons":"hide_icons"](),this[this._data.core.themes.stripes?"show_stripes":"hide_stripes"](),this[this._data.core.themes.ellipsis?"show_ellipsis":"hide_ellipsis"]()},this)).on("blur.jstree",".jstree-anchor",a.proxy(function(b){this._data.core.focused=null,a(b.currentTarget).filter(".jstree-hovered").mouseleave(),this.element.attr("tabindex","0")},this)).on("focus.jstree",".jstree-anchor",a.proxy(function(b){var c=this.get_node(b.currentTarget);c&&c.id&&(this._data.core.focused=c.id),this.element.find(".jstree-hovered").not(b.currentTarget).mouseleave(),a(b.currentTarget).mouseenter(),this.element.attr("tabindex","-1")},this)).on("focus.jstree",a.proxy(function(){if(+new Date-d>500&&!this._data.core.focused&&this.settings.core.restore_focus){d=0;var a=this.get_node(this.element.attr("aria-activedescendant"),!0);a&&a.find("> .jstree-anchor").focus()}},this)).on("mouseenter.jstree",".jstree-anchor",a.proxy(function(a){this.hover_node(a.currentTarget)},this)).on("mouseleave.jstree",".jstree-anchor",a.proxy(function(a){this.dehover_node(a.currentTarget)},this))},unbind:function(){this.element.off(".jstree"),a(i).off(".jstree-"+this._id)},trigger:function(a,b){b||(b={}),b.instance=this,this.element.triggerHandler(a.replace(".jstree","")+".jstree",b)},get_container:function(){return this.element},get_container_ul:function(){return this.element.children(".jstree-children").first()},get_string:function(b){var c=this.settings.core.strings;return a.isFunction(c)?c.call(this,b):c&&c[b]?c[b]:b},_firstChild:function(a){a=a?a.firstChild:null;while(null!==a&&1!==a.nodeType)a=a.nextSibling;return a},_nextSibling:function(a){a=a?a.nextSibling:null;while(null!==a&&1!==a.nodeType)a=a.nextSibling;return a},_previousSibling:function(a){a=a?a.previousSibling:null;while(null!==a&&1!==a.nodeType)a=a.previousSibling;return a},get_node:function(b,c){b&&b.id&&(b=b.id),b instanceof jQuery&&b.length&&b[0].id&&(b=b[0].id);var d;try{if(this._model.data[b])b=this._model.data[b];else if("string"==typeof b&&this._model.data[b.replace(/^#/,"")])b=this._model.data[b.replace(/^#/,"")];else if("string"==typeof b&&(d=a("#"+b.replace(a.jstree.idregex,"\\$&"),this.element)).length&&this._model.data[d.closest(".jstree-node").attr("id")])b=this._model.data[d.closest(".jstree-node").attr("id")];else if((d=this.element.find(b)).length&&this._model.data[d.closest(".jstree-node").attr("id")])b=this._model.data[d.closest(".jstree-node").attr("id")];else{if(!(d=this.element.find(b)).length||!d.hasClass("jstree"))return!1;b=this._model.data[a.jstree.root]}return c&&(b=b.id===a.jstree.root?this.element:a("#"+b.id.replace(a.jstree.idregex,"\\$&"),this.element)),b}catch(e){return!1}},get_path:function(b,c,d){if(b=b.parents?b:this.get_node(b),!b||b.id===a.jstree.root||!b.parents)return!1;var e,f,g=[];for(g.push(d?b.id:b.text),e=0,f=b.parents.length;f>e;e++)g.push(d?b.parents[e]:this.get_text(b.parents[e]));return g=g.reverse().slice(1),c?g.join(c):g},get_next_dom:function(b,c){var d;if(b=this.get_node(b,!0),b[0]===this.element[0]){d=this._firstChild(this.get_container_ul()[0]);while(d&&0===d.offsetHeight)d=this._nextSibling(d);return d?a(d):!1}if(!b||!b.length)return!1;if(c){d=b[0];do d=this._nextSibling(d);while(d&&0===d.offsetHeight);return d?a(d):!1}if(b.hasClass("jstree-open")){d=this._firstChild(b.children(".jstree-children")[0]);while(d&&0===d.offsetHeight)d=this._nextSibling(d);if(null!==d)return a(d)}d=b[0];do d=this._nextSibling(d);while(d&&0===d.offsetHeight);return null!==d?a(d):b.parentsUntil(".jstree",".jstree-node").nextAll(".jstree-node:visible").first()},get_prev_dom:function(b,c){var d;if(b=this.get_node(b,!0),b[0]===this.element[0]){d=this.get_container_ul()[0].lastChild;while(d&&0===d.offsetHeight)d=this._previousSibling(d);return d?a(d):!1}if(!b||!b.length)return!1;if(c){d=b[0];do d=this._previousSibling(d);while(d&&0===d.offsetHeight);return d?a(d):!1}d=b[0];do d=this._previousSibling(d);while(d&&0===d.offsetHeight);if(null!==d){b=a(d);while(b.hasClass("jstree-open"))b=b.children(".jstree-children").first().children(".jstree-node:visible:last");return b}return d=b[0].parentNode.parentNode,d&&d.className&&-1!==d.className.indexOf("jstree-node")?a(d):!1},get_parent:function(b){return b=this.get_node(b),b&&b.id!==a.jstree.root?b.parent:!1},get_children_dom:function(a){return a=this.get_node(a,!0),a[0]===this.element[0]?this.get_container_ul().children(".jstree-node"):a&&a.length?a.children(".jstree-children").children(".jstree-node"):!1},is_parent:function(a){return a=this.get_node(a),a&&(a.state.loaded===!1||a.children.length>0)},is_loaded:function(a){return a=this.get_node(a),a&&a.state.loaded},is_loading:function(a){return a=this.get_node(a),a&&a.state&&a.state.loading},is_open:function(a){return a=this.get_node(a),a&&a.state.opened},is_closed:function(a){return a=this.get_node(a),a&&this.is_parent(a)&&!a.state.opened},is_leaf:function(a){return!this.is_parent(a)},load_node:function(b,c){var d,e,f,g,h;if(a.isArray(b))return this._load_nodes(b.slice(),c),!0;if(b=this.get_node(b),!b)return c&&c.call(this,b,!1),!1;if(b.state.loaded){for(b.state.loaded=!1,f=0,g=b.parents.length;g>f;f++)this._model.data[b.parents[f]].children_d=a.vakata.array_filter(this._model.data[b.parents[f]].children_d,function(c){return-1===a.inArray(c,b.children_d)});for(d=0,e=b.children_d.length;e>d;d++)this._model.data[b.children_d[d]].state.selected&&(h=!0),delete this._model.data[b.children_d[d]];h&&(this._data.core.selected=a.vakata.array_filter(this._data.core.selected,function(c){return-1===a.inArray(c,b.children_d)})),b.children=[],b.children_d=[],h&&this.trigger("changed",{action:"load_node",node:b,selected:this._data.core.selected})}return b.state.failed=!1,b.state.loading=!0,this.get_node(b,!0).addClass("jstree-loading").attr("aria-busy",!0),this._load_node(b,a.proxy(function(a){b=this._model.data[b.id],b.state.loading=!1,b.state.loaded=a,b.state.failed=!b.state.loaded;var d=this.get_node(b,!0),e=0,f=0,g=this._model.data,h=!1;for(e=0,f=b.children.length;f>e;e++)if(g[b.children[e]]&&!g[b.children[e]].state.hidden){h=!0;break}b.state.loaded&&d&&d.length&&(d.removeClass("jstree-closed jstree-open jstree-leaf"),h?"#"!==b.id&&d.addClass(b.state.opened?"jstree-open":"jstree-closed"):d.addClass("jstree-leaf")),d.removeClass("jstree-loading").attr("aria-busy",!1),this.trigger("load_node",{node:b,status:a}),c&&c.call(this,b,a)},this)),!0},_load_nodes:function(a,b,c,d){var e=!0,f=function(){this._load_nodes(a,b,!0)},g=this._model.data,h,i,j=[];for(h=0,i=a.length;i>h;h++)g[a[h]]&&(!g[a[h]].state.loaded&&!g[a[h]].state.failed||!c&&d)&&(this.is_loading(a[h])||this.load_node(a[h],f),e=!1);if(e){for(h=0,i=a.length;i>h;h++)g[a[h]]&&g[a[h]].state.loaded&&j.push(a[h]);b&&!b.done&&(b.call(this,j),b.done=!0)}},load_all:function(b,c){if(b||(b=a.jstree.root),b=this.get_node(b),!b)return!1;var d=[],e=this._model.data,f=e[b.id].children_d,g,h;for(b.state&&!b.state.loaded&&d.push(b.id),g=0,h=f.length;h>g;g++)e[f[g]]&&e[f[g]].state&&!e[f[g]].state.loaded&&d.push(f[g]);d.length?this._load_nodes(d,function(){this.load_all(b,c)}):(c&&c.call(this,b),this.trigger("load_all",{node:b}))},_load_node:function(b,c){var d=this.settings.core.data,e,f=function g(){return 3!==this.nodeType&&8!==this.nodeType};return d?a.isFunction(d)?d.call(this,b,a.proxy(function(d){d===!1?c.call(this,!1):this["string"==typeof d?"_append_html_data":"_append_json_data"](b,"string"==typeof d?a(a.parseHTML(d)).filter(f):d,function(a){c.call(this,a)})},this)):"object"==typeof d?d.url?(d=a.extend(!0,{},d),a.isFunction(d.url)&&(d.url=d.url.call(this,b)),a.isFunction(d.data)&&(d.data=d.data.call(this,b)),a.ajax(d).done(a.proxy(function(d,e,g){var h=g.getResponseHeader("Content-Type");return h&&-1!==h.indexOf("json")||"object"==typeof d?this._append_json_data(b,d,function(a){c.call(this,a)}):h&&-1!==h.indexOf("html")||"string"==typeof d?this._append_html_data(b,a(a.parseHTML(d)).filter(f),function(a){c.call(this,a)}):(this._data.core.last_error={error:"ajax",plugin:"core",id:"core_04",reason:"Could not load node",data:JSON.stringify({id:b.id,xhr:g})},this.settings.core.error.call(this,this._data.core.last_error),c.call(this,!1))},this)).fail(a.proxy(function(a){this._data.core.last_error={error:"ajax",plugin:"core",id:"core_04",reason:"Could not load node",data:JSON.stringify({id:b.id,xhr:a})},c.call(this,!1),this.settings.core.error.call(this,this._data.core.last_error)},this))):(e=a.isArray(d)?a.extend(!0,[],d):a.isPlainObject(d)?a.extend(!0,{},d):d,b.id===a.jstree.root?this._append_json_data(b,e,function(a){c.call(this,a)}):(this._data.core.last_error={error:"nodata",plugin:"core",id:"core_05",reason:"Could not load node",data:JSON.stringify({id:b.id})},this.settings.core.error.call(this,this._data.core.last_error),c.call(this,!1))):"string"==typeof d?b.id===a.jstree.root?this._append_html_data(b,a(a.parseHTML(d)).filter(f),function(a){c.call(this,a)}):(this._data.core.last_error={error:"nodata",plugin:"core",id:"core_06",reason:"Could not load node",data:JSON.stringify({id:b.id})},this.settings.core.error.call(this,this._data.core.last_error),c.call(this,!1)):c.call(this,!1):b.id===a.jstree.root?this._append_html_data(b,this._data.core.original_container_html.clone(!0),function(a){c.call(this,a)}):c.call(this,!1)},_node_changed:function(b){b=this.get_node(b),b&&-1===a.inArray(b.id,this._model.changed)&&this._model.changed.push(b.id)},_append_html_data:function(b,c,d){b=this.get_node(b),b.children=[],b.children_d=[];var e=c.is("ul")?c.children():c,f=b.id,g=[],h=[],i=this._model.data,j=i[f],k=this._data.core.selected.length,l,m,n;for(e.each(a.proxy(function(b,c){l=this._parse_model_from_html(a(c),f,j.parents.concat()),l&&(g.push(l),h.push(l),i[l].children_d.length&&(h=h.concat(i[l].children_d)))},this)),j.children=g,j.children_d=h,m=0,n=j.parents.length;n>m;m++)i[j.parents[m]].children_d=i[j.parents[m]].children_d.concat(h);this.trigger("model",{nodes:h,parent:f}),f!==a.jstree.root?(this._node_changed(f),this.redraw()):(this.get_container_ul().children(".jstree-initial-node").remove(),this.redraw(!0)),this._data.core.selected.length!==k&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),d.call(this,!0)},_append_json_data:function(b,c,d,e){if(null!==this.element){b=this.get_node(b),b.children=[],b.children_d=[],c.d&&(c=c.d,"string"==typeof c&&(c=JSON.parse(c))),a.isArray(c)||(c=[c]);var f=null,g={df:this._model.default_state,dat:c,par:b.id,m:this._model.data,t_id:this._id,t_cnt:this._cnt,sel:this._data.core.selected},h=function(a,b){a.data&&(a=a.data);var c=a.dat,d=a.par,e=[],f=[],g=[],h=a.df,i=a.t_id,j=a.t_cnt,k=a.m,l=k[d],m=a.sel,n,o,p,q,r=function(a,c,d){d=d?d.concat():[],c&&d.unshift(c);var e=a.id.toString(),f,i,j,l,m={id:e,text:a.text||"",icon:a.icon!==b?a.icon:!0,parent:c,parents:d,children:a.children||[],children_d:a.children_d||[],data:a.data,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(f in h)h.hasOwnProperty(f)&&(m.state[f]=h[f]);if(a&&a.data&&a.data.jstree&&a.data.jstree.icon&&(m.icon=a.data.jstree.icon),(m.icon===b||null===m.icon||""===m.icon)&&(m.icon=!0),a&&a.data&&(m.data=a.data,a.data.jstree))for(f in a.data.jstree)a.data.jstree.hasOwnProperty(f)&&(m.state[f]=a.data.jstree[f]);if(a&&"object"==typeof a.state)for(f in a.state)a.state.hasOwnProperty(f)&&(m.state[f]=a.state[f]);if(a&&"object"==typeof a.li_attr)for(f in a.li_attr)a.li_attr.hasOwnProperty(f)&&(m.li_attr[f]=a.li_attr[f]);if(m.li_attr.id||(m.li_attr.id=e),a&&"object"==typeof a.a_attr)for(f in a.a_attr)a.a_attr.hasOwnProperty(f)&&(m.a_attr[f]=a.a_attr[f]);for(a&&a.children&&a.children===!0&&(m.state.loaded=!1,m.children=[],m.children_d=[]),k[m.id]=m,f=0,i=m.children.length;i>f;f++)j=r(k[m.children[f]],m.id,d),l=k[j],m.children_d.push(j),l.children_d.length&&(m.children_d=m.children_d.concat(l.children_d));return delete a.data,delete a.children,k[m.id].original=a,m.state.selected&&g.push(m.id),m.id},s=function(a,c,d){d=d?d.concat():[],c&&d.unshift(c);var e=!1,f,l,m,n,o;do e="j"+i+"_"+ ++j;while(k[e]);o={id:!1,text:"string"==typeof a?a:"",icon:"object"==typeof a&&a.icon!==b?a.icon:!0,parent:c,parents:d,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(f in h)h.hasOwnProperty(f)&&(o.state[f]=h[f]);if(a&&a.id&&(o.id=a.id.toString()),a&&a.text&&(o.text=a.text),a&&a.data&&a.data.jstree&&a.data.jstree.icon&&(o.icon=a.data.jstree.icon),(o.icon===b||null===o.icon||""===o.icon)&&(o.icon=!0),a&&a.data&&(o.data=a.data,a.data.jstree))for(f in a.data.jstree)a.data.jstree.hasOwnProperty(f)&&(o.state[f]=a.data.jstree[f]);if(a&&"object"==typeof a.state)for(f in a.state)a.state.hasOwnProperty(f)&&(o.state[f]=a.state[f]);if(a&&"object"==typeof a.li_attr)for(f in a.li_attr)a.li_attr.hasOwnProperty(f)&&(o.li_attr[f]=a.li_attr[f]);if(o.li_attr.id&&!o.id&&(o.id=o.li_attr.id.toString()),o.id||(o.id=e),o.li_attr.id||(o.li_attr.id=o.id),a&&"object"==typeof a.a_attr)for(f in a.a_attr)a.a_attr.hasOwnProperty(f)&&(o.a_attr[f]=a.a_attr[f]);if(a&&a.children&&a.children.length){for(f=0,l=a.children.length;l>f;f++)m=s(a.children[f],o.id,d),n=k[m],o.children.push(m),n.children_d.length&&(o.children_d=o.children_d.concat(n.children_d));o.children_d=o.children_d.concat(o.children)}return a&&a.children&&a.children===!0&&(o.state.loaded=!1,o.children=[],o.children_d=[]),delete a.data,delete a.children,o.original=a,k[o.id]=o,o.state.selected&&g.push(o.id),o.id};if(c.length&&c[0].id!==b&&c[0].parent!==b){for(o=0,p=c.length;p>o;o++)c[o].children||(c[o].children=[]),c[o].state||(c[o].state={}),k[c[o].id.toString()]=c[o];for(o=0,p=c.length;p>o;o++)k[c[o].parent.toString()]?(k[c[o].parent.toString()].children.push(c[o].id.toString()),l.children_d.push(c[o].id.toString())):(this._data.core.last_error={error:"parse",plugin:"core",id:"core_07",reason:"Node with invalid parent",data:JSON.stringify({id:c[o].id.toString(),parent:c[o].parent.toString()})},this.settings.core.error.call(this,this._data.core.last_error));for(o=0,p=l.children.length;p>o;o++)n=r(k[l.children[o]],d,l.parents.concat()),f.push(n),k[n].children_d.length&&(f=f.concat(k[n].children_d));for(o=0,p=l.parents.length;p>o;o++)k[l.parents[o]].children_d=k[l.parents[o]].children_d.concat(f);q={cnt:j,mod:k,sel:m,par:d,dpc:f,add:g}}else{for(o=0,p=c.length;p>o;o++)n=s(c[o],d,l.parents.concat()),n&&(e.push(n),f.push(n),k[n].children_d.length&&(f=f.concat(k[n].children_d)));for(l.children=e,l.children_d=f,o=0,p=l.parents.length;p>o;o++)k[l.parents[o]].children_d=k[l.parents[o]].children_d.concat(f);q={cnt:j,mod:k,sel:m,par:d,dpc:f,add:g}}return"undefined"!=typeof window&&"undefined"!=typeof window.document?q:void postMessage(q)},i=function(b,c){if(null!==this.element){this._cnt=b.cnt;var e,f=this._model.data;for(e in f)f.hasOwnProperty(e)&&f[e].state&&f[e].state.loading&&b.mod[e]&&(b.mod[e].state.loading=!0);if(this._model.data=b.mod,c){var g,h=b.add,i=b.sel,j=this._data.core.selected.slice();if(f=this._model.data,i.length!==j.length||a.vakata.array_unique(i.concat(j)).length!==i.length){for(e=0,g=i.length;g>e;e++)-1===a.inArray(i[e],h)&&-1===a.inArray(i[e],j)&&(f[i[e]].state.selected=!1);for(e=0,g=j.length;g>e;e++)-1===a.inArray(j[e],i)&&(f[j[e]].state.selected=!0)}}b.add.length&&(this._data.core.selected=this._data.core.selected.concat(b.add)),this.trigger("model",{nodes:b.dpc,parent:b.par}),b.par!==a.jstree.root?(this._node_changed(b.par),this.redraw()):this.redraw(!0),b.add.length&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),d.call(this,!0)}};if(this.settings.core.worker&&window.Blob&&window.URL&&window.Worker)try{null===this._wrk&&(this._wrk=window.URL.createObjectURL(new window.Blob(["self.onmessage = "+h.toString()],{type:"text/javascript"}))),!this._data.core.working||e?(this._data.core.working=!0,f=new window.Worker(this._wrk),f.onmessage=a.proxy(function(a){i.call(this,a.data,!0);try{f.terminate(),f=null}catch(b){}this._data.core.worker_queue.length?this._append_json_data.apply(this,this._data.core.worker_queue.shift()):this._data.core.working=!1},this),g.par?f.postMessage(g):this._data.core.worker_queue.length?this._append_json_data.apply(this,this._data.core.worker_queue.shift()):this._data.core.working=!1):this._data.core.worker_queue.push([b,c,d,!0])}catch(j){i.call(this,h(g),!1),this._data.core.worker_queue.length?this._append_json_data.apply(this,this._data.core.worker_queue.shift()):this._data.core.working=!1}else i.call(this,h(g),!1)}},_parse_model_from_html:function(c,d,e){e=e?[].concat(e):[],d&&e.unshift(d);var f,g,h=this._model.data,i={id:!1,text:!1,icon:!0,parent:d,parents:e,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1},j,k,l;for(j in this._model.default_state)this._model.default_state.hasOwnProperty(j)&&(i.state[j]=this._model.default_state[j]);if(k=a.vakata.attributes(c,!0),a.each(k,function(b,c){return c=a.trim(c),c.length?(i.li_attr[b]=c,void("id"===b&&(i.id=c.toString()))):!0}),k=c.children("a").first(),k.length&&(k=a.vakata.attributes(k,!0),a.each(k,function(b,c){c=a.trim(c),c.length&&(i.a_attr[b]=c)})),k=c.children("a").first().length?c.children("a").first().clone():c.clone(),k.children("ins, i, ul").remove(),k=k.html(),k=a("
      ").html(k),i.text=this.settings.core.force_text?k.text():k.html(),k=c.data(),i.data=k?a.extend(!0,{},k):null,i.state.opened=c.hasClass("jstree-open"),i.state.selected=c.children("a").hasClass("jstree-clicked"),i.state.disabled=c.children("a").hasClass("jstree-disabled"),i.data&&i.data.jstree)for(j in i.data.jstree)i.data.jstree.hasOwnProperty(j)&&(i.state[j]=i.data.jstree[j]);k=c.children("a").children(".jstree-themeicon"),k.length&&(i.icon=k.hasClass("jstree-themeicon-hidden")?!1:k.attr("rel")),i.state.icon!==b&&(i.icon=i.state.icon),(i.icon===b||null===i.icon||""===i.icon)&&(i.icon=!0),k=c.children("ul").children("li");do l="j"+this._id+"_"+ ++this._cnt;while(h[l]);return i.id=i.li_attr.id?i.li_attr.id.toString():l,k.length?(k.each(a.proxy(function(b,c){f=this._parse_model_from_html(a(c),i.id,e),g=this._model.data[f],i.children.push(f),g.children_d.length&&(i.children_d=i.children_d.concat(g.children_d))},this)),i.children_d=i.children_d.concat(i.children)):c.hasClass("jstree-closed")&&(i.state.loaded=!1),i.li_attr["class"]&&(i.li_attr["class"]=i.li_attr["class"].replace("jstree-closed","").replace("jstree-open","")),i.a_attr["class"]&&(i.a_attr["class"]=i.a_attr["class"].replace("jstree-clicked","").replace("jstree-disabled","")),h[i.id]=i,i.state.selected&&this._data.core.selected.push(i.id),i.id},_parse_model_from_flat_json:function(a,c,d){d=d?d.concat():[],c&&d.unshift(c);var e=a.id.toString(),f=this._model.data,g=this._model.default_state,h,i,j,k,l={id:e,text:a.text||"",icon:a.icon!==b?a.icon:!0,parent:c,parents:d,children:a.children||[],children_d:a.children_d||[],data:a.data,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(h in g)g.hasOwnProperty(h)&&(l.state[h]=g[h]);if(a&&a.data&&a.data.jstree&&a.data.jstree.icon&&(l.icon=a.data.jstree.icon),(l.icon===b||null===l.icon||""===l.icon)&&(l.icon=!0),a&&a.data&&(l.data=a.data,a.data.jstree))for(h in a.data.jstree)a.data.jstree.hasOwnProperty(h)&&(l.state[h]=a.data.jstree[h]);if(a&&"object"==typeof a.state)for(h in a.state)a.state.hasOwnProperty(h)&&(l.state[h]=a.state[h]);if(a&&"object"==typeof a.li_attr)for(h in a.li_attr)a.li_attr.hasOwnProperty(h)&&(l.li_attr[h]=a.li_attr[h]);if(l.li_attr.id||(l.li_attr.id=e),a&&"object"==typeof a.a_attr)for(h in a.a_attr)a.a_attr.hasOwnProperty(h)&&(l.a_attr[h]=a.a_attr[h]);for(a&&a.children&&a.children===!0&&(l.state.loaded=!1,l.children=[],l.children_d=[]),f[l.id]=l,h=0,i=l.children.length;i>h;h++)j=this._parse_model_from_flat_json(f[l.children[h]],l.id,d),k=f[j],l.children_d.push(j),k.children_d.length&&(l.children_d=l.children_d.concat(k.children_d));return delete a.data,delete a.children,f[l.id].original=a,l.state.selected&&this._data.core.selected.push(l.id),l.id},_parse_model_from_json:function(a,c,d){d=d?d.concat():[],c&&d.unshift(c);var e=!1,f,g,h,i,j=this._model.data,k=this._model.default_state,l;do e="j"+this._id+"_"+ ++this._cnt;while(j[e]);l={id:!1,text:"string"==typeof a?a:"",icon:"object"==typeof a&&a.icon!==b?a.icon:!0,parent:c,parents:d,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(f in k)k.hasOwnProperty(f)&&(l.state[f]=k[f]);if(a&&a.id&&(l.id=a.id.toString()),a&&a.text&&(l.text=a.text),a&&a.data&&a.data.jstree&&a.data.jstree.icon&&(l.icon=a.data.jstree.icon),(l.icon===b||null===l.icon||""===l.icon)&&(l.icon=!0),a&&a.data&&(l.data=a.data,a.data.jstree))for(f in a.data.jstree)a.data.jstree.hasOwnProperty(f)&&(l.state[f]=a.data.jstree[f]);if(a&&"object"==typeof a.state)for(f in a.state)a.state.hasOwnProperty(f)&&(l.state[f]=a.state[f]);if(a&&"object"==typeof a.li_attr)for(f in a.li_attr)a.li_attr.hasOwnProperty(f)&&(l.li_attr[f]=a.li_attr[f]);if(l.li_attr.id&&!l.id&&(l.id=l.li_attr.id.toString()), +l.id||(l.id=e),l.li_attr.id||(l.li_attr.id=l.id),a&&"object"==typeof a.a_attr)for(f in a.a_attr)a.a_attr.hasOwnProperty(f)&&(l.a_attr[f]=a.a_attr[f]);if(a&&a.children&&a.children.length){for(f=0,g=a.children.length;g>f;f++)h=this._parse_model_from_json(a.children[f],l.id,d),i=j[h],l.children.push(h),i.children_d.length&&(l.children_d=l.children_d.concat(i.children_d));l.children_d=l.children_d.concat(l.children)}return a&&a.children&&a.children===!0&&(l.state.loaded=!1,l.children=[],l.children_d=[]),delete a.data,delete a.children,l.original=a,j[l.id]=l,l.state.selected&&this._data.core.selected.push(l.id),l.id},_redraw:function(){var b=this._model.force_full_redraw?this._model.data[a.jstree.root].children.concat([]):this._model.changed.concat([]),c=i.createElement("UL"),d,e,f,g=this._data.core.focused;for(e=0,f=b.length;f>e;e++)d=this.redraw_node(b[e],!0,this._model.force_full_redraw),d&&this._model.force_full_redraw&&c.appendChild(d);this._model.force_full_redraw&&(c.className=this.get_container_ul()[0].className,c.setAttribute("role","group"),this.element.empty().append(c)),null!==g&&this.settings.core.restore_focus&&(d=this.get_node(g,!0),d&&d.length&&d.children(".jstree-anchor")[0]!==i.activeElement?d.children(".jstree-anchor").focus():this._data.core.focused=null),this._model.force_full_redraw=!1,this._model.changed=[],this.trigger("redraw",{nodes:b})},redraw:function(a){a&&(this._model.force_full_redraw=!0),this._redraw()},draw_children:function(b){var c=this.get_node(b),d=!1,e=!1,f=!1,g=i;if(!c)return!1;if(c.id===a.jstree.root)return this.redraw(!0);if(b=this.get_node(b,!0),!b||!b.length)return!1;if(b.children(".jstree-children").remove(),b=b[0],c.children.length&&c.state.loaded){for(f=g.createElement("UL"),f.setAttribute("role","group"),f.className="jstree-children",d=0,e=c.children.length;e>d;d++)f.appendChild(this.redraw_node(c.children[d],!0,!0));b.appendChild(f)}},redraw_node:function(b,c,d,e){var f=this.get_node(b),g=!1,h=!1,j=!1,k=!1,l=!1,m=!1,n="",o=i,p=this._model.data,q=!1,r=!1,s=null,t=0,u=0,v=!1,w=!1;if(!f)return!1;if(f.id===a.jstree.root)return this.redraw(!0);if(c=c||0===f.children.length,b=i.querySelector?this.element[0].querySelector("#"+(-1!=="0123456789".indexOf(f.id[0])?"\\3"+f.id[0]+" "+f.id.substr(1).replace(a.jstree.idregex,"\\$&"):f.id.replace(a.jstree.idregex,"\\$&"))):i.getElementById(f.id))b=a(b),d||(g=b.parent().parent()[0],g===this.element[0]&&(g=null),h=b.index()),c||!f.children.length||b.children(".jstree-children").length||(c=!0),c||(j=b.children(".jstree-children")[0]),q=b.children(".jstree-anchor")[0]===i.activeElement,b.remove();else if(c=!0,!d){if(g=f.parent!==a.jstree.root?a("#"+f.parent.replace(a.jstree.idregex,"\\$&"),this.element)[0]:null,!(null===g||g&&p[f.parent].state.opened))return!1;h=a.inArray(f.id,null===g?p[a.jstree.root].children:p[f.parent].children)}b=this._data.core.node.cloneNode(!0),n="jstree-node ";for(k in f.li_attr)if(f.li_attr.hasOwnProperty(k)){if("id"===k)continue;"class"!==k?b.setAttribute(k,f.li_attr[k]):n+=f.li_attr[k]}for(f.a_attr.id||(f.a_attr.id=f.id+"_anchor"),b.setAttribute("aria-selected",!!f.state.selected),b.setAttribute("aria-level",f.parents.length),b.setAttribute("aria-labelledby",f.a_attr.id),f.state.disabled&&b.setAttribute("aria-disabled",!0),k=0,l=f.children.length;l>k;k++)if(!p[f.children[k]].state.hidden){v=!0;break}if(null!==f.parent&&p[f.parent]&&!f.state.hidden&&(k=a.inArray(f.id,p[f.parent].children),w=f.id,-1!==k))for(k++,l=p[f.parent].children.length;l>k;k++)if(p[p[f.parent].children[k]].state.hidden||(w=p[f.parent].children[k]),w!==f.id)break;f.state.hidden&&(n+=" jstree-hidden"),f.state.loading&&(n+=" jstree-loading"),f.state.loaded&&!v?n+=" jstree-leaf":(n+=f.state.opened&&f.state.loaded?" jstree-open":" jstree-closed",b.setAttribute("aria-expanded",f.state.opened&&f.state.loaded)),w===f.id&&(n+=" jstree-last"),b.id=f.id,b.className=n,n=(f.state.selected?" jstree-clicked":"")+(f.state.disabled?" jstree-disabled":"");for(l in f.a_attr)if(f.a_attr.hasOwnProperty(l)){if("href"===l&&"#"===f.a_attr[l])continue;"class"!==l?b.childNodes[1].setAttribute(l,f.a_attr[l]):n+=" "+f.a_attr[l]}if(n.length&&(b.childNodes[1].className="jstree-anchor "+n),(f.icon&&f.icon!==!0||f.icon===!1)&&(f.icon===!1?b.childNodes[1].childNodes[0].className+=" jstree-themeicon-hidden":-1===f.icon.indexOf("/")&&-1===f.icon.indexOf(".")?b.childNodes[1].childNodes[0].className+=" "+f.icon+" jstree-themeicon-custom":(b.childNodes[1].childNodes[0].style.backgroundImage='url("'+f.icon+'")',b.childNodes[1].childNodes[0].style.backgroundPosition="center center",b.childNodes[1].childNodes[0].style.backgroundSize="auto",b.childNodes[1].childNodes[0].className+=" jstree-themeicon-custom")),this.settings.core.force_text?b.childNodes[1].appendChild(o.createTextNode(f.text)):b.childNodes[1].innerHTML+=f.text,c&&f.children.length&&(f.state.opened||e)&&f.state.loaded){for(m=o.createElement("UL"),m.setAttribute("role","group"),m.className="jstree-children",k=0,l=f.children.length;l>k;k++)m.appendChild(this.redraw_node(f.children[k],c,!0));b.appendChild(m)}if(j&&b.appendChild(j),!d){for(g||(g=this.element[0]),k=0,l=g.childNodes.length;l>k;k++)if(g.childNodes[k]&&g.childNodes[k].className&&-1!==g.childNodes[k].className.indexOf("jstree-children")){s=g.childNodes[k];break}s||(s=o.createElement("UL"),s.setAttribute("role","group"),s.className="jstree-children",g.appendChild(s)),g=s,hf;f++)this.open_node(c[f],d,e);return!0}return c=this.get_node(c),c&&c.id!==a.jstree.root?(e=e===b?this.settings.core.animation:e,this.is_closed(c)?this.is_loaded(c)?(h=this.get_node(c,!0),i=this,h.length&&(e&&h.children(".jstree-children").length&&h.children(".jstree-children").stop(!0,!0),c.children.length&&!this._firstChild(h.children(".jstree-children")[0])&&this.draw_children(c),e?(this.trigger("before_open",{node:c}),h.children(".jstree-children").css("display","none").end().removeClass("jstree-closed").addClass("jstree-open").attr("aria-expanded",!0).children(".jstree-children").stop(!0,!0).slideDown(e,function(){this.style.display="",i.element&&i.trigger("after_open",{node:c})})):(this.trigger("before_open",{node:c}),h[0].className=h[0].className.replace("jstree-closed","jstree-open"),h[0].setAttribute("aria-expanded",!0))),c.state.opened=!0,d&&d.call(this,c,!0),h.length||this.trigger("before_open",{node:c}),this.trigger("open_node",{node:c}),e&&h.length||this.trigger("after_open",{node:c}),!0):this.is_loading(c)?setTimeout(a.proxy(function(){this.open_node(c,d,e)},this),500):void this.load_node(c,function(a,b){return b?this.open_node(a,d,e):d?d.call(this,a,!1):!1}):(d&&d.call(this,c,!1),!1)):!1},_open_to:function(b){if(b=this.get_node(b),!b||b.id===a.jstree.root)return!1;var c,d,e=b.parents;for(c=0,d=e.length;d>c;c+=1)c!==a.jstree.root&&this.open_node(e[c],!1,0);return a("#"+b.id.replace(a.jstree.idregex,"\\$&"),this.element)},close_node:function(c,d){var e,f,g,h;if(a.isArray(c)){for(c=c.slice(),e=0,f=c.length;f>e;e++)this.close_node(c[e],d);return!0}return c=this.get_node(c),c&&c.id!==a.jstree.root?this.is_closed(c)?!1:(d=d===b?this.settings.core.animation:d,g=this,h=this.get_node(c,!0),c.state.opened=!1,this.trigger("close_node",{node:c}),void(h.length?d?h.children(".jstree-children").attr("style","display:block !important").end().removeClass("jstree-open").addClass("jstree-closed").attr("aria-expanded",!1).children(".jstree-children").stop(!0,!0).slideUp(d,function(){this.style.display="",h.children(".jstree-children").remove(),g.element&&g.trigger("after_close",{node:c})}):(h[0].className=h[0].className.replace("jstree-open","jstree-closed"),h.attr("aria-expanded",!1).children(".jstree-children").remove(),this.trigger("after_close",{node:c})):this.trigger("after_close",{node:c}))):!1},toggle_node:function(b){var c,d;if(a.isArray(b)){for(b=b.slice(),c=0,d=b.length;d>c;c++)this.toggle_node(b[c]);return!0}return this.is_closed(b)?this.open_node(b):this.is_open(b)?this.close_node(b):void 0},open_all:function(b,c,d){if(b||(b=a.jstree.root),b=this.get_node(b),!b)return!1;var e=b.id===a.jstree.root?this.get_container_ul():this.get_node(b,!0),f,g,h;if(!e.length){for(f=0,g=b.children_d.length;g>f;f++)this.is_closed(this._model.data[b.children_d[f]])&&(this._model.data[b.children_d[f]].state.opened=!0);return this.trigger("open_all",{node:b})}d=d||e,h=this,e=this.is_closed(b)?e.find(".jstree-closed").addBack():e.find(".jstree-closed"),e.each(function(){h.open_node(this,function(a,b){b&&this.is_parent(a)&&this.open_all(a,c,d)},c||0)}),0===d.find(".jstree-closed").length&&this.trigger("open_all",{node:this.get_node(d)})},close_all:function(b,c){if(b||(b=a.jstree.root),b=this.get_node(b),!b)return!1;var d=b.id===a.jstree.root?this.get_container_ul():this.get_node(b,!0),e=this,f,g;for(d.length&&(d=this.is_open(b)?d.find(".jstree-open").addBack():d.find(".jstree-open"),a(d.get().reverse()).each(function(){e.close_node(this,c||0)})),f=0,g=b.children_d.length;g>f;f++)this._model.data[b.children_d[f]].state.opened=!1;this.trigger("close_all",{node:b})},is_disabled:function(a){return a=this.get_node(a),a&&a.state&&a.state.disabled},enable_node:function(b){var c,d;if(a.isArray(b)){for(b=b.slice(),c=0,d=b.length;d>c;c++)this.enable_node(b[c]);return!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?(b.state.disabled=!1,this.get_node(b,!0).children(".jstree-anchor").removeClass("jstree-disabled").attr("aria-disabled",!1),void this.trigger("enable_node",{node:b})):!1},disable_node:function(b){var c,d;if(a.isArray(b)){for(b=b.slice(),c=0,d=b.length;d>c;c++)this.disable_node(b[c]);return!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?(b.state.disabled=!0,this.get_node(b,!0).children(".jstree-anchor").addClass("jstree-disabled").attr("aria-disabled",!0),void this.trigger("disable_node",{node:b})):!1},is_hidden:function(a){return a=this.get_node(a),a.state.hidden===!0},hide_node:function(b,c){var d,e;if(a.isArray(b)){for(b=b.slice(),d=0,e=b.length;e>d;d++)this.hide_node(b[d],!0);return c||this.redraw(),!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?void(b.state.hidden||(b.state.hidden=!0,this._node_changed(b.parent),c||this.redraw(),this.trigger("hide_node",{node:b}))):!1},show_node:function(b,c){var d,e;if(a.isArray(b)){for(b=b.slice(),d=0,e=b.length;e>d;d++)this.show_node(b[d],!0);return c||this.redraw(),!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?void(b.state.hidden&&(b.state.hidden=!1,this._node_changed(b.parent),c||this.redraw(),this.trigger("show_node",{node:b}))):!1},hide_all:function(b){var c,d=this._model.data,e=[];for(c in d)d.hasOwnProperty(c)&&c!==a.jstree.root&&!d[c].state.hidden&&(d[c].state.hidden=!0,e.push(c));return this._model.force_full_redraw=!0,b||this.redraw(),this.trigger("hide_all",{nodes:e}),e},show_all:function(b){var c,d=this._model.data,e=[];for(c in d)d.hasOwnProperty(c)&&c!==a.jstree.root&&d[c].state.hidden&&(d[c].state.hidden=!1,e.push(c));return this._model.force_full_redraw=!0,b||this.redraw(),this.trigger("show_all",{nodes:e}),e},activate_node:function(a,c){if(this.is_disabled(a))return!1;if(c&&"object"==typeof c||(c={}),this._data.core.last_clicked=this._data.core.last_clicked&&this._data.core.last_clicked.id!==b?this.get_node(this._data.core.last_clicked.id):null,this._data.core.last_clicked&&!this._data.core.last_clicked.state.selected&&(this._data.core.last_clicked=null),!this._data.core.last_clicked&&this._data.core.selected.length&&(this._data.core.last_clicked=this.get_node(this._data.core.selected[this._data.core.selected.length-1])),this.settings.core.multiple&&(c.metaKey||c.ctrlKey||c.shiftKey)&&(!c.shiftKey||this._data.core.last_clicked&&this.get_parent(a)&&this.get_parent(a)===this._data.core.last_clicked.parent))if(c.shiftKey){var d=this.get_node(a).id,e=this._data.core.last_clicked.id,f=this.get_node(this._data.core.last_clicked.parent).children,g=!1,h,i;for(h=0,i=f.length;i>h;h+=1)f[h]===d&&(g=!g),f[h]===e&&(g=!g),this.is_disabled(f[h])||!g&&f[h]!==d&&f[h]!==e?this.deselect_node(f[h],!0,c):this.is_hidden(f[h])||this.select_node(f[h],!0,!1,c);this.trigger("changed",{action:"select_node",node:this.get_node(a),selected:this._data.core.selected,event:c})}else this.is_selected(a)?this.deselect_node(a,!1,c):this.select_node(a,!1,!1,c);else!this.settings.core.multiple&&(c.metaKey||c.ctrlKey||c.shiftKey)&&this.is_selected(a)?this.deselect_node(a,!1,c):(this.deselect_all(!0),this.select_node(a,!1,!1,c),this._data.core.last_clicked=this.get_node(a));this.trigger("activate_node",{node:this.get_node(a),event:c})},hover_node:function(a){if(a=this.get_node(a,!0),!a||!a.length||a.children(".jstree-hovered").length)return!1;var b=this.element.find(".jstree-hovered"),c=this.element;b&&b.length&&this.dehover_node(b),a.children(".jstree-anchor").addClass("jstree-hovered"),this.trigger("hover_node",{node:this.get_node(a)}),setTimeout(function(){c.attr("aria-activedescendant",a[0].id)},0)},dehover_node:function(a){return a=this.get_node(a,!0),a&&a.length&&a.children(".jstree-hovered").length?(a.children(".jstree-anchor").removeClass("jstree-hovered"),void this.trigger("dehover_node",{node:this.get_node(a)})):!1},select_node:function(b,c,d,e){var f,g,h,i;if(a.isArray(b)){for(b=b.slice(),g=0,h=b.length;h>g;g++)this.select_node(b[g],c,d,e);return!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?(f=this.get_node(b,!0),void(b.state.selected||(b.state.selected=!0,this._data.core.selected.push(b.id),d||(f=this._open_to(b)),f&&f.length&&f.attr("aria-selected",!0).children(".jstree-anchor").addClass("jstree-clicked"),this.trigger("select_node",{node:b,selected:this._data.core.selected,event:e}),c||this.trigger("changed",{action:"select_node",node:b,selected:this._data.core.selected,event:e})))):!1},deselect_node:function(b,c,d){var e,f,g;if(a.isArray(b)){for(b=b.slice(),e=0,f=b.length;f>e;e++)this.deselect_node(b[e],c,d);return!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?(g=this.get_node(b,!0),void(b.state.selected&&(b.state.selected=!1,this._data.core.selected=a.vakata.array_remove_item(this._data.core.selected,b.id),g.length&&g.attr("aria-selected",!1).children(".jstree-anchor").removeClass("jstree-clicked"),this.trigger("deselect_node",{node:b,selected:this._data.core.selected,event:d}),c||this.trigger("changed",{action:"deselect_node",node:b,selected:this._data.core.selected,event:d})))):!1},select_all:function(b){var c=this._data.core.selected.concat([]),d,e;for(this._data.core.selected=this._model.data[a.jstree.root].children_d.concat(),d=0,e=this._data.core.selected.length;e>d;d++)this._model.data[this._data.core.selected[d]]&&(this._model.data[this._data.core.selected[d]].state.selected=!0);this.redraw(!0),this.trigger("select_all",{selected:this._data.core.selected}),b||this.trigger("changed",{action:"select_all",selected:this._data.core.selected,old_selection:c})},deselect_all:function(a){var b=this._data.core.selected.concat([]),c,d;for(c=0,d=this._data.core.selected.length;d>c;c++)this._model.data[this._data.core.selected[c]]&&(this._model.data[this._data.core.selected[c]].state.selected=!1);this._data.core.selected=[],this.element.find(".jstree-clicked").removeClass("jstree-clicked").parent().attr("aria-selected",!1),this.trigger("deselect_all",{selected:this._data.core.selected,node:b}),a||this.trigger("changed",{action:"deselect_all",selected:this._data.core.selected,old_selection:b})},is_selected:function(b){return b=this.get_node(b),b&&b.id!==a.jstree.root?b.state.selected:!1},get_selected:function(b){return b?a.map(this._data.core.selected,a.proxy(function(a){return this.get_node(a)},this)):this._data.core.selected.slice()},get_top_selected:function(b){var c=this.get_selected(!0),d={},e,f,g,h;for(e=0,f=c.length;f>e;e++)d[c[e].id]=c[e];for(e=0,f=c.length;f>e;e++)for(g=0,h=c[e].children_d.length;h>g;g++)d[c[e].children_d[g]]&&delete d[c[e].children_d[g]];c=[];for(e in d)d.hasOwnProperty(e)&&c.push(e);return b?a.map(c,a.proxy(function(a){return this.get_node(a)},this)):c},get_bottom_selected:function(b){var c=this.get_selected(!0),d=[],e,f;for(e=0,f=c.length;f>e;e++)c[e].children.length||d.push(c[e].id);return b?a.map(d,a.proxy(function(a){return this.get_node(a)},this)):d},get_state:function(){var b={core:{open:[],loaded:[],scroll:{left:this.element.scrollLeft(),top:this.element.scrollTop()},selected:[]}},c;for(c in this._model.data)this._model.data.hasOwnProperty(c)&&c!==a.jstree.root&&(this._model.data[c].state.loaded&&this.settings.core.loaded_state&&b.core.loaded.push(c),this._model.data[c].state.opened&&b.core.open.push(c),this._model.data[c].state.selected&&b.core.selected.push(c));return b},set_state:function(c,d){if(c){if(c.core&&c.core.selected&&c.core.initial_selection===b&&(c.core.initial_selection=this._data.core.selected.concat([]).sort().join(",")),c.core){var e,f,g,h,i;if(c.core.loaded)return this.settings.core.loaded_state&&a.isArray(c.core.loaded)&&c.core.loaded.length?this._load_nodes(c.core.loaded,function(a){delete c.core.loaded,this.set_state(c,d)}):(delete c.core.loaded,this.set_state(c,d)),!1;if(c.core.open)return a.isArray(c.core.open)&&c.core.open.length?this._load_nodes(c.core.open,function(a){this.open_node(a,!1,0),delete c.core.open,this.set_state(c,d)}):(delete c.core.open,this.set_state(c,d)),!1;if(c.core.scroll)return c.core.scroll&&c.core.scroll.left!==b&&this.element.scrollLeft(c.core.scroll.left),c.core.scroll&&c.core.scroll.top!==b&&this.element.scrollTop(c.core.scroll.top),delete c.core.scroll,this.set_state(c,d),!1;if(c.core.selected)return h=this,(c.core.initial_selection===b||c.core.initial_selection===this._data.core.selected.concat([]).sort().join(","))&&(this.deselect_all(),a.each(c.core.selected,function(a,b){h.select_node(b,!1,!0)})),delete c.core.initial_selection,delete c.core.selected,this.set_state(c,d),!1;for(i in c)c.hasOwnProperty(i)&&"core"!==i&&-1===a.inArray(i,this.settings.plugins)&&delete c[i];if(a.isEmptyObject(c.core))return delete c.core,this.set_state(c,d),!1}return a.isEmptyObject(c)?(c=null,d&&d.call(this),this.trigger("set_state"),!1):!0}return!1},refresh:function(b,c){this._data.core.state=c===!0?{}:this.get_state(),c&&a.isFunction(c)&&(this._data.core.state=c.call(this,this._data.core.state)),this._cnt=0,this._model.data={},this._model.data[a.jstree.root]={id:a.jstree.root,parent:null,parents:[],children:[],children_d:[],state:{loaded:!1}},this._data.core.selected=[],this._data.core.last_clicked=null,this._data.core.focused=null;var d=this.get_container_ul()[0].className;b||(this.element.html(""),this.element.attr("aria-activedescendant","j"+this._id+"_loading")),this.load_node(a.jstree.root,function(b,c){c&&(this.get_container_ul()[0].className=d,this._firstChild(this.get_container_ul()[0])&&this.element.attr("aria-activedescendant",this._firstChild(this.get_container_ul()[0]).id),this.set_state(a.extend(!0,{},this._data.core.state),function(){this.trigger("refresh")})),this._data.core.state=null})},refresh_node:function(b){if(b=this.get_node(b),!b||b.id===a.jstree.root)return!1;var c=[],d=[],e=this._data.core.selected.concat([]);d.push(b.id),b.state.opened===!0&&c.push(b.id),this.get_node(b,!0).find(".jstree-open").each(function(){d.push(this.id),c.push(this.id)}),this._load_nodes(d,a.proxy(function(a){this.open_node(c,!1,0),this.select_node(e),this.trigger("refresh_node",{node:b,nodes:a})},this),!1,!0)},set_id:function(b,c){if(b=this.get_node(b),!b||b.id===a.jstree.root)return!1;var d,e,f=this._model.data,g=b.id;for(c=c.toString(),f[b.parent].children[a.inArray(b.id,f[b.parent].children)]=c,d=0,e=b.parents.length;e>d;d++)f[b.parents[d]].children_d[a.inArray(b.id,f[b.parents[d]].children_d)]=c;for(d=0,e=b.children.length;e>d;d++)f[b.children[d]].parent=c;for(d=0,e=b.children_d.length;e>d;d++)f[b.children_d[d]].parents[a.inArray(b.id,f[b.children_d[d]].parents)]=c;return d=a.inArray(b.id,this._data.core.selected),-1!==d&&(this._data.core.selected[d]=c),d=this.get_node(b.id,!0),d&&(d.attr("id",c),this.element.attr("aria-activedescendant")===b.id&&this.element.attr("aria-activedescendant",c)),delete f[b.id],b.id=c,b.li_attr.id=c,f[c]=b,this.trigger("set_id",{node:b,"new":b.id,old:g}),!0},get_text:function(b){return b=this.get_node(b),b&&b.id!==a.jstree.root?b.text:!1},set_text:function(b,c){var d,e;if(a.isArray(b)){for(b=b.slice(),d=0,e=b.length;e>d;d++)this.set_text(b[d],c);return!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?(b.text=c,this.get_node(b,!0).length&&this.redraw_node(b.id),this.trigger("set_text",{obj:b,text:c}),!0):!1},get_json:function(b,c,d){if(b=this.get_node(b||a.jstree.root),!b)return!1;c&&c.flat&&!d&&(d=[]);var e={id:b.id,text:b.text,icon:this.get_icon(b),li_attr:a.extend(!0,{},b.li_attr),a_attr:a.extend(!0,{},b.a_attr),state:{},data:c&&c.no_data?!1:a.extend(!0,a.isArray(b.data)?[]:{},b.data)},f,g;if(c&&c.flat?e.parent=b.parent:e.children=[],c&&c.no_state)delete e.state;else for(f in b.state)b.state.hasOwnProperty(f)&&(e.state[f]=b.state[f]);if(c&&c.no_li_attr&&delete e.li_attr,c&&c.no_a_attr&&delete e.a_attr,c&&c.no_id&&(delete e.id,e.li_attr&&e.li_attr.id&&delete e.li_attr.id,e.a_attr&&e.a_attr.id&&delete e.a_attr.id),c&&c.flat&&b.id!==a.jstree.root&&d.push(e),!c||!c.no_children)for(f=0,g=b.children.length;g>f;f++)c&&c.flat?this.get_json(b.children[f],c,d):e.children.push(this.get_json(b.children[f],c));return c&&c.flat?d:b.id===a.jstree.root?e.children:e},create_node:function(c,d,e,f,g){if(null===c&&(c=a.jstree.root),c=this.get_node(c),!c)return!1;if(e=e===b?"last":e,!e.toString().match(/^(before|after)$/)&&!g&&!this.is_loaded(c))return this.load_node(c,function(){this.create_node(c,d,e,f,!0)});d||(d={text:this.get_string("New node")}),d="string"==typeof d?{text:d}:a.extend(!0,{},d),d.text===b&&(d.text=this.get_string("New node"));var h,i,j,k;switch(c.id===a.jstree.root&&("before"===e&&(e="first"),"after"===e&&(e="last")),e){case"before":h=this.get_node(c.parent),e=a.inArray(c.id,h.children),c=h;break;case"after":h=this.get_node(c.parent),e=a.inArray(c.id,h.children)+1,c=h;break;case"inside":case"first":e=0;break;case"last":e=c.children.length;break;default:e||(e=0)}if(e>c.children.length&&(e=c.children.length),d.id||(d.id=!0),!this.check("create_node",d,c,e))return this.settings.core.error.call(this,this._data.core.last_error),!1;if(d.id===!0&&delete d.id,d=this._parse_model_from_json(d,c.id,c.parents.concat()),!d)return!1;for(h=this.get_node(d),i=[],i.push(d),i=i.concat(h.children_d),this.trigger("model",{nodes:i,parent:c.id}),c.children_d=c.children_d.concat(i),j=0,k=c.parents.length;k>j;j++)this._model.data[c.parents[j]].children_d=this._model.data[c.parents[j]].children_d.concat(i);for(d=h,h=[],j=0,k=c.children.length;k>j;j++)h[j>=e?j+1:j]=c.children[j];return h[e]=d.id,c.children=h,this.redraw_node(c,!0),this.trigger("create_node",{node:this.get_node(d),parent:c.id,position:e}),f&&f.call(this,this.get_node(d)),d.id},rename_node:function(b,c){var d,e,f;if(a.isArray(b)){for(b=b.slice(),d=0,e=b.length;e>d;d++)this.rename_node(b[d],c);return!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?(f=b.text,this.check("rename_node",b,this.get_parent(b),c)?(this.set_text(b,c),this.trigger("rename_node",{node:b,text:c,old:f}),!0):(this.settings.core.error.call(this,this._data.core.last_error),!1)):!1},delete_node:function(b){var c,d,e,f,g,h,i,j,k,l,m,n;if(a.isArray(b)){for(b=b.slice(),c=0,d=b.length;d>c;c++)this.delete_node(b[c]);return!0}if(b=this.get_node(b),!b||b.id===a.jstree.root)return!1;if(e=this.get_node(b.parent),f=a.inArray(b.id,e.children),l=!1,!this.check("delete_node",b,e,f))return this.settings.core.error.call(this,this._data.core.last_error),!1;for(-1!==f&&(e.children=a.vakata.array_remove(e.children,f)),g=b.children_d.concat([]),g.push(b.id),h=0,i=b.parents.length;i>h;h++)this._model.data[b.parents[h]].children_d=a.vakata.array_filter(this._model.data[b.parents[h]].children_d,function(b){return-1===a.inArray(b,g)});for(j=0,k=g.length;k>j;j++)if(this._model.data[g[j]].state.selected){l=!0;break}for(l&&(this._data.core.selected=a.vakata.array_filter(this._data.core.selected,function(b){return-1===a.inArray(b,g)})),this.trigger("delete_node",{node:b,parent:e.id}),l&&this.trigger("changed",{action:"delete_node",node:b,selected:this._data.core.selected,parent:e.id}),j=0,k=g.length;k>j;j++)delete this._model.data[g[j]];return-1!==a.inArray(this._data.core.focused,g)&&(this._data.core.focused=null,m=this.element[0].scrollTop,n=this.element[0].scrollLeft,e.id===a.jstree.root?this._model.data[a.jstree.root].children[0]&&this.get_node(this._model.data[a.jstree.root].children[0],!0).children(".jstree-anchor").focus():this.get_node(e,!0).children(".jstree-anchor").focus(),this.element[0].scrollTop=m,this.element[0].scrollLeft=n),this.redraw_node(e,!0),!0},check:function(b,c,d,e,f){c=c&&c.id?c:this.get_node(c),d=d&&d.id?d:this.get_node(d);var g=b.match(/^move_node|copy_node|create_node$/i)?d:c,h=this.settings.core.check_callback;return"move_node"!==b&&"copy_node"!==b||f&&f.is_multi||c.id!==d.id&&("move_node"!==b||a.inArray(c.id,d.children)!==e)&&-1===a.inArray(d.id,c.children_d)?(g&&g.data&&(g=g.data),g&&g.functions&&(g.functions[b]===!1||g.functions[b]===!0)?(g.functions[b]===!1&&(this._data.core.last_error={error:"check",plugin:"core",id:"core_02",reason:"Node data prevents function: "+b,data:JSON.stringify({chk:b,pos:e,obj:c&&c.id?c.id:!1,par:d&&d.id?d.id:!1})}),g.functions[b]):h===!1||a.isFunction(h)&&h.call(this,b,c,d,e,f)===!1||h&&h[b]===!1?(this._data.core.last_error={error:"check",plugin:"core",id:"core_03",reason:"User config for core.check_callback prevents function: "+b,data:JSON.stringify({chk:b,pos:e,obj:c&&c.id?c.id:!1,par:d&&d.id?d.id:!1})},!1):!0):(this._data.core.last_error={error:"check",plugin:"core",id:"core_01",reason:"Moving parent inside child",data:JSON.stringify({chk:b,pos:e,obj:c&&c.id?c.id:!1,par:d&&d.id?d.id:!1})},!1)},last_error:function(){return this._data.core.last_error},move_node:function(c,d,e,f,g,h,i){var j,k,l,m,n,o,p,q,r,s,t,u,v,w;if(d=this.get_node(d),e=e===b?0:e,!d)return!1;if(!e.toString().match(/^(before|after)$/)&&!g&&!this.is_loaded(d))return this.load_node(d,function(){this.move_node(c,d,e,f,!0,!1,i)});if(a.isArray(c)){if(1!==c.length){for(j=0,k=c.length;k>j;j++)(r=this.move_node(c[j],d,e,f,g,!1,i))&&(d=r,e="after");return this.redraw(),!0}c=c[0]}if(c=c&&c.id?c:this.get_node(c),!c||c.id===a.jstree.root)return!1;if(l=(c.parent||a.jstree.root).toString(),n=e.toString().match(/^(before|after)$/)&&d.id!==a.jstree.root?this.get_node(d.parent):d,o=i?i:this._model.data[c.id]?this:a.jstree.reference(c.id),p=!o||!o._id||this._id!==o._id,m=o&&o._id&&l&&o._model.data[l]&&o._model.data[l].children?a.inArray(c.id,o._model.data[l].children):-1,o&&o._id&&(c=o._model.data[c.id]),p)return(r=this.copy_node(c,d,e,f,g,!1,i))?(o&&o.delete_node(c),r):!1;switch(d.id===a.jstree.root&&("before"===e&&(e="first"),"after"===e&&(e="last")),e){case"before":e=a.inArray(d.id,n.children);break;case"after":e=a.inArray(d.id,n.children)+1;break;case"inside":case"first":e=0;break;case"last":e=n.children.length;break;default:e||(e=0)}if(e>n.children.length&&(e=n.children.length),!this.check("move_node",c,n,e,{core:!0,origin:i,is_multi:o&&o._id&&o._id!==this._id,is_foreign:!o||!o._id}))return this.settings.core.error.call(this,this._data.core.last_error),!1;if(c.parent===n.id){for(q=n.children.concat(),r=a.inArray(c.id,q),-1!==r&&(q=a.vakata.array_remove(q,r),e>r&&e--),r=[],s=0,t=q.length;t>s;s++)r[s>=e?s+1:s]=q[s];r[e]=c.id,n.children=r,this._node_changed(n.id),this.redraw(n.id===a.jstree.root)}else{for(r=c.children_d.concat(),r.push(c.id),s=0,t=c.parents.length;t>s;s++){for(q=[],w=o._model.data[c.parents[s]].children_d,u=0,v=w.length;v>u;u++)-1===a.inArray(w[u],r)&&q.push(w[u]);o._model.data[c.parents[s]].children_d=q}for(o._model.data[l].children=a.vakata.array_remove_item(o._model.data[l].children,c.id),s=0,t=n.parents.length;t>s;s++)this._model.data[n.parents[s]].children_d=this._model.data[n.parents[s]].children_d.concat(r);for(q=[],s=0,t=n.children.length;t>s;s++)q[s>=e?s+1:s]=n.children[s];for(q[e]=c.id,n.children=q,n.children_d.push(c.id),n.children_d=n.children_d.concat(c.children_d),c.parent=n.id,r=n.parents.concat(),r.unshift(n.id),w=c.parents.length,c.parents=r,r=r.concat(),s=0,t=c.children_d.length;t>s;s++)this._model.data[c.children_d[s]].parents=this._model.data[c.children_d[s]].parents.slice(0,-1*w),Array.prototype.push.apply(this._model.data[c.children_d[s]].parents,r);(l===a.jstree.root||n.id===a.jstree.root)&&(this._model.force_full_redraw=!0),this._model.force_full_redraw||(this._node_changed(l),this._node_changed(n.id)),h||this.redraw()}return f&&f.call(this,c,n,e),this.trigger("move_node",{node:c,parent:n.id,position:e,old_parent:l,old_position:m,is_multi:o&&o._id&&o._id!==this._id,is_foreign:!o||!o._id,old_instance:o,new_instance:this}),c.id},copy_node:function(c,d,e,f,g,h,i){var j,k,l,m,n,o,p,q,r,s,t;if(d=this.get_node(d),e=e===b?0:e,!d)return!1;if(!e.toString().match(/^(before|after)$/)&&!g&&!this.is_loaded(d))return this.load_node(d,function(){this.copy_node(c,d,e,f,!0,!1,i)});if(a.isArray(c)){if(1!==c.length){for(j=0,k=c.length;k>j;j++)(m=this.copy_node(c[j],d,e,f,g,!0,i))&&(d=m,e="after");return this.redraw(),!0}c=c[0]}if(c=c&&c.id?c:this.get_node(c),!c||c.id===a.jstree.root)return!1;switch(q=(c.parent||a.jstree.root).toString(),r=e.toString().match(/^(before|after)$/)&&d.id!==a.jstree.root?this.get_node(d.parent):d,s=i?i:this._model.data[c.id]?this:a.jstree.reference(c.id),t=!s||!s._id||this._id!==s._id,s&&s._id&&(c=s._model.data[c.id]),d.id===a.jstree.root&&("before"===e&&(e="first"),"after"===e&&(e="last")),e){case"before":e=a.inArray(d.id,r.children);break;case"after":e=a.inArray(d.id,r.children)+1;break;case"inside":case"first":e=0;break;case"last":e=r.children.length;break;default:e||(e=0)}if(e>r.children.length&&(e=r.children.length),!this.check("copy_node",c,r,e,{core:!0,origin:i,is_multi:s&&s._id&&s._id!==this._id,is_foreign:!s||!s._id}))return this.settings.core.error.call(this,this._data.core.last_error),!1;if(p=s?s.get_json(c,{no_id:!0,no_data:!0,no_state:!0}):c,!p)return!1;if(p.id===!0&&delete p.id,p=this._parse_model_from_json(p,r.id,r.parents.concat()),!p)return!1;for(m=this.get_node(p),c&&c.state&&c.state.loaded===!1&&(m.state.loaded=!1),l=[],l.push(p),l=l.concat(m.children_d),this.trigger("model",{nodes:l,parent:r.id}),n=0,o=r.parents.length;o>n;n++)this._model.data[r.parents[n]].children_d=this._model.data[r.parents[n]].children_d.concat(l);for(l=[],n=0,o=r.children.length;o>n;n++)l[n>=e?n+1:n]=r.children[n];return l[e]=m.id,r.children=l,r.children_d.push(m.id),r.children_d=r.children_d.concat(m.children_d),r.id===a.jstree.root&&(this._model.force_full_redraw=!0),this._model.force_full_redraw||this._node_changed(r.id),h||this.redraw(r.id===a.jstree.root),f&&f.call(this,m,r,e),this.trigger("copy_node",{node:m,original:c,parent:r.id,position:e,old_parent:q,old_position:s&&s._id&&q&&s._model.data[q]&&s._model.data[q].children?a.inArray(c.id,s._model.data[q].children):-1,is_multi:s&&s._id&&s._id!==this._id,is_foreign:!s||!s._id,old_instance:s,new_instance:this}),m.id},cut:function(b){if(b||(b=this._data.core.selected.concat()),a.isArray(b)||(b=[b]),!b.length)return!1;var c=[],g,h,i;for(h=0,i=b.length;i>h;h++)g=this.get_node(b[h]),g&&g.id&&g.id!==a.jstree.root&&c.push(g); +return c.length?(d=c,f=this,e="move_node",void this.trigger("cut",{node:b})):!1},copy:function(b){if(b||(b=this._data.core.selected.concat()),a.isArray(b)||(b=[b]),!b.length)return!1;var c=[],g,h,i;for(h=0,i=b.length;i>h;h++)g=this.get_node(b[h]),g&&g.id&&g.id!==a.jstree.root&&c.push(g);return c.length?(d=c,f=this,e="copy_node",void this.trigger("copy",{node:b})):!1},get_buffer:function(){return{mode:e,node:d,inst:f}},can_paste:function(){return e!==!1&&d!==!1},paste:function(a,b){return a=this.get_node(a),a&&e&&e.match(/^(copy_node|move_node)$/)&&d?(this[e](d,a,b,!1,!1,!1,f)&&this.trigger("paste",{parent:a.id,node:d,mode:e}),d=!1,e=!1,void(f=!1)):!1},clear_buffer:function(){d=!1,e=!1,f=!1,this.trigger("clear_buffer")},edit:function(b,c,d){var e,f,g,h,j,k,l,m,n,o=!1;return(b=this.get_node(b))?this.check("edit",b,this.get_parent(b))?(n=b,c="string"==typeof c?c:b.text,this.set_text(b,""),b=this._open_to(b),n.text=c,e=this._data.core.rtl,f=this.element.width(),this._data.core.focused=n.id,g=b.children(".jstree-anchor").focus(),h=a(""),j=c,k=a("
      ",{css:{position:"absolute",top:"-200px",left:e?"0px":"-1000px",visibility:"hidden"}}).appendTo(i.body),l=a("",{value:j,"class":"jstree-rename-input",css:{padding:"0",border:"1px solid silver","box-sizing":"border-box",display:"inline-block",height:this._data.core.li_height+"px",lineHeight:this._data.core.li_height+"px",width:"150px"},blur:a.proxy(function(c){c.stopImmediatePropagation(),c.preventDefault();var e=h.children(".jstree-rename-input"),f=e.val(),i=this.settings.core.force_text,m;""===f&&(f=j),k.remove(),h.replaceWith(g),h.remove(),j=i?j:a("
      ").append(a.parseHTML(j)).html(),b=this.get_node(b),this.set_text(b,j),m=!!this.rename_node(b,i?a("
      ").text(f).text():a("
      ").append(a.parseHTML(f)).html()),m||this.set_text(b,j),this._data.core.focused=n.id,setTimeout(a.proxy(function(){var a=this.get_node(n.id,!0);a.length&&(this._data.core.focused=n.id,a.children(".jstree-anchor").focus())},this),0),d&&d.call(this,n,m,o),l=null},this),keydown:function(a){var b=a.which;27===b&&(o=!0,this.value=j),(27===b||13===b||37===b||38===b||39===b||40===b||32===b)&&a.stopImmediatePropagation(),(27===b||13===b)&&(a.preventDefault(),this.blur())},click:function(a){a.stopImmediatePropagation()},mousedown:function(a){a.stopImmediatePropagation()},keyup:function(a){l.width(Math.min(k.text("pW"+this.value).width(),f))},keypress:function(a){return 13===a.which?!1:void 0}}),m={fontFamily:g.css("fontFamily")||"",fontSize:g.css("fontSize")||"",fontWeight:g.css("fontWeight")||"",fontStyle:g.css("fontStyle")||"",fontStretch:g.css("fontStretch")||"",fontVariant:g.css("fontVariant")||"",letterSpacing:g.css("letterSpacing")||"",wordSpacing:g.css("wordSpacing")||""},h.attr("class",g.attr("class")).append(g.contents().clone()).append(l),g.replaceWith(h),k.css(m),l.css(m).width(Math.min(k.text("pW"+l[0].value).width(),f))[0].select(),void a(i).one("mousedown.jstree touchstart.jstree dnd_start.vakata",function(b){l&&b.target!==l&&a(l).blur()})):(this.settings.core.error.call(this,this._data.core.last_error),!1):!1},set_theme:function(b,c){if(!b)return!1;if(c===!0){var d=this.settings.core.themes.dir;d||(d=a.jstree.path+"/themes"),c=d+"/"+b+"/style.css"}c&&-1===a.inArray(c,g)&&(a("head").append(''),g.push(c)),this._data.core.themes.name&&this.element.removeClass("jstree-"+this._data.core.themes.name),this._data.core.themes.name=b,this.element.addClass("jstree-"+b),this.element[this.settings.core.themes.responsive?"addClass":"removeClass"]("jstree-"+b+"-responsive"),this.trigger("set_theme",{theme:b})},get_theme:function(){return this._data.core.themes.name},set_theme_variant:function(a){this._data.core.themes.variant&&this.element.removeClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant),this._data.core.themes.variant=a,a&&this.element.addClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant)},get_theme_variant:function(){return this._data.core.themes.variant},show_stripes:function(){this._data.core.themes.stripes=!0,this.get_container_ul().addClass("jstree-striped"),this.trigger("show_stripes")},hide_stripes:function(){this._data.core.themes.stripes=!1,this.get_container_ul().removeClass("jstree-striped"),this.trigger("hide_stripes")},toggle_stripes:function(){this._data.core.themes.stripes?this.hide_stripes():this.show_stripes()},show_dots:function(){this._data.core.themes.dots=!0,this.get_container_ul().removeClass("jstree-no-dots"),this.trigger("show_dots")},hide_dots:function(){this._data.core.themes.dots=!1,this.get_container_ul().addClass("jstree-no-dots"),this.trigger("hide_dots")},toggle_dots:function(){this._data.core.themes.dots?this.hide_dots():this.show_dots()},show_icons:function(){this._data.core.themes.icons=!0,this.get_container_ul().removeClass("jstree-no-icons"),this.trigger("show_icons")},hide_icons:function(){this._data.core.themes.icons=!1,this.get_container_ul().addClass("jstree-no-icons"),this.trigger("hide_icons")},toggle_icons:function(){this._data.core.themes.icons?this.hide_icons():this.show_icons()},show_ellipsis:function(){this._data.core.themes.ellipsis=!0,this.get_container_ul().addClass("jstree-ellipsis"),this.trigger("show_ellipsis")},hide_ellipsis:function(){this._data.core.themes.ellipsis=!1,this.get_container_ul().removeClass("jstree-ellipsis"),this.trigger("hide_ellipsis")},toggle_ellipsis:function(){this._data.core.themes.ellipsis?this.hide_ellipsis():this.show_ellipsis()},set_icon:function(c,d){var e,f,g,h;if(a.isArray(c)){for(c=c.slice(),e=0,f=c.length;f>e;e++)this.set_icon(c[e],d);return!0}return c=this.get_node(c),c&&c.id!==a.jstree.root?(h=c.icon,c.icon=d===!0||null===d||d===b||""===d?!0:d,g=this.get_node(c,!0).children(".jstree-anchor").children(".jstree-themeicon"),d===!1?(g.removeClass("jstree-themeicon-custom "+h).css("background","").removeAttr("rel"),this.hide_icon(c)):d===!0||null===d||d===b||""===d?(g.removeClass("jstree-themeicon-custom "+h).css("background","").removeAttr("rel"),h===!1&&this.show_icon(c)):-1===d.indexOf("/")&&-1===d.indexOf(".")?(g.removeClass(h).css("background",""),g.addClass(d+" jstree-themeicon-custom").attr("rel",d),h===!1&&this.show_icon(c)):(g.removeClass(h).css("background",""),g.addClass("jstree-themeicon-custom").css("background","url('"+d+"') center center no-repeat").attr("rel",d),h===!1&&this.show_icon(c)),!0):!1},get_icon:function(b){return b=this.get_node(b),b&&b.id!==a.jstree.root?b.icon:!1},hide_icon:function(b){var c,d;if(a.isArray(b)){for(b=b.slice(),c=0,d=b.length;d>c;c++)this.hide_icon(b[c]);return!0}return b=this.get_node(b),b&&b!==a.jstree.root?(b.icon=!1,this.get_node(b,!0).children(".jstree-anchor").children(".jstree-themeicon").addClass("jstree-themeicon-hidden"),!0):!1},show_icon:function(b){var c,d,e;if(a.isArray(b)){for(b=b.slice(),c=0,d=b.length;d>c;c++)this.show_icon(b[c]);return!0}return b=this.get_node(b),b&&b!==a.jstree.root?(e=this.get_node(b,!0),b.icon=e.length?e.children(".jstree-anchor").children(".jstree-themeicon").attr("rel"):!0,b.icon||(b.icon=!0),e.children(".jstree-anchor").children(".jstree-themeicon").removeClass("jstree-themeicon-hidden"),!0):!1}},a.vakata={},a.vakata.attributes=function(b,c){b=a(b)[0];var d=c?{}:[];return b&&b.attributes&&a.each(b.attributes,function(b,e){-1===a.inArray(e.name.toLowerCase(),["style","contenteditable","hasfocus","tabindex"])&&null!==e.value&&""!==a.trim(e.value)&&(c?d[e.name]=e.value:d.push(e.name))}),d},a.vakata.array_unique=function(a){var c=[],d,e,f,g={};for(d=0,f=a.length;f>d;d++)g[a[d]]===b&&(c.push(a[d]),g[a[d]]=!0);return c},a.vakata.array_remove=function(a,b){return a.splice(b,1),a},a.vakata.array_remove_item=function(b,c){var d=a.inArray(c,b);return-1!==d?a.vakata.array_remove(b,d):b},a.vakata.array_filter=function(a,b,c,d,e){if(a.filter)return a.filter(b,c);d=[];for(e in a)~~e+""==e+""&&e>=0&&b.call(c,a[e],+e,a)&&d.push(a[e]);return d},a.jstree.plugins.changed=function(a,b){var c=[];this.trigger=function(a,d){var e,f;if(d||(d={}),"changed"===a.replace(".jstree","")){d.changed={selected:[],deselected:[]};var g={};for(e=0,f=c.length;f>e;e++)g[c[e]]=1;for(e=0,f=d.selected.length;f>e;e++)g[d.selected[e]]?g[d.selected[e]]=2:d.changed.selected.push(d.selected[e]);for(e=0,f=c.length;f>e;e++)1===g[c[e]]&&d.changed.deselected.push(c[e]);c=d.selected.slice()}b.trigger.call(this,a,d)},this.refresh=function(a,d){return c=[],b.refresh.apply(this,arguments)}};var j=i.createElement("I");j.className="jstree-icon jstree-checkbox",j.setAttribute("role","presentation"),a.jstree.defaults.checkbox={visible:!0,three_state:!0,whole_node:!0,keep_selected_style:!0,cascade:"",tie_selection:!0,cascade_to_disabled:!0,cascade_to_hidden:!0},a.jstree.plugins.checkbox=function(c,d){this.bind=function(){d.bind.call(this),this._data.checkbox.uto=!1,this._data.checkbox.selected=[],this.settings.checkbox.three_state&&(this.settings.checkbox.cascade="up+down+undetermined"),this.element.on("init.jstree",a.proxy(function(){this._data.checkbox.visible=this.settings.checkbox.visible,this.settings.checkbox.keep_selected_style||this.element.addClass("jstree-checkbox-no-clicked"),this.settings.checkbox.tie_selection&&this.element.addClass("jstree-checkbox-selection")},this)).on("loading.jstree",a.proxy(function(){this[this._data.checkbox.visible?"show_checkboxes":"hide_checkboxes"]()},this)),-1!==this.settings.checkbox.cascade.indexOf("undetermined")&&this.element.on("changed.jstree uncheck_node.jstree check_node.jstree uncheck_all.jstree check_all.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree",a.proxy(function(){this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(a.proxy(this._undetermined,this),50)},this)),this.settings.checkbox.tie_selection||this.element.on("model.jstree",a.proxy(function(a,b){var c=this._model.data,d=c[b.parent],e=b.nodes,f,g;for(f=0,g=e.length;g>f;f++)c[e[f]].state.checked=c[e[f]].state.checked||c[e[f]].original&&c[e[f]].original.state&&c[e[f]].original.state.checked,c[e[f]].state.checked&&this._data.checkbox.selected.push(e[f])},this)),(-1!==this.settings.checkbox.cascade.indexOf("up")||-1!==this.settings.checkbox.cascade.indexOf("down"))&&this.element.on("model.jstree",a.proxy(function(b,c){var d=this._model.data,e=d[c.parent],f=c.nodes,g=[],h,i,j,k,l,m,n=this.settings.checkbox.cascade,o=this.settings.checkbox.tie_selection;if(-1!==n.indexOf("down"))if(e.state[o?"selected":"checked"]){for(i=0,j=f.length;j>i;i++)d[f[i]].state[o?"selected":"checked"]=!0;this._data[o?"core":"checkbox"].selected=this._data[o?"core":"checkbox"].selected.concat(f)}else for(i=0,j=f.length;j>i;i++)if(d[f[i]].state[o?"selected":"checked"]){for(k=0,l=d[f[i]].children_d.length;l>k;k++)d[d[f[i]].children_d[k]].state[o?"selected":"checked"]=!0;this._data[o?"core":"checkbox"].selected=this._data[o?"core":"checkbox"].selected.concat(d[f[i]].children_d)}if(-1!==n.indexOf("up")){for(i=0,j=e.children_d.length;j>i;i++)d[e.children_d[i]].children.length||g.push(d[e.children_d[i]].parent);for(g=a.vakata.array_unique(g),k=0,l=g.length;l>k;k++){e=d[g[k]];while(e&&e.id!==a.jstree.root){for(h=0,i=0,j=e.children.length;j>i;i++)h+=d[e.children[i]].state[o?"selected":"checked"];if(h!==j)break;e.state[o?"selected":"checked"]=!0,this._data[o?"core":"checkbox"].selected.push(e.id),m=this.get_node(e,!0),m&&m.length&&m.attr("aria-selected",!0).children(".jstree-anchor").addClass(o?"jstree-clicked":"jstree-checked"),e=this.get_node(e.parent)}}}this._data[o?"core":"checkbox"].selected=a.vakata.array_unique(this._data[o?"core":"checkbox"].selected)},this)).on(this.settings.checkbox.tie_selection?"select_node.jstree":"check_node.jstree",a.proxy(function(b,c){var d=this,e=c.node,f=this._model.data,g=this.get_node(e.parent),h,i,j,k,l=this.settings.checkbox.cascade,m=this.settings.checkbox.tie_selection,n={},o=this._data[m?"core":"checkbox"].selected;for(h=0,i=o.length;i>h;h++)n[o[h]]=!0;if(-1!==l.indexOf("down")){var p=this._cascade_new_checked_state(e.id,!0),q=e.children_d.concat(e.id);for(h=0,i=q.length;i>h;h++)p.indexOf(q[h])>-1?n[q[h]]=!0:delete n[q[h]]}if(-1!==l.indexOf("up"))while(g&&g.id!==a.jstree.root){for(j=0,h=0,i=g.children.length;i>h;h++)j+=f[g.children[h]].state[m?"selected":"checked"];if(j!==i)break;g.state[m?"selected":"checked"]=!0,n[g.id]=!0,k=this.get_node(g,!0),k&&k.length&&k.attr("aria-selected",!0).children(".jstree-anchor").addClass(m?"jstree-clicked":"jstree-checked"),g=this.get_node(g.parent)}o=[];for(h in n)n.hasOwnProperty(h)&&o.push(h);this._data[m?"core":"checkbox"].selected=o},this)).on(this.settings.checkbox.tie_selection?"deselect_all.jstree":"uncheck_all.jstree",a.proxy(function(b,c){var d=this.get_node(a.jstree.root),e=this._model.data,f,g,h;for(f=0,g=d.children_d.length;g>f;f++)h=e[d.children_d[f]],h&&h.original&&h.original.state&&h.original.state.undetermined&&(h.original.state.undetermined=!1)},this)).on(this.settings.checkbox.tie_selection?"deselect_node.jstree":"uncheck_node.jstree",a.proxy(function(a,b){var c=this,d=b.node,e=this.get_node(d,!0),f,g,h,i=this.settings.checkbox.cascade,j=this.settings.checkbox.tie_selection,k=this._data[j?"core":"checkbox"].selected,l={},m=[],n=d.children_d.concat(d.id);if(-1!==i.indexOf("down")){var o=this._cascade_new_checked_state(d.id,!1);k=k.filter(function(a){return-1===n.indexOf(a)||o.indexOf(a)>-1})}if(-1!==i.indexOf("up")&&-1===k.indexOf(d.id)){for(f=0,g=d.parents.length;g>f;f++)h=this._model.data[d.parents[f]],h.state[j?"selected":"checked"]=!1,h&&h.original&&h.original.state&&h.original.state.undetermined&&(h.original.state.undetermined=!1),h=this.get_node(d.parents[f],!0),h&&h.length&&h.attr("aria-selected",!1).children(".jstree-anchor").removeClass(j?"jstree-clicked":"jstree-checked");k=k.filter(function(a){return-1===d.parents.indexOf(a)})}this._data[j?"core":"checkbox"].selected=k},this)),-1!==this.settings.checkbox.cascade.indexOf("up")&&this.element.on("delete_node.jstree",a.proxy(function(b,c){var d=this.get_node(c.parent),e=this._model.data,f,g,h,i,j=this.settings.checkbox.tie_selection;while(d&&d.id!==a.jstree.root&&!d.state[j?"selected":"checked"]){for(h=0,f=0,g=d.children.length;g>f;f++)h+=e[d.children[f]].state[j?"selected":"checked"];if(!(g>0&&h===g))break;d.state[j?"selected":"checked"]=!0,this._data[j?"core":"checkbox"].selected.push(d.id),i=this.get_node(d,!0),i&&i.length&&i.attr("aria-selected",!0).children(".jstree-anchor").addClass(j?"jstree-clicked":"jstree-checked"),d=this.get_node(d.parent)}},this)).on("move_node.jstree",a.proxy(function(b,c){var d=c.is_multi,e=c.old_parent,f=this.get_node(c.parent),g=this._model.data,h,i,j,k,l,m=this.settings.checkbox.tie_selection;if(!d){h=this.get_node(e);while(h&&h.id!==a.jstree.root&&!h.state[m?"selected":"checked"]){for(i=0,j=0,k=h.children.length;k>j;j++)i+=g[h.children[j]].state[m?"selected":"checked"];if(!(k>0&&i===k))break;h.state[m?"selected":"checked"]=!0,this._data[m?"core":"checkbox"].selected.push(h.id),l=this.get_node(h,!0),l&&l.length&&l.attr("aria-selected",!0).children(".jstree-anchor").addClass(m?"jstree-clicked":"jstree-checked"),h=this.get_node(h.parent)}}h=f;while(h&&h.id!==a.jstree.root){for(i=0,j=0,k=h.children.length;k>j;j++)i+=g[h.children[j]].state[m?"selected":"checked"];if(i===k)h.state[m?"selected":"checked"]||(h.state[m?"selected":"checked"]=!0,this._data[m?"core":"checkbox"].selected.push(h.id),l=this.get_node(h,!0),l&&l.length&&l.attr("aria-selected",!0).children(".jstree-anchor").addClass(m?"jstree-clicked":"jstree-checked"));else{if(!h.state[m?"selected":"checked"])break;h.state[m?"selected":"checked"]=!1,this._data[m?"core":"checkbox"].selected=a.vakata.array_remove_item(this._data[m?"core":"checkbox"].selected,h.id),l=this.get_node(h,!0),l&&l.length&&l.attr("aria-selected",!1).children(".jstree-anchor").removeClass(m?"jstree-clicked":"jstree-checked")}h=this.get_node(h.parent)}},this))},this.get_undetermined=function(c){if(-1===this.settings.checkbox.cascade.indexOf("undetermined"))return[];var d,e,f,g,h={},i=this._model.data,j=this.settings.checkbox.tie_selection,k=this._data[j?"core":"checkbox"].selected,l=[],m=this,n=[];for(d=0,e=k.length;e>d;d++)if(i[k[d]]&&i[k[d]].parents)for(f=0,g=i[k[d]].parents.length;g>f;f++){if(h[i[k[d]].parents[f]]!==b)break;i[k[d]].parents[f]!==a.jstree.root&&(h[i[k[d]].parents[f]]=!0,l.push(i[k[d]].parents[f]))}for(this.element.find(".jstree-closed").not(":has(.jstree-children)").each(function(){var c=m.get_node(this),j;if(c)if(c.state.loaded){for(d=0,e=c.children_d.length;e>d;d++)if(j=i[c.children_d[d]],!j.state.loaded&&j.original&&j.original.state&&j.original.state.undetermined&&j.original.state.undetermined===!0)for(h[j.id]===b&&j.id!==a.jstree.root&&(h[j.id]=!0,l.push(j.id)),f=0,g=j.parents.length;g>f;f++)h[j.parents[f]]===b&&j.parents[f]!==a.jstree.root&&(h[j.parents[f]]=!0,l.push(j.parents[f]))}else if(c.original&&c.original.state&&c.original.state.undetermined&&c.original.state.undetermined===!0)for(h[c.id]===b&&c.id!==a.jstree.root&&(h[c.id]=!0,l.push(c.id)),f=0,g=c.parents.length;g>f;f++)h[c.parents[f]]===b&&c.parents[f]!==a.jstree.root&&(h[c.parents[f]]=!0,l.push(c.parents[f]))}),d=0,e=l.length;e>d;d++)i[l[d]].state[j?"selected":"checked"]||n.push(c?i[l[d]]:l[d]);return n},this._undetermined=function(){if(null!==this.element){var a=this.get_undetermined(!1),b,c,d;for(this.element.find(".jstree-undetermined").removeClass("jstree-undetermined"),b=0,c=a.length;c>b;b++)d=this.get_node(a[b],!0),d&&d.length&&d.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-undetermined")}},this.redraw_node=function(b,c,e,f){if(b=d.redraw_node.apply(this,arguments)){var g,h,i=null,k=null;for(g=0,h=b.childNodes.length;h>g;g++)if(b.childNodes[g]&&b.childNodes[g].className&&-1!==b.childNodes[g].className.indexOf("jstree-anchor")){i=b.childNodes[g];break}i&&(!this.settings.checkbox.tie_selection&&this._model.data[b.id].state.checked&&(i.className+=" jstree-checked"),k=j.cloneNode(!1),this._model.data[b.id].state.checkbox_disabled&&(k.className+=" jstree-checkbox-disabled"),i.insertBefore(k,i.childNodes[0]))}return e||-1===this.settings.checkbox.cascade.indexOf("undetermined")||(this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(a.proxy(this._undetermined,this),50)),b},this.show_checkboxes=function(){this._data.core.themes.checkboxes=!0,this.get_container_ul().removeClass("jstree-no-checkboxes")},this.hide_checkboxes=function(){this._data.core.themes.checkboxes=!1,this.get_container_ul().addClass("jstree-no-checkboxes")},this.toggle_checkboxes=function(){this._data.core.themes.checkboxes?this.hide_checkboxes():this.show_checkboxes()},this.is_undetermined=function(b){b=this.get_node(b);var c=this.settings.checkbox.cascade,d,e,f=this.settings.checkbox.tie_selection,g=this._data[f?"core":"checkbox"].selected,h=this._model.data;if(!b||b.state[f?"selected":"checked"]===!0||-1===c.indexOf("undetermined")||-1===c.indexOf("down")&&-1===c.indexOf("up"))return!1;if(!b.state.loaded&&b.original.state.undetermined===!0)return!0;for(d=0,e=b.children_d.length;e>d;d++)if(-1!==a.inArray(b.children_d[d],g)||!h[b.children_d[d]].state.loaded&&h[b.children_d[d]].original.state.undetermined)return!0;return!1},this.disable_checkbox=function(b){var c,d,e;if(a.isArray(b)){for(b=b.slice(),c=0,d=b.length;d>c;c++)this.disable_checkbox(b[c]);return!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?(e=this.get_node(b,!0),void(b.state.checkbox_disabled||(b.state.checkbox_disabled=!0,e&&e.length&&e.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-checkbox-disabled"),this.trigger("disable_checkbox",{node:b})))):!1},this.enable_checkbox=function(b){var c,d,e;if(a.isArray(b)){for(b=b.slice(),c=0,d=b.length;d>c;c++)this.enable_checkbox(b[c]);return!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?(e=this.get_node(b,!0),void(b.state.checkbox_disabled&&(b.state.checkbox_disabled=!1,e&&e.length&&e.children(".jstree-anchor").children(".jstree-checkbox").removeClass("jstree-checkbox-disabled"),this.trigger("enable_checkbox",{node:b})))):!1},this.activate_node=function(b,c){return a(c.target).hasClass("jstree-checkbox-disabled")?!1:(this.settings.checkbox.tie_selection&&(this.settings.checkbox.whole_node||a(c.target).hasClass("jstree-checkbox"))&&(c.ctrlKey=!0),this.settings.checkbox.tie_selection||!this.settings.checkbox.whole_node&&!a(c.target).hasClass("jstree-checkbox")?d.activate_node.call(this,b,c):this.is_disabled(b)?!1:(this.is_checked(b)?this.uncheck_node(b,c):this.check_node(b,c),void this.trigger("activate_node",{node:this.get_node(b)})))},this._cascade_new_checked_state=function(a,b){var c=this,d=this.settings.checkbox.tie_selection,e=this._model.data[a],f=[],g=[],h,i,j;if(!this.settings.checkbox.cascade_to_disabled&&e.state.disabled||!this.settings.checkbox.cascade_to_hidden&&e.state.hidden)j=this.get_checked_descendants(a),e.state[d?"selected":"checked"]&&j.push(e.id),f=f.concat(j);else{if(e.children)for(h=0,i=e.children.length;i>h;h++){var k=e.children[h];j=c._cascade_new_checked_state(k,b),f=f.concat(j),j.indexOf(k)>-1&&g.push(k)}var l=c.get_node(e,!0),m=g.length>0&&g.lengthe;e++)this.check_node(b[e],c);return!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?(d=this.get_node(b,!0),void(b.state.checked||(b.state.checked=!0,this._data.checkbox.selected.push(b.id),d&&d.length&&d.children(".jstree-anchor").addClass("jstree-checked"),this.trigger("check_node",{node:b,selected:this._data.checkbox.selected,event:c})))):!1},this.uncheck_node=function(b,c){if(this.settings.checkbox.tie_selection)return this.deselect_node(b,!1,c);var d,e,f;if(a.isArray(b)){for(b=b.slice(),d=0,e=b.length;e>d;d++)this.uncheck_node(b[d],c);return!0}return b=this.get_node(b),b&&b.id!==a.jstree.root?(f=this.get_node(b,!0),void(b.state.checked&&(b.state.checked=!1,this._data.checkbox.selected=a.vakata.array_remove_item(this._data.checkbox.selected,b.id),f.length&&f.children(".jstree-anchor").removeClass("jstree-checked"),this.trigger("uncheck_node",{node:b,selected:this._data.checkbox.selected,event:c})))):!1},this.check_all=function(){if(this.settings.checkbox.tie_selection)return this.select_all();var b=this._data.checkbox.selected.concat([]),c,d;for(this._data.checkbox.selected=this._model.data[a.jstree.root].children_d.concat(),c=0,d=this._data.checkbox.selected.length;d>c;c++)this._model.data[this._data.checkbox.selected[c]]&&(this._model.data[this._data.checkbox.selected[c]].state.checked=!0);this.redraw(!0),this.trigger("check_all",{selected:this._data.checkbox.selected})},this.uncheck_all=function(){if(this.settings.checkbox.tie_selection)return this.deselect_all();var a=this._data.checkbox.selected.concat([]),b,c;for(b=0,c=this._data.checkbox.selected.length;c>b;b++)this._model.data[this._data.checkbox.selected[b]]&&(this._model.data[this._data.checkbox.selected[b]].state.checked=!1);this._data.checkbox.selected=[],this.element.find(".jstree-checked").removeClass("jstree-checked"),this.trigger("uncheck_all",{selected:this._data.checkbox.selected,node:a})},this.is_checked=function(b){return this.settings.checkbox.tie_selection?this.is_selected(b):(b=this.get_node(b),b&&b.id!==a.jstree.root?b.state.checked:!1)},this.get_checked=function(b){return this.settings.checkbox.tie_selection?this.get_selected(b):b?a.map(this._data.checkbox.selected,a.proxy(function(a){return this.get_node(a)},this)):this._data.checkbox.selected},this.get_top_checked=function(b){if(this.settings.checkbox.tie_selection)return this.get_top_selected(b);var c=this.get_checked(!0),d={},e,f,g,h;for(e=0,f=c.length;f>e;e++)d[c[e].id]=c[e];for(e=0,f=c.length;f>e;e++)for(g=0,h=c[e].children_d.length;h>g;g++)d[c[e].children_d[g]]&&delete d[c[e].children_d[g]];c=[];for(e in d)d.hasOwnProperty(e)&&c.push(e);return b?a.map(c,a.proxy(function(a){return this.get_node(a)},this)):c},this.get_bottom_checked=function(b){if(this.settings.checkbox.tie_selection)return this.get_bottom_selected(b);var c=this.get_checked(!0),d=[],e,f;for(e=0,f=c.length;f>e;e++)c[e].children.length||d.push(c[e].id);return b?a.map(d,a.proxy(function(a){return this.get_node(a)},this)):d},this.load_node=function(b,c){var e,f,g,h,i,j;if(!a.isArray(b)&&!this.settings.checkbox.tie_selection&&(j=this.get_node(b),j&&j.state.loaded))for(e=0,f=j.children_d.length;f>e;e++)this._model.data[j.children_d[e]].state.checked&&(i=!0,this._data.checkbox.selected=a.vakata.array_remove_item(this._data.checkbox.selected,j.children_d[e]));return d.load_node.apply(this,arguments)},this.get_state=function(){var a=d.get_state.apply(this,arguments);return this.settings.checkbox.tie_selection?a:(a.checkbox=this._data.checkbox.selected.slice(),a)},this.set_state=function(b,c){var e=d.set_state.apply(this,arguments);if(e&&b.checkbox){if(!this.settings.checkbox.tie_selection){this.uncheck_all();var f=this;a.each(b.checkbox,function(a,b){f.check_node(b)})}return delete b.checkbox,this.set_state(b,c),!1}return e},this.refresh=function(a,b){return this.settings.checkbox.tie_selection&&(this._data.checkbox.selected=[]),d.refresh.apply(this,arguments)}},a.jstree.defaults.conditionalselect=function(){return!0},a.jstree.plugins.conditionalselect=function(a,b){this.activate_node=function(a,c){return this.settings.conditionalselect.call(this,this.get_node(a),c)?b.activate_node.call(this,a,c):void 0}},a.jstree.defaults.contextmenu={select_node:!0,show_at_node:!0,items:function(b,c){return{create:{separator_before:!1,separator_after:!0,_disabled:!1,label:"Create",action:function(b){var c=a.jstree.reference(b.reference),d=c.get_node(b.reference);c.create_node(d,{},"last",function(a){try{c.edit(a)}catch(b){setTimeout(function(){c.edit(a)},0)}})}},rename:{separator_before:!1,separator_after:!1,_disabled:!1,label:"Rename",action:function(b){var c=a.jstree.reference(b.reference),d=c.get_node(b.reference);c.edit(d)}},remove:{separator_before:!1,icon:!1,separator_after:!1,_disabled:!1,label:"Delete",action:function(b){var c=a.jstree.reference(b.reference),d=c.get_node(b.reference);c.is_selected(d)?c.delete_node(c.get_selected()):c.delete_node(d)}},ccp:{separator_before:!0,icon:!1,separator_after:!1,label:"Edit",action:!1,submenu:{cut:{separator_before:!1,separator_after:!1,label:"Cut",action:function(b){var c=a.jstree.reference(b.reference),d=c.get_node(b.reference);c.is_selected(d)?c.cut(c.get_top_selected()):c.cut(d)}},copy:{separator_before:!1,icon:!1,separator_after:!1,label:"Copy",action:function(b){var c=a.jstree.reference(b.reference),d=c.get_node(b.reference);c.is_selected(d)?c.copy(c.get_top_selected()):c.copy(d)}},paste:{separator_before:!1,icon:!1,_disabled:function(b){return!a.jstree.reference(b.reference).can_paste()},separator_after:!1,label:"Paste",action:function(b){var c=a.jstree.reference(b.reference),d=c.get_node(b.reference);c.paste(d)}}}}}}},a.jstree.plugins.contextmenu=function(c,d){this.bind=function(){d.bind.call(this);var b=0,c=null,e,f;this.element.on("init.jstree loading.jstree ready.jstree",a.proxy(function(){this.get_container_ul().addClass("jstree-contextmenu")},this)).on("contextmenu.jstree",".jstree-anchor",a.proxy(function(a,d){"input"!==a.target.tagName.toLowerCase()&&(a.preventDefault(),b=a.ctrlKey?+new Date:0,(d||c)&&(b=+new Date+1e4),c&&clearTimeout(c),this.is_loading(a.currentTarget)||this.show_contextmenu(a.currentTarget,a.pageX,a.pageY,a))},this)).on("click.jstree",".jstree-anchor",a.proxy(function(c){this._data.contextmenu.visible&&(!b||+new Date-b>250)&&a.vakata.context.hide(),b=0},this)).on("touchstart.jstree",".jstree-anchor",function(b){b.originalEvent&&b.originalEvent.changedTouches&&b.originalEvent.changedTouches[0]&&(e=b.originalEvent.changedTouches[0].clientX,f=b.originalEvent.changedTouches[0].clientY,c=setTimeout(function(){a(b.currentTarget).trigger("contextmenu",!0)},750))}).on("touchmove.vakata.jstree",function(b){c&&b.originalEvent&&b.originalEvent.changedTouches&&b.originalEvent.changedTouches[0]&&(Math.abs(e-b.originalEvent.changedTouches[0].clientX)>10||Math.abs(f-b.originalEvent.changedTouches[0].clientY)>10)&&(clearTimeout(c),a.vakata.context.hide())}).on("touchend.vakata.jstree",function(a){c&&clearTimeout(c)}),a(i).on("context_hide.vakata.jstree",a.proxy(function(b,c){this._data.contextmenu.visible=!1,a(c.reference).removeClass("jstree-context")},this))},this.teardown=function(){this._data.contextmenu.visible&&a.vakata.context.hide(),d.teardown.call(this)},this.show_contextmenu=function(c,d,e,f){if(c=this.get_node(c),!c||c.id===a.jstree.root)return!1;var g=this.settings.contextmenu,h=this.get_node(c,!0),i=h.children(".jstree-anchor"),j=!1,k=!1;(g.show_at_node||d===b||e===b)&&(j=i.offset(),d=j.left,e=j.top+this._data.core.li_height),this.settings.contextmenu.select_node&&!this.is_selected(c)&&this.activate_node(c,f),k=g.items,a.isFunction(k)&&(k=k.call(this,c,a.proxy(function(a){this._show_contextmenu(c,d,e,a)},this))),a.isPlainObject(k)&&this._show_contextmenu(c,d,e,k)},this._show_contextmenu=function(b,c,d,e){var f=this.get_node(b,!0),g=f.children(".jstree-anchor");a(i).one("context_show.vakata.jstree",a.proxy(function(b,c){var d="jstree-contextmenu jstree-"+this.get_theme()+"-contextmenu";a(c.element).addClass(d),g.addClass("jstree-context")},this)),this._data.contextmenu.visible=!0,a.vakata.context.show(g,{x:c,y:d},e),this.trigger("show_contextmenu",{node:b,x:c,y:d})}},function(a){var b=!1,c={element:!1,reference:!1,position_x:0,position_y:0,items:[],html:"",is_visible:!1};a.vakata.context={settings:{hide_onmouseleave:0,icons:!0},_trigger:function(b){a(i).triggerHandler("context_"+b+".vakata",{reference:c.reference,element:c.element,position:{x:c.position_x,y:c.position_y}})},_execute:function(b){return b=c.items[b],b&&(!b._disabled||a.isFunction(b._disabled)&&!b._disabled({item:b,reference:c.reference,element:c.element}))&&b.action?b.action.call(null,{item:b,reference:c.reference,element:c.element,position:{x:c.position_x,y:c.position_y}}):!1},_parse:function(b,d){if(!b)return!1;d||(c.html="",c.items=[]);var e="",f=!1,g;return d&&(e+=""),d||(c.html=e,a.vakata.context._trigger("parse")),e.length>10?e:!1},_show_submenu:function(c){if(c=a(c),c.length&&c.children("ul").length){var d=c.children("ul"),e=c.offset().left,f=e+c.outerWidth(),g=c.offset().top,h=d.width(),i=d.height(),j=a(window).width()+a(window).scrollLeft(),k=a(window).height()+a(window).scrollTop();b?c[f-(h+10+c.outerWidth())<0?"addClass":"removeClass"]("vakata-context-left"):c[f+h>j&&e>j-f?"addClass":"removeClass"]("vakata-context-right"),g+i+10>k&&d.css("bottom","-1px"),c.hasClass("vakata-context-right")?h>e&&d.css("margin-right",e-h):h>j-f&&d.css("margin-left",j-f-h),d.show()}},show:function(d,e,f){var g,h,j,k,l,m,n,o,p=!0;switch(c.element&&c.element.length&&c.element.width(""),p){case!e&&!d:return!1;case!!e&&!!d:c.reference=d,c.position_x=e.x,c.position_y=e.y;break;case!e&&!!d:c.reference=d,g=d.offset(),c.position_x=g.left+d.outerHeight(),c.position_y=g.top;break;case!!e&&!d:c.position_x=e.x,c.position_y=e.y}d&&!f&&a(d).data("vakata_contextmenu")&&(f=a(d).data("vakata_contextmenu")),a.vakata.context._parse(f)&&c.element.html(c.html),c.items.length&&(c.element.appendTo(i.body),h=c.element,j=c.position_x,k=c.position_y,l=h.width(),m=h.height(),n=a(window).width()+a(window).scrollLeft(),o=a(window).height()+a(window).scrollTop(),b&&(j-=h.outerWidth()-a(d).outerWidth(),jn&&(j=n-(l+20)),k+m+20>o&&(k=o-(m+20)),c.element.css({left:j,top:k}).show().find("a").first().focus().parent().addClass("vakata-context-hover"),c.is_visible=!0,a.vakata.context._trigger("show"))},hide:function(){c.is_visible&&(c.element.hide().find("ul").hide().end().find(":focus").blur().end().detach(),c.is_visible=!1,a.vakata.context._trigger("hide"))}},a(function(){b="rtl"===a(i.body).css("direction");var d=!1;c.element=a("
        "),c.element.on("mouseenter","li",function(b){b.stopImmediatePropagation(),a.contains(this,b.relatedTarget)||(d&&clearTimeout(d),c.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end(),a(this).siblings().find("ul").hide().end().end().parentsUntil(".vakata-context","li").addBack().addClass("vakata-context-hover"),a.vakata.context._show_submenu(this))}).on("mouseleave","li",function(b){a.contains(this,b.relatedTarget)||a(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover")}).on("mouseleave",function(b){a(this).find(".vakata-context-hover").removeClass("vakata-context-hover"),a.vakata.context.settings.hide_onmouseleave&&(d=setTimeout(function(b){return function(){a.vakata.context.hide()}}(this),a.vakata.context.settings.hide_onmouseleave))}).on("click","a",function(b){b.preventDefault(),a(this).blur().parent().hasClass("vakata-context-disabled")||a.vakata.context._execute(a(this).attr("rel"))===!1||a.vakata.context.hide()}).on("keydown","a",function(b){var d=null;switch(b.which){case 13:case 32:b.type="click",b.preventDefault(),a(b.currentTarget).trigger(b);break;case 37:c.is_visible&&(c.element.find(".vakata-context-hover").last().closest("li").first().find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children("a").focus(),b.stopImmediatePropagation(),b.preventDefault());break;case 38:c.is_visible&&(d=c.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first(),d.length||(d=c.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last()),d.addClass("vakata-context-hover").children("a").focus(),b.stopImmediatePropagation(),b.preventDefault());break;case 39:c.is_visible&&(c.element.find(".vakata-context-hover").last().children("ul").show().children("li:not(.vakata-context-separator)").removeClass("vakata-context-hover").first().addClass("vakata-context-hover").children("a").focus(),b.stopImmediatePropagation(),b.preventDefault());break;case 40:c.is_visible&&(d=c.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first(),d.length||(d=c.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first()),d.addClass("vakata-context-hover").children("a").focus(),b.stopImmediatePropagation(),b.preventDefault());break;case 27:a.vakata.context.hide(),b.preventDefault()}}).on("keydown",function(a){a.preventDefault();var b=c.element.find(".vakata-contextmenu-shortcut-"+a.which).parent();b.parent().not(".vakata-context-disabled")&&b.click()}),a(i).on("mousedown.vakata.jstree",function(b){c.is_visible&&c.element[0]!==b.target&&!a.contains(c.element[0],b.target)&&a.vakata.context.hide()}).on("context_show.vakata.jstree",function(a,d){c.element.find("li:has(ul)").children("a").addClass("vakata-context-parent"),b&&c.element.addClass("vakata-context-rtl").css("direction","rtl"),c.element.find("ul").hide().end()})})}(a),a.jstree.defaults.dnd={copy:!0,open_timeout:500,is_draggable:!0,check_while_dragging:!0,always_copy:!1,inside_pos:0,drag_selection:!0,touch:!0,large_drop_target:!1,large_drag_target:!1,use_html5:!1};var k,l;a.jstree.plugins.dnd=function(b,c){this.init=function(a,b){c.init.call(this,a,b),this.settings.dnd.use_html5=this.settings.dnd.use_html5&&"draggable"in i.createElement("span")},this.bind=function(){c.bind.call(this),this.element.on(this.settings.dnd.use_html5?"dragstart.jstree":"mousedown.jstree touchstart.jstree",this.settings.dnd.large_drag_target?".jstree-node":".jstree-anchor",a.proxy(function(b){if(this.settings.dnd.large_drag_target&&a(b.target).closest(".jstree-node")[0]!==b.currentTarget)return!0;if("touchstart"===b.type&&(!this.settings.dnd.touch||"selected"===this.settings.dnd.touch&&!a(b.currentTarget).closest(".jstree-node").children(".jstree-anchor").hasClass("jstree-clicked")))return!0;var c=this.get_node(b.target),d=this.is_selected(c)&&this.settings.dnd.drag_selection?this.get_top_selected().length:1,e=d>1?d+" "+this.get_string("nodes"):this.get_text(b.currentTarget);if(this.settings.core.force_text&&(e=a.vakata.html.escape(e)),c&&c.id&&c.id!==a.jstree.root&&(1===b.which||"touchstart"===b.type||"dragstart"===b.type)&&(this.settings.dnd.is_draggable===!0||a.isFunction(this.settings.dnd.is_draggable)&&this.settings.dnd.is_draggable.call(this,d>1?this.get_top_selected(!0):[c],b))){if(k={jstree:!0,origin:this,obj:this.get_node(c,!0),nodes:d>1?this.get_top_selected():[c.id]},l=b.currentTarget,!this.settings.dnd.use_html5)return this.element.trigger("mousedown.jstree"),a.vakata.dnd.start(b,k,'
        '+e+'
        ');a.vakata.dnd._trigger("start",b,{helper:a(),element:l,data:k})}},this)),this.settings.dnd.use_html5&&this.element.on("dragover.jstree",function(b){return b.preventDefault(),a.vakata.dnd._trigger("move",b,{helper:a(),element:l,data:k}),!1}).on("drop.jstree",a.proxy(function(b){return b.preventDefault(),a.vakata.dnd._trigger("stop",b,{helper:a(),element:l,data:k}),!1},this))},this.redraw_node=function(a,b,d,e){if(a=c.redraw_node.apply(this,arguments),a&&this.settings.dnd.use_html5)if(this.settings.dnd.large_drag_target)a.setAttribute("draggable",!0);else{var f,g,h=null;for(f=0,g=a.childNodes.length;g>f;f++)if(a.childNodes[f]&&a.childNodes[f].className&&-1!==a.childNodes[f].className.indexOf("jstree-anchor")){h=a.childNodes[f];break}h&&h.setAttribute("draggable",!0)}return a}},a(function(){var c=!1,d=!1,e=!1,f=!1,g=a('
         
        ').hide();a(i).on("dragover.vakata.jstree",function(b){l&&a.vakata.dnd._trigger("move",b,{helper:a(),element:l,data:k})}).on("drop.vakata.jstree",function(b){l&&(a.vakata.dnd._trigger("stop",b,{helper:a(),element:l,data:k}),l=null,k=null)}).on("dnd_start.vakata.jstree",function(a,b){c=!1,e=!1,b&&b.data&&b.data.jstree&&g.appendTo(i.body)}).on("dnd_move.vakata.jstree",function(h,i){var j=i.event.target!==e.target;if(f&&(!i.event||"dragover"!==i.event.type||j)&&clearTimeout(f),i&&i.data&&i.data.jstree&&(!i.event.target.id||"jstree-marker"!==i.event.target.id)){e=i.event;var k=a.jstree.reference(i.event.target),l=!1,m=!1,n=!1,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E;if(k&&k._data&&k._data.dnd)if(g.attr("class","jstree-"+k.get_theme()+(k.settings.core.themes.responsive?" jstree-dnd-responsive":"")),D=i.data.origin&&(i.data.origin.settings.dnd.always_copy||i.data.origin.settings.dnd.copy&&(i.event.metaKey||i.event.ctrlKey)),i.helper.children().attr("class","jstree-"+k.get_theme()+" jstree-"+k.get_theme()+"-"+k.get_theme_variant()+" "+(k.settings.core.themes.responsive?" jstree-dnd-responsive":"")).find(".jstree-copy").first()[D?"show":"hide"](),i.event.target!==k.element[0]&&i.event.target!==k.get_container_ul()[0]||0!==k.get_container_ul().children().length){if(l=k.settings.dnd.large_drop_target?a(i.event.target).closest(".jstree-node").children(".jstree-anchor"):a(i.event.target).closest(".jstree-anchor"),l&&l.length&&l.parent().is(".jstree-closed, .jstree-open, .jstree-leaf")&&(m=l.offset(),n=(i.event.pageY!==b?i.event.pageY:i.event.originalEvent.pageY)-m.top,r=l.outerHeight(),u=r/3>n?["b","i","a"]:n>r-r/3?["a","i","b"]:n>r/2?["i","a","b"]:["i","b","a"],a.each(u,function(b,e){switch(e){case"b":p=m.left-6,q=m.top,s=k.get_parent(l),t=l.parent().index();break;case"i":B=k.settings.dnd.inside_pos,C=k.get_node(l.parent()),p=m.left-2,q=m.top+r/2+1,s=C.id,t="first"===B?0:"last"===B?C.children.length:Math.min(B,C.children.length);break;case"a":p=m.left-6,q=m.top+r,s=k.get_parent(l),t=l.parent().index()+1}for(v=!0,w=0,x=i.data.nodes.length;x>w;w++)if(y=i.data.origin&&(i.data.origin.settings.dnd.always_copy||i.data.origin.settings.dnd.copy&&(i.event.metaKey||i.event.ctrlKey))?"copy_node":"move_node",z=t,"move_node"===y&&"a"===e&&i.data.origin&&i.data.origin===k&&s===k.get_parent(i.data.nodes[w])&&(A=k.get_node(s),z>a.inArray(i.data.nodes[w],A.children)&&(z-=1)),v=v&&(k&&k.settings&&k.settings.dnd&&k.settings.dnd.check_while_dragging===!1||k.check(y,i.data.origin&&i.data.origin!==k?i.data.origin.get_node(i.data.nodes[w]):i.data.nodes[w],s,z,{dnd:!0,ref:k.get_node(l.parent()),pos:e,origin:i.data.origin,is_multi:i.data.origin&&i.data.origin!==k,is_foreign:!i.data.origin})),!v){k&&k.last_error&&(d=k.last_error());break}return"i"===e&&l.parent().is(".jstree-closed")&&k.settings.dnd.open_timeout&&(!i.event||"dragover"!==i.event.type||j)&&(f&&clearTimeout(f),f=setTimeout(function(a,b){return function(){a.open_node(b)}}(k,l),k.settings.dnd.open_timeout)),v?(E=k.get_node(s,!0),E.hasClass(".jstree-dnd-parent")||(a(".jstree-dnd-parent").removeClass("jstree-dnd-parent"),E.addClass("jstree-dnd-parent")),c={ins:k,par:s,pos:"i"!==e||"last"!==B||0!==t||k.is_loaded(C)?t:"last"},g.css({left:p+"px",top:q+"px"}).show(),i.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok"),i.event.originalEvent&&i.event.originalEvent.dataTransfer&&(i.event.originalEvent.dataTransfer.dropEffect=D?"copy":"move"),d={},u=!0,!1):void 0}),u===!0))return}else{for(v=!0,w=0,x=i.data.nodes.length;x>w;w++)if(v=v&&k.check(i.data.origin&&(i.data.origin.settings.dnd.always_copy||i.data.origin.settings.dnd.copy&&(i.event.metaKey||i.event.ctrlKey))?"copy_node":"move_node",i.data.origin&&i.data.origin!==k?i.data.origin.get_node(i.data.nodes[w]):i.data.nodes[w],a.jstree.root,"last",{dnd:!0,ref:k.get_node(a.jstree.root),pos:"i",origin:i.data.origin,is_multi:i.data.origin&&i.data.origin!==k,is_foreign:!i.data.origin}),!v)break;if(v)return c={ins:k,par:a.jstree.root,pos:"last"},g.hide(),i.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok"),void(i.event.originalEvent&&i.event.originalEvent.dataTransfer&&(i.event.originalEvent.dataTransfer.dropEffect=D?"copy":"move"))}a(".jstree-dnd-parent").removeClass("jstree-dnd-parent"),c=!1,i.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er"),i.event.originalEvent&&i.event.originalEvent.dataTransfer,g.hide()}}).on("dnd_scroll.vakata.jstree",function(a,b){b&&b.data&&b.data.jstree&&(g.hide(),c=!1,e=!1,b.helper.find(".jstree-icon").first().removeClass("jstree-ok").addClass("jstree-er"))}).on("dnd_stop.vakata.jstree",function(b,h){if(a(".jstree-dnd-parent").removeClass("jstree-dnd-parent"),f&&clearTimeout(f),h&&h.data&&h.data.jstree){g.hide().detach();var i,j,k=[];if(c){for(i=0,j=h.data.nodes.length;j>i;i++)k[i]=h.data.origin?h.data.origin.get_node(h.data.nodes[i]):h.data.nodes[i];c.ins[h.data.origin&&(h.data.origin.settings.dnd.always_copy||h.data.origin.settings.dnd.copy&&(h.event.metaKey||h.event.ctrlKey))?"copy_node":"move_node"](k,c.par,c.pos,!1,!1,!1,h.data.origin)}else i=a(h.event.target).closest(".jstree"),i.length&&d&&d.error&&"check"===d.error&&(i=i.jstree(!0),i&&i.settings.core.error.call(this,d));e=!1,c=!1}}).on("keyup.jstree keydown.jstree",function(b,h){h=a.vakata.dnd._get(),h&&h.data&&h.data.jstree&&("keyup"===b.type&&27===b.which?(f&&clearTimeout(f),c=!1,d=!1,e=!1,f=!1,g.hide().detach(),a.vakata.dnd._clean()):(h.helper.find(".jstree-copy").first()[h.data.origin&&(h.data.origin.settings.dnd.always_copy||h.data.origin.settings.dnd.copy&&(b.metaKey||b.ctrlKey))?"show":"hide"](),e&&(e.metaKey=b.metaKey,e.ctrlKey=b.ctrlKey,a.vakata.dnd._trigger("move",e))))})}),function(a){a.vakata.html={div:a("
        "),escape:function(b){return a.vakata.html.div.text(b).html()},strip:function(b){return a.vakata.html.div.empty().append(a.parseHTML(b)).text()}};var c={element:!1,target:!1,is_down:!1,is_drag:!1,helper:!1,helper_w:0,data:!1,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:!1,scroll_i:!1,is_touch:!1};a.vakata.dnd={settings:{scroll_speed:10,scroll_proximity:20,helper_left:5,helper_top:10,threshold:5,threshold_touch:10},_trigger:function(c,d,e){e===b&&(e=a.vakata.dnd._get()),e.event=d,a(i).triggerHandler("dnd_"+c+".vakata",e)},_get:function(){return{data:c.data,element:c.element,helper:c.helper}},_clean:function(){c.helper&&c.helper.remove(),c.scroll_i&&(clearInterval(c.scroll_i),c.scroll_i=!1),c={element:!1,target:!1,is_down:!1,is_drag:!1,helper:!1,helper_w:0,data:!1,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:!1,scroll_i:!1,is_touch:!1},a(i).off("mousemove.vakata.jstree touchmove.vakata.jstree",a.vakata.dnd.drag),a(i).off("mouseup.vakata.jstree touchend.vakata.jstree",a.vakata.dnd.stop)},_scroll:function(b){if(!c.scroll_e||!c.scroll_l&&!c.scroll_t)return c.scroll_i&&(clearInterval(c.scroll_i),c.scroll_i=!1),!1;if(!c.scroll_i)return c.scroll_i=setInterval(a.vakata.dnd._scroll,100),!1;if(b===!0)return!1;var d=c.scroll_e.scrollTop(),e=c.scroll_e.scrollLeft();c.scroll_e.scrollTop(d+c.scroll_t*a.vakata.dnd.settings.scroll_speed),c.scroll_e.scrollLeft(e+c.scroll_l*a.vakata.dnd.settings.scroll_speed),(d!==c.scroll_e.scrollTop()||e!==c.scroll_e.scrollLeft())&&a.vakata.dnd._trigger("scroll",c.scroll_e)},start:function(b,d,e){"touchstart"===b.type&&b.originalEvent&&b.originalEvent.changedTouches&&b.originalEvent.changedTouches[0]&&(b.pageX=b.originalEvent.changedTouches[0].pageX,b.pageY=b.originalEvent.changedTouches[0].pageY,b.target=i.elementFromPoint(b.originalEvent.changedTouches[0].pageX-window.pageXOffset,b.originalEvent.changedTouches[0].pageY-window.pageYOffset)),c.is_drag&&a.vakata.dnd.stop({});try{b.currentTarget.unselectable="on",b.currentTarget.onselectstart=function(){return!1},b.currentTarget.style&&(b.currentTarget.style.touchAction="none",b.currentTarget.style.msTouchAction="none",b.currentTarget.style.MozUserSelect="none")}catch(f){}return c.init_x=b.pageX,c.init_y=b.pageY,c.data=d,c.is_down=!0,c.element=b.currentTarget,c.target=b.target,c.is_touch="touchstart"===b.type,e!==!1&&(c.helper=a("
        ").html(e).css({display:"block",margin:"0",padding:"0",position:"absolute",top:"-2000px",lineHeight:"16px",zIndex:"10000"})),a(i).on("mousemove.vakata.jstree touchmove.vakata.jstree",a.vakata.dnd.drag),a(i).on("mouseup.vakata.jstree touchend.vakata.jstree",a.vakata.dnd.stop),!1},drag:function(b){if("touchmove"===b.type&&b.originalEvent&&b.originalEvent.changedTouches&&b.originalEvent.changedTouches[0]&&(b.pageX=b.originalEvent.changedTouches[0].pageX,b.pageY=b.originalEvent.changedTouches[0].pageY,b.target=i.elementFromPoint(b.originalEvent.changedTouches[0].pageX-window.pageXOffset,b.originalEvent.changedTouches[0].pageY-window.pageYOffset)),c.is_down){if(!c.is_drag){if(!(Math.abs(b.pageX-c.init_x)>(c.is_touch?a.vakata.dnd.settings.threshold_touch:a.vakata.dnd.settings.threshold)||Math.abs(b.pageY-c.init_y)>(c.is_touch?a.vakata.dnd.settings.threshold_touch:a.vakata.dnd.settings.threshold)))return;c.helper&&(c.helper.appendTo(i.body),c.helper_w=c.helper.outerWidth()),c.is_drag=!0,a(c.target).one("click.vakata",!1),a.vakata.dnd._trigger("start",b)}var d=!1,e=!1,f=!1,g=!1,h=!1,j=!1,k=!1,l=!1,m=!1,n=!1;return c.scroll_t=0,c.scroll_l=0,c.scroll_e=!1,a(a(b.target).parentsUntil("body").addBack().get().reverse()).filter(function(){return/^auto|scroll$/.test(a(this).css("overflow"))&&(this.scrollHeight>this.offsetHeight||this.scrollWidth>this.offsetWidth)}).each(function(){var d=a(this),e=d.offset();return this.scrollHeight>this.offsetHeight&&(e.top+d.height()-b.pageYthis.offsetWidth&&(e.left+d.width()-b.pageXg&&b.pageY-kg&&g-(b.pageY-k)j&&b.pageX-lj&&j-(b.pageX-l)f&&(m=f-50),h&&n+c.helper_w>h&&(n=h-(c.helper_w+2)),c.helper.css({left:n+"px",top:m+"px"})),a.vakata.dnd._trigger("move",b),!1}},stop:function(b){if("touchend"===b.type&&b.originalEvent&&b.originalEvent.changedTouches&&b.originalEvent.changedTouches[0]&&(b.pageX=b.originalEvent.changedTouches[0].pageX,b.pageY=b.originalEvent.changedTouches[0].pageY,b.target=i.elementFromPoint(b.originalEvent.changedTouches[0].pageX-window.pageXOffset,b.originalEvent.changedTouches[0].pageY-window.pageYOffset)),c.is_drag)b.target!==c.target&&a(c.target).off("click.vakata"),a.vakata.dnd._trigger("stop",b);else if("touchend"===b.type&&b.target===c.target){var d=setTimeout(function(){a(b.target).click()},100);a(b.target).one("click",function(){d&&clearTimeout(d)})}return a.vakata.dnd._clean(),!1}}}(a),a.jstree.defaults.massload=null,a.jstree.plugins.massload=function(b,c){this.init=function(a,b){this._data.massload={},c.init.call(this,a,b)},this._load_nodes=function(b,d,e,f){var g=this.settings.massload,h=JSON.stringify(b),i=[],j=this._model.data,k,l,m;if(!e){for(k=0,l=b.length;l>k;k++)(!j[b[k]]||!j[b[k]].state.loaded&&!j[b[k]].state.failed||f)&&(i.push(b[k]),m=this.get_node(b[k],!0),m&&m.length&&m.addClass("jstree-loading").attr("aria-busy",!0));if(this._data.massload={},i.length){if(a.isFunction(g))return g.call(this,i,a.proxy(function(a){var g,h;if(a)for(g in a)a.hasOwnProperty(g)&&(this._data.massload[g]=a[g]);for(g=0,h=b.length;h>g;g++)m=this.get_node(b[g],!0),m&&m.length&&m.removeClass("jstree-loading").attr("aria-busy",!1);c._load_nodes.call(this,b,d,e,f)},this));if("object"==typeof g&&g&&g.url)return g=a.extend(!0,{},g),a.isFunction(g.url)&&(g.url=g.url.call(this,i)),a.isFunction(g.data)&&(g.data=g.data.call(this,i)),a.ajax(g).done(a.proxy(function(a,g,h){var i,j;if(a)for(i in a)a.hasOwnProperty(i)&&(this._data.massload[i]=a[i]);for(i=0,j=b.length;j>i;i++)m=this.get_node(b[i],!0),m&&m.length&&m.removeClass("jstree-loading").attr("aria-busy",!1);c._load_nodes.call(this,b,d,e,f)},this)).fail(a.proxy(function(a){c._load_nodes.call(this,b,d,e,f)},this))}}return c._load_nodes.call(this,b,d,e,f)},this._load_node=function(b,d){var e=this._data.massload[b.id],f=null,g;return e?(f=this["string"==typeof e?"_append_html_data":"_append_json_data"](b,"string"==typeof e?a(a.parseHTML(e)).filter(function(){return 3!==this.nodeType}):e,function(a){d.call(this,a)}),g=this.get_node(b.id,!0),g&&g.length&&g.removeClass("jstree-loading").attr("aria-busy",!1),delete this._data.massload[b.id],f):c._load_node.call(this,b,d)}},a.jstree.defaults.search={ajax:!1,fuzzy:!1,case_sensitive:!1,show_only_matches:!1,show_only_matches_children:!1,close_opened_onclear:!0,search_leaves_only:!1,search_callback:!1},a.jstree.plugins.search=function(c,d){this.bind=function(){d.bind.call(this),this._data.search.str="",this._data.search.dom=a(),this._data.search.res=[],this._data.search.opn=[],this._data.search.som=!1,this._data.search.smc=!1,this._data.search.hdn=[],this.element.on("search.jstree",a.proxy(function(b,c){if(this._data.search.som&&c.res.length){var d=this._model.data,e,f,g=[],h,i;for(e=0,f=c.res.length;f>e;e++)if(d[c.res[e]]&&!d[c.res[e]].state.hidden&&(g.push(c.res[e]),g=g.concat(d[c.res[e]].parents),this._data.search.smc))for(h=0,i=d[c.res[e]].children_d.length;i>h;h++)d[d[c.res[e]].children_d[h]]&&!d[d[c.res[e]].children_d[h]].state.hidden&&g.push(d[c.res[e]].children_d[h]);g=a.vakata.array_remove_item(a.vakata.array_unique(g),a.jstree.root),this._data.search.hdn=this.hide_all(!0),this.show_node(g,!0),this.redraw(!0)}},this)).on("clear_search.jstree",a.proxy(function(a,b){this._data.search.som&&b.res.length&&(this.show_node(this._data.search.hdn,!0),this.redraw(!0))},this))},this.search=function(c,d,e,f,g,h){if(c===!1||""===a.trim(c.toString()))return this.clear_search();f=this.get_node(f),f=f&&f.id?f.id:null,c=c.toString();var i=this.settings.search,j=i.ajax?i.ajax:!1,k=this._model.data,l=null,m=[],n=[],o,p;if(this._data.search.res.length&&!g&&this.clear_search(),e===b&&(e=i.show_only_matches),h===b&&(h=i.show_only_matches_children),!d&&j!==!1)return a.isFunction(j)?j.call(this,c,a.proxy(function(b){b&&b.d&&(b=b.d),this._load_nodes(a.isArray(b)?a.vakata.array_unique(b):[],function(){this.search(c,!0,e,f,g,h)})},this),f):(j=a.extend({},j),j.data||(j.data={}),j.data.str=c,f&&(j.data.inside=f),this._data.search.lastRequest&&this._data.search.lastRequest.abort(),this._data.search.lastRequest=a.ajax(j).fail(a.proxy(function(){this._data.core.last_error={error:"ajax",plugin:"search",id:"search_01",reason:"Could not load search parents",data:JSON.stringify(j)},this.settings.core.error.call(this,this._data.core.last_error)},this)).done(a.proxy(function(b){b&&b.d&&(b=b.d),this._load_nodes(a.isArray(b)?a.vakata.array_unique(b):[],function(){this.search(c,!0,e,f,g,h)})},this)),this._data.search.lastRequest);if(g||(this._data.search.str=c,this._data.search.dom=a(),this._data.search.res=[],this._data.search.opn=[],this._data.search.som=e,this._data.search.smc=h),l=new a.vakata.search(c,!0,{caseSensitive:i.case_sensitive,fuzzy:i.fuzzy}),a.each(k[f?f:a.jstree.root].children_d,function(a,b){var d=k[b];d.text&&!d.state.hidden&&(!i.search_leaves_only||d.state.loaded&&0===d.children.length)&&(i.search_callback&&i.search_callback.call(this,c,d)||!i.search_callback&&l.search(d.text).isMatch)&&(m.push(b),n=n.concat(d.parents))}),m.length){for(n=a.vakata.array_unique(n),o=0,p=n.length;p>o;o++)n[o]!==a.jstree.root&&k[n[o]]&&this.open_node(n[o],null,0)===!0&&this._data.search.opn.push(n[o]);g?(this._data.search.dom=this._data.search.dom.add(a(this.element[0].querySelectorAll("#"+a.map(m,function(b){return-1!=="0123456789".indexOf(b[0])?"\\3"+b[0]+" "+b.substr(1).replace(a.jstree.idregex,"\\$&"):b.replace(a.jstree.idregex,"\\$&")}).join(", #")))),this._data.search.res=a.vakata.array_unique(this._data.search.res.concat(m))):(this._data.search.dom=a(this.element[0].querySelectorAll("#"+a.map(m,function(b){return-1!=="0123456789".indexOf(b[0])?"\\3"+b[0]+" "+b.substr(1).replace(a.jstree.idregex,"\\$&"):b.replace(a.jstree.idregex,"\\$&")}).join(", #"))),this._data.search.res=m),this._data.search.dom.children(".jstree-anchor").addClass("jstree-search")}this.trigger("search",{nodes:this._data.search.dom,str:c,res:this._data.search.res,show_only_matches:e})},this.clear_search=function(){this.settings.search.close_opened_onclear&&this.close_node(this._data.search.opn,0),this.trigger("clear_search",{nodes:this._data.search.dom,str:this._data.search.str,res:this._data.search.res}),this._data.search.res.length&&(this._data.search.dom=a(this.element[0].querySelectorAll("#"+a.map(this._data.search.res,function(b){return-1!=="0123456789".indexOf(b[0])?"\\3"+b[0]+" "+b.substr(1).replace(a.jstree.idregex,"\\$&"):b.replace(a.jstree.idregex,"\\$&")}).join(", #"))),this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search")),this._data.search.str="",this._data.search.res=[],this._data.search.opn=[],this._data.search.dom=a()},this.redraw_node=function(b,c,e,f){if(b=d.redraw_node.apply(this,arguments),b&&-1!==a.inArray(b.id,this._data.search.res)){var g,h,i=null;for(g=0,h=b.childNodes.length;h>g;g++)if(b.childNodes[g]&&b.childNodes[g].className&&-1!==b.childNodes[g].className.indexOf("jstree-anchor")){i=b.childNodes[g];break}i&&(i.className+=" jstree-search")}return b}},function(a){a.vakata.search=function(b,c,d){d=d||{},d=a.extend({},a.vakata.search.defaults,d),d.fuzzy!==!1&&(d.fuzzy=!0),b=d.caseSensitive?b:b.toLowerCase();var e=d.location,f=d.distance,g=d.threshold,h=b.length,i,j,k,l;return h>32&&(d.fuzzy=!1),d.fuzzy&&(i=1<c;c++)a[b.charAt(c)]=0;for(c=0;h>c;c++)a[b.charAt(c)]|=1<c;c++){o=0,p=q;while(p>o)k(c,e+p)<=m?o=p:q=p,p=Math.floor((q-o)/2+o);for(q=p,s=Math.max(1,e-p+1),t=Math.min(e+p,l)+h,u=new Array(t+2),u[t+1]=(1<=s;f--)if(v=j[a.charAt(f-1)],0===c?u[f]=(u[f+1]<<1|1)&v:u[f]=(u[f+1]<<1|1)&v|((r[f+1]|r[f])<<1|1)|r[f+1],u[f]&i&&(w=k(c,f-1),m>=w)){if(m=w,n=f-1,x.push(n),!(n>e))break;s=Math.max(1,2*e-n)}if(k(c+1,e)>m)break;r=u}return{isMatch:n>=0,score:w}},c===!0?{search:l}:l(c)},a.vakata.search.defaults={location:0,distance:100,threshold:.6,fuzzy:!1,caseSensitive:!1}}(a),a.jstree.defaults.sort=function(a,b){return this.get_text(a)>this.get_text(b)?1:-1},a.jstree.plugins.sort=function(b,c){this.bind=function(){c.bind.call(this),this.element.on("model.jstree",a.proxy(function(a,b){this.sort(b.parent,!0)},this)).on("rename_node.jstree create_node.jstree",a.proxy(function(a,b){this.sort(b.parent||b.node.parent,!1),this.redraw_node(b.parent||b.node.parent,!0)},this)).on("move_node.jstree copy_node.jstree",a.proxy(function(a,b){this.sort(b.parent,!1),this.redraw_node(b.parent,!0)},this))},this.sort=function(b,c){var d,e;if(b=this.get_node(b),b&&b.children&&b.children.length&&(b.children.sort(a.proxy(this.settings.sort,this)),c))for(d=0,e=b.children_d.length;e>d;d++)this.sort(b.children_d[d],!1)}};var m=!1;a.jstree.defaults.state={key:"jstree",events:"changed.jstree open_node.jstree close_node.jstree check_node.jstree uncheck_node.jstree",ttl:!1,filter:!1,preserve_loaded:!1},a.jstree.plugins.state=function(b,c){this.bind=function(){c.bind.call(this);var b=a.proxy(function(){this.element.on(this.settings.state.events,a.proxy(function(){m&&clearTimeout(m),m=setTimeout(a.proxy(function(){this.save_state()},this),100)},this)),this.trigger("state_ready")},this);this.element.on("ready.jstree",a.proxy(function(a,c){this.element.one("restore_state.jstree",b),this.restore_state()||b()},this))},this.save_state=function(){var b=this.get_state();this.settings.state.preserve_loaded||delete b.core.loaded;var c={state:b,ttl:this.settings.state.ttl,sec:+new Date};a.vakata.storage.set(this.settings.state.key,JSON.stringify(c))},this.restore_state=function(){var b=a.vakata.storage.get(this.settings.state.key);if(b)try{b=JSON.parse(b)}catch(c){return!1}return b&&b.ttl&&b.sec&&+new Date-b.sec>b.ttl?!1:(b&&b.state&&(b=b.state),b&&a.isFunction(this.settings.state.filter)&&(b=this.settings.state.filter.call(this,b)),b?(this.settings.state.preserve_loaded||delete b.core.loaded,this.element.one("set_state.jstree",function(c,d){d.instance.trigger("restore_state",{state:a.extend(!0,{},b)})}),this.set_state(b),!0):!1)},this.clear_state=function(){return a.vakata.storage.del(this.settings.state.key)}},function(a,b){a.vakata.storage={set:function(a,b){return window.localStorage.setItem(a,b)},get:function(a){return window.localStorage.getItem(a)},del:function(a){return window.localStorage.removeItem(a)}}}(a),a.jstree.defaults.types={"default":{}},a.jstree.defaults.types[a.jstree.root]={},a.jstree.plugins.types=function(c,d){this.init=function(c,e){var f,g;if(e&&e.types&&e.types["default"])for(f in e.types)if("default"!==f&&f!==a.jstree.root&&e.types.hasOwnProperty(f))for(g in e.types["default"])e.types["default"].hasOwnProperty(g)&&e.types[f][g]===b&&(e.types[f][g]=e.types["default"][g]);d.init.call(this,c,e),this._model.data[a.jstree.root].type=a.jstree.root},this.refresh=function(b,c){d.refresh.call(this,b,c),this._model.data[a.jstree.root].type=a.jstree.root},this.bind=function(){this.element.on("model.jstree",a.proxy(function(c,d){var e=this._model.data,f=d.nodes,g=this.settings.types,h,i,j="default",k;for(h=0,i=f.length;i>h;h++){if(j="default",e[f[h]].original&&e[f[h]].original.type&&g[e[f[h]].original.type]&&(j=e[f[h]].original.type),e[f[h]].data&&e[f[h]].data.jstree&&e[f[h]].data.jstree.type&&g[e[f[h]].data.jstree.type]&&(j=e[f[h]].data.jstree.type),e[f[h]].type=j,e[f[h]].icon===!0&&g[j].icon!==b&&(e[f[h]].icon=g[j].icon),g[j].li_attr!==b&&"object"==typeof g[j].li_attr)for(k in g[j].li_attr)if(g[j].li_attr.hasOwnProperty(k)){if("id"===k)continue;e[f[h]].li_attr[k]===b?e[f[h]].li_attr[k]=g[j].li_attr[k]:"class"===k&&(e[f[h]].li_attr["class"]=g[j].li_attr["class"]+" "+e[f[h]].li_attr["class"])}if(g[j].a_attr!==b&&"object"==typeof g[j].a_attr)for(k in g[j].a_attr)if(g[j].a_attr.hasOwnProperty(k)){if("id"===k)continue;e[f[h]].a_attr[k]===b?e[f[h]].a_attr[k]=g[j].a_attr[k]:"href"===k&&"#"===e[f[h]].a_attr[k]?e[f[h]].a_attr.href=g[j].a_attr.href:"class"===k&&(e[f[h]].a_attr["class"]=g[j].a_attr["class"]+" "+e[f[h]].a_attr["class"])}}e[a.jstree.root].type=a.jstree.root},this)),d.bind.call(this)},this.get_json=function(b,c,e){var f,g,h=this._model.data,i=c?a.extend(!0,{},c,{no_id:!1}):{},j=d.get_json.call(this,b,i,e);if(j===!1)return!1;if(a.isArray(j))for(f=0,g=j.length;g>f;f++)j[f].type=j[f].id&&h[j[f].id]&&h[j[f].id].type?h[j[f].id].type:"default",c&&c.no_id&&(delete j[f].id,j[f].li_attr&&j[f].li_attr.id&&delete j[f].li_attr.id,j[f].a_attr&&j[f].a_attr.id&&delete j[f].a_attr.id);else j.type=j.id&&h[j.id]&&h[j.id].type?h[j.id].type:"default",c&&c.no_id&&(j=this._delete_ids(j));return j},this._delete_ids=function(b){if(a.isArray(b)){for(var c=0,d=b.length;d>c;c++)b[c]=this._delete_ids(b[c]);return b}return delete b.id, +b.li_attr&&b.li_attr.id&&delete b.li_attr.id,b.a_attr&&b.a_attr.id&&delete b.a_attr.id,b.children&&a.isArray(b.children)&&(b.children=this._delete_ids(b.children)),b},this.check=function(c,e,f,g,h){if(d.check.call(this,c,e,f,g,h)===!1)return!1;e=e&&e.id?e:this.get_node(e),f=f&&f.id?f:this.get_node(f);var i=e&&e.id?h&&h.origin?h.origin:a.jstree.reference(e.id):null,j,k,l,m;switch(i=i&&i._model&&i._model.data?i._model.data:null,c){case"create_node":case"move_node":case"copy_node":if("move_node"!==c||-1===a.inArray(e.id,f.children)){if(j=this.get_rules(f),j.max_children!==b&&-1!==j.max_children&&j.max_children===f.children.length)return this._data.core.last_error={error:"check",plugin:"types",id:"types_01",reason:"max_children prevents function: "+c,data:JSON.stringify({chk:c,pos:g,obj:e&&e.id?e.id:!1,par:f&&f.id?f.id:!1})},!1;if(j.valid_children!==b&&-1!==j.valid_children&&-1===a.inArray(e.type||"default",j.valid_children))return this._data.core.last_error={error:"check",plugin:"types",id:"types_02",reason:"valid_children prevents function: "+c,data:JSON.stringify({chk:c,pos:g,obj:e&&e.id?e.id:!1,par:f&&f.id?f.id:!1})},!1;if(i&&e.children_d&&e.parents){for(k=0,l=0,m=e.children_d.length;m>l;l++)k=Math.max(k,i[e.children_d[l]].parents.length);k=k-e.parents.length+1}(0>=k||k===b)&&(k=1);do{if(j.max_depth!==b&&-1!==j.max_depth&&j.max_depthg;g++)this.set_type(c[g],d);return!0}if(f=this.settings.types,c=this.get_node(c),!f[d]||!c)return!1;if(l=this.get_node(c,!0),l&&l.length&&(m=l.children(".jstree-anchor")),i=c.type,j=this.get_icon(c),c.type=d,(j===!0||!f[i]||f[i].icon!==b&&j===f[i].icon)&&this.set_icon(c,f[d].icon!==b?f[d].icon:!0),f[i]&&f[i].li_attr!==b&&"object"==typeof f[i].li_attr)for(k in f[i].li_attr)if(f[i].li_attr.hasOwnProperty(k)){if("id"===k)continue;"class"===k?(e[c.id].li_attr["class"]=(e[c.id].li_attr["class"]||"").replace(f[i].li_attr[k],""),l&&l.removeClass(f[i].li_attr[k])):e[c.id].li_attr[k]===f[i].li_attr[k]&&(e[c.id].li_attr[k]=null,l&&l.removeAttr(k))}if(f[i]&&f[i].a_attr!==b&&"object"==typeof f[i].a_attr)for(k in f[i].a_attr)if(f[i].a_attr.hasOwnProperty(k)){if("id"===k)continue;"class"===k?(e[c.id].a_attr["class"]=(e[c.id].a_attr["class"]||"").replace(f[i].a_attr[k],""),m&&m.removeClass(f[i].a_attr[k])):e[c.id].a_attr[k]===f[i].a_attr[k]&&("href"===k?(e[c.id].a_attr[k]="#",m&&m.attr("href","#")):(delete e[c.id].a_attr[k],m&&m.removeAttr(k)))}if(f[d].li_attr!==b&&"object"==typeof f[d].li_attr)for(k in f[d].li_attr)if(f[d].li_attr.hasOwnProperty(k)){if("id"===k)continue;e[c.id].li_attr[k]===b?(e[c.id].li_attr[k]=f[d].li_attr[k],l&&("class"===k?l.addClass(f[d].li_attr[k]):l.attr(k,f[d].li_attr[k]))):"class"===k&&(e[c.id].li_attr["class"]=f[d].li_attr[k]+" "+e[c.id].li_attr["class"],l&&l.addClass(f[d].li_attr[k]))}if(f[d].a_attr!==b&&"object"==typeof f[d].a_attr)for(k in f[d].a_attr)if(f[d].a_attr.hasOwnProperty(k)){if("id"===k)continue;e[c.id].a_attr[k]===b?(e[c.id].a_attr[k]=f[d].a_attr[k],m&&("class"===k?m.addClass(f[d].a_attr[k]):m.attr(k,f[d].a_attr[k]))):"href"===k&&"#"===e[c.id].a_attr[k]?(e[c.id].a_attr.href=f[d].a_attr.href,m&&m.attr("href",f[d].a_attr.href)):"class"===k&&(e[c.id].a_attr["class"]=f[d].a_attr["class"]+" "+e[c.id].a_attr["class"],m&&m.addClass(f[d].a_attr[k]))}return!0}},a.jstree.defaults.unique={case_sensitive:!1,trim_whitespace:!1,duplicate:function(a,b){return a+" ("+b+")"}},a.jstree.plugins.unique=function(c,d){this.check=function(b,c,e,f,g){if(d.check.call(this,b,c,e,f,g)===!1)return!1;if(c=c&&c.id?c:this.get_node(c),e=e&&e.id?e:this.get_node(e),!e||!e.children)return!0;var h="rename_node"===b?f:c.text,i=[],j=this.settings.unique.case_sensitive,k=this.settings.unique.trim_whitespace,l=this._model.data,m,n,o;for(m=0,n=e.children.length;n>m;m++)o=l[e.children[m]].text,j||(o=o.toLowerCase()),k&&(o=o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")),i.push(o);switch(j||(h=h.toLowerCase()),k&&(h=h.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")),b){case"delete_node":return!0;case"rename_node":return o=c.text||"",j||(o=o.toLowerCase()),k&&(o=o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")),m=-1===a.inArray(h,i)||c.text&&o===h,m||(this._data.core.last_error={error:"check",plugin:"unique",id:"unique_01",reason:"Child with name "+h+" already exists. Preventing: "+b,data:JSON.stringify({chk:b,pos:f,obj:c&&c.id?c.id:!1,par:e&&e.id?e.id:!1})}),m;case"create_node":return m=-1===a.inArray(h,i),m||(this._data.core.last_error={error:"check",plugin:"unique",id:"unique_04",reason:"Child with name "+h+" already exists. Preventing: "+b,data:JSON.stringify({chk:b,pos:f,obj:c&&c.id?c.id:!1,par:e&&e.id?e.id:!1})}),m;case"copy_node":return m=-1===a.inArray(h,i),m||(this._data.core.last_error={error:"check",plugin:"unique",id:"unique_02",reason:"Child with name "+h+" already exists. Preventing: "+b,data:JSON.stringify({chk:b,pos:f,obj:c&&c.id?c.id:!1,par:e&&e.id?e.id:!1})}),m;case"move_node":return m=c.parent===e.id&&(!g||!g.is_multi)||-1===a.inArray(h,i),m||(this._data.core.last_error={error:"check",plugin:"unique",id:"unique_03",reason:"Child with name "+h+" already exists. Preventing: "+b,data:JSON.stringify({chk:b,pos:f,obj:c&&c.id?c.id:!1,par:e&&e.id?e.id:!1})}),m}return!0},this.create_node=function(c,e,f,g,h){if(!e||e.text===b){if(null===c&&(c=a.jstree.root),c=this.get_node(c),!c)return d.create_node.call(this,c,e,f,g,h);if(f=f===b?"last":f,!f.toString().match(/^(before|after)$/)&&!h&&!this.is_loaded(c))return d.create_node.call(this,c,e,f,g,h);e||(e={});var i,j,k,l,m,n=this._model.data,o=this.settings.unique.case_sensitive,p=this.settings.unique.trim_whitespace,q=this.settings.unique.duplicate,r;for(j=i=this.get_string("New node"),k=[],l=0,m=c.children.length;m>l;l++)r=n[c.children[l]].text,o||(r=r.toLowerCase()),p&&(r=r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")),k.push(r);l=1,r=j,o||(r=r.toLowerCase()),p&&(r=r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""));while(-1!==a.inArray(r,k))j=q.call(this,i,++l).toString(),r=j,o||(r=r.toLowerCase()),p&&(r=r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""));e.text=j}return d.create_node.call(this,c,e,f,g,h)}};var n=i.createElement("DIV");if(n.setAttribute("unselectable","on"),n.setAttribute("role","presentation"),n.className="jstree-wholerow",n.innerHTML=" ",a.jstree.plugins.wholerow=function(b,c){this.bind=function(){c.bind.call(this),this.element.on("ready.jstree set_state.jstree",a.proxy(function(){this.hide_dots()},this)).on("init.jstree loading.jstree ready.jstree",a.proxy(function(){this.get_container_ul().addClass("jstree-wholerow-ul")},this)).on("deselect_all.jstree",a.proxy(function(a,b){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked")},this)).on("changed.jstree",a.proxy(function(a,b){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked");var c=!1,d,e;for(d=0,e=b.selected.length;e>d;d++)c=this.get_node(b.selected[d],!0),c&&c.length&&c.children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("open_node.jstree",a.proxy(function(a,b){this.get_node(b.node,!0).find(".jstree-clicked").parent().children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("hover_node.jstree dehover_node.jstree",a.proxy(function(a,b){"hover_node"===a.type&&this.is_disabled(b.node)||this.get_node(b.node,!0).children(".jstree-wholerow")["hover_node"===a.type?"addClass":"removeClass"]("jstree-wholerow-hovered")},this)).on("contextmenu.jstree",".jstree-wholerow",a.proxy(function(b){if(this._data.contextmenu){b.preventDefault();var c=a.Event("contextmenu",{metaKey:b.metaKey,ctrlKey:b.ctrlKey,altKey:b.altKey,shiftKey:b.shiftKey,pageX:b.pageX,pageY:b.pageY});a(b.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(c)}},this)).on("click.jstree",".jstree-wholerow",function(b){b.stopImmediatePropagation();var c=a.Event("click",{metaKey:b.metaKey,ctrlKey:b.ctrlKey,altKey:b.altKey,shiftKey:b.shiftKey});a(b.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(c).focus()}).on("dblclick.jstree",".jstree-wholerow",function(b){b.stopImmediatePropagation();var c=a.Event("dblclick",{metaKey:b.metaKey,ctrlKey:b.ctrlKey,altKey:b.altKey,shiftKey:b.shiftKey});a(b.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(c).focus()}).on("click.jstree",".jstree-leaf > .jstree-ocl",a.proxy(function(b){b.stopImmediatePropagation();var c=a.Event("click",{metaKey:b.metaKey,ctrlKey:b.ctrlKey,altKey:b.altKey,shiftKey:b.shiftKey});a(b.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(c).focus()},this)).on("mouseover.jstree",".jstree-wholerow, .jstree-icon",a.proxy(function(a){return a.stopImmediatePropagation(),this.is_disabled(a.currentTarget)||this.hover_node(a.currentTarget),!1},this)).on("mouseleave.jstree",".jstree-node",a.proxy(function(a){this.dehover_node(a.currentTarget)},this))},this.teardown=function(){this.settings.wholerow&&this.element.find(".jstree-wholerow").remove(),c.teardown.call(this)},this.redraw_node=function(b,d,e,f){if(b=c.redraw_node.apply(this,arguments)){var g=n.cloneNode(!0);-1!==a.inArray(b.id,this._data.core.selected)&&(g.className+=" jstree-wholerow-clicked"),this._data.core.focused&&this._data.core.focused===b.id&&(g.className+=" jstree-wholerow-hovered"),b.insertBefore(g,b.childNodes[0])}return b}},window.customElements&&Object&&Object.create){var o=Object.create(HTMLElement.prototype);o.createdCallback=function(){var b={core:{},plugins:[]},c;for(c in a.jstree.plugins)a.jstree.plugins.hasOwnProperty(c)&&this.attributes[c]&&(b.plugins.push(c),this.getAttribute(c)&&JSON.parse(this.getAttribute(c))&&(b[c]=JSON.parse(this.getAttribute(c))));for(c in a.jstree.defaults.core)a.jstree.defaults.core.hasOwnProperty(c)&&this.attributes[c]&&(b.core[c]=JSON.parse(this.getAttribute(c))||this.getAttribute(c));a(this).jstree(b)};try{window.customElements.define("vakata-jstree",function(){},{prototype:o})}catch(p){}}}}); \ No newline at end of file diff --git a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default-dark/32px.png b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default-dark/32px.png deleted file mode 100644 index d6fd72114f8205ace7579894ec50cc37739b1471..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1562 zcmZ8heKga182_1NL)y?Sx!97DWU52*G8;`HFB3{gC^fx#KelDfGF0oNTV6Y2ZdXn( zW?q&;2$$7yGo_jk?dL78m$BH`?oapJf9~_g^E}_rdCuo~&i8zt=LXs5u#T3Y761S` z9`2;00H8*M@^GX&H~F9M=;#m#1Z8Dq5Z>6> z$mjF#-n~0GIQa47M*@KWf$i<>91aJI#ZoAgjEs!d)>f5DH9kIGP*5;GKd(?ICMG77 zO6APVj7%n*nwnZ#T3T3GSX^A}>+6GfKoAs(L}IbHv$Inu6lP^*QK{7Q%Q;&hYLmpH zKK_8EZ-l{ijlJvfy6TRlf7~;9DPVu?BhfnV*dK~6$QQ=l0)TZW50Xm&^~-c2Cs^XJ zG2LRnx7N-)T||;kWH254-Gre^cGMJXz zIbn5~l}bdTk#HD`I8|A;99ehHfebTtaNb7o zGG3K;76(qcr3!~V^z!nRWo5aU&-H`AEDPT1G+30PS2S8u73QQ}EU)%_Ff^AV5?k+1 zM3Q=9yvY~Cu9z1rB_q)cA94?xD+WqIPvh>Y8jTwk4}SYJ7x;XDhSF61*rcj;P;F3? zbajJrz<1dK)~3=%Pol3!i&})y(x5z|zRCoajmUH&{JC+)Al#Bw6USa2^+xu{>`<{g zZZj?y70(;=YP0^@W~My$HkHU=N`a0Rxu=|Co@%A%{y4<3F|mV|yI(&@SvJpn`gpT) z_K5>-7wk&=XZjzOO-tYaC5tql=~NO7^5aWhm>& z!4?-=;8r!;7Ub&*w-E2Xfb`NE9F6<}appJs<#6A7k^%`KZWa^Yl*@~Qp%q;UGKbjq zZ1mjlEW1>2d3+(XqXhf6Z60<{k178{uvivcKZB&TzDojSp_`?u7tA*T!p(<3C~8F@ zA6v1*i_$dccr+Y-jYz~Ik#NQwj$Su)a{Zc2*4}E6S}NYsnL{GYny;7xiLmk?2-%|y zJ6v5uS+{2phdBUVf{;Vu{;E@XO6L&ebA|d9Fy@o!cv|$8YgYBw8)}!Dz9T3-7_mO9 z#hGHn-I^xp`ZOjZ|t$Dy3Z|I!w0K2DLvO(#^PglepW~D z%&$Y&;~KOuKfeGA?F|g(g2keH+{T#iQ!1HV{WqGwpV{ljSYKjSAe?+r(Eu_i}J)&5spU+}>Ib+a~+cBQ~@br7nUmR?V}= z%^6Mofa6H*FYNwfUj?QK9`DXKjZ08) zosVpzCY<*Tv8StD?y@1m2E6M)zqV>a<)h&U<8y`5lMOwdXhihh^bg^waQeGlk+;$( z>kXAxpC$Xn_nYZvYWn~ zCkqiYlbw2Jl2$xi$2{Vju$1jrDY^!gky_Q1d`sO*G1W}xe!WufFfQOq8 JiRT)A?H?ng_znO7 diff --git a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default-dark/40px.png b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default-dark/40px.png deleted file mode 100644 index 4fc88e41e66508e4657b3ec6e5ec185a6084b7a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5717 zcmZu#cU)7;wx*+i1Ocf67MfH61(BvGa3J&+IuTH+(xjJAM5L-9Rf@Eu5FpeLN+{Bi zVvrVkk90x_O_H}g_uc!>J-;`9Oun`D%v#^K_RQY16Qi%IafyzLj*N`#lI9+1u4IyyQdBO?Il>FL2>u$7e+YinyDJ_G_WFfed%Z~!jdzI_|$ zLqbA=f`WW}d|tkM>F4Jc5D;KxWo2n;X<=buZf7?;Cre99XJ=;shohsT z{r!Ccfv~l;wX?Icv9YnXwzjaaFgG_hGcz+eImyn>zPh>!BwAct1p0)81Wry)Kw5r& zK49|m^8>_+i;DpacmQtP+}wctjEoE-kqD$1A0IzHK5lDktFEpF2mmpGIEROa03RSD z8jb$>^CysNaBy&UcXwc5U}9pTr>6&?2aw#{-2D3W>+EK+E>_ z_WJsIdwV+qffyMX>F@7vZf-6qDFIZEj*eDURrU4t0j2o%?HdMz85Y!|}F8K7j8 z9Ia$Dw|~RbOjK}y-G^3|A=~=BUmZWggmOrkre}Ax7s<)Sn=xU^B?YC{ zpqcD%(>-pt$Ek_&lo|>f+pWgzE;4~>;3F1g76QRJ!jd$2B?cRb(SZHOfwhyOX-}!g zbv8@(S7Qi$3@c?Y9 zww#^~f~q1v=&_DT9RzOjZlRO@#T#ssYAgD{Zl;jiZjh7T-!s(dF4Q4NDpdTgOK_Hx zWHZm({n%@gNb7G8@r(EUTbFqngVo^Ko27g$F+*_+yB=OootUYch z)zVy3bMKLS&>ID&W~t|Nliu=Rw3mF)_d6kxUtGZ=KK*uwY+oGUUn0g`Vq%m=J#RAg z*Y6v+qVog%BsfqHM`{I9Ecko`A9**Z4@4ymezE!0TgojM^fmJ^Xk%r_g2ng8rTlX7 z;t~0lhjnIJxu3Ms*nDVUx_xVXX|5mR-q>IY?4zA*ce6JSOtEx_3 zTuVC)KnyW~Mnzxj2JD}v#WWxb4K+mJjT$)_oI{vx7lD#g|K5e7{CfQiQTK7UBIH(j zoaAMn=bA->yb6gqn_EiqURNE90$lCl#y?Gor3{aXq{#ZvAXWsJ%f&Grvs=}lX=(L_ zkZ42nUC(@vCYPznnc}hS)aQq&`A|)wE103uQ%XiA+5C>yk!j~#ykOmP$BZ6>+8Y_! zEZLREI`s%~pIAAbL>;l&%!#X#Tc6%WeICuk_GG;(?cA{uyb#~hlZ%-w>@KvW*kR_DlL4i* zpkSo9mFNte9i4pTnm~P)p_X;g?Cm)iVUtL7?mZGQumz);jgT2D8gEk_-A3T;Fe9)@ z@aTLxb}rYGqdf8JbFhzRV5o9Jw*p5Uug#&U$Sl0TYvYMd)_@I9_D3*$QErx_XewG` zhsHCD`tKX?Z+r2-AgUW0&whuNB3=gX!qjTUf-t5NDD#-by}lHG7q8_K{DAMbv#^Wy zfIMCfuXSBq`4b4L9RnHg+dgV&n=|rFIrbwcmD*qyV=Qx>s7HnB1eeL}wVFzZGZhug z+^R1@)sRB7eV@E}gsTI2bs4ABVz_yGDdm;xIjBSNqEDx(+B*xg(X8_ln|v09ah@>o z7*%CJaI31$aznN|7Ew;Fav(xwXYKB%~ZzZTIgIQz>J z!pb(sLq(OtYU~gOn|xmyHC!Wj5;3H?VmGjM<4JOJVp7G=hi1YTU85YelU51L_E`G9 z6pIFNQZyUgSG!fH&OYet@U*TDtv0>lH`a9B-b<+*kwx`e($t5(IYppMtGbn0{5!UY zq5zevViwbi-wYXE&!q*78`@E&u7(&%J-NFt=9=#mXgeE8TTE`235s}8{iCNk>zUs! zr8x*B&~59iTw$60A>7eG7jCV7J8@TZAX;8U%WBCyuTbSE&kZVufnNb9mO%qj*&6L%ftfe&yL)E@u&uVQbE4j&?bzNVJ zJcy(0!8$z%Jsi9_{+uVke+-j4NUGExPi?lWd95qWozNpXgkcQCtGx<#R`!(`RLNd3 z*Tb=ASA~0<&y?eyDB)cQ&Ko>r;+v5AB=pQvZw*`6hKs)=T?Vl5ut+C2AF9O$MAnKkmkj%!E>PQWc|5!m}b)WS~bE*fwjq~;^ z>2ILW!D?PHM^!(EX?*KD|Dt-M3|mVQUrueatZn^GTzSz!hv-0dgicS;gemIgMqA`E zU=Q_Q?_OgVy6^Lo^JM3IoqrD1CPYYy8*6L-&_Qxumg9!R1m#ui^Uxz*I?%<_V@SraB4Pdi$NjyJsw=AP48mRIew2@ zh!0_mM=J-M#3$!M^3CYXu6Ilkzq4Tw1+05vCQDoHe-J{bULSou{5pd$*g6q0Z;g!; z{@SE^ddq=aRMHnCNNj=@*Qr6rxP)42@L`fC2Ze zidu+unxzw#Meb^isxCbFa}CK}mQ0pQUUkT_59Ef&7>;t>I!%U;EJQ&)u1^#4p%r$w zKe1xc4CW^-&_(7Cl8QH~qa%oynexx!>WS8~bD!tkPv4 zYc9fz8wV+vU9L9tzW>3^XO_%+Fm^k=s*5%KG;c(F=4wmmL|cg`{7H~cb&`^M*lHhP z9og20E96FmV*3Q=fUEX>O;0eshJpR}hk3q&228-2FgOWd1O)&g&Q zK}Vj~uAB>H=zM<1t+-2QXH>s=M?(D>sKx)lE#zEAy$qoebkMor=714)2u7Vfp&cLV zRqO*>!gg112OaRCmf(s+=8@H?a?o#D@SVnY;(HFHT`8Hpb^HP``HeXL@%igUK3|VR zb!m4eA33k}JRzF^-J6Z@>xehpy&gyHjOBA8Kh-oFfCs>bw2do4@N3(@OI6_Oy#~GV zkAvjj_wWB5FaPqcmh#T#Ke&dfJArhB2W7+5xKOwg$gA+6T$mag3UmT_9Dep5rpAnt zJc00spC!T6m{2Mw5UTLAWB{h89(Gi^#@r;uUcIf;p5dIw@BXnX>2uNiX{ljSosRuQ z34^N0lzS2CWdAwXilS1U7j4E4ucu30o%cniB(W8$(T^A|_O#r%Fg=JYA@zt&GHCwJ zz>PJ%wXBuL$IhYl@wyZ#*7lHcx(Au5UhaHQkZn-IIlPCsV9}o7Cd$fF#PEr4CO&`Q zUFvUs@1IBI=X{|5sUcI~BvZIzdztFRvTfe-&8JM~J=!x5@*uUGN&AQk6molr&7LB? zV|vyCIwBQam*J!U&h|Z3InLJHMO50=AtC`gSyK1MV9O2K>HZc~j7BVVkn)Cuv8=o8 zgU|kZK#U%8xqZa1(PaO&8>b%mkbI8PoQ{3)|4zssRL}uy0>*{uo)!^ylwJpW-@o%- zUEv=uN_D_qmnX$u^H3m_T$R%|PBLJ9`X&Ouel^ykb7D3_zOg z5aJc*`5c_>W!h~Y;+63EN`uDwmlbsX{$TjWeWp}-@DESbfqgx5;)&|LCs4JaM`9N! zMa@YRpw>qqQ){CHHnY6*<*^RoaLh97bc$V_PO}&%O&tY~po-~dR3$G=Km?%0yx9VD?q?qS>#}Fi6SE|*d4(1pJaD>03Vce{ z`o+d+q@#nrosqcA9dCHvT@guI$c4Q(C7tZJGb*5}iJ={>$t}0-=5rZ1{rB>@q;G?h zOf^c!b}q4}3uwl1!tWkVwNvMKMH$$!IZ}TupL>5nP*4xf=u6EO5x7k!K}CGP#o?z( zt=GLNPw%&~S*gM$;qkz|SEF9k9YY%P2xs>SsLpNdKbhuZWWSf*!xb|9v|ljP8`bLT z+Qx*Fc+_?()J`pNn%sSVn@->yrf3C?ld3`YSx;SG$^~XTO!>jMt(8`+!Y$!ZQ`Mj_ zWZei)nd6YC2pCMo&X>n;9Un#0Z_dr)6_+K31_?Wi>=X4|8P-eX*q-%V5If3a(LAW% z`Yh+bmVrHeGVs_xyOCGr<*yZw@JkA`L&~^vM_PpzS*v-iXD8oCE9H`DGO)W2uE%a$ z)ug4;To}?<*1>fmK-&BGO(Ub@Fig%tf!A{i!{En*U4+RPL)B#C_M+-VU-UoIjKyzu zURr!5^to*g^pD;CukXsgFAC6&<4$F9neX%OE!ztiLp?`Y)Bd12vZEK|3cmQ)vZAFd zH8gg&X1;$f(MqYyLAp(()-;YdFb0lDvpb8n$w-c&f}lJwB)9qFjqlRZEk5Dg1(JCtcYk$9T-Giz@FJG0{BR-!pHgLv~JNUZ!E& zcxvqtoQ39m2*ubC)Z{bYQ>MX!d}oWC$zM$kcV26X?OY5STPR=8AHsp{{X1OD_3$+s zqa3tHN0=fhF}tqD&pXf*uA*OMpHxZkgu=Ud<^!De_K1typ<71kaEnGg&Y&g4A!n%} zLQJQ~Py!-yx3(q%dU&zi^sZnWcb3+`&(WXVX6+#~1()+Kw0e-4_;X!S57AK?&HA1- z!8`97(Wr+Bti7*`={%=~XuM*^ufO+i#!5}mWpO#c$?)DN@2n*KRu0{d%t|Ed zq|uFI3y~`?1Qu7kd_$NPw(1G5KJ}_`Pg_!;C5$RYORrRpV-CuiBjEN`1&@IO0Ae(fMRCc#>x|s=hOuT)CU*ga~q{8;~R$sB(9d@vWtx|c=CP9 zhuJy=U!2R%m|lFB%1=p-1kqJlg%Hh0jshXNz!5@`H`vl`j$iF0m^H=0`P?_R&B@`k zDLIyJNNVGruKfOK;?i85ny*qKq*wFN*^%#lb0lU0I3F0#S`~JF6@QWX$QU^h&_sGf zRN7iK)f?HIn3v%SdA&sV!1NS3K1r(Bf!?_vC)1pblt*T+R20=M>4L{k5_WdCIqq<0 z^1ugFqc)HIkxcn|GU<_{LdUwKHmBf=xe{oF+?WwjnU;@ZC(JWA?_);YJU^q4iPhS0 z&MRd(wef~!j=fp(vbXANu7fyY3SM{4^t}GeHn50&vnj!qFNQ;erbwdF5g!J1mHM9@ zIO4N%QbbPjBVc-^&^v72Kl!C)8vQ&xD&!PcerW#9LNhQk9`_*(6#Ld#&LpT<9(Hllink$rZDeO-*5fT1{{lZa^Nit(%~4htdAMk z_OrL!e1p$qvo~?}Es_;8dk|odSaORb3r9kc{-jwWX_GjqUfk+QJmGn=rF%3+(9IZV z5Nf%}&XLfWM%d)b?^od)KOy+Nsug`ID=lD)<00coUZEWCV#dDta1U+2Ll>Of|9nus zaR(384TUJ*=88M=Kb!a#qO@WizSaLsX3APIzSk=PV^)RTlplYa!!n(Ct}K4Kj9aEE z5M?6y+nA+)Z^PHK=-GH2&VAr&r(HEVr)nW)r3Z$1v<+{lk .jstree-ocl { - cursor: default; -} -.jstree .jstree-open > .jstree-children { - display: block; -} -.jstree .jstree-closed > .jstree-children, -.jstree .jstree-leaf > .jstree-children { - display: none; -} -.jstree-anchor > .jstree-themeicon { - margin-right: 2px; -} -.jstree-no-icons .jstree-themeicon, -.jstree-anchor > .jstree-themeicon-hidden { - display: none; -} -.jstree-hidden, -.jstree-node.jstree-hidden { - display: none; -} -.jstree-rtl .jstree-anchor { - padding: 0 1px 0 4px; -} -.jstree-rtl .jstree-anchor > .jstree-themeicon { - margin-left: 2px; - margin-right: 0; -} -.jstree-rtl .jstree-node { - margin-left: 0; -} -.jstree-rtl .jstree-container-ul > .jstree-node { - margin-right: 0; -} -.jstree-wholerow-ul { - position: relative; - display: inline-block; - min-width: 100%; -} -.jstree-wholerow-ul .jstree-leaf > .jstree-ocl { - cursor: pointer; -} -.jstree-wholerow-ul .jstree-anchor, -.jstree-wholerow-ul .jstree-icon { - position: relative; -} -.jstree-wholerow-ul .jstree-wholerow { - width: 100%; - cursor: pointer; - position: absolute; - left: 0; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -.jstree-contextmenu .jstree-anchor { - -webkit-user-select: none; - /* disable selection/Copy of UIWebView */ - -webkit-touch-callout: none; - /* disable the IOS popup when long-press on a link */ -} -.vakata-context { - display: none; -} -.vakata-context, -.vakata-context ul { - margin: 0; - padding: 2px; - position: absolute; - background: #f5f5f5; - border: 1px solid #979797; - box-shadow: 2px 2px 2px #999999; -} -.vakata-context ul { - list-style: none; - left: 100%; - margin-top: -2.7em; - margin-left: -4px; -} -.vakata-context .vakata-context-right ul { - left: auto; - right: 100%; - margin-left: auto; - margin-right: -4px; -} -.vakata-context li { - list-style: none; -} -.vakata-context li > a { - display: block; - padding: 0 2em 0 2em; - text-decoration: none; - width: auto; - color: black; - white-space: nowrap; - line-height: 2.4em; - text-shadow: 1px 1px 0 white; - border-radius: 1px; -} -.vakata-context li > a:hover { - position: relative; - background-color: #e8eff7; - box-shadow: 0 0 2px #0a6aa1; -} -.vakata-context li > a.vakata-context-parent { - background-image: url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw=="); - background-position: right center; - background-repeat: no-repeat; -} -.vakata-context li > a:focus { - outline: 0; -} -.vakata-context .vakata-context-hover > a { - position: relative; - background-color: #e8eff7; - box-shadow: 0 0 2px #0a6aa1; -} -.vakata-context .vakata-context-separator > a, -.vakata-context .vakata-context-separator > a:hover { - background: white; - border: 0; - border-top: 1px solid #e2e3e3; - height: 1px; - min-height: 1px; - max-height: 1px; - padding: 0; - margin: 0 0 0 2.4em; - border-left: 1px solid #e0e0e0; - text-shadow: 0 0 0 transparent; - box-shadow: 0 0 0 transparent; - border-radius: 0; -} -.vakata-context .vakata-contextmenu-disabled a, -.vakata-context .vakata-contextmenu-disabled a:hover { - color: silver; - background-color: transparent; - border: 0; - box-shadow: 0 0 0; -} -.vakata-context li > a > i { - text-decoration: none; - display: inline-block; - width: 2.4em; - height: 2.4em; - background: transparent; - margin: 0 0 0 -2em; - vertical-align: top; - text-align: center; - line-height: 2.4em; -} -.vakata-context li > a > i:empty { - width: 2.4em; - line-height: 2.4em; -} -.vakata-context li > a .vakata-contextmenu-sep { - display: inline-block; - width: 1px; - height: 2.4em; - background: white; - margin: 0 0.5em 0 0; - border-left: 1px solid #e2e3e3; -} -.vakata-context .vakata-contextmenu-shortcut { - font-size: 0.8em; - color: silver; - opacity: 0.5; - display: none; -} -.vakata-context-rtl ul { - left: auto; - right: 100%; - margin-left: auto; - margin-right: -4px; -} -.vakata-context-rtl li > a.vakata-context-parent { - background-image: url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAINjI+AC7rWHIsPtmoxLAA7"); - background-position: left center; - background-repeat: no-repeat; -} -.vakata-context-rtl .vakata-context-separator > a { - margin: 0 2.4em 0 0; - border-left: 0; - border-right: 1px solid #e2e3e3; -} -.vakata-context-rtl .vakata-context-left ul { - right: auto; - left: 100%; - margin-left: -4px; - margin-right: auto; -} -.vakata-context-rtl li > a > i { - margin: 0 -2em 0 0; -} -.vakata-context-rtl li > a .vakata-contextmenu-sep { - margin: 0 0 0 0.5em; - border-left-color: white; - background: #e2e3e3; -} -#jstree-marker { - position: absolute; - top: 0; - left: 0; - margin: -5px 0 0 0; - padding: 0; - border-right: 0; - border-top: 5px solid transparent; - border-bottom: 5px solid transparent; - border-left: 5px solid; - width: 0; - height: 0; - font-size: 0; - line-height: 0; -} -#jstree-dnd { - line-height: 16px; - margin: 0; - padding: 4px; -} -#jstree-dnd .jstree-icon, -#jstree-dnd .jstree-copy { - display: inline-block; - text-decoration: none; - margin: 0 2px 0 0; - padding: 0; - width: 16px; - height: 16px; -} -#jstree-dnd .jstree-ok { - background: green; -} -#jstree-dnd .jstree-er { - background: red; -} -#jstree-dnd .jstree-copy { - margin: 0 2px 0 2px; -} -.jstree-default-dark .jstree-node, -.jstree-default-dark .jstree-icon { - background-repeat: no-repeat; - background-color: transparent; -} -.jstree-default-dark .jstree-anchor, -.jstree-default-dark .jstree-animated, -.jstree-default-dark .jstree-wholerow { - transition: background-color 0.15s, box-shadow 0.15s; -} -.jstree-default-dark .jstree-hovered { - background: #555555; - border-radius: 2px; - box-shadow: inset 0 0 1px #555555; -} -.jstree-default-dark .jstree-context { - background: #555555; - border-radius: 2px; - box-shadow: inset 0 0 1px #555555; -} -.jstree-default-dark .jstree-clicked { - background: #5fa2db; - border-radius: 2px; - box-shadow: inset 0 0 1px #666666; -} -.jstree-default-dark .jstree-no-icons .jstree-anchor > .jstree-themeicon { - display: none; -} -.jstree-default-dark .jstree-disabled { - background: transparent; - color: #666666; -} -.jstree-default-dark .jstree-disabled.jstree-hovered { - background: transparent; - box-shadow: none; -} -.jstree-default-dark .jstree-disabled.jstree-clicked { - background: #333333; -} -.jstree-default-dark .jstree-disabled > .jstree-icon { - opacity: 0.8; - filter: url("data:image/svg+xml;utf8,#jstree-grayscale"); - /* Firefox 10+ */ - filter: gray; - /* IE6-9 */ - -webkit-filter: grayscale(100%); - /* Chrome 19+ & Safari 6+ */ -} -.jstree-default-dark .jstree-search { - font-style: italic; - color: #ffffff; - font-weight: bold; -} -.jstree-default-dark .jstree-no-checkboxes .jstree-checkbox { - display: none !important; -} -.jstree-default-dark.jstree-checkbox-no-clicked .jstree-clicked { - background: transparent; - box-shadow: none; -} -.jstree-default-dark.jstree-checkbox-no-clicked .jstree-clicked.jstree-hovered { - background: #555555; -} -.jstree-default-dark.jstree-checkbox-no-clicked > .jstree-wholerow-ul .jstree-wholerow-clicked { - background: transparent; -} -.jstree-default-dark.jstree-checkbox-no-clicked > .jstree-wholerow-ul .jstree-wholerow-clicked.jstree-wholerow-hovered { - background: #555555; -} -.jstree-default-dark > .jstree-striped { - min-width: 100%; - display: inline-block; - background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAkCAMAAAB/qqA+AAAABlBMVEUAAAAAAAClZ7nPAAAAAnRSTlMNAMM9s3UAAAAXSURBVHjajcEBAQAAAIKg/H/aCQZ70AUBjAATb6YPDgAAAABJRU5ErkJggg==") left top repeat; -} -.jstree-default-dark > .jstree-wholerow-ul .jstree-hovered, -.jstree-default-dark > .jstree-wholerow-ul .jstree-clicked { - background: transparent; - box-shadow: none; - border-radius: 0; -} -.jstree-default-dark .jstree-wholerow { - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box; -} -.jstree-default-dark .jstree-wholerow-hovered { - background: #555555; -} -.jstree-default-dark .jstree-wholerow-clicked { - background: #5fa2db; - background: -webkit-linear-gradient(top, #5fa2db 0%, #5fa2db 100%); - background: linear-gradient(to bottom, #5fa2db 0%, #5fa2db 100%); -} -.jstree-default-dark .jstree-node { - min-height: 24px; - line-height: 24px; - margin-left: 24px; - min-width: 24px; -} -.jstree-default-dark .jstree-anchor { - line-height: 24px; - height: 24px; -} -.jstree-default-dark .jstree-icon { - width: 24px; - height: 24px; - line-height: 24px; -} -.jstree-default-dark .jstree-icon:empty { - width: 24px; - height: 24px; - line-height: 24px; -} -.jstree-default-dark.jstree-rtl .jstree-node { - margin-right: 24px; -} -.jstree-default-dark .jstree-wholerow { - height: 24px; -} -.jstree-default-dark .jstree-node, -.jstree-default-dark .jstree-icon { - background-image: url("32px.png"); -} -.jstree-default-dark .jstree-node { - background-position: -292px -4px; - background-repeat: repeat-y; -} -.jstree-default-dark .jstree-last { - background: transparent; -} -.jstree-default-dark .jstree-open > .jstree-ocl { - background-position: -132px -4px; -} -.jstree-default-dark .jstree-closed > .jstree-ocl { - background-position: -100px -4px; -} -.jstree-default-dark .jstree-leaf > .jstree-ocl { - background-position: -68px -4px; -} -.jstree-default-dark .jstree-themeicon { - background-position: -260px -4px; -} -.jstree-default-dark > .jstree-no-dots .jstree-node, -.jstree-default-dark > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default-dark > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -36px -4px; -} -.jstree-default-dark > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: -4px -4px; -} -.jstree-default-dark .jstree-disabled { - background: transparent; -} -.jstree-default-dark .jstree-disabled.jstree-hovered { - background: transparent; -} -.jstree-default-dark .jstree-disabled.jstree-clicked { - background: #efefef; -} -.jstree-default-dark .jstree-checkbox { - background-position: -164px -4px; -} -.jstree-default-dark .jstree-checkbox:hover { - background-position: -164px -36px; -} -.jstree-default-dark.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox, -.jstree-default-dark .jstree-checked > .jstree-checkbox { - background-position: -228px -4px; -} -.jstree-default-dark.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover, -.jstree-default-dark .jstree-checked > .jstree-checkbox:hover { - background-position: -228px -36px; -} -.jstree-default-dark .jstree-anchor > .jstree-undetermined { - background-position: -196px -4px; -} -.jstree-default-dark .jstree-anchor > .jstree-undetermined:hover { - background-position: -196px -36px; -} -.jstree-default-dark .jstree-checkbox-disabled { - opacity: 0.8; - filter: url("data:image/svg+xml;utf8,#jstree-grayscale"); - /* Firefox 10+ */ - filter: gray; - /* IE6-9 */ - -webkit-filter: grayscale(100%); - /* Chrome 19+ & Safari 6+ */ -} -.jstree-default-dark > .jstree-striped { - background-size: auto 48px; -} -.jstree-default-dark.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg=="); - background-position: 100% 1px; - background-repeat: repeat-y; -} -.jstree-default-dark.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default-dark.jstree-rtl .jstree-open > .jstree-ocl { - background-position: -132px -36px; -} -.jstree-default-dark.jstree-rtl .jstree-closed > .jstree-ocl { - background-position: -100px -36px; -} -.jstree-default-dark.jstree-rtl .jstree-leaf > .jstree-ocl { - background-position: -68px -36px; -} -.jstree-default-dark.jstree-rtl > .jstree-no-dots .jstree-node, -.jstree-default-dark.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default-dark.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -36px -36px; -} -.jstree-default-dark.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: -4px -36px; -} -.jstree-default-dark .jstree-themeicon-custom { - background-color: transparent; - background-image: none; - background-position: 0 0; -} -.jstree-default-dark > .jstree-container-ul .jstree-loading > .jstree-ocl { - background: url("throbber.gif") center center no-repeat; -} -.jstree-default-dark .jstree-file { - background: url("32px.png") -100px -68px no-repeat; -} -.jstree-default-dark .jstree-folder { - background: url("32px.png") -260px -4px no-repeat; -} -.jstree-default-dark > .jstree-container-ul > .jstree-node { - margin-left: 0; - margin-right: 0; -} -#jstree-dnd.jstree-default-dark { - line-height: 24px; - padding: 0 4px; -} -#jstree-dnd.jstree-default-dark .jstree-ok, -#jstree-dnd.jstree-default-dark .jstree-er { - background-image: url("32px.png"); - background-repeat: no-repeat; - background-color: transparent; -} -#jstree-dnd.jstree-default-dark i { - background: transparent; - width: 24px; - height: 24px; - line-height: 24px; -} -#jstree-dnd.jstree-default-dark .jstree-ok { - background-position: -4px -68px; -} -#jstree-dnd.jstree-default-dark .jstree-er { - background-position: -36px -68px; -} -.jstree-default-dark .jstree-ellipsis { - overflow: hidden; -} -.jstree-default-dark .jstree-ellipsis .jstree-anchor { - width: calc(100% - 29px); - text-overflow: ellipsis; - overflow: hidden; -} -.jstree-default-dark .jstree-ellipsis.jstree-no-icons .jstree-anchor { - width: calc(100% - 5px); -} -.jstree-default-dark.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg=="); -} -.jstree-default-dark.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default-dark-small .jstree-node { - min-height: 18px; - line-height: 18px; - margin-left: 18px; - min-width: 18px; -} -.jstree-default-dark-small .jstree-anchor { - line-height: 18px; - height: 18px; -} -.jstree-default-dark-small .jstree-icon { - width: 18px; - height: 18px; - line-height: 18px; -} -.jstree-default-dark-small .jstree-icon:empty { - width: 18px; - height: 18px; - line-height: 18px; -} -.jstree-default-dark-small.jstree-rtl .jstree-node { - margin-right: 18px; -} -.jstree-default-dark-small .jstree-wholerow { - height: 18px; -} -.jstree-default-dark-small .jstree-node, -.jstree-default-dark-small .jstree-icon { - background-image: url("32px.png"); -} -.jstree-default-dark-small .jstree-node { - background-position: -295px -7px; - background-repeat: repeat-y; -} -.jstree-default-dark-small .jstree-last { - background: transparent; -} -.jstree-default-dark-small .jstree-open > .jstree-ocl { - background-position: -135px -7px; -} -.jstree-default-dark-small .jstree-closed > .jstree-ocl { - background-position: -103px -7px; -} -.jstree-default-dark-small .jstree-leaf > .jstree-ocl { - background-position: -71px -7px; -} -.jstree-default-dark-small .jstree-themeicon { - background-position: -263px -7px; -} -.jstree-default-dark-small > .jstree-no-dots .jstree-node, -.jstree-default-dark-small > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default-dark-small > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -39px -7px; -} -.jstree-default-dark-small > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: -7px -7px; -} -.jstree-default-dark-small .jstree-disabled { - background: transparent; -} -.jstree-default-dark-small .jstree-disabled.jstree-hovered { - background: transparent; -} -.jstree-default-dark-small .jstree-disabled.jstree-clicked { - background: #efefef; -} -.jstree-default-dark-small .jstree-checkbox { - background-position: -167px -7px; -} -.jstree-default-dark-small .jstree-checkbox:hover { - background-position: -167px -39px; -} -.jstree-default-dark-small.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox, -.jstree-default-dark-small .jstree-checked > .jstree-checkbox { - background-position: -231px -7px; -} -.jstree-default-dark-small.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover, -.jstree-default-dark-small .jstree-checked > .jstree-checkbox:hover { - background-position: -231px -39px; -} -.jstree-default-dark-small .jstree-anchor > .jstree-undetermined { - background-position: -199px -7px; -} -.jstree-default-dark-small .jstree-anchor > .jstree-undetermined:hover { - background-position: -199px -39px; -} -.jstree-default-dark-small .jstree-checkbox-disabled { - opacity: 0.8; - filter: url("data:image/svg+xml;utf8,#jstree-grayscale"); - /* Firefox 10+ */ - filter: gray; - /* IE6-9 */ - -webkit-filter: grayscale(100%); - /* Chrome 19+ & Safari 6+ */ -} -.jstree-default-dark-small > .jstree-striped { - background-size: auto 36px; -} -.jstree-default-dark-small.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg=="); - background-position: 100% 1px; - background-repeat: repeat-y; -} -.jstree-default-dark-small.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default-dark-small.jstree-rtl .jstree-open > .jstree-ocl { - background-position: -135px -39px; -} -.jstree-default-dark-small.jstree-rtl .jstree-closed > .jstree-ocl { - background-position: -103px -39px; -} -.jstree-default-dark-small.jstree-rtl .jstree-leaf > .jstree-ocl { - background-position: -71px -39px; -} -.jstree-default-dark-small.jstree-rtl > .jstree-no-dots .jstree-node, -.jstree-default-dark-small.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default-dark-small.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -39px -39px; -} -.jstree-default-dark-small.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: -7px -39px; -} -.jstree-default-dark-small .jstree-themeicon-custom { - background-color: transparent; - background-image: none; - background-position: 0 0; -} -.jstree-default-dark-small > .jstree-container-ul .jstree-loading > .jstree-ocl { - background: url("throbber.gif") center center no-repeat; -} -.jstree-default-dark-small .jstree-file { - background: url("32px.png") -103px -71px no-repeat; -} -.jstree-default-dark-small .jstree-folder { - background: url("32px.png") -263px -7px no-repeat; -} -.jstree-default-dark-small > .jstree-container-ul > .jstree-node { - margin-left: 0; - margin-right: 0; -} -#jstree-dnd.jstree-default-dark-small { - line-height: 18px; - padding: 0 4px; -} -#jstree-dnd.jstree-default-dark-small .jstree-ok, -#jstree-dnd.jstree-default-dark-small .jstree-er { - background-image: url("32px.png"); - background-repeat: no-repeat; - background-color: transparent; -} -#jstree-dnd.jstree-default-dark-small i { - background: transparent; - width: 18px; - height: 18px; - line-height: 18px; -} -#jstree-dnd.jstree-default-dark-small .jstree-ok { - background-position: -7px -71px; -} -#jstree-dnd.jstree-default-dark-small .jstree-er { - background-position: -39px -71px; -} -.jstree-default-dark-small .jstree-ellipsis { - overflow: hidden; -} -.jstree-default-dark-small .jstree-ellipsis .jstree-anchor { - width: calc(100% - 23px); - text-overflow: ellipsis; - overflow: hidden; -} -.jstree-default-dark-small .jstree-ellipsis.jstree-no-icons .jstree-anchor { - width: calc(100% - 5px); -} -.jstree-default-dark-small.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAACAQMAAABv1h6PAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMHBgAAiABBI4gz9AAAAABJRU5ErkJggg=="); -} -.jstree-default-dark-small.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default-dark-large .jstree-node { - min-height: 32px; - line-height: 32px; - margin-left: 32px; - min-width: 32px; -} -.jstree-default-dark-large .jstree-anchor { - line-height: 32px; - height: 32px; -} -.jstree-default-dark-large .jstree-icon { - width: 32px; - height: 32px; - line-height: 32px; -} -.jstree-default-dark-large .jstree-icon:empty { - width: 32px; - height: 32px; - line-height: 32px; -} -.jstree-default-dark-large.jstree-rtl .jstree-node { - margin-right: 32px; -} -.jstree-default-dark-large .jstree-wholerow { - height: 32px; -} -.jstree-default-dark-large .jstree-node, -.jstree-default-dark-large .jstree-icon { - background-image: url("32px.png"); -} -.jstree-default-dark-large .jstree-node { - background-position: -288px 0px; - background-repeat: repeat-y; -} -.jstree-default-dark-large .jstree-last { - background: transparent; -} -.jstree-default-dark-large .jstree-open > .jstree-ocl { - background-position: -128px 0px; -} -.jstree-default-dark-large .jstree-closed > .jstree-ocl { - background-position: -96px 0px; -} -.jstree-default-dark-large .jstree-leaf > .jstree-ocl { - background-position: -64px 0px; -} -.jstree-default-dark-large .jstree-themeicon { - background-position: -256px 0px; -} -.jstree-default-dark-large > .jstree-no-dots .jstree-node, -.jstree-default-dark-large > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default-dark-large > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -32px 0px; -} -.jstree-default-dark-large > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: 0px 0px; -} -.jstree-default-dark-large .jstree-disabled { - background: transparent; -} -.jstree-default-dark-large .jstree-disabled.jstree-hovered { - background: transparent; -} -.jstree-default-dark-large .jstree-disabled.jstree-clicked { - background: #efefef; -} -.jstree-default-dark-large .jstree-checkbox { - background-position: -160px 0px; -} -.jstree-default-dark-large .jstree-checkbox:hover { - background-position: -160px -32px; -} -.jstree-default-dark-large.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox, -.jstree-default-dark-large .jstree-checked > .jstree-checkbox { - background-position: -224px 0px; -} -.jstree-default-dark-large.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover, -.jstree-default-dark-large .jstree-checked > .jstree-checkbox:hover { - background-position: -224px -32px; -} -.jstree-default-dark-large .jstree-anchor > .jstree-undetermined { - background-position: -192px 0px; -} -.jstree-default-dark-large .jstree-anchor > .jstree-undetermined:hover { - background-position: -192px -32px; -} -.jstree-default-dark-large .jstree-checkbox-disabled { - opacity: 0.8; - filter: url("data:image/svg+xml;utf8,#jstree-grayscale"); - /* Firefox 10+ */ - filter: gray; - /* IE6-9 */ - -webkit-filter: grayscale(100%); - /* Chrome 19+ & Safari 6+ */ -} -.jstree-default-dark-large > .jstree-striped { - background-size: auto 64px; -} -.jstree-default-dark-large.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg=="); - background-position: 100% 1px; - background-repeat: repeat-y; -} -.jstree-default-dark-large.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default-dark-large.jstree-rtl .jstree-open > .jstree-ocl { - background-position: -128px -32px; -} -.jstree-default-dark-large.jstree-rtl .jstree-closed > .jstree-ocl { - background-position: -96px -32px; -} -.jstree-default-dark-large.jstree-rtl .jstree-leaf > .jstree-ocl { - background-position: -64px -32px; -} -.jstree-default-dark-large.jstree-rtl > .jstree-no-dots .jstree-node, -.jstree-default-dark-large.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default-dark-large.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -32px -32px; -} -.jstree-default-dark-large.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: 0px -32px; -} -.jstree-default-dark-large .jstree-themeicon-custom { - background-color: transparent; - background-image: none; - background-position: 0 0; -} -.jstree-default-dark-large > .jstree-container-ul .jstree-loading > .jstree-ocl { - background: url("throbber.gif") center center no-repeat; -} -.jstree-default-dark-large .jstree-file { - background: url("32px.png") -96px -64px no-repeat; -} -.jstree-default-dark-large .jstree-folder { - background: url("32px.png") -256px 0px no-repeat; -} -.jstree-default-dark-large > .jstree-container-ul > .jstree-node { - margin-left: 0; - margin-right: 0; -} -#jstree-dnd.jstree-default-dark-large { - line-height: 32px; - padding: 0 4px; -} -#jstree-dnd.jstree-default-dark-large .jstree-ok, -#jstree-dnd.jstree-default-dark-large .jstree-er { - background-image: url("32px.png"); - background-repeat: no-repeat; - background-color: transparent; -} -#jstree-dnd.jstree-default-dark-large i { - background: transparent; - width: 32px; - height: 32px; - line-height: 32px; -} -#jstree-dnd.jstree-default-dark-large .jstree-ok { - background-position: 0px -64px; -} -#jstree-dnd.jstree-default-dark-large .jstree-er { - background-position: -32px -64px; -} -.jstree-default-dark-large .jstree-ellipsis { - overflow: hidden; -} -.jstree-default-dark-large .jstree-ellipsis .jstree-anchor { - width: calc(100% - 37px); - text-overflow: ellipsis; - overflow: hidden; -} -.jstree-default-dark-large .jstree-ellipsis.jstree-no-icons .jstree-anchor { - width: calc(100% - 5px); -} -.jstree-default-dark-large.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg=="); -} -.jstree-default-dark-large.jstree-rtl .jstree-last { - background: transparent; -} -@media (max-width: 768px) { - #jstree-dnd.jstree-dnd-responsive { - line-height: 40px; - font-weight: bold; - font-size: 1.1em; - text-shadow: 1px 1px white; - } - #jstree-dnd.jstree-dnd-responsive > i { - background: transparent; - width: 40px; - height: 40px; - } - #jstree-dnd.jstree-dnd-responsive > .jstree-ok { - background-image: url("40px.png"); - background-position: 0 -200px; - background-size: 120px 240px; - } - #jstree-dnd.jstree-dnd-responsive > .jstree-er { - background-image: url("40px.png"); - background-position: -40px -200px; - background-size: 120px 240px; - } - #jstree-marker.jstree-dnd-responsive { - border-left-width: 10px; - border-top-width: 10px; - border-bottom-width: 10px; - margin-top: -10px; - } -} -@media (max-width: 768px) { - .jstree-default-dark-responsive { - /* - .jstree-open > .jstree-ocl, - .jstree-closed > .jstree-ocl { border-radius:20px; background-color:white; } - */ - } - .jstree-default-dark-responsive .jstree-icon { - background-image: url("40px.png"); - } - .jstree-default-dark-responsive .jstree-node, - .jstree-default-dark-responsive .jstree-leaf > .jstree-ocl { - background: transparent; - } - .jstree-default-dark-responsive .jstree-node { - min-height: 40px; - line-height: 40px; - margin-left: 40px; - min-width: 40px; - white-space: nowrap; - } - .jstree-default-dark-responsive .jstree-anchor { - line-height: 40px; - height: 40px; - } - .jstree-default-dark-responsive .jstree-icon, - .jstree-default-dark-responsive .jstree-icon:empty { - width: 40px; - height: 40px; - line-height: 40px; - } - .jstree-default-dark-responsive > .jstree-container-ul > .jstree-node { - margin-left: 0; - } - .jstree-default-dark-responsive.jstree-rtl .jstree-node { - margin-left: 0; - margin-right: 40px; - background: transparent; - } - .jstree-default-dark-responsive.jstree-rtl .jstree-container-ul > .jstree-node { - margin-right: 0; - } - .jstree-default-dark-responsive .jstree-ocl, - .jstree-default-dark-responsive .jstree-themeicon, - .jstree-default-dark-responsive .jstree-checkbox { - background-size: 120px 240px; - } - .jstree-default-dark-responsive .jstree-leaf > .jstree-ocl, - .jstree-default-dark-responsive.jstree-rtl .jstree-leaf > .jstree-ocl { - background: transparent; - } - .jstree-default-dark-responsive .jstree-open > .jstree-ocl { - background-position: 0 0px !important; - } - .jstree-default-dark-responsive .jstree-closed > .jstree-ocl { - background-position: 0 -40px !important; - } - .jstree-default-dark-responsive.jstree-rtl .jstree-closed > .jstree-ocl { - background-position: -40px 0px !important; - } - .jstree-default-dark-responsive .jstree-themeicon { - background-position: -40px -40px; - } - .jstree-default-dark-responsive .jstree-checkbox, - .jstree-default-dark-responsive .jstree-checkbox:hover { - background-position: -40px -80px; - } - .jstree-default-dark-responsive.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox, - .jstree-default-dark-responsive.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover, - .jstree-default-dark-responsive .jstree-checked > .jstree-checkbox, - .jstree-default-dark-responsive .jstree-checked > .jstree-checkbox:hover { - background-position: 0 -80px; - } - .jstree-default-dark-responsive .jstree-anchor > .jstree-undetermined, - .jstree-default-dark-responsive .jstree-anchor > .jstree-undetermined:hover { - background-position: 0 -120px; - } - .jstree-default-dark-responsive .jstree-anchor { - font-weight: bold; - font-size: 1.1em; - text-shadow: 1px 1px white; - } - .jstree-default-dark-responsive > .jstree-striped { - background: transparent; - } - .jstree-default-dark-responsive .jstree-wholerow { - border-top: 1px solid #666666; - border-bottom: 1px solid #000000; - background: #333333; - height: 40px; - } - .jstree-default-dark-responsive .jstree-wholerow-hovered { - background: #555555; - } - .jstree-default-dark-responsive .jstree-wholerow-clicked { - background: #5fa2db; - } - .jstree-default-dark-responsive .jstree-children .jstree-last > .jstree-wholerow { - box-shadow: inset 0 -6px 3px -5px #111111; - } - .jstree-default-dark-responsive .jstree-children .jstree-open > .jstree-wholerow { - box-shadow: inset 0 6px 3px -5px #111111; - border-top: 0; - } - .jstree-default-dark-responsive .jstree-children .jstree-open + .jstree-open { - box-shadow: none; - } - .jstree-default-dark-responsive .jstree-node, - .jstree-default-dark-responsive .jstree-icon, - .jstree-default-dark-responsive .jstree-node > .jstree-ocl, - .jstree-default-dark-responsive .jstree-themeicon, - .jstree-default-dark-responsive .jstree-checkbox { - background-image: url("40px.png"); - background-size: 120px 240px; - } - .jstree-default-dark-responsive .jstree-node { - background-position: -80px 0; - background-repeat: repeat-y; - } - .jstree-default-dark-responsive .jstree-last { - background: transparent; - } - .jstree-default-dark-responsive .jstree-leaf > .jstree-ocl { - background-position: -40px -120px; - } - .jstree-default-dark-responsive .jstree-last > .jstree-ocl { - background-position: -40px -160px; - } - .jstree-default-dark-responsive .jstree-themeicon-custom { - background-color: transparent; - background-image: none; - background-position: 0 0; - } - .jstree-default-dark-responsive .jstree-file { - background: url("40px.png") 0 -160px no-repeat; - background-size: 120px 240px; - } - .jstree-default-dark-responsive .jstree-folder { - background: url("40px.png") -40px -40px no-repeat; - background-size: 120px 240px; - } - .jstree-default-dark-responsive > .jstree-container-ul > .jstree-node { - margin-left: 0; - margin-right: 0; - } -} -.jstree-default-dark { - background: #333; -} -.jstree-default-dark .jstree-anchor { - color: #999; - text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5); -} -.jstree-default-dark .jstree-clicked, -.jstree-default-dark .jstree-checked { - color: white; -} -.jstree-default-dark .jstree-hovered { - color: white; -} -#jstree-marker.jstree-default-dark { - border-left-color: #999; - background: transparent; -} -.jstree-default-dark .jstree-anchor > .jstree-icon { - opacity: 0.75; -} -.jstree-default-dark .jstree-clicked > .jstree-icon, -.jstree-default-dark .jstree-hovered > .jstree-icon, -.jstree-default-dark .jstree-checked > .jstree-icon { - opacity: 1; -} -.jstree-default-dark.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAACZmZl+9SADAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg=="); -} -.jstree-default-dark.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default-dark-small.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAACAQMAAABv1h6PAAAABlBMVEUAAACZmZl+9SADAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMHBgAAiABBI4gz9AAAAABJRU5ErkJggg=="); -} -.jstree-default-dark-small.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default-dark-large.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAACZmZl+9SADAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg=="); -} -.jstree-default-dark-large.jstree-rtl .jstree-last { - background: transparent; -} diff --git a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default-dark/throbber.gif b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default-dark/throbber.gif deleted file mode 100644 index cd75035ce8086b233c62c3775de4696007ba7950..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1720 zcmZ|OYfMvT7zgm4p2O+ea@rnBg#%t_w^9y@rd%z;T+7W;EEIuRP@n~of>p{*LD94n zD#dD%>4eQ7(f}2w1Jp&gxD-%9@q$L8PU8@DI@}hSaq0)%%HqfF!~5+?{=fX6_gR&k zB#zeL6rA#kLJ1EKkB*MkYPAxH#A31N_4>ZPK7+x~*4Cy{sgz1(XJ@Bct?upZwb^Vn zH8uQyJW~@hGvcMn#IR)|7@|-p{15)|6-An=q7A%lB~@CUrc_g-E7NRPRY{9GBtGW2#F<6Tlp*{3e2sO*9QTn07T-ayS_ZHC-#O>$xhqqdcpZ ztmi!vPe)MeZRuUe$#kkQ=ZCx#&BIF_bl`&&kBftO#70Qh(%BzvH^%Q*V^7k&A({sT z%Y^lTu*avnIgG+U1|!SMokH(YXlu`0j~)X}p;*dbvgwiG8ou~G0H`U%D%A}cX`Z7O z)ni(eb`a})TPHM1hAVH$IJP)wYgYnn9eF%-V%K@toW*&nV8eM+!Cp9L>Vhol^Gh@~ z%&1Z5Vm+|c!un0R(q?jRP)d+nM1>1Mdbt4 zq+z&G4Mf-;dC=>aU>rU4#Qsu;p3RpG$pl+_MhkB8a)~L$l9^5fWiX2+H!!5_T5s^9 z4>JK<{X^Fo%S_uDF%5Ow6`@;%!WN<1E;i0BB-n*W1?E{l7sBj|dY;=Uk(#XoO1L_N z@qGP~b}*65jDQozoGo?S4(63|3?uFyzC7?Gm+`Y=Q}V!~eW9^>IiUQTB_L<1=H*gdQy5&m_IYV z%Li4Uo_>Bi7os#uY}WcRfHHEkH&b8~%gsue?-o<(!aOHjm`s4Z3LOy|RiA_cGTpV7aX)L(k3WdLrb3z#~FKmqZa8IsfA0m#1pKiYPj1TEN53e>tkg z0RTNlJq#uQVrLpQqdM5r6JnuD=hIQXX(5PA4}{kHxmV1!p*>qQvt#tEygNOAs@+Oz zdfw4ZMdhbk+u}+OPG5|*-o?V{NXcn0HBbAn)h^Y1-B04pOzSBDfelR>`teLE(^ROI zh&b$euUUs^kZN*1k{J%gadZHxgJ?{nH{AjOmJrF77iSdv|L<1j9OLgC{;#V|RJlr& zcSW6j{0-Aeuhh1H@4Gt=_&ggRSH>Bn1;_M62O`)zlyTGNWU^sE&gnQmJ~HG$aPw$; zKX(DOIsRy?o{m{z>42;$0!CTTcF2R3?au%K2(p-Mna`zCH@bI}ee7d=$K>rPkFF?8 zv$nvf0d|7yp7!sKocJY+u zY6SVs9!-4A?3JGvc^gfN8$7Nen2o=3aWO!QO@le}aMdx8^`2yXn=H9`9ATLE&9>s? q)n(GDbX6ch9<^Oe2Q%ytegccF@POz|8L)A;FQ!??rHkeqG5-P<(jCG8 diff --git a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/32px.png b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/32px.png index 15327152481789306eadef88393cd1c748dc31a7..4357b910285aba63ad76538b347febe2c2007c8b 100644 GIT binary patch literal 5667 zcmaKwWmHsc)c0q`0cU6!TACrG1`$zEB&3m&6lnn|5owSZx}-t6Q#yvBTSAZ&q#LB9 zYY5>Pyx;fJv(|GyoVC|Jdtb5E+1Ky-?+{gGSwcKoJOBVdC@&}V3IG6#V{Ib{F7|Ds zSj-6kP;ALdNocrE@1)`DXpB$yJPyuItBR042%hSC<1{KLuPRnkRmIcFaM|*f-NJ1^ zK*jY!;i;urI>(-D=T`y=1%?EBfvgaJS$poCG~!`bqOHy@fmng0x)-1##= z(zNa7HAH)AW4_azbbes?skB)Z#PnCUPDde2RyzXlIm9WMIQW&3dQX5=fO@;74rmlkFZ45viAovCBhIH+X9qF`+Ji3X z(R zku1z9CcfV^bea1@3X4mltxs?)zSW~vAT4N`b%B;1oKC3Tk6;POU-Ejrp)#}KusS{FTPfE{?lP@k{QE!Tm?txc;qUI8$zJbQA9*3kgrwBm&jj{Wk z?7E4IUR2W!8Z?%6folkF3EEE`-&fTC+%`s`ld=&W;m{bar7je=YlEYWXv1AD<_V6r ztb|5gGx;pMmvxBFXa-yKNR1UmwDO6+>-+Ho$=r`bp#*aa3RtuBIs<`+=XEW#u^AdI-wbk>5tSCs4mw#)?rkGSm(HWmBRtlZ&^?vVH-`RVy zR*ewr>6nB<1iXSHvkiM{qk$)&*^e?o@l?Ot9?#wDKT)qZ9@XFp%fKCKqheC}xLFMCaWg(dd*|MUY_e2>R!7*>1V?vxxHpmG;Xk5}xZN=^xJpa2M!EZoqH< z9vB?=yKc{lyVCFZJ&qv!_QQg>>5mvF!@FM3>3k9|$|4a$@cOuwe^-|-TzoYcjPbrJTFG>c z!z1Sb%wUgb=a7H9|8e<9QaNYex#ZsU<1OGzC_U>hO%>#*=|mPQdOql*Y=hCCEM;nn zDco`?m%w+J*hJ?=n$IB(_&myBM7pD>s95gw*}r!Q z@aylyO3H*eIcV;Hyz5TY38rT$7_ubom?@{iXMa+5cF-+R!rR{m`Ahh=-*abXe}KNG zE2IR$E8`8qY&4LlS;|tJNiJBX{oq&TRKT0v1CAs!=t%7TGVE9`SOsa|P4j&sMw<3z zrDIqCc#|$mfIrh6M7~bTfg|R}+&;Juu?;fLqW9mQeyd~mscz58j|05h{(h-`o5rm| zMhQ6D0?wEYYAv~eF%ZY`8>RU7IQjyhfB&)_!;TFd5JZN-EtWSmQHIK+6PyioDwL`3 zSu}EGhqzH2;7PhciJE0g=F%<9Pp?-UVJdRs9!&vYX36G47!1M6HpSAe@zFMl?19p2 zwKqt|rsk{e6!&wvjhz+b{2TZ)R2R_GgKfCVAbWRbJ2<3K=KFRLuXxOK{(k93P0>S! zYhB5V0WGPS$P!mT&>%y6q>tInI4m<3?v$B4xPBjml8(+iJUUUoDJqcWX!|XIH>Ha+ znH(XugYc}NIG>WVOZX6)2wbkR4~wt<jGh*aUvx`{L_473{Efq%i?Ai4*V!%>RY}B8sB1< zCh(TVrqoyxV`x)2>!)Dqh>x_=k9v+`_z$Mp+6r!yiMsWRPOt-iQz4r@|qs3^){Wb zQP&+#6_HSC2$)9c?@~bwVR2ypGWof7S;zsb3G-9} zdxf~Pf@B`+5?CqP+vZ_@nZ>_$*Tj*M%$j(lxt5d9L@{obRCxcpl;%f~A_d#b{4wM- z-t-rnL@xYQr%jhJ1v`by<2)5HX`5H%R|tf}{yCujZ@z-b@n6yFTP%_~77C!&I_0b5{Khx%Vy%>gsDrKg5J2Ge>_4&uy@RcVCUU~*W zzs4nzgl7w<)HY%(#0$mv(K>FBr9h|s6Z(P%4>^nQEXa@+5G_HNhFt;qyYGkV`5i;c;eKd27dPoRyeqrgG_f2F7#I)ux-YMT6bc5&iy_r7M{RrUZ*6?$?$~1t%Ymr>dP$(+ zmI*k&tZiEAgJbH*KOi2oqvQ$Kx{%=!(PPR&!5Tn{G)SWbHO;^%F4A`TC9@f3q$qYx z2^=i>Di;YGRTOvYv($(pcz9w@ThgaYw!Zd?M}IY2aNDijCLZU>j7GFK#ZB;G$2<9z z3g)*0LgoWVm0vs<>fqW+R&O8IT{c(QYfYO-caUT9{P>*p4d6$lH{SeukkJ7#!sImi zL9lQG=}6GyrRI%l1wyy;fC}XJ^6&3~qC?aX=TMV>)v7wDqHsv)Ju0=NkMdtkG|_T_fpCp=buNVo z8Kj#w|4jwQHR;W>=gPF~INomy|N7b`)cj1(Fk zq$LQvAm#kz1sKPWaNQ_*S(j?XT;BIz`dia*L{z3koUd(~?ElFP$#>ZZytixi{Qzs2r;&{xDV!dz;r5g<7_p$R>p4sJDkldQm#AH zedQTs^8Cud{1Url>SxvH$;@N`uOHJGj&k>E1=S+ytbtsiXkhR(Ywn#{zW|JL4e4gT z+AuE6Z;Xnm`Pc3w$usmd!!rg><2E5^yo%2V zmG^@E@bsV?nURgzT)TWb*Wc6eEmJKS5|vBoZuE#j*NOQ5!!qTL)@j>j^^(wKc`4w7 zwuPi%BfYs2Q-20CW zyvmc^`$3LKy-Qu|3`U%ddZ#9NZs6!OE-vE5UY@s9IU;S?!4JluZ;yyzIEg)*bH1rb zhIlsCBmG`JD{jb_vGDdUPf6Valb%n;UA-E_#Y3~6UpbSrL6{Au5%9VNt{%@5 z?avk;*@AbG%8*^n*n|bwSPo{>^_uuC?X?~$o#XTi2RkdgD1+)_-Q1TLpKv?Fzf{la z-ARNrzfn8XFS*}xLi9fNX=g2mY|ji;Fj1Bc&Kic{%lC4jQfzM zCbKLM*Uw6@kt}y{FNnwU={MxBQU`7Osr zzk{#v8ttRSf0GzhpWl%={-KeBp1OQtKq;ug&Y{qdgk8nqmHfC&P5auo z&_g_G0^BIb`HLYt5XujLrLq}vXgu1ky?Uq^wFEBo0X%KKS*$J(YNlR(HlDZ6`+cafv4^(V#o2Yx3X{ht zW3+`=qI4|NQ$HtDd~o+lIi^JfA#@VRq^LSp|In&HMfSW%vrw-JtW%AvQ%f{ig)`Yg zKiSGyNi2%e2;<|FkMw`BKsqxFe2E#i7 ztn52$%_vN05^+%%S|uJL=GPz(}KlSsAZFq90X!~+O~EqZf`7i{X!^)PN|i-=v{cgVEd- zOzipNi@em@K|=qDgXgX*lj1)gL$Kv!2h!N4!=mjSBPLrZU$zi@MiTZ%X4f*z*f_!tKV}jAqJycuxj0o? z;Lmkp(LD?9HuQUrwECmLQSyVTO%NOOl}p`Lv}}}^wN}UudD0h-Hsf^ur0snN>B;{_ zcOaiEzEl+b^C^T~|Voqc3K(=C|^C0WORD=>1ibKu9;e=1-+9d~8?y<-BK@)WT*Z`P1G z_j584&)=zVw+5my(>wRig+-KSw-;4EDKyQ#1`-D9F;CZYYL3tkRuM(43O~)USrn&c zS1y^GsoD1bA_NhzUzJ0|e%H7IGb$?flXrA6`?k_BEmD73Yt`Dlw zQ_U@ol0$^bb)T}1C@hzocav$7M>DFA#Lhy#B6{fPNm&hI^1r20RLzWMb=p4QuUgN> z2zMq!9G*J+w|CwloohslzCtSTiV+hN2a&SMxQ=URYsYR_4Cmx`gVK(QbCL&dpg&Rp z*ovW5_CIy>JdLJk#=G#C-=5xy$p{7Ik}mFg4Gu2sQjmS7gk?wKk>ZL7k67&a`EM}n zJ$omLa6KPcK`-l?Fo!AxN@Qj!{G_lDjW zT^LY8ehHdng<&d-z_N?UGV=iu+7gU@MH;2ZvfU&Ds#gDk)iGP*Pd5FU3%4q{tQ_Lo{TYq8P+T z5f#GN%GeTPjAdk><<7nLm-{E&_xqgZdpqwR-se2d>%6h{=dAYeOYs8$u+JKG+5rG~ zOu2J3ADEkN*=|w*00!*sE}h{nU5gzdXvqoyFfcHHKp@!$I+1Y6afnM?O0B%x~Mb|(c2l@8#hDXMUCqv2rKqy4I z6@l2QsK7&^+`G<=>TiUFIV{dwI6NXUP9q(8;688n@#F0Z3P+RG9BWO&y3Wd_@m4~i zfQ#s{=Yr)R(0o!-H6PzfW~NXatPBR*Sl{p>ntc@%+{n!IZL)@WiKq143Tt=C{~6=) z#wLv%lr|8&bp85}we>p*iFp^7MIWDf2;?yUERGkpN=p-*^qJcXSy}1Q($eY58ypU2 zX^F0^tjuPzD1|<|%hQfdZrn#9^MUR8Vb&(u-6wc+W0SQ_Ut_FIPEJu57WNp_sV|SW z=$*NFxy7lDy0rjEkH9@092{C5XjuQ%{CA?0I`X2sF1DfgdM_zs;v3#Fz#<_LySlof zSHrtCH&jL}+g+Yoq|u)Lx!yb5F+DRA77=^=C7@ji>@gOud^)P}3b-?ZYFJC{+pKl1 zF=y`W4FJFb0MM4`1M{5*1m5}i`OVq>SpcB(@Kk&)F>QeAK9f!yJzKZ(@O+y%d5Fx~ zqSe;U+I$e&S{!@3@bojOP%#G*HDo?FH^=zPn4nOG$iqE6JRgU;aFm3n!@+*vv^=UU zkGufTU1~}x2=XAAlbbsRg>FvutN{Sq*O#@uwD;)IQLJp>N88449|~pzhqs%SR+eJB zTzA%g*Z#_T@--l`)itEqDL%fD@cG^F@EE7QegXhkk&)ZV%4@?-t0pEiVc`p(#IAih znLOb2aL^k|Mwd^fRINq@_3C%`H4?s8Z_z35#l*ac7MogHly4QB%F3jiWL#6}g_nlk z$gPk1{7XiYAG8LZDv_zobIhLgC?Lm{P=nfjyfb=o;=@|D)?-y-OU|=5MQT|h4y}hc z6bh%in-do|(OW_2c>i^*qoKfMAv`=hH=>}xKI&XTi_GMefcdn{)x+M3EIZkkl&>W z+}@+UYHm9PvX;jn)BoFXpCC6I`x5++Z98xoB9S;IbW{@)ac9Nj&6^J~RG(PdMnt)+ z=%ZngTU%Z*R@n~9y88kev~gJoMlZf`S*U(cJZ;|KUYAdCdqi#8E1%>Ig6T`G$LG-z zPZ)@DjZ#(q?mA~R4*?ZF#`|ua>%9f32~Y>gafc7yUo$+-FsiDZaChLamHi|(9B~zC zH;IMt|E2@%*PX;K9MstygLL>rm*8p2NpHJfnFCkKB=g zAiRc>g*Ry94~dQVU5c{gyxF&urRuLBp=ghu-n1?n$;!zY9`e_KY_7A1libqmFKr~} zd&bU@9gA_K)U018s?Iy3ao|$WHO+S9F^u+ZS^&Yd`l8e!Oa2=|D#2YX=Z`4p_5Hjs z+F%hn^x1YYw_y#n(Rswy#)Ca|=YX0f7_Vtz3Hp#_LR!nadf48Q<2G2%zTvmS~^R$iV#1Dt8#s}wR82k3O#nwV zuE+&ifu5~c^5O|V(^m31F^Sa1*Er3W=~HKlgZRxRenpOQ3vto3k}09L>o;Q^S!ryec}Tf zV&e!k80}<5?cI^O{mDM;n_}k21o%sLk%teP+;7e3Q9;SG$U2ST9m>J6)klwjv7y)T zjT2NV)j`znGSmr|$~M4^Dl|PKfh;oO?vX&Uo+cMP+or9eVhh!~u%C#bpP&)#`t~`d z+3uLiXSFX@2p_?7SOtYU{Z^cO~x5Pi0ONSr963q)^Pm5Gc942(Hv6Vvn;5<$!3 zyEbi>sbw$x^}Oz?sYt=1i_3eji=vO-fbg2)5BcO*1v_g_`s~g~V3MJ}av6t|{ggUG zRrD|%i5AP5=@TXaioz%m9EpK&t?!6HD+-b6rU;Zg90^CJLl7vC5pG%@4zc!!^#^K7 z#suSnAmcw#VwCew4K#E$`bt|M%1!hcnR6H}t?m%e6wrF;(O8Ox~r6 z=>3_hju^O_rlNmi;!r*>Tsq}w|OrU||lQz?PytEZCeyXg(6c$6TSOB3y zX$uA&^wG|ACmFa4!PQnrV1Z+o0XTE!Wu~CEio0B{RN9(Dw7}UlbCIRfpzkHHTzMmF z#NG%}yIXKphmSvQ&`HkOwN4hX-OZ&;OYJnA-X#rfTWPL&gN&Y@`oYM)mp~4fO&n_b z^ULL%D^in)Bl#WUg={)6RSGdfDd$Y(J>{I8x<+8^stgrPG>D$%#01VVv{i`lYW;K1 z?;ntQ3<5o4Y+&A9>wE(GNrthn+Cx<_(N!n=c_Q@9*D^?(bbAi|y?})L&E6}tm>*PE zBLQg$KK3 z%k$3EFAGbze#Gb>z6O*3{r1v*=a?IQfD=SlAz=485&qfD>dEpMTtD+elvh& zy=)E^hw1r&leGds7HEu1{Om5tu*JkU{SPd$;*5Z3zin_Q=1PVc7JNgQHW3*=CDUYz zd5?7uk*^WDR}=E!1b+QDb~fBk?GtIlH2Xjj^SHn6m@2gQ^niGkXM$;_RkCVYMl*XBu) zek5q=@t1yvU{`=tMQRPN_eFDkh1PfI|2_*tCdlwSDwFb@Hf~$83T0=55}Ulq{81g|>EmsIu@u zwN8`Y8zp@@&Qpy5FO60!@}+2Tyun-QtF%>`dhKgNf@hDWrRZ=U2d}H>`^{&DlDv64I&u>( z8uW=uGK=c7Psu$Hv@8;>zTt+7$`u~2m9z0|)7cfv+3PCBtFeuy&wye3rS%AWA~lN4 q$a=%VWn+k|UtiDv&>%>!2^rk(D6aNK_^-%!; diff --git a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/40px.png b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/40px.png index 1959347aea041d75a58d0584ea7ec51714797983..d0255223f4e4a4aea6a376097265a7203983ca6f 100644 GIT binary patch literal 2218 zcmZ`*cU04P5)TO^NQ;FgLQob&B!CK%C~bA=9L3-n3>Z+r2pR(mhCm<`UBa%EgOebF zvVy>qqTosqDT#E0-r*eK&v1e7@z)cjohE=6!$k^KnyG z(Nh6|K}YisMxPa+3$5eNjI!52L|Jp2WJ z4eagh8H$-Jaz|RR7$1MRRRBYw$|@R~28Mh5P6wTlNM)}>Whf8`w&~$~>?Gx_fE!p; zW~-JmsoX+r^3HjBXLHk^T3@Is+yi|d@T`PHp52P*P{>4@-x=3zC}L|@w2&ccx(7m- zDGCtizX1#oCn1Fn*Tn7sRXOq;T&@$&!2mkeOH4GbU$>W z-|GGh&eiYwsy&_T-aA-1s>_D5T0dr@Cj}a^1vefwXyO@FTaxT6;+0M9<^3H94;Jx4 zr)+sKz!j2+_sx_m&mSNri+IwhQ#@;+*)4tvA8q~668*l7m4RK&qdiii9){JL4m`px z*RR|wT$@uul%Mab*2X0)M|vYBDESriNIV=Usu*LLNRMAK%@`esh)BqCV&F3@ysusP zg>ehtd3Q#&zBY_O#^XjV#wJkAujlU=hK@08+HC#p-$vMpJ?sTtHBy^e@*J0Dgr`P# z%P`m1M1|6B8-Wr=%q}O6bJu=;g|q**zmwu(F`aLbg}rHu=TB0)%ct|$IYeOCGpObz&yg~5pQvHOm?%h5k4)nR@kynb~w z?TSj`(pkdOk6`ossHX}SwfI!%c=op|RuR+ZR*$h;0>t%U_!@nRzP30XY4&4Ms#ez^ zbGDnutn6N761rtf({2scY!`x6*=5NhbfrAGxAQRtxs9?FcPKt2!5y5UnSBtW-!%PM`v`p@;wo)Py}6Ps5qU`tD~OegYZG-wG<=noYq{s3DT`< zj%^j4MXCRxZ2p|_??=V3dD)g|=`=sB0i_&SH}ki>&82b2=+(y^)gLS`@(I5rmET}q z;cd`tCp^5Ag63-lgpsyRP39`Eg=WjM5ZF+1nkq_Oe58+nvD?VSK$#Osoz{ePsR50O zM%74-Eb7wHdEl+xZRS=JJPfl%w>5CRgu{-8UZ#0COGwVdz4fZQGxv?}umg@3tTZpapL8A`=3g>P z3J#7>prAeG$&ST(O>XWW5E*{Tx8(^3hu5lMpiw0m*kHZ-_LrsY>*2J6-bwKz8{glT zfg4wqqNUrF=1t%mF8fBW<5t+2H3b&j71jPsoeKW@3+4l;eAj5R|F+)$;ZRLicmN=~ z?9*m>vojY`cj@F6LYgeK9z!qV)gsj<+9$@e*VUD{70ji5Z%|tX5t4I2Q{qC;?qUAt_(?R<=A&E`k)y4~zmOam0TH#UGui?7*0+1}9RrWTo2Whw^g?FxYonMCpWxaES1Yat0i~G7r zn-$mI$Rqna_1r)l5;d0~RHPtT^+iLPhA(!b zEwwq;7w-YT;sn;jv!6TfAp_0C$yClM+y@ykwwP2;q$ zSE}~IqFQ7)Z2|9h9Wk1J?Fli<0gtb5Z~-M!!^6-PdW;RpJ*C`!kaXTJi8*whQHU5U zDvI5O#d3GfANgJ<>Sb0Ce3s}Ln%8yVW8^|$__2hPvg|M_nr-`oiPZ=NGojM}L(h4( z%N-eeS!NMFs=1x%cU2y*2^T#$oD7#Q+>{RkV?&hL6D|9nJ%n{+_dIo?o3~x83u8Vk zTbAWAUdCfX`cpo1cH9lvaA`7D7(^Q74>Quwd(C7M5w$UEP@dRztq87TWxnzhFN@2NLx^3=eEY8>TXPBdDiI%#QzFoh}MIY z7}ASg1}uzz$vpGPy>QxU9oES4RsJ_X?C_&H#|bUu%={CTVow}nKWHPZoZ>K+YIr2| ztzOPxh}juVK0q9P6x2Pk3pp2mtY$$YgwuN~ zSQs{SLkvT8oI`i^u&hIzfJs-r{zm|LxcE3fI3AMrFTEfO AIsgCw delta 1734 zcmZXVeLT~P8o+04^FHLPu9&x5@*ZKz%dSdcBF4dF(;^pVYn3_sl^Y(c@&*%9(-{+~;7wX>ms~P%i zV3;om1Um93;q&>sySsNo_5o6<^h?y!(=&}6dr_IbCnYop3)0Ow0{6 zW1wf3u-qLG2-@m@(kF~IE}dE`oII$Pd!A@jd?m$TW2eD2@AqRDmU6@=QbrtiPvKa! zBo}aL?wQ2GLTn>=-{DwZriv<5d*5L(t9!sei!;kP3El;yMfuHp8v=fsqWR89`fKzP zPUG|4)7ETy!IUBDf(-|J89}=pp0H5Ok8GP+B6iT^nl^-KR(H9bG7k6y{>^QWMQ+p{L^x+fyRg}z8u^v z`N|DL0RCRVZ7=ALa+)oo+H+~)*)SCT)ymoVPoSWHhV0YwD|bysGIc7 z^rl5Jq7t{!+umWn(QS?Sz>WkS&BZru^B0Zmb?>a{IkFDm$3r>2Ei_i%Y9Zzw6K?Bq z>RyPN8Ng=QVeD2c@WJsW9KW&iain=FtkJFMkjyX{`?N$C-{fw~EsgVAj}4J0bcRE- zTs1l|ol(Uhu_2mm`x|Zir;i9z;k^<~=MFFX1Y$?>yta(_6%jpH=qJ&#)ALYmyUC?9 zo-gz2h=BN1(+LVgXvy}M7))9~Us?`gZU$V;FM!2hpm1%t21sv4AF^spclE*aU&T<1 zG*F|@;*3U^UlVX6!PjqwA~~s^#fB=ie$i`3X_29Zl(fZ%{h+^9&GKpQd&rvig4Ha5 z%~>}-U|!!Xb(y z$U#;-+PqFq929$q3a_P3n+8D~EYz1#Mv9gQ3q)qPsBnxyTA3o0Q7P{omn%?hJA;Q- zq;1tFDAcrBLxud|FQX~2jP0-y0J8$k*p3{vy#mcRAov8H%1Tb-;!WQ#;yXu5zTU3t zOK5(r_xj44Rd*x9;qlgQG-sYlFs2Z%c@s|;HT$xH;tgQz2pnFM-9ql~N&6sGR{`;s zyVo8tK3C1v#zu)Jzca&oyAso@eZ9BhGn~(Oa}(3s!_ah6`tft+zr=bW=X}a@h+Zt; z@{4g^BJ}__~O9+pfb&ovheXF8-CU946i?eB1H6=!nk$d7~IM9_!1&HO`Wq)($akCBv*`Vm2HcM;{#IQR2t{`RZRJmRiOB&y`R(np1MS%LxaT7%SFg4M*o>=t@{}*JVHqf5k(C zq1x^)N~CbZnb?*~f9ghCXts%US&5tQY`0bNVhng?jrBXMX$NIqphxghc{SfNlogaG zXGN^2sEu}m4{e#Q;x50LJAY3Mtiz|tV^TBH>QWD)dpG`EXI*$njIo<~eW0@!dvT&? zgIAQ;3X34=GE~PLUQc%=r3sDL&Q!U$x~!*Vh?_^{d=z3g*coRtEr}iNMCQs`9Qr@k zY*5`DWy$W zN{bAvF+)aA*p(rXdwV+y&=IMgLvZ*l9KLU&asb3GCH&yn|BmP#82`-f=k={$|FYh) z;}=TtG5^$PN~^P_cfNHXJOwB+tK3UMcN# diff --git a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/style.css b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/style.css deleted file mode 100644 index 674f87cc0f86..000000000000 --- a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/style.css +++ /dev/null @@ -1,1108 +0,0 @@ -/* jsTree default theme */ -.jstree-node, -.jstree-children, -.jstree-container-ul { - display: block; - margin: 0; - padding: 0; - list-style-type: none; - list-style-image: none; -} -.jstree-node { - white-space: nowrap; -} -.jstree-anchor { - display: inline-block; - color: black; - white-space: nowrap; - padding: 0 4px 0 1px; - margin: 0; - vertical-align: top; -} -.jstree-anchor:focus { - outline: 0; -} -.jstree-anchor, -.jstree-anchor:link, -.jstree-anchor:visited, -.jstree-anchor:hover, -.jstree-anchor:active { - text-decoration: none; - color: inherit; -} -.jstree-icon { - display: inline-block; - text-decoration: none; - margin: 0; - padding: 0; - vertical-align: top; - text-align: center; -} -.jstree-icon:empty { - display: inline-block; - text-decoration: none; - margin: 0; - padding: 0; - vertical-align: top; - text-align: center; -} -.jstree-ocl { - cursor: pointer; -} -.jstree-leaf > .jstree-ocl { - cursor: default; -} -.jstree .jstree-open > .jstree-children { - display: block; -} -.jstree .jstree-closed > .jstree-children, -.jstree .jstree-leaf > .jstree-children { - display: none; -} -.jstree-anchor > .jstree-themeicon { - margin-right: 2px; -} -.jstree-no-icons .jstree-themeicon, -.jstree-anchor > .jstree-themeicon-hidden { - display: none; -} -.jstree-hidden, -.jstree-node.jstree-hidden { - display: none; -} -.jstree-rtl .jstree-anchor { - padding: 0 1px 0 4px; -} -.jstree-rtl .jstree-anchor > .jstree-themeicon { - margin-left: 2px; - margin-right: 0; -} -.jstree-rtl .jstree-node { - margin-left: 0; -} -.jstree-rtl .jstree-container-ul > .jstree-node { - margin-right: 0; -} -.jstree-wholerow-ul { - position: relative; - display: inline-block; - min-width: 100%; -} -.jstree-wholerow-ul .jstree-leaf > .jstree-ocl { - cursor: pointer; -} -.jstree-wholerow-ul .jstree-anchor, -.jstree-wholerow-ul .jstree-icon { - position: relative; -} -.jstree-wholerow-ul .jstree-wholerow { - width: 100%; - cursor: pointer; - position: absolute; - left: 0; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -.jstree-contextmenu .jstree-anchor { - -webkit-user-select: none; - /* disable selection/Copy of UIWebView */ - -webkit-touch-callout: none; - /* disable the IOS popup when long-press on a link */ -} -.vakata-context { - display: none; -} -.vakata-context, -.vakata-context ul { - margin: 0; - padding: 2px; - position: absolute; - background: #f5f5f5; - border: 1px solid #979797; - box-shadow: 2px 2px 2px #999999; -} -.vakata-context ul { - list-style: none; - left: 100%; - margin-top: -2.7em; - margin-left: -4px; -} -.vakata-context .vakata-context-right ul { - left: auto; - right: 100%; - margin-left: auto; - margin-right: -4px; -} -.vakata-context li { - list-style: none; -} -.vakata-context li > a { - display: block; - padding: 0 2em 0 2em; - text-decoration: none; - width: auto; - color: black; - white-space: nowrap; - line-height: 2.4em; - text-shadow: 1px 1px 0 white; - border-radius: 1px; -} -.vakata-context li > a:hover { - position: relative; - background-color: #e8eff7; - box-shadow: 0 0 2px #0a6aa1; -} -.vakata-context li > a.vakata-context-parent { - background-image: url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw=="); - background-position: right center; - background-repeat: no-repeat; -} -.vakata-context li > a:focus { - outline: 0; -} -.vakata-context .vakata-context-hover > a { - position: relative; - background-color: #e8eff7; - box-shadow: 0 0 2px #0a6aa1; -} -.vakata-context .vakata-context-separator > a, -.vakata-context .vakata-context-separator > a:hover { - background: white; - border: 0; - border-top: 1px solid #e2e3e3; - height: 1px; - min-height: 1px; - max-height: 1px; - padding: 0; - margin: 0 0 0 2.4em; - border-left: 1px solid #e0e0e0; - text-shadow: 0 0 0 transparent; - box-shadow: 0 0 0 transparent; - border-radius: 0; -} -.vakata-context .vakata-contextmenu-disabled a, -.vakata-context .vakata-contextmenu-disabled a:hover { - color: silver; - background-color: transparent; - border: 0; - box-shadow: 0 0 0; -} -.vakata-context li > a > i { - text-decoration: none; - display: inline-block; - width: 2.4em; - height: 2.4em; - background: transparent; - margin: 0 0 0 -2em; - vertical-align: top; - text-align: center; - line-height: 2.4em; -} -.vakata-context li > a > i:empty { - width: 2.4em; - line-height: 2.4em; -} -.vakata-context li > a .vakata-contextmenu-sep { - display: inline-block; - width: 1px; - height: 2.4em; - background: white; - margin: 0 0.5em 0 0; - border-left: 1px solid #e2e3e3; -} -.vakata-context .vakata-contextmenu-shortcut { - font-size: 0.8em; - color: silver; - opacity: 0.5; - display: none; -} -.vakata-context-rtl ul { - left: auto; - right: 100%; - margin-left: auto; - margin-right: -4px; -} -.vakata-context-rtl li > a.vakata-context-parent { - background-image: url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAINjI+AC7rWHIsPtmoxLAA7"); - background-position: left center; - background-repeat: no-repeat; -} -.vakata-context-rtl .vakata-context-separator > a { - margin: 0 2.4em 0 0; - border-left: 0; - border-right: 1px solid #e2e3e3; -} -.vakata-context-rtl .vakata-context-left ul { - right: auto; - left: 100%; - margin-left: -4px; - margin-right: auto; -} -.vakata-context-rtl li > a > i { - margin: 0 -2em 0 0; -} -.vakata-context-rtl li > a .vakata-contextmenu-sep { - margin: 0 0 0 0.5em; - border-left-color: white; - background: #e2e3e3; -} -#jstree-marker { - position: absolute; - top: 0; - left: 0; - margin: -5px 0 0 0; - padding: 0; - border-right: 0; - border-top: 5px solid transparent; - border-bottom: 5px solid transparent; - border-left: 5px solid; - width: 0; - height: 0; - font-size: 0; - line-height: 0; -} -#jstree-dnd { - line-height: 16px; - margin: 0; - padding: 4px; -} -#jstree-dnd .jstree-icon, -#jstree-dnd .jstree-copy { - display: inline-block; - text-decoration: none; - margin: 0 2px 0 0; - padding: 0; - width: 16px; - height: 16px; -} -#jstree-dnd .jstree-ok { - background: green; -} -#jstree-dnd .jstree-er { - background: red; -} -#jstree-dnd .jstree-copy { - margin: 0 2px 0 2px; -} -.jstree-default .jstree-node, -.jstree-default .jstree-icon { - background-repeat: no-repeat; - background-color: transparent; -} -.jstree-default .jstree-anchor, -.jstree-default .jstree-animated, -.jstree-default .jstree-wholerow { - transition: background-color 0.15s, box-shadow 0.15s; -} -.jstree-default .jstree-hovered { - background: #e7f4f9; - border-radius: 2px; - box-shadow: inset 0 0 1px #cccccc; -} -.jstree-default .jstree-context { - background: #e7f4f9; - border-radius: 2px; - box-shadow: inset 0 0 1px #cccccc; -} -.jstree-default .jstree-clicked { - background: #beebff; - border-radius: 2px; - box-shadow: inset 0 0 1px #999999; -} -.jstree-default .jstree-no-icons .jstree-anchor > .jstree-themeicon { - display: none; -} -.jstree-default .jstree-disabled { - background: transparent; - color: #666666; -} -.jstree-default .jstree-disabled.jstree-hovered { - background: transparent; - box-shadow: none; -} -.jstree-default .jstree-disabled.jstree-clicked { - background: #efefef; -} -.jstree-default .jstree-disabled > .jstree-icon { - opacity: 0.8; - filter: url("data:image/svg+xml;utf8,#jstree-grayscale"); - /* Firefox 10+ */ - filter: gray; - /* IE6-9 */ - -webkit-filter: grayscale(100%); - /* Chrome 19+ & Safari 6+ */ -} -.jstree-default .jstree-search { - font-style: italic; - color: #8b0000; - font-weight: bold; -} -.jstree-default .jstree-no-checkboxes .jstree-checkbox { - display: none !important; -} -.jstree-default.jstree-checkbox-no-clicked .jstree-clicked { - background: transparent; - box-shadow: none; -} -.jstree-default.jstree-checkbox-no-clicked .jstree-clicked.jstree-hovered { - background: #e7f4f9; -} -.jstree-default.jstree-checkbox-no-clicked > .jstree-wholerow-ul .jstree-wholerow-clicked { - background: transparent; -} -.jstree-default.jstree-checkbox-no-clicked > .jstree-wholerow-ul .jstree-wholerow-clicked.jstree-wholerow-hovered { - background: #e7f4f9; -} -.jstree-default > .jstree-striped { - min-width: 100%; - display: inline-block; - background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAkCAMAAAB/qqA+AAAABlBMVEUAAAAAAAClZ7nPAAAAAnRSTlMNAMM9s3UAAAAXSURBVHjajcEBAQAAAIKg/H/aCQZ70AUBjAATb6YPDgAAAABJRU5ErkJggg==") left top repeat; -} -.jstree-default > .jstree-wholerow-ul .jstree-hovered, -.jstree-default > .jstree-wholerow-ul .jstree-clicked { - background: transparent; - box-shadow: none; - border-radius: 0; -} -.jstree-default .jstree-wholerow { - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box; -} -.jstree-default .jstree-wholerow-hovered { - background: #e7f4f9; -} -.jstree-default .jstree-wholerow-clicked { - background: #beebff; - background: -webkit-linear-gradient(top, #beebff 0%, #a8e4ff 100%); - background: linear-gradient(to bottom, #beebff 0%, #a8e4ff 100%); -} -.jstree-default .jstree-node { - min-height: 24px; - line-height: 24px; - margin-left: 24px; - min-width: 24px; -} -.jstree-default .jstree-anchor { - line-height: 24px; - height: 24px; -} -.jstree-default .jstree-icon { - width: 24px; - height: 24px; - line-height: 24px; -} -.jstree-default .jstree-icon:empty { - width: 24px; - height: 24px; - line-height: 24px; -} -.jstree-default.jstree-rtl .jstree-node { - margin-right: 24px; -} -.jstree-default .jstree-wholerow { - height: 24px; -} -.jstree-default .jstree-node, -.jstree-default .jstree-icon { - background-image: url("32px.png"); -} -.jstree-default .jstree-node { - background-position: -292px -4px; - background-repeat: repeat-y; -} -.jstree-default .jstree-last { - background: transparent; -} -.jstree-default .jstree-open > .jstree-ocl { - background-position: -132px -4px; -} -.jstree-default .jstree-closed > .jstree-ocl { - background-position: -100px -4px; -} -.jstree-default .jstree-leaf > .jstree-ocl { - background-position: -68px -4px; -} -.jstree-default .jstree-themeicon { - background-position: -260px -4px; -} -.jstree-default > .jstree-no-dots .jstree-node, -.jstree-default > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -36px -4px; -} -.jstree-default > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: -4px -4px; -} -.jstree-default .jstree-disabled { - background: transparent; -} -.jstree-default .jstree-disabled.jstree-hovered { - background: transparent; -} -.jstree-default .jstree-disabled.jstree-clicked { - background: #efefef; -} -.jstree-default .jstree-checkbox { - background-position: -164px -4px; -} -.jstree-default .jstree-checkbox:hover { - background-position: -164px -36px; -} -.jstree-default.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox, -.jstree-default .jstree-checked > .jstree-checkbox { - background-position: -228px -4px; -} -.jstree-default.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover, -.jstree-default .jstree-checked > .jstree-checkbox:hover { - background-position: -228px -36px; -} -.jstree-default .jstree-anchor > .jstree-undetermined { - background-position: -196px -4px; -} -.jstree-default .jstree-anchor > .jstree-undetermined:hover { - background-position: -196px -36px; -} -.jstree-default .jstree-checkbox-disabled { - opacity: 0.8; - filter: url("data:image/svg+xml;utf8,#jstree-grayscale"); - /* Firefox 10+ */ - filter: gray; - /* IE6-9 */ - -webkit-filter: grayscale(100%); - /* Chrome 19+ & Safari 6+ */ -} -.jstree-default > .jstree-striped { - background-size: auto 48px; -} -.jstree-default.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg=="); - background-position: 100% 1px; - background-repeat: repeat-y; -} -.jstree-default.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default.jstree-rtl .jstree-open > .jstree-ocl { - background-position: -132px -36px; -} -.jstree-default.jstree-rtl .jstree-closed > .jstree-ocl { - background-position: -100px -36px; -} -.jstree-default.jstree-rtl .jstree-leaf > .jstree-ocl { - background-position: -68px -36px; -} -.jstree-default.jstree-rtl > .jstree-no-dots .jstree-node, -.jstree-default.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -36px -36px; -} -.jstree-default.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: -4px -36px; -} -.jstree-default .jstree-themeicon-custom { - background-color: transparent; - background-image: none; - background-position: 0 0; -} -.jstree-default > .jstree-container-ul .jstree-loading > .jstree-ocl { - background: url("throbber.gif") center center no-repeat; -} -.jstree-default .jstree-file { - background: url("32px.png") -100px -68px no-repeat; -} -.jstree-default .jstree-folder { - background: url("32px.png") -260px -4px no-repeat; -} -.jstree-default > .jstree-container-ul > .jstree-node { - margin-left: 0; - margin-right: 0; -} -#jstree-dnd.jstree-default { - line-height: 24px; - padding: 0 4px; -} -#jstree-dnd.jstree-default .jstree-ok, -#jstree-dnd.jstree-default .jstree-er { - background-image: url("32px.png"); - background-repeat: no-repeat; - background-color: transparent; -} -#jstree-dnd.jstree-default i { - background: transparent; - width: 24px; - height: 24px; - line-height: 24px; -} -#jstree-dnd.jstree-default .jstree-ok { - background-position: -4px -68px; -} -#jstree-dnd.jstree-default .jstree-er { - background-position: -36px -68px; -} -.jstree-default .jstree-ellipsis { - overflow: hidden; -} -.jstree-default .jstree-ellipsis .jstree-anchor { - width: calc(100% - 29px); - text-overflow: ellipsis; - overflow: hidden; -} -.jstree-default .jstree-ellipsis.jstree-no-icons .jstree-anchor { - width: calc(100% - 5px); -} -.jstree-default.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg=="); -} -.jstree-default.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default-small .jstree-node { - min-height: 18px; - line-height: 18px; - margin-left: 18px; - min-width: 18px; -} -.jstree-default-small .jstree-anchor { - line-height: 18px; - height: 18px; -} -.jstree-default-small .jstree-icon { - width: 18px; - height: 18px; - line-height: 18px; -} -.jstree-default-small .jstree-icon:empty { - width: 18px; - height: 18px; - line-height: 18px; -} -.jstree-default-small.jstree-rtl .jstree-node { - margin-right: 18px; -} -.jstree-default-small .jstree-wholerow { - height: 18px; -} -.jstree-default-small .jstree-node, -.jstree-default-small .jstree-icon { - background-image: url("32px.png"); -} -.jstree-default-small .jstree-node { - background-position: -295px -7px; - background-repeat: repeat-y; -} -.jstree-default-small .jstree-last { - background: transparent; -} -.jstree-default-small .jstree-open > .jstree-ocl { - background-position: -135px -7px; -} -.jstree-default-small .jstree-closed > .jstree-ocl { - background-position: -103px -7px; -} -.jstree-default-small .jstree-leaf > .jstree-ocl { - background-position: -71px -7px; -} -.jstree-default-small .jstree-themeicon { - background-position: -263px -7px; -} -.jstree-default-small > .jstree-no-dots .jstree-node, -.jstree-default-small > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default-small > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -39px -7px; -} -.jstree-default-small > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: -7px -7px; -} -.jstree-default-small .jstree-disabled { - background: transparent; -} -.jstree-default-small .jstree-disabled.jstree-hovered { - background: transparent; -} -.jstree-default-small .jstree-disabled.jstree-clicked { - background: #efefef; -} -.jstree-default-small .jstree-checkbox { - background-position: -167px -7px; -} -.jstree-default-small .jstree-checkbox:hover { - background-position: -167px -39px; -} -.jstree-default-small.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox, -.jstree-default-small .jstree-checked > .jstree-checkbox { - background-position: -231px -7px; -} -.jstree-default-small.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover, -.jstree-default-small .jstree-checked > .jstree-checkbox:hover { - background-position: -231px -39px; -} -.jstree-default-small .jstree-anchor > .jstree-undetermined { - background-position: -199px -7px; -} -.jstree-default-small .jstree-anchor > .jstree-undetermined:hover { - background-position: -199px -39px; -} -.jstree-default-small .jstree-checkbox-disabled { - opacity: 0.8; - filter: url("data:image/svg+xml;utf8,#jstree-grayscale"); - /* Firefox 10+ */ - filter: gray; - /* IE6-9 */ - -webkit-filter: grayscale(100%); - /* Chrome 19+ & Safari 6+ */ -} -.jstree-default-small > .jstree-striped { - background-size: auto 36px; -} -.jstree-default-small.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg=="); - background-position: 100% 1px; - background-repeat: repeat-y; -} -.jstree-default-small.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default-small.jstree-rtl .jstree-open > .jstree-ocl { - background-position: -135px -39px; -} -.jstree-default-small.jstree-rtl .jstree-closed > .jstree-ocl { - background-position: -103px -39px; -} -.jstree-default-small.jstree-rtl .jstree-leaf > .jstree-ocl { - background-position: -71px -39px; -} -.jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-node, -.jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -39px -39px; -} -.jstree-default-small.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: -7px -39px; -} -.jstree-default-small .jstree-themeicon-custom { - background-color: transparent; - background-image: none; - background-position: 0 0; -} -.jstree-default-small > .jstree-container-ul .jstree-loading > .jstree-ocl { - background: url("throbber.gif") center center no-repeat; -} -.jstree-default-small .jstree-file { - background: url("32px.png") -103px -71px no-repeat; -} -.jstree-default-small .jstree-folder { - background: url("32px.png") -263px -7px no-repeat; -} -.jstree-default-small > .jstree-container-ul > .jstree-node { - margin-left: 0; - margin-right: 0; -} -#jstree-dnd.jstree-default-small { - line-height: 18px; - padding: 0 4px; -} -#jstree-dnd.jstree-default-small .jstree-ok, -#jstree-dnd.jstree-default-small .jstree-er { - background-image: url("32px.png"); - background-repeat: no-repeat; - background-color: transparent; -} -#jstree-dnd.jstree-default-small i { - background: transparent; - width: 18px; - height: 18px; - line-height: 18px; -} -#jstree-dnd.jstree-default-small .jstree-ok { - background-position: -7px -71px; -} -#jstree-dnd.jstree-default-small .jstree-er { - background-position: -39px -71px; -} -.jstree-default-small .jstree-ellipsis { - overflow: hidden; -} -.jstree-default-small .jstree-ellipsis .jstree-anchor { - width: calc(100% - 23px); - text-overflow: ellipsis; - overflow: hidden; -} -.jstree-default-small .jstree-ellipsis.jstree-no-icons .jstree-anchor { - width: calc(100% - 5px); -} -.jstree-default-small.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAACAQMAAABv1h6PAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMHBgAAiABBI4gz9AAAAABJRU5ErkJggg=="); -} -.jstree-default-small.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default-large .jstree-node { - min-height: 32px; - line-height: 32px; - margin-left: 32px; - min-width: 32px; -} -.jstree-default-large .jstree-anchor { - line-height: 32px; - height: 32px; -} -.jstree-default-large .jstree-icon { - width: 32px; - height: 32px; - line-height: 32px; -} -.jstree-default-large .jstree-icon:empty { - width: 32px; - height: 32px; - line-height: 32px; -} -.jstree-default-large.jstree-rtl .jstree-node { - margin-right: 32px; -} -.jstree-default-large .jstree-wholerow { - height: 32px; -} -.jstree-default-large .jstree-node, -.jstree-default-large .jstree-icon { - background-image: url("32px.png"); -} -.jstree-default-large .jstree-node { - background-position: -288px 0px; - background-repeat: repeat-y; -} -.jstree-default-large .jstree-last { - background: transparent; -} -.jstree-default-large .jstree-open > .jstree-ocl { - background-position: -128px 0px; -} -.jstree-default-large .jstree-closed > .jstree-ocl { - background-position: -96px 0px; -} -.jstree-default-large .jstree-leaf > .jstree-ocl { - background-position: -64px 0px; -} -.jstree-default-large .jstree-themeicon { - background-position: -256px 0px; -} -.jstree-default-large > .jstree-no-dots .jstree-node, -.jstree-default-large > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default-large > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -32px 0px; -} -.jstree-default-large > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: 0px 0px; -} -.jstree-default-large .jstree-disabled { - background: transparent; -} -.jstree-default-large .jstree-disabled.jstree-hovered { - background: transparent; -} -.jstree-default-large .jstree-disabled.jstree-clicked { - background: #efefef; -} -.jstree-default-large .jstree-checkbox { - background-position: -160px 0px; -} -.jstree-default-large .jstree-checkbox:hover { - background-position: -160px -32px; -} -.jstree-default-large.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox, -.jstree-default-large .jstree-checked > .jstree-checkbox { - background-position: -224px 0px; -} -.jstree-default-large.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover, -.jstree-default-large .jstree-checked > .jstree-checkbox:hover { - background-position: -224px -32px; -} -.jstree-default-large .jstree-anchor > .jstree-undetermined { - background-position: -192px 0px; -} -.jstree-default-large .jstree-anchor > .jstree-undetermined:hover { - background-position: -192px -32px; -} -.jstree-default-large .jstree-checkbox-disabled { - opacity: 0.8; - filter: url("data:image/svg+xml;utf8,#jstree-grayscale"); - /* Firefox 10+ */ - filter: gray; - /* IE6-9 */ - -webkit-filter: grayscale(100%); - /* Chrome 19+ & Safari 6+ */ -} -.jstree-default-large > .jstree-striped { - background-size: auto 64px; -} -.jstree-default-large.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg=="); - background-position: 100% 1px; - background-repeat: repeat-y; -} -.jstree-default-large.jstree-rtl .jstree-last { - background: transparent; -} -.jstree-default-large.jstree-rtl .jstree-open > .jstree-ocl { - background-position: -128px -32px; -} -.jstree-default-large.jstree-rtl .jstree-closed > .jstree-ocl { - background-position: -96px -32px; -} -.jstree-default-large.jstree-rtl .jstree-leaf > .jstree-ocl { - background-position: -64px -32px; -} -.jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-node, -.jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-leaf > .jstree-ocl { - background: transparent; -} -.jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-open > .jstree-ocl { - background-position: -32px -32px; -} -.jstree-default-large.jstree-rtl > .jstree-no-dots .jstree-closed > .jstree-ocl { - background-position: 0px -32px; -} -.jstree-default-large .jstree-themeicon-custom { - background-color: transparent; - background-image: none; - background-position: 0 0; -} -.jstree-default-large > .jstree-container-ul .jstree-loading > .jstree-ocl { - background: url("throbber.gif") center center no-repeat; -} -.jstree-default-large .jstree-file { - background: url("32px.png") -96px -64px no-repeat; -} -.jstree-default-large .jstree-folder { - background: url("32px.png") -256px 0px no-repeat; -} -.jstree-default-large > .jstree-container-ul > .jstree-node { - margin-left: 0; - margin-right: 0; -} -#jstree-dnd.jstree-default-large { - line-height: 32px; - padding: 0 4px; -} -#jstree-dnd.jstree-default-large .jstree-ok, -#jstree-dnd.jstree-default-large .jstree-er { - background-image: url("32px.png"); - background-repeat: no-repeat; - background-color: transparent; -} -#jstree-dnd.jstree-default-large i { - background: transparent; - width: 32px; - height: 32px; - line-height: 32px; -} -#jstree-dnd.jstree-default-large .jstree-ok { - background-position: 0px -64px; -} -#jstree-dnd.jstree-default-large .jstree-er { - background-position: -32px -64px; -} -.jstree-default-large .jstree-ellipsis { - overflow: hidden; -} -.jstree-default-large .jstree-ellipsis .jstree-anchor { - width: calc(100% - 37px); - text-overflow: ellipsis; - overflow: hidden; -} -.jstree-default-large .jstree-ellipsis.jstree-no-icons .jstree-anchor { - width: calc(100% - 5px); -} -.jstree-default-large.jstree-rtl .jstree-node { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg=="); -} -.jstree-default-large.jstree-rtl .jstree-last { - background: transparent; -} -@media (max-width: 768px) { - #jstree-dnd.jstree-dnd-responsive { - line-height: 40px; - font-weight: bold; - font-size: 1.1em; - text-shadow: 1px 1px white; - } - #jstree-dnd.jstree-dnd-responsive > i { - background: transparent; - width: 40px; - height: 40px; - } - #jstree-dnd.jstree-dnd-responsive > .jstree-ok { - background-image: url("40px.png"); - background-position: 0 -200px; - background-size: 120px 240px; - } - #jstree-dnd.jstree-dnd-responsive > .jstree-er { - background-image: url("40px.png"); - background-position: -40px -200px; - background-size: 120px 240px; - } - #jstree-marker.jstree-dnd-responsive { - border-left-width: 10px; - border-top-width: 10px; - border-bottom-width: 10px; - margin-top: -10px; - } -} -@media (max-width: 768px) { - .jstree-default-responsive { - /* - .jstree-open > .jstree-ocl, - .jstree-closed > .jstree-ocl { border-radius:20px; background-color:white; } - */ - } - .jstree-default-responsive .jstree-icon { - background-image: url("40px.png"); - } - .jstree-default-responsive .jstree-node, - .jstree-default-responsive .jstree-leaf > .jstree-ocl { - background: transparent; - } - .jstree-default-responsive .jstree-node { - min-height: 40px; - line-height: 40px; - margin-left: 40px; - min-width: 40px; - white-space: nowrap; - } - .jstree-default-responsive .jstree-anchor { - line-height: 40px; - height: 40px; - } - .jstree-default-responsive .jstree-icon, - .jstree-default-responsive .jstree-icon:empty { - width: 40px; - height: 40px; - line-height: 40px; - } - .jstree-default-responsive > .jstree-container-ul > .jstree-node { - margin-left: 0; - } - .jstree-default-responsive.jstree-rtl .jstree-node { - margin-left: 0; - margin-right: 40px; - background: transparent; - } - .jstree-default-responsive.jstree-rtl .jstree-container-ul > .jstree-node { - margin-right: 0; - } - .jstree-default-responsive .jstree-ocl, - .jstree-default-responsive .jstree-themeicon, - .jstree-default-responsive .jstree-checkbox { - background-size: 120px 240px; - } - .jstree-default-responsive .jstree-leaf > .jstree-ocl, - .jstree-default-responsive.jstree-rtl .jstree-leaf > .jstree-ocl { - background: transparent; - } - .jstree-default-responsive .jstree-open > .jstree-ocl { - background-position: 0 0px !important; - } - .jstree-default-responsive .jstree-closed > .jstree-ocl { - background-position: 0 -40px !important; - } - .jstree-default-responsive.jstree-rtl .jstree-closed > .jstree-ocl { - background-position: -40px 0px !important; - } - .jstree-default-responsive .jstree-themeicon { - background-position: -40px -40px; - } - .jstree-default-responsive .jstree-checkbox, - .jstree-default-responsive .jstree-checkbox:hover { - background-position: -40px -80px; - } - .jstree-default-responsive.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox, - .jstree-default-responsive.jstree-checkbox-selection .jstree-clicked > .jstree-checkbox:hover, - .jstree-default-responsive .jstree-checked > .jstree-checkbox, - .jstree-default-responsive .jstree-checked > .jstree-checkbox:hover { - background-position: 0 -80px; - } - .jstree-default-responsive .jstree-anchor > .jstree-undetermined, - .jstree-default-responsive .jstree-anchor > .jstree-undetermined:hover { - background-position: 0 -120px; - } - .jstree-default-responsive .jstree-anchor { - font-weight: bold; - font-size: 1.1em; - text-shadow: 1px 1px white; - } - .jstree-default-responsive > .jstree-striped { - background: transparent; - } - .jstree-default-responsive .jstree-wholerow { - border-top: 1px solid rgba(255, 255, 255, 0.7); - border-bottom: 1px solid rgba(64, 64, 64, 0.2); - background: #ebebeb; - height: 40px; - } - .jstree-default-responsive .jstree-wholerow-hovered { - background: #e7f4f9; - } - .jstree-default-responsive .jstree-wholerow-clicked { - background: #beebff; - } - .jstree-default-responsive .jstree-children .jstree-last > .jstree-wholerow { - box-shadow: inset 0 -6px 3px -5px #666666; - } - .jstree-default-responsive .jstree-children .jstree-open > .jstree-wholerow { - box-shadow: inset 0 6px 3px -5px #666666; - border-top: 0; - } - .jstree-default-responsive .jstree-children .jstree-open + .jstree-open { - box-shadow: none; - } - .jstree-default-responsive .jstree-node, - .jstree-default-responsive .jstree-icon, - .jstree-default-responsive .jstree-node > .jstree-ocl, - .jstree-default-responsive .jstree-themeicon, - .jstree-default-responsive .jstree-checkbox { - background-image: url("40px.png"); - background-size: 120px 240px; - } - .jstree-default-responsive .jstree-node { - background-position: -80px 0; - background-repeat: repeat-y; - } - .jstree-default-responsive .jstree-last { - background: transparent; - } - .jstree-default-responsive .jstree-leaf > .jstree-ocl { - background-position: -40px -120px; - } - .jstree-default-responsive .jstree-last > .jstree-ocl { - background-position: -40px -160px; - } - .jstree-default-responsive .jstree-themeicon-custom { - background-color: transparent; - background-image: none; - background-position: 0 0; - } - .jstree-default-responsive .jstree-file { - background: url("40px.png") 0 -160px no-repeat; - background-size: 120px 240px; - } - .jstree-default-responsive .jstree-folder { - background: url("40px.png") -40px -40px no-repeat; - background-size: 120px 240px; - } - .jstree-default-responsive > .jstree-container-ul > .jstree-node { - margin-left: 0; - margin-right: 0; - } -} diff --git a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/style.min.css b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/style.min.css new file mode 100644 index 000000000000..93f80e915624 --- /dev/null +++ b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/style.min.css @@ -0,0 +1 @@ +.jstree-node,.jstree-children,.jstree-container-ul{display:block;margin:0;padding:0;list-style-type:none;list-style-image:none}.jstree-node{white-space:nowrap}.jstree-anchor{display:inline-block;color:black;white-space:nowrap;padding:0 4px 0 1px;margin:0;vertical-align:top}.jstree-anchor:focus{outline:0}.jstree-anchor,.jstree-anchor:link,.jstree-anchor:visited,.jstree-anchor:hover,.jstree-anchor:active{text-decoration:none;color:inherit}.jstree-icon{display:inline-block;text-decoration:none;margin:0;padding:0;vertical-align:top;text-align:center}.jstree-icon:empty{display:inline-block;text-decoration:none;margin:0;padding:0;vertical-align:top;text-align:center}.jstree-ocl{cursor:pointer}.jstree-leaf>.jstree-ocl{cursor:default}.jstree .jstree-open>.jstree-children{display:block}.jstree .jstree-closed>.jstree-children,.jstree .jstree-leaf>.jstree-children{display:none}.jstree-anchor>.jstree-themeicon{margin-right:2px}.jstree-no-icons .jstree-themeicon,.jstree-anchor>.jstree-themeicon-hidden{display:none}.jstree-hidden,.jstree-node.jstree-hidden{display:none}.jstree-rtl .jstree-anchor{padding:0 1px 0 4px}.jstree-rtl .jstree-anchor>.jstree-themeicon{margin-left:2px;margin-right:0}.jstree-rtl .jstree-node{margin-left:0}.jstree-rtl .jstree-container-ul>.jstree-node{margin-right:0}.jstree-wholerow-ul{position:relative;display:inline-block;min-width:100%}.jstree-wholerow-ul .jstree-leaf>.jstree-ocl{cursor:pointer}.jstree-wholerow-ul .jstree-anchor,.jstree-wholerow-ul .jstree-icon{position:relative}.jstree-wholerow-ul .jstree-wholerow{width:100%;cursor:pointer;position:absolute;left:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.jstree-contextmenu .jstree-anchor{-webkit-user-select:none;-webkit-touch-callout:none}.vakata-context{display:none}.vakata-context,.vakata-context ul{margin:0;padding:2px;position:absolute;background:#f5f5f5;border:1px solid #979797;box-shadow:2px 2px 2px #999999}.vakata-context ul{list-style:none;left:100%;margin-top:-2.7em;margin-left:-4px}.vakata-context .vakata-context-right ul{left:auto;right:100%;margin-left:auto;margin-right:-4px}.vakata-context li{list-style:none}.vakata-context li>a{display:block;padding:0 2em 0 2em;text-decoration:none;width:auto;color:black;white-space:nowrap;line-height:2.4em;text-shadow:1px 1px 0 white;border-radius:1px}.vakata-context li>a:hover{position:relative;background-color:#e8eff7;box-shadow:0 0 2px #0a6aa1}.vakata-context li>a.vakata-context-parent{background-image:url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw==");background-position:right center;background-repeat:no-repeat}.vakata-context li>a:focus{outline:0}.vakata-context .vakata-context-hover>a{position:relative;background-color:#e8eff7;box-shadow:0 0 2px #0a6aa1}.vakata-context .vakata-context-separator>a,.vakata-context .vakata-context-separator>a:hover{background:white;border:0;border-top:1px solid #e2e3e3;height:1px;min-height:1px;max-height:1px;padding:0;margin:0 0 0 2.4em;border-left:1px solid #e0e0e0;text-shadow:0 0 0 transparent;box-shadow:0 0 0 transparent;border-radius:0}.vakata-context .vakata-contextmenu-disabled a,.vakata-context .vakata-contextmenu-disabled a:hover{color:silver;background-color:transparent;border:0;box-shadow:0 0 0}.vakata-context .vakata-contextmenu-disabled>a>i{filter:grayscale(100%)}.vakata-context li>a>i{text-decoration:none;display:inline-block;width:2.4em;height:2.4em;background:transparent;margin:0 0 0 -2em;vertical-align:top;text-align:center;line-height:2.4em}.vakata-context li>a>i:empty{width:2.4em;line-height:2.4em}.vakata-context li>a .vakata-contextmenu-sep{display:inline-block;width:1px;height:2.4em;background:white;margin:0 .5em 0 0;border-left:1px solid #e2e3e3}.vakata-context .vakata-contextmenu-shortcut{font-size:.8em;color:silver;opacity:.5;display:none}.vakata-context-rtl ul{left:auto;right:100%;margin-left:auto;margin-right:-4px}.vakata-context-rtl li>a.vakata-context-parent{background-image:url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAINjI+AC7rWHIsPtmoxLAA7");background-position:left center;background-repeat:no-repeat}.vakata-context-rtl .vakata-context-separator>a{margin:0 2.4em 0 0;border-left:0;border-right:1px solid #e2e3e3}.vakata-context-rtl .vakata-context-left ul{right:auto;left:100%;margin-left:-4px;margin-right:auto}.vakata-context-rtl li>a>i{margin:0 -2em 0 0}.vakata-context-rtl li>a .vakata-contextmenu-sep{margin:0 0 0 .5em;border-left-color:white;background:#e2e3e3}#jstree-marker{position:absolute;top:0;left:0;margin:-5px 0 0 0;padding:0;border-right:0;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid;width:0;height:0;font-size:0;line-height:0}#jstree-dnd{line-height:16px;margin:0;padding:4px}#jstree-dnd .jstree-icon,#jstree-dnd .jstree-copy{display:inline-block;text-decoration:none;margin:0 2px 0 0;padding:0;width:16px;height:16px}#jstree-dnd .jstree-ok{background:green}#jstree-dnd .jstree-er{background:red}#jstree-dnd .jstree-copy{margin:0 2px 0 2px}.jstree-default .jstree-node,.jstree-default .jstree-icon{background-repeat:no-repeat;background-color:transparent}.jstree-default .jstree-anchor,.jstree-default .jstree-animated,.jstree-default .jstree-wholerow{transition:background-color .15s,box-shadow .15s}.jstree-default .jstree-hovered{background:#e7f4f9;border-radius:2px;box-shadow:inset 0 0 1px #cccccc}.jstree-default .jstree-context{background:#e7f4f9;border-radius:2px;box-shadow:inset 0 0 1px #cccccc}.jstree-default .jstree-clicked{background:#beebff;border-radius:2px;box-shadow:inset 0 0 1px #999999}.jstree-default .jstree-no-icons .jstree-anchor>.jstree-themeicon{display:none}.jstree-default .jstree-disabled{background:transparent;color:#666666}.jstree-default .jstree-disabled.jstree-hovered{background:transparent;box-shadow:none}.jstree-default .jstree-disabled.jstree-clicked{background:#efefef}.jstree-default .jstree-disabled>.jstree-icon{opacity:.8;filter:url("data:image/svg+xml;utf8,#jstree-grayscale");filter:gray;-webkit-filter:grayscale(100%)}.jstree-default .jstree-search{font-style:italic;color:#8b0000;font-weight:bold}.jstree-default .jstree-no-checkboxes .jstree-checkbox{display:none !important}.jstree-default.jstree-checkbox-no-clicked .jstree-clicked{background:transparent;box-shadow:none}.jstree-default.jstree-checkbox-no-clicked .jstree-clicked.jstree-hovered{background:#e7f4f9}.jstree-default.jstree-checkbox-no-clicked>.jstree-wholerow-ul .jstree-wholerow-clicked{background:transparent}.jstree-default.jstree-checkbox-no-clicked>.jstree-wholerow-ul .jstree-wholerow-clicked.jstree-wholerow-hovered{background:#e7f4f9}.jstree-default>.jstree-striped{min-width:100%;display:inline-block;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAkCAMAAAB/qqA+AAAABlBMVEUAAAAAAAClZ7nPAAAAAnRSTlMNAMM9s3UAAAAXSURBVHjajcEBAQAAAIKg/H/aCQZ70AUBjAATb6YPDgAAAABJRU5ErkJggg==") left top repeat}.jstree-default>.jstree-wholerow-ul .jstree-hovered,.jstree-default>.jstree-wholerow-ul .jstree-clicked{background:transparent;box-shadow:none;border-radius:0}.jstree-default .jstree-wholerow{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.jstree-default .jstree-wholerow-hovered{background:#e7f4f9}.jstree-default .jstree-wholerow-clicked{background:#beebff;background:-webkit-linear-gradient(top, #beebff 0, #a8e4ff 100%);background:linear-gradient(to bottom, #beebff 0, #a8e4ff 100%)}.jstree-default .jstree-node{min-height:24px;line-height:24px;margin-left:24px;min-width:24px}.jstree-default .jstree-anchor{line-height:24px;height:24px}.jstree-default .jstree-icon{width:24px;height:24px;line-height:24px}.jstree-default .jstree-icon:empty{width:24px;height:24px;line-height:24px}.jstree-default.jstree-rtl .jstree-node{margin-right:24px}.jstree-default .jstree-wholerow{height:24px}.jstree-default .jstree-node,.jstree-default .jstree-icon{background-image:url("32px.png")}.jstree-default .jstree-node{background-position:-292px -4px;background-repeat:repeat-y}.jstree-default .jstree-last{background:transparent}.jstree-default .jstree-open>.jstree-ocl{background-position:-132px -4px}.jstree-default .jstree-closed>.jstree-ocl{background-position:-100px -4px}.jstree-default .jstree-leaf>.jstree-ocl{background-position:-68px -4px}.jstree-default .jstree-themeicon{background-position:-260px -4px}.jstree-default>.jstree-no-dots .jstree-node,.jstree-default>.jstree-no-dots .jstree-leaf>.jstree-ocl{background:transparent}.jstree-default>.jstree-no-dots .jstree-open>.jstree-ocl{background-position:-36px -4px}.jstree-default>.jstree-no-dots .jstree-closed>.jstree-ocl{background-position:-4px -4px}.jstree-default .jstree-disabled{background:transparent}.jstree-default .jstree-disabled.jstree-hovered{background:transparent}.jstree-default .jstree-disabled.jstree-clicked{background:#efefef}.jstree-default .jstree-checkbox{background-position:-164px -4px}.jstree-default .jstree-checkbox:hover{background-position:-164px -36px}.jstree-default.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox,.jstree-default .jstree-checked>.jstree-checkbox{background-position:-228px -4px}.jstree-default.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox:hover,.jstree-default .jstree-checked>.jstree-checkbox:hover{background-position:-228px -36px}.jstree-default .jstree-anchor>.jstree-undetermined{background-position:-196px -4px}.jstree-default .jstree-anchor>.jstree-undetermined:hover{background-position:-196px -36px}.jstree-default .jstree-checkbox-disabled{opacity:.8;filter:url("data:image/svg+xml;utf8,#jstree-grayscale");filter:gray;-webkit-filter:grayscale(100%)}.jstree-default>.jstree-striped{background-size:auto 48px}.jstree-default.jstree-rtl .jstree-node{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");background-position:100% 1px;background-repeat:repeat-y}.jstree-default.jstree-rtl .jstree-last{background:transparent}.jstree-default.jstree-rtl .jstree-open>.jstree-ocl{background-position:-132px -36px}.jstree-default.jstree-rtl .jstree-closed>.jstree-ocl{background-position:-100px -36px}.jstree-default.jstree-rtl .jstree-leaf>.jstree-ocl{background-position:-68px -36px}.jstree-default.jstree-rtl>.jstree-no-dots .jstree-node,.jstree-default.jstree-rtl>.jstree-no-dots .jstree-leaf>.jstree-ocl{background:transparent}.jstree-default.jstree-rtl>.jstree-no-dots .jstree-open>.jstree-ocl{background-position:-36px -36px}.jstree-default.jstree-rtl>.jstree-no-dots .jstree-closed>.jstree-ocl{background-position:-4px -36px}.jstree-default .jstree-themeicon-custom{background-color:transparent;background-image:none;background-position:0 0}.jstree-default>.jstree-container-ul .jstree-loading>.jstree-ocl{background:url("throbber.gif") center center no-repeat}.jstree-default .jstree-file{background:url("32px.png") -100px -68px no-repeat}.jstree-default .jstree-folder{background:url("32px.png") -260px -4px no-repeat}.jstree-default>.jstree-container-ul>.jstree-node{margin-left:0;margin-right:0}#jstree-dnd.jstree-default{line-height:24px;padding:0 4px}#jstree-dnd.jstree-default .jstree-ok,#jstree-dnd.jstree-default .jstree-er{background-image:url("32px.png");background-repeat:no-repeat;background-color:transparent}#jstree-dnd.jstree-default i{background:transparent;width:24px;height:24px;line-height:24px}#jstree-dnd.jstree-default .jstree-ok{background-position:-4px -68px}#jstree-dnd.jstree-default .jstree-er{background-position:-36px -68px}.jstree-default .jstree-ellipsis{overflow:hidden}.jstree-default .jstree-ellipsis .jstree-anchor{width:calc(100% - 29px);text-overflow:ellipsis;overflow:hidden}.jstree-default.jstree-rtl .jstree-node{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==")}.jstree-default.jstree-rtl .jstree-last{background:transparent}.jstree-default-small .jstree-node{min-height:18px;line-height:18px;margin-left:18px;min-width:18px}.jstree-default-small .jstree-anchor{line-height:18px;height:18px}.jstree-default-small .jstree-icon{width:18px;height:18px;line-height:18px}.jstree-default-small .jstree-icon:empty{width:18px;height:18px;line-height:18px}.jstree-default-small.jstree-rtl .jstree-node{margin-right:18px}.jstree-default-small .jstree-wholerow{height:18px}.jstree-default-small .jstree-node,.jstree-default-small .jstree-icon{background-image:url("32px.png")}.jstree-default-small .jstree-node{background-position:-295px -7px;background-repeat:repeat-y}.jstree-default-small .jstree-last{background:transparent}.jstree-default-small .jstree-open>.jstree-ocl{background-position:-135px -7px}.jstree-default-small .jstree-closed>.jstree-ocl{background-position:-103px -7px}.jstree-default-small .jstree-leaf>.jstree-ocl{background-position:-71px -7px}.jstree-default-small .jstree-themeicon{background-position:-263px -7px}.jstree-default-small>.jstree-no-dots .jstree-node,.jstree-default-small>.jstree-no-dots .jstree-leaf>.jstree-ocl{background:transparent}.jstree-default-small>.jstree-no-dots .jstree-open>.jstree-ocl{background-position:-39px -7px}.jstree-default-small>.jstree-no-dots .jstree-closed>.jstree-ocl{background-position:-7px -7px}.jstree-default-small .jstree-disabled{background:transparent}.jstree-default-small .jstree-disabled.jstree-hovered{background:transparent}.jstree-default-small .jstree-disabled.jstree-clicked{background:#efefef}.jstree-default-small .jstree-checkbox{background-position:-167px -7px}.jstree-default-small .jstree-checkbox:hover{background-position:-167px -39px}.jstree-default-small.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox,.jstree-default-small .jstree-checked>.jstree-checkbox{background-position:-231px -7px}.jstree-default-small.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox:hover,.jstree-default-small .jstree-checked>.jstree-checkbox:hover{background-position:-231px -39px}.jstree-default-small .jstree-anchor>.jstree-undetermined{background-position:-199px -7px}.jstree-default-small .jstree-anchor>.jstree-undetermined:hover{background-position:-199px -39px}.jstree-default-small .jstree-checkbox-disabled{opacity:.8;filter:url("data:image/svg+xml;utf8,#jstree-grayscale");filter:gray;-webkit-filter:grayscale(100%)}.jstree-default-small>.jstree-striped{background-size:auto 36px}.jstree-default-small.jstree-rtl .jstree-node{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");background-position:100% 1px;background-repeat:repeat-y}.jstree-default-small.jstree-rtl .jstree-last{background:transparent}.jstree-default-small.jstree-rtl .jstree-open>.jstree-ocl{background-position:-135px -39px}.jstree-default-small.jstree-rtl .jstree-closed>.jstree-ocl{background-position:-103px -39px}.jstree-default-small.jstree-rtl .jstree-leaf>.jstree-ocl{background-position:-71px -39px}.jstree-default-small.jstree-rtl>.jstree-no-dots .jstree-node,.jstree-default-small.jstree-rtl>.jstree-no-dots .jstree-leaf>.jstree-ocl{background:transparent}.jstree-default-small.jstree-rtl>.jstree-no-dots .jstree-open>.jstree-ocl{background-position:-39px -39px}.jstree-default-small.jstree-rtl>.jstree-no-dots .jstree-closed>.jstree-ocl{background-position:-7px -39px}.jstree-default-small .jstree-themeicon-custom{background-color:transparent;background-image:none;background-position:0 0}.jstree-default-small>.jstree-container-ul .jstree-loading>.jstree-ocl{background:url("throbber.gif") center center no-repeat}.jstree-default-small .jstree-file{background:url("32px.png") -103px -71px no-repeat}.jstree-default-small .jstree-folder{background:url("32px.png") -263px -7px no-repeat}.jstree-default-small>.jstree-container-ul>.jstree-node{margin-left:0;margin-right:0}#jstree-dnd.jstree-default-small{line-height:18px;padding:0 4px}#jstree-dnd.jstree-default-small .jstree-ok,#jstree-dnd.jstree-default-small .jstree-er{background-image:url("32px.png");background-repeat:no-repeat;background-color:transparent}#jstree-dnd.jstree-default-small i{background:transparent;width:18px;height:18px;line-height:18px}#jstree-dnd.jstree-default-small .jstree-ok{background-position:-7px -71px}#jstree-dnd.jstree-default-small .jstree-er{background-position:-39px -71px}.jstree-default-small .jstree-ellipsis{overflow:hidden}.jstree-default-small .jstree-ellipsis .jstree-anchor{width:calc(100% - 23px);text-overflow:ellipsis;overflow:hidden}.jstree-default-small.jstree-rtl .jstree-node{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAACAQMAAABv1h6PAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMHBgAAiABBI4gz9AAAAABJRU5ErkJggg==")}.jstree-default-small.jstree-rtl .jstree-last{background:transparent}.jstree-default-large .jstree-node{min-height:32px;line-height:32px;margin-left:32px;min-width:32px}.jstree-default-large .jstree-anchor{line-height:32px;height:32px}.jstree-default-large .jstree-icon{width:32px;height:32px;line-height:32px}.jstree-default-large .jstree-icon:empty{width:32px;height:32px;line-height:32px}.jstree-default-large.jstree-rtl .jstree-node{margin-right:32px}.jstree-default-large .jstree-wholerow{height:32px}.jstree-default-large .jstree-node,.jstree-default-large .jstree-icon{background-image:url("32px.png")}.jstree-default-large .jstree-node{background-position:-288px 0;background-repeat:repeat-y}.jstree-default-large .jstree-last{background:transparent}.jstree-default-large .jstree-open>.jstree-ocl{background-position:-128px 0}.jstree-default-large .jstree-closed>.jstree-ocl{background-position:-96px 0}.jstree-default-large .jstree-leaf>.jstree-ocl{background-position:-64px 0}.jstree-default-large .jstree-themeicon{background-position:-256px 0}.jstree-default-large>.jstree-no-dots .jstree-node,.jstree-default-large>.jstree-no-dots .jstree-leaf>.jstree-ocl{background:transparent}.jstree-default-large>.jstree-no-dots .jstree-open>.jstree-ocl{background-position:-32px 0}.jstree-default-large>.jstree-no-dots .jstree-closed>.jstree-ocl{background-position:0 0}.jstree-default-large .jstree-disabled{background:transparent}.jstree-default-large .jstree-disabled.jstree-hovered{background:transparent}.jstree-default-large .jstree-disabled.jstree-clicked{background:#efefef}.jstree-default-large .jstree-checkbox{background-position:-160px 0}.jstree-default-large .jstree-checkbox:hover{background-position:-160px -32px}.jstree-default-large.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox,.jstree-default-large .jstree-checked>.jstree-checkbox{background-position:-224px 0}.jstree-default-large.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox:hover,.jstree-default-large .jstree-checked>.jstree-checkbox:hover{background-position:-224px -32px}.jstree-default-large .jstree-anchor>.jstree-undetermined{background-position:-192px 0}.jstree-default-large .jstree-anchor>.jstree-undetermined:hover{background-position:-192px -32px}.jstree-default-large .jstree-checkbox-disabled{opacity:.8;filter:url("data:image/svg+xml;utf8,#jstree-grayscale");filter:gray;-webkit-filter:grayscale(100%)}.jstree-default-large>.jstree-striped{background-size:auto 64px}.jstree-default-large.jstree-rtl .jstree-node{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");background-position:100% 1px;background-repeat:repeat-y}.jstree-default-large.jstree-rtl .jstree-last{background:transparent}.jstree-default-large.jstree-rtl .jstree-open>.jstree-ocl{background-position:-128px -32px}.jstree-default-large.jstree-rtl .jstree-closed>.jstree-ocl{background-position:-96px -32px}.jstree-default-large.jstree-rtl .jstree-leaf>.jstree-ocl{background-position:-64px -32px}.jstree-default-large.jstree-rtl>.jstree-no-dots .jstree-node,.jstree-default-large.jstree-rtl>.jstree-no-dots .jstree-leaf>.jstree-ocl{background:transparent}.jstree-default-large.jstree-rtl>.jstree-no-dots .jstree-open>.jstree-ocl{background-position:-32px -32px}.jstree-default-large.jstree-rtl>.jstree-no-dots .jstree-closed>.jstree-ocl{background-position:0 -32px}.jstree-default-large .jstree-themeicon-custom{background-color:transparent;background-image:none;background-position:0 0}.jstree-default-large>.jstree-container-ul .jstree-loading>.jstree-ocl{background:url("throbber.gif") center center no-repeat}.jstree-default-large .jstree-file{background:url("32px.png") -96px -64px no-repeat}.jstree-default-large .jstree-folder{background:url("32px.png") -256px 0 no-repeat}.jstree-default-large>.jstree-container-ul>.jstree-node{margin-left:0;margin-right:0}#jstree-dnd.jstree-default-large{line-height:32px;padding:0 4px}#jstree-dnd.jstree-default-large .jstree-ok,#jstree-dnd.jstree-default-large .jstree-er{background-image:url("32px.png");background-repeat:no-repeat;background-color:transparent}#jstree-dnd.jstree-default-large i{background:transparent;width:32px;height:32px;line-height:32px}#jstree-dnd.jstree-default-large .jstree-ok{background-position:0 -64px}#jstree-dnd.jstree-default-large .jstree-er{background-position:-32px -64px}.jstree-default-large .jstree-ellipsis{overflow:hidden}.jstree-default-large .jstree-ellipsis .jstree-anchor{width:calc(100% - 37px);text-overflow:ellipsis;overflow:hidden}.jstree-default-large.jstree-rtl .jstree-node{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg==")}.jstree-default-large.jstree-rtl .jstree-last{background:transparent}@media (max-width:768px){#jstree-dnd.jstree-dnd-responsive{line-height:40px;font-weight:bold;font-size:1.1em;text-shadow:1px 1px white}#jstree-dnd.jstree-dnd-responsive>i{background:transparent;width:40px;height:40px}#jstree-dnd.jstree-dnd-responsive>.jstree-ok{background-image:url("40px.png");background-position:0 -200px;background-size:120px 240px}#jstree-dnd.jstree-dnd-responsive>.jstree-er{background-image:url("40px.png");background-position:-40px -200px;background-size:120px 240px}#jstree-marker.jstree-dnd-responsive{border-left-width:10px;border-top-width:10px;border-bottom-width:10px;margin-top:-10px}}@media (max-width:768px){.jstree-default-responsive .jstree-icon{background-image:url("40px.png")}.jstree-default-responsive .jstree-node,.jstree-default-responsive .jstree-leaf>.jstree-ocl{background:transparent}.jstree-default-responsive .jstree-node{min-height:40px;line-height:40px;margin-left:40px;min-width:40px;white-space:nowrap}.jstree-default-responsive .jstree-anchor{line-height:40px;height:40px}.jstree-default-responsive .jstree-icon,.jstree-default-responsive .jstree-icon:empty{width:40px;height:40px;line-height:40px}.jstree-default-responsive>.jstree-container-ul>.jstree-node{margin-left:0}.jstree-default-responsive.jstree-rtl .jstree-node{margin-left:0;margin-right:40px;background:transparent}.jstree-default-responsive.jstree-rtl .jstree-container-ul>.jstree-node{margin-right:0}.jstree-default-responsive .jstree-ocl,.jstree-default-responsive .jstree-themeicon,.jstree-default-responsive .jstree-checkbox{background-size:120px 240px}.jstree-default-responsive .jstree-leaf>.jstree-ocl,.jstree-default-responsive.jstree-rtl .jstree-leaf>.jstree-ocl{background:transparent}.jstree-default-responsive .jstree-open>.jstree-ocl{background-position:0 0 !important}.jstree-default-responsive .jstree-closed>.jstree-ocl{background-position:0 -40px !important}.jstree-default-responsive.jstree-rtl .jstree-closed>.jstree-ocl{background-position:-40px 0 !important}.jstree-default-responsive .jstree-themeicon{background-position:-40px -40px}.jstree-default-responsive .jstree-checkbox,.jstree-default-responsive .jstree-checkbox:hover{background-position:-40px -80px}.jstree-default-responsive.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox,.jstree-default-responsive.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox:hover,.jstree-default-responsive .jstree-checked>.jstree-checkbox,.jstree-default-responsive .jstree-checked>.jstree-checkbox:hover{background-position:0 -80px}.jstree-default-responsive .jstree-anchor>.jstree-undetermined,.jstree-default-responsive .jstree-anchor>.jstree-undetermined:hover{background-position:0 -120px}.jstree-default-responsive .jstree-anchor{font-weight:bold;font-size:1.1em;text-shadow:1px 1px white}.jstree-default-responsive>.jstree-striped{background:transparent}.jstree-default-responsive .jstree-wholerow{border-top:1px solid rgba(255,255,255,0.7);border-bottom:1px solid rgba(64,64,64,0.2);background:#ebebeb;height:40px}.jstree-default-responsive .jstree-wholerow-hovered{background:#e7f4f9}.jstree-default-responsive .jstree-wholerow-clicked{background:#beebff}.jstree-default-responsive .jstree-children .jstree-last>.jstree-wholerow{box-shadow:inset 0 -6px 3px -5px #666666}.jstree-default-responsive .jstree-children .jstree-open>.jstree-wholerow{box-shadow:inset 0 6px 3px -5px #666666;border-top:0}.jstree-default-responsive .jstree-children .jstree-open+.jstree-open{box-shadow:none}.jstree-default-responsive .jstree-node,.jstree-default-responsive .jstree-icon,.jstree-default-responsive .jstree-node>.jstree-ocl,.jstree-default-responsive .jstree-themeicon,.jstree-default-responsive .jstree-checkbox{background-image:url("40px.png");background-size:120px 240px}.jstree-default-responsive .jstree-node{background-position:-80px 0;background-repeat:repeat-y}.jstree-default-responsive .jstree-last{background:transparent}.jstree-default-responsive .jstree-leaf>.jstree-ocl{background-position:-40px -120px}.jstree-default-responsive .jstree-last>.jstree-ocl{background-position:-40px -160px}.jstree-default-responsive .jstree-themeicon-custom{background-color:transparent;background-image:none;background-position:0 0}.jstree-default-responsive .jstree-file{background:url("40px.png") 0 -160px no-repeat;background-size:120px 240px}.jstree-default-responsive .jstree-folder{background:url("40px.png") -40px -40px no-repeat;background-size:120px 240px}.jstree-default-responsive>.jstree-container-ul>.jstree-node{margin-left:0;margin-right:0}} \ No newline at end of file diff --git a/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/throbber.gif b/cvat/apps/dashboard/static/dashboard/js/3rdparty/jstree/themes/default/throbber.gif index 1b5b2fde42f8ea14e6981339196a9d62b681d79e..64c8eebb87be51df85e7fe51d80c6a4918feccd0 100644 GIT binary patch literal 1464 zcmZvbe^8Tk9LK*8dp5SQ!7~^z3FH}!ITG-J1cw?om>b&;=J+8!Aleo`1T_TIT%6c8 z1~~jh1NjxzHYAH94(OM4M&n1oj0+GXOzM`NNuFKvJO#aq9=zzR>;Lcf`~JMX@7E_; zE)~XW5P*OOUZB0boy}%Doz8)Qfr^R>0055TadB~Vb#*S6i^t;?6%|RP((dkV7=~9? zR=6u3N=ashI8h~uiNZ(_ae@11fVjLsbEF_2Jyv|A2-WP@Xb&FJS_GSA*lWq&wS|6Kz&We7i(Rj!J?%GlRQKJ&Z{()`heumO#_HJZsj z#HGMq*)Ql(ltilcV*PsvFJcG)?{PUEkDEMnDk(mcxp84FatgO zM&SAVq5nxl2z~(P5Q)HsM>#ST$^3Zf)v%hDOvy}a111}p)-eo$)jIZzsi-drczong z_oe$qnf0FN`0*a5A#0@4{zW6%cAbn+Owf}qGYY$my3^2v(<^@I)MQ4;zX4Z&8Nj(N zM>zDQ`NF=I&7?)D*9LFDNAGfTHkH zBcyVpNC=&t3gfx<@+!)KDaS9PmibOT>rG>Q7+i~b+D^9iQZFKw*{PFMH7mIjGmn61 zS&Fw?)h)Z3Dr|&F>RD>fF1lTr4~HABq*Rp&5v7kfwC;!Pe$j}=s^yi`W>|FE+}AB5ZL-tb=>B8TB|>BP zS{}g*0f_Kq)s(C$Id`l+^={5@_>G_Ud~=(3k*`vUg$BLMq^lXZU$RuwVs+|76L4&B z)jiop@`3KQp}rezIu*{_nzu}ctKFO})$mISv`iRBZ?=DL1znqK^5FloWOWVFZTOEH zjDgSbbA#NCnKzHpZff2tV4g98b&Lq@S!h$RL?@tca5MBjN@HL>+z!=ZDhD!-rU|ud z-KgO{5cql9XI>M|Rt%a#rcZDJ6ULTM?wvSA{4;QXfctw5h%(d7hW*92=W~``ZRI!G zsY+%{Zl?T$Z@m{h=I;%s{mvl#RI~%A749v+%r||l4^Nx*rb~zQn2-s}#S{#q=p$1O zm$n2M9~G*PVusk;6g~LIou}Qc#o;c8{N*k!KaD&#B=IGun;b4?{{2)#4ofm)GTZh| zIz1@KsAzmS;N2Zn`o3KZb2Hpmn&5dZWY|fH;K90ll(mKG0X6xnZNY#q8_@CVF86bM zpl5$`tvF)ES;ouDXKnq>(&^*rOH|2EG)J-9t@FJcCnI|!*L@g$r&T0UarB>CJ7Y0z vY0OZlvlz7~od)b6Q1;I7Fp4H`1;`;0BrjUuXgq+ literal 1720 zcmZ|OYfMvT7zgm4p2O+ea@rnBg#)OxTPX)YQxLES+gfgxVz~&+f}$;m6s%Hi3W%nq zP@z^qrV}=TNF%FL8K5q@MN>cp#S0pVI*qHSli{|&j8i`-D~lhy5AU}p`Tz2N-e*-( zqBu&8Q*g>F3T19?Zf0i2Y&JU_j>N>onwlC4g`!j{1p>jzlP51;yvXHpJ32ZL1c{7{ z)MzyPIro%=%#1i`T0+<|5ezw}`5%1a$_msK1)F#~iYhcbb+NiiTcX~ytZ3Wj5(@tv zLT5OqLY&VTiBl*@DK5jOqAQC<V}_H8&J8*d!6F|8^P+>r!@8gG==_FR|TOFO5N ztmi!uPli+Ln$x?H-gK%V=cf&)%tK3Ubl`;)j){YK#AZm_($yDbHN+iIVb4-MA(|Tn z%Y=0Su-m75IE?%N1|!SEl|tuKXsXZNj2Z=vp;+=jlJSZD2EODW0H`sM#)b0zgDU0)5!Grr5zO1 zNgN^!L7)EBFUC+Zhm%Mr7yC91@!CieHdPd#!o7Jn^!!TMrU0vgH)|h-!|2wozJKmj z`G&1Z^{+00Fi|SEx@=o?UTI)xo@>T@7i7MZAqTYCMc0JP{oZJEdWye2L~bM45otrq zk@}$q6%b*2<$_YGZVC^6PBqU&pG6rtOM!WN;+E;i3EB*=+K0j60WC&J{7x}V=Ak(w<1X>er- zV`_bHI~Y%5hQkS?_Lf?1C-Yh;suT(z!ZdS6NOH8>FGetNtnE-ngIxI9OKM9M!nq|ao z@ByV)WU%+EiuxlBZ=#rs_ZnY%+O^bXr2P8_g2l~7Z8221w?Uyx%!zc@?f!tWxz6{`xAWPUyeq1Vbvuj7m$3Dh(PTY04bw^_A zwRr|LuoC34N#A1;?zXdaId|wW$kzq2e~Uqdrq=@A0^DlGO4UM zzCO9@&t7@ohLX-t)ftJ| z)q;&?w?;l@^4Pc`;x3vPJ8(itFdKg3;$nap8V7O~;L775>pjUjnIyS=0%4f;&$i;^ q^<`2=x-x(uk2YUU2h;2jemskO_4rHker(fa{min-width:30px;height:28px;line-height:28px;display:block;background:#fff;font-size:14px;color:#333;text-decoration:none;text-align:center}.paginationjs .paginationjs-pages li>a:hover{background:#eee}.paginationjs .paginationjs-pages li.active{border:none}.paginationjs .paginationjs-pages li.active>a{height:30px;line-height:30px;background:#aaa;color:#fff}.paginationjs .paginationjs-pages li.disabled>a{opacity:.3}.paginationjs .paginationjs-pages li.disabled>a:hover{background:0 0}.paginationjs .paginationjs-pages li:first-child,.paginationjs .paginationjs-pages li:first-child>a{border-radius:3px 0 0 3px}.paginationjs .paginationjs-pages li:last-child{border-right:1px solid #aaa;border-radius:0 3px 3px 0}.paginationjs .paginationjs-pages li:last-child>a{border-radius:0 3px 3px 0}.paginationjs .paginationjs-go-input>input[type=text]{width:30px;height:28px;background:#fff;border-radius:3px;border:1px solid #aaa;padding:0;font-size:14px;text-align:center;vertical-align:baseline;outline:0;box-shadow:none;box-sizing:initial}.paginationjs .paginationjs-go-button>input[type=button]{min-width:40px;height:30px;line-height:28px;background:#fff;border-radius:3px;border:1px solid #aaa;text-align:center;padding:0 8px;font-size:14px;vertical-align:baseline;outline:0;box-shadow:none;color:#333;cursor:pointer;vertical-align:middle\9}.paginationjs.paginationjs-theme-blue .paginationjs-go-input>input[type=text],.paginationjs.paginationjs-theme-blue .paginationjs-pages li{border-color:#289de9}.paginationjs .paginationjs-go-button>input[type=button]:hover{background-color:#f8f8f8}.paginationjs .paginationjs-nav{height:30px;line-height:30px}.paginationjs .paginationjs-go-button,.paginationjs .paginationjs-go-input{margin-left:5px\9}.paginationjs.paginationjs-small{font-size:12px}.paginationjs.paginationjs-small .paginationjs-pages li>a{min-width:26px;height:24px;line-height:24px;font-size:12px}.paginationjs.paginationjs-small .paginationjs-pages li.active>a{height:26px;line-height:26px}.paginationjs.paginationjs-small .paginationjs-go-input{font-size:12px}.paginationjs.paginationjs-small .paginationjs-go-input>input[type=text]{width:26px;height:24px;font-size:12px}.paginationjs.paginationjs-small .paginationjs-go-button{font-size:12px}.paginationjs.paginationjs-small .paginationjs-go-button>input[type=button]{min-width:30px;height:26px;line-height:24px;padding:0 6px;font-size:12px}.paginationjs.paginationjs-small .paginationjs-nav{height:26px;line-height:26px;font-size:12px}.paginationjs.paginationjs-big{font-size:16px}.paginationjs.paginationjs-big .paginationjs-pages li>a{min-width:36px;height:34px;line-height:34px;font-size:16px}.paginationjs.paginationjs-big .paginationjs-pages li.active>a{height:36px;line-height:36px}.paginationjs.paginationjs-big .paginationjs-go-input{font-size:16px}.paginationjs.paginationjs-big .paginationjs-go-input>input[type=text]{width:36px;height:34px;font-size:16px}.paginationjs.paginationjs-big .paginationjs-go-button{font-size:16px}.paginationjs.paginationjs-big .paginationjs-go-button>input[type=button]{min-width:50px;height:36px;line-height:34px;padding:0 12px;font-size:16px}.paginationjs.paginationjs-big .paginationjs-nav{height:36px;line-height:36px;font-size:16px}.paginationjs.paginationjs-theme-blue .paginationjs-pages li>a{color:#289de9}.paginationjs.paginationjs-theme-blue .paginationjs-pages li>a:hover{background:#e9f4fc}.paginationjs.paginationjs-theme-blue .paginationjs-pages li.active>a{background:#289de9;color:#fff}.paginationjs.paginationjs-theme-blue .paginationjs-pages li.disabled>a:hover{background:0 0}.paginationjs.paginationjs-theme-blue .paginationjs-go-button>input[type=button]{background:#289de9;border-color:#289de9;color:#fff}.paginationjs.paginationjs-theme-green .paginationjs-go-input>input[type=text],.paginationjs.paginationjs-theme-green .paginationjs-pages li{border-color:#449d44}.paginationjs.paginationjs-theme-blue .paginationjs-go-button>input[type=button]:hover{background-color:#3ca5ea}.paginationjs.paginationjs-theme-green .paginationjs-pages li>a{color:#449d44}.paginationjs.paginationjs-theme-green .paginationjs-pages li>a:hover{background:#ebf4eb}.paginationjs.paginationjs-theme-green .paginationjs-pages li.active>a{background:#449d44;color:#fff}.paginationjs.paginationjs-theme-green .paginationjs-pages li.disabled>a:hover{background:0 0}.paginationjs.paginationjs-theme-green .paginationjs-go-button>input[type=button]{background:#449d44;border-color:#449d44;color:#fff}.paginationjs.paginationjs-theme-yellow .paginationjs-go-input>input[type=text],.paginationjs.paginationjs-theme-yellow .paginationjs-pages li{border-color:#ec971f}.paginationjs.paginationjs-theme-green .paginationjs-go-button>input[type=button]:hover{background-color:#55a555}.paginationjs.paginationjs-theme-yellow .paginationjs-pages li>a{color:#ec971f}.paginationjs.paginationjs-theme-yellow .paginationjs-pages li>a:hover{background:#fdf5e9}.paginationjs.paginationjs-theme-yellow .paginationjs-pages li.active>a{background:#ec971f;color:#fff}.paginationjs.paginationjs-theme-yellow .paginationjs-pages li.disabled>a:hover{background:0 0}.paginationjs.paginationjs-theme-yellow .paginationjs-go-button>input[type=button]{background:#ec971f;border-color:#ec971f;color:#fff}.paginationjs.paginationjs-theme-red .paginationjs-go-input>input[type=text],.paginationjs.paginationjs-theme-red .paginationjs-pages li{border-color:#c9302c}.paginationjs.paginationjs-theme-yellow .paginationjs-go-button>input[type=button]:hover{background-color:#eea135}.paginationjs.paginationjs-theme-red .paginationjs-pages li>a{color:#c9302c}.paginationjs.paginationjs-theme-red .paginationjs-pages li>a:hover{background:#faeaea}.paginationjs.paginationjs-theme-red .paginationjs-pages li.active>a{background:#c9302c;color:#fff}.paginationjs.paginationjs-theme-red .paginationjs-pages li.disabled>a:hover{background:0 0}.paginationjs.paginationjs-theme-red .paginationjs-go-button>input[type=button]{background:#c9302c;border-color:#c9302c;color:#fff}.paginationjs.paginationjs-theme-red .paginationjs-go-button>input[type=button]:hover{background-color:#ce4541}.paginationjs .paginationjs-pages li.paginationjs-next{border-right:1px solid #aaa\9}.paginationjs .paginationjs-go-input>input[type=text]{line-height:28px\9;vertical-align:middle\9}.paginationjs.paginationjs-big .paginationjs-pages li>a{line-height:36px\9}.paginationjs.paginationjs-big .paginationjs-go-input>input[type=text]{height:36px\9;line-height:36px\9} \ No newline at end of file diff --git a/cvat/apps/dashboard/static/dashboard/js/3rdparty/pagination/pagination.min.js b/cvat/apps/dashboard/static/dashboard/js/3rdparty/pagination/pagination.min.js new file mode 100644 index 000000000000..a8472b590cef --- /dev/null +++ b/cvat/apps/dashboard/static/dashboard/js/3rdparty/pagination/pagination.min.js @@ -0,0 +1,11 @@ +/* + * pagination.js 2.1.4 + * A jQuery plugin to provide simple yet fully customisable pagination + * https://github.com/superRaytin/paginationjs + + * Homepage: http://pagination.js.org + * + * Copyright 2014-2100, superRaytin + * Released under the MIT license. +*/ +!function(a,b){function c(a){throw new Error("Pagination: "+a)}function d(a){a.dataSource||c('"dataSource" is required.'),"string"==typeof a.dataSource?void 0===a.totalNumberLocator?void 0===a.totalNumber?c('"totalNumber" is required.'):b.isNumeric(a.totalNumber)||c('"totalNumber" is incorrect. (Number)'):b.isFunction(a.totalNumberLocator)||c('"totalNumberLocator" should be a Function.'):i.isObject(a.dataSource)&&(void 0===a.locator?c('"dataSource" is an Object, please specify "locator".'):"string"==typeof a.locator||b.isFunction(a.locator)||c(a.locator+" is incorrect. (String | Function)")),void 0===a.formatResult||b.isFunction(a.formatResult)||c('"formatResult" should be a Function.')}function e(a){var c=["go","previous","next","disable","enable","refresh","show","hide","destroy"];b.each(c,function(b,c){a.off(h+c)}),a.data("pagination",{}),b(".paginationjs",a).remove()}function f(a,b){return("object"==(b=typeof a)?null==a&&"null"||Object.prototype.toString.call(a).slice(8,-1):b).toLowerCase()}void 0===b&&c("Pagination requires jQuery.");var g="pagination",h="__pagination-";b.fn.pagination&&(g="pagination2"),b.fn[g]=function(f){if(void 0===f)return this;var j=b(this),k=b.extend({},b.fn[g].defaults,f),l={initialize:function(){var a=this;if(j.data("pagination")||j.data("pagination",{}),!1!==a.callHook("beforeInit")){j.data("pagination").initialized&&b(".paginationjs",j).remove(),a.disabled=!!k.disabled;var c=a.model={pageRange:k.pageRange,pageSize:k.pageSize};a.parseDataSource(k.dataSource,function(b){if(a.isAsync=i.isString(b),i.isArray(b)&&(c.totalNumber=k.totalNumber=b.length),a.isDynamicTotalNumber=a.isAsync&&k.totalNumberLocator,!(k.hideWhenLessThanOnePage&&a.getTotalPage()<=1)){var d=a.render(!0);k.className&&d.addClass(k.className),c.el=d,j["bottom"===k.position?"append":"prepend"](d),a.observer(),j.data("pagination").initialized=!0,a.callHook("afterInit",d)}})}},render:function(a){var c=this,d=c.model,e=d.el||b('
        '),f=!0!==a;c.callHook("beforeRender",f);var g=d.pageNumber||k.pageNumber,h=k.pageRange,i=c.getTotalPage(),j=g-h,l=g+h;return l>i&&(l=i,j=i-2*h,j=j<1?1:j),j<=1&&(j=1,l=Math.min(2*h+1,i)),e.html(c.generateHTML({currentPage:g,pageRange:h,rangeStart:j,rangeEnd:l})),c.callHook("afterRender",f),e},generateHTML:function(a){var c,d,e=this,f=a.currentPage,g=e.getTotalPage(),h=a.rangeStart,i=a.rangeEnd,j=e.getTotalNumber(),l=k.showPrevious,m=k.showNext,n=k.showPageNumbers,o=k.showNavigator,p=k.showGoInput,q=k.showGoButton,r=k.pageLink,s=k.prevText,t=k.nextText,u=k.ellipsisText,v=k.goButtonText,w=k.classPrefix,x=k.activeClassName,y=k.disableClassName,z=k.ulClassName,A="",B='',C='',D=b.isFunction(k.formatNavigator)?k.formatNavigator(f,g,j):k.formatNavigator,E=b.isFunction(k.formatGoInput)?k.formatGoInput(B,f,g,j):k.formatGoInput,F=b.isFunction(k.formatGoButton)?k.formatGoButton(C,f,g,j):k.formatGoButton,G=b.isFunction(k.autoHidePrevious)?k.autoHidePrevious():k.autoHidePrevious,H=b.isFunction(k.autoHideNext)?k.autoHideNext():k.autoHideNext,I=b.isFunction(k.header)?k.header(f,g,j):k.header,J=b.isFunction(k.footer)?k.footer(f,g,j):k.footer;if(I&&(c=e.replaceVariables(I,{currentPage:f,totalPage:g,totalNumber:j}),A+=c),l||n||m){if(A+='
        ',A+=z?'
          ':"
        "}return o&&D&&(c=e.replaceVariables(D,{currentPage:f,totalPage:g,totalNumber:j}),A+='
        '+c+"
        "),p&&E&&(c=e.replaceVariables(E,{currentPage:f,totalPage:g,totalNumber:j,input:B}),A+='
        '+c+"
        "),q&&F&&(c=e.replaceVariables(F,{currentPage:f,totalPage:g,totalNumber:j,button:C}),A+='
        '+c+"
        "),J&&(c=e.replaceVariables(J,{currentPage:f,totalPage:g,totalNumber:j}),A+=c),A},findTotalNumberFromRemoteResponse:function(a){this.model.totalNumber=k.totalNumberLocator(a)},go:function(a,c){function d(a){if(!1===e.callHook("beforePaging",g))return!1;if(f.direction=void 0===f.pageNumber?0:g>f.pageNumber?1:-1,f.pageNumber=g,e.render(),e.disabled&&e.isAsync&&e.enable(),j.data("pagination").model=f,k.formatResult){var d=b.extend(!0,[],a);i.isArray(a=k.formatResult(d))||(a=d)}j.data("pagination").currentPageData=a,e.doCallback(a,c),e.callHook("afterPaging",g),1==g&&e.callHook("afterIsFirstPage"),g==e.getTotalPage()&&e.callHook("afterIsLastPage")}var e=this,f=e.model;if(!e.disabled){var g=a;if((g=parseInt(g))&&!(g<1)){var h=k.pageSize,l=e.getTotalNumber(),m=e.getTotalPage();if(!(l>0&&g>m)){if(!e.isAsync)return void d(e.getDataFragment(g));var n={},o=k.alias||{};n[o.pageSize?o.pageSize:"pageSize"]=h,n[o.pageNumber?o.pageNumber:"pageNumber"]=g;var p=b.isFunction(k.ajax)?k.ajax():k.ajax,q={type:"get",cache:!1,data:{},contentType:"application/x-www-form-urlencoded; charset=UTF-8",dataType:"json",async:!0};b.extend(!0,q,p),b.extend(q.data,n),q.url=k.dataSource,q.success=function(a){e.isDynamicTotalNumber?e.findTotalNumberFromRemoteResponse(a):e.model.totalNumber=k.totalNumber,d(e.filterDataByLocator(a))},q.error=function(a,b,c){k.formatAjaxError&&k.formatAjaxError(a,b,c),e.enable()},e.disable(),b.ajax(q)}}}},doCallback:function(a,c){var d=this,e=d.model;b.isFunction(c)?c(a,e):b.isFunction(k.callback)&&k.callback(a,e)},destroy:function(){!1!==this.callHook("beforeDestroy")&&(this.model.el.remove(),j.off(),b("#paginationjs-style").remove(),this.callHook("afterDestroy"))},previous:function(a){this.go(this.model.pageNumber-1,a)},next:function(a){this.go(this.model.pageNumber+1,a)},disable:function(){var a=this,b=a.isAsync?"async":"sync";!1!==a.callHook("beforeDisable",b)&&(a.disabled=!0,a.model.disabled=!0,a.callHook("afterDisable",b))},enable:function(){var a=this,b=a.isAsync?"async":"sync";!1!==a.callHook("beforeEnable",b)&&(a.disabled=!1,a.model.disabled=!1,a.callHook("afterEnable",b))},refresh:function(a){this.go(this.model.pageNumber,a)},show:function(){var a=this;a.model.el.is(":visible")||a.model.el.show()},hide:function(){var a=this;a.model.el.is(":visible")&&a.model.el.hide()},replaceVariables:function(a,b){var c;for(var d in b){var e=b[d],f=new RegExp("<%=\\s*"+d+"\\s*%>","img");c=(c||a).replace(f,e)}return c},getDataFragment:function(a){var b=k.pageSize,c=k.dataSource,d=this.getTotalNumber(),e=b*(a-1)+1,f=Math.min(a*b,d);return c.slice(e-1,f)},getTotalNumber:function(){return this.model.totalNumber||k.totalNumber||0},getTotalPage:function(){return Math.ceil(this.getTotalNumber()/k.pageSize)},getLocator:function(a){var d;return"string"==typeof a?d=a:b.isFunction(a)?d=a():c('"locator" is incorrect. (String | Function)'),d},filterDataByLocator:function(a){var d,e=this.getLocator(k.locator);if(i.isObject(a)){try{b.each(e.split("."),function(b,c){d=(d||a)[c]})}catch(a){}d?i.isArray(d)||c("dataSource."+e+" must be an Array."):c("dataSource."+e+" is undefined.")}return d||a},parseDataSource:function(a,d){var e=this;i.isObject(a)?d(k.dataSource=e.filterDataByLocator(a)):i.isArray(a)?d(k.dataSource=a):b.isFunction(a)?k.dataSource(function(a){i.isArray(a)||c('The parameter of "done" Function should be an Array.'),e.parseDataSource.call(e,a,d)}):"string"==typeof a?(/^https?|file:/.test(a)&&(k.ajaxDataType="jsonp"),d(a)):c('Unexpected type of "dataSource".')},callHook:function(c){var d,e=j.data("pagination"),f=Array.prototype.slice.apply(arguments);return f.shift(),k[c]&&b.isFunction(k[c])&&!1===k[c].apply(a,f)&&(d=!1),e.hooks&&e.hooks[c]&&b.each(e.hooks[c],function(b,c){!1===c.apply(a,f)&&(d=!1)}),!1!==d},observer:function(){var a=this,d=a.model.el;j.on(h+"go",function(d,e,f){(e=parseInt(b.trim(e)))&&(b.isNumeric(e)||c('"pageNumber" is incorrect. (Number)'),a.go(e,f))}),d.delegate(".J-paginationjs-page","click",function(c){var d=b(c.currentTarget),e=b.trim(d.attr("data-num"));if(e&&!d.hasClass(k.disableClassName)&&!d.hasClass(k.activeClassName))return!1!==a.callHook("beforePageOnClick",c,e)&&(a.go(e),a.callHook("afterPageOnClick",c,e),!!k.pageLink&&void 0)}),d.delegate(".J-paginationjs-previous","click",function(c){var d=b(c.currentTarget),e=b.trim(d.attr("data-num"));if(e&&!d.hasClass(k.disableClassName))return!1!==a.callHook("beforePreviousOnClick",c,e)&&(a.go(e),a.callHook("afterPreviousOnClick",c,e),!!k.pageLink&&void 0)}),d.delegate(".J-paginationjs-next","click",function(c){var d=b(c.currentTarget),e=b.trim(d.attr("data-num"));if(e&&!d.hasClass(k.disableClassName))return!1!==a.callHook("beforeNextOnClick",c,e)&&(a.go(e),a.callHook("afterNextOnClick",c,e),!!k.pageLink&&void 0)}),d.delegate(".J-paginationjs-go-button","click",function(c){var e=b(".J-paginationjs-go-pagenumber",d).val();if(!1===a.callHook("beforeGoButtonOnClick",c,e))return!1;j.trigger(h+"go",e),a.callHook("afterGoButtonOnClick",c,e)}),d.delegate(".J-paginationjs-go-pagenumber","keyup",function(c){if(13===c.which){var e=b(c.currentTarget).val();if(!1===a.callHook("beforeGoInputOnEnter",c,e))return!1;j.trigger(h+"go",e),b(".J-paginationjs-go-pagenumber",d).focus(),a.callHook("afterGoInputOnEnter",c,e)}}),j.on(h+"previous",function(b,c){a.previous(c)}),j.on(h+"next",function(b,c){a.next(c)}),j.on(h+"disable",function(){a.disable()}),j.on(h+"enable",function(){a.enable()}),j.on(h+"refresh",function(b,c){a.refresh(c)}),j.on(h+"show",function(){a.show()}),j.on(h+"hide",function(){a.hide()}),j.on(h+"destroy",function(){a.destroy()});var e=Math.max(a.getTotalPage(),1),f=k.pageNumber;a.isDynamicTotalNumber&&(f=1),k.triggerPagingOnInit&&j.trigger(h+"go",Math.min(f,e))}};if(j.data("pagination")&&!0===j.data("pagination").initialized){if(b.isNumeric(f))return j.trigger.call(this,h+"go",f,arguments[1]),this;if("string"==typeof f){var m=Array.prototype.slice.apply(arguments);switch(m[0]=h+m[0],f){case"previous":case"next":case"go":case"disable":case"enable":case"refresh":case"show":case"hide":case"destroy":j.trigger.apply(this,m);break;case"getSelectedPageNum":return j.data("pagination").model?j.data("pagination").model.pageNumber:j.data("pagination").attributes.pageNumber;case"getTotalPage":return Math.ceil(j.data("pagination").model.totalNumber/j.data("pagination").model.pageSize);case"getSelectedPageData":return j.data("pagination").currentPageData;case"isDisabled":return!0===j.data("pagination").model.disabled;default:c("Unknown action: "+f)}return this}e(j)}else i.isObject(f)||c("Illegal options");return d(k),l.initialize(),this},b.fn[g].defaults={totalNumber:0,pageNumber:1,pageSize:10,pageRange:2,showPrevious:!0,showNext:!0,showPageNumbers:!0,showNavigator:!1,showGoInput:!1,showGoButton:!1,pageLink:"",prevText:"«",nextText:"»",ellipsisText:"...",goButtonText:"Go",classPrefix:"paginationjs",activeClassName:"active",disableClassName:"disabled",inlineStyle:!0,formatNavigator:"<%= currentPage %> / <%= totalPage %>",formatGoInput:"<%= input %>",formatGoButton:"<%= button %>",position:"bottom",autoHidePrevious:!1,autoHideNext:!1,triggerPagingOnInit:!0,hideWhenLessThanOnePage:!1,showFirstOnEllipsisShow:!0,showLastOnEllipsisShow:!0,callback:function(){}},b.fn.addHook=function(a,d){arguments.length<2&&c("Missing argument."),b.isFunction(d)||c("callback must be a function.");var e=b(this),f=e.data("pagination");f||(e.data("pagination",{}),f=e.data("pagination")),!f.hooks&&(f.hooks={}),f.hooks[a]=f.hooks[a]||[],f.hooks[a].push(d)},b[g]=function(a,d){arguments.length<2&&c("Requires two parameters.");var e;if(e="string"!=typeof a&&a instanceof jQuery?a:b(a),e.length)return e.pagination(d),e};var i={};b.each(["Object","Array","String"],function(a,b){i["is"+b]=function(a){return f(a)===b.toLowerCase()}}),"function"==typeof define&&define.amd&&define(function(){return b})}(this,window.jQuery); \ No newline at end of file diff --git a/cvat/apps/dashboard/static/dashboard/js/dashboard.js b/cvat/apps/dashboard/static/dashboard/js/dashboard.js index d12668c0d03c..c9d9872e0afa 100644 --- a/cvat/apps/dashboard/static/dashboard/js/dashboard.js +++ b/cvat/apps/dashboard/static/dashboard/js/dashboard.js @@ -6,629 +6,834 @@ /* global AnnotationParser:false - Config:false userConfirm:false - ConstIdGenerator:false createExportContainer:false - dumpAnnotationRequest:false + dumpAnnotationRequest: false + dumpAnnotation:false LabelsInfo:false showMessage:false showOverlay:false */ -"use strict"; -/* Server requests */ -function createTaskRequest(oData, onSuccessRequest, onSuccessCreate, onError, onComplete, onUpdateStatus) { - $.ajax({ - url: "/create/task", - type: "POST", - data: oData, - contentType: false, - processData: false, - success: function(data) { - onSuccessRequest(); - requestCreatingStatus(data); - }, - error: function(data) { - onComplete(); - onError(data.responseText); - } - }); +'use strict'; - function requestCreatingStatus(data) { - let tid = data.tid; - let request_frequency_ms = 1000; - let done = false; - - let requestInterval = setInterval(function() { - $.ajax({ - url: "/check/task/" + tid, - success: receiveStatus, - error: function(data) { - clearInterval(requestInterval); - onComplete(); - onError(data.responseText); - } - }); - }, request_frequency_ms); +class TaskView { + constructor(details, ondelete, onupdate) { + this.init(details); - function receiveStatus(data) { - if (done) return; - if (data["state"] === "created") { - done = true; - clearInterval(requestInterval); - onComplete(); - onSuccessCreate(tid); - } - else if (data["state"] === "error") { - done = true; - clearInterval(requestInterval); - onComplete(); - onError(data.stderr); - } - else if (data["state"] === "started" && "status" in data) { - onUpdateStatus(data["status"]); - } - } + this._ondelete = ondelete; + this._onupdate = onupdate; + this._UI = null; } -} - - -function updateTaskRequest(labels) { - let oData = new FormData(); - oData.append("labels", labels); - - $.ajax({ - url: "/update/task/" + window.cvat.dashboard.taskID, - type: "POST", - data: oData, - contentType: false, - processData: false, - success: function() { - $("#dashboardNewLabels").prop("value", ""); - showMessage("Task successfully updated."); - }, - error: function(data) { - showMessage("Task update error. " + data.responseText); - }, - complete: () => $("#dashboardUpdateModal").addClass("hidden") - }); -} + _disable() { + this._UI.find('*').attr('disabled', true).css('opacity', 0.5); + this._UI.find('.dashboardJobList').empty(); + } -function removeTaskRequest() { - userConfirm("The action can not be undone. Are you sure?", confirmCallback); - - function confirmCallback() { + _remove() { $.ajax ({ - url: "/delete/task/" + window.cvat.dashboard.taskID, - success: function() { - $(`#dashboardTask_${window.cvat.dashboard.taskID}`).remove(); - showMessage("Task removed."); + url: `/api/v1/tasks/${this._id}`, + type: 'DELETE', + success: () => { + this._ondelete(this._id); + this._disable(); }, - error: function(response) { - let message = "Abort. Reason: " + response.responseText; + error: (errorData) => { + const message = `Can not build CVAT dashboard. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; showMessage(message); - throw Error(message); } }); } -} + _update() { + $('#dashboardUpdateModal').remove(); + const dashboardUpdateModal = $($('#dashboardUpdateTemplate').html()).appendTo('body'); + $('#dashboardOldLabels').prop('value', LabelsInfo.serialize(this._labels)); -function uploadAnnotationRequest() { - let input = $("").attr({ - type: "file", - accept: "text/xml" - }).on("change", loadXML).click(); + $('#dashboardCancelUpdate').on('click', () => { + dashboardUpdateModal.remove(); + }); - function loadXML(e) { - input.remove(); - let overlay = showOverlay("File is being uploaded.."); - let file = e.target.files[0]; - let fileReader = new FileReader(); - fileReader.onload = (e) => parseFile(e, overlay); - fileReader.readAsText(file); + $('#dashboardSubmitUpdate').on('click', () => { + try { + const body = { + labels: LabelsInfo.deserialize($('#dashboardNewLabels').prop('value')) + }; + $.ajax({ + url: `/api/v1/tasks/${this._id}`, + type: 'PATCH', + contentType: 'application/json', + data: JSON.stringify(body) + }).done(() => { + this._onupdate(); + dashboardUpdateModal.remove(); + showMessage('Task has been successfully updated'); + }).fail((errorData) => { + const message = `Can not build CVAT dashboard. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + }); + } catch (exception) { + showMessage(exception); + } + }); } - function parseFile(e, overlay) { - let xmlText = e.target.result; - overlay.setMessage("Request task data from server.."); - $.ajax({ - url: "/get/task/" + window.cvat.dashboard.taskID, - success: function(data) { - let annotationParser = new AnnotationParser( - { - start: 0, - stop: data.size, - image_meta_data: data.image_meta_data, - flipped: data.flipped - }, - new LabelsInfo(data.spec), - new ConstIdGenerator(-1) - ); + _upload() { + async function saveChunk(parsed) { + const CHUNK_SIZE = 30000; + + class Chunk { + constructor() { + this.shapes = []; + this.tracks = []; + this.tags = []; + this.capasity = CHUNK_SIZE; + this.version = 0; + } + + length() { + return this.tags.length + + this.shapes.length + + this.tracks.reduce((sum, track) => sum + track.shapes.length, 0); + } + + isFull() { + return this.length() >= this.capasity; + } + + isEmpty() { + return this.length() === 0; + } - let asyncParse = function() { - let parsed = null; + clear() { + this.shapes = []; + this.tracks = []; + this.tags = []; + } + export() { + return { + shapes: this.shapes, + tracks: this.tracks, + tags: this.tags, + version: this.version, + }; + } + async save(taskID) { try { - parsed = annotationParser.parse(xmlText); - } - catch(error) { - overlay.remove(); - showMessage("Parsing errors was occurred. " + error); - return; + const response = await $.ajax({ + url: `/api/v1/tasks/${taskID}/annotations?action=create`, + type: 'PATCH', + data: JSON.stringify(chunk.export()), + contentType: 'application/json', + }); + this.version = response.version; + this.clear(); + } catch (error) { + throw error; } + } + } - let asyncSave = function() { - $.ajax({ - url: "/delete/annotation/task/" + window.cvat.dashboard.taskID, - type: "DELETE", - success: function() { - asyncSaveChunk(0); - }, - error: function(response) { - let message = "Previous annotations cannot be deleted: " + - response.responseText; - showMessage(message); - overlay.remove(); - }, - }); - }; + const splitAndSave = async (chunk, prop, splitStep) => { + for(let start = 0; start < parsed[prop].length; start += splitStep) { + Array.prototype.push.apply(chunk[prop], parsed[prop].slice(start, start + splitStep)); + if (chunk.isFull()) { + await chunk.save(this._id); + } + } + // save tail + if (!chunk.isEmpty()) { + await chunk.save(this._id); + } + }; - let asyncSaveChunk = function(start) { - const CHUNK_SIZE = 100000; - let end = start + CHUNK_SIZE; - let chunk = {}; - let next = false; - for (let prop in parsed) { - if (parsed.hasOwnProperty(prop)) { - chunk[prop] = parsed[prop].slice(start, end); - next |= chunk[prop].length > 0; - } - } + let chunk = new Chunk(); + // FIXME tags aren't supported by parser + // await split(chunk, "tags", CHUNK_SIZE); + await splitAndSave(chunk, "shapes", CHUNK_SIZE); + await splitAndSave(chunk, "tracks", 1); + } - if (next) { - let exportData = createExportContainer(); - exportData.create = chunk; - - $.ajax({ - url: "/save/annotation/task/" + window.cvat.dashboard.taskID, - type: "POST", - data: JSON.stringify(exportData), - contentType: "application/json", - success: function() { - asyncSaveChunk(end); - }, - error: function(response) { - let message = "Annotations uploading errors were occurred: " + - response.responseText; - showMessage(message); - overlay.remove(); - }, - }); - } else { - let message = "Annotations were uploaded successfully"; - showMessage(message); - overlay.remove(); - } - }; + async function save(parsed) { + await $.ajax({ + url: `/api/v1/tasks/${this._id}/annotations`, + type: 'DELETE', + }); - overlay.setMessage("Annotation is being saved.."); - setTimeout(asyncSave); - }; + await saveChunk.call(this, parsed); + } - overlay.setMessage("File is being parsed.."); - setTimeout(asyncParse); - }, - error: function(response) { - overlay.remove(); - let message = "Bad task request: " + response.responseText; + async function onload(overlay, text) { + try { + overlay.setMessage('Required data are being downloaded from the server..'); + const imageCache = await $.get(`/api/v1/tasks/${this._id}/frames/meta`); + const labelsCopy = JSON.parse(JSON.stringify(this._labels)); + const parser = new AnnotationParser({ + start: 0, + stop: this._size, + flipped: this._flipped, + image_meta_data: imageCache, + }, new LabelsInfo(labelsCopy)); + + overlay.setMessage('The annotation file is being parsed..'); + const parsed = parser.parse(text); + + overlay.setMessage('The annotation is being saved..'); + await save.call(this, parsed); + + const message = 'Annotation have been successfully uploaded'; showMessage(message); - throw Error(message); + } catch(errorData) { + let message = null; + if (typeof(errorData) === 'string') { + message = `Can not upload annotations. ${errorData}`; + } else { + message = `Can not upload annotations. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + } + showMessage(message); + } finally { + overlay.remove(); } - }); - } -} + } + $('').on('change', (e) => { + const file = e.target.files[0]; + $(e.target).remove(); + if (file) { + const overlay = showOverlay('File is being parsed..'); + const fileReader = new FileReader(); + fileReader.onload = (e) => { + onload.call(this, overlay, e.target.result); + } + fileReader.readAsText(file); + } + }).click(); + } -/* Dashboard entrypoint */ -window.cvat = window.cvat || {}; -window.cvat.dashboard = window.cvat.dashboard || {}; -window.cvat.dashboard.uiCallbacks = window.cvat.dashboard.uiCallbacks || []; -window.cvat.config = new Config(); - -window.cvat.dashboard.uiCallbacks.push(function(elements) { - elements.each(function(idx) { - let elem = $(elements[idx]); - let taskID = +elem.attr("id").split("_")[1]; - let taskName = $.trim($( elem.find("label.dashboardTaskNameLabel")[0] ).text()); - let buttonsUI = elem.find("div.dashboardButtonsUI")[0]; - - let dumpButton = $( $(buttonsUI).find("button.dashboardDumpAnnotation")[0] ); - let uploadButton = $( $(buttonsUI).find("button.dashboardUploadAnnotation")[0] ); - let updateButton = $( $(buttonsUI).find("button.dashboardUpdateTask")[0] ); - let deleteButton = $( $(buttonsUI).find("button.dashboardDeleteTask")[0] ); - - let bugTrackerButton = $(buttonsUI).find(".dashboardOpenTrackerButton"); - if (bugTrackerButton.length) { - bugTrackerButton = $(bugTrackerButton[0]); - bugTrackerButton.on("click", function() { - window.open($(buttonsUI).find("a.dashboardBugTrackerLink").attr("href")); - }); + async _dump(button) { + button.disabled = true; + try { + await dumpAnnotationRequest(this._id, this._name); + } catch (error) { + showMessage(error.message); + } finally { + button.disabled = false; } + } - dumpButton.on("click", function() { - window.cvat.dashboard.taskID = taskID; - window.cvat.dashboard.taskName = taskName; - dumpAnnotationRequest(dumpButton, taskID, taskName); - }); + init(details) { + for (let prop in details) { + this[`_${prop}`] = details[prop]; + } + } - uploadButton.on("click", function() { - window.cvat.dashboard.taskID = taskID; - window.cvat.dashboard.taskName = taskName; - userConfirm("The current annotation will be lost. Are you sure?", uploadAnnotationRequest); - }); + render(baseURL) { + const self = this; + this._UI = $(`
        `).append( + $(`
        + +
        `) + ).append( + $(`
        + +
        `) + ).append( + $('
        ').css({ + 'background-image': `url("/api/v1/tasks/${this._id}/frames/0")` + }) + ); - updateButton.on("click", function() { - window.cvat.dashboard.taskID = taskID; - window.cvat.dashboard.taskName = taskName; - $("#dashboardUpdateModal").removeClass("hidden"); - $("#dashboardUpdateModal")[0].loadCurrentLabels(); - }); - deleteButton.on("click", function() { - window.cvat.dashboard.taskID = taskID; - window.cvat.dashboard.taskName = taskName; - removeTaskRequest(); - }); - }); -}); + const buttonsContainer = $(`
        `).appendTo(this._UI); + $('').on('click', (e) => { + self._dump(e.target); + }).appendTo(buttonsContainer); -document.addEventListener("DOMContentLoaded", buildDashboard); + $('').on('click', () => { + userConfirm("The current annotation will be lost. Are you sure?", () => self._upload()); + }).appendTo(buttonsContainer); + $('').on('click', () => { + self._update(); + }).appendTo(buttonsContainer); -function buildDashboard() { - /* Setup static content */ - setupTaskCreator(); - setupTaskUpdater(); - setupSearch(); + $('').on('click', () => { + userConfirm("The task will be removed. Are you sure?", () => self._remove()); + }).appendTo(buttonsContainer); - $(window).on("click", function(event) { - if (event.target.classList.contains("modal")) { - event.target.classList.add("hidden"); + if (this._bug_tracker) { + $('').on('click', () => { + window.open(this._bug_tracker); + }).appendTo(buttonsContainer); } - }); - /* Setup task UIs */ - for (let callback of window.cvat.dashboard.uiCallbacks) { - callback( $(".dashboardTaskUI") ); - } - $("#loadingOverlay").remove(); -} + const jobsContainer = $(``); + for (let segment of this._segments) { + for (let job of segment.jobs) { + const link = `${baseURL}?id=${job.id}`; + jobsContainer.append($(``)); + } + } + this._UI.append($(` +
        +
        + +
        +
        + `).append(jobsContainer)); -function setupTaskCreator() { - let dashboardCreateTaskButton = $("#dashboardCreateTaskButton"); - let createModal = $("#dashboardCreateModal"); - let nameInput = $("#dashboardNameInput"); - let labelsInput = $("#dashboardLabelsInput"); - let bugTrackerInput = $("#dashboardBugTrackerInput"); - let localSourceRadio = $("#dashboardLocalSource"); - let shareSourceRadio = $("#dashboardShareSource"); - let selectFiles = $("#dashboardSelectFiles"); - let filesLabel = $("#dashboardFilesLabel"); - let localFileSelector = $("#dashboardLocalFileSelector"); - let shareFileSelector = $("#dashboardShareBrowseModal"); - let shareBrowseTree = $("#dashboardShareBrowser"); - let cancelBrowseServer = $("#dashboardCancelBrowseServer"); - let submitBrowseServer = $("#dashboardSubmitBrowseServer"); - let flipImagesBox = $("#dashboardFlipImages"); - let zOrderBox = $("#dashboardZOrder"); - let segmentSizeInput = $("#dashboardSegmentSize"); - let customSegmentSize = $("#dashboardCustomSegment"); - let overlapSizeInput = $("#dashboardOverlap"); - let customOverlapSize = $("#dashboardCustomOverlap"); - let imageQualityInput = $("#dashboardImageQuality"); - let customCompressQuality = $("#dashboardCustomQuality"); - - let taskMessage = $("#dashboardCreateTaskMessage"); - let submitCreate = $("#dashboardSubmitTask"); - let cancelCreate = $("#dashboardCancelTask"); - - let name = nameInput.prop("value"); - let labels = labelsInput.prop("value"); - let bugTrackerLink = bugTrackerInput.prop("value"); - let source = "local"; - let flipImages = false; - let zOrder = false; - let segmentSize = 5000; - let overlapSize = 0; - let compressQuality = 50; - let files = []; - - dashboardCreateTaskButton.on("click", function() { - $("#dashboardCreateModal").removeClass("hidden"); - }); + if (this._removed) { + this._disable(); + } - nameInput.on("change", (e) => {name = e.target.value;}); - bugTrackerInput.on("change", (e) => {bugTrackerLink = e.target.value;}); - labelsInput.on("change", (e) => {labels = e.target.value;}); + return this._UI; + } +} - localSourceRadio.on("click", function() { - if (source === "local") { - return; - } - source = "local"; - files = []; - updateSelectedFiles(); - }); - shareSourceRadio.on("click", function() { - if (source === "share") { - return; - } - source = "share"; - files = []; - updateSelectedFiles(); - }); +class DashboardView { + constructor(metaData, taskData) { + this._dashboardList = taskData.results; + this._maxUploadSize = metaData.max_upload_size; + this._maxUploadCount = metaData.max_upload_count; + this._baseURL = metaData.base_url; + this._sharePath = metaData.share_path; - selectFiles.on("click", function() { - if (source === "local") { - localFileSelector.click(); - } - else { - shareBrowseTree.jstree("refresh"); - shareFileSelector.removeClass("hidden"); - shareBrowseTree.jstree({ - core: { - data: { - url: "get_share_nodes", - data: (node) => { return {"id" : node.id}; } - } + this._setupList(); + this._setupTaskSearch(); + this._setupCreateDialog(); + } + + _setupList() { + const dashboardList = $('#dashboardList'); + const dashboardPagination = $('#dashboardPagination'); + + const baseURL = this._baseURL; + let overlay = null; + dashboardPagination.pagination({ + dataSource: `/api/v1/tasks${window.location.search}`, + locator: 'results', + alias: { + pageNumber: 'page', + }, + totalNumberLocator: function(response) { + return response.count; + }, + ajax: { + beforeSend() { + overlay = showOverlay('Loading..'); }, - plugins: ["checkbox", "sort"], - }); - } - }); + }, + callback: function(pageList) { + if (overlay) { + overlay.remove(); + overlay = null; + } + dashboardList.empty(); + for (let details of pageList) { + const detailsCopy = JSON.parse(JSON.stringify(details)); + const taskView = new TaskView(detailsCopy, () => { + // on delete task callback + details.removed = true + }, () => { + // on update task callback + $.get(`/api/v1/tasks/${details.id}`).done((taskData) => { + Object.assign(details, taskData); + taskView.init(details); + }).fail((errorData) => { + const message = `Can not get task from server. Showed info may be obsolete. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + }) + }); + dashboardList.append(taskView.render(baseURL)); + } - localFileSelector.on("change", function(e) { - files = e.target.files; - updateSelectedFiles(); - }); + window.dispatchEvent(new CustomEvent('dashboardReady', { + detail: JSON.parse(JSON.stringify(pageList)) + })); + const pages = $('.paginationjs-pages'); + pages.css('margin-left', (window.screen.width - pages.width()) / 2); + } + }); + } - cancelBrowseServer.on("click", () => shareFileSelector.addClass("hidden")); - submitBrowseServer.on("click", function() { - if (!createModal.hasClass("hidden")) { - files = shareBrowseTree.jstree(true).get_selected(); - cancelBrowseServer.click(); - updateSelectedFiles(); - } - }); + _setupTaskSearch() { + const searchInput = $('#dashboardSearchInput'); + const searchSubmit = $('#dashboardSearchSubmit'); - flipImagesBox.on("click", (e) => { - flipImages = e.target.checked; - }); + searchInput.on('keypress', (e) => { + if (e.keyCode != 13) { + return; + } - zOrderBox.on("click", (e) => { - zOrder = e.target.checked; - }); - customSegmentSize.on("change", (e) => segmentSizeInput.prop("disabled", !e.target.checked)); - customOverlapSize.on("change", (e) => overlapSizeInput.prop("disabled", !e.target.checked)); - customCompressQuality.on("change", (e) => imageQualityInput.prop("disabled", !e.target.checked)); - - segmentSizeInput.on("change", function() { - let value = Math.clamp( - +segmentSizeInput.prop("value"), - +segmentSizeInput.prop("min"), - +segmentSizeInput.prop("max") - ); + const params = {}; + const search = e.target.value.replace(/\s+/g, ' ').replace(/\s*:+\s*/g, ':').trim(); + for (let field of ['name', 'mode', 'owner', 'assignee', 'status']) { + for (let param of search.split(' and ')) { + if (param.includes(':')) { + param = param.split(':'); + if (param[0] === field && param[1]) { + params[field] = param[1]; + } + } + } + } - segmentSizeInput.prop("value", value); - segmentSize = value; - }); + if (!Object.keys(params).length && search.length) { + params['search'] = search; + } - overlapSizeInput.on("change", function() { - let value = Math.clamp( - +overlapSizeInput.prop("value"), - +overlapSizeInput.prop("min"), - +overlapSizeInput.prop("max") - ); + if (Object.keys(params).length) { + const searchParams = new URLSearchParams(); + for (let key in params) { + searchParams.set(key, params[key]); + } + window.location.search = searchParams.toString(); + } else { + window.location.search = ''; + } + }); - overlapSizeInput.prop("value", value); - overlapSize = value; - }); + searchSubmit.on('click', function() { + let e = $.Event('keypress'); + e.keyCode = 13; + searchInput.trigger(e); + }); - imageQualityInput.on("change", function() { - let value = Math.clamp( - +imageQualityInput.prop("value"), - +imageQualityInput.prop("min"), - +imageQualityInput.prop("max") - ); + const searchParams = new URLSearchParams(window.location.search.substring(1)); + if (searchParams.get('all')) { + searchInput.prop('value', searchParams.get('all')); + } else { + let search = ''; + for (let field of ['name', 'mode', 'owner', 'assignee', 'status']) { + const fieldVal = searchParams.get(field); + if (fieldVal) { + search += `${field}: ${fieldVal} and `; + } + } + searchInput.prop('value', search.slice(0, -5)); + } + } + + _setupCreateDialog() { + function updateSelectedFiles() { + switch (files.length) { + case 0: + filesLabel.text('No Files'); + break; + case 1: + filesLabel.text(typeof(files[0]) === 'string' ? files[0] : files[0].name); + break; + default: + filesLabel.text(files.length + ' files'); + } + } - imageQualityInput.prop("value", value); - compressQuality = value; - }); - submitCreate.on("click", function() { - if (!validateName(name)) { - taskMessage.css("color", "red"); - taskMessage.text("Invalid task name"); - return; + function validateName(name) { + const math = name.match('[a-zA-Z0-9_]+'); + return math !== null; } - if (!validateLabels(labels)) { - taskMessage.css("color", "red"); - taskMessage.text("Invalid task labels"); - return; + function validateLabels(labels) { + try { + LabelsInfo.deserialize(labels) + return true; + } catch { + return false; + } } - if (!validateSegmentSize(segmentSize)) { - taskMessage.css("color", "red"); - taskMessage.text("Segment size out of range"); - return; + function validateBugTracker(bugTracker) { + return !bugTracker || !!bugTracker.match(/^http[s]?/); } - if (!validateOverlapSize(overlapSize, segmentSize)) { - taskMessage.css("color", "red"); - taskMessage.text("Overlap size must be positive and not more then segment size"); - return; + function validateSegmentSize(segmentSize) { + return (segmentSize >= 100 && segmentSize <= 50000); } - if (files.length <= 0) { - taskMessage.css("color", "red"); - taskMessage.text("Need specify files for task"); - return; + function validateOverlapSize(overlapSize, segmentSize) { + return (overlapSize >= 0 && overlapSize <= segmentSize - 1); } - else if (files.length > window.maxUploadCount && source === "local") { - taskMessage.css("color", "red"); - taskMessage.text("Too many files. Please use share functionality"); - return; + + function requestCreatingStatus(tid, onUpdateStatus, onSuccess, onError) { + function checkCallback() { + $.get(`/api/v1/tasks/${tid}/status`).done((data) => { + if (['Queued', 'Started'].includes(data.state)) { + if (data.message !== '') { + onUpdateStatus(data.message); + } + setTimeout(checkCallback, 1000); + } else { + if (data.state === 'Finished') { + onSuccess(); + } + else if (data.state === 'Failed') { + const message = `Can not create task. ${data.message}`; + onError(message); + } else { + const message = `Unknown state has been received: ${data.state}`; + onError(message); + } + + } + }).fail((errorData) => { + const message = `Can not check task status. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + onError(message); + }); + } + + setTimeout(checkCallback, 1000); } - else if (source === "local") { - let commonSize = 0; - for (let file of files) { - commonSize += file.size; - } - if (commonSize > window.maxUploadSize) { - taskMessage.css("color", "red"); - taskMessage.text("Too big size. Please use share functionality"); + + const dashboardCreateTaskButton = $('#dashboardCreateTaskButton'); + const createModal = $('#dashboardCreateModal'); + const nameInput = $('#dashboardNameInput'); + const labelsInput = $('#dashboardLabelsInput'); + const bugTrackerInput = $('#dashboardBugTrackerInput'); + const localSourceRadio = $('#dashboardLocalSource'); + const shareSourceRadio = $('#dashboardShareSource'); + const selectFiles = $('#dashboardSelectFiles'); + const filesLabel = $('#dashboardFilesLabel'); + const localFileSelector = $('#dashboardLocalFileSelector'); + const shareFileSelector = $('#dashboardShareBrowseModal'); + const shareBrowseTree = $('#dashboardShareBrowser'); + const cancelBrowseServer = $('#dashboardCancelBrowseServer'); + const submitBrowseServer = $('#dashboardSubmitBrowseServer'); + const zOrderBox = $('#dashboardZOrder'); + const segmentSizeInput = $('#dashboardSegmentSize'); + const customSegmentSize = $('#dashboardCustomSegment'); + const overlapSizeInput = $('#dashboardOverlap'); + const customOverlapSize = $('#dashboardCustomOverlap'); + const imageQualityInput = $('#dashboardImageQuality'); + const customCompressQuality = $('#dashboardCustomQuality'); + + const taskMessage = $('#dashboardCreateTaskMessage'); + const submitCreate = $('#dashboardSubmitTask'); + const cancelCreate = $('#dashboardCancelTask'); + + let name = nameInput.prop('value'); + let labels = labelsInput.prop('value'); + let bugTrackerLink = bugTrackerInput.prop('value').trim(); + let source = 'local'; + let zOrder = false; + let segmentSize = 5000; + let overlapSize = 0; + let compressQuality = 50; + let files = []; + + dashboardCreateTaskButton.on('click', () => { + $('#dashboardCreateModal').removeClass('hidden'); + }); + + nameInput.on('change', (e) => name = e.target.value); + bugTrackerInput.on('change', (e) => bugTrackerLink = e.target.value.trim()); + labelsInput.on('change', (e) => labels = e.target.value); + + localSourceRadio.on('click', () => { + if (source === 'local') { return; } - } + source = 'local'; + files = []; + updateSelectedFiles(); + }); - let taskData = new FormData(); - taskData.append("task_name", name); - taskData.append("bug_tracker_link", bugTrackerLink); - taskData.append("labels", labels); - taskData.append("flip_flag", flipImages); - taskData.append("z_order", zOrder); - taskData.append("storage", source); + shareSourceRadio.on('click', () => { + if (source === 'share') { + return; + } + source = 'share'; + files = []; + updateSelectedFiles(); + }); - if (customSegmentSize.prop("checked")) { - taskData.append("segment_size", segmentSize); - } - if (customOverlapSize.prop("checked")) { - taskData.append("overlap_size", overlapSize); - } - if (customCompressQuality.prop("checked")) { - taskData.append("compress_quality", compressQuality); - } + selectFiles.on('click', () => { + if (source === 'local') { + localFileSelector.click(); + } + else { + shareBrowseTree.jstree('refresh'); + shareFileSelector.removeClass('hidden'); + shareBrowseTree.jstree({ + core: { + data: async function (obj, callback) { + let url = '/api/v1/server/share'; + + if (obj.id != '#') { + url += `?directory=${obj.id.substr(2)}`; + } - for (let file of files) { - taskData.append("data", file); - } + const response = await $.get(url); + const files = Array.from(response, (element) => { + return { + id: `${obj.id}/${element.name}`, + children: element.type === 'DIR', + text: element.name, + icon: element.type === 'DIR' ? 'jstree-folder' : 'jstree-file', + } + }); - submitCreate.prop("disabled", true); - createTaskRequest(taskData, - () => { - taskMessage.css("color", "green"); - taskMessage.text("Successful request! Creating.."); - }, - () => window.location.reload(), - (response) => { - taskMessage.css("color", "red"); - taskMessage.text(response); - }, - () => submitCreate.prop("disabled", false), - (status) => { - taskMessage.css("color", "blue"); - taskMessage.text(status); - }); - }); + callback.call(this, files); + } + }, + plugins: ['checkbox', 'sort'], + }); + } + }); - function updateSelectedFiles() { - switch (files.length) { - case 0: - filesLabel.text("No Files"); - break; - case 1: - filesLabel.text(typeof(files[0]) === "string" ? files[0] : files[0].name); - break; - default: - filesLabel.text(files.length + " files"); - } - } + localFileSelector.on('change', function(e) { + files = e.target.files; + updateSelectedFiles(); + }); + + cancelBrowseServer.on('click', () => shareFileSelector.addClass('hidden')); + submitBrowseServer.on('click', () => { + if (!createModal.hasClass('hidden')) { + files = Array.from(shareBrowseTree.jstree(true).get_selected(), (el) => el.substr(2)); + cancelBrowseServer.click(); + updateSelectedFiles(); + } + }); + zOrderBox.on('click', (e) => { + zOrder = e.target.checked; + }); - function validateName(name) { - let math = name.match("[a-zA-Z0-9()_ ]+"); - return math != null; - } + customSegmentSize.on('change', (e) => segmentSizeInput.prop('disabled', !e.target.checked)); + customOverlapSize.on('change', (e) => overlapSizeInput.prop('disabled', !e.target.checked)); + customCompressQuality.on('change', (e) => imageQualityInput.prop('disabled', !e.target.checked)); - function validateLabels(labels) { - let tmp = labels.replace(/\s/g,""); - return tmp.length > 0; - // to do good validator - } + segmentSizeInput.on('change', () => { + const value = Math.clamp( + +segmentSizeInput.prop('value'), + +segmentSizeInput.prop('min'), + +segmentSizeInput.prop('max') + ); - function validateSegmentSize(segmentSize) { - return (segmentSize >= 100 && segmentSize <= 50000); - } + segmentSizeInput.prop('value', value); + segmentSize = value; + }); - function validateOverlapSize(overlapSize, segmentSize) { - return (overlapSize >= 0 && overlapSize <= segmentSize - 1); - } + overlapSizeInput.on('change', () => { + const value = Math.clamp( + +overlapSizeInput.prop('value'), + +overlapSizeInput.prop('min'), + +overlapSizeInput.prop('max') + ); - cancelCreate.on("click", () => createModal.addClass("hidden")); -} + overlapSizeInput.prop('value', value); + overlapSize = value; + }); + imageQualityInput.on('change', () => { + const value = Math.clamp( + +imageQualityInput.prop('value'), + +imageQualityInput.prop('min'), + +imageQualityInput.prop('max') + ); -function setupTaskUpdater() { - let updateModal = $("#dashboardUpdateModal"); - let oldLabels = $("#dashboardOldLabels"); - let newLabels = $("#dashboardNewLabels"); - let submitUpdate = $("#dashboardSubmitUpdate"); - let cancelUpdate = $("#dashboardCancelUpdate"); + imageQualityInput.prop('value', value); + compressQuality = value; + }); - updateModal[0].loadCurrentLabels = function() { - $.ajax({ - url: "/get/task/" + window.cvat.dashboard.taskID, - success: function(data) { - let labels = new LabelsInfo(data.spec); - oldLabels.attr("value", labels.normalize()); - }, - error: function(response) { - oldLabels.attr("value", "Bad request"); - let message = "Bad task request: " + response.responseText; - throw Error(message); + submitCreate.on('click', () => { + if (!validateName(name)) { + taskMessage.css('color', 'red'); + taskMessage.text('Bad task name'); + return; } - }); - }; - cancelUpdate.on("click", function() { - $("#dashboardNewLabels").prop("value", ""); - updateModal.addClass("hidden"); - }); + if (!validateLabels(labels)) { + taskMessage.css('color', 'red'); + taskMessage.text('Bad labels specification'); + return; + } - submitUpdate.on("click", () => updateTaskRequest(newLabels.prop("value"))); -} + if (!validateSegmentSize(segmentSize)) { + taskMessage.css('color', 'red'); + taskMessage.text('Segment size out of range'); + return; + } + if (!validateBugTracker(bugTrackerLink)) { + taskMessage.css('color', 'red'); + taskMessage.text('Bad bag tracker link'); + return; + } -function setupSearch() { - function getUrlParameter(name) { - let regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); - let results = regex.exec(window.location.search); - return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); + if (!validateOverlapSize(overlapSize, segmentSize)) { + taskMessage.css('color', 'red'); + taskMessage.text('Overlap size must be positive and not more then segment size'); + return; + } + + if (files.length <= 0) { + taskMessage.css('color', 'red'); + taskMessage.text('No files specified for the task'); + return; + } + else if (files.length > window.maxUploadCount && source === 'local') { + taskMessage.css('color', 'red'); + taskMessage.text('Too many files were specified. Please use share to upload'); + return; + } + else if (source === 'local') { + let commonSize = 0; + for (let file of files) { + commonSize += file.size; + } + if (commonSize > window.maxUploadSize) { + taskMessage.css('color', 'red'); + taskMessage.text('Too big files size. Please use share to upload'); + return; + } + } + + const description = { + name: name, + labels: LabelsInfo.deserialize(labels), + image_quality: compressQuality + } + + if (bugTrackerLink) { + description.bug_tracker = bugTrackerLink; + } + if (zOrder) { + description.z_order = zOrder; + } + if (customSegmentSize.prop('checked')) { + description.segment_size = segmentSize; + } + if (customOverlapSize.prop('checked')) { + description.overlap = overlapSize; + } + + function cleanupTask(tid) { + $.ajax({ + url: `/api/v1/tasks/${tid}`, + type: 'DELETE' + }); + } + + submitCreate.prop('disabled', true); + $.ajax({ + url: '/api/v1/tasks', + type: 'POST', + data: JSON.stringify(description), + contentType: 'application/json' + }).done((taskData) => { + taskMessage.css('color', 'green'); + taskMessage.text('Task has been created. Uploading the data..'); + + const batchOfFiles = new FormData(); + for (let j = 0; j < files.length; j++) { + if (source === "local") { + batchOfFiles.append(`client_files[${j}]`, files[j]); + } else { + batchOfFiles.append(`server_files[${j}]`, files[j]); + } + } + + $.ajax({ + url: `/api/v1/tasks/${taskData.id}/data`, + type: 'POST', + data: batchOfFiles, + contentType: false, + processData: false + }).done(() => { + taskMessage.text('The data has been sent. Task is being created..'); + + requestCreatingStatus(taskData.id, (status) => { + taskMessage.css('color', 'blue'); + taskMessage.text(status); + }, () => { + const decorators = DashboardView.decorators('createTask'); + let idx = 0; + + function next() { + const decorator = decorators[idx++]; + if (decorator) { + decorator(taskData, next, () => { + submitCreate.prop('disabled', false); + cleanupTask(tid); + }); + } else { + window.location.reload(); + } + } + + next(); + }, (errorMessage) => { + submitCreate.prop('disabled', false); + taskMessage.css('color', 'red'); + taskMessage.text(errorMessage); + cleanupTask(taskData.id); + }); + }).fail((errorData) => { + const message = `Can not put the data for the task. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + taskMessage.css('color', 'red'); + taskMessage.text(message); + submitCreate.prop('disabled', false); + cleanupTask(taskData.id); + }); + }).fail((errorData) => { + const message = `Task has not been created. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + taskMessage.css('color', 'red'); + taskMessage.text(message); + submitCreate.prop('disabled', false); + cleanupTask(taskData.id); + }); + }); + + cancelCreate.on('click', () => createModal.addClass('hidden')); } +} - let searchInput = $("#dashboardSearchInput"); - let searchSubmit = $("#dashboardSearchSubmit"); +DashboardView.decorators = (action) => { + DashboardView._decorators = DashboardView._decorators || {}; + return DashboardView._decorators[action] || []; +} - let line = getUrlParameter("search") || ""; - searchInput.val(line); +DashboardView.registerDecorator = (action, decorator) => { + DashboardView._decorators = DashboardView._decorators || {}; + DashboardView._decorators[action] = DashboardView._decorators[action] || []; + DashboardView._decorators[action].push(decorator); +} - searchSubmit.on("click", function() { - let e = $.Event("keypress"); - e.keyCode = 13; - searchInput.trigger(e); - }); - searchInput.on("keypress", function(e) { - if (e.keyCode != 13) return; - let filter = e.target.value; - if (!filter) window.location.search = ""; - else window.location.search = `search=${filter}`; +// DASHBOARD ENTRYPOINT +window.addEventListener('DOMContentLoaded', () => { + $.when( + // TODO: Use REST API in order to get meta + $.get('/dashboard/meta'), + $.get(`/api/v1/tasks${window.location.search}`), + ).then((metaData, taskData) => { + try { + new DashboardView(metaData[0], taskData[0]); + } + catch(exception) { + $('#content').empty(); + const message = `Can not build CVAT dashboard. Exception: ${exception}.`; + showMessage(message); + } + }).fail((errorData) => { + $('#content').empty(); + const message = `Can not build CVAT dashboard. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + }).always(() => { + $('#loadingOverlay').remove(); }); -} +}); diff --git a/cvat/apps/dashboard/static/dashboard/js/enginePlugin.js b/cvat/apps/dashboard/static/dashboard/js/enginePlugin.js index 4c95fa66bff7..a3bdc16e9f9a 100644 --- a/cvat/apps/dashboard/static/dashboard/js/enginePlugin.js +++ b/cvat/apps/dashboard/static/dashboard/js/enginePlugin.js @@ -4,12 +4,9 @@ * SPDX-License-Identifier: MIT */ -"use strict"; - window.addEventListener('DOMContentLoaded', () => { - $(``).on('click', () => { - let win = window.open(`${window.location.origin }/dashboard/?jid=${window.cvat.job.id}`, '_blank'); + $('').on('click', () => { + const win = window.open(`${window.location.origin}/dashboard/?id=${window.cvat.job.task_id}`, '_blank'); win.focus(); }).prependTo('#engineMenuButtons'); }); - diff --git a/cvat/apps/dashboard/static/dashboard/stylesheet.css b/cvat/apps/dashboard/static/dashboard/stylesheet.css index 4ae41b89e911..bd5bcc8eba0f 100644 --- a/cvat/apps/dashboard/static/dashboard/stylesheet.css +++ b/cvat/apps/dashboard/static/dashboard/stylesheet.css @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -.dashboardTaskUI { +.dashboardItem { margin: 5px auto; width: 1200px; height: 335px; diff --git a/cvat/apps/dashboard/templates/dashboard/dashboard.html b/cvat/apps/dashboard/templates/dashboard/dashboard.html index 18ddd0882f93..e75790d30359 100644 --- a/cvat/apps/dashboard/templates/dashboard/dashboard.html +++ b/cvat/apps/dashboard/templates/dashboard/dashboard.html @@ -3,6 +3,7 @@ SPDX-License-Identifier: MIT --> + {% extends 'engine/base.html' %} {% load static %} {% load pagination_tags %} @@ -14,7 +15,8 @@ {% block head_css %} {{ block.super }} - + + {% for css_file in css_3rdparty %} {% endfor %} @@ -22,7 +24,8 @@ {% block head_js_3rdparty %} {{ block.super }} - + + {% for js_file in js_3rdparty %} {% endfor %} @@ -36,17 +39,13 @@ - {% endblock %} {% block content %}
        -
        +
        @@ -58,13 +57,9 @@
        - {% autopaginate data %} -
        - {% for item in data %} - {% include "dashboard/task.html" %} - {% endfor %} +
        +
        -
        {% paginate %}
        - - - `)); + for (const key in shortkeys) { + if (Object.prototype.hasOwnProperty.call(shortkeys, key)) { + helpTable.append($(``)); + } } } function setupSettingsWindow() { - let closeSettingsButton = $('#closeSettignsButton'); - let autoSaveBox = $('#autoSaveBox'); - let autoSaveTime = $('#autoSaveTime'); + const closeSettingsButton = $('#closeSettignsButton'); - closeSettingsButton.on('click', function() { + closeSettingsButton.on('click', () => { $('#settingsWindow').addClass('hidden'); }); - - let saveInterval = null; - autoSaveBox.on('change', function(e) { - if (saveInterval) { - clearInterval(saveInterval); - saveInterval = null; - } - - if (e.target.checked) { - let time = +autoSaveTime.prop('value'); - saveInterval = setInterval(() => { - let saveButton = $('#saveButton'); - if (!saveButton.prop('disabled')) { - saveButton.click(); - } - }, time * 1000 * 60); - } - - autoSaveTime.on('change', () => { - let value = Math.clamp(+e.target.value, +e.target.min, +e.target.max); - e.target.value = value; - autoSaveBox.trigger('change'); - }); - }); } -function setupMenu(job, shapeCollectionModel, annotationParser, aamModel, playerModel, historyModel) { - let annotationMenu = $('#annotationMenu'); - let menuButton = $('#menuButton'); +function setupMenu(job, task, shapeCollectionModel, + annotationParser, aamModel, playerModel, historyModel) { + const annotationMenu = $('#annotationMenu'); + const menuButton = $('#menuButton'); function hide() { annotationMenu.addClass('hidden'); } - (function setupVisibility() { + function setupVisibility() { let timer = null; menuButton.on('click', () => { - let [byLabelsStat, totalStat] = shapeCollectionModel.collectStatistic(); - let table = $('#annotationStatisticTable'); + const [byLabelsStat, totalStat] = shapeCollectionModel.collectStatistic(); + const table = $('#annotationStatisticTable'); table.find('.temporaryStatisticRow').remove(); - for (let labelId in byLabelsStat) { - $(` + for (const labelId in byLabelsStat) { + if (Object.prototype.hasOwnProperty.call(byLabelsStat, labelId)) { + $(` @@ -523,6 +318,7 @@ function setupMenu(job, shapeCollectionModel, annotationParser, aamModel, player `).addClass('temporaryStatisticRow').appendTo(table); + } } $(` @@ -543,7 +339,7 @@ function setupMenu(job, shapeCollectionModel, annotationParser, aamModel, player menuButton.on('click', () => { annotationMenu.removeClass('hidden'); - annotationMenu.css('top', menuButton.offset().top - annotationMenu.height() - menuButton.height() + 'px'); + annotationMenu.css('top', `${menuButton.offset().top - annotationMenu.height() - menuButton.height()}px`); if (timer) { clearTimeout(timer); timer = null; @@ -561,50 +357,65 @@ function setupMenu(job, shapeCollectionModel, annotationParser, aamModel, player timer = setTimeout(hide, 500); }); - annotationMenu.on('mouseover', function() { + annotationMenu.on('mouseover', () => { if (timer) { clearTimeout(timer); timer = null; } }); - })(); - - $('#statTaskName').text(job.slug); - $('#statFrames').text(`[${job.start}-${job.stop}]`); - $('#statOverlap').text(job.overlap); - $('#statZOrder').text(job.z_order); - $('#statFlipped').text(job.flipped); - $('#statTaskStatus').prop("value", job.status).on('change', (e) => { - $.ajax({ - type: 'POST', - url: 'save/status/job/' + window.cvat.job.id, - data: JSON.stringify({ - status: e.target.value - }), - contentType: "application/json; charset=utf-8", - error: (data) => { - showMessage(`Can not change job status. Code: ${data.status}. Message: ${data.responeText || data.statusText}`); - } - }); + } + + setupVisibility(); + + $('#statTaskName').text(task.name); + $('#statFrames').text(`[${window.cvat.player.frames.start}-${window.cvat.player.frames.stop}]`); + $('#statOverlap').text(task.overlap); + $('#statZOrder').text(task.z_order); + $('#statFlipped').text(task.flipped); + $('#statTaskStatus').prop('value', job.status).on('change', async (e) => { + try { + const jobCopy = JSON.parse(JSON.stringify(job)); + jobCopy.status = e.target.value; + + await $.ajax({ + url: `/api/v1/jobs/${window.cvat.job.id}`, + type: 'PATCH', + data: JSON.stringify(jobCopy), + contentType: 'application/json', + }); + } catch (errorData) { + const message = `Can not update a job status. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + } }); - let shortkeys = window.cvat.config.shortkeys; + const { shortkeys } = window.cvat.config; $('#helpButton').on('click', () => { hide(); $('#helpWindow').removeClass('hidden'); }); + $('#helpButton').attr('title', ` - ${shortkeys['open_help'].view_value} - ${shortkeys['open_help'].description}`); + ${shortkeys.open_help.view_value} - ${shortkeys.open_help.description}`); $('#settingsButton').on('click', () => { hide(); $('#settingsWindow').removeClass('hidden'); }); - $('#settingsButton').attr('title', ` - ${shortkeys['open_settings'].view_value} - ${shortkeys['open_settings'].description}`); - $('#downloadAnnotationButton').on('click', (e) => { - dumpAnnotationRequest(e.target, job.taskid, job.slug); + $('#settingsButton').attr('title', ` + ${shortkeys.open_settings.view_value} - ${shortkeys.open_settings.description}`); + + $('#downloadAnnotationButton').on('click', async (e) => { + e.target.disabled = true; + try { + await dumpAnnotationRequest(task.id, task.name); + } catch (error) { + showMessage(error.message); + } finally { + e.target.disabled = false; + } }); $('#uploadAnnotationButton').on('click', () => { @@ -612,8 +423,7 @@ function setupMenu(job, shapeCollectionModel, annotationParser, aamModel, player userConfirm('Current annotation will be removed from the client. Continue?', () => { uploadAnnotation(shapeCollectionModel, historyModel, annotationParser, $('#uploadAnnotationButton')); - } - ); + }); }); $('#removeAnnotationButton').on('click', () => { @@ -623,17 +433,10 @@ function setupMenu(job, shapeCollectionModel, annotationParser, aamModel, player () => { historyModel.empty(); shapeCollectionModel.empty(); - } - ); + }); } }); - $('#saveButton').on('click', () => { - saveAnnotation(shapeCollectionModel, job); - }); - $('#saveButton').attr('title', ` - ${shortkeys['save_work'].view_value} - ${shortkeys['save_work'].description}`); - // JS function cancelFullScreen don't work after pressing // and it is famous problem. $('#fullScreenButton').on('click', () => { @@ -654,135 +457,268 @@ function setupMenu(job, shapeCollectionModel, annotationParser, aamModel, player }); $('#switchAAMButton').attr('title', ` - ${shortkeys['switch_aam_mode'].view_value} - ${shortkeys['switch_aam_mode'].description}`); + ${shortkeys.switch_aam_mode.view_value} - ${shortkeys.switch_aam_mode.description}`); } -function drawBoxSize(boxScene, textScene, box) { - let clientBox = window.cvat.translate.box.canvasToClient(boxScene.node, box); - let text = `${box.width.toFixed(1)}x${box.height.toFixed(1)}`; - let obj = this && this.textUI && this.rm ? this : { - textUI: textScene.text('').font({ - weight: 'bolder' - }).fill('white'), +function buildAnnotationUI(jobData, taskData, imageMetaData, annotationData, loadJobEvent) { + // Setup some API + window.cvat = { + labelsInfo: new LabelsInfo(taskData.labels), + translate: new CoordinateTranslator(), + player: { + geometry: { + scale: 1, + }, + frames: { + current: jobData.start_frame, + start: jobData.start_frame, + stop: jobData.stop_frame, + }, + }, + mode: null, + job: { + z_order: taskData.z_order, + id: jobData.id, + task_id: taskData.id, + images: imageMetaData, + }, + search: { + value: window.location.search, - rm: function() { - if (this.textUI) { - this.textUI.remove(); - } - } + set(name, value) { + const searchParams = new URLSearchParams(this.value); + + if (typeof value === 'undefined' || value === null) { + if (searchParams.has(name)) { + searchParams.delete(name); + } + } else { + searchParams.set(name, value); + } + this.value = `${searchParams.toString()}`; + }, + + get(name) { + try { + const decodedURI = decodeURIComponent(this.value); + const urlSearchParams = new URLSearchParams(decodedURI); + if (urlSearchParams.has(name)) { + return urlSearchParams.get(name); + } + return null; + } catch (error) { + showMessage('Bad URL has been received'); + this.value = window.location.href; + return null; + } + }, + + toString() { + return `${window.location.origin}/?${this.value}`; + }, + }, }; - let textPoint = window.cvat.translate.point.clientToCanvas(textScene.node, clientBox.x, clientBox.y); + // Remove external search parameters from url + window.history.replaceState(null, null, `${window.location.origin}/?id=${jobData.id}`); - obj.textUI.clear().plain(text); - obj.textUI.addClass("shapeText"); - obj.textUI.move(textPoint.x, textPoint.y); + window.cvat.config = new Config(); - return obj; -} + // Setup components + const annotationParser = new AnnotationParser({ + start: window.cvat.player.frames.start, + stop: window.cvat.player.frames.stop, + flipped: taskData.flipped, + image_meta_data: imageMetaData, + }, window.cvat.labelsInfo); + const shapeCollectionModel = new ShapeCollectionModel().import(annotationData); + const shapeCollectionController = new ShapeCollectionController(shapeCollectionModel); + const shapeCollectionView = new ShapeCollectionView(shapeCollectionModel, + shapeCollectionController); -function uploadAnnotation(shapeCollectionModel, historyModel, annotationParser, uploadAnnotationButton) { - $('#annotationFileSelector').one('change', (e) => { - let file = e.target.files['0']; - e.target.value = ""; - if (!file || file.type != 'text/xml') return; - uploadAnnotationButton.text('Preparing..'); - uploadAnnotationButton.prop('disabled', true); - let overlay = showOverlay("File is being uploaded.."); + buildAnnotationSaver(annotationData, shapeCollectionModel); - let fileReader = new FileReader(); - fileReader.onload = function(e) { - let data = null; + window.cvat.data = { + get: () => shapeCollectionModel.export()[0], + set: (data) => { + shapeCollectionModel.import(data); + shapeCollectionModel.update(); + }, + clear: () => shapeCollectionModel.empty(), + }; - let asyncParse = function() { - try { - data = annotationParser.parse(e.target.result); - } - catch (err) { - overlay.remove(); - showMessage(err.message); - return; - } - finally { - uploadAnnotationButton.text('Upload Annotation'); - uploadAnnotationButton.prop('disabled', false); - } + const shapeBufferModel = new ShapeBufferModel(shapeCollectionModel); + const shapeBufferController = new ShapeBufferController(shapeBufferModel); + const shapeBufferView = new ShapeBufferView(shapeBufferModel, shapeBufferController); - let asyncImport = function() { - try { - historyModel.empty(); - shapeCollectionModel.empty(); - shapeCollectionModel.import(data, false); - shapeCollectionModel.update(); - } - finally { - overlay.remove(); - } - }; + $('#shapeModeSelector').prop('value', taskData.mode); + const shapeCreatorModel = new ShapeCreatorModel(shapeCollectionModel); + const shapeCreatorController = new ShapeCreatorController(shapeCreatorModel); + const shapeCreatorView = new ShapeCreatorView(shapeCreatorModel, shapeCreatorController); - overlay.setMessage('Data are being imported..'); - setTimeout(asyncImport); - }; + const polyshapeEditorModel = new PolyshapeEditorModel(); + const polyshapeEditorController = new PolyshapeEditorController(polyshapeEditorModel); + const polyshapeEditorView = new PolyshapeEditorView(polyshapeEditorModel, + polyshapeEditorController); - overlay.setMessage('File is being parsed..'); - setTimeout(asyncParse); - }; - fileReader.readAsText(file); - }).click(); -} + // Add static member for class. It will be used by all polyshapes. + PolyShapeView.editor = polyshapeEditorModel; + const shapeMergerModel = new ShapeMergerModel(shapeCollectionModel); + const shapeMergerController = new ShapeMergerController(shapeMergerModel); + new ShapeMergerView(shapeMergerModel, shapeMergerController); + + const shapeGrouperModel = new ShapeGrouperModel(shapeCollectionModel); + const shapeGrouperController = new ShapeGrouperController(shapeGrouperModel); + const shapeGrouperView = new ShapeGrouperView(shapeGrouperModel, shapeGrouperController); -function saveAnnotation(shapeCollectionModel, job) { - let saveButton = $('#saveButton'); + const playerGeometry = { + width: $('#playerFrame').width(), + height: $('#playerFrame').height(), + }; - Logger.addEvent(Logger.EventType.saveJob); - let totalStat = shapeCollectionModel.collectStatistic()[1]; - Logger.addEvent(Logger.EventType.sendTaskInfo, { - 'track count': totalStat.boxes.annotation + totalStat.boxes.interpolation + - totalStat.polygons.annotation + totalStat.polygons.interpolation + - totalStat.polylines.annotation + totalStat.polylines.interpolation + - totalStat.points.annotation + totalStat.points.interpolation, - 'frame count': job.stop - job.start + 1, + const playerModel = new PlayerModel(taskData, playerGeometry); + const playerController = new PlayerController(playerModel, + () => shapeCollectionModel.activeShape, + direction => shapeCollectionModel.find(direction), + Object.assign({}, playerGeometry, { + left: $('#playerFrame').offset().left, + top: $('#playerFrame').offset().top, + })); + new PlayerView(playerModel, playerController); + + + const aamModel = new AAMModel(shapeCollectionModel, (xtl, xbr, ytl, ybr) => { + playerModel.focus(xtl, xbr, ytl, ybr); + }, () => { + playerModel.fit(); + }); + const aamController = new AAMController(aamModel); + new AAMView(aamModel, aamController); + + shapeCreatorModel.subscribe(shapeCollectionModel); + shapeGrouperModel.subscribe(shapeCollectionView); + shapeCollectionModel.subscribe(shapeGrouperModel); + + $('#playerProgress').css('width', $('#player')['0'].clientWidth - 420); + + const historyModel = new HistoryModel(playerModel); + const historyController = new HistoryController(historyModel); + new HistoryView(historyController, historyModel); + + playerModel.subscribe(shapeCollectionModel); + playerModel.subscribe(shapeCollectionView); + playerModel.subscribe(shapeCreatorView); + playerModel.subscribe(shapeBufferView); + playerModel.subscribe(shapeGrouperView); + playerModel.subscribe(polyshapeEditorView); + playerModel.shift(window.cvat.search.get('frame') || 0, true); + + const { shortkeys } = window.cvat.config; + + setupHelpWindow(shortkeys); + setupSettingsWindow(); + setupMenu(jobData, taskData, shapeCollectionModel, + annotationParser, aamModel, playerModel, historyModel); + setupFrameFilters(); + setupShortkeys(shortkeys, { + aam: aamModel, + shapeCreator: shapeCreatorModel, + shapeMerger: shapeMergerModel, + shapeGrouper: shapeGrouperModel, + shapeBuffer: shapeBufferModel, + shapeEditor: polyshapeEditorModel, + }); + + $(window).on('click', (event) => { + Logger.updateUserActivityTimer(); + if (event.target.classList.contains('modal') && !event.target.classList.contains('force-modal')) { + event.target.classList.add('hidden'); + } + }); + + const totalStat = shapeCollectionModel.collectStatistic()[1]; + loadJobEvent.addValues({ + 'track count': totalStat.boxes.annotation + totalStat.boxes.interpolation + + totalStat.polygons.annotation + totalStat.polygons.interpolation + + totalStat.polylines.annotation + totalStat.polylines.interpolation + + totalStat.points.annotation + totalStat.points.interpolation, + 'frame count': window.cvat.player.frames.stop - window.cvat.player.frames.start + 1, 'object count': totalStat.total, 'box count': totalStat.boxes.annotation + totalStat.boxes.interpolation, 'polygon count': totalStat.polygons.annotation + totalStat.polygons.interpolation, 'polyline count': totalStat.polylines.annotation + totalStat.polylines.interpolation, 'points count': totalStat.points.annotation + totalStat.points.interpolation, }); + loadJobEvent.close(); + + $('#player').on('click', (e) => { + if (e.target.tagName.toLowerCase() !== 'input') { + blurAllElements(); + } + }); +} - const exportedData = shapeCollectionModel.export(); - shapeCollectionModel.updateExportedState(); - const annotationLogs = Logger.getLogs(); - const data = { - annotation: JSON.stringify(exportedData), - logs: JSON.stringify(annotationLogs.export()), - }; +function callAnnotationUI(jid) { + function onError(errorData) { + $('body').empty(); + const message = `Can not build CVAT annotation UI. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + } - saveButton.prop('disabled', true); - saveButton.text('Saving..'); - - saveJobRequest(job.jobid, data, () => { - // success - shapeCollectionModel.confirmExportedState(); - saveButton.text('Success!'); - setTimeout(() => { - saveButton.prop('disabled', false); - saveButton.text('Save Work'); - }, 3000); - }, (response) => { - // error - saveButton.prop('disabled', false); - saveButton.text('Save Work'); - let message = `Impossible to save job. Errors was occured. Status: ${response.status}`; - showMessage(message + ' ' + 'Please immediately report the problem to support team'); - throw Error(message); - }); + initLogger(jid); + + const loadJobEvent = Logger.addContinuedEvent(Logger.EventType.loadJob); + $.get(`/api/v1/jobs/${jid}`).done((jobData) => { + $.when( + $.get(`/api/v1/tasks/${jobData.task_id}`), + $.get(`/api/v1/tasks/${jobData.task_id}/frames/meta`), + $.get(`/api/v1/jobs/${jid}/annotations`), + ).then((taskData, imageMetaData, annotationData) => { + $('#loadingOverlay').remove(); + setTimeout(() => { + buildAnnotationUI(jobData, taskData[0], + imageMetaData[0], annotationData[0], loadJobEvent); + }); + }).fail(onError); + }).fail(onError); } -function blurAllElements() { - document.activeElement.blur(); +function copyToClipboard(text) { + const tempInput = $(''); + $('body').append(tempInput); + tempInput.prop('value', text).select(); + document.execCommand('copy'); + tempInput.remove(); +} + + +function drawBoxSize(boxScene, textScene, box) { + const clientBox = window.cvat.translate.box.canvasToClient(boxScene.node, box); + const text = `${box.width.toFixed(1)}x${box.height.toFixed(1)}`; + const obj = this && this.textUI && this.rm ? this : { + textUI: textScene.text('').font({ + weight: 'bolder', + }).fill('white'), + + rm() { + if (this.textUI) { + this.textUI.remove(); + } + }, + }; + + const textPoint = window.cvat.translate.point.clientToCanvas(textScene.node, + clientBox.x, clientBox.y); + + obj.textUI.clear().plain(text); + obj.textUI.addClass('shapeText'); + obj.textUI.move(textPoint.x, textPoint.y); + + return obj; } diff --git a/cvat/apps/engine/static/engine/js/attributeAnnotationMode.js b/cvat/apps/engine/static/engine/js/attributeAnnotationMode.js index f091bb01a72b..ece1d78b9c66 100644 --- a/cvat/apps/engine/static/engine/js/attributeAnnotationMode.js +++ b/cvat/apps/engine/static/engine/js/attributeAnnotationMode.js @@ -14,8 +14,6 @@ SVG:false */ -"use strict"; - const AAMUndefinedKeyword = '__undefined__'; class AAMModel extends Listener { @@ -31,40 +29,27 @@ class AAMModel extends Listener { this._currentShapes = []; this._attrNumberByLabel = {}; this._helps = {}; - for (let labelId in window.cvat.labelsInfo.labels()) { - let labelAttributes = window.cvat.labelsInfo.labelAttributes(labelId); - if (Object.keys(labelAttributes).length) { - this._attrNumberByLabel[labelId] = { - current: 0, - end: Object.keys(labelAttributes).length - }; - - for (let attrId in labelAttributes) { - this._helps[attrId] = { - title: `${window.cvat.labelsInfo.labels()[labelId]}, ${window.cvat.labelsInfo.attributes()[attrId]}`, - help: getHelp(attrId), - }; - } - } - } function getHelp(attrId) { - let attrInfo = window.cvat.labelsInfo.attrInfo(attrId); - let help = []; + const attrInfo = window.cvat.labelsInfo.attrInfo(attrId); + const help = []; switch (attrInfo.type) { case 'checkbox': - help.push('0 - ' + attrInfo.values[0]); - help.push('1 - ' + !attrInfo.values[0]); + help.push(`0 - ${attrInfo.values[0]}`); + help.push(`1 - ${!attrInfo.values[0]}`); break; default: - for (let idx = 0; idx < attrInfo.values.length; idx ++) { - if (idx > 9) break; - if (attrInfo.values[0] === AAMUndefinedKeyword) { - if (!idx) continue; - help.push(idx - 1 + ' - ' + attrInfo.values[idx]); + for (let idx = 0; idx < attrInfo.values.length; idx += 1) { + if (idx > 9) { + break; } - else { - help.push(idx + ' - ' + attrInfo.values[idx]); + if (attrInfo.values[0] === AAMUndefinedKeyword) { + if (!idx) { + continue; + } + help.push(`${idx - 1} - ${attrInfo.values[idx]}`); + } else { + help.push(`${idx} - ${attrInfo.values[idx]}`); } } } @@ -72,35 +57,56 @@ class AAMModel extends Listener { return help; } + const labels = window.cvat.labelsInfo.labels(); + for (const labelId in labels) { + if (Object.prototype.hasOwnProperty.call(labels, labelId)) { + const labelAttributes = window.cvat.labelsInfo.labelAttributes(labelId); + if (Object.keys(labelAttributes).length) { + this._attrNumberByLabel[labelId] = { + current: 0, + end: Object.keys(labelAttributes).length, + }; + + for (const attrId in labelAttributes) { + if (Object.prototype.hasOwnProperty.call(labelAttributes, attrId)) { + this._helps[attrId] = { + title: `${window.cvat.labelsInfo.labels()[labelId]}, ${window.cvat.labelsInfo.attributes()[attrId]}`, + help: getHelp(attrId), + }; + } + } + } + } + } + shapeCollection.subscribe(this); } _bbRect(pos) { if ('points' in pos) { - let points = PolyShapeModel.convertStringToNumberArray(pos.points); + const points = PolyShapeModel.convertStringToNumberArray(pos.points); let xtl = Number.MAX_SAFE_INTEGER; let ytl = Number.MAX_SAFE_INTEGER; let xbr = Number.MIN_SAFE_INTEGER; let ybr = Number.MIN_SAFE_INTEGER; - for (let point of points) { + for (const point of points) { xtl = Math.min(xtl, point.x); ytl = Math.min(ytl, point.y); xbr = Math.max(xbr, point.x); ybr = Math.max(ybr, point.y); } - return [xtl, ytl, xbr, ybr]; - } - else { - return [pos.xtl, pos.ytl, pos.xbr, pos.ybr]; + return [xtl, ytl, xbr, ybr]; } + return [pos.xtl, pos.ytl, pos.xbr, pos.ybr]; } _updateCollection() { this._currentShapes = []; - for (let shape of this._shapeCollection.currentShapes) { - let labelAttributes = window.cvat.labelsInfo.labelAttributes(shape.model.label); - if (Object.keys(labelAttributes).length && !shape.model.removed && !shape.interpolation.position.outside) { + for (const shape of this._shapeCollection.currentShapes) { + const labelAttributes = window.cvat.labelsInfo.labelAttributes(shape.model.label); + if (Object.keys(labelAttributes).length + && !shape.model.removed && !shape.interpolation.position.outside) { this._currentShapes.push({ model: shape.model, interpolation: shape.model.interpolate(window.cvat.player.frames.current), @@ -111,8 +117,7 @@ class AAMModel extends Listener { if (this._currentShapes.length) { this._activeIdx = 0; this._active = this._currentShapes[0].model; - } - else { + } else { this._activeIdx = null; this._active = null; } @@ -124,15 +129,16 @@ class AAMModel extends Listener { _activate() { if (this._activeAAM && this._active) { - let label = this._active.label; - let attrId = +this._attrIdByIdx(label, this._attrNumberByLabel[label].current); + const { label } = this._active; + const attrId = +this._attrIdByIdx(label, this._attrNumberByLabel[label].current); - let [xtl, ytl, xbr, ybr] = this._bbRect(this._currentShapes[this._activeIdx].interpolation.position); - this._focus(xtl - this._margin, xbr + this._margin, ytl - this._margin, ybr + this._margin); + const [xtl, ytl, xbr, ybr] = this._bbRect(this._currentShapes[this._activeIdx] + .interpolation.position); + this._focus(xtl - this._margin, xbr + this._margin, + ytl - this._margin, ybr + this._margin); this.notify(); this._active.activeAttribute = attrId; - } - else { + } else { this.notify(); } } @@ -170,8 +176,7 @@ class AAMModel extends Listener { switchAAMMode() { if (this._activeAAM) { this._disable(); - } - else { + } else { this._enable(); } } @@ -184,14 +189,13 @@ class AAMModel extends Listener { this._deactivate(); if (Math.sign(direction) < 0) { // next - this._activeIdx ++; + this._activeIdx += 1; if (this._activeIdx >= this._currentShapes.length) { this._activeIdx = 0; } - } - else { + } else { // prev - this._activeIdx --; + this._activeIdx -= 1; if (this._activeIdx < 0) { this._activeIdx = this._currentShapes.length - 1; } @@ -206,7 +210,7 @@ class AAMModel extends Listener { return; } - let curAttr = this._attrNumberByLabel[this._active.label]; + const curAttr = this._attrNumberByLabel[this._active.label]; if (curAttr.end < 2) { return; @@ -214,14 +218,13 @@ class AAMModel extends Listener { if (Math.sign(direction) > 0) { // next - curAttr.current ++; + curAttr.current += 1; if (curAttr.current >= curAttr.end) { curAttr.current = 0; } - } - else { + } else { // prev - curAttr.current --; + curAttr.current -= 1; if (curAttr.current < 0) { curAttr.current = curAttr.end - 1; } @@ -233,10 +236,10 @@ class AAMModel extends Listener { if (!this._activeAAM || !this._active) { return; } - let label = this._active.label; - let frame = window.cvat.player.frames.current; - let attrId = this._attrIdByIdx(label, this._attrNumberByLabel[label].current); - let attrInfo = window.cvat.labelsInfo.attrInfo(attrId); + const { label } = this._active; + const frame = window.cvat.player.frames.current; + const attrId = this._attrIdByIdx(label, this._attrNumberByLabel[label].current); + const attrInfo = window.cvat.labelsInfo.attrInfo(attrId); if (key >= attrInfo.values.length) { if (attrInfo.type === 'checkbox' && key < 2) { this._active.updateAttribute(frame, attrId, !attrInfo.values[0]); @@ -247,7 +250,7 @@ class AAMModel extends Listener { if (key >= attrInfo.values.length - 1) { return; } - key ++; + key += 1; } this._active.updateAttribute(frame, attrId, attrInfo.values[key]); } @@ -262,13 +265,11 @@ class AAMModel extends Listener { generateHelps() { if (this._active) { - let label = this._active.label; - let attrId = +this._attrIdByIdx(label, this._attrNumberByLabel[label].current); + const { label } = this._active; + const attrId = +this._attrIdByIdx(label, this._attrNumberByLabel[label].current); return [this._helps[attrId].title, this._helps[attrId].help, `${this._activeIdx + 1}/${this._currentShapes.length}`]; } - else { - return ['No Shapes Found', '', '0/0']; - } + return ['No Shapes Found', '', '0/0']; } get activeAAM() { @@ -285,60 +286,57 @@ class AAMModel extends Listener { } - class AAMController { constructor(aamModel) { this._model = aamModel; - setupAAMShortkeys.call(this); - function setupAAMShortkeys() { - let switchAAMHandler = Logger.shortkeyLogDecorator(function() { + const switchAAMHandler = Logger.shortkeyLogDecorator(() => { this._model.switchAAMMode(); - }.bind(this)); + }); - let nextAttributeHandler = Logger.shortkeyLogDecorator(function(e) { + const nextAttributeHandler = Logger.shortkeyLogDecorator((e) => { this._model.moveAttr(1); e.preventDefault(); - }.bind(this)); + }); - let prevAttributeHandler = Logger.shortkeyLogDecorator(function(e) { + const prevAttributeHandler = Logger.shortkeyLogDecorator((e) => { this._model.moveAttr(-1); e.preventDefault(); - }.bind(this)); + }); - let nextShapeHandler = Logger.shortkeyLogDecorator(function(e) { + const nextShapeHandler = Logger.shortkeyLogDecorator((e) => { this._model.moveShape(1); e.preventDefault(); - }.bind(this)); + }); - let prevShapeHandler = Logger.shortkeyLogDecorator(function(e) { + const prevShapeHandler = Logger.shortkeyLogDecorator((e) => { this._model.moveShape(-1); e.preventDefault(); - }.bind(this)); + }); - let selectAttributeHandler = Logger.shortkeyLogDecorator(function(e) { + const selectAttributeHandler = Logger.shortkeyLogDecorator((e) => { let key = e.keyCode; if (key >= 48 && key <= 57) { - key -= 48; // 0 and 9 - } - else if (key >= 96 && key <= 105) { + key -= 48; // 0 and 9 + } else if (key >= 96 && key <= 105) { key -= 96; // num 0 and 9 - } - else { + } else { return; } this._model.setupAttributeValue(key); - }.bind(this)); - - let shortkeys = window.cvat.config.shortkeys; - Mousetrap.bind(shortkeys["switch_aam_mode"].value, switchAAMHandler, 'keydown'); - Mousetrap.bind(shortkeys["aam_next_attribute"].value, nextAttributeHandler, 'keydown'); - Mousetrap.bind(shortkeys["aam_prev_attribute"].value, prevAttributeHandler, 'keydown'); - Mousetrap.bind(shortkeys["aam_next_shape"].value, nextShapeHandler, 'keydown'); - Mousetrap.bind(shortkeys["aam_prev_shape"].value, prevShapeHandler, 'keydown'); - Mousetrap.bind(shortkeys["select_i_attribute"].value, selectAttributeHandler, 'keydown'); + }); + + const { shortkeys } = window.cvat.config; + Mousetrap.bind(shortkeys.switch_aam_mode.value, switchAAMHandler, 'keydown'); + Mousetrap.bind(shortkeys.aam_next_attribute.value, nextAttributeHandler, 'keydown'); + Mousetrap.bind(shortkeys.aam_prev_attribute.value, prevAttributeHandler, 'keydown'); + Mousetrap.bind(shortkeys.aam_next_shape.value, nextShapeHandler, 'keydown'); + Mousetrap.bind(shortkeys.aam_prev_shape.value, prevShapeHandler, 'keydown'); + Mousetrap.bind(shortkeys.select_i_attribute.value, selectAttributeHandler, 'keydown'); } + + setupAAMShortkeys.call(this); } setMargin(value) { @@ -359,15 +357,15 @@ class AAMView { this._controller = aamController; this._zoomMargin.on('change', (e) => { - let value = +e.target.value; + const value = +e.target.value; this._controller.setMargin(value); }).trigger('change'); aamModel.subscribe(this); } _setupAAMView(active, type, pos) { - let oldRect = $('#outsideRect'); - let oldMask = $('#outsideMask'); + const oldRect = $('#outsideRect'); + const oldMask = $('#outsideMask'); if (active) { if (oldRect.length) { @@ -375,45 +373,47 @@ class AAMView { oldMask.remove(); } - let size = window.cvat.translate.box.actualToCanvas({ + const size = window.cvat.translate.box.actualToCanvas({ x: 0, y: 0, width: window.cvat.player.geometry.frameWidth, - height: window.cvat.player.geometry.frameHeight + height: window.cvat.player.geometry.frameHeight, }); - let excludeField = this._frameContent.rect(size.width, size.height).move(size.x, size.y).fill('#666'); + const excludeField = this._frameContent.rect(size.width, size.height).move(size.x, size.y).fill('#666'); let includeField = null; if (type === 'box') { pos = window.cvat.translate.box.actualToCanvas(pos); - includeField = this._frameContent.rect(pos.xbr - pos.xtl, pos.ybr - pos.ytl).move(pos.xtl, pos.ytl); - } - else { + includeField = this._frameContent.rect(pos.xbr - pos.xtl, + pos.ybr - pos.ytl).move(pos.xtl, pos.ytl); + } else { pos.points = window.cvat.translate.points.actualToCanvas(pos.points); includeField = this._frameContent.polygon(pos.points); } - this._frameContent.mask().add(excludeField).add(includeField).fill('black').attr('id', 'outsideMask'); - this._frameContent.rect(size.width, size.height).move(size.x, size.y).attr({ - mask: 'url(#outsideMask)', - id: 'outsideRect' - }); + this._frameContent.mask().add(excludeField) + .add(includeField).fill('black') + .attr('id', 'outsideMask'); + this._frameContent.rect(size.width, size.height) + .move(size.x, size.y).attr({ + mask: 'url(#outsideMask)', + id: 'outsideRect', + }); - let content = $(this._frameContent.node); - let texts = content.find('.shapeText'); - for (let text of texts) { + const content = $(this._frameContent.node); + const texts = content.find('.shapeText'); + for (const text of texts) { content.append(text); } - } - else { + } else { oldRect.remove(); oldMask.remove(); } } onAAMUpdate(aam) { - this._setupAAMView(aam.active ? true : false, + this._setupAAMView(Boolean(aam.active), aam.active ? aam.active.type.split('_')[1] : '', aam.active ? aam.active.interpolate(window.cvat.player.frames.current).position : 0); @@ -423,20 +423,17 @@ class AAMView { this._aamMenu.removeClass('hidden'); } - let [title, help, counter] = aam.generateHelps(); + const [title, help, counter] = aam.generateHelps(); this._aamHelpContainer.empty(); this._aamCounter.text(counter); this._aamTitle.text(title); - for (let helpRow of help) { + for (const helpRow of help) { $(`
        ${link}
        - - - -
        @@ -180,7 +167,7 @@ -
        ${shortkeys[key].view_value} ${shortkeys[key].description}
        ${shortkeys[key].view_value} ${shortkeys[key].description}
        ${window.cvat.labelsInfo.labels()[labelId].normalize()} ${byLabelsStat[labelId].boxes.annotation} ${byLabelsStat[labelId].boxes.interpolation} ${byLabelsStat[labelId].interpolated} ${byLabelsStat[labelId].total}
        + + + + + + + + + +
        + + + +
        + + +
        + + +
        +
        + +
        +
        +
        + +
        +
        +
        `; + + $.get('/git/repository/meta/get').done((gitData) => { + const dashboardItems = $('.dashboardItem'); + dashboardItems.each(function setupDashboardItem() { + const tid = +this.getAttribute('tid'); + if (tid in gitData) { + if (['sync', 'syncing'].includes(gitData[tid])) { + this.style.background = 'floralwhite'; + } else if (gitData[tid] === 'merged') { + this.style.background = 'azure'; + } else { + this.style.background = 'mistyrose'; } - }); - }, - error: (data) => { - let message = `Can not get git repositories meta info. Code: ${data.status}. Message: ${data.responseText || data.statusText}`; - showMessage(message); - throw Error(message); - } - }); + $('').addClass('regular dashboardButtonUI').on('click', () => { + $(`#${reposWindowId}`).remove(); + const gitWindow = $(reposWindowTemplate).appendTo('body'); + const closeReposWindowButton = $(`#${closeReposWindowButtonId}`); + const reposSyncButton = $(`#${reposSyncButtonId}`); + const gitLabelMessage = $(`#${labelMessageId}`); + const gitLabelStatus = $(`#${labelStatusId}`); + const reposURLText = $(`#${reposURLTextId}`); -}); + function updateState() { + reposURLText.attr('placeholder', 'Waiting for server response..'); + reposURLText.prop('value', ''); + gitLabelMessage.css('color', '#cccc00').text('Waiting for server response..'); + gitLabelStatus.css('color', '#cccc00').text('\u25cc'); + reposSyncButton.attr('disabled', true); -window.cvat.git = { - reposWindowId: "gitReposWindow", - closeReposWindowButtonId: "closeGitReposButton", - reposURLTextId: "gitReposURLText", - reposSyncButtonId: "gitReposSyncButton", - labelStatusId: "gitReposLabelStatus", - labelMessageId: "gitReposLabelMessage", - createURLInputTextId: "gitCreateURLInputText", - lfsCheckboxId: "gitLFSCheckbox", - - updateState: () => { - let gitWindow = $(`#${window.cvat.git.reposWindowId}`); - let gitLabelMessage = $(`#${window.cvat.git.labelMessageId}`); - let gitLabelStatus = $(`#${window.cvat.git.labelStatusId}`); - let reposURLText = $(`#${window.cvat.git.reposURLTextId}`); - let syncButton = $(`#${window.cvat.git.reposSyncButtonId}`); - - reposURLText.attr("placeholder", "Waiting for server response.."); - reposURLText.prop("value", ""); - gitLabelMessage.css("color", "#cccc00").text("Waiting for server response.."); - gitLabelStatus.css("color", "#cccc00").text("\u25cc"); - syncButton.attr("disabled", true); - - let tid = gitWindow.attr("current_tid"); - - $.get(`/git/repository/get/${tid}`).done(function(data) { - if (!data.url.value) { - gitLabelMessage.css("color", "black").text("Repository is not attached"); - reposURLText.prop("value", ""); - reposURLText.attr("placeholder", "Repository is not attached"); - return; - } + $.get(`/git/repository/get/${tid}`).done((data) => { + reposURLText.attr('placeholder', ''); + reposURLText.prop('value', data.url.value); - reposURLText.attr("placeholder", ""); - reposURLText.prop("value", data.url.value); + if (!data.status.value) { + gitLabelStatus.css('color', 'red').text('\u26a0'); + gitLabelMessage.css('color', 'red').text(data.status.error); + reposSyncButton.attr('disabled', false); + return; + } - if (!data.status.value) { - gitLabelStatus.css("color", "red").text("\u26a0"); - gitLabelMessage.css("color", "red").text(data.status.error); - syncButton.attr("disabled", false); - return; - } + if (data.status.value === '!sync') { + gitLabelStatus.css('color', 'red').text('\u2606'); + gitLabelMessage.css('color', 'red').text('Repository is not synchronized'); + reposSyncButton.attr('disabled', false); + } else if (data.status.value === 'sync') { + gitLabelStatus.css('color', '#cccc00').text('\u2605'); + gitLabelMessage.css('color', 'black').text('Synchronized (merge required)'); + } else if (data.status.value === 'merged') { + gitLabelStatus.css('color', 'darkgreen').text('\u2605'); + gitLabelMessage.css('color', 'darkgreen').text('Synchronized'); + } else if (data.status.value === 'syncing') { + gitLabelMessage.css('color', '#cccc00').text('Synchronization..'); + gitLabelStatus.css('color', '#cccc00').text('\u25cc'); + } else { + const message = `Got unknown repository status: ${data.status.value}`; + gitLabelStatus.css('color', 'red').text('\u26a0'); + gitLabelMessage.css('color', 'red').text(message); + } + }).fail((data) => { + gitWindow.remove(); + const message = 'Error occured during get an repos status. ' + + `Code: ${data.status}, text: ${data.responseText || data.statusText}`; + showMessage(message); + }); + } - if (data.status.value === "!sync") { - gitLabelStatus.css("color", "red").text("\u2606"); - gitLabelMessage.css("color", "red").text("Repository is not synchronized"); - syncButton.attr("disabled", false); - } - else if (data.status.value === "sync") { - gitLabelStatus.css("color", "#cccc00").text("\u2605"); - gitLabelMessage.css("color", "black").text("Synchronized (merge required)"); - } - else if (data.status.value === "merged") { - gitLabelStatus.css("color", "darkgreen").text("\u2605"); - gitLabelMessage.css("color", "darkgreen").text("Synchronized"); - } - else if (data.status.value === "syncing") { - gitLabelMessage.css("color", "#cccc00").text("Synchronization.."); - gitLabelStatus.css("color", "#cccc00").text("\u25cc"); - } - else { - let message = `Got unknown repository status: ${data.status.value}`; - gitLabelStatus.css("color", "red").text("\u26a0"); - gitLabelMessage.css("color", "red").text(message); - throw Error(message); + closeReposWindowButton.on('click', () => { + gitWindow.remove(); + }); + + reposSyncButton.on('click', () => { + function badResponse(message) { + try { + showMessage(message); + throw Error(message); + } finally { + gitWindow.remove(); + } + } + + gitLabelMessage.css('color', '#cccc00').text('Synchronization..'); + gitLabelStatus.css('color', '#cccc00').text('\u25cc'); + reposSyncButton.attr('disabled', true); + + $.get(`/git/repository/push/${tid}`).done((rqData) => { + function checkCallback() { + $.get(`/git/repository/check/${rqData.rq_id}`).done((statusData) => { + if (['queued', 'started'].includes(statusData.status)) { + setTimeout(checkCallback, 1000); + } else if (statusData.status === 'finished') { + updateState(); + } else if (statusData.status === 'failed') { + const message = `Can not push to remote repository. Message: ${statusData.stderr}`; + badResponse(message); + } else { + const message = `Check returned status "${statusData.status}".`; + badResponse(message); + } + }).fail((errorData) => { + const message = 'Errors occured during pushing an repos entry. ' + + `Code: ${errorData.status}, text: ${errorData.responseText || errorData.statusText}`; + badResponse(message); + }); + } + + setTimeout(checkCallback, 1000); + }).fail((errorData) => { + const message = 'Errors occured during pushing an repos entry. ' + + `Code: ${errorData.status}, text: ${errorData.responseText || errorData.statusText}`; + badResponse(message); + }); + }); + + updateState(); + }).appendTo($(this).find('div.dashboardButtonsUI')[0]); } - }).fail(function(data) { - gitWindow.addClass("hidden"); - let message = `Error occured during get an repos status. ` + - `Code: ${data.status}, text: ${data.responseText || data.statusText}`; - showMessage(message); - throw Error(message); }); - }, -}; + }).fail((errorData) => { + const message = `Can not get repository meta information. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + }); + // Setup the "Create task" dialog + const title = 'Field for a repository URL and a relative path inside the repository. \n' + + 'Default repository path is `annotation/.zip`. \n' + + 'There are .zip or .xml extenstions are supported.'; + const placeh = 'github.com/user/repos [annotation/.zip]'; -document.addEventListener("DOMContentLoaded", () => { $(` - ` + - ` + + + - - ` - ).insertAfter($("#dashboardBugTrackerInput").parent().parent()); - - // Wrap create task request function - let originalCreateTaskRequest = window.createTaskRequest; - window.createTaskRequest = function(oData, onSuccessRequest, onSuccessCreate, onError, onComplete, onUpdateStatus) { - let gitPath = $(`#${window.cvat.git.createURLInputTextId}`).prop("value").replace(/\s/g, ""); - if (gitPath.length) { - oData.append("git_path", gitPath); - oData.append("use_lfs", $(`#${window.cvat.git.lfsCheckboxId}`).prop("checked")); - } - originalCreateTaskRequest(oData, onSuccessRequest, onSuccessCreate, onError, onComplete, onUpdateStatus); - }; - - /* GIT MODAL WINDOW PLUGIN PART */ - $(``).appendTo("body"); - - let gitWindow = $(`#${window.cvat.git.reposWindowId}`); - let closeRepositoryWindowButton = $(`#${window.cvat.git.closeReposWindowButtonId}`); - let repositorySyncButton = $(`#${window.cvat.git.reposSyncButtonId}`); - let gitLabelMessage = $(`#${window.cvat.git.labelMessageId}`); - let gitLabelStatus = $(`#${window.cvat.git.labelStatusId}`); - - closeRepositoryWindowButton.on("click", () => { - gitWindow.addClass("hidden"); - }); + + `).insertAfter($('#dashboardBugTrackerInput').parent().parent()); - repositorySyncButton.on("click", () => { - function badResponse(message) { - try { - showMessage(message); - throw Error(message); - } - finally { - window.cvat.git.updateState(); - } - } - gitLabelMessage.css("color", "#cccc00").text("Synchronization.."); - gitLabelStatus.css("color", "#cccc00").text("\u25cc"); - repositorySyncButton.attr("disabled", true); + DashboardView.registerDecorator('createTask', (taskData, next, onFault) => { + const taskMessage = $('#dashboardCreateTaskMessage'); - let tid = gitWindow.attr("current_tid"); - $.get(`/git/repository/push/${tid}`).done((data) => { - setTimeout(timeoutCallback, 1000); + const path = $(`#${createURLInputTextId}`).prop('value').replace(/\s/g, ''); + const lfs = $(`#${lfsCheckboxId}`).prop('checked'); - function timeoutCallback() { - $.get(`/git/repository/check/${data.rq_id}`).done((data) => { - if (["finished", "failed", "unknown"].indexOf(data.status) != -1) { - if (data.status === "failed") { - let message = data.error; - badResponse(message); - } - else if (data.status === "unknown") { - let message = `Request for pushing returned status "${data.status}".`; - badResponse(message); - } - else { - window.cvat.git.updateState(); + if (path.length) { + taskMessage.css('color', 'blue'); + taskMessage.text('Git repository is being cloned..'); + + $.ajax({ + url: `/git/repository/create/${taskData.id}`, + type: 'POST', + data: JSON.stringify({ + path, + lfs, + tid: taskData.id, + }), + contentType: 'application/json', + }).done((rqData) => { + function checkCallback() { + $.ajax({ + url: `/git/repository/check/${rqData.rq_id}`, + type: 'GET', + }).done((statusData) => { + if (['queued', 'started'].includes(statusData.status)) { + setTimeout(checkCallback, 1000); + } else if (statusData.status === 'finished') { + taskMessage.css('color', 'blue'); + taskMessage.text('Git repository has been cloned'); + next(); + } else if (statusData.status === 'failed') { + let message = 'Repository status check failed. '; + if (statusData.stderr) { + message += statusData.stderr; + } + + taskMessage.css('color', 'red'); + taskMessage.text(message); + onFault(); + } else { + const message = `Repository status check returned the status "${statusData.status}"`; + taskMessage.css('color', 'red'); + taskMessage.text(message); + onFault(); } - } - else { - setTimeout(timeoutCallback, 1000); - } - }).fail((data) => { - let message = `Error was occured during pushing an repos entry. ` + - `Code: ${data.status}, text: ${data.responseText || data.statusText}`; - badResponse(message); - }); - } - }).fail((data) => { - let message = `Error was occured during pushing an repos entry. ` + - `Code: ${data.status}, text: ${data.responseText || data.statusText}`; - badResponse(message); - }); + }).fail((errorData) => { + const message = `Can not sent a request to clone the repository. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + taskMessage.css('color', 'red'); + taskMessage.text(message); + onFault(); + }); + } + + setTimeout(checkCallback, 1000); + }).fail((errorData) => { + const message = `Can not sent a request to clone the repository. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + taskMessage.css('color', 'red'); + taskMessage.text(message); + onFault(); + }); + } else { + next(); + } }); }); diff --git a/cvat/apps/git/urls.py b/cvat/apps/git/urls.py index 7a168290083b..317ddf82ed56 100644 --- a/cvat/apps/git/urls.py +++ b/cvat/apps/git/urls.py @@ -8,6 +8,7 @@ urlpatterns = [ + path('create/', views.create), path('get/', views.get_repository), path('push/', views.push_repository), path('check/', views.check_process), diff --git a/cvat/apps/git/views.py b/cvat/apps/git/views.py index 5cc6e23baf0b..770f0678f3e9 100644 --- a/cvat/apps/git/views.py +++ b/cvat/apps/git/views.py @@ -12,6 +12,7 @@ import cvat.apps.git.git as CVATGit import django_rq +import json @login_required def check_process(request, rq_id): @@ -21,11 +22,11 @@ def check_process(request, rq_id): if rq_job is not None: if rq_job.is_queued or rq_job.is_started: - return JsonResponse({"status": "processing"}) + return JsonResponse({"status": rq_job.get_status()}) elif rq_job.is_finished: - return JsonResponse({"status": "finished"}) + return JsonResponse({"status": rq_job.get_status()}) else: - return JsonResponse({"status": "failed", "error": rq_job.exc_info}) + return JsonResponse({"status": rq_job.get_status(), "stderr": rq_job.exc_info}) else: return JsonResponse({"status": "unknown"}) except Exception as ex: @@ -33,6 +34,26 @@ def check_process(request, rq_id): return HttpResponseBadRequest(str(ex)) +@login_required +@permission_required(perm=['engine.task.create'], + fn=objectgetter(models.Task, 'tid'), raise_exception=True) +def create(request, tid): + try: + slogger.task[tid].info("create repository request") + + body = json.loads(request.body.decode('utf-8')) + path = body["path"] + lfs = body["lfs"] + rq_id = "git.create.{}".format(tid) + queue = django_rq.get_queue("default") + + queue.enqueue_call(func = CVATGit.initial_create, args = (tid, path, lfs, request.user), job_id = rq_id) + return JsonResponse({ "rq_id": rq_id }) + except Exception as ex: + slogger.glob.error("error occured during initial cloning repository request with rq id {}".format(rq_id), exc_info=True) + return HttpResponseBadRequest(str(ex)) + + @login_required @permission_required(perm=['engine.task.access'], fn=objectgetter(models.Task, 'tid'), raise_exception=True) diff --git a/cvat/apps/log_viewer/__init__.py b/cvat/apps/log_viewer/__init__.py index 3c7cca70670d..4c96c2ab030f 100644 --- a/cvat/apps/log_viewer/__init__.py +++ b/cvat/apps/log_viewer/__init__.py @@ -4,4 +4,4 @@ from cvat.settings.base import JS_3RDPARTY -JS_3RDPARTY['dashboard'] = JS_3RDPARTY.get('dashboard', []) + ['log_viewer/js/shortcuts.js'] +JS_3RDPARTY['dashboard'] = JS_3RDPARTY.get('dashboard', []) + ['log_viewer/js/dashboardPlugin.js'] diff --git a/cvat/apps/log_viewer/static/log_viewer/js/dashboardPlugin.js b/cvat/apps/log_viewer/static/log_viewer/js/dashboardPlugin.js new file mode 100644 index 000000000000..e40e279283d4 --- /dev/null +++ b/cvat/apps/log_viewer/static/log_viewer/js/dashboardPlugin.js @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +window.addEventListener('DOMContentLoaded', () => { + $('').on('click', () => { + window.open('/analytics/app/kibana'); + }).appendTo('#dashboardManageButtons'); +}); diff --git a/cvat/apps/log_viewer/static/log_viewer/js/shortcuts.js b/cvat/apps/log_viewer/static/log_viewer/js/shortcuts.js deleted file mode 100644 index 880178ca7d03..000000000000 --- a/cvat/apps/log_viewer/static/log_viewer/js/shortcuts.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) 2018 Intel Corporation - * - * SPDX-License-Identifier: MIT - */ - -/* global - Mousetrap:false -*/ - -Mousetrap.bind(window.cvat.config.shortkeys["open_analytics"].value, function() { - window.open("/analytics/app/kibana"); - - return false; -}); \ No newline at end of file diff --git a/cvat/apps/reid/reid.py b/cvat/apps/reid/reid.py index 915359b3e11a..59fce1cbfe1b 100644 --- a/cvat/apps/reid/reid.py +++ b/cvat/apps/reid/reid.py @@ -82,10 +82,10 @@ def __del__(self): def __boxes_are_compatible(self, cur_box, next_box): - cur_c_x = (cur_box["xtl"] + cur_box["xbr"]) / 2 - cur_c_y = (cur_box["ytl"] + cur_box["ybr"]) / 2 - next_c_x = (next_box["xtl"] + next_box["xbr"]) / 2 - next_c_y = (next_box["ytl"] + next_box["ybr"]) / 2 + cur_c_x = (cur_box["points"][0] + cur_box["points"][2]) / 2 + cur_c_y = (cur_box["points"][1] + cur_box["points"][3]) / 2 + next_c_x = (next_box["points"][0] + next_box["points"][2]) / 2 + next_c_y = (next_box["points"][1] + next_box["points"][3]) / 2 compatible_distance = euclidean([cur_c_x, cur_c_y], [next_c_x, next_c_y]) <= self.__max_distance compatible_label = cur_box["label_id"] == next_box["label_id"] return compatible_distance and compatible_label and "path_id" not in next_box @@ -123,8 +123,8 @@ def _int(number, upper): cur_width = cur_image.shape[1] cur_height = cur_image.shape[0] cur_xtl, cur_xbr, cur_ytl, cur_ybr = ( - _int(cur_box["xtl"], cur_width), _int(cur_box["xbr"], cur_width), - _int(cur_box["ytl"], cur_height), _int(cur_box["ybr"], cur_height) + _int(cur_box["points"][0], cur_width), _int(cur_box["points"][2], cur_width), + _int(cur_box["points"][1], cur_height), _int(cur_box["points"][3], cur_height) ) for col, next_box in enumerate(next_boxes): @@ -132,8 +132,8 @@ def _int(number, upper): next_width = next_image.shape[1] next_height = next_image.shape[0] next_xtl, next_xbr, next_ytl, next_ybr = ( - _int(next_box["xtl"], next_width), _int(next_box["xbr"], next_width), - _int(next_box["ytl"], next_height), _int(next_box["ybr"], next_height) + _int(next_box["points"][0], next_width), _int(next_box["points"][2], next_width), + _int(next_box["points"][1], next_height), _int(next_box["points"][3], next_height) ) if not self.__boxes_are_compatible(cur_box, next_box): @@ -149,7 +149,7 @@ def _int(number, upper): def __apply_matching(self): frames = sorted(list(self.__frame_boxes.keys())) job = rq.get_current_job() - box_paths = {} + box_tracks = {} for idx, (cur_frame, next_frame) in enumerate(list(zip(frames[:-1], frames[1:]))): job.refresh() @@ -164,8 +164,8 @@ def __apply_matching(self): for box in cur_boxes: if "path_id" not in box: - path_id = len(box_paths) - box_paths[path_id] = [box] + path_id = len(box_tracks) + box_tracks[path_id] = [box] box["path_id"] = path_id if not (len(cur_boxes) and len(next_boxes)): @@ -180,38 +180,39 @@ def __apply_matching(self): cur_box = cur_boxes[cur_idx] next_box = next_boxes[next_idxs[idx]] next_box["path_id"] = cur_box["path_id"] - box_paths[cur_box["path_id"]].append(next_box) + box_tracks[cur_box["path_id"]].append(next_box) for box in self.__frame_boxes[frames[-1]]: if "path_id" not in box: - path_id = len(box_paths) + path_id = len(box_tracks) box["path_id"] = path_id - box_paths[path_id] = [box] + box_tracks[path_id] = [box] - return box_paths + return box_tracks def run(self): - box_paths = self.__apply_matching() + box_tracks = self.__apply_matching() output = [] # ReID process has been canceled - if box_paths is None: + if box_tracks is None: return - for path_id in box_paths: + for path_id in box_tracks: output.append({ - "label_id": box_paths[path_id][0]["label_id"], - "group_id": 0, + "label_id": box_tracks[path_id][0]["label_id"], + "group": None, "attributes": [], - "frame": box_paths[path_id][0]["frame"], - "shapes": box_paths[path_id] + "frame": box_tracks[path_id][0]["frame"], + "shapes": box_tracks[path_id] }) for box in output[-1]["shapes"]: - del box["id"] + if "id" in box: + del box["id"] del box["path_id"] - del box["group_id"] + del box["group"] del box["label_id"] box["outside"] = False box["attributes"] = [] diff --git a/cvat/apps/reid/static/reid/js/enginePlugin.js b/cvat/apps/reid/static/reid/js/enginePlugin.js index 6bf14377cf5a..28fabb82319c 100644 --- a/cvat/apps/reid/static/reid/js/enginePlugin.js +++ b/cvat/apps/reid/static/reid/js/enginePlugin.js @@ -8,97 +8,96 @@ document.addEventListener('DOMContentLoaded', () => { - function run(overlay, cancelButton, thresholdInput, distanceInput) { + async function run(overlay, cancelButton, thresholdInput, distanceInput) { const collection = window.cvat.data.get(); const data = { threshold: +thresholdInput.prop('value'), maxDistance: +distanceInput.prop('value'), - boxes: collection.boxes, + boxes: collection.shapes.filter(el => el.type === 'rectangle'), }; overlay.removeClass('hidden'); cancelButton.prop('disabled', true); - $.ajax({ - url: `reid/start/job/${window.cvat.job.id}`, - type: 'POST', - data: JSON.stringify(data), - contentType: 'application/json', - success: () => { - function checkCallback() { - $.ajax({ - url: `/reid/check/${window.cvat.job.id}`, - type: 'GET', - success: (jobData) => { - if (jobData.progress) { - cancelButton.text(`Cancel ReID Merge (${jobData.progress.toString().slice(0, 4)}%)`); - } - - if (['queued', 'started'].includes(jobData.status)) { - setTimeout(checkCallback, 1000); - } else { - overlay.addClass('hidden'); - - if (jobData.status === 'finished') { - if (jobData.result) { - collection.boxes = []; - collection.box_paths = collection.box_paths - .concat(JSON.parse(jobData.result)); - window.cvat.data.clear(); - window.cvat.data.set(collection); - showMessage('ReID merge has done.'); - } else { - showMessage('ReID merge been canceled.'); - } - } else if (jobData.status === 'failed') { - const message = `ReID merge has fallen. Error: '${jobData.stderr}'`; - showMessage(message); - } else { - let message = `Check request returned "${jobData.status}" status.`; - if (jobData.stderr) { - message += ` Error: ${jobData.stderr}`; - } - showMessage(message); - } - } - }, - error: (errorData) => { - overlay.addClass('hidden'); - const message = `Can not check ReID merge. Code: ${errorData.status}. Message: ${errorData.responseText || errorData.statusText}`; - showMessage(message); - }, - }); - } - setTimeout(checkCallback, 1000); - }, - error: (errorData) => { + async function checkCallback() { + let jobData = null; + try { + jobData = await $.get(`/reid/check/${window.cvat.job.id}`); + } catch (errorData) { overlay.addClass('hidden'); - const message = `Can not start ReID merge. Code: ${errorData.status}. Message: ${errorData.responseText || errorData.statusText}`; + const message = `Can not check ReID merge. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; showMessage(message); - }, - complete: () => { - cancelButton.prop('disabled', false); - }, - }); - } + } - function cancel(overlay, cancelButton) { - cancelButton.prop('disabled', true); - $.ajax({ - url: `/reid/cancel/${window.cvat.job.id}`, - type: 'GET', - success: () => { + if (jobData.progress) { + cancelButton.text(`Cancel ReID Merge (${jobData.progress.toString().slice(0, 4)}%)`); + } + + if (['queued', 'started'].includes(jobData.status)) { + setTimeout(checkCallback, 1000); + } else { overlay.addClass('hidden'); - cancelButton.text('Cancel ReID Merge (0%)'); - }, - error: (errorData) => { - const message = `Can not cancel ReID process. Code: ${errorData.status}. Message: ${errorData.responseText || errorData.statusText}`; - showMessage(message); - }, - complete: () => { - cancelButton.prop('disabled', false); + + if (jobData.status === 'finished') { + if (jobData.result) { + const result = JSON.parse(jobData.result); + collection.shapes = collection.shapes + .filter(el => el.type !== 'rectangle'); + collection.tracks = collection.tracks + .concat(result); + + window.cvat.data.clear(); + window.cvat.data.set(collection); + + showMessage('ReID merge has done.'); + } else { + showMessage('ReID merge been canceled.'); + } + } else if (jobData.status === 'failed') { + const message = `ReID merge has fallen. Error: '${jobData.stderr}'`; + showMessage(message); + } else { + let message = `Check request returned "${jobData.status}" status.`; + if (jobData.stderr) { + message += ` Error: ${jobData.stderr}`; + } + showMessage(message); + } } - }); + } + + try { + await $.ajax({ + url: `/reid/start/job/${window.cvat.job.id}`, + type: 'POST', + data: JSON.stringify(data), + contentType: 'application/json', + }); + + setTimeout(checkCallback, 1000); + } catch (errorData) { + overlay.addClass('hidden'); + const message = `Can not start ReID merge. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + } finally { + cancelButton.prop('disabled', false); + } + } + + async function cancel(overlay, cancelButton) { + cancelButton.prop('disabled', true); + try { + await $.get(`/reid/cancel/${window.cvat.job.id}`); + overlay.addClass('hidden'); + cancelButton.text('Cancel ReID Merge (0%)'); + } catch (errorData) { + const message = `Can not cancel ReID process. Code: ${errorData.status}. Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + } finally { + cancelButton.prop('disabled', false); + } } const buttonsUI = $('#engineMenuButtons'); @@ -121,13 +120,13 @@ document.addEventListener('DOMContentLoaded', () => { - + - + @@ -165,6 +164,11 @@ document.addEventListener('DOMContentLoaded', () => { $(`#${reidSubmitMergeId}`).on('click', () => { $(`#${reidWindowId}`).addClass('hidden'); run($(`#${reidOverlay}`), $(`#${reidCancelButtonId}`), - $(`#${reidThresholdValueId}`), $(`#${reidDistanceValueId}`)); + $(`#${reidThresholdValueId}`), $(`#${reidDistanceValueId}`)) + .catch((error) => { + setTimeout(() => { + throw error; + }); + }); }); }); diff --git a/cvat/apps/tf_annotation/__init__.py b/cvat/apps/tf_annotation/__init__.py index 2949bfd44427..7c9219c09832 100644 --- a/cvat/apps/tf_annotation/__init__.py +++ b/cvat/apps/tf_annotation/__init__.py @@ -5,5 +5,5 @@ from cvat.settings.base import JS_3RDPARTY -JS_3RDPARTY['dashboard'] = JS_3RDPARTY.get('dashboard', []) + ['tf_annotation/js/tf_annotation.js'] +JS_3RDPARTY['dashboard'] = JS_3RDPARTY.get('dashboard', []) + ['tf_annotation/js/dashboardPlugin.js'] diff --git a/cvat/apps/tf_annotation/static/tf_annotation/js/dashboardPlugin.js b/cvat/apps/tf_annotation/static/tf_annotation/js/dashboardPlugin.js new file mode 100644 index 000000000000..b0f319a349a6 --- /dev/null +++ b/cvat/apps/tf_annotation/static/tf_annotation/js/dashboardPlugin.js @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/* global + userConfirm:false + showMessage:false +*/ + +window.addEventListener('dashboardReady', () => { + function checkProcess(tid, button) { + function checkCallback() { + $.get(`/tensorflow/annotation/check/task/${tid}`).done((statusData) => { + if (['started', 'queued'].includes(statusData.status)) { + const progress = Math.round(statusData.progress) || '0'; + button.text(`Cancel TF Annotation (${progress}%)`); + setTimeout(checkCallback, 5000); + } else { + button.text('Run TF Annotation'); + button.removeClass('tfAnnotationProcess'); + button.prop('disabled', false); + + if (statusData.status === 'failed') { + const message = `Tensorflow annotation failed. Error: ${statusData.stderr}`; + showMessage(message); + } else if (statusData.status !== 'finished') { + const message = `Tensorflow annotation check request returned status "${statusData.status}"`; + showMessage(message); + } + } + }).fail((errorData) => { + const message = `Can not sent tensorflow annotation check request. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + }); + } + + setTimeout(checkCallback, 5000); + } + + + function runProcess(tid, button) { + $.get(`/tensorflow/annotation/create/task/${tid}`).done(() => { + showMessage('Process has started'); + button.text('Cancel TF Annotation (0%)'); + button.addClass('tfAnnotationProcess'); + checkProcess(tid, button); + }).fail((errorData) => { + const message = `Can not run tf annotation. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + }); + } + + + function cancelProcess(tid, button) { + $.get(`/tensorflow/annotation/cancel/task/${tid}`).done(() => { + button.prop('disabled', true); + }).fail((errorData) => { + const message = `Can not cancel tf annotation. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + }); + } + + + function setupDashboardItem(item, metaData) { + const tid = +item.attr('tid'); + const button = $(''); + + button.on('click', () => { + if (button.hasClass('tfAnnotationProcess')) { + userConfirm('The process will be canceled. Continue?', () => { + cancelProcess(tid, button); + }); + } else { + userConfirm('The current annotation will be lost. Are you sure?', () => { + runProcess(tid, button); + }); + } + }); + + button.addClass('dashboardTFAnnotationButton regular dashboardButtonUI'); + button.appendTo(item.find('div.dashboardButtonsUI')); + + if ((tid in metaData) && (metaData[tid].active)) { + button.text('Cancel TF Annotation'); + button.addClass('tfAnnotationProcess'); + checkProcess(tid, button); + } + } + + const elements = $('.dashboardItem'); + const tids = Array.from(elements, el => +el.getAttribute('tid')); + + $.ajax({ + type: 'POST', + url: '/tensorflow/annotation/meta/get', + data: JSON.stringify(tids), + contentType: 'application/json; charset=utf-8', + }).done((metaData) => { + elements.each(function setupDashboardItemWrapper() { + setupDashboardItem($(this), metaData); + }); + }).fail((errorData) => { + const message = `Can not get tf annotation meta info. Code: ${errorData.status}. ` + + `Message: ${errorData.responseText || errorData.statusText}`; + showMessage(message); + }); +}); diff --git a/cvat/apps/tf_annotation/static/tf_annotation/js/tf_annotation.js b/cvat/apps/tf_annotation/static/tf_annotation/js/tf_annotation.js deleted file mode 100644 index 84ad318d3a4b..000000000000 --- a/cvat/apps/tf_annotation/static/tf_annotation/js/tf_annotation.js +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2018 Intel Corporation - * - * SPDX-License-Identifier: MIT - */ - -/* global - userConfirm:false - showMessage:false -*/ - -"use strict"; - -function CheckTFAnnotationRequest(taskId, tfAnnotationButton) { - let frequence = 5000; - let errorCount = 0; - let interval = setInterval(function() { - $.ajax ({ - url: '/tensorflow/annotation/check/task/' + taskId, - success: function(jsonData) { - let status = jsonData["status"]; - if (status == "started" || status == "queued") { - let progress = Math.round(jsonData["progress"]) || "0"; - tfAnnotationButton.text(`Cancel TF Annotation (${progress}%)`); - } - else { - tfAnnotationButton.text("Run TF Annotation"); - tfAnnotationButton.removeClass("tfAnnotationProcess"); - tfAnnotationButton.prop("disabled", false); - clearInterval(interval); - } - }, - error: function() { - errorCount ++; - if (errorCount > 5) { - clearInterval(interval); - tfAnnotationButton.prop("disabled", false); - tfAnnotationButton.text("Status Check Error"); - throw Error(`TF annotation check request error for task ${window.cvat.dashboard.taskID}:${window.cvat.dashboard.taskName}`); - } - } - }); - }, frequence); -} - -function RunTFAnnotationRequest() { - let tfAnnotationButton = this; - let taskID = window.cvat.dashboard.taskID; - $.ajax ({ - url: '/tensorflow/annotation/create/task/' + taskID, - success: function() { - showMessage('Process started.'); - tfAnnotationButton.text(`Cancel TF Annotation (0%)`); - tfAnnotationButton.addClass("tfAnnotationProcess"); - CheckTFAnnotationRequest(taskID, tfAnnotationButton); - }, - error: function(response) { - let message = 'Abort. Reason: ' + response.responseText; - showMessage(message); - } - }); -} - -function CancelTFAnnotationRequest() { - let tfAnnotationButton = this; - $.ajax ({ - url: '/tensorflow/annotation/cancel/task/' + window.cvat.dashboard.taskID, - success: function() { - tfAnnotationButton.prop("disabled", true); - }, - error: function(data) { - let message = `TF annotation cancel error: ${data.responseText}`; - showMessage(message); - } - }); -} - -function onTFAnnotationClick() { - let button = this; - let uiElem = button.closest('div.dashboardTaskUI'); - let taskId = +uiElem.attr('id').split('_')[1]; - let taskName = $.trim($( uiElem.find('label.dashboardTaskNameLabel')[0] ).text()); - - window.cvat.dashboard.taskID = taskId; - window.cvat.dashboard.taskName = taskName; - - if (button.hasClass("tfAnnotationProcess")) { - userConfirm('The process will be canceled. Continue?', CancelTFAnnotationRequest.bind(button)); - } - else { - userConfirm('The current annotation will be lost. Are you sure?', RunTFAnnotationRequest.bind(button)); - } -} - -window.cvat = window.cvat || {}; -window.cvat.dashboard = window.cvat.dashboard || {}; -window.cvat.dashboard.uiCallbacks = window.cvat.dashboard.uiCallbacks || []; - -window.cvat.dashboard.uiCallbacks.push(function(newElements) { - let tids = []; - for (let el of newElements) { - tids.push(el.id.split('_')[1]); - } - - $.ajax({ - type: 'POST', - url: '/tensorflow/annotation/meta/get', - data: JSON.stringify(tids), - contentType: "application/json; charset=utf-8", - success: (data) => { - newElements.each(function(idx) { - let elem = $(newElements[idx]); - let tid = +elem.attr('id').split('_')[1]; - let buttonsUI = elem.find('div.dashboardButtonsUI')[0]; - let tfAnnotationButton = $(''); - - tfAnnotationButton.on('click', onTFAnnotationClick.bind(tfAnnotationButton)); - tfAnnotationButton.addClass('dashboardTFAnnotationButton regular dashboardButtonUI'); - tfAnnotationButton.appendTo(buttonsUI); - - if ((tid in data) && (data[tid].active)) { - tfAnnotationButton.text("Cancel TF Annotation"); - tfAnnotationButton.addClass("tfAnnotationProcess"); - CheckTFAnnotationRequest(tid, tfAnnotationButton); - } - }); - }, - error: (data) => { - let message = `Can not get tf annotation meta info. Code: ${data.status}. Message: ${data.responseText || data.statusText}`; - showMessage(message); - throw Error(message); - } - }); -}); diff --git a/cvat/apps/tf_annotation/views.py b/cvat/apps/tf_annotation/views.py index 729da1fc0da0..c98c56765e6f 100644 --- a/cvat/apps/tf_annotation/views.py +++ b/cvat/apps/tf_annotation/views.py @@ -10,7 +10,8 @@ from cvat.apps.authentication.decorators import login_required from cvat.apps.engine.models import Task as TaskModel from cvat.apps.engine import annotation, task - +from cvat.apps.engine.serializers import LabeledDataSerializer +from cvat.apps.engine.annotation import put_task_data import django_rq import fnmatch @@ -168,44 +169,30 @@ def get_image_key(item): def convert_to_cvat_format(data): - def create_anno_container(): - return { - "boxes": [], - "polygons": [], - "polylines": [], - "points": [], - "box_paths": [], - "polygon_paths": [], - "polyline_paths": [], - "points_paths": [], - } - result = { - 'create': create_anno_container(), - 'update': create_anno_container(), - 'delete': create_anno_container(), + "tracks": [], + "shapes": [], + "tags": [], + "version": 0, } for label in data: boxes = data[label] for box in boxes: - result['create']['boxes'].append({ + result['shapes'].append({ + "type": "rectangle", "label_id": label, "frame": box[0], - "xtl": box[1], - "ytl": box[2], - "xbr": box[3], - "ybr": box[4], + "points": [box[1], box[2], box[3], box[4]], "z_order": 0, - "group_id": 0, + "group": None, "occluded": False, "attributes": [], - "id": -1, }) return result -def create_thread(tid, labels_mapping): +def create_thread(tid, labels_mapping, user): try: TRESHOLD = 0.5 # Init rq job @@ -228,14 +215,16 @@ def create_thread(tid, labels_mapping): # Modify data format and save result = convert_to_cvat_format(result) - annotation.clear_task(tid) - annotation.save_task(tid, result) + serializer = LabeledDataSerializer(data = result) + if serializer.is_valid(raise_exception=True): + put_task_data(tid, user, result) slogger.glob.info('tf annotation for task {} done'.format(tid)) - except: + except Exception as ex: try: slogger.task[tid].exception('exception was occured during tf annotation of the task', exc_info=True) except: slogger.glob.exception('exception was occured during tf annotation of the task {}'.format(tid), exc_into=True) + raise ex @login_required def get_meta_info(request): @@ -301,7 +290,7 @@ def create(request, tid): # Run tf annotation job queue.enqueue_call(func=create_thread, - args=(tid, labels_mapping), + args=(tid, labels_mapping, request.user), job_id='tf_annotation.create/{}'.format(tid), timeout=604800) # 7 days @@ -338,6 +327,7 @@ def check(request, tid): job.delete() else: data['status'] = 'failed' + data['stderr'] = job.exc_info job.delete() except Exception: diff --git a/cvat/requirements/all.txt b/cvat/requirements/all.txt new file mode 100644 index 000000000000..ec7a170b14a9 --- /dev/null +++ b/cvat/requirements/all.txt @@ -0,0 +1,4 @@ +-r development.txt +-r production.txt +-r staging.txt +-r testing.txt diff --git a/cvat/requirements/base.txt b/cvat/requirements/base.txt index 5d1dee3d8ac2..e7e82c297662 100644 --- a/cvat/requirements/base.txt +++ b/cvat/requirements/base.txt @@ -1,14 +1,14 @@ click==6.7 -Django==2.1.5 +Django==2.1.7 django-appconf==1.0.2 django-auth-ldap==1.4.0 django-cacheops==4.0.6 django-compressor==2.2 -django-rq==1.3.0 +django-rq==2.0.0 EasyProcess==0.2.3 ffmpy==0.2.2 Pillow==5.1.0 -numpy==1.14.2 +numpy==1.16.2 patool==1.12 python-ldap==3.0.0 pytz==2018.3 @@ -17,8 +17,8 @@ rcssmin==1.0.6 redis==3.2.0 requests==2.20.0 rjsmin==1.0.12 -rq==0.13.0 -scipy==1.0.1 +rq==1.0.0 +scipy==1.2.1 sqlparse==0.2.4 django-sendfile==0.3.11 dj-pagination==2.4.0 @@ -26,3 +26,10 @@ python-logstash==0.4.6 django-revproxy==0.9.15 rules==2.0 GitPython==2.1.11 +coreapi==2.3.3 +django-filter==2.0.0 +Markdown==3.0.1 +djangorestframework==3.9.0 +Pygments==2.3.1 +drf-yasg==1.15.0 +Shapely==1.6.4.post2 diff --git a/cvat/requirements/testing.txt b/cvat/requirements/testing.txt new file mode 100644 index 000000000000..cb208059a91e --- /dev/null +++ b/cvat/requirements/testing.txt @@ -0,0 +1,2 @@ +-f development.txt +fakeredis==1.0.3 \ No newline at end of file diff --git a/cvat/settings/base.py b/cvat/settings/base.py index 7ba1e668664d..26a66cfc5a4f 100644 --- a/cvat/settings/base.py +++ b/cvat/settings/base.py @@ -99,8 +99,31 @@ def generate_ssh_keys(): 'dj_pagination', 'revproxy', 'rules', + 'rest_framework', + 'django_filters', + 'drf_yasg', ] +REST_FRAMEWORK = { + 'DEFAULT_PERMISSION_CLASSES': [ + 'rest_framework.permissions.IsAuthenticated', + ], + 'DEFAULT_VERSIONING_CLASS': + # Don't try to use URLPathVersioning. It will give you /api/{version} + # in path and '/api/docs' will not collapse similar items (flat list + # of all possible methods isn't readable). + 'rest_framework.versioning.NamespaceVersioning', + # Need to add 'api-docs' here as a workaround for include_docs_urls. + 'ALLOWED_VERSIONS': ('v1', 'api-docs'), + 'DEFAULT_PAGINATION_CLASS': + 'rest_framework.pagination.PageNumberPagination', + 'PAGE_SIZE': 10, + 'DEFAULT_FILTER_BACKENDS': ( + 'rest_framework.filters.SearchFilter', + 'django_filters.rest_framework.DjangoFilterBackend', + 'rest_framework.filters.OrderingFilter') +} + if 'yes' == os.environ.get('TF_ANNOTATION', 'no'): INSTALLED_APPS += ['cvat.apps.tf_annotation'] diff --git a/cvat/settings/development.py b/cvat/settings/development.py index 8c1b8ee818c7..9205c8d51d7c 100644 --- a/cvat/settings/development.py +++ b/cvat/settings/development.py @@ -11,6 +11,8 @@ 'django_extensions', ] +ALLOWED_HOSTS.append('testserver') + # Django-sendfile: # https://github.com/johnsensible/django-sendfile SENDFILE_BACKEND = 'sendfile.backends.development' diff --git a/cvat/settings/staging.py b/cvat/settings/staging.py index 46ddeb8c150a..bae862d9ce94 100644 --- a/cvat/settings/staging.py +++ b/cvat/settings/staging.py @@ -1,4 +1,3 @@ - # Copyright (C) 2018 Intel Corporation # # SPDX-License-Identifier: MIT @@ -30,7 +29,7 @@ SILKY_MAX_RECORDED_REQUESTS = 10**4 def SILKY_INTERCEPT_FUNC(request): # Ignore all requests which try to get a frame (too many of them) - if request.method == 'GET' and '/frame/' in request.path: + if request.method == 'GET' and '/frames/' in request.path: return False return True diff --git a/cvat/settings/testing.py b/cvat/settings/testing.py new file mode 100644 index 000000000000..4a0560f78578 --- /dev/null +++ b/cvat/settings/testing.py @@ -0,0 +1,51 @@ +# Copyright (C) 2018 Intel Corporation +# +# SPDX-License-Identifier: MIT + +from .development import * +import tempfile + +_temp_dir = tempfile.TemporaryDirectory(suffix="cvat") + +DATA_ROOT = os.path.join(_temp_dir.name, 'data') +os.makedirs(DATA_ROOT, exist_ok=True) +SHARE_ROOT = os.path.join(_temp_dir.name, 'share') +os.makedirs(SHARE_ROOT, exist_ok=True) + +# To avoid ERROR django.security.SuspiciousFileOperation: +# The joined path (...) is located outside of the base path component +MEDIA_ROOT = _temp_dir.name + +# Suppress all logs by default +for logger in LOGGING["loggers"].values(): + if isinstance(logger, dict) and "level" in logger: + logger["level"] = "ERROR" + +LOGGING["handlers"]["server_file"] = LOGGING["handlers"]["console"] + +PASSWORD_HASHERS = ( + 'django.contrib.auth.hashers.MD5PasswordHasher', +) + +# When you run ./manage.py test, Django looks at the TEST_RUNNER setting to +# determine what to do. By default, TEST_RUNNER points to +# 'django.test.runner.DiscoverRunner'. This class defines the default Django +# testing behavior. +TEST_RUNNER = "cvat.settings.testing.PatchedDiscoverRunner" + +from django.test.runner import DiscoverRunner +class PatchedDiscoverRunner(DiscoverRunner): + def __init__(self, *args, **kwargs): + # Used fakeredis for testing (don't affect production redis) + from fakeredis import FakeRedis, FakeStrictRedis + import django_rq.queues + simple_redis = FakeRedis() + strict_redis = FakeStrictRedis() + django_rq.queues.get_redis_connection = lambda _, strict: strict_redis \ + if strict else simple_redis + + # Run all RQ requests syncroniously + for config in RQ_QUEUES.values(): + config["ASYNC"] = False + + super().__init__(*args, **kwargs) \ No newline at end of file diff --git a/cvat/simpleworker.py b/cvat/simpleworker.py index 6f2e38624fee..15265b062902 100644 --- a/cvat/simpleworker.py +++ b/cvat/simpleworker.py @@ -25,4 +25,4 @@ def main_work_horse(self, *args, **kwargs): def execute_job(self, *args, **kwargs): """Execute job in same thread/process, do not fork()""" - return self.perform_job(*args, **kwargs) \ No newline at end of file + return self.perform_job(*args, **kwargs) diff --git a/cvat/utils/version.py b/cvat/utils/version.py new file mode 100644 index 000000000000..b69c718b4111 --- /dev/null +++ b/cvat/utils/version.py @@ -0,0 +1,59 @@ +# Copyright (C) 2019 Intel Corporation +# +# SPDX-License-Identifier: MIT +# +# Note: It is slightly re-implemented Django version of code. We cannot use +# get_version from django.utils.version module because get_git_changeset will +# always return empty value (cwd=repo_dir isn't correct). Also it gives us a +# way to define the version as we like. + +import datetime +import os +import subprocess + +def get_version(version): + """Return a PEP 440-compliant version number from VERSION.""" + # Now build the two parts of the version number: + # main = X.Y[.Z] + # sub = .devN - for pre-alpha releases + # | {a|b|rc}N - for alpha, beta, and rc releases + + main = get_main_version(version) + + sub = '' + if version[3] == 'alpha' and version[4] == 0: + git_changeset = get_git_changeset() + if git_changeset: + sub = '.dev%s' % git_changeset + + elif version[3] != 'final': + mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'rc'} + sub = mapping[version[3]] + str(version[4]) + + return main + sub + +def get_main_version(version): + """Return main version (X.Y[.Z]) from VERSION.""" + parts = 2 if version[2] == 0 else 3 + return '.'.join(str(x) for x in version[:parts]) + +def get_git_changeset(): + """Return a numeric identifier of the latest git changeset. + + The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format. + This value isn't guaranteed to be unique, but collisions are very unlikely, + so it's sufficient for generating the development version numbers. + """ + repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + git_log = subprocess.Popen( + 'git log --pretty=format:%ct --quiet -1 HEAD', + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + shell=True, cwd=repo_dir, universal_newlines=True, + ) + timestamp = git_log.communicate()[0] + try: + timestamp = datetime.datetime.utcfromtimestamp(int(timestamp)) + except ValueError: + return None + return timestamp.strftime('%Y%m%d%H%M%S') + diff --git a/tests/karma.conf.js b/tests/karma.conf.js index 1d31075604a8..8e28f6566b0d 100644 --- a/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -10,7 +10,6 @@ module.exports = function(config) { basePath: path.join(process.env.HOME, 'cvat/apps/'), frameworks: ['qunit'], files: [ - 'engine/static/engine/js/idGenerator.js', 'engine/static/engine/js/labelsInfo.js', 'engine/static/engine/js/annotationParser.js', 'engine/static/engine/js/listener.js', @@ -40,7 +39,7 @@ module.exports = function(config) { coverageReporter: { dir: path.join(process.env.HOME, 'media/coverage'), reporters: [ - { type: 'html', subdir: '.' }, { type: 'lcov', subdir: '.' } + { type: 'html', subdir: '.' }, { type: 'lcov', subdir: '.' } ], instrumenterOptions: { istanbul: { noCompact: true }