kiteditor 1.0.11 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (289) hide show
  1. data/POST_INSTALL +21 -0
  2. data/{vendor → app}/assets/images/mercury/button.png +0 -0
  3. data/{vendor → app}/assets/images/mercury/close.png +0 -0
  4. data/app/assets/images/mercury/default-snippet.png +0 -0
  5. data/{vendor → app}/assets/images/mercury/loading-dark.gif +0 -0
  6. data/{vendor → app}/assets/images/mercury/loading-light.gif +0 -0
  7. data/{vendor → app}/assets/images/mercury/missing-image.png +0 -0
  8. data/{vendor → app}/assets/images/mercury/search-icon.png +0 -0
  9. data/{vendor → app}/assets/images/mercury/temp-logo.png +0 -0
  10. data/app/assets/images/mercury/toolbar/editable/buttons.png +0 -0
  11. data/app/assets/images/mercury/toolbar/primary/_expander.png +0 -0
  12. data/app/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
  13. data/app/assets/images/mercury/toolbar/primary/action.png +0 -0
  14. data/app/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
  15. data/app/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
  16. data/app/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
  17. data/app/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
  18. data/app/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
  19. data/app/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
  20. data/app/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
  21. data/app/assets/images/mercury/toolbar/primary/preview.png +0 -0
  22. data/app/assets/images/mercury/toolbar/primary/redo.png +0 -0
  23. data/app/assets/images/mercury/toolbar/primary/save.png +0 -0
  24. data/app/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
  25. data/app/assets/images/mercury/toolbar/primary/tools.png +0 -0
  26. data/app/assets/images/mercury/toolbar/primary/undo.png +0 -0
  27. data/app/assets/images/mercury/toolbar/primary/user.png +0 -0
  28. data/app/assets/images/mercury/toolbar/snippets/buttons.png +0 -0
  29. data/{vendor/assets/javascripts/mercury/dependencies → app/assets/javascripts}/jquery-1.7.js +0 -0
  30. data/{vendor → app}/assets/javascripts/mercury.js +60 -87
  31. data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +0 -0
  32. data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.additions.js +103 -13
  33. data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +0 -0
  34. data/{vendor → app}/assets/javascripts/mercury/dependencies/liquidmetal.js +0 -0
  35. data/{vendor → app}/assets/javascripts/mercury/dependencies/showdown.js +0 -0
  36. data/{vendor → app}/assets/javascripts/mercury/dialog.js.coffee +0 -0
  37. data/{vendor → app}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
  38. data/{vendor → app}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +1 -1
  39. data/{vendor → app}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
  40. data/{vendor → app}/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +1 -1
  41. data/{vendor → app}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
  42. data/{vendor → app}/assets/javascripts/mercury/finalize.js.coffee +0 -0
  43. data/{vendor → app}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
  44. data/{vendor → app}/assets/javascripts/mercury/lightview.js.coffee +38 -17
  45. data/app/assets/javascripts/mercury/locales/ar.locale.js.coffee +201 -0
  46. data/app/assets/javascripts/mercury/locales/da.locale.js.coffee +208 -0
  47. data/{vendor → app}/assets/javascripts/mercury/locales/de.locale.js.coffee +4 -10
  48. data/{vendor → app}/assets/javascripts/mercury/locales/es.locale.js.coffee +3 -9
  49. data/{vendor → app}/assets/javascripts/mercury/locales/example.local.js.coffee +3 -5
  50. data/{vendor → app}/assets/javascripts/mercury/locales/fr.locale.js.coffee +3 -9
  51. data/app/assets/javascripts/mercury/locales/hu.locale.js.coffee +209 -0
  52. data/{vendor → app}/assets/javascripts/mercury/locales/it.locale.js.coffee +3 -9
  53. data/{vendor → app}/assets/javascripts/mercury/locales/ko.local.js.coffee +4 -10
  54. data/{vendor → app}/assets/javascripts/mercury/locales/nl.locale.js.coffee +3 -9
  55. data/app/assets/javascripts/mercury/locales/pl.locale.js.coffee +213 -0
  56. data/{vendor → app}/assets/javascripts/mercury/locales/pt.locale.js.coffee +3 -9
  57. data/app/assets/javascripts/mercury/locales/ru.locale.js.coffee +200 -0
  58. data/{vendor → app}/assets/javascripts/mercury/locales/sv.local.js.coffee +3 -9
  59. data/{vendor → app}/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +3 -9
  60. data/app/assets/javascripts/mercury/locales/uk.locale.js.coffee +200 -0
  61. data/app/assets/javascripts/mercury/locales/zh.local.js.coffee +203 -0
  62. data/app/assets/javascripts/mercury/mercury-compiled.js +10720 -0
  63. data/{vendor → app}/assets/javascripts/mercury/mercury.js.coffee +10 -1
  64. data/{vendor → app}/assets/javascripts/mercury/modal.js.coffee +62 -40
  65. data/{vendor → app}/assets/javascripts/mercury/modals/htmleditor.js.coffee +1 -0
  66. data/{vendor → app}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +1 -0
  67. data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +152 -0
  68. data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +132 -0
  69. data/{vendor → app}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +2 -0
  70. data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +68 -0
  71. data/{vendor → app}/assets/javascripts/mercury/native_extensions.js.coffee +0 -6
  72. data/{vendor → app}/assets/javascripts/mercury/page_editor.js.coffee +84 -50
  73. data/{vendor → app}/assets/javascripts/mercury/palette.js.coffee +1 -1
  74. data/{vendor → app}/assets/javascripts/mercury/panel.js.coffee +3 -2
  75. data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +2 -2
  76. data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +0 -0
  77. data/{vendor → app}/assets/javascripts/mercury/region.js.coffee +18 -17
  78. data/{vendor/assets/javascripts/mercury/regions/editable.js.coffee → app/assets/javascripts/mercury/regions/full.js.coffee} +41 -31
  79. data/app/assets/javascripts/mercury/regions/image.js.coffee +93 -0
  80. data/{vendor/assets/javascripts/mercury/regions/markupable.js.coffee → app/assets/javascripts/mercury/regions/markdown.js.coffee} +29 -24
  81. data/{vendor → app}/assets/javascripts/mercury/regions/simple.js.coffee +11 -54
  82. data/{vendor/assets/javascripts/mercury/regions/snippetable.js.coffee → app/assets/javascripts/mercury/regions/snippets.js.coffee} +10 -9
  83. data/{vendor → app}/assets/javascripts/mercury/select.js.coffee +1 -1
  84. data/app/assets/javascripts/mercury/snippet.js.coffee +136 -0
  85. data/{vendor → app}/assets/javascripts/mercury/snippet_toolbar.js.coffee +19 -6
  86. data/{vendor → app}/assets/javascripts/mercury/statusbar.js.coffee +0 -0
  87. data/{vendor → app}/assets/javascripts/mercury/support/history.js +0 -0
  88. data/{vendor → app}/assets/javascripts/mercury/table_editor.js.coffee +16 -0
  89. data/{vendor → app}/assets/javascripts/mercury/toolbar.button.js.coffee +45 -30
  90. data/{vendor → app}/assets/javascripts/mercury/toolbar.button_group.js.coffee +2 -2
  91. data/{vendor → app}/assets/javascripts/mercury/toolbar.expander.js.coffee +4 -4
  92. data/{vendor → app}/assets/javascripts/mercury/toolbar.js.coffee +10 -6
  93. data/{vendor → app}/assets/javascripts/mercury/tooltip.js.coffee +0 -0
  94. data/{vendor → app}/assets/javascripts/mercury/uploader.js.coffee +37 -19
  95. data/app/assets/stylesheets/_mercury-bootstrap-overrides.scss +61 -0
  96. data/app/assets/stylesheets/_mercury-sass.scss +33 -0
  97. data/{vendor → app}/assets/stylesheets/mercury.css +1 -5
  98. data/{vendor → app}/assets/stylesheets/mercury/all_images.css.erb +6 -2
  99. data/app/assets/stylesheets/mercury/bootstrap-ish.css +1367 -0
  100. data/app/assets/stylesheets/mercury/bootstrap-overrides.css +61 -0
  101. data/{vendor → app}/assets/stylesheets/mercury/dialog.css +21 -8
  102. data/{vendor → app}/assets/stylesheets/mercury/lightview.css +6 -56
  103. data/app/assets/stylesheets/mercury/mercury.css +43 -0
  104. data/{vendor → app}/assets/stylesheets/mercury/modal.css +15 -32
  105. data/{vendor → app}/assets/stylesheets/mercury/statusbar.css +0 -0
  106. data/{vendor → app}/assets/stylesheets/mercury/toolbar.css +4 -1
  107. data/{vendor → app}/assets/stylesheets/mercury/tooltip.css +0 -0
  108. data/{vendor → app}/assets/stylesheets/mercury/uploader.css +4 -4
  109. data/app/helpers/mercury_helper.rb +7 -0
  110. data/app/views/layouts/mercury.html.erb +10 -20
  111. data/app/views/layouts/mercury.html.haml +19 -0
  112. data/app/views/layouts/mercury.html.slim +19 -0
  113. data/app/views/mercury/modals/character.html +1 -1
  114. data/app/views/mercury/modals/htmleditor.html +3 -7
  115. data/app/views/mercury/modals/link.html +37 -51
  116. data/app/views/mercury/modals/media.html +102 -0
  117. data/app/views/mercury/modals/table.html +79 -73
  118. data/app/views/mercury/panels/snippets.html +6 -1
  119. data/app/views/mercury/snippets/example/options.html.erb +23 -27
  120. data/app/views/mercury/snippets/no_options/preview.html.erb +1 -0
  121. data/config/routes.rb +9 -0
  122. data/features/generators/authentication.feature +10 -0
  123. data/features/generators/images.feature +41 -0
  124. data/features/generators/install.feature +21 -0
  125. data/features/loading/loading.feature +5 -2
  126. data/features/loading/user_interface.feature +9 -7
  127. data/features/regions/{editable → full}/advanced_editing.feature +0 -0
  128. data/features/regions/full/basic_editing.feature +198 -0
  129. data/features/regions/{editable → full}/inserting_links.feature +20 -19
  130. data/features/regions/{editable → full}/inserting_media.feature +36 -18
  131. data/features/regions/{editable → full}/inserting_snippets.feature +28 -18
  132. data/features/regions/{editable → full}/inserting_special_characters.feature +2 -2
  133. data/features/regions/full/inserting_tables.feature +109 -0
  134. data/features/regions/{editable → full}/pasting.feature +0 -0
  135. data/features/regions/{editable → full}/uploading_images.feature +0 -0
  136. data/features/regions/{markupable → image}/uploading_images.feature +0 -0
  137. data/features/regions/{markupable → markdown}/advanced_editing.feature +0 -0
  138. data/features/regions/{markupable → markdown}/basic_editing.feature +0 -0
  139. data/features/regions/{markupable → markdown}/inserting_links.feature +0 -0
  140. data/features/regions/{markupable → markdown}/inserting_media.feature +0 -0
  141. data/features/regions/{markupable → markdown}/inserting_snippets.feature +0 -0
  142. data/features/regions/{markupable → markdown}/inserting_special_characters.feature +0 -0
  143. data/features/regions/{markupable → markdown}/inserting_tables.feature +0 -0
  144. data/features/regions/{snippetable/advanced_editing.feature → markdown/uploading_images.feature} +0 -0
  145. data/features/regions/simple/basic_editing.feature +5 -0
  146. data/features/regions/{snippetable/basic_editing.feature → snippets/advanced_editing.feature} +0 -0
  147. data/features/regions/{snippetable/inserting_snippets.feature → snippets/basic_editing.feature} +0 -0
  148. data/{vendor/assets/javascripts/mercury/locales/da.locale.js.coffee → features/regions/snippets/inserting_snippets.feature} +0 -0
  149. data/features/saving/saving.feature +8 -8
  150. data/features/step_definitions/custom_web_steps.rb +22 -0
  151. data/features/step_definitions/generator_steps.rb +23 -0
  152. data/features/step_definitions/mercury_steps.rb +1 -438
  153. data/features/support/aruba.rb +28 -0
  154. data/features/support/env.rb +11 -1
  155. data/features/support/selectors.rb +23 -0
  156. data/lib/generators/mercury/install/authentication/authentication_generator.rb +17 -0
  157. data/lib/generators/mercury/install/images/images_generator.rb +47 -0
  158. data/{app/models/mercury/image.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image.rb} +7 -0
  159. data/{db/migrate/20110526035601_create_mercury_images.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image_migration.rb} +0 -0
  160. data/{app/controllers/mercury → lib/generators/mercury/install/images/templates}/images_controller.rb +0 -0
  161. data/lib/generators/mercury/install/{templates → images/templates}/mongoid_paperclip_image.rb +0 -0
  162. data/lib/generators/mercury/install/install_generator.rb +12 -23
  163. data/lib/mercury-rails.rb +1 -2
  164. data/lib/mercury/authentication.rb +1 -0
  165. data/lib/mercury/cucumber/step_definitions.rb +13 -0
  166. data/lib/mercury/cucumber/step_definitions/mercury_steps.rb +408 -0
  167. data/{features → lib/mercury/cucumber}/support/mercury_contents.rb +3 -3
  168. data/{features → lib/mercury/cucumber}/support/mercury_selectors.rb +0 -20
  169. data/lib/mercury/engine.rb +19 -0
  170. data/lib/mercury/rails.rb +5 -0
  171. data/lib/mercury/version.rb +3 -0
  172. data/spec/dummy/Rakefile +7 -0
  173. data/spec/dummy/app/assets/javascripts/application.js +0 -0
  174. data/spec/dummy/app/assets/javascripts/prototype.js +6082 -0
  175. data/spec/dummy/app/assets/stylesheets/application.css.scss +110 -0
  176. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  177. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  178. data/spec/dummy/app/views/layouts/mercury.html.erb +28 -0
  179. data/spec/dummy/config.ru +4 -0
  180. data/spec/dummy/config/application.rb +58 -0
  181. data/spec/dummy/config/boot.rb +10 -0
  182. data/spec/dummy/config/database.yml +10 -0
  183. data/spec/dummy/config/environment.rb +5 -0
  184. data/spec/dummy/config/environments/development.rb +37 -0
  185. data/spec/dummy/config/environments/production.rb +67 -0
  186. data/spec/dummy/config/environments/test.rb +37 -0
  187. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  188. data/spec/dummy/config/initializers/inflections.rb +15 -0
  189. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  190. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  191. data/spec/dummy/config/initializers/session_store.rb +8 -0
  192. data/spec/dummy/config/initializers/teabag.rb +9 -0
  193. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  194. data/spec/dummy/config/locales/en.yml +5 -0
  195. data/spec/dummy/config/routes.rb +5 -0
  196. data/spec/dummy/db/.gitkeep +0 -0
  197. data/spec/dummy/public/500.html +25 -0
  198. data/spec/dummy/public/blank.html +1 -0
  199. data/spec/dummy/public/favicon.ico +0 -0
  200. data/spec/dummy/public/images/bunny.gif +0 -0
  201. data/spec/dummy/public/images/bunny2.jpg +0 -0
  202. data/spec/dummy/public/index.html +279 -0
  203. data/spec/dummy/script/rails +6 -0
  204. data/spec/javascripts/{templates → fixtures}/mercury/dialog.html +0 -0
  205. data/spec/javascripts/{templates → fixtures}/mercury/dialogs/backcolor.html +0 -0
  206. data/spec/javascripts/{templates → fixtures}/mercury/dialogs/forecolor.html +0 -0
  207. data/spec/javascripts/{templates → fixtures}/mercury/dialogs/formatblock.html +0 -0
  208. data/spec/javascripts/{templates → fixtures}/mercury/dialogs/snippetpanel.html +0 -0
  209. data/spec/javascripts/{templates → fixtures}/mercury/dialogs/style.html +0 -0
  210. data/spec/javascripts/{templates → fixtures}/mercury/lightview.html +0 -0
  211. data/spec/javascripts/{templates → fixtures}/mercury/modal.html +0 -0
  212. data/spec/javascripts/{templates → fixtures}/mercury/modals/htmleditor.html +0 -0
  213. data/spec/javascripts/{templates → fixtures}/mercury/modals/insertcharacter.html +0 -0
  214. data/spec/javascripts/fixtures/mercury/modals/insertlink.html +67 -0
  215. data/spec/javascripts/fixtures/mercury/modals/insertmedia.html +87 -0
  216. data/spec/javascripts/{templates → fixtures}/mercury/modals/insertsnippet.html +0 -0
  217. data/spec/javascripts/fixtures/mercury/modals/inserttable.html +73 -0
  218. data/spec/javascripts/{templates → fixtures}/mercury/page_editor.html +4 -4
  219. data/spec/javascripts/{templates → fixtures}/mercury/palette.html +0 -0
  220. data/spec/javascripts/{templates → fixtures}/mercury/panel.html +0 -0
  221. data/spec/javascripts/fixtures/mercury/region.html +6 -0
  222. data/spec/javascripts/fixtures/mercury/regions/full.html +1 -0
  223. data/spec/javascripts/fixtures/mercury/regions/image.html +1 -0
  224. data/spec/javascripts/fixtures/mercury/regions/markdown.html +1 -0
  225. data/spec/javascripts/fixtures/mercury/regions/simple.html +1 -0
  226. data/spec/javascripts/fixtures/mercury/regions/snippets.html +4 -0
  227. data/spec/javascripts/{templates → fixtures}/mercury/select.html +0 -0
  228. data/spec/javascripts/{templates → fixtures}/mercury/snippet.html +0 -0
  229. data/spec/javascripts/{templates → fixtures}/mercury/snippet_toolbar.html +0 -0
  230. data/spec/javascripts/{templates → fixtures}/mercury/statusbar.html +0 -0
  231. data/spec/javascripts/{templates → fixtures}/mercury/table_editor.html +0 -0
  232. data/spec/javascripts/{templates → fixtures}/mercury/toolbar.button.html +0 -0
  233. data/spec/javascripts/{templates → fixtures}/mercury/toolbar.button_group.html +0 -0
  234. data/spec/javascripts/{templates → fixtures}/mercury/toolbar.expander.html +0 -0
  235. data/spec/javascripts/{templates → fixtures}/mercury/toolbar.html +0 -0
  236. data/spec/javascripts/{templates → fixtures}/mercury/tooltip.html +0 -0
  237. data/spec/javascripts/{templates → fixtures}/mercury/uploader.html +0 -0
  238. data/spec/javascripts/mercury/{dialog_spec.js.coffee → dialog_spec.coffee} +11 -12
  239. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +2 -3
  240. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +3 -4
  241. data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +2 -3
  242. data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +2 -3
  243. data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +2 -3
  244. data/spec/javascripts/mercury/lightview_spec.js.coffee +180 -142
  245. data/spec/javascripts/mercury/mercury_spec.js.coffee +19 -13
  246. data/spec/javascripts/mercury/modal_spec.js.coffee +192 -148
  247. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +4 -5
  248. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +2 -3
  249. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +107 -34
  250. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +106 -26
  251. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +2 -3
  252. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +50 -40
  253. data/spec/javascripts/mercury/page_editor_spec.js.coffee +124 -80
  254. data/spec/javascripts/mercury/palette_spec.js.coffee +4 -5
  255. data/spec/javascripts/mercury/panel_spec.js.coffee +9 -12
  256. data/spec/javascripts/mercury/region_spec.js.coffee +22 -17
  257. data/spec/javascripts/mercury/regions/{editable_spec.js.coffee → full_spec.js.coffee} +26 -28
  258. data/spec/javascripts/mercury/regions/image_spec.js.coffee +33 -0
  259. data/spec/javascripts/mercury/regions/{markupable_spec.js.coffee → markdown_spec.js.coffee} +32 -34
  260. data/spec/javascripts/mercury/regions/simple_spec.js.coffee +32 -0
  261. data/spec/javascripts/mercury/regions/{snippetable_spec.js.coffee → snippets_spec.js.coffee} +54 -55
  262. data/spec/javascripts/mercury/select_spec.js.coffee +4 -5
  263. data/spec/javascripts/mercury/snippet_spec.js.coffee +92 -16
  264. data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +31 -16
  265. data/spec/javascripts/mercury/statusbar_spec.js.coffee +9 -10
  266. data/spec/javascripts/mercury/table_editor_spec.js.coffee +1 -2
  267. data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +7 -9
  268. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +55 -26
  269. data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +13 -13
  270. data/spec/javascripts/mercury/toolbar_spec.js.coffee +43 -14
  271. data/spec/javascripts/mercury/tooltip_spec.js.coffee +1 -2
  272. data/spec/javascripts/mercury/uploader_spec.js.coffee +47 -33
  273. data/spec/javascripts/spec_helper.coffee +4 -0
  274. data/spec/javascripts/{spec_helper.js → support/event_simulation.js} +0 -2
  275. data/spec/teabag_env.rb +32 -0
  276. metadata +366 -196
  277. data/features/regions/editable/basic_editing.feature +0 -195
  278. data/features/regions/editable/inserting_tables.feature +0 -109
  279. data/spec/javascripts/templates/mercury/modals/insertlink.html +0 -30
  280. data/spec/javascripts/templates/mercury/modals/insertmedia.html +0 -35
  281. data/spec/javascripts/templates/mercury/modals/inserttable.html +0 -27
  282. data/spec/javascripts/templates/mercury/region.html +0 -2
  283. data/spec/javascripts/templates/mercury/regions/editable.html +0 -3
  284. data/spec/javascripts/templates/mercury/regions/snippetable.html +0 -4
  285. data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +0 -54
  286. data/vendor/assets/javascripts/mercury_loader.js +0 -193
  287. data/vendor/assets/javascripts/mercury_overrides.js +0 -6
  288. data/vendor/assets/stylesheets/mercury/mercury.css +0 -151
  289. data/vendor/assets/stylesheets/mercury_overrides.css +0 -17
