summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE/client/bower_components/jqTree/lib/tree.jquery.js
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-portal-FE/client/bower_components/jqTree/lib/tree.jquery.js')
-rw-r--r--ecomp-portal-FE/client/bower_components/jqTree/lib/tree.jquery.js1101
1 files changed, 0 insertions, 1101 deletions
diff --git a/ecomp-portal-FE/client/bower_components/jqTree/lib/tree.jquery.js b/ecomp-portal-FE/client/bower_components/jqTree/lib/tree.jquery.js
deleted file mode 100644
index c7ac2f08..00000000
--- a/ecomp-portal-FE/client/bower_components/jqTree/lib/tree.jquery.js
+++ /dev/null
@@ -1,1101 +0,0 @@
-var $, BorderDropHint, DragAndDropHandler, DragElement, ElementsRenderer, FolderElement, GhostDropHint, HitAreasGenerator, JqTreeWidget, KeyHandler, MouseWidget, Node, NodeElement, Position, SaveStateHandler, ScrollHandler, SelectNodeHandler, SimpleWidget, __version__, drag_and_drop_handler, isFunction, node_module, ref, util_module,
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
-
-__version__ = require('./version');
-
-drag_and_drop_handler = require('./drag_and_drop_handler');
-
-ElementsRenderer = require('./elements_renderer');
-
-KeyHandler = require('./key_handler');
-
-MouseWidget = require('./mouse.widget');
-
-SaveStateHandler = require('./save_state_handler');
-
-ScrollHandler = require('./scroll_handler');
-
-SelectNodeHandler = require('./select_node_handler');
-
-SimpleWidget = require('./simple.widget');
-
-node_module = require('./node');
-
-Node = node_module.Node;
-
-Position = node_module.Position;
-
-util_module = require('./util');
-
-isFunction = util_module.isFunction;
-
-ref = require('./node_element'), BorderDropHint = ref.BorderDropHint, FolderElement = ref.FolderElement, GhostDropHint = ref.GhostDropHint, NodeElement = ref.NodeElement;
-
-DragAndDropHandler = drag_and_drop_handler.DragAndDropHandler, DragElement = drag_and_drop_handler.DragElement, HitAreasGenerator = drag_and_drop_handler.HitAreasGenerator;
-
-$ = jQuery;
-
-JqTreeWidget = (function(superClass) {
- extend(JqTreeWidget, superClass);
-
- function JqTreeWidget() {
- return JqTreeWidget.__super__.constructor.apply(this, arguments);
- }
-
- JqTreeWidget.prototype.BorderDropHint = BorderDropHint;
-
- JqTreeWidget.prototype.DragElement = DragElement;
-
- JqTreeWidget.prototype.DragAndDropHandler = DragAndDropHandler;
-
- JqTreeWidget.prototype.ElementsRenderer = ElementsRenderer;
-
- JqTreeWidget.prototype.GhostDropHint = GhostDropHint;
-
- JqTreeWidget.prototype.HitAreasGenerator = HitAreasGenerator;
-
- JqTreeWidget.prototype.Node = Node;
-
- JqTreeWidget.prototype.SaveStateHandler = SaveStateHandler;
-
- JqTreeWidget.prototype.ScrollHandler = ScrollHandler;
-
- JqTreeWidget.prototype.SelectNodeHandler = SelectNodeHandler;
-
- JqTreeWidget.prototype.defaults = {
- autoOpen: false,
- saveState: false,
- dragAndDrop: false,
- selectable: true,
- useContextMenu: true,
- onCanSelectNode: null,
- onSetStateFromStorage: null,
- onGetStateFromStorage: null,
- onCreateLi: null,
- onIsMoveHandle: null,
- onCanMove: null,
- onCanMoveTo: null,
- onLoadFailed: null,
- autoEscape: true,
- dataUrl: null,
- closedIcon: null,
- openedIcon: '▼',
- slide: true,
- nodeClass: Node,
- dataFilter: null,
- keyboardSupport: true,
- openFolderDelay: 500,
- rtl: null,
- onDragMove: null,
- onDragStop: null,
- buttonLeft: true,
- onLoading: null
- };
-
- JqTreeWidget.prototype.toggle = function(node, slide) {
- if (slide == null) {
- slide = null;
- }
- if (slide === null) {
- slide = this.options.slide;
- }
- if (node.is_open) {
- this.closeNode(node, slide);
- } else {
- this.openNode(node, slide);
- }
- return this.element;
- };
-
- JqTreeWidget.prototype.getTree = function() {
- return this.tree;
- };
-
- JqTreeWidget.prototype.selectNode = function(node) {
- this._selectNode(node, false);
- return this.element;
- };
-
- JqTreeWidget.prototype._selectNode = function(node, must_toggle) {
- var canSelect, deselected_node, openParents, saveState;
- if (must_toggle == null) {
- must_toggle = false;
- }
- if (!this.select_node_handler) {
- return;
- }
- canSelect = (function(_this) {
- return function() {
- if (_this.options.onCanSelectNode) {
- return _this.options.selectable && _this.options.onCanSelectNode(node);
- } else {
- return _this.options.selectable;
- }
- };
- })(this);
- openParents = (function(_this) {
- return function() {
- var parent;
- parent = node.parent;
- if (parent && parent.parent && !parent.is_open) {
- return _this.openNode(parent, false);
- }
- };
- })(this);
- saveState = (function(_this) {
- return function() {
- if (_this.options.saveState) {
- return _this.save_state_handler.saveState();
- }
- };
- })(this);
- if (!node) {
- this._deselectCurrentNode();
- saveState();
- return;
- }
- if (!canSelect()) {
- return;
- }
- if (this.select_node_handler.isNodeSelected(node)) {
- if (must_toggle) {
- this._deselectCurrentNode();
- this._triggerEvent('tree.select', {
- node: null,
- previous_node: node
- });
- }
- } else {
- deselected_node = this.getSelectedNode();
- this._deselectCurrentNode();
- this.addToSelection(node);
- this._triggerEvent('tree.select', {
- node: node,
- deselected_node: deselected_node
- });
- openParents();
- }
- return saveState();
- };
-
- JqTreeWidget.prototype.getSelectedNode = function() {
- if (this.select_node_handler) {
- return this.select_node_handler.getSelectedNode();
- } else {
- return null;
- }
- };
-
- JqTreeWidget.prototype.toJson = function() {
- return JSON.stringify(this.tree.getData());
- };
-
- JqTreeWidget.prototype.loadData = function(data, parent_node) {
- this._loadData(data, parent_node);
- return this.element;
- };
-
-
- /*
- signatures:
- - loadDataFromUrl(url, parent_node=null, on_finished=null)
- loadDataFromUrl('/my_data');
- loadDataFromUrl('/my_data', node1);
- loadDataFromUrl('/my_data', node1, function() { console.log('finished'); });
- loadDataFromUrl('/my_data', null, function() { console.log('finished'); });
-
- - loadDataFromUrl(parent_node=null, on_finished=null)
- loadDataFromUrl();
- loadDataFromUrl(node1);
- loadDataFromUrl(null, function() { console.log('finished'); });
- loadDataFromUrl(node1, function() { console.log('finished'); });
- */
-
- JqTreeWidget.prototype.loadDataFromUrl = function(param1, param2, param3) {
- if ($.type(param1) === 'string') {
- this._loadDataFromUrl(param1, param2, param3);
- } else {
- this._loadDataFromUrl(null, param1, param2);
- }
- return this.element;
- };
-
- JqTreeWidget.prototype.reload = function(on_finished) {
- this._loadDataFromUrl(null, null, on_finished);
- return this.element;
- };
-
- JqTreeWidget.prototype._loadDataFromUrl = function(url_info, parent_node, on_finished) {
- var $el, addLoadingClass, handeLoadData, handleError, handleSuccess, loadDataFromUrlInfo, parseUrlInfo, removeLoadingClass;
- $el = null;
- addLoadingClass = (function(_this) {
- return function() {
- if (parent_node) {
- $el = $(parent_node.element);
- } else {
- $el = _this.element;
- }
- $el.addClass('jqtree-loading');
- return _this._notifyLoading(true, parent_node, $el);
- };
- })(this);
- removeLoadingClass = (function(_this) {
- return function() {
- if ($el) {
- $el.removeClass('jqtree-loading');
- return _this._notifyLoading(false, parent_node, $el);
- }
- };
- })(this);
- parseUrlInfo = function() {
- if ($.type(url_info) === 'string') {
- return {
- url: url_info
- };
- }
- if (!url_info.method) {
- url_info.method = 'get';
- }
- return url_info;
- };
- handeLoadData = (function(_this) {
- return function(data) {
- removeLoadingClass();
- _this._loadData(data, parent_node);
- if (on_finished && $.isFunction(on_finished)) {
- return on_finished();
- }
- };
- })(this);
- handleSuccess = (function(_this) {
- return function(response) {
- var data;
- if ($.isArray(response) || typeof response === 'object') {
- data = response;
- } else if (data != null) {
- data = $.parseJSON(response);
- } else {
- data = [];
- }
- if (_this.options.dataFilter) {
- data = _this.options.dataFilter(data);
- }
- return handeLoadData(data);
- };
- })(this);
- handleError = (function(_this) {
- return function(response) {
- removeLoadingClass();
- if (_this.options.onLoadFailed) {
- return _this.options.onLoadFailed(response);
- }
- };
- })(this);
- loadDataFromUrlInfo = function() {
- url_info = parseUrlInfo();
- return $.ajax($.extend({}, url_info, {
- method: url_info.method != null ? url_info.method.toUpperCase() : 'GET',
- cache: false,
- dataType: 'json',
- success: handleSuccess,
- error: handleError
- }));
- };
- if (!url_info) {
- url_info = this._getDataUrlInfo(parent_node);
- }
- addLoadingClass();
- if (!url_info) {
- removeLoadingClass();
- } else if ($.isArray(url_info)) {
- handeLoadData(url_info);
- } else {
- loadDataFromUrlInfo();
- }
- };
-
- JqTreeWidget.prototype._loadData = function(data, parent_node) {
- var deselectNodes, loadSubtree;
- if (parent_node == null) {
- parent_node = null;
- }
- deselectNodes = (function(_this) {
- return function() {
- var i, len, n, selected_nodes_under_parent;
- if (_this.select_node_handler) {
- selected_nodes_under_parent = _this.select_node_handler.getSelectedNodesUnder(parent_node);
- for (i = 0, len = selected_nodes_under_parent.length; i < len; i++) {
- n = selected_nodes_under_parent[i];
- _this.select_node_handler.removeFromSelection(n);
- }
- }
- return null;
- };
- })(this);
- loadSubtree = (function(_this) {
- return function() {
- parent_node.loadFromData(data);
- parent_node.load_on_demand = false;
- parent_node.is_loading = false;
- return _this._refreshElements(parent_node);
- };
- })(this);
- if (!data) {
- return;
- }
- this._triggerEvent('tree.load_data', {
- tree_data: data
- });
- if (!parent_node) {
- this._initTree(data);
- } else {
- deselectNodes();
- loadSubtree();
- }
- if (this.isDragging()) {
- return this.dnd_handler.refresh();
- }
- };
-
- JqTreeWidget.prototype.getNodeById = function(node_id) {
- return this.tree.getNodeById(node_id);
- };
-
- JqTreeWidget.prototype.getNodeByName = function(name) {
- return this.tree.getNodeByName(name);
- };
-
- JqTreeWidget.prototype.getNodesByProperty = function(key, value) {
- return this.tree.getNodesByProperty(key, value);
- };
-
- JqTreeWidget.prototype.getNodeByHtmlElement = function(element) {
- return this._getNode($(element));
- };
-
- JqTreeWidget.prototype.getNodeByCallback = function(callback) {
- return this.tree.getNodeByCallback(callback);
- };
-
- JqTreeWidget.prototype.openNode = function(node, slide_param, on_finished_param) {
- var on_finished, parseParams, ref1, slide;
- if (slide_param == null) {
- slide_param = null;
- }
- if (on_finished_param == null) {
- on_finished_param = null;
- }
- parseParams = (function(_this) {
- return function() {
- var on_finished, slide;
- if (isFunction(slide_param)) {
- on_finished = slide_param;
- slide = null;
- } else {
- slide = slide_param;
- on_finished = on_finished_param;
- }
- if (slide === null) {
- slide = _this.options.slide;
- }
- return [slide, on_finished];
- };
- })(this);
- ref1 = parseParams(), slide = ref1[0], on_finished = ref1[1];
- if (node) {
- this._openNode(node, slide, on_finished);
- }
- return this.element;
- };
-
- JqTreeWidget.prototype._openNode = function(node, slide, on_finished) {
- var doOpenNode, parent;
- if (slide == null) {
- slide = true;
- }
- doOpenNode = (function(_this) {
- return function(_node, _slide, _on_finished) {
- var folder_element;
- folder_element = new FolderElement(_node, _this);
- return folder_element.open(_on_finished, _slide);
- };
- })(this);
- if (node.isFolder()) {
- if (node.load_on_demand) {
- return this._loadFolderOnDemand(node, slide, on_finished);
- } else {
- parent = node.parent;
- while (parent) {
- if (parent.parent) {
- doOpenNode(parent, false, null);
- }
- parent = parent.parent;
- }
- doOpenNode(node, slide, on_finished);
- return this._saveState();
- }
- }
- };
-
- JqTreeWidget.prototype._loadFolderOnDemand = function(node, slide, on_finished) {
- if (slide == null) {
- slide = true;
- }
- node.is_loading = true;
- return this._loadDataFromUrl(null, node, (function(_this) {
- return function() {
- return _this._openNode(node, slide, on_finished);
- };
- })(this));
- };
-
- JqTreeWidget.prototype.closeNode = function(node, slide) {
- if (slide == null) {
- slide = null;
- }
- if (slide === null) {
- slide = this.options.slide;
- }
- if (node.isFolder()) {
- new FolderElement(node, this).close(slide);
- this._saveState();
- }
- return this.element;
- };
-
- JqTreeWidget.prototype.isDragging = function() {
- if (this.dnd_handler) {
- return this.dnd_handler.is_dragging;
- } else {
- return false;
- }
- };
-
- JqTreeWidget.prototype.refreshHitAreas = function() {
- this.dnd_handler.refresh();
- return this.element;
- };
-
- JqTreeWidget.prototype.addNodeAfter = function(new_node_info, existing_node) {
- var new_node;
- new_node = existing_node.addAfter(new_node_info);
- this._refreshElements(existing_node.parent);
- return new_node;
- };
-
- JqTreeWidget.prototype.addNodeBefore = function(new_node_info, existing_node) {
- var new_node;
- new_node = existing_node.addBefore(new_node_info);
- this._refreshElements(existing_node.parent);
- return new_node;
- };
-
- JqTreeWidget.prototype.addParentNode = function(new_node_info, existing_node) {
- var new_node;
- new_node = existing_node.addParent(new_node_info);
- this._refreshElements(new_node.parent);
- return new_node;
- };
-
- JqTreeWidget.prototype.removeNode = function(node) {
- var parent;
- parent = node.parent;
- if (parent) {
- this.select_node_handler.removeFromSelection(node, true);
- node.remove();
- this._refreshElements(parent);
- }
- return this.element;
- };
-
- JqTreeWidget.prototype.appendNode = function(new_node_info, parent_node) {
- var node;
- parent_node = parent_node || this.tree;
- node = parent_node.append(new_node_info);
- this._refreshElements(parent_node);
- return node;
- };
-
- JqTreeWidget.prototype.prependNode = function(new_node_info, parent_node) {
- var node;
- if (!parent_node) {
- parent_node = this.tree;
- }
- node = parent_node.prepend(new_node_info);
- this._refreshElements(parent_node);
- return node;
- };
-
- JqTreeWidget.prototype.updateNode = function(node, data) {
- var id_is_changed;
- id_is_changed = data.id && data.id !== node.id;
- if (id_is_changed) {
- this.tree.removeNodeFromIndex(node);
- }
- node.setData(data);
- if (id_is_changed) {
- this.tree.addNodeToIndex(node);
- }
- if (typeof data === 'object' && data.children) {
- node.removeChildren();
- if (data.children.length) {
- node.loadFromData(data.children);
- }
- }
- this.renderer.renderFromNode(node);
- this._selectCurrentNode();
- return this.element;
- };
-
- JqTreeWidget.prototype.moveNode = function(node, target_node, position) {
- var position_index;
- position_index = Position.nameToIndex(position);
- this.tree.moveNode(node, target_node, position_index);
- this._refreshElements();
- return this.element;
- };
-
- JqTreeWidget.prototype.getStateFromStorage = function() {
- return this.save_state_handler.getStateFromStorage();
- };
-
- JqTreeWidget.prototype.addToSelection = function(node) {
- if (node) {
- this.select_node_handler.addToSelection(node);
- this._getNodeElementForNode(node).select();
- this._saveState();
- }
- return this.element;
- };
-
- JqTreeWidget.prototype.getSelectedNodes = function() {
- return this.select_node_handler.getSelectedNodes();
- };
-
- JqTreeWidget.prototype.isNodeSelected = function(node) {
- return this.select_node_handler.isNodeSelected(node);
- };
-
- JqTreeWidget.prototype.removeFromSelection = function(node) {
- this.select_node_handler.removeFromSelection(node);
- this._getNodeElementForNode(node).deselect();
- this._saveState();
- return this.element;
- };
-
- JqTreeWidget.prototype.scrollToNode = function(node) {
- var $element, top;
- $element = $(node.element);
- top = $element.offset().top - this.$el.offset().top;
- this.scroll_handler.scrollTo(top);
- return this.element;
- };
-
- JqTreeWidget.prototype.getState = function() {
- return this.save_state_handler.getState();
- };
-
- JqTreeWidget.prototype.setState = function(state) {
- this.save_state_handler.setInitialState(state);
- this._refreshElements();
- return this.element;
- };
-
- JqTreeWidget.prototype.setOption = function(option, value) {
- this.options[option] = value;
- return this.element;
- };
-
- JqTreeWidget.prototype.moveDown = function() {
- if (this.key_handler) {
- this.key_handler.moveDown();
- }
- return this.element;
- };
-
- JqTreeWidget.prototype.moveUp = function() {
- if (this.key_handler) {
- this.key_handler.moveUp();
- }
- return this.element;
- };
-
- JqTreeWidget.prototype.getVersion = function() {
- return __version__;
- };
-
- JqTreeWidget.prototype._init = function() {
- JqTreeWidget.__super__._init.call(this);
- this.element = this.$el;
- this.mouse_delay = 300;
- this.is_initialized = false;
- this.options.rtl = this._getRtlOption();
- if (!this.options.closedIcon) {
- this.options.closedIcon = this._getDefaultClosedIcon();
- }
- this.renderer = new ElementsRenderer(this);
- if (SaveStateHandler != null) {
- this.save_state_handler = new SaveStateHandler(this);
- } else {
- this.options.saveState = false;
- }
- if (SelectNodeHandler != null) {
- this.select_node_handler = new SelectNodeHandler(this);
- }
- if (DragAndDropHandler != null) {
- this.dnd_handler = new DragAndDropHandler(this);
- } else {
- this.options.dragAndDrop = false;
- }
- if (ScrollHandler != null) {
- this.scroll_handler = new ScrollHandler(this);
- }
- if ((KeyHandler != null) && (SelectNodeHandler != null)) {
- this.key_handler = new KeyHandler(this);
- }
- this._initData();
- this.element.click($.proxy(this._click, this));
- this.element.dblclick($.proxy(this._dblclick, this));
- if (this.options.useContextMenu) {
- return this.element.bind('contextmenu', $.proxy(this._contextmenu, this));
- }
- };
-
- JqTreeWidget.prototype._deinit = function() {
- this.element.empty();
- this.element.unbind();
- if (this.key_handler) {
- this.key_handler.deinit();
- }
- this.tree = null;
- return JqTreeWidget.__super__._deinit.call(this);
- };
-
- JqTreeWidget.prototype._initData = function() {
- var data_url;
- if (this.options.data) {
- return this._loadData(this.options.data);
- } else {
- data_url = this._getDataUrlInfo();
- if (data_url) {
- return this._loadDataFromUrl();
- } else {
- return this._loadData([]);
- }
- }
- };
-
- JqTreeWidget.prototype._getDataUrlInfo = function(node) {
- var data_url, getUrlFromString;
- data_url = this.options.dataUrl || this.element.data('url');
- getUrlFromString = (function(_this) {
- return function() {
- var data, selected_node_id, url_info;
- url_info = {
- url: data_url
- };
- if (node && node.id) {
- data = {
- node: node.id
- };
- url_info['data'] = data;
- } else {
- selected_node_id = _this._getNodeIdToBeSelected();
- if (selected_node_id) {
- data = {
- selected_node: selected_node_id
- };
- url_info['data'] = data;
- }
- }
- return url_info;
- };
- })(this);
- if ($.isFunction(data_url)) {
- return data_url(node);
- } else if ($.type(data_url) === 'string') {
- return getUrlFromString();
- } else {
- return data_url;
- }
- };
-
- JqTreeWidget.prototype._getNodeIdToBeSelected = function() {
- if (this.options.saveState) {
- return this.save_state_handler.getNodeIdToBeSelected();
- } else {
- return null;
- }
- };
-
- JqTreeWidget.prototype._initTree = function(data) {
- var doInit, must_load_on_demand;
- doInit = (function(_this) {
- return function() {
- if (!_this.is_initialized) {
- _this.is_initialized = true;
- return _this._triggerEvent('tree.init');
- }
- };
- })(this);
- this.tree = new this.options.nodeClass(null, true, this.options.nodeClass);
- if (this.select_node_handler) {
- this.select_node_handler.clear();
- }
- this.tree.loadFromData(data);
- must_load_on_demand = this._setInitialState();
- this._refreshElements();
- if (!must_load_on_demand) {
- return doInit();
- } else {
- return this._setInitialStateOnDemand(doInit);
- }
- };
-
- JqTreeWidget.prototype._setInitialState = function() {
- var autoOpenNodes, is_restored, must_load_on_demand, ref1, restoreState;
- restoreState = (function(_this) {
- return function() {
- var must_load_on_demand, state;
- if (!(_this.options.saveState && _this.save_state_handler)) {
- return [false, false];
- } else {
- state = _this.save_state_handler.getStateFromStorage();
- if (!state) {
- return [false, false];
- } else {
- must_load_on_demand = _this.save_state_handler.setInitialState(state);
- return [true, must_load_on_demand];
- }
- }
- };
- })(this);
- autoOpenNodes = (function(_this) {
- return function() {
- var max_level, must_load_on_demand;
- if (_this.options.autoOpen === false) {
- return false;
- }
- max_level = _this._getAutoOpenMaxLevel();
- must_load_on_demand = false;
- _this.tree.iterate(function(node, level) {
- if (node.load_on_demand) {
- must_load_on_demand = true;
- return false;
- } else if (!node.hasChildren()) {
- return false;
- } else {
- node.is_open = true;
- return level !== max_level;
- }
- });
- return must_load_on_demand;
- };
- })(this);
- ref1 = restoreState(), is_restored = ref1[0], must_load_on_demand = ref1[1];
- if (!is_restored) {
- must_load_on_demand = autoOpenNodes();
- }
- return must_load_on_demand;
- };
-
- JqTreeWidget.prototype._setInitialStateOnDemand = function(cb_finished) {
- var autoOpenNodes, restoreState;
- restoreState = (function(_this) {
- return function() {
- var state;
- if (!(_this.options.saveState && _this.save_state_handler)) {
- return false;
- } else {
- state = _this.save_state_handler.getStateFromStorage();
- if (!state) {
- return false;
- } else {
- _this.save_state_handler.setInitialStateOnDemand(state, cb_finished);
- return true;
- }
- }
- };
- })(this);
- autoOpenNodes = (function(_this) {
- return function() {
- var loadAndOpenNode, loading_count, max_level, openNodes;
- max_level = _this._getAutoOpenMaxLevel();
- loading_count = 0;
- loadAndOpenNode = function(node) {
- loading_count += 1;
- return _this._openNode(node, false, function() {
- loading_count -= 1;
- return openNodes();
- });
- };
- openNodes = function() {
- _this.tree.iterate(function(node, level) {
- if (node.load_on_demand) {
- if (!node.is_loading) {
- loadAndOpenNode(node);
- }
- return false;
- } else {
- _this._openNode(node, false);
- return level !== max_level;
- }
- });
- if (loading_count === 0) {
- return cb_finished();
- }
- };
- return openNodes();
- };
- })(this);
- if (!restoreState()) {
- return autoOpenNodes();
- }
- };
-
- JqTreeWidget.prototype._getAutoOpenMaxLevel = function() {
- if (this.options.autoOpen === true) {
- return -1;
- } else {
- return parseInt(this.options.autoOpen);
- }
- };
-
-
- /*
- Redraw the tree or part of the tree.
- * from_node: redraw this subtree
- */
-
- JqTreeWidget.prototype._refreshElements = function(from_node) {
- if (from_node == null) {
- from_node = null;
- }
- this.renderer.render(from_node);
- return this._triggerEvent('tree.refresh');
- };
-
- JqTreeWidget.prototype._click = function(e) {
- var click_target, event, node;
- click_target = this._getClickTarget(e.target);
- if (click_target) {
- if (click_target.type === 'button') {
- this.toggle(click_target.node, this.options.slide);
- e.preventDefault();
- return e.stopPropagation();
- } else if (click_target.type === 'label') {
- node = click_target.node;
- event = this._triggerEvent('tree.click', {
- node: node,
- click_event: e
- });
- if (!event.isDefaultPrevented()) {
- return this._selectNode(node, true);
- }
- }
- }
- };
-
- JqTreeWidget.prototype._dblclick = function(e) {
- var click_target;
- click_target = this._getClickTarget(e.target);
- if (click_target && click_target.type === 'label') {
- return this._triggerEvent('tree.dblclick', {
- node: click_target.node,
- click_event: e
- });
- }
- };
-
- JqTreeWidget.prototype._getClickTarget = function(element) {
- var $button, $el, $target, node;
- $target = $(element);
- $button = $target.closest('.jqtree-toggler');
- if ($button.length) {
- node = this._getNode($button);
- if (node) {
- return {
- type: 'button',
- node: node
- };
- }
- } else {
- $el = $target.closest('.jqtree-element');
- if ($el.length) {
- node = this._getNode($el);
- if (node) {
- return {
- type: 'label',
- node: node
- };
- }
- }
- }
- return null;
- };
-
- JqTreeWidget.prototype._getNode = function($element) {
- var $li;
- $li = $element.closest('li.jqtree_common');
- if ($li.length === 0) {
- return null;
- } else {
- return $li.data('node');
- }
- };
-
- JqTreeWidget.prototype._getNodeElementForNode = function(node) {
- if (node.isFolder()) {
- return new FolderElement(node, this);
- } else {
- return new NodeElement(node, this);
- }
- };
-
- JqTreeWidget.prototype._getNodeElement = function($element) {
- var node;
- node = this._getNode($element);
- if (node) {
- return this._getNodeElementForNode(node);
- } else {
- return null;
- }
- };
-
- JqTreeWidget.prototype._contextmenu = function(e) {
- var $div, node;
- $div = $(e.target).closest('ul.jqtree-tree .jqtree-element');
- if ($div.length) {
- node = this._getNode($div);
- if (node) {
- e.preventDefault();
- e.stopPropagation();
- this._triggerEvent('tree.contextmenu', {
- node: node,
- click_event: e
- });
- return false;
- }
- }
- };
-
- JqTreeWidget.prototype._saveState = function() {
- if (this.options.saveState) {
- return this.save_state_handler.saveState();
- }
- };
-
- JqTreeWidget.prototype._mouseCapture = function(position_info) {
- if (this.options.dragAndDrop) {
- return this.dnd_handler.mouseCapture(position_info);
- } else {
- return false;
- }
- };
-
- JqTreeWidget.prototype._mouseStart = function(position_info) {
- if (this.options.dragAndDrop) {
- return this.dnd_handler.mouseStart(position_info);
- } else {
- return false;
- }
- };
-
- JqTreeWidget.prototype._mouseDrag = function(position_info) {
- var result;
- if (this.options.dragAndDrop) {
- result = this.dnd_handler.mouseDrag(position_info);
- if (this.scroll_handler) {
- this.scroll_handler.checkScrolling();
- }
- return result;
- } else {
- return false;
- }
- };
-
- JqTreeWidget.prototype._mouseStop = function(position_info) {
- if (this.options.dragAndDrop) {
- return this.dnd_handler.mouseStop(position_info);
- } else {
- return false;
- }
- };
-
- JqTreeWidget.prototype._triggerEvent = function(event_name, values) {
- var event;
- event = $.Event(event_name);
- $.extend(event, values);
- this.element.trigger(event);
- return event;
- };
-
- JqTreeWidget.prototype.testGenerateHitAreas = function(moving_node) {
- this.dnd_handler.current_item = this._getNodeElementForNode(moving_node);
- this.dnd_handler.generateHitAreas();
- return this.dnd_handler.hit_areas;
- };
-
- JqTreeWidget.prototype._selectCurrentNode = function() {
- var node, node_element;
- node = this.getSelectedNode();
- if (node) {
- node_element = this._getNodeElementForNode(node);
- if (node_element) {
- return node_element.select();
- }
- }
- };
-
- JqTreeWidget.prototype._deselectCurrentNode = function() {
- var node;
- node = this.getSelectedNode();
- if (node) {
- return this.removeFromSelection(node);
- }
- };
-
- JqTreeWidget.prototype._getDefaultClosedIcon = function() {
- if (this.options.rtl) {
- return '&#x25c0;';
- } else {
- return '&#x25ba;';
- }
- };
-
- JqTreeWidget.prototype._getRtlOption = function() {
- var data_rtl;
- if (this.options.rtl !== null) {
- return this.options.rtl;
- } else {
- data_rtl = this.element.data('rtl');
- if ((data_rtl != null) && data_rtl !== false) {
- return true;
- } else {
- return false;
- }
- }
- };
-
- JqTreeWidget.prototype._notifyLoading = function(is_loading, node, $el) {
- if (this.options.onLoading) {
- return this.options.onLoading(is_loading, node, $el);
- }
- };
-
- return JqTreeWidget;
-
-})(MouseWidget);
-
-JqTreeWidget.getModule = function(name) {
- var modules;
- modules = {
- 'node': node_module,
- 'util': util_module,
- 'drag_and_drop_handler': drag_and_drop_handler
- };
- return modules[name];
-};
-
-SimpleWidget.register(JqTreeWidget, 'tree');