jstree-rails-4 3.3.3 → 3.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e38671e9e216082caf625aaf59c40a125492ad2
4
- data.tar.gz: 4d33d52ed69182d6b87b42615c5cc8bfdc0eb004
3
+ metadata.gz: fc466fd09787baf263981593e1e218175853cc0e
4
+ data.tar.gz: 339f485ad09c8bc3f9df4c381ad8766625263d52
5
5
  SHA512:
6
- metadata.gz: 9b6acdb78d4c4b24575a8efbeebdfdffc45f66d6641e83ff0301589e3eb9244dd57b873433a06ff0dcca07a572d3a908b24030ed5239f4c8c7567c9c889d8eb4
7
- data.tar.gz: e2544fd84ca1b7831edcd31a956276a2a9cee12bce5386c5df86f5f67c1a22083a70c99f134ded69a9dd069602d22c6161e9776870c97deefda2be2af84635dd
6
+ metadata.gz: 49bacacf259e1a723d3d773af2f66116c768bec96d09a737a04ba2599be14dee7c81ca6d33e5d875c1144fa6e11e0aafa50adad0efcac8ebb014bf055bf2d343
7
+ data.tar.gz: c2bb926645064947f28980b8eb9d6a5feff6d18f4b8ff701d61f1b978c9ad8c0ad0ce832001f70d2a78134162f7b167e7ba88455d91e0e574518065d5a108639
data/Gemfile.lock CHANGED
@@ -1,112 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jstree-rails-4 (3.3.3)
4
+ jstree-rails-4 (3.3.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- actionmailer (4.2.3)
10
- actionpack (= 4.2.3)
11
- actionview (= 4.2.3)
12
- activejob (= 4.2.3)
13
- mail (~> 2.5, >= 2.5.4)
14
- rails-dom-testing (~> 1.0, >= 1.0.5)
15
- actionpack (4.2.3)
16
- actionview (= 4.2.3)
17
- activesupport (= 4.2.3)
18
- rack (~> 1.6)
19
- rack-test (~> 0.6.2)
20
- rails-dom-testing (~> 1.0, >= 1.0.5)
21
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
22
- actionview (4.2.3)
23
- activesupport (= 4.2.3)
24
- builder (~> 3.1)
25
- erubis (~> 2.7.0)
26
- rails-dom-testing (~> 1.0, >= 1.0.5)
27
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
- activejob (4.2.3)
29
- activesupport (= 4.2.3)
30
- globalid (>= 0.3.0)
31
- activemodel (4.2.3)
32
- activesupport (= 4.2.3)
33
- builder (~> 3.1)
34
- activerecord (4.2.3)
35
- activemodel (= 4.2.3)
36
- activesupport (= 4.2.3)
37
- arel (~> 6.0)
38
- activesupport (4.2.3)
39
- i18n (~> 0.7)
40
- json (~> 1.7, >= 1.7.7)
41
- minitest (~> 5.1)
42
- thread_safe (~> 0.3, >= 0.3.4)
43
- tzinfo (~> 1.1)
44
- arel (6.0.3)
45
- builder (3.2.2)
46
- erubis (2.7.0)
47
- globalid (0.3.6)
48
- activesupport (>= 4.1.0)
49
9
  httpclient (2.8.3)
50
- i18n (0.7.0)
51
- json (1.8.6)
52
- loofah (2.0.2)
53
- nokogiri (>= 1.5.9)
54
- mail (2.6.3)
55
- mime-types (>= 1.16, < 3)
56
- mime-types (2.6.1)
57
- mini_portile (0.6.2)
58
- minitest (5.8.0)
59
- nokogiri (1.6.6.2)
60
- mini_portile (~> 0.6.0)
61
- rack (1.6.4)
62
- rack-test (0.6.3)
63
- rack (>= 1.0)
64
- rails (4.2.3)
65
- actionmailer (= 4.2.3)
66
- actionpack (= 4.2.3)
67
- actionview (= 4.2.3)
68
- activejob (= 4.2.3)
69
- activemodel (= 4.2.3)
70
- activerecord (= 4.2.3)
71
- activesupport (= 4.2.3)
72
- bundler (>= 1.3.0, < 2.0)
73
- railties (= 4.2.3)
74
- sprockets-rails
75
- rails-deprecated_sanitizer (1.0.3)
76
- activesupport (>= 4.2.0.alpha)
77
- rails-dom-testing (1.0.6)
78
- activesupport (>= 4.2.0.beta, < 5.0)
79
- nokogiri (~> 1.6.0)
80
- rails-deprecated_sanitizer (>= 1.0.1)
81
- rails-html-sanitizer (1.0.2)
82
- loofah (~> 2.0)
83
- railties (4.2.3)
84
- actionpack (= 4.2.3)
85
- activesupport (= 4.2.3)
86
- rake (>= 0.8.7)
87
- thor (>= 0.18.1, < 2.0)
88
- rake (10.4.2)
89
- sprockets (3.2.0)
90
- rack (~> 1.0)
91
- sprockets-rails (2.3.2)
92
- actionpack (>= 3.0)
93
- activesupport (>= 3.0)
94
- sprockets (>= 2.8, < 4.0)
10
+ json (2.0.3)
95
11
  thor (0.19.1)
96
- thread_safe (0.3.5)
97
- tzinfo (1.2.2)
98
- thread_safe (~> 0.1)
99
12
 
100
13
  PLATFORMS
101
14
  ruby
102
15
 
103
16
  DEPENDENCIES
104
17
  bundler (~> 1.14)
105
- httpclient (~> 2.8)
106
- json (~> 1.8.6)
18
+ httpclient (~> 2.8.3)
19
+ json (~> 2.0.3)
107
20
  jstree-rails-4!
108
- rails (>= 4.0)
109
21
  thor (~> 0.19)
110
22
 
111
23
  BUNDLED WITH
112
- 1.14.0
24
+ 1.14.6
data/LICENSE CHANGED
@@ -1,21 +1,24 @@
1
- The MIT License (MIT)
1
+ This is free and unencumbered software released into the public domain.
2
2
 
3
- Copyright (c) 2015 Innokentii Antonov
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
4
7
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
11
15
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
14
23
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
24
+ For more information, please refer to <http://unlicense.org>
data/README.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  The `jstree-rails-4` gem integrates the `jsTree` jQuery plugin with the Rails asset pipeline.
6
6
 
7
- GemVersion: 3.3.3
7
+ GemVersion: 3.3.4
8
8
 
9
- jsTree Version: 3.3.3
9
+ jsTree Version: 3.3.4
10
10
 
11
11
  ## Usage
12
12
 
@@ -45,7 +45,8 @@ Use command line:
45
45
  * bundle install
46
46
  * ruby -r './lib/jstree-rails-4/source_file.rb' -e 'SourceFile.new.fetch'
47
47
  * Choose version and enter 'Y' on each request
48
+ * ruby -r './lib/jstree-rails-4/source_file.rb' -e 'SourceFile.new.convert'
48
49
 
49
50
  ## License
50
51
 
51
- jsTree-Rails-4 is released under the [MIT License](http://www.opensource.org/licenses/MIT).
52
+ jsTree-Rails-4 is [free and unencumbered software released into the public domain](http://unlicense.org).
@@ -15,9 +15,8 @@ Gem::Specification.new do |s|
15
15
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
16
  s.require_paths = ["lib"]
17
17
 
18
- s.add_development_dependency "json", "~> 1.8.6"
18
+ s.add_development_dependency "json", "~> 2.0.3"
19
19
  s.add_development_dependency "thor", "~> 0.19"
20
20
  s.add_development_dependency "bundler", "~> 1.14"
21
- s.add_development_dependency "rails", ">= 4.0"
22
- s.add_development_dependency "httpclient", "~> 2.8"
21
+ s.add_development_dependency "httpclient", "~> 2.8.3"
23
22
  end
@@ -1,5 +1,5 @@
1
1
  module JSTree
2
2
  module Rails
3
- VERSION = '3.3.3'
3
+ VERSION = '3.3.4'
4
4
  end
5
5
  end
@@ -13,7 +13,7 @@
13
13
  }(function ($, undefined) {
14
14
  "use strict";
15
15
  /*!
16
- * jsTree 3.3.3
16
+ * jsTree 3.3.4
17
17
  * http://jstree.com/
18
18
  *
19
19
  * Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
@@ -54,7 +54,7 @@
54
54
  * specifies the jstree version in use
55
55
  * @name $.jstree.version
56
56
  */
57
- version : '3.3.3',
57
+ version : '3.3.4',
58
58
  /**
59
59
  * holds all the default options used when creating new instances
60
60
  * @name $.jstree.defaults
@@ -338,7 +338,7 @@
338
338
  * $('#tree').jstree({
339
339
  * 'core' : {
340
340
  * 'check_callback' : function (operation, node, node_parent, node_position, more) {
341
- * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node' or 'copy_node'
341
+ * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node', 'copy_node' or 'edit'
342
342
  * // in case of 'rename_node' node_position is filled with the new node name
343
343
  * return operation === 'rename_node' ? true : false;
344
344
  * }
@@ -515,7 +515,7 @@
515
515
  .remove();
516
516
  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>");
517
517
  this.element.attr('aria-activedescendant','j' + this._id + '_loading');
518
- this._data.core.li_height = this.get_container_ul().children("li").first().height() || 24;
518
+ this._data.core.li_height = this.get_container_ul().children("li").first().outerHeight() || 24;
519
519
  this._data.core.node = this._create_prototype_node();
520
520
  /**
521
521
  * triggered after the loading text is shown and before loading starts
@@ -531,6 +531,12 @@
531
531
  * @param {Boolean} keep_html if not set to `true` the container will be emptied, otherwise the current DOM elements will be kept intact
532
532
  */
533
533
  destroy : function (keep_html) {
534
+ /**
535
+ * triggered before the tree is destroyed
536
+ * @event
537
+ * @name destroy.jstree
538
+ */
539
+ this.trigger("destroy");
534
540
  if(this._wrk) {
535
541
  try {
536
542
  window.URL.revokeObjectURL(this._wrk);
@@ -1400,12 +1406,18 @@
1400
1406
  return callback.call(this, false);
1401
1407
  }, this))
1402
1408
  .fail($.proxy(function (f) {
1403
- callback.call(this, false);
1404
1409
  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 }) };
1410
+ callback.call(this, false);
1405
1411
  this.settings.core.error.call(this, this._data.core.last_error);
1406
1412
  }, this));
1407
1413
  }
