diff --git a/mfr/extensions/zip/render.py b/mfr/extensions/zip/render.py index a6370530c..8abde946f 100644 --- a/mfr/extensions/zip/render.py +++ b/mfr/extensions/zip/render.py @@ -1,32 +1,20 @@ import os -import zipfile +from typing import List, Union +from zipfile import ZipFile, ZipInfo -import markupsafe from mako.lookup import TemplateLookup -from mfr.core import extension from mfr.core.utils import sizeof_fmt +from mfr.core.extension import BaseRenderer -class ZipRenderer(extension.BaseRenderer): +class ZipRenderer(BaseRenderer): TEMPLATE = TemplateLookup( directories=[ os.path.join(os.path.dirname(__file__), 'templates') ]).get_template('viewer.mako') - def render(self): - zip_file = zipfile.ZipFile(self.file_path, 'r') - - filelist = [{'name': markupsafe.escape(file.filename), - 'size': sizeof_fmt(int(file.file_size)), - 'date': "%d-%02d-%02d %02d:%02d:%02d" % file.date_time[:6]} for file in zip_file.filelist - if not file.filename.startswith('__MACOSX')] - - message = '' if filelist else 'This zip file is empty.' - - return self.TEMPLATE.render(zipped_filenames=filelist, message=message) - @property def file_required(self): return True @@ -34,3 +22,194 @@ def file_required(self): @property def cache_result(self): return True + + def render(self): + + zip_file = ZipFile(self.file_path, 'r') + + # ``ZipFile.filelist`` contains both files and folders. Using ``obj`` for better clarity. + sorted_obj_list = self.sanitize_obj_list(zip_file.filelist, sort=True) + obj_tree = self.sorted_obj_list_to_tree(sorted_obj_list) + + return self.TEMPLATE.render(data=obj_tree, base=self.assets_url) + + def sorted_obj_list_to_tree(self, sorted_obj_list: list) -> List[dict]: + """Build the object tree from a sorted object list. Each node is a dictionary. Leaf nodes + represent files and empty folders. Non-leaf nodes represent non-emtpy folders. Return a + list of dictionary that contains only one element: the root node. The tree can be accessed + and searched via the ``children`` key, of which the value is a list of child nodes. + + :param sorted_obj_list: the sorted object list + :rtype: ``List[dict]`` + :return: a list that contains only one element: the root node. + """ + # Build the root node of the tree + tree_root = { + 'text': self.metadata.name + self.metadata.ext, + 'icon': self.assets_url + '/img/file-ext-zip.png', + 'children': [] + } + # Iterate through each path and build the tree + for obj in sorted_obj_list: + path_from_root = obj.filename + path_segments = [segment for segment in path_from_root.split('/') if segment] + # Find the parent node of the current object, always start from the root node + parent = tree_root + for index, segment in enumerate(path_segments): + # last segment is the current object, parents must have been found, end loop + if index == len(path_segments) - 1: + break + # for a sorted list, every segment on the path must have a tree node + sibling_list = parent.get('children', []) + parent = self.find_node_among_siblings(segment, sibling_list) + # TODO: do we need this assert? + assert parent + # Create a new node, update details and add it to the sibling list + sibling_list = parent.get('children', []) + is_folder = path_from_root[-1] == '/' + new_node = { + 'text': path_segments[-1], + 'children': [], + } + self.update_node_with_attributes(new_node, obj, is_folder=is_folder) + sibling_list.append(new_node) + return [tree_root, ] + + # TODO: should we remove this function? + def unsorted_obj_list_to_tree(self, obj_list: list) -> List[dict]: + """Build the object tree from an object list. Each node is a dictionary, where leaf nodes + represent empty folders and files and non-leaf nodes represent non-emtpy folders. Return a + list that contains only one element: the root node. + + :param obj_list: the object list + :rtype: ``List[dict]`` + :return: a list that contains only one element: the root node. + """ + # Build the root node of the tree + tree_root = { + 'text': self.metadata.name + self.metadata.ext, + 'icon': self.assets_url + '/img/file-ext-zip.png', + 'children': [] + } + for obj in obj_list: + # For each object, always start from the root of the tree + parent = tree_root + path_from_root = obj.filename + is_folder = path_from_root[-1] == '/' + path_segments = [segment for segment in path_from_root.split('/') if segment] + last_index = len(path_segments) - 1 + # Iterate through the path segments list. Add the segment to tree if not already there + # and update the details with the current object if it is the last one along the path. + for index, segment in enumerate(path_segments): + # Check if the segment has already been added + siblings = parent.get('children', []) + current_node = self.find_node_among_siblings(segment, siblings) + # Found + if current_node: + if index == last_index: + # If it is the last segment, this node must be a folder and represents the + # current object. Update it with the objects' info and break. + assert is_folder + self.update_node_with_attributes(current_node, obj, is_folder=is_folder) + break + # Otherwise, jump to the next segment with the current node as the new parent + parent = current_node + continue + # Not found + new_node = { + 'text': segment, + 'children': [], + } + if index == last_index: + # If it is the last segment, the node represents the current object. Update the + # it with the objects' info, add it to the siblings and break. + self.update_node_with_attributes(new_node, obj, is_folder=is_folder) + siblings.append(new_node) + break + # Otherwise, append the new node to tree, jump to the next segment with the current + # node as the new parent + siblings.append(new_node) + parent = new_node + continue + return [tree_root, ] + + def update_node_with_attributes(self, node: dict, obj: ZipInfo, is_folder: bool=True) -> None: + """Update details (date, size, icon, etc.) of the node with the given object. + + :param node: the node to update + :param obj: the object that the node represents + :param is_folder: the folder flag + """ + date = '%d-%02d-%02d %02d:%02d:%02d' % obj.date_time[:6] + size = sizeof_fmt(int(obj.file_size)) if obj.file_size else '' + if is_folder: + icon_path = self.assets_url + '/img/folder.png' + else: + ext = (os.path.splitext(obj.filename)[1].lstrip('.')).lower() + if self.icon_exists(ext): + icon_path = '{}/img/file-ext-{}.png'.format(self.assets_url, ext) + else: + icon_path = '{}/img/file-ext-generic.png'.format(self.assets_url) + node.update({ + 'icon': icon_path, + 'data': { + 'date': date, + 'size': size, + }, + }) + + @staticmethod + def icon_exists(ext: str) -> bool: + """Check if an icon exists for the given file type. The extension string is converted to + lower case. + + :param ext: the file extension string + :rtype: ``bool`` + :return: ``True`` if found, ``False`` otherwise + """ + return os.path.isfile(os.path.join( + os.path.dirname(__file__), + 'static', + 'img', + 'file-ext-{}.png'.format(ext.lower()) + )) + + @staticmethod + def sanitize_obj_list(obj_list: list, sort: bool=False) -> list: + """Remove macOS system and temporary files with an option flag to sort the list. Current + implementation only removes '__MACOSX/' and '.DS_Store'. + + TODO: If necessary, extend the sanitizer to exclude more file types. + + :param obj_list: a list of full paths for each file or folder in the zip + :param sort: the flag for returning a sorted list + :rtype: ``list`` + :return: a sanitized list + """ + sanitized_obj_list = [] + for obj in obj_list: + obj_path = obj.filename + # Ignore macOS '__MACOSX' folder for zip file + if obj_path.startswith('__MACOSX/'): + continue + # Ignore macOS '.DS_STORE' file + if obj_path == '.DS_Store' or obj_path.endswith('/.DS_Store'): + continue + sanitized_obj_list.append(obj) + if sort: + return sorted(sanitized_obj_list, key=lambda obj: obj.filename) + return sanitized_obj_list + + @staticmethod + def find_node_among_siblings(segment: str, siblings: list) -> Union[dict, None]: + """Find the folder or file node represented by the path segment. + + :param segment: the path segment + :param siblings: the list containing all sibling nodes + :rtype: ``Union[dict, None]`` + :return: the node dictionary if found or ``None`` otherwise + """ + for sibling in siblings: + if sibling.get('text', '') == segment: + return sibling + return None diff --git a/mfr/extensions/zip/static/img/file-ext-3gp.png b/mfr/extensions/zip/static/img/file-ext-3gp.png new file mode 100644 index 000000000..1c1a2fc68 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-3gp.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-7z.png b/mfr/extensions/zip/static/img/file-ext-7z.png new file mode 100644 index 000000000..1e03f4613 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-7z.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-ace.png b/mfr/extensions/zip/static/img/file-ext-ace.png new file mode 100644 index 000000000..c7020ef45 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-ace.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-ai.png b/mfr/extensions/zip/static/img/file-ext-ai.png new file mode 100644 index 000000000..8136601dc Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-ai.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-aif.png b/mfr/extensions/zip/static/img/file-ext-aif.png new file mode 100644 index 000000000..84e59be58 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-aif.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-aiff.png b/mfr/extensions/zip/static/img/file-ext-aiff.png new file mode 100644 index 000000000..2d287056a Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-aiff.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-amr.png b/mfr/extensions/zip/static/img/file-ext-amr.png new file mode 100644 index 000000000..f1afbdb26 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-amr.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-asf.png b/mfr/extensions/zip/static/img/file-ext-asf.png new file mode 100644 index 000000000..736cff7a6 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-asf.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-asx.png b/mfr/extensions/zip/static/img/file-ext-asx.png new file mode 100644 index 000000000..2b638eb36 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-asx.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-bat.png b/mfr/extensions/zip/static/img/file-ext-bat.png new file mode 100644 index 000000000..a7c5606ff Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-bat.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-bin.png b/mfr/extensions/zip/static/img/file-ext-bin.png new file mode 100644 index 000000000..44bdc7cf9 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-bin.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-bmp.png b/mfr/extensions/zip/static/img/file-ext-bmp.png new file mode 100644 index 000000000..187657679 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-bmp.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-bup.png b/mfr/extensions/zip/static/img/file-ext-bup.png new file mode 100644 index 000000000..4a504e57d Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-bup.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-cab.png b/mfr/extensions/zip/static/img/file-ext-cab.png new file mode 100644 index 000000000..5f8c11ac7 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-cab.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-cbr.png b/mfr/extensions/zip/static/img/file-ext-cbr.png new file mode 100644 index 000000000..7c61e7d61 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-cbr.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-cda.png b/mfr/extensions/zip/static/img/file-ext-cda.png new file mode 100644 index 000000000..6c216231b Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-cda.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-cdl.png b/mfr/extensions/zip/static/img/file-ext-cdl.png new file mode 100644 index 000000000..d064572db Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-cdl.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-cdr.png b/mfr/extensions/zip/static/img/file-ext-cdr.png new file mode 100644 index 000000000..0fa8e850a Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-cdr.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-chm.png b/mfr/extensions/zip/static/img/file-ext-chm.png new file mode 100644 index 000000000..8fe071dfe Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-chm.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-dat.png b/mfr/extensions/zip/static/img/file-ext-dat.png new file mode 100644 index 000000000..e8b2350f5 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-dat.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-divx.png b/mfr/extensions/zip/static/img/file-ext-divx.png new file mode 100644 index 000000000..c3daad12d Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-divx.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-dll.png b/mfr/extensions/zip/static/img/file-ext-dll.png new file mode 100644 index 000000000..f69421085 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-dll.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-dmg.png b/mfr/extensions/zip/static/img/file-ext-dmg.png new file mode 100644 index 000000000..a50620282 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-dmg.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-doc.png b/mfr/extensions/zip/static/img/file-ext-doc.png new file mode 100644 index 000000000..23b079c7d Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-doc.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-docx.png b/mfr/extensions/zip/static/img/file-ext-docx.png new file mode 100644 index 000000000..23b079c7d Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-docx.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-dss.png b/mfr/extensions/zip/static/img/file-ext-dss.png new file mode 100644 index 000000000..34e892d69 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-dss.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-dvf.png b/mfr/extensions/zip/static/img/file-ext-dvf.png new file mode 100644 index 000000000..11db5a9ff Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-dvf.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-dwg.png b/mfr/extensions/zip/static/img/file-ext-dwg.png new file mode 100644 index 000000000..3caee9403 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-dwg.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-eml.png b/mfr/extensions/zip/static/img/file-ext-eml.png new file mode 100644 index 000000000..e10ad5725 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-eml.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-eps.png b/mfr/extensions/zip/static/img/file-ext-eps.png new file mode 100644 index 000000000..2623955aa Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-eps.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-exe.png b/mfr/extensions/zip/static/img/file-ext-exe.png new file mode 100644 index 000000000..608b77547 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-exe.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-fla.png b/mfr/extensions/zip/static/img/file-ext-fla.png new file mode 100644 index 000000000..b3faa0a08 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-fla.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-flv.png b/mfr/extensions/zip/static/img/file-ext-flv.png new file mode 100644 index 000000000..222df3c50 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-flv.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-generic.png b/mfr/extensions/zip/static/img/file-ext-generic.png new file mode 100644 index 000000000..3f0592ab4 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-generic.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-gif.png b/mfr/extensions/zip/static/img/file-ext-gif.png new file mode 100644 index 000000000..8f3b7c6cb Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-gif.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-gz.png b/mfr/extensions/zip/static/img/file-ext-gz.png new file mode 100644 index 000000000..90321d397 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-gz.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-hqx.png b/mfr/extensions/zip/static/img/file-ext-hqx.png new file mode 100644 index 000000000..07fd23f40 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-hqx.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-htm.png b/mfr/extensions/zip/static/img/file-ext-htm.png new file mode 100644 index 000000000..5c262dd16 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-htm.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-html.png b/mfr/extensions/zip/static/img/file-ext-html.png new file mode 100644 index 000000000..c94f677c3 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-html.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-ifo.png b/mfr/extensions/zip/static/img/file-ext-ifo.png new file mode 100644 index 000000000..28a95d906 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-ifo.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-indd.png b/mfr/extensions/zip/static/img/file-ext-indd.png new file mode 100644 index 000000000..7c43535ed Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-indd.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-iso.png b/mfr/extensions/zip/static/img/file-ext-iso.png new file mode 100644 index 000000000..5c8135aa1 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-iso.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-jar.png b/mfr/extensions/zip/static/img/file-ext-jar.png new file mode 100644 index 000000000..5897bbe8a Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-jar.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-jpeg.png b/mfr/extensions/zip/static/img/file-ext-jpeg.png new file mode 100644 index 000000000..961d2eff4 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-jpeg.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-jpg.png b/mfr/extensions/zip/static/img/file-ext-jpg.png new file mode 100644 index 000000000..1a9d0cd5d Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-jpg.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-lnk.png b/mfr/extensions/zip/static/img/file-ext-lnk.png new file mode 100644 index 000000000..a86c9e659 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-lnk.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-log.png b/mfr/extensions/zip/static/img/file-ext-log.png new file mode 100644 index 000000000..7f0892bf9 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-log.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-m4a.png b/mfr/extensions/zip/static/img/file-ext-m4a.png new file mode 100644 index 000000000..1fbe06f7b Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-m4a.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-m4b.png b/mfr/extensions/zip/static/img/file-ext-m4b.png new file mode 100644 index 000000000..5a6f67a56 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-m4b.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-m4p.png b/mfr/extensions/zip/static/img/file-ext-m4p.png new file mode 100644 index 000000000..a9b01ae10 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-m4p.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-m4v.png b/mfr/extensions/zip/static/img/file-ext-m4v.png new file mode 100644 index 000000000..a65dc2a8e Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-m4v.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-mcd.png b/mfr/extensions/zip/static/img/file-ext-mcd.png new file mode 100644 index 000000000..aa993f57f Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-mcd.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-mdb.png b/mfr/extensions/zip/static/img/file-ext-mdb.png new file mode 100644 index 000000000..efb086b97 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-mdb.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-mid.png b/mfr/extensions/zip/static/img/file-ext-mid.png new file mode 100644 index 000000000..c2c3e8489 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-mid.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-mov.png b/mfr/extensions/zip/static/img/file-ext-mov.png new file mode 100644 index 000000000..02f6a7b68 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-mov.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-mp2.png b/mfr/extensions/zip/static/img/file-ext-mp2.png new file mode 100644 index 000000000..f8f7d1ab5 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-mp2.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-mp3.png b/mfr/extensions/zip/static/img/file-ext-mp3.png new file mode 100644 index 000000000..c2c3e8489 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-mp3.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-mp4.png b/mfr/extensions/zip/static/img/file-ext-mp4.png new file mode 100644 index 000000000..10fab5777 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-mp4.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-mpeg.png b/mfr/extensions/zip/static/img/file-ext-mpeg.png new file mode 100644 index 000000000..75c087df9 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-mpeg.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-mpg.png b/mfr/extensions/zip/static/img/file-ext-mpg.png new file mode 100644 index 000000000..d7d4c0271 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-mpg.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-msi.png b/mfr/extensions/zip/static/img/file-ext-msi.png new file mode 100644 index 000000000..519338fd7 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-msi.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-mswmm.png b/mfr/extensions/zip/static/img/file-ext-mswmm.png new file mode 100644 index 000000000..e8840b83a Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-mswmm.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-ogg.png b/mfr/extensions/zip/static/img/file-ext-ogg.png new file mode 100644 index 000000000..1242b3437 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-ogg.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-pdf.png b/mfr/extensions/zip/static/img/file-ext-pdf.png new file mode 100644 index 000000000..df97fdb25 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-pdf.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-png.png b/mfr/extensions/zip/static/img/file-ext-png.png new file mode 100644 index 000000000..7c43535ed Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-png.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-pps.png b/mfr/extensions/zip/static/img/file-ext-pps.png new file mode 100644 index 000000000..f8659ace8 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-pps.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-ps.png b/mfr/extensions/zip/static/img/file-ext-ps.png new file mode 100644 index 000000000..c4f768d60 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-ps.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-psd.png b/mfr/extensions/zip/static/img/file-ext-psd.png new file mode 100644 index 000000000..6629aec8f Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-psd.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-pst.png b/mfr/extensions/zip/static/img/file-ext-pst.png new file mode 100644 index 000000000..eecf90ecd Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-pst.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-ptb.png b/mfr/extensions/zip/static/img/file-ext-ptb.png new file mode 100644 index 000000000..02aa8fe74 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-ptb.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-pub.png b/mfr/extensions/zip/static/img/file-ext-pub.png new file mode 100644 index 000000000..086c3e4bc Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-pub.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-py.png b/mfr/extensions/zip/static/img/file-ext-py.png new file mode 100644 index 000000000..81221cc27 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-py.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-qbb.png b/mfr/extensions/zip/static/img/file-ext-qbb.png new file mode 100644 index 000000000..5012020e6 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-qbb.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-qbw.png b/mfr/extensions/zip/static/img/file-ext-qbw.png new file mode 100644 index 000000000..9a1c7f383 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-qbw.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-qxd.png b/mfr/extensions/zip/static/img/file-ext-qxd.png new file mode 100644 index 000000000..04a707beb Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-qxd.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-ram.png b/mfr/extensions/zip/static/img/file-ext-ram.png new file mode 100644 index 000000000..3224bc1b2 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-ram.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-rar.png b/mfr/extensions/zip/static/img/file-ext-rar.png new file mode 100644 index 000000000..cf13a8853 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-rar.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-rm.png b/mfr/extensions/zip/static/img/file-ext-rm.png new file mode 100644 index 000000000..69afd0710 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-rm.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-rmvb.png b/mfr/extensions/zip/static/img/file-ext-rmvb.png new file mode 100644 index 000000000..94c25d829 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-rmvb.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-rtf.png b/mfr/extensions/zip/static/img/file-ext-rtf.png new file mode 100644 index 000000000..7df474d1b Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-rtf.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-sea.png b/mfr/extensions/zip/static/img/file-ext-sea.png new file mode 100644 index 000000000..7faf28579 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-sea.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-ses.png b/mfr/extensions/zip/static/img/file-ext-ses.png new file mode 100644 index 000000000..0a127f4d0 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-ses.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-sit.png b/mfr/extensions/zip/static/img/file-ext-sit.png new file mode 100644 index 000000000..0ae867371 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-sit.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-sitx.png b/mfr/extensions/zip/static/img/file-ext-sitx.png new file mode 100644 index 000000000..18ff4d82d Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-sitx.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-ss.png b/mfr/extensions/zip/static/img/file-ext-ss.png new file mode 100644 index 000000000..b5dcfcc41 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-ss.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-swf.png b/mfr/extensions/zip/static/img/file-ext-swf.png new file mode 100644 index 000000000..3b90e7036 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-swf.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-tgz.png b/mfr/extensions/zip/static/img/file-ext-tgz.png new file mode 100644 index 000000000..87d75fa50 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-tgz.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-thm.png b/mfr/extensions/zip/static/img/file-ext-thm.png new file mode 100644 index 000000000..6fc70ad01 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-thm.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-tif.png b/mfr/extensions/zip/static/img/file-ext-tif.png new file mode 100644 index 000000000..7674433ed Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-tif.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-tmp.png b/mfr/extensions/zip/static/img/file-ext-tmp.png new file mode 100644 index 000000000..23e07ae93 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-tmp.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-torrent.png b/mfr/extensions/zip/static/img/file-ext-torrent.png new file mode 100644 index 000000000..1e9f5f69b Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-torrent.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-ttf.png b/mfr/extensions/zip/static/img/file-ext-ttf.png new file mode 100644 index 000000000..626a4a184 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-ttf.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-txt.png b/mfr/extensions/zip/static/img/file-ext-txt.png new file mode 100644 index 000000000..8af23576f Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-txt.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-vcd.png b/mfr/extensions/zip/static/img/file-ext-vcd.png new file mode 100644 index 000000000..0b487709d Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-vcd.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-vob.png b/mfr/extensions/zip/static/img/file-ext-vob.png new file mode 100644 index 000000000..b3b2e1b4c Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-vob.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-wav.png b/mfr/extensions/zip/static/img/file-ext-wav.png new file mode 100644 index 000000000..122fced86 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-wav.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-wma.png b/mfr/extensions/zip/static/img/file-ext-wma.png new file mode 100644 index 000000000..605aeb6cd Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-wma.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-wmv.png b/mfr/extensions/zip/static/img/file-ext-wmv.png new file mode 100644 index 000000000..18d3b48c6 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-wmv.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-wps.png b/mfr/extensions/zip/static/img/file-ext-wps.png new file mode 100644 index 000000000..e57f08a19 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-wps.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-xls.png b/mfr/extensions/zip/static/img/file-ext-xls.png new file mode 100644 index 000000000..42446b422 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-xls.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-xlsx.png b/mfr/extensions/zip/static/img/file-ext-xlsx.png new file mode 100644 index 000000000..42446b422 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-xlsx.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-xpi.png b/mfr/extensions/zip/static/img/file-ext-xpi.png new file mode 100644 index 000000000..ce9cee583 Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-xpi.png differ diff --git a/mfr/extensions/zip/static/img/file-ext-zip.png b/mfr/extensions/zip/static/img/file-ext-zip.png new file mode 100644 index 000000000..955e2339e Binary files /dev/null and b/mfr/extensions/zip/static/img/file-ext-zip.png differ diff --git a/mfr/extensions/zip/static/img/folder.png b/mfr/extensions/zip/static/img/folder.png new file mode 100644 index 000000000..055089d05 Binary files /dev/null and b/mfr/extensions/zip/static/img/folder.png differ diff --git a/mfr/extensions/zip/static/js/jstree.min.js b/mfr/extensions/zip/static/js/jstree.min.js new file mode 100644 index 000000000..4c9b30ca3 --- /dev/null +++ b/mfr/extensions/zip/static/js/jstree.min.js @@ -0,0 +1,4 @@ +/*! jsTree - v3.0.0 - 2014-04-16 - (MIT) */ +(function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)})(function(e,t){"use strict";if(!e.jstree){var i=0,n=!1,r=!1,s=!1,a=[],o=e("script:last").attr("src"),d=document,l=d.createElement("LI"),c,h;l.setAttribute("role","treeitem"),c=d.createElement("I"),c.className="jstree-icon jstree-ocl",l.appendChild(c),c=d.createElement("A"),c.className="jstree-anchor",c.setAttribute("href","#"),h=d.createElement("I"),h.className="jstree-icon jstree-themeicon",c.appendChild(h),l.appendChild(c),c=h=null,e.jstree={version:"3.0.0",defaults:{plugins:[]},plugins:{},path:o&&-1!==o.indexOf("/")?o.replace(/\/[^\/]+$/,""):"",idregex:/[\\:&'".,=\- \/]/g},e.jstree.create=function(t,n){var r=new e.jstree.core(++i),s=n;return n=e.extend(!0,{},e.jstree.defaults,n),s&&s.plugins&&(n.plugins=s.plugins),e.each(n.plugins,function(e,t){"core"!==e&&(r=r.plugin(t,n[t]))}),r.init(t,n),r},e.jstree.core=function(e){this._id=e,this._cnt=0,this._data={core:{themes:{name:!1,dots:!1,icons:!1},selected:[],last_error:{}}}},e.jstree.reference=function(i){var n=null,r=null;if(i&&i.id&&(i=i.id),!r||!r.length)try{r=e(i)}catch(s){}if(!r||!r.length)try{r=e("#"+i.replace(e.jstree.idregex,"\\$&"))}catch(s){}return r&&r.length&&(r=r.closest(".jstree")).length&&(r=r.data("jstree"))?n=r:e(".jstree").each(function(){var r=e(this).data("jstree");return r&&r._model.data[i]?(n=r,!1):t}),n},e.fn.jstree=function(i){var n="string"==typeof i,r=Array.prototype.slice.call(arguments,1),s=null;return this.each(function(){var a=e.jstree.reference(this),o=n&&a?a[i]:null;return s=n&&o?o.apply(a,r):null,a||n||i!==t&&!e.isPlainObject(i)||e(this).data("jstree",new e.jstree.create(this,i)),(a&&!n||i===!0)&&(s=a||!1),null!==s&&s!==t?!1:t}),null!==s&&s!==t?s:this},e.expr[":"].jstree=e.expr.createPseudo(function(i){return function(i){return e(i).hasClass("jstree")&&e(i).data("jstree")!==t}}),e.jstree.defaults.core={data:!1,strings:!1,check_callback:!1,error:e.noop,animation:200,multiple:!0,themes:{name:!1,url:!1,dir:!1,dots:!0,icons:!0,stripes:!1,variant:!1,responsive:!0},expand_selected_onload:!0},e.jstree.core.prototype={plugin:function(t,i){var n=e.jstree.plugins[t];return n?(this._data[t]={},n.prototype=this,new n(i,this)):this},init:function(t,i){this._model={data:{"#":{id:"#",parent:null,parents:[],children:[],children_d:[],state:{loaded:!1}}},changed:[],force_full_redraw:!1,redraw_timeout:!1,default_state:{loaded:!0,opened:!1,selected:!1,disabled:!1}},this.element=e(t).addClass("jstree jstree-"+this._id),this.settings=i,this.element.bind("destroyed",e.proxy(this.teardown,this)),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.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._data.core.li_height=this.get_container_ul().children("li:eq(0)").height()||18,this.trigger("loading"),this.load_node("#")},destroy:function(){this.element.unbind("destroyed",this.teardown),this.teardown()},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(){this.element.on("dblclick.jstree",function(){if(document.selection&&document.selection.empty)document.selection.empty();else if(window.getSelection){var e=window.getSelection();try{e.removeAllRanges(),e.collapse()}catch(t){}}}).on("click.jstree",".jstree-ocl",e.proxy(function(e){this.toggle_node(e.target)},this)).on("click.jstree",".jstree-anchor",e.proxy(function(t){t.preventDefault(),e(t.currentTarget).focus(),this.activate_node(t.currentTarget,t)},this)).on("keydown.jstree",".jstree-anchor",e.proxy(function(t){if("INPUT"===t.target.tagName)return!0;var i=null;switch(t.which){case 13:case 32:t.type="click",e(t.currentTarget).trigger(t);break;case 37:t.preventDefault(),this.is_open(t.currentTarget)?this.close_node(t.currentTarget):(i=this.get_prev_dom(t.currentTarget),i&&i.length&&i.children(".jstree-anchor").focus());break;case 38:t.preventDefault(),i=this.get_prev_dom(t.currentTarget),i&&i.length&&i.children(".jstree-anchor").focus();break;case 39:t.preventDefault(),this.is_closed(t.currentTarget)?this.open_node(t.currentTarget,function(e){this.get_node(e,!0).children(".jstree-anchor").focus()}):(i=this.get_next_dom(t.currentTarget),i&&i.length&&i.children(".jstree-anchor").focus());break;case 40:t.preventDefault(),i=this.get_next_dom(t.currentTarget),i&&i.length&&i.children(".jstree-anchor").focus();break;case 46:t.preventDefault(),i=this.get_node(t.currentTarget),i&&i.id&&"#"!==i.id&&(i=this.is_selected(i)?this.get_selected():i);break;case 113:t.preventDefault(),i=this.get_node(t.currentTarget);break;default:}},this)).on("load_node.jstree",e.proxy(function(t,i){if(i.status&&("#"!==i.node.id||this._data.core.loaded||(this._data.core.loaded=!0,this.trigger("loaded")),!this._data.core.ready&&!this.get_container_ul().find(".jstree-loading:eq(0)").length)){if(this._data.core.ready=!0,this._data.core.selected.length){if(this.settings.core.expand_selected_onload){var n=[],r,s;for(r=0,s=this._data.core.selected.length;s>r;r++)n=n.concat(this._model.data[this._data.core.selected[r]].parents);for(n=e.vakata.array_unique(n),r=0,s=n.length;s>r;r++)this.open_node(n[r],!1,0)}this.trigger("changed",{action:"ready",selected:this._data.core.selected})}setTimeout(e.proxy(function(){this.trigger("ready")},this),0)}},this)).on("init.jstree",e.proxy(function(){var e=this.settings.core.themes;this._data.core.themes.dots=e.dots,this._data.core.themes.stripes=e.stripes,this._data.core.themes.icons=e.icons,this.set_theme(e.name||"default",e.url),this.set_theme_variant(e.variant)},this)).on("loading.jstree",e.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)).on("focus.jstree",".jstree-anchor",e.proxy(function(t){this.element.find(".jstree-hovered").not(t.currentTarget).mouseleave(),e(t.currentTarget).mouseenter()},this)).on("mouseenter.jstree",".jstree-anchor",e.proxy(function(e){this.hover_node(e.currentTarget)},this)).on("mouseleave.jstree",".jstree-anchor",e.proxy(function(e){this.dehover_node(e.currentTarget)},this))},unbind:function(){this.element.off(".jstree"),e(document).off(".jstree-"+this._id)},trigger:function(e,t){t||(t={}),t.instance=this,this.element.triggerHandler(e.replace(".jstree","")+".jstree",t)},get_container:function(){return this.element},get_container_ul:function(){return this.element.children("ul:eq(0)")},get_string:function(t){var i=this.settings.core.strings;return e.isFunction(i)?i.call(this,t):i&&i[t]?i[t]:t},_firstChild:function(e){e=e?e.firstChild:null;while(null!==e&&1!==e.nodeType)e=e.nextSibling;return e},_nextSibling:function(e){e=e?e.nextSibling:null;while(null!==e&&1!==e.nodeType)e=e.nextSibling;return e},_previousSibling:function(e){e=e?e.previousSibling:null;while(null!==e&&1!==e.nodeType)e=e.previousSibling;return e},get_node:function(t,i){t&&t.id&&(t=t.id);var n;try{if(this._model.data[t])t=this._model.data[t];else if(((n=e(t,this.element)).length||(n=e("#"+t.replace(e.jstree.idregex,"\\$&"),this.element)).length)&&this._model.data[n.closest("li").attr("id")])t=this._model.data[n.closest("li").attr("id")];else{if(!(n=e(t,this.element)).length||!n.hasClass("jstree"))return!1;t=this._model.data["#"]}return i&&(t="#"===t.id?this.element:e("#"+t.id.replace(e.jstree.idregex,"\\$&"),this.element)),t}catch(r){return!1}},get_path:function(e,t,i){if(e=e.parents?e:this.get_node(e),!e||"#"===e.id||!e.parents)return!1;var n,r,s=[];for(s.push(i?e.id:e.text),n=0,r=e.parents.length;r>n;n++)s.push(i?e.parents[n]:this.get_text(e.parents[n]));return s=s.reverse().slice(1),t?s.join(t):s},get_next_dom:function(t,i){var n;return t=this.get_node(t,!0),t[0]===this.element[0]?(n=this._firstChild(this.get_container_ul()[0]),n?e(n):!1):t&&t.length?i?(n=this._nextSibling(t[0]),n?e(n):!1):t.hasClass("jstree-open")?(n=this._firstChild(t.children("ul")[0]),n?e(n):!1):null!==(n=this._nextSibling(t[0]))?e(n):t.parentsUntil(".jstree","li").next("li").eq(0):!1},get_prev_dom:function(t,i){var n;if(t=this.get_node(t,!0),t[0]===this.element[0])return n=this.get_container_ul()[0].lastChild,n?e(n):!1;if(!t||!t.length)return!1;if(i)return n=this._previousSibling(t[0]),n?e(n):!1;if(null!==(n=this._previousSibling(t[0]))){t=e(n);while(t.hasClass("jstree-open"))t=t.children("ul:eq(0)").children("li:last");return t}return n=t[0].parentNode.parentNode,n&&"LI"===n.tagName?e(n):!1},get_parent:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.parent:!1},get_children_dom:function(e){return e=this.get_node(e,!0),e[0]===this.element[0]?this.get_container_ul().children("li"):e&&e.length?e.children("ul").children("li"):!1},is_parent:function(e){return e=this.get_node(e),e&&(e.state.loaded===!1||e.children.length>0)},is_loaded:function(e){return e=this.get_node(e),e&&e.state.loaded},is_loading:function(e){return e=this.get_node(e),e&&e.state&&e.state.loading},is_open:function(e){return e=this.get_node(e),e&&e.state.opened},is_closed:function(e){return e=this.get_node(e),e&&this.is_parent(e)&&!e.state.opened},is_leaf:function(e){return!this.is_parent(e)},load_node:function(t,i){var n,r,s,a,o,d,l;if(e.isArray(t)){for(t=t.slice(),n=0,r=t.length;r>n;n++)this.load_node(t[n],i);return!0}if(t=this.get_node(t),!t)return i&&i.call(this,t,!1),!1;if(t.state.loaded){for(t.state.loaded=!1,s=0,a=t.children_d.length;a>s;s++){for(o=0,d=t.parents.length;d>o;o++)this._model.data[t.parents[o]].children_d=e.vakata.array_remove_item(this._model.data[t.parents[o]].children_d,t.children_d[s]);this._model.data[t.children_d[s]].state.selected&&(l=!0,this._data.core.selected=e.vakata.array_remove_item(this._data.core.selected,t.children_d[s])),delete this._model.data[t.children_d[s]]}t.children=[],t.children_d=[],l&&this.trigger("changed",{action:"load_node",node:t,selected:this._data.core.selected})}return t.state.loading=!0,this.get_node(t,!0).addClass("jstree-loading"),this._load_node(t,e.proxy(function(e){t.state.loading=!1,t.state.loaded=e;var n=this.get_node(t,!0);t.state.loaded&&!t.children.length&&n&&n.length&&!n.hasClass("jstree-leaf")&&n.removeClass("jstree-closed jstree-open").addClass("jstree-leaf"),n.removeClass("jstree-loading"),this.trigger("load_node",{node:t,status:e}),i&&i.call(this,t,e)},this)),!0},_load_nodes:function(e,t,i){var n=!0,r=function(){this._load_nodes(e,t,!0)},s=this._model.data,a,o;for(a=0,o=e.length;o>a;a++)!s[e[a]]||s[e[a]].state.loaded&&i||(this.is_loading(e[a])||this.load_node(e[a],r),n=!1);n&&(t.done||(t.call(this,e),t.done=!0))},_load_node:function(t,i){var n=this.settings.core.data,r;return n?e.isFunction(n)?n.call(this,t,e.proxy(function(n){return n===!1?i.call(this,!1):i.call(this,this["string"==typeof n?"_append_html_data":"_append_json_data"](t,"string"==typeof n?e(n):n))},this)):"object"==typeof n?n.url?(n=e.extend(!0,{},n),e.isFunction(n.url)&&(n.url=n.url.call(this,t)),e.isFunction(n.data)&&(n.data=n.data.call(this,t)),e.ajax(n).done(e.proxy(function(n,r,s){var a=s.getResponseHeader("Content-Type");return-1!==a.indexOf("json")||"object"==typeof n?i.call(this,this._append_json_data(t,n)):-1!==a.indexOf("html")||"string"==typeof n?i.call(this,this._append_html_data(t,e(n))):(this._data.core.last_error={error:"ajax",plugin:"core",id:"core_04",reason:"Could not load node",data:JSON.stringify({id:t.id,xhr:s})},i.call(this,!1))},this)).fail(e.proxy(function(e){i.call(this,!1),this._data.core.last_error={error:"ajax",plugin:"core",id:"core_04",reason:"Could not load node",data:JSON.stringify({id:t.id,xhr:e})},this.settings.core.error.call(this,this._data.core.last_error)},this))):(r=e.isArray(n)||e.isPlainObject(n)?JSON.parse(JSON.stringify(n)):n,"#"!==t.id&&(this._data.core.last_error={error:"nodata",plugin:"core",id:"core_05",reason:"Could not load node",data:JSON.stringify({id:t.id})}),i.call(this,"#"===t.id?this._append_json_data(t,r):!1)):"string"==typeof n?("#"!==t.id&&(this._data.core.last_error={error:"nodata",plugin:"core",id:"core_06",reason:"Could not load node",data:JSON.stringify({id:t.id})}),i.call(this,"#"===t.id?this._append_html_data(t,e(n)):!1)):i.call(this,!1):i.call(this,"#"===t.id?this._append_html_data(t,this._data.core.original_container_html.clone(!0)):!1)},_node_changed:function(e){e=this.get_node(e),e&&this._model.changed.push(e.id)},_append_html_data:function(t,i){t=this.get_node(t),t.children=[],t.children_d=[];var n=i.is("ul")?i.children():i,r=t.id,s=[],a=[],o=this._model.data,d=o[r],l=this._data.core.selected.length,c,h,_;for(n.each(e.proxy(function(t,i){c=this._parse_model_from_html(e(i),r,d.parents.concat()),c&&(s.push(c),a.push(c),o[c].children_d.length&&(a=a.concat(o[c].children_d)))},this)),d.children=s,d.children_d=a,h=0,_=d.parents.length;_>h;h++)o[d.parents[h]].children_d=o[d.parents[h]].children_d.concat(a);return this.trigger("model",{nodes:a,parent:r}),"#"!==r?(this._node_changed(r),this.redraw()):(this.get_container_ul().children(".jstree-initial-node").remove(),this.redraw(!0)),this._data.core.selected.length!==l&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),!0},_append_json_data:function(i,n){i=this.get_node(i),i.children=[],i.children_d=[];var r=n,s=i.id,a=[],o=[],d=this._model.data,l=d[s],c=this._data.core.selected.length,h,_,u;if(r.d&&(r=r.d,"string"==typeof r&&(r=JSON.parse(r))),e.isArray(r)||(r=[r]),r.length&&r[0].id!==t&&r[0].parent!==t){for(_=0,u=r.length;u>_;_++)r[_].children||(r[_].children=[]),d[""+r[_].id]=r[_];for(_=0,u=r.length;u>_;_++)d[""+r[_].parent].children.push(""+r[_].id),l.children_d.push(""+r[_].id);for(_=0,u=l.children.length;u>_;_++)h=this._parse_model_from_flat_json(d[l.children[_]],s,l.parents.concat()),o.push(h),d[h].children_d.length&&(o=o.concat(d[h].children_d))}else{for(_=0,u=r.length;u>_;_++)h=this._parse_model_from_json(r[_],s,l.parents.concat()),h&&(a.push(h),o.push(h),d[h].children_d.length&&(o=o.concat(d[h].children_d)));for(l.children=a,l.children_d=o,_=0,u=l.parents.length;u>_;_++)d[l.parents[_]].children_d=d[l.parents[_]].children_d.concat(o)}return this.trigger("model",{nodes:o,parent:s}),"#"!==s?(this._node_changed(s),this.redraw()):this.redraw(!0),this._data.core.selected.length!==c&&this.trigger("changed",{action:"model",selected:this._data.core.selected}),!0},_parse_model_from_html:function(i,n,r){r=r?[].concat(r):[],n&&r.unshift(n);var s,a,o=this._model.data,d={id:!1,text:!1,icon:!0,parent:n,parents:r,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1},l,c,h;for(l in this._model.default_state)this._model.default_state.hasOwnProperty(l)&&(d.state[l]=this._model.default_state[l]);if(c=e.vakata.attributes(i,!0),e.each(c,function(i,n){return n=e.trim(n),n.length?(d.li_attr[i]=n,"id"===i&&(d.id=""+n),t):!0}),c=i.children("a").eq(0),c.length&&(c=e.vakata.attributes(c,!0),e.each(c,function(t,i){i=e.trim(i),i.length&&(d.a_attr[t]=i)})),c=i.children("a:eq(0)").length?i.children("a:eq(0)").clone():i.clone(),c.children("ins, i, ul").remove(),c=c.html(),c=e("
").html(c),d.text=c.html(),c=i.data(),d.data=c?e.extend(!0,{},c):null,d.state.opened=i.hasClass("jstree-open"),d.state.selected=i.children("a").hasClass("jstree-clicked"),d.state.disabled=i.children("a").hasClass("jstree-disabled"),d.data&&d.data.jstree)for(l in d.data.jstree)d.data.jstree.hasOwnProperty(l)&&(d.state[l]=d.data.jstree[l]);c=i.children("a").children(".jstree-themeicon"),c.length&&(d.icon=c.hasClass("jstree-themeicon-hidden")?!1:c.attr("rel")),d.state.icon&&(d.icon=d.state.icon),c=i.children("ul").children("li");do h="j"+this._id+"_"+ ++this._cnt;while(o[h]);return d.id=d.li_attr.id?""+d.li_attr.id:h,c.length?(c.each(e.proxy(function(t,i){s=this._parse_model_from_html(e(i),d.id,r),a=this._model.data[s],d.children.push(s),a.children_d.length&&(d.children_d=d.children_d.concat(a.children_d))},this)),d.children_d=d.children_d.concat(d.children)):i.hasClass("jstree-closed")&&(d.state.loaded=!1),d.li_attr["class"]&&(d.li_attr["class"]=d.li_attr["class"].replace("jstree-closed","").replace("jstree-open","")),d.a_attr["class"]&&(d.a_attr["class"]=d.a_attr["class"].replace("jstree-clicked","").replace("jstree-disabled","")),o[d.id]=d,d.state.selected&&this._data.core.selected.push(d.id),d.id},_parse_model_from_flat_json:function(e,i,n){n=n?n.concat():[],i&&n.unshift(i);var r=""+e.id,s=this._model.data,a=this._model.default_state,o,d,l,c,h={id:r,text:e.text||"",icon:e.icon!==t?e.icon:!0,parent:i,parents:n,children:e.children||[],children_d:e.children_d||[],data:e.data,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(o in a)a.hasOwnProperty(o)&&(h.state[o]=a[o]);if(e&&e.data&&e.data.jstree&&e.data.jstree.icon&&(h.icon=e.data.jstree.icon),e&&e.data&&(h.data=e.data,e.data.jstree))for(o in e.data.jstree)e.data.jstree.hasOwnProperty(o)&&(h.state[o]=e.data.jstree[o]);if(e&&"object"==typeof e.state)for(o in e.state)e.state.hasOwnProperty(o)&&(h.state[o]=e.state[o]);if(e&&"object"==typeof e.li_attr)for(o in e.li_attr)e.li_attr.hasOwnProperty(o)&&(h.li_attr[o]=e.li_attr[o]);if(h.li_attr.id||(h.li_attr.id=r),e&&"object"==typeof e.a_attr)for(o in e.a_attr)e.a_attr.hasOwnProperty(o)&&(h.a_attr[o]=e.a_attr[o]);for(e&&e.children&&e.children===!0&&(h.state.loaded=!1,h.children=[],h.children_d=[]),s[h.id]=h,o=0,d=h.children.length;d>o;o++)l=this._parse_model_from_flat_json(s[h.children[o]],h.id,n),c=s[l],h.children_d.push(l),c.children_d.length&&(h.children_d=h.children_d.concat(c.children_d));return delete e.data,delete e.children,s[h.id].original=e,h.state.selected&&this._data.core.selected.push(h.id),h.id},_parse_model_from_json:function(e,i,n){n=n?n.concat():[],i&&n.unshift(i);var r=!1,s,a,o,d,l=this._model.data,c=this._model.default_state,h;do r="j"+this._id+"_"+ ++this._cnt;while(l[r]);h={id:!1,text:"string"==typeof e?e:"",icon:"object"==typeof e&&e.icon!==t?e.icon:!0,parent:i,parents:n,children:[],children_d:[],data:null,state:{},li_attr:{id:!1},a_attr:{href:"#"},original:!1};for(s in c)c.hasOwnProperty(s)&&(h.state[s]=c[s]);if(e&&e.id&&(h.id=""+e.id),e&&e.text&&(h.text=e.text),e&&e.data&&e.data.jstree&&e.data.jstree.icon&&(h.icon=e.data.jstree.icon),e&&e.data&&(h.data=e.data,e.data.jstree))for(s in e.data.jstree)e.data.jstree.hasOwnProperty(s)&&(h.state[s]=e.data.jstree[s]);if(e&&"object"==typeof e.state)for(s in e.state)e.state.hasOwnProperty(s)&&(h.state[s]=e.state[s]);if(e&&"object"==typeof e.li_attr)for(s in e.li_attr)e.li_attr.hasOwnProperty(s)&&(h.li_attr[s]=e.li_attr[s]);if(h.li_attr.id&&!h.id&&(h.id=""+h.li_attr.id),h.id||(h.id=r),h.li_attr.id||(h.li_attr.id=h.id),e&&"object"==typeof e.a_attr)for(s in e.a_attr)e.a_attr.hasOwnProperty(s)&&(h.a_attr[s]=e.a_attr[s]);if(e&&e.children&&e.children.length){for(s=0,a=e.children.length;a>s;s++)o=this._parse_model_from_json(e.children[s],h.id,n),d=l[o],h.children.push(o),d.children_d.length&&(h.children_d=h.children_d.concat(d.children_d));h.children_d=h.children_d.concat(h.children)}return e&&e.children&&e.children===!0&&(h.state.loaded=!1,h.children=[],h.children_d=[]),delete e.data,delete e.children,h.original=e,l[h.id]=h,h.state.selected&&this._data.core.selected.push(h.id),h.id},_redraw:function(){var e=this._model.force_full_redraw?this._model.data["#"].children.concat([]):this._model.changed.concat([]),t=document.createElement("UL"),i,n,r;for(n=0,r=e.length;r>n;n++)i=this.redraw_node(e[n],!0,this._model.force_full_redraw),i&&this._model.force_full_redraw&&t.appendChild(i);this._model.force_full_redraw&&(t.className=this.get_container_ul()[0].className,this.element.empty().append(t)),this._model.force_full_redraw=!1,this._model.changed=[],this.trigger("redraw",{nodes:e})},redraw:function(e){e&&(this._model.force_full_redraw=!0),this._redraw()},redraw_node:function(t,i,n){var r=this.get_node(t),s=!1,a=!1,o=!1,d=!1,c=!1,h=!1,_="",u=document,g=this._model.data,f=!1,p=!1;if(!r)return!1;if("#"===r.id)return this.redraw(!0);if(i=i||0===r.children.length,t=document.querySelector?this.element[0].querySelector("#"+(-1!=="0123456789".indexOf(r.id[0])?"\\3"+r.id[0]+" "+r.id.substr(1).replace(e.jstree.idregex,"\\$&"):r.id.replace(e.jstree.idregex,"\\$&"))):document.getElementById(r.id))t=e(t),n||(s=t.parent().parent()[0],s===this.element[0]&&(s=null),a=t.index()),i||!r.children.length||t.children("ul").length||(i=!0),i||(o=t.children("UL")[0]),p=t.attr("aria-selected"),f=t.children(".jstree-anchor")[0]===document.activeElement,t.remove();else if(i=!0,!n){if(s="#"!==r.parent?e("#"+r.parent.replace(e.jstree.idregex,"\\$&"),this.element)[0]:null,!(null===s||s&&g[r.parent].state.opened))return!1;a=e.inArray(r.id,null===s?g["#"].children:g[r.parent].children)}t=l.cloneNode(!0),_="jstree-node ";for(d in r.li_attr)if(r.li_attr.hasOwnProperty(d)){if("id"===d)continue;"class"!==d?t.setAttribute(d,r.li_attr[d]):_+=r.li_attr[d]}p&&"false"!==p&&t.setAttribute("aria-selected",!0),r.state.loaded&&!r.children.length?_+=" jstree-leaf":(_+=r.state.opened&&r.state.loaded?" jstree-open":" jstree-closed",t.setAttribute("aria-expanded",r.state.opened&&r.state.loaded)),null!==r.parent&&g[r.parent].children[g[r.parent].children.length-1]===r.id&&(_+=" jstree-last"),t.id=r.id,t.className=_,_=(r.state.selected?" jstree-clicked":"")+(r.state.disabled?" jstree-disabled":"");for(c in r.a_attr)if(r.a_attr.hasOwnProperty(c)){if("href"===c&&"#"===r.a_attr[c])continue;"class"!==c?t.childNodes[1].setAttribute(c,r.a_attr[c]):_+=" "+r.a_attr[c]}if(_.length&&(t.childNodes[1].className="jstree-anchor "+_),(r.icon&&r.icon!==!0||r.icon===!1)&&(r.icon===!1?t.childNodes[1].childNodes[0].className+=" jstree-themeicon-hidden":-1===r.icon.indexOf("/")&&-1===r.icon.indexOf(".")?t.childNodes[1].childNodes[0].className+=" "+r.icon+" jstree-themeicon-custom":(t.childNodes[1].childNodes[0].style.backgroundImage="url("+r.icon+")",t.childNodes[1].childNodes[0].style.backgroundPosition="center center",t.childNodes[1].childNodes[0].style.backgroundSize="auto",t.childNodes[1].childNodes[0].className+=" jstree-themeicon-custom")),t.childNodes[1].innerHTML+=r.text,i&&r.children.length&&r.state.opened&&r.state.loaded){for(h=u.createElement("UL"),h.setAttribute("role","group"),h.className="jstree-children",d=0,c=r.children.length;c>d;d++)h.appendChild(this.redraw_node(r.children[d],i,!0));t.appendChild(h)}return o&&t.appendChild(o),n||(s||(s=this.element[0]),s.getElementsByTagName("UL").length?s=s.getElementsByTagName("UL")[0]:(d=u.createElement("UL"),d.setAttribute("role","group"),d.className="jstree-children",s.appendChild(d),s=d),s.childNodes.length>a?s.insertBefore(t,s.childNodes[a]):s.appendChild(t),f&&t.childNodes[1].focus()),r.state.opened&&!r.state.loaded&&(r.state.opened=!1,setTimeout(e.proxy(function(){this.open_node(r.id,!1,0)},this),0)),t},open_node:function(i,n,r){var s,a,o,d;if(e.isArray(i)){for(i=i.slice(),s=0,a=i.length;a>s;s++)this.open_node(i[s],n,r);return!0}if(i=this.get_node(i),!i||"#"===i.id)return!1;if(r=r===t?this.settings.core.animation:r,!this.is_closed(i))return n&&n.call(this,i,!1),!1;if(this.is_loaded(i))o=this.get_node(i,!0),d=this,o.length&&(i.children.length&&!this._firstChild(o.children("ul")[0])&&(i.state.opened=!0,this.redraw_node(i,!0),o=this.get_node(i,!0)),r?(this.trigger("before_open",{node:i}),o.children("ul").css("display","none").end().removeClass("jstree-closed").addClass("jstree-open").attr("aria-expanded",!0).children("ul").stop(!0,!0).slideDown(r,function(){this.style.display="",d.trigger("after_open",{node:i})})):(this.trigger("before_open",{node:i}),o[0].className=o[0].className.replace("jstree-closed","jstree-open"),o[0].setAttribute("aria-expanded",!0))),i.state.opened=!0,n&&n.call(this,i,!0),o.length||this.trigger("before_open",{node:i}),this.trigger("open_node",{node:i}),r&&o.length||this.trigger("after_open",{node:i});else{if(this.is_loading(i))return setTimeout(e.proxy(function(){this.open_node(i,n,r)},this),500);this.load_node(i,function(e,t){return t?this.open_node(e,n,r):n?n.call(this,e,!1):!1})}},_open_to:function(t){if(t=this.get_node(t),!t||"#"===t.id)return!1;var i,n,r=t.parents;for(i=0,n=r.length;n>i;i+=1)"#"!==i&&this.open_node(r[i],!1,0);return e("#"+t.id.replace(e.jstree.idregex,"\\$&"),this.element)},close_node:function(i,n){var r,s,a,o;if(e.isArray(i)){for(i=i.slice(),r=0,s=i.length;s>r;r++)this.close_node(i[r],n);return!0}return i=this.get_node(i),i&&"#"!==i.id?this.is_closed(i)?!1:(n=n===t?this.settings.core.animation:n,a=this,o=this.get_node(i,!0),o.length&&(n?o.children("ul").attr("style","display:block !important").end().removeClass("jstree-open").addClass("jstree-closed").attr("aria-expanded",!1).children("ul").stop(!0,!0).slideUp(n,function(){this.style.display="",o.children("ul").remove(),a.trigger("after_close",{node:i})}):(o[0].className=o[0].className.replace("jstree-open","jstree-closed"),o.attr("aria-expanded",!1).children("ul").remove())),i.state.opened=!1,this.trigger("close_node",{node:i}),n&&o.length||this.trigger("after_close",{node:i}),t):!1},toggle_node:function(i){var n,r;if(e.isArray(i)){for(i=i.slice(),n=0,r=i.length;r>n;n++)this.toggle_node(i[n]);return!0}return this.is_closed(i)?this.open_node(i):this.is_open(i)?this.close_node(i):t},open_all:function(e,t,i){if(e||(e="#"),e=this.get_node(e),!e)return!1;var n="#"===e.id?this.get_container_ul():this.get_node(e,!0),r,s,a;if(!n.length){for(r=0,s=e.children_d.length;s>r;r++)this.is_closed(this._model.data[e.children_d[r]])&&(this._model.data[e.children_d[r]].state.opened=!0);return this.trigger("open_all",{node:e})}i=i||n,a=this,n=this.is_closed(e)?n.find("li.jstree-closed").addBack():n.find("li.jstree-closed"),n.each(function(){a.open_node(this,function(e,n){n&&this.is_parent(e)&&this.open_all(e,t,i)},t||0)}),0===i.find("li.jstree-closed").length&&this.trigger("open_all",{node:this.get_node(i)})},close_all:function(t,i){if(t||(t="#"),t=this.get_node(t),!t)return!1;var n="#"===t.id?this.get_container_ul():this.get_node(t,!0),r=this,s,a;if(!n.length){for(s=0,a=t.children_d.length;a>s;s++)this._model.data[t.children_d[s]].state.opened=!1;return this.trigger("close_all",{node:t})}n=this.is_open(t)?n.find("li.jstree-open").addBack():n.find("li.jstree-open"),e(n.get().reverse()).each(function(){r.close_node(this,i||0)}),this.trigger("close_all",{node:t})},is_disabled:function(e){return e=this.get_node(e),e&&e.state&&e.state.disabled},enable_node:function(i){var n,r;if(e.isArray(i)){for(i=i.slice(),n=0,r=i.length;r>n;n++)this.enable_node(i[n]);return!0}return i=this.get_node(i),i&&"#"!==i.id?(i.state.disabled=!1,this.get_node(i,!0).children(".jstree-anchor").removeClass("jstree-disabled"),this.trigger("enable_node",{node:i}),t):!1},disable_node:function(i){var n,r;if(e.isArray(i)){for(i=i.slice(),n=0,r=i.length;r>n;n++)this.disable_node(i[n]);return!0}return i=this.get_node(i),i&&"#"!==i.id?(i.state.disabled=!0,this.get_node(i,!0).children(".jstree-anchor").addClass("jstree-disabled"),this.trigger("disable_node",{node:i}),t):!1},activate_node:function(e,i){if(this.is_disabled(e))return!1;if(this._data.core.last_clicked=this._data.core.last_clicked&&this._data.core.last_clicked.id!==t?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&&(i.metaKey||i.ctrlKey||i.shiftKey)&&(!i.shiftKey||this._data.core.last_clicked&&this.get_parent(e)&&this.get_parent(e)===this._data.core.last_clicked.parent))if(i.shiftKey){var n=this.get_node(e).id,r=this._data.core.last_clicked.id,s=this.get_node(this._data.core.last_clicked.parent).children,a=!1,o,d;for(o=0,d=s.length;d>o;o+=1)s[o]===n&&(a=!a),s[o]===r&&(a=!a),a||s[o]===n||s[o]===r?this.select_node(s[o],!1,!1,i):this.deselect_node(s[o],!1,!1,i)}else this.is_selected(e)?this.deselect_node(e,!1,!1,i):this.select_node(e,!1,!1,i);else!this.settings.core.multiple&&(i.metaKey||i.ctrlKey||i.shiftKey)&&this.is_selected(e)?this.deselect_node(e,!1,!1,i):(this.deselect_all(!0),this.select_node(e,!1,!1,i),this._data.core.last_clicked=this.get_node(e));this.trigger("activate_node",{node:this.get_node(e)})},hover_node:function(e){if(e=this.get_node(e,!0),!e||!e.length||e.children(".jstree-hovered").length)return!1;var t=this.element.find(".jstree-hovered"),i=this.element;t&&t.length&&this.dehover_node(t),e.children(".jstree-anchor").addClass("jstree-hovered"),this.trigger("hover_node",{node:this.get_node(e)}),setTimeout(function(){i.attr("aria-activedescendant",e[0].id),e.attr("aria-selected",!0)},0)},dehover_node:function(e){return e=this.get_node(e,!0),e&&e.length&&e.children(".jstree-hovered").length?(e.attr("aria-selected",!1).children(".jstree-anchor").removeClass("jstree-hovered"),this.trigger("dehover_node",{node:this.get_node(e)}),t):!1},select_node:function(i,n,r,s){var a,o,d,l;if(e.isArray(i)){for(i=i.slice(),o=0,d=i.length;d>o;o++)this.select_node(i[o],n,r,s);return!0}return i=this.get_node(i),i&&"#"!==i.id?(a=this.get_node(i,!0),i.state.selected||(i.state.selected=!0,this._data.core.selected.push(i.id),r||(a=this._open_to(i)),a&&a.length&&a.children(".jstree-anchor").addClass("jstree-clicked"),this.trigger("select_node",{node:i,selected:this._data.core.selected,event:s}),n||this.trigger("changed",{action:"select_node",node:i,selected:this._data.core.selected,event:s})),t):!1},deselect_node:function(i,n,r){var s,a,o;if(e.isArray(i)){for(i=i.slice(),s=0,a=i.length;a>s;s++)this.deselect_node(i[s],n,r);return!0}return i=this.get_node(i),i&&"#"!==i.id?(o=this.get_node(i,!0),i.state.selected&&(i.state.selected=!1,this._data.core.selected=e.vakata.array_remove_item(this._data.core.selected,i.id),o.length&&o.children(".jstree-anchor").removeClass("jstree-clicked"),this.trigger("deselect_node",{node:i,selected:this._data.core.selected,event:r}),n||this.trigger("changed",{action:"deselect_node",node:i,selected:this._data.core.selected,event:r})),t):!1},select_all:function(e){var t=this._data.core.selected.concat([]),i,n;for(this._data.core.selected=this._model.data["#"].children_d.concat(),i=0,n=this._data.core.selected.length;n>i;i++)this._model.data[this._data.core.selected[i]]&&(this._model.data[this._data.core.selected[i]].state.selected=!0);this.redraw(!0),this.trigger("select_all",{selected:this._data.core.selected}),e||this.trigger("changed",{action:"select_all",selected:this._data.core.selected,old_selection:t})},deselect_all:function(e){var t=this._data.core.selected.concat([]),i,n;for(i=0,n=this._data.core.selected.length;n>i;i++)this._model.data[this._data.core.selected[i]]&&(this._model.data[this._data.core.selected[i]].state.selected=!1);this._data.core.selected=[],this.element.find(".jstree-clicked").removeClass("jstree-clicked"),this.trigger("deselect_all",{selected:this._data.core.selected,node:t}),e||this.trigger("changed",{action:"deselect_all",selected:this._data.core.selected,old_selection:t})},is_selected:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.state.selected:!1},get_selected:function(t){return t?e.map(this._data.core.selected,e.proxy(function(e){return this.get_node(e) +},this)):this._data.core.selected},get_top_selected:function(t){var i=this.get_selected(!0),n={},r,s,a,o;for(r=0,s=i.length;s>r;r++)n[i[r].id]=i[r];for(r=0,s=i.length;s>r;r++)for(a=0,o=i[r].children_d.length;o>a;a++)n[i[r].children_d[a]]&&delete n[i[r].children_d[a]];i=[];for(r in n)n.hasOwnProperty(r)&&i.push(r);return t?e.map(i,e.proxy(function(e){return this.get_node(e)},this)):i},get_bottom_selected:function(t){var i=this.get_selected(!0),n=[],r,s;for(r=0,s=i.length;s>r;r++)i[r].children.length||n.push(i[r].id);return t?e.map(n,e.proxy(function(e){return this.get_node(e)},this)):n},get_state:function(){var e={core:{open:[],scroll:{left:this.element.scrollLeft(),top:this.element.scrollTop()},selected:[]}},t;for(t in this._model.data)this._model.data.hasOwnProperty(t)&&"#"!==t&&(this._model.data[t].state.opened&&e.core.open.push(t),this._model.data[t].state.selected&&e.core.selected.push(t));return e},set_state:function(i,n){if(i){if(i.core){var r,s,a,o;if(i.core.open)return e.isArray(i.core.open)?(r=!0,s=!1,a=this,e.each(i.core.open.concat([]),function(t,o){s=a.get_node(o),s&&(a.is_loaded(o)?(a.is_closed(o)&&a.open_node(o,!1,0),i&&i.core&&i.core.open&&e.vakata.array_remove_item(i.core.open,o)):(a.is_loading(o)||a.open_node(o,e.proxy(function(t,r){!r&&i&&i.core&&i.core.open&&e.vakata.array_remove_item(i.core.open,t.id),this.set_state(i,n)},a),0),r=!1))}),r&&(delete i.core.open,this.set_state(i,n)),!1):(delete i.core.open,this.set_state(i,n),!1);if(i.core.scroll)return i.core.scroll&&i.core.scroll.left!==t&&this.element.scrollLeft(i.core.scroll.left),i.core.scroll&&i.core.scroll.top!==t&&this.element.scrollTop(i.core.scroll.top),delete i.core.scroll,this.set_state(i,n),!1;if(i.core.selected)return o=this,this.deselect_all(),e.each(i.core.selected,function(e,t){o.select_node(t)}),delete i.core.selected,this.set_state(i,n),!1;if(e.isEmptyObject(i.core))return delete i.core,this.set_state(i,n),!1}return e.isEmptyObject(i)?(i=null,n&&n.call(this),this.trigger("set_state"),!1):!0}return!1},refresh:function(t){this._data.core.state=this.get_state(),this._cnt=0,this._model.data={"#":{id:"#",parent:null,parents:[],children:[],children_d:[],state:{loaded:!1}}};var i=this.get_container_ul()[0].className;t||this.element.html(""),this.load_node("#",function(t,n){n&&(this.get_container_ul()[0].className=i,this.set_state(e.extend(!0,{},this._data.core.state),function(){this.trigger("refresh")})),this._data.core.state=null})},refresh_node:function(t){if(t=this.get_node(t),!t||"#"===t.id)return!1;var i=[],n=this._data.core.selected.concat([]);t.state.opened===!0&&i.push(t.id),this.get_node(t,!0).find(".jstree-open").each(function(){i.push(this.id)}),this._load_nodes(i,e.proxy(function(e){this.open_node(e,!1,0),this.select_node(this._data.core.selected),this.trigger("refresh_node",{node:t,nodes:e})},this))},set_id:function(t,i){if(t=this.get_node(t),!t||"#"===t.id)return!1;var n,r,s=this._model.data;for(i=""+i,s[t.parent].children[e.inArray(t.id,s[t.parent].children)]=i,n=0,r=t.parents.length;r>n;n++)s[t.parents[n]].children_d[e.inArray(t.id,s[t.parents[n]].children_d)]=i;for(n=0,r=t.children.length;r>n;n++)s[t.children[n]].parent=i;for(n=0,r=t.children_d.length;r>n;n++)s[t.children_d[n]].parents[e.inArray(t.id,s[t.children_d[n]].parents)]=i;return n=e.inArray(t.id,this._data.core.selected),-1!==n&&(this._data.core.selected[n]=i),n=this.get_node(t.id,!0),n&&n.attr("id",i),delete s[t.id],t.id=i,s[i]=t,!0},get_text:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.text:!1},set_text:function(t,i){var n,r,s,a;if(e.isArray(t)){for(t=t.slice(),n=0,r=t.length;r>n;n++)this.set_text(t[n],i);return!0}return t=this.get_node(t),t&&"#"!==t.id?(t.text=i,s=this.get_node(t,!0),s.length&&(s=s.children(".jstree-anchor:eq(0)"),a=s.children("I").clone(),s.html(i).prepend(a),this.trigger("set_text",{obj:t,text:i})),!0):!1},get_json:function(e,t,i){if(e=this.get_node(e||"#"),!e)return!1;t&&t.flat&&!i&&(i=[]);var n={id:e.id,text:e.text,icon:this.get_icon(e),li_attr:e.li_attr,a_attr:e.a_attr,state:{},data:t&&t.no_data?!1:e.data},r,s;if(t&&t.flat?n.parent=e.parent:n.children=[],!t||!t.no_state)for(r in e.state)e.state.hasOwnProperty(r)&&(n.state[r]=e.state[r]);if(t&&t.no_id&&(delete n.id,n.li_attr&&n.li_attr.id&&delete n.li_attr.id),t&&t.flat&&"#"!==e.id&&i.push(n),!t||!t.no_children)for(r=0,s=e.children.length;s>r;r++)t&&t.flat?this.get_json(e.children[r],t,i):n.children.push(this.get_json(e.children[r],t));return t&&t.flat?i:"#"===e.id?n.children:n},create_node:function(i,n,r,s,a){if(null===i&&(i="#"),i=this.get_node(i),!i)return!1;if(r=r===t?"last":r,!(""+r).match(/^(before|after)$/)&&!a&&!this.is_loaded(i))return this.load_node(i,function(){this.create_node(i,n,r,s,!0)});n||(n={text:this.get_string("New node")}),n.text===t&&(n.text=this.get_string("New node"));var o,d,l,c;switch("#"===i.id&&("before"===r&&(r="first"),"after"===r&&(r="last")),r){case"before":o=this.get_node(i.parent),r=e.inArray(i.id,o.children),i=o;break;case"after":o=this.get_node(i.parent),r=e.inArray(i.id,o.children)+1,i=o;break;case"inside":case"first":r=0;break;case"last":r=i.children.length;break;default:r||(r=0)}if(r>i.children.length&&(r=i.children.length),n.id||(n.id=!0),!this.check("create_node",n,i,r))return this.settings.core.error.call(this,this._data.core.last_error),!1;if(n.id===!0&&delete n.id,n=this._parse_model_from_json(n,i.id,i.parents.concat()),!n)return!1;for(o=this.get_node(n),d=[],d.push(n),d=d.concat(o.children_d),this.trigger("model",{nodes:d,parent:i.id}),i.children_d=i.children_d.concat(d),l=0,c=i.parents.length;c>l;l++)this._model.data[i.parents[l]].children_d=this._model.data[i.parents[l]].children_d.concat(d);for(n=o,o=[],l=0,c=i.children.length;c>l;l++)o[l>=r?l+1:l]=i.children[l];return o[r]=n.id,i.children=o,this.redraw_node(i,!0),s&&s.call(this,this.get_node(n)),this.trigger("create_node",{node:this.get_node(n),parent:i.id,position:r}),n.id},rename_node:function(t,i){var n,r,s;if(e.isArray(t)){for(t=t.slice(),n=0,r=t.length;r>n;n++)this.rename_node(t[n],i);return!0}return t=this.get_node(t),t&&"#"!==t.id?(s=t.text,this.check("rename_node",t,this.get_parent(t),i)?(this.set_text(t,i),this.trigger("rename_node",{node:t,text:i,old:s}),!0):(this.settings.core.error.call(this,this._data.core.last_error),!1)):!1},delete_node:function(t){var i,n,r,s,a,o,d,l,c,h;if(e.isArray(t)){for(t=t.slice(),i=0,n=t.length;n>i;i++)this.delete_node(t[i]);return!0}if(t=this.get_node(t),!t||"#"===t.id)return!1;if(r=this.get_node(t.parent),s=e.inArray(t.id,r.children),h=!1,!this.check("delete_node",t,r,s))return this.settings.core.error.call(this,this._data.core.last_error),!1;for(-1!==s&&(r.children=e.vakata.array_remove(r.children,s)),a=t.children_d.concat([]),a.push(t.id),l=0,c=a.length;c>l;l++){for(o=0,d=t.parents.length;d>o;o++)s=e.inArray(a[l],this._model.data[t.parents[o]].children_d),-1!==s&&(this._model.data[t.parents[o]].children_d=e.vakata.array_remove(this._model.data[t.parents[o]].children_d,s));this._model.data[a[l]].state.selected&&(h=!0,s=e.inArray(a[l],this._data.core.selected),-1!==s&&(this._data.core.selected=e.vakata.array_remove(this._data.core.selected,s)))}for(this.trigger("delete_node",{node:t,parent:r.id}),h&&this.trigger("changed",{action:"delete_node",node:t,selected:this._data.core.selected,parent:r.id}),l=0,c=a.length;c>l;l++)delete this._model.data[a[l]];return this.redraw_node(r,!0),!0},check:function(t,i,n,r,s){i=i&&i.id?i:this.get_node(i),n=n&&n.id?n:this.get_node(n);var a=t.match(/^move_node|copy_node|create_node$/i)?n:i,o=this.settings.core.check_callback;return"move_node"!==t&&"copy_node"!==t||s&&s.is_multi||i.id!==n.id&&e.inArray(i.id,n.children)!==r&&-1===e.inArray(n.id,i.children_d)?(a&&a.data&&(a=a.data),a&&a.functions&&(a.functions[t]===!1||a.functions[t]===!0)?(a.functions[t]===!1&&(this._data.core.last_error={error:"check",plugin:"core",id:"core_02",reason:"Node data prevents function: "+t,data:JSON.stringify({chk:t,pos:r,obj:i&&i.id?i.id:!1,par:n&&n.id?n.id:!1})}),a.functions[t]):o===!1||e.isFunction(o)&&o.call(this,t,i,n,r,s)===!1||o&&o[t]===!1?(this._data.core.last_error={error:"check",plugin:"core",id:"core_03",reason:"User config for core.check_callback prevents function: "+t,data:JSON.stringify({chk:t,pos:r,obj:i&&i.id?i.id:!1,par:n&&n.id?n.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:t,pos:r,obj:i&&i.id?i.id:!1,par:n&&n.id?n.id:!1})},!1)},last_error:function(){return this._data.core.last_error},move_node:function(i,n,r,s,a){var o,d,l,c,h,_,u,g,f,p,m,v,y;if(e.isArray(i)){for(i=i.reverse().slice(),o=0,d=i.length;d>o;o++)this.move_node(i[o],n,r,s,a);return!0}if(i=i&&i.id?i:this.get_node(i),n=this.get_node(n),r=r===t?0:r,!n||!i||"#"===i.id)return!1;if(!(""+r).match(/^(before|after)$/)&&!a&&!this.is_loaded(n))return this.load_node(n,function(){this.move_node(i,n,r,s,!0)});if(l=""+(i.parent||"#"),c=(""+r).match(/^(before|after)$/)&&"#"!==n.id?this.get_node(n.parent):n,h=i.instance?i.instance:this._model.data[i.id]?this:e.jstree.reference(i.id),_=!h||!h._id||this._id!==h._id)return this.copy_node(i,n,r,s,a)?(h&&h.delete_node(i),!0):!1;switch("#"===c.id&&("before"===r&&(r="first"),"after"===r&&(r="last")),r){case"before":r=e.inArray(n.id,c.children);break;case"after":r=e.inArray(n.id,c.children)+1;break;case"inside":case"first":r=0;break;case"last":r=c.children.length;break;default:r||(r=0)}if(r>c.children.length&&(r=c.children.length),!this.check("move_node",i,c,r,{core:!0,is_multi:h&&h._id&&h._id!==this._id,is_foreign:!h||!h._id}))return this.settings.core.error.call(this,this._data.core.last_error),!1;if(i.parent===c.id){for(u=c.children.concat(),g=e.inArray(i.id,u),-1!==g&&(u=e.vakata.array_remove(u,g),r>g&&r--),g=[],f=0,p=u.length;p>f;f++)g[f>=r?f+1:f]=u[f];g[r]=i.id,c.children=g,this._node_changed(c.id),this.redraw("#"===c.id)}else{for(g=i.children_d.concat(),g.push(i.id),f=0,p=i.parents.length;p>f;f++){for(u=[],y=h._model.data[i.parents[f]].children_d,m=0,v=y.length;v>m;m++)-1===e.inArray(y[m],g)&&u.push(y[m]);h._model.data[i.parents[f]].children_d=u}for(h._model.data[l].children=e.vakata.array_remove_item(h._model.data[l].children,i.id),f=0,p=c.parents.length;p>f;f++)this._model.data[c.parents[f]].children_d=this._model.data[c.parents[f]].children_d.concat(g);for(u=[],f=0,p=c.children.length;p>f;f++)u[f>=r?f+1:f]=c.children[f];for(u[r]=i.id,c.children=u,c.children_d.push(i.id),c.children_d=c.children_d.concat(i.children_d),i.parent=c.id,g=c.parents.concat(),g.unshift(c.id),y=i.parents.length,i.parents=g,g=g.concat(),f=0,p=i.children_d.length;p>f;f++)this._model.data[i.children_d[f]].parents=this._model.data[i.children_d[f]].parents.slice(0,-1*y),Array.prototype.push.apply(this._model.data[i.children_d[f]].parents,g);this._node_changed(l),this._node_changed(c.id),this.redraw("#"===l||"#"===c.id)}return s&&s.call(this,i,c,r),this.trigger("move_node",{node:i,parent:c.id,position:r,old_parent:l,is_multi:h&&h._id&&h._id!==this._id,is_foreign:!h||!h._id,old_instance:h,new_instance:this}),!0},copy_node:function(i,n,r,s,a){var o,d,l,c,h,_,u,g,f,p,m;if(e.isArray(i)){for(i=i.reverse().slice(),o=0,d=i.length;d>o;o++)this.copy_node(i[o],n,r,s,a);return!0}if(i=i&&i.id?i:this.get_node(i),n=this.get_node(n),r=r===t?0:r,!n||!i||"#"===i.id)return!1;if(!(""+r).match(/^(before|after)$/)&&!a&&!this.is_loaded(n))return this.load_node(n,function(){this.copy_node(i,n,r,s,!0)});switch(g=""+(i.parent||"#"),f=(""+r).match(/^(before|after)$/)&&"#"!==n.id?this.get_node(n.parent):n,p=i.instance?i.instance:this._model.data[i.id]?this:e.jstree.reference(i.id),m=!p||!p._id||this._id!==p._id,"#"===f.id&&("before"===r&&(r="first"),"after"===r&&(r="last")),r){case"before":r=e.inArray(n.id,f.children);break;case"after":r=e.inArray(n.id,f.children)+1;break;case"inside":case"first":r=0;break;case"last":r=f.children.length;break;default:r||(r=0)}if(r>f.children.length&&(r=f.children.length),!this.check("copy_node",i,f,r,{core:!0,is_multi:p&&p._id&&p._id!==this._id,is_foreign:!p||!p._id}))return this.settings.core.error.call(this,this._data.core.last_error),!1;if(u=p?p.get_json(i,{no_id:!0,no_data:!0,no_state:!0}):i,!u)return!1;if(u.id===!0&&delete u.id,u=this._parse_model_from_json(u,f.id,f.parents.concat()),!u)return!1;for(c=this.get_node(u),i&&i.state&&i.state.loaded===!1&&(c.state.loaded=!1),l=[],l.push(u),l=l.concat(c.children_d),this.trigger("model",{nodes:l,parent:f.id}),h=0,_=f.parents.length;_>h;h++)this._model.data[f.parents[h]].children_d=this._model.data[f.parents[h]].children_d.concat(l);for(l=[],h=0,_=f.children.length;_>h;h++)l[h>=r?h+1:h]=f.children[h];return l[r]=c.id,f.children=l,f.children_d.push(c.id),f.children_d=f.children_d.concat(c.children_d),this._node_changed(f.id),this.redraw("#"===f.id),s&&s.call(this,c,f,r),this.trigger("copy_node",{node:c,original:i,parent:f.id,position:r,old_parent:g,is_multi:p&&p._id&&p._id!==this._id,is_foreign:!p||!p._id,old_instance:p,new_instance:this}),c.id},cut:function(i){if(i||(i=this._data.core.selected.concat()),e.isArray(i)||(i=[i]),!i.length)return!1;var a=[],o,d,l;for(d=0,l=i.length;l>d;d++)o=this.get_node(i[d]),o&&o.id&&"#"!==o.id&&a.push(o);return a.length?(n=a,s=this,r="move_node",this.trigger("cut",{node:i}),t):!1},copy:function(i){if(i||(i=this._data.core.selected.concat()),e.isArray(i)||(i=[i]),!i.length)return!1;var a=[],o,d,l;for(d=0,l=i.length;l>d;d++)o=this.get_node(i[d]),o&&o.id&&"#"!==o.id&&a.push(o);return a.length?(n=a,s=this,r="copy_node",this.trigger("copy",{node:i}),t):!1},get_buffer:function(){return{mode:r,node:n,inst:s}},can_paste:function(){return r!==!1&&n!==!1},paste:function(e,i){return e=this.get_node(e),e&&r&&r.match(/^(copy_node|move_node)$/)&&n?(this[r](n,e,i)&&this.trigger("paste",{parent:e.id,node:n,mode:r}),n=!1,r=!1,s=!1,t):!1},edit:function(i,n){if(i=this._open_to(i),!i||!i.length)return!1;var r=this._data.core.rtl,s=this.element.width(),a=i.children(".jstree-anchor"),o=e(""),d="string"==typeof n?n:this.get_text(i),l=e("
",{css:{position:"absolute",top:"-200px",left:r?"0px":"-1000px",visibility:"hidden"}}).appendTo("body"),c=e("",{value:d,"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:e.proxy(function(){var e=o.children(".jstree-rename-input"),t=e.val();""===t&&(t=d),l.remove(),o.replaceWith(a),o.remove(),this.set_text(i,d),this.rename_node(i,t)===!1&&this.set_text(i,d)},this),keydown:function(e){var t=e.which;27===t&&(this.value=d),(27===t||13===t||37===t||38===t||39===t||40===t||32===t)&&e.stopImmediatePropagation(),(27===t||13===t)&&(e.preventDefault(),this.blur())},click:function(e){e.stopImmediatePropagation()},mousedown:function(e){e.stopImmediatePropagation()},keyup:function(e){c.width(Math.min(l.text("pW"+this.value).width(),s))},keypress:function(e){return 13===e.which?!1:t}}),h={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")||""};this.set_text(i,""),o.attr("class",a.attr("class")).append(a.contents().clone()).append(c),a.replaceWith(o),l.css(h),c.css(h).width(Math.min(l.text("pW"+c[0].value).width(),s))[0].select()},set_theme:function(t,i){if(!t)return!1;if(i===!0){var n=this.settings.core.themes.dir;n||(n=e.jstree.path+"/themes"),i=n+"/"+t+"/style.css"}i&&-1===e.inArray(i,a)&&(e("head").append(''),a.push(i)),this._data.core.themes.name&&this.element.removeClass("jstree-"+this._data.core.themes.name),this._data.core.themes.name=t,this.element.addClass("jstree-"+t),this.element[this.settings.core.themes.responsive?"addClass":"removeClass"]("jstree-"+t+"-responsive"),this.trigger("set_theme",{theme:t})},get_theme:function(){return this._data.core.themes.name},set_theme_variant:function(e){this._data.core.themes.variant&&this.element.removeClass("jstree-"+this._data.core.themes.name+"-"+this._data.core.themes.variant),this._data.core.themes.variant=e,e&&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")},hide_stripes:function(){this._data.core.themes.stripes=!1,this.get_container_ul().removeClass("jstree-striped")},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")},hide_dots:function(){this._data.core.themes.dots=!1,this.get_container_ul().addClass("jstree-no-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")},hide_icons:function(){this._data.core.themes.icons=!1,this.get_container_ul().addClass("jstree-no-icons")},toggle_icons:function(){this._data.core.themes.icons?this.hide_icons():this.show_icons()},set_icon:function(t,i){var n,r,s,a;if(e.isArray(t)){for(t=t.slice(),n=0,r=t.length;r>n;n++)this.set_icon(t[n],i);return!0}return t=this.get_node(t),t&&"#"!==t.id?(a=t.icon,t.icon=i,s=this.get_node(t,!0).children(".jstree-anchor").children(".jstree-themeicon"),i===!1?this.hide_icon(t):i===!0?s.removeClass("jstree-themeicon-custom "+a).css("background","").removeAttr("rel"):-1===i.indexOf("/")&&-1===i.indexOf(".")?(s.removeClass(a).css("background",""),s.addClass(i+" jstree-themeicon-custom").attr("rel",i)):(s.removeClass(a).css("background",""),s.addClass("jstree-themeicon-custom").css("background","url('"+i+"') center center no-repeat").attr("rel",i)),!0):!1},get_icon:function(e){return e=this.get_node(e),e&&"#"!==e.id?e.icon:!1},hide_icon:function(t){var i,n;if(e.isArray(t)){for(t=t.slice(),i=0,n=t.length;n>i;i++)this.hide_icon(t[i]);return!0}return t=this.get_node(t),t&&"#"!==t?(t.icon=!1,this.get_node(t,!0).children("a").children(".jstree-themeicon").addClass("jstree-themeicon-hidden"),!0):!1},show_icon:function(t){var i,n,r;if(e.isArray(t)){for(t=t.slice(),i=0,n=t.length;n>i;i++)this.show_icon(t[i]);return!0}return t=this.get_node(t),t&&"#"!==t?(r=this.get_node(t,!0),t.icon=r.length?r.children("a").children(".jstree-themeicon").attr("rel"):!0,t.icon||(t.icon=!0),r.children("a").children(".jstree-themeicon").removeClass("jstree-themeicon-hidden"),!0):!1}},e.vakata={},e.vakata.attributes=function(t,i){t=e(t)[0];var n=i?{}:[];return t&&t.attributes&&e.each(t.attributes,function(t,r){-1===e.inArray(r.nodeName.toLowerCase(),["style","contenteditable","hasfocus","tabindex"])&&null!==r.nodeValue&&""!==e.trim(r.nodeValue)&&(i?n[r.nodeName]=r.nodeValue:n.push(r.nodeName))}),n},e.vakata.array_unique=function(e){var t=[],i,n,r;for(i=0,r=e.length;r>i;i++){for(n=0;i>=n;n++)if(e[i]===e[n])break;n===i&&t.push(e[i])}return t},e.vakata.array_remove=function(e,t,i){var n=e.slice((i||t)+1||e.length);return e.length=0>t?e.length+t:t,e.push.apply(e,n),e},e.vakata.array_remove_item=function(t,i){var n=e.inArray(i,t);return-1!==n?e.vakata.array_remove(t,n):t},function(){var t={},i=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||0>e.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},n=i(window.navigator.userAgent);n.browser&&(t[n.browser]=!0,t.version=n.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),e.vakata.browser=t}(),e.vakata.browser.msie&&8>e.vakata.browser.version&&(e.jstree.defaults.core.animation=0);var _=document.createElement("I");_.className="jstree-icon jstree-checkbox",e.jstree.defaults.checkbox={visible:!0,three_state:!0,whole_node:!0,keep_selected_style:!0},e.jstree.plugins.checkbox=function(t,i){this.bind=function(){i.bind.call(this),this._data.checkbox.uto=!1,this.element.on("init.jstree",e.proxy(function(){this._data.checkbox.visible=this.settings.checkbox.visible,this.settings.checkbox.keep_selected_style||this.element.addClass("jstree-checkbox-no-clicked")},this)).on("loading.jstree",e.proxy(function(){this[this._data.checkbox.visible?"show_checkboxes":"hide_checkboxes"]()},this)),this.settings.checkbox.three_state&&this.element.on("changed.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree",e.proxy(function(){this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(e.proxy(this._undetermined,this),50)},this)).on("model.jstree",e.proxy(function(t,i){var n=this._model.data,r=n[i.parent],s=i.nodes,a=[],o,d,l,c,h,_;if(r.state.selected){for(d=0,l=s.length;l>d;d++)n[s[d]].state.selected=!0;this._data.core.selected=this._data.core.selected.concat(s)}else for(d=0,l=s.length;l>d;d++)if(n[s[d]].state.selected){for(c=0,h=n[s[d]].children_d.length;h>c;c++)n[n[s[d]].children_d[c]].state.selected=!0;this._data.core.selected=this._data.core.selected.concat(n[s[d]].children_d)}for(d=0,l=r.children_d.length;l>d;d++)n[r.children_d[d]].children.length||a.push(n[r.children_d[d]].parent);for(a=e.vakata.array_unique(a),c=0,h=a.length;h>c;c++){r=n[a[c]];while(r&&"#"!==r.id){for(o=0,d=0,l=r.children.length;l>d;d++)o+=n[r.children[d]].state.selected;if(o!==l)break;r.state.selected=!0,this._data.core.selected.push(r.id),_=this.get_node(r,!0),_&&_.length&&_.children(".jstree-anchor").addClass("jstree-clicked"),r=this.get_node(r.parent)}}this._data.core.selected=e.vakata.array_unique(this._data.core.selected)},this)).on("select_node.jstree",e.proxy(function(t,i){var n=i.node,r=this._model.data,s=this.get_node(n.parent),a=this.get_node(n,!0),o,d,l,c;for(this._data.core.selected=e.vakata.array_unique(this._data.core.selected.concat(n.children_d)),o=0,d=n.children_d.length;d>o;o++)c=r[n.children_d[o]],c.state.selected=!0,c&&c.original&&c.original.state&&c.original.state.undetermined&&(c.original.state.undetermined=!1);while(s&&"#"!==s.id){for(l=0,o=0,d=s.children.length;d>o;o++)l+=r[s.children[o]].state.selected;if(l!==d)break;s.state.selected=!0,this._data.core.selected.push(s.id),c=this.get_node(s,!0),c&&c.length&&c.children(".jstree-anchor").addClass("jstree-clicked"),s=this.get_node(s.parent)}a.length&&a.find(".jstree-anchor").addClass("jstree-clicked")},this)).on("deselect_all.jstree",e.proxy(function(e,t){var i=this.get_node("#"),n=this._model.data,r,s,a;for(r=0,s=i.children_d.length;s>r;r++)a=n[i.children_d[r]],a&&a.original&&a.original.state&&a.original.state.undetermined&&(a.original.state.undetermined=!1)},this)).on("deselect_node.jstree",e.proxy(function(t,i){var n=i.node,r=this.get_node(n,!0),s,a,o;for(n&&n.original&&n.original.state&&n.original.state.undetermined&&(n.original.state.undetermined=!1),s=0,a=n.children_d.length;a>s;s++)o=this._model.data[n.children_d[s]],o.state.selected=!1,o&&o.original&&o.original.state&&o.original.state.undetermined&&(o.original.state.undetermined=!1);for(s=0,a=n.parents.length;a>s;s++)o=this._model.data[n.parents[s]],o.state.selected=!1,o&&o.original&&o.original.state&&o.original.state.undetermined&&(o.original.state.undetermined=!1),o=this.get_node(n.parents[s],!0),o&&o.length&&o.children(".jstree-anchor").removeClass("jstree-clicked");for(o=[],s=0,a=this._data.core.selected.length;a>s;s++)-1===e.inArray(this._data.core.selected[s],n.children_d)&&-1===e.inArray(this._data.core.selected[s],n.parents)&&o.push(this._data.core.selected[s]);this._data.core.selected=e.vakata.array_unique(o),r.length&&r.find(".jstree-anchor").removeClass("jstree-clicked")},this)).on("delete_node.jstree",e.proxy(function(e,t){var i=this.get_node(t.parent),n=this._model.data,r,s,a,o;while(i&&"#"!==i.id){for(a=0,r=0,s=i.children.length;s>r;r++)a+=n[i.children[r]].state.selected;if(a!==s)break;i.state.selected=!0,this._data.core.selected.push(i.id),o=this.get_node(i,!0),o&&o.length&&o.children(".jstree-anchor").addClass("jstree-clicked"),i=this.get_node(i.parent)}},this)).on("move_node.jstree",e.proxy(function(t,i){var n=i.is_multi,r=i.old_parent,s=this.get_node(i.parent),a=this._model.data,o,d,l,c,h;if(!n){o=this.get_node(r);while(o&&"#"!==o.id){for(d=0,l=0,c=o.children.length;c>l;l++)d+=a[o.children[l]].state.selected;if(d!==c)break;o.state.selected=!0,this._data.core.selected.push(o.id),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").addClass("jstree-clicked"),o=this.get_node(o.parent)}}o=s;while(o&&"#"!==o.id){for(d=0,l=0,c=o.children.length;c>l;l++)d+=a[o.children[l]].state.selected;if(d===c)o.state.selected||(o.state.selected=!0,this._data.core.selected.push(o.id),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").addClass("jstree-clicked"));else{if(!o.state.selected)break;o.state.selected=!1,this._data.core.selected=e.vakata.array_remove_item(this._data.core.selected,o.id),h=this.get_node(o,!0),h&&h.length&&h.children(".jstree-anchor").removeClass("jstree-clicked")}o=this.get_node(o.parent)}},this))},this._undetermined=function(){var t,i,n=this._model.data,r=this._data.core.selected,s=[],a=this;for(t=0,i=r.length;i>t;t++)n[r[t]]&&n[r[t]].parents&&(s=s.concat(n[r[t]].parents));for(this.element.find(".jstree-closed").not(":has(ul)").each(function(){var e=a.get_node(this),r;if(e.state.loaded)for(t=0,i=e.children_d.length;i>t;t++)r=n[e.children_d[t]],!r.state.loaded&&r.original&&r.original.state&&r.original.state.undetermined&&r.original.state.undetermined===!0&&(s.push(r.id),s=s.concat(r.parents));else e.original&&e.original.state&&e.original.state.undetermined&&e.original.state.undetermined===!0&&(s.push(e.id),s=s.concat(e.parents))}),s=e.vakata.array_unique(s),s=e.vakata.array_remove_item(s,"#"),this.element.find(".jstree-undetermined").removeClass("jstree-undetermined"),t=0,i=s.length;i>t;t++)n[s[t]].state.selected||(r=this.get_node(s[t],!0),r&&r.length&&r.children("a").children(".jstree-checkbox").addClass("jstree-undetermined"))},this.redraw_node=function(t,n,r){if(t=i.redraw_node.call(this,t,n,r)){var s=t.getElementsByTagName("A")[0];s.insertBefore(_.cloneNode(!1),s.childNodes[0])}return!r&&this.settings.checkbox.three_state&&(this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(e.proxy(this._undetermined,this),50)),t},this.activate_node=function(t,n){return(this.settings.checkbox.whole_node||e(n.target).hasClass("jstree-checkbox"))&&(n.ctrlKey=!0),i.activate_node.call(this,t,n)},this.show_checkboxes=function(){this._data.core.themes.checkboxes=!0,this.element.children("ul").removeClass("jstree-no-checkboxes")},this.hide_checkboxes=function(){this._data.core.themes.checkboxes=!1,this.element.children("ul").addClass("jstree-no-checkboxes")},this.toggle_checkboxes=function(){this._data.core.themes.checkboxes?this.hide_checkboxes():this.show_checkboxes()}},e.jstree.defaults.contextmenu={select_node:!0,show_at_node:!0,items:function(t,i){return{create:{separator_before:!1,separator_after:!0,_disabled:!1,label:"Create",action:function(t){var i=e.jstree.reference(t.reference),n=i.get_node(t.reference);i.create_node(n,{},"last",function(e){setTimeout(function(){i.edit(e)},0)})}},rename:{separator_before:!1,separator_after:!1,_disabled:!1,label:"Rename",action:function(t){var i=e.jstree.reference(t.reference),n=i.get_node(t.reference);i.edit(n)}},remove:{separator_before:!1,icon:!1,separator_after:!1,_disabled:!1,label:"Delete",action:function(t){var i=e.jstree.reference(t.reference),n=i.get_node(t.reference);i.is_selected(n)?i.delete_node(i.get_selected()):i.delete_node(n)}},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(t){var i=e.jstree.reference(t.reference),n=i.get_node(t.reference);i.is_selected(n)?i.cut(i.get_selected()):i.cut(n)}},copy:{separator_before:!1,icon:!1,separator_after:!1,label:"Copy",action:function(t){var i=e.jstree.reference(t.reference),n=i.get_node(t.reference);i.is_selected(n)?i.copy(i.get_selected()):i.copy(n)}},paste:{separator_before:!1,icon:!1,_disabled:function(t){return!e.jstree.reference(t.reference).can_paste()},separator_after:!1,label:"Paste",action:function(t){var i=e.jstree.reference(t.reference),n=i.get_node(t.reference);i.paste(n)}}}}}}},e.jstree.plugins.contextmenu=function(i,n){this.bind=function(){n.bind.call(this);var t=0;this.element.on("contextmenu.jstree",".jstree-anchor",e.proxy(function(e){e.preventDefault(),t=e.ctrlKey?e.timeStamp:0,this.is_loading(e.currentTarget)||this.show_contextmenu(e.currentTarget,e.pageX,e.pageY,e)},this)).on("click.jstree",".jstree-anchor",e.proxy(function(i){this._data.contextmenu.visible&&(!t||i.timeStamp-t>250)&&e.vakata.context.hide()},this)),e(document).on("context_hide.vakata",e.proxy(function(){this._data.contextmenu.visible=!1},this))},this.teardown=function(){this._data.contextmenu.visible&&e.vakata.context.hide(),n.teardown.call(this)},this.show_contextmenu=function(i,n,r,s){if(i=this.get_node(i),!i||"#"===i.id)return!1;var a=this.settings.contextmenu,o=this.get_node(i,!0),d=o.children(".jstree-anchor"),l=!1,c=!1;(a.show_at_node||n===t||r===t)&&(l=d.offset(),n=l.left,r=l.top+this._data.core.li_height),this.settings.contextmenu.select_node&&!this.is_selected(i)&&(this.deselect_all(),this.select_node(i,!1,!1,s)),c=a.items,e.isFunction(c)&&(c=c.call(this,i,e.proxy(function(e){this._show_contextmenu(i,n,r,e)},this))),e.isPlainObject(c)&&this._show_contextmenu(i,n,r,c)},this._show_contextmenu=function(t,i,n,r){var s=this.get_node(t,!0),a=s.children(".jstree-anchor");e(document).one("context_show.vakata",e.proxy(function(t,i){var n="jstree-contextmenu jstree-"+this.get_theme()+"-contextmenu";e(i.element).addClass(n)},this)),this._data.contextmenu.visible=!0,e.vakata.context.show(a,{x:i,y:n},r),this.trigger("show_contextmenu",{node:t,x:i,y:n})}},function(e){var i=!1,n={element:!1,reference:!1,position_x:0,position_y:0,items:[],html:"",is_visible:!1};e.vakata.context={settings:{hide_onmouseleave:0,icons:!0},_trigger:function(t){e(document).triggerHandler("context_"+t+".vakata",{reference:n.reference,element:n.element,position:{x:n.position_x,y:n.position_y}})},_execute:function(t){return t=n.items[t],t&&(!t._disabled||e.isFunction(t._disabled)&&!t._disabled({item:t,reference:n.reference,element:n.element}))&&t.action?t.action.call(null,{item:t,reference:n.reference,element:n.element,position:{x:n.position_x,y:n.position_y}}):!1},_parse:function(i,r){if(!i)return!1;r||(n.html="",n.items=[]);var s="",a=!1,o;return r&&(s+=""),r||(n.html=s,e.vakata.context._trigger("parse")),s.length>10?s:!1},_show_submenu:function(t){if(t=e(t),t.length&&t.children("ul").length){var n=t.children("ul"),r=t.offset().left+t.outerWidth(),s=t.offset().top,a=n.width(),o=n.height(),d=e(window).width()+e(window).scrollLeft(),l=e(window).height()+e(window).scrollTop();i?t[0>r-(a+10+t.outerWidth())?"addClass":"removeClass"]("vakata-context-left"):t[r+a+10>d?"addClass":"removeClass"]("vakata-context-right"),s+o+10>l&&n.css("bottom","-1px"),n.show()}},show:function(t,r,s){var a,o,d,l,c,h,_,u,g=!0;switch(n.element&&n.element.length&&n.element.width(""),g){case!r&&!t:return!1;case!!r&&!!t:n.reference=t,n.position_x=r.x,n.position_y=r.y;break;case!r&&!!t:n.reference=t,a=t.offset(),n.position_x=a.left+t.outerHeight(),n.position_y=a.top;break;case!!r&&!t:n.position_x=r.x,n.position_y=r.y}t&&!s&&e(t).data("vakata_contextmenu")&&(s=e(t).data("vakata_contextmenu")),e.vakata.context._parse(s)&&n.element.html(n.html),n.items.length&&(o=n.element,d=n.position_x,l=n.position_y,c=o.width(),h=o.height(),_=e(window).width()+e(window).scrollLeft(),u=e(window).height()+e(window).scrollTop(),i&&(d-=o.outerWidth(),e(window).scrollLeft()+20>d&&(d=e(window).scrollLeft()+20)),d+c+20>_&&(d=_-(c+20)),l+h+20>u&&(l=u-(h+20)),n.element.css({left:d,top:l}).show().find("a:eq(0)").focus().parent().addClass("vakata-context-hover"),n.is_visible=!0,e.vakata.context._trigger("show"))},hide:function(){n.is_visible&&(n.element.hide().find("ul").hide().end().find(":focus").blur(),n.is_visible=!1,e.vakata.context._trigger("hide"))}},e(function(){i="rtl"===e("body").css("direction");var t=!1;n.element=e("
    "),n.element.on("mouseenter","li",function(i){i.stopImmediatePropagation(),e.contains(this,i.relatedTarget)||(t&&clearTimeout(t),n.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end(),e(this).siblings().find("ul").hide().end().end().parentsUntil(".vakata-context","li").addBack().addClass("vakata-context-hover"),e.vakata.context._show_submenu(this))}).on("mouseleave","li",function(t){e.contains(this,t.relatedTarget)||e(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover")}).on("mouseleave",function(i){e(this).find(".vakata-context-hover").removeClass("vakata-context-hover"),e.vakata.context.settings.hide_onmouseleave&&(t=setTimeout(function(t){return function(){e.vakata.context.hide()}}(this),e.vakata.context.settings.hide_onmouseleave))}).on("click","a",function(e){e.preventDefault()}).on("mouseup","a",function(t){e(this).blur().parent().hasClass("vakata-context-disabled")||e.vakata.context._execute(e(this).attr("rel"))===!1||e.vakata.context.hide()}).on("keydown","a",function(t){var i=null;switch(t.which){case 13:case 32:t.type="mouseup",t.preventDefault(),e(t.currentTarget).trigger(t);break;case 37:n.is_visible&&(n.element.find(".vakata-context-hover").last().parents("li:eq(0)").find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children("a").focus(),t.stopImmediatePropagation(),t.preventDefault());break;case 38:n.is_visible&&(i=n.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first(),i.length||(i=n.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last()),i.addClass("vakata-context-hover").children("a").focus(),t.stopImmediatePropagation(),t.preventDefault());break;case 39:n.is_visible&&(n.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(),t.stopImmediatePropagation(),t.preventDefault());break;case 40:n.is_visible&&(i=n.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first(),i.length||(i=n.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first()),i.addClass("vakata-context-hover").children("a").focus(),t.stopImmediatePropagation(),t.preventDefault());break;case 27:e.vakata.context.hide(),t.preventDefault();break;default:}}).on("keydown",function(e){e.preventDefault();var t=n.element.find(".vakata-contextmenu-shortcut-"+e.which).parent();t.parent().not(".vakata-context-disabled")&&t.mouseup()}).appendTo("body"),e(document).on("mousedown",function(t){n.is_visible&&!e.contains(n.element[0],t.target)&&e.vakata.context.hide()}).on("context_show.vakata",function(e,t){n.element.find("li:has(ul)").children("a").addClass("vakata-context-parent"),i&&n.element.addClass("vakata-context-rtl").css("direction","rtl"),n.element.find("ul").hide().end()})})}(e),e.jstree.defaults.dnd={copy:!0,open_timeout:500,is_draggable:!0,check_while_dragging:!0,always_copy:!1},e.jstree.plugins.dnd=function(i,n){this.bind=function(){n.bind.call(this),this.element.on("mousedown.jstree touchstart.jstree",".jstree-anchor",e.proxy(function(i){var n=this.get_node(i.target),r=this.is_selected(n)?this.get_selected().length:1;return n&&n.id&&"#"!==n.id&&(1===i.which||"touchstart"===i.type)&&(this.settings.dnd.is_draggable===!0||e.isFunction(this.settings.dnd.is_draggable)&&this.settings.dnd.is_draggable.call(this,r>1?this.get_selected(!0):[n]))?(this.element.trigger("mousedown.jstree"),e.vakata.dnd.start(i,{jstree:!0,origin:this,obj:this.get_node(n,!0),nodes:r>1?this.get_selected():[n.id]},'
    '+(r>1?r+" "+this.get_string("nodes"):this.get_text(i.currentTarget,!0))+'
    ')):t},this))}},e(function(){var i=!1,n=!1,r=!1,s=e('
     
    ').hide().appendTo("body");e(document).bind("dnd_start.vakata",function(e,t){i=!1}).bind("dnd_move.vakata",function(a,o){if(r&&clearTimeout(r),o.data.jstree&&(!o.event.target.id||"jstree-marker"!==o.event.target.id)){var d=e.jstree.reference(o.event.target),l=!1,c=!1,h=!1,_,u,g,f,p,m,v,y,j,x,k,b;if(d&&d._data&&d._data.dnd)if(s.attr("class","jstree-"+d.get_theme()),o.helper.children().attr("class","jstree-"+d.get_theme()).find(".jstree-copy:eq(0)")[o.data.origin&&(o.data.origin.settings.dnd.always_copy||o.data.origin.settings.dnd.copy&&(o.event.metaKey||o.event.ctrlKey))?"show":"hide"](),o.event.target!==d.element[0]&&o.event.target!==d.get_container_ul()[0]||0!==d.get_container_ul().children().length){if(l=e(o.event.target).closest("a"),l&&l.length&&l.parent().is(".jstree-closed, .jstree-open, .jstree-leaf")&&(c=l.offset(),h=o.event.pageY-c.top,g=l.height(),m=g/3>h?["b","i","a"]:h>g-g/3?["a","i","b"]:h>g/2?["i","a","b"]:["i","b","a"],e.each(m,function(a,h){switch(h){case"b":_=c.left-6,u=c.top-5,f=d.get_parent(l),p=l.parent().index();break;case"i":_=c.left-2,u=c.top-5+g/2+1,f=d.get_node(l.parent()).id,p=0;break;case"a":_=c.left-6,u=c.top-5+g,f=d.get_parent(l),p=l.parent().index()+1}for(v=!0,y=0,j=o.data.nodes.length;j>y;y++)if(x=o.data.origin&&(o.data.origin.settings.dnd.always_copy||o.data.origin.settings.dnd.copy&&(o.event.metaKey||o.event.ctrlKey))?"copy_node":"move_node",k=p,"move_node"===x&&"a"===h&&o.data.origin&&o.data.origin===d&&f===d.get_parent(o.data.nodes[y])&&(b=d.get_node(f),k>e.inArray(o.data.nodes[y],b.children)&&(k-=1)),v=v&&(d&&d.settings&&d.settings.dnd&&d.settings.dnd.check_while_dragging===!1||d.check(x,o.data.origin&&o.data.origin!==d?o.data.origin.get_node(o.data.nodes[y]):o.data.nodes[y],f,k,{dnd:!0,ref:d.get_node(l.parent()),pos:h,is_multi:o.data.origin&&o.data.origin!==d,is_foreign:!o.data.origin})),!v){d&&d.last_error&&(n=d.last_error());break}return v?("i"===h&&l.parent().is(".jstree-closed")&&d.settings.dnd.open_timeout&&(r=setTimeout(function(e,t){return function(){e.open_node(t)}}(d,l),d.settings.dnd.open_timeout)),i={ins:d,par:f,pos:p},s.css({left:_+"px",top:u+"px"}).show(),o.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok"),n={},m=!0,!1):t}),m===!0))return}else{for(v=!0,y=0,j=o.data.nodes.length;j>y;y++)if(v=v&&d.check(o.data.origin&&(o.data.origin.settings.dnd.always_copy||o.data.origin.settings.dnd.copy&&(o.event.metaKey||o.event.ctrlKey))?"copy_node":"move_node",o.data.origin&&o.data.origin!==d?o.data.origin.get_node(o.data.nodes[y]):o.data.nodes[y],"#","last",{dnd:!0,ref:d.get_node("#"),pos:"i",is_multi:o.data.origin&&o.data.origin!==d,is_foreign:!o.data.origin}),!v)break;if(v)return i={ins:d,par:"#",pos:"last"},s.hide(),o.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok"),t}i=!1,o.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er"),s.hide()}}).bind("dnd_scroll.vakata",function(e,t){t.data.jstree&&(s.hide(),i=!1,t.helper.find(".jstree-icon:eq(0)").removeClass("jstree-ok").addClass("jstree-er"))}).bind("dnd_stop.vakata",function(t,a){if(r&&clearTimeout(r),a.data.jstree){s.hide();var o,d,l=[];if(i){for(o=0,d=a.data.nodes.length;d>o;o++)l[o]=a.data.origin?a.data.origin.get_node(a.data.nodes[o]):a.data.nodes[o],a.data.origin&&(l[o].instance=a.data.origin);i.ins[a.data.origin&&(a.data.origin.settings.dnd.always_copy||a.data.origin.settings.dnd.copy&&(a.event.metaKey||a.event.ctrlKey))?"copy_node":"move_node"](l,i.par,i.pos)}else o=e(a.event.target).closest(".jstree"),o.length&&n&&n.error&&"check"===n.error&&(o=o.jstree(!0),o&&o.settings.core.error.call(this,n))}}).bind("keyup keydown",function(t,i){i=e.vakata.dnd._get(),i.data&&i.data.jstree&&i.helper.find(".jstree-copy:eq(0)")[i.data.origin&&(i.data.origin.settings.dnd.always_copy||i.data.origin.settings.dnd.copy&&(t.metaKey||t.ctrlKey))?"show":"hide"]()})}),function(e){var i={element:!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};e.vakata.dnd={settings:{scroll_speed:10,scroll_proximity:20,helper_left:5,helper_top:10,threshold:5},_trigger:function(t,i){var n=e.vakata.dnd._get();n.event=i,e(document).triggerHandler("dnd_"+t+".vakata",n)},_get:function(){return{data:i.data,element:i.element,helper:i.helper}},_clean:function(){i.helper&&i.helper.remove(),i.scroll_i&&(clearInterval(i.scroll_i),i.scroll_i=!1),i={element:!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},e(document).off("mousemove touchmove",e.vakata.dnd.drag),e(document).off("mouseup touchend",e.vakata.dnd.stop)},_scroll:function(t){if(!i.scroll_e||!i.scroll_l&&!i.scroll_t)return i.scroll_i&&(clearInterval(i.scroll_i),i.scroll_i=!1),!1;if(!i.scroll_i)return i.scroll_i=setInterval(e.vakata.dnd._scroll,100),!1;if(t===!0)return!1;var n=i.scroll_e.scrollTop(),r=i.scroll_e.scrollLeft();i.scroll_e.scrollTop(n+i.scroll_t*e.vakata.dnd.settings.scroll_speed),i.scroll_e.scrollLeft(r+i.scroll_l*e.vakata.dnd.settings.scroll_speed),(n!==i.scroll_e.scrollTop()||r!==i.scroll_e.scrollLeft())&&e.vakata.dnd._trigger("scroll",i.scroll_e)},start:function(t,n,r){"touchstart"===t.type&&t.originalEvent&&t.originalEvent.changedTouches&&t.originalEvent.changedTouches[0]&&(t.pageX=t.originalEvent.changedTouches[0].pageX,t.pageY=t.originalEvent.changedTouches[0].pageY,t.target=document.elementFromPoint(t.originalEvent.changedTouches[0].pageX-window.pageXOffset,t.originalEvent.changedTouches[0].pageY-window.pageYOffset)),i.is_drag&&e.vakata.dnd.stop({});try{t.currentTarget.unselectable="on",t.currentTarget.onselectstart=function(){return!1},t.currentTarget.style&&(t.currentTarget.style.MozUserSelect="none")}catch(s){}return i.init_x=t.pageX,i.init_y=t.pageY,i.data=n,i.is_down=!0,i.element=t.currentTarget,r!==!1&&(i.helper=e("
    ").html(r).css({display:"block",margin:"0",padding:"0",position:"absolute",top:"-2000px",lineHeight:"16px",zIndex:"10000"})),e(document).bind("mousemove touchmove",e.vakata.dnd.drag),e(document).bind("mouseup touchend",e.vakata.dnd.stop),!1},drag:function(n){if("touchmove"===n.type&&n.originalEvent&&n.originalEvent.changedTouches&&n.originalEvent.changedTouches[0]&&(n.pageX=n.originalEvent.changedTouches[0].pageX,n.pageY=n.originalEvent.changedTouches[0].pageY,n.target=document.elementFromPoint(n.originalEvent.changedTouches[0].pageX-window.pageXOffset,n.originalEvent.changedTouches[0].pageY-window.pageYOffset)),i.is_down){if(!i.is_drag){if(!(Math.abs(n.pageX-i.init_x)>e.vakata.dnd.settings.threshold||Math.abs(n.pageY-i.init_y)>e.vakata.dnd.settings.threshold))return;i.helper&&(i.helper.appendTo("body"),i.helper_w=i.helper.outerWidth()),i.is_drag=!0,e.vakata.dnd._trigger("start",n)}var r=!1,s=!1,a=!1,o=!1,d=!1,l=!1,c=!1,h=!1,_=!1,u=!1;i.scroll_t=0,i.scroll_l=0,i.scroll_e=!1,e(e(n.target).parentsUntil("body").addBack().get().reverse()).filter(function(){return/^auto|scroll$/.test(e(this).css("overflow"))&&(this.scrollHeight>this.offsetHeight||this.scrollWidth>this.offsetWidth)}).each(function(){var r=e(this),s=r.offset();return this.scrollHeight>this.offsetHeight&&(s.top+r.height()-n.pageYthis.offsetWidth&&(s.left+r.width()-n.pageXo&&n.pageY-co&&o-(n.pageY-c)l&&n.pageX-hl&&l-(n.pageX-h)a&&(_=a-50),d&&u+i.helper_w>d&&(u=d-(i.helper_w+2)),i.helper.css({left:u+"px",top:_+"px"})),e.vakata.dnd._trigger("move",n)}},stop:function(t){"touchend"===t.type&&t.originalEvent&&t.originalEvent.changedTouches&&t.originalEvent.changedTouches[0]&&(t.pageX=t.originalEvent.changedTouches[0].pageX,t.pageY=t.originalEvent.changedTouches[0].pageY,t.target=document.elementFromPoint(t.originalEvent.changedTouches[0].pageX-window.pageXOffset,t.originalEvent.changedTouches[0].pageY-window.pageYOffset)),i.is_drag&&e.vakata.dnd._trigger("stop",t),e.vakata.dnd._clean()}}}(jQuery),e.jstree.defaults.search={ajax:!1,fuzzy:!0,case_sensitive:!1,show_only_matches:!1,close_opened_onclear:!0,search_leaves_only:!1},e.jstree.plugins.search=function(t,i){this.bind=function(){i.bind.call(this),this._data.search.str="",this._data.search.dom=e(),this._data.search.res=[],this._data.search.opn=[],this.element.on("before_open.jstree",e.proxy(function(t,i){var n,r,s,a=this._data.search.res,o=[],d=e();if(a&&a.length){for(this._data.search.dom=e(),n=0,r=a.length;r>n;n++)o=o.concat(this.get_node(a[n]).parents),s=this.get_node(a[n],!0),s&&(this._data.search.dom=this._data.search.dom.add(s));for(o=e.vakata.array_unique(o),n=0,r=o.length;r>n;n++)"#"!==o[n]&&(s=this.get_node(o[n],!0),s&&(d=d.add(s)));this._data.search.dom.children(".jstree-anchor").addClass("jstree-search"),this.settings.search.show_only_matches&&this._data.search.res.length&&(this.element.find("li").hide().filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last"),d=d.add(this._data.search.dom),d.parentsUntil(".jstree").addBack().show().filter("ul").each(function(){e(this).children("li:visible").eq(-1).addClass("jstree-last")}))}},this)),this.settings.search.show_only_matches&&this.element.on("search.jstree",function(t,i){i.nodes.length&&(e(this).find("li").hide().filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last"),i.nodes.parentsUntil(".jstree").addBack().show().filter("ul").each(function(){e(this).children("li:visible").eq(-1).addClass("jstree-last")}))}).on("clear_search.jstree",function(t,i){i.nodes.length&&e(this).find("li").css("display","").filter(".jstree-last").filter(function(){return this.nextSibling}).removeClass("jstree-last")})},this.search=function(t,i){if(t===!1||""===e.trim(t))return this.clear_search();var n=this.settings.search,r=n.ajax?n.ajax:!1,s=null,a=[],o=[],d,l;if(this._data.search.res.length&&this.clear_search(),!i&&r!==!1)return e.isFunction(r)?r.call(this,t,e.proxy(function(i){i&&i.d&&(i=i.d),this._load_nodes(e.isArray(i)?i:[],function(){this.search(t,!0)})},this)):(r=e.extend({},r),r.data||(r.data={}),r.data.str=t,e.ajax(r).fail(e.proxy(function(){this._data.core.last_error={error:"ajax",plugin:"search",id:"search_01",reason:"Could not load search parents",data:JSON.stringify(r)},this.settings.core.error.call(this,this._data.core.last_error)},this)).done(e.proxy(function(i){i&&i.d&&(i=i.d),this._load_nodes(e.isArray(i)?i:[],function(){this.search(t,!0)})},this)));if(this._data.search.str=t,this._data.search.dom=e(),this._data.search.res=[],this._data.search.opn=[],s=new e.vakata.search(t,!0,{caseSensitive:n.case_sensitive,fuzzy:n.fuzzy}),e.each(this._model.data,function(e,t){t.text&&s.search(t.text).isMatch&&(!n.search_leaves_only||t.state.loaded&&0===t.children.length)&&(a.push(e),o=o.concat(t.parents))}),a.length){for(o=e.vakata.array_unique(o),this._search_open(o),d=0,l=a.length;l>d;d++)s=this.get_node(a[d],!0),s&&(this._data.search.dom=this._data.search.dom.add(s));this._data.search.res=a,this._data.search.dom.children(".jstree-anchor").addClass("jstree-search")}this.trigger("search",{nodes:this._data.search.dom,str:t,res:this._data.search.res})},this.clear_search=function(){this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search"),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.str="",this._data.search.res=[],this._data.search.opn=[],this._data.search.dom=e()},this._search_open=function(t){var i=this;e.each(t.concat([]),function(n,r){if("#"===r)return!0;try{r=e("#"+r.replace(e.jstree.idregex,"\\$&"),i.element)}catch(s){}r&&r.length&&i.is_closed(r)&&(i._data.search.opn.push(r[0].id),i.open_node(r,function(){i._search_open(t)},0))})}},function(e){e.vakata.search=function(e,t,i){i=i||{},i.fuzzy!==!1&&(i.fuzzy=!0),e=i.caseSensitive?e:e.toLowerCase();var n=i.location||0,r=i.distance||100,s=i.threshold||.6,a=e.length,o,d,l,c;return a>32&&(i.fuzzy=!1),i.fuzzy&&(o=1<i;i++)t[e.charAt(i)]=0;for(i=0;a>i;i++)t[e.charAt(i)]|=1<r;r++){g=0,f=p;while(f>g)_>=l(r,n+f)?g=f:p=f,f=Math.floor((p-g)/2+g);for(p=f,v=Math.max(1,n-f+1),y=Math.min(n+f,h)+a,j=Array(y+2),j[y+1]=(1<=v;c--)if(x=d[t.charAt(c-1)],j[c]=0===r?(1|j[c+1]<<1)&x:(1|j[c+1]<<1)&x|(1|(m[c+1]|m[c])<<1)|m[c+1],j[c]&o&&(k=l(r,c-1),_>=k)){if(_=k,u=c-1,b.push(u),!(u>n))break;v=Math.max(1,2*n-u)}if(l(r+1,n)>_)break;m=j}return{isMatch:u>=0,score:k}},t===!0?{search:c}:c(t)}}(jQuery),e.jstree.defaults.sort=function(e,t){return this.get_text(e)>this.get_text(t)?1:-1},e.jstree.plugins.sort=function(t,i){this.bind=function(){i.bind.call(this),this.element.on("model.jstree",e.proxy(function(e,t){this.sort(t.parent,!0)},this)).on("rename_node.jstree create_node.jstree",e.proxy(function(e,t){this.sort(t.parent||t.node.parent,!1),this.redraw_node(t.parent||t.node.parent,!0)},this)).on("move_node.jstree copy_node.jstree",e.proxy(function(e,t){this.sort(t.parent,!1),this.redraw_node(t.parent,!0)},this))},this.sort=function(t,i){var n,r;if(t=this.get_node(t),t&&t.children&&t.children.length&&(t.children.sort(e.proxy(this.settings.sort,this)),i))for(n=0,r=t.children_d.length;r>n;n++)this.sort(t.children_d[n],!1)}};var u=!1;e.jstree.defaults.state={key:"jstree",events:"changed.jstree open_node.jstree close_node.jstree",ttl:!1,filter:!1},e.jstree.plugins.state=function(t,i){this.bind=function(){i.bind.call(this);var t=e.proxy(function(){this.element.on(this.settings.state.events,e.proxy(function(){u&&clearTimeout(u),u=setTimeout(e.proxy(function(){this.save_state()},this),100)},this))},this);this.element.on("ready.jstree",e.proxy(function(e,i){this.element.one("restore_state.jstree",t),this.restore_state()||t()},this))},this.save_state=function(){var t={state:this.get_state(),ttl:this.settings.state.ttl,sec:+new Date};e.vakata.storage.set(this.settings.state.key,JSON.stringify(t))},this.restore_state=function(){var t=e.vakata.storage.get(this.settings.state.key);if(t)try{t=JSON.parse(t)}catch(i){return!1}return t&&t.ttl&&t.sec&&+new Date-t.sec>t.ttl?!1:(t&&t.state&&(t=t.state),t&&e.isFunction(this.settings.state.filter)&&(t=this.settings.state.filter.call(this,t)),t?(this.element.one("set_state.jstree",function(i,n){n.instance.trigger("restore_state",{state:e.extend(!0,{},t)})}),this.set_state(t),!0):!1)},this.clear_state=function(){return e.vakata.storage.del(this.settings.state.key)}},function(e,t){e.vakata.storage={set:function(e,t){return window.localStorage.setItem(e,t)},get:function(e){return window.localStorage.getItem(e)},del:function(e){return window.localStorage.removeItem(e)}}}(jQuery),e.jstree.defaults.types={"#":{},"default":{}},e.jstree.plugins.types=function(i,n){this.init=function(e,i){var r,s;if(i&&i.types&&i.types["default"])for(r in i.types)if("default"!==r&&"#"!==r&&i.types.hasOwnProperty(r))for(s in i.types["default"])i.types["default"].hasOwnProperty(s)&&i.types[r][s]===t&&(i.types[r][s]=i.types["default"][s]);n.init.call(this,e,i),this._model.data["#"].type="#"},this.refresh=function(e){n.refresh.call(this,e),this._model.data["#"].type="#"},this.bind=function(){this.element.on("model.jstree",e.proxy(function(e,i){var n=this._model.data,r=i.nodes,s=this.settings.types,a,o,d="default";for(a=0,o=r.length;o>a;a++)d="default",n[r[a]].original&&n[r[a]].original.type&&s[n[r[a]].original.type]&&(d=n[r[a]].original.type),n[r[a]].data&&n[r[a]].data.jstree&&n[r[a]].data.jstree.type&&s[n[r[a]].data.jstree.type]&&(d=n[r[a]].data.jstree.type),n[r[a]].type=d,n[r[a]].icon===!0&&s[d].icon!==t&&(n[r[a]].icon=s[d].icon)},this)),n.bind.call(this)},this.get_json=function(t,i,r){var s,a,o=this._model.data,d=i?e.extend(!0,{},i,{no_id:!1}):{},l=n.get_json.call(this,t,d,r);if(l===!1)return!1;if(e.isArray(l))for(s=0,a=l.length;a>s;s++)l[s].type=l[s].id&&o[l[s].id]&&o[l[s].id].type?o[l[s].id].type:"default",i&&i.no_id&&(delete l[s].id,l[s].li_attr&&l[s].li_attr.id&&delete l[s].li_attr.id);else l.type=l.id&&o[l.id]&&o[l.id].type?o[l.id].type:"default",i&&i.no_id&&(l=this._delete_ids(l));return l},this._delete_ids=function(t){if(e.isArray(t)){for(var i=0,n=t.length;n>i;i++)t[i]=this._delete_ids(t[i]);return t}return delete t.id,t.li_attr&&t.li_attr.id&&delete t.li_attr.id,t.children&&e.isArray(t.children)&&(t.children=this._delete_ids(t.children)),t},this.check=function(i,r,s,a,o){if(n.check.call(this,i,r,s,a,o)===!1)return!1;r=r&&r.id?r:this.get_node(r),s=s&&s.id?s:this.get_node(s);var d=r&&r.id?e.jstree.reference(r.id):null,l,c,h,_;switch(d=d&&d._model&&d._model.data?d._model.data:null,i){case"create_node":case"move_node":case"copy_node":if("move_node"!==i||-1===e.inArray(r.id,s.children)){if(l=this.get_rules(s),l.max_children!==t&&-1!==l.max_children&&l.max_children===s.children.length)return this._data.core.last_error={error:"check",plugin:"types",id:"types_01",reason:"max_children prevents function: "+i,data:JSON.stringify({chk:i,pos:a,obj:r&&r.id?r.id:!1,par:s&&s.id?s.id:!1})},!1;if(l.valid_children!==t&&-1!==l.valid_children&&-1===e.inArray(r.type,l.valid_children))return this._data.core.last_error={error:"check",plugin:"types",id:"types_02",reason:"valid_children prevents function: "+i,data:JSON.stringify({chk:i,pos:a,obj:r&&r.id?r.id:!1,par:s&&s.id?s.id:!1})},!1;if(d&&r.children_d&&r.parents){for(c=0,h=0,_=r.children_d.length;_>h;h++)c=Math.max(c,d[r.children_d[h]].parents.length);c=c-r.parents.length+1}(0>=c||c===t)&&(c=1);do{if(l.max_depth!==t&&-1!==l.max_depth&&c>l.max_depth)return this._data.core.last_error={error:"check",plugin:"types",id:"types_03",reason:"max_depth prevents function: "+i,data:JSON.stringify({chk:i,pos:a,obj:r&&r.id?r.id:!1,par:s&&s.id?s.id:!1})},!1;s=this.get_node(s.parent),l=this.get_rules(s),c++}while(s)}}return!0},this.get_rules=function(e){if(e=this.get_node(e),!e)return!1;var i=this.get_type(e,!0);return i.max_depth===t&&(i.max_depth=-1),i.max_children===t&&(i.max_children=-1),i.valid_children===t&&(i.valid_children=-1),i},this.get_type=function(t,i){return t=this.get_node(t),t?i?e.extend({type:t.type},this.settings.types[t.type]):t.type:!1},this.set_type=function(i,n){var r,s,a,o,d;if(e.isArray(i)){for(i=i.slice(),s=0,a=i.length;a>s;s++)this.set_type(i[s],n);return!0}return r=this.settings.types,i=this.get_node(i),r[n]&&i?(o=i.type,d=this.get_icon(i),i.type=n,(d===!0||r[o]&&r[o].icon&&d===r[o].icon)&&this.set_icon(i,r[n].icon!==t?r[n].icon:!0),!0):!1}},e.jstree.plugins.unique=function(t,i){this.check=function(t,n,r,s,a){if(i.check.call(this,t,n,r,s,a)===!1)return!1;if(n=n&&n.id?n:this.get_node(n),r=r&&r.id?r:this.get_node(r),!r||!r.children)return!0;var o="rename_node"===t?s:n.text,d=[],l=this._model.data,c,h;for(c=0,h=r.children.length;h>c;c++)d.push(l[r.children[c]].text);switch(t){case"delete_node":return!0;case"rename_node":case"copy_node":return c=-1===e.inArray(o,d),c||(this._data.core.last_error={error:"check",plugin:"unique",id:"unique_01",reason:"Child with name "+o+" already exists. Preventing: "+t,data:JSON.stringify({chk:t,pos:s,obj:n&&n.id?n.id:!1,par:r&&r.id?r.id:!1})}),c;case"move_node":return c=n.parent===r.id||-1===e.inArray(o,d),c||(this._data.core.last_error={error:"check",plugin:"unique",id:"unique_01",reason:"Child with name "+o+" already exists. Preventing: "+t,data:JSON.stringify({chk:t,pos:s,obj:n&&n.id?n.id:!1,par:r&&r.id?r.id:!1})}),c}return!0}};var g=document.createElement("DIV");g.setAttribute("unselectable","on"),g.className="jstree-wholerow",g.innerHTML=" ",e.jstree.plugins.wholerow=function(t,i){this.bind=function(){i.bind.call(this),this.element.on("loading",e.proxy(function(){g.style.height=this._data.core.li_height+"px"},this)).on("ready.jstree set_state.jstree",e.proxy(function(){this.hide_dots()},this)).on("ready.jstree",e.proxy(function(){this.get_container_ul().addClass("jstree-wholerow-ul")},this)).on("deselect_all.jstree",e.proxy(function(e,t){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked")},this)).on("changed.jstree",e.proxy(function(e,t){this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked");var i=!1,n,r;for(n=0,r=t.selected.length;r>n;n++)i=this.get_node(t.selected[n],!0),i&&i.length&&i.children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("open_node.jstree",e.proxy(function(e,t){this.get_node(t.node,!0).find(".jstree-clicked").parent().children(".jstree-wholerow").addClass("jstree-wholerow-clicked")},this)).on("hover_node.jstree dehover_node.jstree",e.proxy(function(e,t){this.get_node(t.node,!0).children(".jstree-wholerow")["hover_node"===e.type?"addClass":"removeClass"]("jstree-wholerow-hovered")},this)).on("contextmenu.jstree",".jstree-wholerow",e.proxy(function(t){t.preventDefault();var i=e.Event("contextmenu",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,pageX:t.pageX,pageY:t.pageY});e(t.currentTarget).closest("li").children("a:eq(0)").trigger(i)},this)).on("click.jstree",".jstree-wholerow",function(t){t.stopImmediatePropagation();var i=e.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});e(t.currentTarget).closest("li").children("a:eq(0)").trigger(i).focus()}).on("click.jstree",".jstree-leaf > .jstree-ocl",e.proxy(function(t){t.stopImmediatePropagation();var i=e.Event("click",{metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey});e(t.currentTarget).closest("li").children("a:eq(0)").trigger(i).focus()},this)).on("mouseover.jstree",".jstree-wholerow, .jstree-icon",e.proxy(function(e){return e.stopImmediatePropagation(),this.hover_node(e.currentTarget),!1},this)).on("mouseleave.jstree",".jstree-node",e.proxy(function(e){this.dehover_node(e.currentTarget)},this))},this.teardown=function(){this.settings.wholerow&&this.element.find(".jstree-wholerow").remove(),i.teardown.call(this)},this.redraw_node=function(t,n,r){if(t=i.redraw_node.call(this,t,n,r)){var s=g.cloneNode(!0);-1!==e.inArray(t.id,this._data.core.selected)&&(s.className+=" jstree-wholerow-clicked"),t.insertBefore(s,t.childNodes[0])}return t}}}}); \ No newline at end of file diff --git a/mfr/extensions/zip/static/js/jstreetable.js b/mfr/extensions/zip/static/js/jstreetable.js new file mode 100755 index 000000000..86559beaf --- /dev/null +++ b/mfr/extensions/zip/static/js/jstreetable.js @@ -0,0 +1,1066 @@ +/** + * MFR Customizations: + * + * "jstreetable.js" doesn't have a min version and the comments doesn't provide the release number. + * MFR uses 4.0.0: https://raw.githubusercontent.com/adamjimenez/jstree-table/4.0.0/jstreetable.js. + * There is no functional customization of the file except linting updates. Please refer to the + * ".eslintrc.json" in the MFR root for more information. + */ + +/* + * http://github.com/adamjimenez/jstree-table + * + * This plugin handles adding columns to a tree to display additional data + * + * Licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * Works only with jstree version >= 3.0.0 + * + * $Revision: 3.4.2 $ + */ + +/*jslint nosmen:true */ +/*jshint unused:vars */ +/*global navigator, document, jQuery, define, localStorage */ + +(function (factory) { + if (typeof define === "function" && define.amd) { + // AMD. Register as an anonymous module. + define(["jquery", "jstree"], factory); + } else { + // Browser globals + factory(jQuery); + } +}(function ($) { + var renderAWidth, renderATitle, getIndent, copyData, htmlstripre, findLastClosedNode, BLANKRE = /^\s*$/g, + IDREGEX = /[\\:&!^|()\[\]<>@*'+~#";,= \/${}%]/g, escapeId = function (id) { + return (id||"").replace(IDREGEX,"\\$&"); + }, NODE_DATA_ATTR = "data-jstreetable", COL_DATA_ATTR = "data-jstreetable-column", + SPECIAL_TITLE = "_DATA_", LEVELINDENT = 24, styled = false, TABLECELLID_PREFIX = "jstable_",TABLECELLID_POSTFIX = "_col", + MINCOLWIDTH = 10, + findDataCell = function (from,id) { + return from.find("div["+NODE_DATA_ATTR+"=\""+ escapeId(id) +"\"]"); + }, + isClickedSep = false, toResize = null, oldMouseX = 0, newMouseX = 0; + + /*jslint regexp:true */ + htmlstripre = /<\/?[^>]+>/gi; + /*jslint regexp:false */ + + getIndent = function(node,tree) { + var div, i, li, width; + + // did we already save it for this tree? + tree._tableSettings = tree._tableSettings || {}; + if (tree._tableSettings.indent > 0) { + width = tree._tableSettings.indent; + } else { + // create a new div on the DOM but not visible on the page + div = $("
    "); + i = node.prev("i"); + li = i.parent(); + // add to that div all of the classes on the tree root + div.addClass(tree.get_node("#",true).attr("class")); + + // move the li to the temporary div root + li.appendTo(div); + + // attach to the body quickly + div.appendTo($("body")); + + // get the width + width = i.width() || LEVELINDENT; + + // detach the li from the new div and destroy the new div + li.detach(); + div.remove(); + + // save it for the future + tree._tableSettings.indent = width; + } + + + return(width); + + }; + + copyData = function (fromtree,from,totree,to,recurse) { + var i, j; + to.data = $.extend(true, {}, from.data); + if (from && from.children_d && recurse) { + for(i = 0, j = from.children_d.length; i < j; i++) { + copyData(fromtree,fromtree.get_node(from.children_d[i]),totree,totree.get_node(to.children_d[i]),recurse); + } + } + }; + + findLastClosedNode = function (tree,id) { + // first get our node + var ret, node = tree.get_node(id), children = node.children; + // is it closed? + if (!children || children.length <= 0 || !node.state.opened) { + ret = id; + } else { + ret = findLastClosedNode(tree,children[children.length-1]); + } + return(ret); + }; + + renderAWidth = function(node,tree) { + var depth, width, + fullWidth = parseInt(tree.settings.table.columns[0].width,10) + parseInt(tree._tableSettings.treeWidthDiff,10); + // need to use a selector in jquery 1.4.4+ + depth = tree.get_node(node).parents.length; + width = fullWidth - depth*getIndent(node,tree); + // the following line is no longer needed, since we are doing this inside a + //a.css({"vertical-align": "top", "overflow":"hidden"}); + return(fullWidth); + }; + renderATitle = function(node,t,tree) { + var a = node.get(0).tagName.toLowerCase() === "a" ? node : node.children("a"), title, col = tree.settings.table.columns[0]; + // get the title + title = ""; + if (col.title) { + if (col.title === SPECIAL_TITLE) { + title = tree.get_text(t); + } else if (t.attr(col.title)) { + title = t.attr(col.title); + } + } + // strip out HTML + title = title.replace(htmlstripre, ""); + if (title) { + a.attr("title",title); + } + }; + + $.jstree.defaults.table = { + width: "auto" + }; + + $.jstree.plugins.table = function(options,parent) { + var _this = this; + + this._initialize = function () { + if (!this._initialized) { + var s = this.settings.table || {}, styles, container = this.element, i, + gs = this._tableSettings = { + columns : s.columns || [], + treeClass : "jstree-table-col-0", + context: s.contextmenu || false, + columnWidth : s.columnWidth, + defaultConf : {"*display":"inline","*+display":"inline"}, + isThemeroller : !!this._data.themeroller, + treeWidthDiff : 0, + resizable : s.resizable, + draggable : s.draggable, + stateful: s.stateful, + indent: 0, + sortFn: [], + sortOrder: "text", + sortAsc: true, + fixedHeader: s.fixedHeader !== false, + headerContextMenu: s.headerContextMenu !== false, + checkIcon: "fa fa-check", + arrowDownIcon: "fa fa-chevron-down", + arrowUpIcon: "fa fa-chevron-up", + width: s.width, + height: s.height + }, cols = gs.columns, treecol = 0; + // find which column our tree shuld go in + for (i=0;i"+styles.join("\n")+"").appendTo("head"); + } + this.tableWrapper = $("
    ").addClass("jstree-table-wrapper").insertAfter(container); + this.midWrapper = $("
    ").addClass("jstree-table-midwrapper").appendTo(this.tableWrapper); + // set the wrapper width + if (s.width) { + this.tableWrapper.width(s.width); + } + if (s.height) { + this.tableWrapper.height(s.height); + } + // create the data columns + for (i=0;i
    ").addClass("jstree-default jstree-table-column jstree-table-column-"+i+" jstree-table-column-root-"+this.rootid).appendTo(this.midWrapper); + + if (typeof(cols[i].value) === "function") { + console.warn("[jstree-table] using value as a function is no longer supported, use 'format' option instead."); + } + } + this.midWrapper.children("div:eq("+treecol+")").append(container); + container.addClass("jstree-table-cell"); + + //move header with scroll + if (gs.fixedHeader) { + this.tableWrapper.scroll(function() { + $(this).find(".jstree-table-header").css("top", $(this).scrollTop()); + }); + } + + // copy original sort function + var defaultSort = $.proxy(this.settings.sort, this); + + // override sort function + this.settings.sort = function (a, b) { + var bigger; + + if (gs.sortOrder==="text") { + bigger = defaultSort(a, b); + } else { + var nodeA = this.get_node(a); + var nodeB = this.get_node(b); + var valueA = nodeA.data[gs.sortOrder]; + var valueB = nodeB.data[gs.sortOrder]; + if(valueA && valueB){ + if(gs.sortFn[gs.sortOrder]){ + bigger = gs.sortFn[gs.sortOrder](valueA, valueB, nodeA, nodeB); + }else{ + // Default sorting + bigger = (valueA > valueB ? 1 : -1); + } + }else{ + // undefined is second + if(valueA){ + bigger = 1; + }else if(valueB){ + bigger = -1; + }else{ + // Compare two nodes without values + bigger = defaultSort(a, b); + } + } + } + + if (gs.sortAsc===false){ + bigger = -bigger; + + } + + return bigger; + }; + + // sortable columns when jQuery UI is available + if (gs.draggable) { + if (!$.ui || !$.ui.sortable) { + console.warn("[jstree-table] draggable option requires jQuery UI"); + } else { + var from, to; + + $(this.midWrapper).sortable({ + axis: "x", + handle: ".jstree-table-header", + cancel: ".jstree-table-separator", + start: function (event, ui) { + from = ui.item.index(); + }, + stop: function (event, ui) { + to = ui.item.index(); + gs.columns.splice(to, 0, gs.columns.splice(from, 1)[0]); + } + }); + } + } + + this._initialized = true; + } + }; + this.init = function (el,options) { + parent.init.call(this,el,options); + this._initialize(); + }; + this.bind = function () { + parent.bind.call(this); + this._initialize(); + this.element + .on("move_node.jstree create_node.jstree clean_node.jstree change_node.jstree", $.proxy(function (e, data) { + var target = this.get_node(data || "#",true); + this._prepare_table(target); + }, this)) + .on("delete_node.jstree",$.proxy(function (e,data) { + if (data.node.id !== undefined) { + var table = this.tableWrapper, removeNodes = [data.node.id], i; + // add children to remove list + if (data.node && data.node.children_d) { + removeNodes = removeNodes.concat(data.node.children_d); + } + for (i=0;idiv.jstree-table-cell-root-"+me.rootid+" {line-height: "+anchorHeight+"px; min-height: "+anchorHeight+"px;}div.jstree-table-midwrapper a.jstree-clicked:before, .jstree-table-midwrapper a.jstree-hovered:before {width: " + tableWidth + "px;}").appendTo("head"); + } + + resize(); + + // resize rows on zoom + $(window).on("resize", resize); + + // resize column expand + this.element.on("resize_column.jstree-table", resize); + },this)) + .on("move_node.jstree",$.proxy(function(e,data) { + var node = data.new_instance.element; + //renderAWidth(node,this); + // check all the children, because we could drag a tree over + node.find("li > a").each($.proxy(function(i,elm) { + //renderAWidth($(elm),this); + },this)); + },this)) + .on("search.jstree", $.proxy(function (e, data) { + // search sometimes filters, so we need to hide all of the appropriate table cells as well, and show only the matches + var table = this.tableWrapper; + if(this._data.search.som) { + if(data.nodes.length) { + // hide all of the table cells + table.find("div.jstree-table-cell-regular").hide(); + // show only those that match + data.nodes.add(data.nodes.parentsUntil(".jstree")).filter(".jstree-node").each(function (i,node) { + var id = node.id; + if (id) { + findDataCell(table,id).show(); + } + }); + } + } + return true; + }, this)) + .on("clear_search.jstree", $.proxy(function (e, data) { + // search has been cleared, so we need to show all rows + this.tableWrapper.find("div.jstree-table-cell").show(); + return true; + }, this)) + .on("copy_node.jstree", function (e, data) { + var newtree = data.new_instance, oldtree = data.old_instance, obj = newtree.get_node(data.node,true); + copyData(oldtree,data.original,newtree,data.node,true); + newtree._prepare_table(obj); + return true; + }); + if (this._tableSettings.isThemeroller) { + this.element + .on("select_node.jstree",$.proxy(function(e,data) { + data.rslt.obj.children("a").nextAll("div").addClass("ui-state-active"); + },this)) + .on("deselect_node.jstree deselect_all.jstree",$.proxy(function(e,data) { + data.rslt.obj.children("a").nextAll("div").removeClass("ui-state-active"); + },this)) + .on("hover_node.jstree",$.proxy(function(e,data) { + data.rslt.obj.children("a").nextAll("div").addClass("ui-state-hover"); + },this)) + .on("dehover_node.jstree",$.proxy(function(e,data) { + data.rslt.obj.children("a").nextAll("div").removeClass("ui-state-hover"); + },this)); + } + + if (this._tableSettings.stateful) { + this.element + .on("resize_column.jstree-table",$.proxy(function(e,col,width) { + localStorage["jstree-root-"+this.rootid+"-column-"+col] = width; + },this)); + } + }; + // tear down the tree entirely + this.teardown = function() { + var gw = this.tableWrapper, container = this.element, tableparent = gw.parent(); + container.detach(); + gw.remove(); + tableparent.append(container); + parent.teardown.call(this); + }; + // clean the table in case of redraw or refresh entire tree + this._clean_table = function (target,id) { + var table = this.tableWrapper; + if (target) { + findDataCell(table,id).remove(); + } else { + // get all of the `div` children in all of the `td` in dataRow except for :first (that is the tree itself) and remove + table.find("div.jstree-table-cell-regular").remove(); + } + }; + // prepare the headers + this._prepare_headers = function() { + var header, i, col, _this = this, gs = this._tableSettings,cols = gs.columns || [], width, defaultWidth = gs.columnWidth, resizable = gs.resizable || false, + cl, ccl, val, name, margin, last, tr = gs.isThemeroller, classAdd = (tr?"themeroller":"regular"), puller, + hasHeaders = false, tableparent = this.tableparent, rootid = this.rootid, + conf = gs.defaultConf, + borPadWidth = 0, totalWidth = 0; + // save the original parent so we can reparent on destroy + this.parent = tableparent; + + + // create the headers + for (i=0;i"); + //col.appendTo(colgroup); + cl = cols[i].headerClass || ""; + ccl = cols[i].columnClass || ""; + val = cols[i].header || ""; + name = cols[i].value || "text"; + + if (val) {hasHeaders = true;} + if(gs.stateful && localStorage["jstree-root-"+rootid+"-column-"+i]) + width = localStorage["jstree-root-"+rootid+"-column-"+i]; + else + width = cols[i].width || defaultWidth; + + col = this.midWrapper.children("div.jstree-table-column-"+i); + last = $("
    ").css(conf).addClass("jstree-table-div-"+this.uniq+"-"+i+" "+(tr?"ui-widget-header ":"")+" jstree-table-header jstree-table-header-cell jstree-table-header-"+classAdd+" "+cl+" "+ccl).html(val); + last.addClass((tr?"ui-widget-header ":"")+"jstree-table-header jstree-table-header-"+classAdd); + last.prependTo(col); + + if (name) { + last.attr(COL_DATA_ATTR, name); + } + last.hover(function () { + $(this).addClass("jstree-hovered jstree-table-header-hovered"); + }, function () { + $(this).removeClass("jstree-hovered jstree-table-header-hovered"); + }); + totalWidth += last.outerWidth(); + puller = $("
     
    ").appendTo(last); + col.width(width); + col.css("min-width",width); + col.css("max-width",width); + } + + last.addClass((tr?"ui-widget-header ":"")+"jstree-table-header jstree-table-header-last jstree-table-header-"+classAdd); + // if there is no width given for the last column, do it via automatic + if (cols[cols.length-1].width === undefined) { + totalWidth -= width; + col.css({width:"auto"}); + last.addClass("jstree-table-width-auto").next(".jstree-table-separator").remove(); + } + if (hasHeaders) { + // save the offset of the div from the body + //gs.divOffset = header.parent().offset().left; + gs.header = header; + } else { + $("div.jstree-table-header").hide(); + } + + if (!this.bound && resizable) { + this.bound = true; + $(document).mouseup(function () { + var ref, cols, width, headers, currentTree, colNum; + if (isClickedSep) { + colNum = toResize.prevAll(".jstree-table-column").length; + currentTree = toResize.closest(".jstree-table-wrapper").find(".jstree"); + ref = $.jstree.reference(currentTree); + cols = ref.settings.table.columns; + headers = toResize.parent().children("div.jstree-table-column"); + if (isNaN(colNum) || colNum < 0) { ref._tableSettings.treeWidthDiff = currentTree.find("ins:eq(0)").width() + currentTree.find("a:eq(0)").width() - ref._tableSettings.columns[0].width; } + width = ref._tableSettings.columns[colNum].width = parseFloat(toResize.css("width")); + isClickedSep = false; + toResize = null; + + currentTree.trigger("resize_column.jstree-table", [colNum,width]); + } + }).mousemove(function (e) { + if (isClickedSep) { + newMouseX = e.pageX; + var diff = newMouseX - oldMouseX, + oldPrevHeaderInner, + oldPrevColWidth, newPrevColWidth; + + if (diff !== 0) { + oldPrevHeaderInner = toResize.width(); + oldPrevColWidth = parseFloat(toResize.css("width")); + + // handle a Chrome issue with columns set to auto + // thanks to Brabus https://github.com/side-by-side + if (!oldPrevColWidth) { + oldPrevColWidth = toResize.innerWidth(); + } + + // make sure that diff cannot be beyond the left/right limits + diff = diff < 0 ? Math.max(diff,-oldPrevHeaderInner) : diff; + newPrevColWidth = oldPrevColWidth+diff; + + // only do this if we are not shrinking past 0 on left - and limit it to that amount + if ((diff > 0 || oldPrevHeaderInner > 0) && newPrevColWidth > MINCOLWIDTH) { + toResize.width(newPrevColWidth+"px"); + toResize.css("min-width",newPrevColWidth+"px"); + toResize.css("max-width",newPrevColWidth+"px"); + oldMouseX = newMouseX; + } + } + } + }); + this.tableWrapper.on("selectstart", ".jstree-table-resizable-separator", function () { + return false; + }) + .on("mousedown", ".jstree-table-resizable-separator", function (e) { + isClickedSep = true; + oldMouseX = e.pageX; + toResize = $(this).closest("div.jstree-table-column"); + // the max rightmost position we will allow is the right-most of the wrapper minus a buffer (10) + return false; + }) + .on("dblclick", ".jstree-table-resizable-separator", function (e) { + var col = $(this).closest("div.jstree-table-column"); + _this.autosize_column(col); + }) + .on("click", ".jstree-table-separator", function (e) { + // don't sort after resize + e.stopPropagation(); + }); + } + + this.tableWrapper.on("click", ".jstree-table-header-cell", function (e) { + if (!_this.sort) { return; } + + // get column + var name = $(this).attr(COL_DATA_ATTR); + if (!name) { return; } + + // sort order + var arrowClass; + if (gs.sortOrder === name && gs.sortAsc === true) { + gs.sortAsc = false; + arrowClass = gs.arrowDownIcon; + } else { + gs.sortOrder = name; + gs.sortAsc = true; + arrowClass = gs.arrowUpIcon; + } + + // add sort arrow + $(this).closest(".jstree-table-wrapper").find(".jstree-table-sort-icon").remove(); + $("").addClass("jstree-table-sort-icon").appendTo($(this)).addClass(arrowClass); + + // sort by column + var rootNode = _this.get_node("#"); + _this.sort(rootNode, true); + _this.redraw_node(rootNode, true); + }); + + // header context menu + this.midWrapper.on("contextmenu", ".jstree-table-header-cell", function(e) { + if (!gs.headerContextMenu) { return; } + e.preventDefault(); + + var options = { + "fit":{label:"Size column to fit","action": function (data) { + var col = $(e.target).closest("div.jstree-table-column"); + _this.autosize_column(col); + }}, + "fitAll":{"separator_after": true,label:"Size all columns to fit","action": function (data) { + _this.autosize_all_columns(); + }} + }; + + // create menu item for every header cell + var cell, icon, value, label; + _this.midWrapper.find(".jstree-table-header-cell").each(function() { + cell = $(this); + icon = cell.is(":visible") ? gs.checkIcon : false; + value = cell.attr(COL_DATA_ATTR); + //get label without sorting arrows + label = cell.clone().children(".jstree-table-sort-icon").remove().end().text().trim(); + + options[value] = {icon:icon, column:value, label:label, _disabled: (value === "text"), "action": function (data) { + var col = _this.midWrapper.find(".jstree-table-header-cell["+COL_DATA_ATTR+"='"+data.item.column+"']").parent(); + col.toggle(); + }}; + }); + + $.vakata.context.show(this,{ "x" : e.pageX, "y" : e.pageY },options); + }); + }; + /** + * Override redraw_node to correctly insert the table + */ + this.redraw_node = function(obj, deep, is_callback, force_render) { + // first allow the parent to redraw the node + obj = parent.redraw_node.call(this, obj, deep, is_callback, force_render); + // next prepare the table + if(obj) { + this._prepare_table(obj); + } + return obj; + }; + this.refresh = function () { + this._clean_table(); + return parent.refresh.apply(this,arguments); + }; + /** + * Override set_id to update cell attributes + */ + this.set_id = function (obj, id) { + var old; + if(obj) { + old = obj.id; + } + var result = parent.set_id.apply(this,arguments); + if(result) { + if (old !== undefined) { + var table = this.tableWrapper, oldNodes = [old], i; + // get children + if (obj && obj.children_d) { + oldNodes = oldNodes.concat(obj.children_d); + } + // update id in children + for (i=0;i", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"), + h2 = $("<"+"input />", { + "value" : t, + "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" // will be set a bit further down + }, + "blur" : $.proxy(function () { + var v = h2.val(); + // save the value if changed + if(v === "" || v === t) { + v = t; + } else { + obj.data[col.value] = v; + this.element.trigger("update_cell.jstree-table",{node:obj, col:col.value, value:v, old:t}); + this._prepare_table(this.get_node(obj,true)); + } + h2.remove(); + element.show(); + }, this), + "keydown" : function (event) { + var key = event.which; + if(key === 27) { + this.value = t; + } + if(key === 27 || key === 13 || key === 37 || key === 38 || key === 39 || key === 40 || key === 32) { + event.stopImmediatePropagation(); + } + if(key === 27 || key === 13) { + event.preventDefault(); + this.blur(); + } + }, + "click" : function (e) { e.stopImmediatePropagation(); }, + "mousedown" : function (e) { e.stopImmediatePropagation(); }, + "keyup" : function (event) { + h2.width(Math.min(h1.text("pW" + this.value).width(),w)); + }, + "keypress" : function(event) { + if(event.which === 13) { return false; } + } + }), + fn = { + fontFamily : element.css("fontFamily") || "", + fontSize : element.css("fontSize") || "", + fontWeight : element.css("fontWeight") || "", + fontStyle : element.css("fontStyle") || "", + fontStretch : element.css("fontStretch") || "", + fontVariant : element.css("fontVariant") || "", + letterSpacing : element.css("letterSpacing") || "", + wordSpacing : element.css("wordSpacing") || "" + }; + element.hide(); + element.parent().append(h2); + h2.css(fn).width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select(); + }; + + this.autosize_column = function (col) { + // don't resize hidden columns + if (col.is(":hidden")) { return; } + + var oldPrevColWidth = parseFloat(col.css("width")), newWidth = 0, diff, + colNum = col.prevAll(".jstree-table-column").length, + oldPrevHeaderInner = col.width(), newPrevColWidth; + + //find largest width + col.find(".jstree-table-cell").each(function() { + var item = $(this), width; + item.css("position", "absolute"); + item.css("width", "auto"); + width = item.outerWidth(); + item.css("position", "relative"); + + if (width>newWidth) { + newWidth = width; + } + }); + + diff = newWidth-oldPrevColWidth; + + // make sure that diff cannot be beyond the left limits + diff = diff < 0 ? Math.max(diff,-oldPrevHeaderInner) : diff; + newPrevColWidth = (oldPrevColWidth+diff)+"px"; + + col.width(newPrevColWidth); + col.css("min-width",newPrevColWidth); + col.css("max-width",newPrevColWidth); + + $(this).closest(".jstree-table-wrapper").find(".jstree").trigger("resize_column.jstree-table",[colNum,newPrevColWidth]); + }; + + this.autosize_all_columns = function () { + this.tableWrapper.find(".jstree-table-column").each(function() { + _this.autosize_column($(this)); + }); + }; + + this._prepare_table = function (obj) { + var gs = this._tableSettings, c = gs.treeClass, _this = this, t, cols = gs.columns || [], width, tr = gs.isThemeroller, + tree = this.element, rootid = this.rootid, + classAdd = (tr?"themeroller":"regular"), img, objData = this.get_node(obj), + defaultWidth = gs.columnWidth, conf = gs.defaultConf, cellClickHandler = function (tree,node,val,col,t) { + return function(e) { + //node = tree.find("#"+node.attr("id")); + node.children(".jstree-anchor").trigger("click.jstree",e); + tree.trigger("select_cell.jstree-table", [{value: val,column: col.header,node: node,table:$(this),sourceName: col.value}]); + }; + }, cellRightClickHandler = function (tree,node,val,col,t) { + return function (e) { + if (gs.context) { + e.preventDefault(); + $.vakata.context.show(this,{ "x" : e.pageX, "y" : e.pageY },{ + "edit":{label:"Edit","action": function (data) { + var obj = t.get_node(node); + _this._edit(obj,col,e.target); + }} + }); + } + }; + }, + hoverInHandler = function (node, jsTreeInstance) { + return function() { jsTreeInstance.hover_node(node); }; + }, + hoverOutHandler = function (node, jsTreeInstance) { + return function() { jsTreeInstance.dehover_node(node); }; + }, + i, val, cl, wcl, ccl, a, last, valClass, wideValClass, span, paddingleft, title, tableCellName, tableCellParentId, tableCellParent, + tableCellPrev, tableCellPrevId, tableCellNext, tableCellNextId, tableCellChild, tableCellChildId, + col, content, tmpWidth, mw = this.midWrapper, dataCell, lid = objData.id, + peers = this.get_node(objData.parent).children, + // find my position in the list of peers. "peers" is the list of everyone at my level under my parent, in order + pos = $.inArray(lid,peers), + hc = this.holdingCells, rendered = false, closed; + // get our column definition + t = $(obj); + + // find the a children + a = t.children("a"); + + if (a.length === 1) { + closed = !objData.state.opened; + tableCellName = TABLECELLID_PREFIX+escapeId(lid)+TABLECELLID_POSTFIX; + tableCellParentId = objData.parent === "#" ? null : objData.parent; + a.addClass(c); + //renderAWidth(a,_this); + renderATitle(a,t,_this); + last = a; + // find which column our tree shuld go in + var s = this.settings.table; + var treecol = 0; + for (i=0;i
    " : "";} + } else { content = val; } + + // content cannot be blank, or it messes up heights + if (content === undefined || content === null || BLANKRE.test(content)) { + content = " "; + } + + // get the valueClass + valClass = col.valueClass && objData.data !== null && objData.data !== undefined ? objData.data[col.valueClass] || "" : ""; + if (valClass && col.valueClassPrefix && col.valueClassPrefix !== "") { + valClass = col.valueClassPrefix + valClass; + } + // get the wideValueClass + wideValClass = col.wideValueClass && objData.data !== null && objData.data !== undefined ? objData.data[col.wideValueClass] || "" : ""; + if (wideValClass && col.wideValueClassPrefix && col.wideValueClassPrefix !== "") { + wideValClass = col.wideValueClassPrefix + wideValClass; + } + // get the title + title = col.title && objData.data !== null && objData.data !== undefined ? objData.data[col.title] || "" : ""; + // strip out HTML + if (typeof title === "string") { + title = title.replace(htmlstripre, ""); + } + + // get the width + paddingleft = 7; + width = col.width || defaultWidth; + if (width !== "auto") { + width = tmpWidth || (width - paddingleft); + } + + last = findDataCell(dataCell, lid); + if (!last || last.length < 1) { + last = $("
    "); + $("").appendTo(last); + last.attr("id",tableCellName+i); + last.addClass(tableCellName); + last.attr(NODE_DATA_ATTR,lid); + + } + // we need to put it in the dataCell - after the parent, but the position matters + // if we have no parent, then we are one of the root nodes, but still need to look at peers + + + // if we are first, i.e. pos === 0, we go right after the parent; + // if we are not first, and our previous peer (one before us) is closed, we go right after the previous peer cell + // if we are not first, and our previous peer is opened, then we have to find its youngest & lowest closed child (incl. leaf) + // + // probably be much easier to go *before* our next one + // but that one might not be drawn yet + // here is the logic for jstree drawing: + // it draws peers from first to last or from last to first + // it draws children before a parent + // + // so I can rely on my *parent* not being drawn, but I cannot rely on my previous peer or my next peer being drawn + + // so we do the following: + // 1- We are the first child: install after the parent + // 2- Our previous peer is already drawn: install after the previous peer + // 3- Our previous peer is not drawn, we have a child that is drawn: install right before our first child + // 4- Our previous peer is not drawn, we have no child that is drawn, our next peer is drawn: install right before our next peer + // 5- Our previous peer is not drawn, we have no child that is drawn, our next peer is not drawn: install right after parent + tableCellPrevId = pos <=0 ? objData.parent : findLastClosedNode(this,peers[pos-1]); + tableCellPrev = findDataCell(dataCell,tableCellPrevId); + tableCellNextId = pos >= peers.length-1 ? "NULL" : peers[pos+1]; + tableCellNext = findDataCell(dataCell,tableCellNextId); + tableCellChildId = objData.children && objData.children.length > 0 ? objData.children[0] : "NULL"; + tableCellChild = findDataCell(dataCell,tableCellChildId); + tableCellParent = findDataCell(dataCell,tableCellParentId); + + // if our parent is already drawn, then we put this in the right order under our parent + if (tableCellParentId) { + if (tableCellParent && tableCellParent.length > 0) { + if (tableCellPrev && tableCellPrev.length > 0) { + last.insertAfter(tableCellPrev); + } else if (tableCellChild && tableCellChild.length > 0) { + last.insertBefore(tableCellChild); + } else if (tableCellNext && tableCellNext.length > 0) { + last.insertBefore(tableCellNext); + } else { + last.insertAfter(tableCellParent); + } + rendered = true; + } else { + rendered = false; + } + // always put it in the holding cells, and then sort when the parent comes in, in case parent is (re)drawn later + hc[tableCellName+i] = last; + } else { + if (tableCellPrev && tableCellPrev.length > 0) { + last.insertAfter(tableCellPrev); + } else if (tableCellChild && tableCellChild.length > 0) { + last.insertBefore(tableCellChild); + } else if (tableCellNext && tableCellNext.length > 0) { + last.insertBefore(tableCellNext); + } else { + last.appendTo(dataCell); + } + rendered = true; + } + // do we have any children waiting for this cell? walk down through the children/grandchildren/etc tree + if (rendered) { + last.after(this.getHoldingCells(objData,i,hc)); + } + // need to make the height of this match the line height of the tree. How? + span = last.children("span"); + + // create a span inside the div, so we can control what happens in the whole div versus inside just the text/background + span.addClass(cl+" "+valClass).html(content); + last = last.css(conf).addClass("jstree-table-cell jstree-table-cell-regular jstree-table-cell-root-"+rootid+" jstree-table-cell-"+classAdd+" "+wcl+ " " + wideValClass + (tr?" ui-state-default":"")).addClass("jstree-table-col-"+i); + // add click handler for clicking inside a table cell + last.click(cellClickHandler(tree,t,val,col,this)); + last.on("contextmenu",cellRightClickHandler(tree,t,val,col,this)); + last.hover(hoverInHandler(t, this), hoverOutHandler(t, this)); + + if (title) { + span.attr("title",title); + } + } + last.addClass("jstree-table-cell-last"+(tr?" ui-state-default":"")); + // if there is no width given for the last column, do it via automatic + if (cols[cols.length-1].width === undefined) { + last.addClass("jstree-table-width-auto").next(".jstree-table-separator").remove(); + } + } + this.element.css({"overflow-y":"auto !important"}); + }; + // clean up holding cells + this.holdingCells = {}; + }; +})); diff --git a/mfr/extensions/zip/static/jstree-theme/32px.png b/mfr/extensions/zip/static/jstree-theme/32px.png new file mode 100755 index 000000000..803950234 Binary files /dev/null and b/mfr/extensions/zip/static/jstree-theme/32px.png differ diff --git a/mfr/extensions/zip/static/jstree-theme/40px.png b/mfr/extensions/zip/static/jstree-theme/40px.png new file mode 100755 index 000000000..a66b8f78e Binary files /dev/null and b/mfr/extensions/zip/static/jstree-theme/40px.png differ diff --git a/mfr/extensions/zip/static/jstree-theme/style.min.css b/mfr/extensions/zip/static/jstree-theme/style.min.css new file mode 100755 index 000000000..f9822c747 --- /dev/null +++ b/mfr/extensions/zip/static/jstree-theme/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:#000;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 #999}.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;text-decoration:none;width:auto;color:#000;white-space:nowrap;line-height:2.4em;text-shadow:1px 1px 0 #fff;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:#fff;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:0 0;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:#fff;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:#fff;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}.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 #ccc}.jstree-default .jstree-context{background:#e7f4f9;border-radius:2px;box-shadow:inset 0 0 1px #ccc}.jstree-default .jstree-clicked{background:#beebff;border-radius:2px;box-shadow:inset 0 0 1px #999}.jstree-default .jstree-no-icons .jstree-anchor>.jstree-themeicon{display:none}.jstree-default .jstree-disabled{background:0 0;color:#666}.jstree-default .jstree-disabled.jstree-hovered{background:0 0;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:700}.jstree-default .jstree-no-checkboxes .jstree-checkbox{display:none!important}.jstree-default.jstree-checkbox-no-clicked .jstree-clicked{background:0 0;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:0 0}.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:0 0;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:0 0}.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:0 0}.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:0 0}.jstree-default .jstree-disabled.jstree-hovered{background:0 0}.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:0 0}.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:0 0}.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:0 0;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:0 0}.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:0 0}.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:0 0}.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:0 0}.jstree-default-small .jstree-disabled.jstree-hovered{background:0 0}.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:0 0}.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:0 0}.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:0 0;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:0 0}.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:0 0}.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:0 0}.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:0 0}.jstree-default-large .jstree-disabled.jstree-hovered{background:0 0}.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:0 0}.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:0 0}.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:0 0;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-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:0 0}@media (max-width:768px){#jstree-dnd.jstree-dnd-responsive{line-height:40px;font-weight:700;font-size:1.1em;text-shadow:1px 1px #fff}#jstree-dnd.jstree-dnd-responsive>i{background:0 0;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:0 0}.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:0 0}.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:0 0}.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:700;font-size:1.1em;text-shadow:1px 1px #fff}.jstree-default-responsive>.jstree-striped{background:0 0}.jstree-default-responsive .jstree-wholerow{border-top:1px solid rgba(255,255,255,.7);border-bottom:1px solid rgba(64,64,64,.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 #666}.jstree-default-responsive .jstree-children .jstree-open>.jstree-wholerow{box-shadow:inset 0 6px 3px -5px #666;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:0 0}.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/mfr/extensions/zip/static/jstree-theme/throbber.gif b/mfr/extensions/zip/static/jstree-theme/throbber.gif new file mode 100755 index 000000000..2525782bb Binary files /dev/null and b/mfr/extensions/zip/static/jstree-theme/throbber.gif differ diff --git a/mfr/extensions/zip/templates/viewer.mako b/mfr/extensions/zip/templates/viewer.mako index f8b8b5438..de29a152a 100644 --- a/mfr/extensions/zip/templates/viewer.mako +++ b/mfr/extensions/zip/templates/viewer.mako @@ -1,31 +1,51 @@ - - -
    -

    - Zip File: -

    -

    - Download the .zip file to view the contents. -

    - ${message} - - - - - - - - % for file in zipped_filenames: - - - - - % endfor - -
    File NameModifiedSize
    ${file['name']}${file['date']}${file['size']} -
    + + + + + + + + +
    + +
    + + diff --git a/tests/extensions/zip/__init__.py b/tests/extensions/zip/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/extensions/zip/files/empty.zip b/tests/extensions/zip/files/empty.zip deleted file mode 100644 index 15cb0ecb3..000000000 Binary files a/tests/extensions/zip/files/empty.zip and /dev/null differ diff --git a/tests/extensions/zip/files/test.zip b/tests/extensions/zip/files/test.zip deleted file mode 100644 index 8338e8a2d..000000000 Binary files a/tests/extensions/zip/files/test.zip and /dev/null differ diff --git a/tests/extensions/zip/files/zip-empty.zip b/tests/extensions/zip/files/zip-empty.zip new file mode 100644 index 000000000..6e0bd5d41 Binary files /dev/null and b/tests/extensions/zip/files/zip-empty.zip differ diff --git a/tests/extensions/zip/files/zip-test.zip b/tests/extensions/zip/files/zip-test.zip new file mode 100644 index 000000000..459822d2a Binary files /dev/null and b/tests/extensions/zip/files/zip-test.zip differ diff --git a/tests/extensions/zip/fixtures/obj_list.json b/tests/extensions/zip/fixtures/obj_list.json new file mode 100644 index 000000000..6c102f131 --- /dev/null +++ b/tests/extensions/zip/fixtures/obj_list.json @@ -0,0 +1,22 @@ +{ + "test_file_list": [ + "zip-test/", + "zip-test/file-generic-ext.mfr", + "zip-test/folder-3/", + "zip-test/folder-3/folder-3-1/", + "zip-test/folder-3/folder-3-1/text-3.docx", + "zip-test/folder-3/folder-3-1/folder-3-1-1/", + "zip-test/folder-3/folder-3-1/folder-3-1-1/image-3.bmp", + "zip-test/folder-2/", + "zip-test/folder-2/text-2.pdf", + "zip-test/folder-2/folder-2-1/", + "zip-test/folder-2/folder-2-1/image-2.jpg", + "zip-test/file-no-ext", + "zip-test/folder-1/", + "zip-test/folder-1/text-1.txt", + "zip-test/folder-1/image-1.png" + ], + "empty_file_list": [ + "zip-empty/" + ] +} diff --git a/tests/extensions/zip/fixtures/obj_tree.json b/tests/extensions/zip/fixtures/obj_tree.json new file mode 100644 index 000000000..52fa7f94e --- /dev/null +++ b/tests/extensions/zip/fixtures/obj_tree.json @@ -0,0 +1,319 @@ +{ + "test_file_tree": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-zip.png", + "text": "test.zip", + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "zip-test", + "data": { + "size": "", + "date": "2018-04-16 11:52:50" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-generic.png", + "text": "file-generic-ext.mfr", + "data": { + "size": " 29B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-3", + "data": { + "size": "", + "date": "2018-04-16 17:07:48" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-3-1", + "data": { + "size": "", + "date": "2018-04-16 11:56:56" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-docx.png", + "text": "text-3.docx", + "data": { + "size": " 19B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-3-1-1", + "data": { + "size": "", + "date": "2018-04-16 11:57:12" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-bmp.png", + "text": "image-3.bmp", + "data": { + "size": " 17B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + } + ] + } + ] + } + ] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-2", + "data": { + "size": "", + "date": "2018-04-16 11:56:50" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-pdf.png", + "text": "text-2.pdf", + "data": { + "size": " 37B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-2-1", + "data": { + "size": "", + "date": "2018-04-16 11:56:56" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-jpg.png", + "text": "image-2.jpg", + "data": { + "size": " 26B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + } + ] + } + ] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-generic.png", + "text": "file-no-ext", + "data": { + "size": " 19B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-1", + "data": { + "size": "", + "date": "2018-04-16 11:50:48" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-txt.png", + "text": "text-1.txt", + "data": { + "size": " 35B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-png.png", + "text": "image-1.png", + "data": { + "size": " 19B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + } + ] + } + ] + } + ] + } + ], + "test_file_tree_sorted": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-zip.png", + "text": "test.zip", + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "zip-test", + "data": { + "size": "", + "date": "2018-04-16 11:52:50" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-generic.png", + "text": "file-generic-ext.mfr", + "data": { + "size": " 29B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-generic.png", + "text": "file-no-ext", + "data": { + "size": " 19B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-1", + "data": { + "size": "", + "date": "2018-04-16 11:50:48" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-png.png", + "text": "image-1.png", + "data": { + "size": " 19B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-txt.png", + "text": "text-1.txt", + "data": { + "size": " 35B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + } + ] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-2", + "data": { + "size": "", + "date": "2018-04-16 11:56:50" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-2-1", + "data": { + "size": "", + "date": "2018-04-16 11:56:56" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-jpg.png", + "text": "image-2.jpg", + "data": { + "size": " 26B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + } + ] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-pdf.png", + "text": "text-2.pdf", + "data": { + "size": " 37B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + } + ] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-3", + "data": { + "size": "", + "date": "2018-04-16 17:07:48" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-3-1", + "data": { + "size": "", + "date": "2018-04-16 11:56:56" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-3-1-1", + "data": { + "size": "", + "date": "2018-04-16 11:57:12" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-bmp.png", + "text": "image-3.bmp", + "data": { + "size": " 17B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + } + ] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-docx.png", + "text": "text-3.docx", + "data": { + "size": " 19B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + } + ] + } + ] + } + ] + } + ] + } + ], + "empty_file_tree": [ + { + "text": "test.zip", + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-zip.png", + "children": [ + { + "text": "zip-empty", + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "data": { + "date": "2018-04-16 11:53:50", + "size": "" + }, + "children": [] + } + ] + } + ] +} diff --git a/tests/extensions/zip/fixtures/obj_tree_partial.json b/tests/extensions/zip/fixtures/obj_tree_partial.json new file mode 100644 index 000000000..2a3fe0c84 --- /dev/null +++ b/tests/extensions/zip/fixtures/obj_tree_partial.json @@ -0,0 +1,90 @@ +{ + "test_file_tree_partial": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-zip.png", + "text": "test.zip", + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "zip-test", + "data": { + "size": "", + "date": "2018-04-16 11:52:50" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-generic.png", + "text": "file-generic-ext.mfr", + "data": { + "size": " 29B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-2", + "data": { + "size": "", + "date": "2018-04-16 11:56:50" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-pdf.png", + "text": "text-2.pdf", + "data": { + "size": " 37B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/folder.png", + "text": "folder-2-1", + "data": { + "size": "", + "date": "2018-04-16 11:56:56" + }, + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-jpg.png", + "text": "image-2.jpg", + "data": { + "size": " 26B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + } + ] + } + ] + }, + { + "text": "folder-1", + "children": [ + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-txt.png", + "text": "text-1.txt", + "data": { + "size": " 35B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + }, + { + "icon": "http://mfr.osf.io/assets/zip/img/file-ext-png.png", + "text": "image-1.png", + "data": { + "size": " 19B", + "date": "2018-03-27 15:42:32" + }, + "children": [] + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/extensions/zip/test_renderer.py b/tests/extensions/zip/test_renderer.py index 162e27349..877b4beba 100644 --- a/tests/extensions/zip/test_renderer.py +++ b/tests/extensions/zip/test_renderer.py @@ -1,42 +1,88 @@ import os -import re +import json from zipfile import ZipFile import pytest -from bs4 import BeautifulSoup -from mfr.core.provider import ProviderMetadata from mfr.extensions.zip import ZipRenderer - +from mfr.core.provider import ProviderMetadata BASE = os.path.dirname(os.path.abspath(__file__)) @pytest.fixture -def metadata(): - return ProviderMetadata('test', - '.zip', - 'text/plain', - '1234', - 'http://wb.osf.io/file/test.zip?token=1234') +def test_file(): + return ZipFile(os.path.join(BASE, 'files', 'zip-test.zip'), 'r') + @pytest.fixture -def zip_file(): - return ZipFile(os.path.join(BASE, 'files', 'test.zip'), 'r') +def empty_file(): + return ZipFile(os.path.join(BASE, 'files', 'zip-empty.zip'), 'r') @pytest.fixture -def zip_empty_file(): - return ZipFile(os.path.join(BASE, 'files', 'empty.zip'), 'r') +def test_file_path(): + return os.path.join(BASE, 'files', 'zip-test.zip') @pytest.fixture def test_file_path(): - return os.path.join(BASE, 'files', 'test.zip') + return os.path.join(BASE, 'files', 'zip-empty.zip') + + +@pytest.fixture +def test_file_obj_name_list(): + with open(os.path.join(os.path.dirname(__file__), 'fixtures/obj_list.json'), 'r') as fp: + return json.load(fp)['test_file_list'] + + +@pytest.fixture +def empty_file_obj_name_list(): + with open(os.path.join(os.path.dirname(__file__), 'fixtures/obj_list.json'), 'r') as fp: + return json.load(fp)['empty_file_list'] + + +@pytest.fixture +def test_file_obj_list(test_file): + return ZipRenderer.sanitize_obj_list(test_file.filelist, sort=False) + + +@pytest.fixture +def test_file_sorted_obj_list(test_file): + return ZipRenderer.sanitize_obj_list(test_file.filelist, sort=True) + + +@pytest.fixture +def test_file_obj_tree(): + with open(os.path.join(os.path.dirname(__file__), 'fixtures/obj_tree.json'), 'r') as fp: + return json.load(fp)['test_file_tree'] + + +@pytest.fixture +def test_file_obj_tree_sorted(): + with open(os.path.join(os.path.dirname(__file__), 'fixtures/obj_tree.json'), 'r') as fp: + return json.load(fp)['test_file_tree_sorted'] @pytest.fixture -def url(): +def empty_file_obj_list(empty_file): + return ZipRenderer.sanitize_obj_list(empty_file.filelist, sort=False) + + +@pytest.fixture +def empty_file_obj_tree(): + with open(os.path.join(os.path.dirname(__file__), 'fixtures/obj_tree.json'), 'r') as fp: + return json.load(fp)['empty_file_tree'] + + +@pytest.fixture +def file_metadata(): + return ProviderMetadata('test', '.zip', 'text/plain', '9876543210', + 'https://test-wb.osf.io/file/test.zip?token=9876543210') + + +@pytest.fixture +def file_url(): return 'http://osf.io/file/test.zip' @@ -46,45 +92,142 @@ def assets_url(): @pytest.fixture -def export_url(url): - return 'http://mfr.osf.io/export?url=' + url +def export_url(file_url): + return 'http://mfr.osf.io/export?url=' + file_url + + +@pytest.fixture +def test_file_renderer(file_metadata, test_file_path, file_url, assets_url, export_url): + return ZipRenderer(file_metadata, test_file_path, file_url, assets_url, export_url) @pytest.fixture -def renderer(metadata, test_file_path, url, assets_url, export_url): - return ZipRenderer(metadata, test_file_path, url, assets_url, export_url) +def empty_file_renderer(file_metadata, test_file_path, file_url, assets_url, export_url): + return ZipRenderer(file_metadata, test_file_path, file_url, assets_url, export_url) +@pytest.fixture +def test_file_obj_tree_partial(): + with open(os.path.join(os.path.dirname(__file__), 'fixtures/obj_tree_partial.json'), 'r') as fp: + return json.load(fp)['test_file_tree_partial'][0] -def remove_whitespace(str): - str = re.sub('\n*', '', str) - return re.sub(r'\ {2,}', '', str) +@pytest.fixture +def new_file_to_add(test_file_obj_tree_partial): + return { + 'full_path': 'zip-test/file-no-ext', + 'path_segment': 'file-no-ext', + 'siblings': test_file_obj_tree_partial['children'][0]['children'] + } -class TestZipRenderer: - def test_render(self, renderer): - body = renderer.render() - parsed_html = BeautifulSoup(body) - rows = parsed_html.findChildren('table')[0].findChildren(['tr']) +@pytest.fixture +def new_folder_to_add(test_file_obj_tree_partial): + return { + 'full_path': 'zip-test/folder-3/', + 'path_segment': 'folder-3', + 'siblings': test_file_obj_tree_partial['children'][0]['children'] + } - name = rows[2].findChildren('td')[0].get_text().strip() - assert 'test/test 1' == name - date_modified = rows[2].findChildren('td')[1].get_text().strip() - assert '2017-03-02 16:22:14' == date_modified +@pytest.fixture +def exiting_folder_to_skip(test_file_obj_tree_partial): + return { + 'full_path': 'zip-test/folder-2/text-2.pdf', + 'path_segment': 'folder-2', + 'siblings': test_file_obj_tree_partial['children'][0]['children'] + } - size = rows[2].findChildren('td')[2].get_text().strip() - assert '15B' == size - # non-expanded zip file should have no children - name = rows[4].findChildren('td')[0].get_text().strip() - assert 'test/zip file which is not expanded.zip' == name - assert body.count('zip file which is not expanded.zip') == 1 +@pytest.fixture +def existing_folder_to_update(test_file_obj_tree_partial): + return { + 'full_path': 'zip-test/folder-1/', + 'path_segment': 'folder-1', + 'siblings': test_file_obj_tree_partial['children'][0]['children'], + 'icon': 'http://mfr.osf.io/assets/zip/img/folder.png', + 'data': { + 'size': '', + 'date': '2018-04-16 11:50:48' + }, + } + - size = rows[4].findChildren('td')[2].get_text().strip() - assert '1.8KB' == size # formatting of larger byte sizes +@pytest.fixture +def obj_zip_info_to_update(test_file): + for obj in test_file.filelist: + if obj.filename == 'zip-test/folder-1/': + return obj - # hidden files should be hidden - assert body.count('__MACOSX') == 0 +class TestZipRenderer: + + # The rendered template HTML does not contain the actual data + def test_render(self, test_file_renderer): + test_file_renderer.render() + + def test_sanitize_obj_list(self, test_file, test_file_obj_name_list): + obj_list = ZipRenderer.sanitize_obj_list(test_file.filelist) + obj_name_list = [obj.filename for obj in obj_list if obj] + assert sorted(obj_name_list) == sorted(test_file_obj_name_list) + + def test_sanitize_and_sort_obj_list(self, test_file, test_file_obj_name_list): + sorted_obj_list = ZipRenderer.sanitize_obj_list(test_file.filelist, sort=True) + sorted_obj_name_list = [obj.filename for obj in sorted_obj_list if obj] + assert sorted_obj_name_list == sorted(test_file_obj_name_list) + + def test_sanitize_obj_list_empty(self, empty_file, empty_file_obj_name_list): + obj_list = ZipRenderer.sanitize_obj_list(empty_file.filelist) + obj_name_list = [obj.filename for obj in obj_list if obj] + assert sorted(obj_name_list) == sorted(empty_file_obj_name_list) + + def test_find_node_among_siblings_return_node(self, exiting_folder_to_skip): + segment = exiting_folder_to_skip['path_segment'] + siblings = exiting_folder_to_skip['siblings'] + assert ZipRenderer.find_node_among_siblings(segment, siblings) + + def test_find_node_among_siblings_return_none_file(self, new_file_to_add): + segment = new_file_to_add['path_segment'] + siblings = new_file_to_add['siblings'] + assert not ZipRenderer.find_node_among_siblings(segment, siblings) + + def test_find_node_among_siblings_return_none_folder(self, new_folder_to_add): + segment = new_folder_to_add['path_segment'] + siblings = new_folder_to_add['siblings'] + assert not ZipRenderer.find_node_among_siblings(segment, siblings) + + def test_icon_exists_true(self): + assert ZipRenderer.icon_exists('png') + + def test_icon_exists_false(self): + assert not ZipRenderer.icon_exists('mfr') + + def test_update_node_with_attributes(self, test_file_renderer, obj_zip_info_to_update, + existing_folder_to_update): + segment = existing_folder_to_update['path_segment'] + siblings = existing_folder_to_update['siblings'] + node_to_update = ZipRenderer.find_node_among_siblings(segment, siblings) + assert not node_to_update.get('data', None) and not node_to_update.get('icon', None) + test_file_renderer.update_node_with_attributes(node_to_update, obj_zip_info_to_update) + assert node_to_update.get('data', {}) == existing_folder_to_update['data'] + assert node_to_update.get('icon', {}) == existing_folder_to_update['icon'] + + def test_unsorted_obj_list_to_tree(self, test_file_obj_list, test_file_renderer, + test_file_obj_tree): + obj_tree = test_file_renderer.unsorted_obj_list_to_tree(test_file_obj_list) + assert obj_tree == test_file_obj_tree + + def test_sorted_obj_list_to_tree(self, test_file_sorted_obj_list, test_file_renderer, + test_file_obj_tree_sorted): + obj_tree = test_file_renderer.sorted_obj_list_to_tree(test_file_sorted_obj_list) + assert obj_tree == test_file_obj_tree_sorted + + def test_unsorted_obj_list_to_tree_empty(self, empty_file_obj_list, empty_file_renderer, + empty_file_obj_tree): + obj_tree = empty_file_renderer.unsorted_obj_list_to_tree(empty_file_obj_list) + assert obj_tree == empty_file_obj_tree + + def test_sorted_obj_list_to_tree_empty(self, empty_file_obj_list, empty_file_renderer, + empty_file_obj_tree): + obj_tree = empty_file_renderer.sorted_obj_list_to_tree(empty_file_obj_list) + assert obj_tree == empty_file_obj_tree