bivouac 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/README +15 -0
  2. data/bin/bivouac +5 -10
  3. data/doc/rdoc/classes/BivouacHelpers/HtmlView.html +46 -37
  4. data/doc/rdoc/classes/BivouacHelpers/ScriptAculoUsView.html +27 -20
  5. data/doc/rdoc/created.rid +1 -1
  6. data/doc/rdoc/files/README.html +45 -1
  7. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/html_rb.html +1 -1
  8. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/javascript_rb.html +1 -1
  9. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/scriptaculous_rb.html +1 -1
  10. data/examples/bivouac_sample/Rakefile +0 -0
  11. data/examples/bivouac_sample/app/controllers/toggle_sortable.rb +2 -1
  12. data/examples/bivouac_sample/app/views/_sortable_result.rb +1 -1
  13. data/examples/bivouac_sample/script/console +0 -0
  14. data/examples/bivouac_sample/script/generate +0 -0
  15. data/examples/bivouac_sample/script/plugin +0 -0
  16. data/examples/bivouac_sample/script/server +0 -0
  17. data/examples/blog/Rakefile +56 -0
  18. data/examples/blog/app/blog.rb +107 -0
  19. data/examples/blog/app/controllers/comment.rb +17 -0
  20. data/examples/blog/app/controllers/index.rb +15 -0
  21. data/examples/blog/app/controllers/login.rb +33 -0
  22. data/examples/blog/app/controllers/logout.rb +15 -0
  23. data/examples/blog/app/controllers/not_found.rb +14 -0
  24. data/examples/blog/app/controllers/post.rb +48 -0
  25. data/examples/blog/app/helpers/_helpers.rb +30 -0
  26. data/examples/blog/app/helpers/blog.rb +14 -0
  27. data/examples/blog/app/models/comment.rb +18 -0
  28. data/examples/blog/app/models/post.rb +19 -0
  29. data/examples/blog/app/models/user.rb +12 -0
  30. data/examples/blog/app/views/_partials.rb +81 -0
  31. data/examples/blog/app/views/index/index.rb +23 -0
  32. data/examples/blog/app/views/layouts/default_layout.rb +40 -0
  33. data/examples/blog/app/views/login/login.rb +27 -0
  34. data/examples/blog/app/views/not_found.rb +13 -0
  35. data/examples/blog/app/views/post/add.rb +12 -0
  36. data/examples/blog/app/views/post/edit.rb +12 -0
  37. data/examples/blog/app/views/post/view.rb +14 -0
  38. data/examples/blog/config/console.rc +12 -0
  39. data/examples/blog/config/database.yml +3 -0
  40. data/examples/blog/config/environment.rb +58 -0
  41. data/examples/blog/db/blog.db +0 -0
  42. data/examples/blog/db/create.rb +11 -0
  43. data/examples/blog/db/migrate/001_users.rb +22 -0
  44. data/examples/blog/db/migrate/002_posts.rb +24 -0
  45. data/examples/blog/db/migrate/003_comments.rb +24 -0
  46. data/examples/blog/log/Blog.log +382 -0
  47. data/examples/{blog_goh → blog}/public/images/camping.png +0 -0
  48. data/examples/{blog_goh → blog}/public/index.html +3 -2
  49. data/examples/blog/public/javascripts/builder.js +136 -0
  50. data/examples/blog/public/javascripts/controls.js +965 -0
  51. data/examples/blog/public/javascripts/dragdrop.js +974 -0
  52. data/examples/blog/public/javascripts/effects.js +1122 -0
  53. data/examples/blog/public/javascripts/prototype.js +4320 -0
  54. data/examples/blog/public/javascripts/scriptaculous.js +58 -0
  55. data/examples/blog/public/javascripts/slider.js +275 -0
  56. data/examples/blog/public/javascripts/sound.js +55 -0
  57. data/examples/blog/public/javascripts/unittest.js +568 -0
  58. data/examples/blog/public/stylesheets/autocomplete.css +22 -0
  59. data/examples/blog/public/stylesheets/blog.css +107 -0
  60. data/examples/blog/script/console +12 -0
  61. data/examples/blog/script/generate +17 -0
  62. data/examples/blog/script/plugin +16 -0
  63. data/examples/blog/script/server +135 -0
  64. data/examples/blog/test/test_comment.rb +22 -0
  65. data/examples/blog/test/test_index.rb +22 -0
  66. data/examples/blog/test/test_login.rb +22 -0
  67. data/examples/blog/test/test_logout.rb +18 -0
  68. data/examples/blog/test/test_post.rb +30 -0
  69. data/examples/blog/test/test_post_new.rb +22 -0
  70. data/lib/bivouac.rb +2 -2
  71. data/lib/bivouac/commands/generate.rb +48 -8
  72. data/lib/bivouac/commands/plugin.rb +30 -15
  73. data/lib/bivouac/ext/filtering_camping.rb +46 -0
  74. data/lib/bivouac/helpers/view/goh/html.rb +9 -0
  75. data/lib/bivouac/helpers/view/goh/scriptaculous.rb +12 -8
  76. data/lib/bivouac/tasks/bivouac.rb +1 -0
  77. data/lib/bivouac/tasks/framework.rake +8 -8
  78. data/lib/bivouac/tasks/plugins.rake +17 -1
  79. data/lib/bivouac/template.rb +0 -0
  80. data/lib/bivouac/template/{application_goh.rb → application.rb} +36 -12
  81. data/lib/bivouac/template/application/{helpers_goh.rb → helpers.rb} +1 -1
  82. data/lib/bivouac/template/console.rb +2 -4
  83. data/lib/bivouac/template/environment.rb +1 -1
  84. data/lib/bivouac/template/generate.rb +0 -0
  85. data/lib/bivouac/template/generate/create.rb +0 -0
  86. data/lib/bivouac/template/generate/helper.rb +12 -0
  87. data/lib/bivouac/template/generate/migrate.rb +0 -0
  88. data/lib/bivouac/template/generate/migrate_end.rb +1 -0
  89. data/lib/bivouac/template/plugin.rb +6 -1
  90. data/lib/bivouac/template/server.rb +124 -3
  91. data/lib/bivouac/template/static/builder.js +19 -19
  92. data/lib/bivouac/template/static/controls.js +74 -74
  93. data/lib/bivouac/template/static/dragdrop.js +167 -166
  94. data/lib/bivouac/template/static/effects.js +171 -163
  95. data/lib/bivouac/template/static/not_found_controller.rb +8 -4
  96. data/lib/bivouac/template/static/prototype.js +218 -119
  97. data/lib/bivouac/template/static/scriptaculous.js +22 -20
  98. data/lib/bivouac/template/static/slider.js +39 -39
  99. data/lib/bivouac/template/static/sound.js +11 -11
  100. data/lib/bivouac/template/static/unittest.js +16 -16
  101. metadata +96 -60
  102. data/examples/blog_goh/app/blog.rb +0 -72
  103. data/examples/blog_goh/app/controllers/add.rb +0 -19
  104. data/examples/blog_goh/app/controllers/comment.rb +0 -9
  105. data/examples/blog_goh/app/controllers/edit.rb +0 -18
  106. data/examples/blog_goh/app/controllers/index.rb +0 -8
  107. data/examples/blog_goh/app/controllers/info.rb +0 -11
  108. data/examples/blog_goh/app/controllers/login.rb +0 -15
  109. data/examples/blog_goh/app/controllers/logout.rb +0 -8
  110. data/examples/blog_goh/app/controllers/view.rb +0 -9
  111. data/examples/blog_goh/app/models/comment.rb +0 -5
  112. data/examples/blog_goh/app/models/post.rb +0 -5
  113. data/examples/blog_goh/app/models/user.rb +0 -4
  114. data/examples/blog_goh/app/views/_form.rb +0 -16
  115. data/examples/blog_goh/app/views/_login.rb +0 -13
  116. data/examples/blog_goh/app/views/_post.rb +0 -9
  117. data/examples/blog_goh/app/views/add.rb +0 -9
  118. data/examples/blog_goh/app/views/edit.rb +0 -9
  119. data/examples/blog_goh/app/views/index.rb +0 -12
  120. data/examples/blog_goh/app/views/layout.rb +0 -18
  121. data/examples/blog_goh/app/views/login.rb +0 -6
  122. data/examples/blog_goh/app/views/logout.rb +0 -6
  123. data/examples/blog_goh/app/views/view.rb +0 -20
  124. data/examples/blog_goh/config/environment.rb +0 -27
  125. data/examples/blog_goh/db/Blog.db +0 -0
  126. data/examples/blog_goh/db/create.rb +0 -8
  127. data/examples/blog_goh/db/migrate/comment.rb +0 -15
  128. data/examples/blog_goh/db/migrate/post.rb +0 -15
  129. data/examples/blog_goh/db/migrate/user.rb +0 -15
  130. data/examples/blog_goh/log/Blog.log +0 -75
  131. data/examples/blog_goh/public/stylesheets/style.css +0 -10
  132. data/examples/blog_goh/script/generate +0 -3
  133. data/examples/blog_goh/script/server +0 -5
  134. data/lib/bivouac/template/application/postamble.rb +0 -195
  135. data/lib/camping/cookies_sessions.rb +0 -39
