parlement 0.14 → 0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. data/CHANGES +41 -1
  2. data/MEMORY +66 -5
  3. data/README +10 -5
  4. data/Rakefile +15 -23
  5. data/app/controllers/account_controller.rb +48 -43
  6. data/app/controllers/{application.rb → application_controller.rb} +15 -12
  7. data/app/controllers/elt_controller.rb +77 -32
  8. data/app/controllers/subscriber_controller.rb +11 -10
  9. data/app/helpers/application_helper.rb +14 -1
  10. data/app/helpers/elt_helper.rb +9 -7
  11. data/app/models/elt.rb +25 -24
  12. data/app/models/mail.rb +44 -47
  13. data/app/models/person_notify.rb +2 -2
  14. data/app/models/user.rb +128 -2
  15. data/app/models/user_notify.rb +15 -15
  16. data/app/views/account/_login.rhtml +39 -39
  17. data/app/views/account/_show.rhtml +22 -30
  18. data/app/views/account/signup.rhtml +2 -2
  19. data/app/views/elt/_choice.rhtml +6 -6
  20. data/app/views/elt/_elt.rhtml +27 -32
  21. data/app/views/elt/choices.rhtml +16 -18
  22. data/app/views/elt/list/_byDate.rhtml +14 -14
  23. data/app/views/elt/list/_byVote.rhtml +15 -15
  24. data/app/views/elt/list/_children.rhtml +48 -40
  25. data/app/views/elt/list/_subscribers.rhtml +1 -1
  26. data/app/views/elt/new.rhtml +22 -21
  27. data/app/views/elt/rss.rxml +4 -11
  28. data/app/views/elt/show.rhtml +65 -61
  29. data/app/views/elt/vote_rss.rxml +4 -11
  30. data/app/views/layouts/top.rhtml +39 -50
  31. data/app/views/person/_listElts.rhtml +1 -1
  32. data/app/views/person/show.rhtml +1 -1
  33. data/{vendor/plugins/login_engine/app → app}/views/user_notify/change_password.rhtml +0 -0
  34. data/{vendor/plugins/login_engine/app → app}/views/user_notify/delete.rhtml +0 -0
  35. data/{vendor/plugins/login_engine/app → app}/views/user_notify/forgot_password.rhtml +0 -0
  36. data/{vendor/plugins/login_engine/app → app}/views/user_notify/pending_delete.rhtml +0 -0
  37. data/{vendor/plugins/login_engine/app → app}/views/user_notify/signup.rhtml +0 -0
  38. data/config/boot.rb +97 -32
  39. data/config/environment.rb +37 -35
  40. data/config/environments/development.rb +2 -3
  41. data/config/environments/production.rb +3 -0
  42. data/config/initializers/string_ruby_1.8.rb +10 -0
  43. data/config/routes.rb +17 -22
  44. data/db/schema.rb +102 -74
  45. data/lib/tasks/rspec.rake +167 -0
  46. data/public/404.html +25 -7
  47. data/public/500.html +26 -7
  48. data/public/dispatch.cgi +0 -0
  49. data/public/dispatch.fcgi +0 -0
  50. data/public/dispatch.rb +0 -0
  51. data/public/images/live_tree_branch_collapsed_icon.gif +0 -0
  52. data/public/images/live_tree_branch_expanded_icon.gif +0 -0
  53. data/public/images/live_tree_leaf_icon.gif +0 -0
  54. data/public/javascripts/application.js +258 -0
  55. data/public/javascripts/controls.js +544 -414
  56. data/public/javascripts/dragdrop.js +229 -198
  57. data/public/javascripts/effects.js +499 -459
  58. data/public/javascripts/prototype.js +2926 -1121
  59. data/public/javascripts/shadedborder.js +68 -50
  60. data/public/stylesheets/default.css +34 -34
  61. data/public/stylesheets/live_tree.css +0 -0
  62. data/public/stylesheets/scaffold.css +6 -6
  63. data/script/about +0 -0
  64. data/script/autospec +6 -0
  65. data/script/benchmarker +0 -0
  66. data/script/breakpointer +0 -0
  67. data/script/console +0 -0
  68. data/script/dbconsole +3 -0
  69. data/script/destroy +0 -0
  70. data/script/generate +0 -0
  71. data/script/plugin +0 -0
  72. data/script/profiler +0 -0
  73. data/script/runner +0 -0
  74. data/script/server +0 -0
  75. data/script/spec +10 -0
  76. data/script/spec_server +9 -0
  77. data/test/unit/attachment_test.rb +4 -4
  78. data/test/unit/choice_test.rb +1 -1
  79. data/test/unit/elt_test.rb +9 -9
  80. data/test/unit/mail_notify_test.rb +2 -2
  81. data/test/unit/mail_test.rb +18 -11
  82. data/test/unit/person_notify_test.rb +1 -1
  83. data/test/unit/person_test.rb +1 -1
  84. data/test/unit/subscriber_test.rb +1 -1
  85. data/test/unit/user_test.rb +81 -0
  86. data/test/unit/visit_test.rb +6 -6
  87. data/vendor/plugins/activerecord_foreign_key_extensions/init.rb +2 -0
  88. data/vendor/plugins/activerecord_foreign_key_extensions/lib/active_record_extensions.rb +182 -0
  89. data/vendor/plugins/activerecord_text_id_extensions/init.rb +2 -0
  90. data/vendor/plugins/activerecord_text_id_extensions/lib/active_record_extensions.rb +24 -0
  91. data/vendor/plugins/acts_as_nested_set/README +15 -0
  92. data/vendor/plugins/acts_as_nested_set/init.rb +1 -0
  93. data/vendor/plugins/acts_as_nested_set/lib/active_record/acts/nested_set.rb +210 -0
  94. data/vendor/plugins/acts_as_nested_set/test/nested_set_test.rb +269 -0
  95. data/vendor/plugins/acts_as_tree/README +26 -0
  96. data/vendor/plugins/acts_as_tree/Rakefile +22 -0
  97. data/vendor/plugins/acts_as_tree/init.rb +1 -0
  98. data/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
  99. data/vendor/plugins/{output_compression/CHANGELOG → acts_as_tree/test/abstract_unit.rb} +0 -0
  100. data/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
  101. data/vendor/plugins/acts_as_tree/test/database.yml +0 -0
  102. data/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
  103. data/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
  104. data/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
  105. data/vendor/plugins/classic_pagination/CHANGELOG +152 -0
  106. data/vendor/plugins/classic_pagination/README +18 -0
  107. data/vendor/plugins/{output_compression/rakefile → classic_pagination/Rakefile} +22 -22
  108. data/vendor/plugins/classic_pagination/init.rb +33 -0
  109. data/vendor/plugins/classic_pagination/install.rb +1 -0
  110. data/vendor/plugins/classic_pagination/lib/pagination.rb +405 -0
  111. data/vendor/plugins/classic_pagination/lib/pagination_helper.rb +135 -0
  112. data/vendor/plugins/classic_pagination/test/fixtures/companies.yml +24 -0
  113. data/vendor/plugins/classic_pagination/test/fixtures/company.rb +9 -0
  114. data/vendor/plugins/classic_pagination/test/fixtures/developer.rb +7 -0
  115. data/vendor/plugins/classic_pagination/test/fixtures/developers.yml +21 -0
  116. data/vendor/plugins/classic_pagination/test/fixtures/developers_projects.yml +13 -0
  117. data/vendor/plugins/classic_pagination/test/fixtures/project.rb +3 -0
  118. data/vendor/plugins/classic_pagination/test/fixtures/projects.yml +7 -0
  119. data/vendor/plugins/classic_pagination/test/fixtures/replies.yml +13 -0
  120. data/vendor/plugins/classic_pagination/test/fixtures/reply.rb +5 -0
  121. data/vendor/plugins/classic_pagination/test/fixtures/schema.sql +42 -0
  122. data/vendor/plugins/classic_pagination/test/fixtures/topic.rb +3 -0
  123. data/vendor/plugins/classic_pagination/test/fixtures/topics.yml +22 -0
  124. data/vendor/plugins/classic_pagination/test/helper.rb +117 -0
  125. data/vendor/plugins/classic_pagination/test/pagination_helper_test.rb +38 -0
  126. data/vendor/plugins/classic_pagination/test/pagination_test.rb +177 -0
  127. data/vendor/plugins/file_column/lib/file_column.rb +1 -1
  128. data/vendor/plugins/file_column/test/file_column_test.rb +0 -0
  129. metadata +151 -197
  130. data/app/helpers/live_tree.rb +0 -238
  131. data/app/views/elt/_form.rhtml +0 -31
  132. data/app/views/elt/show_tree.rhtml +0 -8
  133. data/config/environments/user_environment.rb +0 -1
  134. data/db/ROOT/Titemagli.txt +0 -3
  135. data/db/ROOT/titemagli.txt +0 -9
  136. data/public/javascripts/behaviour.js +0 -254
  137. data/public/javascripts/ie7-load.htc +0 -1
  138. data/public/javascripts/ie7.js +0 -6
  139. data/public/javascripts/live_tree.js +0 -749
  140. data/public/javascripts/mybehaviour.js +0 -225
  141. data/public/javascripts/scriptaculous.js +0 -47
  142. data/public/javascripts/slider.js +0 -283
  143. data/public/stylesheets/blue.css +0 -471
  144. data/vendor/plugins/engines/CHANGELOG +0 -241
  145. data/vendor/plugins/engines/MIT-LICENSE +0 -21
  146. data/vendor/plugins/engines/README +0 -64
  147. data/vendor/plugins/engines/Rakefile +0 -32
  148. data/vendor/plugins/engines/UPGRADING +0 -93
  149. data/vendor/plugins/engines/about.yml +0 -7
  150. data/vendor/plugins/engines/generators/plugin_migration/USAGE +0 -45
  151. data/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +0 -79
  152. data/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +0 -13
  153. data/vendor/plugins/engines/init.rb +0 -40
  154. data/vendor/plugins/engines/install.rb +0 -32
  155. data/vendor/plugins/engines/lib/engines.rb +0 -323
  156. data/vendor/plugins/engines/lib/engines/deprecated_config_support.rb +0 -135
  157. data/vendor/plugins/engines/lib/engines/plugin.rb +0 -214
  158. data/vendor/plugins/engines/lib/engines/plugin_list.rb +0 -31
  159. data/vendor/plugins/engines/lib/engines/plugin_migrator.rb +0 -60
  160. data/vendor/plugins/engines/lib/engines/rails_extensions.rb +0 -6
  161. data/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +0 -19
  162. data/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +0 -143
  163. data/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +0 -155
  164. data/vendor/plugins/engines/lib/engines/rails_extensions/public_asset_helpers.rb +0 -116
  165. data/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +0 -20
  166. data/vendor/plugins/engines/lib/engines/rails_extensions/rails_initializer.rb +0 -86
  167. data/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +0 -77
  168. data/vendor/plugins/engines/lib/engines/rails_extensions/templates.rb +0 -140
  169. data/vendor/plugins/engines/lib/engines/testing.rb +0 -87
  170. data/vendor/plugins/engines/tasks/engines.rake +0 -149
  171. data/vendor/plugins/login_engine/CHANGELOG +0 -22
  172. data/vendor/plugins/login_engine/README +0 -344
  173. data/vendor/plugins/login_engine/app/controllers/user_controller.rb +0 -262
  174. data/vendor/plugins/login_engine/app/helpers/user_helper.rb +0 -88
  175. data/vendor/plugins/login_engine/app/models/user.rb +0 -7
  176. data/vendor/plugins/login_engine/app/models/user_notify.rb +0 -75
  177. data/vendor/plugins/login_engine/app/views/user/_edit.rhtml +0 -11
  178. data/vendor/plugins/login_engine/app/views/user/_password.rhtml +0 -9
  179. data/vendor/plugins/login_engine/app/views/user/change_password.rhtml +0 -17
  180. data/vendor/plugins/login_engine/app/views/user/edit.rhtml +0 -23
  181. data/vendor/plugins/login_engine/app/views/user/forgot_password.rhtml +0 -18
  182. data/vendor/plugins/login_engine/app/views/user/home.rhtml +0 -7
  183. data/vendor/plugins/login_engine/app/views/user/login.rhtml +0 -17
  184. data/vendor/plugins/login_engine/app/views/user/logout.rhtml +0 -8
  185. data/vendor/plugins/login_engine/app/views/user/signup.rhtml +0 -17
  186. data/vendor/plugins/login_engine/db/migrate/001_initial_schema.rb +0 -25
  187. data/vendor/plugins/login_engine/init_engine.rb +0 -11
  188. data/vendor/plugins/login_engine/install.rb +0 -4
  189. data/vendor/plugins/login_engine/lib/login_engine.rb +0 -62
  190. data/vendor/plugins/login_engine/lib/login_engine/authenticated_system.rb +0 -113
  191. data/vendor/plugins/login_engine/lib/login_engine/authenticated_user.rb +0 -155
  192. data/vendor/plugins/login_engine/public/stylesheets/login_engine.css +0 -81
  193. data/vendor/plugins/login_engine/test/fixtures/users.yml +0 -41
  194. data/vendor/plugins/login_engine/test/functional/user_controller_test.rb +0 -536
  195. data/vendor/plugins/login_engine/test/mocks/mail.rb +0 -14
  196. data/vendor/plugins/login_engine/test/mocks/time.rb +0 -19
  197. data/vendor/plugins/login_engine/test/test_helper.rb +0 -11
  198. data/vendor/plugins/login_engine/test/unit/user_test.rb +0 -114
  199. data/vendor/plugins/output_compression/MIT-LICENSE +0 -20
  200. data/vendor/plugins/output_compression/README +0 -4
  201. data/vendor/plugins/output_compression/init.rb +0 -1
  202. data/vendor/plugins/output_compression/lib/output_compression.rb +0 -84
  203. data/vendor/plugins/output_compression/test/output_test.rb +0 -11
  204. data/vendor/plugins/output_compression/test/test_controller.rb +0 -3
  205. data/vendor/plugins/output_compression/test/test_helper.rb +0 -14
