gettext 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/ChangeLog +74 -0
  2. data/NEWS +16 -0
  3. data/README +9 -9
  4. data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
  5. data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
  6. data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
  7. data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
  8. data/data/locale/el/LC_MESSAGES/rails.mo +0 -0
  9. data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
  10. data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
  11. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  12. data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
  13. data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
  14. data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
  15. data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
  16. data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
  17. data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
  18. data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
  19. data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
  20. data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
  21. data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
  22. data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
  23. data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
  24. data/lib/gettext.rb +9 -4
  25. data/lib/gettext/locale.rb +11 -5
  26. data/lib/gettext/locale_cgi.rb +2 -5
  27. data/lib/gettext/locale_object.rb +68 -21
  28. data/lib/gettext/poparser.rb +2 -2
  29. data/lib/gettext/rails.rb +150 -30
  30. data/lib/gettext/version.rb +1 -1
  31. data/po/cs/rails.po +27 -27
  32. data/po/cs/rgettext.po +8 -8
  33. data/po/de/rails.po +28 -28
  34. data/po/de/rgettext.po +8 -8
  35. data/po/el/rails.po +25 -25
  36. data/po/el/rgettext.po +8 -8
  37. data/po/es/rails.po +25 -25
  38. data/po/es/rgettext.po +8 -8
  39. data/po/fr/rails.po +26 -26
  40. data/po/fr/rgettext.po +8 -8
  41. data/po/it/rgettext.po +8 -8
  42. data/po/ja/rails.po +23 -23
  43. data/po/ja/rgettext.po +8 -8
  44. data/po/ko/rails.po +23 -23
  45. data/po/ko/rgettext.po +8 -8
  46. data/po/nl/rails.po +25 -25
  47. data/po/nl/rgettext.po +8 -8
  48. data/po/pt_BR/rails.po +25 -25
  49. data/po/pt_BR/rgettext.po +8 -8
  50. data/po/rails.pot +25 -25
  51. data/po/rgettext.pot +8 -8
  52. data/po/sv/rgettext.po +8 -8
  53. data/samples/rails/README +3 -2
  54. data/samples/rails/Rakefile +6 -217
  55. data/samples/rails/app/controllers/application.rb +1 -0
  56. data/samples/rails/app/models/article.rb +7 -16
  57. data/samples/rails/config/database.yml +1 -0
  58. data/samples/rails/lib/tasks/gettext.rake +18 -0
  59. data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
  60. data/samples/rails/po/ja/blog.po +12 -0
  61. data/samples/rails/public/index.html +15 -17
  62. data/samples/rails/public/javascripts/controls.js +30 -1
  63. data/samples/rails/public/javascripts/dragdrop.js +210 -145
  64. data/samples/rails/public/javascripts/effects.js +261 -399
  65. data/samples/rails/public/javascripts/prototype.js +131 -72
  66. data/test/gettext_test.rb +5 -0
  67. data/test/gettext_test_locale.rb +133 -9
  68. metadata +5 -5
  69. data/pkg/ruby-gettext-package-1.2.0/ext/gettext/extconf.rb +0 -20
  70. data/samples/rails/script/benchmarker +0 -19
  71. data/samples/rails/script/profiler +0 -34
