jqtree-rails 0.1.3 → 0.1.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,2 +1,3 @@
1
1
  source 'http://rubygems.org'
2
- gemspec
2
+
3
+ gem 'version'
data/Gemfile.lock CHANGED
@@ -1,64 +1,10 @@
1
- PATH
2
- remote: .
3
- specs:
4
- jqtree-rails (0.1.2)
5
- railties (>= 3.2.0, < 5.0)
6
- thor (~> 0.14)
7
- version (~> 1.0)
8
-
9
1
  GEM
10
2
  remote: http://rubygems.org/
11
3
  specs:
12
- actionpack (3.2.8)
13
- activemodel (= 3.2.8)
14
- activesupport (= 3.2.8)
15
- builder (~> 3.0.0)
16
- erubis (~> 2.7.0)
17
- journey (~> 1.0.4)
18
- rack (~> 1.4.0)
19
- rack-cache (~> 1.2)
20
- rack-test (~> 0.6.1)
21
- sprockets (~> 2.1.3)
22
- activemodel (3.2.8)
23
- activesupport (= 3.2.8)
24
- builder (~> 3.0.0)
25
- activesupport (3.2.8)
26
- i18n (~> 0.6)
27
- multi_json (~> 1.0)
28
- builder (3.0.3)
29
- erubis (2.7.0)
30
- hike (1.2.1)
31
- i18n (0.6.1)
32
- journey (1.0.4)
33
- json (1.7.5)
34
- multi_json (1.3.6)
35
- rack (1.4.1)
36
- rack-cache (1.2)
37
- rack (>= 0.4)
38
- rack-ssl (1.3.2)
39
- rack
40
- rack-test (0.6.2)
41
- rack (>= 1.0)
42
- railties (3.2.8)
43
- actionpack (= 3.2.8)
44
- activesupport (= 3.2.8)
45
- rack-ssl (~> 1.3.2)
46
- rake (>= 0.8.7)
47
- rdoc (~> 3.4)
48
- thor (>= 0.14.6, < 2.0)
49
- rake (0.9.2.2)
50
- rdoc (3.12)
51
- json (~> 1.4)
52
- sprockets (2.1.3)
53
- hike (~> 1.2)
54
- rack (~> 1.0)
55
- tilt (~> 1.1, != 1.3.0)
56
- thor (0.16.0)
57
- tilt (1.3.3)
58
4
  version (1.0.0)
59
5
 
60
6
  PLATFORMS
61
7
  ruby
62
8
 
63
9
  DEPENDENCIES
64
- jqtree-rails!
10
+ version
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4.2
data/jqtree-rails.gemspec CHANGED
@@ -2,22 +2,21 @@
2
2
  require File.expand_path('../lib/jqtree/rails/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = File.basename(__FILE__, '.gemspec')
5
+ s.name = 'jqtree-rails'
6
6
  s.version = JqTree::Rails::VERSION
7
- s.platform = Gem::Platform::RUBY
8
- s.authors = ["Ryan Scott Lewis", "Mario Uher"] # TODO:
9
- s.email = ["c00lryguy@gmail.com", "uher.mario@gmail.com"] # Pull from Git repo (see f.files)
10
- s.homepage = "http://rubygems.org/gems/#{s.name}"
7
+ s.authors = ["Ryan Scott Lewis", "Mario Uher"] # TODO:
8
+ s.email = ["ryan@rynet.us", "uher.mario@gmail.com"] # Pull from Git repo (see f.files)
9
+ s.homepage = "https://github.com/RyanScottLewis/jqtree-rails"
11
10
  s.summary = "Use jqTree with Rails 3"
12
11
  s.description = "This gem provides jqTree assets for your Rails 3 application."
13
12
 
14
13
  s.required_rubygems_version = ">= 1.3.6"
15
14
 
15
+ s.files = `git ls-files`.split("\n")
16
+
16
17
  s.add_dependency "railties", ">= 3.2.0", "< 5.0"
17
18
  s.add_dependency "thor", "~> 0.14" # TODO: Find out why this is needed
18
19
  s.add_dependency "version", "~> 1.0"
19
20
 
20
- s.files = `git ls-files`.split("\n")
21
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } # TODO: Remove
22
- s.require_path = 'lib' # TODO: Pretty sure this is implied, check gemspec specifications
21
+
23
22
  end
@@ -4,6 +4,6 @@ require 'version'
4
4
  module JqTree
5
5
  module Rails
6
6
  VERSION = Version.current