@@ -34,7 +34,7 @@
34
34
  #
35
35
  @Mercury ||= {}
36
36
  jQuery.extend @Mercury,
37
- version: '0.3.0'
37
+ version: '0.9.0'
38
38
 
39
39
  # Mercury object namespaces
40
40
  Regions: Mercury.Regions || {}
@@ -55,6 +55,14 @@ jQuery.extend @Mercury,
55
55
  jQuery(window).on("mercury:#{eventName}", callback)
56
56
 
57
57
 
58
+ off: (eventName, callback) ->
59
+ jQuery(window).off("mercury:#{eventName}", callback)
60
+
61
+
62
+ one: (eventName, callback) ->
63
+ jQuery(window).one("mercury:#{eventName}", callback)
64
+
65
+
58
66
  trigger: (eventName, options) ->
59
67
  Mercury.log(eventName, options)
60
68
  jQuery(window).trigger("mercury:#{eventName}", options)
@@ -92,6 +100,7 @@ jQuery.extend @Mercury,
92
100
  locale: ->
93
101
  return Mercury.determinedLocale if Mercury.determinedLocale
94
102
  if Mercury.config.localization.enabled
103
+ debugger
95
104
  locale = []
96
105
  if navigator.language && (locale = navigator.language.toString().split('-')).length