1408
- t = ($.isArray(s) || $.isPlainObject(s)) ? JSON.parse(JSON.stringify(s)) : s;
1414
+ if ($.isArray(s)) {
1415
+ t = $.extend(true, [], s);
1416
+ } else if ($.isPlainObject(s)) {
1417
+ t = $.extend(true, {}, s);
1418
+ } else {
1419
+ t = s;
1420
+ }
1409
1421
  if(obj.id === $.jstree.root) {
1410
1422
  return this._append_json_data(obj, t, function (status) {
1411
1423
  callback.call(this, status);
@@ -3386,6 +3398,9 @@
3386
3398
  */
3387
3399
  set_state : function (state, callback) {
3388
3400
  if(state) {
3401
+ if(state.core && state.core.selected && state.core.initial_selection === undefined) {
3402
+ state.core.initial_selection = this._data.core.selected.concat([]).sort().join(',');
3403
+ }
3389
3404
  if(state.core) {
3390
3405
  var res, n, t, _this, i;
3391
3406
  if(state.core.open) {
@@ -3415,10 +3430,15 @@
3415
3430
  }
3416
3431
  if(state.core.selected) {
3417
3432
  _this = this;
3418
- this.deselect_all();
3419
- $.each(state.core.selected, function (i, v) {
3420
- _this.select_node(v, false, true);
3421
- });
3433
+ if (state.core.initial_selection === undefined ||
3434
+ state.core.initial_selection === this._data.core.selected.concat([]).sort().join(',')
3435
+ ) {
3436
+ this.deselect_all();
3437
+ $.each(state.core.selected, function (i, v) {
3438
+ _this.select_node(v, false, true);
3439
+ });
3440
+ }
3441
+ delete state.core.initial_selection;
3422
3442
  delete state.core.selected;
3423
3443
  this.set_state(state, callback);
3424
3444
  return false;
@@ -3640,7 +3660,7 @@
3640
3660
  'li_attr' : $.extend(true, {}, obj.li_attr),
3641
3661
  'a_attr' : $.extend(true, {}, obj.a_attr),
3642
3662
  'state' : {},
3643
- 'data' : options && options.no_data ? false : $.extend(true, {}, obj.data)
3663
+ 'data' : options && options.no_data ? false : $.extend(true, $.isArray(obj.data)?[]:{}, obj.data)
3644
3664
  //( this.get_node(obj, true).length ? this.get_node(obj, true).data() : obj.data ),
3645
3665
  }, i, j;
3646
3666
  if(options && options.flat) {
@@ -3708,7 +3728,11 @@
3708
3728
  return this.load_node(par, function () { this.create_node(par, node, pos, callback, true); });
3709
3729
  }
3710
3730
  if(!node) { node = { "text" : this.get_string('New node') }; }
3711
- if(typeof node === "string") { node = { "text" : node }; }
3731
+ if(typeof node === "string") {
3732
+ node = { "text" : node };
3733
+ } else {
3734
+ node = $.extend(true, {}, node);
3735
+ }
3712
3736
  if(node.text === undefined) { node.text = this.get_string('New node'); }
3713
3737
  var tmp, dpc, i, j;
3714
3738
 
@@ -3766,7 +3790,6 @@
3766
3790
  par.children = tmp;
3767
3791
 
3768
3792
  this.redraw_node(par, true);
3769
- if(callback) { callback.call(this, this.get_node(node)); }
3770
3793
  /**
3771
3794
  * triggered when a node is created
3772
3795
  * @event
@@ -3776,6 +3799,7 @@
3776
3799
  * @param {Number} position the position of the new node among the parent's children
3777
3800
  */
3778
3801
  this.trigger('create_node', { "node" : this.get_node(node), "parent" : par.id, "position" : pos });
3802
+ if(callback) { callback.call(this, this.get_node(node)); }
3779
3803
  return node.id;
3780
3804
  },
3781
3805
  /**
@@ -4359,8 +4383,7 @@
4359
4383
  var rtl, w, a, s, t, h1, h2, fn, tmp, cancel = false;
4360
4384
  obj = this.get_node(obj);
4361
4385
  if(!obj) { return false; }
4362
- if(this.settings.core.check_callback === false) {
4363
- this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_07', 'reason' : 'Could not edit node because of check_callback' };
4386
+ if(!this.check("edit", obj, this.get_parent(obj))) {
4364
4387
  this.settings.core.error.call(this, this._data.core.last_error);
4365
4388
  return false;
4366
4389
  }
@@ -4915,7 +4938,21 @@
4915
4938
  * @name $.jstree.defaults.checkbox.tie_selection
4916
4939
  * @plugin checkbox
4917
4940
  */
4918
- tie_selection : true
4941
+ tie_selection : true,
4942
+
4943
+ /**
4944
+ * This setting controls if cascading down affects disabled checkboxes
4945
+ * @name $.jstree.defaults.checkbox.cascade_to_disabled
4946
+ * @plugin checkbox
4947
+ */
4948
+ cascade_to_disabled : true,
4949
+
4950
+ /**
4951
+ * This setting controls if cascading down affects hidden checkboxes
4952
+ * @name $.jstree.defaults.checkbox.cascade_to_hidden
4953
+ * @plugin checkbox
4954
+ */
4955
+ cascade_to_hidden : true
4919
4956
  };
4920
4957
  $.jstree.plugins.checkbox = function (options, parent) {
4921
4958
  this.bind = function () {
@@ -4976,6 +5013,7 @@
4976
5013
  for(i = 0, j = dpc.length; i < j; i++) {
4977
5014
  m[dpc[i]].state[ t ? 'selected' : 'checked' ] = true;
4978
5015
  }
5016
+
4979
5017
  this._data[ t ? 'core' : 'checkbox' ].selected = this._data[ t ? 'core' : 'checkbox' ].selected.concat(dpc);
4980
5018
  }
4981
5019
  else {
@@ -5024,27 +5062,29 @@
5024
5062
  this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected);
5025
5063
  }, this))
5026
5064
  .on(this.settings.checkbox.tie_selection ? 'select_node.jstree' : 'check_node.jstree', $.proxy(function (e, data) {
5027
- var obj = data.node,
5065
+ var self = this,
5066
+ obj = data.node,
5028
5067
  m = this._model.data,
5029
5068
  par = this.get_node(obj.parent),
5030
- dom = this.get_node(obj, true),
5031
5069
  i, j, c, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection,
5032
5070
  sel = {}, cur = this._data[ t ? 'core' : 'checkbox' ].selected;
5033
5071
 
5034
5072
  for (i = 0, j = cur.length; i < j; i++) {
5035
5073
  sel[cur[i]] = true;
5036
5074
  }
5075
+
5037
5076
  // apply down
5038
5077
  if(s.indexOf('down') !== -1) {
5039
5078
  //this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected.concat(obj.children_d));
5040
- for(i = 0, j = obj.children_d.length; i < j; i++) {
5041
- sel[obj.children_d[i]] = true;
5042
- tmp = m[obj.children_d[i]];
5043
- tmp.state[ t ? 'selected' : 'checked' ] = true;
5044
- if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) {
5045
- tmp.original.state.undetermined = false;
5046
- }
5047
- }
5079
+ var selectedIds = this._cascade_new_checked_state(obj.id, true);
5080
+ obj.children_d.concat(obj.id).forEach(function(id) {
5081
+ if (selectedIds.indexOf(id) > -1) {
5082
+ sel[id] = true;
5083
+ }
5084
+ else {
5085
+ delete sel[id];
5086
+ }
5087
+ });
5048
5088
  }
5049
5089
 
5050
5090
  // apply up
@@ -5077,11 +5117,6 @@
5077
5117
  }
5078
5118
  }
5079
5119
  this._data[ t ? 'core' : 'checkbox' ].selected = cur;
5080
-
5081
- // apply down (process .children separately?)
5082
- if(s.indexOf('down') !== -1 && dom.length) {
5083
- dom.find('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked').parent().attr('aria-selected', true);
5084
- }
5085
5120
  }, this))