7
- JQTREE_VERSION = "0.13"
7
+ JQTREE_VERSION = "0.14"
8
8
  end
9
9
  end
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 1.3.3
1
+ // Generated by CoffeeScript 1.4.0
2
2
 
3
3
  /*
4
4
  Copyright 2012 Marco Braak
@@ -18,7 +18,7 @@ limitations under the License.
18
18
 
19
19
 
20
20
  (function() {
21
- var $, BorderDropHint, DragAndDropHandler, DragElement, FolderElement, GhostDropHint, JqTreeWidget, MouseWidget, Node, NodeElement, Position, SaveStateHandler, SelectNodeHandler, SimpleWidget, TRIANGLE_DOWN, TRIANGLE_RIGHT, Tree, html_escape, indexOf, json_escapable, json_meta, json_quote, json_str,
21
+ var $, BorderDropHint, DragAndDropHandler, DragElement, FolderElement, GhostDropHint, JqTreeWidget, MouseWidget, Node, NodeElement, Position, SaveStateHandler, ScrollHandler, SelectNodeHandler, SimpleWidget, TRIANGLE_DOWN, TRIANGLE_RIGHT, Tree, html_escape, indexOf, json_escapable, json_meta, json_quote, json_str,
22
22
  __slice = [].slice,
23
23
  __hasProp = {}.hasOwnProperty,
24
24
  __extends = 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; };
@@ -499,6 +499,11 @@ limitations under the License.
499
499
 
500
500
 
501
501
  Node.prototype.removeChild = function(node) {
502
+ var _this = this;
503
+ node.iterate(function(child) {
504
+ _this.tree.removeNodeFromIndex(child);
505
+ return true;
506
+ });
502
507
  this.children.splice(this.getChildIndex(node), 1);
503
508
  return this.tree.removeNodeFromIndex(node);
504
509
  };
@@ -749,6 +754,8 @@ limitations under the License.
749
754
 
750
755
  this.Tree.Tree = Tree;
751
756
 
757
+ this.Tree.Node = Node;
758
+
752
759
  TRIANGLE_RIGHT = '&#x25ba;';
753
760
 
754
761
  TRIANGLE_DOWN = '&#x25bc;';
@@ -774,14 +781,18 @@ limitations under the License.
774
781
  onCanMove: null,
775
782
  onCanMoveTo: null,
776
783
  autoEscape: true,
777
- dataUrl: null
784
+ dataUrl: null,
785
+ slide: true
778
786
  };
779
787
 
780
- JqTreeWidget.prototype.toggle = function(node) {
788
+ JqTreeWidget.prototype.toggle = function(node, slide) {
789
+ if (slide == null) {
790
+ slide = true;
791
+ }
781
792
  if (node.is_open) {
782
- return this.closeNode(node);
793
+ return this.closeNode(node, slide);
783
794
  } else {
784
- return this.openNode(node);
795
+ return this.openNode(node, slide);
785
796
  }
786
797
  };
787
798
 
@@ -789,8 +800,8 @@ limitations under the License.
789
800
  return this.tree;
790
801
  };
791
802
 
792
- JqTreeWidget.prototype.selectNode = function(node, must_open_parents) {
793
- return this.select_node_handler.selectNode(node, must_open_parents);
803
+ JqTreeWidget.prototype.selectNode = function(node) {
804
+ return this.select_node_handler.selectNode(node);
794
805
  };
795
806
 
796
807
  JqTreeWidget.prototype.getSelectedNode = function() {
@@ -801,18 +812,59 @@ limitations under the License.
801
812
  return JSON.stringify(this.tree.getData());
802
813
  };
803
814
 
804
- JqTreeWidget.prototype.loadData = function(data_or_url, parent_node, on_finished) {
805
- var data, data_url;
806
- if (typeof data_or_url === 'string') {
807
- data_url = data_or_url;
808
- return this._loadDataFromServer(data_url, parent_node, on_finished);
809
- } else {
810
- data = data_or_url;
811
- this._loadData(data, parent_node);
812
- if (on_finished) {
813
- return on_finished();
815
+ JqTreeWidget.prototype.loadData = function(data, parent_node) {
816
+ return this._loadData(data, parent_node);
817
+ };
818
+
819
+ JqTreeWidget.prototype.loadDataFromUrl = function(url_info, parent_node, on_finished) {
820
+ var $li, addLoadingClass, parseUrlInfo, removeLoadingClass,
821
+ _this = this;
822
+ $li = null;
823
+ addLoadingClass = function() {
824
+ var folder_element;
825
+ if (parent_node) {
826
+ folder_element = new FolderElement(parent_node, _this);
827
+ $li = folder_element.getLi();
828
+ return $li.addClass('jqtree-loading');
814
829
  }
815
- }
830
+ };
831
+ removeLoadingClass = function() {
832
+ if ($li) {
833
+ return $li.removeClass('loading');
834
+ }
835
+ };
836
+ parseUrlInfo = function() {
837
+ if ($.type(url_info) === 'string') {
838
+ url_info = {
839
+ url: url_info
840
+ };
841
+ }
842
+ if (!url_info.method) {
843
+ return url_info.method = 'get';
844
+ }
845
+ };
846
+ addLoadingClass();
847
+ parseUrlInfo();
848
+ return $.ajax({
849
+ url: url_info.url,
850
+ data: url_info.data,
851
+ type: url_info.method.toUpperCase(),
852
+ cache: false,
853
+ dataType: 'json',
854
+ success: function(response) {
855
+ var data;
856
+ if ($.isArray(response) || typeof response === 'object') {
857
+ data = response;
858
+ } else {
859
+ data = $.parseJSON(response);
860
+ }
861
+ removeLoadingClass();
862
+ _this._loadData(data, parent_node);
863
+ if (on_finished) {
864
+ return on_finished();
865
+ }
866
+ }
867
+ });
816
868
  };
817
869
 
818
870
  JqTreeWidget.prototype._loadData = function(data, parent_node) {
@@ -838,40 +890,6 @@ limitations under the License.
838
890
  }
839
891
  };
840
892
 
841
- JqTreeWidget.prototype._loadDataFromServer = function(data_url, parent_node, on_finished) {
842
- var $li, folder_element,
843
- _this = this;
844
- if (!data_url) {
845
- return;
846
- }
847
- if (parent_node) {
848
- folder_element = new FolderElement(parent_node, this);
849
- $li = folder_element.getLi();
850
- $li.addClass('jqtree-loading');
851
- } else {
852
- $li = null;
853
- }
854
- return $.ajax({
855
- url: data_url,
856
- cache: false,
857
- success: function(response) {
858
- var data;
859
- if ($.isArray(response) || typeof response === 'object') {
860
- data = response;
861
- } else {
862
- data = $.parseJSON(response);
863
- }
864
- if ($li) {
865
- $li.removeClass('loading');
866
- }
867
- _this._loadData(data, parent_node);
868
- if (on_finished) {
869
- return on_finished();
870
- }
871
- }
872
- });
873
- };
874
-
875
893
  JqTreeWidget.prototype.getNodeById = function(node_id) {
876
894
  return this.tree.getNodeById(node_id);
877
895
  };
@@ -880,34 +898,58 @@ limitations under the License.
880
898
  return this.tree.getNodeByName(name);
881
899
  };
882
900
 
883
- JqTreeWidget.prototype.openNode = function(node, skip_slide) {
884
- return this._openNode(node, skip_slide);
901
+ JqTreeWidget.prototype.openNode = function(node, slide) {
902
+ if (slide == null) {
903
+ slide = true;
904
+ }
905
+ return this._openNode(node, slide);
885
906
  };
886
907
 
887
- JqTreeWidget.prototype._openNode = function(node, skip_slide, on_finished) {
888
- var folder_element;
908
+ JqTreeWidget.prototype._openNode = function(node, slide, on_finished) {
909
+ var doOpenNode, parent,
910
+ _this = this;
911
+ if (slide == null) {
912
+ slide = true;
913
+ }
914
+ doOpenNode = function(_node, _slide, _on_finished) {
915
+ var folder_element;
916
+ folder_element = new FolderElement(_node, _this);
917
+ return folder_element.open(_on_finished, _slide);
918
+ };
889
919
  if (node.isFolder()) {
890
920
  if (node.load_on_demand) {
891
- return this._loadFolderOnDemand(node, skip_slide, on_finished);
921
+ return this._loadFolderOnDemand(node, slide, on_finished);
892
922
  } else {
893
- folder_element = new FolderElement(node, this);
894
- folder_element.open(on_finished, skip_slide);
923
+ parent = node.parent;
924
+ while (parent && !parent.is_open) {
925
+ if (parent.parent) {
926
+ doOpenNode(parent, false, null);
927
+ }
928
+ parent = parent.parent;
929
+ }
930
+ doOpenNode(node, slide, on_finished);
895
931
  return this._saveState();
896
932
  }
897
933
  }
898
934
  };
899
935
 
900
- JqTreeWidget.prototype._loadFolderOnDemand = function(node, skip_slide, on_finished) {
936
+ JqTreeWidget.prototype._loadFolderOnDemand = function(node, slide, on_finished) {
901
937
  var _this = this;
938
+ if (slide == null) {
939
+ slide = true;
940
+ }
902
941
  node.load_on_demand = false;
903
- return this.loadData(this._getDataUrl(node), node, function() {
904
- return _this._openNode(node, skip_slide, on_finished);
942
+ return this.loadDataFromUrl(this._getDataUrlInfo(node), node, function() {
943
+ return _this._openNode(node, slide, on_finished);
905
944
  });
906
945
  };
907
946
 
908
- JqTreeWidget.prototype.closeNode = function(node, skip_slide) {
947
+ JqTreeWidget.prototype.closeNode = function(node, slide) {
948
+ if (slide == null) {
949
+ slide = true;
950
+ }
909
951
  if (node.isFolder()) {
910
- new FolderElement(node, this).close(skip_slide);
952
+ new FolderElement(node, this).close(slide);
911
953
  return this._saveState();
912
954
  }
913
955
  };
@@ -942,9 +984,32 @@ limitations under the License.
942
984
  };
943
985
 
944
986
  JqTreeWidget.prototype.removeNode = function(node) {
945
- var parent;
987
+ var mustUnselectedNode, parent,
988
+ _this = this;
989
+ mustUnselectedNode = function() {
990
+ var result;
991
+ if (!_this.selected_node) {
992
+ return false;
993
+ } else if (_this.selected_node === node) {
994
+ return true;
995
+ } else {
996
+ result = true;
997
+ iterate(function(child) {
998
+ if (node === child) {
999
+ result = true;
1000
+ return false;
1001
+ } else {
1002
+ return true;
1003
+ }
1004
+ });
1005
+ return result;
1006
+ }
1007
+ };
946
1008
  parent = node.parent;
947
1009
  if (parent) {
1010
+ if (mustUnselectedNode()) {
1011
+ this.selected_node = null;
1012
+ }
948
1013
  node.remove();
949
1014
  return this._refreshElements(parent.parent);
950
1015
  }
@@ -1000,6 +1065,7 @@ limitations under the License.
1000
1065
  this.save_state_handler = new SaveStateHandler(this);
1001
1066
  this.select_node_handler = new SelectNodeHandler(this);
1002
1067
  this.dnd_handler = new DragAndDropHandler(this);
1068
+ this.scroll_handler = new ScrollHandler(this);
1003
1069
  this._initData();
1004
1070
  this.element.click($.proxy(this._click, this));
1005
1071
  return this.element.bind('contextmenu', $.proxy(this._contextmenu, this));
@@ -1016,19 +1082,27 @@ limitations under the License.
1016
1082
  if (this.options.data) {
1017
1083
  return this.loadData(this.options.data);
1018
1084
  } else {
1019
- return this.loadData(this._getDataUrl());
1085
+ return this.loadDataFromUrl(this._getDataUrlInfo());
1020
1086
  }
1021
1087
  };
1022
1088
 
1023
- JqTreeWidget.prototype._getDataUrl = function(node) {
1024
- var data_url;
1089
+ JqTreeWidget.prototype._getDataUrlInfo = function(node) {
1090
+ var data, data_url, url_info;
1025
1091
  data_url = this.options.dataUrl || this.element.data('url');
1026
1092
  if ($.isFunction(data_url)) {
1027
1093
  return data_url(node);
1028
- } else {
1029
- if (node) {
1030
- data_url += "?node=" + node.id;
1094
+ } else if ($.type(data_url) === 'string') {
1095
+ url_info = {
1096
+ url: data_url
1097
+ };
1098
+ if (node && node.id) {
1099
+ data = {
1100
+ node: node.id
1101
+ };
1102
+ url_info['data'] = data;
1031
1103
  }
1104
+ return url_info;
1105
+ } else {
1032
1106
  return data_url;
1033
1107
  }
1034
1108
  };
@@ -1078,11 +1152,11 @@ limitations under the License.
1078
1152
  createUl = function(is_root_node) {
1079
1153
  var class_string;
1080
1154
  if (is_root_node) {
1081
- class_string = ' class="jqtree-tree"';
1155
+ class_string = 'jqtree-tree';
1082
1156
  } else {
1083
1157
  class_string = '';
1084
1158
  }
1085
- return $("<ul" + class_string + "></ul>");
1159
+ return $("<ul class=\"jqtree_common " + class_string + "\"></ul>");
1086
1160
  };
1087
1161
  createLi = function(node) {
1088
1162
  var $li;
@@ -1099,7 +1173,7 @@ limitations under the License.
1099
1173
  createNodeLi = function(node) {
1100
1174
  var escaped_name;
1101
1175
  escaped_name = escapeIfNecessary(node.name);
1102
- return $("<li><div><span class=\"jqtree-title\">" + escaped_name + "</span></div></li>");
1176
+ return $("<li class=\"jqtree_common\"><div><span class=\"jqtree-title jqtree_common\">" + escaped_name + "</span></div></li>");
1103
1177
  };
1104
1178
  createFolderLi = function(node) {
1105
1179
  var button_char, button_classes, escaped_name, folder_classes, getButtonClasses, getFolderClasses;
@@ -1127,7 +1201,7 @@ limitations under the License.
1127
1201
  } else {
1128
1202
  button_char = TRIANGLE_RIGHT;
1129
1203
  }
1130
- return $("<li class=\"" + folder_classes + "\"><div><a class=\"" + button_classes + "\">" + button_char + "</a><span class=\"jqtree-title\">" + escaped_name + "</span></div></li>");
1204
+ return $("<li class=\"jqtree_common " + folder_classes + "\"><div><a class=\"jqtree_common " + button_classes + "\">" + button_char + "</a><span class=\"jqtree_common jqtree-title\">" + escaped_name + "</span></div></li>");
1131
1205
  };
1132
1206
  doCreateDomElements = function($element, children, is_root_node, is_open) {
1133
1207
  var $li, $ul, child, _i, _len;
@@ -1161,26 +1235,30 @@ limitations under the License.
1161
1235
  };
1162
1236
 
1163
1237
  JqTreeWidget.prototype._click = function(e) {
1164
- var $target, node;
1238
+ var $button, $target, $title, node;
1165
1239
  if (e.ctrlKey) {
1166
1240
  return;
1167
1241
  }
1168
1242
  $target = $(e.target);
1169
- if ($target.is('.jqtree-toggler')) {
1170
- node = this._getNode($target);
1171
- if (node) {
1172
- this.toggle(node);
1173
- e.preventDefault();
1174
- return e.stopPropagation();
1175
- }
1176
- } else if ($target.is('div') || $target.is('span')) {
1177
- node = this._getNode($target);
1243
+ $title = $target.closest('.jqtree-title');
1244
+ if ($title.length) {
1245
+ node = this._getNode($title);
1178
1246
  if (node) {
1179
1247
  this._triggerEvent('tree.click', {
1180
1248
  node: node
1181
1249
  });
1182
1250
  return this.selectNode(node);
1183
1251
  }
1252
+ } else {
1253
+ $button = $target.closest('.jqtree-toggler');
1254
+ if ($button.length) {
1255
+ node = this._getNode($button);
1256
+ if (node) {
1257
+ this.toggle(node, this.options.slide);
1258
+ e.preventDefault();
1259
+ return e.stopPropagation();
1260
+ }
1261
+ }
1184
1262
  }
1185
1263
  };
1186
1264
 
@@ -1252,8 +1330,11 @@ limitations under the License.
1252
1330
  };
1253
1331
 
1254
1332
  JqTreeWidget.prototype._mouseDrag = function(event) {
1333
+ var result;
1255
1334
  if (this.options.dragAndDrop) {
1256
- return this.dnd_handler.mouseDrag(event);
1335
+ result = this.dnd_handler.mouseDrag(event);
1336
+ this.scroll_handler.checkScrolling();
1337
+ return result;
1257
1338
  } else {
1258
1339
  return false;
1259
1340
  }
@@ -1292,7 +1373,7 @@ limitations under the License.
1292
1373
  function GhostDropHint(node, $element, position) {
1293
1374
  this.$element = $element;
1294
1375
  this.node = node;
1295
- this.$ghost = $('<li class="jqtree-ghost"><span class="jqtree-circle"></span><span class="jqtree-line"></span></li>');
1376
+ this.$ghost = $('<li class="jqtree_common jqtree-ghost"><span class="jqtree_common jqtree-circle"></span><span class="jqtree_common jqtree-line"></span></li>');
1296
1377
  if (position === Position.AFTER) {
1297
1378
  this.moveAfter();
1298
1379
  } else if (position === Position.BEFORE) {
@@ -1405,9 +1486,12 @@ limitations under the License.
1405
1486
  return FolderElement.__super__.constructor.apply(this, arguments);
1406
1487
  }
1407
1488
 
1408
- FolderElement.prototype.open = function(on_finished, skip_slide) {
1489
+ FolderElement.prototype.open = function(on_finished, slide) {
1409
1490
  var $button, doOpen,
1410
1491
  _this = this;
1492
+ if (slide == null) {
1493
+ slide = true;
1494
+ }
1411
1495
  if (!this.node.is_open) {
1412
1496
  this.node.is_open = true;
1413
1497
  $button = this.getButton();
@@ -1422,18 +1506,21 @@ limitations under the License.
1422
1506
  node: _this.node
1423
1507
  });
1424
1508
  };
1425
- if (skip_slide) {
1509
+ if (slide) {
1510
+ return this.getUl().slideDown('fast', doOpen);
1511
+ } else {
1426
1512
  this.getUl().show();
1427
1513
  return doOpen();
1428
- } else {
1429
- return this.getUl().slideDown('fast', doOpen);
1430
1514
  }
1431
1515
  }
1432
1516
  };
1433
1517
 
1434
- FolderElement.prototype.close = function(skip_slide) {
1518
+ FolderElement.prototype.close = function(slide) {
1435
1519
  var $button, doClose,
1436
1520
  _this = this;
1521
+ if (slide == null) {
1522
+ slide = true;
1523
+ }
1437
1524
  if (this.node.is_open) {
1438
1525
  this.node.is_open = false;
1439
1526
  $button = this.getButton();
@@ -1445,11 +1532,11 @@ limitations under the License.
1445
1532
  node: _this.node
1446
1533
  });
1447
1534
  };
1448
- if (skip_slide) {
1535
+ if (slide) {
1536
+ return this.getUl().slideUp('fast', doClose);
1537
+ } else {
1449
1538
  this.getUl().hide();
1450
1539
  return doClose();
1451
- } else {
1452
- return this.getUl().slideUp('fast', doClose);
1453
1540
  }
1454
1541
  }
1455
1542
  };
@@ -1595,13 +1682,10 @@ limitations under the License.
1595
1682
  this.tree_widget = tree_widget;
1596
1683
  }
1597
1684
 
1598
- SelectNodeHandler.prototype.selectNode = function(node, must_open_parents) {
1685
+ SelectNodeHandler.prototype.selectNode = function(node) {
1599
1686
  var canSelect, parent,
1600
1687
  _this = this;
1601
1688
  canSelect = function() {
1602
- if (!_this.tree_widget.options.selectable) {
1603
- return false;
1604
- }
1605
1689
  if (!_this.tree_widget.options.onCanSelectNode) {
1606
1690
  return true;
1607
1691
  }
@@ -1618,14 +1702,9 @@ limitations under the License.
1618
1702
  this.tree_widget._triggerEvent('tree.select', {
1619
1703
  node: node
1620
1704
  });
1621
- if (must_open_parents) {
1622
- parent = this.tree_widget.selected_node.parent;
1623
- while (parent) {
1624
- if (!parent.is_open) {
1625
- this.tree_widget.openNode(parent, true);
1626
- }
1627
- parent = parent.parent;
1628
- }
1705
+ parent = this.tree_widget.selected_node.parent;
1706
+ if (!parent.is_open) {
1707
+ this.tree_widget.openNode(parent, false);
1629
1708
  }
1630
1709
  }
1631
1710
  if (this.tree_widget.options.saveState) {
@@ -1935,7 +2014,7 @@ limitations under the License.
1935
2014
  var openFolder,
1936
2015
  _this = this;
1937
2016
  openFolder = function() {
1938
- return _this.tree_widget._openNode(folder, false, function() {
2017
+ return _this.tree_widget._openNode(folder, _this.tree_widget.options.slide, function() {
1939
2018
  _this.refreshHitAreas();
1940
2019
  return _this.updateDropHint();
1941
2020
  });
@@ -1985,6 +2064,88 @@ limitations under the License.
1985
2064
 
1986
2065
  })();
1987
2066
 
1988
- this.Tree.Node = Node;
2067
+ ScrollHandler = (function() {
2068
+
2069
+ function ScrollHandler(tree_widget) {
2070
+ this.tree_widget = tree_widget;
2071
+ this.previous_top = -1;
2072
+ this._initScrollParent();
2073
+ }
2074
+
2075
+ ScrollHandler.prototype._initScrollParent = function() {
2076
+ var $scroll_parent, getParentWithOverflow, setDocumentAsScrollParent,
2077
+ _this = this;
2078
+ getParentWithOverflow = function() {
2079
+ var css_value, css_values, parent, scroll_parent, _i, _j, _len, _len1, _ref, _ref1;
2080
+ css_values = ['overflow', 'overflow-y'];
2081
+ scroll_parent = null;
2082
+ _ref = _this.tree_widget.$el.parents();
2083
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
2084
+ parent = _ref[_i];
2085
+ for (_j = 0, _len1 = css_values.length; _j < _len1; _j++) {
2086
+ css_value = css_values[_j];
2087
+ if ((_ref1 = $.css(parent, css_value)) === 'auto' || _ref1 === 'scroll') {
2088
+ return $(parent);
2089
+ }
2090
+ }
2091
+ }
2092
+ return null;
2093
+ };
2094
+ setDocumentAsScrollParent = function() {
2095
+ _this.scroll_parent_top = 0;
2096
+ return _this.$scroll_parent = null;
2097
+ };
2098
+ if (this.tree_widget.$el.css('position') === 'fixed') {
2099
+ setDocumentAsScrollParent();
2100
+ }
2101
+ $scroll_parent = getParentWithOverflow();
2102
+ if ($scroll_parent && $scroll_parent.length && $scroll_parent[0].tagName !== 'HTML') {
2103
+ this.$scroll_parent = $scroll_parent;
2104
+ return this.scroll_parent_top = this.$scroll_parent.offset().top;
2105
+ } else {
2106
+ return setDocumentAsScrollParent();
2107
+ }
2108
+ };
2109
+
2110
+ ScrollHandler.prototype.checkScrolling = function() {
2111
+ var hovered_area;
2112
+ hovered_area = this.tree_widget.dnd_handler.hovered_area;
2113
+ if (hovered_area && hovered_area.top !== this.previous_top) {
2114
+ this.previous_top = hovered_area.top;
2115
+ if (this.$scroll_parent) {
2116
+ return this._handleScrollingWithScrollParent(hovered_area);
2117
+ } else {
2118
+ return this._handleScrollingWithDocument(hovered_area);
2119
+ }
2120
+ }
2121
+ };
2122
+
2123
+ ScrollHandler.prototype._handleScrollingWithScrollParent = function(area) {
2124
+ var distance_bottom;
2125
+ distance_bottom = this.scroll_parent_top + this.$scroll_parent[0].offsetHeight - area.bottom;
2126
+ if (distance_bottom < 20) {
2127
+ this.$scroll_parent[0].scrollTop += 20;
2128
+ this.tree_widget.refreshHitAreas();
2129
+ return this.previous_top = -1;
2130
+ } else if ((area.top - this.scroll_parent_top) < 20) {
2131
+ this.$scroll_parent[0].scrollTop -= 20;
2132
+ this.tree_widget.refreshHitAreas();
2133
+ return this.previous_top = -1;
2134
+ }
2135
+ };
2136
+
2137
+ ScrollHandler.prototype._handleScrollingWithDocument = function(area) {
2138
+ var distance_top;
2139
+ distance_top = area.top - $(document).scrollTop();
2140
+ if (distance_top < 20) {
2141
+ return $(document).scrollTop($(document).scrollTop() - 20);
2142
+ } else if ($(window).height() - (area.bottom - $(document).scrollTop()) < 20) {
2143
+ return $(document).scrollTop($(document).scrollTop() + 20);
2144
+ }
2145
+ };
2146
+
2147
+ return ScrollHandler;
2148
+
2149
+ })();
1989
2150
 
1990
2151
  }).call(this);
@@ -3,26 +3,24 @@ ul.jqtree-tree {
3
3
  }
4
4
 
5
5
  ul.jqtree-tree,
6
- ul.jqtree-tree ul {
6
+ ul.jqtree-tree ul.jqtree_common {
7
7
  list-style: none outside;
8
8
  margin-bottom: 0;
9
9
  padding: 0;
10
10
  }
11
11
 
12
- ul.jqtree-tree ul {
12
+ ul.jqtree-tree ul.jqtree_common {
13
13
  display: block;
14
14
  margin-left: 12px;
15
15
  margin-right: 0;
16
16
  }
17
-
18
- ul.jqtree-tree li.jqtree-closed > ul {
17
+ ul.jqtree-tree li.jqtree-closed > ul.jqtree_common {
19
18
  display: none;
20
19
  }
21
20
 
22
- ul.jqtree-tree li {
21
+ ul.jqtree-tree li.jqtree_common {
23
22
  clear: both;
24
23
  }
25
-
26
24
  ul.jqtree-tree .jqtree-toggler {
27
25
  display: block;
28
26
  position: absolute;
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jqtree-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
4
  prerelease:
5
+ version: 0.1.4.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan Scott Lewis
@@ -10,12 +10,10 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-14 00:00:00.000000000 Z
13
+ date: 2012-12-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: railties
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
16
+ version_requirements: !ruby/object:Gem::Requirement
19
17
  requirements:
20
18
  - - ! '>='
21
19
  - !ruby/object:Gem::Version
@@ -23,10 +21,11 @@ dependencies:
23
21
  - - <
24
22
  - !ruby/object:Gem::Version
25
23
  version: '5.0'
24
+ none: false
25
+ name: railties
26
26
  type: :runtime
27
27
  prerelease: false
28
- version_requirements: !ruby/object:Gem::Requirement
29
- none: false
28
+ requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - ! '>='
32
31
  - !ruby/object:Gem::Version
@@ -34,41 +33,42 @@ dependencies:
34
33
  - - <
35
34
  - !ruby/object:Gem::Version
36
35
  version: '5.0'
37
- - !ruby/object:Gem::Dependency
38
- name: thor
39
- requirement: !ruby/object:Gem::Requirement
40
36
  none: false
37
+ - !ruby/object:Gem::Dependency
38
+ version_requirements: !ruby/object:Gem::Requirement
41
39
  requirements:
42
40
  - - ~>
43
41
  - !ruby/object:Gem::Version
44
42
  version: '0.14'
43
+ none: false
44
+ name: thor
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: !ruby/object:Gem::Requirement
48
- none: false
47
+ requirement: !ruby/object:Gem::Requirement
49
48
  requirements:
50
49
  - - ~>
51
50
  - !ruby/object:Gem::Version
52
51
  version: '0.14'
53
- - !ruby/object:Gem::Dependency
54
- name: version
55
- requirement: !ruby/object:Gem::Requirement
56
52
  none: false
53
+ - !ruby/object:Gem::Dependency
54
+ version_requirements: !ruby/object:Gem::Requirement
57
55
  requirements:
58
56
  - - ~>
59
57
  - !ruby/object:Gem::Version
60
58
  version: '1.0'
59
+ none: false
60
+ name: version
61
61
  type: :runtime
62
62
  prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- none: false
63
+ requirement: !ruby/object:Gem::Requirement
65
64
  requirements:
66
65
  - - ~>
67
66
  - !ruby/object:Gem::Version
68
67
  version: '1.0'
68
+ none: false
69
69
  description: This gem provides jqTree assets for your Rails 3 application.
70
70
  email:
71
- - c00lryguy@gmail.com
71
+ - ryan@rynet.us
72
72
  - uher.mario@gmail.com
73
73
  executables: []
74
74
  extensions: []
@@ -91,24 +91,24 @@ files:
91
91
  - vendor/assets/images/jqtree-circle.png
92
92
  - vendor/assets/javascripts/tree.jquery.js
93
93
  - vendor/assets/stylesheets/jqtree.css
94
- homepage: http://rubygems.org/gems/jqtree-rails
94
+ homepage: https://github.com/RyanScottLewis/jqtree-rails
95
95
  licenses: []
96
96
  post_install_message:
97
97
  rdoc_options: []
98
98
  require_paths:
99
99
  - lib
100
100
  required_ruby_version: !ruby/object:Gem::Requirement
101
- none: false
102
101
  requirements:
103
102
  - - ! '>='
104
103
  - !ruby/object:Gem::Version
105
104
  version: '0'
106
- required_rubygems_version: !ruby/object:Gem::Requirement
107
105
  none: false
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
107
  requirements:
109
108
  - - ! '>='
110
109
  - !ruby/object:Gem::Version
111
110
  version: 1.3.6
111
+ none: false
112
112
  requirements: []
113
113
  rubyforge_project:
114
114
  rubygems_version: 1.8.23
@@ -116,4 +116,3 @@ signing_key:
116
116
  specification_version: 3
117
117
  summary: Use jqTree with Rails 3
118
118
  test_files: []
119
- has_rdoc: