Mercurial > hg > mpiwg_geobrowser
changeset 2:35c11979b58b
added current version of platin
author | Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 02 Jun 2015 13:52:44 +0200 |
parents | ea066ce001bd |
children | 1b6cde0e4b83 |
files | lib/GeoTemCo/platin.js |
diffstat | 1 files changed, 6 insertions(+), 8441 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/GeoTemCo/platin.js Fri May 29 13:59:32 2015 +0200 +++ b/lib/GeoTemCo/platin.js Tue Jun 02 13:52:44 2015 +0200 @@ -18303,7245 +18303,6 @@ }; })(jQuery); -/*globals jQuery, define, exports, require, window, document, postMessage */ -(function (factory) { - "use strict"; - if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); - } - else if(typeof exports === 'object') { - factory(require('jquery')); - } - else { - factory(jQuery); - } -}(function ($, undefined) { - "use strict"; -/*! - * jsTree 3.0.9 - * http://jstree.com/ - * - * Copyright (c) 2014 Ivan Bozhanov (http://vakata.com) - * - * Licensed same as jquery - under the terms of the MIT License - * http://www.opensource.org/licenses/mit-license.php - */ -/*! - * if using jslint please allow for the jQuery global and use following options: - * jslint: browser: true, ass: true, bitwise: true, continue: true, nomen: true, plusplus: true, regexp: true, unparam: true, todo: true, white: true - */ - - // prevent another load? maybe there is a better way? - if($.jstree) { - return; - } - - /** - * ### jsTree core functionality - */ - - // internal variables - var instance_counter = 0, - ccp_node = false, - ccp_mode = false, - ccp_inst = false, - themes_loaded = [], - src = $('script:last').attr('src'), - _d = document, _node = _d.createElement('LI'), _temp1, _temp2; - - _node.setAttribute('role', 'treeitem'); - _temp1 = _d.createElement('I'); - _temp1.className = 'jstree-icon jstree-ocl'; - _temp1.setAttribute('role', 'presentation'); - _node.appendChild(_temp1); - _temp1 = _d.createElement('A'); - _temp1.className = 'jstree-anchor'; - _temp1.setAttribute('href','#'); - _temp1.setAttribute('tabindex','-1'); - _temp2 = _d.createElement('I'); - _temp2.className = 'jstree-icon jstree-themeicon'; - _temp2.setAttribute('role', 'presentation'); - _temp1.appendChild(_temp2); - _node.appendChild(_temp1); - _temp1 = _temp2 = null; - - - /** - * holds all jstree related functions and variables, including the actual class and methods to create, access and manipulate instances. - * @name $.jstree - */ - $.jstree = { - /** - * specifies the jstree version in use - * @name $.jstree.version - */ - version : '3.0.9', - /** - * holds all the default options used when creating new instances - * @name $.jstree.defaults - */ - defaults : { - /** - * configure which plugins will be active on an instance. Should be an array of strings, where each element is a plugin name. The default is `[]` - * @name $.jstree.defaults.plugins - */ - plugins : [] - }, - /** - * stores all loaded jstree plugins (used internally) - * @name $.jstree.plugins - */ - plugins : {}, - path : src && src.indexOf('/') !== -1 ? src.replace(/\/[^\/]+$/,'') : '', - idregex : /[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g - }; - /** - * creates a jstree instance - * @name $.jstree.create(el [, options]) - * @param {DOMElement|jQuery|String} el the element to create the instance on, can be jQuery extended or a selector - * @param {Object} options options for this instance (extends `$.jstree.defaults`) - * @return {jsTree} the new instance - */ - $.jstree.create = function (el, options) { - var tmp = new $.jstree.core(++instance_counter), - opt = options; - options = $.extend(true, {}, $.jstree.defaults, options); - if(opt && opt.plugins) { - options.plugins = opt.plugins; - } - $.each(options.plugins, function (i, k) { - if(i !== 'core') { - tmp = tmp.plugin(k, options[k]); - } - }); - tmp.init(el, options); - return tmp; - }; - /** - * remove all traces of jstree from the DOM and destroy all instances - * @name $.jstree.destroy() - */ - $.jstree.destroy = function () { - $('.jstree:jstree').jstree('destroy'); - $(document).off('.jstree'); - }; - /** - * the jstree class constructor, used only internally - * @private - * @name $.jstree.core(id) - * @param {Number} id this instance's index - */ - $.jstree.core = function (id) { - this._id = id; - this._cnt = 0; - this._wrk = null; - this._data = { - core : { - themes : { - name : false, - dots : false, - icons : false - }, - selected : [], - last_error : {}, - working : false, - worker_queue : [], - focused : null - } - }; - }; - /** - * get a reference to an existing instance - * - * __Examples__ - * - * // provided a container with an ID of "tree", and a nested node with an ID of "branch" - * // all of there will return the same instance - * $.jstree.reference('tree'); - * $.jstree.reference('#tree'); - * $.jstree.reference($('#tree')); - * $.jstree.reference(document.getElementByID('tree')); - * $.jstree.reference('branch'); - * $.jstree.reference('#branch'); - * $.jstree.reference($('#branch')); - * $.jstree.reference(document.getElementByID('branch')); - * - * @name $.jstree.reference(needle) - * @param {DOMElement|jQuery|String} needle - * @return {jsTree|null} the instance or `null` if not found - */ - $.jstree.reference = function (needle) { - var tmp = null, - obj = null; - if(needle && needle.id) { needle = needle.id; } - - if(!obj || !obj.length) { - try { obj = $(needle); } catch (ignore) { } - } - if(!obj || !obj.length) { - try { obj = $('#' + needle.replace($.jstree.idregex,'\\$&')); } catch (ignore) { } - } - if(obj && obj.length && (obj = obj.closest('.jstree')).length && (obj = obj.data('jstree'))) { - tmp = obj; - } - else { - $('.jstree').each(function () { - var inst = $(this).data('jstree'); - if(inst && inst._model.data[needle]) { - tmp = inst; - return false; - } - }); - } - return tmp; - }; - /** - * Create an instance, get an instance or invoke a command on a instance. - * - * If there is no instance associated with the current node a new one is created and `arg` is used to extend `$.jstree.defaults` for this new instance. There would be no return value (chaining is not broken). - * - * If there is an existing instance and `arg` is a string the command specified by `arg` is executed on the instance, with any additional arguments passed to the function. If the function returns a value it will be returned (chaining could break depending on function). - * - * If there is an existing instance and `arg` is not a string the instance itself is returned (similar to `$.jstree.reference`). - * - * In any other case - nothing is returned and chaining is not broken. - * - * __Examples__ - * - * $('#tree1').jstree(); // creates an instance - * $('#tree2').jstree({ plugins : [] }); // create an instance with some options - * $('#tree1').jstree('open_node', '#branch_1'); // call a method on an existing instance, passing additional arguments - * $('#tree2').jstree(); // get an existing instance (or create an instance) - * $('#tree2').jstree(true); // get an existing instance (will not create new instance) - * $('#branch_1').jstree().select_node('#branch_1'); // get an instance (using a nested element and call a method) - * - * @name $().jstree([arg]) - * @param {String|Object} arg - * @return {Mixed} - */ - $.fn.jstree = function (arg) { - // check for string argument - var is_method = (typeof arg === 'string'), - args = Array.prototype.slice.call(arguments, 1), - result = null; - if(arg === true && !this.length) { return false; } - this.each(function () { - // get the instance (if there is one) and method (if it exists) - var instance = $.jstree.reference(this), - method = is_method && instance ? instance[arg] : null; - // if calling a method, and method is available - execute on the instance - result = is_method && method ? - method.apply(instance, args) : - null; - // if there is no instance and no method is being called - create one - if(!instance && !is_method && (arg === undefined || $.isPlainObject(arg))) { - $(this).data('jstree', new $.jstree.create(this, arg)); - } - // if there is an instance and no method is called - return the instance - if( (instance && !is_method) || arg === true ) { - result = instance || false; - } - // if there was a method call which returned a result - break and return the value - if(result !== null && result !== undefined) { - return false; - } - }); - // if there was a method call with a valid return value - return that, otherwise continue the chain - return result !== null && result !== undefined ? - result : this; - }; - /** - * used to find elements containing an instance - * - * __Examples__ - * - * $('div:jstree').each(function () { - * $(this).jstree('destroy'); - * }); - * - * @name $(':jstree') - * @return {jQuery} - */ - $.expr[':'].jstree = $.expr.createPseudo(function(search) { - return function(a) { - return $(a).hasClass('jstree') && - $(a).data('jstree') !== undefined; - }; - }); - - /** - * stores all defaults for the core - * @name $.jstree.defaults.core - */ - $.jstree.defaults.core = { - /** - * data configuration - * - * If left as `false` the HTML inside the jstree container element is used to populate the tree (that should be an unordered list with list items). - * - * You can also pass in a HTML string or a JSON array here. - * - * It is possible to pass in a standard jQuery-like AJAX config and jstree will automatically determine if the response is JSON or HTML and use that to populate the tree. - * In addition to the standard jQuery ajax options here you can suppy functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node is being loaded, the return value of those functions will be used. - * - * The last option is to specify a function, that function will receive the node being loaded as argument and a second param which is a function which should be called with the result. - * - * __Examples__ - * - * // AJAX - * $('#tree').jstree({ - * 'core' : { - * 'data' : { - * 'url' : '/get/children/', - * 'data' : function (node) { - * return { 'id' : node.id }; - * } - * } - * }); - * - * // direct data - * $('#tree').jstree({ - * 'core' : { - * 'data' : [ - * 'Simple root node', - * { - * 'id' : 'node_2', - * 'text' : 'Root node with options', - * 'state' : { 'opened' : true, 'selected' : true }, - * 'children' : [ { 'text' : 'Child 1' }, 'Child 2'] - * } - * ] - * }); - * - * // function - * $('#tree').jstree({ - * 'core' : { - * 'data' : function (obj, callback) { - * callback.call(this, ['Root 1', 'Root 2']); - * } - * }); - * - * @name $.jstree.defaults.core.data - */ - data : false, - /** - * configure the various strings used throughout the tree - * - * You can use an object where the key is the string you need to replace and the value is your replacement. - * Another option is to specify a function which will be called with an argument of the needed string and should return the replacement. - * If left as `false` no replacement is made. - * - * __Examples__ - * - * $('#tree').jstree({ - * 'core' : { - * 'strings' : { - * 'Loading ...' : 'Please wait ...' - * } - * } - * }); - * - * @name $.jstree.defaults.core.strings - */ - strings : false, - /** - * determines what happens when a user tries to modify the structure of the tree - * If left as `false` all operations like create, rename, delete, move or copy are prevented. - * You can set this to `true` to allow all interactions or use a function to have better control. - * - * __Examples__ - * - * $('#tree').jstree({ - * 'core' : { - * 'check_callback' : function (operation, node, node_parent, node_position, more) { - * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node' or 'copy_node' - * // in case of 'rename_node' node_position is filled with the new node name - * return operation === 'rename_node' ? true : false; - * } - * } - * }); - * - * @name $.jstree.defaults.core.check_callback - */ - check_callback : false, - /** - * a callback called with a single object parameter in the instance's scope when something goes wrong (operation prevented, ajax failed, etc) - * @name $.jstree.defaults.core.error - */ - error : $.noop, - /** - * the open / close animation duration in milliseconds - set this to `false` to disable the animation (default is `200`) - * @name $.jstree.defaults.core.animation - */ - animation : 200, - /** - * a boolean indicating if multiple nodes can be selected - * @name $.jstree.defaults.core.multiple - */ - multiple : true, - /** - * theme configuration object - * @name $.jstree.defaults.core.themes - */ - themes : { - /** - * the name of the theme to use (if left as `false` the default theme is used) - * @name $.jstree.defaults.core.themes.name - */ - name : false, - /** - * the URL of the theme's CSS file, leave this as `false` if you have manually included the theme CSS (recommended). You can set this to `true` too which will try to autoload the theme. - * @name $.jstree.defaults.core.themes.url - */ - url : false, - /** - * the location of all jstree themes - only used if `url` is set to `true` - * @name $.jstree.defaults.core.themes.dir - */ - dir : false, - /** - * a boolean indicating if connecting dots are shown - * @name $.jstree.defaults.core.themes.dots - */ - dots : true, - /** - * a boolean indicating if node icons are shown - * @name $.jstree.defaults.core.themes.icons - */ - icons : true, - /** - * a boolean indicating if the tree background is striped - * @name $.jstree.defaults.core.themes.stripes - */ - stripes : false, - /** - * a string (or boolean `false`) specifying the theme variant to use (if the theme supports variants) - * @name $.jstree.defaults.core.themes.variant - */ - variant : false, - /** - * a boolean specifying if a reponsive version of the theme should kick in on smaller screens (if the theme supports it). Defaults to `false`. - * @name $.jstree.defaults.core.themes.responsive - */ - responsive : false - }, - /** - * if left as `true` all parents of all selected nodes will be opened once the tree loads (so that all selected nodes are visible to the user) - * @name $.jstree.defaults.core.expand_selected_onload - */ - expand_selected_onload : true, - /** - * if left as `true` web workers will be used to parse incoming JSON data where possible, so that the UI will not be blocked by large requests. Workers are however about 30% slower. Defaults to `true` - * @name $.jstree.defaults.core.worker - */ - worker : true, - /** - * Force node text to plain text (and escape HTML). Defaults to `false` - * @name $.jstree.defaults.core.force_text - */ - force_text : false, - /** - * Should the node should be toggled if the text is double clicked . Defaults to `true` - * @name $.jstree.defaults.core.dblclick_toggle - */ - dblclick_toggle : true - }; - $.jstree.core.prototype = { - /** - * used to decorate an instance with a plugin. Used internally. - * @private - * @name plugin(deco [, opts]) - * @param {String} deco the plugin to decorate with - * @param {Object} opts options for the plugin - * @return {jsTree} - */ - plugin : function (deco, opts) { - var Child = $.jstree.plugins[deco]; - if(Child) { - this._data[deco] = {}; - Child.prototype = this; - return new Child(opts, this); - } - return this; - }, - /** - * used to decorate an instance with a plugin. Used internally. - * @private - * @name init(el, optons) - * @param {DOMElement|jQuery|String} el the element we are transforming - * @param {Object} options options for this instance - * @trigger init.jstree, loading.jstree, loaded.jstree, ready.jstree, changed.jstree - */ - init : function (el, options) { - this._model = { - data : { - '#' : { - id : '#', - parent : null, - parents : [], - children : [], - children_d : [], - state : { loaded : false } - } - }, - changed : [], - force_full_redraw : false, - redraw_timeout : false, - default_state : { - loaded : true, - opened : false, - selected : false, - disabled : false - } - }; - - this.element = $(el).addClass('jstree jstree-' + this._id); - this.settings = options; - - this._data.core.ready = false; - this._data.core.loaded = false; - this._data.core.rtl = (this.element.css("direction") === "rtl"); - this.element[this._data.core.rtl ? 'addClass' : 'removeClass']("jstree-rtl"); - this.element.attr('role','tree'); - if(this.settings.core.multiple) { - this.element.attr('aria-multiselectable', true); - } - if(!this.element.attr('tabindex')) { - this.element.attr('tabindex','0'); - } - - this.bind(); - /** - * triggered after all events are bound - * @event - * @name init.jstree - */ - this.trigger("init"); - - this._data.core.original_container_html = this.element.find(" > ul > li").clone(true); - this._data.core.original_container_html - .find("li").addBack() - .contents().filter(function() { - return this.nodeType === 3 && (!this.nodeValue || /^\s+$/.test(this.nodeValue)); - }) - .remove(); - this.element.html("<"+"ul class='jstree-container-ul jstree-children' role='group'><"+"li id='j"+this._id+"_loading' class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='tree-item'><i class='jstree-icon jstree-ocl'></i><"+"a class='jstree-anchor' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>" + this.get_string("Loading ...") + "</a></li></ul>"); - this.element.attr('aria-activedescendant','j' + this._id + '_loading'); - this._data.core.li_height = this.get_container_ul().children("li").first().height() || 24; - /** - * triggered after the loading text is shown and before loading starts - * @event - * @name loading.jstree - */ - this.trigger("loading"); - this.load_node('#'); - }, - /** - * destroy an instance - * @name destroy() - * @param {Boolean} keep_html if not set to `true` the container will be emptied, otherwise the current DOM elements will be kept intact - */ - destroy : function (keep_html) { - if(this._wrk) { - try { - window.URL.revokeObjectURL(this._wrk); - this._wrk = null; - } - catch (ignore) { } - } - if(!keep_html) { this.element.empty(); } - this.teardown(); - }, - /** - * part of the destroying of an instance. Used internally. - * @private - * @name teardown() - */ - teardown : function () { - this.unbind(); - this.element - .removeClass('jstree') - .removeData('jstree') - .find("[class^='jstree']") - .addBack() - .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); }); - this.element = null; - }, - /** - * bind all events. Used internally. - * @private - * @name bind() - */ - bind : function () { - var word = '', - tout = null, - was_click = 0; - this.element - .on("dblclick.jstree", function () { - if(document.selection && document.selection.empty) { - document.selection.empty(); - } - else { - if(window.getSelection) { - var sel = window.getSelection(); - try { - sel.removeAllRanges(); - sel.collapse(); - } catch (ignore) { } - } - } - }) - .on("mousedown.jstree", $.proxy(function (e) { - if(e.target === this.element[0]) { - e.preventDefault(); // prevent losing focus when clicking scroll arrows (FF, Chrome) - was_click = +(new Date()); // ie does not allow to prevent losing focus - } - }, this)) - .on("mousedown.jstree", ".jstree-ocl", function (e) { - e.preventDefault(); // prevent any node inside from losing focus when clicking the open/close icon - }) - .on("click.jstree", ".jstree-ocl", $.proxy(function (e) { - this.toggle_node(e.target); - }, this)) - .on("dblclick.jstree", ".jstree-anchor", $.proxy(function (e) { - if(this.settings.core.dblclick_toggle) { - this.toggle_node(e.target); - } - }, this)) - .on("click.jstree", ".jstree-anchor", $.proxy(function (e) { - e.preventDefault(); - if(e.currentTarget !== document.activeElement) { $(e.currentTarget).focus(); } - this.activate_node(e.currentTarget, e); - }, this)) - .on('keydown.jstree', '.jstree-anchor', $.proxy(function (e) { - if(e.target.tagName === "INPUT") { return true; } - var o = null; - if(this._data.core.rtl) { - if(e.which === 37) { e.which = 39; } - else if(e.which === 39) { e.which = 37; } - } - switch(e.which) { - case 32: // aria defines space only with Ctrl - if(e.ctrlKey) { - e.type = "click"; - $(e.currentTarget).trigger(e); - } - break; - case 13: // enter - e.type = "click"; - $(e.currentTarget).trigger(e); - break; - case 37: // right - e.preventDefault(); - if(this.is_open(e.currentTarget)) { - this.close_node(e.currentTarget); - } - else { - o = this.get_parent(e.currentTarget); - if(o && o.id !== '#') { this.get_node(o, true).children('.jstree-anchor').focus(); } - } - break; - case 38: // up - e.preventDefault(); - o = this.get_prev_dom(e.currentTarget); - if(o && o.length) { o.children('.jstree-anchor').focus(); } - break; - case 39: // left - e.preventDefault(); - if(this.is_closed(e.currentTarget)) { - this.open_node(e.currentTarget, function (o) { this.get_node(o, true).children('.jstree-anchor').focus(); }); - } - else if (this.is_open(e.currentTarget)) { - o = this.get_node(e.currentTarget, true).children('.jstree-children')[0]; - if(o) { $(this._firstChild(o)).children('.jstree-anchor').focus(); } - } - break; - case 40: // down - e.preventDefault(); - o = this.get_next_dom(e.currentTarget); - if(o && o.length) { o.children('.jstree-anchor').focus(); } - break; - case 106: // aria defines * on numpad as open_all - not very common - this.open_all(); - break; - case 36: // home - e.preventDefault(); - o = this._firstChild(this.get_container_ul()[0]); - if(o) { $(o).children('.jstree-anchor').filter(':visible').focus(); } - break; - case 35: // end - e.preventDefault(); - this.element.find('.jstree-anchor').filter(':visible').last().focus(); - break; - /* - // delete - case 46: - e.preventDefault(); - o = this.get_node(e.currentTarget); - if(o && o.id && o.id !== '#') { - o = this.is_selected(o) ? this.get_selected() : o; - this.delete_node(o); - } - break; - // f2 - case 113: - e.preventDefault(); - o = this.get_node(e.currentTarget); - if(o && o.id && o.id !== '#') { - // this.edit(o); - } - break; - default: - // console.log(e.which); - break; - */ - } - }, this)) - .on("load_node.jstree", $.proxy(function (e, data) { - if(data.status) { - if(data.node.id === '#' && !this._data.core.loaded) { - this._data.core.loaded = true; - if(this._firstChild(this.get_container_ul()[0])) { - this.element.attr('aria-activedescendant',this._firstChild(this.get_container_ul()[0]).id); - } - /** - * triggered after the root node is loaded for the first time - * @event - * @name loaded.jstree - */ - this.trigger("loaded"); - } - if(!this._data.core.ready) { - setTimeout($.proxy(function() { - if(!this.get_container_ul().find('.jstree-loading').length) { - this._data.core.ready = true; - if(this._data.core.selected.length) { - if(this.settings.core.expand_selected_onload) { - var tmp = [], i, j; - for(i = 0, j = this._data.core.selected.length; i < j; i++) { - tmp = tmp.concat(this._model.data[this._data.core.selected[i]].parents); - } - tmp = $.vakata.array_unique(tmp); - for(i = 0, j = tmp.length; i < j; i++) { - this.open_node(tmp[i], false, 0); - } - } - this.trigger('changed', { 'action' : 'ready', 'selected' : this._data.core.selected }); - } - /** - * triggered after all nodes are finished loading - * @event - * @name ready.jstree - */ - this.trigger("ready"); - } - }, this), 0); - } - } - }, this)) - // quick searching when the tree is focused - .on('keypress.jstree', $.proxy(function (e) { - if(e.target.tagName === "INPUT") { return true; } - if(tout) { clearTimeout(tout); } - tout = setTimeout(function () { - word = ''; - }, 500); - - var chr = String.fromCharCode(e.which).toLowerCase(), - col = this.element.find('.jstree-anchor').filter(':visible'), - ind = col.index(document.activeElement) || 0, - end = false; - word += chr; - - // match for whole word from current node down (including the current node) - if(word.length > 1) { - col.slice(ind).each($.proxy(function (i, v) { - if($(v).text().toLowerCase().indexOf(word) === 0) { - $(v).focus(); - end = true; - return false; - } - }, this)); - if(end) { return; } - - // match for whole word from the beginning of the tree - col.slice(0, ind).each($.proxy(function (i, v) { - if($(v).text().toLowerCase().indexOf(word) === 0) { - $(v).focus(); - end = true; - return false; - } - }, this)); - if(end) { return; } - } - // list nodes that start with that letter (only if word consists of a single char) - if(new RegExp('^' + chr + '+$').test(word)) { - // search for the next node starting with that letter - col.slice(ind + 1).each($.proxy(function (i, v) { - if($(v).text().toLowerCase().charAt(0) === chr) { - $(v).focus(); - end = true; - return false; - } - }, this)); - if(end) { return; } - - // search from the beginning - col.slice(0, ind + 1).each($.proxy(function (i, v) { - if($(v).text().toLowerCase().charAt(0) === chr) { - $(v).focus(); - end = true; - return false; - } - }, this)); - if(end) { return; } - } - }, this)) - // THEME RELATED - .on("init.jstree", $.proxy(function () { - var s = this.settings.core.themes; - this._data.core.themes.dots = s.dots; - this._data.core.themes.stripes = s.stripes; - this._data.core.themes.icons = s.icons; - this.set_theme(s.name || "default", s.url); - this.set_theme_variant(s.variant); - }, this)) - .on("loading.jstree", $.proxy(function () { - this[ this._data.core.themes.dots ? "show_dots" : "hide_dots" ](); - this[ this._data.core.themes.icons ? "show_icons" : "hide_icons" ](); - this[ this._data.core.themes.stripes ? "show_stripes" : "hide_stripes" ](); - }, this)) - .on('blur.jstree', '.jstree-anchor', $.proxy(function (e) { - this._data.core.focused = null; - $(e.currentTarget).filter('.jstree-hovered').mouseleave(); - this.element.attr('tabindex', '0'); - }, this)) - .on('focus.jstree', '.jstree-anchor', $.proxy(function (e) { - var tmp = this.get_node(e.currentTarget); - if(tmp && tmp.id) { - this._data.core.focused = tmp.id; - } - this.element.find('.jstree-hovered').not(e.currentTarget).mouseleave(); - $(e.currentTarget).mouseenter(); - this.element.attr('tabindex', '-1'); - }, this)) - .on('focus.jstree', $.proxy(function () { - if(+(new Date()) - was_click > 500 && !this._data.core.focused) { - was_click = 0; - this.get_node(this.element.attr('aria-activedescendant'), true).find('> .jstree-anchor').focus(); - } - }, this)) - .on('mouseenter.jstree', '.jstree-anchor', $.proxy(function (e) { - this.hover_node(e.currentTarget); - }, this)) - .on('mouseleave.jstree', '.jstree-anchor', $.proxy(function (e) { - this.dehover_node(e.currentTarget); - }, this)); - }, - /** - * part of the destroying of an instance. Used internally. - * @private - * @name unbind() - */ - unbind : function () { - this.element.off('.jstree'); - $(document).off('.jstree-' + this._id); - }, - /** - * trigger an event. Used internally. - * @private - * @name trigger(ev [, data]) - * @param {String} ev the name of the event to trigger - * @param {Object} data additional data to pass with the event - */ - trigger : function (ev, data) { - if(!data) { - data = {}; - } - data.instance = this; - this.element.triggerHandler(ev.replace('.jstree','') + '.jstree', data); - }, - /** - * returns the jQuery extended instance container - * @name get_container() - * @return {jQuery} - */ - get_container : function () { - return this.element; - }, - /** - * returns the jQuery extended main UL node inside the instance container. Used internally. - * @private - * @name get_container_ul() - * @return {jQuery} - */ - get_container_ul : function () { - return this.element.children(".jstree-children").first(); - }, - /** - * gets string replacements (localization). Used internally. - * @private - * @name get_string(key) - * @param {String} key - * @return {String} - */ - get_string : function (key) { - var a = this.settings.core.strings; - if($.isFunction(a)) { return a.call(this, key); } - if(a && a[key]) { return a[key]; } - return key; - }, - /** - * gets the first child of a DOM node. Used internally. - * @private - * @name _firstChild(dom) - * @param {DOMElement} dom - * @return {DOMElement} - */ - _firstChild : function (dom) { - dom = dom ? dom.firstChild : null; - while(dom !== null && dom.nodeType !== 1) { - dom = dom.nextSibling; - } - return dom; - }, - /** - * gets the next sibling of a DOM node. Used internally. - * @private - * @name _nextSibling(dom) - * @param {DOMElement} dom - * @return {DOMElement} - */ - _nextSibling : function (dom) { - dom = dom ? dom.nextSibling : null; - while(dom !== null && dom.nodeType !== 1) { - dom = dom.nextSibling; - } - return dom; - }, - /** - * gets the previous sibling of a DOM node. Used internally. - * @private - * @name _previousSibling(dom) - * @param {DOMElement} dom - * @return {DOMElement} - */ - _previousSibling : function (dom) { - dom = dom ? dom.previousSibling : null; - while(dom !== null && dom.nodeType !== 1) { - dom = dom.previousSibling; - } - return dom; - }, - /** - * get the JSON representation of a node (or the actual jQuery extended DOM node) by using any input (child DOM element, ID string, selector, etc) - * @name get_node(obj [, as_dom]) - * @param {mixed} obj - * @param {Boolean} as_dom - * @return {Object|jQuery} - */ - get_node : function (obj, as_dom) { - if(obj && obj.id) { - obj = obj.id; - } - var dom; - try { - if(this._model.data[obj]) { - obj = this._model.data[obj]; - } - else if(typeof obj === "string" && this._model.data[obj.replace(/^#/, '')]) { - obj = this._model.data[obj.replace(/^#/, '')]; - } - else if(typeof obj === "string" && (dom = $('#' + obj.replace($.jstree.idregex,'\\$&'), this.element)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) { - obj = this._model.data[dom.closest('.jstree-node').attr('id')]; - } - else if((dom = $(obj, this.element)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) { - obj = this._model.data[dom.closest('.jstree-node').attr('id')]; - } - else if((dom = $(obj, this.element)).length && dom.hasClass('jstree')) { - obj = this._model.data['#']; - } - else { - return false; - } - - if(as_dom) { - obj = obj.id === '#' ? this.element : $('#' + obj.id.replace($.jstree.idregex,'\\$&'), this.element); - } - return obj; - } catch (ex) { return false; } - }, - /** - * get the path to a node, either consisting of node texts, or of node IDs, optionally glued together (otherwise an array) - * @name get_path(obj [, glue, ids]) - * @param {mixed} obj the node - * @param {String} glue if you want the path as a string - pass the glue here (for example '/'), if a falsy value is supplied here, an array is returned - * @param {Boolean} ids if set to true build the path using ID, otherwise node text is used - * @return {mixed} - */ - get_path : function (obj, glue, ids) { - obj = obj.parents ? obj : this.get_node(obj); - if(!obj || obj.id === '#' || !obj.parents) { - return false; - } - var i, j, p = []; - p.push(ids ? obj.id : obj.text); - for(i = 0, j = obj.parents.length; i < j; i++) { - p.push(ids ? obj.parents[i] : this.get_text(obj.parents[i])); - } - p = p.reverse().slice(1); - return glue ? p.join(glue) : p; - }, - /** - * get the next visible node that is below the `obj` node. If `strict` is set to `true` only sibling nodes are returned. - * @name get_next_dom(obj [, strict]) - * @param {mixed} obj - * @param {Boolean} strict - * @return {jQuery} - */ - get_next_dom : function (obj, strict) { - var tmp; - obj = this.get_node(obj, true); - if(obj[0] === this.element[0]) { - tmp = this._firstChild(this.get_container_ul()[0]); - while (tmp && tmp.offsetHeight === 0) { - tmp = this._nextSibling(tmp); - } - return tmp ? $(tmp) : false; - } - if(!obj || !obj.length) { - return false; - } - if(strict) { - tmp = obj[0]; - do { - tmp = this._nextSibling(tmp); - } while (tmp && tmp.offsetHeight === 0); - return tmp ? $(tmp) : false; - } - if(obj.hasClass("jstree-open")) { - tmp = this._firstChild(obj.children('.jstree-children')[0]); - while (tmp && tmp.offsetHeight === 0) { - tmp = this._nextSibling(tmp); - } - if(tmp !== null) { - return $(tmp); - } - } - tmp = obj[0]; - do { - tmp = this._nextSibling(tmp); - } while (tmp && tmp.offsetHeight === 0); - if(tmp !== null) { - return $(tmp); - } - return obj.parentsUntil(".jstree",".jstree-node").next(".jstree-node:visible").first(); - }, - /** - * get the previous visible node that is above the `obj` node. If `strict` is set to `true` only sibling nodes are returned. - * @name get_prev_dom(obj [, strict]) - * @param {mixed} obj - * @param {Boolean} strict - * @return {jQuery} - */ - get_prev_dom : function (obj, strict) { - var tmp; - obj = this.get_node(obj, true); - if(obj[0] === this.element[0]) { - tmp = this.get_container_ul()[0].lastChild; - while (tmp && tmp.offsetHeight === 0) { - tmp = this._previousSibling(tmp); - } - return tmp ? $(tmp) : false; - } - if(!obj || !obj.length) { - return false; - } - if(strict) { - tmp = obj[0]; - do { - tmp = this._previousSibling(tmp); - } while (tmp && tmp.offsetHeight === 0); - return tmp ? $(tmp) : false; - } - tmp = obj[0]; - do { - tmp = this._previousSibling(tmp); - } while (tmp && tmp.offsetHeight === 0); - if(tmp !== null) { - obj = $(tmp); - while(obj.hasClass("jstree-open")) { - obj = obj.children(".jstree-children").first().children(".jstree-node:visible:last"); - } - return obj; - } - tmp = obj[0].parentNode.parentNode; - return tmp && tmp.className && tmp.className.indexOf('jstree-node') !== -1 ? $(tmp) : false; - }, - /** - * get the parent ID of a node - * @name get_parent(obj) - * @param {mixed} obj - * @return {String} - */ - get_parent : function (obj) { - obj = this.get_node(obj); - if(!obj || obj.id === '#') { - return false; - } - return obj.parent; - }, - /** - * get a jQuery collection of all the children of a node (node must be rendered) - * @name get_children_dom(obj) - * @param {mixed} obj - * @return {jQuery} - */ - get_children_dom : function (obj) { - obj = this.get_node(obj, true); - if(obj[0] === this.element[0]) { - return this.get_container_ul().children(".jstree-node"); - } - if(!obj || !obj.length) { - return false; - } - return obj.children(".jstree-children").children(".jstree-node"); - }, - /** - * checks if a node has children - * @name is_parent(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_parent : function (obj) { - obj = this.get_node(obj); - return obj && (obj.state.loaded === false || obj.children.length > 0); - }, - /** - * checks if a node is loaded (its children are available) - * @name is_loaded(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_loaded : function (obj) { - obj = this.get_node(obj); - return obj && obj.state.loaded; - }, - /** - * check if a node is currently loading (fetching children) - * @name is_loading(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_loading : function (obj) { - obj = this.get_node(obj); - return obj && obj.state && obj.state.loading; - }, - /** - * check if a node is opened - * @name is_open(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_open : function (obj) { - obj = this.get_node(obj); - return obj && obj.state.opened; - }, - /** - * check if a node is in a closed state - * @name is_closed(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_closed : function (obj) { - obj = this.get_node(obj); - return obj && this.is_parent(obj) && !obj.state.opened; - }, - /** - * check if a node has no children - * @name is_leaf(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_leaf : function (obj) { - return !this.is_parent(obj); - }, - /** - * loads a node (fetches its children using the `core.data` setting). Multiple nodes can be passed to by using an array. - * @name load_node(obj [, callback]) - * @param {mixed} obj - * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives two arguments - the node and a boolean status - * @return {Boolean} - * @trigger load_node.jstree - */ - load_node : function (obj, callback) { - var k, l, i, j, c; - if($.isArray(obj)) { - this._load_nodes(obj.slice(), callback); - return true; - } - obj = this.get_node(obj); - if(!obj) { - if(callback) { callback.call(this, obj, false); } - return false; - } - // if(obj.state.loading) { } // the node is already loading - just wait for it to load and invoke callback? but if called implicitly it should be loaded again? - if(obj.state.loaded) { - obj.state.loaded = false; - for(k = 0, l = obj.children_d.length; k < l; k++) { - for(i = 0, j = obj.parents.length; i < j; i++) { - this._model.data[obj.parents[i]].children_d = $.vakata.array_remove_item(this._model.data[obj.parents[i]].children_d, obj.children_d[k]); - } - if(this._model.data[obj.children_d[k]].state.selected) { - c = true; - this._data.core.selected = $.vakata.array_remove_item(this._data.core.selected, obj.children_d[k]); - } - delete this._model.data[obj.children_d[k]]; - } - obj.children = []; - obj.children_d = []; - if(c) { - this.trigger('changed', { 'action' : 'load_node', 'node' : obj, 'selected' : this._data.core.selected }); - } - } - obj.state.loading = true; - this.get_node(obj, true).addClass("jstree-loading").attr('aria-busy',true); - this._load_node(obj, $.proxy(function (status) { - obj = this._model.data[obj.id]; - obj.state.loading = false; - obj.state.loaded = status; - var dom = this.get_node(obj, true); - if(obj.state.loaded && !obj.children.length && dom && dom.length && !dom.hasClass('jstree-leaf')) { - dom.removeClass('jstree-closed jstree-open').addClass('jstree-leaf'); - } - dom.removeClass("jstree-loading").attr('aria-busy',false); - /** - * triggered after a node is loaded - * @event - * @name load_node.jstree - * @param {Object} node the node that was loading - * @param {Boolean} status was the node loaded successfully - */ - this.trigger('load_node', { "node" : obj, "status" : status }); - if(callback) { - callback.call(this, obj, status); - } - }, this)); - return true; - }, - /** - * load an array of nodes (will also load unavailable nodes as soon as the appear in the structure). Used internally. - * @private - * @name _load_nodes(nodes [, callback]) - * @param {array} nodes - * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - the array passed to _load_nodes - */ - _load_nodes : function (nodes, callback, is_callback) { - var r = true, - c = function () { this._load_nodes(nodes, callback, true); }, - m = this._model.data, i, j; - for(i = 0, j = nodes.length; i < j; i++) { - if(m[nodes[i]] && (!m[nodes[i]].state.loaded || !is_callback)) { - if(!this.is_loading(nodes[i])) { - this.load_node(nodes[i], c); - } - r = false; - } - } - if(r) { - if(callback && !callback.done) { - callback.call(this, nodes); - callback.done = true; - } - } - }, - /** - * loads all unloaded nodes - * @name load_all([obj, callback]) - * @param {mixed} obj the node to load recursively, omit to load all nodes in the tree - * @param {function} callback a function to be executed once loading all the nodes is complete, - * @trigger load_all.jstree - */ - load_all : function (obj, callback) { - if(!obj) { obj = '#'; } - obj = this.get_node(obj); - if(!obj) { return false; } - var to_load = [], - m = this._model.data, - c = m[obj.id].children_d, - i, j; - if(obj.state && !obj.state.loaded) { - to_load.push(obj.id); - } - for(i = 0, j = c.length; i < j; i++) { - if(m[c[i]] && m[c[i]].state && !m[c[i]].state.loaded) { - to_load.push(c[i]); - } - } - if(to_load.length) { - this._load_nodes(to_load, function () { - this.load_all(obj, callback); - }); - } - else { - /** - * triggered after a load_all call completes - * @event - * @name load_all.jstree - * @param {Object} node the recursively loaded node - */ - if(callback) { callback.call(this, obj); } - this.trigger('load_all', { "node" : obj }); - } - }, - /** - * handles the actual loading of a node. Used only internally. - * @private - * @name _load_node(obj [, callback]) - * @param {mixed} obj - * @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - a boolean status - * @return {Boolean} - */ - _load_node : function (obj, callback) { - var s = this.settings.core.data, t; - // use original HTML - if(!s) { - if(obj.id === '#') { - return this._append_html_data(obj, this._data.core.original_container_html.clone(true), function (status) { - callback.call(this, status); - }); - } - else { - return callback.call(this, false); - } - // return callback.call(this, obj.id === '#' ? this._append_html_data(obj, this._data.core.original_container_html.clone(true)) : false); - } - if($.isFunction(s)) { - return s.call(this, obj, $.proxy(function (d) { - if(d === false) { - callback.call(this, false); - } - this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $(d) : d, function (status) { - callback.call(this, status); - }); - // return d === false ? callback.call(this, false) : callback.call(this, this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $(d) : d)); - }, this)); - } - if(typeof s === 'object') { - if(s.url) { - s = $.extend(true, {}, s); - if($.isFunction(s.url)) { - s.url = s.url.call(this, obj); - } - if($.isFunction(s.data)) { - s.data = s.data.call(this, obj); - } - return $.ajax(s) - .done($.proxy(function (d,t,x) { - var type = x.getResponseHeader('Content-Type'); - if(type.indexOf('json') !== -1 || typeof d === "object") { - return this._append_json_data(obj, d, function (status) { callback.call(this, status); }); - //return callback.call(this, this._append_json_data(obj, d)); - } - if(type.indexOf('html') !== -1 || typeof d === "string") { - return this._append_html_data(obj, $(d), function (status) { callback.call(this, status); }); - // return callback.call(this, this._append_html_data(obj, $(d))); - } - this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'core', 'id' : 'core_04', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id, 'xhr' : x }) }; - this.settings.core.error.call(this, this._data.core.last_error); - return callback.call(this, false); - }, this)) - .fail($.proxy(function (f) { - callback.call(this, false); - this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'core', 'id' : 'core_04', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id, 'xhr' : f }) }; - this.settings.core.error.call(this, this._data.core.last_error); - }, this)); - } - t = ($.isArray(s) || $.isPlainObject(s)) ? JSON.parse(JSON.stringify(s)) : s; - if(obj.id === '#') { - return this._append_json_data(obj, t, function (status) { - callback.call(this, status); - }); - } - else { - this._data.core.last_error = { 'error' : 'nodata', 'plugin' : 'core', 'id' : 'core_05', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id }) }; - this.settings.core.error.call(this, this._data.core.last_error); - return callback.call(this, false); - } - //return callback.call(this, (obj.id === "#" ? this._append_json_data(obj, t) : false) ); - } - if(typeof s === 'string') { - if(obj.id === '#') { - return this._append_html_data(obj, $(s), function (status) { - callback.call(this, status); - }); - } - else { - this._data.core.last_error = { 'error' : 'nodata', 'plugin' : 'core', 'id' : 'core_06', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id }) }; - this.settings.core.error.call(this, this._data.core.last_error); - return callback.call(this, false); - } - //return callback.call(this, (obj.id === "#" ? this._append_html_data(obj, $(s)) : false) ); - } - return callback.call(this, false); - }, - /** - * adds a node to the list of nodes to redraw. Used only internally. - * @private - * @name _node_changed(obj [, callback]) - * @param {mixed} obj - */ - _node_changed : function (obj) { - obj = this.get_node(obj); - if(obj) { - this._model.changed.push(obj.id); - } - }, - /** - * appends HTML content to the tree. Used internally. - * @private - * @name _append_html_data(obj, data) - * @param {mixed} obj the node to append to - * @param {String} data the HTML string to parse and append - * @trigger model.jstree, changed.jstree - */ - _append_html_data : function (dom, data, cb) { - dom = this.get_node(dom); - dom.children = []; - dom.children_d = []; - var dat = data.is('ul') ? data.children() : data, - par = dom.id, - chd = [], - dpc = [], - m = this._model.data, - p = m[par], - s = this._data.core.selected.length, - tmp, i, j; - dat.each($.proxy(function (i, v) { - tmp = this._parse_model_from_html($(v), par, p.parents.concat()); - if(tmp) { - chd.push(tmp); - dpc.push(tmp); - if(m[tmp].children_d.length) { - dpc = dpc.concat(m[tmp].children_d); - } - } - }, this)); - p.children = chd; - p.children_d = dpc; - for(i = 0, j = p.parents.length; i < j; i++) { - m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc); - } - /** - * triggered when new data is inserted to the tree model - * @event - * @name model.jstree - * @param {Array} nodes an array of node IDs - * @param {String} parent the parent ID of the nodes - */ - this.trigger('model', { "nodes" : dpc, 'parent' : par }); - if(par !== '#') { - this._node_changed(par); - this.redraw(); - } - else { - this.get_container_ul().children('.jstree-initial-node').remove(); - this.redraw(true); - } - if(this._data.core.selected.length !== s) { - this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected }); - } - cb.call(this, true); - }, - /** - * appends JSON content to the tree. Used internally. - * @private - * @name _append_json_data(obj, data) - * @param {mixed} obj the node to append to - * @param {String} data the JSON object to parse and append - * @param {Boolean} force_processing internal param - do not set - * @trigger model.jstree, changed.jstree - */ - _append_json_data : function (dom, data, cb, force_processing) { - dom = this.get_node(dom); - dom.children = []; - dom.children_d = []; - // *%$@!!! - if(data.d) { - data = data.d; - if(typeof data === "string") { - data = JSON.parse(data); - } - } - if(!$.isArray(data)) { data = [data]; } - var w = null, - args = { - 'df' : this._model.default_state, - 'dat' : data, - 'par' : dom.id, - 'm' : this._model.data, - 't_id' : this._id, - 't_cnt' : this._cnt, - 'sel' : this._data.core.selected - }, - func = function (data, undefined) { - if(data.data) { data = data.data; } - var dat = data.dat, - par = data.par, - chd = [], - dpc = [], - add = [], - df = data.df, - t_id = data.t_id, - t_cnt = data.t_cnt, - m = data.m, - p = m[par], - sel = data.sel, - tmp, i, j, rslt, - parse_flat = function (d, p, ps) { - if(!ps) { ps = []; } - else { ps = ps.concat(); } - if(p) { ps.unshift(p); } - var tid = d.id.toString(), - i, j, c, e, - tmp = { - id : tid, - text : d.text || '', - icon : d.icon !== undefined ? d.icon : true, - parent : p, - parents : ps, - children : d.children || [], - children_d : d.children_d || [], - data : d.data, - state : { }, - li_attr : { id : false }, - a_attr : { href : '#' }, - original : false - }; - for(i in df) { - if(df.hasOwnProperty(i)) { - tmp.state[i] = df[i]; - } - } - if(d && d.data && d.data.jstree && d.data.jstree.icon) { - tmp.icon = d.data.jstree.icon; - } - if(d && d.data) { - tmp.data = d.data; - if(d.data.jstree) { - for(i in d.data.jstree) { - if(d.data.jstree.hasOwnProperty(i)) { - tmp.state[i] = d.data.jstree[i]; - } - } - } - } - if(d && typeof d.state === 'object') { - for (i in d.state) { - if(d.state.hasOwnProperty(i)) { - tmp.state[i] = d.state[i]; - } - } - } - if(d && typeof d.li_attr === 'object') { - for (i in d.li_attr) { - if(d.li_attr.hasOwnProperty(i)) { - tmp.li_attr[i] = d.li_attr[i]; - } - } - } - if(!tmp.li_attr.id) { - tmp.li_attr.id = tid; - } - if(d && typeof d.a_attr === 'object') { - for (i in d.a_attr) { - if(d.a_attr.hasOwnProperty(i)) { - tmp.a_attr[i] = d.a_attr[i]; - } - } - } - if(d && d.children && d.children === true) { - tmp.state.loaded = false; - tmp.children = []; - tmp.children_d = []; - } - m[tmp.id] = tmp; - for(i = 0, j = tmp.children.length; i < j; i++) { - c = parse_flat(m[tmp.children[i]], tmp.id, ps); - e = m[c]; - tmp.children_d.push(c); - if(e.children_d.length) { - tmp.children_d = tmp.children_d.concat(e.children_d); - } - } - delete d.data; - delete d.children; - m[tmp.id].original = d; - if(tmp.state.selected) { - add.push(tmp.id); - } - return tmp.id; - }, - parse_nest = function (d, p, ps) { - if(!ps) { ps = []; } - else { ps = ps.concat(); } - if(p) { ps.unshift(p); } - var tid = false, i, j, c, e, tmp; - do { - tid = 'j' + t_id + '_' + (++t_cnt); - } while(m[tid]); - - tmp = { - id : false, - text : typeof d === 'string' ? d : '', - icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true, - parent : p, - parents : ps, - children : [], - children_d : [], - data : null, - state : { }, - li_attr : { id : false }, - a_attr : { href : '#' }, - original : false - }; - for(i in df) { - if(df.hasOwnProperty(i)) { - tmp.state[i] = df[i]; - } - } - if(d && d.id) { tmp.id = d.id.toString(); } - if(d && d.text) { tmp.text = d.text; } - if(d && d.data && d.data.jstree && d.data.jstree.icon) { - tmp.icon = d.data.jstree.icon; - } - if(d && d.data) { - tmp.data = d.data; - if(d.data.jstree) { - for(i in d.data.jstree) { - if(d.data.jstree.hasOwnProperty(i)) { - tmp.state[i] = d.data.jstree[i]; - } - } - } - } - if(d && typeof d.state === 'object') { - for (i in d.state) { - if(d.state.hasOwnProperty(i)) { - tmp.state[i] = d.state[i]; - } - } - } - if(d && typeof d.li_attr === 'object') { - for (i in d.li_attr) { - if(d.li_attr.hasOwnProperty(i)) { - tmp.li_attr[i] = d.li_attr[i]; - } - } - } - if(tmp.li_attr.id && !tmp.id) { - tmp.id = tmp.li_attr.id.toString(); - } - if(!tmp.id) { - tmp.id = tid; - } - if(!tmp.li_attr.id) { - tmp.li_attr.id = tmp.id; - } - if(d && typeof d.a_attr === 'object') { - for (i in d.a_attr) { - if(d.a_attr.hasOwnProperty(i)) { - tmp.a_attr[i] = d.a_attr[i]; - } - } - } - if(d && d.children && d.children.length) { - for(i = 0, j = d.children.length; i < j; i++) { - c = parse_nest(d.children[i], tmp.id, ps); - e = m[c]; - tmp.children.push(c); - if(e.children_d.length) { - tmp.children_d = tmp.children_d.concat(e.children_d); - } - } - tmp.children_d = tmp.children_d.concat(tmp.children); - } - if(d && d.children && d.children === true) { - tmp.state.loaded = false; - tmp.children = []; - tmp.children_d = []; - } - delete d.data; - delete d.children; - tmp.original = d; - m[tmp.id] = tmp; - if(tmp.state.selected) { - add.push(tmp.id); - } - return tmp.id; - }; - - if(dat.length && dat[0].id !== undefined && dat[0].parent !== undefined) { - // Flat JSON support (for easy import from DB): - // 1) convert to object (foreach) - for(i = 0, j = dat.length; i < j; i++) { - if(!dat[i].children) { - dat[i].children = []; - } - m[dat[i].id.toString()] = dat[i]; - } - // 2) populate children (foreach) - for(i = 0, j = dat.length; i < j; i++) { - m[dat[i].parent.toString()].children.push(dat[i].id.toString()); - // populate parent.children_d - p.children_d.push(dat[i].id.toString()); - } - // 3) normalize && populate parents and children_d with recursion - for(i = 0, j = p.children.length; i < j; i++) { - tmp = parse_flat(m[p.children[i]], par, p.parents.concat()); - dpc.push(tmp); - if(m[tmp].children_d.length) { - dpc = dpc.concat(m[tmp].children_d); - } - } - for(i = 0, j = p.parents.length; i < j; i++) { - m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc); - } - // ?) three_state selection - p.state.selected && t - (if three_state foreach(dat => ch) -> foreach(parents) if(parent.selected) child.selected = true; - rslt = { - 'cnt' : t_cnt, - 'mod' : m, - 'sel' : sel, - 'par' : par, - 'dpc' : dpc, - 'add' : add - }; - } - else { - for(i = 0, j = dat.length; i < j; i++) { - tmp = parse_nest(dat[i], par, p.parents.concat()); - if(tmp) { - chd.push(tmp); - dpc.push(tmp); - if(m[tmp].children_d.length) { - dpc = dpc.concat(m[tmp].children_d); - } - } - } - p.children = chd; - p.children_d = dpc; - for(i = 0, j = p.parents.length; i < j; i++) { - m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc); - } - rslt = { - 'cnt' : t_cnt, - 'mod' : m, - 'sel' : sel, - 'par' : par, - 'dpc' : dpc, - 'add' : add - }; - } - if(typeof window === 'undefined' || typeof window.document === 'undefined') { - postMessage(rslt); - } - else { - return rslt; - } - }, - rslt = function (rslt, worker) { - this._cnt = rslt.cnt; - this._model.data = rslt.mod; // breaks the reference in load_node - careful - - if(worker) { - var i, j, a = rslt.add, r = rslt.sel, s = this._data.core.selected.slice(), m = this._model.data; - // if selection was changed while calculating in worker - if(r.length !== s.length || $.vakata.array_unique(r.concat(s)).length !== r.length) { - // deselect nodes that are no longer selected - for(i = 0, j = r.length; i < j; i++) { - if($.inArray(r[i], a) === -1 && $.inArray(r[i], s) === -1) { - m[r[i]].state.selected = false; - } - } - // select nodes that were selected in the mean time - for(i = 0, j = s.length; i < j; i++) { - if($.inArray(s[i], r) === -1) { - m[s[i]].state.selected = true; - } - } - } - } - if(rslt.add.length) { - this._data.core.selected = this._data.core.selected.concat(rslt.add); - } - - this.trigger('model', { "nodes" : rslt.dpc, 'parent' : rslt.par }); - - if(rslt.par !== '#') { - this._node_changed(rslt.par); - this.redraw(); - } - else { - // this.get_container_ul().children('.jstree-initial-node').remove(); - this.redraw(true); - } - if(rslt.add.length) { - this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected }); - } - cb.call(this, true); - }; - if(this.settings.core.worker && window.Blob && window.URL && window.Worker) { - try { - if(this._wrk === null) { - this._wrk = window.URL.createObjectURL( - new window.Blob( - ['self.onmessage = ' + func.toString()], - {type:"text/javascript"} - ) - ); - } - if(!this._data.core.working || force_processing) { - this._data.core.working = true; - w = new window.Worker(this._wrk); - w.onmessage = $.proxy(function (e) { - rslt.call(this, e.data, true); - try { w.terminate(); w = null; } catch(ignore) { } - if(this._data.core.worker_queue.length) { - this._append_json_data.apply(this, this._data.core.worker_queue.shift()); - } - else { - this._data.core.working = false; - } - }, this); - if(!args.par) { - if(this._data.core.worker_queue.length) { - this._append_json_data.apply(this, this._data.core.worker_queue.shift()); - } - else { - this._data.core.working = false; - } - } - else { - w.postMessage(args); - } - } - else { - this._data.core.worker_queue.push([dom, data, cb, true]); - } - } - catch(e) { - rslt.call(this, func(args), false); - if(this._data.core.worker_queue.length) { - this._append_json_data.apply(this, this._data.core.worker_queue.shift()); - } - else { - this._data.core.working = false; - } - } - } - else { - rslt.call(this, func(args), false); - } - }, - /** - * parses a node from a jQuery object and appends them to the in memory tree model. Used internally. - * @private - * @name _parse_model_from_html(d [, p, ps]) - * @param {jQuery} d the jQuery object to parse - * @param {String} p the parent ID - * @param {Array} ps list of all parents - * @return {String} the ID of the object added to the model - */ - _parse_model_from_html : function (d, p, ps) { - if(!ps) { ps = []; } - else { ps = [].concat(ps); } - if(p) { ps.unshift(p); } - var c, e, m = this._model.data, - data = { - id : false, - text : false, - icon : true, - parent : p, - parents : ps, - children : [], - children_d : [], - data : null, - state : { }, - li_attr : { id : false }, - a_attr : { href : '#' }, - original : false - }, i, tmp, tid; - for(i in this._model.default_state) { - if(this._model.default_state.hasOwnProperty(i)) { - data.state[i] = this._model.default_state[i]; - } - } - tmp = $.vakata.attributes(d, true); - $.each(tmp, function (i, v) { - v = $.trim(v); - if(!v.length) { return true; } - data.li_attr[i] = v; - if(i === 'id') { - data.id = v.toString(); - } - }); - tmp = d.children('a').first(); - if(tmp.length) { - tmp = $.vakata.attributes(tmp, true); - $.each(tmp, function (i, v) { - v = $.trim(v); - if(v.length) { - data.a_attr[i] = v; - } - }); - } - tmp = d.children("a").first().length ? d.children("a").first().clone() : d.clone(); - tmp.children("ins, i, ul").remove(); - tmp = tmp.html(); - tmp = $('<div />').html(tmp); - data.text = this.settings.core.force_text ? tmp.text() : tmp.html(); - tmp = d.data(); - data.data = tmp ? $.extend(true, {}, tmp) : null; - data.state.opened = d.hasClass('jstree-open'); - data.state.selected = d.children('a').hasClass('jstree-clicked'); - data.state.disabled = d.children('a').hasClass('jstree-disabled'); - if(data.data && data.data.jstree) { - for(i in data.data.jstree) { - if(data.data.jstree.hasOwnProperty(i)) { - data.state[i] = data.data.jstree[i]; - } - } - } - tmp = d.children("a").children(".jstree-themeicon"); - if(tmp.length) { - data.icon = tmp.hasClass('jstree-themeicon-hidden') ? false : tmp.attr('rel'); - } - if(data.state.icon) { - data.icon = data.state.icon; - } - tmp = d.children("ul").children("li"); - do { - tid = 'j' + this._id + '_' + (++this._cnt); - } while(m[tid]); - data.id = data.li_attr.id ? data.li_attr.id.toString() : tid; - if(tmp.length) { - tmp.each($.proxy(function (i, v) { - c = this._parse_model_from_html($(v), data.id, ps); - e = this._model.data[c]; - data.children.push(c); - if(e.children_d.length) { - data.children_d = data.children_d.concat(e.children_d); - } - }, this)); - data.children_d = data.children_d.concat(data.children); - } - else { - if(d.hasClass('jstree-closed')) { - data.state.loaded = false; - } - } - if(data.li_attr['class']) { - data.li_attr['class'] = data.li_attr['class'].replace('jstree-closed','').replace('jstree-open',''); - } - if(data.a_attr['class']) { - data.a_attr['class'] = data.a_attr['class'].replace('jstree-clicked','').replace('jstree-disabled',''); - } - m[data.id] = data; - if(data.state.selected) { - this._data.core.selected.push(data.id); - } - return data.id; - }, - /** - * parses a node from a JSON object (used when dealing with flat data, which has no nesting of children, but has id and parent properties) and appends it to the in memory tree model. Used internally. - * @private - * @name _parse_model_from_flat_json(d [, p, ps]) - * @param {Object} d the JSON object to parse - * @param {String} p the parent ID - * @param {Array} ps list of all parents - * @return {String} the ID of the object added to the model - */ - _parse_model_from_flat_json : function (d, p, ps) { - if(!ps) { ps = []; } - else { ps = ps.concat(); } - if(p) { ps.unshift(p); } - var tid = d.id.toString(), - m = this._model.data, - df = this._model.default_state, - i, j, c, e, - tmp = { - id : tid, - text : d.text || '', - icon : d.icon !== undefined ? d.icon : true, - parent : p, - parents : ps, - children : d.children || [], - children_d : d.children_d || [], - data : d.data, - state : { }, - li_attr : { id : false }, - a_attr : { href : '#' }, - original : false - }; - for(i in df) { - if(df.hasOwnProperty(i)) { - tmp.state[i] = df[i]; - } - } - if(d && d.data && d.data.jstree && d.data.jstree.icon) { - tmp.icon = d.data.jstree.icon; - } - if(d && d.data) { - tmp.data = d.data; - if(d.data.jstree) { - for(i in d.data.jstree) { - if(d.data.jstree.hasOwnProperty(i)) { - tmp.state[i] = d.data.jstree[i]; - } - } - } - } - if(d && typeof d.state === 'object') { - for (i in d.state) { - if(d.state.hasOwnProperty(i)) { - tmp.state[i] = d.state[i]; - } - } - } - if(d && typeof d.li_attr === 'object') { - for (i in d.li_attr) { - if(d.li_attr.hasOwnProperty(i)) { - tmp.li_attr[i] = d.li_attr[i]; - } - } - } - if(!tmp.li_attr.id) { - tmp.li_attr.id = tid; - } - if(d && typeof d.a_attr === 'object') { - for (i in d.a_attr) { - if(d.a_attr.hasOwnProperty(i)) { - tmp.a_attr[i] = d.a_attr[i]; - } - } - } - if(d && d.children && d.children === true) { - tmp.state.loaded = false; - tmp.children = []; - tmp.children_d = []; - } - m[tmp.id] = tmp; - for(i = 0, j = tmp.children.length; i < j; i++) { - c = this._parse_model_from_flat_json(m[tmp.children[i]], tmp.id, ps); - e = m[c]; - tmp.children_d.push(c); - if(e.children_d.length) { - tmp.children_d = tmp.children_d.concat(e.children_d); - } - } - delete d.data; - delete d.children; - m[tmp.id].original = d; - if(tmp.state.selected) { - this._data.core.selected.push(tmp.id); - } - return tmp.id; - }, - /** - * parses a node from a JSON object and appends it to the in memory tree model. Used internally. - * @private - * @name _parse_model_from_json(d [, p, ps]) - * @param {Object} d the JSON object to parse - * @param {String} p the parent ID - * @param {Array} ps list of all parents - * @return {String} the ID of the object added to the model - */ - _parse_model_from_json : function (d, p, ps) { - if(!ps) { ps = []; } - else { ps = ps.concat(); } - if(p) { ps.unshift(p); } - var tid = false, i, j, c, e, m = this._model.data, df = this._model.default_state, tmp; - do { - tid = 'j' + this._id + '_' + (++this._cnt); - } while(m[tid]); - - tmp = { - id : false, - text : typeof d === 'string' ? d : '', - icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true, - parent : p, - parents : ps, - children : [], - children_d : [], - data : null, - state : { }, - li_attr : { id : false }, - a_attr : { href : '#' }, - original : false - }; - for(i in df) { - if(df.hasOwnProperty(i)) { - tmp.state[i] = df[i]; - } - } - if(d && d.id) { tmp.id = d.id.toString(); } - if(d && d.text) { tmp.text = d.text; } - if(d && d.data && d.data.jstree && d.data.jstree.icon) { - tmp.icon = d.data.jstree.icon; - } - if(d && d.data) { - tmp.data = d.data; - if(d.data.jstree) { - for(i in d.data.jstree) { - if(d.data.jstree.hasOwnProperty(i)) { - tmp.state[i] = d.data.jstree[i]; - } - } - } - } - if(d && typeof d.state === 'object') { - for (i in d.state) { - if(d.state.hasOwnProperty(i)) { - tmp.state[i] = d.state[i]; - } - } - } - if(d && typeof d.li_attr === 'object') { - for (i in d.li_attr) { - if(d.li_attr.hasOwnProperty(i)) { - tmp.li_attr[i] = d.li_attr[i]; - } - } - } - if(tmp.li_attr.id && !tmp.id) { - tmp.id = tmp.li_attr.id.toString(); - } - if(!tmp.id) { - tmp.id = tid; - } - if(!tmp.li_attr.id) { - tmp.li_attr.id = tmp.id; - } - if(d && typeof d.a_attr === 'object') { - for (i in d.a_attr) { - if(d.a_attr.hasOwnProperty(i)) { - tmp.a_attr[i] = d.a_attr[i]; - } - } - } - if(d && d.children && d.children.length) { - for(i = 0, j = d.children.length; i < j; i++) { - c = this._parse_model_from_json(d.children[i], tmp.id, ps); - e = m[c]; - tmp.children.push(c); - if(e.children_d.length) { - tmp.children_d = tmp.children_d.concat(e.children_d); - } - } - tmp.children_d = tmp.children_d.concat(tmp.children); - } - if(d && d.children && d.children === true) { - tmp.state.loaded = false; - tmp.children = []; - tmp.children_d = []; - } - delete d.data; - delete d.children; - tmp.original = d; - m[tmp.id] = tmp; - if(tmp.state.selected) { - this._data.core.selected.push(tmp.id); - } - return tmp.id; - }, - /** - * redraws all nodes that need to be redrawn. Used internally. - * @private - * @name _redraw() - * @trigger redraw.jstree - */ - _redraw : function () { - var nodes = this._model.force_full_redraw ? this._model.data['#'].children.concat([]) : this._model.changed.concat([]), - f = document.createElement('UL'), tmp, i, j, fe = this._data.core.focused; - for(i = 0, j = nodes.length; i < j; i++) { - tmp = this.redraw_node(nodes[i], true, this._model.force_full_redraw); - if(tmp && this._model.force_full_redraw) { - f.appendChild(tmp); - } - } - if(this._model.force_full_redraw) { - f.className = this.get_container_ul()[0].className; - f.setAttribute('role','group'); - this.element.empty().append(f); - //this.get_container_ul()[0].appendChild(f); - } - if(fe !== null) { - tmp = this.get_node(fe, true); - if(tmp && tmp.length && tmp.children('.jstree-anchor')[0] !== document.activeElement) { - tmp.children('.jstree-anchor').focus(); - } - else { - this._data.core.focused = null; - } - } - this._model.force_full_redraw = false; - this._model.changed = []; - /** - * triggered after nodes are redrawn - * @event - * @name redraw.jstree - * @param {array} nodes the redrawn nodes - */ - this.trigger('redraw', { "nodes" : nodes }); - }, - /** - * redraws all nodes that need to be redrawn or optionally - the whole tree - * @name redraw([full]) - * @param {Boolean} full if set to `true` all nodes are redrawn. - */ - redraw : function (full) { - if(full) { - this._model.force_full_redraw = true; - } - //if(this._model.redraw_timeout) { - // clearTimeout(this._model.redraw_timeout); - //} - //this._model.redraw_timeout = setTimeout($.proxy(this._redraw, this),0); - this._redraw(); - }, - /** - * redraws a single node's children. Used internally. - * @private - * @name draw_children(node) - * @param {mixed} node the node whose children will be redrawn - */ - draw_children : function (node) { - var obj = this.get_node(node), - i = false, - j = false, - k = false, - d = document; - if(!obj) { return false; } - if(obj.id === '#') { return this.redraw(true); } - node = this.get_node(node, true); - if(!node || !node.length) { return false; } // TODO: quick toggle - - node.children('.jstree-children').remove(); - node = node[0]; - if(obj.children.length && obj.state.loaded) { - k = d.createElement('UL'); - k.setAttribute('role', 'group'); - k.className = 'jstree-children'; - for(i = 0, j = obj.children.length; i < j; i++) { - k.appendChild(this.redraw_node(obj.children[i], true, true)); - } - node.appendChild(k); - } - }, - /** - * redraws a single node. Used internally. - * @private - * @name redraw_node(node, deep, is_callback, force_render) - * @param {mixed} node the node to redraw - * @param {Boolean} deep should child nodes be redrawn too - * @param {Boolean} is_callback is this a recursion call - * @param {Boolean} force_render should children of closed parents be drawn anyway - */ - redraw_node : function (node, deep, is_callback, force_render) { - var obj = this.get_node(node), - par = false, - ind = false, - old = false, - i = false, - j = false, - k = false, - c = '', - d = document, - m = this._model.data, - f = false, - s = false, - tmp = null, - t = 0, - l = 0; - if(!obj) { return false; } - if(obj.id === '#') { return this.redraw(true); } - deep = deep || obj.children.length === 0; - node = !document.querySelector ? document.getElementById(obj.id) : this.element[0].querySelector('#' + ("0123456789".indexOf(obj.id[0]) !== -1 ? '\\3' + obj.id[0] + ' ' + obj.id.substr(1).replace($.jstree.idregex,'\\$&') : obj.id.replace($.jstree.idregex,'\\$&')) ); //, this.element); - if(!node) { - deep = true; - //node = d.createElement('LI'); - if(!is_callback) { - par = obj.parent !== '#' ? $('#' + obj.parent.replace($.jstree.idregex,'\\$&'), this.element)[0] : null; - if(par !== null && (!par || !m[obj.parent].state.opened)) { - return false; - } - ind = $.inArray(obj.id, par === null ? m['#'].children : m[obj.parent].children); - } - } - else { - node = $(node); - if(!is_callback) { - par = node.parent().parent()[0]; - if(par === this.element[0]) { - par = null; - } - ind = node.index(); - } - // m[obj.id].data = node.data(); // use only node's data, no need to touch jquery storage - if(!deep && obj.children.length && !node.children('.jstree-children').length) { - deep = true; - } - if(!deep) { - old = node.children('.jstree-children')[0]; - } - f = node.children('.jstree-anchor')[0] === document.activeElement; - node.remove(); - //node = d.createElement('LI'); - //node = node[0]; - } - node = _node.cloneNode(true); - // node is DOM, deep is boolean - - c = 'jstree-node '; - for(i in obj.li_attr) { - if(obj.li_attr.hasOwnProperty(i)) { - if(i === 'id') { continue; } - if(i !== 'class') { - node.setAttribute(i, obj.li_attr[i]); - } - else { - c += obj.li_attr[i]; - } - } - } - if(!obj.a_attr.id) { - obj.a_attr.id = obj.id + '_anchor'; - } - node.setAttribute('aria-selected', !!obj.state.selected); - node.setAttribute('aria-level', obj.parents.length); - node.setAttribute('aria-labelledby', obj.a_attr.id); - if(obj.state.disabled) { - node.setAttribute('aria-disabled', true); - } - - if(obj.state.loaded && !obj.children.length) { - c += ' jstree-leaf'; - } - else { - c += obj.state.opened && obj.state.loaded ? ' jstree-open' : ' jstree-closed'; - node.setAttribute('aria-expanded', (obj.state.opened && obj.state.loaded) ); - } - if(obj.parent !== null && m[obj.parent].children[m[obj.parent].children.length - 1] === obj.id) { - c += ' jstree-last'; - } - node.id = obj.id; - node.className = c; - c = ( obj.state.selected ? ' jstree-clicked' : '') + ( obj.state.disabled ? ' jstree-disabled' : ''); - for(j in obj.a_attr) { - if(obj.a_attr.hasOwnProperty(j)) { - if(j === 'href' && obj.a_attr[j] === '#') { continue; } - if(j !== 'class') { - node.childNodes[1].setAttribute(j, obj.a_attr[j]); - } - else { - c += ' ' + obj.a_attr[j]; - } - } - } - if(c.length) { - node.childNodes[1].className = 'jstree-anchor ' + c; - } - if((obj.icon && obj.icon !== true) || obj.icon === false) { - if(obj.icon === false) { - node.childNodes[1].childNodes[0].className += ' jstree-themeicon-hidden'; - } - else if(obj.icon.indexOf('/') === -1 && obj.icon.indexOf('.') === -1) { - node.childNodes[1].childNodes[0].className += ' ' + obj.icon + ' jstree-themeicon-custom'; - } - else { - node.childNodes[1].childNodes[0].style.backgroundImage = 'url('+obj.icon+')'; - node.childNodes[1].childNodes[0].style.backgroundPosition = 'center center'; - node.childNodes[1].childNodes[0].style.backgroundSize = 'auto'; - node.childNodes[1].childNodes[0].className += ' jstree-themeicon-custom'; - } - } - - if(this.settings.core.force_text) { - node.childNodes[1].appendChild(d.createTextNode(obj.text)); - } - else { - node.childNodes[1].innerHTML += obj.text; - } - - - if(deep && obj.children.length && (obj.state.opened || force_render) && obj.state.loaded) { - k = d.createElement('UL'); - k.setAttribute('role', 'group'); - k.className = 'jstree-children'; - for(i = 0, j = obj.children.length; i < j; i++) { - k.appendChild(this.redraw_node(obj.children[i], deep, true)); - } - node.appendChild(k); - } - if(old) { - node.appendChild(old); - } - if(!is_callback) { - // append back using par / ind - if(!par) { - par = this.element[0]; - } - for(i = 0, j = par.childNodes.length; i < j; i++) { - if(par.childNodes[i] && par.childNodes[i].className && par.childNodes[i].className.indexOf('jstree-children') !== -1) { - tmp = par.childNodes[i]; - break; - } - } - if(!tmp) { - tmp = d.createElement('UL'); - tmp.setAttribute('role', 'group'); - tmp.className = 'jstree-children'; - par.appendChild(tmp); - } - par = tmp; - - if(ind < par.childNodes.length) { - par.insertBefore(node, par.childNodes[ind]); - } - else { - par.appendChild(node); - } - if(f) { - t = this.element[0].scrollTop; - l = this.element[0].scrollLeft; - node.childNodes[1].focus(); - this.element[0].scrollTop = t; - this.element[0].scrollLeft = l; - } - } - if(obj.state.opened && !obj.state.loaded) { - obj.state.opened = false; - setTimeout($.proxy(function () { - this.open_node(obj.id, false, 0); - }, this), 0); - } - return node; - }, - /** - * opens a node, revaling its children. If the node is not loaded it will be loaded and opened once ready. - * @name open_node(obj [, callback, animation]) - * @param {mixed} obj the node to open - * @param {Function} callback a function to execute once the node is opened - * @param {Number} animation the animation duration in milliseconds when opening the node (overrides the `core.animation` setting). Use `false` for no animation. - * @trigger open_node.jstree, after_open.jstree, before_open.jstree - */ - open_node : function (obj, callback, animation) { - var t1, t2, d, t; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.open_node(obj[t1], callback, animation); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { - return false; - } - animation = animation === undefined ? this.settings.core.animation : animation; - if(!this.is_closed(obj)) { - if(callback) { - callback.call(this, obj, false); - } - return false; - } - if(!this.is_loaded(obj)) { - if(this.is_loading(obj)) { - return setTimeout($.proxy(function () { - this.open_node(obj, callback, animation); - }, this), 500); - } - this.load_node(obj, function (o, ok) { - return ok ? this.open_node(o, callback, animation) : (callback ? callback.call(this, o, false) : false); - }); - } - else { - d = this.get_node(obj, true); - t = this; - if(d.length) { - if(animation && d.children(".jstree-children").length) { - d.children(".jstree-children").stop(true, true); - } - if(obj.children.length && !this._firstChild(d.children('.jstree-children')[0])) { - this.draw_children(obj); - //d = this.get_node(obj, true); - } - if(!animation) { - this.trigger('before_open', { "node" : obj }); - d[0].className = d[0].className.replace('jstree-closed', 'jstree-open'); - d[0].setAttribute("aria-expanded", true); - } - else { - this.trigger('before_open', { "node" : obj }); - d - .children(".jstree-children").css("display","none").end() - .removeClass("jstree-closed").addClass("jstree-open").attr("aria-expanded", true) - .children(".jstree-children").stop(true, true) - .slideDown(animation, function () { - this.style.display = ""; - t.trigger("after_open", { "node" : obj }); - }); - } - } - obj.state.opened = true; - if(callback) { - callback.call(this, obj, true); - } - if(!d.length) { - /** - * triggered when a node is about to be opened (if the node is supposed to be in the DOM, it will be, but it won't be visible yet) - * @event - * @name before_open.jstree - * @param {Object} node the opened node - */ - this.trigger('before_open', { "node" : obj }); - } - /** - * triggered when a node is opened (if there is an animation it will not be completed yet) - * @event - * @name open_node.jstree - * @param {Object} node the opened node - */ - this.trigger('open_node', { "node" : obj }); - if(!animation || !d.length) { - /** - * triggered when a node is opened and the animation is complete - * @event - * @name after_open.jstree - * @param {Object} node the opened node - */ - this.trigger("after_open", { "node" : obj }); - } - } - }, - /** - * opens every parent of a node (node should be loaded) - * @name _open_to(obj) - * @param {mixed} obj the node to reveal - * @private - */ - _open_to : function (obj) { - obj = this.get_node(obj); - if(!obj || obj.id === '#') { - return false; - } - var i, j, p = obj.parents; - for(i = 0, j = p.length; i < j; i+=1) { - if(i !== '#') { - this.open_node(p[i], false, 0); - } - } - return $('#' + obj.id.replace($.jstree.idregex,'\\$&'), this.element); - }, - /** - * closes a node, hiding its children - * @name close_node(obj [, animation]) - * @param {mixed} obj the node to close - * @param {Number} animation the animation duration in milliseconds when closing the node (overrides the `core.animation` setting). Use `false` for no animation. - * @trigger close_node.jstree, after_close.jstree - */ - close_node : function (obj, animation) { - var t1, t2, t, d; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.close_node(obj[t1], animation); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { - return false; - } - if(this.is_closed(obj)) { - return false; - } - animation = animation === undefined ? this.settings.core.animation : animation; - t = this; - d = this.get_node(obj, true); - if(d.length) { - if(!animation) { - d[0].className = d[0].className.replace('jstree-open', 'jstree-closed'); - d.attr("aria-expanded", false).children('.jstree-children').remove(); - } - else { - d - .children(".jstree-children").attr("style","display:block !important").end() - .removeClass("jstree-open").addClass("jstree-closed").attr("aria-expanded", false) - .children(".jstree-children").stop(true, true).slideUp(animation, function () { - this.style.display = ""; - d.children('.jstree-children').remove(); - t.trigger("after_close", { "node" : obj }); - }); - } - } - obj.state.opened = false; - /** - * triggered when a node is closed (if there is an animation it will not be complete yet) - * @event - * @name close_node.jstree - * @param {Object} node the closed node - */ - this.trigger('close_node',{ "node" : obj }); - if(!animation || !d.length) { - /** - * triggered when a node is closed and the animation is complete - * @event - * @name after_close.jstree - * @param {Object} node the closed node - */ - this.trigger("after_close", { "node" : obj }); - } - }, - /** - * toggles a node - closing it if it is open, opening it if it is closed - * @name toggle_node(obj) - * @param {mixed} obj the node to toggle - */ - toggle_node : function (obj) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.toggle_node(obj[t1]); - } - return true; - } - if(this.is_closed(obj)) { - return this.open_node(obj); - } - if(this.is_open(obj)) { - return this.close_node(obj); - } - }, - /** - * opens all nodes within a node (or the tree), revaling their children. If the node is not loaded it will be loaded and opened once ready. - * @name open_all([obj, animation, original_obj]) - * @param {mixed} obj the node to open recursively, omit to open all nodes in the tree - * @param {Number} animation the animation duration in milliseconds when opening the nodes, the default is no animation - * @param {jQuery} reference to the node that started the process (internal use) - * @trigger open_all.jstree - */ - open_all : function (obj, animation, original_obj) { - if(!obj) { obj = '#'; } - obj = this.get_node(obj); - if(!obj) { return false; } - var dom = obj.id === '#' ? this.get_container_ul() : this.get_node(obj, true), i, j, _this; - if(!dom.length) { - for(i = 0, j = obj.children_d.length; i < j; i++) { - if(this.is_closed(this._model.data[obj.children_d[i]])) { - this._model.data[obj.children_d[i]].state.opened = true; - } - } - return this.trigger('open_all', { "node" : obj }); - } - original_obj = original_obj || dom; - _this = this; - dom = this.is_closed(obj) ? dom.find('.jstree-closed').addBack() : dom.find('.jstree-closed'); - dom.each(function () { - _this.open_node( - this, - function(node, status) { if(status && this.is_parent(node)) { this.open_all(node, animation, original_obj); } }, - animation || 0 - ); - }); - if(original_obj.find('.jstree-closed').length === 0) { - /** - * triggered when an `open_all` call completes - * @event - * @name open_all.jstree - * @param {Object} node the opened node - */ - this.trigger('open_all', { "node" : this.get_node(original_obj) }); - } - }, - /** - * closes all nodes within a node (or the tree), revaling their children - * @name close_all([obj, animation]) - * @param {mixed} obj the node to close recursively, omit to close all nodes in the tree - * @param {Number} animation the animation duration in milliseconds when closing the nodes, the default is no animation - * @trigger close_all.jstree - */ - close_all : function (obj, animation) { - if(!obj) { obj = '#'; } - obj = this.get_node(obj); - if(!obj) { return false; } - var dom = obj.id === '#' ? this.get_container_ul() : this.get_node(obj, true), - _this = this, i, j; - if(!dom.length) { - for(i = 0, j = obj.children_d.length; i < j; i++) { - this._model.data[obj.children_d[i]].state.opened = false; - } - return this.trigger('close_all', { "node" : obj }); - } - dom = this.is_open(obj) ? dom.find('.jstree-open').addBack() : dom.find('.jstree-open'); - $(dom.get().reverse()).each(function () { _this.close_node(this, animation || 0); }); - /** - * triggered when an `close_all` call completes - * @event - * @name close_all.jstree - * @param {Object} node the closed node - */ - this.trigger('close_all', { "node" : obj }); - }, - /** - * checks if a node is disabled (not selectable) - * @name is_disabled(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_disabled : function (obj) { - obj = this.get_node(obj); - return obj && obj.state && obj.state.disabled; - }, - /** - * enables a node - so that it can be selected - * @name enable_node(obj) - * @param {mixed} obj the node to enable - * @trigger enable_node.jstree - */ - enable_node : function (obj) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.enable_node(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { - return false; - } - obj.state.disabled = false; - this.get_node(obj,true).children('.jstree-anchor').removeClass('jstree-disabled').attr('aria-disabled', false); - /** - * triggered when an node is enabled - * @event - * @name enable_node.jstree - * @param {Object} node the enabled node - */ - this.trigger('enable_node', { 'node' : obj }); - }, - /** - * disables a node - so that it can not be selected - * @name disable_node(obj) - * @param {mixed} obj the node to disable - * @trigger disable_node.jstree - */ - disable_node : function (obj) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.disable_node(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { - return false; - } - obj.state.disabled = true; - this.get_node(obj,true).children('.jstree-anchor').addClass('jstree-disabled').attr('aria-disabled', true); - /** - * triggered when an node is disabled - * @event - * @name disable_node.jstree - * @param {Object} node the disabled node - */ - this.trigger('disable_node', { 'node' : obj }); - }, - /** - * called when a node is selected by the user. Used internally. - * @private - * @name activate_node(obj, e) - * @param {mixed} obj the node - * @param {Object} e the related event - * @trigger activate_node.jstree, changed.jstree - */ - activate_node : function (obj, e) { - if(this.is_disabled(obj)) { - return false; - } - - // ensure last_clicked is still in the DOM, make it fresh (maybe it was moved?) and make sure it is still selected, if not - make last_clicked the last selected node - this._data.core.last_clicked = this._data.core.last_clicked && this._data.core.last_clicked.id !== undefined ? this.get_node(this._data.core.last_clicked.id) : null; - if(this._data.core.last_clicked && !this._data.core.last_clicked.state.selected) { this._data.core.last_clicked = null; } - if(!this._data.core.last_clicked && this._data.core.selected.length) { this._data.core.last_clicked = this.get_node(this._data.core.selected[this._data.core.selected.length - 1]); } - - if(!this.settings.core.multiple || (!e.metaKey && !e.ctrlKey && !e.shiftKey) || (e.shiftKey && (!this._data.core.last_clicked || !this.get_parent(obj) || this.get_parent(obj) !== this._data.core.last_clicked.parent ) )) { - if(!this.settings.core.multiple && (e.metaKey || e.ctrlKey || e.shiftKey) && this.is_selected(obj)) { - this.deselect_node(obj, false, e); - } - else { - this.deselect_all(true); - this.select_node(obj, false, false, e); - this._data.core.last_clicked = this.get_node(obj); - } - } - else { - if(e.shiftKey) { - var o = this.get_node(obj).id, - l = this._data.core.last_clicked.id, - p = this.get_node(this._data.core.last_clicked.parent).children, - c = false, - i, j; - for(i = 0, j = p.length; i < j; i += 1) { - // separate IFs work whem o and l are the same - if(p[i] === o) { - c = !c; - } - if(p[i] === l) { - c = !c; - } - if(c || p[i] === o || p[i] === l) { - this.select_node(p[i], true, false, e); - } - else { - this.deselect_node(p[i], true, e); - } - } - this.trigger('changed', { 'action' : 'select_node', 'node' : this.get_node(obj), 'selected' : this._data.core.selected, 'event' : e }); - } - else { - if(!this.is_selected(obj)) { - this.select_node(obj, false, false, e); - } - else { - this.deselect_node(obj, false, e); - } - } - } - /** - * triggered when an node is clicked or intercated with by the user - * @event - * @name activate_node.jstree - * @param {Object} node - */ - this.trigger('activate_node', { 'node' : this.get_node(obj) }); - }, - /** - * applies the hover state on a node, called when a node is hovered by the user. Used internally. - * @private - * @name hover_node(obj) - * @param {mixed} obj - * @trigger hover_node.jstree - */ - hover_node : function (obj) { - obj = this.get_node(obj, true); - if(!obj || !obj.length || obj.children('.jstree-hovered').length) { - return false; - } - var o = this.element.find('.jstree-hovered'), t = this.element; - if(o && o.length) { this.dehover_node(o); } - - obj.children('.jstree-anchor').addClass('jstree-hovered'); - /** - * triggered when an node is hovered - * @event - * @name hover_node.jstree - * @param {Object} node - */ - this.trigger('hover_node', { 'node' : this.get_node(obj) }); - setTimeout(function () { t.attr('aria-activedescendant', obj[0].id); }, 0); - }, - /** - * removes the hover state from a nodecalled when a node is no longer hovered by the user. Used internally. - * @private - * @name dehover_node(obj) - * @param {mixed} obj - * @trigger dehover_node.jstree - */ - dehover_node : function (obj) { - obj = this.get_node(obj, true); - if(!obj || !obj.length || !obj.children('.jstree-hovered').length) { - return false; - } - obj.children('.jstree-anchor').removeClass('jstree-hovered'); - /** - * triggered when an node is no longer hovered - * @event - * @name dehover_node.jstree - * @param {Object} node - */ - this.trigger('dehover_node', { 'node' : this.get_node(obj) }); - }, - /** - * select a node - * @name select_node(obj [, supress_event, prevent_open]) - * @param {mixed} obj an array can be used to select multiple nodes - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @param {Boolean} prevent_open if set to `true` parents of the selected node won't be opened - * @trigger select_node.jstree, changed.jstree - */ - select_node : function (obj, supress_event, prevent_open, e) { - var dom, t1, t2, th; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.select_node(obj[t1], supress_event, prevent_open, e); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { - return false; - } - dom = this.get_node(obj, true); - if(!obj.state.selected) { - obj.state.selected = true; - this._data.core.selected.push(obj.id); - if(!prevent_open) { - dom = this._open_to(obj); - } - if(dom && dom.length) { - dom.attr('aria-selected', true).children('.jstree-anchor').addClass('jstree-clicked'); - } - /** - * triggered when an node is selected - * @event - * @name select_node.jstree - * @param {Object} node - * @param {Array} selected the current selection - * @param {Object} event the event (if any) that triggered this select_node - */ - this.trigger('select_node', { 'node' : obj, 'selected' : this._data.core.selected, 'event' : e }); - if(!supress_event) { - /** - * triggered when selection changes - * @event - * @name changed.jstree - * @param {Object} node - * @param {Object} action the action that caused the selection to change - * @param {Array} selected the current selection - * @param {Object} event the event (if any) that triggered this changed event - */ - this.trigger('changed', { 'action' : 'select_node', 'node' : obj, 'selected' : this._data.core.selected, 'event' : e }); - } - } - }, - /** - * deselect a node - * @name deselect_node(obj [, supress_event]) - * @param {mixed} obj an array can be used to deselect multiple nodes - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @trigger deselect_node.jstree, changed.jstree - */ - deselect_node : function (obj, supress_event, e) { - var t1, t2, dom; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.deselect_node(obj[t1], supress_event, e); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { - return false; - } - dom = this.get_node(obj, true); - if(obj.state.selected) { - obj.state.selected = false; - this._data.core.selected = $.vakata.array_remove_item(this._data.core.selected, obj.id); - if(dom.length) { - dom.attr('aria-selected', false).children('.jstree-anchor').removeClass('jstree-clicked'); - } - /** - * triggered when an node is deselected - * @event - * @name deselect_node.jstree - * @param {Object} node - * @param {Array} selected the current selection - * @param {Object} event the event (if any) that triggered this deselect_node - */ - this.trigger('deselect_node', { 'node' : obj, 'selected' : this._data.core.selected, 'event' : e }); - if(!supress_event) { - this.trigger('changed', { 'action' : 'deselect_node', 'node' : obj, 'selected' : this._data.core.selected, 'event' : e }); - } - } - }, - /** - * select all nodes in the tree - * @name select_all([supress_event]) - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @trigger select_all.jstree, changed.jstree - */ - select_all : function (supress_event) { - var tmp = this._data.core.selected.concat([]), i, j; - this._data.core.selected = this._model.data['#'].children_d.concat(); - for(i = 0, j = this._data.core.selected.length; i < j; i++) { - if(this._model.data[this._data.core.selected[i]]) { - this._model.data[this._data.core.selected[i]].state.selected = true; - } - } - this.redraw(true); - /** - * triggered when all nodes are selected - * @event - * @name select_all.jstree - * @param {Array} selected the current selection - */ - this.trigger('select_all', { 'selected' : this._data.core.selected }); - if(!supress_event) { - this.trigger('changed', { 'action' : 'select_all', 'selected' : this._data.core.selected, 'old_selection' : tmp }); - } - }, - /** - * deselect all selected nodes - * @name deselect_all([supress_event]) - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @trigger deselect_all.jstree, changed.jstree - */ - deselect_all : function (supress_event) { - var tmp = this._data.core.selected.concat([]), i, j; - for(i = 0, j = this._data.core.selected.length; i < j; i++) { - if(this._model.data[this._data.core.selected[i]]) { - this._model.data[this._data.core.selected[i]].state.selected = false; - } - } - this._data.core.selected = []; - this.element.find('.jstree-clicked').removeClass('jstree-clicked').parent().attr('aria-selected', false); - /** - * triggered when all nodes are deselected - * @event - * @name deselect_all.jstree - * @param {Object} node the previous selection - * @param {Array} selected the current selection - */ - this.trigger('deselect_all', { 'selected' : this._data.core.selected, 'node' : tmp }); - if(!supress_event) { - this.trigger('changed', { 'action' : 'deselect_all', 'selected' : this._data.core.selected, 'old_selection' : tmp }); - } - }, - /** - * checks if a node is selected - * @name is_selected(obj) - * @param {mixed} obj - * @return {Boolean} - */ - is_selected : function (obj) { - obj = this.get_node(obj); - if(!obj || obj.id === '#') { - return false; - } - return obj.state.selected; - }, - /** - * get an array of all selected nodes - * @name get_selected([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - */ - get_selected : function (full) { - return full ? $.map(this._data.core.selected, $.proxy(function (i) { return this.get_node(i); }, this)) : this._data.core.selected.slice(); - }, - /** - * get an array of all top level selected nodes (ignoring children of selected nodes) - * @name get_top_selected([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - */ - get_top_selected : function (full) { - var tmp = this.get_selected(true), - obj = {}, i, j, k, l; - for(i = 0, j = tmp.length; i < j; i++) { - obj[tmp[i].id] = tmp[i]; - } - for(i = 0, j = tmp.length; i < j; i++) { - for(k = 0, l = tmp[i].children_d.length; k < l; k++) { - if(obj[tmp[i].children_d[k]]) { - delete obj[tmp[i].children_d[k]]; - } - } - } - tmp = []; - for(i in obj) { - if(obj.hasOwnProperty(i)) { - tmp.push(i); - } - } - return full ? $.map(tmp, $.proxy(function (i) { return this.get_node(i); }, this)) : tmp; - }, - /** - * get an array of all bottom level selected nodes (ignoring selected parents) - * @name get_bottom_selected([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - */ - get_bottom_selected : function (full) { - var tmp = this.get_selected(true), - obj = [], i, j; - for(i = 0, j = tmp.length; i < j; i++) { - if(!tmp[i].children.length) { - obj.push(tmp[i].id); - } - } - return full ? $.map(obj, $.proxy(function (i) { return this.get_node(i); }, this)) : obj; - }, - /** - * gets the current state of the tree so that it can be restored later with `set_state(state)`. Used internally. - * @name get_state() - * @private - * @return {Object} - */ - get_state : function () { - var state = { - 'core' : { - 'open' : [], - 'scroll' : { - 'left' : this.element.scrollLeft(), - 'top' : this.element.scrollTop() - }, - /*! - 'themes' : { - 'name' : this.get_theme(), - 'icons' : this._data.core.themes.icons, - 'dots' : this._data.core.themes.dots - }, - */ - 'selected' : [] - } - }, i; - for(i in this._model.data) { - if(this._model.data.hasOwnProperty(i)) { - if(i !== '#') { - if(this._model.data[i].state.opened) { - state.core.open.push(i); - } - if(this._model.data[i].state.selected) { - state.core.selected.push(i); - } - } - } - } - return state; - }, - /** - * sets the state of the tree. Used internally. - * @name set_state(state [, callback]) - * @private - * @param {Object} state the state to restore - * @param {Function} callback an optional function to execute once the state is restored. - * @trigger set_state.jstree - */ - set_state : function (state, callback) { - if(state) { - if(state.core) { - var res, n, t, _this; - if(state.core.open) { - if(!$.isArray(state.core.open)) { - delete state.core.open; - this.set_state(state, callback); - return false; - } - res = true; - n = false; - t = this; - $.each(state.core.open.concat([]), function (i, v) { - n = t.get_node(v); - if(n) { - if(t.is_loaded(v)) { - if(t.is_closed(v)) { - t.open_node(v, false, 0); - } - if(state && state.core && state.core.open) { - $.vakata.array_remove_item(state.core.open, v); - } - } - else { - if(!t.is_loading(v)) { - t.open_node(v, $.proxy(function (o, s) { - if(!s && state && state.core && state.core.open) { - $.vakata.array_remove_item(state.core.open, o.id); - } - this.set_state(state, callback); - }, t), 0); - } - // there will be some async activity - so wait for it - res = false; - } - } - }); - if(res) { - delete state.core.open; - this.set_state(state, callback); - } - return false; - } - if(state.core.scroll) { - if(state.core.scroll && state.core.scroll.left !== undefined) { - this.element.scrollLeft(state.core.scroll.left); - } - if(state.core.scroll && state.core.scroll.top !== undefined) { - this.element.scrollTop(state.core.scroll.top); - } - delete state.core.scroll; - this.set_state(state, callback); - return false; - } - /*! - if(state.core.themes) { - if(state.core.themes.name) { - this.set_theme(state.core.themes.name); - } - if(typeof state.core.themes.dots !== 'undefined') { - this[ state.core.themes.dots ? "show_dots" : "hide_dots" ](); - } - if(typeof state.core.themes.icons !== 'undefined') { - this[ state.core.themes.icons ? "show_icons" : "hide_icons" ](); - } - delete state.core.themes; - delete state.core.open; - this.set_state(state, callback); - return false; - } - */ - if(state.core.selected) { - _this = this; - this.deselect_all(); - $.each(state.core.selected, function (i, v) { - _this.select_node(v); - }); - delete state.core.selected; - this.set_state(state, callback); - return false; - } - if($.isEmptyObject(state.core)) { - delete state.core; - this.set_state(state, callback); - return false; - } - } - if($.isEmptyObject(state)) { - state = null; - if(callback) { callback.call(this); } - /** - * triggered when a `set_state` call completes - * @event - * @name set_state.jstree - */ - this.trigger('set_state'); - return false; - } - return true; - } - return false; - }, - /** - * refreshes the tree - all nodes are reloaded with calls to `load_node`. - * @name refresh() - * @param {Boolean} skip_loading an option to skip showing the loading indicator - * @param {Mixed} forget_state if set to `true` state will not be reapplied, if set to a function (receiving the current state as argument) the result of that function will be used as state - * @trigger refresh.jstree - */ - refresh : function (skip_loading, forget_state) { - this._data.core.state = forget_state === true ? {} : this.get_state(); - if(forget_state && $.isFunction(forget_state)) { this._data.core.state = forget_state.call(this, this._data.core.state); } - this._cnt = 0; - this._model.data = { - '#' : { - id : '#', - parent : null, - parents : [], - children : [], - children_d : [], - state : { loaded : false } - } - }; - var c = this.get_container_ul()[0].className; - if(!skip_loading) { - this.element.html("<"+"ul class='"+c+"' role='group'><"+"li class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='treeitem' id='j"+this._id+"_loading'><i class='jstree-icon jstree-ocl'></i><"+"a class='jstree-anchor' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>" + this.get_string("Loading ...") + "</a></li></ul>"); - this.element.attr('aria-activedescendant','j'+this._id+'_loading'); - } - this.load_node('#', function (o, s) { - if(s) { - this.get_container_ul()[0].className = c; - if(this._firstChild(this.get_container_ul()[0])) { - this.element.attr('aria-activedescendant',this._firstChild(this.get_container_ul()[0]).id); - } - this.set_state($.extend(true, {}, this._data.core.state), function () { - /** - * triggered when a `refresh` call completes - * @event - * @name refresh.jstree - */ - this.trigger('refresh'); - }); - } - this._data.core.state = null; - }); - }, - /** - * refreshes a node in the tree (reload its children) all opened nodes inside that node are reloaded with calls to `load_node`. - * @name refresh_node(obj) - * @param {mixed} obj the node - * @trigger refresh_node.jstree - */ - refresh_node : function (obj) { - obj = this.get_node(obj); - if(!obj || obj.id === '#') { return false; } - var opened = [], to_load = [], s = this._data.core.selected.concat([]); - to_load.push(obj.id); - if(obj.state.opened === true) { opened.push(obj.id); } - this.get_node(obj, true).find('.jstree-open').each(function() { opened.push(this.id); }); - this._load_nodes(to_load, $.proxy(function (nodes) { - this.open_node(opened, false, 0); - this.select_node(this._data.core.selected); - /** - * triggered when a node is refreshed - * @event - * @name refresh_node.jstree - * @param {Object} node - the refreshed node - * @param {Array} nodes - an array of the IDs of the nodes that were reloaded - */ - this.trigger('refresh_node', { 'node' : obj, 'nodes' : nodes }); - }, this)); - }, - /** - * set (change) the ID of a node - * @name set_id(obj, id) - * @param {mixed} obj the node - * @param {String} id the new ID - * @return {Boolean} - */ - set_id : function (obj, id) { - obj = this.get_node(obj); - if(!obj || obj.id === '#') { return false; } - var i, j, m = this._model.data; - id = id.toString(); - // update parents (replace current ID with new one in children and children_d) - m[obj.parent].children[$.inArray(obj.id, m[obj.parent].children)] = id; - for(i = 0, j = obj.parents.length; i < j; i++) { - m[obj.parents[i]].children_d[$.inArray(obj.id, m[obj.parents[i]].children_d)] = id; - } - // update children (replace current ID with new one in parent and parents) - for(i = 0, j = obj.children.length; i < j; i++) { - m[obj.children[i]].parent = id; - } - for(i = 0, j = obj.children_d.length; i < j; i++) { - m[obj.children_d[i]].parents[$.inArray(obj.id, m[obj.children_d[i]].parents)] = id; - } - i = $.inArray(obj.id, this._data.core.selected); - if(i !== -1) { this._data.core.selected[i] = id; } - // update model and obj itself (obj.id, this._model.data[KEY]) - i = this.get_node(obj.id, true); - if(i) { - i.attr('id', id); - } - delete m[obj.id]; - obj.id = id; - m[id] = obj; - return true; - }, - /** - * get the text value of a node - * @name get_text(obj) - * @param {mixed} obj the node - * @return {String} - */ - get_text : function (obj) { - obj = this.get_node(obj); - return (!obj || obj.id === '#') ? false : obj.text; - }, - /** - * set the text value of a node. Used internally, please use `rename_node(obj, val)`. - * @private - * @name set_text(obj, val) - * @param {mixed} obj the node, you can pass an array to set the text on multiple nodes - * @param {String} val the new text value - * @return {Boolean} - * @trigger set_text.jstree - */ - set_text : function (obj, val) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.set_text(obj[t1], val); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { return false; } - obj.text = val; - if(this.get_node(obj, true).length) { - this.redraw_node(obj.id); - } - /** - * triggered when a node text value is changed - * @event - * @name set_text.jstree - * @param {Object} obj - * @param {String} text the new value - */ - this.trigger('set_text',{ "obj" : obj, "text" : val }); - return true; - }, - /** - * gets a JSON representation of a node (or the whole tree) - * @name get_json([obj, options]) - * @param {mixed} obj - * @param {Object} options - * @param {Boolean} options.no_state do not return state information - * @param {Boolean} options.no_id do not return ID - * @param {Boolean} options.no_children do not include children - * @param {Boolean} options.no_data do not include node data - * @param {Boolean} options.flat return flat JSON instead of nested - * @return {Object} - */ - get_json : function (obj, options, flat) { - obj = this.get_node(obj || '#'); - if(!obj) { return false; } - if(options && options.flat && !flat) { flat = []; } - var tmp = { - 'id' : obj.id, - 'text' : obj.text, - 'icon' : this.get_icon(obj), - 'li_attr' : $.extend(true, {}, obj.li_attr), - 'a_attr' : $.extend(true, {}, obj.a_attr), - 'state' : {}, - 'data' : options && options.no_data ? false : $.extend(true, {}, obj.data) - //( this.get_node(obj, true).length ? this.get_node(obj, true).data() : obj.data ), - }, i, j; - if(options && options.flat) { - tmp.parent = obj.parent; - } - else { - tmp.children = []; - } - if(!options || !options.no_state) { - for(i in obj.state) { - if(obj.state.hasOwnProperty(i)) { - tmp.state[i] = obj.state[i]; - } - } - } - if(options && options.no_id) { - delete tmp.id; - if(tmp.li_attr && tmp.li_attr.id) { - delete tmp.li_attr.id; - } - if(tmp.a_attr && tmp.a_attr.id) { - delete tmp.a_attr.id; - } - } - if(options && options.flat && obj.id !== '#') { - flat.push(tmp); - } - if(!options || !options.no_children) { - for(i = 0, j = obj.children.length; i < j; i++) { - if(options && options.flat) { - this.get_json(obj.children[i], options, flat); - } - else { - tmp.children.push(this.get_json(obj.children[i], options)); - } - } - } - return options && options.flat ? flat : (obj.id === '#' ? tmp.children : tmp); - }, - /** - * create a new node (do not confuse with load_node) - * @name create_node([obj, node, pos, callback, is_loaded]) - * @param {mixed} par the parent node (to create a root node use either "#" (string) or `null`) - * @param {mixed} node the data for the new node (a valid JSON object, or a simple string with the name) - * @param {mixed} pos the index at which to insert the node, "first" and "last" are also supported, default is "last" - * @param {Function} callback a function to be called once the node is created - * @param {Boolean} is_loaded internal argument indicating if the parent node was succesfully loaded - * @return {String} the ID of the newly create node - * @trigger model.jstree, create_node.jstree - */ - create_node : function (par, node, pos, callback, is_loaded) { - if(par === null) { par = "#"; } - par = this.get_node(par); - if(!par) { return false; } - pos = pos === undefined ? "last" : pos; - if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { - return this.load_node(par, function () { this.create_node(par, node, pos, callback, true); }); - } - if(!node) { node = { "text" : this.get_string('New node') }; } - if(typeof node === "string") { node = { "text" : node }; } - if(node.text === undefined) { node.text = this.get_string('New node'); } - var tmp, dpc, i, j; - - if(par.id === '#') { - if(pos === "before") { pos = "first"; } - if(pos === "after") { pos = "last"; } - } - switch(pos) { - case "before": - tmp = this.get_node(par.parent); - pos = $.inArray(par.id, tmp.children); - par = tmp; - break; - case "after" : - tmp = this.get_node(par.parent); - pos = $.inArray(par.id, tmp.children) + 1; - par = tmp; - break; - case "inside": - case "first": - pos = 0; - break; - case "last": - pos = par.children.length; - break; - default: - if(!pos) { pos = 0; } - break; - } - if(pos > par.children.length) { pos = par.children.length; } - if(!node.id) { node.id = true; } - if(!this.check("create_node", node, par, pos)) { - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - if(node.id === true) { delete node.id; } - node = this._parse_model_from_json(node, par.id, par.parents.concat()); - if(!node) { return false; } - tmp = this.get_node(node); - dpc = []; - dpc.push(node); - dpc = dpc.concat(tmp.children_d); - this.trigger('model', { "nodes" : dpc, "parent" : par.id }); - - par.children_d = par.children_d.concat(dpc); - for(i = 0, j = par.parents.length; i < j; i++) { - this._model.data[par.parents[i]].children_d = this._model.data[par.parents[i]].children_d.concat(dpc); - } - node = tmp; - tmp = []; - for(i = 0, j = par.children.length; i < j; i++) { - tmp[i >= pos ? i+1 : i] = par.children[i]; - } - tmp[pos] = node.id; - par.children = tmp; - - this.redraw_node(par, true); - if(callback) { callback.call(this, this.get_node(node)); } - /** - * triggered when a node is created - * @event - * @name create_node.jstree - * @param {Object} node - * @param {String} parent the parent's ID - * @param {Number} position the position of the new node among the parent's children - */ - this.trigger('create_node', { "node" : this.get_node(node), "parent" : par.id, "position" : pos }); - return node.id; - }, - /** - * set the text value of a node - * @name rename_node(obj, val) - * @param {mixed} obj the node, you can pass an array to rename multiple nodes to the same name - * @param {String} val the new text value - * @return {Boolean} - * @trigger rename_node.jstree - */ - rename_node : function (obj, val) { - var t1, t2, old; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.rename_node(obj[t1], val); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { return false; } - old = obj.text; - if(!this.check("rename_node", obj, this.get_parent(obj), val)) { - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - this.set_text(obj, val); // .apply(this, Array.prototype.slice.call(arguments)) - /** - * triggered when a node is renamed - * @event - * @name rename_node.jstree - * @param {Object} node - * @param {String} text the new value - * @param {String} old the old value - */ - this.trigger('rename_node', { "node" : obj, "text" : val, "old" : old }); - return true; - }, - /** - * remove a node - * @name delete_node(obj) - * @param {mixed} obj the node, you can pass an array to delete multiple nodes - * @return {Boolean} - * @trigger delete_node.jstree, changed.jstree - */ - delete_node : function (obj) { - var t1, t2, par, pos, tmp, i, j, k, l, c; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.delete_node(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { return false; } - par = this.get_node(obj.parent); - pos = $.inArray(obj.id, par.children); - c = false; - if(!this.check("delete_node", obj, par, pos)) { - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - if(pos !== -1) { - par.children = $.vakata.array_remove(par.children, pos); - } - tmp = obj.children_d.concat([]); - tmp.push(obj.id); - for(k = 0, l = tmp.length; k < l; k++) { - for(i = 0, j = obj.parents.length; i < j; i++) { - pos = $.inArray(tmp[k], this._model.data[obj.parents[i]].children_d); - if(pos !== -1) { - this._model.data[obj.parents[i]].children_d = $.vakata.array_remove(this._model.data[obj.parents[i]].children_d, pos); - } - } - if(this._model.data[tmp[k]].state.selected) { - c = true; - pos = $.inArray(tmp[k], this._data.core.selected); - if(pos !== -1) { - this._data.core.selected = $.vakata.array_remove(this._data.core.selected, pos); - } - } - } - /** - * triggered when a node is deleted - * @event - * @name delete_node.jstree - * @param {Object} node - * @param {String} parent the parent's ID - */ - this.trigger('delete_node', { "node" : obj, "parent" : par.id }); - if(c) { - this.trigger('changed', { 'action' : 'delete_node', 'node' : obj, 'selected' : this._data.core.selected, 'parent' : par.id }); - } - for(k = 0, l = tmp.length; k < l; k++) { - delete this._model.data[tmp[k]]; - } - this.redraw_node(par, true); - return true; - }, - /** - * check if an operation is premitted on the tree. Used internally. - * @private - * @name check(chk, obj, par, pos) - * @param {String} chk the operation to check, can be "create_node", "rename_node", "delete_node", "copy_node" or "move_node" - * @param {mixed} obj the node - * @param {mixed} par the parent - * @param {mixed} pos the position to insert at, or if "rename_node" - the new name - * @param {mixed} more some various additional information, for example if a "move_node" operations is triggered by DND this will be the hovered node - * @return {Boolean} - */ - check : function (chk, obj, par, pos, more) { - obj = obj && obj.id ? obj : this.get_node(obj); - par = par && par.id ? par : this.get_node(par); - var tmp = chk.match(/^move_node|copy_node|create_node$/i) ? par : obj, - chc = this.settings.core.check_callback; - if(chk === "move_node" || chk === "copy_node") { - if((!more || !more.is_multi) && (obj.id === par.id || $.inArray(obj.id, par.children) === pos || $.inArray(par.id, obj.children_d) !== -1)) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_01', 'reason' : 'Moving parent inside child', 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - return false; - } - } - if(tmp && tmp.data) { tmp = tmp.data; } - if(tmp && tmp.functions && (tmp.functions[chk] === false || tmp.functions[chk] === true)) { - if(tmp.functions[chk] === false) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_02', 'reason' : 'Node data prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - } - return tmp.functions[chk]; - } - if(chc === false || ($.isFunction(chc) && chc.call(this, chk, obj, par, pos, more) === false) || (chc && chc[chk] === false)) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_03', 'reason' : 'User config for core.check_callback prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - return false; - } - return true; - }, - /** - * get the last error - * @name last_error() - * @return {Object} - */ - last_error : function () { - return this._data.core.last_error; - }, - /** - * move a node to a new parent - * @name move_node(obj, par [, pos, callback, is_loaded]) - * @param {mixed} obj the node to move, pass an array to move multiple nodes - * @param {mixed} par the new parent - * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0` - * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position - * @param {Boolean} internal parameter indicating if the parent node has been loaded - * @param {Boolean} internal parameter indicating if the tree should be redrawn - * @trigger move_node.jstree - */ - move_node : function (obj, par, pos, callback, is_loaded, skip_redraw) { - var t1, t2, old_par, old_pos, new_par, old_ins, is_multi, dpc, tmp, i, j, k, l, p; - - par = this.get_node(par); - pos = pos === undefined ? 0 : pos; - if(!par) { return false; } - if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { - return this.load_node(par, function () { this.move_node(obj, par, pos, callback, true); }); - } - - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - if(this.move_node(obj[t1], par, pos, callback, is_loaded, true)) { - par = obj[t1]; - pos = "after"; - } - } - this.redraw(); - return true; - } - obj = obj && obj.id ? obj : this.get_node(obj); - - if(!obj || obj.id === '#') { return false; } - - old_par = (obj.parent || '#').toString(); - new_par = (!pos.toString().match(/^(before|after)$/) || par.id === '#') ? par : this.get_node(par.parent); - old_ins = obj.instance ? obj.instance : (this._model.data[obj.id] ? this : $.jstree.reference(obj.id)); - is_multi = !old_ins || !old_ins._id || (this._id !== old_ins._id); - old_pos = old_ins && old_ins._id && old_par && old_ins._model.data[old_par] && old_ins._model.data[old_par].children ? $.inArray(obj.id, old_ins._model.data[old_par].children) : -1; - if(is_multi) { - if(this.copy_node(obj, par, pos, callback, is_loaded)) { - if(old_ins) { old_ins.delete_node(obj); } - return true; - } - return false; - } - //var m = this._model.data; - if(par.id === '#') { - if(pos === "before") { pos = "first"; } - if(pos === "after") { pos = "last"; } - } - switch(pos) { - case "before": - pos = $.inArray(par.id, new_par.children); - break; - case "after" : - pos = $.inArray(par.id, new_par.children) + 1; - break; - case "inside": - case "first": - pos = 0; - break; - case "last": - pos = new_par.children.length; - break; - default: - if(!pos) { pos = 0; } - break; - } - if(pos > new_par.children.length) { pos = new_par.children.length; } - if(!this.check("move_node", obj, new_par, pos, { 'core' : true, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) { - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - if(obj.parent === new_par.id) { - dpc = new_par.children.concat(); - tmp = $.inArray(obj.id, dpc); - if(tmp !== -1) { - dpc = $.vakata.array_remove(dpc, tmp); - if(pos > tmp) { pos--; } - } - tmp = []; - for(i = 0, j = dpc.length; i < j; i++) { - tmp[i >= pos ? i+1 : i] = dpc[i]; - } - tmp[pos] = obj.id; - new_par.children = tmp; - this._node_changed(new_par.id); - this.redraw(new_par.id === '#'); - } - else { - // clean old parent and up - tmp = obj.children_d.concat(); - tmp.push(obj.id); - for(i = 0, j = obj.parents.length; i < j; i++) { - dpc = []; - p = old_ins._model.data[obj.parents[i]].children_d; - for(k = 0, l = p.length; k < l; k++) { - if($.inArray(p[k], tmp) === -1) { - dpc.push(p[k]); - } - } - old_ins._model.data[obj.parents[i]].children_d = dpc; - } - old_ins._model.data[old_par].children = $.vakata.array_remove_item(old_ins._model.data[old_par].children, obj.id); - - // insert into new parent and up - for(i = 0, j = new_par.parents.length; i < j; i++) { - this._model.data[new_par.parents[i]].children_d = this._model.data[new_par.parents[i]].children_d.concat(tmp); - } - dpc = []; - for(i = 0, j = new_par.children.length; i < j; i++) { - dpc[i >= pos ? i+1 : i] = new_par.children[i]; - } - dpc[pos] = obj.id; - new_par.children = dpc; - new_par.children_d.push(obj.id); - new_par.children_d = new_par.children_d.concat(obj.children_d); - - // update object - obj.parent = new_par.id; - tmp = new_par.parents.concat(); - tmp.unshift(new_par.id); - p = obj.parents.length; - obj.parents = tmp; - - // update object children - tmp = tmp.concat(); - for(i = 0, j = obj.children_d.length; i < j; i++) { - this._model.data[obj.children_d[i]].parents = this._model.data[obj.children_d[i]].parents.slice(0,p*-1); - Array.prototype.push.apply(this._model.data[obj.children_d[i]].parents, tmp); - } - - if(old_par === '#' || new_par.id === '#') { - this._model.force_full_redraw = true; - } - if(!this._model.force_full_redraw) { - this._node_changed(old_par); - this._node_changed(new_par.id); - } - if(!skip_redraw) { - this.redraw(); - } - } - if(callback) { callback.call(this, obj, new_par, pos); } - /** - * triggered when a node is moved - * @event - * @name move_node.jstree - * @param {Object} node - * @param {String} parent the parent's ID - * @param {Number} position the position of the node among the parent's children - * @param {String} old_parent the old parent of the node - * @param {Number} old_position the old position of the node - * @param {Boolean} is_multi do the node and new parent belong to different instances - * @param {jsTree} old_instance the instance the node came from - * @param {jsTree} new_instance the instance of the new parent - */ - this.trigger('move_node', { "node" : obj, "parent" : new_par.id, "position" : pos, "old_parent" : old_par, "old_position" : old_pos, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id), 'old_instance' : old_ins, 'new_instance' : this }); - return true; - }, - /** - * copy a node to a new parent - * @name copy_node(obj, par [, pos, callback, is_loaded]) - * @param {mixed} obj the node to copy, pass an array to copy multiple nodes - * @param {mixed} par the new parent - * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0` - * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position - * @param {Boolean} internal parameter indicating if the parent node has been loaded - * @param {Boolean} internal parameter indicating if the tree should be redrawn - * @trigger model.jstree copy_node.jstree - */ - copy_node : function (obj, par, pos, callback, is_loaded, skip_redraw) { - var t1, t2, dpc, tmp, i, j, node, old_par, new_par, old_ins, is_multi; - - par = this.get_node(par); - pos = pos === undefined ? 0 : pos; - if(!par) { return false; } - if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { - return this.load_node(par, function () { this.copy_node(obj, par, pos, callback, true); }); - } - - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - tmp = this.copy_node(obj[t1], par, pos, callback, is_loaded, true); - if(tmp) { - par = tmp; - pos = "after"; - } - } - this.redraw(); - return true; - } - obj = obj && obj.id ? obj : this.get_node(obj); - if(!obj || obj.id === '#') { return false; } - - old_par = (obj.parent || '#').toString(); - new_par = (!pos.toString().match(/^(before|after)$/) || par.id === '#') ? par : this.get_node(par.parent); - old_ins = obj.instance ? obj.instance : (this._model.data[obj.id] ? this : $.jstree.reference(obj.id)); - is_multi = !old_ins || !old_ins._id || (this._id !== old_ins._id); - if(par.id === '#') { - if(pos === "before") { pos = "first"; } - if(pos === "after") { pos = "last"; } - } - switch(pos) { - case "before": - pos = $.inArray(par.id, new_par.children); - break; - case "after" : - pos = $.inArray(par.id, new_par.children) + 1; - break; - case "inside": - case "first": - pos = 0; - break; - case "last": - pos = new_par.children.length; - break; - default: - if(!pos) { pos = 0; } - break; - } - if(pos > new_par.children.length) { pos = new_par.children.length; } - if(!this.check("copy_node", obj, new_par, pos, { 'core' : true, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) { - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - node = old_ins ? old_ins.get_json(obj, { no_id : true, no_data : true, no_state : true }) : obj; - if(!node) { return false; } - if(node.id === true) { delete node.id; } - node = this._parse_model_from_json(node, new_par.id, new_par.parents.concat()); - if(!node) { return false; } - tmp = this.get_node(node); - if(obj && obj.state && obj.state.loaded === false) { tmp.state.loaded = false; } - dpc = []; - dpc.push(node); - dpc = dpc.concat(tmp.children_d); - this.trigger('model', { "nodes" : dpc, "parent" : new_par.id }); - - // insert into new parent and up - for(i = 0, j = new_par.parents.length; i < j; i++) { - this._model.data[new_par.parents[i]].children_d = this._model.data[new_par.parents[i]].children_d.concat(dpc); - } - dpc = []; - for(i = 0, j = new_par.children.length; i < j; i++) { - dpc[i >= pos ? i+1 : i] = new_par.children[i]; - } - dpc[pos] = tmp.id; - new_par.children = dpc; - new_par.children_d.push(tmp.id); - new_par.children_d = new_par.children_d.concat(tmp.children_d); - - if(new_par.id === '#') { - this._model.force_full_redraw = true; - } - if(!this._model.force_full_redraw) { - this._node_changed(new_par.id); - } - if(!skip_redraw) { - this.redraw(new_par.id === '#'); - } - if(callback) { callback.call(this, tmp, new_par, pos); } - /** - * triggered when a node is copied - * @event - * @name copy_node.jstree - * @param {Object} node the copied node - * @param {Object} original the original node - * @param {String} parent the parent's ID - * @param {Number} position the position of the node among the parent's children - * @param {String} old_parent the old parent of the node - * @param {Number} old_position the position of the original node - * @param {Boolean} is_multi do the node and new parent belong to different instances - * @param {jsTree} old_instance the instance the node came from - * @param {jsTree} new_instance the instance of the new parent - */ - this.trigger('copy_node', { "node" : tmp, "original" : obj, "parent" : new_par.id, "position" : pos, "old_parent" : old_par, "old_position" : old_ins && old_ins._id && old_par && old_ins._model.data[old_par] && old_ins._model.data[old_par].children ? $.inArray(obj.id, old_ins._model.data[old_par].children) : -1,'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id), 'old_instance' : old_ins, 'new_instance' : this }); - return tmp.id; - }, - /** - * cut a node (a later call to `paste(obj)` would move the node) - * @name cut(obj) - * @param {mixed} obj multiple objects can be passed using an array - * @trigger cut.jstree - */ - cut : function (obj) { - if(!obj) { obj = this._data.core.selected.concat(); } - if(!$.isArray(obj)) { obj = [obj]; } - if(!obj.length) { return false; } - var tmp = [], o, t1, t2; - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - o = this.get_node(obj[t1]); - if(o && o.id && o.id !== '#') { tmp.push(o); } - } - if(!tmp.length) { return false; } - ccp_node = tmp; - ccp_inst = this; - ccp_mode = 'move_node'; - /** - * triggered when nodes are added to the buffer for moving - * @event - * @name cut.jstree - * @param {Array} node - */ - this.trigger('cut', { "node" : obj }); - }, - /** - * copy a node (a later call to `paste(obj)` would copy the node) - * @name copy(obj) - * @param {mixed} obj multiple objects can be passed using an array - * @trigger copy.jstre - */ - copy : function (obj) { - if(!obj) { obj = this._data.core.selected.concat(); } - if(!$.isArray(obj)) { obj = [obj]; } - if(!obj.length) { return false; } - var tmp = [], o, t1, t2; - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - o = this.get_node(obj[t1]); - if(o && o.id && o.id !== '#') { tmp.push(o); } - } - if(!tmp.length) { return false; } - ccp_node = tmp; - ccp_inst = this; - ccp_mode = 'copy_node'; - /** - * triggered when nodes are added to the buffer for copying - * @event - * @name copy.jstree - * @param {Array} node - */ - this.trigger('copy', { "node" : obj }); - }, - /** - * get the current buffer (any nodes that are waiting for a paste operation) - * @name get_buffer() - * @return {Object} an object consisting of `mode` ("copy_node" or "move_node"), `node` (an array of objects) and `inst` (the instance) - */ - get_buffer : function () { - return { 'mode' : ccp_mode, 'node' : ccp_node, 'inst' : ccp_inst }; - }, - /** - * check if there is something in the buffer to paste - * @name can_paste() - * @return {Boolean} - */ - can_paste : function () { - return ccp_mode !== false && ccp_node !== false; // && ccp_inst._model.data[ccp_node]; - }, - /** - * copy or move the previously cut or copied nodes to a new parent - * @name paste(obj [, pos]) - * @param {mixed} obj the new parent - * @param {mixed} pos the position to insert at (besides integer, "first" and "last" are supported), defaults to integer `0` - * @trigger paste.jstree - */ - paste : function (obj, pos) { - obj = this.get_node(obj); - if(!obj || !ccp_mode || !ccp_mode.match(/^(copy_node|move_node)$/) || !ccp_node) { return false; } - if(this[ccp_mode](ccp_node, obj, pos)) { - /** - * triggered when paste is invoked - * @event - * @name paste.jstree - * @param {String} parent the ID of the receiving node - * @param {Array} node the nodes in the buffer - * @param {String} mode the performed operation - "copy_node" or "move_node" - */ - this.trigger('paste', { "parent" : obj.id, "node" : ccp_node, "mode" : ccp_mode }); - } - ccp_node = false; - ccp_mode = false; - ccp_inst = false; - }, - /** - * clear the buffer of previously copied or cut nodes - * @name clear_buffer() - * @trigger clear_buffer.jstree - */ - clear_buffer : function () { - ccp_node = false; - ccp_mode = false; - ccp_inst = false; - /** - * triggered when the copy / cut buffer is cleared - * @event - * @name clear_buffer.jstree - */ - this.trigger('clear_buffer'); - }, - /** - * put a node in edit mode (input field to rename the node) - * @name edit(obj [, default_text]) - * @param {mixed} obj - * @param {String} default_text the text to populate the input with (if omitted the node text value is used) - */ - edit : function (obj, default_text) { - obj = this.get_node(obj); - if(!obj) { return false; } - if(this.settings.core.check_callback === false) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_07', 'reason' : 'Could not edit node because of check_callback' }; - this.settings.core.error.call(this, this._data.core.last_error); - return false; - } - default_text = typeof default_text === 'string' ? default_text : obj.text; - this.set_text(obj, ""); - obj = this._open_to(obj); - - var rtl = this._data.core.rtl, - w = this.element.width(), - a = obj.children('.jstree-anchor'), - s = $('<span>'), - /*! - oi = obj.children("i:visible"), - ai = a.children("i:visible"), - w1 = oi.width() * oi.length, - w2 = ai.width() * ai.length, - */ - t = default_text, - h1 = $("<"+"div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"), - h2 = $("<"+"input />", { - "value" : t, - "class" : "jstree-rename-input", - // "size" : t.length, - "css" : { - "padding" : "0", - "border" : "1px solid silver", - "box-sizing" : "border-box", - "display" : "inline-block", - "height" : (this._data.core.li_height) + "px", - "lineHeight" : (this._data.core.li_height) + "px", - "width" : "150px" // will be set a bit further down - }, - "blur" : $.proxy(function () { - var i = s.children(".jstree-rename-input"), - v = i.val(); - if(v === "") { v = t; } - h1.remove(); - s.replaceWith(a); - s.remove(); - this.set_text(obj, t); - if(this.rename_node(obj, $('<div></div>').text(v)[this.settings.core.force_text ? 'text' : 'html']()) === false) { - this.set_text(obj, t); // move this up? and fix #483 - } - }, 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 : a.css('fontFamily') || '', - fontSize : a.css('fontSize') || '', - fontWeight : a.css('fontWeight') || '', - fontStyle : a.css('fontStyle') || '', - fontStretch : a.css('fontStretch') || '', - fontVariant : a.css('fontVariant') || '', - letterSpacing : a.css('letterSpacing') || '', - wordSpacing : a.css('wordSpacing') || '' - }; - s.attr('class', a.attr('class')).append(a.contents().clone()).append(h2); - a.replaceWith(s); - h1.css(fn); - h2.css(fn).width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select(); - }, - - - /** - * changes the theme - * @name set_theme(theme_name [, theme_url]) - * @param {String} theme_name the name of the new theme to apply - * @param {mixed} theme_url the location of the CSS file for this theme. Omit or set to `false` if you manually included the file. Set to `true` to autoload from the `core.themes.dir` directory. - * @trigger set_theme.jstree - */ - set_theme : function (theme_name, theme_url) { - if(!theme_name) { return false; } - if(theme_url === true) { - var dir = this.settings.core.themes.dir; - if(!dir) { dir = $.jstree.path + '/themes'; } - theme_url = dir + '/' + theme_name + '/style.css'; - } - if(theme_url && $.inArray(theme_url, themes_loaded) === -1) { - $('head').append('<'+'link rel="stylesheet" href="' + theme_url + '" type="text/css" />'); - themes_loaded.push(theme_url); - } - if(this._data.core.themes.name) { - this.element.removeClass('jstree-' + this._data.core.themes.name); - } - this._data.core.themes.name = theme_name; - this.element.addClass('jstree-' + theme_name); - this.element[this.settings.core.themes.responsive ? 'addClass' : 'removeClass' ]('jstree-' + theme_name + '-responsive'); - /** - * triggered when a theme is set - * @event - * @name set_theme.jstree - * @param {String} theme the new theme - */ - this.trigger('set_theme', { 'theme' : theme_name }); - }, - /** - * gets the name of the currently applied theme name - * @name get_theme() - * @return {String} - */ - get_theme : function () { return this._data.core.themes.name; }, - /** - * changes the theme variant (if the theme has variants) - * @name set_theme_variant(variant_name) - * @param {String|Boolean} variant_name the variant to apply (if `false` is used the current variant is removed) - */ - set_theme_variant : function (variant_name) { - if(this._data.core.themes.variant) { - this.element.removeClass('jstree-' + this._data.core.themes.name + '-' + this._data.core.themes.variant); - } - this._data.core.themes.variant = variant_name; - if(variant_name) { - this.element.addClass('jstree-' + this._data.core.themes.name + '-' + this._data.core.themes.variant); - } - }, - /** - * gets the name of the currently applied theme variant - * @name get_theme() - * @return {String} - */ - get_theme_variant : function () { return this._data.core.themes.variant; }, - /** - * shows a striped background on the container (if the theme supports it) - * @name show_stripes() - */ - show_stripes : function () { this._data.core.themes.stripes = true; this.get_container_ul().addClass("jstree-striped"); }, - /** - * hides the striped background on the container - * @name hide_stripes() - */ - hide_stripes : function () { this._data.core.themes.stripes = false; this.get_container_ul().removeClass("jstree-striped"); }, - /** - * toggles the striped background on the container - * @name toggle_stripes() - */ - toggle_stripes : function () { if(this._data.core.themes.stripes) { this.hide_stripes(); } else { this.show_stripes(); } }, - /** - * shows the connecting dots (if the theme supports it) - * @name show_dots() - */ - show_dots : function () { this._data.core.themes.dots = true; this.get_container_ul().removeClass("jstree-no-dots"); }, - /** - * hides the connecting dots - * @name hide_dots() - */ - hide_dots : function () { this._data.core.themes.dots = false; this.get_container_ul().addClass("jstree-no-dots"); }, - /** - * toggles the connecting dots - * @name toggle_dots() - */ - toggle_dots : function () { if(this._data.core.themes.dots) { this.hide_dots(); } else { this.show_dots(); } }, - /** - * show the node icons - * @name show_icons() - */ - show_icons : function () { this._data.core.themes.icons = true; this.get_container_ul().removeClass("jstree-no-icons"); }, - /** - * hide the node icons - * @name hide_icons() - */ - hide_icons : function () { this._data.core.themes.icons = false; this.get_container_ul().addClass("jstree-no-icons"); }, - /** - * toggle the node icons - * @name toggle_icons() - */ - toggle_icons : function () { if(this._data.core.themes.icons) { this.hide_icons(); } else { this.show_icons(); } }, - /** - * set the node icon for a node - * @name set_icon(obj, icon) - * @param {mixed} obj - * @param {String} icon the new icon - can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class - */ - set_icon : function (obj, icon) { - var t1, t2, dom, old; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.set_icon(obj[t1], icon); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { return false; } - old = obj.icon; - obj.icon = icon; - dom = this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon"); - if(icon === false) { - this.hide_icon(obj); - } - else if(icon === true) { - dom.removeClass('jstree-themeicon-custom ' + old).css("background","").removeAttr("rel"); - if(old === false) { this.show_icon(obj); } - } - else if(icon.indexOf("/") === -1 && icon.indexOf(".") === -1) { - dom.removeClass(old).css("background",""); - dom.addClass(icon + ' jstree-themeicon-custom').attr("rel",icon); - if(old === false) { this.show_icon(obj); } - } - else { - dom.removeClass(old).css("background",""); - dom.addClass('jstree-themeicon-custom').css("background", "url('" + icon + "') center center no-repeat").attr("rel",icon); - if(old === false) { this.show_icon(obj); } - } - return true; - }, - /** - * get the node icon for a node - * @name get_icon(obj) - * @param {mixed} obj - * @return {String} - */ - get_icon : function (obj) { - obj = this.get_node(obj); - return (!obj || obj.id === '#') ? false : obj.icon; - }, - /** - * hide the icon on an individual node - * @name hide_icon(obj) - * @param {mixed} obj - */ - hide_icon : function (obj) { - var t1, t2; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.hide_icon(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj === '#') { return false; } - obj.icon = false; - this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon").addClass('jstree-themeicon-hidden'); - return true; - }, - /** - * show the icon on an individual node - * @name show_icon(obj) - * @param {mixed} obj - */ - show_icon : function (obj) { - var t1, t2, dom; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.show_icon(obj[t1]); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj === '#') { return false; } - dom = this.get_node(obj, true); - obj.icon = dom.length ? dom.children(".jstree-anchor").children(".jstree-themeicon").attr('rel') : true; - if(!obj.icon) { obj.icon = true; } - dom.children(".jstree-anchor").children(".jstree-themeicon").removeClass('jstree-themeicon-hidden'); - return true; - } - }; - - // helpers - $.vakata = {}; - // collect attributes - $.vakata.attributes = function(node, with_values) { - node = $(node)[0]; - var attr = with_values ? {} : []; - if(node && node.attributes) { - $.each(node.attributes, function (i, v) { - if($.inArray(v.name.toLowerCase(),['style','contenteditable','hasfocus','tabindex']) !== -1) { return; } - if(v.value !== null && $.trim(v.value) !== '') { - if(with_values) { attr[v.name] = v.value; } - else { attr.push(v.name); } - } - }); - } - return attr; - }; - $.vakata.array_unique = function(array) { - var a = [], i, j, l; - for(i = 0, l = array.length; i < l; i++) { - for(j = 0; j <= i; j++) { - if(array[i] === array[j]) { - break; - } - } - if(j === i) { a.push(array[i]); } - } - return a; - }; - // remove item from array - $.vakata.array_remove = function(array, from, to) { - var rest = array.slice((to || from) + 1 || array.length); - array.length = from < 0 ? array.length + from : from; - array.push.apply(array, rest); - return array; - }; - // remove item from array - $.vakata.array_remove_item = function(array, item) { - var tmp = $.inArray(item, array); - return tmp !== -1 ? $.vakata.array_remove(array, tmp) : array; - }; - - -/** - * ### Checkbox plugin - * - * This plugin renders checkbox icons in front of each node, making multiple selection much easier. - * It also supports tri-state behavior, meaning that if a node has a few of its children checked it will be rendered as undetermined, and state will be propagated up. - */ - - var _i = document.createElement('I'); - _i.className = 'jstree-icon jstree-checkbox'; - _i.setAttribute('role', 'presentation'); - /** - * stores all defaults for the checkbox plugin - * @name $.jstree.defaults.checkbox - * @plugin checkbox - */ - $.jstree.defaults.checkbox = { - /** - * a boolean indicating if checkboxes should be visible (can be changed at a later time using `show_checkboxes()` and `hide_checkboxes`). Defaults to `true`. - * @name $.jstree.defaults.checkbox.visible - * @plugin checkbox - */ - visible : true, - /** - * a boolean indicating if checkboxes should cascade down and have an undetermined state. Defaults to `true`. - * @name $.jstree.defaults.checkbox.three_state - * @plugin checkbox - */ - three_state : true, - /** - * a boolean indicating if clicking anywhere on the node should act as clicking on the checkbox. Defaults to `true`. - * @name $.jstree.defaults.checkbox.whole_node - * @plugin checkbox - */ - whole_node : true, - /** - * a boolean indicating if the selected style of a node should be kept, or removed. Defaults to `true`. - * @name $.jstree.defaults.checkbox.keep_selected_style - * @plugin checkbox - */ - keep_selected_style : true, - /** - * This setting controls how cascading and undetermined nodes are applied. - * If 'up' is in the string - cascading up is enabled, if 'down' is in the string - cascading down is enabled, if 'undetermined' is in the string - undetermined nodes will be used. - * If `three_state` is set to `true` this setting is automatically set to 'up+down+undetermined'. Defaults to ''. - * @name $.jstree.defaults.checkbox.cascade - * @plugin checkbox - */ - cascade : '', - /** - * This setting controls if checkbox are bound to the general tree selection or to an internal array maintained by the checkbox plugin. Defaults to `true`, only set to `false` if you know exactly what you are doing. - * @name $.jstree.defaults.checkbox.tie_selection - * @plugin checkbox - */ - tie_selection : true - }; - $.jstree.plugins.checkbox = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - this._data.checkbox.uto = false; - this._data.checkbox.selected = []; - if(this.settings.checkbox.three_state) { - this.settings.checkbox.cascade = 'up+down+undetermined'; - } - this.element - .on("init.jstree", $.proxy(function () { - this._data.checkbox.visible = this.settings.checkbox.visible; - if(!this.settings.checkbox.keep_selected_style) { - this.element.addClass('jstree-checkbox-no-clicked'); - } - if(this.settings.checkbox.tie_selection) { - this.element.addClass('jstree-checkbox-selection'); - } - }, this)) - .on("loading.jstree", $.proxy(function () { - this[ this._data.checkbox.visible ? 'show_checkboxes' : 'hide_checkboxes' ](); - }, this)); - if(this.settings.checkbox.cascade.indexOf('undetermined') !== -1) { - this.element - .on('changed.jstree uncheck_node.jstree check_node.jstree uncheck_all.jstree check_all.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree', $.proxy(function () { - // only if undetermined is in setting - if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); } - this._data.checkbox.uto = setTimeout($.proxy(this._undetermined, this), 50); - }, this)); - } - if(!this.settings.checkbox.tie_selection) { - this.element - .on('model.jstree', $.proxy(function (e, data) { - var m = this._model.data, - p = m[data.parent], - dpc = data.nodes, - i, j; - for(i = 0, j = dpc.length; i < j; i++) { - m[dpc[i]].state.checked = (m[dpc[i]].original && m[dpc[i]].original.state && m[dpc[i]].original.state.checked); - if(m[dpc[i]].state.checked) { - this._data.checkbox.selected.push(dpc[i]); - } - } - }, this)); - } - if(this.settings.checkbox.cascade.indexOf('up') !== -1 || this.settings.checkbox.cascade.indexOf('down') !== -1) { - this.element - .on('model.jstree', $.proxy(function (e, data) { - var m = this._model.data, - p = m[data.parent], - dpc = data.nodes, - chd = [], - c, i, j, k, l, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection; - - if(s.indexOf('down') !== -1) { - // apply down - if(p.state[ t ? 'selected' : 'checked' ]) { - for(i = 0, j = dpc.length; i < j; i++) { - m[dpc[i]].state[ t ? 'selected' : 'checked' ] = true; - } - this._data[ t ? 'core' : 'checkbox' ].selected = this._data[ t ? 'core' : 'checkbox' ].selected.concat(dpc); - } - else { - for(i = 0, j = dpc.length; i < j; i++) { - if(m[dpc[i]].state[ t ? 'selected' : 'checked' ]) { - for(k = 0, l = m[dpc[i]].children_d.length; k < l; k++) { - m[m[dpc[i]].children_d[k]].state[ t ? 'selected' : 'checked' ] = true; - } - this._data[ t ? 'core' : 'checkbox' ].selected = this._data[ t ? 'core' : 'checkbox' ].selected.concat(m[dpc[i]].children_d); - } - } - } - } - - if(s.indexOf('up') !== -1) { - // apply up - for(i = 0, j = p.children_d.length; i < j; i++) { - if(!m[p.children_d[i]].children.length) { - chd.push(m[p.children_d[i]].parent); - } - } - chd = $.vakata.array_unique(chd); - for(k = 0, l = chd.length; k < l; k++) { - p = m[chd[k]]; - while(p && p.id !== '#') { - c = 0; - for(i = 0, j = p.children.length; i < j; i++) { - c += m[p.children[i]].state[ t ? 'selected' : 'checked' ]; - } - if(c === j) { - p.state[ t ? 'selected' : 'checked' ] = true; - this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id); - tmp = this.get_node(p, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', true).children('.jstree-anchor').addClass( t ? 'jstree-clicked' : 'jstree-checked'); - } - } - else { - break; - } - p = this.get_node(p.parent); - } - } - } - - this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected); - }, this)) - .on(this.settings.checkbox.tie_selection ? 'select_node.jstree' : 'check_node.jstree', $.proxy(function (e, data) { - var obj = data.node, - m = this._model.data, - par = this.get_node(obj.parent), - dom = this.get_node(obj, true), - i, j, c, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection; - - // apply down - if(s.indexOf('down') !== -1) { - this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected.concat(obj.children_d)); - for(i = 0, j = obj.children_d.length; i < j; i++) { - tmp = m[obj.children_d[i]]; - tmp.state[ t ? 'selected' : 'checked' ] = true; - if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) { - tmp.original.state.undetermined = false; - } - } - } - - // apply up - if(s.indexOf('up') !== -1) { - while(par && par.id !== '#') { - c = 0; - for(i = 0, j = par.children.length; i < j; i++) { - c += m[par.children[i]].state[ t ? 'selected' : 'checked' ]; - } - if(c === j) { - par.state[ t ? 'selected' : 'checked' ] = true; - this._data[ t ? 'core' : 'checkbox' ].selected.push(par.id); - tmp = this.get_node(par, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - else { - break; - } - par = this.get_node(par.parent); - } - } - - // apply down (process .children separately?) - if(s.indexOf('down') !== -1 && dom.length) { - dom.find('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked').parent().attr('aria-selected', true); - } - }, this)) - .on(this.settings.checkbox.tie_selection ? 'deselect_all.jstree' : 'uncheck_all.jstree', $.proxy(function (e, data) { - var obj = this.get_node('#'), - m = this._model.data, - i, j, tmp; - for(i = 0, j = obj.children_d.length; i < j; i++) { - tmp = m[obj.children_d[i]]; - if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) { - tmp.original.state.undetermined = false; - } - } - }, this)) - .on(this.settings.checkbox.tie_selection ? 'deselect_node.jstree' : 'uncheck_node.jstree', $.proxy(function (e, data) { - var obj = data.node, - dom = this.get_node(obj, true), - i, j, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection; - if(obj && obj.original && obj.original.state && obj.original.state.undetermined) { - obj.original.state.undetermined = false; - } - - // apply down - if(s.indexOf('down') !== -1) { - for(i = 0, j = obj.children_d.length; i < j; i++) { - tmp = this._model.data[obj.children_d[i]]; - tmp.state[ t ? 'selected' : 'checked' ] = false; - if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) { - tmp.original.state.undetermined = false; - } - } - } - - // apply up - if(s.indexOf('up') !== -1) { - for(i = 0, j = obj.parents.length; i < j; i++) { - tmp = this._model.data[obj.parents[i]]; - tmp.state[ t ? 'selected' : 'checked' ] = false; - if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) { - tmp.original.state.undetermined = false; - } - tmp = this.get_node(obj.parents[i], true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - } - tmp = []; - for(i = 0, j = this._data[ t ? 'core' : 'checkbox' ].selected.length; i < j; i++) { - // apply down + apply up - if( - (s.indexOf('down') === -1 || $.inArray(this._data[ t ? 'core' : 'checkbox' ].selected[i], obj.children_d) === -1) && - (s.indexOf('up') === -1 || $.inArray(this._data[ t ? 'core' : 'checkbox' ].selected[i], obj.parents) === -1) - ) { - tmp.push(this._data[ t ? 'core' : 'checkbox' ].selected[i]); - } - } - this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(tmp); - - // apply down (process .children separately?) - if(s.indexOf('down') !== -1 && dom.length) { - dom.find('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked').parent().attr('aria-selected', false); - } - }, this)); - } - if(this.settings.checkbox.cascade.indexOf('up') !== -1) { - this.element - .on('delete_node.jstree', $.proxy(function (e, data) { - // apply up (whole handler) - var p = this.get_node(data.parent), - m = this._model.data, - i, j, c, tmp, t = this.settings.checkbox.tie_selection; - while(p && p.id !== '#') { - c = 0; - for(i = 0, j = p.children.length; i < j; i++) { - c += m[p.children[i]].state[ t ? 'selected' : 'checked' ]; - } - if(c === j) { - p.state[ t ? 'selected' : 'checked' ] = true; - this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id); - tmp = this.get_node(p, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - else { - break; - } - p = this.get_node(p.parent); - } - }, this)) - .on('move_node.jstree', $.proxy(function (e, data) { - // apply up (whole handler) - var is_multi = data.is_multi, - old_par = data.old_parent, - new_par = this.get_node(data.parent), - m = this._model.data, - p, c, i, j, tmp, t = this.settings.checkbox.tie_selection; - if(!is_multi) { - p = this.get_node(old_par); - while(p && p.id !== '#') { - c = 0; - for(i = 0, j = p.children.length; i < j; i++) { - c += m[p.children[i]].state[ t ? 'selected' : 'checked' ]; - } - if(c === j) { - p.state[ t ? 'selected' : 'checked' ] = true; - this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id); - tmp = this.get_node(p, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - else { - break; - } - p = this.get_node(p.parent); - } - } - p = new_par; - while(p && p.id !== '#') { - c = 0; - for(i = 0, j = p.children.length; i < j; i++) { - c += m[p.children[i]].state[ t ? 'selected' : 'checked' ]; - } - if(c === j) { - if(!p.state[ t ? 'selected' : 'checked' ]) { - p.state[ t ? 'selected' : 'checked' ] = true; - this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id); - tmp = this.get_node(p, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - } - else { - if(p.state[ t ? 'selected' : 'checked' ]) { - p.state[ t ? 'selected' : 'checked' ] = false; - this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_remove_item(this._data[ t ? 'core' : 'checkbox' ].selected, p.id); - tmp = this.get_node(p, true); - if(tmp && tmp.length) { - tmp.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked'); - } - } - else { - break; - } - } - p = this.get_node(p.parent); - } - }, this)); - } - }; - /** - * set the undetermined state where and if necessary. Used internally. - * @private - * @name _undetermined() - * @plugin checkbox - */ - this._undetermined = function () { - var i, j, m = this._model.data, t = this.settings.checkbox.tie_selection, s = this._data[ t ? 'core' : 'checkbox' ].selected, p = [], tt = this; - for(i = 0, j = s.length; i < j; i++) { - if(m[s[i]] && m[s[i]].parents) { - p = p.concat(m[s[i]].parents); - } - } - // attempt for server side undetermined state - this.element.find('.jstree-closed').not(':has(.jstree-children)') - .each(function () { - var tmp = tt.get_node(this), tmp2; - if(!tmp.state.loaded) { - if(tmp.original && tmp.original.state && tmp.original.state.undetermined && tmp.original.state.undetermined === true) { - p.push(tmp.id); - p = p.concat(tmp.parents); - } - } - else { - for(i = 0, j = tmp.children_d.length; i < j; i++) { - tmp2 = m[tmp.children_d[i]]; - if(!tmp2.state.loaded && tmp2.original && tmp2.original.state && tmp2.original.state.undetermined && tmp2.original.state.undetermined === true) { - p.push(tmp2.id); - p = p.concat(tmp2.parents); - } - } - } - }); - p = $.vakata.array_unique(p); - p = $.vakata.array_remove_item(p,'#'); - - this.element.find('.jstree-undetermined').removeClass('jstree-undetermined'); - for(i = 0, j = p.length; i < j; i++) { - if(!m[p[i]].state[ t ? 'selected' : 'checked' ]) { - s = this.get_node(p[i], true); - if(s && s.length) { - s.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-undetermined'); - } - } - } - }; - this.redraw_node = function(obj, deep, is_callback, force_render) { - obj = parent.redraw_node.apply(this, arguments); - if(obj) { - var i, j, tmp = null; - for(i = 0, j = obj.childNodes.length; i < j; i++) { - if(obj.childNodes[i] && obj.childNodes[i].className && obj.childNodes[i].className.indexOf("jstree-anchor") !== -1) { - tmp = obj.childNodes[i]; - break; - } - } - if(tmp) { - if(!this.settings.checkbox.tie_selection && this._model.data[obj.id].state.checked) { tmp.className += ' jstree-checked'; } - tmp.insertBefore(_i.cloneNode(false), tmp.childNodes[0]); - } - } - if(!is_callback && this.settings.checkbox.cascade.indexOf('undetermined') !== -1) { - if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); } - this._data.checkbox.uto = setTimeout($.proxy(this._undetermined, this), 50); - } - return obj; - }; - /** - * show the node checkbox icons - * @name show_checkboxes() - * @plugin checkbox - */ - this.show_checkboxes = function () { this._data.core.themes.checkboxes = true; this.get_container_ul().removeClass("jstree-no-checkboxes"); }; - /** - * hide the node checkbox icons - * @name hide_checkboxes() - * @plugin checkbox - */ - this.hide_checkboxes = function () { this._data.core.themes.checkboxes = false; this.get_container_ul().addClass("jstree-no-checkboxes"); }; - /** - * toggle the node icons - * @name toggle_checkboxes() - * @plugin checkbox - */ - this.toggle_checkboxes = function () { if(this._data.core.themes.checkboxes) { this.hide_checkboxes(); } else { this.show_checkboxes(); } }; - /** - * checks if a node is in an undetermined state - * @name is_undetermined(obj) - * @param {mixed} obj - * @return {Boolean} - */ - this.is_undetermined = function (obj) { - obj = this.get_node(obj); - var s = this.settings.checkbox.cascade, i, j, t = this.settings.checkbox.tie_selection, d = this._data[ t ? 'core' : 'checkbox' ].selected, m = this._model.data; - if(!obj || obj.state[ t ? 'selected' : 'checked' ] === true || s.indexOf('undetermined') === -1 || (s.indexOf('down') === -1 && s.indexOf('up') === -1)) { - return false; - } - if(!obj.state.loaded && obj.original.state.undetermined === true) { - return true; - } - for(i = 0, j = obj.children_d.length; i < j; i++) { - if($.inArray(obj.children_d[i], d) !== -1 || (!m[obj.children_d[i]].state.loaded && m[obj.children_d[i]].original.state.undetermined)) { - return true; - } - } - return false; - }; - - this.activate_node = function (obj, e) { - if(this.settings.checkbox.tie_selection && (this.settings.checkbox.whole_node || $(e.target).hasClass('jstree-checkbox'))) { - e.ctrlKey = true; - } - if(this.settings.checkbox.tie_selection || (!this.settings.checkbox.whole_node && !$(e.target).hasClass('jstree-checkbox'))) { - return parent.activate_node.call(this, obj, e); - } - if(this.is_disabled(obj)) { - return false; - } - if(this.is_checked(obj)) { - this.uncheck_node(obj, e); - } - else { - this.check_node(obj, e); - } - this.trigger('activate_node', { 'node' : this.get_node(obj) }); - }; - - /** - * check a node (only if tie_selection in checkbox settings is false, otherwise select_node will be called internally) - * @name check_node(obj) - * @param {mixed} obj an array can be used to check multiple nodes - * @trigger check_node.jstree - * @plugin checkbox - */ - this.check_node = function (obj, e) { - if(this.settings.checkbox.tie_selection) { return this.select_node(obj, false, true, e); } - var dom, t1, t2, th; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.check_node(obj[t1], e); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { - return false; - } - dom = this.get_node(obj, true); - if(!obj.state.checked) { - obj.state.checked = true; - this._data.checkbox.selected.push(obj.id); - if(dom && dom.length) { - dom.children('.jstree-anchor').addClass('jstree-checked'); - } - /** - * triggered when an node is checked (only if tie_selection in checkbox settings is false) - * @event - * @name check_node.jstree - * @param {Object} node - * @param {Array} selected the current selection - * @param {Object} event the event (if any) that triggered this check_node - * @plugin checkbox - */ - this.trigger('check_node', { 'node' : obj, 'selected' : this._data.checkbox.selected, 'event' : e }); - } - }; - /** - * uncheck a node (only if tie_selection in checkbox settings is false, otherwise deselect_node will be called internally) - * @name deselect_node(obj) - * @param {mixed} obj an array can be used to deselect multiple nodes - * @trigger uncheck_node.jstree - * @plugin checkbox - */ - this.uncheck_node = function (obj, e) { - if(this.settings.checkbox.tie_selection) { return this.deselect_node(obj, false, e); } - var t1, t2, dom; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.uncheck_node(obj[t1], e); - } - return true; - } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { - return false; - } - dom = this.get_node(obj, true); - if(obj.state.checked) { - obj.state.checked = false; - this._data.checkbox.selected = $.vakata.array_remove_item(this._data.checkbox.selected, obj.id); - if(dom.length) { - dom.children('.jstree-anchor').removeClass('jstree-checked'); - } - /** - * triggered when an node is unchecked (only if tie_selection in checkbox settings is false) - * @event - * @name uncheck_node.jstree - * @param {Object} node - * @param {Array} selected the current selection - * @param {Object} event the event (if any) that triggered this uncheck_node - * @plugin checkbox - */ - this.trigger('uncheck_node', { 'node' : obj, 'selected' : this._data.checkbox.selected, 'event' : e }); - } - }; - /** - * checks all nodes in the tree (only if tie_selection in checkbox settings is false, otherwise select_all will be called internally) - * @name check_all() - * @trigger check_all.jstree, changed.jstree - * @plugin checkbox - */ - this.check_all = function () { - if(this.settings.checkbox.tie_selection) { return this.select_all(); } - var tmp = this._data.checkbox.selected.concat([]), i, j; - this._data.checkbox.selected = this._model.data['#'].children_d.concat(); - for(i = 0, j = this._data.checkbox.selected.length; i < j; i++) { - if(this._model.data[this._data.checkbox.selected[i]]) { - this._model.data[this._data.checkbox.selected[i]].state.checked = true; - } - } - this.redraw(true); - /** - * triggered when all nodes are checked (only if tie_selection in checkbox settings is false) - * @event - * @name check_all.jstree - * @param {Array} selected the current selection - * @plugin checkbox - */ - this.trigger('check_all', { 'selected' : this._data.checkbox.selected }); - }; - /** - * uncheck all checked nodes (only if tie_selection in checkbox settings is false, otherwise deselect_all will be called internally) - * @name uncheck_all() - * @trigger uncheck_all.jstree - * @plugin checkbox - */ - this.uncheck_all = function () { - if(this.settings.checkbox.tie_selection) { return this.deselect_all(); } - var tmp = this._data.checkbox.selected.concat([]), i, j; - for(i = 0, j = this._data.checkbox.selected.length; i < j; i++) { - if(this._model.data[this._data.checkbox.selected[i]]) { - this._model.data[this._data.checkbox.selected[i]].state.checked = false; - } - } - this._data.checkbox.selected = []; - this.element.find('.jstree-checked').removeClass('jstree-checked'); - /** - * triggered when all nodes are unchecked (only if tie_selection in checkbox settings is false) - * @event - * @name uncheck_all.jstree - * @param {Object} node the previous selection - * @param {Array} selected the current selection - * @plugin checkbox - */ - this.trigger('uncheck_all', { 'selected' : this._data.checkbox.selected, 'node' : tmp }); - }; - /** - * checks if a node is checked (if tie_selection is on in the settings this function will return the same as is_selected) - * @name is_checked(obj) - * @param {mixed} obj - * @return {Boolean} - * @plugin checkbox - */ - this.is_checked = function (obj) { - if(this.settings.checkbox.tie_selection) { return this.is_selected(obj); } - obj = this.get_node(obj); - if(!obj || obj.id === '#') { return false; } - return obj.state.checked; - }; - /** - * get an array of all checked nodes (if tie_selection is on in the settings this function will return the same as get_selected) - * @name get_checked([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - * @plugin checkbox - */ - this.get_checked = function (full) { - if(this.settings.checkbox.tie_selection) { return this.get_selected(full); } - return full ? $.map(this._data.checkbox.selected, $.proxy(function (i) { return this.get_node(i); }, this)) : this._data.checkbox.selected; - }; - /** - * get an array of all top level checked nodes (ignoring children of checked nodes) (if tie_selection is on in the settings this function will return the same as get_top_selected) - * @name get_top_checked([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - * @plugin checkbox - */ - this.get_top_checked = function (full) { - if(this.settings.checkbox.tie_selection) { return this.get_top_selected(full); } - var tmp = this.get_checked(true), - obj = {}, i, j, k, l; - for(i = 0, j = tmp.length; i < j; i++) { - obj[tmp[i].id] = tmp[i]; - } - for(i = 0, j = tmp.length; i < j; i++) { - for(k = 0, l = tmp[i].children_d.length; k < l; k++) { - if(obj[tmp[i].children_d[k]]) { - delete obj[tmp[i].children_d[k]]; - } - } - } - tmp = []; - for(i in obj) { - if(obj.hasOwnProperty(i)) { - tmp.push(i); - } - } - return full ? $.map(tmp, $.proxy(function (i) { return this.get_node(i); }, this)) : tmp; - }; - /** - * get an array of all bottom level checked nodes (ignoring selected parents) (if tie_selection is on in the settings this function will return the same as get_bottom_selected) - * @name get_bottom_checked([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} - * @plugin checkbox - */ - this.get_bottom_checked = function (full) { - if(this.settings.checkbox.tie_selection) { return this.get_bottom_selected(full); } - var tmp = this.get_checked(true), - obj = [], i, j; - for(i = 0, j = tmp.length; i < j; i++) { - if(!tmp[i].children.length) { - obj.push(tmp[i].id); - } - } - return full ? $.map(obj, $.proxy(function (i) { return this.get_node(i); }, this)) : obj; - }; - this.load_node = function (obj, callback) { - var k, l, i, j, c, tmp; - if(!$.isArray(obj) && !this.settings.checkbox.tie_selection) { - tmp = this.get_node(obj); - if(tmp && tmp.state.loaded) { - for(k = 0, l = tmp.children_d.length; k < l; k++) { - if(this._model.data[tmp.children_d[k]].state.checked) { - c = true; - this._data.checkbox.selected = $.vakata.array_remove_item(this._data.checkbox.selected, tmp.children_d[k]); - } - } - } - } - return parent.load_node.apply(this, arguments); - }; - this.get_state = function () { - var state = parent.get_state.apply(this, arguments); - if(this.settings.checkbox.tie_selection) { return state; } - state.checkbox = this._data.checkbox.selected.slice(); - return state; - }; - this.set_state = function (state, callback) { - var res = parent.set_state.apply(this, arguments); - if(res && state.checkbox) { - if(!this.settings.checkbox.tie_selection) { - this.uncheck_all(); - var _this = this; - $.each(state.checkbox, function (i, v) { - _this.check_node(v); - }); - } - delete state.checkbox; - return false; - } - return res; - }; - }; - - // include the checkbox plugin by default - // $.jstree.defaults.plugins.push("checkbox"); - -/** - * ### Contextmenu plugin - * - * Shows a context menu when a node is right-clicked. - */ - - var cto = null, ex, ey; - - /** - * stores all defaults for the contextmenu plugin - * @name $.jstree.defaults.contextmenu - * @plugin contextmenu - */ - $.jstree.defaults.contextmenu = { - /** - * a boolean indicating if the node should be selected when the context menu is invoked on it. Defaults to `true`. - * @name $.jstree.defaults.contextmenu.select_node - * @plugin contextmenu - */ - select_node : true, - /** - * a boolean indicating if the menu should be shown aligned with the node. Defaults to `true`, otherwise the mouse coordinates are used. - * @name $.jstree.defaults.contextmenu.show_at_node - * @plugin contextmenu - */ - show_at_node : true, - /** - * an object of actions, or a function that accepts a node and a callback function and calls the callback function with an object of actions available for that node (you can also return the items too). - * - * Each action consists of a key (a unique name) and a value which is an object with the following properties (only label and action are required): - * - * * `separator_before` - a boolean indicating if there should be a separator before this item - * * `separator_after` - a boolean indicating if there should be a separator after this item - * * `_disabled` - a boolean indicating if this action should be disabled - * * `label` - a string - the name of the action (could be a function returning a string) - * * `action` - a function to be executed if this item is chosen - * * `icon` - a string, can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class - * * `shortcut` - keyCode which will trigger the action if the menu is open (for example `113` for rename, which equals F2) - * * `shortcut_label` - shortcut label (like for example `F2` for rename) - * - * @name $.jstree.defaults.contextmenu.items - * @plugin contextmenu - */ - items : function (o, cb) { // Could be an object directly - return { - "create" : { - "separator_before" : false, - "separator_after" : true, - "_disabled" : false, //(this.check("create_node", data.reference, {}, "last")), - "label" : "Create", - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - inst.create_node(obj, {}, "last", function (new_node) { - setTimeout(function () { inst.edit(new_node); },0); - }); - } - }, - "rename" : { - "separator_before" : false, - "separator_after" : false, - "_disabled" : false, //(this.check("rename_node", data.reference, this.get_parent(data.reference), "")), - "label" : "Rename", - /* - "shortcut" : 113, - "shortcut_label" : 'F2', - "icon" : "glyphicon glyphicon-leaf", - */ - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - inst.edit(obj); - } - }, - "remove" : { - "separator_before" : false, - "icon" : false, - "separator_after" : false, - "_disabled" : false, //(this.check("delete_node", data.reference, this.get_parent(data.reference), "")), - "label" : "Delete", - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - if(inst.is_selected(obj)) { - inst.delete_node(inst.get_selected()); - } - else { - inst.delete_node(obj); - } - } - }, - "ccp" : { - "separator_before" : true, - "icon" : false, - "separator_after" : false, - "label" : "Edit", - "action" : false, - "submenu" : { - "cut" : { - "separator_before" : false, - "separator_after" : false, - "label" : "Cut", - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - if(inst.is_selected(obj)) { - inst.cut(inst.get_selected()); - } - else { - inst.cut(obj); - } - } - }, - "copy" : { - "separator_before" : false, - "icon" : false, - "separator_after" : false, - "label" : "Copy", - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - if(inst.is_selected(obj)) { - inst.copy(inst.get_selected()); - } - else { - inst.copy(obj); - } - } - }, - "paste" : { - "separator_before" : false, - "icon" : false, - "_disabled" : function (data) { - return !$.jstree.reference(data.reference).can_paste(); - }, - "separator_after" : false, - "label" : "Paste", - "action" : function (data) { - var inst = $.jstree.reference(data.reference), - obj = inst.get_node(data.reference); - inst.paste(obj); - } - } - } - } - }; - } - }; - - $.jstree.plugins.contextmenu = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - - var last_ts = 0; - this.element - .on("contextmenu.jstree", ".jstree-anchor", $.proxy(function (e, data) { - e.preventDefault(); - last_ts = e.ctrlKey ? +new Date() : 0; - if(data || cto) { - last_ts = (+new Date()) + 10000; - } - if(cto) { - clearTimeout(cto); - } - if(!this.is_loading(e.currentTarget)) { - this.show_contextmenu(e.currentTarget, e.pageX, e.pageY, e); - } - }, this)) - .on("click.jstree", ".jstree-anchor", $.proxy(function (e) { - if(this._data.contextmenu.visible && (!last_ts || (+new Date()) - last_ts > 250)) { // work around safari & macOS ctrl+click - $.vakata.context.hide(); - } - last_ts = 0; - }, this)) - .on("touchstart.jstree", ".jstree-anchor", function (e) { - if(!e.originalEvent || !e.originalEvent.changedTouches || !e.originalEvent.changedTouches[0]) { - return; - } - ex = e.pageX; - ey = e.pageY; - cto = setTimeout(function () { - $(e.currentTarget).trigger('contextmenu', true); - }, 750); - }); - /* - if(!('oncontextmenu' in document.body) && ('ontouchstart' in document.body)) { - var el = null, tm = null; - this.element - .on("touchstart", ".jstree-anchor", function (e) { - el = e.currentTarget; - tm = +new Date(); - $(document).one("touchend", function (e) { - e.target = document.elementFromPoint(e.originalEvent.targetTouches[0].pageX - window.pageXOffset, e.originalEvent.targetTouches[0].pageY - window.pageYOffset); - e.currentTarget = e.target; - tm = ((+(new Date())) - tm); - if(e.target === el && tm > 600 && tm < 1000) { - e.preventDefault(); - $(el).trigger('contextmenu', e); - } - el = null; - tm = null; - }); - }); - } - */ - $(document).on("context_hide.vakata.jstree", $.proxy(function () { this._data.contextmenu.visible = false; }, this)); - }; - this.teardown = function () { - if(this._data.contextmenu.visible) { - $.vakata.context.hide(); - } - parent.teardown.call(this); - }; - - /** - * prepare and show the context menu for a node - * @name show_contextmenu(obj [, x, y]) - * @param {mixed} obj the node - * @param {Number} x the x-coordinate relative to the document to show the menu at - * @param {Number} y the y-coordinate relative to the document to show the menu at - * @param {Object} e the event if available that triggered the contextmenu - * @plugin contextmenu - * @trigger show_contextmenu.jstree - */ - this.show_contextmenu = function (obj, x, y, e) { - obj = this.get_node(obj); - if(!obj || obj.id === '#') { return false; } - var s = this.settings.contextmenu, - d = this.get_node(obj, true), - a = d.children(".jstree-anchor"), - o = false, - i = false; - if(s.show_at_node || x === undefined || y === undefined) { - o = a.offset(); - x = o.left; - y = o.top + this._data.core.li_height; - } - if(this.settings.contextmenu.select_node && !this.is_selected(obj)) { - this.activate_node(obj, e); - } - - i = s.items; - if($.isFunction(i)) { - i = i.call(this, obj, $.proxy(function (i) { - this._show_contextmenu(obj, x, y, i); - }, this)); - } - if($.isPlainObject(i)) { - this._show_contextmenu(obj, x, y, i); - } - }; - /** - * show the prepared context menu for a node - * @name _show_contextmenu(obj, x, y, i) - * @param {mixed} obj the node - * @param {Number} x the x-coordinate relative to the document to show the menu at - * @param {Number} y the y-coordinate relative to the document to show the menu at - * @param {Number} i the object of items to show - * @plugin contextmenu - * @trigger show_contextmenu.jstree - * @private - */ - this._show_contextmenu = function (obj, x, y, i) { - var d = this.get_node(obj, true), - a = d.children(".jstree-anchor"); - $(document).one("context_show.vakata.jstree", $.proxy(function (e, data) { - var cls = 'jstree-contextmenu jstree-' + this.get_theme() + '-contextmenu'; - $(data.element).addClass(cls); - }, this)); - this._data.contextmenu.visible = true; - $.vakata.context.show(a, { 'x' : x, 'y' : y }, i); - /** - * triggered when the contextmenu is shown for a node - * @event - * @name show_contextmenu.jstree - * @param {Object} node the node - * @param {Number} x the x-coordinate of the menu relative to the document - * @param {Number} y the y-coordinate of the menu relative to the document - * @plugin contextmenu - */ - this.trigger('show_contextmenu', { "node" : obj, "x" : x, "y" : y }); - }; - }; - - $(function () { - $(document) - .on('touchmove.vakata.jstree', function (e) { - if(cto && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0] && (Math.abs(ex - e.pageX) > 50 || Math.abs(ey - e.pageY) > 50)) { - clearTimeout(cto); - } - }) - .on('touchend.vakata.jstree', function (e) { - if(cto) { - clearTimeout(cto); - } - }); - }); - - // contextmenu helper - (function ($) { - var right_to_left = false, - vakata_context = { - element : false, - reference : false, - position_x : 0, - position_y : 0, - items : [], - html : "", - is_visible : false - }; - - $.vakata.context = { - settings : { - hide_onmouseleave : 0, - icons : true - }, - _trigger : function (event_name) { - $(document).triggerHandler("context_" + event_name + ".vakata", { - "reference" : vakata_context.reference, - "element" : vakata_context.element, - "position" : { - "x" : vakata_context.position_x, - "y" : vakata_context.position_y - } - }); - }, - _execute : function (i) { - i = vakata_context.items[i]; - return i && (!i._disabled || ($.isFunction(i._disabled) && !i._disabled({ "item" : i, "reference" : vakata_context.reference, "element" : vakata_context.element }))) && i.action ? i.action.call(null, { - "item" : i, - "reference" : vakata_context.reference, - "element" : vakata_context.element, - "position" : { - "x" : vakata_context.position_x, - "y" : vakata_context.position_y - } - }) : false; - }, - _parse : function (o, is_callback) { - if(!o) { return false; } - if(!is_callback) { - vakata_context.html = ""; - vakata_context.items = []; - } - var str = "", - sep = false, - tmp; - - if(is_callback) { str += "<"+"ul>"; } - $.each(o, function (i, val) { - if(!val) { return true; } - vakata_context.items.push(val); - if(!sep && val.separator_before) { - str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + "> <"+"/a><"+"/li>"; - } - sep = false; - str += "<"+"li class='" + (val._class || "") + (val._disabled === true || ($.isFunction(val._disabled) && val._disabled({ "item" : val, "reference" : vakata_context.reference, "element" : vakata_context.element })) ? " vakata-contextmenu-disabled " : "") + "' "+(val.shortcut?" data-shortcut='"+val.shortcut+"' ":'')+">"; - str += "<"+"a href='#' rel='" + (vakata_context.items.length - 1) + "'>"; - if($.vakata.context.settings.icons) { - str += "<"+"i "; - if(val.icon) { - if(val.icon.indexOf("/") !== -1 || val.icon.indexOf(".") !== -1) { str += " style='background:url(\"" + val.icon + "\") center center no-repeat' "; } - else { str += " class='" + val.icon + "' "; } - } - str += "><"+"/i><"+"span class='vakata-contextmenu-sep'> <"+"/span>"; - } - str += ($.isFunction(val.label) ? val.label({ "item" : i, "reference" : vakata_context.reference, "element" : vakata_context.element }) : val.label) + (val.shortcut?' <span class="vakata-contextmenu-shortcut vakata-contextmenu-shortcut-'+val.shortcut+'">'+ (val.shortcut_label || '') +'</span>':'') + "<"+"/a>"; - if(val.submenu) { - tmp = $.vakata.context._parse(val.submenu, true); - if(tmp) { str += tmp; } - } - str += "<"+"/li>"; - if(val.separator_after) { - str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'style="margin-left:0px;"') + "> <"+"/a><"+"/li>"; - sep = true; - } - }); - str = str.replace(/<li class\='vakata-context-separator'\><\/li\>$/,""); - if(is_callback) { str += "</ul>"; } - /** - * triggered on the document when the contextmenu is parsed (HTML is built) - * @event - * @plugin contextmenu - * @name context_parse.vakata - * @param {jQuery} reference the element that was right clicked - * @param {jQuery} element the DOM element of the menu itself - * @param {Object} position the x & y coordinates of the menu - */ - if(!is_callback) { vakata_context.html = str; $.vakata.context._trigger("parse"); } - return str.length > 10 ? str : false; - }, - _show_submenu : function (o) { - o = $(o); - if(!o.length || !o.children("ul").length) { return; } - var e = o.children("ul"), - x = o.offset().left + o.outerWidth(), - y = o.offset().top, - w = e.width(), - h = e.height(), - dw = $(window).width() + $(window).scrollLeft(), - dh = $(window).height() + $(window).scrollTop(); - // може да се спести е една проверка - дали няма някой от класовете вече нагоре - if(right_to_left) { - o[x - (w + 10 + o.outerWidth()) < 0 ? "addClass" : "removeClass"]("vakata-context-left"); - } - else { - o[x + w + 10 > dw ? "addClass" : "removeClass"]("vakata-context-right"); - } - if(y + h + 10 > dh) { - e.css("bottom","-1px"); - } - e.show(); - }, - show : function (reference, position, data) { - var o, e, x, y, w, h, dw, dh, cond = true; - if(vakata_context.element && vakata_context.element.length) { - vakata_context.element.width(''); - } - switch(cond) { - case (!position && !reference): - return false; - case (!!position && !!reference): - vakata_context.reference = reference; - vakata_context.position_x = position.x; - vakata_context.position_y = position.y; - break; - case (!position && !!reference): - vakata_context.reference = reference; - o = reference.offset(); - vakata_context.position_x = o.left + reference.outerHeight(); - vakata_context.position_y = o.top; - break; - case (!!position && !reference): - vakata_context.position_x = position.x; - vakata_context.position_y = position.y; - break; - } - if(!!reference && !data && $(reference).data('vakata_contextmenu')) { - data = $(reference).data('vakata_contextmenu'); - } - if($.vakata.context._parse(data)) { - vakata_context.element.html(vakata_context.html); - } - if(vakata_context.items.length) { - vakata_context.element.appendTo("body"); - e = vakata_context.element; - x = vakata_context.position_x; - y = vakata_context.position_y; - w = e.width(); - h = e.height(); - dw = $(window).width() + $(window).scrollLeft(); - dh = $(window).height() + $(window).scrollTop(); - if(right_to_left) { - x -= (e.outerWidth() - $(reference).outerWidth()); - if(x < $(window).scrollLeft() + 20) { - x = $(window).scrollLeft() + 20; - } - } - if(x + w + 20 > dw) { - x = dw - (w + 20); - } - if(y + h + 20 > dh) { - y = dh - (h + 20); - } - - vakata_context.element - .css({ "left" : x, "top" : y }) - .show() - .find('a').first().focus().parent().addClass("vakata-context-hover"); - vakata_context.is_visible = true; - /** - * triggered on the document when the contextmenu is shown - * @event - * @plugin contextmenu - * @name context_show.vakata - * @param {jQuery} reference the element that was right clicked - * @param {jQuery} element the DOM element of the menu itself - * @param {Object} position the x & y coordinates of the menu - */ - $.vakata.context._trigger("show"); - } - }, - hide : function () { - if(vakata_context.is_visible) { - vakata_context.element.hide().find("ul").hide().end().find(':focus').blur().end().detach(); - vakata_context.is_visible = false; - /** - * triggered on the document when the contextmenu is hidden - * @event - * @plugin contextmenu - * @name context_hide.vakata - * @param {jQuery} reference the element that was right clicked - * @param {jQuery} element the DOM element of the menu itself - * @param {Object} position the x & y coordinates of the menu - */ - $.vakata.context._trigger("hide"); - } - } - }; - $(function () { - right_to_left = $("body").css("direction") === "rtl"; - var to = false; - - vakata_context.element = $("<ul class='vakata-context'></ul>"); - vakata_context.element - .on("mouseenter", "li", function (e) { - e.stopImmediatePropagation(); - - if($.contains(this, e.relatedTarget)) { - // премахнато заради delegate mouseleave по-долу - // $(this).find(".vakata-context-hover").removeClass("vakata-context-hover"); - return; - } - - if(to) { clearTimeout(to); } - vakata_context.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end(); - - $(this) - .siblings().find("ul").hide().end().end() - .parentsUntil(".vakata-context", "li").addBack().addClass("vakata-context-hover"); - $.vakata.context._show_submenu(this); - }) - // тестово - дали не натоварва? - .on("mouseleave", "li", function (e) { - if($.contains(this, e.relatedTarget)) { return; } - $(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover"); - }) - .on("mouseleave", function (e) { - $(this).find(".vakata-context-hover").removeClass("vakata-context-hover"); - if($.vakata.context.settings.hide_onmouseleave) { - to = setTimeout( - (function (t) { - return function () { $.vakata.context.hide(); }; - }(this)), $.vakata.context.settings.hide_onmouseleave); - } - }) - .on("click", "a", function (e) { - e.preventDefault(); - //}) - //.on("mouseup", "a", function (e) { - if(!$(this).blur().parent().hasClass("vakata-context-disabled") && $.vakata.context._execute($(this).attr("rel")) !== false) { - $.vakata.context.hide(); - } - }) - .on('keydown', 'a', function (e) { - var o = null; - switch(e.which) { - case 13: - case 32: - e.type = "mouseup"; - e.preventDefault(); - $(e.currentTarget).trigger(e); - break; - case 37: - if(vakata_context.is_visible) { - vakata_context.element.find(".vakata-context-hover").last().closest("li").first().find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children('a').focus(); - e.stopImmediatePropagation(); - e.preventDefault(); - } - break; - case 38: - if(vakata_context.is_visible) { - o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first(); - if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last(); } - o.addClass("vakata-context-hover").children('a').focus(); - e.stopImmediatePropagation(); - e.preventDefault(); - } - break; - case 39: - if(vakata_context.is_visible) { - vakata_context.element.find(".vakata-context-hover").last().children("ul").show().children("li:not(.vakata-context-separator)").removeClass("vakata-context-hover").first().addClass("vakata-context-hover").children('a').focus(); - e.stopImmediatePropagation(); - e.preventDefault(); - } - break; - case 40: - if(vakata_context.is_visible) { - o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first(); - if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first(); } - o.addClass("vakata-context-hover").children('a').focus(); - e.stopImmediatePropagation(); - e.preventDefault(); - } - break; - case 27: - $.vakata.context.hide(); - e.preventDefault(); - break; - default: - //console.log(e.which); - break; - } - }) - .on('keydown', function (e) { - e.preventDefault(); - var a = vakata_context.element.find('.vakata-contextmenu-shortcut-' + e.which).parent(); - if(a.parent().not('.vakata-context-disabled')) { - a.click(); - } - }); - - $(document) - .on("mousedown.vakata.jstree", function (e) { - if(vakata_context.is_visible && !$.contains(vakata_context.element[0], e.target)) { - $.vakata.context.hide(); - } - }) - .on("context_show.vakata.jstree", function (e, data) { - vakata_context.element.find("li:has(ul)").children("a").addClass("vakata-context-parent"); - if(right_to_left) { - vakata_context.element.addClass("vakata-context-rtl").css("direction", "rtl"); - } - // also apply a RTL class? - vakata_context.element.find("ul").hide().end(); - }); - }); - }($)); - // $.jstree.defaults.plugins.push("contextmenu"); - -/** - * ### Drag'n'drop plugin - * - * Enables dragging and dropping of nodes in the tree, resulting in a move or copy operations. - */ - - /** - * stores all defaults for the drag'n'drop plugin - * @name $.jstree.defaults.dnd - * @plugin dnd - */ - $.jstree.defaults.dnd = { - /** - * a boolean indicating if a copy should be possible while dragging (by pressint the meta key or Ctrl). Defaults to `true`. - * @name $.jstree.defaults.dnd.copy - * @plugin dnd - */ - copy : true, - /** - * a number indicating how long a node should remain hovered while dragging to be opened. Defaults to `500`. - * @name $.jstree.defaults.dnd.open_timeout - * @plugin dnd - */ - open_timeout : 500, - /** - * a function invoked each time a node is about to be dragged, invoked in the tree's scope and receives the nodes about to be dragged as an argument (array) - return `false` to prevent dragging - * @name $.jstree.defaults.dnd.is_draggable - * @plugin dnd - */ - is_draggable : true, - /** - * a boolean indicating if checks should constantly be made while the user is dragging the node (as opposed to checking only on drop), default is `true` - * @name $.jstree.defaults.dnd.check_while_dragging - * @plugin dnd - */ - check_while_dragging : true, - /** - * a boolean indicating if nodes from this tree should only be copied with dnd (as opposed to moved), default is `false` - * @name $.jstree.defaults.dnd.always_copy - * @plugin dnd - */ - always_copy : false, - /** - * when dropping a node "inside", this setting indicates the position the node should go to - it can be an integer or a string: "first" (same as 0) or "last", default is `0` - * @name $.jstree.defaults.dnd.inside_pos - * @plugin dnd - */ - inside_pos : 0, - /** - * when starting the drag on a node that is selected this setting controls if all selected nodes are dragged or only the single node, default is `true`, which means all selected nodes are dragged when the drag is started on a selected node - * @name $.jstree.defaults.dnd.drag_selection - * @plugin dnd - */ - drag_selection : true, - /** - * controls whether dnd works on touch devices. If left as boolean true dnd will work the same as in desktop browsers, which in some cases may impair scrolling. If set to boolean false dnd will not work on touch devices. There is a special third option - string "selected" which means only selected nodes can be dragged on touch devices. - * @name $.jstree.defaults.dnd.touch - * @plugin dnd - */ - touch : true - }; - // TODO: now check works by checking for each node individually, how about max_children, unique, etc? - $.jstree.plugins.dnd = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - - this.element - .on('mousedown.jstree touchstart.jstree', '.jstree-anchor', $.proxy(function (e) { - if(e.type === "touchstart" && (!this.settings.dnd.touch || (this.settings.dnd.touch === 'selected' && !$(e.currentTarget).hasClass('jstree-clicked')))) { - return true; - } - var obj = this.get_node(e.target), - mlt = this.is_selected(obj) && this.settings.drag_selection ? this.get_selected().length : 1, - txt = (mlt > 1 ? mlt + ' ' + this.get_string('nodes') : this.get_text(e.currentTarget)); - if(this.settings.core.force_text) { - txt = $('<div />').text(txt).html(); - } - if(obj && obj.id && obj.id !== "#" && (e.which === 1 || e.type === "touchstart") && - (this.settings.dnd.is_draggable === true || ($.isFunction(this.settings.dnd.is_draggable) && this.settings.dnd.is_draggable.call(this, (mlt > 1 ? this.get_selected(true) : [obj])))) - ) { - this.element.trigger('mousedown.jstree'); - return $.vakata.dnd.start(e, { 'jstree' : true, 'origin' : this, 'obj' : this.get_node(obj,true), 'nodes' : mlt > 1 ? this.get_selected() : [obj.id] }, '<div id="jstree-dnd" class="jstree-' + this.get_theme() + ' jstree-' + this.get_theme() + '-' + this.get_theme_variant() + ' ' + ( this.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' ) + '"><i class="jstree-icon jstree-er"></i>' + txt + '<ins class="jstree-copy" style="display:none;">+</ins></div>'); - } - }, this)); - }; - }; - - $(function() { - // bind only once for all instances - var lastmv = false, - laster = false, - opento = false, - marker = $('<div id="jstree-marker"> </div>').hide(); //.appendTo('body'); - - $(document) - .on('dnd_start.vakata.jstree', function (e, data) { - lastmv = false; - if(!data || !data.data || !data.data.jstree) { return; } - marker.appendTo('body'); //.show(); - }) - .on('dnd_move.vakata.jstree', function (e, data) { - if(opento) { clearTimeout(opento); } - if(!data || !data.data || !data.data.jstree) { return; } - - // if we are hovering the marker image do nothing (can happen on "inside" drags) - if(data.event.target.id && data.event.target.id === 'jstree-marker') { - return; - } - - var ins = $.jstree.reference(data.event.target), - ref = false, - off = false, - rel = false, - l, t, h, p, i, o, ok, t1, t2, op, ps, pr, ip, tm; - // if we are over an instance - if(ins && ins._data && ins._data.dnd) { - marker.attr('class', 'jstree-' + ins.get_theme() + ( ins.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' )); - data.helper - .children().attr('class', 'jstree-' + ins.get_theme() + ' jstree-' + ins.get_theme() + '-' + ins.get_theme_variant() + ' ' + ( ins.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' )) - .find('.jstree-copy').first()[ data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))) ? 'show' : 'hide' ](); - - - // if are hovering the container itself add a new root node - if( (data.event.target === ins.element[0] || data.event.target === ins.get_container_ul()[0]) && ins.get_container_ul().children().length === 0) { - ok = true; - for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) { - ok = ok && ins.check( (data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey)) ) ? "copy_node" : "move_node"), (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), '#', 'last', { 'dnd' : true, 'ref' : ins.get_node('#'), 'pos' : 'i', 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) }); - if(!ok) { break; } - } - if(ok) { - lastmv = { 'ins' : ins, 'par' : '#', 'pos' : 'last' }; - marker.hide(); - data.helper.find('.jstree-icon').first().removeClass('jstree-er').addClass('jstree-ok'); - return; - } - } - else { - // if we are hovering a tree node - ref = $(data.event.target).closest('.jstree-anchor'); - if(ref && ref.length && ref.parent().is('.jstree-closed, .jstree-open, .jstree-leaf')) { - off = ref.offset(); - rel = data.event.pageY - off.top; - h = ref.height(); - if(rel < h / 3) { - o = ['b', 'i', 'a']; - } - else if(rel > h - h / 3) { - o = ['a', 'i', 'b']; - } - else { - o = rel > h / 2 ? ['i', 'a', 'b'] : ['i', 'b', 'a']; - } - $.each(o, function (j, v) { - switch(v) { - case 'b': - l = off.left - 6; - t = off.top; - p = ins.get_parent(ref); - i = ref.parent().index(); - break; - case 'i': - ip = ins.settings.dnd.inside_pos; - tm = ins.get_node(ref.parent()); - l = off.left - 2; - t = off.top + h / 2 + 1; - p = tm.id; - i = ip === 'first' ? 0 : (ip === 'last' ? tm.children.length : Math.min(ip, tm.children.length)); - break; - case 'a': - l = off.left - 6; - t = off.top + h; - p = ins.get_parent(ref); - i = ref.parent().index() + 1; - break; - } - ok = true; - for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) { - op = data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))) ? "copy_node" : "move_node"; - ps = i; - if(op === "move_node" && v === 'a' && (data.data.origin && data.data.origin === ins) && p === ins.get_parent(data.data.nodes[t1])) { - pr = ins.get_node(p); - if(ps > $.inArray(data.data.nodes[t1], pr.children)) { - ps -= 1; - } - } - ok = ok && ( (ins && ins.settings && ins.settings.dnd && ins.settings.dnd.check_while_dragging === false) || ins.check(op, (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), p, ps, { 'dnd' : true, 'ref' : ins.get_node(ref.parent()), 'pos' : v, 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) }) ); - if(!ok) { - if(ins && ins.last_error) { laster = ins.last_error(); } - break; - } - } - if(v === 'i' && ref.parent().is('.jstree-closed') && ins.settings.dnd.open_timeout) { - opento = setTimeout((function (x, z) { return function () { x.open_node(z); }; }(ins, ref)), ins.settings.dnd.open_timeout); - } - if(ok) { - lastmv = { 'ins' : ins, 'par' : p, 'pos' : v === 'i' && ip === 'last' && i === 0 && !ins.is_loaded(tm) ? 'last' : i }; - marker.css({ 'left' : l + 'px', 'top' : t + 'px' }).show(); - data.helper.find('.jstree-icon').first().removeClass('jstree-er').addClass('jstree-ok'); - laster = {}; - o = true; - return false; - } - }); - if(o === true) { return; } - } - } - } - lastmv = false; - data.helper.find('.jstree-icon').removeClass('jstree-ok').addClass('jstree-er'); - marker.hide(); - }) - .on('dnd_scroll.vakata.jstree', function (e, data) { - if(!data || !data.data || !data.data.jstree) { return; } - marker.hide(); - lastmv = false; - data.helper.find('.jstree-icon').first().removeClass('jstree-ok').addClass('jstree-er'); - }) - .on('dnd_stop.vakata.jstree', function (e, data) { - if(opento) { clearTimeout(opento); } - if(!data || !data.data || !data.data.jstree) { return; } - marker.hide().detach(); - var i, j, nodes = []; - if(lastmv) { - for(i = 0, j = data.data.nodes.length; i < j; i++) { - nodes[i] = data.data.origin ? data.data.origin.get_node(data.data.nodes[i]) : data.data.nodes[i]; - if(data.data.origin) { - nodes[i].instance = data.data.origin; - } - } - lastmv.ins[ data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))) ? 'copy_node' : 'move_node' ](nodes, lastmv.par, lastmv.pos); - for(i = 0, j = nodes.length; i < j; i++) { - if(nodes[i].instance) { - nodes[i].instance = null; - } - } - } - else { - i = $(data.event.target).closest('.jstree'); - if(i.length && laster && laster.error && laster.error === 'check') { - i = i.jstree(true); - if(i) { - i.settings.core.error.call(this, laster); - } - } - } - }) - .on('keyup.jstree keydown.jstree', function (e, data) { - data = $.vakata.dnd._get(); - if(data && data.data && data.data.jstree) { - data.helper.find('.jstree-copy').first()[ data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (e.metaKey || e.ctrlKey))) ? 'show' : 'hide' ](); - } - }); - }); - - // helpers - (function ($) { - // private variable - var vakata_dnd = { - element : false, - target : false, - is_down : false, - is_drag : false, - helper : false, - helper_w: 0, - data : false, - init_x : 0, - init_y : 0, - scroll_l: 0, - scroll_t: 0, - scroll_e: false, - scroll_i: false, - is_touch: false - }; - $.vakata.dnd = { - settings : { - scroll_speed : 10, - scroll_proximity : 20, - helper_left : 5, - helper_top : 10, - threshold : 5, - threshold_touch : 50 - }, - _trigger : function (event_name, e) { - var data = $.vakata.dnd._get(); - data.event = e; - $(document).triggerHandler("dnd_" + event_name + ".vakata", data); - }, - _get : function () { - return { - "data" : vakata_dnd.data, - "element" : vakata_dnd.element, - "helper" : vakata_dnd.helper - }; - }, - _clean : function () { - if(vakata_dnd.helper) { vakata_dnd.helper.remove(); } - if(vakata_dnd.scroll_i) { clearInterval(vakata_dnd.scroll_i); vakata_dnd.scroll_i = false; } - vakata_dnd = { - element : false, - target : false, - is_down : false, - is_drag : false, - helper : false, - helper_w: 0, - data : false, - init_x : 0, - init_y : 0, - scroll_l: 0, - scroll_t: 0, - scroll_e: false, - scroll_i: false, - is_touch: false - }; - $(document).off("mousemove.vakata.jstree touchmove.vakata.jstree", $.vakata.dnd.drag); - $(document).off("mouseup.vakata.jstree touchend.vakata.jstree", $.vakata.dnd.stop); - }, - _scroll : function (init_only) { - if(!vakata_dnd.scroll_e || (!vakata_dnd.scroll_l && !vakata_dnd.scroll_t)) { - if(vakata_dnd.scroll_i) { clearInterval(vakata_dnd.scroll_i); vakata_dnd.scroll_i = false; } - return false; - } - if(!vakata_dnd.scroll_i) { - vakata_dnd.scroll_i = setInterval($.vakata.dnd._scroll, 100); - return false; - } - if(init_only === true) { return false; } - - var i = vakata_dnd.scroll_e.scrollTop(), - j = vakata_dnd.scroll_e.scrollLeft(); - vakata_dnd.scroll_e.scrollTop(i + vakata_dnd.scroll_t * $.vakata.dnd.settings.scroll_speed); - vakata_dnd.scroll_e.scrollLeft(j + vakata_dnd.scroll_l * $.vakata.dnd.settings.scroll_speed); - if(i !== vakata_dnd.scroll_e.scrollTop() || j !== vakata_dnd.scroll_e.scrollLeft()) { - /** - * triggered on the document when a drag causes an element to scroll - * @event - * @plugin dnd - * @name dnd_scroll.vakata - * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start - * @param {DOM} element the DOM element being dragged - * @param {jQuery} helper the helper shown next to the mouse - * @param {jQuery} event the element that is scrolling - */ - $.vakata.dnd._trigger("scroll", vakata_dnd.scroll_e); - } - }, - start : function (e, data, html) { - if(e.type === "touchstart" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) { - e.pageX = e.originalEvent.changedTouches[0].pageX; - e.pageY = e.originalEvent.changedTouches[0].pageY; - e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset); - } - if(vakata_dnd.is_drag) { $.vakata.dnd.stop({}); } - try { - e.currentTarget.unselectable = "on"; - e.currentTarget.onselectstart = function() { return false; }; - if(e.currentTarget.style) { e.currentTarget.style.MozUserSelect = "none"; } - } catch(ignore) { } - vakata_dnd.init_x = e.pageX; - vakata_dnd.init_y = e.pageY; - vakata_dnd.data = data; - vakata_dnd.is_down = true; - vakata_dnd.element = e.currentTarget; - vakata_dnd.target = e.target; - vakata_dnd.is_touch = e.type === "touchstart"; - if(html !== false) { - vakata_dnd.helper = $("<div id='vakata-dnd'></div>").html(html).css({ - "display" : "block", - "margin" : "0", - "padding" : "0", - "position" : "absolute", - "top" : "-2000px", - "lineHeight" : "16px", - "zIndex" : "10000" - }); - } - $(document).on("mousemove.vakata.jstree touchmove.vakata.jstree", $.vakata.dnd.drag); - $(document).on("mouseup.vakata.jstree touchend.vakata.jstree", $.vakata.dnd.stop); - return false; - }, - drag : function (e) { - if(e.type === "touchmove" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) { - e.pageX = e.originalEvent.changedTouches[0].pageX; - e.pageY = e.originalEvent.changedTouches[0].pageY; - e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset); - } - if(!vakata_dnd.is_down) { return; } - if(!vakata_dnd.is_drag) { - if( - Math.abs(e.pageX - vakata_dnd.init_x) > (vakata_dnd.is_touch ? $.vakata.dnd.settings.threshold_touch : $.vakata.dnd.settings.threshold) || - Math.abs(e.pageY - vakata_dnd.init_y) > (vakata_dnd.is_touch ? $.vakata.dnd.settings.threshold_touch : $.vakata.dnd.settings.threshold) - ) { - if(vakata_dnd.helper) { - vakata_dnd.helper.appendTo("body"); - vakata_dnd.helper_w = vakata_dnd.helper.outerWidth(); - } - vakata_dnd.is_drag = true; - /** - * triggered on the document when a drag starts - * @event - * @plugin dnd - * @name dnd_start.vakata - * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start - * @param {DOM} element the DOM element being dragged - * @param {jQuery} helper the helper shown next to the mouse - * @param {Object} event the event that caused the start (probably mousemove) - */ - $.vakata.dnd._trigger("start", e); - } - else { return; } - } - - var d = false, w = false, - dh = false, wh = false, - dw = false, ww = false, - dt = false, dl = false, - ht = false, hl = false; - - vakata_dnd.scroll_t = 0; - vakata_dnd.scroll_l = 0; - vakata_dnd.scroll_e = false; - $($(e.target).parentsUntil("body").addBack().get().reverse()) - .filter(function () { - return (/^auto|scroll$/).test($(this).css("overflow")) && - (this.scrollHeight > this.offsetHeight || this.scrollWidth > this.offsetWidth); - }) - .each(function () { - var t = $(this), o = t.offset(); - if(this.scrollHeight > this.offsetHeight) { - if(o.top + t.height() - e.pageY < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = 1; } - if(e.pageY - o.top < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = -1; } - } - if(this.scrollWidth > this.offsetWidth) { - if(o.left + t.width() - e.pageX < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = 1; } - if(e.pageX - o.left < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = -1; } - } - if(vakata_dnd.scroll_t || vakata_dnd.scroll_l) { - vakata_dnd.scroll_e = $(this); - return false; - } - }); - - if(!vakata_dnd.scroll_e) { - d = $(document); w = $(window); - dh = d.height(); wh = w.height(); - dw = d.width(); ww = w.width(); - dt = d.scrollTop(); dl = d.scrollLeft(); - if(dh > wh && e.pageY - dt < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = -1; } - if(dh > wh && wh - (e.pageY - dt) < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_t = 1; } - if(dw > ww && e.pageX - dl < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = -1; } - if(dw > ww && ww - (e.pageX - dl) < $.vakata.dnd.settings.scroll_proximity) { vakata_dnd.scroll_l = 1; } - if(vakata_dnd.scroll_t || vakata_dnd.scroll_l) { - vakata_dnd.scroll_e = d; - } - } - if(vakata_dnd.scroll_e) { $.vakata.dnd._scroll(true); } - - if(vakata_dnd.helper) { - ht = parseInt(e.pageY + $.vakata.dnd.settings.helper_top, 10); - hl = parseInt(e.pageX + $.vakata.dnd.settings.helper_left, 10); - if(dh && ht + 25 > dh) { ht = dh - 50; } - if(dw && hl + vakata_dnd.helper_w > dw) { hl = dw - (vakata_dnd.helper_w + 2); } - vakata_dnd.helper.css({ - left : hl + "px", - top : ht + "px" - }); - } - /** - * triggered on the document when a drag is in progress - * @event - * @plugin dnd - * @name dnd_move.vakata - * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start - * @param {DOM} element the DOM element being dragged - * @param {jQuery} helper the helper shown next to the mouse - * @param {Object} event the event that caused this to trigger (most likely mousemove) - */ - $.vakata.dnd._trigger("move", e); - return false; - }, - stop : function (e) { - if(e.type === "touchend" && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0]) { - e.pageX = e.originalEvent.changedTouches[0].pageX; - e.pageY = e.originalEvent.changedTouches[0].pageY; - e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].pageX - window.pageXOffset, e.originalEvent.changedTouches[0].pageY - window.pageYOffset); - } - if(vakata_dnd.is_drag) { - /** - * triggered on the document when a drag stops (the dragged element is dropped) - * @event - * @plugin dnd - * @name dnd_stop.vakata - * @param {Mixed} data any data supplied with the call to $.vakata.dnd.start - * @param {DOM} element the DOM element being dragged - * @param {jQuery} helper the helper shown next to the mouse - * @param {Object} event the event that caused the stop - */ - $.vakata.dnd._trigger("stop", e); - } - else { - if(e.type === "touchend" && e.target === vakata_dnd.target) { - var to = setTimeout(function () { $(e.target).click(); }, 100); - $(e.target).one('click', function() { if(to) { clearTimeout(to); } }); - } - } - $.vakata.dnd._clean(); - return false; - } - }; - }($)); - - // include the dnd plugin by default - // $.jstree.defaults.plugins.push("dnd"); - - -/** - * ### Search plugin - * - * Adds search functionality to jsTree. - */ - - /** - * stores all defaults for the search plugin - * @name $.jstree.defaults.search - * @plugin search - */ - $.jstree.defaults.search = { - /** - * a jQuery-like AJAX config, which jstree uses if a server should be queried for results. - * - * A `str` (which is the search string) parameter will be added with the request. The expected result is a JSON array with nodes that need to be opened so that matching nodes will be revealed. - * Leave this setting as `false` to not query the server. You can also set this to a function, which will be invoked in the instance's scope and receive 2 parameters - the search string and the callback to call with the array of nodes to load. - * @name $.jstree.defaults.search.ajax - * @plugin search - */ - ajax : false, - /** - * Indicates if the search should be fuzzy or not (should `chnd3` match `child node 3`). Default is `false`. - * @name $.jstree.defaults.search.fuzzy - * @plugin search - */ - fuzzy : false, - /** - * Indicates if the search should be case sensitive. Default is `false`. - * @name $.jstree.defaults.search.case_sensitive - * @plugin search - */ - case_sensitive : false, - /** - * Indicates if the tree should be filtered (by default) to show only matching nodes (keep in mind this can be a heavy on large trees in old browsers). - * This setting can be changed at runtime when calling the search method. Default is `false`. - * @name $.jstree.defaults.search.show_only_matches - * @plugin search - */ - show_only_matches : false, - /** - * Indicates if all nodes opened to reveal the search result, should be closed when the search is cleared or a new search is performed. Default is `true`. - * @name $.jstree.defaults.search.close_opened_onclear - * @plugin search - */ - close_opened_onclear : true, - /** - * Indicates if only leaf nodes should be included in search results. Default is `false`. - * @name $.jstree.defaults.search.search_leaves_only - * @plugin search - */ - search_leaves_only : false, - /** - * If set to a function it wil be called in the instance's scope with two arguments - search string and node (where node will be every node in the structure, so use with caution). - * If the function returns a truthy value the node will be considered a match (it might not be displayed if search_only_leaves is set to true and the node is not a leaf). Default is `false`. - * @name $.jstree.defaults.search.search_callback - * @plugin search - */ - search_callback : false - }; - - $.jstree.plugins.search = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - - this._data.search.str = ""; - this._data.search.dom = $(); - this._data.search.res = []; - this._data.search.opn = []; - this._data.search.som = false; - - this.element - .on('before_open.jstree', $.proxy(function (e, data) { - var i, j, f, r = this._data.search.res, s = [], o = $(); - if(r && r.length) { - this._data.search.dom = $(this.element[0].querySelectorAll('#' + $.map(r, function (v) { return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); }).join(', #'))); - this._data.search.dom.children(".jstree-anchor").addClass('jstree-search'); - if(this._data.search.som && this._data.search.res.length) { - for(i = 0, j = r.length; i < j; i++) { - s = s.concat(this.get_node(r[i]).parents); - } - s = $.vakata.array_remove_item($.vakata.array_unique(s),'#'); - o = s.length ? $(this.element[0].querySelectorAll('#' + $.map(s, function (v) { return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); }).join(', #'))) : $(); - - this.element.find(".jstree-node").hide().filter('.jstree-last').filter(function() { return this.nextSibling; }).removeClass('jstree-last'); - o = o.add(this._data.search.dom); - o.parentsUntil(".jstree").addBack().show() - .filter(".jstree-children").each(function () { $(this).children(".jstree-node:visible").eq(-1).addClass("jstree-last"); }); - } - } - }, this)) - .on("search.jstree", $.proxy(function (e, data) { - if(this._data.search.som) { - if(data.nodes.length) { - this.element.find(".jstree-node").hide().filter('.jstree-last').filter(function() { return this.nextSibling; }).removeClass('jstree-last'); - data.nodes.parentsUntil(".jstree").addBack().show() - .filter(".jstree-children").each(function () { $(this).children(".jstree-node:visible").eq(-1).addClass("jstree-last"); }); - } - } - }, this)) - .on("clear_search.jstree", $.proxy(function (e, data) { - if(this._data.search.som && data.nodes.length) { - this.element.find(".jstree-node").css("display","").filter('.jstree-last').filter(function() { return this.nextSibling; }).removeClass('jstree-last'); - } - }, this)); - }; - /** - * used to search the tree nodes for a given string - * @name search(str [, skip_async]) - * @param {String} str the search string - * @param {Boolean} skip_async if set to true server will not be queried even if configured - * @param {Boolean} show_only_matches if set to true only matching nodes will be shown (keep in mind this can be very slow on large trees or old browsers) - * @plugin search - * @trigger search.jstree - */ - this.search = function (str, skip_async, show_only_matches) { - if(str === false || $.trim(str.toString()) === "") { - return this.clear_search(); - } - str = str.toString(); - var s = this.settings.search, - a = s.ajax ? s.ajax : false, - f = null, - r = [], - p = [], i, j; - if(this._data.search.res.length) { - this.clear_search(); - } - if(show_only_matches === undefined) { - show_only_matches = s.show_only_matches; - } - if(!skip_async && a !== false) { - if($.isFunction(a)) { - return a.call(this, str, $.proxy(function (d) { - if(d && d.d) { d = d.d; } - this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () { - this.search(str, true, show_only_matches); - }, true); - }, this)); - } - else { - a = $.extend({}, a); - if(!a.data) { a.data = {}; } - a.data.str = str; - return $.ajax(a) - .fail($.proxy(function () { - this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'search', 'id' : 'search_01', 'reason' : 'Could not load search parents', 'data' : JSON.stringify(a) }; - this.settings.core.error.call(this, this._data.core.last_error); - }, this)) - .done($.proxy(function (d) { - if(d && d.d) { d = d.d; } - this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () { - this.search(str, true, show_only_matches); - }, true); - }, this)); - } - } - this._data.search.str = str; - this._data.search.dom = $(); - this._data.search.res = []; - this._data.search.opn = []; - this._data.search.som = show_only_matches; - - f = new $.vakata.search(str, true, { caseSensitive : s.case_sensitive, fuzzy : s.fuzzy }); - - $.each(this._model.data, function (i, v) { - if(v.text && ( (s.search_callback && s.search_callback.call(this, str, v)) || (!s.search_callback && f.search(v.text).isMatch) ) && (!s.search_leaves_only || (v.state.loaded && v.children.length === 0)) ) { - r.push(i); - p = p.concat(v.parents); - } - }); - if(r.length) { - p = $.vakata.array_unique(p); - this._search_open(p); - this._data.search.dom = $(this.element[0].querySelectorAll('#' + $.map(r, function (v) { return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); }).join(', #'))); - this._data.search.res = r; - this._data.search.dom.children(".jstree-anchor").addClass('jstree-search'); - } - /** - * triggered after search is complete - * @event - * @name search.jstree - * @param {jQuery} nodes a jQuery collection of matching nodes - * @param {String} str the search string - * @param {Array} res a collection of objects represeing the matching nodes - * @plugin search - */ - this.trigger('search', { nodes : this._data.search.dom, str : str, res : this._data.search.res, show_only_matches : show_only_matches }); - }; - /** - * used to clear the last search (removes classes and shows all nodes if filtering is on) - * @name clear_search() - * @plugin search - * @trigger clear_search.jstree - */ - this.clear_search = function () { - this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search"); - if(this.settings.search.close_opened_onclear) { - this.close_node(this._data.search.opn, 0); - } - /** - * triggered after search is complete - * @event - * @name clear_search.jstree - * @param {jQuery} nodes a jQuery collection of matching nodes (the result from the last search) - * @param {String} str the search string (the last search string) - * @param {Array} res a collection of objects represeing the matching nodes (the result from the last search) - * @plugin search - */ - this.trigger('clear_search', { 'nodes' : this._data.search.dom, str : this._data.search.str, res : this._data.search.res }); - this._data.search.str = ""; - this._data.search.res = []; - this._data.search.opn = []; - this._data.search.dom = $(); - }; - /** - * opens nodes that need to be opened to reveal the search results. Used only internally. - * @private - * @name _search_open(d) - * @param {Array} d an array of node IDs - * @plugin search - */ - this._search_open = function (d) { - var t = this; - $.each(d.concat([]), function (i, v) { - if(v === "#") { return true; } - try { v = $('#' + v.replace($.jstree.idregex,'\\$&'), t.element); } catch(ignore) { } - if(v && v.length) { - if(t.is_closed(v)) { - t._data.search.opn.push(v[0].id); - t.open_node(v, function () { t._search_open(d); }, 0); - } - } - }); - }; - }; - - // helpers - (function ($) { - // from http://kiro.me/projects/fuse.html - $.vakata.search = function(pattern, txt, options) { - options = options || {}; - if(options.fuzzy !== false) { - options.fuzzy = true; - } - pattern = options.caseSensitive ? pattern : pattern.toLowerCase(); - var MATCH_LOCATION = options.location || 0, - MATCH_DISTANCE = options.distance || 100, - MATCH_THRESHOLD = options.threshold || 0.6, - patternLen = pattern.length, - matchmask, pattern_alphabet, match_bitapScore, search; - if(patternLen > 32) { - options.fuzzy = false; - } - if(options.fuzzy) { - matchmask = 1 << (patternLen - 1); - pattern_alphabet = (function () { - var mask = {}, - i = 0; - for (i = 0; i < patternLen; i++) { - mask[pattern.charAt(i)] = 0; - } - for (i = 0; i < patternLen; i++) { - mask[pattern.charAt(i)] |= 1 << (patternLen - i - 1); - } - return mask; - }()); - match_bitapScore = function (e, x) { - var accuracy = e / patternLen, - proximity = Math.abs(MATCH_LOCATION - x); - if(!MATCH_DISTANCE) { - return proximity ? 1.0 : accuracy; - } - return accuracy + (proximity / MATCH_DISTANCE); - }; - } - search = function (text) { - text = options.caseSensitive ? text : text.toLowerCase(); - if(pattern === text || text.indexOf(pattern) !== -1) { - return { - isMatch: true, - score: 0 - }; - } - if(!options.fuzzy) { - return { - isMatch: false, - score: 1 - }; - } - var i, j, - textLen = text.length, - scoreThreshold = MATCH_THRESHOLD, - bestLoc = text.indexOf(pattern, MATCH_LOCATION), - binMin, binMid, - binMax = patternLen + textLen, - lastRd, start, finish, rd, charMatch, - score = 1, - locations = []; - if (bestLoc !== -1) { - scoreThreshold = Math.min(match_bitapScore(0, bestLoc), scoreThreshold); - bestLoc = text.lastIndexOf(pattern, MATCH_LOCATION + patternLen); - if (bestLoc !== -1) { - scoreThreshold = Math.min(match_bitapScore(0, bestLoc), scoreThreshold); - } - } - bestLoc = -1; - for (i = 0; i < patternLen; i++) { - binMin = 0; - binMid = binMax; - while (binMin < binMid) { - if (match_bitapScore(i, MATCH_LOCATION + binMid) <= scoreThreshold) { - binMin = binMid; - } else { - binMax = binMid; - } - binMid = Math.floor((binMax - binMin) / 2 + binMin); - } - binMax = binMid; - start = Math.max(1, MATCH_LOCATION - binMid + 1); - finish = Math.min(MATCH_LOCATION + binMid, textLen) + patternLen; - rd = new Array(finish + 2); - rd[finish + 1] = (1 << i) - 1; - for (j = finish; j >= start; j--) { - charMatch = pattern_alphabet[text.charAt(j - 1)]; - if (i === 0) { - rd[j] = ((rd[j + 1] << 1) | 1) & charMatch; - } else { - rd[j] = ((rd[j + 1] << 1) | 1) & charMatch | (((lastRd[j + 1] | lastRd[j]) << 1) | 1) | lastRd[j + 1]; - } - if (rd[j] & matchmask) { - score = match_bitapScore(i, j - 1); - if (score <= scoreThreshold) { - scoreThreshold = score; - bestLoc = j - 1; - locations.push(bestLoc); - if (bestLoc > MATCH_LOCATION) { - start = Math.max(1, 2 * MATCH_LOCATION - bestLoc); - } else { - break; - } - } - } - } - if (match_bitapScore(i + 1, MATCH_LOCATION) > scoreThreshold) { - break; - } - lastRd = rd; - } - return { - isMatch: bestLoc >= 0, - score: score - }; - }; - return txt === true ? { 'search' : search } : search(txt); - }; - }($)); - - // include the search plugin by default - // $.jstree.defaults.plugins.push("search"); - -/** - * ### Sort plugin - * - * Automatically sorts all siblings in the tree according to a sorting function. - */ - - /** - * the settings function used to sort the nodes. - * It is executed in the tree's context, accepts two nodes as arguments and should return `1` or `-1`. - * @name $.jstree.defaults.sort - * @plugin sort - */ - $.jstree.defaults.sort = function (a, b) { - //return this.get_type(a) === this.get_type(b) ? (this.get_text(a) > this.get_text(b) ? 1 : -1) : this.get_type(a) >= this.get_type(b); - return this.get_text(a) > this.get_text(b) ? 1 : -1; - }; - $.jstree.plugins.sort = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - this.element - .on("model.jstree", $.proxy(function (e, data) { - this.sort(data.parent, true); - }, this)) - .on("rename_node.jstree create_node.jstree", $.proxy(function (e, data) { - this.sort(data.parent || data.node.parent, false); - this.redraw_node(data.parent || data.node.parent, true); - }, this)) - .on("move_node.jstree copy_node.jstree", $.proxy(function (e, data) { - this.sort(data.parent, false); - this.redraw_node(data.parent, true); - }, this)); - }; - /** - * used to sort a node's children - * @private - * @name sort(obj [, deep]) - * @param {mixed} obj the node - * @param {Boolean} deep if set to `true` nodes are sorted recursively. - * @plugin sort - * @trigger search.jstree - */ - this.sort = function (obj, deep) { - var i, j; - obj = this.get_node(obj); - if(obj && obj.children && obj.children.length) { - obj.children.sort($.proxy(this.settings.sort, this)); - if(deep) { - for(i = 0, j = obj.children_d.length; i < j; i++) { - this.sort(obj.children_d[i], false); - } - } - } - }; - }; - - // include the sort plugin by default - // $.jstree.defaults.plugins.push("sort"); - -/** - * ### State plugin - * - * Saves the state of the tree (selected nodes, opened nodes) on the user's computer using available options (localStorage, cookies, etc) - */ - - var to = false; - /** - * stores all defaults for the state plugin - * @name $.jstree.defaults.state - * @plugin state - */ - $.jstree.defaults.state = { - /** - * A string for the key to use when saving the current tree (change if using multiple trees in your project). Defaults to `jstree`. - * @name $.jstree.defaults.state.key - * @plugin state - */ - key : 'jstree', - /** - * A space separated list of events that trigger a state save. Defaults to `changed.jstree open_node.jstree close_node.jstree`. - * @name $.jstree.defaults.state.events - * @plugin state - */ - events : 'changed.jstree open_node.jstree close_node.jstree check_node.jstree uncheck_node.jstree', - /** - * Time in milliseconds after which the state will expire. Defaults to 'false' meaning - no expire. - * @name $.jstree.defaults.state.ttl - * @plugin state - */ - ttl : false, - /** - * A function that will be executed prior to restoring state with one argument - the state object. Can be used to clear unwanted parts of the state. - * @name $.jstree.defaults.state.filter - * @plugin state - */ - filter : false - }; - $.jstree.plugins.state = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - var bind = $.proxy(function () { - this.element.on(this.settings.state.events, $.proxy(function () { - if(to) { clearTimeout(to); } - to = setTimeout($.proxy(function () { this.save_state(); }, this), 100); - }, this)); - /** - * triggered when the state plugin is finished restoring the state (and immediately after ready if there is no state to restore). - * @event - * @name state_ready.jstree - * @plugin state - */ - this.trigger('state_ready'); - }, this); - this.element - .on("ready.jstree", $.proxy(function (e, data) { - this.element.one("restore_state.jstree", bind); - if(!this.restore_state()) { bind(); } - }, this)); - }; - /** - * save the state - * @name save_state() - * @plugin state - */ - this.save_state = function () { - var st = { 'state' : this.get_state(), 'ttl' : this.settings.state.ttl, 'sec' : +(new Date()) }; - $.vakata.storage.set(this.settings.state.key, JSON.stringify(st)); - }; - /** - * restore the state from the user's computer - * @name restore_state() - * @plugin state - */ - this.restore_state = function () { - var k = $.vakata.storage.get(this.settings.state.key); - if(!!k) { try { k = JSON.parse(k); } catch(ex) { return false; } } - if(!!k && k.ttl && k.sec && +(new Date()) - k.sec > k.ttl) { return false; } - if(!!k && k.state) { k = k.state; } - if(!!k && $.isFunction(this.settings.state.filter)) { k = this.settings.state.filter.call(this, k); } - if(!!k) { - this.element.one("set_state.jstree", function (e, data) { data.instance.trigger('restore_state', { 'state' : $.extend(true, {}, k) }); }); - this.set_state(k); - return true; - } - return false; - }; - /** - * clear the state on the user's computer - * @name clear_state() - * @plugin state - */ - this.clear_state = function () { - return $.vakata.storage.del(this.settings.state.key); - }; - }; - - (function ($, undefined) { - $.vakata.storage = { - // simply specifying the functions in FF throws an error - set : function (key, val) { return window.localStorage.setItem(key, val); }, - get : function (key) { return window.localStorage.getItem(key); }, - del : function (key) { return window.localStorage.removeItem(key); } - }; - }($)); - - // include the state plugin by default - // $.jstree.defaults.plugins.push("state"); - -/** - * ### Types plugin - * - * Makes it possible to add predefined types for groups of nodes, which make it possible to easily control nesting rules and icon for each group. - */ - - /** - * An object storing all types as key value pairs, where the key is the type name and the value is an object that could contain following keys (all optional). - * - * * `max_children` the maximum number of immediate children this node type can have. Do not specify or set to `-1` for unlimited. - * * `max_depth` the maximum number of nesting this node type can have. A value of `1` would mean that the node can have children, but no grandchildren. Do not specify or set to `-1` for unlimited. - * * `valid_children` an array of node type strings, that nodes of this type can have as children. Do not specify or set to `-1` for no limits. - * * `icon` a string - can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class. Omit to use the default icon from your theme. - * - * There are two predefined types: - * - * * `#` represents the root of the tree, for example `max_children` would control the maximum number of root nodes. - * * `default` represents the default node - any settings here will be applied to all nodes that do not have a type specified. - * - * @name $.jstree.defaults.types - * @plugin types - */ - $.jstree.defaults.types = { - '#' : {}, - 'default' : {} - }; - - $.jstree.plugins.types = function (options, parent) { - this.init = function (el, options) { - var i, j; - if(options && options.types && options.types['default']) { - for(i in options.types) { - if(i !== "default" && i !== "#" && options.types.hasOwnProperty(i)) { - for(j in options.types['default']) { - if(options.types['default'].hasOwnProperty(j) && options.types[i][j] === undefined) { - options.types[i][j] = options.types['default'][j]; - } - } - } - } - } - parent.init.call(this, el, options); - this._model.data['#'].type = '#'; - }; - this.refresh = function (skip_loading, forget_state) { - parent.refresh.call(this, skip_loading, forget_state); - this._model.data['#'].type = '#'; - }; - this.bind = function () { - this.element - .on('model.jstree', $.proxy(function (e, data) { - var m = this._model.data, - dpc = data.nodes, - t = this.settings.types, - i, j, c = 'default'; - for(i = 0, j = dpc.length; i < j; i++) { - c = 'default'; - if(m[dpc[i]].original && m[dpc[i]].original.type && t[m[dpc[i]].original.type]) { - c = m[dpc[i]].original.type; - } - if(m[dpc[i]].data && m[dpc[i]].data.jstree && m[dpc[i]].data.jstree.type && t[m[dpc[i]].data.jstree.type]) { - c = m[dpc[i]].data.jstree.type; - } - m[dpc[i]].type = c; - if(m[dpc[i]].icon === true && t[c].icon !== undefined) { - m[dpc[i]].icon = t[c].icon; - } - } - m['#'].type = '#'; - }, this)); - parent.bind.call(this); - }; - this.get_json = function (obj, options, flat) { - var i, j, - m = this._model.data, - opt = options ? $.extend(true, {}, options, {no_id:false}) : {}, - tmp = parent.get_json.call(this, obj, opt, flat); - if(tmp === false) { return false; } - if($.isArray(tmp)) { - for(i = 0, j = tmp.length; i < j; i++) { - tmp[i].type = tmp[i].id && m[tmp[i].id] && m[tmp[i].id].type ? m[tmp[i].id].type : "default"; - if(options && options.no_id) { - delete tmp[i].id; - if(tmp[i].li_attr && tmp[i].li_attr.id) { - delete tmp[i].li_attr.id; - } - if(tmp[i].a_attr && tmp[i].a_attr.id) { - delete tmp[i].a_attr.id; - } - } - } - } - else { - tmp.type = tmp.id && m[tmp.id] && m[tmp.id].type ? m[tmp.id].type : "default"; - if(options && options.no_id) { - tmp = this._delete_ids(tmp); - } - } - return tmp; - }; - this._delete_ids = function (tmp) { - if($.isArray(tmp)) { - for(var i = 0, j = tmp.length; i < j; i++) { - tmp[i] = this._delete_ids(tmp[i]); - } - return tmp; - } - delete tmp.id; - if(tmp.li_attr && tmp.li_attr.id) { - delete tmp.li_attr.id; - } - if(tmp.a_attr && tmp.a_attr.id) { - delete tmp.a_attr.id; - } - if(tmp.children && $.isArray(tmp.children)) { - tmp.children = this._delete_ids(tmp.children); - } - return tmp; - }; - this.check = function (chk, obj, par, pos, more) { - if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; } - obj = obj && obj.id ? obj : this.get_node(obj); - par = par && par.id ? par : this.get_node(par); - var m = obj && obj.id ? $.jstree.reference(obj.id) : null, tmp, d, i, j; - m = m && m._model && m._model.data ? m._model.data : null; - switch(chk) { - case "create_node": - case "move_node": - case "copy_node": - if(chk !== 'move_node' || $.inArray(obj.id, par.children) === -1) { - tmp = this.get_rules(par); - if(tmp.max_children !== undefined && tmp.max_children !== -1 && tmp.max_children === par.children.length) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_01', 'reason' : 'max_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - return false; - } - if(tmp.valid_children !== undefined && tmp.valid_children !== -1 && $.inArray((obj.type || 'default'), tmp.valid_children) === -1) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_02', 'reason' : 'valid_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - return false; - } - if(m && obj.children_d && obj.parents) { - d = 0; - for(i = 0, j = obj.children_d.length; i < j; i++) { - d = Math.max(d, m[obj.children_d[i]].parents.length); - } - d = d - obj.parents.length + 1; - } - if(d <= 0 || d === undefined) { d = 1; } - do { - if(tmp.max_depth !== undefined && tmp.max_depth !== -1 && tmp.max_depth < d) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_03', 'reason' : 'max_depth prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - return false; - } - par = this.get_node(par.parent); - tmp = this.get_rules(par); - d++; - } while(par); - } - break; - } - return true; - }; - /** - * used to retrieve the type settings object for a node - * @name get_rules(obj) - * @param {mixed} obj the node to find the rules for - * @return {Object} - * @plugin types - */ - this.get_rules = function (obj) { - obj = this.get_node(obj); - if(!obj) { return false; } - var tmp = this.get_type(obj, true); - if(tmp.max_depth === undefined) { tmp.max_depth = -1; } - if(tmp.max_children === undefined) { tmp.max_children = -1; } - if(tmp.valid_children === undefined) { tmp.valid_children = -1; } - return tmp; - }; - /** - * used to retrieve the type string or settings object for a node - * @name get_type(obj [, rules]) - * @param {mixed} obj the node to find the rules for - * @param {Boolean} rules if set to `true` instead of a string the settings object will be returned - * @return {String|Object} - * @plugin types - */ - this.get_type = function (obj, rules) { - obj = this.get_node(obj); - return (!obj) ? false : ( rules ? $.extend({ 'type' : obj.type }, this.settings.types[obj.type]) : obj.type); - }; - /** - * used to change a node's type - * @name set_type(obj, type) - * @param {mixed} obj the node to change - * @param {String} type the new type - * @plugin types - */ - this.set_type = function (obj, type) { - var t, t1, t2, old_type, old_icon; - if($.isArray(obj)) { - obj = obj.slice(); - for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { - this.set_type(obj[t1], type); - } - return true; - } - t = this.settings.types; - obj = this.get_node(obj); - if(!t[type] || !obj) { return false; } - old_type = obj.type; - old_icon = this.get_icon(obj); - obj.type = type; - if(old_icon === true || (t[old_type] && t[old_type].icon !== undefined && old_icon === t[old_type].icon)) { - this.set_icon(obj, t[type].icon !== undefined ? t[type].icon : true); - } - return true; - }; - }; - // include the types plugin by default - // $.jstree.defaults.plugins.push("types"); - -/** - * ### Unique plugin - * - * Enforces that no nodes with the same name can coexist as siblings. - */ - - /** - * stores all defaults for the unique plugin - * @name $.jstree.defaults.unique - * @plugin unique - */ - $.jstree.defaults.unique = { - /** - * Indicates if the comparison should be case sensitive. Default is `false`. - * @name $.jstree.defaults.unique.case_sensitive - * @plugin unique - */ - case_sensitive : false, - /** - * A callback executed in the instance's scope when a new node is created and the name is already taken, the two arguments are the conflicting name and the counter. The default will produce results like `New node (2)`. - * @name $.jstree.defaults.unique.duplicate - * @plugin unique - */ - duplicate : function (name, counter) { - return name + ' (' + counter + ')'; - } - }; - - $.jstree.plugins.unique = function (options, parent) { - this.check = function (chk, obj, par, pos, more) { - if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; } - obj = obj && obj.id ? obj : this.get_node(obj); - par = par && par.id ? par : this.get_node(par); - if(!par || !par.children) { return true; } - var n = chk === "rename_node" ? pos : obj.text, - c = [], - s = this.settings.unique.case_sensitive, - m = this._model.data, i, j; - for(i = 0, j = par.children.length; i < j; i++) { - c.push(s ? m[par.children[i]].text : m[par.children[i]].text.toLowerCase()); - } - if(!s) { n = n.toLowerCase(); } - switch(chk) { - case "delete_node": - return true; - case "rename_node": - i = ($.inArray(n, c) === -1 || (obj.text && obj.text[ s ? 'toString' : 'toLowerCase']() === n)); - if(!i) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_01', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - } - return i; - case "create_node": - i = ($.inArray(n, c) === -1); - if(!i) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_04', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - } - return i; - case "copy_node": - i = ($.inArray(n, c) === -1); - if(!i) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_02', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - } - return i; - case "move_node": - i = (obj.parent === par.id || $.inArray(n, c) === -1); - if(!i) { - this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_03', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) }; - } - return i; - } - return true; - }; - this.create_node = function (par, node, pos, callback, is_loaded) { - if(!node || node.text === undefined) { - if(par === null) { - par = "#"; - } - par = this.get_node(par); - if(!par) { - return parent.create_node.call(this, par, node, pos, callback, is_loaded); - } - pos = pos === undefined ? "last" : pos; - if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) { - return parent.create_node.call(this, par, node, pos, callback, is_loaded); - } - if(!node) { node = {}; } - var tmp, n, dpc, i, j, m = this._model.data, s = this.settings.unique.case_sensitive, cb = this.settings.unique.duplicate; - n = tmp = this.get_string('New node'); - dpc = []; - for(i = 0, j = par.children.length; i < j; i++) { - dpc.push(s ? m[par.children[i]].text : m[par.children[i]].text.toLowerCase()); - } - i = 1; - while($.inArray(s ? n : n.toLowerCase(), dpc) !== -1) { - n = cb.call(this, tmp, (++i)).toString(); - } - node.text = n; - } - return parent.create_node.call(this, par, node, pos, callback, is_loaded); - }; - }; - - // include the unique plugin by default - // $.jstree.defaults.plugins.push("unique"); - - -/** - * ### Wholerow plugin - * - * Makes each node appear block level. Making selection easier. May cause slow down for large trees in old browsers. - */ - - var div = document.createElement('DIV'); - div.setAttribute('unselectable','on'); - div.setAttribute('role','presentation'); - div.className = 'jstree-wholerow'; - div.innerHTML = ' '; - $.jstree.plugins.wholerow = function (options, parent) { - this.bind = function () { - parent.bind.call(this); - - this.element - .on('ready.jstree set_state.jstree', $.proxy(function () { - this.hide_dots(); - }, this)) - .on("init.jstree loading.jstree ready.jstree", $.proxy(function () { - //div.style.height = this._data.core.li_height + 'px'; - this.get_container_ul().addClass('jstree-wholerow-ul'); - }, this)) - .on("deselect_all.jstree", $.proxy(function (e, data) { - this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked'); - }, this)) - .on("changed.jstree", $.proxy(function (e, data) { - this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked'); - var tmp = false, i, j; - for(i = 0, j = data.selected.length; i < j; i++) { - tmp = this.get_node(data.selected[i], true); - if(tmp && tmp.length) { - tmp.children('.jstree-wholerow').addClass('jstree-wholerow-clicked'); - } - } - }, this)) - .on("open_node.jstree", $.proxy(function (e, data) { - this.get_node(data.node, true).find('.jstree-clicked').parent().children('.jstree-wholerow').addClass('jstree-wholerow-clicked'); - }, this)) - .on("hover_node.jstree dehover_node.jstree", $.proxy(function (e, data) { - if(e.type === "hover_node" && this.is_disabled(data.node)) { return; } - this.get_node(data.node, true).children('.jstree-wholerow')[e.type === "hover_node"?"addClass":"removeClass"]('jstree-wholerow-hovered'); - }, this)) - .on("contextmenu.jstree", ".jstree-wholerow", $.proxy(function (e) { - e.preventDefault(); - var tmp = $.Event('contextmenu', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey, pageX : e.pageX, pageY : e.pageY }); - $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp); - }, this)) - .on("click.jstree", ".jstree-wholerow", function (e) { - e.stopImmediatePropagation(); - var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey }); - $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus(); - }) - .on("click.jstree", ".jstree-leaf > .jstree-ocl", $.proxy(function (e) { - e.stopImmediatePropagation(); - var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey }); - $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus(); - }, this)) - .on("mouseover.jstree", ".jstree-wholerow, .jstree-icon", $.proxy(function (e) { - e.stopImmediatePropagation(); - if(!this.is_disabled(e.currentTarget)) { - this.hover_node(e.currentTarget); - } - return false; - }, this)) - .on("mouseleave.jstree", ".jstree-node", $.proxy(function (e) { - this.dehover_node(e.currentTarget); - }, this)); - }; - this.teardown = function () { - if(this.settings.wholerow) { - this.element.find(".jstree-wholerow").remove(); - } - parent.teardown.call(this); - }; - this.redraw_node = function(obj, deep, callback, force_render) { - obj = parent.redraw_node.apply(this, arguments); - if(obj) { - var tmp = div.cloneNode(true); - //tmp.style.height = this._data.core.li_height + 'px'; - if($.inArray(obj.id, this._data.core.selected) !== -1) { tmp.className += ' jstree-wholerow-clicked'; } - if(this._data.core.focused && this._data.core.focused === obj.id) { tmp.className += ' jstree-wholerow-hovered'; } - obj.insertBefore(tmp, obj.childNodes[0]); - } - return obj; - }; - }; - // include the wholerow plugin by default - // $.jstree.defaults.plugins.push("wholerow"); - - -(function ($) { - if(document.registerElement && Object && Object.create) { - var proto = Object.create(HTMLElement.prototype); - proto.createdCallback = function () { - var c = { core : {}, plugins : [] }, i; - for(i in $.jstree.plugins) { - if($.jstree.plugins.hasOwnProperty(i) && this.attributes[i]) { - c.plugins.push(i); - if(this.getAttribute(i) && JSON.parse(this.getAttribute(i))) { - c[i] = JSON.parse(this.getAttribute(i)); - } - } - } - for(i in $.jstree.defaults.core) { - if($.jstree.defaults.core.hasOwnProperty(i) && this.attributes[i]) { - c.core[i] = JSON.parse(this.getAttribute(i)) || this.getAttribute(i); - } - } - jQuery(this).jstree(c); - }; - // proto.attributeChangedCallback = function (name, previous, value) { }; - try { - document.registerElement("vakata-jstree", { prototype: proto }); - } catch(ignore) { } - } -}(jQuery)); -})); /*! JSZip - A Javascript class for generating and reading zip files @@ -25799,7 +18560,7 @@ var parse_RRTabId=parseuint16a;var parse_ScenarioProtect=parsebool;var parse_Scl=parseuint16a;var parse_String=parse_XLUnicodeString;var parse_SxBool=parsebool;var parse_TopMargin=parse_Xnum;var parse_UsesELFs=parsebool;var parse_VCenter=parsebool;var parse_WinProtect=parsebool;var parse_WriteProtect=parsenoop;var parse_VerticalPageBreaks=parsenoop;var parse_HorizontalPageBreaks=parsenoop;var parse_Selection=parsenoop;var parse_Continue=parsenoop;var parse_Pane=parsenoop;var parse_Pls=parsenoop;var parse_DCon=parsenoop;var parse_DConRef=parsenoop;var parse_DConName=parsenoop;var parse_XCT=parsenoop;var parse_CRN=parsenoop;var parse_FileSharing=parsenoop;var parse_Uncalced=parsenoop;var parse_Template=parsenoop;var parse_Intl=parsenoop;var parse_ColInfo=parsenoop;var parse_WsBool=parsenoop;var parse_Sort=parsenoop;var parse_Palette=parsenoop;var parse_Sync=parsenoop;var parse_LPr=parsenoop;var parse_DxGCol=parsenoop;var parse_FnGroupName=parsenoop;var parse_FilterMode=parsenoop;var parse_AutoFilterInfo=parsenoop;var parse_AutoFilter=parsenoop;var parse_Setup=parsenoop;var parse_ScenMan=parsenoop;var parse_SCENARIO=parsenoop;var parse_SxView=parsenoop;var parse_Sxvd=parsenoop;var parse_SXVI=parsenoop;var parse_SxIvd=parsenoop;var parse_SXLI=parsenoop;var parse_SXPI=parsenoop;var parse_DocRoute=parsenoop;var parse_RecipName=parsenoop;var parse_MulBlank=parsenoop;var parse_SXDI=parsenoop;var parse_SXDB=parsenoop;var parse_SXFDB=parsenoop;var parse_SXDBB=parsenoop;var parse_SXNum=parsenoop;var parse_SxErr=parsenoop;var parse_SXInt=parsenoop;var parse_SXString=parsenoop;var parse_SXDtr=parsenoop;var parse_SxNil=parsenoop;var parse_SXTbl=parsenoop;var parse_SXTBRGIITM=parsenoop;var parse_SxTbpg=parsenoop;var parse_ObProj=parsenoop;var parse_SXStreamID=parsenoop;var parse_DBCell=parsenoop;var parse_SXRng=parsenoop;var parse_SxIsxoper=parsenoop;var parse_BookBool=parsenoop;var parse_DbOrParamQry=parsenoop;var parse_OleObjectSize=parsenoop;var parse_SXVS=parsenoop;var parse_BkHim=parsenoop;var parse_MsoDrawingGroup=parsenoop;var parse_MsoDrawing=parsenoop;var parse_MsoDrawingSelection=parsenoop;var parse_PhoneticInfo=parsenoop;var parse_SxRule=parsenoop;var parse_SXEx=parsenoop;var parse_SxFilt=parsenoop;var parse_SxDXF=parsenoop;var parse_SxItm=parsenoop;var parse_SxName=parsenoop;var parse_SxSelect=parsenoop;var parse_SXPair=parsenoop;var parse_SxFmla=parsenoop;var parse_SxFormat=parsenoop;var parse_SXVDEx=parsenoop;var parse_SXFormula=parsenoop;var parse_SXDBEx=parsenoop;var parse_RRDInsDel=parsenoop;var parse_RRDHead=parsenoop;var parse_RRDChgCell=parsenoop;var parse_RRDRenSheet=parsenoop;var parse_RRSort=parsenoop;var parse_RRDMove=parsenoop;var parse_RRFormat=parsenoop;var parse_RRAutoFmt=parsenoop;var parse_RRInsertSh=parsenoop;var parse_RRDMoveBegin=parsenoop;var parse_RRDMoveEnd=parsenoop;var parse_RRDInsDelBegin=parsenoop;var parse_RRDInsDelEnd=parsenoop;var parse_RRDConflict=parsenoop;var parse_RRDDefName=parsenoop;var parse_RRDRstEtxp=parsenoop;var parse_LRng=parsenoop;var parse_CUsr=parsenoop;var parse_CbUsr=parsenoop;var parse_UsrInfo=parsenoop;var parse_UsrExcl=parsenoop;var parse_FileLock=parsenoop;var parse_RRDInfo=parsenoop;var parse_BCUsrs=parsenoop;var parse_UsrChk=parsenoop;var parse_UserBView=parsenoop;var parse_UserSViewBegin=parsenoop;var parse_UserSViewEnd=parsenoop;var parse_RRDUserView=parsenoop;var parse_Qsi=parsenoop;var parse_CondFmt=parsenoop;var parse_CF=parsenoop;var parse_DVal=parsenoop;var parse_DConBin=parsenoop;var parse_Lel=parsenoop;var parse_CodeName=parse_XLUnicodeString;var parse_SXFDBType=parsenoop;var parse_ObNoMacros=parsenoop;var parse_Dv=parsenoop;var parse_Index=parsenoop;var parse_Table=parsenoop;var parse_Window2=parsenoop;var parse_Style=parsenoop;var parse_BigName=parsenoop;var parse_ContinueBigName=parsenoop;var parse_WebPub=parsenoop;var parse_QsiSXTag=parsenoop;var parse_DBQueryExt=parsenoop;var parse_ExtString=parsenoop;var parse_TxtQry=parsenoop;var parse_Qsir=parsenoop;var parse_Qsif=parsenoop;var parse_RRDTQSIF=parsenoop;var parse_OleDbConn=parsenoop;var parse_WOpt=parsenoop;var parse_SXViewEx=parsenoop;var parse_SXTH=parsenoop;var parse_SXPIEx=parsenoop;var parse_SXVDTEx=parsenoop;var parse_SXViewEx9=parsenoop;var parse_ContinueFrt=parsenoop;var parse_RealTimeData=parsenoop;var parse_ChartFrtInfo=parsenoop;var parse_FrtWrapper=parsenoop;var parse_StartBlock=parsenoop;var parse_EndBlock=parsenoop;var parse_StartObject=parsenoop;var parse_EndObject=parsenoop;var parse_CatLab=parsenoop;var parse_YMult=parsenoop;var parse_SXViewLink=parsenoop;var parse_PivotChartBits=parsenoop;var parse_FrtFontList=parsenoop;var parse_SheetExt=parsenoop;var parse_BookExt=parsenoop;var parse_SXAddl=parsenoop;var parse_CrErr=parsenoop;var parse_HFPicture=parsenoop;var parse_Feat=parsenoop;var parse_DataLabExt=parsenoop;var parse_DataLabExtContents=parsenoop;var parse_CellWatch=parsenoop;var parse_FeatHdr11=parsenoop;var parse_Feature11=parsenoop;var parse_DropDownObjIds=parsenoop;var parse_ContinueFrt11=parsenoop;var parse_DConn=parsenoop;var parse_List12=parsenoop;var parse_Feature12=parsenoop;var parse_CondFmt12=parsenoop;var parse_CF12=parsenoop;var parse_CFEx=parsenoop;var parse_XFCRC=parsenoop;var parse_XFExt=parsenoop;var parse_AutoFilter12=parsenoop;var parse_ContinueFrt12=parsenoop;var parse_MDTInfo=parsenoop;var parse_MDXStr=parsenoop;var parse_MDXTuple=parsenoop;var parse_MDXSet=parsenoop;var parse_MDXProp=parsenoop;var parse_MDXKPI=parsenoop;var parse_MDB=parsenoop;var parse_PLV=parsenoop;var parse_DXF=parsenoop;var parse_TableStyles=parsenoop;var parse_TableStyle=parsenoop;var parse_TableStyleElement=parsenoop;var parse_StyleExt=parsenoop;var parse_NamePublish=parsenoop;var parse_NameCmt=parsenoop;var parse_SortData=parsenoop;var parse_Theme=parsenoop;var parse_GUIDTypeLib=parsenoop;var parse_FnGrp12=parsenoop;var parse_NameFnGrp12=parsenoop;var parse_HeaderFooter=parsenoop;var parse_CrtLayout12=parsenoop;var parse_CrtMlFrt=parsenoop;var parse_CrtMlFrtContinue=parsenoop;var parse_ShapePropsStream=parsenoop;var parse_TextPropsStream=parsenoop;var parse_RichTextStream=parsenoop;var parse_CrtLayout12A=parsenoop;var parse_Units=parsenoop;var parse_Chart=parsenoop;var parse_Series=parsenoop;var parse_DataFormat=parsenoop;var parse_LineFormat=parsenoop;var parse_MarkerFormat=parsenoop;var parse_AreaFormat=parsenoop;var parse_PieFormat=parsenoop;var parse_AttachedLabel=parsenoop;var parse_SeriesText=parsenoop;var parse_ChartFormat=parsenoop;var parse_Legend=parsenoop;var parse_SeriesList=parsenoop;var parse_Bar=parsenoop;var parse_Line=parsenoop;var parse_Pie=parsenoop;var parse_Area=parsenoop;var parse_Scatter=parsenoop;var parse_CrtLine=parsenoop;var parse_Axis=parsenoop;var parse_Tick=parsenoop;var parse_ValueRange=parsenoop;var parse_CatSerRange=parsenoop;var parse_AxisLine=parsenoop;var parse_CrtLink=parsenoop;var parse_DefaultText=parsenoop;var parse_Text=parsenoop;var parse_ObjectLink=parsenoop;var parse_Frame=parsenoop;var parse_Begin=parsenoop;var parse_End=parsenoop;var parse_PlotArea=parsenoop;var parse_Chart3d=parsenoop;var parse_PicF=parsenoop;var parse_DropBar=parsenoop;var parse_Radar=parsenoop;var parse_Surf=parsenoop;var parse_RadarArea=parsenoop;var parse_AxisParent=parsenoop;var parse_LegendException=parsenoop;var parse_ShtProps=parsenoop;var parse_SerToCrt=parsenoop;var parse_AxesUsed=parsenoop;var parse_SBaseRef=parsenoop;var parse_SerParent=parsenoop;var parse_SerAuxTrend=parsenoop;var parse_IFmtRecord=parsenoop;var parse_Pos=parsenoop;var parse_AlRuns=parsenoop;var parse_BRAI=parsenoop;var parse_SerAuxErrBar=parsenoop;var parse_ClrtClient=parsenoop;var parse_SerFmt=parsenoop;var parse_Chart3DBarShape=parsenoop;var parse_Fbi=parsenoop;var parse_BopPop=parsenoop;var parse_AxcExt=parsenoop;var parse_Dat=parsenoop;var parse_PlotGrowth=parsenoop;var parse_SIIndex=parsenoop;var parse_GelFrame=parsenoop;var parse_BopPopCustom=parsenoop;var parse_Fbi2=parsenoop;function parse_BIFF5String(blob){var len=blob.read_shift(1);return blob.read_shift(len,"sbcs")}var _chr=function(c){return String.fromCharCode(c)};var attregexg=/([\w:]+)=((?:")([^"]*)(?:")|(?:')([^']*)(?:'))/g;var attregex=/([\w:]+)=((?:")(?:[^"]*)(?:")|(?:')(?:[^']*)(?:'))/;function parsexmltag(tag,skip_root){var words=tag.split(/\s+/);var z=[];if(!skip_root)z[0]=words[0];if(words.length===1)return z;var m=tag.match(attregexg),y,j,w,i;if(m)for(i=0;i!=m.length;++i){y=m[i].match(attregex);if((j=y[1].indexOf(":"))===-1)z[y[1]]=y[2].substr(1,y[2].length-2);else{if(y[1].substr(0,6)==="xmlns:")w="xmlns"+y[1].substr(6);else w=y[1].substr(j+1);z[w]=y[2].substr(1,y[2].length-2)}}return z}function parsexmltagobj(tag){var words=tag.split(/\s+/);var z={};if(words.length===1)return z;var m=tag.match(attregexg),y,j,w,i;if(m)for(i=0;i!=m.length;++i){y=m[i].match(attregex);if((j=y[1].indexOf(":"))===-1)z[y[1]]=y[2].substr(1,y[2].length-2);else{if(y[1].substr(0,6)==="xmlns:")w="xmlns"+y[1].substr(6);else w=y[1].substr(j+1);z[w]=y[2].substr(1,y[2].length-2)}}return z}var encodings={""":'"',"'":"'",">":">","<":"<","&":"&"};var rencoding=evert(encodings);var rencstr="&<>'\"".split("");var XML_HEADER='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';var OFFCRYPTO={};var make_offcrypto=function(O,_crypto){var crypto;if(typeof _crypto!=="undefined")crypto=_crypto;else if(typeof require!=="undefined"){try{crypto=require("cry"+"pto")}catch(e){crypto=null}}O.rc4=function(key,data){var S=new Array(256);var c=0,i=0,j=0,t=0;for(i=0;i!=256;++i)S[i]=i;for(i=0;i!=256;++i){j=j+S[i]+key[i%key.length].charCodeAt(0)&255;t=S[i];S[i]=S[j];S[j]=t}i=j=0;out=Buffer(data.length);for(c=0;c!=data.length;++c){i=i+1&255;j=(j+S[i])%256;t=S[i];S[i]=S[j];S[j]=t;out[c]=data[c]^S[S[i]+S[j]&255]}return out};if(crypto){O.md5=function(hex){return crypto.createHash("md5").update(hex).digest("hex")}}else{O.md5=function(hex){throw"unimplemented"}}};make_offcrypto(OFFCRYPTO,typeof crypto!=="undefined"?crypto:undefined);function _JS2ANSI(str){if(typeof cptable!=="undefined")return cptable.utils.encode(1252,str);return str.split("").map(function(x){return x.charCodeAt(0)})}function parse_Version(blob,length){var o={};o.Major=blob.read_shift(2);o.Minor=blob.read_shift(2);return o}function parse_EncryptionHeader(blob,length){var o={};o.Flags=blob.read_shift(4);var tmp=blob.read_shift(4);if(tmp!==0)throw"Unrecognized SizeExtra: "+tmp;o.AlgID=blob.read_shift(4);switch(o.AlgID){case 0:case 26625:case 26126:case 26127:case 26128:break;default:throw"Unrecognized encryption algorithm: "+o.AlgID}parsenoop(blob,length-12);return o}function parse_EncryptionVerifier(blob,length){return parsenoop(blob,length)}function parse_RC4CryptoHeader(blob,length){var o={};var vers=o.EncryptionVersionInfo=parse_Version(blob,4);length-=4;if(vers.Minor!=2)throw"unrecognized minor version code: "+vers.Minor;if(vers.Major>4||vers.Major<2)throw"unrecognized major version code: "+vers.Major;o.Flags=blob.read_shift(4);length-=4;var sz=blob.read_shift(4);length-=4;o.EncryptionHeader=parse_EncryptionHeader(blob,sz);length-=sz;o.EncryptionVerifier=parse_EncryptionVerifier(blob,length);return o}function parse_RC4Header(blob,length){var o={};var vers=o.EncryptionVersionInfo=parse_Version(blob,4);length-=4;if(vers.Major!=1||vers.Minor!=1)throw"unrecognized version code "+vers.Major+" : "+vers.Minor;o.Salt=blob.read_shift(16);o.EncryptedVerifier=blob.read_shift(16);o.EncryptedVerifierHash=blob.read_shift(16);return o}function crypto_CreatePasswordVerifier_Method1(Password){var Verifier=0,PasswordArray;var PasswordDecoded=_JS2ANSI(Password);var len=PasswordDecoded.length+1,i,PasswordByte;var Intermediate1,Intermediate2,Intermediate3;PasswordArray=new_buf(len);PasswordArray[0]=PasswordDecoded.length;for(i=1;i!=len;++i)PasswordArray[i]=PasswordDecoded[i-1];for(i=len-1;i>=0;--i){PasswordByte=PasswordArray[i];Intermediate1=(Verifier&16384)===0?0:1;Intermediate2=Verifier<<1&32767;Intermediate3=Intermediate1|Intermediate2;Verifier=Intermediate3^PasswordByte}return Verifier^52811}var crypto_CreateXorArray_Method1=function(){var PadArray=[187,255,255,186,255,255,185,128,0,190,15,0,191,15,0];var InitialCode=[57840,7439,52380,33984,4364,3600,61902,12606,6258,57657,54287,34041,10252,43370,20163];var XorMatrix=[44796,19929,39858,10053,20106,40212,10761,31585,63170,64933,60267,50935,40399,11199,17763,35526,1453,2906,5812,11624,23248,885,1770,3540,7080,14160,28320,56640,55369,41139,20807,41614,21821,43642,17621,28485,56970,44341,19019,38038,14605,29210,60195,50791,40175,10751,21502,43004,24537,18387,36774,3949,7898,15796,31592,63184,47201,24803,49606,37805,14203,28406,56812,17824,35648,1697,3394,6788,13576,27152,43601,17539,35078,557,1114,2228,4456,30388,60776,51953,34243,7079,14158,28316,14128,28256,56512,43425,17251,34502,7597,13105,26210,52420,35241,883,1766,3532,4129,8258,16516,33032,4657,9314,18628];var Ror=function(Byte){return(Byte/2|Byte*128)&255};var XorRor=function(byte1,byte2){return Ror(byte1^byte2)};var CreateXorKey_Method1=function(Password){var XorKey=InitialCode[Password.length-1];var CurrentElement=104;for(var i=Password.length-1;i>=0;--i){var Char=Password[i];for(var j=0;j!=7;++j){if(Char&64)XorKey^=XorMatrix[CurrentElement];Char*=2;--CurrentElement}}return XorKey};return function(password){var Password=_JS2ANSI(password);var XorKey=CreateXorKey_Method1(Password);var Index=Password.length;var ObfuscationArray=new_buf(16);for(var i=0;i!=16;++i)ObfuscationArray[i]=0;var Temp,PasswordLastChar,PadIndex;if((Index&1)===1){Temp=XorKey>>8;ObfuscationArray[Index]=XorRor(PadArray[0],Temp);--Index;Temp=XorKey&255;PasswordLastChar=Password[Password.length-1];ObfuscationArray[Index]=XorRor(PasswordLastChar,Temp)}while(Index>0){--Index;Temp=XorKey>>8;ObfuscationArray[Index]=XorRor(Password[Index],Temp);--Index;Temp=XorKey&255;ObfuscationArray[Index]=XorRor(Password[Index],Temp)}Index=15;PadIndex=15-Password.length;while(PadIndex>0){Temp=XorKey>>8;ObfuscationArray[Index]=XorRor(PadArray[PadIndex],Temp);--Index;--PadIndex;Temp=XorKey&255;ObfuscationArray[Index]=XorRor(Password[Index],Temp);--Index;--PadIndex}return ObfuscationArray}}();var crypto_DecryptData_Method1=function(password,Data,XorArrayIndex,XorArray,O){if(!O)O=Data;if(!XorArray)XorArray=crypto_CreateXorArray_Method1(password);var Index,Value;for(Index=0;Index!=Data.length;++Index){Value=Data[Index];Value^=XorArray[XorArrayIndex];Value=(Value>>5|Value<<3)&255;O[Index]=Value;++XorArrayIndex}return[O,XorArrayIndex,XorArray]};var crypto_MakeXorDecryptor=function(password){var XorArrayIndex=0,XorArray=crypto_CreateXorArray_Method1(password);return function(Data){var O=crypto_DecryptData_Method1(null,Data,XorArrayIndex,XorArray);XorArrayIndex=O[1];return O[0]}};function parse_XORObfuscation(blob,length,opts,out){var o={key:parseuint16(blob),verificationBytes:parseuint16(blob)};if(opts.password)o.verifier=crypto_CreatePasswordVerifier_Method1(opts.password);out.valid=o.verificationBytes===o.verifier;if(out.valid)out.insitu_decrypt=crypto_MakeXorDecryptor(opts.password);return o}function parse_FilePassHeader(blob,length,oo){var o=oo||{};o.Info=blob.read_shift(2);blob.l-=2;if(o.Info===1)o.Data=parse_RC4Header(blob,length);else o.Data=parse_RC4CryptoHeader(blob,length);return o}function parse_FilePass(blob,length,opts){var o={Type:blob.read_shift(2)};if(o.Type)parse_FilePassHeader(blob,length-2,o);else parse_XORObfuscation(blob,length-2,opts,o);return o}function parseread(l){return function(blob,length){blob.l+=l;return}}function parseread1(blob,length){blob.l+=1;return}function parse_ColRelU(blob,length){var c=blob.read_shift(2);return[c&16383,c>>14&1,c>>15&1]}function parse_RgceArea(blob,length){var r=blob.read_shift(2),R=blob.read_shift(2);var c=parse_ColRelU(blob,2);var C=parse_ColRelU(blob,2);return{s:{r:r,c:c[0],cRel:c[1],rRel:c[2]},e:{r:R,c:C[0],cRel:C[1],rRel:C[2]}}}function parse_RgceAreaRel(blob,length){var r=blob.read_shift(2),R=blob.read_shift(2);var c=parse_ColRelU(blob,2);var C=parse_ColRelU(blob,2);return{s:{r:r,c:c[0],cRel:c[1],rRel:c[2]},e:{r:R,c:C[0],cRel:C[1],rRel:C[2]}}}function parse_RgceLoc(blob,length){var r=blob.read_shift(2);var c=parse_ColRelU(blob,2);return{r:r,c:c[0],cRel:c[1],rRel:c[2]}}function parse_RgceLocRel(blob,length){var r=blob.read_shift(2);var cl=blob.read_shift(2);var cRel=(cl&32768)>>15,rRel=(cl&16384)>>14;cl&=16383;if(cRel!==0)while(cl>=256)cl-=256;return{r:r,c:cl,cRel:cRel,rRel:rRel}}function parse_PtgArea(blob,length){var type=(blob[blob.l++]&96)>>5;var area=parse_RgceArea(blob,8);return[type,area]}function parse_PtgArea3d(blob,length){var type=(blob[blob.l++]&96)>>5;var ixti=blob.read_shift(2);var area=parse_RgceArea(blob,8);return[type,ixti,area]}function parse_PtgAreaErr(blob,length){var type=(blob[blob.l++]&96)>>5;blob.l+=8;return[type]}function parse_PtgAreaErr3d(blob,length){var type=(blob[blob.l++]&96)>>5;var ixti=blob.read_shift(2);blob.l+=8;return[type,ixti]}function parse_PtgAreaN(blob,length){var type=(blob[blob.l++]&96)>>5;var area=parse_RgceAreaRel(blob,8);return[type,area]}function parse_PtgArray(blob,length){var type=(blob[blob.l++]&96)>>5;blob.l+=7;return[type]}function parse_PtgAttrBaxcel(blob,length){var bitSemi=blob[blob.l+1]&1;var bitBaxcel=1;blob.l+=4;return[bitSemi,bitBaxcel]}function parse_PtgAttrChoose(blob,length){blob.l+=2;var offset=blob.read_shift(2);var o=[];for(var i=0;i<=offset;++i)o.push(blob.read_shift(2));return o}function parse_PtgAttrGoto(blob,length){var bitGoto=blob[blob.l+1]&255?1:0;blob.l+=2;return[bitGoto,blob.read_shift(2)]}function parse_PtgAttrIf(blob,length){var bitIf=blob[blob.l+1]&255?1:0;blob.l+=2;return[bitIf,blob.read_shift(2)]}function parse_PtgAttrSemi(blob,length){var bitSemi=blob[blob.l+1]&255?1:0;blob.l+=4;return[bitSemi]}function parse_PtgAttrSpaceType(blob,length){var type=blob.read_shift(1),cch=blob.read_shift(1);return[type,cch]}function parse_PtgAttrSpace(blob,length){blob.read_shift(2);return parse_PtgAttrSpaceType(blob,2)}function parse_PtgAttrSpaceSemi(blob,length){blob.read_shift(2);return parse_PtgAttrSpaceType(blob,2)}function parse_PtgRef(blob,length){var ptg=blob[blob.l]&31;var type=(blob[blob.l]&96)>>5;blob.l+=1;var loc=parse_RgceLoc(blob,4);return[type,loc]}function parse_PtgRefN(blob,length){var ptg=blob[blob.l]&31;var type=(blob[blob.l]&96)>>5;blob.l+=1;var loc=parse_RgceLocRel(blob,4);return[type,loc]}function parse_PtgRef3d(blob,length){var ptg=blob[blob.l]&31;var type=(blob[blob.l]&96)>>5;blob.l+=1;var ixti=blob.read_shift(2);var loc=parse_RgceLoc(blob,4);return[type,ixti,loc]}function parse_PtgFunc(blob,length){var ptg=blob[blob.l]&31;var type=(blob[blob.l]&96)>>5;blob.l+=1;var iftab=blob.read_shift(2);return[FtabArgc[iftab],Ftab[iftab]]}function parse_PtgFuncVar(blob,length){blob.l++;var cparams=blob.read_shift(1),tab=parsetab(blob);return[cparams,(tab[0]===0?Ftab:Cetab)[tab[1]]]}function parsetab(blob,length){return[blob[blob.l+1]>>7,blob.read_shift(2)&32767]}var parse_PtgAttrSum=parseread(4);var parse_PtgConcat=parseread1;function parse_PtgExp(blob,length){blob.l++;var row=blob.read_shift(2);var col=blob.read_shift(2);return[row,col]}function parse_PtgErr(blob,length){blob.l++;return BERR[blob.read_shift(1)]}function parse_PtgInt(blob,length){blob.l++;return blob.read_shift(2)}function parse_PtgBool(blob,length){blob.l++;return blob.read_shift(1)!==0}function parse_PtgNum(blob,length){blob.l++;return parse_Xnum(blob,8)}function parse_PtgStr(blob,length){blob.l++;return parse_ShortXLUnicodeString(blob)}function parse_SerAr(blob){var val=[];switch(val[0]=blob.read_shift(1)){case 4:val[1]=parsebool(blob,1)?"TRUE":"FALSE";blob.l+=7;break;case 16:val[1]=BERR[blob[blob.l]];blob.l+=8;break;case 0:blob.l+=8;break;case 1:val[1]=parse_Xnum(blob,8);break;case 2:val[1]=parse_XLUnicodeString(blob);break}return val}function parse_PtgExtraMem(blob,cce){var count=blob.read_shift(2);var out=[];for(var i=0;i!=count;++i)out.push(parse_Ref8U(blob,8));return out}function parse_PtgExtraArray(blob){var cols=1+blob.read_shift(1);var rows=1+blob.read_shift(2);for(var i=0,o=[];i!=rows&&(o[i]=[]);++i)for(var j=0;j!=cols;++j)o[i][j]=parse_SerAr(blob);return o}function parse_PtgName(blob,length){var type=blob.read_shift(1)>>>5&3;var nameindex=blob.read_shift(4);return[type,0,nameindex]}function parse_PtgNameX(blob,length){var type=blob.read_shift(1)>>>5&3;var ixti=blob.read_shift(2);var nameindex=blob.read_shift(4);return[type,ixti,nameindex]}function parse_PtgMemArea(blob,length){var type=blob.read_shift(1)>>>5&3;blob.l+=4;var cce=blob.read_shift(2);return[type,cce]}function parse_PtgMemFunc(blob,length){var type=blob.read_shift(1)>>>5&3;var cce=blob.read_shift(2);return[type,cce]}function parse_PtgRefErr(blob,length){var type=blob.read_shift(1)>>>5&3;blob.l+=4;return[type]}var parse_PtgAdd=parseread1;var parse_PtgDiv=parseread1;var parse_PtgEq=parseread1;var parse_PtgGe=parseread1;var parse_PtgGt=parseread1;var parse_PtgIsect=parseread1;var parse_PtgLe=parseread1;var parse_PtgLt=parseread1;var parse_PtgMissArg=parseread1;var parse_PtgMul=parseread1;var parse_PtgNe=parseread1;var parse_PtgParen=parseread1;var parse_PtgPercent=parseread1;var parse_PtgPower=parseread1;var parse_PtgRange=parseread1;var parse_PtgSub=parseread1;var parse_PtgUminus=parseread1;var parse_PtgUnion=parseread1;var parse_PtgUplus=parseread1;var parse_PtgMemErr=parsenoop;var parse_PtgMemNoMem=parsenoop;var parse_PtgRefErr3d=parsenoop;var parse_PtgTbl=parsenoop;var PtgTypes={1:{n:"PtgExp",f:parse_PtgExp},2:{n:"PtgTbl",f:parse_PtgTbl},3:{n:"PtgAdd",f:parse_PtgAdd},4:{n:"PtgSub",f:parse_PtgSub},5:{n:"PtgMul",f:parse_PtgMul},6:{n:"PtgDiv",f:parse_PtgDiv},7:{n:"PtgPower",f:parse_PtgPower},8:{n:"PtgConcat",f:parse_PtgConcat},9:{n:"PtgLt",f:parse_PtgLt},10:{n:"PtgLe",f:parse_PtgLe},11:{n:"PtgEq",f:parse_PtgEq},12:{n:"PtgGe",f:parse_PtgGe},13:{n:"PtgGt",f:parse_PtgGt},14:{n:"PtgNe",f:parse_PtgNe},15:{n:"PtgIsect",f:parse_PtgIsect},16:{n:"PtgUnion",f:parse_PtgUnion},17:{n:"PtgRange",f:parse_PtgRange},18:{n:"PtgUplus",f:parse_PtgUplus},19:{n:"PtgUminus",f:parse_PtgUminus},20:{n:"PtgPercent",f:parse_PtgPercent},21:{n:"PtgParen",f:parse_PtgParen},22:{n:"PtgMissArg",f:parse_PtgMissArg},23:{n:"PtgStr",f:parse_PtgStr},28:{n:"PtgErr",f:parse_PtgErr},29:{n:"PtgBool",f:parse_PtgBool},30:{n:"PtgInt",f:parse_PtgInt},31:{n:"PtgNum",f:parse_PtgNum},32:{n:"PtgArray",f:parse_PtgArray},33:{n:"PtgFunc",f:parse_PtgFunc},34:{n:"PtgFuncVar",f:parse_PtgFuncVar},35:{n:"PtgName",f:parse_PtgName},36:{n:"PtgRef",f:parse_PtgRef},37:{n:"PtgArea",f:parse_PtgArea},38:{n:"PtgMemArea",f:parse_PtgMemArea},39:{n:"PtgMemErr",f:parse_PtgMemErr},40:{n:"PtgMemNoMem",f:parse_PtgMemNoMem},41:{n:"PtgMemFunc",f:parse_PtgMemFunc},42:{n:"PtgRefErr",f:parse_PtgRefErr},43:{n:"PtgAreaErr",f:parse_PtgAreaErr},44:{n:"PtgRefN",f:parse_PtgRefN},45:{n:"PtgAreaN",f:parse_PtgAreaN},57:{n:"PtgNameX",f:parse_PtgNameX},58:{n:"PtgRef3d",f:parse_PtgRef3d},59:{n:"PtgArea3d",f:parse_PtgArea3d},60:{n:"PtgRefErr3d",f:parse_PtgRefErr3d},61:{n:"PtgAreaErr3d",f:parse_PtgAreaErr3d},255:{}};var PtgDupes={64:32,96:32,65:33,97:33,66:34,98:34,67:35,99:35,68:36,100:36,69:37,101:37,70:38,102:38,71:39,103:39,72:40,104:40,73:41,105:41,74:42,106:42,75:43,107:43,76:44,108:44,77:45,109:45,89:57,121:57,90:58,122:58,91:59,123:59,92:60,124:60,93:61,125:61};(function(){for(var y in PtgDupes)PtgTypes[y]=PtgTypes[PtgDupes[y]]})();var Ptg18={};var Ptg19={1:{n:"PtgAttrSemi",f:parse_PtgAttrSemi},2:{n:"PtgAttrIf",f:parse_PtgAttrIf},4:{n:"PtgAttrChoose",f:parse_PtgAttrChoose},8:{n:"PtgAttrGoto",f:parse_PtgAttrGoto},16:{n:"PtgAttrSum",f:parse_PtgAttrSum},32:{n:"PtgAttrBaxcel",f:parse_PtgAttrBaxcel},64:{n:"PtgAttrSpace",f:parse_PtgAttrSpace},65:{n:"PtgAttrSpaceSemi",f:parse_PtgAttrSpaceSemi},255:{}};var rcregex=/(^|[^A-Za-z])R(\[?)(-?\d+|)\]?C(\[?)(-?\d+|)\]?/g;var rcbase;function rcfunc($$,$1,$2,$3,$4,$5){var R=$3.length>0?parseInt($3,10)|0:0,C=$5.length>0?parseInt($5,10)|0:0;if(C<0&&$4.length===0)C=0;if($4.length>0)C+=rcbase.c;if($2.length>0)R+=rcbase.r;return $1+encode_col(C)+encode_row(R)}function rc_to_a1(fstr,base){rcbase=base;return fstr.replace(rcregex,rcfunc)}function parse_Formula(blob,length,opts){var cell=parse_Cell(blob,6);var val=parse_FormulaValue(blob,8);var flags=blob.read_shift(1);blob.read_shift(1);var chn=blob.read_shift(4);var cbf="";if(opts.biff===5)blob.l+=length-20;else cbf=parse_CellParsedFormula(blob,length-20,opts);return{cell:cell,val:val[0],formula:cbf,shared:flags>>3&1,tt:val[1]}}function parse_FormulaValue(blob){var b;if(__readUInt16LE(blob,blob.l+6)!==65535)return[parse_Xnum(blob),"n"];switch(blob[blob.l]){case 0:blob.l+=8;return["String","s"];case 1:b=blob[blob.l+2]===1;blob.l+=8;return[b,"b"];case 2:b=BERR[blob[blob.l+2]];blob.l+=8;return[b,"e"];case 3:blob.l+=8;return["","s"]}}function parse_RgbExtra(blob,length,rgce,opts){if(opts.biff<8)return parsenoop(blob,length);var target=blob.l+length;var o=[];for(var i=0;i!==rgce.length;++i){switch(rgce[i][0]){case"PtgArray":rgce[i][1]=parse_PtgExtraArray(blob);o.push(rgce[i][1]);break;case"PtgMemArea":rgce[i][2]=parse_PtgExtraMem(blob,rgce[i][1]);o.push(rgce[i][2]);break;default:break}}length=target-blob.l;if(length!==0)o.push(parsenoop(blob,length));return o}function parse_NameParsedFormula(blob,length,opts,cce){var target=blob.l+length;var rgce=parse_Rgce(blob,cce);var rgcb;if(target!==blob.l)rgcb=parse_RgbExtra(blob,target-blob.l,rgce,opts);return[rgce,rgcb]}function parse_CellParsedFormula(blob,length,opts){var target=blob.l+length;var rgcb,cce=blob.read_shift(2);if(cce==65535)return[[],parsenoop(blob,length-2)];var rgce=parse_Rgce(blob,cce);if(length!==cce+2)rgcb=parse_RgbExtra(blob,length-cce-2,rgce,opts);return[rgce,rgcb]}function parse_SharedParsedFormula(blob,length,opts){var target=blob.l+length;var rgcb,cce=blob.read_shift(2);var rgce=parse_Rgce(blob,cce);if(cce==65535)return[[],parsenoop(blob,length-2)];if(length!==cce+2)rgcb=parse_RgbExtra(blob,target-cce-2,rgce,opts);return[rgce,rgcb]}function parse_ArrayParsedFormula(blob,length,opts,ref){var target=blob.l+length;var rgcb,cce=blob.read_shift(2);if(cce==65535)return[[],parsenoop(blob,length-2)];var rgce=parse_Rgce(blob,cce);if(length!==cce+2)rgcb=parse_RgbExtra(blob,target-cce-2,rgce,opts);return[rgce,rgcb]}function parse_Rgce(blob,length){var target=blob.l+length;var R,id,ptgs=[];while(target!=blob.l){length=target-blob.l;id=blob[blob.l];R=PtgTypes[id];if(id===24||id===25){id=blob[blob.l+1];R=(id===24?Ptg18:Ptg19)[id]}if(!R||!R.f){ptgs.push(parsenoop(blob,length))}else{ptgs.push([R.n,R.f(blob,length)])}}return ptgs}function mapper(x){return x.map(function f2(y){return y[1]}).join(",")}function stringify_formula(formula,range,cell,supbooks,opts){if(opts!==undefined&&opts.biff===5)return"BIFF5??";var _range=range!==undefined?range:{s:{c:0,r:0}};var stack=[],e1,e2,type,c,ixti,nameidx,r;if(!formula[0]||!formula[0][0])return"";for(var ff=0,fflen=formula[0].length;ff<fflen;++ff){var f=formula[0][ff];switch(f[0]){case"PtgUminus":stack.push("-"+stack.pop());break;case"PtgUplus":stack.push("+"+stack.pop());break;case"PtgPercent":stack.push(stack.pop()+"%");break;case"PtgAdd":e1=stack.pop();e2=stack.pop();stack.push(e2+"+"+e1);break;case"PtgSub":e1=stack.pop();e2=stack.pop();stack.push(e2+"-"+e1);break;case"PtgMul":e1=stack.pop();e2=stack.pop();stack.push(e2+"*"+e1);break;case"PtgDiv":e1=stack.pop();e2=stack.pop();stack.push(e2+"/"+e1);break;case"PtgPower":e1=stack.pop();e2=stack.pop();stack.push(e2+"^"+e1);break;case"PtgConcat":e1=stack.pop();e2=stack.pop();stack.push(e2+"&"+e1);break;case"PtgLt":e1=stack.pop();e2=stack.pop();stack.push(e2+"<"+e1);break;case"PtgLe":e1=stack.pop();e2=stack.pop();stack.push(e2+"<="+e1);break;case"PtgEq":e1=stack.pop();e2=stack.pop();stack.push(e2+"="+e1);break;case"PtgGe":e1=stack.pop();e2=stack.pop();stack.push(e2+">="+e1);break;case"PtgGt":e1=stack.pop();e2=stack.pop();stack.push(e2+">"+e1);break;case"PtgNe":e1=stack.pop();e2=stack.pop();stack.push(e2+"<>"+e1);break;case"PtgIsect":e1=stack.pop();e2=stack.pop();stack.push(e2+" "+e1);break;case"PtgUnion":e1=stack.pop();e2=stack.pop();stack.push(e2+","+e1);break;case"PtgRange":break;case"PtgAttrChoose":break;case"PtgAttrGoto":break;case"PtgAttrIf":break;case"PtgRef":type=f[1][0];c=shift_cell(decode_cell(encode_cell(f[1][1])),_range);stack.push(encode_cell(c));break;case"PtgRefN":type=f[1][0];c=shift_cell(decode_cell(encode_cell(f[1][1])),cell);stack.push(encode_cell(c));break;case"PtgRef3d":type=f[1][0];ixti=f[1][1];c=shift_cell(f[1][2],_range);stack.push(supbooks[1][ixti+1]+"!"+encode_cell(c));break;case"PtgFunc":case"PtgFuncVar":var argc=f[1][0],func=f[1][1];if(!argc)argc=0;var args=stack.slice(-argc);stack.length-=argc;if(func==="User")func=args.shift();stack.push(func+"("+args.join(",")+")");break;case"PtgBool":stack.push(f[1]?"TRUE":"FALSE");break;case"PtgInt":stack.push(f[1]);break;case"PtgNum":stack.push(String(f[1]));break;case"PtgStr":stack.push('"'+f[1]+'"');break;case"PtgErr":stack.push(f[1]);break;case"PtgArea":type=f[1][0];r=shift_range(f[1][1],_range);stack.push(encode_range(r));break;case"PtgArea3d":type=f[1][0];ixti=f[1][1];r=f[1][2];stack.push(supbooks[1][ixti+1]+"!"+encode_range(r));break;case"PtgAttrSum":stack.push("SUM("+stack.pop()+")");break;case"PtgAttrSemi":break;case"PtgName":nameidx=f[1][2];var lbl=supbooks[0][nameidx];var name=lbl.Name;if(name in XLSXFutureFunctions)name=XLSXFutureFunctions[name];stack.push(name);break;case"PtgNameX":var bookidx=f[1][1];nameidx=f[1][2];var externbook;if(supbooks[bookidx+1])externbook=supbooks[bookidx+1][nameidx];else if(supbooks[bookidx-1])externbook=supbooks[bookidx-1][nameidx];if(!externbook)externbook={body:"??NAMEX??"};stack.push(externbook.body);break;case"PtgParen":stack.push("("+stack.pop()+")");break;case"PtgRefErr":stack.push("#REF!");break;case"PtgExp":c={c:f[1][1],r:f[1][0]};var q={c:cell.c,r:cell.r};if(supbooks.sharedf[encode_cell(c)]){var parsedf=supbooks.sharedf[encode_cell(c)];stack.push(stringify_formula(parsedf,_range,q,supbooks,opts))}else{var fnd=false;for(e1=0;e1!=supbooks.arrayf.length;++e1){e2=supbooks.arrayf[e1];if(c.c<e2[0].s.c||c.c>e2[0].e.c)continue;if(c.r<e2[0].s.r||c.r>e2[0].e.r)continue;stack.push(stringify_formula(e2[1],_range,q,supbooks,opts))}if(!fnd)stack.push(f[1])}break;case"PtgArray":stack.push("{"+f[1].map(mapper).join(";")+"}");break;case"PtgMemArea":break;case"PtgAttrSpace":break;case"PtgTbl":break;case"PtgMemErr":break;case"PtgMissArg":stack.push("");break;case"PtgAreaErr":break;case"PtgAreaN":stack.push("");break;case"PtgRefErr3d":break;case"PtgMemFunc":break;default:throw"Unrecognized Formula Token: "+f}}return stack[0]}var PtgDataType={1:"REFERENCE",2:"VALUE",3:"ARRAY"};var BERR={0:"#NULL!",7:"#DIV/0!",15:"#VALUE!",23:"#REF!",29:"#NAME?",36:"#NUM!",42:"#N/A",43:"#GETTING_DATA",255:"#WTF?"};var Cetab={0:"BEEP",1:"OPEN",2:"OPEN.LINKS",3:"CLOSE.ALL",4:"SAVE",5:"SAVE.AS",6:"FILE.DELETE",7:"PAGE.SETUP",8:"PRINT",9:"PRINTER.SETUP",10:"QUIT",11:"NEW.WINDOW",12:"ARRANGE.ALL",13:"WINDOW.SIZE",14:"WINDOW.MOVE",15:"FULL",16:"CLOSE",17:"RUN",22:"SET.PRINT.AREA",23:"SET.PRINT.TITLES",24:"SET.PAGE.BREAK",25:"REMOVE.PAGE.BREAK",26:"FONT",27:"DISPLAY",28:"PROTECT.DOCUMENT",29:"PRECISION",30:"A1.R1C1",31:"CALCULATE.NOW",32:"CALCULATION",34:"DATA.FIND",35:"EXTRACT",36:"DATA.DELETE",37:"SET.DATABASE",38:"SET.CRITERIA",39:"SORT",40:"DATA.SERIES",41:"TABLE",42:"FORMAT.NUMBER",43:"ALIGNMENT",44:"STYLE",45:"BORDER",46:"CELL.PROTECTION",47:"COLUMN.WIDTH",48:"UNDO",49:"CUT",50:"COPY",51:"PASTE",52:"CLEAR",53:"PASTE.SPECIAL",54:"EDIT.DELETE",55:"INSERT",56:"FILL.RIGHT",57:"FILL.DOWN",61:"DEFINE.NAME",62:"CREATE.NAMES",63:"FORMULA.GOTO",64:"FORMULA.FIND",65:"SELECT.LAST.CELL",66:"SHOW.ACTIVE.CELL",67:"GALLERY.AREA",68:"GALLERY.BAR",69:"GALLERY.COLUMN",70:"GALLERY.LINE",71:"GALLERY.PIE",72:"GALLERY.SCATTER",73:"COMBINATION",74:"PREFERRED",75:"ADD.OVERLAY",76:"GRIDLINES",77:"SET.PREFERRED",78:"AXES",79:"LEGEND",80:"ATTACH.TEXT",81:"ADD.ARROW",82:"SELECT.CHART",83:"SELECT.PLOT.AREA",84:"PATTERNS",85:"MAIN.CHART",86:"OVERLAY",87:"SCALE",88:"FORMAT.LEGEND",89:"FORMAT.TEXT",90:"EDIT.REPEAT",91:"PARSE",92:"JUSTIFY",93:"HIDE",94:"UNHIDE",95:"WORKSPACE",96:"FORMULA",97:"FORMULA.FILL",98:"FORMULA.ARRAY",99:"DATA.FIND.NEXT",100:"DATA.FIND.PREV",101:"FORMULA.FIND.NEXT",102:"FORMULA.FIND.PREV",103:"ACTIVATE",104:"ACTIVATE.NEXT",105:"ACTIVATE.PREV",106:"UNLOCKED.NEXT",107:"UNLOCKED.PREV",108:"COPY.PICTURE",109:"SELECT",110:"DELETE.NAME",111:"DELETE.FORMAT",112:"VLINE",113:"HLINE",114:"VPAGE",115:"HPAGE",116:"VSCROLL",117:"HSCROLL",118:"ALERT",119:"NEW",120:"CANCEL.COPY",121:"SHOW.CLIPBOARD",122:"MESSAGE",124:"PASTE.LINK",125:"APP.ACTIVATE",126:"DELETE.ARROW",127:"ROW.HEIGHT",128:"FORMAT.MOVE",129:"FORMAT.SIZE",130:"FORMULA.REPLACE",131:"SEND.KEYS",132:"SELECT.SPECIAL",133:"APPLY.NAMES",134:"REPLACE.FONT",135:"FREEZE.PANES",136:"SHOW.INFO",137:"SPLIT",138:"ON.WINDOW",139:"ON.DATA",140:"DISABLE.INPUT",142:"OUTLINE",143:"LIST.NAMES",144:"FILE.CLOSE",145:"SAVE.WORKBOOK",146:"DATA.FORM",147:"COPY.CHART",148:"ON.TIME",149:"WAIT",150:"FORMAT.FONT",151:"FILL.UP",152:"FILL.LEFT",153:"DELETE.OVERLAY",155:"SHORT.MENUS",159:"SET.UPDATE.STATUS",161:"COLOR.PALETTE",162:"DELETE.STYLE",163:"WINDOW.RESTORE",164:"WINDOW.MAXIMIZE",166:"CHANGE.LINK",167:"CALCULATE.DOCUMENT",168:"ON.KEY",169:"APP.RESTORE",170:"APP.MOVE",171:"APP.SIZE",172:"APP.MINIMIZE",173:"APP.MAXIMIZE",174:"BRING.TO.FRONT",175:"SEND.TO.BACK",185:"MAIN.CHART.TYPE",186:"OVERLAY.CHART.TYPE",187:"SELECT.END",188:"OPEN.MAIL",189:"SEND.MAIL",190:"STANDARD.FONT",191:"CONSOLIDATE",192:"SORT.SPECIAL",193:"GALLERY.3D.AREA",194:"GALLERY.3D.COLUMN",195:"GALLERY.3D.LINE",196:"GALLERY.3D.PIE",197:"VIEW.3D",198:"GOAL.SEEK",199:"WORKGROUP",200:"FILL.GROUP",201:"UPDATE.LINK",202:"PROMOTE",203:"DEMOTE",204:"SHOW.DETAIL",206:"UNGROUP",207:"OBJECT.PROPERTIES",208:"SAVE.NEW.OBJECT",209:"SHARE",210:"SHARE.NAME",211:"DUPLICATE",212:"APPLY.STYLE",213:"ASSIGN.TO.OBJECT",214:"OBJECT.PROTECTION",215:"HIDE.OBJECT",216:"SET.EXTRACT",217:"CREATE.PUBLISHER",218:"SUBSCRIBE.TO",219:"ATTRIBUTES",220:"SHOW.TOOLBAR",222:"PRINT.PREVIEW",223:"EDIT.COLOR",224:"SHOW.LEVELS",225:"FORMAT.MAIN",226:"FORMAT.OVERLAY",227:"ON.RECALC",228:"EDIT.SERIES",229:"DEFINE.STYLE",240:"LINE.PRINT",243:"ENTER.DATA",249:"GALLERY.RADAR",250:"MERGE.STYLES",251:"EDITION.OPTIONS",252:"PASTE.PICTURE",253:"PASTE.PICTURE.LINK",254:"SPELLING",256:"ZOOM",259:"INSERT.OBJECT",260:"WINDOW.MINIMIZE",265:"SOUND.NOTE",266:"SOUND.PLAY",267:"FORMAT.SHAPE",268:"EXTEND.POLYGON",269:"FORMAT.AUTO",272:"GALLERY.3D.BAR",273:"GALLERY.3D.SURFACE",274:"FILL.AUTO",276:"CUSTOMIZE.TOOLBAR",277:"ADD.TOOL",278:"EDIT.OBJECT",279:"ON.DOUBLECLICK",280:"ON.ENTRY",281:"WORKBOOK.ADD",282:"WORKBOOK.MOVE",283:"WORKBOOK.COPY",284:"WORKBOOK.OPTIONS",285:"SAVE.WORKSPACE",288:"CHART.WIZARD",289:"DELETE.TOOL",290:"MOVE.TOOL",291:"WORKBOOK.SELECT",292:"WORKBOOK.ACTIVATE",293:"ASSIGN.TO.TOOL",295:"COPY.TOOL",296:"RESET.TOOL",297:"CONSTRAIN.NUMERIC",298:"PASTE.TOOL",302:"WORKBOOK.NEW",305:"SCENARIO.CELLS",306:"SCENARIO.DELETE",307:"SCENARIO.ADD",308:"SCENARIO.EDIT",309:"SCENARIO.SHOW",310:"SCENARIO.SHOW.NEXT",311:"SCENARIO.SUMMARY",312:"PIVOT.TABLE.WIZARD",313:"PIVOT.FIELD.PROPERTIES",314:"PIVOT.FIELD",315:"PIVOT.ITEM",316:"PIVOT.ADD.FIELDS",318:"OPTIONS.CALCULATION",319:"OPTIONS.EDIT",320:"OPTIONS.VIEW",321:"ADDIN.MANAGER",322:"MENU.EDITOR",323:"ATTACH.TOOLBARS",324:"VBAActivate",325:"OPTIONS.CHART",328:"VBA.INSERT.FILE",330:"VBA.PROCEDURE.DEFINITION",336:"ROUTING.SLIP",338:"ROUTE.DOCUMENT",339:"MAIL.LOGON",342:"INSERT.PICTURE",343:"EDIT.TOOL",344:"GALLERY.DOUGHNUT",350:"CHART.TREND",352:"PIVOT.ITEM.PROPERTIES",354:"WORKBOOK.INSERT",355:"OPTIONS.TRANSITION",356:"OPTIONS.GENERAL",370:"FILTER.ADVANCED",373:"MAIL.ADD.MAILER",374:"MAIL.DELETE.MAILER",375:"MAIL.REPLY",376:"MAIL.REPLY.ALL",377:"MAIL.FORWARD",378:"MAIL.NEXT.LETTER",379:"DATA.LABEL",380:"INSERT.TITLE",381:"FONT.PROPERTIES",382:"MACRO.OPTIONS",383:"WORKBOOK.HIDE",384:"WORKBOOK.UNHIDE",385:"WORKBOOK.DELETE",386:"WORKBOOK.NAME",388:"GALLERY.CUSTOM",390:"ADD.CHART.AUTOFORMAT",391:"DELETE.CHART.AUTOFORMAT",392:"CHART.ADD.DATA",393:"AUTO.OUTLINE",394:"TAB.ORDER",395:"SHOW.DIALOG",396:"SELECT.ALL",397:"UNGROUP.SHEETS",398:"SUBTOTAL.CREATE",399:"SUBTOTAL.REMOVE",400:"RENAME.OBJECT",412:"WORKBOOK.SCROLL",413:"WORKBOOK.NEXT",414:"WORKBOOK.PREV",415:"WORKBOOK.TAB.SPLIT",416:"FULL.SCREEN",417:"WORKBOOK.PROTECT",420:"SCROLLBAR.PROPERTIES",421:"PIVOT.SHOW.PAGES",422:"TEXT.TO.COLUMNS",423:"FORMAT.CHARTTYPE",424:"LINK.FORMAT",425:"TRACER.DISPLAY",430:"TRACER.NAVIGATE",431:"TRACER.CLEAR",432:"TRACER.ERROR",433:"PIVOT.FIELD.GROUP",434:"PIVOT.FIELD.UNGROUP",435:"CHECKBOX.PROPERTIES",436:"LABEL.PROPERTIES",437:"LISTBOX.PROPERTIES",438:"EDITBOX.PROPERTIES",439:"PIVOT.REFRESH",440:"LINK.COMBO",441:"OPEN.TEXT",442:"HIDE.DIALOG",443:"SET.DIALOG.FOCUS",444:"ENABLE.OBJECT",445:"PUSHBUTTON.PROPERTIES",446:"SET.DIALOG.DEFAULT",447:"FILTER",448:"FILTER.SHOW.ALL",449:"CLEAR.OUTLINE",450:"FUNCTION.WIZARD",451:"ADD.LIST.ITEM",452:"SET.LIST.ITEM",453:"REMOVE.LIST.ITEM",454:"SELECT.LIST.ITEM",455:"SET.CONTROL.VALUE",456:"SAVE.COPY.AS",458:"OPTIONS.LISTS.ADD",459:"OPTIONS.LISTS.DELETE",460:"SERIES.AXES",461:"SERIES.X",462:"SERIES.Y",463:"ERRORBAR.X",464:"ERRORBAR.Y",465:"FORMAT.CHART",466:"SERIES.ORDER",467:"MAIL.LOGOFF",468:"CLEAR.ROUTING.SLIP",469:"APP.ACTIVATE.MICROSOFT",470:"MAIL.EDIT.MAILER",471:"ON.SHEET",472:"STANDARD.WIDTH",473:"SCENARIO.MERGE",474:"SUMMARY.INFO",475:"FIND.FILE",476:"ACTIVE.CELL.FONT",477:"ENABLE.TIPWIZARD",478:"VBA.MAKE.ADDIN",480:"INSERTDATATABLE",481:"WORKGROUP.OPTIONS",482:"MAIL.SEND.MAILER",485:"AUTOCORRECT",489:"POST.DOCUMENT",491:"PICKLIST",493:"VIEW.SHOW",494:"VIEW.DEFINE",495:"VIEW.DELETE",509:"SHEET.BACKGROUND",510:"INSERT.MAP.OBJECT",511:"OPTIONS.MENONO",517:"MSOCHECKS",518:"NORMAL",519:"LAYOUT",520:"RM.PRINT.AREA",521:"CLEAR.PRINT.AREA",522:"ADD.PRINT.AREA",523:"MOVE.BRK",545:"HIDECURR.NOTE",546:"HIDEALL.NOTES",547:"DELETE.NOTE",548:"TRAVERSE.NOTES",549:"ACTIVATE.NOTES",620:"PROTECT.REVISIONS",621:"UNPROTECT.REVISIONS",647:"OPTIONS.ME",653:"WEB.PUBLISH",667:"NEWWEBQUERY",673:"PIVOT.TABLE.CHART",753:"OPTIONS.SAVE",755:"OPTIONS.SPELL",808:"HIDEALL.INKANNOTS"}; var Ftab={0:"COUNT",1:"IF",2:"ISNA",3:"ISERROR",4:"SUM",5:"AVERAGE",6:"MIN",7:"MAX",8:"ROW",9:"COLUMN",10:"NA",11:"NPV",12:"STDEV",13:"DOLLAR",14:"FIXED",15:"SIN",16:"COS",17:"TAN",18:"ATAN",19:"PI",20:"SQRT",21:"EXP",22:"LN",23:"LOG10",24:"ABS",25:"INT",26:"SIGN",27:"ROUND",28:"LOOKUP",29:"INDEX",30:"REPT",31:"MID",32:"LEN",33:"VALUE",34:"TRUE",35:"FALSE",36:"AND",37:"OR",38:"NOT",39:"MOD",40:"DCOUNT",41:"DSUM",42:"DAVERAGE",43:"DMIN",44:"DMAX",45:"DSTDEV",46:"VAR",47:"DVAR",48:"TEXT",49:"LINEST",50:"TREND",51:"LOGEST",52:"GROWTH",53:"GOTO",54:"HALT",55:"RETURN",56:"PV",57:"FV",58:"NPER",59:"PMT",60:"RATE",61:"MIRR",62:"IRR",63:"RAND",64:"MATCH",65:"DATE",66:"TIME",67:"DAY",68:"MONTH",69:"YEAR",70:"WEEKDAY",71:"HOUR",72:"MINUTE",73:"SECOND",74:"NOW",75:"AREAS",76:"ROWS",77:"COLUMNS",78:"OFFSET",79:"ABSREF",80:"RELREF",81:"ARGUMENT",82:"SEARCH",83:"TRANSPOSE",84:"ERROR",85:"STEP",86:"TYPE",87:"ECHO",88:"SET.NAME",89:"CALLER",90:"DEREF",91:"WINDOWS",92:"SERIES",93:"DOCUMENTS",94:"ACTIVE.CELL",95:"SELECTION",96:"RESULT",97:"ATAN2",98:"ASIN",99:"ACOS",100:"CHOOSE",101:"HLOOKUP",102:"VLOOKUP",103:"LINKS",104:"INPUT",105:"ISREF",106:"GET.FORMULA",107:"GET.NAME",108:"SET.VALUE",109:"LOG",110:"EXEC",111:"CHAR",112:"LOWER",113:"UPPER",114:"PROPER",115:"LEFT",116:"RIGHT",117:"EXACT",118:"TRIM",119:"REPLACE",120:"SUBSTITUTE",121:"CODE",122:"NAMES",123:"DIRECTORY",124:"FIND",125:"CELL",126:"ISERR",127:"ISTEXT",128:"ISNUMBER",129:"ISBLANK",130:"T",131:"N",132:"FOPEN",133:"FCLOSE",134:"FSIZE",135:"FREADLN",136:"FREAD",137:"FWRITELN",138:"FWRITE",139:"FPOS",140:"DATEVALUE",141:"TIMEVALUE",142:"SLN",143:"SYD",144:"DDB",145:"GET.DEF",146:"REFTEXT",147:"TEXTREF",148:"INDIRECT",149:"REGISTER",150:"CALL",151:"ADD.BAR",152:"ADD.MENU",153:"ADD.COMMAND",154:"ENABLE.COMMAND",155:"CHECK.COMMAND",156:"RENAME.COMMAND",157:"SHOW.BAR",158:"DELETE.MENU",159:"DELETE.COMMAND",160:"GET.CHART.ITEM",161:"DIALOG.BOX",162:"CLEAN",163:"MDETERM",164:"MINVERSE",165:"MMULT",166:"FILES",167:"IPMT",168:"PPMT",169:"COUNTA",170:"CANCEL.KEY",171:"FOR",172:"WHILE",173:"BREAK",174:"NEXT",175:"INITIATE",176:"REQUEST",177:"POKE",178:"EXECUTE",179:"TERMINATE",180:"RESTART",181:"HELP",182:"GET.BAR",183:"PRODUCT",184:"FACT",185:"GET.CELL",186:"GET.WORKSPACE",187:"GET.WINDOW",188:"GET.DOCUMENT",189:"DPRODUCT",190:"ISNONTEXT",191:"GET.NOTE",192:"NOTE",193:"STDEVP",194:"VARP",195:"DSTDEVP",196:"DVARP",197:"TRUNC",198:"ISLOGICAL",199:"DCOUNTA",200:"DELETE.BAR",201:"UNREGISTER",204:"USDOLLAR",205:"FINDB",206:"SEARCHB",207:"REPLACEB",208:"LEFTB",209:"RIGHTB",210:"MIDB",211:"LENB",212:"ROUNDUP",213:"ROUNDDOWN",214:"ASC",215:"DBCS",216:"RANK",219:"ADDRESS",220:"DAYS360",221:"TODAY",222:"VDB",223:"ELSE",224:"ELSE.IF",225:"END.IF",226:"FOR.CELL",227:"MEDIAN",228:"SUMPRODUCT",229:"SINH",230:"COSH",231:"TANH",232:"ASINH",233:"ACOSH",234:"ATANH",235:"DGET",236:"CREATE.OBJECT",237:"VOLATILE",238:"LAST.ERROR",239:"CUSTOM.UNDO",240:"CUSTOM.REPEAT",241:"FORMULA.CONVERT",242:"GET.LINK.INFO",243:"TEXT.BOX",244:"INFO",245:"GROUP",246:"GET.OBJECT",247:"DB",248:"PAUSE",251:"RESUME",252:"FREQUENCY",253:"ADD.TOOLBAR",254:"DELETE.TOOLBAR",255:"User",256:"RESET.TOOLBAR",257:"EVALUATE",258:"GET.TOOLBAR",259:"GET.TOOL",260:"SPELLING.CHECK",261:"ERROR.TYPE",262:"APP.TITLE",263:"WINDOW.TITLE",264:"SAVE.TOOLBAR",265:"ENABLE.TOOL",266:"PRESS.TOOL",267:"REGISTER.ID",268:"GET.WORKBOOK",269:"AVEDEV",270:"BETADIST",271:"GAMMALN",272:"BETAINV",273:"BINOMDIST",274:"CHIDIST",275:"CHIINV",276:"COMBIN",277:"CONFIDENCE",278:"CRITBINOM",279:"EVEN",280:"EXPONDIST",281:"FDIST",282:"FINV",283:"FISHER",284:"FISHERINV",285:"FLOOR",286:"GAMMADIST",287:"GAMMAINV",288:"CEILING",289:"HYPGEOMDIST",290:"LOGNORMDIST",291:"LOGINV",292:"NEGBINOMDIST",293:"NORMDIST",294:"NORMSDIST",295:"NORMINV",296:"NORMSINV",297:"STANDARDIZE",298:"ODD",299:"PERMUT",300:"POISSON",301:"TDIST",302:"WEIBULL",303:"SUMXMY2",304:"SUMX2MY2",305:"SUMX2PY2",306:"CHITEST",307:"CORREL",308:"COVAR",309:"FORECAST",310:"FTEST",311:"INTERCEPT",312:"PEARSON",313:"RSQ",314:"STEYX",315:"SLOPE",316:"TTEST",317:"PROB",318:"DEVSQ",319:"GEOMEAN",320:"HARMEAN",321:"SUMSQ",322:"KURT",323:"SKEW",324:"ZTEST",325:"LARGE",326:"SMALL",327:"QUARTILE",328:"PERCENTILE",329:"PERCENTRANK",330:"MODE",331:"TRIMMEAN",332:"TINV",334:"MOVIE.COMMAND",335:"GET.MOVIE",336:"CONCATENATE",337:"POWER",338:"PIVOT.ADD.DATA",339:"GET.PIVOT.TABLE",340:"GET.PIVOT.FIELD",341:"GET.PIVOT.ITEM",342:"RADIANS",343:"DEGREES",344:"SUBTOTAL",345:"SUMIF",346:"COUNTIF",347:"COUNTBLANK",348:"SCENARIO.GET",349:"OPTIONS.LISTS.GET",350:"ISPMT",351:"DATEDIF",352:"DATESTRING",353:"NUMBERSTRING",354:"ROMAN",355:"OPEN.DIALOG",356:"SAVE.DIALOG",357:"VIEW.GET",358:"GETPIVOTDATA",359:"HYPERLINK",360:"PHONETIC",361:"AVERAGEA",362:"MAXA",363:"MINA",364:"STDEVPA",365:"VARPA",366:"STDEVA",367:"VARA",368:"BAHTTEXT",369:"THAIDAYOFWEEK",370:"THAIDIGIT",371:"THAIMONTHOFYEAR",372:"THAINUMSOUND",373:"THAINUMSTRING",374:"THAISTRINGLENGTH",375:"ISTHAIDIGIT",376:"ROUNDBAHTDOWN",377:"ROUNDBAHTUP",378:"THAIYEAR",379:"RTD"};var FtabArgc={2:1,3:1,15:1,16:1,17:1,18:1,20:1,21:1,22:1,23:1,24:1,25:1,26:1,27:2,30:2,31:3,32:1,33:1,38:1,39:2,40:3,41:3,42:3,43:3,44:3,45:3,47:3,48:2,53:1,61:3,65:3,66:3,67:1,68:1,69:1,71:1,72:1,73:1,75:1,76:1,77:1,79:2,80:2,83:1,86:1,90:1,97:2,98:1,99:1,105:1,111:1,112:1,113:1,114:1,117:2,118:1,119:4,121:1,126:1,127:1,128:1,129:1,130:1,131:1,133:1,134:1,135:1,136:2,137:2,138:2,140:1,141:1,142:3,143:4,162:1,163:1,164:1,165:2,172:1,175:2,176:2,177:3,178:2,179:1,184:1,189:3,190:1,195:3,196:3,198:1,199:3,201:1,207:4,210:3,211:1,212:2,213:2,214:1,215:1,229:1,230:1,231:1,232:1,233:1,234:1,235:3,244:1,252:2,257:1,261:1,271:1,273:4,274:2,275:2,276:2,277:3,278:3,279:1,280:3,281:3,282:3,283:1,284:1,285:2,286:4,287:3,288:2,289:4,290:3,291:3,292:3,293:4,294:1,295:3,296:1,297:3,298:1,299:2,300:3,301:3,302:4,303:2,304:2,305:2,306:2,307:2,308:2,309:3,310:2,311:2,312:2,313:2,314:2,315:2,316:4,325:2,326:2,327:2,328:2,331:2,332:2,337:2,342:1,343:1,346:2,347:1,350:4,351:3,352:1,353:2,360:1,368:1,369:1,370:1,371:1,372:1,373:1,374:1,375:1,376:1,377:1,378:1,65535:0};var XLSXFutureFunctions={"_xlfn.ACOT":"ACOT","_xlfn.ACOTH":"ACOTH","_xlfn.AGGREGATE":"AGGREGATE","_xlfn.ARABIC":"ARABIC","_xlfn.AVERAGEIF":"AVERAGEIF","_xlfn.AVERAGEIFS":"AVERAGEIFS","_xlfn.BASE":"BASE","_xlfn.BETA.DIST":"BETA.DIST","_xlfn.BETA.INV":"BETA.INV","_xlfn.BINOM.DIST":"BINOM.DIST","_xlfn.BINOM.DIST.RANGE":"BINOM.DIST.RANGE","_xlfn.BINOM.INV":"BINOM.INV","_xlfn.BITAND":"BITAND","_xlfn.BITLSHIFT":"BITLSHIFT","_xlfn.BITOR":"BITOR","_xlfn.BITRSHIFT":"BITRSHIFT","_xlfn.BITXOR":"BITXOR","_xlfn.CEILING.MATH":"CEILING.MATH","_xlfn.CEILING.PRECISE":"CEILING.PRECISE","_xlfn.CHISQ.DIST":"CHISQ.DIST","_xlfn.CHISQ.DIST.RT":"CHISQ.DIST.RT","_xlfn.CHISQ.INV":"CHISQ.INV","_xlfn.CHISQ.INV.RT":"CHISQ.INV.RT","_xlfn.CHISQ.TEST":"CHISQ.TEST","_xlfn.COMBINA":"COMBINA","_xlfn.CONFIDENCE.NORM":"CONFIDENCE.NORM","_xlfn.CONFIDENCE.T":"CONFIDENCE.T","_xlfn.COT":"COT","_xlfn.COTH":"COTH","_xlfn.COUNTIFS":"COUNTIFS","_xlfn.COVARIANCE.P":"COVARIANCE.P","_xlfn.COVARIANCE.S":"COVARIANCE.S","_xlfn.CSC":"CSC","_xlfn.CSCH":"CSCH","_xlfn.DAYS":"DAYS","_xlfn.DECIMAL":"DECIMAL","_xlfn.ECMA.CEILING":"ECMA.CEILING","_xlfn.ERF.PRECISE":"ERF.PRECISE","_xlfn.ERFC.PRECISE":"ERFC.PRECISE","_xlfn.EXPON.DIST":"EXPON.DIST","_xlfn.F.DIST":"F.DIST","_xlfn.F.DIST.RT":"F.DIST.RT","_xlfn.F.INV":"F.INV","_xlfn.F.INV.RT":"F.INV.RT","_xlfn.F.TEST":"F.TEST","_xlfn.FILTERXML":"FILTERXML","_xlfn.FLOOR.MATH":"FLOOR.MATH","_xlfn.FLOOR.PRECISE":"FLOOR.PRECISE","_xlfn.FORMULATEXT":"FORMULATEXT","_xlfn.GAMMA":"GAMMA","_xlfn.GAMMA.DIST":"GAMMA.DIST","_xlfn.GAMMA.INV":"GAMMA.INV","_xlfn.GAMMALN.PRECISE":"GAMMALN.PRECISE","_xlfn.GAUSS":"GAUSS","_xlfn.HYPGEOM.DIST":"HYPGEOM.DIST","_xlfn.IFNA":"IFNA","_xlfn.IFERROR":"IFERROR","_xlfn.IMCOSH":"IMCOSH","_xlfn.IMCOT":"IMCOT","_xlfn.IMCSC":"IMCSC","_xlfn.IMCSCH":"IMCSCH","_xlfn.IMSEC":"IMSEC","_xlfn.IMSECH":"IMSECH","_xlfn.IMSINH":"IMSINH","_xlfn.IMTAN":"IMTAN","_xlfn.ISFORMULA":"ISFORMULA","_xlfn.ISO.CEILING":"ISO.CEILING","_xlfn.ISOWEEKNUM":"ISOWEEKNUM","_xlfn.LOGNORM.DIST":"LOGNORM.DIST","_xlfn.LOGNORM.INV":"LOGNORM.INV","_xlfn.MODE.MULT":"MODE.MULT","_xlfn.MODE.SNGL":"MODE.SNGL","_xlfn.MUNIT":"MUNIT","_xlfn.NEGBINOM.DIST":"NEGBINOM.DIST","_xlfn.NETWORKDAYS.INTL":"NETWORKDAYS.INTL","_xlfn.NIGBINOM":"NIGBINOM","_xlfn.NORM.DIST":"NORM.DIST","_xlfn.NORM.INV":"NORM.INV","_xlfn.NORM.S.DIST":"NORM.S.DIST","_xlfn.NORM.S.INV":"NORM.S.INV","_xlfn.NUMBERVALUE":"NUMBERVALUE","_xlfn.PDURATION":"PDURATION","_xlfn.PERCENTILE.EXC":"PERCENTILE.EXC","_xlfn.PERCENTILE.INC":"PERCENTILE.INC","_xlfn.PERCENTRANK.EXC":"PERCENTRANK.EXC","_xlfn.PERCENTRANK.INC":"PERCENTRANK.INC","_xlfn.PERMUTATIONA":"PERMUTATIONA","_xlfn.PHI":"PHI","_xlfn.POISSON.DIST":"POISSON.DIST","_xlfn.QUARTILE.EXC":"QUARTILE.EXC","_xlfn.QUARTILE.INC":"QUARTILE.INC","_xlfn.QUERYSTRING":"QUERYSTRING","_xlfn.RANK.AVG":"RANK.AVG","_xlfn.RANK.EQ":"RANK.EQ","_xlfn.RRI":"RRI","_xlfn.SEC":"SEC","_xlfn.SECH":"SECH","_xlfn.SHEET":"SHEET","_xlfn.SHEETS":"SHEETS","_xlfn.SKEW.P":"SKEW.P","_xlfn.STDEV.P":"STDEV.P","_xlfn.STDEV.S":"STDEV.S","_xlfn.SUMIFS":"SUMIFS","_xlfn.T.DIST":"T.DIST","_xlfn.T.DIST.2T":"T.DIST.2T","_xlfn.T.DIST.RT":"T.DIST.RT","_xlfn.T.INV":"T.INV","_xlfn.T.INV.2T":"T.INV.2T","_xlfn.T.TEST":"T.TEST","_xlfn.UNICHAR":"UNICHAR","_xlfn.UNICODE":"UNICODE","_xlfn.VAR.P":"VAR.P","_xlfn.VAR.S":"VAR.S","_xlfn.WEBSERVICE":"WEBSERVICE","_xlfn.WEIBULL.DIST":"WEIBULL.DIST","_xlfn.WORKDAY.INTL":"WORKDAY.INTL","_xlfn.XOR":"XOR","_xlfn.Z.TEST":"Z.TEST"};var RecordEnum={6:{n:"Formula",f:parse_Formula},10:{n:"EOF",f:parse_EOF},12:{n:"CalcCount",f:parse_CalcCount},13:{n:"CalcMode",f:parse_CalcMode},14:{n:"CalcPrecision",f:parse_CalcPrecision},15:{n:"CalcRefMode",f:parse_CalcRefMode},16:{n:"CalcDelta",f:parse_CalcDelta},17:{n:"CalcIter",f:parse_CalcIter},18:{n:"Protect",f:parse_Protect},19:{n:"Password",f:parse_Password},20:{n:"Header",f:parse_Header},21:{n:"Footer",f:parse_Footer},23:{n:"ExternSheet",f:parse_ExternSheet},24:{n:"Lbl",f:parse_Lbl},25:{n:"WinProtect",f:parse_WinProtect},26:{n:"VerticalPageBreaks",f:parse_VerticalPageBreaks},27:{n:"HorizontalPageBreaks",f:parse_HorizontalPageBreaks},28:{n:"Note",f:parse_Note},29:{n:"Selection",f:parse_Selection},34:{n:"Date1904",f:parse_Date1904},35:{n:"ExternName",f:parse_ExternName},38:{n:"LeftMargin",f:parse_LeftMargin},39:{n:"RightMargin",f:parse_RightMargin},40:{n:"TopMargin",f:parse_TopMargin},41:{n:"BottomMargin",f:parse_BottomMargin},42:{n:"PrintRowCol",f:parse_PrintRowCol},43:{n:"PrintGrid",f:parse_PrintGrid},47:{n:"FilePass",f:parse_FilePass},49:{n:"Font",f:parse_Font},51:{n:"PrintSize",f:parse_PrintSize},60:{n:"Continue",f:parse_Continue},61:{n:"Window1",f:parse_Window1},64:{n:"Backup",f:parse_Backup},65:{n:"Pane",f:parse_Pane},66:{n:"CodePage",f:parse_CodePage},77:{n:"Pls",f:parse_Pls},80:{n:"DCon",f:parse_DCon},81:{n:"DConRef",f:parse_DConRef},82:{n:"DConName",f:parse_DConName},85:{n:"DefColWidth",f:parse_DefColWidth},89:{n:"XCT",f:parse_XCT},90:{n:"CRN",f:parse_CRN},91:{n:"FileSharing",f:parse_FileSharing},92:{n:"WriteAccess",f:parse_WriteAccess},93:{n:"Obj",f:parse_Obj},94:{n:"Uncalced",f:parse_Uncalced},95:{n:"CalcSaveRecalc",f:parse_CalcSaveRecalc},96:{n:"Template",f:parse_Template},97:{n:"Intl",f:parse_Intl},99:{n:"ObjProtect",f:parse_ObjProtect},125:{n:"ColInfo",f:parse_ColInfo},128:{n:"Guts",f:parse_Guts},129:{n:"WsBool",f:parse_WsBool},130:{n:"GridSet",f:parse_GridSet},131:{n:"HCenter",f:parse_HCenter},132:{n:"VCenter",f:parse_VCenter},133:{n:"BoundSheet8",f:parse_BoundSheet8},134:{n:"WriteProtect",f:parse_WriteProtect},140:{n:"Country",f:parse_Country},141:{n:"HideObj",f:parse_HideObj},144:{n:"Sort",f:parse_Sort},146:{n:"Palette",f:parse_Palette},151:{n:"Sync",f:parse_Sync},152:{n:"LPr",f:parse_LPr},153:{n:"DxGCol",f:parse_DxGCol},154:{n:"FnGroupName",f:parse_FnGroupName},155:{n:"FilterMode",f:parse_FilterMode},156:{n:"BuiltInFnGroupCount",f:parse_BuiltInFnGroupCount},157:{n:"AutoFilterInfo",f:parse_AutoFilterInfo},158:{n:"AutoFilter",f:parse_AutoFilter},160:{n:"Scl",f:parse_Scl},161:{n:"Setup",f:parse_Setup},174:{n:"ScenMan",f:parse_ScenMan},175:{n:"SCENARIO",f:parse_SCENARIO},176:{n:"SxView",f:parse_SxView},177:{n:"Sxvd",f:parse_Sxvd},178:{n:"SXVI",f:parse_SXVI},180:{n:"SxIvd",f:parse_SxIvd},181:{n:"SXLI",f:parse_SXLI},182:{n:"SXPI",f:parse_SXPI},184:{n:"DocRoute",f:parse_DocRoute},185:{n:"RecipName",f:parse_RecipName},189:{n:"MulRk",f:parse_MulRk},190:{n:"MulBlank",f:parse_MulBlank},193:{n:"Mms",f:parse_Mms},197:{n:"SXDI",f:parse_SXDI},198:{n:"SXDB",f:parse_SXDB},199:{n:"SXFDB",f:parse_SXFDB},200:{n:"SXDBB",f:parse_SXDBB},201:{n:"SXNum",f:parse_SXNum},202:{n:"SxBool",f:parse_SxBool},203:{n:"SxErr",f:parse_SxErr},204:{n:"SXInt",f:parse_SXInt},205:{n:"SXString",f:parse_SXString},206:{n:"SXDtr",f:parse_SXDtr},207:{n:"SxNil",f:parse_SxNil},208:{n:"SXTbl",f:parse_SXTbl},209:{n:"SXTBRGIITM",f:parse_SXTBRGIITM},210:{n:"SxTbpg",f:parse_SxTbpg},211:{n:"ObProj",f:parse_ObProj},213:{n:"SXStreamID",f:parse_SXStreamID},215:{n:"DBCell",f:parse_DBCell},216:{n:"SXRng",f:parse_SXRng},217:{n:"SxIsxoper",f:parse_SxIsxoper},218:{n:"BookBool",f:parse_BookBool},220:{n:"DbOrParamQry",f:parse_DbOrParamQry},221:{n:"ScenarioProtect",f:parse_ScenarioProtect},222:{n:"OleObjectSize",f:parse_OleObjectSize},224:{n:"XF",f:parse_XF},225:{n:"InterfaceHdr",f:parse_InterfaceHdr},226:{n:"InterfaceEnd",f:parse_InterfaceEnd},227:{n:"SXVS",f:parse_SXVS},229:{n:"MergeCells",f:parse_MergeCells},233:{n:"BkHim",f:parse_BkHim},235:{n:"MsoDrawingGroup",f:parse_MsoDrawingGroup},236:{n:"MsoDrawing",f:parse_MsoDrawing},237:{n:"MsoDrawingSelection",f:parse_MsoDrawingSelection},239:{n:"PhoneticInfo",f:parse_PhoneticInfo},240:{n:"SxRule",f:parse_SxRule},241:{n:"SXEx",f:parse_SXEx},242:{n:"SxFilt",f:parse_SxFilt},244:{n:"SxDXF",f:parse_SxDXF},245:{n:"SxItm",f:parse_SxItm},246:{n:"SxName",f:parse_SxName},247:{n:"SxSelect",f:parse_SxSelect},248:{n:"SXPair",f:parse_SXPair},249:{n:"SxFmla",f:parse_SxFmla},251:{n:"SxFormat",f:parse_SxFormat},252:{n:"SST",f:parse_SST},253:{n:"LabelSst",f:parse_LabelSst},255:{n:"ExtSST",f:parse_ExtSST},256:{n:"SXVDEx",f:parse_SXVDEx},259:{n:"SXFormula",f:parse_SXFormula},290:{n:"SXDBEx",f:parse_SXDBEx},311:{n:"RRDInsDel",f:parse_RRDInsDel},312:{n:"RRDHead",f:parse_RRDHead},315:{n:"RRDChgCell",f:parse_RRDChgCell},317:{n:"RRTabId",f:parse_RRTabId},318:{n:"RRDRenSheet",f:parse_RRDRenSheet},319:{n:"RRSort",f:parse_RRSort},320:{n:"RRDMove",f:parse_RRDMove},330:{n:"RRFormat",f:parse_RRFormat},331:{n:"RRAutoFmt",f:parse_RRAutoFmt},333:{n:"RRInsertSh",f:parse_RRInsertSh},334:{n:"RRDMoveBegin",f:parse_RRDMoveBegin},335:{n:"RRDMoveEnd",f:parse_RRDMoveEnd},336:{n:"RRDInsDelBegin",f:parse_RRDInsDelBegin},337:{n:"RRDInsDelEnd",f:parse_RRDInsDelEnd},338:{n:"RRDConflict",f:parse_RRDConflict},339:{n:"RRDDefName",f:parse_RRDDefName},340:{n:"RRDRstEtxp",f:parse_RRDRstEtxp},351:{n:"LRng",f:parse_LRng},352:{n:"UsesELFs",f:parse_UsesELFs},353:{n:"DSF",f:parse_DSF},401:{n:"CUsr",f:parse_CUsr},402:{n:"CbUsr",f:parse_CbUsr},403:{n:"UsrInfo",f:parse_UsrInfo},404:{n:"UsrExcl",f:parse_UsrExcl},405:{n:"FileLock",f:parse_FileLock},406:{n:"RRDInfo",f:parse_RRDInfo},407:{n:"BCUsrs",f:parse_BCUsrs},408:{n:"UsrChk",f:parse_UsrChk},425:{n:"UserBView",f:parse_UserBView},426:{n:"UserSViewBegin",f:parse_UserSViewBegin},427:{n:"UserSViewEnd",f:parse_UserSViewEnd},428:{n:"RRDUserView",f:parse_RRDUserView},429:{n:"Qsi",f:parse_Qsi},430:{n:"SupBook",f:parse_SupBook},431:{n:"Prot4Rev",f:parse_Prot4Rev},432:{n:"CondFmt",f:parse_CondFmt},433:{n:"CF",f:parse_CF},434:{n:"DVal",f:parse_DVal},437:{n:"DConBin",f:parse_DConBin},438:{n:"TxO",f:parse_TxO},439:{n:"RefreshAll",f:parse_RefreshAll},440:{n:"HLink",f:parse_HLink},441:{n:"Lel",f:parse_Lel},442:{n:"CodeName",f:parse_CodeName},443:{n:"SXFDBType",f:parse_SXFDBType},444:{n:"Prot4RevPass",f:parse_Prot4RevPass},445:{n:"ObNoMacros",f:parse_ObNoMacros},446:{n:"Dv",f:parse_Dv},448:{n:"Excel9File",f:parse_Excel9File},449:{n:"RecalcId",f:parse_RecalcId,r:2},450:{n:"EntExU2",f:parse_EntExU2},512:{n:"Dimensions",f:parse_Dimensions},513:{n:"Blank",f:parse_Blank},515:{n:"Number",f:parse_Number},516:{n:"Label",f:parse_Label},517:{n:"BoolErr",f:parse_BoolErr},519:{n:"String",f:parse_String},520:{n:"Row",f:parse_Row},523:{n:"Index",f:parse_Index},545:{n:"Array",f:parse_Array},549:{n:"DefaultRowHeight",f:parse_DefaultRowHeight},566:{n:"Table",f:parse_Table},574:{n:"Window2",f:parse_Window2},638:{n:"RK",f:parse_RK},659:{n:"Style",f:parse_Style},1048:{n:"BigName",f:parse_BigName},1054:{n:"Format",f:parse_Format},1084:{n:"ContinueBigName",f:parse_ContinueBigName},1212:{n:"ShrFmla",f:parse_ShrFmla},2048:{n:"HLinkTooltip",f:parse_HLinkTooltip},2049:{n:"WebPub",f:parse_WebPub},2050:{n:"QsiSXTag",f:parse_QsiSXTag},2051:{n:"DBQueryExt",f:parse_DBQueryExt},2052:{n:"ExtString",f:parse_ExtString},2053:{n:"TxtQry",f:parse_TxtQry},2054:{n:"Qsir",f:parse_Qsir},2055:{n:"Qsif",f:parse_Qsif},2056:{n:"RRDTQSIF",f:parse_RRDTQSIF},2057:{n:"BOF",f:parse_BOF},2058:{n:"OleDbConn",f:parse_OleDbConn},2059:{n:"WOpt",f:parse_WOpt},2060:{n:"SXViewEx",f:parse_SXViewEx},2061:{n:"SXTH",f:parse_SXTH},2062:{n:"SXPIEx",f:parse_SXPIEx},2063:{n:"SXVDTEx",f:parse_SXVDTEx},2064:{n:"SXViewEx9",f:parse_SXViewEx9},2066:{n:"ContinueFrt",f:parse_ContinueFrt},2067:{n:"RealTimeData",f:parse_RealTimeData},2128:{n:"ChartFrtInfo",f:parse_ChartFrtInfo},2129:{n:"FrtWrapper",f:parse_FrtWrapper},2130:{n:"StartBlock",f:parse_StartBlock},2131:{n:"EndBlock",f:parse_EndBlock},2132:{n:"StartObject",f:parse_StartObject},2133:{n:"EndObject",f:parse_EndObject},2134:{n:"CatLab",f:parse_CatLab},2135:{n:"YMult",f:parse_YMult},2136:{n:"SXViewLink",f:parse_SXViewLink},2137:{n:"PivotChartBits",f:parse_PivotChartBits},2138:{n:"FrtFontList",f:parse_FrtFontList},2146:{n:"SheetExt",f:parse_SheetExt},2147:{n:"BookExt",f:parse_BookExt,r:12},2148:{n:"SXAddl",f:parse_SXAddl},2149:{n:"CrErr",f:parse_CrErr},2150:{n:"HFPicture",f:parse_HFPicture},2151:{n:"FeatHdr",f:parse_FeatHdr},2152:{n:"Feat",f:parse_Feat},2154:{n:"DataLabExt",f:parse_DataLabExt},2155:{n:"DataLabExtContents",f:parse_DataLabExtContents},2156:{n:"CellWatch",f:parse_CellWatch},2161:{n:"FeatHdr11",f:parse_FeatHdr11},2162:{n:"Feature11",f:parse_Feature11},2164:{n:"DropDownObjIds",f:parse_DropDownObjIds},2165:{n:"ContinueFrt11",f:parse_ContinueFrt11},2166:{n:"DConn",f:parse_DConn},2167:{n:"List12",f:parse_List12},2168:{n:"Feature12",f:parse_Feature12},2169:{n:"CondFmt12",f:parse_CondFmt12},2170:{n:"CF12",f:parse_CF12},2171:{n:"CFEx",f:parse_CFEx},2172:{n:"XFCRC",f:parse_XFCRC},2173:{n:"XFExt",f:parse_XFExt},2174:{n:"AutoFilter12",f:parse_AutoFilter12},2175:{n:"ContinueFrt12",f:parse_ContinueFrt12},2180:{n:"MDTInfo",f:parse_MDTInfo},2181:{n:"MDXStr",f:parse_MDXStr},2182:{n:"MDXTuple",f:parse_MDXTuple},2183:{n:"MDXSet",f:parse_MDXSet},2184:{n:"MDXProp",f:parse_MDXProp},2185:{n:"MDXKPI",f:parse_MDXKPI},2186:{n:"MDB",f:parse_MDB},2187:{n:"PLV",f:parse_PLV},2188:{n:"Compat12",f:parse_Compat12,r:12},2189:{n:"DXF",f:parse_DXF},2190:{n:"TableStyles",f:parse_TableStyles,r:12},2191:{n:"TableStyle",f:parse_TableStyle},2192:{n:"TableStyleElement",f:parse_TableStyleElement},2194:{n:"StyleExt",f:parse_StyleExt},2195:{n:"NamePublish",f:parse_NamePublish},2196:{n:"NameCmt",f:parse_NameCmt},2197:{n:"SortData",f:parse_SortData},2198:{n:"Theme",f:parse_Theme},2199:{n:"GUIDTypeLib",f:parse_GUIDTypeLib},2200:{n:"FnGrp12",f:parse_FnGrp12},2201:{n:"NameFnGrp12",f:parse_NameFnGrp12},2202:{n:"MTRSettings",f:parse_MTRSettings,r:12},2203:{n:"CompressPictures",f:parse_CompressPictures},2204:{n:"HeaderFooter",f:parse_HeaderFooter},2205:{n:"CrtLayout12",f:parse_CrtLayout12},2206:{n:"CrtMlFrt",f:parse_CrtMlFrt},2207:{n:"CrtMlFrtContinue",f:parse_CrtMlFrtContinue},2211:{n:"ForceFullCalculation",f:parse_ForceFullCalculation},2212:{n:"ShapePropsStream",f:parse_ShapePropsStream},2213:{n:"TextPropsStream",f:parse_TextPropsStream},2214:{n:"RichTextStream",f:parse_RichTextStream},2215:{n:"CrtLayout12A",f:parse_CrtLayout12A},4097:{n:"Units",f:parse_Units},4098:{n:"Chart",f:parse_Chart},4099:{n:"Series",f:parse_Series},4102:{n:"DataFormat",f:parse_DataFormat},4103:{n:"LineFormat",f:parse_LineFormat},4105:{n:"MarkerFormat",f:parse_MarkerFormat},4106:{n:"AreaFormat",f:parse_AreaFormat},4107:{n:"PieFormat",f:parse_PieFormat},4108:{n:"AttachedLabel",f:parse_AttachedLabel},4109:{n:"SeriesText",f:parse_SeriesText},4116:{n:"ChartFormat",f:parse_ChartFormat},4117:{n:"Legend",f:parse_Legend},4118:{n:"SeriesList",f:parse_SeriesList},4119:{n:"Bar",f:parse_Bar},4120:{n:"Line",f:parse_Line},4121:{n:"Pie",f:parse_Pie},4122:{n:"Area",f:parse_Area},4123:{n:"Scatter",f:parse_Scatter},4124:{n:"CrtLine",f:parse_CrtLine},4125:{n:"Axis",f:parse_Axis},4126:{n:"Tick",f:parse_Tick},4127:{n:"ValueRange",f:parse_ValueRange},4128:{n:"CatSerRange",f:parse_CatSerRange},4129:{n:"AxisLine",f:parse_AxisLine},4130:{n:"CrtLink",f:parse_CrtLink},4132:{n:"DefaultText",f:parse_DefaultText},4133:{n:"Text",f:parse_Text},4134:{n:"FontX",f:parse_FontX},4135:{n:"ObjectLink",f:parse_ObjectLink},4146:{n:"Frame",f:parse_Frame},4147:{n:"Begin",f:parse_Begin},4148:{n:"End",f:parse_End},4149:{n:"PlotArea",f:parse_PlotArea},4154:{n:"Chart3d",f:parse_Chart3d},4156:{n:"PicF",f:parse_PicF},4157:{n:"DropBar",f:parse_DropBar},4158:{n:"Radar",f:parse_Radar},4159:{n:"Surf",f:parse_Surf},4160:{n:"RadarArea",f:parse_RadarArea},4161:{n:"AxisParent",f:parse_AxisParent},4163:{n:"LegendException",f:parse_LegendException},4164:{n:"ShtProps",f:parse_ShtProps},4165:{n:"SerToCrt",f:parse_SerToCrt},4166:{n:"AxesUsed",f:parse_AxesUsed},4168:{n:"SBaseRef",f:parse_SBaseRef},4170:{n:"SerParent",f:parse_SerParent},4171:{n:"SerAuxTrend",f:parse_SerAuxTrend},4174:{n:"IFmtRecord",f:parse_IFmtRecord},4175:{n:"Pos",f:parse_Pos},4176:{n:"AlRuns",f:parse_AlRuns},4177:{n:"BRAI",f:parse_BRAI},4187:{n:"SerAuxErrBar",f:parse_SerAuxErrBar},4188:{n:"ClrtClient",f:parse_ClrtClient},4189:{n:"SerFmt",f:parse_SerFmt},4191:{n:"Chart3DBarShape",f:parse_Chart3DBarShape},4192:{n:"Fbi",f:parse_Fbi},4193:{n:"BopPop",f:parse_BopPop},4194:{n:"AxcExt",f:parse_AxcExt},4195:{n:"Dat",f:parse_Dat},4196:{n:"PlotGrowth",f:parse_PlotGrowth},4197:{n:"SIIndex",f:parse_SIIndex},4198:{n:"GelFrame",f:parse_GelFrame},4199:{n:"BopPopCustom",f:parse_BopPopCustom},4200:{n:"Fbi2",f:parse_Fbi2},22:{n:"ExternCount",f:parsenoop},126:{n:"RK",f:parsenoop},127:{n:"ImData",f:parsenoop},135:{n:"Addin",f:parsenoop},136:{n:"Edg",f:parsenoop},137:{n:"Pub",f:parsenoop},145:{n:"Sub",f:parsenoop},148:{n:"LHRecord",f:parsenoop},149:{n:"LHNGraph",f:parsenoop},150:{n:"Sound",f:parsenoop},169:{n:"CoordList",f:parsenoop},171:{n:"GCW",f:parsenoop},188:{n:"ShrFmla",f:parsenoop},194:{n:"AddMenu",f:parsenoop},195:{n:"DelMenu",f:parsenoop},214:{n:"RString",f:parsenoop},223:{n:"UDDesc",f:parsenoop},234:{n:"TabIdConf",f:parsenoop},354:{n:"XL5Modify",f:parsenoop},421:{n:"FileSharing2",f:parsenoop},536:{n:"Name",f:parsenoop},547:{n:"ExternName",f:parse_ExternName},561:{n:"Font",f:parsenoop},1030:{n:"Formula",f:parse_Formula},2157:{n:"FeatInfo",f:parsenoop},2163:{n:"FeatInfo11",f:parsenoop},2177:{n:"SXAddl12",f:parsenoop},2240:{n:"AutoWebPub",f:parsenoop},2241:{n:"ListObj",f:parsenoop},2242:{n:"ListField",f:parsenoop},2243:{n:"ListDV",f:parsenoop},2244:{n:"ListCondFmt",f:parsenoop},2245:{n:"ListCF",f:parsenoop},2246:{n:"FMQry",f:parsenoop},2247:{n:"FMSQry",f:parsenoop},2248:{n:"PLV",f:parsenoop},2249:{n:"LnExt",f:parsenoop},2250:{n:"MkrExt",f:parsenoop},2251:{n:"CrtCoopt",f:parsenoop},0:{}};var CountryEnum={1:"US",2:"CA",3:"",7:"RU",20:"EG",30:"GR",31:"NL",32:"BE",33:"FR",34:"ES",36:"HU",39:"IT",41:"CH",43:"AT",44:"GB",45:"DK",46:"SE",47:"NO",48:"PL",49:"DE",52:"MX",55:"BR",61:"AU",64:"NZ",66:"TH",81:"JP",82:"KR",84:"VN",86:"CN",90:"TR",105:"JS",213:"DZ",216:"MA",218:"LY",351:"PT",354:"IS",358:"FI",420:"CZ",886:"TW",961:"LB",962:"JO",963:"SY",964:"IQ",965:"KW",966:"SA",971:"AE",972:"IL",974:"QA",981:"IR",65535:"US"};function fix_opts_func(defaults){return function fix_opts(opts){for(var i=0;i!=defaults.length;++i){var d=defaults[i];if(typeof opts[d[0]]==="undefined")opts[d[0]]=d[1];if(d[2]==="n")opts[d[0]]=Number(opts[d[0]])}}}var fixopts=fix_opts_func([["cellNF",false],["cellFormula",true],["sheetRows",0,"n"],["bookSheets",false],["bookProps",false],["bookFiles",false],["password",""],["WTF",false]]);function parse_compobj(obj){var v={};var o=obj.content;var l=28,m;m=__lpstr(o,l);l+=4+__readUInt32LE(o,l);v.UserType=m;m=__readUInt32LE(o,l);l+=4;switch(m){case 0:break;case 4294967295:case 4294967294:l+=4;break;default:if(m>400)throw new Error("Unsupported Clipboard: "+m.toString(16));l+=m}m=__lpstr(o,l);l+=m.length===0?0:5+m.length;v.Reserved1=m;if((m=__readUInt32LE(o,l))!==1907550708)return v;throw"Unsupported Unicode Extension"}function parse_xlscfb(cfb,options){if(!options)options={};fixopts(options);reset_cp();var CompObj=cfb.find("!CompObj");var Summary=cfb.find("!SummaryInformation");var Workbook=cfb.find("/Workbook");if(!Workbook)Workbook=cfb.find("/Book");var CompObjP,SummaryP,WorkbookP;function slurp(R,blob,length,opts){var l=length;var bufs=[];var d=blob.slice(blob.l,blob.l+l);if(opts.enc&&opts.enc.insitu_decrypt)switch(R.n){case"BOF":case"FilePass":case"FileLock":case"InterfaceHdr":case"RRDInfo":case"RRDHead":case"UsrExcl":break;default:if(d.length===0)break;opts.enc.insitu_decrypt(d)}bufs.push(d);blob.l+=l;var next=RecordEnum[__readUInt16LE(blob,blob.l)];while(next!=null&&next.n==="Continue"){l=__readUInt16LE(blob,blob.l+2);bufs.push(blob.slice(blob.l+4,blob.l+4+l));blob.l+=4+l;next=RecordEnum[__readUInt16LE(blob,blob.l)]}var b=bconcat(bufs);prep_blob(b,0);var ll=0;b.lens=[];for(var j=0;j<bufs.length;++j){b.lens.push(ll);ll+=bufs[j].length}return R.f(b,b.length,opts)}function safe_format_xf(p,opts){if(!p.XF)return;try{var fmtid=p.XF.ifmt||0;if(fmtid===0){if(p.t==="n"){if((p.v|0)===p.v)p.w=SSF._general_int(p.v);else p.w=SSF._general_num(p.v)}else p.w=SSF._general(p.v)}else p.w=SSF.format(fmtid,p.v);if(opts.cellNF)p.z=SSF._table[fmtid]}catch(e){if(opts.WTF)throw e}}function make_cell(val,ixfe,t){return{v:val,ixfe:ixfe,t:t}}function parse_workbook(blob,options){var wb={opts:{}};var Sheets={};var out={};var Directory={};var found_sheet=false;var range={};var last_formula=null;var sst=[];var cur_sheet="";var Preamble={};var lastcell,last_cell,cc,cmnt,rng,rngC,rngR;var shared_formulae={};var array_formulae=[];var temp_val;var country;var cell_valid=true;var XFs=[];var addline=function addline(cell,line,options){if(!cell_valid)return;lastcell=cell;last_cell=encode_cell(cell);if(range.s){if(cell.r<range.s.r)range.s.r=cell.r;if(cell.c<range.s.c)range.s.c=cell.c}if(range.e){if(cell.r+1>range.e.r)range.e.r=cell.r+1;if(cell.c+1>range.e.c)range.e.c=cell.c+1}if(options.sheetRows&&lastcell.r>=options.sheetRows)cell_valid=false;else out[last_cell]=line};var opts={enc:false,sbcch:0,snames:[],sharedf:shared_formulae,arrayf:array_formulae,rrtabid:[],lastuser:"",biff:8,codepage:0,winlocked:0,wtf:false};if(options.password)opts.password=options.password;var mergecells=[];var objects=[];var supbooks=[[]];var sbc=0,sbci=0,sbcli=0;supbooks.SheetNames=opts.snames;supbooks.sharedf=opts.sharedf;supbooks.arrayf=opts.arrayf;var last_Rn="";var file_depth=0;while(blob.l<blob.length-1){var s=blob.l;var RecordType=blob.read_shift(2);if(RecordType===0&&last_Rn==="EOF")break;var length=blob.l===blob.length?0:blob.read_shift(2),y;var R=RecordEnum[RecordType];if(R&&R.f){if(options.bookSheets){if(last_Rn==="BoundSheet8"&&R.n!=="BoundSheet8")break}last_Rn=R.n;if(R.r===2||R.r==12){var rt=blob.read_shift(2);length-=2;if(!opts.enc&&rt!==RecordType)throw"rt mismatch";if(R.r==12){blob.l+=10;length-=10}}var val;if(R.n==="EOF")val=R.f(blob,length,opts);else val=slurp(R,blob,length,opts);var Rn=R.n;if(opts.biff===5)switch(Rn){case"Lbl":Rn="Label";break}switch(Rn){case"Date1904":wb.opts.Date1904=val;break;case"WriteProtect":wb.opts.WriteProtect=true;break;case"FilePass":if(!opts.enc)blob.l=0;opts.enc=val;if(opts.WTF)console.error(val);if(!options.password)throw new Error("File is password-protected");if(val.Type!==0)throw new Error("Encryption scheme unsupported");if(!val.valid)throw new Error("Password is incorrect");break;case"WriteAccess":opts.lastuser=val;break;case"FileSharing":break;case"CodePage":if(val===21010)val=1200;opts.codepage=val;set_cp(val);break;case"RRTabId":opts.rrtabid=val;break;case"WinProtect":opts.winlocked=val;break;case"Template":break;case"RefreshAll":wb.opts.RefreshAll=val;break;case"BookBool":break;case"UsesELFs":break;case"MTRSettings":{if(val[0]&&val[1])throw"Unsupported threads: "+val}break;case"CalcCount":wb.opts.CalcCount=val;break;case"CalcDelta":wb.opts.CalcDelta=val;break;case"CalcIter":wb.opts.CalcIter=val;break;case"CalcMode":wb.opts.CalcMode=val;break;case"CalcPrecision":wb.opts.CalcPrecision=val;break;case"CalcSaveRecalc":wb.opts.CalcSaveRecalc=val;break;case"CalcRefMode":opts.CalcRefMode=val;break;case"Uncalced":break;case"ForceFullCalculation":wb.opts.FullCalc=val;break;case"WsBool":break;case"XF":XFs.push(val);break;case"ExtSST":break;case"BookExt":break;case"RichTextStream":break;case"BkHim":break;case"SupBook":supbooks[++sbc]=[val];sbci=0;break;case"ExternName":supbooks[sbc][++sbci]=val;break;case"Index":break;case"Lbl":supbooks[0][++sbcli]=val;break;case"ExternSheet":supbooks[sbc]=supbooks[sbc].concat(val);sbci+=val.length;break;case"Protect":out["!protect"]=val;break;case"Password":if(val!==0&&opts.WTF)console.error("Password verifier: "+val);break;case"Prot4Rev":case"Prot4RevPass":break;case"BoundSheet8":{Directory[val.pos]=val;opts.snames.push(val.name)}break;case"EOF":{if(--file_depth)break;if(range.e){out["!range"]=range;if(range.e.r>0&&range.e.c>0){range.e.r--;range.e.c--;out["!ref"]=encode_range(range);range.e.r++;range.e.c++}if(mergecells.length>0)out["!merges"]=mergecells;if(objects.length>0)out["!objects"]=objects}if(cur_sheet==="")Preamble=out;else Sheets[cur_sheet]=out;out={}}break;case"BOF":{if(val.BIFFVer===1280)opts.biff=5;if(file_depth++)break;cell_valid=true;out={};cur_sheet=(Directory[s]||{name:""}).name;mergecells=[];objects=[]}break;case"Number":{temp_val={ixfe:val.ixfe,XF:XFs[val.ixfe],v:val.val,t:"n"};if(temp_val.XF)safe_format_xf(temp_val,options);addline({c:val.c,r:val.r},temp_val,options)}break;case"BoolErr":{temp_val={ixfe:val.ixfe,XF:XFs[val.ixfe],v:val.val,t:val.t};if(temp_val.XF)safe_format_xf(temp_val,options);addline({c:val.c,r:val.r},temp_val,options)}break;case"RK":{temp_val={ixfe:val.ixfe,XF:XFs[val.ixfe],v:val.rknum,t:"n"};if(temp_val.XF)safe_format_xf(temp_val,options);addline({c:val.c,r:val.r},temp_val,options)}break;case"MulRk":{for(var j=val.c;j<=val.C;++j){var ixfe=val.rkrec[j-val.c][0];temp_val={ixfe:ixfe,XF:XFs[ixfe],v:val.rkrec[j-val.c][1],t:"n"};if(temp_val.XF)safe_format_xf(temp_val,options);addline({c:j,r:val.r},temp_val,options)}}break;case"Formula":{switch(val.val){case"String":last_formula=val;break;case"Array Formula":throw"Array Formula unsupported";default:temp_val={v:val.val,ixfe:val.cell.ixfe,t:val.tt};temp_val.XF=XFs[temp_val.ixfe];if(options.cellFormula)temp_val.f="="+stringify_formula(val.formula,range,val.cell,supbooks,opts);if(temp_val.XF)safe_format_xf(temp_val,options);addline(val.cell,temp_val,options);last_formula=val}}break;case"String":{if(last_formula){last_formula.val=val;temp_val={v:last_formula.val,ixfe:last_formula.cell.ixfe,t:"s"};temp_val.XF=XFs[temp_val.ixfe];if(options.cellFormula)temp_val.f="="+stringify_formula(last_formula.formula,range,last_formula.cell,supbooks,opts);if(temp_val.XF)safe_format_xf(temp_val,options);addline(last_formula.cell,temp_val,options);last_formula=null}}break;case"Array":{array_formulae.push(val)}break;case"ShrFmla":{if(!cell_valid)break;shared_formulae[encode_cell(last_formula.cell)]=val[0]}break;case"LabelSst":temp_val=make_cell(sst[val.isst].t,val.ixfe,"s");temp_val.XF=XFs[temp_val.ixfe];if(temp_val.XF)safe_format_xf(temp_val,options);addline({c:val.c,r:val.r},temp_val,options);break;case"Label":temp_val=make_cell(val.val,val.ixfe,"s");temp_val.XF=XFs[temp_val.ixfe]; if(temp_val.XF)safe_format_xf(temp_val,options);addline({c:val.c,r:val.r},temp_val,options);break;case"Dimensions":{if(file_depth===1)range=val}break;case"SST":{sst=val}break;case"Format":{SSF.load(val[1],val[0])}break;case"MergeCells":mergecells=mergecells.concat(val);break;case"Obj":objects[val.cmo[0]]=opts.lastobj=val;break;case"TxO":opts.lastobj.TxO=val;break;case"HLink":{for(rngR=val[0].s.r;rngR<=val[0].e.r;++rngR)for(rngC=val[0].s.c;rngC<=val[0].e.c;++rngC)if(out[encode_cell({c:rngC,r:rngR})])out[encode_cell({c:rngC,r:rngR})].l=val[1]}break;case"HLinkTooltip":{for(rngR=val[0].s.r;rngR<=val[0].e.r;++rngR)for(rngC=val[0].s.c;rngC<=val[0].e.c;++rngC)if(out[encode_cell({c:rngC,r:rngR})])out[encode_cell({c:rngC,r:rngR})].l.tooltip=val[1]}break;case"Note":{if(opts.biff===5)break;cc=out[encode_cell(val[0])];var noteobj=objects[val[2]];if(!cc)break;if(!cc.c)cc.c=[];cmnt={a:val[1],t:noteobj.TxO.t};cc.c.push(cmnt)}break;case"NameCmt":break;default:switch(R.n){case"Header":break;case"Footer":break;case"HCenter":break;case"VCenter":break;case"Pls":break;case"Setup":break;case"DefColWidth":break;case"GCW":break;case"LHRecord":break;case"ColInfo":break;case"Row":break;case"DBCell":break;case"MulBlank":break;case"EntExU2":break;case"SxView":break;case"Sxvd":break;case"SXVI":break;case"SXVDEx":break;case"SxIvd":break;case"SXDI":break;case"SXLI":break;case"SXEx":break;case"QsiSXTag":break;case"Selection":break;case"Feat":break;case"FeatHdr":case"FeatHdr11":break;case"Feature11":case"Feature12":case"List12":break;case"Blank":break;case"Country":country=val;break;case"RecalcId":break;case"DefaultRowHeight":case"DxGCol":break;case"Fbi":case"Fbi2":case"GelFrame":break;case"Font":break;case"XFCRC":break;case"XFExt":break;case"Style":break;case"StyleExt":break;case"Palette":break;case"ClrtClient":break;case"Theme":break;case"ScenarioProtect":break;case"ObjProtect":break;case"CondFmt12":break;case"Table":break;case"TableStyles":break;case"TableStyle":break;case"TableStyleElement":break;case"SXStreamID":break;case"SXVS":break;case"DConRef":break;case"SXAddl":break;case"DConName":break;case"SXPI":break;case"SxFormat":break;case"SxSelect":break;case"SxRule":break;case"SxFilt":break;case"SxItm":break;case"SxDXF":break;case"ScenMan":break;case"DCon":break;case"CellWatch":break;case"PrintRowCol":break;case"PrintGrid":break;case"PrintSize":break;case"XCT":break;case"CRN":break;case"Scl":{}break;case"SheetExt":{}break;case"SheetExtOptional":{}break;case"ObNoMacros":{}break;case"ObProj":{}break;case"CodeName":{}break;case"GUIDTypeLib":{}break;case"WOpt":break;case"PhoneticInfo":break;case"OleObjectSize":break;case"DXF":case"DXFN":case"DXFN12":case"DXFN12List":case"DXFN12NoCB":break;case"Dv":case"DVal":break;case"BRAI":case"Series":case"SeriesText":break;case"DConn":break;case"DbOrParamQry":break;case"DBQueryExt":break;case"IFmtRecord":break;case"CondFmt":case"CF":case"CF12":case"CFEx":break;case"Excel9File":break;case"Units":break;case"InterfaceHdr":case"Mms":case"InterfaceEnd":case"DSF":case"BuiltInFnGroupCount":case"Window1":case"Window2":case"HideObj":case"GridSet":case"Guts":case"UserBView":case"UserSViewBegin":case"UserSViewEnd":case"Pane":break;default:switch(R.n){case"Dat":case"Begin":case"End":case"StartBlock":case"EndBlock":case"Frame":case"Area":case"Axis":case"AxisLine":case"Tick":break;case"AxesUsed":case"CrtLayout12":case"CrtLayout12A":case"CrtLink":case"CrtLine":case"CrtMlFrt":break;case"LineFormat":case"AreaFormat":case"Chart":case"Chart3d":case"Chart3DBarShape":case"ChartFormat":case"ChartFrtInfo":break;case"PlotArea":case"PlotGrowth":break;case"SeriesList":case"SerParent":case"SerAuxTrend":break;case"DataFormat":case"SerToCrt":case"FontX":break;case"CatSerRange":case"AxcExt":case"SerFmt":break;case"ShtProps":break;case"DefaultText":case"Text":case"CatLab":break;case"DataLabExtContents":break;case"Legend":case"LegendException":break;case"Pie":case"Scatter":break;case"PieFormat":case"MarkerFormat":break;case"StartObject":case"EndObject":break;case"AlRuns":case"ObjectLink":break;case"SIIndex":break;case"AttachedLabel":break;case"Line":case"Bar":break;case"Surf":break;case"AxisParent":break;case"Pos":break;case"ValueRange":break;case"SXViewEx9":break;case"SXViewLink":break;case"PivotChartBits":break;case"SBaseRef":break;case"TextPropsStream":break;case"LnExt":break;case"MkrExt":break;case"CrtCoopt":break;case"Qsi":case"Qsif":case"Qsir":case"QsiSXTag":break;case"TxtQry":break;case"FilterMode":break;case"AutoFilter":case"AutoFilterInfo":break;case"AutoFilter12":break;case"DropDownObjIds":break;case"Sort":break;case"SortData":break;case"ShapePropsStream":break;case"MsoDrawing":case"MsoDrawingGroup":case"MsoDrawingSelection":break;case"ImData":break;case"WebPub":case"AutoWebPub":case"RightMargin":case"LeftMargin":case"TopMargin":case"BottomMargin":case"HeaderFooter":case"HFPicture":case"PLV":case"HorizontalPageBreaks":case"VerticalPageBreaks":case"Backup":case"CompressPictures":case"Compat12":break;case"Continue":case"ContinueFrt12":break;case"ExternCount":break;case"RString":break;case"TabIdConf":case"Radar":case"RadarArea":case"DropBar":case"Intl":case"CoordList":case"SerAuxErrBar":break;default:if(options.WTF)throw"Unrecognized Record "+R.n}}}}else blob.l+=length}var sheetnamesraw=Object.keys(Directory).sort(function(a,b){return Number(a)-Number(b)}).map(function(x){return Directory[x].name});var sheetnames=sheetnamesraw.slice();wb.Directory=sheetnamesraw;wb.SheetNames=sheetnamesraw;if(!options.bookSheets)wb.Sheets=Sheets;wb.Preamble=Preamble;wb.Strings=sst;wb.SSF=SSF.get_table();if(opts.enc)wb.Encryption=opts.enc;wb.Metadata={};if(country!==undefined)wb.Metadata.Country=country;return wb}if(CompObj)CompObjP=parse_compobj(CompObj);if(options.bookProps&&!options.bookSheets)WorkbookP={};else{if(Workbook)WorkbookP=parse_workbook(Workbook.content,options);else throw new Error("Cannot find Workbook stream")}parse_props(cfb);var props={};for(var y in cfb.Summary)props[y]=cfb.Summary[y];for(y in cfb.DocSummary)props[y]=cfb.DocSummary[y];WorkbookP.Props=WorkbookP.Custprops=props;if(options.bookFiles)WorkbookP.cfb=cfb;WorkbookP.CompObjP=CompObjP;return WorkbookP}function parse_props(cfb){var DSI=cfb.find("!DocumentSummaryInformation");if(DSI)try{cfb.DocSummary=parse_PropertySetStream(DSI,DocSummaryPIDDSI)}catch(e){}var SI=cfb.find("!SummaryInformation");if(SI)try{cfb.Summary=parse_PropertySetStream(SI,SummaryPIDSI)}catch(e){}}var encregex=/&[a-z]*;/g,coderegex=/_x([0-9a-fA-F]+)_/g;function coderepl(m,c){return _chr(parseInt(c,16))}function encrepl($$){return encodings[$$]}function unescapexml(s){if(s.indexOf("&")>-1)s=s.replace(encregex,encrepl);return s.indexOf("_")===-1?s:s.replace(coderegex,coderepl)}function parsexmlbool(value,tag){switch(value){case"1":case"true":case"TRUE":return true;default:return false}}function matchtag(f,g){return new RegExp("<"+f+'(?: xml:space="preserve")?>([^☃]*)</'+f+">",(g||"")+"m")}var entregex=/&#(\d+);/g;function entrepl($$,$1){return String.fromCharCode(parseInt($1,10))}function fixstr(str){return str.replace(entregex,entrepl)}var everted_BERR=evert(BERR);var magic_formats={"General Number":"General","General Date":SSF._table[22],"Long Date":"dddd, mmmm dd, yyyy","Medium Date":SSF._table[15],"Short Date":SSF._table[14],"Long Time":SSF._table[19],"Medium Time":SSF._table[18],"Short Time":SSF._table[20],Currency:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',Fixed:SSF._table[2],Standard:SSF._table[4],Percent:SSF._table[10],Scientific:SSF._table[11],"Yes/No":'"Yes";"Yes";"No";@',"True/False":'"True";"True";"False";@',"On/Off":'"Yes";"Yes";"No";@'};function xlml_format(format,value){var fmt=magic_formats[format]||unescapexml(format);if(fmt==="General")return SSF._general(value);return SSF.format(fmt,value)}function xlml_set_prop(Props,tag,val){switch(tag){case"Description":tag="Comments";break}Props[tag]=val}function xlml_set_custprop(Custprops,Rn,cp,val){switch((cp[0].match(/dt:dt="([\w.]+)"/)||["",""])[1]){case"boolean":val=parsexmlbool(val);break;case"i2":case"int":val=parseInt(val,10);break;case"r4":case"float":val=parseFloat(val);break;case"date":case"dateTime.tz":val=new Date(val);break;case"i8":case"string":case"fixed":case"uuid":case"bin.base64":break;default:throw"bad custprop:"+cp[0]}Custprops[unescapexml(Rn[3])]=val}function safe_format_xlml(cell,nf,o){try{if(nf==="General"){if(cell.t==="n"){if((cell.v|0)===cell.v)cell.w=SSF._general_int(cell.v);else cell.w=SSF._general_num(cell.v)}else cell.w=SSF._general(cell.v)}else cell.w=xlml_format(nf||"General",cell.v);if(o.cellNF)cell.z=magic_formats[nf]||nf||"General"}catch(e){if(o.WTF)throw e}}function parse_xlml_data(xml,ss,data,cell,base,styles,csty,o){var nf="General",sid=cell.StyleID;o=o||{};if(sid===undefined&&csty)sid=csty.StyleID;while(styles[sid]!==undefined){if(styles[sid].nf)nf=styles[sid].nf;if(!styles[sid].Parent)break;sid=styles[sid].Parent}switch(data.Type){case"Boolean":cell.t="b";cell.v=parsexmlbool(xml);break;case"String":cell.t="str";cell.r=fixstr(unescapexml(xml));cell.v=xml.indexOf("<")>-1?ss:cell.r;break;case"DateTime":cell.v=(Date.parse(xml)-new Date(Date.UTC(1899,11,30)))/(24*60*60*1e3);if(cell.v!==cell.v)cell.v=unescapexml(xml);else if(cell.v>=1&&cell.v<60)cell.v=cell.v-1;if(!nf||nf=="General")nf="yyyy-mm-dd";case"Number":if(cell.v===undefined)cell.v=+xml;if(!cell.t)cell.t="n";break;case"Error":cell.t="e";cell.v=xml;cell.w=xml;break;default:cell.t="s";cell.v=fixstr(ss);break}if(cell.t!=="e")safe_format_xlml(cell,nf,o);if(o.cellFormula!=null&&cell.Formula){cell.f=rc_to_a1(unescapexml(cell.Formula),base);cell.Formula=undefined}cell.ixfe=cell.StyleID!==undefined?cell.StyleID:"Default"}function xlml_clean_comment(comment){comment.t=comment.v;comment.v=comment.w=comment.ixfe=undefined}function xlml_normalize(d){if(has_buf&&Buffer.isBuffer(d))return d.toString("utf8");if(typeof d==="string")return d;throw"badf"}var xlmlregex=/<(\/?)([a-z0-9]*:|)(\w+)[^>]*>/gm;function parse_xlml_xml(d,opts){var str=xlml_normalize(d);var Rn;var state=[],tmp;var sheets={},sheetnames=[],cursheet={},sheetname="";var table={},cell={},row={},dtag,didx;var c=0,r=0;var refguess={s:{r:1e6,c:1e6},e:{r:0,c:0}};var styles={},stag={};var ss="",fidx=0;var mergecells=[];var Props={},Custprops={},pidx=0,cp={};var comments=[],comment={};var cstys=[],csty;while(Rn=xlmlregex.exec(str))switch(Rn[3]){case"Data":if(state[state.length-1][1])break;if(Rn[1]==="/")parse_xlml_data(str.slice(didx,Rn.index),ss,dtag,state[state.length-1][0]=="Comment"?comment:cell,{c:c,r:r},styles,cstys[c],opts);else{ss="";dtag=parsexmltag(Rn[0]);didx=Rn.index+Rn[0].length}break;case"Cell":if(Rn[1]==="/"){if(comments.length>0)cell.c=comments;if((!opts.sheetRows||opts.sheetRows>r)&&cell.v!==undefined)cursheet[encode_col(c)+encode_row(r)]=cell;if(cell.HRef){cell.l={Target:cell.HRef,tooltip:cell.HRefScreenTip};cell.HRef=cell.HRefScreenTip=undefined}if(cell.MergeAcross||cell.MergeDown){var cc=c+(parseInt(cell.MergeAcross,10)|0);var rr=r+(parseInt(cell.MergeDown,10)|0);mergecells.push({s:{c:c,r:r},e:{c:cc,r:rr}})}++c;if(cell.MergeAcross)c+=+cell.MergeAcross}else{cell=parsexmltagobj(Rn[0]);if(cell.Index)c=+cell.Index-1;if(c<refguess.s.c)refguess.s.c=c;if(c>refguess.e.c)refguess.e.c=c;if(Rn[0].substr(-2)==="/>")++c;comments=[]}break;case"Row":if(Rn[1]==="/"||Rn[0].substr(-2)==="/>"){if(r<refguess.s.r)refguess.s.r=r;if(r>refguess.e.r)refguess.e.r=r;if(Rn[0].substr(-2)==="/>"){row=parsexmltag(Rn[0]);if(row.Index)r=+row.Index-1}c=0;++r}else{row=parsexmltag(Rn[0]);if(row.Index)r=+row.Index-1}break;case"Worksheet":if(Rn[1]==="/"){if((tmp=state.pop())[0]!==Rn[3])throw"Bad state: "+tmp;sheetnames.push(sheetname);if(refguess.s.r<=refguess.e.r&&refguess.s.c<=refguess.e.c)cursheet["!ref"]=encode_range(refguess);if(mergecells.length)cursheet["!merges"]=mergecells;sheets[sheetname]=cursheet}else{refguess={s:{r:1e6,c:1e6},e:{r:0,c:0}};r=c=0;state.push([Rn[3],false]);tmp=parsexmltag(Rn[0]);sheetname=tmp.Name;cursheet={};mergecells=[]}break;case"Table":if(Rn[1]==="/"){if((tmp=state.pop())[0]!==Rn[3])throw"Bad state: "+tmp}else if(Rn[0].slice(-2)=="/>")break;else{table=parsexmltag(Rn[0]);state.push([Rn[3],false]);cstys=[]}break;case"Style":if(Rn[1]==="/")styles[stag.ID]=stag;else stag=parsexmltag(Rn[0]);break;case"NumberFormat":stag.nf=parsexmltag(Rn[0]).Format||"General";break;case"Column":if(state[state.length-1][0]!=="Table")break;csty=parsexmltag(Rn[0]);cstys[csty.Index-1||cstys.length]=csty;for(var i=0;i<+csty.Span;++i)cstys[cstys.length]=csty;break;case"NamedRange":break;case"NamedCell":break;case"B":break;case"I":break;case"U":break;case"S":break;case"Sub":break;case"Sup":break;case"Span":break;case"Border":break;case"Alignment":break;case"Borders":break;case"Font":if(Rn[0].substr(-2)==="/>")break;else if(Rn[1]==="/")ss+=str.slice(fidx,Rn.index);else fidx=Rn.index+Rn[0].length;break;case"Interior":break;case"Protection":break;case"Author":case"Title":case"Description":case"Created":case"Keywords":case"Subject":case"Category":case"Company":case"LastAuthor":case"LastSaved":case"LastPrinted":case"Version":case"Revision":case"TotalTime":case"HyperlinkBase":case"Manager":if(Rn[0].substr(-2)==="/>")break;else if(Rn[1]==="/")xlml_set_prop(Props,Rn[3],str.slice(pidx,Rn.index));else pidx=Rn.index+Rn[0].length;break;case"Paragraphs":break;case"Styles":case"Workbook":if(Rn[1]==="/"){if((tmp=state.pop())[0]!==Rn[3])throw"Bad state: "+tmp}else state.push([Rn[3],false]);break;case"Comment":if(Rn[1]==="/"){if((tmp=state.pop())[0]!==Rn[3])throw"Bad state: "+tmp;xlml_clean_comment(comment);comments.push(comment)}else{state.push([Rn[3],false]);tmp=parsexmltag(Rn[0]);comment={a:tmp.Author}}break;case"Name":break;case"ComponentOptions":case"DocumentProperties":case"CustomDocumentProperties":case"OfficeDocumentSettings":case"PivotTable":case"PivotCache":case"Names":case"MapInfo":case"PageBreaks":case"QueryTable":case"DataValidation":case"AutoFilter":case"Sorting":case"Schema":case"data":case"ConditionalFormatting":case"SmartTagType":case"SmartTags":case"ExcelWorkbook":case"WorkbookOptions":case"WorksheetOptions":if(Rn[1]==="/"){if((tmp=state.pop())[0]!==Rn[3])throw"Bad state: "+tmp}else if(Rn[0].charAt(Rn[0].length-2)!=="/")state.push([Rn[3],true]);break;default:var seen=true;switch(state[state.length-1][0]){case"OfficeDocumentSettings":switch(Rn[3]){case"AllowPNG":break;case"RemovePersonalInformation":break;case"DownloadComponents":break;case"LocationOfComponents":break;case"Colors":break;case"Color":break;case"Index":break;case"RGB":break;case"PixelsPerInch":break;case"TargetScreenSize":break;case"ReadOnlyRecommended":break;default:seen=false}break;case"ComponentOptions":switch(Rn[3]){case"Toolbar":break;case"HideOfficeLogo":break;case"SpreadsheetAutoFit":break;case"Label":break;case"Caption":break;case"MaxHeight":break;case"MaxWidth":break;case"NextSheetNumber":break;default:seen=false}break;case"ExcelWorkbook":switch(Rn[3]){case"WindowHeight":break;case"WindowWidth":break;case"WindowTopX":break;case"WindowTopY":break;case"TabRatio":break;case"ProtectStructure":break;case"ProtectWindows":break;case"ActiveSheet":break;case"DisplayInkNotes":break;case"FirstVisibleSheet":break;case"SupBook":break;case"SheetName":break;case"SheetIndex":break;case"SheetIndexFirst":break;case"SheetIndexLast":break;case"Dll":break;case"AcceptLabelsInFormulas":break;case"DoNotSaveLinkValues":break;case"Date1904":break;case"Iteration":break;case"MaxIterations":break;case"MaxChange":break;case"Path":break;case"Xct":break;case"Count":break;case"SelectedSheets":break;case"Calculation":break;case"Uncalced":break;case"StartupPrompt":break;case"Crn":break;case"ExternName":break;case"Formula":break;case"ColFirst":break;case"ColLast":break;case"WantAdvise":break;case"Boolean":break;case"Error":break;case"Text":break;case"OLE":break;case"NoAutoRecover":break;case"PublishObjects":break;case"DoNotCalculateBeforeSave":break;case"Number":break;case"RefModeR1C1":break;case"EmbedSaveSmartTags":break;default:seen=false}break;case"WorkbookOptions":switch(Rn[3]){case"OWCVersion":break;case"Height":break;case"Width":break;default:seen=false}break;case"WorksheetOptions":switch(Rn[3]){case"Unsynced":break;case"Visible":break;case"Print":break;case"Panes":break;case"Scale":break;case"Pane":break;case"Number":break;case"Layout":break;case"Header":break;case"Footer":break;case"PageSetup":break;case"PageMargins":break;case"Selected":break;case"ProtectObjects":break;case"EnableSelection":break;case"ProtectScenarios":break;case"ValidPrinterInfo":break;case"HorizontalResolution":break;case"VerticalResolution":break;case"NumberofCopies":break;case"ActiveRow":break;case"ActiveCol":break;case"ActivePane":break;case"TopRowVisible":break;case"TopRowBottomPane":break;case"LeftColumnVisible":break;case"LeftColumnRightPane":break;case"FitToPage":break;case"RangeSelection":break;case"PaperSizeIndex":break;case"PageLayoutZoom":break;case"PageBreakZoom":break;case"FilterOn":break;case"DoNotDisplayGridlines":break;case"SplitHorizontal":break;case"SplitVertical":break;case"FreezePanes":break;case"FrozenNoSplit":break;case"FitWidth":break;case"FitHeight":break;case"CommentsLayout":break;case"Zoom":break;case"LeftToRight":break;case"Gridlines":break;case"AllowSort":break;case"AllowFilter":break;case"AllowInsertRows":break;case"AllowDeleteRows":break;case"AllowInsertCols":break;case"AllowDeleteCols":break;case"AllowInsertHyperlinks":break;case"AllowFormatCells":break;case"AllowSizeCols":break;case"AllowSizeRows":break;case"NoSummaryRowsBelowDetail":break;case"TabColorIndex":break;case"DoNotDisplayHeadings":break;case"ShowPageLayoutZoom":break;case"NoSummaryColumnsRightDetail":break;case"BlackAndWhite":break;case"DoNotDisplayZeros":break;case"DisplayPageBreak":break;case"RowColHeadings":break;case"DoNotDisplayOutline":break;case"NoOrientation":break;case"AllowUsePivotTables":break;case"ZeroHeight":break;case"ViewableRange":break;case"Selection":break;case"ProtectContents":break;default:seen=false}break;case"PivotTable":case"PivotCache":switch(Rn[3]){case"ImmediateItemsOnDrop":break;case"ShowPageMultipleItemLabel":break;case"CompactRowIndent":break;case"Location":break;case"PivotField":break;case"Orientation":break;case"LayoutForm":break;case"LayoutSubtotalLocation":break;case"LayoutCompactRow":break;case"Position":break;case"PivotItem":break;case"DataType":break;case"DataField":break;case"SourceName":break;case"ParentField":break;case"PTLineItems":break;case"PTLineItem":break;case"CountOfSameItems":break;case"Item":break;case"ItemType":break;case"PTSource":break;case"CacheIndex":break;case"ConsolidationReference":break;case"FileName":break;case"Reference":break;case"NoColumnGrand":break;case"NoRowGrand":break;case"BlankLineAfterItems":break;case"Hidden":break;case"Subtotal":break;case"BaseField":break;case"MapChildItems":break;case"Function":break;case"RefreshOnFileOpen":break;case"PrintSetTitles":break;case"MergeLabels":break;case"DefaultVersion":break;case"RefreshName":break;case"RefreshDate":break;case"RefreshDateCopy":break;case"VersionLastRefresh":break;case"VersionLastUpdate":break;case"VersionUpdateableMin":break;case"VersionRefreshableMin":break;case"Calculation":break;default:seen=false}break;case"PageBreaks":switch(Rn[3]){case"ColBreaks":break;case"ColBreak":break;case"RowBreaks":break;case"RowBreak":break;case"ColStart":break;case"ColEnd":break;case"RowEnd":break;default:seen=false}break;case"AutoFilter":switch(Rn[3]){case"AutoFilterColumn":break;case"AutoFilterCondition":break;case"AutoFilterAnd":break;case"AutoFilterOr":break;default:seen=false}break;case"QueryTable":switch(Rn[3]){case"Id":break;case"AutoFormatFont":break;case"AutoFormatPattern":break;case"QuerySource":break;case"QueryType":break;case"EnableRedirections":break;case"RefreshedInXl9":break;case"URLString":break;case"HTMLTables":break;case"Connection":break;case"CommandText":break;case"RefreshInfo":break;case"NoTitles":break;case"NextId":break;case"ColumnInfo":break;case"OverwriteCells":break;case"DoNotPromptForFile":break;case"TextWizardSettings":break;case"Source":break;case"Number":break;case"Decimal":break;case"ThousandSeparator":break;case"TrailingMinusNumbers":break;case"FormatSettings":break;case"FieldType":break;case"Delimiters":break;case"Tab":break;case"Comma":break;case"AutoFormatName":break;case"VersionLastEdit":break;case"VersionLastRefresh":break;default:seen=false}break;case"Sorting":case"ConditionalFormatting":case"DataValidation":switch(Rn[3]){case"Range":break;case"Type":break;case"Min":break;case"Max":break;case"Sort":break;case"Descending":break;case"Order":break;case"CaseSensitive":break;case"Value":break;case"ErrorStyle":break;case"ErrorMessage":break;case"ErrorTitle":break;case"CellRangeList":break;case"InputMessage":break;case"InputTitle":break;case"ComboHide":break;case"InputHide":break;case"Condition":break;case"Qualifier":break;case"UseBlank":break;case"Value1":break;case"Value2":break;case"Format":break;default:seen=false}break;case"MapInfo":case"Schema":case"data":switch(Rn[3]){case"Map":break;case"Entry":break;case"Range":break;case"XPath":break;case"Field":break;case"XSDType":break;case"FilterOn":break;case"Aggregate":break;case"ElementType":break;case"AttributeType":break;case"schema":case"element":case"complexType":case"datatype":case"all":case"attribute":case"extends":break;case"row":break;default:seen=false}break;case"SmartTags":break;default:seen=false;break}if(seen)break;if(!state[state.length-1][1])throw"Unrecognized tag: "+Rn[3]+"|"+state.join("|");if(state[state.length-1][0]==="CustomDocumentProperties"){if(Rn[0].substr(-2)==="/>")break;else if(Rn[1]==="/")xlml_set_custprop(Custprops,Rn,cp,str.slice(pidx,Rn.index));else{cp=Rn;pidx=Rn.index+Rn[0].length}break}if(opts.WTF)throw"Unrecognized tag: "+Rn[3]+"|"+state.join("|")}var out={};if(!opts.bookSheets&&!opts.bookProps)out.Sheets=sheets;out.SheetNames=sheetnames;out.SSF=SSF.get_table();out.Props=Props;out.Custprops=Custprops;return out}function parse_xlml(data,opts){fixopts(opts=opts||{});switch(opts.type||"base64"){case"base64":return parse_xlml_xml(Base64.decode(data),opts);case"binary":case"buffer":case"file":return parse_xlml_xml(data,opts);case"array":return parse_xlml_xml(data.map(_chr).join(""),opts)}}function write_xlml(wb,opts){}var fs;if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports){fs=require("fs")}}function firstbyte(f,o){switch((o||{}).type||"base64"){case"buffer":return f[0];case"base64":return Base64.decode(f.substr(0,12)).charCodeAt(0);case"binary":return f.charCodeAt(0);case"array":return f[0];default:throw new Error("Unrecognized type "+o.type)}}function xlsread(f,o){if(!o)o={};if(!o.type)o.type=has_buf&&Buffer.isBuffer(f)?"buffer":"base64";switch(firstbyte(f,o)){case 208:return parse_xlscfb(CFB.read(f,o),o);case 60:return parse_xlml(f,o);default:throw"Unsupported file"}}var readFile=function(f,o){var d=fs.readFileSync(f);if(!o)o={};switch(firstbyte(d,{type:"buffer"})){case 208:return parse_xlscfb(CFB.read(d,{type:"buffer"}),o);case 60:return parse_xlml(d,(o.type="buffer",o));default:throw"Unsupported file"}};function writeSync(wb,opts){var o=opts||{};switch(o.bookType){case"xml":return write_xlml(wb,o);default:throw"unsupported output format "+o.bookType}}function writeFileSync(wb,filename,opts){var o=opts|{};o.type="file";o.file=filename;switch(o.file.substr(-4).toLowerCase()){case".xls":o.bookType="xls";break;case".xml":o.bookType="xml";break}return writeSync(wb,o)}function shift_cell(cell,tgt){if(tgt.s){if(cell.cRel)cell.c+=tgt.s.c;if(cell.rRel)cell.r+=tgt.s.r}else{cell.c+=tgt.c;cell.r+=tgt.r}cell.cRel=cell.rRel=0;while(cell.c>=256)cell.c-=256;while(cell.r>=65536)cell.r-=65536;return cell}function shift_range(cell,range){cell.s=shift_cell(cell.s,range.s);cell.e=shift_cell(cell.e,range.s);return cell}function decode_row(rowstr){return parseInt(unfix_row(rowstr),10)-1}function encode_row(row){return""+(row+1)}function fix_row(cstr){return cstr.replace(/([A-Z]|^)(\d+)$/,"$1$$$2")}function unfix_row(cstr){return cstr.replace(/\$(\d+)$/,"$1")}function decode_col(colstr){var c=unfix_col(colstr),d=0,i=0;for(;i!==c.length;++i)d=26*d+c.charCodeAt(i)-64;return d-1}function encode_col(col){var s="";for(++col;col;col=Math.floor((col-1)/26))s=String.fromCharCode((col-1)%26+65)+s;return s}function fix_col(cstr){return cstr.replace(/^([A-Z])/,"$$$1")}function unfix_col(cstr){return cstr.replace(/^\$([A-Z])/,"$1")}function split_cell(cstr){return cstr.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(",")}function decode_cell(cstr){var splt=split_cell(cstr);return{c:decode_col(splt[0]),r:decode_row(splt[1])}}function encode_cell(cell){return encode_col(cell.c)+encode_row(cell.r)}function fix_cell(cstr){return fix_col(fix_row(cstr))}function unfix_cell(cstr){return unfix_col(unfix_row(cstr))}function decode_range(range){var x=range.split(":").map(decode_cell);return{s:x[0],e:x[x.length-1]}}function encode_range(cs,ce){if(ce===undefined||typeof ce==="number")return encode_range(cs.s,cs.e);if(typeof cs!=="string")cs=encode_cell(cs);if(typeof ce!=="string")ce=encode_cell(ce);return cs==ce?cs:cs+":"+ce}function safe_decode_range(range){var o={s:{c:0,r:0},e:{c:0,r:0}};var idx=0,i=0,cc=0;var len=range.length;for(idx=0;i<len;++i){if((cc=range.charCodeAt(i)-64)<1||cc>26)break;idx=26*idx+cc}o.s.c=--idx;for(idx=0;i<len;++i){if((cc=range.charCodeAt(i)-48)<0||cc>9)break;idx=10*idx+cc}o.s.r=--idx;if(i===len||range.charCodeAt(++i)===58){o.e.c=o.s.c;o.e.r=o.s.r;return o}for(idx=0;i!=len;++i){if((cc=range.charCodeAt(i)-64)<1||cc>26)break;idx=26*idx+cc}o.e.c=--idx;for(idx=0;i!=len;++i){if((cc=range.charCodeAt(i)-48)<0||cc>9)break;idx=10*idx+cc}o.e.r=--idx;return o}function safe_format_cell(cell,v){if(cell.z!==undefined)try{return cell.w=SSF.format(cell.z,v)}catch(e){}if(!cell.XF)return v;try{return cell.w=SSF.format(cell.XF.ifmt||0,v)}catch(e){return""+v}}function format_cell(cell,v){if(cell==null||cell.t==null)return"";if(cell.w!==undefined)return cell.w;if(v===undefined)return safe_format_cell(cell,cell.v);return safe_format_cell(cell,v)}function sheet_to_json(sheet,opts){var val,row,range,header=0,offset=1,r,hdr=[],isempty,R,C,v;var o=opts!=null?opts:{};var raw=o.raw;if(sheet==null||sheet["!ref"]==null)return[];range=o.range!==undefined?o.range:sheet["!ref"];if(o.header===1)header=1;else if(o.header==="A")header=2;else if(Array.isArray(o.header))header=3;switch(typeof range){case"string":r=safe_decode_range(range);break;case"number":r=safe_decode_range(sheet["!ref"]);r.s.r=range;break;default:r=range}if(header>0)offset=0;var rr=encode_row(r.s.r);var cols=new Array(r.e.c-r.s.c+1);var out=new Array(r.e.r-r.s.r-offset+1);var outi=0;for(C=r.s.c;C<=r.e.c;++C){cols[C]=encode_col(C);val=sheet[cols[C]+rr];switch(header){case 1:hdr[C]=C;break;case 2:hdr[C]=cols[C];break;case 3:hdr[C]=o.header[C-r.s.c];break;default:if(val===undefined)continue;hdr[C]=format_cell(val)}}for(R=r.s.r+offset;R<=r.e.r;++R){rr=encode_row(R);isempty=true;row=header===1?[]:Object.create({__rowNum__:R});for(C=r.s.c;C<=r.e.c;++C){val=sheet[cols[C]+rr];if(val===undefined||val.t===undefined)continue;v=val.v;switch(val.t){case"e":continue;case"s":case"str":break;case"b":case"n":break;default:throw"unrecognized type "+val.t}if(v!==undefined){row[hdr[C]]=raw?v:format_cell(val,v);isempty=false}}if(isempty===false)out[outi++]=row}out.length=outi;return out}function sheet_to_row_object_array(sheet,opts){return sheet_to_json(sheet,opts!=null?opts:{})}function sheet_to_csv(sheet,opts){var out="",txt="",qreg=/"/g;var o=opts==null?{}:opts;if(sheet==null||sheet["!ref"]==null)return"";var r=safe_decode_range(sheet["!ref"]);var FS=o.FS!==undefined?o.FS:",",fs=FS.charCodeAt(0);var RS=o.RS!==undefined?o.RS:"\n",rs=RS.charCodeAt(0);var row="",rr="",cols=[];var i=0,cc=0,val;var R=0,C=0;for(C=r.s.c;C<=r.e.c;++C)cols[C]=encode_col(C);for(R=r.s.r;R<=r.e.r;++R){row="";rr=encode_row(R);for(C=r.s.c;C<=r.e.c;++C){val=sheet[cols[C]+rr];txt=val!==undefined?""+format_cell(val):"";for(i=0,cc=0;i!==txt.length;++i)if((cc=txt.charCodeAt(i))===fs||cc===rs||cc===34){txt='"'+txt.replace(qreg,'""')+'"';break}row+=(C===r.s.c?"":FS)+txt}out+=row+RS}return out}var make_csv=sheet_to_csv;function sheet_to_formulae(sheet){var cmds,y="",x,val="";if(sheet==null||sheet["!ref"]==null)return"";var r=safe_decode_range(sheet["!ref"]),rr="",cols=[],C;cmds=new Array((r.e.r-r.s.r+1)*(r.e.c-r.s.c+1));var i=0;for(C=r.s.c;C<=r.e.c;++C)cols[C]=encode_col(C);for(var R=r.s.r;R<=r.e.r;++R){rr=encode_row(R);for(C=r.s.c;C<=r.e.c;++C){y=cols[C]+rr;x=sheet[y];val="";if(x===undefined)continue;if(x.f!=null)val=x.f;else if(x.w!==undefined)val="'"+x.w;else if(x.v===undefined)continue;else val=""+x.v;cmds[i++]=y+"="+val}}cmds.length=i;return cmds}var utils={encode_col:encode_col,encode_row:encode_row,encode_cell:encode_cell,encode_range:encode_range,decode_col:decode_col,decode_row:decode_row,split_cell:split_cell,decode_cell:decode_cell,decode_range:decode_range,format_cell:format_cell,get_formulae:sheet_to_formulae,make_csv:sheet_to_csv,make_json:sheet_to_json,make_formulae:sheet_to_formulae,sheet_to_csv:sheet_to_csv,sheet_to_json:sheet_to_json,sheet_to_formulae:sheet_to_formulae,sheet_to_row_object_array:sheet_to_row_object_array};XLS.parse_xlscfb=parse_xlscfb;XLS.read=xlsread;XLS.readFile=readFile;XLS.utils=utils;XLS.CFB=CFB;XLS.SSF=SSF})(typeof exports!=="undefined"?exports:XLS); -//@ sourceMappingURL=dist/xls.min.map +//# sourceMappingURL=dist/xls.min.map /* xlsx.js (C) 2013-2014 SheetJS -- http://sheetjs.com */ /* vim: set ts=2: */ /*jshint -W041 */ @@ -39097,11 +31858,6 @@ } } -GeoTemConfig.quoteVal = function(val){ - return val.replace(new RegExp('"', 'g'), '%22'); - -} - GeoTemConfig.getIndependentId = function(target){ if( target == 'map' ){ return ++GeoTemConfig.independentMapId; @@ -39342,14 +32098,6 @@ Publisher.Publish('filterData', GeoTemConfig.datasets, null); }; -GeoTemConfig.removeAllDatasets = function() { - - if (GeoTemConfig.datasets.length > 0) { - GeoTemConfig.datasets.splice(0, GeoTemConfig.datasets.length); - Publisher.Publish('filterData', GeoTemConfig.datasets, null); - } -}; - /** * converts the csv-file into json-format * @@ -40041,7 +32789,7 @@ csvContent += "\""+val+"\""; }); //Names according to CSV import definition - csvContent += ",\"Address\",\"Latitude\",\"Longitude\",\"TimeStamp\",\"TimeSpan:begin\",\"TimeSpan:end\""; + csvContent += ",\"Address\",\"Latitude\",\"Longitude\",\"TimeStamp\""; csvContent += "\n"; var isFirstRow = true; @@ -40069,7 +32817,7 @@ } else { csvContent += ","; } - csvContent += "\""+GeoTemConfig.quoteVal(elem.tableContent[val])+"\""; + csvContent += "\""+elem.tableContent[val]+"\""; }); csvContent += ","; @@ -40100,14 +32848,6 @@ csvContent += elem.getDate(0).toISOString(); } csvContent += "\""; - - csvContent += ","; - if (elem.isFuzzyTemporal){ - //TODO: not supported in IE8 switch to moment.js - csvContent += "\""+elem.TimeSpanBegin.format()+"\",\""+elem.TimeSpanEnd.format()+"\""; - } else { - csvContent += "\"\",\"\""; - } }); return(csvContent); @@ -43554,38 +36294,7 @@ } else { return 3; } - }, - - - getConfig : function(inquiringWidget){ - var mapWidget = this; - var config = {}; - - //save widget specific configurations here into the config object - config.mapIndex = this.baselayerIndex; - config.mapCenter = this.openlayersMap.center; - config.mapZoom = this.openlayersMap.zoom; - //send config to iquiring widget - if (typeof inquiringWidget.sendConfig !== "undefined"){ - inquiringWidget.sendConfig({widgetName: "map", 'config': config}); - } - }, - - setConfig : function(configObj){ - var mapWidget = this; - - if (configObj.widgetName === "map"){ - var config = configObj.config; - - //set widgets configuration provided by config - this.setMap(config.mapIndex); - this.gui.mapTypeDropdown.setEntry(config.mapIndex); - - this.openlayersMap.setCenter(config.mapCenter); - this.openlayersMap.zoomTo(config.mapZoom); - } - }, - + } } /* * TimeConfig.js @@ -45425,27 +38134,6 @@ } var tableNameDiv = document.createElement('div'); $(tableNameDiv).append(name); - $(tableNameDiv).dblclick(function() { - var n = $(tableNameDiv).text(); - $(tableNameDiv).empty(); - var nameInput = $('<input type="text" name="nameinput" value="'+n+'" />'); - $(tableNameDiv).append(nameInput); - $(nameInput).focus(); - $(nameInput).focusout(function() { - var newname = $(nameInput).val(); - $(tableNameDiv).empty(); - $(tableNameDiv).append(newname); - dataSet.label = newname; - }); - $(nameInput).keypress(function(event) { - if (event.which == 13) { - var newname = $(nameInput).val(); - $(tableNameDiv).empty(); - $(tableNameDiv).append(newname); - dataSet.label = newname; - } - }); - }); if (typeof dataSet.url !== "undefined"){ var tableLinkDiv = document.createElement('a'); @@ -45795,32 +38483,7 @@ this.tables[this.activeTable].reset(); this.tables[this.activeTable].update(); } - }, - - - getConfig : function(inquiringWidget){ - var tableWidget = this; - var config = {}; - - //save widget specific configurations here into the config object - - //send config to iquiring widget - if (typeof inquiringWidget.sendConfig !== "undefined"){ - inquiringWidget.sendConfig({widgetName: "table", 'config': config}); - } - }, - - setConfig : function(configObj){ - var tableWidget = this; - - if (configObj.widgetName === "table"){ - var config = configObj.config; - - //set widgets configuration provided by config - - } - }, - + } } /* * Table.js @@ -49837,57 +42500,7 @@ handle.x1 = handle.x1 * (zoomFactor/oldZoomFactor); handle.x2 = handle.x2 * (zoomFactor/oldZoomFactor); }); - }, - - getConfig : function(inquiringWidget){ - var fuzzyTimeline = this; - var config = {}; - - //create handle copy - var handleCopy = JSON.parse( JSON.stringify( fuzzyTimeline.handles ) ); - config.handles = handleCopy; - - config.viewMode = fuzzyTimeline.viewMode; - - config.rangeDropdownVal = $(fuzzyTimeline.rangeSlider.rangeDropdown).val(); - config.rangeStartVal = $(fuzzyTimeline.rangeSlider.rangeStart).val(); - - //send config to iquiring widget - if (typeof inquiringWidget.sendConfig !== "undefined"){ - inquiringWidget.sendConfig({widgetName: "fuzzyTimeline", 'config': config}); - } - }, - - setConfig : function(configObj){ - var fuzzyTimeline = this; - - if (configObj.widgetName === "fuzzyTimeline"){ - var config = configObj.config; - - $(fuzzyTimeline.rangeSlider.rangeDropdown).val(config.rangeDropdownVal); - $(fuzzyTimeline.rangeSlider.rangeDropdown).change(); - fuzzyTimeline.switchViewMode(config.viewMode); - - $(fuzzyTimeline.rangeSlider.rangeStart).val(config.rangeStartVal); - $(fuzzyTimeline.rangeSlider.rangeStart).change(); - - //clear handles - fuzzyTimeline.clearHandles(); - - //create handle copy - var handleCopy = JSON.parse( JSON.stringify( config.handles ) ); - fuzzyTimeline.handles = handleCopy; - - // redraw handles - fuzzyTimeline.drawHandles(); - - // select elements - $(fuzzyTimeline.handles).each(function(){ - var handle = this; - fuzzyTimeline.selectByX(handle.x1, handle.x2) - }); - } - }, + } }; /* * Overlayloader.js @@ -51990,72 +44603,6 @@ return elements; }, - - getConfig : function(inquiringWidget){ - var pieChartWidget = this; - var config = {}; - - //save widget specific configurations here into the config object - var pieCharts = []; - for (var i=0; i < pieChartWidget.pieCharts.length; i++){ - pieChart = pieChartWidget.pieCharts[i]; - - if (!pieChart){ - continue; - } - - if (pieChart.selectionFunction.categories){ - pieCharts.push({ - watchColumn:pieChart.watchColumn, - watchedDataset:pieChart.watchedDataset, - type:pieChart.selectionFunction.type, - categories:pieChart.selectionFunction.categories - }); - } else { - pieCharts.push({ - watchColumn:pieChart.watchColumn, - watchedDataset:pieChart.watchedDataset - }); - } - } - - config.pieCharts = pieCharts; - - //send config to iquiring widget - if (typeof inquiringWidget.sendConfig !== "undefined"){ - inquiringWidget.sendConfig({widgetName: "pieChart", 'config': config}); - } - }, - - setConfig : function(configObj){ - var pieChartWidget = this; - - if (configObj.widgetName === "pieChart"){ - var config = configObj.config; - - //remove old piecharts - pieChartWidget.pieCharts = []; - //set widgets configuration provided by config - for (var i=0; i < config.pieCharts.length; i++){ - pieChart = config.pieCharts[i]; - - if (pieChart.type){ - pieChartWidget.addCategorizedPieChart( - pieChart.watchedDataset, - pieChart.watchColumn, - pieChart.type, - pieChart.categories - ); - } else { - pieChartWidget.addPieChart( - pieChart.watchedDataset, - pieChart.watchColumn - ); - } - } - } - }, - }; /* * Storytelling.js @@ -52409,965 +44956,6 @@ }, }; /* -* Storytellingv2.js -* -* Copyright (c) 2013, Sebastian Kruse. All rights reserved. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -* MA 02110-1301 USA -*/ - -/** - * @class Storytellingv2 - * Storytelling Version 2 - * @author Mike Bretschneider (mike.bretschneider@gmx.de) - * - * @param {HTML object} parent div to append the Storytellingv2 widget - */ -function Storytellingv2(parent) { - - this.index; - this.storytellingv2 = this; - - this.parent = parent; - this.options = parent.options; - - this.initialize(); -} - -Storytellingv2.prototype = { - - - deleteAllNodes : function(tree) { - var nodes = tree.jstree().get_children_dom('#'); - nodes.each(function() { - tree.jstree().delete_node(this); - }); - }, - - findNodesByType : function(tree,type, parent) { - if (parent != undefined) { - parent = tree.jstree().get_node(parent); - } else { - parent = tree.jstree().get_node('#'); - } - var nodes = new Array(); - - if (parent.type == type) { - nodes.push(parent); - } - for (var i = 0; i < parent.children_d.length; i++) { - var n = tree.jstree().get_node(parent.children_d[i]); - if (n.type == type) { - nodes.push(n); - } - } - - return nodes; - }, - - - handleFileSelect : function(evt) { - -// var storytellingv2 = this; - - var file = evt.target.files[0]; - var tree = $('#storytellingv2jstree'); - - var reader = new FileReader(); - - var deleteAllNodes = function(tree) { - var nodes = tree.jstree().get_children_dom('#'); - nodes.each(function() { - tree.jstree().delete_node(this); - }); - } - - reader.onload = (function(f) { - return function(e) { - - var treedata = JSON.parse(e.target.result); - deleteAllNodes(tree); - for (var i = 0; i < treedata.length; i++) { - if (treedata[i].type == 'dataset') { - tree.jstree().create_node(treedata[i].parent,treedata[i]); - var n = tree.jstree().get_node(treedata[i].id); - tree.jstree().set_type(n, 'snapshot'); - $('#storytellingv2expert').show(); - $('#storytellingv2simple').hide(); - } else if (treedata[i].type == 'snapshot') { - treedata[i].type = 'dataset'; - tree.jstree().create_node(treedata[i].parent,treedata[i]); - var n = tree.jstree().get_node(treedata[i].id); - tree.jstree().set_type(n, 'snapshot'); - $('#storytellingv2expert').show(); - $('#storytellingv2simple').hide(); - } else { - tree.jstree().create_node(treedata[i].parent,treedata[i]); - } - }; - - } - })(file); - reader.readAsText(file); - }, - - - makeSimple : function(tree) { - var configs = this.findNodesByType(tree,'config'); - var datasets = this.findNodesByType(tree,'dataset'); - for (var i = 0; i < datasets.length; i++) { - tree.jstree().set_type(datasets[i], 'snapshot'); - datasets[i].li_attr.dataset_text = datasets[i].text; - datasets[i].text = datasets[i].li_attr.snapshot_text || datasets[i].text; - } - for (var i = 0; i < configs.length; i++) { - var c = tree.jstree().get_node(configs[i], true); - $(c).hide(); - } - }, - - - - - - - - - defaultSession : function(tree) { - if (tree.jstree().is_leaf('#')) { - tree.jstree().create_node('#', { - 'text' : 'Default Session', - 'type' : 'session', - 'li_attr' : { - 'timestamp' : Date.now(), - 'description' : 'Default Session' - } - }) - }; - - }, - - remove : function() { - }, - - initialize : function() { - }, - - triggerHighlight : function(columnElement) { - }, - - triggerSelection : function(columnElement) { - }, - - deselection : function() { - }, - - filtering : function() { - }, - - inverseFiltering : function() { - }, - - triggerRefining : function() { - }, - - reset : function() { - }, - - show : function() { - }, - - hide : function() { - } -}; -/* -* Storytellingv2Config.js -* -* Copyright (c) 2013, Sebastian Kruse. All rights reserved. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -* MA 02110-1301 USA -*/ - -/** - * @class Storytellingv2Config - * Storytellingv2 Configuration File - * @author Mike Bretschneider (mike.bretschneider@gmx.de) - */ -function Storytellingv2Config(options) { - - this.options = { - dariahStorage : false, - localStorage : true - }; - if ( typeof options != 'undefined') { - $.extend(this.options, options); - } - -}; -/* -* Storytellingv2Gui.js -* -* Copyright (c) 2013, Sebastian Kruse. All rights reserved. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -* MA 02110-1301 USA -*/ - -/** - * @class StorytellingGui - * Storytellingv2 GUI Implementation - * @author Mike Bretschneider (mike.bretschneider@gmx.de) - * - * @param {Storytellingv2Widget} parent Storytellingv2 widget object - * @param {HTML object} div parent div to append the Storytellingv2 gui - * @param {JSON} options Storytellingv2 configuration - */ -function Storytellingv2Gui(storytellingv2, div, options) { - - this.parent = storytellingv2; - var storytellingv2Gui = this; - - storytellingv2Gui.storytellingv2Container = document.createElement('div'); - $(div).append(storytellingv2Gui.storytellingv2Container); - storytellingv2Gui.storytellingv2Container.style.position = 'relative'; -}; - -Storytellingv2Gui.prototype = { - - initGui : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - if (storytellingv2Gui.tree == undefined) { - storytellingv2Gui.initTree(); - } - }, - - initTree : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - $(storytellingv2Gui.storytellingv2Container).empty(); - - storytellingv2Gui.tree = $('<div style="border: 2px solid; padding: 5px; float: left;" id="storytellingv2jstree"><ul></ul></div>'); - storytellingv2Gui.tree.jstree({ - 'core' : { - 'check_callback' : true, - }, - 'plugins' : [ 'dnd', 'types' ], - 'types' : { - '#' : { - valid_children : ['session'] - }, - 'session' : { - valid_children : ['dataset', 'config'] - }, - 'dataset' : { - 'valid_children' : ['config'], - 'icon' : 'lib/jstree/themes/default/dataset.png' - }, - 'snapshot' : { - 'valid_children' : ['config'], - 'icon' : 'lib/jstree/themes/default/snapshot.png' - }, - 'config' : { - 'valid_children' : ['config'], - 'icon' : 'lib/jstree/themes/default/filter.png' - } - } - }); - - storytellingv2Gui.tree.on('open_node.jstree', function(e, data) { - var node = data.node; - if (node.type == 'snapshot') { - storytellingv2Gui.tree.jstree().close_node(node, false); - } - - }); - - storytellingv2Gui.menu = $('<div style="float: left;"></div>'); - storytellingv2Gui.importexportsubmenu = $('<div style="border: 2px solid; margin: 2px; padding: 5px;"></div>'); - - storytellingv2Gui.addImportButton(); - storytellingv2Gui.addExportButton(); - storytellingv2Gui.addResetButton(); - storytellingv2Gui.addExpertButton(); - storytellingv2Gui.addSimpleButton(); - - storytellingv2Gui.simplebutton.hide(); - $(storytellingv2Gui.importexportsubmenu).append(storytellingv2Gui.importbutton); - $(storytellingv2Gui.importexportsubmenu).append(storytellingv2Gui.exportbutton); - $(storytellingv2Gui.importexportsubmenu).append(storytellingv2Gui.resetbutton); - $(storytellingv2Gui.importexportsubmenu).append(storytellingv2Gui.expertbutton); - $(storytellingv2Gui.importexportsubmenu).append(storytellingv2Gui.simplebutton); - $(storytellingv2Gui.importexportsubmenu).append(storytellingv2Gui.importfile); - - storytellingv2Gui.treemanipulationsubmenu = $('<div style="border: 2px solid; margin: 2px; padding: 5px;"></div>'); - - storytellingv2Gui.addNewButton(); - storytellingv2Gui.addSnapshotButton(); - storytellingv2Gui.addRestoreButton(); - storytellingv2Gui.addDeleteButton(); - storytellingv2Gui.addEditButton(); - storytellingv2Gui.addBackwardButton(); - storytellingv2Gui.addForwardButton(); - - $(storytellingv2Gui.treemanipulationsubmenu).append(storytellingv2Gui.newbutton); - $(storytellingv2Gui.treemanipulationsubmenu).append(storytellingv2Gui.snapshotbutton); - $(storytellingv2Gui.treemanipulationsubmenu).append(storytellingv2Gui.restorebutton); - $(storytellingv2Gui.treemanipulationsubmenu).append(storytellingv2Gui.deletebutton); - $(storytellingv2Gui.treemanipulationsubmenu).append(storytellingv2Gui.editbutton); - $(storytellingv2Gui.treemanipulationsubmenu).append(storytellingv2Gui.backwardbutton); - $(storytellingv2Gui.treemanipulationsubmenu).append(storytellingv2Gui.forwardbutton); - - storytellingv2Gui.addMetadata(); - - storytellingv2Gui.newbutton.hide(); - $(storytellingv2Gui.storytellingv2Container).append(storytellingv2Gui.tree); - $(storytellingv2Gui.menu).append(storytellingv2Gui.importexportsubmenu); - $(storytellingv2Gui.menu).append(storytellingv2Gui.treemanipulationsubmenu); - $(storytellingv2Gui.menu).append(storytellingv2Gui.metadata); - $(storytellingv2Gui.storytellingv2Container).append(storytellingv2Gui.menu); - - storytellingv2Gui.tree.hide(); - storytellingv2Gui.metadata.hide(); - - storytellingv2Gui.tree.on('create_node.jstree delete_node.jstree', function(e, data) { - var root = storytellingv2Gui.tree.jstree().get_node('#'); - if (root.children.length > 0) { - storytellingv2Gui.tree.show(); - storytellingv2Gui.metadata.show(); - if (e.type == "create_node") { - storytellingv2Gui.tree.jstree().deselect_all(); - storytellingv2Gui.tree.jstree().select_node(data.node); - } if (e.type == "delete_node") { - storytellingv2Gui.tree.jstree().deselect_all(); - var prev_node = storytellingv2Gui.tree.jstree().get_prev_dom(data.node); - storytellingv2Gui.tree.jstree().select_node(prev_node); - } - } else { - storytellingv2Gui.tree.hide(); - storytellingv2Gui.metadata.hide(); - } - - }); - - if (localStorage.getItem('PLATIN.storytellingv2.last_snapshot')) { - var lastSession = storytellingv2Gui.tree.jstree().create_node('#', { - 'text' : 'Last Session', - 'type' : 'session', - 'li_attr' : { - 'timestamp' : Date.now(), - 'description' : 'Default Session' - } - }); - var nodes = JSON.parse(localStorage.getItem('PLATIN.storytellingv2.last_snapshot')); - var last = storytellingv2Gui.tree.jstree().create_node(lastSession, nodes); - storytellingv2.makeSimple(storytellingv2Gui.tree); - - } - - }, - - addImportButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.importbutton = $('<input type="button" id="storytellingv2import" name="import" value="import" />'); - storytellingv2Gui.importfile = $('<input type="file" id="storytellingv2importfile" accept="application/json" style="display: block; visibility:hidden; width: 0; height: 0" />'); - storytellingv2Gui.importfile.change(storytellingv2.handleFileSelect); - - storytellingv2Gui.importbutton.click($.proxy(function() { - storytellingv2Gui.importfile.click(); - })); - - }, - - addExportButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.exportbutton = $('<input type="button" id="storytellingv2export" name="export" value="export" />'); - var dialog = $('<div id="tree-export-filename" title="Save File As?"><p><input type="text" size="25" /></p></div>'); - storytellingv2Gui.exportbutton.append(dialog); - dialog.dialog({ - resizable: false, - autoOpen: false, - height: 220, - modal: true, - buttons: { - 'Ok': function() { - $(this).dialog("close"); - }, - Cancel: function() { - $(this).dialog("close"); - } - } - }); - storytellingv2Gui.exportbutton.click($.proxy(function() { - var tree_as_json = JSON.stringify($('#storytellingv2jstree').jstree(true).get_json('#', { 'flat': true })); - var exportdate = new Date().toUTCString(); - - dialog.dialog('open'); - $(dialog).find(':input').val("Storytelling State(" + exportdate + ").json"); - dialog.dialog('option', 'buttons', { - 'Ok': function() { - var blob = new Blob([tree_as_json], {type: "text/plain;charset=utf-8"}); - saveAs(blob, dialog.find(':input').val()); - $(this).dialog("close"); - }, - Cancel: function() { - $(this).dialog("close"); - } - }) -// var blob = new Blob([tree_as_json], {type: "text/plain;charset=utf-8"}); -// saveAs(blob, "Storytelling State(" + exportdate + ").json"); - - /* - var pom = document.createElement('a'); - pom.setAttribute('href','data:application/json;charset=UTF-8, ' + encodeURIComponent(tree_as_json)); - pom.setAttribute('download','Storytelling State(' + exportdate + ').json'); - pom.click(); - */ - })); - - }, - - addResetButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.resetbutton = $('<input type="button" id="storytellingv2reset" name="reset" value="reset" />'); - var dialog = $('<div id="tree-reset-dialog-confirm" title="Erase all tree content?"><p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Tree items will be permanently deleted and cannot be recovered. Are you sure?</p></div>'); - storytellingv2Gui.resetbutton.append(dialog) - dialog.dialog({ - resizable: false, - autoOpen: false, - height: 260, - modal: true, - buttons: { - 'Yes': function() { - storytellingv2.deleteAllNodes(storytellingv2Gui.tree); - $(this).dialog("close"); - }, - Cancel: function() { - $(this).dialog("close"); - } - } - }); - - storytellingv2Gui.resetbutton.click($.proxy(function() { - dialog.dialog('open'); - })); - }, - - addExpertButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.expertbutton = $('<input type="button" id="storytellingv2expert" name="expert" value="expert" />'); - storytellingv2Gui.expertbutton.click($.proxy(function() { - storytellingv2Gui.expertbutton.hide(); - storytellingv2Gui.simplebutton.show(); - storytellingv2Gui.snapshotbutton.hide(); - storytellingv2Gui.newbutton.show(); - storytellingv2Gui.parent.simplemode = false; - var configs = storytellingv2.findNodesByType(storytellingv2Gui.tree,'config'); - for (var i = 0; i < configs.length; i++) { - storytellingv2Gui.tree.jstree().get_node(configs[i], true).show(); - } - var snapshots = storytellingv2.findNodesByType(storytellingv2Gui.tree,'snapshot'); - for (var i = 0; i < snapshots.length; i++) { - storytellingv2Gui.tree.jstree().set_type(snapshots[i], 'dataset'); - snapshots[i].li_attr.snapshot_text = snapshots[i].text; - snapshots[i].text = snapshots[i].li_attr.dataset_text || snapshots[i].text; - } - - })); - - }, - - addSimpleButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.simplebutton = $('<input type="button" id="storytellingv2simple" name="simple" value="simple" />'); - storytellingv2Gui.simplebutton.click($.proxy(function() { - storytellingv2Gui.simplebutton.hide(); - storytellingv2Gui.expertbutton.show(); - storytellingv2Gui.newbutton.hide(); - storytellingv2Gui.snapshotbutton.show(); - storytellingv2Gui.parent.simplemode = true; - storytellingv2.makeSimple(storytellingv2Gui.tree); - })); - - }, - - addNewButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.newbutton = $('<input type="button" id="storytellingv2new" name="new" value="new" />'); - storytellingv2Gui.newbutton.click($.proxy(function() { - storytellingv2.defaultSession(storytellingv2Gui.tree); - var newform = $('<div></div>'); - var nameinput = $('<p>Name: <input type="text" /></p>'); - var typeinput = $('<p>Type: <select name="type"><option value="session">Session</option><option value="dataset">Dataset</option><option value="config">Config</option></select></p>'); - var descriptioninput = $('<p>Description: <textarea name="description"></textarea></p>'); - var addbutton = $('<p><input type="button" name="add" value="add" /></p>'); - newform.focusout(function() { - var elem = $(this); - setTimeout(function() { - var hasFocus = !!(elem.find(':focus').length > 0); - if (! hasFocus) { - newform.empty(); - } - }, 10); - }); - addbutton.click($.proxy(function() { - var sel = storytellingv2Gui.tree.jstree().get_selected()[0] || '#' ; - if ($(typeinput).find('option:selected').val() == 'session') { - sel = '#'; - } - sel = storytellingv2Gui.tree.jstree().create_node(sel, { - "text" : $(nameinput).find(':text').first().val(), - "type" : $(typeinput).find('option:selected').val(), - "li_attr" : { - "timestamp" : Date.now(), - "description" : $(descriptioninput).find('textarea').first().val() - } - }); - var newNode = storytellingv2Gui.tree.jstree().get_node(sel); - - if (newNode.type == 'config') { - Publisher.Publish('getConfig',storytellingv2Widget); - newNode.li_attr.configs = storytellingv2Widget.configArray.slice(); - } else if (newNode.type == 'dataset') { - var datasets = []; - if (storytellingv2Widget.datasets != undefined) { - for (var i = 0; i < storytellingv2Widget.datasets.length; i++) { - var ds = {}; - ds.label = storytellingv2Widget.datasets[i].label; - ds.objects = GeoTemConfig.convertCsv(GeoTemConfig.createCSVfromDataset(i)); - datasets.push(ds); - } - } - newNode.li_attr.selected = storytellingv2Widget.selected; - newNode.li_attr.datasets = datasets; - } -// tree.jstree().set_type(sel, 'session'); - $(newform).empty(); - })); - $(newform).append(nameinput); - $(newform).append(typeinput); - $(newform).append(descriptioninput); - $(newform).append(addbutton); - $(storytellingv2Gui.treemanipulationsubmenu).append(newform); - $(nameinput).find(':input').focus(); - })); - - }, - - addSnapshotButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.snapshotbutton = $('<input type="button" id="storytellingv2snapshot" name="snapshot" value="snapshot" />'); - storytellingv2Gui.snapshotbutton.click($.proxy(function() { - storytellingv2.defaultSession(storytellingv2Gui.tree); - var root = storytellingv2Gui.tree.jstree().get_node('#'); - var session = storytellingv2Gui.tree.jstree().get_node(root.children[0]); - var countSnapshots = session.children.length + 1; - var datasets = []; - - if (storytellingv2Widget.datasets != undefined) { - for (var i = 0; i < storytellingv2Widget.datasets.length; i++) { - var ds = {}; - ds.label = storytellingv2Widget.datasets[i].label; - ds.objects = GeoTemConfig.convertCsv(GeoTemConfig.createCSVfromDataset(i)); - datasets.push(ds); - } - } - var newDataset = storytellingv2Gui.tree.jstree().create_node(session, { - 'text' : 'Snapshot #'+countSnapshots, - 'type' : 'dataset', - 'li_attr' : { - 'timestamp' : Date.now(), - 'description' : 'Snapshot #'+countSnapshots+' Dataset', - 'datasets' : datasets, - 'selected' : storytellingv2Widget.selected - } - }); - Publisher.Publish('getConfig',storytellingv2Widget); - var newConfig = storytellingv2Gui.tree.jstree().create_node(newDataset, { - 'text' : 'Snapshot #'+countSnapshots, - 'type' : 'config', - 'li_attr' : { - 'timestamp' : Date.now(), - 'description' : 'Snapshot #'+countSnapshots+' Config', - 'configs' : storytellingv2Widget.configArray.slice() - } - }); - snapshot_as_json = JSON.stringify(storytellingv2Gui.tree.jstree(true).get_json(newDataset)); - localStorage.setItem("PLATIN.storytellingv2.last_snapshot",snapshot_as_json); - storytellingv2.makeSimple(storytellingv2Gui.tree); - - })); - - }, - - addRestoreButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.restorebutton = $('<input type="button" id="storytellingv2restore" name="restore" value="restore" />'); - var loadDataset = function(node) { - var datasets = node.li_attr.datasets; - if (datasets != undefined) { - GeoTemConfig.removeAllDatasets(); - for (var i = 0; i < datasets.length; i++) { - var dataset = new Dataset(GeoTemConfig.loadJson(datasets[i].objects), datasets[i].label); - GeoTemConfig.addDataset(dataset); - } - } - - } - - var loadFilter = function(node) { - var configArray = node.li_attr.configs; - for (var i = 0; i < configArray.length; i++) { - Publisher.Publish('setConfig', configArray[i]); - } - } - - var loadSnapshot = function(node) { - loadDataset(node); - var childNode = node; - while (storytellingv2Gui.tree.jstree().is_parent(childNode)) { - childNode = storytellingv2Gui.tree.jstree().get_node(childNode.children[0]); - if (childNode.type == 'config') { - loadFilter(childNode); - } - } - } - - storytellingv2Gui.restorebutton.click($.proxy(function() { - var selectedNode = storytellingv2Gui.tree.jstree().get_node(storytellingv2Gui.tree.jstree().get_selected()[0]); - if (selectedNode == 'undefined' || selectedNode.type == 'session') { - return; - } - if (selectedNode.type == 'snapshot') { - loadSnapshot(selectedNode); - return; - } - for (var i = selectedNode.parents.length - 1; i >= 0; i--) { - var curNode = storytellingv2Gui.tree.jstree().get_node(selectedNode.parents[i]); - if (curNode.type == 'dataset') { - loadDataset(curNode); - } else if (curNode.type == 'config') { - loadFilter(curNode); - } - } - if (selectedNode.type == 'dataset') { - loadDataset(selectedNode); - } else if (selectedNode.type == 'config') { - loadFilter(selectedNode); - } - })); - - }, - - addDeleteButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.deletebutton = $('<input type="button" id="storytellingv2delete" name="delete" value="delete" />'); - storytellingv2Gui.deletebutton.click($.proxy(function() { - var selectedNode = storytellingv2Gui.tree.jstree().get_node(storytellingv2Gui.tree.jstree().get_selected()[0]); - storytellingv2Gui.tree.jstree().delete_node(selectedNode); - })) - - }, - - addEditButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.editbutton = $('<input type="button" id="storytellingv2edit" name="edit" value="edit" />'); - storytellingv2Gui.editbutton.click($.proxy(function() { - var sel = storytellingv2Gui.tree.jstree().get_selected()[0]; - if (sel != undefined ) { - sel = storytellingv2Gui.tree.jstree().get_node(sel); - var editform = $('<div></div>'); - var nameinput = $('<p>Name: <input type="text" value="'+sel.text+'" /></p>'); - var descriptioninput = $('<p>Description: <textarea name="description">'+sel.li_attr.description+'</textarea></p>'); - var savebutton = $('<p><input type="button" name="save" value="save" /></p>'); - editform.focusout(function() { - var elem = $(this); - setTimeout(function() { - var hasFocus = !!(elem.find(':focus').length > 0); - if (! hasFocus) { - editform.empty(); - } - }, 10); - }); - savebutton.click($.proxy(function() { - storytellingv2Gui.tree.jstree().rename_node(sel, $(nameinput).find(':text').first().val()); - sel.li_attr.description = $(descriptioninput).find('textarea').first().val(); - storytellingv2Gui.tree.jstree().redraw(); - $(editform).empty(); - })); -// $(editform).focusout(function() { -// $(editform).empty(); -// }); - $(editform).append(nameinput); - $(editform).append(descriptioninput); - $(editform).append(savebutton); - storytellingv2Gui.treemanipulationsubmenu.append(editform); - nameinput.find(':input').focus(); - } - - - })); - - }, - - addForwardButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.forwardbutton = $('<input type="button" id="storytellingv2forward" name="forward" value=">>" />'); - storytellingv2Gui.forwardbutton.click($.proxy(function() { - var sel = storytellingv2Gui.tree.jstree().get_selected()[0]; - if (storytellingv2Gui.tree.jstree().get_next_dom(sel, true)) { - storytellingv2Gui.tree.jstree().deselect_node(sel); - storytellingv2Gui.tree.jstree().select_node(storytellingv2Gui.tree.jstree().get_next_dom(sel, true)); - } - - })); - - }, - - addBackwardButton : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.backwardbutton = $('<input type="button" id="storytellingv2backward" name="backward" value="<<" />'); - storytellingv2Gui.backwardbutton.click($.proxy(function() { - var sel = storytellingv2Gui.tree.jstree().get_selected()[0]; - if (storytellingv2Gui.tree.jstree().get_prev_dom(sel, true)) { - storytellingv2Gui.tree.jstree().deselect_node(sel); - storytellingv2Gui.tree.jstree().select_node(storytellingv2Gui.tree.jstree().get_prev_dom(sel, true)); - } - - })); - - - }, - - addMetadata : function() { - - var storytellingv2Gui = this; - var storytellingv2Widget = storytellingv2Gui.parent; - var storytellingv2 = storytellingv2Widget.storytellingv2; - - storytellingv2Gui.metadata = $('<div></div>'); - var metadatafieldset = $('<fieldset style="border: 2px solid; margin: 2px; padding: 5px;"><legend>Metadata</legend></fieldset>'); - var metadataname = $('<p>Name:</p>'); - var metadatatype = $('<p>Type:</p>'); - var metadatatimestamp = $('<p>Timestamp:</p>'); - var metadatadescription = $('<p>Description:</p>'); - var metadataselected = $('<p></p>'); - $(metadatafieldset).append(metadataname); - $(metadatafieldset).append(metadatatype); - $(metadatafieldset).append(metadatatimestamp); - $(metadatafieldset).append(metadatadescription); - $(metadatafieldset).append(metadataselected); - $(storytellingv2Gui.metadata).append(metadatafieldset); - storytellingv2Gui.tree.on('changed.jstree rename_node.jstree', function(e, data) { - if (data.node == undefined) { - return; - } - $(metadataname).empty().append($('<p>Name: '+data.node.text+'</p>')); - $(metadatatype).empty().append($('<p>Type: '+data.node.type+'</p>')); - var tstamp = new Date(data.node.li_attr.timestamp); - $(metadatatimestamp).empty().append($('<p>Timestamp: '+tstamp.toUTCString()+'</p>')); - $(metadatadescription).empty().append($('<p>Description: '+data.node.li_attr.description+'</p>')); - var objectcount = 0; - var datasetcount = 0; - if ($.isArray(data.node.li_attr.selected)) { - datasetcount = data.node.li_attr.selected.length; - $(data.node.li_attr.selected).each(function() { - objectcount += this.length; - }); - } -// $(metadataselected).empty().append($('<p>'+objectcount+' Selected Objects in '+datasetcount+' Datasets</p>')); - }); - - } - - -}; -/* -* StorytellingWidget.js -* -* Copyright (c) 2013, Sebastian Kruse. All rights reserved. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -* MA 02110-1301 USA -*/ - -/** - * @class Storytellingv2Widget - * Storytellingv2Widget Implementation - * @author Mike Bretschneider (mike.bretschneider@gmx.de) - * - * @param {WidgetWrapper} core wrapper for interaction to other widgets - * @param {HTML object} div parent div to append the Storytellingv2 widget div - * @param {JSON} options user specified configuration that overwrites options in Storytellingv2Config.js - */ -Storytellingv2Widget = function(core, div, options) { -/* HACK DW: stelle sicher, dass das nicht zweimal aufgerufen wird! */ - if (typeof Storytellingv2Widget_cont == "undefined"){ - Storytellingv2Widget_cont="Done"; - - this.datasets; - this.core = core; - this.core.setWidget(this); - this.currentStatus = new Object(); - - this.options = (new Storytellingv2Config(options)).options; - this.gui = new Storytellingv2Gui(this, div, this.options); - this.storytellingv2 = new Storytellingv2(this); - - this.datasetLink; - - this.selected; - this.configArray = []; - - this.simplemode = true; - - this.initWidget(); - -} -} - -Storytellingv2Widget.prototype = { - - initWidget : function(data) { - - - var storytellingv2Widget = this; - var gui = storytellingv2Widget.gui; - - storytellingv2Widget.datasets = data; - - gui.initGui(); - - }, - - createLink : function() { - }, - - highlightChanged : function(objects) { - }, - - selectionChanged : function(selection) { - if (!selection.valid()) { - selection.loadAllObjects(); - } - this.selected = selection.objects; - }, - - sendConfig : function(widgetConfig){ - for (var i = 0; i < this.configArray.length; i++) { - if (this.configArray[i].widgetName == widgetConfig.widgetName) { - this.configArray.splice(i,1); - } - } - this.configArray.push(widgetConfig); - }, - -}; -/* * LineOverlay.js * * Copyright (c) 2013, Sebastian Kruse. All rights reserved. @@ -57203,29 +48791,6 @@ wrapper.widget.gui.resize(); } }); - - Publisher.Subscribe('getConfig', this, function(inquiringWidget) { - if (inquiringWidget == undefined) { - return; - } - if ( typeof wrapper.widget != 'undefined') { - if ( typeof wrapper.widget.getConfig != 'undefined') { - wrapper.widget.getConfig(inquiringWidget); - } - } - }); - - Publisher.Subscribe('setConfig', this, function(config) { - if (config == undefined) { - return; - } - if ( typeof wrapper.widget != 'undefined') { - if ( typeof wrapper.widget.setConfig != 'undefined') { - wrapper.widget.setConfig(config); - } - } - }); - this.triggerRefining = function(datasets) { Publisher.Publish('filterData', datasets, null);