diff --git a/jstree/jstree.d.ts b/jstree/jstree.d.ts index 161ad5618f..d5641c8ba3 100644 --- a/jstree/jstree.d.ts +++ b/jstree/jstree.d.ts @@ -36,7 +36,8 @@ interface JSTreeStatic { * stores all loaded jstree plugins (used internally) */ plugins: any[]; - + path: string; + idregex:any; /** * creates a jstree instance * @param el the element to create the instance on, can be jQuery extended or a selector @@ -120,11 +121,12 @@ interface JSTreeStaticDefaults { * stores all defaults for the search plugin */ search?: JSTreeStaticDefaultsSearch; - /** - * 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. - */ + /** + * 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 + */ sort?: (x: any, y: any) => number; /** * stores all defaults for the state plugin @@ -153,41 +155,121 @@ interface JSTreeStaticDefaults { interface JSTreeStaticDefaultsCore { /** - * data configuration + * 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?: any; /** - * configure the various strings used throughout the tree + * 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?: any; /** - * + * 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?: (operation: string, node: any, node_parent: any, node_position: any) => boolean; + check_callback?: any; - /** - * a callback called with a single object parameter in the instance's scope - * when something goes wrong (operation prevented, ajax failed, etc) + /** + * 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: () => any; - /** - * the open / close animation duration in milliseconds - * set this to false to disable the animation (default is 200) + /** + * the open / close animation duration in milliseconds - set this to `false` to disable the animation (default is `200`) + * @name $.jstree.defaults.core.animation */ animation?: any; - /** - * a boolean indicating if multiple nodes can be selected + /** + * a boolean indicating if multiple nodes can be selected + * @name $.jstree.defaults.core.multiple */ multiple?: boolean; - /** - * theme configuration object + /** + * theme configuration object + * @name $.jstree.defaults.core.themes */ themes?: JSTreeStaticDefaultsCoreThemes; - /** - * 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) + /** + * 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?: boolean; } @@ -233,143 +315,181 @@ interface JSTreeStaticDefaultsCoreThemes { } interface JSTreeStaticDefaultsCheckbox { - /** - * a boolean indicating if checkboxes should be visible - * (can be changed at a later time using show_checkboxes() - * and hide_checkboxes). Defaults to true. + /** + * 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: boolean; - /** - * a boolean indicating if checkboxes should cascade down - * and have an undetermined state. Defaults to 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: boolean; - /** - * a boolean indicating if clicking anywhere on the node - * should act as clicking on the checkbox. Defaults to 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: boolean; - /** - * a boolean indicating if the selected style of a node - * should be kept, or removed. Defaults to 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: boolean; } interface JSTreeStaticDefaultsContextMenu { - /** - * a boolean indicating if the node should be selected - * when the context menu is invoked on it. Defaults to true. + /** + * 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: boolean; - /** - * a boolean indicating if the menu should be shown aligned - * with the node. Defaults to true, otherwise the mouse coordinates are used. + /** + * 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: boolean; - /** - * an object of actions, or a function that accepts a node - * and returns an object of actions available for that node - * Each action consists of a key (a unique name) and a value which is an object with the following properties: - * 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 - * action - a function to be executed if this item is chosen + /** + * 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: any; } interface JSTreeStaticDefaultsDragNDrop { - /** - * a boolean indicating if a copy should be possible - * while dragging (by pressint the meta key or Ctrl). Defaults to 'true'. + /** + * 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: boolean; - /** - * a number indicating how long a node should remain hovered - * while dragging to be opened. Defaults to 500. + /** + * 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: number; - /** - * 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 + /** + * 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: boolean; - /** - * 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` + /** + * 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: boolean; - /** - * a boolean indicating if nodes from this tree should only be copied - * with dnd (as opposed to moved), default is `false` + /** + * 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: boolean; + + /** + * 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: any; } interface JSTreeStaticDefaultsSearch { - /** - * 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. + /** + * 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: any; - /** - * Indicates if the search should be fuzzy - * or not (should chnd3 match child node 3). Default is true. + /** + * Indicates if the search should be fuzzy or not (should `chnd3` match `child node 3`). Default is `true`. + * @name $.jstree.defaults.search.fuzzy + * @plugin search */ fuzzy: boolean; - /** - * Indicates if the search should be case sensitive. Default is false. + /** + * Indicates if the search should be case sensitive. Default is `false`. + * @name $.jstree.defaults.search.case_sensitive + * @plugin search */ case_sensitive: boolean; - /** - * Indicates if the tree should be filtered to show only matching nodes - * (keep in mind this can be a heavy on large trees in old browsers). Default is false. + /** + * Indicates if the tree should be filtered to show only matching nodes + * (keep in mind this can be a heavy on large trees in old browsers). Default is `false`. + * @name $.jstree.defaults.search.show_only_matches + * @plugin search */ show_only_matches: boolean; - /** - * 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. + /** + * 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: boolean; - /** - * Indicates if only leaf nodes should be included in search results. Default is `false`. + /** + * 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: boolean; } interface JSTreeStaticDefaultsState { - /** - * A string for the key to use when saving the current tree - * (change if using multiple trees in your project). Defaults to jstree. + /** + * 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: string; - /** - * A space separated list of events that trigger a state save. - * Defaults to changed.jstree open_node.jstree close_node.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: string; - /** - * Time in milliseconds after which the state will expire. - * Defaults to 'false' meaning - no expire. + /** + * Time in milliseconds after which the state will expire. Defaults to 'false' meaning - no expire. + * @name $.jstree.defaults.state.ttl + * @plugin state */ ttl: any; - /** - * 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. + /** + * 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: any; @@ -383,319 +503,482 @@ interface JQuery { } interface JSTree extends JQuery { - /** - * destroy an instance + /** + * 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: () => void; - /** - * returns the jQuery extended instance container + destroy: (keep_html: boolean) => void; + /** + * returns the jQuery extended instance container + * @name get_container() + * @return {jQuery} */ get_container: () => JQuery; - /** - * 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) + /** + * 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: (obj: any, as_dom?: boolean) => JQuery; - /** - * get the next visible node that is below the obj node. - * If strict is set to true only sibling nodes are returned. + /** + * 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_next_dom: (obj:any,strict?:boolean) => JQuery; - /** - * get the previous visible node that is above the obj node. - * If strict is set to true only sibling nodes are returned. + get_path: (obj:any, glue:string, ids:boolean) => JQuery; + /** + * 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: (obj:any, strict?:boolean) => JQuery; + /** + * 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: (obj: any, strict?: boolean) => JQuery; - /** - * get the parent ID of a node + /** + * get the parent ID of a node + * @name get_parent(obj) + * @param {mixed} obj + * @return {String} */ get_parent: (obj: any) => string; - /** - * get a jQuery collection of all the children of a node (node must be rendered) + /** + * 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: (obj: any) => JQuery; - /** - * checks if a node has children + /** + * checks if a node has children + * @name is_parent(obj) + * @param {mixed} obj + * @return {Boolean} */ is_parent: (obj: any) => boolean; - /** - * checks if a node is loaded (its children are available) + /** + * checks if a node is loaded (its children are available) + * @name is_loaded(obj) + * @param {mixed} obj + * @return {Boolean} */ is_loaded: (obj: any) => boolean; - /** - * check if a node is currently loading (fetching children) + /** + * check if a node is currently loading (fetching children) + * @name is_loading(obj) + * @param {mixed} obj + * @return {Boolean} */ is_loading: (obj: any) => boolean; - /** - * check if a node is opened + /** + * check if a node is opened + * @name is_open(obj) + * @param {mixed} obj + * @return {Boolean} */ is_open: (obj: any) => boolean; - /** - * check if a node is in a closed state + /** + * check if a node is in a closed state + * @name is_closed(obj) + * @param {mixed} obj + * @return {Boolean} */ is_closed: (obj: any) => boolean; - /** - * check if a node has no children + /** + * check if a node has no children + * @name is_leaf(obj) + * @param {mixed} obj + * @return {Boolean} */ is_leaf: (obj: any) => boolean; - /** - * loads a node (fetches its children using the core.data setting). - * Multiple nodes can be passed to by using an array. - * @param obj mixed - * @param callback a function to be executed once loading is conplete, - * the function is executed in the instance's scope and receives two arguments - * the node and a boolean status + /** + * 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 conplete, 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: (obj: any, callback: any) => boolean; - /** - * redraws all nodes that need to be redrawn or optionally - the whole tree - * @param full if set to `true` all nodes are redrawn. + /** + * 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: (full?: boolean) => void; - /** - * opens a node, revaling its children. If the node is not loaded - * it will be loaded and opened once ready. - * @param obj the node to open - * @param callback a function to execute once the node is opened - * @param animation the animation duration in milliseconds when opening the node - * (overrides the `core.animation` setting). Use `false` for no animation. + /** + * 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: (obj: any, callback?: any, animation?: any) => void; - /** - * opens a node, revaling its children. If the node is not loaded - * it will be loaded and opened once ready. - * @param obj the node to close - * @param animation the animation duration in milliseconds when closing the node - * (overrides the `core.animation` setting). Use `false` for no animation. + /** + * 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: (obj: any, animation?: any) => void; - /** - * toggles a node - closing it if it is open, opening it if it is closed + /** + * 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: (obj: any) => void; - /** - * 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. - * @param obj the node to open recursively, omit to open all nodes in the tree - * @param animation the animation duration in milliseconds when opening the nodes, the default is no animation - * @param original_obj to the node that started the process (internal use) + /** + * 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: (obj?: any, animation?: number, original_obj?: any) => void; - /** - * closes all nodes within a node (or the tree), revaling their children - * @param obj the node to close recursively, omit to close all nodes in the tree - * @param animation the animation duration in milliseconds when closing the nodes, the default is no animation + /** + * 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: (obj?: any, animation?: number) => void; - /** - * checks if a node is disabled (not selectable) + /** + * checks if a node is disabled (not selectable) + * @name is_disabled(obj) + * @param {mixed} obj + * @return {Boolean} */ is_disabled: (obj: any) => boolean; - /** - * enables a node - so that it can be selected + /** + * 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: (obj: any) => boolean; - /** - * disables a node - so that it can not be selected + /** + * 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: (obj: any) => boolean; - /** - * select a node - * @param obj an array can be used to select multiple nodes - * @param supress_event if set to `true` the `changed.jstree` event won't be triggered - * @param prevent_open if set to `true` parents of the selected node won't be opened + /** + * 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: (obj: any, supress_event?: boolean, prevent_open?: boolean) => void; - /** - * deselect a node - * @param obj an array can be used to deselect multiple nodes - * @param supress_event if set to `true` the `changed.jstree` event won't be triggered + select_node: (obj: any, supress_event?: boolean, prevent_open?: boolean, e?:any) => void; + /** + * 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: (obj: any, supress_event?: boolean) => void; - /** - * select all nodes in the tree - * @param supress_event if set to `true` the `changed.jstree` event won't be triggered + deselect_node: (obj: any, supress_event?: boolean, e?:any) => void; + /** + * 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: (supress_event?: boolean) => void; - /** - * deselect all selected nodes - * @param supress_event if set to `true` the `changed.jstree` event won't be triggered + /** + * 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: (supress_event?: boolean) => void; - /** - * checks if a node is selected + /** + * checks if a node is selected + * @name is_selected(obj) + * @param {mixed} obj + * @return {Boolean} */ is_selected: (obj: any) => boolean; - /** - * get an array of all selected node IDs - * @param full if set to `true` the returned array will consist of the full node objects, - * otherwise - only IDs will be returned + /** + * 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: (full?: any) => string[]; - /** - * refreshes the tree - all nodes are reloaded with calls to load_node. + /** + * 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} */ - refresh: () => void; - /** - * set (change) the ID of a node - * @param obj the node - * @param id the new ID + get_top_selected: (full?: any) => string[]; + /** + * get an array of all bottom level selected nodes (ignoring selected parents) + * @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_bottom_selected: (full?: any) => string[]; + /** + * 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 + * @trigger refresh.jstree + */ + refresh: (skip_loading:boolean) => void; + /** + * 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 {Boolean} skip_loading an option to skip showing the loading indicator + * @trigger refresh.jstree + */ + refresh_node: (obj:any) => void; + /** + * 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: (obj: any, id: string) => void; - /** - * get the text value of a node + /** + * get the text value of a node + * @name get_text(obj) + * @param {mixed} obj the node + * @return {String} */ get_text: (obj: any) => string; - /** - * gets a JSON representation of a node (or the whole tree) + /** + * 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: (obj?: any, options?: JSTreeGetJsonOptions) => any; - /** - * create a new node (do not confuse with load_node) - * @param obj the parent node - * @param node the data for the new node (a valid JSON object, or a simple string with the name) - * @param pos the index at which to insert the node, "first" and "last" are also supported, default is "last" - * @param callback a function to be called once the node is created - * @param is_loaded internal argument indicating if the parent node was succesfully loaded - * @returns the ID of the newly create node + /** + * 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: (obj?: any, node?: any, pos?: any, callback?: any, is_loaded?: boolean) => string; - /** - * set the text value of a node - * @param obj the node, you can pass an array to rename multiple nodes to the same name - * @param val the new text value + /** + * 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: (obj: any, val: string) => boolean; - /** - * remove a node - * @param obj the node, you can pass an array to delete multiple nodes + /** + * 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: (obj: any) => boolean; - /** - * move a node to a new parent - * @param obj the node to move, pass an array to move multiple nodes - * @param par the new parent - * @param pos the position to insert at ("first" and "last" are supported, as well as "before" and "after"), defaults to `0` - * @param callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position - * @param internal parameter indicating if the parent node has been loaded + /** + * get the last error + * @name last_error() + * @return {Object} + */ + last_error: () => any; + /** + * 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 + * @trigger move_node.jstree */ move_node: (obj: any, par: any, pos?: any, callback?: any, internal?: boolean) => void; - /** - * copy a node to a new parent - * @param obj the node to copy, pass an array to copy multiple nodes - * @param par the new parent - * @param pos the position to insert at ("first" and "last" are supported, as well as "before" and "after"), defaults to `0` - * @param callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position - * @param internal parameter indicating if the parent node has been loaded + /** + * 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 + * @trigger model.jstree copy_node.jstree */ copy_node: (obj: any, par: any, pos?: any, callback?: any, internal?: boolean) => void; - /** - * cut a node (a later call to paste(obj) would move the node) - * @param obj multiple objects can be passed using an array + /** + * 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: (obj: any) => void; - /** - * copy a node (a later call to paste(obj) would copy the node) - * @param obj multiple objects can be passed using an array + /** + * 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: (obj: any) => void; - /** - * get the current buffer (any nodes that are waiting for a paste operation) - * @returns an object consisting of `mode` ("copy_node" or "move_node"), - * `node` (an array of objects) and `inst` (the instance) + /** + * 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: () => any; - /** - * check if there is something in the buffer to paste + /** + * check if there is something in the buffer to paste + * @name can_paste() + * @return {Boolean} */ can_paste: () => boolean; - /** - * copy or move the previously cut or copied nodes to a new parent - * @param obj the new parent + /** + * 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: (obj: any) => void; - /** - * put a node in edit mode (input field to rename the node) - * @param obj - * @param default_text the text to populate the input with (if omitted the node text value is used) + /** + * 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: (obj: any, default_text?: string) => void; - /** - * changes the theme - * @param theme_name the name of the new theme to apply - * @param 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. + /** + * 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: (theme_name: string, theme_url?: any) => void; - /** - * gets the name of the currently applied theme name + /** + * gets the name of the currently applied theme name + * @name get_theme() + * @return {String} */ get_theme: () => string; - /** - * changes the theme variant (if the theme has variants) - * @param variant_name the variant to apply (if `false` is used the current variant is removed) + /** + * 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: (variant_name: any) => void; - /** - * gets the name of the currently applied theme variant name + /** + * gets the name of the currently applied theme variant + * @name get_theme() + * @return {String} */ get_theme_variant: () => string; - /** - * shows a striped background on the container (if the theme supports it) + /** + * shows a striped background on the container (if the theme supports it) + * @name show_stripes() */ show_stripes: () => void; - /** - * hides the striped background on the container + /** + * hides the striped background on the container + * @name hide_stripes() */ hide_stripes: () => void; - /** - * toggles the striped background on the container + /** + * toggles the striped background on the container + * @name toggle_stripes() */ toggle_stripes: () => void; - /** - * shows the connecting dots (if the theme supports it) + /** + * shows the connecting dots (if the theme supports it) + * @name show_dots() */ show_dots: () => void; - /** - * hides the connecting dots + /** + * hides the connecting dots + * @name hide_dots() */ hide_dots: () => void; - /** - * toggles the connecting dots + /** + * toggles the connecting dots + * @name toggle_dots() */ toggle_dots: () => void; - /** - * show the node icons + /** + * show the node icons + * @name show_icons() */ show_icons: () => void; - /** - * hide the node icons + /** + * hide the node icons + * @name hide_icons() */ hide_icons: () => void; - /** - * toggle the node icons + /** + * toggle the node icons + * @name toggle_icons() */ toggle_icons: () => void; - /** - * set the node icon for a node - * @param obj - * @param 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 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: (obj: any, icon: string) => void; - /** - * get the node icon for a node + /** + * get the node icon for a node + * @name get_icon(obj) + * @param {mixed} obj + * @return {String} */ get_icon: (obj: any) => string; - /** - * hide the icon on an individual node + /** + * hide the icon on an individual node + * @name hide_icon(obj) + * @param {mixed} obj */ hide_icon: (obj: any) => void; - /** - * show the icon on an individual node + /** + * show the icon on an individual node + * @name show_icon(obj) + * @param {mixed} obj */ show_icon: (obj: any) => void; /** @@ -703,66 +986,96 @@ interface JSTree extends JQuery { redraw_node: (obj: any, deep:boolean, is_callback:boolean) => any; activate_node: (obj: any, e: any) => any; - /* - * checkbox plugin: show the node checkbox icons + /** + * show the node checkbox icons + * @name show_checkboxes() + * @plugin checkbox */ show_checkboxes: () => void; - /* - * checkbox plugin: hide the node checkbox icons + /** + * hide the node checkbox icons + * @name hide_checkboxes() + * @plugin checkbox */ hide_checkboxes: () => void; - /* - * checkbox plugin: toggle the node icons + /** + * toggle the node icons + * @name toggle_checkboxes() + * @plugin checkbox */ toggle_checkboxes: () => void; /** * context menu plugin */ teardown: () => void; - /** - * context menu plugin: show the context menu for a node - * @param obj the node - * @param x the x-coordinate relative to the document to show the menu at - * @param y the y-coordinate relative to the document to show the menu at + /** + * 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 */ - show_contextmenu: (obj: any, x?: number, y?: number) => void; - /** - * search plugin: used to search the tree nodes for a given string - * @param str the search string - * @param skip_async if set to true server will not be queried even if configured + show_contextmenu: (obj: any, x?: number, y?: number, e?:any) => void; + /** + * 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 + * @plugin search + * @trigger search.jstree */ search: (str: string, skip_async?: boolean) => void; - /** - * search plugin: used to clear the last search (removes classes and shows all nodes if filtering is on) + /** + * 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 */ clear_search: () => void; - /** - * state plugin: save the state + /** + * save the state + * @name save_state() + * @plugin state */ save_state: () => void; - /** - * state plugin: restore the state from the user's computer + /** + * restore the state from the user's computer + * @name restore_state() + * @plugin state */ restore_state: () => void; - /** - * state plugin: clear the state on the user's computer + /** + * clear the state on the user's computer + * @name clear_state() + * @plugin state */ clear_state: () => void; - /** - * types plugin: used to retrieve the type settings object for a node - * @param obj the node to find the rules for + /** + * 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 */ get_rules: (obj: any) => any; - /** - * types plugin: used to retrieve the type string or settings object for a node - * @param obj the node to find the rules for - * @param rules if set to `true` instead of a string the settings object will be returned + /** + * 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 */ get_type: (obj: any, rules?: any) => any; - /** - * types plugin: used to change a node's type - * @param obj the node to change - * @param type the new 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 */ set_type: (obj: any, type: string) => any; //bind(eventType: string, handler?: (event: any, data: JSTreeBindOptions) => any): JSTree; @@ -788,4 +1101,4 @@ interface JSTreeBindOptions { args?: any; rslt?: any; rlbk?: any; -} \ No newline at end of file +}