jqtree-rails 0.1.0 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "jqTree"]
2
+ path = jqTree
3
+ url = git://github.com/mbraak/jqTree.git
data/Gemfile.lock CHANGED
@@ -1,62 +1,64 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inflection-js-rails (0.1.0)
4
+ jqtree-rails (0.1.2)
5
5
  railties (>= 3.2.0, < 5.0)
6
6
  thor (~> 0.14)
7
+ version (~> 1.0)
7
8
 
8
9
  GEM
9
10
  remote: http://rubygems.org/
10
11
  specs:
11
- actionpack (3.2.3)
12
- activemodel (= 3.2.3)
13
- activesupport (= 3.2.3)
12
+ actionpack (3.2.8)
13
+ activemodel (= 3.2.8)
14
+ activesupport (= 3.2.8)
14
15
  builder (~> 3.0.0)
15
16
  erubis (~> 2.7.0)
16
- journey (~> 1.0.1)
17
+ journey (~> 1.0.4)
17
18
  rack (~> 1.4.0)
18
19
  rack-cache (~> 1.2)
19
20
  rack-test (~> 0.6.1)
20
- sprockets (~> 2.1.2)
21
- activemodel (3.2.3)
22
- activesupport (= 3.2.3)
21
+ sprockets (~> 2.1.3)
22
+ activemodel (3.2.8)
23
+ activesupport (= 3.2.8)
23
24
  builder (~> 3.0.0)
24
- activesupport (3.2.3)
25
+ activesupport (3.2.8)
25
26
  i18n (~> 0.6)
26
27
  multi_json (~> 1.0)
27
- builder (3.0.0)
28
+ builder (3.0.3)
28
29
  erubis (2.7.0)
29
30
  hike (1.2.1)
30
- i18n (0.6.0)
31
- journey (1.0.3)
32
- json (1.6.6)
33
- multi_json (1.2.0)
31
+ i18n (0.6.1)
32
+ journey (1.0.4)
33
+ json (1.7.5)
34
+ multi_json (1.3.6)
34
35
  rack (1.4.1)
35
36
  rack-cache (1.2)
36
37
  rack (>= 0.4)
37
38
  rack-ssl (1.3.2)
38
39
  rack
39
- rack-test (0.6.1)
40
+ rack-test (0.6.2)
40
41
  rack (>= 1.0)
41
- railties (3.2.3)
42
- actionpack (= 3.2.3)
43
- activesupport (= 3.2.3)
42
+ railties (3.2.8)
43
+ actionpack (= 3.2.8)
44
+ activesupport (= 3.2.8)
44
45
  rack-ssl (~> 1.3.2)
45
46
  rake (>= 0.8.7)
46
47
  rdoc (~> 3.4)
47
- thor (~> 0.14.6)
48
+ thor (>= 0.14.6, < 2.0)
48
49
  rake (0.9.2.2)
49
50
  rdoc (3.12)
50
51
  json (~> 1.4)
51
- sprockets (2.1.2)
52
+ sprockets (2.1.3)
52
53
  hike (~> 1.2)
53
54
  rack (~> 1.0)
54
55
  tilt (~> 1.1, != 1.3.0)
55
- thor (0.14.6)
56
+ thor (0.16.0)
56
57
  tilt (1.3.3)
58
+ version (1.0.0)
57
59
 
58
60
  PLATFORMS
59
61
  ruby
60
62
 
61
63
  DEPENDENCIES