@@ -1,10 +1,10 @@
1
- // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2
- // (c) 2005, 2006 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
3
- //
1
+ // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2
+ // (c) 2005-2008 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
3
+ //
4
4
  // script.aculo.us is freely distributable under the terms of an MIT-style license.
5
5
  // For details, see the script.aculo.us web site: http://script.aculo.us/
6
6
 
7
- if(typeof Effect == 'undefined')
7
+ if(Object.isUndefined(Effect))
8
8
  throw("dragdrop.js requires including script.aculo.us' effects.js library");
9
9
 
10
10
  var Droppables = {
@@ -20,20 +20,19 @@ var Droppables = {
20
20
  greedy: true,
21
21
  hoverclass: null,
22
22
  tree: false
23
- }, arguments[1] || {});
23
+ }, arguments[1] || { });
24
24
 
25
25
  // cache containers
26
26
  if(options.containment) {
27
27
  options._containers = [];
28
28
  var containment = options.containment;
29
- if((typeof containment == 'object') &&
30
- (containment.constructor == Array)) {
29
+ if(Object.isArray(containment)) {
31
30
  containment.each( function(c) { options._containers.push($(c)) });
32
31
  } else {
33
32
  options._containers.push($(containment));
34
33
  }
35
34
  }
36
-
35
+
37
36
  if(options.accept) options.accept = [options.accept].flatten();
38
37
 
39
38
  Element.makePositioned(element); // fix IE
@@ -41,34 +40,34 @@ var Droppables = {
41
40
 
42
41
  this.drops.push(options);
43
42
  },
44
-
43
+
45
44
  findDeepestChild: function(drops) {
46
45
  deepest = drops[0];
47
-
46
+
48
47
  for (i = 1; i < drops.length; ++i)
49
48
  if (Element.isParent(drops[i].element, deepest.element))
50
49
  deepest = drops[i];
51
-
50
+
52
51
  return deepest;
53
52
  },
54
53
 
55
54
  isContained: function(element, drop) {
56
55
  var containmentNode;
57
56
  if(drop.tree) {
58
- containmentNode = element.treeNode;
57
+ containmentNode = element.treeNode;
59
58
  } else {
60
59
  containmentNode = element.parentNode;
61
60
  }
62
61
  return drop._containers.detect(function(c) { return containmentNode == c });
63
62
  },
64
-
63
+
65
64
  isAffected: function(point, element, drop) {
66
65
  return (
67
66
  (drop.element!=element) &&
68
67
  ((!drop._containers) ||
69
68
  this.isContained(element, drop)) &&
70
69
  ((!drop.accept) ||
71
- (Element.classNames(element).detect(
70
+ (Element.classNames(element).detect(
72
71
  function(v) { return drop.accept.include(v) } ) )) &&
73
72
  Position.within(drop.element, point[0], point[1]) );
74
73
  },
@@ -87,21 +86,23 @@ var Droppables = {
87
86
 
88
87
  show: function(point, element) {
89
88
  if(!this.drops.length) return;
90
- var affected = [];
91
-
92
- if(this.last_active) this.deactivate(this.last_active);
89
+ var drop, affected = [];
90
+
93
91
  this.drops.each( function(drop) {
94
92
  if(Droppables.isAffected(point, element, drop))
95
93
  affected.push(drop);
96
94
  });
97
-
98
- if(affected.length>0) {
95
+
96
+ if(affected.length>0)
99
97
  drop = Droppables.findDeepestChild(affected);
98
+
99
+ if(this.last_active && this.last_active != drop) this.deactivate(this.last_active);
100
+ if (drop) {
100
101
  Position.within(drop.element, point[0], point[1]);
101
102
  if(drop.onHover)
102
103
  drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
103
-
104
- Droppables.activate(drop);
104
+
105
+ if (drop != this.last_active) Droppables.activate(drop);
105
106
  }
106
107
  },
107
108
 
@@ -110,33 +111,35 @@ var Droppables = {
110
111
  Position.prepare();
111
112
 
112
113
  if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
113
- if (this.last_active.onDrop)
114
+ if (this.last_active.onDrop) {
114
115
  this.last_active.onDrop(element, this.last_active.element, event);
116
+ return true;
117
+ }
115
118
  },
116
119
 
117
120
  reset: function() {
118
121
  if(this.last_active)
119
122
  this.deactivate(this.last_active);
120
123
  }
121
- }
124
+ };
122
125
 
123
126
  var Draggables = {
124
127
  drags: [],
125
128
  observers: [],
126
-
129
+
127
130
  register: function(draggable) {
128
131
  if(this.drags.length == 0) {
129
132
  this.eventMouseUp = this.endDrag.bindAsEventListener(this);
130
133
  this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
131
134
  this.eventKeypress = this.keyPress.bindAsEventListener(this);
132
-
135
+
133
136
  Event.observe(document, "mouseup", this.eventMouseUp);
134
137
  Event.observe(document, "mousemove", this.eventMouseMove);
135
138
  Event.observe(document, "keypress", this.eventKeypress);
136
139
  }
137
140
  this.drags.push(draggable);
138
141
  },
139
-
142
+
140
143
  unregister: function(draggable) {
141
144
  this.drags = this.drags.reject(function(d) { return d==draggable });
142
145
  if(this.drags.length == 0) {
@@ -145,24 +148,24 @@ var Draggables = {
145
148
  Event.stopObserving(document, "keypress", this.eventKeypress);
146
149
  }
147
150
  },
148
-
151
+
149
152
  activate: function(draggable) {
150
- if(draggable.options.delay) {
151
- this._timeout = setTimeout(function() {
152
- Draggables._timeout = null;
153
- window.focus();
154
- Draggables.activeDraggable = draggable;
155
- }.bind(this), draggable.options.delay);
153
+ if(draggable.options.delay) {
154
+ this._timeout = setTimeout(function() {
155
+ Draggables._timeout = null;
156
+ window.focus();
157
+ Draggables.activeDraggable = draggable;
158
+ }.bind(this), draggable.options.delay);
156
159
  } else {
157
160
  window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
158
161
  this.activeDraggable = draggable;
159
162
  }
160
163
  },
161
-
164
+
162
165
  deactivate: function() {
163
166
  this.activeDraggable = null;
164
167
  },
165
-
168
+
166
169
  updateDrag: function(event) {
167
170
  if(!this.activeDraggable) return;
168
171
  var pointer = [Event.pointerX(event), Event.pointerY(event)];
@@ -170,36 +173,36 @@ var Draggables = {
170
173
  // the same coordinates, prevent needless redrawing (moz bug?)
171
174
  if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
172
175
  this._lastPointer = pointer;
173
-
176
+
174
177
  this.activeDraggable.updateDrag(event, pointer);
175
178
  },
176
-
179
+
177
180
  endDrag: function(event) {
178
- if(this._timeout) {
179
- clearTimeout(this._timeout);
180
- this._timeout = null;
181
+ if(this._timeout) {
182
+ clearTimeout(this._timeout);
183
+ this._timeout = null;
181
184
  }
182
185
  if(!this.activeDraggable) return;
183
186
  this._lastPointer = null;
184
187
  this.activeDraggable.endDrag(event);
185
188
  this.activeDraggable = null;
186
189
  },
187
-
190
+
188
191
  keyPress: function(event) {
189
192
  if(this.activeDraggable)
190
193
  this.activeDraggable.keyPress(event);
191
194
  },
192
-
195
+
193
196
  addObserver: function(observer) {
194
197
  this.observers.push(observer);
195
198
  this._cacheObserverCallbacks();
196
199
  },
197
-
200
+
198
201
  removeObserver: function(element) { // element instead of observer fixes mem leaks
199
202
  this.observers = this.observers.reject( function(o) { return o.element==element });
200
203
  this._cacheObserverCallbacks();
201
204
  },
202
-
205
+
203
206
  notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
204
207
  if(this[eventName+'Count'] > 0)
205
208
  this.observers.each( function(o) {
@@ -207,7 +210,7 @@ var Draggables = {
207
210
  });
208
211
  if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
209
212
  },
210
-
213
+
211
214
  _cacheObserverCallbacks: function() {
212
215
  ['onStart','onEnd','onDrag'].each( function(eventName) {
213
216
  Draggables[eventName+'Count'] = Draggables.observers.select(
@@ -215,14 +218,11 @@ var Draggables = {
215
218
  ).length;
216
219
  });
217
220
  }
218
- }
221
+ };
219
222
 
220
223
  /*--------------------------------------------------------------------------*/
221
224
 
222
- var Draggable = Class.create();
223
- Draggable._dragging = {};
224
-
225
- Draggable.prototype = {
225
+ var Draggable = Class.create({
226
226
  initialize: function(element) {
227
227
  var defaults = {
228
228
  handle: false,
@@ -233,106 +233,110 @@ Draggable.prototype = {
233
233
  });
234
234
  },
235
235
  endeffect: function(element) {
236
- var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0;
237
- new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
236
+ var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
237
+ new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
238
238
  queue: {scope:'_draggable', position:'end'},
239
- afterFinish: function(){
240
- Draggable._dragging[element] = false
239
+ afterFinish: function(){
240
+ Draggable._dragging[element] = false
241
241
  }
242
- });
242
+ });
243
243
  },
244
244
  zindex: 1000,
245
245
  revert: false,
246
+ quiet: false,
246
247
  scroll: false,
247
248
  scrollSensitivity: 20,
248
249
  scrollSpeed: 15,
249
250
  snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
250
251
  delay: 0
251
252
  };
252
-
253
- if(!arguments[1] || typeof arguments[1].endeffect == 'undefined')
253
+
254
+ if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
254
255
  Object.extend(defaults, {
255
256
  starteffect: function(element) {
256
257
  element._opacity = Element.getOpacity(element);
257
258
  Draggable._dragging[element] = true;
258
- new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
259
+ new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
259
260
  }
260
261
  });
261
-
262
- var options = Object.extend(defaults, arguments[1] || {});
262
+
263
+ var options = Object.extend(defaults, arguments[1] || { });
263
264
 
264
265
  this.element = $(element);
265
-
266
- if(options.handle && (typeof options.handle == 'string'))
266
+
267
+ if(options.handle && Object.isString(options.handle))
267
268
  this.handle = this.element.down('.'+options.handle, 0);
268
-
269
+
269
270
  if(!this.handle) this.handle = $(options.handle);
270
271
  if(!this.handle) this.handle = this.element;
271
-
272
+
272
273
  if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
273
274
  options.scroll = $(options.scroll);
274
275
  this._isScrollChild = Element.childOf(this.element, options.scroll);
275
276
  }
276
277
 
277
- Element.makePositioned(this.element); // fix IE
278
+ Element.makePositioned(this.element); // fix IE
278
279
 
279
- this.delta = this.currentDelta();
280
280
  this.options = options;
281
- this.dragging = false;
281
+ this.dragging = false;
282
282
 
283
283
  this.eventMouseDown = this.initDrag.bindAsEventListener(this);
284
284
  Event.observe(this.handle, "mousedown", this.eventMouseDown);
285
-
285
+
286
286
  Draggables.register(this);
287
287
  },
288
-
288
+
289
289
  destroy: function() {
290
290
  Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
291
291
  Draggables.unregister(this);
292
292
  },
293
-
293
+
294
294
  currentDelta: function() {
295
295
  return([
296
296
  parseInt(Element.getStyle(this.element,'left') || '0'),
297
297
  parseInt(Element.getStyle(this.element,'top') || '0')]);
298
298
  },
299
-
299
+
300
300
  initDrag: function(event) {
301
- if(typeof Draggable._dragging[this.element] != 'undefined' &&
301
+ if(!Object.isUndefined(Draggable._dragging[this.element]) &&
302
302
  Draggable._dragging[this.element]) return;
303
- if(Event.isLeftClick(event)) {
303
+ if(Event.isLeftClick(event)) {
304
304
  // abort on form elements, fixes a Firefox issue
305
305
  var src = Event.element(event);
306
- if(src.tagName && (
307
- src.tagName=='INPUT' ||
308
- src.tagName=='SELECT' ||
309
- src.tagName=='OPTION' ||
310
- src.tagName=='BUTTON' ||
311
- src.tagName=='TEXTAREA')) return;
312
-
306
+ if((tag_name = src.tagName.toUpperCase()) && (
307
+ tag_name=='INPUT' ||
308
+ tag_name=='SELECT' ||
309
+ tag_name=='OPTION' ||
310
+ tag_name=='BUTTON' ||
311
+ tag_name=='TEXTAREA')) return;
312
+
313
313
  var pointer = [Event.pointerX(event), Event.pointerY(event)];
314
314
  var pos = Position.cumulativeOffset(this.element);
315
315
  this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
316
-
316
+
317
317
  Draggables.activate(this);
318
318
  Event.stop(event);
319
319
  }
320
320
  },
321
-
321
+
322
322
  startDrag: function(event) {
323
323
  this.dragging = true;
324
-
324
+ if(!this.delta)
325
+ this.delta = this.currentDelta();
326
+
325
327
  if(this.options.zindex) {
326
328
  this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
327
329
  this.element.style.zIndex = this.options.zindex;
328
330
  }
329
-
331
+
330
332
  if(this.options.ghosting) {
331
333
  this._clone = this.element.cloneNode(true);
332
- Position.absolutize(this.element);
334
+ this._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
335
+ if (!this._originallyAbsolute)
336
+ Position.absolutize(this.element);
333
337
  this.element.parentNode.insertBefore(this._clone, this.element);
334
338
  }
335
-
339
+
336
340
  if(this.options.scroll) {
337
341
  if (this.options.scroll == window) {
338
342
  var where = this._getWindowScroll(this.options.scroll);
@@ -343,24 +347,28 @@ Draggable.prototype = {
343
347
  this.originalScrollTop = this.options.scroll.scrollTop;
344
348
  }
345
349
  }
346
-
350
+
347
351
  Draggables.notify('onStart', this, event);
348
-
352
+
349
353
  if(this.options.starteffect) this.options.starteffect(this.element);
350
354
  },
351
-
355
+
352
356
  updateDrag: function(event, pointer) {
353
357
  if(!this.dragging) this.startDrag(event);
354
- Position.prepare();
355
- Droppables.show(pointer, this.element);
358
+
359
+ if(!this.options.quiet){
360
+ Position.prepare();
361
+ Droppables.show(pointer, this.element);
362
+ }
363
+
356
364
  Draggables.notify('onDrag', this, event);
357
-
365
+
358
366
  this.draw(pointer);
359
367
  if(this.options.change) this.options.change(this);
360
-
368
+
361
369
  if(this.options.scroll) {
362
370
  this.stopScrolling();
363
-
371
+
364
372
  var p;
365
373
  if (this.options.scroll == window) {
366
374
  with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
@@ -378,32 +386,46 @@ Draggable.prototype = {
378
386
  if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
379
387
  this.startScrolling(speed);
380
388
  }
381
-
389
+
382
390
  // fix AppleWebKit rendering
383
- if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
384
-
391
+ if(Prototype.Browser.WebKit) window.scrollBy(0,0);
392
+
385
393
  Event.stop(event);
386
394
  },
387
-
395
+
388
396
  finishDrag: function(event, success) {
389
397
  this.dragging = false;
390
398
 
399
+ if(this.options.quiet){
400
+ Position.prepare();
401
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
402
+ Droppables.show(pointer, this.element);
403
+ }
404
+
391
405
  if(this.options.ghosting) {
392
- Position.relativize(this.element);
406
+ if (!this._originallyAbsolute)
407
+ Position.relativize(this.element);
408
+ delete this._originallyAbsolute;
393
409
  Element.remove(this._clone);
394
410
  this._clone = null;
395
411
  }
396
412
 
397
- if(success) Droppables.fire(event, this.element);
413
+ var dropped = false;
414
+ if(success) {
415
+ dropped = Droppables.fire(event, this.element);
416
+ if (!dropped) dropped = false;
417
+ }
418
+ if(dropped && this.options.onDropped) this.options.onDropped(this.element);
398
419
  Draggables.notify('onEnd', this, event);
399
420
 
400
421
  var revert = this.options.revert;
401
- if(revert && typeof revert == 'function') revert = revert(this.element);
402
-
422
+ if(revert && Object.isFunction(revert)) revert = revert(this.element);
423
+
403
424
  var d = this.currentDelta();
404
425
  if(revert && this.options.reverteffect) {
405
- this.options.reverteffect(this.element,
406
- d[1]-this.delta[1], d[0]-this.delta[0]);
426
+ if (dropped == 0 || revert != 'failure')
427
+ this.options.reverteffect(this.element,
428
+ d[1]-this.delta[1], d[0]-this.delta[0]);
407
429
  } else {
408
430
  this.delta = d;
409
431
  }
@@ -411,67 +433,67 @@ Draggable.prototype = {
411
433
  if(this.options.zindex)
412
434
  this.element.style.zIndex = this.originalZ;
413
435
 
414
- if(this.options.endeffect)
436
+ if(this.options.endeffect)
415
437
  this.options.endeffect(this.element);
416
-
438
+
417
439
  Draggables.deactivate(this);
418
440
  Droppables.reset();
419
441
  },
420
-
442
+
421
443
  keyPress: function(event) {
422
444
  if(event.keyCode!=Event.KEY_ESC) return;
423
445
  this.finishDrag(event, false);
424
446
  Event.stop(event);
425
447
  },
426
-
448
+
427
449
  endDrag: function(event) {
428
450
  if(!this.dragging) return;
429
451
  this.stopScrolling();
430
452
  this.finishDrag(event, true);
431
453
  Event.stop(event);
432
454
  },
433
-
455
+
434
456
  draw: function(point) {
435
457
  var pos = Position.cumulativeOffset(this.element);
436
458
  if(this.options.ghosting) {
437
459
  var r = Position.realOffset(this.element);
438
460
  pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
439
461
  }
440
-
462
+
441
463
  var d = this.currentDelta();
442
464
  pos[0] -= d[0]; pos[1] -= d[1];
443
-
465
+
444
466
  if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
445
467
  pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
446
468
  pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
447
469
  }
448
-
449
- var p = [0,1].map(function(i){
450
- return (point[i]-pos[i]-this.offset[i])
470
+
471
+ var p = [0,1].map(function(i){
472
+ return (point[i]-pos[i]-this.offset[i])
451
473
  }.bind(this));
452
-
474
+
453
475
  if(this.options.snap) {
454
- if(typeof this.options.snap == 'function') {
476
+ if(Object.isFunction(this.options.snap)) {
455
477
  p = this.options.snap(p[0],p[1],this);
456
478
  } else {
457
- if(this.options.snap instanceof Array) {
479
+ if(Object.isArray(this.options.snap)) {
458
480
  p = p.map( function(v, i) {
459
- return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this))
481
+ return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this));
460
482
  } else {
461
483
  p = p.map( function(v) {
462
- return Math.round(v/this.options.snap)*this.options.snap }.bind(this))
484
+ return (v/this.options.snap).round()*this.options.snap }.bind(this));
463
485
  }
464
486
  }}
465
-
487
+
466
488
  var style = this.element.style;
467
489
  if((!this.options.constraint) || (this.options.constraint=='horizontal'))
468
490
  style.left = p[0] + "px";
469
491
  if((!this.options.constraint) || (this.options.constraint=='vertical'))
470
492
  style.top = p[1] + "px";
471
-
493
+
472
494
  if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
473
495
  },
474
-
496
+
475
497
  stopScrolling: function() {
476
498
  if(this.scrollInterval) {
477
499
  clearInterval(this.scrollInterval);
@@ -479,14 +501,14 @@ Draggable.prototype = {
479
501
  Draggables._lastScrollPointer = null;
480
502
  }
481
503
  },
482
-
504
+
483
505
  startScrolling: function(speed) {
484
506
  if(!(speed[0] || speed[1])) return;
485
507
  this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
486
508
  this.lastScrolled = new Date();
487
509
  this.scrollInterval = setInterval(this.scroll.bind(this), 10);
488
510
  },
489
-
511
+
490
512
  scroll: function() {
491
513
  var current = new Date();
492
514
  var delta = current - this.lastScrolled;
@@ -502,7 +524,7 @@ Draggable.prototype = {
502
524
  this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
503
525
  this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
504
526
  }
505
-
527
+
506
528
  Position.prepare();
507
529
  Droppables.show(Draggables._lastPointer, this.element);
508
530
  Draggables.notify('onDrag', this);
@@ -516,10 +538,10 @@ Draggable.prototype = {
516
538
  Draggables._lastScrollPointer[1] = 0;
517
539
  this.draw(Draggables._lastScrollPointer);
518
540
  }
519
-
541
+
520
542
  if(this.options.change) this.options.change(this);
521
543
  },
522
-
544
+
523
545
  _getWindowScroll: function(w) {
524
546
  var T, L, W, H;
525
547
  with (w.document) {
@@ -538,41 +560,42 @@ Draggable.prototype = {
538
560
  H = documentElement.clientHeight;
539
561
  } else {
540
562
  W = body.offsetWidth;
541
- H = body.offsetHeight
563
+ H = body.offsetHeight;
542
564
  }
543
565
  }
544
566
  return { top: T, left: L, width: W, height: H };
545
567
  }
546
- }
568
+ });
569
+
570
+ Draggable._dragging = { };
547
571
 
548
572
  /*--------------------------------------------------------------------------*/
549
573
 
550
- var SortableObserver = Class.create();
551
- SortableObserver.prototype = {
574
+ var SortableObserver = Class.create({
552
575
  initialize: function(element, observer) {
553
576
  this.element = $(element);
554
577
  this.observer = observer;
555
578
  this.lastValue = Sortable.serialize(this.element);
556
579
  },
557
-
580
+
558
581
  onStart: function() {
559
582
  this.lastValue = Sortable.serialize(this.element);
560
583
  },
561
-
584
+
562
585
  onEnd: function() {
563
586
  Sortable.unmark();
564
587
  if(this.lastValue != Sortable.serialize(this.element))
565
588
  this.observer(this.element)
566
589
  }
567
- }
590
+ });
568
591
 
569
592
  var Sortable = {
570
593
  SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
571
-
572
- sortables: {},
573
-
594
+
595
+ sortables: { },
596
+
574
597
  _findRootElement: function(element) {
575
- while (element.tagName != "BODY") {
598
+ while (element.tagName.toUpperCase() != "BODY") {
576
599
  if(element.id && Sortable.sortables[element.id]) return element;
577
600
  element = element.parentNode;
578
601
  }
@@ -583,22 +606,23 @@ var Sortable = {
583
606
  if(!element) return;
584
607
  return Sortable.sortables[element.id];
585
608
  },
586
-
609
+
587
610
  destroy: function(element){
588
- var s = Sortable.options(element);
589
-
611
+ element = $(element);
612
+ var s = Sortable.sortables[element.id];
613
+
590
614
  if(s) {
591
615
  Draggables.removeObserver(s.element);
592
616
  s.droppables.each(function(d){ Droppables.remove(d) });
593
617
  s.draggables.invoke('destroy');
594
-
618
+
595
619
  delete Sortable.sortables[s.element.id];
596
620
  }
597
621
  },
598
622
 
599
623
  create: function(element) {
600
624
  element = $(element);
601
- var options = Object.extend({
625
+ var options = Object.extend({
602
626
  element: element,
603
627
  tag: 'li', // assumes li children, override with tag: 'tagname'
604
628
  dropOnEmpty: false,
@@ -612,13 +636,20 @@ var Sortable = {
612
636
  delay: 0,
613
637
  hoverclass: null,
614
638
  ghosting: false,
639
+ quiet: false,
615
640
  scroll: false,
616
641
  scrollSensitivity: 20,
617
642
  scrollSpeed: 15,
618
643
  format: this.SERIALIZE_RULE,
644
+
645
+ // these take arrays of elements or ids and can be
646
+ // used for better initialization performance
647
+ elements: false,
648
+ handles: false,
649
+
619
650
  onChange: Prototype.emptyFunction,
620
651
  onUpdate: Prototype.emptyFunction
621
- }, arguments[1] || {});
652
+ }, arguments[1] || { });
622
653
 
623
654
  // clear any old sortable with same element
624
655
  this.destroy(element);
@@ -626,6 +657,7 @@ var Sortable = {
626
657
  // build options for the draggables
627
658
  var options_for_draggable = {
628
659
  revert: true,
660
+ quiet: options.quiet,
629
661
  scroll: options.scroll,
630
662
  scrollSpeed: options.scrollSpeed,
631
663
  scrollSensitivity: options.scrollSensitivity,
@@ -651,24 +683,24 @@ var Sortable = {
651
683
  if(options.zindex)
652
684
  options_for_draggable.zindex = options.zindex;
653
685
 
654
- // build options for the droppables
686
+ // build options for the droppables
655
687
  var options_for_droppable = {
656
688
  overlap: options.overlap,
657
689
  containment: options.containment,
658
690
  tree: options.tree,
659
691
  hoverclass: options.hoverclass,
660
692
  onHover: Sortable.onHover
661
- }
662
-
693
+ };
694
+
663
695
  var options_for_tree = {
664
696
  onHover: Sortable.onEmptyHover,
665
697
  overlap: options.overlap,
666
698
  containment: options.containment,
667
699
  hoverclass: options.hoverclass
668
- }
700
+ };
669
701
 
670
702
  // fix for gecko engine
671
- Element.cleanWhitespace(element);
703
+ Element.cleanWhitespace(element);
672
704
 
673
705
  options.draggables = [];
674
706
  options.droppables = [];
@@ -679,17 +711,16 @@ var Sortable = {
679
711
  options.droppables.push(element);
680
712
  }
681
713
 
682
- (this.findElements(element, options) || []).each( function(e) {
683
- // handles are per-draggable
684
- var handle = options.handle ?
685
- $(e).down('.'+options.handle,0) : e;
714
+ (options.elements || this.findElements(element, options) || []).each( function(e,i) {
715
+ var handle = options.handles ? $(options.handles[i]) :
716
+ (options.handle ? $(e).select('.' + options.handle)[0] : e);
686
717
  options.draggables.push(
687
718
  new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
688
719
  Droppables.add(e, options_for_droppable);
689
720
  if(options.tree) e.treeNode = element;
690
- options.droppables.push(e);
721
+ options.droppables.push(e);
691
722
  });
692
-
723
+
693
724
  if(options.tree) {
694
725
  (Sortable.findTreeElements(element, options) || []).each( function(e) {
695
726
  Droppables.add(e, options_for_tree);
@@ -711,7 +742,7 @@ var Sortable = {
711
742
  return Element.findChildren(
712
743
  element, options.only, options.tree ? true : false, options.tag);
713
744
  },
714
-
745
+
715
746
  findTreeElements: function(element, options) {
716
747
  return Element.findChildren(
717
748
  element, options.only, options.tree ? true : false, options.treeTag);
@@ -728,7 +759,7 @@ var Sortable = {
728
759
  var oldParentNode = element.parentNode;
729
760
  element.style.visibility = "hidden"; // fix gecko rendering
730
761
  dropon.parentNode.insertBefore(element, dropon);
731
- if(dropon.parentNode!=oldParentNode)
762
+ if(dropon.parentNode!=oldParentNode)
732
763
  Sortable.options(oldParentNode).onChange(element);
733
764
  Sortable.options(dropon.parentNode).onChange(element);
734
765
  }
@@ -739,26 +770,26 @@ var Sortable = {
739
770
  var oldParentNode = element.parentNode;
740
771
  element.style.visibility = "hidden"; // fix gecko rendering
741
772
  dropon.parentNode.insertBefore(element, nextElement);
742
- if(dropon.parentNode!=oldParentNode)
773
+ if(dropon.parentNode!=oldParentNode)
743
774
  Sortable.options(oldParentNode).onChange(element);
744
775
  Sortable.options(dropon.parentNode).onChange(element);
745
776
  }
746
777
  }
747
778
  },
748
-
779
+
749
780
  onEmptyHover: function(element, dropon, overlap) {
750
781
  var oldParentNode = element.parentNode;
751
782
  var droponOptions = Sortable.options(dropon);
752
-
783
+
753
784
  if(!Element.isParent(dropon, element)) {
754
785
  var index;
755
-
786
+
756
787
  var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
757
788
  var child = null;
758
-
789
+
759
790
  if(children) {
760
791
  var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
761
-
792
+
762
793
  for (index = 0; index < children.length; index += 1) {
763
794
  if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) {
764
795
  offset -= Element.offsetSize (children[index], droponOptions.overlap);
@@ -771,9 +802,9 @@ var Sortable = {
771
802
  }
772
803
  }
773
804
  }
774
-
805
+
775
806
  dropon.insertBefore(element, child);
776
-
807
+
777
808
  Sortable.options(oldParentNode).onChange(element);
778
809
  droponOptions.onChange(element);
779
810
  }
@@ -786,34 +817,34 @@ var Sortable = {
786
817
  mark: function(dropon, position) {
787
818
  // mark on ghosting only
788
819
  var sortable = Sortable.options(dropon.parentNode);
789
- if(sortable && !sortable.ghosting) return;
820
+ if(sortable && !sortable.ghosting) return;
790
821
 
791
822
  if(!Sortable._marker) {
792
- Sortable._marker =
823
+ Sortable._marker =
793
824
  ($('dropmarker') || Element.extend(document.createElement('DIV'))).
794
825
  hide().addClassName('dropmarker').setStyle({position:'absolute'});
795
826
  document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
796
- }
827
+ }
797
828
  var offsets = Position.cumulativeOffset(dropon);
798
829
  Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
799
-
830
+
800
831
  if(position=='after')
801
- if(sortable.overlap == 'horizontal')
832
+ if(sortable.overlap == 'horizontal')
802
833
  Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'});
803
834
  else
804
835
  Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'});
805
-
836
+
806
837
  Sortable._marker.show();
807
838
  },
808
-
839
+
809
840
  _tree: function(element, options, parent) {
810
841
  var children = Sortable.findElements(element, options) || [];
811
-
842
+
812
843
  for (var i = 0; i < children.length; ++i) {
813
844
  var match = children[i].id.match(options.format);
814
845
 
815
846
  if (!match) continue;
816
-
847
+
817
848
  var child = {
818
849
  id: encodeURIComponent(match ? match[1] : null),
819
850
  element: element,
@@ -821,16 +852,16 @@ var Sortable = {
821
852
  children: [],
822
853
  position: parent.children.length,
823
854
  container: $(children[i]).down(options.treeTag)
824
- }
825
-
855
+ };
856
+
826
857
  /* Get the element containing the children and recurse over it */
827
858
  if (child.container)
828
- this._tree(child.container, options, child)
829
-
859
+ this._tree(child.container, options, child);
860
+
830
861
  parent.children.push (child);
831
862
  }
832
863
 
833
- return parent;
864
+ return parent;
834
865
  },
835
866
 
836
867
  tree: function(element) {
@@ -842,16 +873,16 @@ var Sortable = {
842
873
  only: sortableOptions.only,
843
874
  name: element.id,
844
875
  format: sortableOptions.format
845
- }, arguments[1] || {});
846
-
876
+ }, arguments[1] || { });
877
+
847
878
  var root = {
848
879
  id: null,
849
880
  parent: null,
850
881
  children: [],
851
882
  container: element,
852
883
  position: 0
853
- }
854
-
884
+ };
885
+
855
886
  return Sortable._tree(element, options, root);
856
887
  },
857
888
 
@@ -866,8 +897,8 @@ var Sortable = {
866
897
 
867
898
  sequence: function(element) {
868
899
  element = $(element);
869
- var options = Object.extend(this.options(element), arguments[1] || {});
870
-
900
+ var options = Object.extend(this.options(element), arguments[1] || { });
901
+
871
902
  return $(this.findElements(element, options) || []).map( function(item) {
872
903
  return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
873
904
  });
@@ -875,15 +906,15 @@ var Sortable = {
875
906
 
876
907
  setSequence: function(element, new_sequence) {
877
908
  element = $(element);
878
- var options = Object.extend(this.options(element), arguments[2] || {});
879
-
880
- var nodeMap = {};
909
+ var options = Object.extend(this.options(element), arguments[2] || { });
910
+
911
+ var nodeMap = { };
881
912
  this.findElements(element, options).each( function(n) {
882
913
  if (n.id.match(options.format))
883
914
  nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
884
915
  n.parentNode.removeChild(n);
885
916
  });
886
-
917
+
887
918
  new_sequence.each(function(ident) {
888
919
  var n = nodeMap[ident];
889
920
  if (n) {
@@ -892,16 +923,16 @@ var Sortable = {
892
923
  }
893
924
  });
894
925
  },
895
-
926
+
896
927
  serialize: function(element) {
897
928
  element = $(element);
898
- var options = Object.extend(Sortable.options(element), arguments[1] || {});
929
+ var options = Object.extend(Sortable.options(element), arguments[1] || { });
899
930
  var name = encodeURIComponent(
900
931
  (arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
901
-
932
+
902
933
  if (options.tree) {
903
934
  return Sortable.tree(element, arguments[1]).children.map( function (item) {
904
- return [name + Sortable._constructIndex(item) + "[id]=" +
935
+ return [name + Sortable._constructIndex(item) + "[id]=" +
905
936
  encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
906
937
  }).flatten().join('&');
907
938
  } else {
@@ -910,16 +941,16 @@ var Sortable = {
910
941
  }).join('&');
911
942
  }
912
943
  }
913
- }
944
+ };
914
945
 
915
946
  // Returns true if child is contained within element
916
947
  Element.isParent = function(child, element) {
917
948
  if (!child.parentNode || child == element) return false;
918
949
  if (child.parentNode == element) return true;
919
950
  return Element.isParent(child.parentNode, element);
920
- }
951
+ };
921
952
 
922
- Element.findChildren = function(element, only, recursive, tagName) {
953
+ Element.findChildren = function(element, only, recursive, tagName) {
923
954
  if(!element.hasChildNodes()) return null;
924
955
  tagName = tagName.toUpperCase();
925
956
  if(only) only = [only].flatten();
@@ -935,8 +966,8 @@ Element.findChildren = function(element, only, recursive, tagName) {
935
966
  });
936
967
 
937
968
  return (elements.length>0 ? elements.flatten() : []);
938
- }
969
+ };
939
970
 
940
971
  Element.offsetSize = function (element, type) {
941
972
  return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
942
- }
973
+ };