@@ -1,8 +1,8 @@
1
- // script.aculo.us dragdrop.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
1
+ // script.aculo.us dragdrop.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
2
2
 
3
- // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4
- // (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
5
- //
3
+ // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4
+ // (c) 2005-2008 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
5
+ //
6
6
  // script.aculo.us is freely distributable under the terms of an MIT-style license.
7
7
  // For details, see the script.aculo.us web site: http://script.aculo.us/
8
8
 
@@ -34,7 +34,7 @@ var Droppables = {
34
34
  options._containers.push($(containment));
35
35
  }
36
36
  }
37
-
37
+
38
38
  if(options.accept) options.accept = [options.accept].flatten();
39
39
 
40
40
  Element.makePositioned(element); // fix IE
@@ -42,34 +42,34 @@ var Droppables = {
42
42
 
43
43
  this.drops.push(options);
44
44
  },
45
-
45
+
46
46
  findDeepestChild: function(drops) {
47
47
  deepest = drops[0];
48
-
48
+
49
49
  for (i = 1; i < drops.length; ++i)
50
50
  if (Element.isParent(drops[i].element, deepest.element))
51
51
  deepest = drops[i];
52
-
52
+
53
53
  return deepest;
54
54
  },
55
55
 
56
56
  isContained: function(element, drop) {
57
57
  var containmentNode;
58
58
  if(drop.tree) {
59
- containmentNode = element.treeNode;
59
+ containmentNode = element.treeNode;
60
60
  } else {
61
61
  containmentNode = element.parentNode;
62
62
  }
63
63
  return drop._containers.detect(function(c) { return containmentNode == c });
64
64
  },
