kiteditor 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/LICENSE +25 -0
  2. data/app/controllers/mercury/images_controller.rb +5 -0
  3. data/app/controllers/mercury_controller.rb +34 -0
  4. data/app/models/mercury/image.rb +17 -0
  5. data/app/views/layouts/mercury.html.erb +33 -0
  6. data/app/views/layouts/popup.html.haml +9 -0
  7. data/app/views/mercury/images/_list.html.haml +22 -0
  8. data/app/views/mercury/images/index.html.haml +4 -0
  9. data/app/views/mercury/images/index.js.erb +2 -0
  10. data/app/views/mercury/lightviews/about.html +11 -0
  11. data/app/views/mercury/modals/character.html +255 -0
  12. data/app/views/mercury/modals/htmleditor.html +13 -0
  13. data/app/views/mercury/modals/link.html +94 -0
  14. data/app/views/mercury/modals/media.html +1 -0
  15. data/app/views/mercury/modals/table.html +84 -0
  16. data/app/views/mercury/palettes/backcolor.html +73 -0
  17. data/app/views/mercury/palettes/forecolor.html +73 -0
  18. data/app/views/mercury/panels/history.html +3 -0
  19. data/app/views/mercury/panels/notes.html +3 -0
  20. data/app/views/mercury/panels/snippets.html +12 -0
  21. data/app/views/mercury/selects/formatblock.html +11 -0
  22. data/app/views/mercury/selects/style.html +5 -0
  23. data/app/views/mercury/snippets/example/options.html.erb +34 -0
  24. data/app/views/mercury/snippets/example/preview.html.erb +1 -0
  25. data/config/engine.rb +44 -0
  26. data/db/migrate/20110526035601_create_mercury_images.rb +11 -0
  27. data/features/loading/loading.feature +22 -0
  28. data/features/loading/navigating.feature +77 -0
  29. data/features/loading/user_interface.feature +67 -0
  30. data/features/regions/editable/advanced_editing.feature +0 -0
  31. data/features/regions/editable/basic_editing.feature +195 -0
  32. data/features/regions/editable/inserting_links.feature +98 -0
  33. data/features/regions/editable/inserting_media.feature +110 -0
  34. data/features/regions/editable/inserting_snippets.feature +102 -0
  35. data/features/regions/editable/inserting_special_characters.feature +24 -0
  36. data/features/regions/editable/inserting_tables.feature +109 -0
  37. data/features/regions/editable/pasting.feature +0 -0
  38. data/features/regions/editable/uploading_images.feature +0 -0
  39. data/features/regions/markupable/advanced_editing.feature +0 -0
  40. data/features/regions/markupable/basic_editing.feature +0 -0
  41. data/features/regions/markupable/inserting_links.feature +0 -0
  42. data/features/regions/markupable/inserting_media.feature +0 -0
  43. data/features/regions/markupable/inserting_snippets.feature +0 -0
  44. data/features/regions/markupable/inserting_special_characters.feature +0 -0
  45. data/features/regions/markupable/inserting_tables.feature +0 -0
  46. data/features/regions/markupable/uploading_images.feature +0 -0
  47. data/features/regions/snippetable/advanced_editing.feature +0 -0
  48. data/features/regions/snippetable/basic_editing.feature +0 -0
  49. data/features/regions/snippetable/inserting_snippets.feature +0 -0
  50. data/features/saving/saving.feature +33 -0
  51. data/features/step_definitions/debug_steps.rb +14 -0
  52. data/features/step_definitions/mercury_steps.rb +438 -0
  53. data/features/step_definitions/web_steps.rb +211 -0
  54. data/features/support/env.rb +46 -0
  55. data/features/support/mercury_contents.rb +25 -0
  56. data/features/support/mercury_selectors.rb +148 -0
  57. data/features/support/paths.rb +38 -0
  58. data/features/support/selectors.rb +44 -0
  59. data/lib/generators/mercury/install/install_generator.rb +49 -0
  60. data/lib/generators/mercury/install/templates/mongoid_paperclip_image.rb +17 -0
  61. data/lib/mercury/authentication.rb +8 -0
  62. data/lib/mercury-rails.rb +3 -0
  63. data/spec/javascripts/mercury/dialog_spec.js.coffee +281 -0
  64. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +37 -0
  65. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +37 -0
  66. data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +25 -0
  67. data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +30 -0
  68. data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +25 -0
  69. data/spec/javascripts/mercury/history_buffer_spec.js.coffee +76 -0
  70. data/spec/javascripts/mercury/lightview_spec.js.coffee +497 -0
  71. data/spec/javascripts/mercury/mercury_spec.js.coffee +132 -0
  72. data/spec/javascripts/mercury/modal_spec.js.coffee +504 -0
  73. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +30 -0
  74. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +29 -0
  75. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +220 -0
  76. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +167 -0
  77. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +52 -0
  78. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +160 -0
  79. data/spec/javascripts/mercury/native_extensions_spec.js.coffee +60 -0
  80. data/spec/javascripts/mercury/page_editor_spec.js.coffee +750 -0
  81. data/spec/javascripts/mercury/palette_spec.js.coffee +49 -0
  82. data/spec/javascripts/mercury/panel_spec.js.coffee +185 -0
  83. data/spec/javascripts/mercury/region_spec.js.coffee +298 -0
  84. data/spec/javascripts/mercury/regions/editable_spec.js.coffee +561 -0
  85. data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +367 -0
  86. data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +370 -0
  87. data/spec/javascripts/mercury/select_spec.js.coffee +49 -0
  88. data/spec/javascripts/mercury/snippet_spec.js.coffee +245 -0
  89. data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +184 -0
  90. data/spec/javascripts/mercury/statusbar_spec.js.coffee +150 -0
  91. data/spec/javascripts/mercury/table_editor_spec.js.coffee +194 -0
  92. data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +90 -0
  93. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +360 -0
  94. data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +118 -0
  95. data/spec/javascripts/mercury/toolbar_spec.js.coffee +222 -0
  96. data/spec/javascripts/mercury/tooltip_spec.js.coffee +186 -0
  97. data/spec/javascripts/mercury/uploader_spec.js.coffee +514 -0
  98. data/spec/javascripts/spec_helper.js +513 -0
  99. data/spec/javascripts/templates/mercury/dialog.html +2 -0
  100. data/spec/javascripts/templates/mercury/dialogs/backcolor.html +5 -0
  101. data/spec/javascripts/templates/mercury/dialogs/forecolor.html +5 -0
  102. data/spec/javascripts/templates/mercury/dialogs/formatblock.html +3 -0
  103. data/spec/javascripts/templates/mercury/dialogs/snippetpanel.html +16 -0
  104. data/spec/javascripts/templates/mercury/dialogs/style.html +3 -0
  105. data/spec/javascripts/templates/mercury/lightview.html +13 -0
  106. data/spec/javascripts/templates/mercury/modal.html +13 -0
  107. data/spec/javascripts/templates/mercury/modals/htmleditor.html +5 -0
  108. data/spec/javascripts/templates/mercury/modals/insertcharacter.html +5 -0
  109. data/spec/javascripts/templates/mercury/modals/insertlink.html +30 -0
  110. data/spec/javascripts/templates/mercury/modals/insertmedia.html +35 -0
  111. data/spec/javascripts/templates/mercury/modals/insertsnippet.html +6 -0
  112. data/spec/javascripts/templates/mercury/modals/inserttable.html +27 -0
  113. data/spec/javascripts/templates/mercury/page_editor.html +35 -0
  114. data/spec/javascripts/templates/mercury/palette.html +16 -0
  115. data/spec/javascripts/templates/mercury/panel.html +16 -0
  116. data/spec/javascripts/templates/mercury/region.html +2 -0
  117. data/spec/javascripts/templates/mercury/regions/editable.html +3 -0
  118. data/spec/javascripts/templates/mercury/regions/snippetable.html +4 -0
  119. data/spec/javascripts/templates/mercury/select.html +16 -0
  120. data/spec/javascripts/templates/mercury/snippet.html +1 -0
  121. data/spec/javascripts/templates/mercury/snippet_toolbar.html +16 -0
  122. data/spec/javascripts/templates/mercury/statusbar.html +8 -0
  123. data/spec/javascripts/templates/mercury/table_editor.html +65 -0
  124. data/spec/javascripts/templates/mercury/toolbar.button.html +64 -0
  125. data/spec/javascripts/templates/mercury/toolbar.button_group.html +9 -0
  126. data/spec/javascripts/templates/mercury/toolbar.expander.html +18 -0
  127. data/spec/javascripts/templates/mercury/toolbar.html +11 -0
  128. data/spec/javascripts/templates/mercury/tooltip.html +12 -0
  129. data/spec/javascripts/templates/mercury/uploader.html +11 -0
  130. data/vendor/assets/images/mercury/button.png +0 -0
  131. data/vendor/assets/images/mercury/close.png +0 -0
  132. data/vendor/assets/images/mercury/default-snippet.png +0 -0
  133. data/vendor/assets/images/mercury/loading-dark.gif +0 -0
  134. data/vendor/assets/images/mercury/loading-light.gif +0 -0
  135. data/vendor/assets/images/mercury/missing-image.png +0 -0
  136. data/vendor/assets/images/mercury/search-icon.png +0 -0
  137. data/vendor/assets/images/mercury/temp-logo.png +0 -0
  138. data/vendor/assets/images/mercury/toolbar/editable/buttons.png +0 -0
  139. data/vendor/assets/images/mercury/toolbar/primary/_expander.png +0 -0
  140. data/vendor/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
  141. data/vendor/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
  142. data/vendor/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
  143. data/vendor/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
  144. data/vendor/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
  145. data/vendor/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
  146. data/vendor/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
  147. data/vendor/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
  148. data/vendor/assets/images/mercury/toolbar/primary/preview.png +0 -0
  149. data/vendor/assets/images/mercury/toolbar/primary/redo.png +0 -0
  150. data/vendor/assets/images/mercury/toolbar/primary/save.png +0 -0
  151. data/vendor/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
  152. data/vendor/assets/images/mercury/toolbar/primary/undo.png +0 -0
  153. data/vendor/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
  154. data/vendor/assets/javascripts/mercury/dependencies/jquery-1.7.js +9300 -0
  155. data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +1328 -0
  156. data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.18.custom.min.js +356 -0
  157. data/vendor/assets/javascripts/mercury/dependencies/jquery-ui.1.8.13.custom.min.js +356 -0
  158. data/vendor/assets/javascripts/mercury/dependencies/jquery.additions.js +206 -0
  159. data/vendor/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +527 -0
  160. data/vendor/assets/javascripts/mercury/dependencies/liquidmetal.js +88 -0
  161. data/vendor/assets/javascripts/mercury/dependencies/showdown.js +1340 -0
  162. data/vendor/assets/javascripts/mercury/dialog.js.coffee +159 -0
  163. data/vendor/assets/javascripts/mercury/dialogs/backcolor.js.coffee +6 -0
  164. data/vendor/assets/javascripts/mercury/dialogs/forecolor.js.coffee +6 -0
  165. data/vendor/assets/javascripts/mercury/dialogs/formatblock.js.coffee +4 -0
  166. data/vendor/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +10 -0
  167. data/vendor/assets/javascripts/mercury/dialogs/style.js.coffee +4 -0
  168. data/vendor/assets/javascripts/mercury/finalize.js.coffee +3 -0
  169. data/vendor/assets/javascripts/mercury/history_buffer.js.coffee +30 -0
  170. data/vendor/assets/javascripts/mercury/lightview.js.coffee +205 -0
  171. data/vendor/assets/javascripts/mercury/locales/da.locale.js.coffee +0 -0
  172. data/vendor/assets/javascripts/mercury/locales/de.locale.js.coffee +206 -0
  173. data/vendor/assets/javascripts/mercury/locales/es.locale.js.coffee +211 -0
  174. data/vendor/assets/javascripts/mercury/locales/example.local.js.coffee +211 -0
  175. data/vendor/assets/javascripts/mercury/locales/fr.locale.js.coffee +211 -0
  176. data/vendor/assets/javascripts/mercury/locales/it.locale.js.coffee +208 -0
  177. data/vendor/assets/javascripts/mercury/locales/ko.local.js.coffee +206 -0
  178. data/vendor/assets/javascripts/mercury/locales/nl.locale.js.coffee +206 -0
  179. data/vendor/assets/javascripts/mercury/locales/pt.locale.js.coffee +211 -0
  180. data/vendor/assets/javascripts/mercury/locales/sv.local.js.coffee +209 -0
  181. data/vendor/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +213 -0
  182. data/vendor/assets/javascripts/mercury/mercury.js.coffee +109 -0
  183. data/vendor/assets/javascripts/mercury/modal.js.coffee +204 -0
  184. data/vendor/assets/javascripts/mercury/modals/htmleditor.js.coffee +11 -0
  185. data/vendor/assets/javascripts/mercury/modals/insertcharacter.js.coffee +4 -0
  186. data/vendor/assets/javascripts/mercury/modals/insertlink.js.coffee +95 -0
  187. data/vendor/assets/javascripts/mercury/modals/insertmedia.js.coffee +107 -0
  188. data/vendor/assets/javascripts/mercury/modals/insertsnippet.js.coffee +12 -0
  189. data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +54 -0
  190. data/vendor/assets/javascripts/mercury/native_extensions.js.coffee +55 -0
  191. data/vendor/assets/javascripts/mercury/page_editor.js.coffee +241 -0
  192. data/vendor/assets/javascripts/mercury/palette.js.coffee +29 -0
  193. data/vendor/assets/javascripts/mercury/panel.js.coffee +115 -0
  194. data/vendor/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +28 -0
  195. data/vendor/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +9 -0
  196. data/vendor/assets/javascripts/mercury/region.js.coffee +107 -0
  197. data/vendor/assets/javascripts/mercury/regions/editable.js.coffee +600 -0
  198. data/vendor/assets/javascripts/mercury/regions/markupable.js.coffee +398 -0
  199. data/vendor/assets/javascripts/mercury/regions/simple.js.coffee +339 -0
  200. data/vendor/assets/javascripts/mercury/regions/snippetable.js.coffee +124 -0
  201. data/vendor/assets/javascripts/mercury/select.js.coffee +44 -0
  202. data/vendor/assets/javascripts/mercury/snippet.js.coffee +104 -0
  203. data/vendor/assets/javascripts/mercury/snippet_toolbar.js.coffee +72 -0
  204. data/vendor/assets/javascripts/mercury/statusbar.js.coffee +51 -0
  205. data/vendor/assets/javascripts/mercury/support/history.js +1 -0
  206. data/vendor/assets/javascripts/mercury/table_editor.js.coffee +265 -0
  207. data/vendor/assets/javascripts/mercury/toolbar.button.js.coffee +173 -0
  208. data/vendor/assets/javascripts/mercury/toolbar.button_group.js.coffee +42 -0
  209. data/vendor/assets/javascripts/mercury/toolbar.expander.js.coffee +56 -0
  210. data/vendor/assets/javascripts/mercury/toolbar.js.coffee +86 -0
  211. data/vendor/assets/javascripts/mercury/tooltip.js.coffee +74 -0
  212. data/vendor/assets/javascripts/mercury/uploader.js.coffee +227 -0
  213. data/vendor/assets/javascripts/mercury.js +479 -0
  214. data/vendor/assets/javascripts/mercury_loader.js +193 -0
  215. data/vendor/assets/javascripts/mercury_overrides.js +6 -0
  216. data/vendor/assets/javascripts/popup.js +8 -0
  217. data/vendor/assets/stylesheets/mercury/all_images.css.erb +89 -0
  218. data/vendor/assets/stylesheets/mercury/dialog.css +208 -0
  219. data/vendor/assets/stylesheets/mercury/lightview.css +151 -0
  220. data/vendor/assets/stylesheets/mercury/mercury.css +151 -0
  221. data/vendor/assets/stylesheets/mercury/modal.css +183 -0
  222. data/vendor/assets/stylesheets/mercury/statusbar.css +32 -0
  223. data/vendor/assets/stylesheets/mercury/toolbar.css +304 -0
  224. data/vendor/assets/stylesheets/mercury/tooltip.css +26 -0
  225. data/vendor/assets/stylesheets/mercury/uploader.css +111 -0
  226. data/vendor/assets/stylesheets/mercury.css +28 -0
  227. data/vendor/assets/stylesheets/mercury_overrides.css +17 -0
  228. data/vendor/assets/stylesheets/popup.css.erb +37 -0
  229. metadata +634 -0