@@ -80,7 +80,10 @@ Autocompleter.Base.prototype = {
80
80
 
81
81
  show: function() {
82
82
  if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
83
- if(!this.iefix && (navigator.appVersion.indexOf('MSIE')>0) && (Element.getStyle(this.update, 'position')=='absolute')) {
83
+ if(!this.iefix &&
84
+ (navigator.appVersion.indexOf('MSIE')>0) &&
85
+ (navigator.userAgent.indexOf('Opera')<0) &&
86
+ (Element.getStyle(this.update, 'position')=='absolute')) {
84
87
  new Insertion.After(this.update,
85
88
  '<iframe id="' + this.update.id + '_iefix" '+
86
89
  'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
@@ -718,4 +721,30 @@ Ajax.InPlaceEditor.prototype = {
718
721
  Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener);
719
722
  }
720
723
  }
724
+ };
725
+
726
+ // Delayed observer, like Form.Element.Observer,
727
+ // but waits for delay after last key input
728
+ // Ideal for live-search fields
729
+
730
+ Form.Element.DelayedObserver = Class.create();
731
+ Form.Element.DelayedObserver.prototype = {
732
+ initialize: function(element, delay, callback) {
733
+ this.delay = delay || 0.5;
734
+ this.element = $(element);
735
+ this.callback = callback;
736
+ this.timer = null;
737
+ this.lastValue = $F(this.element);
738
+ Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
739
+ },
740
+ delayedListener: function(event) {
741
+ if(this.lastValue == $F(this.element)) return;
742
+ if(this.timer) clearTimeout(this.timer);
743
+ this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
744
+ this.lastValue = $F(this.element);
745
+ },
746
+ onTimerEvent: function() {
747
+ this.timer = null;
748
+ this.callback(this.element, $F(this.element));
749
+ }
721
750
  };
@@ -1,7 +1,5 @@
1
1
  // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2
2
  //
3
- // Element.Class part Copyright (c) 2005 by Rick Olson
4
- //
5
3
  // See scriptaculous.js for full license.
6
4
 
7
5
  /*--------------------------------------------------------------------------*/
@@ -10,7 +8,7 @@ var Droppables = {
10
8
  drops: [],
11
9
 
12
10
  remove: function(element) {
13
- this.drops = this.drops.reject(function(d) { return d.element==element });
11
+ this.drops = this.drops.reject(function(d) { return d.element==$(element) });
14
12
  },
15
13
 
16
14
  add: function(element) {
@@ -31,6 +29,8 @@ var Droppables = {
31
29
  options._containers.push($(containment));
32
30
  }
33
31
  }
32
+
33
+ if(options.accept) options.accept = [options.accept].flatten();
34
34
 
35
35
  Element.makePositioned(element); // fix IE
36
36
  options.element = element;
@@ -43,55 +43,50 @@ var Droppables = {
43
43
  return drop._containers.detect(function(c) { return parentNode == c });
44
44
  },
45
45
 
46
- isAffected: function(pX, pY, element, drop) {
46
+ isAffected: function(point, element, drop) {
47
47
  return (
48
48
  (drop.element!=element) &&
49
49
  ((!drop._containers) ||
50
50
  this.isContained(element, drop)) &&
51
51
  ((!drop.accept) ||
52
- (Element.Class.has_any(element, drop.accept))) &&
53
- Position.within(drop.element, pX, pY) );
52
+ (Element.classNames(element).detect(
53
+ function(v) { return drop.accept.include(v) } ) )) &&
54
+ Position.within(drop.element, point[0], point[1]) );
54
55
  },
55
56
 
56
57
  deactivate: function(drop) {
57
58
  if(drop.hoverclass)
58
- Element.Class.remove(drop.element, drop.hoverclass);
59
+ Element.removeClassName(drop.element, drop.hoverclass);
59
60
  this.last_active = null;
60
61
  },
61
62
 
62
63
  activate: function(drop) {
63
- if(this.last_active) this.deactivate(this.last_active);
64
64
  if(drop.hoverclass)
65
- Element.Class.add(drop.element, drop.hoverclass);
65
+ Element.addClassName(drop.element, drop.hoverclass);
66
66
  this.last_active = drop;
67
67
  },
68
68
 
69
- show: function(event, element) {
69
+ show: function(point, element) {
70
70
  if(!this.drops.length) return;
71
- var pX = Event.pointerX(event);
72
- var pY = Event.pointerY(event);
73
- Position.prepare();
74
-
75
- var i = this.drops.length-1; do {
76
- var drop = this.drops[i];
77
- if(this.isAffected(pX, pY, element, drop)) {
71
+
72
+ if(this.last_active) this.deactivate(this.last_active);
73
+ this.drops.each( function(drop) {
74
+ if(Droppables.isAffected(point, element, drop)) {
78
75
  if(drop.onHover)
79
76
  drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
80
77
  if(drop.greedy) {
81
- this.activate(drop);
82
- return;
78
+ Droppables.activate(drop);
79
+ throw $break;
83
80
  }
84
81
  }
85
- } while (i--);
86
-
87
- if(this.last_active) this.deactivate(this.last_active);
82
+ });
88
83
  },
89
84
 
90
85
  fire: function(event, element) {
91
86
  if(!this.last_active) return;
92
87
  Position.prepare();
93
88
 
94
- if (this.isAffected(Event.pointerX(event), Event.pointerY(event), element, this.last_active))
89
+ if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
95
90
  if (this.last_active.onDrop)
96
91
  this.last_active.onDrop(element, this.last_active.element, event);
97
92
  },
@@ -103,15 +98,84 @@ var Droppables = {
103
98
  }
104
99
 
105
100
  var Draggables = {
101
+ drags: [],
106
102
  observers: [],
103
+
104
+ register: function(draggable) {
105
+ if(this.drags.length == 0) {
106
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
107
+ this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
108
+ this.eventKeypress = this.keyPress.bindAsEventListener(this);
109
+
110
+ Event.observe(document, "mouseup", this.eventMouseUp);
111
+ Event.observe(document, "mousemove", this.eventMouseMove);
112
+ Event.observe(document, "keypress", this.eventKeypress);
113
+ }
114
+ this.drags.push(draggable);
115
+ },
116
+
117
+ unregister: function(draggable) {
118
+ this.drags = this.drags.reject(function(d) { return d==draggable });
119
+ if(this.drags.length == 0) {
120
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
121
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
122
+ Event.stopObserving(document, "keypress", this.eventKeypress);
123
+ }
124
+ },
125
+
126
+ activate: function(draggable) {
127
+ window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
128
+ this.activeDraggable = draggable;
129
+ },
130
+
131
+ deactivate: function(draggbale) {
132
+ this.activeDraggable = null;
133
+ },
134
+
135
+ updateDrag: function(event) {
136
+ if(!this.activeDraggable) return;
137
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
138
+ // Mozilla-based browsers fire successive mousemove events with
139
+ // the same coordinates, prevent needless redrawing (moz bug?)
140
+ if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
141
+ this._lastPointer = pointer;
142
+ this.activeDraggable.updateDrag(event, pointer);
143
+ },
144
+
145
+ endDrag: function(event) {
146
+ if(!this.activeDraggable) return;
147
+ this._lastPointer = null;
148
+ this.activeDraggable.endDrag(event);
149
+ },
150
+
151
+ keyPress: function(event) {
152
+ if(this.activeDraggable)
153
+ this.activeDraggable.keyPress(event);
154
+ },
155
+
107
156
  addObserver: function(observer) {
108
- this.observers.push(observer);
157
+ this.observers.push(observer);
158
+ this._cacheObserverCallbacks();
109
159
  },
110
- removeObserver: function(element) { // element instead of obsever fixes mem leaks
160
+
161
+ removeObserver: function(element) { // element instead of observer fixes mem leaks
111
162
  this.observers = this.observers.reject( function(o) { return o.element==element });
163
+ this._cacheObserverCallbacks();
112
164
  },
113
- notify: function(eventName, draggable) { // 'onStart', 'onEnd'
114
- this.observers.invoke(eventName, draggable);
165
+
166
+ notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
167
+ if(this[eventName+'Count'] > 0)
168
+ this.observers.each( function(o) {
169
+ if(o[eventName]) o[eventName](eventName, draggable, event);
170
+ });
171
+ },
172
+
173
+ _cacheObserverCallbacks: function() {
174
+ ['onStart','onEnd','onDrag'].each( function(eventName) {
175
+ Draggables[eventName+'Count'] = Draggables.observers.select(
176
+ function(o) { return o[eventName]; }
177
+ ).length;
178
+ });
115
179
  }
116
180
  }
117
181
 
@@ -127,68 +191,48 @@ Draggable.prototype = {
127
191
  },
128
192
  reverteffect: function(element, top_offset, left_offset) {
129
193
  var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
130
- new Effect.MoveBy(element, -top_offset, -left_offset, {duration:dur});
194
+ element._revert = new Effect.MoveBy(element, -top_offset, -left_offset, {duration:dur});
131
195
  },
132
196
  endeffect: function(element) {
133
- new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0});
197
+ new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0});
134
198
  },
135
199
  zindex: 1000,
136
- revert: false
200
+ revert: false,
201
+ snap: false // false, or xy or [x,y] or function(x,y){ return [x,y] }
137
202
  }, arguments[1] || {});