5086
5121
  .on(this.settings.checkbox.tie_selection ? 'deselect_all.jstree' : 'uncheck_all.jstree', $.proxy(function (e, data) {
5087
5122
  var obj = this.get_node($.jstree.root),
@@ -5095,27 +5130,26 @@
5095
5130
  }
5096
5131
  }, this))
5097
5132
  .on(this.settings.checkbox.tie_selection ? 'deselect_node.jstree' : 'uncheck_node.jstree', $.proxy(function (e, data) {
5098
- var obj = data.node,
5133
+ var self = this,
5134
+ obj = data.node,
5099
5135
  dom = this.get_node(obj, true),
5100
5136
  i, j, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection,
5101
- cur = this._data[ t ? 'core' : 'checkbox' ].selected, sel = {};
5102
- if(obj && obj.original && obj.original.state && obj.original.state.undetermined) {
5103
- obj.original.state.undetermined = false;
5104
- }
5137
+ cur = this._data[ t ? 'core' : 'checkbox' ].selected, sel = {},
5138
+ stillSelectedIds = [],
5139
+ allIds = obj.children_d.concat(obj.id);
5105
5140
 
5106
5141
  // apply down
5107
5142
  if(s.indexOf('down') !== -1) {
5108
- for(i = 0, j = obj.children_d.length; i < j; i++) {
5109
- tmp = this._model.data[obj.children_d[i]];
5110
- tmp.state[ t ? 'selected' : 'checked' ] = false;
5111
- if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) {
5112
- tmp.original.state.undetermined = false;
5113
- }
5114
- }
5143
+ var selectedIds = this._cascade_new_checked_state(obj.id, false);
5144
+
5145
+ cur = cur.filter(function(id) {
5146
+ return allIds.indexOf(id) === -1 || selectedIds.indexOf(id) > -1;
5147
+ });
5115
5148
  }
5116
5149
 
5117
- // apply up
5118
- if(s.indexOf('up') !== -1) {
5150
+ // only apply up if cascade up is enabled and if this node is not selected
5151
+ // (if all child nodes are disabled and cascade_to_disabled === false then this node will till be selected).
5152
+ if(s.indexOf('up') !== -1 && cur.indexOf(obj.id) === -1) {
5119
5153
  for(i = 0, j = obj.parents.length; i < j; i++) {
5120
5154
  tmp = this._model.data[obj.parents[i]];
5121
5155
  tmp.state[ t ? 'selected' : 'checked' ] = false;
@@ -5127,29 +5161,13 @@
5127
5161
  tmp.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5128
5162
  }
5129
5163
  }
5164
+
5165
+ cur = cur.filter(function(id) {
5166
+ return obj.parents.indexOf(id) === -1;
5167
+ });
5130
5168
  }
5131
- sel = {};
5132
- for(i = 0, j = cur.length; i < j; i++) {
5133
- // apply down + apply up
5134
- if(
5135
- (s.indexOf('down') === -1 || $.inArray(cur[i], obj.children_d) === -1) &&
5136
- (s.indexOf('up') === -1 || $.inArray(cur[i], obj.parents) === -1)
5137
- ) {
5138
- sel[cur[i]] = true;
5139
- }
5140
- }
5141
- cur = [];
5142
- for (i in sel) {
5143
- if (sel.hasOwnProperty(i)) {
5144
- cur.push(i);
5145
- }
5146
- }
5169
+
5147
5170
  this._data[ t ? 'core' : 'checkbox' ].selected = cur;
5148
-
5149
- // apply down (process .children separately?)
5150
- if(s.indexOf('down') !== -1 && dom.length) {
5151
- dom.find('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked').parent().attr('aria-selected', false);
5152
- }
5153
5171
  }, this));