97
106
  topLocale = Mercury.I18n[locale[0]] || {}
@@ -1,19 +1,27 @@
1
1
  @Mercury.modal = (url, options = {}) ->
2
- Mercury.modal.show(url, options)
3
- return Mercury.modal
2
+ instance = new Mercury.Modal(url, options)
3
+ instance.show()
4
+ return instance
4
5
 
5
- jQuery.extend Mercury.modal,
6
- minWidth: 500
6
+ class @Mercury.Modal
7
+
8
+ constructor: (@url, @options = {}) ->
9
+
10
+
11
+ show: (url = null, options = null) ->
12
+ @url = url || @url
13
+ @options = options || @options
14
+ @options.minWidth ||= 400
15
+ @options.ujsHandling = true unless @options.ujsHandling == false
7
16
 
8
- show: (@url, @options = {}) ->
9
17
  Mercury.trigger('focus:window')
10
- @initialize()
18
+ @initializeModal()
11
19
  if @visible then @update() else @appear()
12
20
  if @options.content
13
- setTimeout 500, => @loadContent(@options.content)
21
+ setTimeout((=> @loadContent(@options.content)), 500)
14
22
 
15
23
 
16
- initialize: ->
24
+ initializeModal: ->
17
25
  return if @initialized
18
26
  @build()
