Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 901b145

Browse files
committed
Fixed CS in select_tree
1 parent eaa92f8 commit 901b145

File tree

1 file changed

+44
-35
lines changed

1 file changed

+44
-35
lines changed

Resources/public/js/select_tree.js

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,64 @@
33
*/
44
var SelectTree = (function () {
55

6+
'use strict';
7+
68
var my = {};
79

810
my.initTree = function (config) {
9-
if (! 'rootNode' in config) {
10-
config.rootNode = "/";
11-
}
12-
jQuery(config.selector).jstree({
13-
"core": {
14-
"initially_load": config.path.expanded,
15-
"initially_open": config.path.preloaded
16-
},
17-
"plugins": [ "themes", "types", "ui", "json_data"],
18-
"json_data": {
19-
"ajax": {
20-
"url": config.ajax.children_url,
21-
"data": function (node) {
22-
if (node == -1) {
23-
return { 'root' : config.rootNode };
24-
} else {
25-
return { 'root' : jQuery(node).attr('id') };
11+
jQuery.extend({
12+
rootNode: '/',
13+
}, config);
14+
15+
jQuery(config.selector)
16+
.jstree({
17+
"core": {
18+
"initially_load": config.path.expanded,
19+
"initially_open": config.path.preloaded
20+
},
21+
"plugins": ["themes", "types", "ui", "json_data"],
22+
"json_data": {
23+
"ajax": {
24+
"url": config.ajax.children_url,
25+
"data": function (node) {
26+
if (-1 === node) {
27+
return { 'root' : config.rootNode };
28+
} else {
29+
return { 'root' : jQuery(node).attr('id') };
30+
}
2631
}
2732
}
33+
},
34+
"types": {
35+
"max_depth": -1,
36+
"max_children": -1,
37+
"valid_children": ["all"],
38+
"types": config.types
39+
},
40+
"ui": {
41+
"initially_select" : [config.selected]
2842
}
29-
},
30-
"types": {
31-
"max_depth": -1,
32-
"max_children": -1,
33-
"valid_children": [ "all"],
34-
"types": config.types
35-
},
36-
"ui": {
37-
"initially_select" : [ config.selected ]
38-
}
3943

40-
})
41-
.bind("select_node.jstree", function (event, data) {
42-
jQuery(config.output).val(data.rslt.obj.attr("id"));
43-
jQuery(config.output).trigger('change');
44-
})
45-
.delegate("a", "click", function (event, data) { event.preventDefault(); });
44+
})
45+
.bind("select_node.jstree", function (event, data) {
46+
jQuery(config.output).val(data.rslt.obj.attr("id"));
47+
jQuery(config.output).trigger('change');
48+
})
49+
.on("click", "a", function (event, data) {
50+
event.preventDefault();
51+
})
52+
;
53+
54+
jQuery(config.reset).on("click", function (e) {
55+
e.preventDefault();
4656

47-
jQuery(config.reset).bind("click", function(e) {
4857
jQuery(config.selector).jstree("deselect_all");
4958
jQuery(config.output).val("");
59+
5060
if (config.selectRootNode) {
5161
jQuery(config.selector).jstree("select", config.rootNode);
5262
jQuery(config.output).val(config.rootNode);
5363
}
54-
e.preventDefault();
5564
});
5665
};
5766

0 commit comments

Comments
 (0)