5154
5172
  }
5155
5173
  if(this.settings.checkbox.cascade.indexOf('up') !== -1) {
@@ -5240,6 +5258,7 @@
5240
5258
  }, this));
5241
5259
  }
5242
5260
  };
5261
+
5243
5262
  /**
5244
5263
  * set the undetermined state where and if necessary. Used internally.
5245
5264
  * @private
@@ -5266,6 +5285,9 @@
5266
5285
  this.element.find('.jstree-closed').not(':has(.jstree-children)')
5267
5286
  .each(function () {
5268
5287
  var tmp = tt.get_node(this), tmp2;
5288
+
5289
+ if(!tmp) { return; }
5290
+
5269
5291
  if(!tmp.state.loaded) {
5270
5292
  if(tmp.original && tmp.original.state && tmp.original.state.undetermined && tmp.original.state.undetermined === true) {
5271
5293
  if(o[tmp.id] === undefined && tmp.id !== $.jstree.root) {
@@ -5467,6 +5489,89 @@
5467
5489
  this.trigger('activate_node', { 'node' : this.get_node(obj) });
5468
5490
  };
5469
5491
 
5492
+ /**
5493
+ * Unchecks a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants).
5494
+ * However if these unaffected nodes are already selected their ids will be included in the returned array.
5495
+ * @param id
5496
+ * @param checkedState
5497
+ * @returns {Array} Array of all node id's (in this tree branch) that are checked.
5498
+ */
5499
+ this._cascade_new_checked_state = function(id, checkedState) {
5500
+ var self = this;
5501
+ var t = this.settings.checkbox.tie_selection;
5502
+ var node = this._model.data[id];
5503
+ var selectedNodeIds = [];
5504
+ var selectedChildrenIds = [];
5505
+
5506
+ if (
5507
+ (this.settings.checkbox.cascade_to_disabled || !node.state.disabled) &&
5508
+ (this.settings.checkbox.cascade_to_hidden || !node.state.hidden)
5509
+ ) {
5510
+ //First try and check/uncheck the children
5511
+ if (node.children) {
5512
+ node.children.forEach(function(childId) {
5513
+ var selectedChildIds = self._cascade_new_checked_state(childId, checkedState);
5514
+ selectedNodeIds = selectedNodeIds.concat(selectedChildIds);
5515
+ if (selectedChildIds.indexOf(childId) > -1) {
5516
+ selectedChildrenIds.push(childId);
5517
+ }
5518
+ });
5519
+ }
5520
+
5521
+ var dom = self.get_node(node, true);
5522
+
5523
+ //A node's state is undetermined if some but not all of it's children are checked/selected .
5524
+ var undetermined = selectedChildrenIds.length > 0 && selectedChildrenIds.length < node.children.length;
5525
+
5526
+ if(node.original && node.original.state && node.original.state.undetermined) {
5527
+ node.original.state.undetermined = undetermined;
5528
+ }
5529
+
5530
+ //If a node is undetermined then remove selected class
5531
+ if (undetermined) {
5532
+ node.state[ t ? 'selected' : 'checked' ] = false;
5533
+ dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5534
+ }
5535
+ //Otherwise, if the checkedState === true (i.e. the node is being checked now) and all of the node's children are checked (if it has any children),
5536
+ //check the node and style it correctly.
5537
+ else if (checkedState && selectedChildrenIds.length === node.children.length) {
5538
+ node.state[ t ? 'selected' : 'checked' ] = checkedState;
5539
+ selectedNodeIds.push(node.id);
5540
+
5541
+ dom.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5542
+ }
5543
+ else {
5544
+ node.state[ t ? 'selected' : 'checked' ] = false;
5545
+ dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5546
+ }
5547
+ }
5548
+ else {
5549
+ var selectedChildIds = this.get_checked_descendants(id);
5550
+
5551
+ if (node.state[ t ? 'selected' : 'checked' ]) {
5552
+ selectedChildIds.push(node.id);
5553
+ }
5554
+
5555
+ selectedNodeIds = selectedNodeIds.concat(selectedChildIds);
5556
+ }
5557
+
5558
+ return selectedNodeIds;
5559
+ };
5560
+
5561
+ /**
5562
+ * Gets ids of nodes selected in branch (of tree) specified by id (does not include the node specified by id)
5563
+ * @param id
5564
+ */
5565
+ this.get_checked_descendants = function(id) {
5566
+ var self = this;
5567
+ var t = self.settings.checkbox.tie_selection;
5568
+ var node = self._model.data[id];
5569
+
5570
+ return node.children_d.filter(function(_id) {
5571
+ return self._model.data[_id].state[ t ? 'selected' : 'checked' ];
5572
+ });
5573
+ };
5574
+
5470
5575
  /**
5471
5576
  * check a node (only if tie_selection in checkbox settings is false, otherwise select_node will be called internally)
5472
5577
  * @name check_node(obj)
@@ -5547,6 +5652,7 @@
5547
5652
  this.trigger('uncheck_node', { 'node' : obj, 'selected' : this._data.checkbox.selected, 'event' : e });
5548
5653
  }
5549
5654
  };
5655
+
5550
5656
  /**
5551
5657
  * checks all nodes in the tree (only if tie_selection in checkbox settings is false, otherwise select_all will be called internally)
5552
5658
  * @name check_all()
@@ -5717,6 +5823,7 @@
5717
5823
  // include the checkbox plugin by default
5718
5824
  // $.jstree.defaults.plugins.push("checkbox");
5719
5825
 
5826
+
5720
5827
  /**
5721
5828
  * ### Conditionalselect plugin
5722
5829
  *
@@ -5793,7 +5900,11 @@
5793
5900
  var inst = $.jstree.reference(data.reference),
5794
5901
  obj = inst.get_node(data.reference);
5795
5902
  inst.create_node(obj, {}, "last", function (new_node) {
5796
- setTimeout(function () { inst.edit(new_node); },0);
5903
+ try {
5904
+ inst.edit(new_node);
5905
+ } catch (ex) {
5906
+ setTimeout(function () { inst.edit(new_node); },0);
5907
+ }
5797
5908
  });
5798
5909
  }
5799
5910
  },
@@ -5894,6 +6005,9 @@
5894
6005
 
5895
6006
  var last_ts = 0, cto = null, ex, ey;
5896
6007
  this.element
6008
+ .on("init.jstree loading.jstree ready.jstree", $.proxy(function () {
6009
+ this.get_container_ul().addClass('jstree-contextmenu');
6010
+ }, this))
5897
6011
  .on("contextmenu.jstree", ".jstree-anchor", $.proxy(function (e, data) {
5898
6012
  if (e.target.tagName.toLowerCase() === 'input') {
5899
6013
  return;
@@ -6360,7 +6474,7 @@
6360
6474
 
6361
6475
  $(document)
6362
6476
  .on("mousedown.vakata.jstree", function (e) {
6363
- if(vakata_context.is_visible && !$.contains(vakata_context.element[0], e.target)) {
6477
+ if(vakata_context.is_visible && vakata_context.element[0] !== e.target && !$.contains(vakata_context.element[0], e.target)) {
6364
6478
  $.vakata.context.hide();
6365
6479
  }
6366
6480
  })
@@ -6551,8 +6665,9 @@
6551
6665
  marker.appendTo('body'); //.show();
6552
6666
  })
6553
6667
  .on('dnd_move.vakata.jstree', function (e, data) {
6668
+ var isDifferentNode = data.event.target !== lastev.target;
6554
6669
  if(opento) {
6555
- if (!data.event || data.event.type !== 'dragover' || data.event.target !== lastev.target) {
6670
+ if (!data.event || data.event.type !== 'dragover' || isDifferentNode) {
6556
6671
  clearTimeout(opento);
6557
6672
  }
6558
6673
  }
@@ -6651,7 +6766,10 @@
6651
6766
  }
6652
6767
  }
6653
6768
  if(v === 'i' && ref.parent().is('.jstree-closed') && ins.settings.dnd.open_timeout) {
6654
- opento = setTimeout((function (x, z) { return function () { x.open_node(z); }; }(ins, ref)), ins.settings.dnd.open_timeout);
6769
+ if (!data.event || data.event.type !== 'dragover' || isDifferentNode) {
6770
+ if (opento) { clearTimeout(opento); }
6771
+ opento = setTimeout((function (x, z) { return function () { x.open_node(z); }; }(ins, ref)), ins.settings.dnd.open_timeout);
6772
+ }
6655
6773
  }
6656
6774
  if(ok) {
6657
6775
  pn = ins.get_node(p, true);
@@ -105,6 +105,12 @@
105
105
  -ms-user-select: none;
106
106
  user-select: none;
107
107
  }
108
+ .jstree-contextmenu .jstree-anchor {
109
+ -webkit-user-select: none;
110
+ /* disable selection/Copy of UIWebView */
111
+ -webkit-touch-callout: none;
112
+ /* disable the IOS popup when long-press on a link */
113
+ }
108
114
  .vakata-context {
109
115
  display: none;
110
116
  }
