qwik2md 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/lib/qwik2md/version.rb +1 -1
  3. data/vendor/qwik/lib/qwik/act-christel.rb +1 -1
  4. data/vendor/qwik/lib/qwik/page-get.rb +4 -4
  5. data/vendor/qwik/lib/qwik/util-filename.rb +2 -5
  6. data/vendor/qwik/lib/qwik/util-string.rb +7 -7
  7. data/vendor/qwik/share/super/FrontPage.txt +17 -0
  8. data/vendor/qwik/share/super/QwikWebPlugin.txt +0 -0
  9. data/vendor/qwik/share/super/QwikWebStructure.txt +0 -0
  10. data/vendor/qwik/share/super/RecentList.txt +2 -0
  11. data/vendor/qwik/share/super/SandBox.txt +3 -0
  12. data/vendor/qwik/share/super/TextFormat.txt +186 -0
  13. data/vendor/qwik/share/super/TextFormatSimple.txt +23 -0
  14. data/vendor/qwik/share/super/TitleList.txt +2 -0
  15. data/vendor/qwik/share/super/_AdminMenu.txt +11 -0
  16. data/vendor/qwik/share/super/_BookSearch.txt +3 -0
  17. data/vendor/qwik/share/super/_EditorFooter.txt +9 -0
  18. data/vendor/qwik/share/super/_EditorHelp.txt +9 -0
  19. data/vendor/qwik/share/super/_InterWikiName.txt +17 -0
  20. data/vendor/qwik/share/super/_IsbnLink.txt +8 -0
  21. data/vendor/qwik/share/super/_MemberAdd.txt +4 -0
  22. data/vendor/qwik/share/super/_MemberList.txt +2 -0
  23. data/vendor/qwik/share/super/_MemberListCSV.txt +2 -0
  24. data/vendor/qwik/share/super/_PageAttribute.txt +7 -0
  25. data/vendor/qwik/share/super/_SideMenu.txt +15 -0
  26. data/vendor/qwik/share/super/_SiteConfig.txt +30 -0
  27. data/vendor/qwik/share/super/_SiteFooter.txt +3 -0
  28. data/vendor/qwik/share/super/_SiteLog.txt +0 -0
  29. data/vendor/qwik/share/super/_SiteLogView.txt +2 -0
  30. data/vendor/qwik/share/super/_SiteMember.txt +0 -0
  31. data/vendor/qwik/share/super/_SiteMenu.txt +2 -0
  32. data/vendor/qwik/share/super/_SiteSearch.txt +3 -0
  33. data/vendor/qwik/share/super/_SiteTheme.txt +9 -0
  34. data/vendor/qwik/share/super/_textformat.txt +2 -0
  35. data/vendor/qwik/share/template/Makefile +10 -0
  36. data/vendor/qwik/share/template/edit.html +22 -0
  37. data/vendor/qwik/share/template/edit.rb +40 -0
  38. data/vendor/qwik/share/template/editor.html +23 -0
  39. data/vendor/qwik/share/template/editor.rb +47 -0
  40. data/vendor/qwik/share/template/notice.html +21 -0
  41. data/vendor/qwik/share/template/notice.rb +43 -0
  42. data/vendor/qwik/share/template/plain.html +19 -0
  43. data/vendor/qwik/share/template/plain.rb +43 -0
  44. data/vendor/qwik/share/template/surface.html +22 -0
  45. data/vendor/qwik/share/template/surface.rb +50 -0
  46. data/vendor/qwik/share/template/system.html +30 -0
  47. data/vendor/qwik/share/template/system.rb +46 -0
  48. data/vendor/qwik/share/template/view.html +20 -0
  49. data/vendor/qwik/share/template/view.rb +40 -0
  50. data/vendor/qwik/share/theme/css/Makefile +10 -0
  51. data/vendor/qwik/share/theme/css/base.css +779 -0
  52. data/vendor/qwik/share/theme/css/delete.png +0 -0
  53. data/vendor/qwik/share/theme/css/menu.css +77 -0
  54. data/vendor/qwik/share/theme/css/wema.css +141 -0
  55. data/vendor/qwik/share/theme/i/a.gif +0 -0
  56. data/vendor/qwik/share/theme/i/binary.gif +0 -0
  57. data/vendor/qwik/share/theme/i/broken.gif +0 -0
  58. data/vendor/qwik/share/theme/i/compressed.gif +0 -0
  59. data/vendor/qwik/share/theme/i/external.png +0 -0
  60. data/vendor/qwik/share/theme/i/external_hover.png +0 -0
  61. data/vendor/qwik/share/theme/i/favicon.ico +0 -0
  62. data/vendor/qwik/share/theme/i/favicon.png +0 -0
  63. data/vendor/qwik/share/theme/i/generic.gif +0 -0
  64. data/vendor/qwik/share/theme/i/image2.gif +0 -0
  65. data/vendor/qwik/share/theme/i/login_bg.gif +0 -0
  66. data/vendor/qwik/share/theme/i/login_inputform_bg.gif +0 -0
  67. data/vendor/qwik/share/theme/i/login_inputform_bg_footer.gif +0 -0
  68. data/vendor/qwik/share/theme/i/login_inputform_bg_header.gif +0 -0
  69. data/vendor/qwik/share/theme/i/login_li.gif +0 -0
  70. data/vendor/qwik/share/theme/i/login_qwik_logo.gif +0 -0
  71. data/vendor/qwik/share/theme/i/movie.gif +0 -0
  72. data/vendor/qwik/share/theme/i/new.png +0 -0
  73. data/vendor/qwik/share/theme/i/pdf.gif +0 -0
  74. data/vendor/qwik/share/theme/i/ps.gif +0 -0
  75. data/vendor/qwik/share/theme/i/sound2.gif +0 -0
  76. data/vendor/qwik/share/theme/i/sphere2.gif +0 -0
  77. data/vendor/qwik/share/theme/i/tar.gif +0 -0
  78. data/vendor/qwik/share/theme/i/text.gif +0 -0
  79. data/vendor/qwik/share/theme/js/Makefile +23 -0
  80. data/vendor/qwik/share/theme/js/base.js +176 -0
  81. data/vendor/qwik/share/theme/js/builder.js +101 -0
  82. data/vendor/qwik/share/theme/js/controls.js +750 -0
  83. data/vendor/qwik/share/theme/js/debugwindow-test.html +60 -0
  84. data/vendor/qwik/share/theme/js/debugwindow.html +24 -0
  85. data/vendor/qwik/share/theme/js/debugwindow.js +476 -0
  86. data/vendor/qwik/share/theme/js/dragdrop.js +559 -0
  87. data/vendor/qwik/share/theme/js/effects.js +904 -0
  88. data/vendor/qwik/share/theme/js/event.js +98 -0
  89. data/vendor/qwik/share/theme/js/history.js +110 -0
  90. data/vendor/qwik/share/theme/js/menu.js +27 -0
  91. data/vendor/qwik/share/theme/js/monitor.js +96 -0
  92. data/vendor/qwik/share/theme/js/niftypp.js +272 -0
  93. data/vendor/qwik/share/theme/js/prototype.js +1758 -0
  94. data/vendor/qwik/share/theme/js/scriptaculous.js +48 -0
  95. data/vendor/qwik/share/theme/js/se_hilite_jp.js +234 -0
  96. data/vendor/qwik/share/theme/js/slider.js +275 -0
  97. data/vendor/qwik/share/theme/js/test-all.html +24 -0
  98. data/vendor/qwik/share/theme/js/test-debug.html +56 -0
  99. data/vendor/qwik/share/theme/js/test-wema.html +304 -0
  100. data/vendor/qwik/share/theme/js/test-xp.html +99 -0
  101. data/vendor/qwik/share/theme/js/unittest.js +363 -0
  102. data/vendor/qwik/share/theme/js/watch.js +109 -0
  103. data/vendor/qwik/share/theme/js/wema.js +580 -0
  104. data/vendor/qwik/share/theme/js/wysiwyg.js +143 -0
  105. data/vendor/qwik/share/theme/qwikborder/qwikborder.css +277 -0
  106. data/vendor/qwik/share/theme/qwikborder/qwikborder_ball.png +0 -0
  107. data/vendor/qwik/share/theme/qwikborder/qwikborder_h2.png +0 -0
  108. data/vendor/qwik/share/theme/qwikborder/qwikborder_li.png +0 -0
  109. data/vendor/qwik/share/theme/qwikcyan/qwikcyan.css +216 -0
  110. data/vendor/qwik/share/theme/qwikcyan/qwikcyan_li.png +0 -0
  111. data/vendor/qwik/share/theme/qwikeditor/command.gif +0 -0
  112. data/vendor/qwik/share/theme/qwikeditor/edit_form_bg.jpg +0 -0
  113. data/vendor/qwik/share/theme/qwikeditor/edit_qwik_logo.gif +0 -0
  114. data/vendor/qwik/share/theme/qwikeditor/edit_title_bg.jpg +0 -0
  115. data/vendor/qwik/share/theme/qwikeditor/login_bg.gif +0 -0
  116. data/vendor/qwik/share/theme/qwikeditor/login_qwik_logo.gif +0 -0
  117. data/vendor/qwik/share/theme/qwikeditor/qwikeditor.css +336 -0
  118. data/vendor/qwik/share/theme/qwikeditor/sidebar_bg.gif +0 -0
  119. data/vendor/qwik/share/theme/qwikgreen/qwikgreen.css +306 -0
  120. data/vendor/qwik/share/theme/qwiknotice/qwiknotice.css +246 -0
  121. data/vendor/qwik/share/theme/qwiknotice/qwiknotice_body_bg.gif +0 -0
  122. data/vendor/qwik/share/theme/qwiknotice/qwiknotice_inputform_bg.gif +0 -0
  123. data/vendor/qwik/share/theme/qwiknotice/qwiknotice_inputform_bg_footer.gif +0 -0
  124. data/vendor/qwik/share/theme/qwiknotice/qwiknotice_inputform_bg_header.gif +0 -0
  125. data/vendor/qwik/share/theme/qwiknotice/qwiknotice_li.gif +0 -0
  126. data/vendor/qwik/share/theme/qwiknotice/qwiknotice_qwik_logo.gif +0 -0
  127. data/vendor/qwik/share/theme/qwikplain/command.gif +0 -0
  128. data/vendor/qwik/share/theme/qwikplain/edit_form_bg.jpg +0 -0
  129. data/vendor/qwik/share/theme/qwikplain/edit_qwik_logo.gif +0 -0
  130. data/vendor/qwik/share/theme/qwikplain/edit_title_bg.jpg +0 -0
  131. data/vendor/qwik/share/theme/qwikplain/login_bg.gif +0 -0
  132. data/vendor/qwik/share/theme/qwikplain/login_qwik_logo.gif +0 -0
  133. data/vendor/qwik/share/theme/qwikplain/qwikplain.css +223 -0
  134. data/vendor/qwik/share/theme/qwikplain/sidebar_bg.gif +0 -0
  135. data/vendor/qwik/share/theme/qwikskelton/qwikskelton.css +224 -0
  136. data/vendor/qwik/share/theme/qwiksystem/qwiksystem.css +323 -0
  137. data/vendor/qwik/share/theme/qwiksystem/qwiksystem_bg.png +0 -0
  138. data/vendor/qwik/share/theme/qwiksystem/qwiksystem_header.png +0 -0
  139. data/vendor/qwik/share/theme/qwiksystem/qwiksystem_headerbar.png +0 -0
  140. data/vendor/qwik/share/theme/qwiksystem/qwiksystem_qwikweb.png +0 -0
  141. data/vendor/qwik/share/theme/qwikviridian/qwikviridian.css +413 -0
  142. data/vendor/qwik/share/theme/qwikviridian/qwikviridian_adminmenu_bg.gif +0 -0
  143. data/vendor/qwik/share/theme/qwikviridian/qwikviridian_bg.gif +0 -0
  144. data/vendor/qwik/share/theme/qwikviridian/qwikviridian_bg_shade.gif +0 -0
  145. data/vendor/qwik/share/theme/qwikviridian/qwikviridian_sidebar_a_bg.gif +0 -0
  146. data/vendor/qwik/share/theme/qwikviridian/qwikviridian_siderbar_li_a.gif +0 -0
  147. data/vendor/qwik/share/theme/s5/blue/bluebg.gif +0 -0
  148. data/vendor/qwik/share/theme/s5/blue/bluebottom.gif +0 -0
  149. data/vendor/qwik/share/theme/s5/blue/bluefooter.gif +0 -0
  150. data/vendor/qwik/share/theme/s5/blue/framing.css +25 -0
  151. data/vendor/qwik/share/theme/s5/blue/pretty.css +91 -0
  152. data/vendor/qwik/share/theme/s5/blue/s5-core.css +11 -0
  153. data/vendor/qwik/share/theme/s5/blue/slides.css +3 -0
  154. data/vendor/qwik/share/theme/s5/default/iepngfix.htc +42 -0
  155. data/vendor/qwik/share/theme/s5/default/opera.css +7 -0
  156. data/vendor/qwik/share/theme/s5/default/outline.css +15 -0
  157. data/vendor/qwik/share/theme/s5/default/print.css +24 -0
  158. data/vendor/qwik/share/theme/s5/default/slides.js +558 -0
  159. data/vendor/qwik/share/theme/s5/flower/blume.jpg +0 -0
  160. data/vendor/qwik/share/theme/s5/flower/blumerechts.jpg +0 -0
  161. data/vendor/qwik/share/theme/s5/flower/framing.css +25 -0
  162. data/vendor/qwik/share/theme/s5/flower/pretty.css +83 -0
  163. data/vendor/qwik/share/theme/s5/flower/s5-core.css +11 -0
  164. data/vendor/qwik/share/theme/s5/flower/slides.css +3 -0
  165. data/vendor/qwik/share/theme/s5/i18n/00_head.txt +8 -0
  166. data/vendor/qwik/share/theme/s5/i18n/bg-shade.png +0 -0
  167. data/vendor/qwik/share/theme/s5/i18n/bg-slide.jpg +0 -0
  168. data/vendor/qwik/share/theme/s5/i18n/framing.css +23 -0
  169. data/vendor/qwik/share/theme/s5/i18n/pretty.css +44 -0
  170. data/vendor/qwik/share/theme/s5/i18n/s5-core.css +9 -0
  171. data/vendor/qwik/share/theme/s5/i18n/slides.css +3 -0
  172. data/vendor/qwik/share/theme/s5/pixel/framing.css +25 -0
  173. data/vendor/qwik/share/theme/s5/pixel/pixelbg.gif +0 -0
  174. data/vendor/qwik/share/theme/s5/pixel/pixelheader.jpg +0 -0
  175. data/vendor/qwik/share/theme/s5/pixel/pixelslide0bg.gif +0 -0
  176. data/vendor/qwik/share/theme/s5/pixel/pretty.css +80 -0
  177. data/vendor/qwik/share/theme/s5/pixel/s5-core.css +11 -0
  178. data/vendor/qwik/share/theme/s5/pixel/slides.css +3 -0
  179. data/vendor/qwik/share/theme/s5/qwikblack/framing.css +23 -0
  180. data/vendor/qwik/share/theme/s5/qwikblack/pretty.css +245 -0
  181. data/vendor/qwik/share/theme/s5/qwikblack/s5-core.css +9 -0
  182. data/vendor/qwik/share/theme/s5/qwikblack/slides.css +3 -0
  183. data/vendor/qwik/share/theme/s5/qwikworld/bg-shade.png +0 -0
  184. data/vendor/qwik/share/theme/s5/qwikworld/bg-slide.jpg +0 -0
  185. data/vendor/qwik/share/theme/s5/qwikworld/framing.css +61 -0
  186. data/vendor/qwik/share/theme/s5/qwikworld/pretty.css +250 -0
  187. data/vendor/qwik/share/theme/s5/qwikworld/qwikcyan_li.png +0 -0
  188. data/vendor/qwik/share/theme/s5/qwikworld/s5-core.css +28 -0
  189. data/vendor/qwik/share/theme/s5/qwikworld/slides.css +3 -0
  190. data/vendor/qwik/share/theme/s5/shell/blank.gif +0 -0
  191. data/vendor/qwik/share/theme/s5/shell/bodybg.gif +0 -0
  192. data/vendor/qwik/share/theme/s5/shell/framing.css +23 -0
  193. data/vendor/qwik/share/theme/s5/shell/pretty.css +86 -0
  194. data/vendor/qwik/share/theme/s5/shell/s5-core.css +9 -0
  195. data/vendor/qwik/share/theme/s5/shell/slides.css +3 -0
  196. metadata +190 -1