19
27
  @bindEvents()
@@ -21,20 +29,23 @@ jQuery.extend Mercury.modal,
21
29
 
22
30
 
23
31
  build: ->
24
- @element = jQuery('<div>', {class: 'mercury-modal loading'})
25
- @element.html('<h1 class="mercury-modal-title"><span></span><a>&times;</a></h1>')
26
- @element.append('<div class="mercury-modal-content-container"><div class="mercury-modal-content"></div></div>')
27
-
28
- @overlay = jQuery('<div>', {class: 'mercury-modal-overlay'})
29
-
32
+ @element = jQuery('.mercury-modal')
33
+ @overlay = jQuery('.mercury-modal-overlay')
34
+
35
+ unless @element.get(0) && @overlay.get(0)
36
+ @element = jQuery('<div>', {class: 'mercury-modal loading'})
37
+ @element.html('<h1 class="mercury-modal-title"><span></span><a>&times;</a></h1>')
38
+ @element.append('<div class="mercury-modal-content-container"><div class="mercury-modal-content"></div></div>')
39
+
40
+ @overlay = jQuery('<div>', {class: 'mercury-modal-overlay'})
41
+
42
+ @element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
43
+ @overlay.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
44
+
30
45
  @titleElement = @element.find('.mercury-modal-title')