62
- inflection-js-rails!
64
+ jqtree-rails!
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2010 Andre Arko
3
+ Copyright (c) 2012 Ryan Scott Lewis
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -4,7 +4,7 @@ Adds [jqTree](https://github.com/mbraak/jqTree) to the Rails 3 asset pipeline.
4
4
 
5
5
  ## Installation
6
6
 
7
- In your Gemfile, add this line:
7
+ In your Gemfile, add the following lines:
8
8
 
9
9
  ```ruby
10
10
  gem :assets do
@@ -16,7 +16,7 @@ Now run `bundle install`.
16
16
 
17
17
  ### Rails 3.0
18
18
 
19
- This gem adds a single generator to Rails 3, `jqtree:install`.
19
+ This gem adds a single generator to Rails 3, `jq_tree:install`.
20
20
 
21
21
  Running the generator will copy over the assets to your assets to your public directory.
22
22
 
@@ -31,7 +31,7 @@ Simply the following to `app/assets/javascripts/application.js`:
31
31
  And the following to `app/assets/stylesheets/application.css`:
32
32
 
33
33
  /*
34
- * require jqtree
34
+ *= require jqtree
35
35
  */
36
36
 
37
37
  ## saveState
data/Rakefile CHANGED
@@ -1,10 +1,18 @@
1
+ require 'bundler/setup'
2
+ Bundler.require(:development)
3
+
1
4
  require 'bundler'
2
5
  Bundler::GemHelper.install_tasks
3
6
 
7
+ require 'rake/version_task'
8
+ Rake::VersionTask.new do |task|
9
+ task.with_git_tag = true
10
+ end
11
+
12
+ # TODO: This project needs specs! That means we need a whole Rails test project.
4
13
  # require "spec/rake/spectask"
5
14
  # desc "Run all examples"
6
15
  # Spec::Rake::SpecTask.new(:spec) do |t|
7
16
  # t.ruby_opts = ['-r test/unit']
8
17
  # t.spec_opts = %w[--color]
9
18
  # end
10
- task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
data/jqtree-rails.gemspec CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.name = File.basename(__FILE__, '.gemspec')
6
6
  s.version = JqTree::Rails::VERSION
7
7
  s.platform = Gem::Platform::RUBY
8
- s.authors = ["Ryan Scott Lewis"]
9
- s.email = ["c00lryguy@gmail.com"]
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
10
  s.homepage = "http://rubygems.org/gems/#{s.name}"
11
11
  s.summary = "Use jqTree with Rails 3"
12
12
  s.description = "This gem provides jqTree assets for your Rails 3 application."
@@ -14,9 +14,10 @@ Gem::Specification.new do |s|
14
14
  s.required_rubygems_version = ">= 1.3.6"
15
15
 
16
16
  s.add_dependency "railties", ">= 3.2.0", "< 5.0"
17
- s.add_dependency "thor", "~> 0.14"
17
+ s.add_dependency "thor", "~> 0.14" # TODO: Find out why this is needed
18
+ s.add_dependency "version", "~> 1.0"
18
19
 
19
20
  s.files = `git ls-files`.split("\n")
20
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
21
- s.require_path = 'lib'
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
22
23
  end
@@ -30,7 +30,7 @@ else
30
30
  say_status("deprecated", "You are using Rails 3.1 or the asset pipeline enabled, so this generator is not needed.")
31
31
  say_status("", "The necessary files are already in your asset pipeline.")
32
32
  say_status("", "Just add `//= require tree.jquery` to your app/assets/javascripts/application.js")
33
- say_status("", "and add `/* require jqtree */` to your app/assets/stylesheets/application.css")
33
+ say_status("", "and add `/*= require jqtree */` to your app/assets/stylesheets/application.css")
34
34
  say_status("", "If you do not want the asset pipeline enabled, you may turn it off in application.rb and re-run this generator.")
35
35
  # ok, nothing
36
36
  end
@@ -1,6 +1,9 @@
1
+ gem 'version', '~> 1.0' # Ugly, but works!
2
+ require 'version'
3
+
1
4
  module JqTree
2
5
  module Rails
3
- VERSION = "0.1.0"
4
- JQTREE_VERSION = "0.7"
6
+ VERSION = Version.current
7
+ JQTREE_VERSION = "0.13"
5
8
  end
6
9
  end
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 1.3.1
1
+ // Generated by CoffeeScript 1.3.3
2
2
 
3
3
  /*
4
4
  Copyright 2012 Marco Braak
@@ -18,23 +18,20 @@ limitations under the License.
18
18
 
19
19
 
20
20
  (function() {
21
- var $, BorderDropHint, DragElement, FolderElement, GhostDropHint, JqueryWidget, Json, MouseWidget, Node, NodeElement, Position, SimpleWidget, indexOf, toJson,
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,
22
22
  __slice = [].slice,
23
23
  __hasProp = {}.hasOwnProperty,
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; };
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; };
25
25
 
26
26
  $ = this.jQuery;
27
27
 
28
28
  SimpleWidget = (function() {
29
29
 
30
- SimpleWidget.name = 'SimpleWidget';
31
-
32
30
  SimpleWidget.prototype.defaults = {};
33
31
 
34
32
  function SimpleWidget(el, options) {
35
33
  this.$el = $(el);
36
34
  this.options = $.extend({}, this.defaults, options);
37
- this._init();
38
35
  }
39
36
 
40
37
  SimpleWidget.prototype.destroy = function() {
@@ -49,71 +46,74 @@ limitations under the License.
49
46
  return null;
50
47
  };
51
48
 
52
- return SimpleWidget;
53
-
54
- })();
55
-
56
- SimpleWidget.register = function(widget_class, widget_name) {
57
- var callFunction, createWidget, destroyWidget, getDataKey;
58
- getDataKey = function() {
59
- return "simple_widget_" + widget_name;
60
- };
61
- createWidget = function($el, options) {
62
- var data_key;
63
- data_key = getDataKey();
64
- $el.each(function() {
65
- var widget;
66
- widget = new widget_class(this, options);
67
- if (!$.data(this, data_key)) {
68
- return $.data(this, data_key, widget);
49
+ SimpleWidget.register = function(widget_class, widget_name) {
50
+ var callFunction, createWidget, destroyWidget, getDataKey;
51
+ getDataKey = function() {
52
+ return "simple_widget_" + widget_name;
53
+ };
54
+ createWidget = function($el, options) {
55
+ var data_key, el, widget, _i, _len;
56
+ data_key = getDataKey();
57
+ for (_i = 0, _len = $el.length; _i < _len; _i++) {
58
+ el = $el[_i];
59
+ widget = new widget_class(el, options);
60
+ if (!$.data(el, data_key)) {
61
+ $.data(el, data_key, widget);
62
+ }
63
+ widget._init();
69
64
  }
70
- });
71
- return $el;
72
- };
73
- destroyWidget = function($el) {
74
- var data_key;
75
- data_key = getDataKey();
76
- return $el.each(function() {
77
- var widget;
78
- widget = $.data(this, data_key);
79
- if (widget && (widget instanceof SimpleWidget)) {
80
- widget.destroy();
65
+ return $el;
66
+ };
67
+ destroyWidget = function($el) {
68
+ var data_key, el, widget, _i, _len, _results;
69
+ data_key = getDataKey();
70
+ _results = [];
71
+ for (_i = 0, _len = $el.length; _i < _len; _i++) {
72
+ el = $el[_i];
73
+ widget = $.data(el, data_key);
74
+ if (widget && (widget instanceof SimpleWidget)) {
75
+ widget.destroy();
76
+ }
77
+ _results.push($.removeData(el, data_key));
81
78
  }
82
- return $.removeData(this, data_key);
83
- });
84
- };
85
- callFunction = function($el, function_name, args) {
86
- var result;
87
- result = null;
88
- $el.each(function() {
89
- var widget, widget_function;
90
- widget = $.data(this, getDataKey());
91
- if (widget && (widget instanceof SimpleWidget)) {
92
- widget_function = widget[function_name];
93
- if (widget_function && (typeof widget_function === 'function')) {
94
- return result = widget_function.apply(widget, args);
79
+ return _results;
80
+ };
81
+ callFunction = function($el, function_name, args) {
82
+ var el, result, widget, widget_function, _i, _len;
83
+ result = null;
84
+ for (_i = 0, _len = $el.length; _i < _len; _i++) {
85
+ el = $el[_i];
86
+ widget = $.data(el, getDataKey());
87
+ if (widget && (widget instanceof SimpleWidget)) {
88
+ widget_function = widget[function_name];
89
+ if (widget_function && (typeof widget_function === 'function')) {
90
+ result = widget_function.apply(widget, args);
91
+ }
95
92
  }
96
93
  }
97
- });
98
- return result;
99
- };
100
- return $.fn[widget_name] = function() {
101
- var $el, args, argument1, function_name, options;
102
- argument1 = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
103
- $el = this;
104
- if (argument1 === void 0 || typeof argument1 === 'object') {
105
- options = argument1;
106
- return createWidget($el, options);
107
- } else if (typeof argument1 === 'string' && argument1[0] !== '_') {
108
- function_name = argument1;
109
- if (function_name === 'destroy') {
110
- return destroyWidget($el);
111
- } else {
112
- return callFunction($el, function_name, args);
94
+ return result;
95
+ };
96
+ return $.fn[widget_name] = function() {
97
+ var $el, args, argument1, function_name, options;
98
+ argument1 = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
99
+ $el = this;
100
+ if (argument1 === void 0 || typeof argument1 === 'object') {
101
+ options = argument1;
102
+ return createWidget($el, options);
103
+ } else if (typeof argument1 === 'string' && argument1[0] !== '_') {
104
+ function_name = argument1;
105
+ if (function_name === 'destroy') {
106
+ return destroyWidget($el);
107
+ } else {
108
+ return callFunction($el, function_name, args);
109
+ }
113
110
  }
114
- }
111
+ };
115
112
  };
116
- };
113
+
114
+ return SimpleWidget;
115
+
116
+ })();
117
117
 
118
118
  this.SimpleWidget = SimpleWidget;
119
119
 
@@ -126,8 +126,6 @@ limitations under the License.
126
126
 
127
127
  __extends(MouseWidget, _super);
128
128
 
129
- MouseWidget.name = 'MouseWidget';
130
-
131
129
  function MouseWidget() {
132
130
  return MouseWidget.__super__.constructor.apply(this, arguments);
133
131
  }
@@ -135,16 +133,19 @@ limitations under the License.
135
133
  MouseWidget.is_mouse_handled = false;
136
134
 
137
135
  MouseWidget.prototype._init = function() {
138
- this.$el.bind('mousedown', $.proxy(this._mouseDown, this));
139
- return this.is_mouse_started = false;
136
+ this.$el.bind('mousedown.mousewidget', $.proxy(this._mouseDown, this));
137
+ this.is_mouse_started = false;
138
+ this.mouse_delay = 0;
139
+ this._mouse_delay_timer = null;
140
+ return this._is_mouse_delay_met = true;
140
141
  };
141
142
 
142
143
  MouseWidget.prototype._deinit = function() {
143
144
  var $document;
144
- this.$el.unbind('mousedown');
145
+ this.$el.unbind('mousedown.mousewidget');
145
146
  $document = $(document);
146
- $document.unbind('mousemove');
147
- return $document.unbind('mouseup');
147
+ $document.unbind('mousemove.mousewidget');
148
+ return $document.unbind('mouseup.mousewidget');
148
149
  };
149
150
 
150
151
  MouseWidget.prototype._mouseDown = function(e) {
@@ -163,18 +164,35 @@ limitations under the License.
163
164
  }
164
165
  this.mouse_down_event = e;
165
166
  $document = $(document);
166
- $document.bind('mousemove', $.proxy(this._mouseMove, this));
167
- $document.bind('mouseup', $.proxy(this._mouseUp, this));
167
+ $document.bind('mousemove.mousewidget', $.proxy(this._mouseMove, this));
168
+ $document.bind('mouseup.mousewidget', $.proxy(this._mouseUp, this));
169
+ if (this.mouse_delay) {
170
+ this._startMouseDelayTimer();
171
+ }
168
172
  e.preventDefault();
169
173
  this.is_mouse_handled = true;
170
174
  return true;
171
175
  };
172
176
 
177
+ MouseWidget.prototype._startMouseDelayTimer = function() {
178
+ var _this = this;
179
+ if (this._mouse_delay_timer) {
180
+ clearTimeout(this._mouse_delay_timer);
181
+ }
182
+ this._mouse_delay_timer = setTimeout(function() {
183
+ return _this._is_mouse_delay_met = true;
184
+ }, this.mouse_delay);
185
+ return this._is_mouse_delay_met = false;
186
+ };
187
+
173
188
  MouseWidget.prototype._mouseMove = function(e) {
174
189
  if (this.is_mouse_started) {
175
190
  this._mouseDrag(e);
176
191
  return e.preventDefault();
177
192
  }
193
+ if (this.mouse_delay && !this._is_mouse_delay_met) {
194
+ return true;
195
+ }
178
196
  this.is_mouse_started = this._mouseStart(this.mouse_down_event) !== false;
179
197
  if (this.is_mouse_started) {
180
198
  this._mouseDrag(e);
@@ -187,8 +205,8 @@ limitations under the License.
187
205
  MouseWidget.prototype._mouseUp = function(e) {
188
206
  var $document;
189
207
  $document = $(document);
190
- $document.unbind('mousemove');
191
- $document.unbind('mouseup');
208
+ $document.unbind('mousemove.mousewidget');
209
+ $document.unbind('mouseup.mousewidget');
192
210
  if (this.is_mouse_started) {
193
211
  this.is_mouse_started = false;
194
212
  this._mouseStop(e);
@@ -254,94 +272,93 @@ limitations under the License.
254
272
 
255
273
  this.Tree.indexOf = indexOf;
256
274
 
257
- Json = {};
258
-
259
- Json.escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
260
-
261
- Json.meta = {
262
- '\b': '\\b',
263
- '\t': '\\t',
264
- '\n': '\\n',
265
- '\f': '\\f',
266
- '\r': '\\r',
267
- '"': '\\"',
268
- '\\': '\\\\'
269
- };
270
-
271
- Json.quote = function(string) {
272
- Json.escapable.lastIndex = 0;
273
- if (Json.escapable.test(string)) {
274
- return '"' + string.replace(Json.escapable, function(a) {
275
- var c;
276
- c = Json.meta[a];
277
- return (typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4));
278
- }) + '"';
279
- } else {
280
- return '"' + string + '"';
281
- }
282
- };
283
-
284
- Json.str = function(key, holder) {
285
- var i, k, partial, v, value, _i, _len;
286
- value = holder[key];
287
- if (value && typeof value === 'object' && typeof value.toJSON === 'function') {
288
- value = value.toJSON(key);
289
- }
290
- switch (typeof value) {
291
- case 'string':
292
- return Json.quote(value);
293
- case 'number':
294
- if (isFinite(value)) {
275
+ if (!((this.JSON != null) && (this.JSON.stringify != null) && typeof this.JSON.stringify === 'function')) {
276
+ json_escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
277
+ json_meta = {
278
+ '\b': '\\b',
279
+ '\t': '\\t',
280
+ '\n': '\\n',
281
+ '\f': '\\f',
282
+ '\r': '\\r',
283
+ '"': '\\"',
284
+ '\\': '\\\\'
285
+ };
286
+ json_quote = function(string) {
287
+ json_escapable.lastIndex = 0;
288
+ if (json_escapable.test(string)) {
289
+ return '"' + string.replace(json_escapable, function(a) {
290
+ var c;
291
+ c = json_meta[a];
292
+ return (typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4));
293
+ }) + '"';
294
+ } else {
295
+ return '"' + string + '"';
296
+ }
297
+ };
298
+ json_str = function(key, holder) {
299
+ var i, k, partial, v, value, _i, _len;
300
+ value = holder[key];
301
+ switch (typeof value) {
302
+ case 'string':
303
+ return json_quote(value);
304
+ case 'number':
305
+ if (isFinite(value)) {
306
+ return String(value);
307
+ } else {
308
+ return 'null';
309
+ }
310
+ case 'boolean':
311
+ case 'null':
295
312
  return String(value);
296
- } else {
297
- return 'null';
298
- }
299
- case 'boolean':
300
- case 'null':
301
- return String(value);
302
- case 'object':
303
- if (!value) {
304
- return 'null';
305
- }
306
- partial = [];
307
- if (Object.prototype.toString.apply(value) === '[object Array]') {
308
- for (i = _i = 0, _len = value.length; _i < _len; i = ++_i) {
309
- v = value[i];
310
- partial[i] = Json.str(i, value) || 'null';
313
+ case 'object':
314
+ if (!value) {
315
+ return 'null';
311
316
  }
312
- return (partial.length === 0 ? '[]' : '[' + partial.join(',') + ']');
313
- }
314
- for (k in value) {
315
- if (Object.prototype.hasOwnProperty.call(value, k)) {
316
- v = Json.str(k, value);
317
- if (v) {
318
- partial.push(Json.quote(k) + ':' + v);
317
+ partial = [];
318
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
319
+ for (i = _i = 0, _len = value.length; _i < _len; i = ++_i) {
320
+ v = value[i];
321
+ partial[i] = json_str(i, value) || 'null';
319
322
  }
323
+ return (partial.length === 0 ? '[]' : '[' + partial.join(',') + ']');
320
324
  }
321
- }
322
- return (partial.length === 0 ? '{}' : '{' + partial.join(',') + '}');
325
+ for (k in value) {
326
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
327
+ v = json_str(k, value);
328
+ if (v) {
329
+ partial.push(json_quote(k) + ':' + v);
330
+ }
331
+ }
332
+ }
333
+ return (partial.length === 0 ? '{}' : '{' + partial.join(',') + '}');
334
+ }
335
+ };
336
+ if (!(this.JSON != null)) {
337
+ this.JSON = {};
323
338
  }
324
- };
339
+ this.JSON.stringify = function(value) {
340
+ return json_str('', {
341
+ '': value
342
+ });
343
+ };
344
+ }
325
345
 
326
- toJson = function(value) {
327
- return Json.str('', {
328
- '': value
329
- });
346
+ html_escape = function(string) {
347
+ return ('' + string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g, '&#x2F;');
330
348
  };
331
349
 
332
- this.Tree.toJson = toJson;
333
-
334
350
  Position = {
335
351
  getName: function(position) {
336
- if (position === Position.BEFORE) {
337
- return 'before';
338
- } else if (position === Position.AFTER) {
339
- return 'after';
340
- } else if (position === Position.INSIDE) {
341
- return 'inside';
342
- } else {
343
- return 'none';
352
+ return Position.strings[position - 1];
353
+ },
354
+ nameToIndex: function(name) {
355
+ var i, _i, _ref;
356
+ for (i = _i = 1, _ref = Position.strings.length; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) {
357
+ if (Position.strings[i - 1] === name) {
358
+ return i;
359
+ }
344
360
  }
361
+ return 0;
345
362
  }
346
363
  };
347
364
 
@@ -353,49 +370,57 @@ limitations under the License.
353
370
 
354
371
  Position.NONE = 4;
355
372
 
373
+ Position.strings = ['before', 'after', 'inside', 'none'];
374
+
356
375
  this.Tree.Position = Position;
357
376
 
358
377
  Node = (function() {
359
378
 
360
- Node.name = 'Node';
361
-
362
- function Node(name) {
363
- this.init(name);
379
+ function Node(o) {
380
+ this.setData(o);
381
+ this.children = [];
382
+ this.parent = null;
364
383
  }
365
384
 
366
- Node.prototype.init = function(name) {
367
- this.name = name;
368
- this.children = [];
369
- return this.parent = null;
385
+ Node.prototype.setData = function(o) {
386
+ var key, value, _results;
387
+ if (typeof o !== 'object') {
388
+ return this.name = o;
389
+ } else {
390
+ _results = [];
391
+ for (key in o) {
392
+ value = o[key];
393
+ if (key === 'label') {
394
+ _results.push(this.name = value);
395
+ } else {
396
+ _results.push(this[key] = value);
397
+ }
398
+ }
399
+ return _results;
400
+ }
370
401
  };
371
402
 
372
403
  Node.prototype.initFromData = function(data) {
373
404
  var addChildren, addNode,
374
405
  _this = this;
375
406
  addNode = function(node_data) {
376
- return $.each(node_data, function(key, value) {
377
- if (key === 'children') {
378
- addChildren(value);
379
- } else if (key === 'label') {
380
- _this['name'] = value;
381
- } else {
382
- _this[key] = value;
383
- }
384
- return true;
385
- });
407
+ _this.setData(node_data);
408
+ if (node_data.children) {
409
+ return addChildren(node_data.children);
410
+ }
386
411
  };
387
412
  addChildren = function(children_data) {
388
- var child, node, _i, _len, _results;
389
- _results = [];
413
+ var child, node, _i, _len;
390
414
  for (_i = 0, _len = children_data.length; _i < _len; _i++) {
391
415
  child = children_data[_i];
392
- node = new Node();
416
+ node = new Node('');
393
417
  node.initFromData(child);
394
- _results.push(_this.addChild(node));
418
+ _this.addChild(node);
395
419
  }
396
- return _results;
420
+ return null;
397
421
  };
398
- return addNode(data);
422
+ addNode(data);
423
+ return null;
399
424
  };
400
425
 
401
426
  /*
@@ -418,27 +443,17 @@ limitations under the License.
418
443
 
419
444
 
420
445
  Node.prototype.loadFromData = function(data) {
421
- var node, o, _i, _len, _results,
422
- _this = this;
446
+ var node, o, _i, _len;
423
447
  this.children = [];
424
- _results = [];
425
448
  for (_i = 0, _len = data.length; _i < _len; _i++) {
426
449
  o = data[_i];
427
- node = new Node(o.label);
428
- $.each(o, function(key, value) {
429
- if (key !== 'label') {
430
- node[key] = value;
431
- }
432
- return true;
433
- });
450
+ node = new Node(o);
434
451
  this.addChild(node);
435
- if (o.children) {
436
- _results.push(node.loadFromData(o.children));
437
- } else {
438
- _results.push(void 0);
452
+ if (typeof o === 'object' && o.children) {
453
+ node.loadFromData(o.children);
439
454
  }
440
455
  }
441
- return _results;
456
+ return null;
442
457
  };
443
458
 
444
459
  /*
@@ -452,7 +467,7 @@ limitations under the License.
452
467
 
453
468
  Node.prototype.addChild = function(node) {
454
469
  this.children.push(node);
455
- return node.parent = this;
470
+ return node._setParent(this);
456
471
  };
457
472
 
458
473
  /*
@@ -467,18 +482,25 @@ limitations under the License.
467
482
 
468
483
  Node.prototype.addChildAtPosition = function(node, index) {
469
484
  this.children.splice(index, 0, node);
470
- return node.parent = this;
485
+ return node._setParent(this);
486
+ };
487
+
488
+ Node.prototype._setParent = function(parent) {
489
+ this.parent = parent;
490
+ this.tree = parent.tree;
491
+ return this.tree.addNodeToIndex(this);
471
492
  };
472
493
 
473
494
  /*
474
495
  Remove child.
475
496
 
476
- tree.removeChile(tree.children[0]);
497
+ tree.removeChild(tree.children[0]);
477
498
  */
478
499
 
479
500
 
480
501
  Node.prototype.removeChild = function(node) {
481
- return this.children.splice(this.getChildIndex(node), 1);
502
+ this.children.splice(this.getChildIndex(node), 1);
503
+ return this.tree.removeNodeFromIndex(node);
482
504
  };
483
505
 
484
506
  /*
@@ -505,6 +527,10 @@ limitations under the License.
505
527
  return this.children.length !== 0;
506
528
  };
507
529
 
530
+ Node.prototype.isFolder = function() {
531
+ return this.hasChildren() || this.load_on_demand;
532
+ };
533
+
508
534
  /*
509
535
  Iterate over all the nodes in the tree.
510
536
 
@@ -526,22 +552,22 @@ limitations under the License.
526
552
  Node.prototype.iterate = function(callback) {
527
553
  var _iterate,
528
554
  _this = this;
529
- _iterate = function(level) {
530
- var child, result, _i, _len, _ref, _results;
531
- _ref = _this.children;
532
- _results = [];
533
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
534
- child = _ref[_i];
535
- result = callback(child, level);
536
- if (_this.hasChildren() && result) {
537
- _results.push(child.iterate(callback, level + 1));
538
- } else {
539
- _results.push(void 0);
555
+ _iterate = function(node, level) {
556
+ var child, result, _i, _len, _ref;
557
+ if (node.children) {
558
+ _ref = node.children;
559
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
560
+ child = _ref[_i];
561
+ result = callback(child, level);
562
+ if (_this.hasChildren() && result) {
563
+ _iterate(child, level + 1);
564
+ }
540
565
  }
566
+ return null;
541
567
  }
542
- return _results;
543
568
  };
544
- return _iterate(0);
569
+ _iterate(this, 0);
570
+ return null;
545
571
  };
546
572
 
547
573
  /*
@@ -555,6 +581,9 @@ limitations under the License.
555
581
 
556
582
 
557
583
  Node.prototype.moveNode = function(moved_node, target_node, position) {
584
+ if (moved_node.isParentOf(target_node)) {
585
+ return;
586
+ }
558
587
  moved_node.parent.removeChild(moved_node);
559
588
  if (position === Position.AFTER) {
560
589
  return target_node.parent.addChildAtPosition(moved_node, target_node.parent.getChildIndex(target_node) + 1);
@@ -581,7 +610,7 @@ limitations under the License.
581
610
  tmp_node = {};
582
611
  for (k in node) {
583
612
  v = node[k];
584
- if ((k !== 'parent' && k !== 'children' && k !== 'element') && Object.prototype.hasOwnProperty.call(node, k)) {
613
+ if ((k !== 'parent' && k !== 'children' && k !== 'element' && k !== 'tree') && Object.prototype.hasOwnProperty.call(node, k)) {
585
614
  tmp_node[k] = v;
586
615
  }
587
616
  }
@@ -595,23 +624,144 @@ limitations under the License.
595
624
  return getDataFromNodes(this.children);
596
625
  };
597
626
 
627
+ Node.prototype.getNodeByName = function(name) {
628
+ var result;
629
+ result = null;
630
+ this.iterate(function(node) {
631
+ if (node.name === name) {
632
+ result = node;
633
+ return false;
634
+ } else {
635
+ return true;
636
+ }
637
+ });
638
+ return result;
639
+ };
640
+
641
+ Node.prototype.addAfter = function(node_info) {
642
+ var child_index, node;
643
+ if (!this.parent) {
644
+ return null;
645
+ } else {
646
+ node = new Node(node_info);
647
+ child_index = this.parent.getChildIndex(this);
648
+ this.parent.addChildAtPosition(node, child_index + 1);
649
+ return node;
650
+ }
651
+ };
652
+
653
+ Node.prototype.addBefore = function(node_info) {
654
+ var child_index, node;
655
+ if (!this.parent) {
656
+ return null;
657
+ } else {
658
+ node = new Node(node_info);
659
+ child_index = this.parent.getChildIndex(this);
660
+ return this.parent.addChildAtPosition(node, child_index);
661
+ }
662
+ };
663
+
664
+ Node.prototype.addParent = function(node_info) {
665
+ var child, new_parent, original_parent, _i, _len, _ref;
666
+ if (!this.parent) {
667
+ return null;
668
+ } else {
669
+ new_parent = new Node(node_info);
670
+ new_parent._setParent(this.tree);
671
+ original_parent = this.parent;
672
+ _ref = original_parent.children;
673
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
674
+ child = _ref[_i];
675
+ new_parent.addChild(child);
676
+ }
677
+ original_parent.children = [];
678
+ original_parent.addChild(new_parent);
679
+ return new_parent;
680
+ }
681
+ };
682
+
683
+ Node.prototype.remove = function() {
684
+ if (this.parent) {
685
+ this.parent.removeChild(this);
686
+ return this.parent = null;
687
+ }
688
+ };
689
+
690
+ Node.prototype.append = function(node_info) {
691
+ var node;
692
+ node = new Node(node_info);
693
+ this.addChild(node);
694
+ return node;
695
+ };
696
+
697
+ Node.prototype.prepend = function(node_info) {
698
+ var node;
699
+ node = new Node(node_info);
700
+ this.addChildAtPosition(node, 0);
701
+ return node;
702
+ };
703
+
704
+ Node.prototype.isParentOf = function(node) {
705
+ var parent;
706
+ parent = node.parent;
707
+ while (parent) {
708
+ if (parent === this) {
709
+ return true;
710
+ }
711
+ parent = parent.parent;
712
+ }
713
+ return false;
714
+ };
715
+
598
716
  return Node;
599
717
 
600
718
  })();
601
719
 
602
- this.Tree.Tree = Node;
720
+ Tree = (function(_super) {
721
+
722
+ __extends(Tree, _super);
723
+
724
+ function Tree(o) {
725
+ Tree.__super__.constructor.call(this, o, null, true);
726
+ this.id_mapping = {};
727
+ this.tree = this;
728
+ }
729
+
730
+ Tree.prototype.getNodeById = function(node_id) {
731
+ return this.id_mapping[node_id];
732
+ };
733
+
734
+ Tree.prototype.addNodeToIndex = function(node) {
735
+ if (node.id) {
736
+ return this.id_mapping[node.id] = node;
737
+ }
738
+ };
739
+
740
+ Tree.prototype.removeNodeFromIndex = function(node) {
741
+ if (node.id) {
742
+ return delete this.id_mapping[node.id];
743
+ }
744
+ };
745
+
746
+ return Tree;
603
747
 
604
- JqueryWidget = (function(_super) {
748
+ })(Node);
605
749
 
606
- __extends(JqueryWidget, _super);
750
+ this.Tree.Tree = Tree;
607
751
 
608
- JqueryWidget.name = 'JqueryWidget';
752
+ TRIANGLE_RIGHT = '&#x25ba;';
609
753
 
610
- function JqueryWidget() {
611
- return JqueryWidget.__super__.constructor.apply(this, arguments);
754
+ TRIANGLE_DOWN = '&#x25bc;';
755
+
756
+ JqTreeWidget = (function(_super) {
757
+
758
+ __extends(JqTreeWidget, _super);
759
+
760
+ function JqTreeWidget() {
761
+ return JqTreeWidget.__super__.constructor.apply(this, arguments);
612
762
  }
613
763
 
614
- JqueryWidget.prototype.defaults = {
764
+ JqTreeWidget.prototype.defaults = {
615
765
  autoOpen: false,
616
766
  saveState: false,
617
767
  dragAndDrop: false,
@@ -622,141 +772,289 @@ limitations under the License.
622
772
  onCreateLi: null,
623
773
  onIsMoveHandle: null,
624
774
  onCanMove: null,
625
- onCanMoveTo: null
775
+ onCanMoveTo: null,
776
+ autoEscape: true,
777
+ dataUrl: null
626
778
  };
627
779
 
628
- JqueryWidget.prototype.toggle = function(node, on_finished) {
629
- if (node.hasChildren()) {
630
- new FolderElement(node).toggle(on_finished);
631
- }
632
- if (this.options.saveState) {
633
- return this._saveState();
780
+ JqTreeWidget.prototype.toggle = function(node) {
781
+ if (node.is_open) {
782
+ return this.closeNode(node);
783
+ } else {
784
+ return this.openNode(node);
634
785
  }
635
786
  };
636
787
 
637
- JqueryWidget.prototype.getTree = function() {
788
+ JqTreeWidget.prototype.getTree = function() {
638
789
  return this.tree;
639
790
  };
640
791
 
641
- JqueryWidget.prototype.selectNode = function(node, must_open_parents) {
642
- var parent;
643
- if (this.options.selectable) {
644
- if (this.selected_node) {
645
- this._getNodeElementForNode(this.selected_node).deselect();
646
- }
647
- this._getNodeElementForNode(node).select();
648
- this.selected_node = node;
649
- if (must_open_parents) {
650
- parent = this.selected_node.parent;
651
- while (parent) {
652
- if (!parent.is_open) {
653
- this.openNode(parent, null, true);
654
- }
655
- parent = parent.parent;
656
- }
657
- }
658
- if (this.options.saveState) {
659
- return this._saveState();
660
- }
661
- }
792
+ JqTreeWidget.prototype.selectNode = function(node, must_open_parents) {
793
+ return this.select_node_handler.selectNode(node, must_open_parents);
662
794
  };
663
795
 
664
- JqueryWidget.prototype.getSelectedNode = function() {
796
+ JqTreeWidget.prototype.getSelectedNode = function() {
665
797
  return this.selected_node || false;
666
798
  };
667
799
 
668
- JqueryWidget.prototype.toJson = function() {
669
- return toJson(this.tree.getData());
800
+ JqTreeWidget.prototype.toJson = function() {
801
+ return JSON.stringify(this.tree.getData());
802
+ };
803
+
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();
814
+ }
815
+ }
670
816
  };
671
817
 
672
- JqueryWidget.prototype.loadData = function(data, parent_node) {
673
- var $div, $element, child, subtree, _i, _len, _ref;
818
+ JqTreeWidget.prototype._loadData = function(data, parent_node) {
819
+ var child, subtree, _i, _len, _ref;
820
+ this._triggerEvent('tree.load_data', {
821
+ tree_data: data
822
+ });
674
823
  if (!parent_node) {
675
- return this._initTree(data);
824
+ this._initTree(data);
676
825
  } else {
677
- subtree = new Node();
826
+ subtree = new Node('');
827
+ subtree._setParent(parent_node.tree);
678
828
  subtree.loadFromData(data);
679
829
  _ref = subtree.children;
680
830
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
681
831
  child = _ref[_i];
682
832
  parent_node.addChild(child);
683
833
  }
684
- $element = $(parent_node.element);
685
- $element.children('ul').detach();
686
- this._createDomElements(parent_node, $element);
687
- $div = $element.children('div');
688
- if (!$div.find('.toggler').length) {
689
- return $div.prepend('<a class="toggler">&raquo;</a>');
690
- }
834
+ this._refreshElements(parent_node.parent);
835
+ }
836
+ if (this.is_dragging) {
837
+ return this.dnd_handler.refreshHitAreas();
691
838
  }
692
839
  };
693
840
 
694
- JqueryWidget.prototype.getNodeById = function(node_id) {
695
- var result;
696
- result = null;
697
- this.tree.iterate(function(node) {
698
- if (node.id === node_id) {
699
- result = node;
700
- return false;
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
+ JqTreeWidget.prototype.getNodeById = function(node_id) {
876
+ return this.tree.getNodeById(node_id);
877
+ };
878
+
879
+ JqTreeWidget.prototype.getNodeByName = function(name) {
880
+ return this.tree.getNodeByName(name);
881
+ };
882
+
883
+ JqTreeWidget.prototype.openNode = function(node, skip_slide) {
884
+ return this._openNode(node, skip_slide);
885
+ };
886
+
887
+ JqTreeWidget.prototype._openNode = function(node, skip_slide, on_finished) {
888
+ var folder_element;
889
+ if (node.isFolder()) {
890
+ if (node.load_on_demand) {
891
+ return this._loadFolderOnDemand(node, skip_slide, on_finished);
701
892
  } else {
702
- return true;
893
+ folder_element = new FolderElement(node, this);
894
+ folder_element.open(on_finished, skip_slide);
895
+ return this._saveState();
703
896
  }
897
+ }
898
+ };
899
+
900
+ JqTreeWidget.prototype._loadFolderOnDemand = function(node, skip_slide, on_finished) {
901
+ var _this = this;
902
+ node.load_on_demand = false;
903
+ return this.loadData(this._getDataUrl(node), node, function() {
904
+ return _this._openNode(node, skip_slide, on_finished);
704
905
  });
705
- return result;
706
906
  };
707
907
 
708
- JqueryWidget.prototype.openNode = function(node, on_finished, skip_slide) {
709
- if (node.hasChildren()) {
710
- return new FolderElement(node).open(on_finished, skip_slide);
908
+ JqTreeWidget.prototype.closeNode = function(node, skip_slide) {
909
+ if (node.isFolder()) {
910
+ new FolderElement(node, this).close(skip_slide);
911
+ return this._saveState();
711
912
  }
712
913
  };
713
914
 
714
- JqueryWidget.prototype._init = function() {
715
- JqueryWidget.__super__._init.apply(this, arguments);
716
- this.element = this.$el;
717
- this._initTree(this.options.data);
718
- this.element.click($.proxy(this._click, this));
719
- this.element.bind('contextmenu', $.proxy(this._contextmenu, this));
720
- this.hovered_area = null;
721
- this.$ghost = null;
722
- return this.hit_areas = [];
915
+ JqTreeWidget.prototype.isDragging = function() {
916
+ return this.is_dragging;
723
917
  };
724
918
 
725
- JqueryWidget.prototype._deinit = function() {
726
- this.element.empty();
727
- this.element.unbind();
728
- this.tree = null;
729
- return JqueryWidget.__super__._deinit.apply(this, arguments);
919
+ JqTreeWidget.prototype.refreshHitAreas = function() {
920
+ return this.dnd_handler.refreshHitAreas();
730
921
  };
731
922
 
732
- JqueryWidget.prototype._initTree = function(data) {
733
- var node_element;
734
- this.tree = new Node();
735
- this.tree.loadFromData(data);
736
- this.selected_node = null;
737
- this._openNodes();
738
- this._createDomElements(this.tree);
739
- if (this.selected_node) {
740
- node_element = this._getNodeElementForNode(this.selected_node);
741
- if (node_element) {
742
- return node_element.select();
743
- }
923
+ JqTreeWidget.prototype.addNodeAfter = function(new_node_info, existing_node) {
924
+ var new_node;
925
+ new_node = existing_node.addAfter(new_node_info);
926
+ this._refreshElements(existing_node.parent);
927
+ return new_node;
928
+ };
929
+
930
+ JqTreeWidget.prototype.addNodeBefore = function(new_node_info, existing_node) {
931
+ var new_node;
932
+ new_node = existing_node.addBefore(new_node_info);
933
+ this._refreshElements(existing_node.parent);
934
+ return new_node;
935
+ };
936
+
937
+ JqTreeWidget.prototype.addParentNode = function(new_node_info, existing_node) {
938
+ var new_node;
939
+ new_node = existing_node.addParent(new_node_info);
940
+ this._refreshElements(new_node.parent);
941
+ return new_node;
942
+ };
943
+
944
+ JqTreeWidget.prototype.removeNode = function(node) {
945
+ var parent;
946
+ parent = node.parent;
947
+ if (parent) {
948
+ node.remove();
949
+ return this._refreshElements(parent.parent);
744
950
  }
745
951
  };
746
952
 
747
- JqueryWidget.prototype._openNodes = function() {
748
- var max_level;
749
- if (this.options.saveState) {
750
- if (this._restoreState()) {
751
- return;
752
- }
953
+ JqTreeWidget.prototype.appendNode = function(new_node_info, parent_node) {
954
+ var is_already_root_node, node;
955
+ if (!parent_node) {
956
+ parent_node = this.tree;
753
957
  }
754
- if (this.options.autoOpen === false) {
755
- return;
756
- } else if (this.options.autoOpen === true) {
757
- max_level = -1;
958
+ is_already_root_node = parent_node.isFolder();
959
+ node = parent_node.append(new_node_info);
960
+ if (is_already_root_node) {
961
+ this._refreshElements(parent_node);
758
962
  } else {
759
- max_level = parseInt(this.options.autoOpen);
963
+ this._refreshElements(parent_node.parent);
964
+ }
965
+ return node;
966
+ };
967
+
968
+ JqTreeWidget.prototype.prependNode = function(new_node_info, parent_node) {
969
+ var node;
970
+ if (!parent_node) {
971
+ parent_node = this.tree;
972
+ }
973
+ node = parent_node.prepend(new_node_info);
974
+ this._refreshElements(parent_node);
975
+ return node;
976
+ };
977
+
978
+ JqTreeWidget.prototype.updateNode = function(node, data) {
979
+ node.setData(data);
980
+ this._refreshElements(node.parent);
981
+ return this.select_node_handler.selectCurrentNode();
982
+ };
983
+
984
+ JqTreeWidget.prototype.moveNode = function(node, target_node, position) {
985
+ var position_index;
986
+ position_index = Position.nameToIndex(position);
987
+ this.tree.moveNode(node, target_node, position_index);
988
+ return this._refreshElements();
989
+ };
990
+
991
+ JqTreeWidget.prototype.getStateFromStorage = function() {
992
+ return this.save_state_handler.getStateFromStorage();
993
+ };
994
+
995
+ JqTreeWidget.prototype._init = function() {
996
+ JqTreeWidget.__super__._init.call(this);
997
+ this.element = this.$el;
998
+ this.selected_node = null;
999
+ this.mouse_delay = 300;
1000
+ this.save_state_handler = new SaveStateHandler(this);
1001
+ this.select_node_handler = new SelectNodeHandler(this);
1002
+ this.dnd_handler = new DragAndDropHandler(this);
1003
+ this._initData();
1004
+ this.element.click($.proxy(this._click, this));
1005
+ return this.element.bind('contextmenu', $.proxy(this._contextmenu, this));
1006
+ };
1007
+
1008
+ JqTreeWidget.prototype._deinit = function() {
1009
+ this.element.empty();
1010
+ this.element.unbind();
1011
+ this.tree = null;
1012
+ return JqTreeWidget.__super__._deinit.call(this);
1013
+ };
1014
+
1015
+ JqTreeWidget.prototype._initData = function() {
1016
+ if (this.options.data) {
1017
+ return this.loadData(this.options.data);
1018
+ } else {
1019
+ return this.loadData(this._getDataUrl());
1020
+ }
1021
+ };
1022
+
1023
+ JqTreeWidget.prototype._getDataUrl = function(node) {
1024
+ var data_url;
1025
+ data_url = this.options.dataUrl || this.element.data('url');
1026
+ if ($.isFunction(data_url)) {
1027
+ return data_url(node);
1028
+ } else {
1029
+ if (node) {
1030
+ data_url += "?node=" + node.id;
1031
+ }
1032
+ return data_url;
1033
+ }
1034
+ };
1035
+
1036
+ JqTreeWidget.prototype._initTree = function(data) {
1037
+ this.tree = new Tree();
1038
+ this.tree.loadFromData(data);
1039
+ this._openNodes();
1040
+ this._refreshElements();
1041
+ this.select_node_handler.selectCurrentNode();
1042
+ return this._triggerEvent('tree.init');
1043
+ };
1044
+
1045
+ JqTreeWidget.prototype._openNodes = function() {
1046
+ var max_level;
1047
+ if (this.options.saveState) {
1048
+ if (this.save_state_handler.restoreState()) {
1049
+ return;
1050
+ }
1051
+ }
1052
+ if (this.options.autoOpen === false) {
1053
+ return;
1054
+ } else if (this.options.autoOpen === true) {
1055
+ max_level = -1;
1056
+ } else {
1057
+ max_level = parseInt(this.options.autoOpen);
760
1058
  }
761
1059
  return this.tree.iterate(function(node, level) {
762
1060
  node.is_open = true;
@@ -764,21 +1062,31 @@ limitations under the License.
764
1062
  });
765
1063
  };
766
1064
 
767
- JqueryWidget.prototype._createDomElements = function(tree, $element) {
768
- var createFolderLi, createLi, createNodeLi, createUl, depth, doCreateDomElements,
1065
+ JqTreeWidget.prototype._refreshElements = function(from_node) {
1066
+ var $element, createFolderLi, createLi, createNodeLi, createUl, doCreateDomElements, escapeIfNecessary, is_root_node, node_element,
769
1067
  _this = this;
770
- createUl = function(depth, is_open) {
1068
+ if (from_node == null) {
1069
+ from_node = null;
1070
+ }
1071
+ escapeIfNecessary = function(value) {
1072
+ if (_this.options.autoEscape) {
1073
+ return html_escape(value);
1074
+ } else {
1075
+ return value;
1076
+ }
1077
+ };
1078
+ createUl = function(is_root_node) {
771
1079
  var class_string;
772
- if (depth) {
773
- class_string = '';
1080
+ if (is_root_node) {
1081
+ class_string = ' class="jqtree-tree"';
774
1082
  } else {
775
- class_string = ' class="tree"';
1083
+ class_string = '';
776
1084
  }
777
1085
  return $("<ul" + class_string + "></ul>");
778
1086
  };
779
1087
  createLi = function(node) {
780
1088
  var $li;
781
- if (node.hasChildren()) {
1089
+ if (node.isFolder()) {
782
1090
  $li = createFolderLi(node);
783
1091
  } else {
784
1092
  $li = createNodeLi(node);
@@ -789,35 +1097,42 @@ limitations under the License.
789
1097
  return $li;
790
1098
  };
791
1099
  createNodeLi = function(node) {
792
- return $("<li><div><span class=\"title\">" + node.name + "</span></div></li>");
1100
+ var escaped_name;
1101
+ escaped_name = escapeIfNecessary(node.name);
1102
+ return $("<li><div><span class=\"jqtree-title\">" + escaped_name + "</span></div></li>");
793
1103
  };
794
1104
  createFolderLi = function(node) {
795
- var button_class, folder_class, getButtonClass, getFolderClass;
796
- getButtonClass = function() {
1105
+ var button_char, button_classes, escaped_name, folder_classes, getButtonClasses, getFolderClasses;
1106
+ getButtonClasses = function() {
797
1107
  var classes;
798
- classes = ['toggler'];
1108
+ classes = ['jqtree-toggler'];
799
1109
  if (!node.is_open) {
800
- classes.push('closed');
1110
+ classes.push('jqtree-closed');
801
1111
  }
802
1112
  return classes.join(' ');
803
1113
  };
804
- getFolderClass = function() {
1114
+ getFolderClasses = function() {
805
1115
  var classes;
806
- classes = ['folder'];
1116
+ classes = ['jqtree-folder'];
807
1117
  if (!node.is_open) {
808
- classes.push('closed');
1118
+ classes.push('jqtree-closed');
809
1119
  }
810
1120
  return classes.join(' ');
811
1121
  };
812
- button_class = getButtonClass();
813
- folder_class = getFolderClass();
814
- return $("<li class=\"" + folder_class + "\"><div><a class=\"" + button_class + "\">&raquo;</a><span class=\"title\">" + node.name + "</span></div></li>");
1122
+ button_classes = getButtonClasses();
1123
+ folder_classes = getFolderClasses();
1124
+ escaped_name = escapeIfNecessary(node.name);
1125
+ if (node.is_open) {
1126
+ button_char = TRIANGLE_DOWN;
1127
+ } else {
1128
+ button_char = TRIANGLE_RIGHT;
1129
+ }
1130
+ return $("<li class=\"" + folder_classes + "\"><div><a class=\"" + button_classes + "\">" + button_char + "</a><span class=\"jqtree-title\">" + escaped_name + "</span></div></li>");
815
1131
  };
816
- doCreateDomElements = function($element, children, depth, is_open) {
817
- var $li, $ul, child, _i, _len, _results;
818
- $ul = createUl(depth, is_open);
1132
+ doCreateDomElements = function($element, children, is_root_node, is_open) {
1133
+ var $li, $ul, child, _i, _len;
1134
+ $ul = createUl(is_root_node);
819
1135
  $element.append($ul);
820
- _results = [];
821
1136
  for (_i = 0, _len = children.length; _i < _len; _i++) {
822
1137
  child = children[_i];
823
1138
  $li = createLi(child);
@@ -825,65 +1140,51 @@ limitations under the License.
825
1140
  child.element = $li[0];
826
1141
  $li.data('node', child);
827
1142
  if (child.hasChildren()) {
828
- _results.push(doCreateDomElements($li, child.children, depth + 1, child.is_open));
829
- } else {
830
- _results.push(void 0);
1143
+ doCreateDomElements($li, child.children, false, child.is_open);
831
1144
  }
832
1145
  }
833
- return _results;
1146
+ return null;
834
1147
  };
835
- if ($element) {
836
- depth = 1;
1148
+ if (from_node && from_node.parent) {
1149
+ is_root_node = false;
1150
+ node_element = this._getNodeElementForNode(from_node);
1151
+ node_element.getUl().remove();
1152
+ $element = node_element.$element;
837
1153
  } else {
1154
+ from_node = this.tree;
838
1155
  $element = this.element;
839
1156
  $element.empty();
840
- depth = 0;
1157
+ is_root_node = true;
841
1158
  }
842
- return doCreateDomElements($element, tree.children, depth, true);
1159
+ doCreateDomElements($element, from_node.children, is_root_node, is_root_node);
1160
+ return this._triggerEvent('tree.refresh');
843
1161
  };
844
1162
 
845
- JqueryWidget.prototype._click = function(e) {
846
- var $target, event, node, node_element,
847
- _this = this;
1163
+ JqTreeWidget.prototype._click = function(e) {
1164
+ var $target, node;
848
1165
  if (e.ctrlKey) {
849
1166
  return;
850
1167
  }
851
1168
  $target = $(e.target);
852
- if ($target.is('.toggler')) {
853
- node_element = this._getNodeElement($target);
854
- if (node_element && node_element.node.hasChildren()) {
855
- node_element.toggle(function() {
856
- var event, event_name, node;
857
- node = node_element.node;
858
- if (node.is_open) {
859
- event_name = 'tree.open';
860
- } else {
861
- event_name = 'tree.close';
862
- }
863
- event = $.Event(event_name);
864
- event.node = node;
865
- return _this.element.trigger(event);
866
- });
867
- if (this.options.saveState) {
868
- this._saveState();
869
- }
1169
+ if ($target.is('.jqtree-toggler')) {
1170
+ node = this._getNode($target);
1171
+ if (node) {
1172
+ this.toggle(node);
870
1173
  e.preventDefault();
871
1174
  return e.stopPropagation();
872
1175
  }
873
1176
  } else if ($target.is('div') || $target.is('span')) {
874
1177
  node = this._getNode($target);
875
1178
  if (node) {
876
- if ((!this.options.onCanSelectNode) || this.options.onCanSelectNode(node)) {
877
- this.selectNode(node);
878
- event = $.Event('tree.click');
879
- event.node = node;
880
- return this.element.trigger(event);
881
- }
1179
+ this._triggerEvent('tree.click', {
1180
+ node: node
1181
+ });
1182
+ return this.selectNode(node);
882
1183
  }
883
1184
  }
884
1185
  };
885
1186
 
886
- JqueryWidget.prototype._getNode = function($element) {
1187
+ JqTreeWidget.prototype._getNode = function($element) {
887
1188
  var $li;
888
1189
  $li = $element.closest('li');
889
1190
  if ($li.length === 0) {
@@ -893,131 +1194,479 @@ limitations under the License.
893
1194
  }
894
1195
  };
895
1196
 
896
- JqueryWidget.prototype._restoreState = function() {
897
- var state;
898
- if (this.options.onGetStateFromStorage) {
899
- state = this.options.onGetStateFromStorage();
1197
+ JqTreeWidget.prototype._getNodeElementForNode = function(node) {
1198
+ if (node.isFolder()) {
1199
+ return new FolderElement(node, this);
1200
+ } else {
1201
+ return new NodeElement(node, this);
1202
+ }
1203
+ };
1204
+
1205
+ JqTreeWidget.prototype._getNodeElement = function($element) {
1206
+ var node;
1207
+ node = this._getNode($element);
1208
+ if (node) {
1209
+ return this._getNodeElementForNode(node);
900
1210
  } else {
901
- if ($.cookie) {
902
- state = $.cookie(this._getCookieName(), {
903
- path: '/'
1211
+ return null;
1212
+ }
1213
+ };
1214
+
1215
+ JqTreeWidget.prototype._contextmenu = function(e) {
1216
+ var $div, node;
1217
+ $div = $(e.target).closest('ul.jqtree-tree div');
1218
+ if ($div.length) {
1219
+ node = this._getNode($div);
1220
+ if (node) {
1221
+ e.preventDefault();
1222
+ e.stopPropagation();
1223
+ this._triggerEvent('tree.contextmenu', {
1224
+ node: node,
1225
+ click_event: e
904
1226
  });
905
- } else {
906
- state = null;
1227
+ return false;
907
1228
  }
908
1229
  }
909
- if (!state) {
1230
+ };
1231
+
1232
+ JqTreeWidget.prototype._saveState = function() {
1233
+ if (this.options.saveState) {
1234
+ return this.save_state_handler.saveState();
1235
+ }
1236
+ };
1237
+
1238
+ JqTreeWidget.prototype._mouseCapture = function(event) {
1239
+ if (this.options.dragAndDrop) {
1240
+ return this.dnd_handler.mouseCapture(event);
1241
+ } else {
910
1242
  return false;
1243
+ }
1244
+ };
1245
+
1246
+ JqTreeWidget.prototype._mouseStart = function(event) {
1247
+ if (this.options.dragAndDrop) {
1248
+ return this.dnd_handler.mouseStart(event);
911
1249
  } else {
912
- this._setState(state);
913
- return true;
1250
+ return false;
914
1251
  }
915
1252
  };
916
1253
 
917
- JqueryWidget.prototype._saveState = function() {
918
- if (this.options.onSetStateFromStorage) {
919
- return this.options.onSetStateFromStorage(this._getState());
1254
+ JqTreeWidget.prototype._mouseDrag = function(event) {
1255
+ if (this.options.dragAndDrop) {
1256
+ return this.dnd_handler.mouseDrag(event);
920
1257
  } else {
921
- if ($.cookie) {
922
- return $.cookie(this._getCookieName(), this._getState(), {
923
- path: '/'
1258
+ return false;
1259
+ }
1260
+ };
1261
+
1262
+ JqTreeWidget.prototype._mouseStop = function() {
1263
+ if (this.options.dragAndDrop) {
1264
+ return this.dnd_handler.mouseStop();
1265
+ } else {
1266
+ return false;
1267
+ }
1268
+ };
1269
+
1270
+ JqTreeWidget.prototype._triggerEvent = function(event_name, values) {
1271
+ var event;
1272
+ event = $.Event(event_name);
1273
+ $.extend(event, values);
1274
+ this.element.trigger(event);
1275
+ return event;
1276
+ };
1277
+
1278
+ JqTreeWidget.prototype.testGenerateHitAreas = function(moving_node) {
1279
+ this.dnd_handler.current_item = this._getNodeElementForNode(moving_node);
1280
+ this.dnd_handler.generateHitAreas();
1281
+ return this.dnd_handler.hit_areas;
1282
+ };
1283
+
1284
+ return JqTreeWidget;
1285
+
1286
+ })(MouseWidget);
1287
+
1288
+ SimpleWidget.register(JqTreeWidget, 'tree');
1289
+
1290
+ GhostDropHint = (function() {
1291
+
1292
+ function GhostDropHint(node, $element, position) {
1293
+ this.$element = $element;
1294
+ this.node = node;
1295
+ this.$ghost = $('<li class="jqtree-ghost"><span class="jqtree-circle"></span><span class="jqtree-line"></span></li>');
1296
+ if (position === Position.AFTER) {
1297
+ this.moveAfter();
1298
+ } else if (position === Position.BEFORE) {
1299
+ this.moveBefore();
1300
+ } else if (position === Position.INSIDE) {
1301
+ if (node.isFolder() && node.is_open) {
1302
+ this.moveInsideOpenFolder();
1303
+ } else {
1304
+ this.moveInside();
1305
+ }
1306
+ }
1307
+ }
1308
+
1309
+ GhostDropHint.prototype.remove = function() {
1310
+ return this.$ghost.remove();
1311
+ };
1312
+
1313
+ GhostDropHint.prototype.moveAfter = function() {
1314
+ return this.$element.after(this.$ghost);
1315
+ };
1316
+
1317
+ GhostDropHint.prototype.moveBefore = function() {
1318
+ return this.$element.before(this.$ghost);
1319
+ };
1320
+
1321
+ GhostDropHint.prototype.moveInsideOpenFolder = function() {
1322
+ return $(this.node.children[0].element).before(this.$ghost);
1323
+ };
1324
+
1325
+ GhostDropHint.prototype.moveInside = function() {
1326
+ this.$element.after(this.$ghost);
1327
+ return this.$ghost.addClass('jqtree-inside');
1328
+ };
1329
+
1330
+ return GhostDropHint;
1331
+
1332
+ })();
1333
+
1334
+ BorderDropHint = (function() {
1335
+
1336
+ function BorderDropHint($element) {
1337
+ var $div, width;
1338
+ $div = $element.children('div');
1339
+ width = $element.width() - 4;
1340
+ this.$hint = $('<span class="jqtree-border"></span>');
1341
+ $div.append(this.$hint);
1342
+ this.$hint.css({
1343
+ width: width,
1344
+ height: $div.height() - 4
1345
+ });
1346
+ }
1347
+
1348
+ BorderDropHint.prototype.remove = function() {
1349
+ return this.$hint.remove();
1350
+ };
1351
+
1352
+ return BorderDropHint;
1353
+
1354
+ })();
1355
+
1356
+ NodeElement = (function() {
1357
+
1358
+ function NodeElement(node, tree_widget) {
1359
+ this.init(node, tree_widget);
1360
+ }
1361
+
1362
+ NodeElement.prototype.init = function(node, tree_widget) {
1363
+ this.node = node;
1364
+ this.tree_widget = tree_widget;
1365
+ return this.$element = $(node.element);
1366
+ };
1367
+
1368
+ NodeElement.prototype.getUl = function() {
1369
+ return this.$element.children('ul:first');
1370
+ };
1371
+
1372
+ NodeElement.prototype.getSpan = function() {
1373
+ return this.$element.children('div').find('span.jqtree-title');
1374
+ };
1375
+
1376
+ NodeElement.prototype.getLi = function() {
1377
+ return this.$element;
1378
+ };
1379
+
1380
+ NodeElement.prototype.addDropHint = function(position) {
1381
+ if (position === Position.INSIDE) {
1382
+ return new BorderDropHint(this.$element);
1383
+ } else {
1384
+ return new GhostDropHint(this.node, this.$element, position);
1385
+ }
1386
+ };
1387
+
1388
+ NodeElement.prototype.select = function() {
1389
+ return this.getLi().addClass('jqtree-selected');
1390
+ };
1391
+
1392
+ NodeElement.prototype.deselect = function() {
1393
+ return this.getLi().removeClass('jqtree-selected');
1394
+ };
1395
+
1396
+ return NodeElement;
1397
+
1398
+ })();
1399
+
1400
+ FolderElement = (function(_super) {
1401
+
1402
+ __extends(FolderElement, _super);
1403
+
1404
+ function FolderElement() {
1405
+ return FolderElement.__super__.constructor.apply(this, arguments);
1406
+ }
1407
+
1408
+ FolderElement.prototype.open = function(on_finished, skip_slide) {
1409
+ var $button, doOpen,
1410
+ _this = this;
1411
+ if (!this.node.is_open) {
1412
+ this.node.is_open = true;
1413
+ $button = this.getButton();
1414
+ $button.removeClass('jqtree-closed');
1415
+ $button.html(TRIANGLE_DOWN);
1416
+ doOpen = function() {
1417
+ _this.getLi().removeClass('jqtree-closed');
1418
+ if (on_finished) {
1419
+ on_finished();
1420
+ }
1421
+ return _this.tree_widget._triggerEvent('tree.open', {
1422
+ node: _this.node
1423
+ });
1424
+ };
1425
+ if (skip_slide) {
1426
+ this.getUl().show();
1427
+ return doOpen();
1428
+ } else {
1429
+ return this.getUl().slideDown('fast', doOpen);
1430
+ }
1431
+ }
1432
+ };
1433
+
1434
+ FolderElement.prototype.close = function(skip_slide) {
1435
+ var $button, doClose,
1436
+ _this = this;
1437
+ if (this.node.is_open) {
1438
+ this.node.is_open = false;
1439
+ $button = this.getButton();
1440
+ $button.addClass('jqtree-closed');
1441
+ $button.html(TRIANGLE_RIGHT);
1442
+ doClose = function() {
1443
+ _this.getLi().addClass('jqtree-closed');
1444
+ return _this.tree_widget._triggerEvent('tree.close', {
1445
+ node: _this.node
924
1446
  });
1447
+ };
1448
+ if (skip_slide) {
1449
+ this.getUl().hide();
1450
+ return doClose();
1451
+ } else {
1452
+ return this.getUl().slideUp('fast', doClose);
925
1453
  }
926
1454
  }
927
1455
  };
928
1456
 
929
- JqueryWidget.prototype._getState = function() {
1457
+ FolderElement.prototype.getButton = function() {
1458
+ return this.$element.children('div').find('a.jqtree-toggler');
1459
+ };
1460
+
1461
+ FolderElement.prototype.addDropHint = function(position) {
1462
+ if (!this.node.is_open && position === Position.INSIDE) {
1463
+ return new BorderDropHint(this.$element);
1464
+ } else {
1465
+ return new GhostDropHint(this.node, this.$element, position);
1466
+ }
1467
+ };
1468
+
1469
+ return FolderElement;
1470
+
1471
+ })(NodeElement);
1472
+
1473
+ DragElement = (function() {
1474
+
1475
+ function DragElement(node, offset_x, offset_y, $tree) {
1476
+ this.offset_x = offset_x;
1477
+ this.offset_y = offset_y;
1478
+ this.$element = $("<span class=\"jqtree-title jqtree-dragging\">" + node.name + "</span>");
1479
+ this.$element.css("position", "absolute");
1480
+ $tree.append(this.$element);
1481
+ }
1482
+
1483
+ DragElement.prototype.move = function(page_x, page_y) {
1484
+ return this.$element.offset({
1485
+ left: page_x - this.offset_x,
1486
+ top: page_y - this.offset_y
1487
+ });
1488
+ };
1489
+
1490
+ DragElement.prototype.remove = function() {
1491
+ return this.$element.remove();
1492
+ };
1493
+
1494
+ return DragElement;
1495
+
1496
+ })();
1497
+
1498
+ SaveStateHandler = (function() {
1499
+
1500
+ function SaveStateHandler(tree_widget) {
1501
+ this.tree_widget = tree_widget;
1502
+ }
1503
+
1504
+ SaveStateHandler.prototype.saveState = function() {
1505
+ if (this.tree_widget.options.onSetStateFromStorage) {
1506
+ return this.tree_widget.options.onSetStateFromStorage(this.getState());
1507
+ } else if (typeof localStorage !== "undefined" && localStorage !== null) {
1508
+ return localStorage.setItem(this.getCookieName(), this.getState());
1509
+ } else if ($.cookie) {
1510
+ return $.cookie(this.getCookieName(), this.getState(), {
1511
+ path: '/'
1512
+ });
1513
+ }
1514
+ };
1515
+
1516
+ SaveStateHandler.prototype.restoreState = function() {
1517
+ var state;
1518
+ state = this.getStateFromStorage();
1519
+ if (state) {
1520
+ this.setState(state);
1521
+ return true;
1522
+ } else {
1523
+ return false;
1524
+ }
1525
+ };
1526
+
1527
+ SaveStateHandler.prototype.getStateFromStorage = function() {
1528
+ if (this.tree_widget.options.onGetStateFromStorage) {
1529
+ return this.tree_widget.options.onGetStateFromStorage();
1530
+ } else if (typeof localStorage !== "undefined" && localStorage !== null) {
1531
+ return localStorage.getItem(this.getCookieName());
1532
+ } else if ($.cookie) {
1533
+ return $.cookie(this.getCookieName(), {
1534
+ path: '/'
1535
+ });
1536
+ } else {
1537
+ return null;
1538
+ }
1539
+ };
1540
+
1541
+ SaveStateHandler.prototype.getState = function() {
930
1542
  var open_nodes, selected_node,
931
1543
  _this = this;
932
1544
  open_nodes = [];
933
- this.tree.iterate(function(node) {
1545
+ this.tree_widget.tree.iterate(function(node) {
934
1546
  if (node.is_open && node.id && node.hasChildren()) {
935
1547
  open_nodes.push(node.id);
936
1548
  }
937
1549
  return true;
938
1550
  });
939
1551
  selected_node = '';
940
- if (this.selected_node) {
941
- selected_node = this.selected_node.id;
1552
+ if (this.tree_widget.selected_node) {
1553
+ selected_node = this.tree_widget.selected_node.id;
942
1554
  }
943
- return toJson({
1555
+ return JSON.stringify({
944
1556
  open_nodes: open_nodes,
945
1557
  selected_node: selected_node
946
1558
  });
947
1559
  };
948
1560
 
949
- JqueryWidget.prototype._setState = function(state) {
1561
+ SaveStateHandler.prototype.setState = function(state) {
950
1562
  var data, open_nodes, selected_node_id,
951
1563
  _this = this;
952
1564
  data = $.parseJSON(state);
953
- open_nodes = data.open_nodes;
954
- selected_node_id = data.selected_node;
955
- return this.tree.iterate(function(node) {
956
- if (node.id && node.hasChildren() && (indexOf(open_nodes, node.id) >= 0)) {
957
- node.is_open = true;
958
- }
959
- if (selected_node_id && (node.id === selected_node_id)) {
960
- _this.selected_node = node;
961
- }
962
- return true;
963
- });
1565
+ if (data) {
1566
+ open_nodes = data.open_nodes;
1567
+ selected_node_id = data.selected_node;
1568
+ return this.tree_widget.tree.iterate(function(node) {
1569
+ if (node.id && node.hasChildren() && (indexOf(open_nodes, node.id) >= 0)) {
1570
+ node.is_open = true;
1571
+ }
1572
+ if (selected_node_id && (node.id === selected_node_id)) {
1573
+ _this.tree_widget.selected_node = node;
1574
+ }
1575
+ return true;
1576
+ });
1577
+ }
964
1578
  };
965
1579
 
966
- JqueryWidget.prototype._getCookieName = function() {
967
- if (typeof this.options.saveState === 'string') {
968
- return this.options.saveState;
1580
+ SaveStateHandler.prototype.getCookieName = function() {
1581
+ if (typeof this.tree_widget.options.saveState === 'string') {
1582
+ return this.tree_widget.options.saveState;
969
1583
  } else {
970
1584
  return 'tree';
971
1585
  }
972
1586
  };
973
1587
 
974
- JqueryWidget.prototype._getNodeElementForNode = function(node) {
975
- if (node.hasChildren()) {
976
- return new FolderElement(node);
977
- } else {
978
- return new NodeElement(node);
1588
+ return SaveStateHandler;
1589
+
1590
+ })();
1591
+
1592
+ SelectNodeHandler = (function() {
1593
+
1594
+ function SelectNodeHandler(tree_widget) {
1595
+ this.tree_widget = tree_widget;
1596
+ }
1597
+
1598
+ SelectNodeHandler.prototype.selectNode = function(node, must_open_parents) {
1599
+ var canSelect, parent,
1600
+ _this = this;
1601
+ canSelect = function() {
1602
+ if (!_this.tree_widget.options.selectable) {
1603
+ return false;
1604
+ }
1605
+ if (!_this.tree_widget.options.onCanSelectNode) {
1606
+ return true;
1607
+ }
1608
+ return _this.tree_widget.options.onCanSelectNode(node);
1609
+ };
1610
+ if (canSelect()) {
1611
+ if (this.tree_widget.selected_node) {
1612
+ this.tree_widget._getNodeElementForNode(this.tree_widget.selected_node).deselect();
1613
+ this.tree_widget.selected_node = null;
1614
+ }
1615
+ if (node) {
1616
+ this.tree_widget._getNodeElementForNode(node).select();
1617
+ this.tree_widget.selected_node = node;
1618
+ this.tree_widget._triggerEvent('tree.select', {
1619
+ node: node
1620
+ });
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
+ }
1629
+ }
1630
+ }
1631
+ if (this.tree_widget.options.saveState) {
1632
+ return this.tree_widget.save_state_handler.saveState();
1633
+ }
1634
+ }
1635
+ };
1636
+
1637
+ SelectNodeHandler.prototype.selectCurrentNode = function() {
1638
+ var node_element;
1639
+ if (this.tree_widget.selected_node) {
1640
+ node_element = this.tree_widget._getNodeElementForNode(this.tree_widget.selected_node);
1641
+ if (node_element) {
1642
+ return node_element.select();
1643
+ }
979
1644
  }
980
1645
  };
981
1646
 
982
- JqueryWidget.prototype._getNodeElement = function($element) {
983
- var node;
984
- node = this._getNode($element);
985
- if (node) {
986
- return this._getNodeElementForNode(node);
987
- } else {
988
- return null;
989
- }
990
- };
1647
+ return SelectNodeHandler;
991
1648
 
992
- JqueryWidget.prototype._contextmenu = function(e) {
993
- var $div, event, node;
994
- $div = $(e.target).closest('ul.tree div');
995
- if ($div.length) {
996
- node = this._getNode($div);
997
- if (node) {
998
- e.preventDefault();
999
- e.stopPropagation();
1000
- event = $.Event('tree.contextmenu');
1001
- event.node = node;
1002
- event.click_event = e;
1003
- this.element.trigger(event);
1004
- return false;
1005
- }
1006
- }
1007
- };
1649
+ })();
1008
1650
 
1009
- JqueryWidget.prototype._mouseCapture = function(event) {
1651
+ DragAndDropHandler = (function() {
1652
+
1653
+ function DragAndDropHandler(tree_widget) {
1654
+ this.tree_widget = tree_widget;
1655
+ this.hovered_area = null;
1656
+ this.$ghost = null;
1657
+ this.hit_areas = [];
1658
+ this.is_dragging = false;
1659
+ }
1660
+
1661
+ DragAndDropHandler.prototype.mouseCapture = function(event) {
1010
1662
  var $element, node_element;
1011
- if (!this.options.dragAndDrop) {
1012
- return;
1013
- }
1014
1663
  $element = $(event.target);
1015
- if (this.options.onIsMoveHandle && !this.options.onIsMoveHandle($element)) {
1664
+ if (this.tree_widget.options.onIsMoveHandle && !this.tree_widget.options.onIsMoveHandle($element)) {
1016
1665
  return null;
1017
1666
  }
1018
- node_element = this._getNodeElement($(event.target));
1019
- if (node_element && this.options.onCanMove) {
1020
- if (!this.options.onCanMove(node_element.node)) {
1667
+ node_element = this.tree_widget._getNodeElement($element);
1668
+ if (node_element && this.tree_widget.options.onCanMove) {
1669
+ if (!this.tree_widget.options.onCanMove(node_element.node)) {
1021
1670
  node_element = null;
1022
1671
  }
1023
1672
  }
@@ -1025,63 +1674,81 @@ limitations under the License.
1025
1674
  return this.current_item !== null;
1026
1675
  };
1027
1676
 
1028
- JqueryWidget.prototype._mouseStart = function(event) {
1677
+ DragAndDropHandler.prototype.mouseStart = function(event) {
1029
1678
  var offsetX, offsetY, _ref;
1030
- if (!this.options.dragAndDrop) {
1031
- return;
1032
- }
1033
- this._refreshHitAreas();
1034
- _ref = this._getOffsetFromEvent(event), offsetX = _ref[0], offsetY = _ref[1];
1035
- this.drag_element = new DragElement(this.current_item.node, offsetX, offsetY, this.element);
1036
- this.current_item.$element.addClass('moving');
1679
+ this.refreshHitAreas();
1680
+ _ref = this.getOffsetFromEvent(event), offsetX = _ref[0], offsetY = _ref[1];
1681
+ this.drag_element = new DragElement(this.current_item.node, offsetX, offsetY, this.tree_widget.element);
1682
+ this.is_dragging = true;
1683
+ this.current_item.$element.addClass('jqtree-moving');
1037
1684
  return true;
1038
1685
  };
1039
1686
 
1040
- JqueryWidget.prototype._mouseDrag = function(event) {
1687
+ DragAndDropHandler.prototype.mouseDrag = function(event) {
1041
1688
  var area, position_name;
1042
- if (!this.options.dragAndDrop) {
1043
- return;
1044
- }
1045
1689
  this.drag_element.move(event.pageX, event.pageY);
1046
- area = this._findHoveredArea(event.pageX, event.pageY);
1047
- if (area && this.options.onCanMoveTo) {
1690
+ area = this.findHoveredArea(event.pageX, event.pageY);
1691
+ if (area && this.tree_widget.options.onCanMoveTo) {
1048
1692
  position_name = Position.getName(area.position);
1049
- if (!this.options.onCanMoveTo(this.current_item.node, area.node, position_name)) {
1693
+ if (!this.tree_widget.options.onCanMoveTo(this.current_item.node, area.node, position_name)) {
1050
1694
  area = null;
1051
1695
  }
1052
1696
  }
1053
1697
  if (!area) {
1054
- this._removeDropHint();
1055
- this._removeHover();
1056
- this._stopOpenFolderTimer();
1698
+ this.removeDropHint();
1699
+ this.removeHover();
1700
+ this.stopOpenFolderTimer();
1057
1701
  } else {
1058
1702
  if (this.hovered_area !== area) {
1059
1703
  this.hovered_area = area;
1060
- this._updateDropHint();
1704
+ this.updateDropHint();
1061
1705
  }
1062
1706
  }
1063
1707
  return true;
1064
1708
  };
1065
1709
 
1066
- JqueryWidget.prototype._mouseStop = function() {
1067
- if (!this.options.dragAndDrop) {
1068
- return;
1069
- }
1070
- this._moveItem();
1071
- this._clear();
1072
- this._removeHover();
1073
- this._removeDropHint();
1074
- this._removeHitAreas();
1075
- this.current_item.$element.removeClass('moving');
1710
+ DragAndDropHandler.prototype.mouseStop = function() {
1711
+ this.moveItem();
1712
+ this.clear();
1713
+ this.removeHover();
1714
+ this.removeDropHint();
1715
+ this.removeHitAreas();
1716
+ this.current_item.$element.removeClass('jqtree-moving');
1717
+ this.is_dragging = false;
1076
1718
  return false;
1077
1719
  };
1078
1720
 
1079
- JqueryWidget.prototype._refreshHitAreas = function() {
1080
- this._removeHitAreas();
1081
- return this._generateHitAreas();
1721
+ DragAndDropHandler.prototype.getOffsetFromEvent = function(event) {
1722
+ var element_offset;
1723
+ element_offset = $(event.target).offset();
1724
+ return [event.pageX - element_offset.left, event.pageY - element_offset.top];
1725
+ };
1726
+
1727
+ DragAndDropHandler.prototype.refreshHitAreas = function() {
1728
+ this.removeHitAreas();
1729
+ return this.generateHitAreas();
1730
+ };
1731
+
1732
+ DragAndDropHandler.prototype.removeHitAreas = function() {
1733
+ return this.hit_areas = [];
1734
+ };
1735
+
1736
+ DragAndDropHandler.prototype.clear = function() {
1737
+ this.drag_element.remove();
1738
+ return this.drag_element = null;
1739
+ };
1740
+
1741
+ DragAndDropHandler.prototype.removeDropHint = function() {
1742
+ if (this.previous_ghost) {
1743
+ return this.previous_ghost.remove();
1744
+ }
1745
+ };
1746
+
1747
+ DragAndDropHandler.prototype.removeHover = function() {
1748
+ return this.hovered_area = null;
1082
1749
  };
1083
1750
 
1084
- JqueryWidget.prototype._generateHitAreas = function() {
1751
+ DragAndDropHandler.prototype.generateHitAreas = function() {
1085
1752
  var addPosition, getTop, groupPositions, handleAfterOpenFolder, handleClosedFolder, handleFirstNode, handleNode, handleOpenFolder, hit_areas, last_top, positions,
1086
1753
  _this = this;
1087
1754
  positions = [];
@@ -1112,7 +1779,7 @@ limitations under the License.
1112
1779
  }
1113
1780
  group.push(position);
1114
1781
  }
1115
- return handle_group(group, previous_top, _this.element.offset().top + _this.element.height());
1782
+ return handle_group(group, previous_top, _this.tree_widget.element.offset().top + _this.tree_widget.element.height());
1116
1783
  };
1117
1784
  handleNode = function(node, next_node, $element) {
1118
1785
  var top;
@@ -1161,13 +1828,12 @@ limitations under the License.
1161
1828
  return addPosition(node, Position.BEFORE, getTop($(node.element)));
1162
1829
  }
1163
1830
  };
1164
- this._iterateVisibleNodes(handleNode, handleOpenFolder, handleClosedFolder, handleAfterOpenFolder, handleFirstNode);
1831
+ this.iterateVisibleNodes(handleNode, handleOpenFolder, handleClosedFolder, handleAfterOpenFolder, handleFirstNode);
1165
1832
  hit_areas = [];
1166
1833
  groupPositions(function(positions_in_group, top, bottom) {
1167
- var area_height, area_top, position, _i, _len, _results;
1834
+ var area_height, area_top, position, _i, _len;
1168
1835
  area_height = (bottom - top) / positions_in_group.length;
1169
1836
  area_top = top;
1170
- _results = [];
1171
1837
  for (_i = 0, _len = positions_in_group.length; _i < _len; _i++) {
1172
1838
  position = positions_in_group[_i];
1173
1839
  hit_areas.push({
@@ -1176,18 +1842,14 @@ limitations under the License.
1176
1842
  node: position.node,
1177
1843
  position: position.position
1178
1844
  });
1179
- _results.push(area_top += area_height);
1845
+ area_top += area_height;
1180
1846
  }
1181
- return _results;
1847
+ return null;
1182
1848
  });
1183
1849
  return this.hit_areas = hit_areas;
1184
1850
  };
1185
1851
 
1186
- JqueryWidget.prototype._removeHitAreas = function() {
1187
- return this.hit_areas = [];
1188
- };
1189
-
1190
- JqueryWidget.prototype._iterateVisibleNodes = function(handle_node, handle_open_folder, handle_closed_folder, handle_after_open_folder, handle_first_node) {
1852
+ DragAndDropHandler.prototype.iterateVisibleNodes = function(handle_node, handle_open_folder, handle_closed_folder, handle_after_open_folder, handle_first_node) {
1191
1853
  var is_first_node, iterate,
1192
1854
  _this = this;
1193
1855
  is_first_node = true;
@@ -1229,19 +1891,13 @@ limitations under the License.
1229
1891
  }
1230
1892
  }
1231
1893
  };
1232
- return iterate(this.tree);
1233
- };
1234
-
1235
- JqueryWidget.prototype._getOffsetFromEvent = function(event) {
1236
- var element_offset;
1237
- element_offset = $(event.target).offset();
1238
- return [event.pageX - element_offset.left, event.pageY - element_offset.top];
1894
+ return iterate(this.tree_widget.tree);
1239
1895
  };
1240
1896
 
1241
- JqueryWidget.prototype._findHoveredArea = function(x, y) {
1897
+ DragAndDropHandler.prototype.findHoveredArea = function(x, y) {
1242
1898
  var area, high, low, mid, tree_offset;
1243
- tree_offset = this.element.offset();
1244
- if (x < tree_offset.left || y < tree_offset.top || x > (tree_offset.left + this.element.width()) || y > (tree_offset.top + this.element.height())) {
1899
+ tree_offset = this.tree_widget.element.offset();
1900
+ if (x < tree_offset.left || y < tree_offset.top || x > (tree_offset.left + this.tree_widget.element.width()) || y > (tree_offset.top + this.tree_widget.element.height())) {
1245
1901
  return null;
1246
1902
  }
1247
1903
  low = 0;
@@ -1260,292 +1916,75 @@ limitations under the License.
1260
1916
  return null;
1261
1917
  };
1262
1918
 
1263
- JqueryWidget.prototype._updateDropHint = function() {
1919
+ DragAndDropHandler.prototype.updateDropHint = function() {
1264
1920
  var node, node_element;
1265
- this._stopOpenFolderTimer();
1921
+ this.stopOpenFolderTimer();
1266
1922
  if (!this.hovered_area) {
1267
1923
  return;
1268
1924
  }
1269
1925
  node = this.hovered_area.node;
1270
- if (node.hasChildren() && !node.is_open && this.hovered_area.position === Position.INSIDE) {
1271
- this._startOpenFolderTimer(node);
1926
+ if (node.isFolder() && !node.is_open && this.hovered_area.position === Position.INSIDE) {
1927
+ this.startOpenFolderTimer(node);
1272
1928
  }
1273
- this._removeDropHint();
1274
- node_element = this._getNodeElementForNode(this.hovered_area.node);
1929
+ this.removeDropHint();
1930
+ node_element = this.tree_widget._getNodeElementForNode(this.hovered_area.node);
1275
1931
  return this.previous_ghost = node_element.addDropHint(this.hovered_area.position);
1276
1932
  };
1277
1933
 
1278
- JqueryWidget.prototype._startOpenFolderTimer = function(folder) {
1934
+ DragAndDropHandler.prototype.startOpenFolderTimer = function(folder) {
1279
1935
  var openFolder,
1280
1936
  _this = this;
1281
1937
  openFolder = function() {
1282
- return _this._getNodeElementForNode(folder).open(function() {
1283
- _this._refreshHitAreas();
1284
- return _this._updateDropHint();
1938
+ return _this.tree_widget._openNode(folder, false, function() {
1939
+ _this.refreshHitAreas();
1940
+ return _this.updateDropHint();
1285
1941
  });
1286
1942
  };
1287
1943
  return this.open_folder_timer = setTimeout(openFolder, 500);
1288
1944
  };
1289
1945
 
1290
- JqueryWidget.prototype._stopOpenFolderTimer = function() {
1946
+ DragAndDropHandler.prototype.stopOpenFolderTimer = function() {
1291
1947
  if (this.open_folder_timer) {
1292
1948
  clearTimeout(this.open_folder_timer);
1293
1949
  return this.open_folder_timer = null;
1294
1950
  }
1295
1951
  };
1296
1952
 
1297
- JqueryWidget.prototype._removeDropHint = function() {
1298
- if (this.previous_ghost) {
1299
- return this.previous_ghost.remove();
1300
- }
1301
- };
1302
-
1303
- JqueryWidget.prototype._removeHover = function() {
1304
- return this.hovered_area = null;
1305
- };
1306
-
1307
- JqueryWidget.prototype._moveItem = function() {
1308
- var event, moved_node, position, previous_parent, target_node;
1953
+ DragAndDropHandler.prototype.moveItem = function() {
1954
+ var doMove, event, moved_node, position, previous_parent, target_node,
1955
+ _this = this;
1309
1956
  if (this.hovered_area && this.hovered_area.position !== Position.NONE) {
1310
1957
  moved_node = this.current_item.node;
1311
1958
  target_node = this.hovered_area.node;
1312
1959
  position = this.hovered_area.position;
1313
1960
  previous_parent = moved_node.parent;
1314
- this.tree.moveNode(moved_node, target_node, position);
1315
1961
  if (position === Position.INSIDE) {
1316
1962
  this.hovered_area.node.is_open = true;
1317
1963
  }
1318
- event = $.Event('tree.move');
1319
- event.move_info = {
1320
- moved_node: moved_node,
1321
- target_node: target_node,
1322
- position: Position.getName(position),
1323
- previous_parent: previous_parent
1964
+ doMove = function() {
1965
+ _this.tree_widget.tree.moveNode(moved_node, target_node, position);
1966
+ _this.tree_widget.element.empty();
1967
+ return _this.tree_widget._refreshElements();
1324
1968
  };
1325
- this.element.trigger(event);
1326
- this.element.empty();
1327
- return this._createDomElements(this.tree);
1328
- }
1329
- };
1330
-
1331
- JqueryWidget.prototype._clear = function() {
1332
- this.drag_element.remove();
1333
- return this.drag_element = null;
1334
- };
1335
-
1336
- return JqueryWidget;
1337
-
1338
- })(MouseWidget);
1339
-
1340
- SimpleWidget.register(JqueryWidget, 'tree');
1341
-
1342
- GhostDropHint = (function() {
1343
-
1344
- GhostDropHint.name = 'GhostDropHint';
1345
-
1346
- function GhostDropHint(node, $element, position) {
1347
- this.$element = $element;
1348
- this.node = node;
1349
- this.$ghost = $('<li class="ghost"><span class="circle"></span><span class="line"></span></li>');
1350
- if (position === Position.AFTER) {
1351
- this.moveAfter();
1352
- } else if (position === Position.BEFORE) {
1353
- this.moveBefore();
1354
- } else if (position === Position.INSIDE) {
1355
- if (node.hasChildren() && node.is_open) {
1356
- this.moveInsideOpenFolder();
1357
- } else {
1358
- this.moveInside();
1359
- }
1360
- }
1361
- }
1362
-
1363
- GhostDropHint.prototype.remove = function() {
1364
- return this.$ghost.remove();
1365
- };
1366
-
1367
- GhostDropHint.prototype.moveAfter = function() {
1368
- return this.$element.after(this.$ghost);
1369
- };
1370
-
1371
- GhostDropHint.prototype.moveBefore = function() {
1372
- return this.$element.before(this.$ghost);
1373
- };
1374
-
1375
- GhostDropHint.prototype.moveInsideOpenFolder = function() {
1376
- return $(this.node.children[0].element).before(this.$ghost);
1377
- };
1378
-
1379
- GhostDropHint.prototype.moveInside = function() {
1380
- this.$element.after(this.$ghost);
1381
- return this.$ghost.addClass('inside');
1382
- };
1383
-
1384
- return GhostDropHint;
1385
-
1386
- })();
1387
-
1388
- BorderDropHint = (function() {
1389
-
1390
- BorderDropHint.name = 'BorderDropHint';
1391
-
1392
- function BorderDropHint($element) {
1393
- var $div, width;
1394
- $div = $element.children('div');
1395
- width = $element.width() - 4;
1396
- this.$hint = $('<span class="border"></span>');
1397
- $div.append(this.$hint);
1398
- this.$hint.css({
1399
- width: width,
1400
- height: $div.height() - 4
1401
- });
1402
- }
1403
-
1404
- BorderDropHint.prototype.remove = function() {
1405
- return this.$hint.remove();
1406
- };
1407
-
1408
- return BorderDropHint;
1409
-
1410
- })();
1411
-
1412
- NodeElement = (function() {
1413
-
1414
- NodeElement.name = 'NodeElement';
1415
-
1416
- function NodeElement(node) {
1417
- this.init(node);
1418
- }
1419
-
1420
- NodeElement.prototype.init = function(node) {
1421
- this.node = node;
1422
- return this.$element = $(node.element);
1423
- };
1424
-
1425
- NodeElement.prototype.getUl = function() {
1426
- return this.$element.children('ul:first');
1427
- };
1428
-
1429
- NodeElement.prototype.getSpan = function() {
1430
- return this.$element.children('div').find('span.title');
1431
- };
1432
-
1433
- NodeElement.prototype.getLi = function() {
1434
- return this.$element;
1435
- };
1436
-
1437
- NodeElement.prototype.addDropHint = function(position) {
1438
- if (position === Position.INSIDE) {
1439
- return new BorderDropHint(this.$element);
1440
- } else {
1441
- return new GhostDropHint(this.node, this.$element, position);
1442
- }
1443
- };
1444
-
1445
- NodeElement.prototype.select = function() {
1446
- return this.getLi().addClass('selected');
1447
- };
1448
-
1449
- NodeElement.prototype.deselect = function() {
1450
- return this.getLi().removeClass('selected');
1451
- };
1452
-
1453
- return NodeElement;
1454
-
1455
- })();
1456
-
1457
- FolderElement = (function(_super) {
1458
-
1459
- __extends(FolderElement, _super);
1460
-
1461
- FolderElement.name = 'FolderElement';
1462
-
1463
- function FolderElement() {
1464
- return FolderElement.__super__.constructor.apply(this, arguments);
1465
- }
1466
-
1467
- FolderElement.prototype.toggle = function(on_finished) {
1468
- if (this.node.is_open) {
1469
- return this.close(on_finished);
1470
- } else {
1471
- return this.open(on_finished);
1472
- }
1473
- };
1474
-
1475
- FolderElement.prototype.open = function(on_finished, skip_slide) {
1476
- var doOpen,
1477
- _this = this;
1478
- this.node.is_open = true;
1479
- this.getButton().removeClass('closed');
1480
- doOpen = function() {
1481
- _this.getLi().removeClass('closed');
1482
- if (on_finished) {
1483
- return on_finished();
1484
- }
1485
- };
1486
- if (skip_slide) {
1487
- this.getUl().show();
1488
- return doOpen();
1489
- } else {
1490
- return this.getUl().slideDown('fast', doOpen);
1491
- }
1492
- };
1493
-
1494
- FolderElement.prototype.close = function(on_finished) {
1495
- var _this = this;
1496
- this.node.is_open = false;
1497
- this.getButton().addClass('closed');
1498
- return this.getUl().slideUp('fast', function() {
1499
- _this.getLi().addClass('closed');
1500
- if (on_finished) {
1501
- return on_finished();
1969
+ event = this.tree_widget._triggerEvent('tree.move', {
1970
+ move_info: {
1971
+ moved_node: moved_node,
1972
+ target_node: target_node,
1973
+ position: Position.getName(position),
1974
+ previous_parent: previous_parent,
1975
+ do_move: doMove
1976
+ }
1977
+ });
1978
+ if (!event.isDefaultPrevented()) {
1979
+ return doMove();
1502
1980
  }
1503
- });
1504
- };
1505
-
1506
- FolderElement.prototype.getButton = function() {
1507
- return this.$element.children('div').find('a.toggler');
1508
- };
1509
-
1510
- FolderElement.prototype.addDropHint = function(position) {
1511
- if (!this.node.is_open && position === Position.INSIDE) {
1512
- return new BorderDropHint(this.$element);
1513
- } else {
1514
- return new GhostDropHint(this.node, this.$element, position);
1515
1981
  }
1516
1982
  };
1517
1983
 
1518
- return FolderElement;
1519
-
1520
- })(NodeElement);
1521
-
1522
- DragElement = (function() {
1523
-
1524
- DragElement.name = 'DragElement';
1525
-
1526
- function DragElement(node, offset_x, offset_y, $tree) {
1527
- this.offset_x = offset_x;
1528
- this.offset_y = offset_y;
1529
- this.$element = $("<span class=\"title tree-dragging\">" + node.name + "</span>");
1530
- this.$element.css("position", "absolute");
1531
- $tree.append(this.$element);
1532
- }
1533
-
1534
- DragElement.prototype.move = function(page_x, page_y) {
1535
- return this.$element.offset({
1536
- left: page_x - this.offset_x,
1537
- top: page_y - this.offset_y
1538
- });
1539
- };
1540
-
1541
- DragElement.prototype.remove = function() {
1542
- return this.$element.remove();
1543
- };
1544
-
1545
- return DragElement;
1984
+ return DragAndDropHandler;
1546
1985
 
1547
1986
  })();
1548
1987
 
1549
1988
  this.Tree.Node = Node;
1550
1989
 
1551
- }).call(this);
1990
+ }).call(this);