@@ -0,0 +1,513 @@
1
+ require('/assets/mercury.js');
2
+
3
+ jasmine.simulate = {
4
+
5
+ /**
6
+ * Simulates a key event using the given event information to populate
7
+ * the generated event object. This method does browser-equalizing
8
+ * calculations to account for differences in the DOM and IE event models
9
+ * as well as different browser quirks. Note: keydown causes Safari 2.x to
10
+ * crash.
11
+ *
12
+ * @param {HTMLElement} target The target of the given event.
13
+ * @param {String} type The type of event to fire. This can be any one of
14
+ * the following: keyup, keydown, and keypress.
15
+ * @param {Boolean} bubbles (Optional) Indicates if the event can be
16
+ * bubbled up. DOM Level 3 specifies that all key events bubble by
17
+ * default. The default is true.
18
+ * @param {Boolean} cancelable (Optional) Indicates if the event can be
19
+ * canceled using preventDefault(). DOM Level 3 specifies that all
20
+ * key events can be cancelled. The default
21
+ * is true.
22
+ * @param {Window} view (Optional) The view containing the target. This is
23
+ * typically the window object. The default is window.
24
+ * @param {Boolean} ctrlKey (Optional) Indicates if one of the CTRL keys
25
+ * is pressed while the event is firing. The default is false.
26
+ * @param {Boolean} altKey (Optional) Indicates if one of the ALT keys
27
+ * is pressed while the event is firing. The default is false.
28
+ * @param {Boolean} shiftKey (Optional) Indicates if one of the SHIFT keys
29
+ * is pressed while the event is firing. The default is false.
30
+ * @param {Boolean} metaKey (Optional) Indicates if one of the META keys
31
+ * is pressed while the event is firing. The default is false.
32
+ * @param {int} keyCode (Optional) The code for the key that is in use.
33
+ * The default is 0.
34
+ * @param {int} charCode (Optional) The Unicode code for the character
35
+ * associated with the key being used. The default is 0.
36
+ * @static
37
+ */
38
+ keyEvent: function (target, type, bubbles, cancelable, view, ctrlKey, altKey, shiftKey, metaKey, keyCode, charCode) {
39
+ if (!target) throw('simulateKeyEvent(): Invalid target.');
40
+ if (typeof(type) != 'string') throw('simulateKeyEvent(): Event type must be a string.');
41
+
42
+ type = type.toLowerCase();
43
+ switch(type) {
44
+ case 'keyup':
45
+ case 'keydown':
46
+ case 'keypress':
47
+ break;
48
+ case 'textevent': // DOM Level 3
49
+ type = 'keypress';
50
+ break;
51
+ default: throw("simulateKeyEvent(): Event type '" + type + "' not supported.");
52
+ }
53
+
54
+ // setup default values
55
+ if (typeof(bubbles) == 'undefined') bubbles = true; // all key events bubble
56
+ if (typeof(cancelable) == 'undefined') cancelable = true; // all key events can be cancelled
57
+ if (typeof(view) == 'undefined') view = window;
58
+ if (typeof(ctrlKey) == 'undefined') ctrlKey = false;
59
+ if (typeof(altKey) == 'undefined') altKey = false;
60
+ if (typeof(shiftKey) == 'undefined') shiftKey = false;
61
+ if (typeof(metaKey) == 'undefined') metaKey = false;
62
+ if (typeof(keyCode) == 'undefined') keyCode = 0;
63
+ if (typeof(charCode) == 'undefined') charCode = 0;
64
+
65
+ // try to create a mouse event
66
+ var customEvent = null;
67
+
68
+ // check for DOM-compliant browsers first
69
+ if (typeof(document.createEvent) == 'function') {
70
+ try {
71
+ customEvent = document.createEvent('KeyEvents');
72
+ // Interesting problem: Firefox implemented a non-standard version
73
+ // of initKeyEvent() based on DOM Level 2 specs. Key event was
74
+ // removed from DOM Level 2 and re-introduced in DOM Level 3 with a
75
+ // different interface. Firefox is the only browser with any
76
+ // implementation of Key Events, so for now, assume it's Firefox if
77
+ // the above line doesn't error.
78
+ // TODO: Decipher between Firefox's implementation and a correct one.
79
+ customEvent.initKeyEvent(type, bubbles, cancelable, view, ctrlKey, altKey, shiftKey, metaKey, keyCode, charCode);
80
+ } catch (ex) {
81
+ // If we got here, that means key events aren't officially supported.
82
+ // Safari/WebKit is a real problem now. WebKit 522 won't let you set
83
+ // keyCode, charCode, or other properties if you use a UIEvent, so we
84
+ // first must try to create a generic event. The fun part is that
85
+ // this will throw an error on Safari 2.x. The end result is that we
86
+ // need another try...catch statement just to deal with this mess.
87
+ try {
88
+ // try to create generic event - will fail in Safari 2.x
89
+ customEvent = document.createEvent('Events');
90
+ } catch (uierror) {
91
+ // the above failed, so create a UIEvent for Safari 2.x
92
+ customEvent = document.createEvent('UIEvents');
93
+ } finally {
94
+ customEvent.initEvent(type, bubbles, cancelable);
95
+ customEvent.view = view;
96
+ customEvent.altKey = altKey;
97
+ customEvent.ctrlKey = ctrlKey;
98
+ customEvent.shiftKey = shiftKey;
99
+ customEvent.metaKey = metaKey;
100
+ customEvent.keyCode = keyCode;
101
+ customEvent.charCode = charCode;
102
+ }
103
+ }
104
+ // fire the event
105
+ target.dispatchEvent(customEvent);
106
+ } else if (typeof(document.createEventObject) == 'object') {
107
+ //create an IE event object
108
+ customEvent = document.createEventObject();
109
+ customEvent.bubbles = bubbles;
110
+ customEvent.cancelable = cancelable;
111
+ customEvent.view = view;
112
+ customEvent.ctrlKey = ctrlKey;
113
+ customEvent.altKey = altKey;
114
+ customEvent.shiftKey = shiftKey;
115
+ customEvent.metaKey = metaKey;
116
+
117
+ // IE doesn't support charCode explicitly. CharCode should take
118
+ // precedence over any keyCode value for accurate representation.
119
+ customEvent.keyCode = (charCode > 0) ? charCode : keyCode;
120
+
121
+ // fire the event
122
+ target.fireEvent('on' + type, customEvent);
123
+ } else {
124
+ throw('simulateKeyEvent(): No event simulation framework present.');
125
+ }
126
+ },
127
+
128
+ /**
129
+ * Simulates a mouse event using the given event information to populate
130
+ * the generated event object. This method does browser-equalizing
131
+ * calculations to account for differences in the DOM and IE event models
132
+ * as well as different browser quirks.
133
+ *
134
+ * @param {HTMLElement} target The target of the given event.
135
+ * @param {String} type The type of event to fire. This can be any one of
136
+ * the following: click, dblclick, mousedown, mouseup, mouseout,
137
+ * mouseover, and mousemove.
138
+ * @param {Boolean} bubbles (Optional) Indicates if the event can be
139
+ * bubbled up. DOM Level 2 specifies that all mouse events bubble by
140
+ * default. The default is true.
141
+ * @param {Boolean} cancelable (Optional) Indicates if the event can be
142
+ * canceled using preventDefault(). DOM Level 2 specifies that all
143
+ * mouse events except mousemove can be cancelled. The default
144
+ * is true for all events except mousemove, for which the default
145
+ * is false.
146
+ * @param {Window} view (Optional) The view containing the target. This is
147
+ * typically the window object. The default is window.
148
+ * @param {int} detail (Optional) The number of times the mouse button has
149
+ * been used. The default value is 1.
150
+ * @param {int} screenX (Optional) The x-coordinate on the screen at which
151
+ * point the event occured. The default is 0.
152
+ * @param {int} screenY (Optional) The y-coordinate on the screen at which
153
+ * point the event occured. The default is 0.
154
+ * @param {int} clientX (Optional) The x-coordinate on the client at which
155
+ * point the event occured. The default is 0.
156
+ * @param {int} clientY (Optional) The y-coordinate on the client at which
157
+ * point the event occured. The default is 0.
158
+ * @param {Boolean} ctrlKey (Optional) Indicates if one of the CTRL keys
159
+ * is pressed while the event is firing. The default is false.
160
+ * @param {Boolean} altKey (Optional) Indicates if one of the ALT keys
161
+ * is pressed while the event is firing. The default is false.
162
+ * @param {Boolean} shiftKey (Optional) Indicates if one of the SHIFT keys
163
+ * is pressed while the event is firing. The default is false.
164
+ * @param {Boolean} metaKey (Optional) Indicates if one of the META keys
165
+ * is pressed while the event is firing. The default is false.
166
+ * @param {int} button (Optional) The button being pressed while the event
167
+ * is executing. The value should be 0 for the primary mouse button
168
+ * (typically the left button), 1 for the terciary mouse button
169
+ * (typically the middle button), and 2 for the secondary mouse button
170
+ * (typically the right button). The default is 0.
171
+ * @param {HTMLElement} relatedTarget (Optional) For mouseout events,
172
+ * this is the element that the mouse has moved to. For mouseover
173
+ * events, this is the element that the mouse has moved from. This
174
+ * argument is ignored for all other events. The default is null.
175
+ * @static
176
+ */
177
+ mouseEvent: function(target, type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget) {
178
+ if (!target) throw('simulateMouseEvent(): Invalid target.');
179
+ if (typeof(type) != 'string') throw('simulateMouseEvent(): Event type must be a string.');
180
+
181
+ type = type.toLowerCase();
182
+ switch(type){
183
+ case 'mouseover':
184
+ case 'mouseout':
185
+ case 'mousedown':
186
+ case 'mouseup':
187
+ case 'click':
188
+ case 'dblclick':
189
+ case 'mousemove':
190
+ break;
191
+ default: throw("simulateMouseEvent(): Event type '" + type + "' not supported.");
192
+ }
193
+
194
+ //setup default values
195
+ if (typeof(bubbles) == 'undefined') bubbles = true; // all mouse events bubble
196
+ if (typeof(cancelable) == 'undefined') cancelable = (type != "mousemove"); // mousemove is the only one that can't be cancelled
197
+ if (typeof(view) == 'undefined') view = window; // view is typically window
198
+ if (typeof(detail) == 'undefined') detail = 1; // number of mouse clicks must be at least one
199
+ if (typeof(screenX) == 'undefined') screenX = 0;
200
+ if (typeof(screenY) == 'undefined') screenY = 0;
201
+ if (typeof(clientX) == 'undefined') clientX = 0;
202
+ if (typeof(clientY) == 'undefined') clientY = 0;
203
+ if (typeof(ctrlKey) == 'undefined') ctrlKey = false;
204
+ if (typeof(altKey) == 'undefined') altKey = false;
205
+ if (typeof(shiftKey) == 'undefined') shiftKey = false;
206
+ if (typeof(metaKey) == 'undefined') metaKey = false;
207
+ if (typeof(button) == 'undefined') button = 0;
208
+
209
+ // try to create a mouse event
210
+ var customEvent = null;
211
+
212
+ // check for DOM-compliant browsers first
213
+ if (typeof(document.createEvent) == 'function') {
214
+ customEvent = document.createEvent("MouseEvents");
215
+
216
+ // Safari 2.x (WebKit 418) still doesn't implement initMouseEvent()
217
+ if (customEvent.initMouseEvent) {
218
+ customEvent.initMouseEvent(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);
219
+ } else {
220
+ // the closest thing available in Safari 2.x is UIEvents
221
+ customEvent = document.createEvent("UIEvents");
222
+ customEvent.initEvent(type, bubbles, cancelable);
223
+ customEvent.view = view;
224
+ customEvent.detail = detail;
225
+ customEvent.screenX = screenX;
226
+ customEvent.screenY = screenY;
227
+ customEvent.clientX = clientX;
228
+ customEvent.clientY = clientY;
229
+ customEvent.ctrlKey = ctrlKey;
230
+ customEvent.altKey = altKey;
231
+ customEvent.metaKey = metaKey;
232
+ customEvent.shiftKey = shiftKey;
233
+ customEvent.button = button;
234
+ customEvent.relatedTarget = relatedTarget;
235
+ }
236
+
237
+ // Check to see if relatedTarget has been assigned. Firefox versions
238
+ // less than 2.0 don't allow it to be assigned via initMouseEvent()
239
+ // and the property is readonly after event creation, so in order to
240
+ // keep YAHOO.util.getRelatedTarget() working, assign to the IE
241
+ // proprietary toElement property for mouseout event and fromElement
242
+ // property for mouseover event.
243
+ if (relatedTarget && !customEvent.relatedTarget) {
244
+ if (type == "mouseout") {
245
+ customEvent.toElement = relatedTarget;
246
+ } else if (type == "mouseover") {
247
+ customEvent.fromElement = relatedTarget;
248
+ }
249
+ }
250
+
251
+ //fire the event
252
+ target.dispatchEvent(customEvent);
253
+ } else if (typeof(document.createEventObject) == 'object') {
254
+ //create an IE event object
255
+ customEvent = document.createEventObject();
256
+ customEvent.bubbles = bubbles;
257
+ customEvent.cancelable = cancelable;
258
+ customEvent.view = view;
259
+ customEvent.detail = detail;
260
+ customEvent.screenX = screenX;
261
+ customEvent.screenY = screenY;
262
+ customEvent.clientX = clientX;
263
+ customEvent.clientY = clientY;
264
+ customEvent.ctrlKey = ctrlKey;
265
+ customEvent.altKey = altKey;
266
+ customEvent.metaKey = metaKey;
267
+ customEvent.shiftKey = shiftKey;
268
+ //fix button property for IE's wacky implementation
269
+ switch(button) {
270
+ case 0: customEvent.button = 1; break;
271
+ case 1: customEvent.button = 4; break;
272
+ case 2: break; // leave as is
273
+ default: customEvent.button = 0;
274
+ }
275
+ // Have to use relatedTarget because IE won't allow assignment to
276
+ // toElement or fromElement on generic events. This keeps
277
+ // YAHOO.util.customEvent.getRelatedTarget() functional.
278
+ customEvent.relatedTarget = relatedTarget;
279
+
280
+ //fire the event
281
+ target.fireEvent("on" + type, customEvent);
282
+ } else {
283
+ throw('simulateMouseEvent(): No event simulation framework present.');
284
+ }
285
+ },
286
+
287
+ //--------------------------------------------------------------------------
288
+ // Mouse events
289
+ //--------------------------------------------------------------------------
290
+
291
+ /**
292
+ * Simulates a mouse event on a particular element.
293
+ *
294
+ * @param {HTMLElement} target The element to click on.
295
+ * @param {String} type The type of event to fire. This can be any one of
296
+ * the following: click, dblclick, mousedown, mouseup, mouseout,
297
+ * mouseover, and mousemove.
298
+ * @param {Object} options Additional event options (use DOM standard names).
299
+ * @static
300
+ */
301
+ fireMouseEvent: function(type, target, options) {
302
+ options = options || {};
303
+ this.mouseEvent(target, type, options.bubbles,
304
+ options.cancelable, options.view, options.detail, options.screenX,
305
+ options.screenY, options.clientX, options.clientY, options.ctrlKey,
306
+ options.altKey, options.shiftKey, options.metaKey, options.button,
307
+ options.relatedTarget);
308
+ },
309
+
310
+ /**
311
+ * Simulates a click on a particular element.
312
+ *
313
+ * @param {HTMLElement} target The element to click on.
314
+ * @param {Object} options Additional event options (use DOM standard names).
315
+ * @static
316
+ */
317
+ click: function(target, options) {
318
+ try {
319
+ this.fireMouseEvent('click', target, options);
320
+ } catch(e) {
321
+ alert(e);
322
+ }
323
+ },
324
+
325
+ /**
326
+ * Simulates a double click on a particular element.
327
+ *
328
+ * @param {HTMLElement} target The element to double click on.
329
+ * @param {Object} options Additional event options (use DOM standard names).
330
+ * @static
331
+ */
332
+ dblclick: function(target, options) {
333
+ this.fireMouseEvent('dblclick', target, options);
334
+ },
335
+
336
+ /**
337
+ * Simulates a mousedown on a particular element.
338
+ *
339
+ * @param {HTMLElement} target The element to act on.
340
+ * @param {Object} options Additional event options (use DOM standard names).
341
+ * @static
342
+ */
343
+ mousedown: function(target, options) {
344
+ this.fireMouseEvent('mousedown', target, options);
345
+ },
346
+
347
+ /**
348
+ * Simulates a mousemove on a particular element.
349
+ *
350
+ * @param {HTMLElement} target The element to act on.
351
+ * @param {Object} options Additional event options (use DOM standard names).
352
+ * @static
353
+ */
354
+ mousemove: function(target, options) {
355
+ this.fireMouseEvent('mousemove', target, options);
356
+ },
357
+
358
+ /**
359
+ * Simulates a mouseout event on a particular element. Use 'relatedTarget'
360
+ * on the options object to specify where the mouse moved to.
361
+ *
362
+ * Quirks: Firefox less than 2.0 doesn't set relatedTarget properly, so
363
+ * toElement is assigned in its place. IE doesn't allow toElement to be
364
+ * be assigned, so relatedTarget is assigned in its place. Both of these
365
+ * concessions allow YAHOO.util.Event.getRelatedTarget() to work correctly
366
+ * in both browsers.
367
+ *
368
+ * @param {HTMLElement} target The element to act on.
369
+ * @param {Object} options Additional event options (use DOM standard names).
370
+ * @static
371
+ */
372
+ mouseout: function(target, options) {
373
+ this.fireMouseEvent('mouseout', target, options);
374
+ },
375
+
376
+ /**
377
+ * Simulates a mouseover event on a particular element. Use 'relatedTarget'
378
+ * on the options object to specify where the mouse moved from.
379
+ *
380
+ * Quirks: Firefox less than 2.0 doesn't set relatedTarget properly, so
381
+ * fromElement is assigned in its place. IE doesn't allow fromElement to be
382
+ * be assigned, so relatedTarget is assigned in its place. Both of these
383
+ * concessions allow YAHOO.util.Event.getRelatedTarget() to work correctly
384
+ * in both browsers.
385
+ *
386
+ * @param {HTMLElement} target The element to act on.
387
+ * @param {Object} options Additional event options (use DOM standard names).
388
+ * @static
389
+ */
390
+ mouseover: function(target, options) {
391
+ this.fireMouseEvent('mouseover', target, options);
392
+ },
393
+
394
+ /**
395
+ * Simulates a mouseup on a particular element.
396
+ *
397
+ * @param {HTMLElement} target The element to act on.
398
+ * @param {Object} options Additional event options (use DOM standard names).
399
+ * @static
400
+ */
401
+ mouseup: function(target, options) {
402
+ this.fireMouseEvent('mouseup', target, options);
403
+ },
404
+
405
+ //--------------------------------------------------------------------------
406
+ // Key events
407
+ //--------------------------------------------------------------------------
408
+
409
+ /**
410
+ * Fires an event that normally would be fired by the keyboard (keyup,
411
+ * keydown, keypress). Make sure to specify either keyCode or charCode as
412
+ * an option.
413
+ *
414
+ * @param {String} type The type of event ("keyup", "keydown" or "keypress").
415
+ * @param {HTMLElement} target The target of the event.
416
+ * @param {Object} options Options for the event. Either keyCode or charCode are required.
417
+ * @static
418
+ */
419
+ fireKeyEvent: function(type, target, options) {
420
+ options = options || {};
421
+ this.keyEvent(target, type, options.bubbles,
422
+ options.cancelable, options.view, options.ctrlKey,
423
+ options.altKey, options.shiftKey, options.metaKey,
424
+ options.keyCode, options.charCode);
425
+ },
426
+
427
+ /**
428
+ * Simulates a keydown event on a particular element.
429
+ *
430
+ * @param {HTMLElement} target The element to act on.
431
+ * @param {Object} options Additional event options (use DOM standard names).
432
+ * @static
433
+ */
434
+ keydown: function(target, options) {
435
+ this.fireKeyEvent('keydown', target, options);
436
+ },
437
+
438
+ /**
439
+ * Simulates a keypress on a particular element.
440
+ *
441
+ * @param {HTMLElement} target The element to act on.
442
+ * @param {Object} options Additional event options (use DOM standard names).
443
+ * @static
444
+ */
445
+ keypress: function(target, options) {
446
+ this.fireKeyEvent('keypress', target, options);
447
+ },
448
+
449
+ /**
450
+ * Simulates a keyup event on a particular element.
451
+ *
452
+ * @param {HTMLElement} target The element to act on.
453
+ * @param {Object} options Additional event options (use DOM standard names).
454
+ * @static
455
+ */
456
+ keyup: function(target, options) {
457
+ this.fireKeyEvent('keyup', target, options);
458
+ },
459
+
460
+ //--------------------------------------------------------------------------
461
+ // Other events
462
+ //--------------------------------------------------------------------------
463
+
464
+ /**
465
+ * Emulates a selection.. This doesn't simulate moving the mouse to make a
466
+ * selection, or using the arrow keys with shift, but it does create a
467
+ * selection that contains whatever target element you pass to it.
468
+ *
469
+ * @param {HTMLElement} target The element to select.
470
+ * @static
471
+ */
472
+ selection: function(target, contentWindow) {
473
+ contentWindow = contentWindow || window;
474
+ var selection = contentWindow.getSelection();
475
+ var range = contentWindow.document.createRange();
476
+ range.selectNode(target);
477
+ selection.removeAllRanges();
478
+ selection.addRange(range);
479
+ return selection;
480
+ },
481
+
482
+ /**
483
+ * Emulates pressing the tab button.
484
+ *
485
+ * @param {HTMLElement} target The element to press tab in.
486
+ * @static
487
+ */
488
+ tab: function(target) {
489
+ this.keydown(target, {keyCode: 9});
490
+ },
491
+
492
+ /**
493
+ * Executes a focus event
494
+ * -- not simulated, but it seems like the right place to put it.
495
+ *
496
+ * @param {HTMLElement} target The element to act on.
497
+ * @static
498
+ */
499
+ focus: function(target) {
500
+ target.focus();
501
+ },
502
+
503
+ /**
504
+ * Executes a focus event
505
+ * -- not simulated, but it seems like the right place to put it.
506
+ *
507
+ * @param {HTMLElement} target The element to act on.
508
+ * @static
509
+ */
510
+ blur: function(target) {
511
+ target.blur();
512
+ }
513
+ };
@@ -0,0 +1,2 @@
1
+ <div id="dialog_container"></div>
2
+ <div id="button"></div>
@@ -0,0 +1,5 @@
1
+ <div id="button">button</div>
2
+ <div id="white" class="picker" style="background:#FFFFFF"></div>
3
+ <div id="red" class="picker" style="background:#FF0000"></div>
4
+ <div id="green" style="background:#00FF00"></div>
5
+ <div class="last-picked">Last Color Picked</div>
@@ -0,0 +1,5 @@
1
+ <div id="button">button</div>
2
+ <div id="white" class="picker" style="background:#FFFFFF"></div>
3
+ <div id="red" class="picker" style="background:#FF0000"></div>
4
+ <div id="green" style="background:#00FF00"></div>
5
+ <div class="last-picked">Last Color Picked</div>
@@ -0,0 +1,3 @@
1
+ <h1 id="h1" data-tag="h1">Heading 1 &lt;h1&gt;</h1>
2
+ <div id="div" data-tag="pre">Formatted &lt;pre&gt;</div>
3
+ <em id="em">em</em>
@@ -0,0 +1,16 @@
1
+ <div class="mercury-snippet-panel">
2
+
3
+ <div class="filter">
4
+ <input id="filter" type="text" class="filter"/>
5
+ </div>
6
+
7
+ <ul>
8
+ <li id="first" data-filter="foo, bar">
9
+ <img src="" data-snippet="test"/>
10
+ </li>
11
+ <li id="second" data-filter="baz">
12
+ <img src="" data-snippet="test"/>
13
+ </li>
14
+ </ul>
15
+
16
+ </div>
@@ -0,0 +1,3 @@
1
+ <div id="red" class="red" data-class="red">Red text</div>
2
+ <div id="bold" class="foo" data-class="bold">Bold text</div>
3
+ <div id="blue" class="blue">Blue background</div>
@@ -0,0 +1,13 @@
1
+ <style>
2
+ .mercury-lightview, .mercury-lightview-overlay {
3
+ display: none;
4
+ }
5
+ .mercury-lightview {
6
+ position: absolute;
7
+ opacity: 0;
8
+ }
9
+ .mercury-lightview-overlay {
10
+ opacity: 0;
11
+ }
12
+ </style>
13
+ <div id="lightview_container"></div>
@@ -0,0 +1,13 @@
1
+ <style>
2
+ .mercury-modal, .mercury-modal-overlay {
3
+ display: none;
4
+ }
5
+ .mercury-modal {
6
+ position: absolute;
7
+ top: -100px;
8
+ }
9
+ .mercury-modal-overlay {
10
+ opacity: 0;
11
+ }
12
+ </style>
13
+ <div id="modal_container"></div>
@@ -0,0 +1,5 @@
1
+ <form>
2
+ <textarea cols="" rows=""></textarea>
3
+
4
+ <input id="submit" type="submit">
5
+ </form>
@@ -0,0 +1,5 @@
1
+ <form>
2
+ <div id="char1" class="character" data-entity="#34" title="quotation mark (APL quote)">&#34;</div>
3
+ <div id="char2" class="character" data-entity="#38" title="ampersand">&#38;</div>
4
+ <div id="char3" data-entity="#38" title="ampersand">&#38;</div>
5
+ </form>
@@ -0,0 +1,30 @@
1
+ <form>
2
+ <fieldset id="link_text_container">
3
+ <input id="link_text" name="link[text]" type="text"/>
4
+ </fieldset>
5
+
6
+ <label for="link_external_url"><input id="checkbox1" name="link_type" type="radio" value="external_url" checked="checked"/>URL</label>
7
+ <input class="selectable" id="link_external_url" name="link[external_url]" type="text"/>
8
+
9
+ <label for="link_existing_bookmark"><input id="checkbox2" name="link_type" type="radio" value="existing_bookmark"/>Existing Links</label>
10
+ <select class="selectable" id="link_existing_bookmark" name="link[existing_bookmark]"></select>
11
+
12
+ <label for="link_new_bookmark"><input name="link_type" type="radio" value="new_bookmark"/>Bookmark</label>
13
+ <input class="selectable" id="link_new_bookmark" name="link[new_bookmark]" type="text"/>
14
+
15
+ <select id="link_target" name="link[target]">
16
+ <option value="">Self (the same window or tab)</option>
17
+ <option value="_blank">Blank (a new window or tab)</option>
18
+ <option value="_top">Top (removes any frames)</option>
19
+ <option value="popup">Popup Window (javascript new window popup)</option>
20
+ </select>
21
+
22
+ <div class="link-target-options" id="popup_options" style="display:none">
23
+ <input id="link_popup_width" name="link[popup_width]" type="text"/>
24
+ <input id="link_popup_height" name="link[popup_height]" type="text"/>
25
+ </div>
26
+
27
+ <input id="submit" type="submit"/>
28
+ </form>
29
+ <a name="link1">Link One</a>
30
+ <a name="link2">Link Two</a>
@@ -0,0 +1,35 @@
1
+ <form>
2
+ <label for="media_image_url"><input id="checkbox1" name="media_type" type="radio" value="image_url" checked="checked"/>URL</label>
3
+ <input class="selectable" id="media_image_url" name="media[image_url]" type="text"/>
4
+
5
+ <label for="media_youtube_url"><input id="checkbox2" name="media_type" type="radio" value="youtube_url"/>YouTube Share URL</label>
6
+ <input class="selectable" id="media_youtube_url" name="media[youtube_url]" type="text"/>
7
+
8
+ <label for="media_vimeo_url"><input name="media_type" type="radio" value="vimeo_url"/>Vimeo URL</label>
9
+ <input class="selectable" id="media_vimeo_url" name="media[vimeo_url]" type="text"/>
10
+
11
+ <div class="media-options" id="image_url">
12
+ <select id="media_image_alignment" name="media[image_alignment]">
13
+ <option value="">None</option>
14
+ <option value="left">Left</option>
15
+ <option value="right">Right</option>
16
+ <option value="top">Top</option>
17
+ <option value="middle">Middle</option>
18
+ <option value="bottom">Bottom</option>
19
+ <option value="absmiddle">Absolute Middle</option>
20
+ <option value="absbottom">Absolute Bottom</option>
21
+ </select>
22
+ </div>
23
+
24
+ <div class="media-options" id="youtube_url" style="display:none">
25
+ <input id="media_youtube_width" name="media[youtube_width]" type="text" value="560"/>
26
+ <input id="media_youtube_height" name="media[youtube_height]" type="text" value="349"/>
27
+ </div>
28
+
29
+ <div class="media-options" id="vimeo_url" style="display:none">
30
+ <input id="media_vimeo_width" name="media[vimeo_width]" type="text" value="400"/>
31
+ <input id="media_vimeo_height" name="media[vimeo_height]" type="text" value="225"/>
32
+ </div>
33
+
34
+ <input id="submit" type="submit"/>
35
+ </form>
@@ -0,0 +1,6 @@
1
+ <form>
2
+ <input type="text" name="first_name" value="Wilma"/>
3
+ <input type="text" name="last_name" value="Flintstone"/>
4
+
5
+ <input id="submit" type="submit"/>
6
+ </form>