138
203
 
139
- this.element = $(element);
204
+ this.element = $(element);
205
+
140
206
  if(options.handle && (typeof options.handle == 'string'))
141
- this.handle = Element.Class.childrenWith(this.element, options.handle)[0];
142
-
207
+ this.handle = Element.childrenWithClassName(this.element, options.handle)[0];
143
208
  if(!this.handle) this.handle = $(options.handle);
144
209
  if(!this.handle) this.handle = this.element;
145
210
 
146
211
  Element.makePositioned(this.element); // fix IE
147
212
 
148
- this.offsetX = 0;
149
- this.offsetY = 0;
150
- this.originalLeft = this.currentLeft();
151
- this.originalTop = this.currentTop();
152
- this.originalX = this.element.offsetLeft;
153
- this.originalY = this.element.offsetTop;
154
-
155
- this.options = options;
213
+ this.delta = this.currentDelta();
214
+ this.options = options;
215
+ this.dragging = false;
156
216
 
157
- this.active = false;
158
- this.dragging = false;
159
-
160
- this.eventMouseDown = this.startDrag.bindAsEventListener(this);
161
- this.eventMouseUp = this.endDrag.bindAsEventListener(this);
162
- this.eventMouseMove = this.update.bindAsEventListener(this);
163
- this.eventKeypress = this.keyPress.bindAsEventListener(this);
217
+ this.eventMouseDown = this.initDrag.bindAsEventListener(this);
218
+ Event.observe(this.handle, "mousedown", this.eventMouseDown);
164
219
 
