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,159 @@
1
+ # # Mercury Dialog
2
+ #
3
+ # Dialog is a base class that's used by Palette, Select, Panel, and through Palette, the Toolbar.Expander. It's basic
4
+ # function is to provide an interface element that can be opened, interacted with, and then closed.
5
+ #
6
+ class @Mercury.Dialog
7
+
8
+ # The constructor expects a url to load, a name, and options.
9
+ #
10
+ # @url _string_ used to load the contents, either using Ajax or by pulling content from preloadedViews
11
+ #
12
+ # @name _string_ used in building of the element, and is assigned as part of the elements class (eg.
13
+ # `mercury-[name]-dialog`)
14
+ #
15
+ # @options _object_
16
+ #
17
+ # **Options**
18
+ #
19
+ # @for _Toolbar.Button_ used so the dialog can be shown/hidden based on button interactions.
20
+ #
21
+ # @preload _boolean_ if true, the view for this dialog will be loaded prior to being shown, otherwise the view will be
22
+ # loaded the first time it's shown, and cached for all future interactions.
23
+ #
24
+ # @appendTo _element_ you can append a dialog to any element by providing this option.
25
+ constructor: (@url, @name, @options = {}) ->
26
+ @button = @options.for
27
+
28
+ @build()
29
+ @bindEvents()
30
+ @preload()
31
+
32
+
33
+ # ## #build
34
+ #
35
+ # Builds the element and appends it to the DOM. You can provide an element to append it to in the options, otherwise
36
+ # it will be appended to the body.
37
+ build: ->
38
+ @element = jQuery('<div>', {class: "mercury-dialog mercury-#{@name}-dialog loading", style: 'display:none'})
39
+ @element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
40
+
41
+
42
+ # ## #bindEvents
43
+ #
44
+ # Bind to all the events we should handle. In this case we only stop the mousedown event, since dialogs aren't
45
+ # expected to have inputs etc.
46
+ #
47
+ # **Note:** By stopping the mousedown event we're limiting what's possible in dialogs, but this is needed to keep
48
+ # focus from being taken away from the active region when different things are clicked on in dialogs.
49
+ bindEvents: ->
50
+ @element.on 'mousedown', (event) ->
51
+ event.stopPropagation()
52
+
53
+
54
+ # ## #preload
55
+ #
56
+ # If the options dictate that the content should be preloaded we load the view before we do anything else. This is
57
+ # useful if you don't want to make the user wait the half second or however long the server may take to respond when
58
+ # they open various dialogs.
59
+ preload: ->
60
+ @load() if @options.preload
61
+
62
+
63
+ # ## #toggle
64
+ #
65
+ # Toggle the dialog based on current visibility.
66
+ toggle: ->
67
+ if @visible then @hide() else @show()
68
+
69
+
70
+ # ## #resize
71
+ #
72
+ # In the base class resize just calls through to show, but in the implementation classes resize typically adjusts the
73
+ # size based on it's contents.
74
+ resize: ->
75
+ @show()
76
+
77
+
78
+ # ## #show
79
+ #
80
+ # When showing a dialog it's expected that all other dialogs will close, and we fire an event for this. The dialog is
81
+ # then positioned and shown. The show animation of the dialog is typically dictated by the implementation class.
82
+ show: ->
83
+ # Tell all other dialogs to close.
84
+ Mercury.trigger('hide:dialogs', @)
85
+ @visible = true
86
+ if @loaded
87
+ @element.css({width: 'auto', height: 'auto'})
88
+ @position(@visible)
89
+ else
90
+ @position()
91
+ # Then show the element.
92
+ @appear()
93
+
94
+
95
+ # ## #position
96
+ #
97
+ # Interface method. Implementations are expected to position the dialog themselves.
98
+ #
99
+ # @keepVisible _boolean_ specifies if the element should stay visible if it's already visible.
100
+ position: (keepVisible) ->
101
+
102
+
103
+ # ## #appear
104
+ #
105
+ # Animate the element into view. After it's done showing, we load and resize it if it's not already loaded, so in
106
+ # cases where content is not preloaded we can display the dialog, fill it's contents, and then animate the resize.
107
+ appear: ->
108
+ @element.css({display: 'block', opacity: 0})
109
+ @element.animate {opacity: 0.95}, 200, 'easeInOutSine', =>
110
+ @load(=> @resize()) unless @loaded
111
+
112
+
113
+ # ## #hide
114
+ #
115
+ # Hides the element and keeps track of it's visibility.
116
+ hide: ->
117
+ @element.hide()
118
+ @visible = false
119
+
120
+
121
+ # ## #load
122
+ #
123
+ # Fetches the content that will be loaded into the dialog.
124
+ #
125
+ # @callback _function_ will be called after the content is loaded.
126
+ load: (callback) ->
127
+ return unless @url
128
+ if Mercury.preloadedViews[@url]
129
+ # If there's a preloadedView defined for the url being requested, load that one.
130
+ @loadContent(Mercury.preloadedViews[@url])
131
+ # And call the dialog handler if there's one. We've broken the handlers out into separate files so they can be
132
+ # tested more easily, but you can define your own by putting them in dialogHandlers.
133
+ Mercury.dialogHandlers[@name].call(@) if Mercury.dialogHandlers[@name]
134
+ callback() if callback
135
+ else
136
+ # Otherwise make an Ajax request to get the content.
137
+ jQuery.ajax @url, {
138
+ success: (data) =>
139
+ @loadContent(data)
140
+ Mercury.dialogHandlers[@name].call(@) if Mercury.dialogHandlers[@name]
141
+ callback() if callback
142
+ error: =>
143
+ # If the Ajax fails, we hide the dialog and alert the user about the error.
144
+ @hide()
145
+ @button.removeClass('pressed') if @button
146
+ Mercury.notify('Mercury was unable to load %s for the "%s" dialog.', @url, @name)
147
+ }
148
+
149
+
150
+ # ## #loadContent
151
+ #
152
+ # Loads content into the element, and removes the loading class.
153
+ #
154
+ # @data _mixed_ a string or jQuery object that can be inserted into the dialog.
155
+ loadContent: (data) ->
156
+ @loaded = true
157
+ @element.removeClass('loading')
158
+ @element.html(data)
159
+ @element.localize(Mercury.locale()) if Mercury.config.localization.enabled
@@ -0,0 +1,6 @@
1
+ @Mercury.dialogHandlers.backColor = ->
2
+ @element.find('.picker, .last-picked').on 'click', (event) =>
3
+ color = jQuery(event.target).css('background-color')
4
+ @element.find('.last-picked').css({background: color})
5
+ @button.css({backgroundColor: color})
6
+ Mercury.trigger('action', {action: 'backColor', value: color})
@@ -0,0 +1,6 @@
1
+ @Mercury.dialogHandlers.foreColor = ->
2
+ @element.find('.picker, .last-picked').on 'click', (event) =>
3
+ color = jQuery(event.target).css('background-color')
4
+ @element.find('.last-picked').css({background: color})
5
+ @button.css({backgroundColor: color})
6
+ Mercury.trigger('action', {action: 'foreColor', value: color})
@@ -0,0 +1,4 @@
1
+ @Mercury.dialogHandlers.formatblock = ->
2
+ @element.find('[data-tag]').on 'click', (event) =>
3
+ tag = jQuery(event.target).data('tag')
4
+ Mercury.trigger('action', {action: 'formatblock', value: tag})
@@ -0,0 +1,10 @@
1
+ @Mercury.dialogHandlers.snippetPanel = ->
2
+ # make the filter work
3
+ @element.find('input.filter').on 'keyup', =>
4
+ value = @element.find('input.filter').val()
5
+ for snippet in @element.find('li[data-filter]')
6
+ if LiquidMetal.score(jQuery(snippet).data('filter'), value) == 0 then jQuery(snippet).hide() else jQuery(snippet).show()
7
+
8
+ # when an element is dragged, set it so we have a global object
9
+ @element.find('img[data-snippet]').on 'dragstart', ->
10
+ Mercury.snippet = jQuery(@).data('snippet')
@@ -0,0 +1,4 @@
1
+ @Mercury.dialogHandlers.style = ->
2
+ @element.find('[data-class]').on 'click', (event) =>
3
+ className = jQuery(event.target).data('class')
4
+ Mercury.trigger('action', {action: 'style', value: className})
@@ -0,0 +1,3 @@
1
+ # tell everyone that Mercury has loaded
2
+ Mercury.onload() if Mercury.onload
3
+ jQuery(window).trigger('mercury:loaded')
@@ -0,0 +1,30 @@
1
+ class @Mercury.HistoryBuffer
2
+
3
+ constructor: (@maxLength = 200) ->
4
+ @index = 0
5
+ @stack = []
6
+ @markerRegExp = /<em class="mercury-marker"><\/em>/g
7
+
8
+
9
+ push: (item) ->
10
+ if jQuery.type(item) == 'string'
11
+ return if @stack[@index] && @stack[@index].replace(@markerRegExp, '') == item.replace(@markerRegExp, '')
12
+ else if jQuery.type(item) == 'object' && item.html
13
+ return if @stack[@index] && @stack[@index].html == item.html
14
+
15
+ @stack = @stack[0...@index + 1]
16
+ @stack.push(item)
17
+ @stack.shift() if @stack.length > @maxLength
18
+ @index = @stack.length - 1
19
+
20
+
21
+ undo: ->
22
+ return null if @index < 1
23
+ @index -= 1
24
+ return @stack[@index]
25
+
26
+
27
+ redo: ->
28
+ return null if @index >= @stack.length - 1
29
+ @index += 1
30
+ return @stack[@index]
@@ -0,0 +1,205 @@
1
+ @Mercury.lightview = (url, options = {}) ->
2
+ Mercury.lightview.show(url, options)
3
+ return Mercury.lightview
4
+
5
+ jQuery.extend Mercury.lightview,
6
+ minWidth: 400
7
+
8
+ show: (@url, @options = {}) ->
9
+ Mercury.trigger('focus:window')
10
+ @initialize()
11
+ if @visible then @update() else @appear()
12
+ if @options.content
13
+ setTimeout 500, => @loadContent(@options.content)
14
+
15
+
16
+ initialize: ->
17
+ return if @initialized
18
+ @build()
19
+ @bindEvents()
20
+ @initialized = true
21
+
22
+
23
+ build: ->
24
+ @element = jQuery('<div>', {class: 'mercury-lightview loading'})
25
+ @element.html('<h1 class="mercury-lightview-title"><span></span></h1>')
26
+ @element.append('<div class="mercury-lightview-content"></div>')
27
+
28
+ @overlay = jQuery('<div>', {class: 'mercury-lightview-overlay'})
29
+
30
+ @titleElement = @element.find('.mercury-lightview-title')
31
+ @titleElement.append('<a class="mercury-lightview-close"></a>') if @options.closeButton
32
+
33
+ @contentElement = @element.find('.mercury-lightview-content')
34
+
35
+ @element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
36
+ @overlay.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
37
+
38
+
39
+ bindEvents: ->
40
+ Mercury.on 'refresh', => @resize(true)
41
+ Mercury.on 'resize', => @position() if @visible
42
+
43
+ @overlay.on 'click', =>
44
+ @hide() unless @options.closeButton
45
+
46
+ @titleElement.find('.mercury-lightview-close').on 'click', =>
47
+ @hide()
48
+
49
+ @element.on 'ajax:beforeSend', (event, xhr, options) =>
50
+ options.success = (content) =>
51
+ @loadContent(content)
52
+
53
+ jQuery(document).on 'keydown', (event) =>
54
+ @hide() if event.keyCode == 27 && @visible
55
+
56
+
57
+ appear: ->
58
+ @showing = true
59
+ @position()
60
+
61
+ @overlay.show().css({opacity: 0})
62
+ @overlay.animate {opacity: 1}, 200, 'easeInOutSine', =>
63
+ @setTitle()
64
+ @element.show().css({opacity: 0})
65
+ @element.stop().animate {opacity: 1}, 200, 'easeInOutSine', =>
66
+ @visible = true
67
+ @showing = false
68
+ @load()
69
+
70
+
71
+ resize: (keepVisible) ->
72
+ visibility = if keepVisible then 'visible' else 'hidden'
73
+
74
+ viewportWidth = Mercury.displayRect.width
75
+ viewportHeight = Mercury.displayRect.fullHeight
76
+
77
+ titleHeight = @titleElement.outerHeight()
78
+
79
+ width = @contentElement.outerWidth()
80
+ width = viewportWidth - 40 if width > viewportWidth - 40 || @options.fullSize
81
+
82
+ @contentPane.css({height: 'auto'}) if @contentPane
83
+ @contentElement.css({height: 'auto', visibility: visibility, display: 'block'})
84
+
85
+ height = @contentElement.outerHeight() + titleHeight
86
+ height = viewportHeight - 20 if height > viewportHeight - 20 || @options.fullSize
87
+
88
+ width = 300 if width < 300
89
+ height = 150 if height < 150
90
+
91
+ @element.stop().animate {top: ((viewportHeight - height) / 2) + 10, left: (Mercury.displayRect.width - width) / 2, width: width, height: height}, 200, 'easeInOutSine', =>
92
+ @contentElement.css({visibility: 'visible', display: 'block'})
93
+ if @contentPane.length
94
+ @contentElement.css({height: height - titleHeight, overflow: 'visible'})
95
+ controlHeight = if @contentControl.length then @contentControl.outerHeight() else 0
96
+ @contentPane.css({height: height - titleHeight - controlHeight - 40})
97
+ @contentPane.find('.mercury-display-pane').css({width: width - 40})
98
+ else
99
+ @contentElement.css({height: height - titleHeight - 30, overflow: 'auto'})
100
+
101
+
102
+ position: ->
103
+ viewportWidth = Mercury.displayRect.width
104
+ viewportHeight = Mercury.displayRect.fullHeight
105
+
106
+ @contentPane.css({height: 'auto'}) if @contentPane
107
+ @contentElement.css({height: 'auto'})
108
+ @element.css({width: 'auto', height: 'auto', display: 'block', visibility: 'hidden'})
109
+
110
+ width = @contentElement.width() + 40
111
+ height = @contentElement.height() + @titleElement.outerHeight() + 30
112
+
113
+ width = viewportWidth - 40 if width > viewportWidth - 40 || @options.fullSize
114
+ height = viewportHeight - 20 if height > viewportHeight - 20 || @options.fullSize
115
+
116
+ width = 300 if width < 300
117
+ height = 150 if height < 150
118
+
119
+ titleHeight = @titleElement.outerHeight()
120
+ if @contentPane && @contentPane.length
121
+ @contentElement.css({height: height - titleHeight, overflow: 'visible'})
122
+ controlHeight = if @contentControl.length then @contentControl.outerHeight() else 0
123
+ @contentPane.css({height: height - titleHeight - controlHeight - 40})
124
+ @contentPane.find('.mercury-display-pane').css({width: width - 40})
125
+ else
126
+ @contentElement.css({height: height - titleHeight - 30, overflow: 'auto'})
127
+
128
+ @element.css {
129
+ top: ((viewportHeight - height) / 2) + 10,
130
+ left: (viewportWidth - width) / 2,
131
+ width: width
132
+ height: height
133
+ display: if @visible then 'block' else 'none'
134
+ visibility: 'visible'
135
+ }
136
+
137
+
138
+ update: ->
139
+ @reset()
140
+ @resize()
141
+ @load()
142
+
143
+
144
+ load: ->
145
+ @setTitle()
146
+ return unless @url
147
+ @element.addClass('loading')
148
+ if Mercury.preloadedViews[@url]
149
+ setTimeout(10, => @loadContent(Mercury.preloadedViews[@url]))
150
+ else
151
+ jQuery.ajax @url, {
152
+ headers: Mercury.ajaxHeaders()
153
+ type: @options.loadType || 'GET'
154
+ data: @options.loadData
155
+ success: (data) => @loadContent(data)
156
+ error: =>
157
+ @hide()
158
+ Mercury.notify('Mercury was unable to load %s for the lightview.', @url)
159
+ }
160
+
161
+
162
+ loadContent: (data, options = null) ->
163
+ @initialize()
164
+ @options = options || @options
165
+ @setTitle()
166
+ @loaded = true
167
+ @element.removeClass('loading')
168
+ @contentElement.html(data)
169
+ @contentElement.css({display: 'none', visibility: 'hidden'})
170
+
171
+ # for complex lightview content, we provide panes and controls
172
+ @contentPane = @element.find('.mercury-display-pane-container')
173
+ @contentControl = @element.find('.mercury-display-controls')
174
+
175
+ @options.afterLoad.call(@) if @options.afterLoad
176
+ if @options.handler
177
+ if Mercury.modalHandlers[@options.handler]
178
+ Mercury.modalHandlers[@options.handler].call(@)
179
+ else if Mercury.lightviewHandlers[@options.handler]
180
+ Mercury.lightviewHandlers[@options.handler].call(@)
181
+
182
+ @element.localize(Mercury.locale()) if Mercury.config.localization.enabled
183
+ @resize()
184
+
185
+
186
+ setTitle: ->
187
+ @titleElement.find('span').html(Mercury.I18n(@options.title))
188
+
189
+
190
+ reset: ->
191
+ @titleElement.find('span').html('')
192
+ @contentElement.html('')
193
+
194
+
195
+ hide: ->
196
+ return if @showing
197
+ @options = {}
198
+ @initialized = false
199
+
200
+ Mercury.trigger('focus:frame')
201
+ @element.hide()
202
+ @overlay.hide()
203
+ @reset()
204
+
205
+ @visible = false
@@ -0,0 +1,206 @@
1
+ Mercury.I18n['de'] =
2
+ # ## Javascript Strings
3
+
4
+ # ### Default Configuration
5
+ "Save": "Speichern"
6
+ "Save this page": "Diese Seite speichern"
7
+ "Preview": "Vorschau"
8
+ "Preview this page": "Diese Seite in der Vorschau betrachten"
9
+ "Undo": "Rückgängig"
10
+ "Undo your last action": "Letzte Aktion rückgängig machen"
11
+ "Redo": "Wiederherstellen"
12
+ "Redo your last action": "Letzte Aktion wiederherstellen"
13
+ "Link": "Link"
14
+ "Insert Link": "Link einfügen"
15
+ "Media": "Media"
16
+ "Insert Media (images and videos)": "Bilder und Videos einfügen"
17
+ "Table": "Tabelle"
18
+ "Insert Table": "Tabelle einfügen"
19
+ "Character": "Zeichen"
20
+ "Special Characters": "Sonderzeichen"
21
+ "Snippet": "Snippet"
22
+ "Snippet Panel": "Snippet-Fenster"
23
+ "History": "Verlauf"
24
+ "Page Version History": "Versionsverlauf der Seite"
25
+ "Notes": "Notizen"
26
+ "Page Notes": "Notizen der Seite"
27
+ "Style": "Stil"
28
+ "Block Format": "Blockformatierung"
29
+ "Background Color": "Hintergrundfarbe"
30
+ "Text Color": "Textfarbe"
31
+ "Bold": "Fett"
32
+ "Italicize": "Kursiv"
33
+ "Overline": "Überstrichen"
34
+ "Strikethrough": "Durchgestrichen"
35
+ "Underline": "Unterstrichen"
36
+ "Subscript": "Tiefgestellt"
37
+ "Superscript": "Hochgestellt"
38
+ "Align Left": "Linksbündig ausgerichtet"
39
+ "Center": "Zentriert"
40
+ "Align Right": "Rechtsbündig ausgerichtet"
41
+ "Justify Full": "Blocksatz"
42
+ "Unordered List": "Ungeordnete Liste"
43
+ "Numbered List": "Numerierte Liste"
44
+ "Decrease Indentation": "Einzug verkleinern"
45
+ "Increase Indentation": "Einzug vergrößern"
46
+ "Insert Table Row": "Zeile einfügen"
47
+ "Insert a table row before the cursor": "Zeile vor dem Cursor einfügen"
48
+ "Insert a table row after the cursor": "Zeile nach dem Cursor einfügen"
49
+ "Delete Table Row": "Zeile löschen"
50
+ "Delete this table row": "Aktuelle Zeile löschen"
51
+ "Insert Table Column": "Spalte einfügen"
52
+ "Insert a table column before the cursor": "Spalte vor dem Cursor einfügen"
53
+ "Insert a table column after the cursor": "Spalte nach dem Cursor einfügen"
54
+ "Delete Table Column": "Spalte löschen"
55
+ "Delete this table column": "Aktuelle Spalte löschen"
56
+ "Increase Cell Columns": "Mehr Spalten"
57
+ "Decrease Cell Columns": "Weniger Spalten"
58
+ "Increase Cell Rows": "Mehr Reihen"
59
+ "Decrease Cell Rows": "Weniger Reihen"
60
+ "Horizontal Rule": "Horizontaler Trennstrich"
61
+ "Insert a horizontal rule": "Horizontalen Trennstrich einfügen"
62
+ "Remove Formatting": "Formatierung löschen"
63
+ "Remove formatting for the selection": "Formatierung der Auswahl löschen"
64
+ "Edit HTML": "HTML bearbeiten"
65
+ "Edit the HTML content": "HTML-Inhalt bearbeiten"
66
+ "Edit Snippet Settings": "Snippet-Einstellungen bearbeiten"
67
+ "Remove Snippet": "Snippet entfernen"
68
+
69
+ # ### General
70
+ # Error Messages
71
+ "Mercury.Regions.%s is unsupported in this client. Supported browsers are %s.": "Mercury.Regions.%s wird von diesem Client nicht unterstützt. Unterstützte Browser sind: %s."
72
+ "Mercury.PageEditor can only be instantiated once.": "Mercury.PageEditor kann nur einmal instanziiert werden."
73
+ "Opera isn't a fully supported browser, your results may not be optimal.": "Opera ist ein nicht vollständig unterstützter Browser, daher sind nicht-optimale Ergebnisse möglich."
74
+ "Mercury.PageEditor failed to load: %s\n\nPlease try refreshing.": "Mercury.PageEditor konnte nicht geladen werden: %s\n\nBitte versuche die Seite neu zu laden."
75
+ "Region type is malformed, no data-type provided, or \"%s\" is unknown for the \"%s\" region.": "Regionstyp ist ungültig, kein Datentyp angegeben, oder \"%s\" ist unbekannt für die \"%s\"-Region."
76
+ "Mercury was unable to save to the url: %s": "Mercury war nicht in der Lage unter der URL zu speichern: %s"
77
+ # Confirmations
78
+ "You have unsaved changes. Are you sure you want to leave without saving them first?": "Es gibt ungespeicherte Änderungen. Möchtest du wirklich beenden, ohne die Änderungen vorher zu speichern?"
79
+
80
+ # ### Toolbar / Buttons
81
+ # Error Messages
82
+ "Unknown button type \"%s\" used for the \"%s\" button.": "Unbekannter Button-Typ \"%s\" wurde für den Button \"%s\" benutzt."
83
+ "Unknown button structure -- please provide an array, object, or string for \"%s\".": "Unbekannte Button-Struktur – bitte gib ein Array, Objekt oder einen String für \"%s\" an."
84
+
85
+ # ### Modals / Dialogs / Etc.
86
+ # Error Messages
87
+ "Mercury was unable to load %s for the \"%s\" dialog.": "Mercury konnte %s nicht für den \"%s\"-Dialog laden."
88
+ "Mercury was unable to load %s for the lightview.": "Mercury konnte %s nicht für die Lightansicht laden."
89
+ "Mercury was unable to load %s for the modal.": "Mercury konnte %s nicht für den Modaldialog laden."
90
+
91
+ # ### Snippets
92
+ # Error Messages
93
+ "Error loading the preview for the \"%s\" snippet.": "Fehler beim Laden der Vorschau für das \"%s\"-Snippet."
94
+ # Misc
95
+ "Snippet Options": "Snippet-Optionen"
96
+
97
+ # ### Uploader
98
+ # Error Messages
99
+ "Unable to process response: %s": "Nicht in der Lage, die folgende Antwort zu verarbeiten: %s"
100
+ "Error: Unable to upload the file": "Fehler: Nicht in der Lage, die Datei hochzuladen"
101
+ "Malformed response from server": "Fehlerhafte Antwort des Servers"
102
+ "Too large": "Zu groß"
103
+ "Unsupported format": "Nicht unterstütztes Format"
104
+ # Statuses
105
+ "Processing...": "Verarbeite…"
106
+ "Uploading...": "Lade hoch…"
107
+ "Aborted": "Abgebrochen"
108
+ "Successfully uploaded...": "Erfolgreich hochgeladen…"
109
+ "Name: %s": "Name: %s"
110
+ "Size: %s": "Größe: %s"
111
+ "Type: %s": "Typ: %s"
112
+
113
+ # Inserting Media
114
+ "Error: The provided youtube share url was invalid.": "Fehler: Die angegebene YouTube Share-URL war ungültig."
115
+ "Error: The provided vimeo url was invalid.": "Fehler: Die angegebene Vimeo-URL war ungültig."
116
+
117
+ # Statusbar
118
+ "Path:": "Pfad"
119
+
120
+
121
+ # ## HTML / Template Strings
122
+
123
+ # ### Modals
124
+ # Insert Link Modal (link.html)
125
+ "Link Content": "Linkbeschreibung"
126
+ "Standard Links": "Standardlinks"
127
+ "URL": "URL"
128
+ "Index / Bookmark Links": "Index/Lesezeichen-Link"
129
+ "Existing Links": "Existierender Link"
130
+ "Bookmark": "Lesezeichen"
131
+ "Options": "Optionen"
132
+ "Link Target": "Link-Ziel"
133
+ "Self (the same window or tab)": "Self (das gleiche Fenster oder Tab)"
134
+ "Blank (a new window or tab)": "Blank (ein neues Fenster oder Tab)"
135
+ "Top (removes any frames)": "Top (entfernt Frames)"
136
+ "Popup Window (javascript new window popup)": "Popupfenster"
137
+ "Popup Width": "Popup-Breite"
138
+ "Popup Height": "Popup-Höhe"
139
+ "Insert Link": "Link einfügen"
140
+
141
+ # Insert Media Modal (media.html)
142
+ "Images": "Bilder"
143
+ "Videos": "Videos"
144
+ "YouTube Share URL": "YouTube Share-URL"
145
+ "Vimeo URL": "Vimeo-URL"
146
+ "Alignment": "Ausrichtung"
147
+ "None": "Normal"
148
+ "Left": "Links"
149
+ "Right": "Rechts"
150
+ "Top": "Oben"
151
+ "Middle": "Mitte"
152
+ "Bottom": "Unten"
153
+ "Absolute Middle": "Mitte, absolut"
154
+ "Absolute Bottom": "Unten, absolut"
155
+ "Width": "Breite"
156
+ "Height": "Höhe"
157
+ "Insert Media": "Element einfügen"
158
+
159
+ # Insert Table Modal (table.html)
160
+ "Rows": "Reihen"
161
+ "Add Before": "Davor hinzufügen"
162
+ "Add After": "Danach hinzufügen"
163
+ "Remove": "Entfernen"
164
+ "Columns": "Spalten"
165
+ "Row Span": "Reihenabstand"
166
+ "Column Span": "Spaltenabstand"
167
+ "Options": "Optionen"
168
+ "Alignment": "Ausrichtung"
169
+ "Border": "Rahmen"
170
+ "Spacing": "Zwischenraum"
171
+ "Insert Table": "Tabelle einfügen"
172
+
173
+ # HTML Editor Modal (htmleditor.html)
174
+ "HTML Editor": "HTML-Editor"
175
+ "Save and Replace": "Speichern und ersetzen"
176
+
177
+ # ### Dialogs / Etc.
178
+ # Color Palettes (forecolor.html, backcolor.html)
179
+ "Last Color Picked": "Zuletzt gewählte Farbe"
180
+
181
+ # Block Format Select (formatblock.html)
182
+ "Heading 1": "Überschrift 1"
183
+ "Heading 2": "Überschrift 2"
184
+ "Heading 3": "Überschrift 3"
185
+ "Heading 4": "Überschrift 4"
186
+ "Heading 5": "Überschrift 5"
187
+ "Heading 6": "Überschrift 6"
188
+ "Paragraph": "Absatz"
189
+ "Blockquote": "Zitat"
190
+ "Formatted": "Formatiert"
191
+
192
+ # About Mercury Panel (about.html)
193
+ "Project Home": "Projekt-Website"
194
+ "Project Source": "Projekt-Quelltext"
195
+
196
+ # ### Demo / Placeholder / Defaults
197
+ "The history panel is expected to be implemented with a server back end. Since this is a demo, we didn't include it.": "Der Verlaufsdialog setzt ein Server-Backend voraus. Da dies eine Demo ist, steht es nicht zur Verfügung."
198
+
199
+ "The notes panel is expected to be implemented with a server back end. Since this is a demo, we didn't include it.": "Der Notizendialog setzt ein Server-Backend voraus. Da dies eine Demo ist, steht es nicht zur Verfügung."
200
+
201
+ "Snippet Name": "Snippet-Name"
202
+ "A one or two line long description of what this snippet does.": "Eine ein- oder zweizeilige Beschreibung dessen, was dieses Snippet tut."
203
+
204
+ "First Name": "Vorname"
205
+ "Favorite Beer": "Lieblingsbier"
206
+ "Insert Snippet": "Snippet einfügen"