31
46
  @contentContainerElement = @element.find('.mercury-modal-content-container')
32
-
33
47
  @contentElement = @element.find('.mercury-modal-content')
34
48
 
35
- @element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
36
- @overlay.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
37
-
38
49
 
39
50
  bindEvents: ->
40
51
  Mercury.on 'refresh', => @resize(true)
@@ -46,12 +57,13 @@ jQuery.extend Mercury.modal,
46
57
  @titleElement.find('a').on 'click', =>
47
58
  @hide()
48
59
 
49
- @element.on 'ajax:beforeSend', (event, xhr, options) =>
50
- options.success = (content) =>
51
- @loadContent(content)
60
+ if @options.ujsHandling
61
+ @element.on 'ajax:beforeSend', (event, xhr, options) =>
62
+ options.success = (content) =>
63
+ @loadContent(content)
52
64
 
53
65
  jQuery(document).on 'keydown', (event) =>
54
- @hide() if event.keyCode == 27 && @visible
66
+ @hide() if event.keyCode == 27 && @visible
55
67
 
56
68
 
57
69
  appear: ->
@@ -85,18 +97,16 @@ jQuery.extend Mercury.modal,
85
97
 
86
98
  height = @contentElement.outerHeight() + titleHeight
87
99
 
88
- width = @minWidth if width < @minWidth
89
- height = Mercury.displayRect.fullHeight - 20 if height > Mercury.displayRect.fullHeight - 20 || @options.fullHeight
90
- if @fix_height
91
- height = @fix_height
100
+ width = @options.minWidth if width < @options.minWidth
101
+ height = Mercury.displayRect.fullHeight -20 if height > Mercury.displayRect.fullHeight - 20 || @options.fullHeight
92
102
 
93
103
  @element.stop().animate {left: (Mercury.displayRect.width - width) / 2, width: width, height: height}, 200, 'easeInOutSine', =>
94
104
  @contentElement.css({visibility: 'visible', display: 'block'})
95
105
  if @contentPane.length
96
106
  @contentElement.css({height: height - titleHeight, overflow: 'visible'})
97
- controlHeight = if @contentControl.length then @contentControl.outerHeight() else 0
98
- @contentPane.css({height: height - titleHeight - controlHeight - 40})
99
- @contentPane.find('.mercury-display-pane').css({width: width - 40})
107
+ controlHeight = if @contentControl.length then @contentControl.outerHeight() + 10 else 0
108
+ @contentPane.css({height: height - titleHeight - controlHeight - 20})
109
+ @contentPane.find('.mercury-display-pane').css({width: width - 20})
100
110
  else
101
111
  @contentElement.css({height: height - titleHeight, overflow: 'auto'})
102
112
 
@@ -111,15 +121,15 @@ jQuery.extend Mercury.modal,
111
121
  width = @element.width()
112
122
  height = @element.height()
113
123
 
114
- width = @minWidth if width < @minWidth
115
- height = Mercury.displayRect.fullHeight - 20 if height > Mercury.displayRect.fullHeight - 20 || @options.fullHeight
124
+ width = @options.minWidth if width < @options.minWidth
125
+ height = Mercury.displayRect.fullHeight if height > Mercury.displayRect.fullHeight || @options.fullHeight
116
126
 
117
127
  titleHeight = @titleElement.outerHeight()
118
128
  if @contentPane && @contentPane.length
119
129
  @contentElement.css({height: height - titleHeight, overflow: 'visible'})
120
- controlHeight = if @contentControl.length then @contentControl.outerHeight() else 0
121
- @contentPane.css({height: height - titleHeight - controlHeight - 40})
122
- @contentPane.find('.mercury-display-pane').css({width: width - 40})
130
+ controlHeight = if @contentControl.length then @contentControl.outerHeight() + 10 else 0
131
+ @contentPane.css({height: height - titleHeight - controlHeight - 20})
132
+ @contentPane.find('.mercury-display-pane').css({width: width - 20})
123
133
  else
124
134
  @contentElement.css({height: height - titleHeight, overflow: 'auto'})
125
135
 
@@ -143,7 +153,7 @@ jQuery.extend Mercury.modal,
143
153
  return unless @url
144
154
  @element.addClass('loading')
145
155
  if Mercury.preloadedViews[@url]
146
- setTimeout(10, => @loadContent(Mercury.preloadedViews[@url]))
156
+ setTimeout((=> @loadContent(Mercury.preloadedViews[@url])), 10)
147
157
  else