165
- this.registerEvents();
220
+ Draggables.register(this);
166
221
  },
222
+
167
223
  destroy: function() {
168
224
  Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
169
- this.unregisterEvents();
225
+ Draggables.unregister(this);
170
226
  },
171
- registerEvents: function() {
172
- Event.observe(document, "mouseup", this.eventMouseUp);
173
- Event.observe(document, "mousemove", this.eventMouseMove);
174
- Event.observe(document, "keypress", this.eventKeypress);
175
- Event.observe(this.handle, "mousedown", this.eventMouseDown);
176
- },
177
- unregisterEvents: function() {
178
- //if(!this.active) return;
179
- //Event.stopObserving(document, "mouseup", this.eventMouseUp);
180
- //Event.stopObserving(document, "mousemove", this.eventMouseMove);
181
- //Event.stopObserving(document, "keypress", this.eventKeypress);
182
- },
183
- currentLeft: function() {
184
- return parseInt(this.element.style.left || '0');
227
+
228
+ currentDelta: function() {
229
+ return([
230
+ parseInt(this.element.style.left || '0'),
231
+ parseInt(this.element.style.top || '0')]);
185
232
  },
186
- currentTop: function() {
187
- return parseInt(this.element.style.top || '0')
188
- },
189
- startDrag: function(event) {
190
- if(Event.isLeftClick(event)) {
191
-
233
+
234
+ initDrag: function(event) {
235
+ if(Event.isLeftClick(event)) {
192
236
  // abort on form elements, fixes a Firefox issue
193
237
  var src = Event.element(event);
194
238
  if(src.tagName && (
@@ -196,20 +240,53 @@ Draggable.prototype = {
196
240
  src.tagName=='SELECT' ||
197
241
  src.tagName=='BUTTON' ||
198
242
  src.tagName=='TEXTAREA')) return;
243
+
244
+ if(this.element._revert) {
245
+ this.element._revert.cancel();
246
+ this.element._revert = null;
247
+ }
199
248
 
200
- // this.registerEvents();
201
- this.active = true;
202
249
  var pointer = [Event.pointerX(event), Event.pointerY(event)];
203
- var offsets = Position.cumulativeOffset(this.element);
204
- this.offsetX = (pointer[0] - offsets[0]);
205
- this.offsetY = (pointer[1] - offsets[1]);
250
+ var pos = Position.cumulativeOffset(this.element);
251
+ this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
252
+
253
+ Draggables.activate(this);
206
254
  Event.stop(event);
207
255
  }
208
256
  },
257
+
258
+ startDrag: function(event) {
259
+ this.dragging = true;
260
+
261
+ if(this.options.zindex) {
262
+ this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
263
+ this.element.style.zIndex = this.options.zindex;
264
+ }
265
+
266
+ if(this.options.ghosting) {
267
+ this._clone = this.element.cloneNode(true);
268
+ Position.absolutize(this.element);
269
+ this.element.parentNode.insertBefore(this._clone, this.element);
270
+ }
271
+
272
+ Draggables.notify('onStart', this, event);
273
+ if(this.options.starteffect) this.options.starteffect(this.element);
274
+ },
275
+
276
+ updateDrag: function(event, pointer) {
277
+ if(!this.dragging) this.startDrag(event);
278
+ Position.prepare();
279
+ Droppables.show(pointer, this.element);
280
+ Draggables.notify('onDrag', this, event);
281
+ this.draw(pointer);
282
+ if(this.options.change) this.options.change(this);
283
+
284
+ // fix AppleWebKit rendering
285
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
286
+ Event.stop(event);
287
+ },
288
+
209
289
  finishDrag: function(event, success) {
210
- // this.unregisterEvents();
211
-
212
- this.active = false;
213
290
  this.dragging = false;
214
291
 
215
292
  if(this.options.ghosting) {
@@ -219,18 +296,17 @@ Draggable.prototype = {
219
296
  }
220
297
 
221
298
  if(success) Droppables.fire(event, this.element);
222
- Draggables.notify('onEnd', this);
299
+ Draggables.notify('onEnd', this, event);
223
300
 
224
301
  var revert = this.options.revert;
225
302
  if(revert && typeof revert == 'function') revert = revert(this.element);
226
-
303
+
304
+ var d = this.currentDelta();
227
305
  if(revert && this.options.reverteffect) {
228
306
  this.options.reverteffect(this.element,
229
- this.currentTop()-this.originalTop,
230
- this.currentLeft()-this.originalLeft);
307
+ d[1]-this.delta[1], d[0]-this.delta[0]);
231
308
  } else {
232
- this.originalLeft = this.currentLeft();
233
- this.originalTop = this.currentTop();
309
+ this.delta = d;
234
310
  }
235
311
 
236
312
  if(this.options.zindex)
@@ -239,70 +315,48 @@ Draggable.prototype = {
239
315
  if(this.options.endeffect)
240
316
  this.options.endeffect(this.element);
241
317
 
242
-
318
+ Draggables.deactivate(this);
243
319
  Droppables.reset();
244
320
  },
321
+
245
322
  keyPress: function(event) {
246
- if(this.active) {
247
- if(event.keyCode==Event.KEY_ESC) {
248
- this.finishDrag(event, false);
249
- Event.stop(event);
250
- }
251
- }
323
+ if(!event.keyCode==Event.KEY_ESC) return;
324
+ this.finishDrag(event, false);
325
+ Event.stop(event);
252
326
  },
327
+
253
328
  endDrag: function(event) {
254
- if(this.active && this.dragging) {
255
- this.finishDrag(event, true);
256
- Event.stop(event);
257
- }
258
- this.active = false;
259
- this.dragging = false;
329
+ if(!this.dragging) return;
330
+ this.finishDrag(event, true);
331
+ Event.stop(event);
260
332
  },
261
- draw: function(event) {
262
- var pointer = [Event.pointerX(event), Event.pointerY(event)];
263
- var offsets = Position.cumulativeOffset(this.element);
264
- offsets[0] -= this.currentLeft();
265
- offsets[1] -= this.currentTop();
333
+
334
+ draw: function(point) {
335
+ var pos = Position.cumulativeOffset(this.element);
336
+ var d = this.currentDelta();
337
+ pos[0] -= d[0]; pos[1] -= d[1];
338
+
339
+ var p = [0,1].map(function(i){ return (point[i]-pos[i]-this.offset[i]) }.bind(this));
340
+
341
+ if(this.options.snap) {
342
+ if(typeof this.options.snap == 'function') {
343
+ p = this.options.snap(p[0],p[1]);
344
+ } else {
345
+ if(this.options.snap instanceof Array) {
346
+ p = p.map( function(v, i) {
347
+ return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this))
348
+ } else {
349
+ p = p.map( function(v) {
350
+ return Math.round(v/this.options.snap)*this.options.snap }.bind(this))
351
+ }
352
+ }}
353
+
266
354
  var style = this.element.style;
267
355
  if((!this.options.constraint) || (this.options.constraint=='horizontal'))
268
- style.left = (pointer[0] - offsets[0] - this.offsetX) + "px";
356
+ style.left = p[0] + "px";
269
357
  if((!this.options.constraint) || (this.options.constraint=='vertical'))
270
- style.top = (pointer[1] - offsets[1] - this.offsetY) + "px";
358
+ style.top = p[1] + "px";
271
359
  if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
272
- },
273
- update: function(event) {
274
- if(this.active) {
275
- if(!this.dragging) {
276
- var style = this.element.style;
277
- this.dragging = true;
278
-
279
- if(Element.getStyle(this.element,'position')=='')
280
- style.position = "relative";
281
-
282
- if(this.options.zindex) {
283
- this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
284
- style.zIndex = this.options.zindex;
285
- }
286
-
287
- if(this.options.ghosting) {
288
- this._clone = this.element.cloneNode(true);
289
- Position.absolutize(this.element);
290
- this.element.parentNode.insertBefore(this._clone, this.element);
291
- }
292
-
293
- Draggables.notify('onStart', this);
294
- if(this.options.starteffect) this.options.starteffect(this.element);
295
- }
296
-
297
- Droppables.show(event, this.element);
298
- this.draw(event);
299
- if(this.options.change) this.options.change(this);
300
-
301
- // fix AppleWebKit rendering
302
- if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
303
-
304
- Event.stop(event);
305
- }
306
360
  }
307
361
  }
308
362
 
@@ -315,9 +369,11 @@ SortableObserver.prototype = {
315
369
  this.observer = observer;
316
370
  this.lastValue = Sortable.serialize(this.element);
317
371
  },
372
+
318
373
  onStart: function() {
319
374
  this.lastValue = Sortable.serialize(this.element);
320
375
  },
376
+
321
377
  onEnd: function() {
322
378
  Sortable.unmark();
323
379
  if(this.lastValue != Sortable.serialize(this.element))
@@ -327,10 +383,12 @@ SortableObserver.prototype = {
327
383
 
328
384
  var Sortable = {
329
385
  sortables: new Array(),
386
+
330
387
  options: function(element){
331
388
  element = $(element);
332
389
  return this.sortables.detect(function(s) { return s.element == element });
333
390
  },
391
+
334
392
  destroy: function(element){
335
393
  element = $(element);
336
394
  this.sortables.findAll(function(s) { return s.element == element }).each(function(s){
@@ -340,6 +398,7 @@ var Sortable = {
340
398
  });
341
399
  this.sortables = this.sortables.reject(function(s) { return s.element == element });
342
400
  },
401
+
343
402
  create: function(element) {
344
403
  element = $(element);
345
404
  var options = Object.extend({
@@ -413,7 +472,7 @@ var Sortable = {
413
472
  (this.findElements(element, options) || []).each( function(e) {
414
473
  // handles are per-draggable
415
474
  var handle = options.handle ?
416
- Element.Class.childrenWith(e, options.handle)[0] : e;
475
+ Element.childrenWithClassName(e, options.handle)[0] : e;
417
476
  options.draggables.push(
418
477
  new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
419
478
  Droppables.add(e, options_for_droppable);
@@ -433,8 +492,8 @@ var Sortable = {
433
492
  if(!element.hasChildNodes()) return null;
434
493
  var elements = [];
435
494
  $A(element.childNodes).each( function(e) {
436
- if(e.tagName && e.tagName==options.tag.toUpperCase() &&
437
- (!options.only || (Element.Class.has(e, options.only))))
495
+ if(e.tagName && e.tagName.toUpperCase()==options.tag.toUpperCase() &&
496
+ (!options.only || (Element.hasClassName(e, options.only))))
438
497
  elements.push(e);
439
498
  if(options.tree) {
440
499
  var grandchildren = this.findElements(e, options);
@@ -491,14 +550,20 @@ var Sortable = {
491
550
  if(!Sortable._marker) {
492
551
  Sortable._marker = $('dropmarker') || document.createElement('DIV');
493
552
  Element.hide(Sortable._marker);
494
- Element.Class.add(Sortable._marker, 'dropmarker');
553
+ Element.addClassName(Sortable._marker, 'dropmarker');
495
554
  Sortable._marker.style.position = 'absolute';
496
555
  document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
497
556
  }
498
557
  var offsets = Position.cumulativeOffset(dropon);
499
- Sortable._marker.style.top = offsets[1] + 'px';
500
- if(position=='after') Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px';
501
558
  Sortable._marker.style.left = offsets[0] + 'px';
559
+ Sortable._marker.style.top = offsets[1] + 'px';
560
+
561
+ if(position=='after')
562
+ if(sortable.overlap == 'horizontal')
563
+ Sortable._marker.style.left = (offsets[0]+dropon.clientWidth) + 'px';
564
+ else
565
+ Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px';
566
+
502
567
  Element.show(Sortable._marker);
503
568
  },
504
569
 
@@ -511,7 +576,7 @@ var Sortable = {
511
576
  name: element.id,
512
577
  format: sortableOptions.format || /^[^_]*_(.*)$/
513
578
  }, arguments[1] || {});
514
- return $(this.findElements(element, options) || []).collect( function(item) {
579
+ return $(this.findElements(element, options) || []).map( function(item) {
515
580
  return (encodeURIComponent(options.name) + "[]=" +
516
581
  encodeURIComponent(item.id.match(options.format) ? item.id.match(options.format)[1] : ''));
517
582
  }).join("&");