65
-
65
+
66
66
  isAffected: function(point, element, drop) {
67
67
  return (
68
68
  (drop.element!=element) &&
69
69
  ((!drop._containers) ||
70
70
  this.isContained(element, drop)) &&
71
71
  ((!drop.accept) ||
72
- (Element.classNames(element).detect(
72
+ (Element.classNames(element).detect(
73
73
  function(v) { return drop.accept.include(v) } ) )) &&
74
74
  Position.within(drop.element, point[0], point[1]) );
75
75
  },
@@ -89,12 +89,12 @@ var Droppables = {
89
89
  show: function(point, element) {
90
90
  if(!this.drops.length) return;
91
91
  var drop, affected = [];
92
-
92
+
93
93
  this.drops.each( function(drop) {
94
94
  if(Droppables.isAffected(point, element, drop))
95
95
  affected.push(drop);
96
96
  });
97
-
97
+
98
98
  if(affected.length>0)
99
99
  drop = Droppables.findDeepestChild(affected);
100
100
 
@@ -103,7 +103,7 @@ var Droppables = {
103
103
  Position.within(drop.element, point[0], point[1]);
104
104
  if(drop.onHover)
105
105
  drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
106
-
106
+
107
107
  if (drop != this.last_active) Droppables.activate(drop);
108
108
  }
109
109
  },
@@ -114,8 +114,8 @@ var Droppables = {
114
114
 
115
115
  if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
116
116
  if (this.last_active.onDrop) {
117
- this.last_active.onDrop(element, this.last_active.element, event);
118
- return true;
117
+ this.last_active.onDrop(element, this.last_active.element, event);
118
+ return true;
119
119
  }
120
120
  },
121
121
 
@@ -123,25 +123,25 @@ var Droppables = {
123
123
  if(this.last_active)
124
124
  this.deactivate(this.last_active);
125
125
  }
126
- }
126
+ };
127
127
 
128
128
  var Draggables = {
129
129
  drags: [],
130
130
  observers: [],
131
-
131
+
132
132
  register: function(draggable) {
133
133
  if(this.drags.length == 0) {
134
134
  this.eventMouseUp = this.endDrag.bindAsEventListener(this);
135
135
  this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
136
136
  this.eventKeypress = this.keyPress.bindAsEventListener(this);
137
-
137
+
138
138
  Event.observe(document, "mouseup", this.eventMouseUp);
139
139
  Event.observe(document, "mousemove", this.eventMouseMove);
140
140
  Event.observe(document, "keypress", this.eventKeypress);
141
141
  }
142
142
  this.drags.push(draggable);
143
143
  },
144
-
144
+
145
145
  unregister: function(draggable) {
146
146
  this.drags = this.drags.reject(function(d) { return d==draggable });
147
147
  if(this.drags.length == 0) {
@@ -150,24 +150,24 @@ var Draggables = {
150
150
  Event.stopObserving(document, "keypress", this.eventKeypress);
151
151
  }
152
152
  },
153
-
153
+
154
154
  activate: function(draggable) {
155
- if(draggable.options.delay) {
156
- this._timeout = setTimeout(function() {
157
- Draggables._timeout = null;
158
- window.focus();
159
- Draggables.activeDraggable = draggable;
160
- }.bind(this), draggable.options.delay);
155
+ if(draggable.options.delay) {
156
+ this._timeout = setTimeout(function() {
157
+ Draggables._timeout = null;
158
+ window.focus();
159
+ Draggables.activeDraggable = draggable;
160
+ }.bind(this), draggable.options.delay);
161
161
  } else {
162
162
  window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
163
163
  this.activeDraggable = draggable;
164
164
  }
165
165
  },
166
-
166
+
167
167
  deactivate: function() {
168
168
  this.activeDraggable = null;
169
169
  },
170
-
170
+
171
171
  updateDrag: function(event) {
172
172
  if(!this.activeDraggable) return;
173
173
  var pointer = [Event.pointerX(event), Event.pointerY(event)];
@@ -175,36 +175,36 @@ var Draggables = {
175
175
  // the same coordinates, prevent needless redrawing (moz bug?)
176
176
  if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
177
177
  this._lastPointer = pointer;
178
-
178
+
179
179
  this.activeDraggable.updateDrag(event, pointer);
180
180
  },
181
-
181
+
182
182
  endDrag: function(event) {
183
- if(this._timeout) {
184
- clearTimeout(this._timeout);
185
- this._timeout = null;
183
+ if(this._timeout) {
184
+ clearTimeout(this._timeout);
185
+ this._timeout = null;
186
186
  }
187
187
  if(!this.activeDraggable) return;
188
188
  this._lastPointer = null;
189
189
  this.activeDraggable.endDrag(event);
190
190
  this.activeDraggable = null;
191
191
  },
192
-
192
+
193
193
  keyPress: function(event) {
194
194
  if(this.activeDraggable)
195
195
  this.activeDraggable.keyPress(event);
196
196
  },
197
-
197
+
198
198
  addObserver: function(observer) {
199
199
  this.observers.push(observer);
200
200
  this._cacheObserverCallbacks();
201
201
  },
202
-
202
+
203
203
  removeObserver: function(element) { // element instead of observer fixes mem leaks
204
204
  this.observers = this.observers.reject( function(o) { return o.element==element });
205
205
  this._cacheObserverCallbacks();
206
206
  },
207
-
207
+
208
208
  notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
209
209
  if(this[eventName+'Count'] > 0)
210
210
  this.observers.each( function(o) {
@@ -212,7 +212,7 @@ var Draggables = {
212
212
  });
213
213
  if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
214
214
  },
215
-
215
+
216
216
  _cacheObserverCallbacks: function() {
217
217
  ['onStart','onEnd','onDrag'].each( function(eventName) {
218
218
  Draggables[eventName+'Count'] = Draggables.observers.select(
@@ -220,7 +220,7 @@ var Draggables = {
220
220
  ).length;
221
221
  });
222
222
  }
223
- }
223
+ };
224
224
 
225
225
  /*--------------------------------------------------------------------------*/
226
226
 
@@ -236,12 +236,12 @@ var Draggable = Class.create({
236
236
  },
237
237
  endeffect: function(element) {
238
238
  var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
239
- new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
239
+ new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
240
240
  queue: {scope:'_draggable', position:'end'},
241
- afterFinish: function(){
242
- Draggable._dragging[element] = false
241
+ afterFinish: function(){
242
+ Draggable._dragging[element] = false
243
243
  }
244
- });
244
+ });
245
245
  },
246
246
  zindex: 1000,
247
247
  revert: false,
@@ -252,57 +252,57 @@ var Draggable = Class.create({
252
252
  snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
253
253
  delay: 0
254
254
  };
255
-
255
+
256
256
  if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
257
257
  Object.extend(defaults, {
258
258
  starteffect: function(element) {
259
259
  element._opacity = Element.getOpacity(element);
260
260
  Draggable._dragging[element] = true;
261
- new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
261
+ new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
262
262
  }
263
263
  });
264
-
264
+
265
265
  var options = Object.extend(defaults, arguments[1] || { });
266
266
 
267
267
  this.element = $(element);
268
-
268
+
269
269
  if(options.handle && Object.isString(options.handle))
270
270
  this.handle = this.element.down('.'+options.handle, 0);
271
-
271
+
272
272
  if(!this.handle) this.handle = $(options.handle);
273
273
  if(!this.handle) this.handle = this.element;
274
-
274
+
275
275
  if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
276
276
  options.scroll = $(options.scroll);
277
277
  this._isScrollChild = Element.childOf(this.element, options.scroll);
278
278
  }
279
279
 
280
- Element.makePositioned(this.element); // fix IE
280
+ Element.makePositioned(this.element); // fix IE
281
281
 
282
282
  this.options = options;
283
- this.dragging = false;
283
+ this.dragging = false;
284
284
 
285
285
  this.eventMouseDown = this.initDrag.bindAsEventListener(this);
286
286
  Event.observe(this.handle, "mousedown", this.eventMouseDown);
287
-
287
+
288
288
  Draggables.register(this);
289
289
  },
290
-
290
+
291
291
  destroy: function() {
292
292
  Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
293
293
  Draggables.unregister(this);
294
294
  },
295
-
295
+
296
296
  currentDelta: function() {
297
297
  return([
298
298
  parseInt(Element.getStyle(this.element,'left') || '0'),
299
299
  parseInt(Element.getStyle(this.element,'top') || '0')]);
300
300
  },
301
-
301
+
302
302
  initDrag: function(event) {
303
303
  if(!Object.isUndefined(Draggable._dragging[this.element]) &&
304
304
  Draggable._dragging[this.element]) return;
305
- if(Event.isLeftClick(event)) {
305
+ if(Event.isLeftClick(event)) {
306
306
  // abort on form elements, fixes a Firefox issue
307
307
  var src = Event.element(event);
308
308
  if((tag_name = src.tagName.toUpperCase()) && (
@@ -311,34 +311,34 @@ var Draggable = Class.create({
311
311
  tag_name=='OPTION' ||
312
312
  tag_name=='BUTTON' ||
313
313
  tag_name=='TEXTAREA')) return;
314
-
314
+
315
315
  var pointer = [Event.pointerX(event), Event.pointerY(event)];
316
316
  var pos = Position.cumulativeOffset(this.element);
317
317
  this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
318
-
318
+
319
319
  Draggables.activate(this);
320
320
  Event.stop(event);
321
321
  }
322
322
  },
323
-
323
+
324
324
  startDrag: function(event) {
325
325
  this.dragging = true;
326
326
  if(!this.delta)
327
327
  this.delta = this.currentDelta();
328
-
328
+
329
329
  if(this.options.zindex) {
330
330
  this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
331
331
  this.element.style.zIndex = this.options.zindex;
332
332
  }
333
-
333
+
334
334
  if(this.options.ghosting) {
335
335
  this._clone = this.element.cloneNode(true);
336
- this.element._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
337
- if (!this.element._originallyAbsolute)
336
+ this._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
337
+ if (!this._originallyAbsolute)
338
338
  Position.absolutize(this.element);
339
339
  this.element.parentNode.insertBefore(this._clone, this.element);
340
340
  }
341
-
341
+
342
342
  if(this.options.scroll) {
343
343
  if (this.options.scroll == window) {
344
344
  var where = this._getWindowScroll(this.options.scroll);
@@ -349,28 +349,28 @@ var Draggable = Class.create({
349
349
  this.originalScrollTop = this.options.scroll.scrollTop;
350
350
  }
351
351
  }
352
-
352
+
353
353
  Draggables.notify('onStart', this, event);
354
-
354
+
355
355
  if(this.options.starteffect) this.options.starteffect(this.element);
356
356
  },
357
-
357
+
358
358
  updateDrag: function(event, pointer) {
359
359
  if(!this.dragging) this.startDrag(event);
360
-
360
+
361
361
  if(!this.options.quiet){
362
362
  Position.prepare();
363
363
  Droppables.show(pointer, this.element);
364
364
  }
365
-
365
+
366
366
  Draggables.notify('onDrag', this, event);
367
-
367
+
368
368
  this.draw(pointer);
369
369
  if(this.options.change) this.options.change(this);
370
-
370
+
371
371
  if(this.options.scroll) {
372
372
  this.stopScrolling();
373
-
373
+
374
374
  var p;
375
375
  if (this.options.scroll == window) {
376
376
  with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
@@ -388,16 +388,16 @@ var Draggable = Class.create({
388
388
  if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
389
389
  this.startScrolling(speed);
390
390
  }
391
-
391
+
392
392
  // fix AppleWebKit rendering
393
393
  if(Prototype.Browser.WebKit) window.scrollBy(0,0);
394
-
394
+
395
395
  Event.stop(event);
396
396
  },
397
-
397
+
398
398
  finishDrag: function(event, success) {
399
399
  this.dragging = false;
400
-
400
+
401
401
  if(this.options.quiet){
402
402
  Position.prepare();
403
403
  var pointer = [Event.pointerX(event), Event.pointerY(event)];
@@ -405,24 +405,24 @@ var Draggable = Class.create({
405
405
  }
406
406
 
407
407
  if(this.options.ghosting) {
408
- if (!this.element._originallyAbsolute)
408
+ if (!this._originallyAbsolute)
409
409
  Position.relativize(this.element);
410
- delete this.element._originallyAbsolute;
410
+ delete this._originallyAbsolute;
411
411
  Element.remove(this._clone);
412
412
  this._clone = null;
413
413
  }
414
414
 
415
- var dropped = false;
416
- if(success) {
417
- dropped = Droppables.fire(event, this.element);
418
- if (!dropped) dropped = false;
415
+ var dropped = false;
416
+ if(success) {
417
+ dropped = Droppables.fire(event, this.element);
418
+ if (!dropped) dropped = false;
419
419
  }
420
420
  if(dropped && this.options.onDropped) this.options.onDropped(this.element);
421
421
  Draggables.notify('onEnd', this, event);
422
422
 
423
423
  var revert = this.options.revert;
424
424
  if(revert && Object.isFunction(revert)) revert = revert(this.element);
425
-
425
+
426
426
  var d = this.currentDelta();
427
427
  if(revert && this.options.reverteffect) {
428
428
  if (dropped == 0 || revert != 'failure')
@@ -435,67 +435,67 @@ var Draggable = Class.create({
435
435
  if(this.options.zindex)
436
436
  this.element.style.zIndex = this.originalZ;
437
437
 
438
- if(this.options.endeffect)
438
+ if(this.options.endeffect)
439
439
  this.options.endeffect(this.element);
440
-
440
+
441
441
  Draggables.deactivate(this);
442
442
  Droppables.reset();
443
443
  },
444
-
444
+
445
445
  keyPress: function(event) {
446
446
  if(event.keyCode!=Event.KEY_ESC) return;
447
447
  this.finishDrag(event, false);
448
448
  Event.stop(event);
449
449
  },
450
-
450
+
451
451
  endDrag: function(event) {
452
452
  if(!this.dragging) return;
453
453
  this.stopScrolling();
454
454
  this.finishDrag(event, true);
455
455
  Event.stop(event);
456
456
  },
457
-
457
+
458
458
  draw: function(point) {
459
459
  var pos = Position.cumulativeOffset(this.element);
460
460
  if(this.options.ghosting) {
461
461
  var r = Position.realOffset(this.element);
462
462
  pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
463
463
  }
464
-
464
+
465
465
  var d = this.currentDelta();
466
466
  pos[0] -= d[0]; pos[1] -= d[1];
467
-
467
+
468
468
  if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
469
469
  pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
470
470
  pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
471
471
  }
472
-
473
- var p = [0,1].map(function(i){
474
- return (point[i]-pos[i]-this.offset[i])
472
+
473
+ var p = [0,1].map(function(i){
474
+ return (point[i]-pos[i]-this.offset[i])
475
475
  }.bind(this));
476
-
476
+
477
477
  if(this.options.snap) {
478
478
  if(Object.isFunction(this.options.snap)) {
479
479
  p = this.options.snap(p[0],p[1],this);
480
480
  } else {
481
481
  if(Object.isArray(this.options.snap)) {
482
482
  p = p.map( function(v, i) {
483
- return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this))
483
+ return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this));
484
484
  } else {
485
485
  p = p.map( function(v) {
486
- return (v/this.options.snap).round()*this.options.snap }.bind(this))
486
+ return (v/this.options.snap).round()*this.options.snap }.bind(this));
487
487
  }
488
488
  }}
489
-
489
+
490
490
  var style = this.element.style;
491
491
  if((!this.options.constraint) || (this.options.constraint=='horizontal'))
492
492
  style.left = p[0] + "px";
493
493
  if((!this.options.constraint) || (this.options.constraint=='vertical'))
494
494
  style.top = p[1] + "px";
495
-
495
+
496
496
  if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
497
497
  },
498
-
498
+
499
499
  stopScrolling: function() {
500
500
  if(this.scrollInterval) {
501
501
  clearInterval(this.scrollInterval);
@@ -503,14 +503,14 @@ var Draggable = Class.create({
503
503
  Draggables._lastScrollPointer = null;
504
504
  }
505
505
  },
506
-
506
+
507
507
  startScrolling: function(speed) {
508
508
  if(!(speed[0] || speed[1])) return;
509
509
  this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
510
510
  this.lastScrolled = new Date();
511
511
  this.scrollInterval = setInterval(this.scroll.bind(this), 10);
512
512
  },
513
-
513
+
514
514
  scroll: function() {
515
515
  var current = new Date();
516
516
  var delta = current - this.lastScrolled;
@@ -526,7 +526,7 @@ var Draggable = Class.create({
526
526
  this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
527
527
  this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
528
528
  }
529
-
529
+
530
530
  Position.prepare();
531
531
  Droppables.show(Draggables._lastPointer, this.element);
532
532
  Draggables.notify('onDrag', this);
@@ -540,10 +540,10 @@ var Draggable = Class.create({
540
540
  Draggables._lastScrollPointer[1] = 0;
541
541
  this.draw(Draggables._lastScrollPointer);
542
542
  }
543
-
543
+
544
544
  if(this.options.change) this.options.change(this);
545
545
  },
546
-
546
+
547
547
  _getWindowScroll: function(w) {
548
548
  var T, L, W, H;
549
549
  with (w.document) {
@@ -562,7 +562,7 @@ var Draggable = Class.create({
562
562
  H = documentElement.clientHeight;
563
563
  } else {
564
564
  W = body.offsetWidth;
565
- H = body.offsetHeight
565
+ H = body.offsetHeight;
566
566
  }
567
567
  }
568
568
  return { top: T, left: L, width: W, height: H };
@@ -579,11 +579,11 @@ var SortableObserver = Class.create({
579
579
  this.observer = observer;
580
580
  this.lastValue = Sortable.serialize(this.element);
581
581
  },
582
-
582
+
583
583
  onStart: function() {
584
584
  this.lastValue = Sortable.serialize(this.element);
585
585
  },
586
-
586
+
587
587
  onEnd: function() {
588
588
  Sortable.unmark();
589
589
  if(this.lastValue != Sortable.serialize(this.element))
@@ -593,11 +593,11 @@ var SortableObserver = Class.create({
593
593
 
594
594
  var Sortable = {
595
595
  SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
596
-
596
+
597
597
  sortables: { },
598
-
598
+
599
599
  _findRootElement: function(element) {
600
- while (element.tagName.toUpperCase() != "BODY") {
600
+ while (element.tagName.toUpperCase() != "BODY") {
601
601
  if(element.id && Sortable.sortables[element.id]) return element;
602
602
  element = element.parentNode;
603
603
  }
@@ -608,22 +608,23 @@ var Sortable = {
608
608
  if(!element) return;
609
609
  return Sortable.sortables[element.id];
610
610
  },
611
-
611
+
612
612
  destroy: function(element){
613
- var s = Sortable.options(element);
614
-
613
+ element = $(element);
614
+ var s = Sortable.sortables[element.id];
615
+
615
616
  if(s) {
616
617
  Draggables.removeObserver(s.element);
617
618
  s.droppables.each(function(d){ Droppables.remove(d) });
618
619
  s.draggables.invoke('destroy');
619
-
620
+
620
621
  delete Sortable.sortables[s.element.id];
621
622
  }
622
623
  },
623
624
 
624
625
  create: function(element) {
625
626
  element = $(element);
626
- var options = Object.extend({
627
+ var options = Object.extend({
627
628
  element: element,
628
629
  tag: 'li', // assumes li children, override with tag: 'tagname'
629
630
  dropOnEmpty: false,
@@ -637,17 +638,17 @@ var Sortable = {
637
638
  delay: 0,
638
639
  hoverclass: null,
639
640
  ghosting: false,
640
- quiet: false,
641
+ quiet: false,
641
642
  scroll: false,
642
643
  scrollSensitivity: 20,
643
644
  scrollSpeed: 15,
644
645
  format: this.SERIALIZE_RULE,
645
-
646
- // these take arrays of elements or ids and can be
646
+
647
+ // these take arrays of elements or ids and can be
647
648
  // used for better initialization performance
648
649
  elements: false,
649
650
  handles: false,
650
-
651
+
651
652
  onChange: Prototype.emptyFunction,
652
653
  onUpdate: Prototype.emptyFunction
653
654
  }, arguments[1] || { });
@@ -684,24 +685,24 @@ var Sortable = {
684
685
  if(options.zindex)
685
686
  options_for_draggable.zindex = options.zindex;
686
687
 
687
- // build options for the droppables
688
+ // build options for the droppables
688
689
  var options_for_droppable = {
689
690
  overlap: options.overlap,
690
691
  containment: options.containment,
691
692
  tree: options.tree,
692
693
  hoverclass: options.hoverclass,
693
694
  onHover: Sortable.onHover
694
- }
695
-
695
+ };
696
+
696
697
  var options_for_tree = {
697
698
  onHover: Sortable.onEmptyHover,
698
699
  overlap: options.overlap,
699
700
  containment: options.containment,
700
701
  hoverclass: options.hoverclass
701
- }
702
+ };
702
703
 
703
704
  // fix for gecko engine
704
- Element.cleanWhitespace(element);
705
+ Element.cleanWhitespace(element);
705
706
 
706
707
  options.draggables = [];
707
708
  options.droppables = [];
@@ -714,14 +715,14 @@ var Sortable = {
714
715
 
715
716
  (options.elements || this.findElements(element, options) || []).each( function(e,i) {
716
717
  var handle = options.handles ? $(options.handles[i]) :
717
- (options.handle ? $(e).select('.' + options.handle)[0] : e);
718
+ (options.handle ? $(e).select('.' + options.handle)[0] : e);
718
719
  options.draggables.push(
719
720
  new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
720
721
  Droppables.add(e, options_for_droppable);
721
722
  if(options.tree) e.treeNode = element;
722
- options.droppables.push(e);
723
+ options.droppables.push(e);
723
724
  });
724
-
725
+
725
726
  if(options.tree) {
726
727
  (Sortable.findTreeElements(element, options) || []).each( function(e) {
727
728
  Droppables.add(e, options_for_tree);
@@ -743,7 +744,7 @@ var Sortable = {
743
744
  return Element.findChildren(
744
745
  element, options.only, options.tree ? true : false, options.tag);
745
746
  },
746
-
747
+
747
748
  findTreeElements: function(element, options) {
748
749
  return Element.findChildren(
749
750
  element, options.only, options.tree ? true : false, options.treeTag);
@@ -760,7 +761,7 @@ var Sortable = {
760
761
  var oldParentNode = element.parentNode;
761
762
  element.style.visibility = "hidden"; // fix gecko rendering
762
763
  dropon.parentNode.insertBefore(element, dropon);
763
- if(dropon.parentNode!=oldParentNode)
764
+ if(dropon.parentNode!=oldParentNode)
764
765
  Sortable.options(oldParentNode).onChange(element);
765
766
  Sortable.options(dropon.parentNode).onChange(element);
766
767
  }
@@ -771,26 +772,26 @@ var Sortable = {
771
772
  var oldParentNode = element.parentNode;
772
773
  element.style.visibility = "hidden"; // fix gecko rendering
773
774
  dropon.parentNode.insertBefore(element, nextElement);
774
- if(dropon.parentNode!=oldParentNode)
775
+ if(dropon.parentNode!=oldParentNode)
775
776
  Sortable.options(oldParentNode).onChange(element);
776
777
  Sortable.options(dropon.parentNode).onChange(element);
777
778
  }
778
779
  }
779
780
  },
780
-
781
+
781
782
  onEmptyHover: function(element, dropon, overlap) {
782
783
  var oldParentNode = element.parentNode;
783
784
  var droponOptions = Sortable.options(dropon);
784
-
785
+
785
786
  if(!Element.isParent(dropon, element)) {
786
787
  var index;
787
-
788
+
788
789
  var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
789
790
  var child = null;
790
-
791
+
791
792
  if(children) {
792
793
  var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
793
-
794
+
794
795
  for (index = 0; index < children.length; index += 1) {
795
796
  if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) {
796
797
  offset -= Element.offsetSize (children[index], droponOptions.overlap);
@@ -803,9 +804,9 @@ var Sortable = {
803
804
  }
804
805
  }
805
806
  }
806
-
807
+
807
808
  dropon.insertBefore(element, child);
808
-
809
+
809
810
  Sortable.options(oldParentNode).onChange(element);
810
811
  droponOptions.onChange(element);
811
812
  }
@@ -818,34 +819,34 @@ var Sortable = {
818
819
  mark: function(dropon, position) {
819
820
  // mark on ghosting only
820
821
  var sortable = Sortable.options(dropon.parentNode);
821
- if(sortable && !sortable.ghosting) return;
822
+ if(sortable && !sortable.ghosting) return;
822
823
 
823
824
  if(!Sortable._marker) {
824
- Sortable._marker =
825
+ Sortable._marker =
825
826
  ($('dropmarker') || Element.extend(document.createElement('DIV'))).
826
827
  hide().addClassName('dropmarker').setStyle({position:'absolute'});
827
828
  document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
828
- }
829
+ }
829
830
  var offsets = Position.cumulativeOffset(dropon);
830
831
  Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
831
-
832
+
832
833
  if(position=='after')
833
- if(sortable.overlap == 'horizontal')
834
+ if(sortable.overlap == 'horizontal')
834
835
  Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'});
835
836
  else
836
837
  Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'});
837
-
838
+
838
839
  Sortable._marker.show();
839
840
  },
840
-
841
+
841
842
  _tree: function(element, options, parent) {
842
843
  var children = Sortable.findElements(element, options) || [];
843
-
844
+
844
845
  for (var i = 0; i < children.length; ++i) {
845
846
  var match = children[i].id.match(options.format);
846
847
 
847
848
  if (!match) continue;
848
-
849
+
849
850
  var child = {
850
851
  id: encodeURIComponent(match ? match[1] : null),
851
852
  element: element,
@@ -853,16 +854,16 @@ var Sortable = {
853
854
  children: [],
854
855
  position: parent.children.length,
855
856
  container: $(children[i]).down(options.treeTag)
856
- }
857
-
857
+ };
858
+
858
859
  /* Get the element containing the children and recurse over it */
859
860
  if (child.container)
860
- this._tree(child.container, options, child)
861
-
861
+ this._tree(child.container, options, child);
862
+
862
863
  parent.children.push (child);
863
864
  }
864
865
 
865
- return parent;
866
+ return parent;
866
867
  },
867
868
 
868
869
  tree: function(element) {
@@ -875,15 +876,15 @@ var Sortable = {
875
876
  name: element.id,
876
877
  format: sortableOptions.format
877
878
  }, arguments[1] || { });
878
-
879
+
879
880
  var root = {
880
881
  id: null,
881
882
  parent: null,
882
883
  children: [],
883
884
  container: element,
884
885
  position: 0
885
- }
886
-
886
+ };
887
+
887
888
  return Sortable._tree(element, options, root);
888
889
  },
889
890
 
@@ -899,7 +900,7 @@ var Sortable = {
899
900
  sequence: function(element) {
900
901
  element = $(element);
901
902
  var options = Object.extend(this.options(element), arguments[1] || { });
902
-
903
+
903
904
  return $(this.findElements(element, options) || []).map( function(item) {
904
905
  return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
905
906
  });
@@ -908,14 +909,14 @@ var Sortable = {
908
909
  setSequence: function(element, new_sequence) {
909
910
  element = $(element);
910
911
  var options = Object.extend(this.options(element), arguments[2] || { });
911
-
912
+
912
913
  var nodeMap = { };
913
914
  this.findElements(element, options).each( function(n) {
914
915
  if (n.id.match(options.format))
915
916
  nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
916
917
  n.parentNode.removeChild(n);
917
918
  });
918
-
919
+
919
920
  new_sequence.each(function(ident) {
920
921
  var n = nodeMap[ident];
921
922
  if (n) {
@@ -924,16 +925,16 @@ var Sortable = {
924
925
  }
925
926
  });
926
927
  },
927
-
928
+
928
929
  serialize: function(element) {
929
930
  element = $(element);
930
931
  var options = Object.extend(Sortable.options(element), arguments[1] || { });
931
932
  var name = encodeURIComponent(
932
933
  (arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
933
-
934
+
934
935
  if (options.tree) {
935
936
  return Sortable.tree(element, arguments[1]).children.map( function (item) {
936
- return [name + Sortable._constructIndex(item) + "[id]=" +
937
+ return [name + Sortable._constructIndex(item) + "[id]=" +
937
938
  encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
938
939
  }).flatten().join('&');
939
940
  } else {
@@ -942,16 +943,16 @@ var Sortable = {
942
943
  }).join('&');
943
944
  }
944
945
  }
945
- }
946
+ };
946
947
 
947
948
  // Returns true if child is contained within element
948
949
  Element.isParent = function(child, element) {
949
950
  if (!child.parentNode || child == element) return false;
950
951
  if (child.parentNode == element) return true;
951
952
  return Element.isParent(child.parentNode, element);
952
- }
953
+ };
953
954
 
954
- Element.findChildren = function(element, only, recursive, tagName) {
955
+ Element.findChildren = function(element, only, recursive, tagName) {
955
956
  if(!element.hasChildNodes()) return null;
956
957
  tagName = tagName.toUpperCase();
957
958
  if(only) only = [only].flatten();
@@ -967,8 +968,8 @@ Element.findChildren = function(element, only, recursive, tagName) {
967
968
  });
968
969
 
969
970
  return (elements.length>0 ? elements.flatten() : []);
970
- }
971
+ };
971
972
 
972
973
  Element.offsetSize = function (element, type) {
973
974
  return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
974
- }
975
+ };