Mercurial > repos > mingchen0919 > aurora_htseq
annotate vakata-jstree-3.3.5/src/jstree.conditionalselect.js @ 2:e08dd15646c6 draft
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1-dirty
author | mingchen0919 |
---|---|
date | Thu, 13 Dec 2018 23:45:31 -0500 |
parents | 803f4888f36a |
children |
rev | line source |
---|---|
0
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
1 /** |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
2 * ### Conditionalselect plugin |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
3 * |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
4 * This plugin allows defining a callback to allow or deny node selection by user input (activate node method). |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
5 */ |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
6 /*globals jQuery, define, exports, require, document */ |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
7 (function (factory) { |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
8 "use strict"; |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
9 if (typeof define === 'function' && define.amd) { |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
10 define('jstree.conditionalselect', ['jquery','jstree'], factory); |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
11 } |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
12 else if(typeof exports === 'object') { |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
13 factory(require('jquery'), require('jstree')); |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
14 } |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
15 else { |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
16 factory(jQuery, jQuery.jstree); |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
17 } |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
18 }(function ($, jstree, undefined) { |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
19 "use strict"; |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
20 |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
21 if($.jstree.plugins.conditionalselect) { return; } |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
22 |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
23 /** |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
24 * a callback (function) which is invoked in the instance's scope and receives two arguments - the node and the event that triggered the `activate_node` call. Returning false prevents working with the node, returning true allows invoking activate_node. Defaults to returning `true`. |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
25 * @name $.jstree.defaults.checkbox.visible |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
26 * @plugin checkbox |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
27 */ |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
28 $.jstree.defaults.conditionalselect = function () { return true; }; |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
29 $.jstree.plugins.conditionalselect = function (options, parent) { |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
30 // own function |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
31 this.activate_node = function (obj, e) { |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
32 if(this.settings.conditionalselect.call(this, this.get_node(obj), e)) { |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
33 return parent.activate_node.call(this, obj, e); |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
34 } |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
35 }; |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
36 }; |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
37 |
803f4888f36a
planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
mingchen0919
parents:
diff
changeset
|
38 })); |