@@ -0,0 +1,559 @@
1
+ // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2
+ //
3
+ // See scriptaculous.js for full license.
4
+
5
+ /*--------------------------------------------------------------------------*/
6
+
7
+ var Droppables = {
8
+ drops: [],
9
+
10
+ remove: function(element) {
11
+ this.drops = this.drops.reject(function(d) { return d.element==$(element) });
12
+ },
13
+
14
+ add: function(element) {
15
+ element = $(element);
16
+ var options = Object.extend({
17
+ greedy: true,
18
+ hoverclass: null
19
+ }, arguments[1] || {});
20
+
21
+ // cache containers
22
+ if(options.containment) {
23
+ options._containers = [];
24
+ var containment = options.containment;
25
+ if((typeof containment == 'object') &&
26
+ (containment.constructor == Array)) {
27
+ containment.each( function(c) { options._containers.push($(c)) });
28
+ } else {
29
+ options._containers.push($(containment));
30
+ }
31
+ }
32
+
33
+ if(options.accept) options.accept = [options.accept].flatten();
34
+
35
+ Element.makePositioned(element); // fix IE
36
+ options.element = element;
37
+
38
+ this.drops.push(options);
39
+ },
40
+
41
+ isContained: function(element, drop) {
42
+ var parentNode = element.parentNode;
43
+ return drop._containers.detect(function(c) { return parentNode == c });
44
+ },
45
+
46
+ isAffected: function(pX, pY, element, drop) {
47
+ return (
48
+ (drop.element!=element) &&
49
+ ((!drop._containers) ||
50
+ this.isContained(element, drop)) &&
51
+ ((!drop.accept) ||
52
+ (Element.classNames(element).detect(
53
+ function(v) { return drop.accept.include(v) } ) )) &&
54
+ Position.within(drop.element, pX, pY) );
55
+ },
56
+
57
+ deactivate: function(drop) {
58
+ if(drop.hoverclass)
59
+ Element.removeClassName(drop.element, drop.hoverclass);
60
+ this.last_active = null;
61
+ },
62
+
63
+ activate: function(drop) {
64
+ if(this.last_active) this.deactivate(this.last_active);
65
+ if(drop.hoverclass)
66
+ Element.addClassName(drop.element, drop.hoverclass);
67
+ this.last_active = drop;
68
+ },
69
+
70
+ show: function(event, element) {
71
+ if(!this.drops.length) return;
72
+ var pX = Event.pointerX(event);
73
+ var pY = Event.pointerY(event);
74
+ Position.prepare();
75
+
76
+ var i = this.drops.length-1; do {
77
+ var drop = this.drops[i];
78
+ if(this.isAffected(pX, pY, element, drop)) {
79
+ if(drop.onHover)
80
+ drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
81
+ if(drop.greedy) {
82
+ this.activate(drop);
83
+ return;
84
+ }
85
+ }
86
+ } while (i--);
87
+
88
+ if(this.last_active) this.deactivate(this.last_active);
89
+ },
90
+
91
+ fire: function(event, element) {
92
+ if(!this.last_active) return;
93
+ Position.prepare();
94
+
95
+ if (this.isAffected(Event.pointerX(event), Event.pointerY(event), element, this.last_active))
96
+ if (this.last_active.onDrop)
97
+ this.last_active.onDrop(element, this.last_active.element, event);
98
+ },
99
+
100
+ reset: function() {
101
+ if(this.last_active)
102
+ this.deactivate(this.last_active);
103
+ }
104
+ }
105
+
106
+ var Draggables = {
107
+ observers: [],
108
+ addObserver: function(observer) {
109
+ this.observers.push(observer);
110
+ this._cacheObserverCallbacks();
111
+ },
112
+ removeObserver: function(element) { // element instead of observer fixes mem leaks
113
+ this.observers = this.observers.reject( function(o) { return o.element==element });
114
+ this._cacheObserverCallbacks();
115
+ },
116
+ notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
117
+ if(this[eventName+'Count'] > 0)
118
+ this.observers.each( function(o) {
119
+ if(o[eventName]) o[eventName](eventName, draggable, event);
120
+ });
121
+ },
122
+ _cacheObserverCallbacks: function() {
123
+ ['onStart','onEnd','onDrag'].each( function(eventName) {
124
+ Draggables[eventName+'Count'] = Draggables.observers.select(
125
+ function(o) { return o[eventName]; }
126
+ ).length;
127
+ });
128
+ }
129
+ }
130
+
131
+ /*--------------------------------------------------------------------------*/
132
+
133
+ var Draggable = Class.create();
134
+ Draggable.prototype = {
135
+ initialize: function(element) {
136
+ var options = Object.extend({
137
+ handle: false,
138
+ starteffect: function(element) {
139
+ new Effect.Opacity(element, {duration:0.2, from:1.0, to:0.7});
140
+ },
141
+ reverteffect: function(element, top_offset, left_offset) {
142
+ var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
143
+ new Effect.MoveBy(element, -top_offset, -left_offset, {duration:dur});
144
+ },
145
+ endeffect: function(element) {
146
+ new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0});
147
+ },
148
+ zindex: 1000,
149
+ revert: false,
150
+ snap: false // false, or xy or [x,y] or function(x,y){ return [x,y] }
151
+ }, arguments[1] || {});
152
+
153
+ this.element = $(element);
154
+ if(options.handle && (typeof options.handle == 'string'))
155
+ this.handle = Element.childrenWithClassName(this.element, options.handle)[0];
156
+
157
+ if(!this.handle) this.handle = $(options.handle);
158
+ if(!this.handle) this.handle = this.element;
159
+
160
+ Element.makePositioned(this.element); // fix IE
161
+
162
+ this.offsetX = 0;
163
+ this.offsetY = 0;
164
+ this.originalLeft = this.currentLeft();
165
+ this.originalTop = this.currentTop();
166
+ this.originalX = this.element.offsetLeft;
167
+ this.originalY = this.element.offsetTop;
168
+
169
+ this.options = options;
170
+
171
+ this.active = false;
172
+ this.dragging = false;
173
+
174
+ this.eventMouseDown = this.startDrag.bindAsEventListener(this);
175
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
176
+ this.eventMouseMove = this.update.bindAsEventListener(this);
177
+ this.eventKeypress = this.keyPress.bindAsEventListener(this);
178
+
179
+ this.registerEvents();
180
+ },
181
+ destroy: function() {
182
+ Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
183
+ this.unregisterEvents();
184
+ },
185
+ registerEvents: function() {
186
+ Event.observe(document, "mouseup", this.eventMouseUp);
187
+ Event.observe(document, "mousemove", this.eventMouseMove);
188
+ Event.observe(document, "keypress", this.eventKeypress);
189
+ Event.observe(this.handle, "mousedown", this.eventMouseDown);
190
+ },
191
+ unregisterEvents: function() {
192
+ //if(!this.active) return;
193
+ //Event.stopObserving(document, "mouseup", this.eventMouseUp);
194
+ //Event.stopObserving(document, "mousemove", this.eventMouseMove);
195
+ //Event.stopObserving(document, "keypress", this.eventKeypress);
196
+ },
197
+ currentLeft: function() {
198
+ return parseInt(this.element.style.left || '0');
199
+ },
200
+ currentTop: function() {
201
+ return parseInt(this.element.style.top || '0')
202
+ },
203
+ startDrag: function(event) {
204
+ if(Event.isLeftClick(event)) {
205
+
206
+ // abort on form elements, fixes a Firefox issue
207
+ var src = Event.element(event);
208
+ if(src.tagName && (
209
+ src.tagName=='INPUT' ||
210
+ src.tagName=='SELECT' ||
211
+ src.tagName=='BUTTON' ||
212
+ src.tagName=='TEXTAREA')) return;
213
+
214
+ // this.registerEvents();
215
+ this.active = true;
216
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
217
+ var offsets = Position.cumulativeOffset(this.element);
218
+ this.offsetX = (pointer[0] - offsets[0]);
219
+ this.offsetY = (pointer[1] - offsets[1]);
220
+ Event.stop(event);
221
+ }
222
+ },
223
+ finishDrag: function(event, success) {
224
+ // this.unregisterEvents();
225
+
226
+ this.active = false;
227
+ this.dragging = false;
228
+
229
+ if(this.options.ghosting) {
230
+ Position.relativize(this.element);
231
+ Element.remove(this._clone);
232
+ this._clone = null;
233
+ }
234
+
235
+ if(success) Droppables.fire(event, this.element);
236
+ Draggables.notify('onEnd', this, event);
237
+
238
+ var revert = this.options.revert;
239
+ if(revert && typeof revert == 'function') revert = revert(this.element);
240
+
241
+ if(revert && this.options.reverteffect) {
242
+ this.options.reverteffect(this.element,
243
+ this.currentTop()-this.originalTop,
244
+ this.currentLeft()-this.originalLeft);
245
+ } else {
246
+ this.originalLeft = this.currentLeft();
247
+ this.originalTop = this.currentTop();
248
+ }
249
+
250
+ if(this.options.zindex)
251
+ this.element.style.zIndex = this.originalZ;
252
+
253
+ if(this.options.endeffect)
254
+ this.options.endeffect(this.element);
255
+
256
+
257
+ Droppables.reset();
258
+ },
259
+ keyPress: function(event) {
260
+ if(this.active) {
261
+ if(event.keyCode==Event.KEY_ESC) {
262
+ this.finishDrag(event, false);
263
+ Event.stop(event);
264
+ }
265
+ }
266
+ },
267
+ endDrag: function(event) {
268
+ if(this.active && this.dragging) {
269
+ this.finishDrag(event, true);
270
+ Event.stop(event);
271
+ }
272
+ this.active = false;
273
+ this.dragging = false;
274
+ },
275
+ draw: function(event) {
276
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
277
+ var offsets = Position.cumulativeOffset(this.element);
278
+ offsets[0] -= this.currentLeft();
279
+ offsets[1] -= this.currentTop();
280
+ var style = this.element.style;
281
+
282
+ var pos = [
283
+ (pointer[0] - offsets[0] - this.offsetX),
284
+ (pointer[1] - offsets[1] - this.offsetY)];
285
+
286
+ if(this.options.snap) {
287
+ if(typeof this.options.snap == 'function') {
288
+ pos = this.options.snap(pos[0],pos[1]);
289
+ } else {
290
+ var draggable = this;
291
+ if(this.options.snap instanceof Array) {
292
+ pos = pos.collect( function(v, i) {
293
+ return Math.round(v/draggable.options.snap[i])*draggable.options.snap[i] })
294
+ } else {
295
+ pos = pos.collect( function(v) {
296
+ return Math.round(v/draggable.options.snap)*draggable.options.snap })
297
+ }
298
+ }}
299
+
300
+ if((!this.options.constraint) || (this.options.constraint=='horizontal'))
301
+ style.left = pos[0] + "px";
302
+ if((!this.options.constraint) || (this.options.constraint=='vertical'))
303
+ style.top = pos[1] + "px";
304
+ if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
305
+ },
306
+ update: function(event) {
307
+ if(this.active) {
308
+ if(!this.dragging) {
309
+ var style = this.element.style;
310
+ this.dragging = true;
311
+
312
+ if(Element.getStyle(this.element,'position')=='')
313
+ style.position = "relative";
314
+
315
+ if(this.options.zindex) {
316
+ this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
317
+ style.zIndex = this.options.zindex;
318
+ }
319
+
320
+ if(this.options.ghosting) {
321
+ this._clone = this.element.cloneNode(true);
322
+ Position.absolutize(this.element);
323
+ this.element.parentNode.insertBefore(this._clone, this.element);
324
+ }
325
+
326
+ Draggables.notify('onStart', this, event);
327
+ if(this.options.starteffect) this.options.starteffect(this.element);
328
+ }
329
+
330
+ Droppables.show(event, this.element);
331
+ Draggables.notify('onDrag', this, event);
332
+ this.draw(event);
333
+ if(this.options.change) this.options.change(this);
334
+
335
+ // fix AppleWebKit rendering
336
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
337
+
338
+ Event.stop(event);
339
+ }
340
+ }
341
+ }
342
+
343
+ /*--------------------------------------------------------------------------*/
344
+
345
+ var SortableObserver = Class.create();
346
+ SortableObserver.prototype = {
347
+ initialize: function(element, observer) {
348
+ this.element = $(element);
349
+ this.observer = observer;
350
+ this.lastValue = Sortable.serialize(this.element);
351
+ },
352
+ onStart: function() {
353
+ this.lastValue = Sortable.serialize(this.element);
354
+ },
355
+ onEnd: function() {
356
+ Sortable.unmark();
357
+ if(this.lastValue != Sortable.serialize(this.element))
358
+ this.observer(this.element)
359
+ }
360
+ }
361
+
362
+ var Sortable = {
363
+ sortables: new Array(),
364
+ options: function(element){
365
+ element = $(element);
366
+ return this.sortables.detect(function(s) { return s.element == element });
367
+ },
368
+ destroy: function(element){
369
+ element = $(element);
370
+ this.sortables.findAll(function(s) { return s.element == element }).each(function(s){
371
+ Draggables.removeObserver(s.element);
372
+ s.droppables.each(function(d){ Droppables.remove(d) });
373
+ s.draggables.invoke('destroy');
374
+ });
375
+ this.sortables = this.sortables.reject(function(s) { return s.element == element });
376
+ },
377
+ create: function(element) {
378
+ element = $(element);
379
+ var options = Object.extend({
380
+ element: element,
381
+ tag: 'li', // assumes li children, override with tag: 'tagname'
382
+ dropOnEmpty: false,
383
+ tree: false, // fixme: unimplemented
384
+ overlap: 'vertical', // one of 'vertical', 'horizontal'
385
+ constraint: 'vertical', // one of 'vertical', 'horizontal', false
386
+ containment: element, // also takes array of elements (or id's); or false
387
+ handle: false, // or a CSS class
388
+ only: false,
389
+ hoverclass: null,
390
+ ghosting: false,
391
+ format: null,
392
+ onChange: Prototype.emptyFunction,
393
+ onUpdate: Prototype.emptyFunction
394
+ }, arguments[1] || {});
395
+
396
+ // clear any old sortable with same element
397
+ this.destroy(element);
398
+
399
+ // build options for the draggables
400
+ var options_for_draggable = {
401
+ revert: true,
402
+ ghosting: options.ghosting,
403
+ constraint: options.constraint,
404
+ handle: options.handle };
405
+
406
+ if(options.starteffect)
407
+ options_for_draggable.starteffect = options.starteffect;
408
+
409
+ if(options.reverteffect)
410
+ options_for_draggable.reverteffect = options.reverteffect;
411
+ else
412
+ if(options.ghosting) options_for_draggable.reverteffect = function(element) {
413
+ element.style.top = 0;
414
+ element.style.left = 0;
415
+ };
416
+
417
+ if(options.endeffect)
418
+ options_for_draggable.endeffect = options.endeffect;
419
+
420
+ if(options.zindex)
421
+ options_for_draggable.zindex = options.zindex;
422
+
423
+ // build options for the droppables
424
+ var options_for_droppable = {
425
+ overlap: options.overlap,
426
+ containment: options.containment,
427
+ hoverclass: options.hoverclass,
428
+ onHover: Sortable.onHover,
429
+ greedy: !options.dropOnEmpty
430
+ }
431
+
432
+ // fix for gecko engine
433
+ Element.cleanWhitespace(element);
434
+
435
+ options.draggables = [];
436
+ options.droppables = [];
437
+
438
+ // make it so
439
+
440
+ // drop on empty handling
441
+ if(options.dropOnEmpty) {
442
+ Droppables.add(element,
443
+ {containment: options.containment, onHover: Sortable.onEmptyHover, greedy: false});
444
+ options.droppables.push(element);
445
+ }
446
+
447
+ (this.findElements(element, options) || []).each( function(e) {
448
+ // handles are per-draggable
449
+ var handle = options.handle ?
450
+ Element.childrenWithClassName(e, options.handle)[0] : e;
451
+ options.draggables.push(
452
+ new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
453
+ Droppables.add(e, options_for_droppable);
454
+ options.droppables.push(e);
455
+ });
456
+
457
+ // keep reference
458
+ this.sortables.push(options);
459
+
460
+ // for onupdate
461
+ Draggables.addObserver(new SortableObserver(element, options.onUpdate));
462
+
463
+ },
464
+
465
+ // return all suitable-for-sortable elements in a guaranteed order
466
+ findElements: function(element, options) {
467
+ if(!element.hasChildNodes()) return null;
468
+ var elements = [];
469
+ $A(element.childNodes).each( function(e) {
470
+ if(e.tagName && e.tagName==options.tag.toUpperCase() &&
471
+ (!options.only || (Element.hasClassName(e, options.only))))
472
+ elements.push(e);
473
+ if(options.tree) {
474
+ var grandchildren = this.findElements(e, options);
475
+ if(grandchildren) elements.push(grandchildren);
476
+ }
477
+ });
478
+
479
+ return (elements.length>0 ? elements.flatten() : null);
480
+ },
481
+
482
+ onHover: function(element, dropon, overlap) {
483
+ if(overlap>0.5) {
484
+ Sortable.mark(dropon, 'before');
485
+ if(dropon.previousSibling != element) {
486
+ var oldParentNode = element.parentNode;
487
+ element.style.visibility = "hidden"; // fix gecko rendering
488
+ dropon.parentNode.insertBefore(element, dropon);
489
+ if(dropon.parentNode!=oldParentNode)
490
+ Sortable.options(oldParentNode).onChange(element);
491
+ Sortable.options(dropon.parentNode).onChange(element);
492
+ }
493
+ } else {
494
+ Sortable.mark(dropon, 'after');
495
+ var nextElement = dropon.nextSibling || null;
496
+ if(nextElement != element) {
497
+ var oldParentNode = element.parentNode;
498
+ element.style.visibility = "hidden"; // fix gecko rendering
499
+ dropon.parentNode.insertBefore(element, nextElement);
500
+ if(dropon.parentNode!=oldParentNode)
501
+ Sortable.options(oldParentNode).onChange(element);
502
+ Sortable.options(dropon.parentNode).onChange(element);
503
+ }
504
+ }
505
+ },
506
+
507
+ onEmptyHover: function(element, dropon) {
508
+ if(element.parentNode!=dropon) {
509
+ var oldParentNode = element.parentNode;
510
+ dropon.appendChild(element);
511
+ Sortable.options(oldParentNode).onChange(element);
512
+ Sortable.options(dropon).onChange(element);
513
+ }
514
+ },
515
+
516
+ unmark: function() {
517
+ if(Sortable._marker) Element.hide(Sortable._marker);
518
+ },
519
+
520
+ mark: function(dropon, position) {
521
+ // mark on ghosting only
522
+ var sortable = Sortable.options(dropon.parentNode);
523
+ if(sortable && !sortable.ghosting) return;
524
+
525
+ if(!Sortable._marker) {
526
+ Sortable._marker = $('dropmarker') || document.createElement('DIV');
527
+ Element.hide(Sortable._marker);
528
+ Element.addClassName(Sortable._marker, 'dropmarker');
529
+ Sortable._marker.style.position = 'absolute';
530
+ document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
531
+ }
532
+ var offsets = Position.cumulativeOffset(dropon);
533
+ Sortable._marker.style.left = offsets[0] + 'px';
534
+ Sortable._marker.style.top = offsets[1] + 'px';
535
+
536
+ if(position=='after')
537
+ if(sortable.overlap == 'horizontal')
538
+ Sortable._marker.style.left = (offsets[0]+dropon.clientWidth) + 'px';
539
+ else
540
+ Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px';
541
+
542
+ Element.show(Sortable._marker);
543
+ },
544
+
545
+ serialize: function(element) {
546
+ element = $(element);
547
+ var sortableOptions = this.options(element);
548
+ var options = Object.extend({
549
+ tag: sortableOptions.tag,
550
+ only: sortableOptions.only,
551
+ name: element.id,
552
+ format: sortableOptions.format || /^[^_]*_(.*)$/
553
+ }, arguments[1] || {});
554
+ return $(this.findElements(element, options) || []).collect( function(item) {
555
+ return (encodeURIComponent(options.name) + "[]=" +
556
+ encodeURIComponent(item.id.match(options.format) ? item.id.match(options.format)[1] : ''));
557
+ }).join("&");
558
+ }
559
+ }