@@ -105,6 +105,12 @@
105
105
  -ms-user-select: none;
106
106
  user-select: none;
107
107
  }
108
+ .jstree-contextmenu .jstree-anchor {
109
+ -webkit-user-select: none;
110
+ /* disable selection/Copy of UIWebView */
111
+ -webkit-touch-callout: none;
112
+ /* disable the IOS popup when long-press on a link */
113
+ }
108
114
  .vakata-context {
109
115
  display: none;
110
116
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jstree-rails-4
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kesha Antonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-13 00:00:00.000000000 Z
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.8.6
19
+ version: 2.0.3
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.8.6
26
+ version: 2.0.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,34 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.14'
55
- - !ruby/object:Gem::Dependency
56
- name: rails
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '4.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '4.0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: httpclient
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '2.8'
61
+ version: 2.8.3
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '2.8'
68
+ version: 2.8.3
83
69
  description: jsTree is jquery plugin, that provides interactive trees. It is absolutely
84
70
  free, open source and distributed under the MIT license.
85
71
  email:
@@ -127,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
113
  version: '0'
128
114
  requirements: []
129
115
  rubyforge_project:
130
- rubygems_version: 2.6.8
116
+ rubygems_version: 2.6.11
131
117
  signing_key:
132
118
  specification_version: 4
133
119
  summary: Integrate jsTree javascript library with Rails asset pipeline