148
158
  jQuery.ajax @url, {
149
159
  headers: Mercury.ajaxHeaders()
@@ -157,7 +167,7 @@ jQuery.extend Mercury.modal,
157
167
 
158
168
 
159
169
  loadContent: (data, options = null) ->
160
- @initialize()
170
+ @initializeModal()
161
171
  @options = options || @options
162
172
  @setTitle()
163
173
  @loaded = true
@@ -172,11 +182,20 @@ jQuery.extend Mercury.modal,
172
182
  @options.afterLoad.call(@) if @options.afterLoad
173
183
  if @options.handler
174
184
  if Mercury.modalHandlers[@options.handler]
175
- Mercury.modalHandlers[@options.handler].call(@)
185
+ if typeof(Mercury.modalHandlers[@options.handler]) == 'function'
186
+ Mercury.modalHandlers[@options.handler].call(@)
187
+ else
188
+ jQuery.extend(@, Mercury.modalHandlers[@options.handler])
189
+ @initialize()
176
190
  else if Mercury.lightviewHandlers[@options.handler]
177
- Mercury.lightviewHandlers[@options.handler].call(@)
191
+ if typeof(Mercury.lightviewHandlers[@options.handler]) == 'function'
192
+ Mercury.lightviewHandlers[@options.handler].call(@)
193
+ else
194
+ jQuery.extend(@, Mercury.lightviewHandlers[@options.handler])
195
+ @initialize()
178
196
 
179
197
  @element.localize(Mercury.locale()) if Mercury.config.localization.enabled
198
+ @element.find('.modal-close').on('click', @hide)
180
199
  @resize()
181
200
 
182
201
 
@@ -186,15 +205,18 @@ jQuery.extend Mercury.modal,
186
205
  if @options.closeButton == false then closeButton.hide() else closeButton.show()
187
206
 
188
207
 
208
+ serializeForm: ->
209
+ return @element.find('form').serializeObject() || {}
210
+
211
+
189
212
  reset: ->
190
213
  @titleElement.find('span').html('')
191
214
  @contentElement.html('')
192
215
 
193
216
 
194
- hide: ->
217
+ hide: =>
195
218
  return if @showing
196
219
  @options = {}
197
- @initialized = false
198
220
 
199
221
  Mercury.trigger('focus:frame')
200
222
  @element.hide()
@@ -1,4 +1,5 @@
1
1
  @Mercury.modalHandlers.htmlEditor = ->
2
+
2
3
  # fill the text area with the content
3
4
  content = Mercury.region.content(null, true, false)
4
5
  @element.find('textarea').val(content)
@@ -1,4 +1,5 @@
1
1
  @Mercury.modalHandlers.insertCharacter = ->
2
+
2
3
  @element.find('.character').on 'click', (event) =>
3
4
  Mercury.trigger('action', {action: 'insertHTML', value: "&#{jQuery(event.target).attr('data-entity')};"})
4
5
  @hide()
@@ -0,0 +1,152 @@
1
+ @Mercury.modalHandlers.insertLink = {
2
+
3
+ initialize: ->
4
+ @editing = false
5
+ @content = null
6
+
7
+ # make the inputs work with the radio buttons
8
+ @element.find('.control-label input').on('click', @onLabelChecked)
9
+ @element.find('.controls .optional, .controls .required').on('focus', @onInputFocused)
10
+
11
+ # show/hide the link target options on target change
12
+ @element.find('#link_target').on('change', => @onChangeTarget())
13
+
14
+ @initializeForm()
15
+
16
+ # build the link on form submission
17
+ @element.find('form').on 'submit', (event) =>
18
+ event.preventDefault()
19
+ @validateForm()
20
+ unless @valid
21
+ @resize()
22
+ return
23
+ @submitForm()
24
+ @hide()
25
+
26
+
27
+ initializeForm: ->
28
+ @fillExistingBookmarks()
29
+
30
+ # get the selection and initialize its information into the form
31
+ return unless Mercury.region && Mercury.region.selection
32
+ selection = Mercury.region.selection()
33
+
34
+ # set the text content
35
+ @element.find('#link_text').val(selection.textContent()) if selection.textContent
36
+
37
+ # if we're editing a link prefill the information
38
+
39
+ a = selection.commonAncestor(true).closest('a') if selection && selection.commonAncestor
40
+ img = /<img/.test(selection.htmlContent()) if selection.htmlContent
41
+ return false unless img || a && a.length
42
+
43
+ # don't allow changing the content on edit
44
+ @element.find('#link_text_container').hide()
45
+
46
+ @content = selection.htmlContent() if img
47
+
48
+ return false unless a && a.length
49
+ @editing = a
50
+
51
+ # fill in the external url or bookmark select based on what it looks like
52
+ if a.attr('href') && a.attr('href').indexOf('#') == 0
53
+ bookmarkSelect = @element.find('#link_existing_bookmark')
54
+ bookmarkSelect.val(a.attr('href').replace(/[^#]*#/, ''))
55
+ bookmarkSelect.closest('.control-group').find('input[type=radio]').prop('checked', true)
56
+ else
57
+ @element.find('#link_external_url').val(a.attr('href'))
58
+
59
+ # if it has a name, assume it's a bookmark target
60
+ if a.attr('name')
61
+ newBookmarkInput = @element.find('#link_new_bookmark')
62
+ newBookmarkInput.val(a.attr('name'))
63
+ newBookmarkInput.closest('.control-group').find('input[type=radio]').prop('checked', true)
64
+
65
+ # if it has a target, select it, and try to pull options out
66
+ if a.attr('target')
67
+ @element.find('#link_target').val(a.attr('target'))
68
+
69
+ # if it's a popup window
70
+ if a.attr('href') && a.attr('href').indexOf('javascript:void') == 0
71
+ href = a.attr('href')
72
+ @element.find('#link_external_url').val(href.match(/window.open\('([^']+)',/)[1])
73
+ @element.find('#link_target').val('popup')
74
+ @element.find('#link_popup_width').val(href.match(/width=(\d+),/)[1])
75
+ @element.find('#link_popup_height').val(href.match(/height=(\d+),/)[1])
76
+ @element.find('#popup_options').show()
77
+
78
+
79
+ fillExistingBookmarks: ->
80
+ bookmarkSelect = @element.find('#link_existing_bookmark')
81
+ for tag in jQuery('a[name]', window.mercuryInstance.document)
82
+ bookmarkSelect.append(jQuery('<option>', {value: jQuery(tag).attr('name')}).text(jQuery(tag).text()))
83
+
84
+
85
+ onLabelChecked: ->
86
+ forInput = jQuery(@).closest('.control-label').attr('for')
87
+ jQuery(@).closest('.control-group').find("##{forInput}").focus()
88
+
89
+
90
+ onInputFocused: ->
91
+ jQuery(@).closest('.control-group').find('input[type=radio]').prop('checked', true)
92
+
93
+
94
+ onChangeTarget: ->
95
+ @element.find(".link-target-options").hide()
96
+ @element.find("##{@element.find('#link_target').val()}_options").show()
97
+ @resize(true)
98
+
99
+
100
+ addInputError: (input, message) ->
101
+ input.after('<span class="help-inline error-message">' + Mercury.I18n(message) + '</span>').closest('.control-group').addClass('error')
102
+ @valid = false
103
+
104
+
105
+ clearInputErrors: ->
106
+ @element.find('.control-group.error').removeClass('error').find('.error-message').remove()
107
+ @valid = true
108
+
109
+
110
+ validateForm: ->
111
+ @clearInputErrors()
112
+
113
+ type = @element.find('input[name=link_type]:checked').val()
114
+
115
+ el = @element.find("#link_#{type}")
116
+ @addInputError(el, "can't be blank") unless el.val()
117
+
118
+ if !@editing && !@content
119
+ el = @element.find('#link_text')
120
+ @addInputError(el, "can't be blank") unless el.val()
121
+
122
+
123
+ submitForm: ->
124
+ content = @element.find('#link_text').val()
125
+ target = @element.find('#link_target').val()
126
+ type = @element.find('input[name=link_type]:checked').val()
127
+
128
+ switch type
129
+ when 'existing_bookmark' then attrs = {href: "##{@element.find('#link_existing_bookmark').val()}"}
130
+ when 'new_bookmark' then attrs = {name: "#{@element.find('#link_new_bookmark').val()}"}
131
+ else attrs = {href: @element.find("#link_#{type}").val()}
132
+
133
+ switch target
134
+ when 'popup'
135
+ args = {
136
+ width: parseInt(@element.find('#link_popup_width').val()) || 500,
137
+ height: parseInt(@element.find('#link_popup_height').val()) || 500,
138
+ menubar: 'no',
139
+ toolbar: 'no'
140
+ }
141
+ attrs['href'] = "javascript:void(window.open('#{attrs['href']}', 'popup_window', '#{jQuery.param(args).replace(/&/g, ',')}'))"
142
+ else
143
+ attrs['target'] = target if target
144
+
145
+ value = {tagName: 'a', attrs: attrs, content: @content || content}
146
+
147
+ if @editing
148
+ Mercury.trigger('action', {action: 'replaceLink', value: value, node: @editing.get(0)})
149
+ else
150
+ Mercury.trigger('action', {action: 'insertLink', value: value})
151
+
152
+ }
@@ -0,0 +1,132 @@
1
+ @Mercury.modalHandlers.insertMedia = {
2
+
3
+ initialize: ->
4
+ @element.find('.control-label input').on('click', @onLabelChecked)
5
+ @element.find('.controls .optional, .controls .required').on('focus', (event) => @onInputFocused($(event.target)))
6
+
7
+ @focus('#media_image_url')
8
+ @initializeForm()
9
+
10
+ # build the image or embed/iframe on form submission
11
+ @element.find('form').on 'submit', (event) =>
12
+ event.preventDefault()
13
+ @validateForm()
14
+ unless @valid
15
+ @resize()
16
+ return
17
+ @submitForm()
18
+ @hide()
19
+
20
+
21
+ initializeForm: ->
22
+ # get the selection and initialize its information into the form
23
+ return unless Mercury.region && Mercury.region.selection
24
+ selection = Mercury.region.selection()
25
+
26
+ # if we're editing an image prefill the information
27
+ if image = selection.is?('img')
28
+ @element.find('#media_image_url').val(image.attr('src'))
29
+ @element.find('#media_image_alignment').val(image.attr('align'))
30
+ @element.find('#media_image_float').val(if image.attr('style')? then image.css('float') else '')
31
+ @focus('#media_image_url')
32
+
33
+ # if we're editing an iframe (assume it's a video for now)
34
+ if iframe = selection.is?('iframe')
35
+ src = iframe.attr('src')
36
+ if /^https?:\/\/www.youtube.com\//i.test(src)
37
+ # it's a youtube video
38
+ @element.find('#media_youtube_url').val("#{src.match(/^https?/)[0]}://youtu.be/#{src.match(/\/embed\/(\w+)/)[1]}")
39
+ @element.find('#media_youtube_width').val(iframe.width())
40
+ @element.find('#media_youtube_height').val(iframe.height())
41
+ @focus('#media_youtube_url')
42
+ else if /^https?:\/\/player.vimeo.com\//i.test(src)
43
+ # it's a vimeo video
44
+ @element.find('#media_vimeo_url').val("#{src.match(/^https?/)[0]}://vimeo.com/#{src.match(/\/video\/(\w+)/)[1]}")
45
+ @element.find('#media_vimeo_width').val(iframe.width())
46
+ @element.find('#media_vimeo_height').val(iframe.height())
47
+ @focus('#media_vimeo_url')
48
+
49
+
50
+ focus: (selector) ->
51
+ setTimeout((=> @element.find(selector).focus()), 300)
52
+
53
+
54
+ onLabelChecked: ->
55
+ forInput = jQuery(@).closest('.control-label').attr('for')
56
+ jQuery(@).closest('.control-group').find("##{forInput}").focus()
57
+
58
+
59
+ onInputFocused: (input) ->
60
+ input.closest('.control-group').find('input[type=radio]').prop('checked', true)
61
+
62
+ return if input.closest('.media-options').length
63
+ @element.find(".media-options").hide()
64
+ @element.find("##{input.attr('id').replace('media_', '')}_options").show()
65
+ @resize(true)
66
+
67
+
68
+ addInputError: (input, message) ->
69
+ input.after('<span class="help-inline error-message">' + Mercury.I18n(message) + '</span>').closest('.control-group').addClass('error')
70
+ @valid = false
71
+
72
+
73
+ clearInputErrors: ->
74
+ @element.find('.control-group.error').removeClass('error').find('.error-message').remove()
75
+ @valid = true
76
+
77
+
78
+ validateForm: ->
79
+ @clearInputErrors()
80
+
81
+ type = @element.find('input[name=media_type]:checked').val()
82
+ el = @element.find("#media_#{type}")
83
+
84
+ switch type
85
+ when 'youtube_url'
86
+ url = @element.find('#media_youtube_url').val()
87
+ @addInputError(el, "is invalid") unless /^https?:\/\/youtu.be\//.test(url)
88
+ when 'vimeo_url'
89
+ url = @element.find('#media_vimeo_url').val()
90
+ @addInputError(el, "is invalid") unless /^https?:\/\/vimeo.com\//.test(url)
91
+ else
92
+ @addInputError(el, "can't be blank") unless el.val()
93
+
94
+
95
+ submitForm: ->
96
+ type = @element.find('input[name=media_type]:checked').val()
97
+
98
+ switch type
99
+ when 'image_url'
100
+ attrs = {src: @element.find('#media_image_url').val()}
101
+ attrs['align'] = alignment if alignment = @element.find('#media_image_alignment').val()
102
+ attrs['style'] = 'float: ' + float + ';' if float = @element.find('#media_image_float').val()
103
+ Mercury.trigger('action', {action: 'insertImage', value: attrs})
104
+
105
+ when 'youtube_url'
106
+ url = @element.find('#media_youtube_url').val()
107
+ code = url.replace(/https?:\/\/youtu.be\//, '')
108
+ protocol = 'http'
109
+ protocol = 'https' if /^https:/.test(url)
110
+ value = jQuery('<iframe>', {
111
+ width: parseInt(@element.find('#media_youtube_width').val(), 10) || 560,
112
+ height: parseInt(@element.find('#media_youtube_height').val(), 10) || 349,
113
+ src: "#{protocol}://www.youtube.com/embed/#{code}?wmode=transparent",
114
+ frameborder: 0,
115
+ allowfullscreen: 'true'
116
+ })
117
+ Mercury.trigger('action', {action: 'insertHTML', value: value})
118
+
119
+ when 'vimeo_url'
120
+ url = @element.find('#media_vimeo_url').val()
121
+ code = url.replace(/^https?:\/\/vimeo.com\//, '')
122
+ protocol = 'http'
123
+ protocol = 'https' if /^https:/.test(url)
124
+ value = jQuery('<iframe>', {
125
+ width: parseInt(@element.find('#media_vimeo_width').val(), 10) || 400,
126
+ height: parseInt(@element.find('#media_vimeo_height').val(), 10) || 225,
127
+ src: "#{protocol}://player.vimeo.com/video/#{code}?title=1&byline=1&portrait=0&color=ffffff",
128
+ frameborder: 0
129
+ })
130
+ Mercury.trigger('action', {action: 'insertHTML', value: value})
131
+
132
+ }