mercury-rails 0.2.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. data/app/controllers/{images_controller.rb → mercury/images_controller.rb} +3 -3
  2. data/app/controllers/mercury_controller.rb +13 -3
  3. data/app/models/{image.rb → mercury/image.rb} +3 -1
  4. data/app/views/layouts/mercury.html.erb +14 -6
  5. data/app/views/mercury/lightviews/about.html +7 -3
  6. data/app/views/mercury/modals/character.html +2 -2
  7. data/app/views/mercury/modals/htmleditor.html +2 -2
  8. data/app/views/mercury/modals/link.html +3 -3
  9. data/app/views/mercury/modals/media.html +3 -3
  10. data/app/views/mercury/modals/table.html +3 -3
  11. data/app/views/mercury/panels/snippets.html +1 -1
  12. data/app/views/mercury/selects/formatblock.html +9 -9
  13. data/app/views/mercury/snippets/example/options.html.erb +27 -16
  14. data/config/engine.rb +35 -0
  15. data/db/migrate/{20110526035601_create_images.rb → 20110526035601_create_mercury_images.rb} +2 -2
  16. data/features/loading/loading.feature +1 -1
  17. data/features/loading/navigating.feature +1 -1
  18. data/features/loading/user_interface.feature +2 -2
  19. data/features/regions/editable/basic_editing.feature +8 -8
  20. data/features/regions/editable/inserting_snippets.feature +4 -5
  21. data/features/regions/editable/inserting_tables.feature +9 -9
  22. data/features/step_definitions/mercury_steps.rb +20 -23
  23. data/features/step_definitions/web_steps.rb +5 -5
  24. data/features/support/mercury_selectors.rb +1 -0
  25. data/lib/generators/mercury/install/install_generator.rb +24 -3
  26. data/lib/generators/mercury/install/templates/mongoid_paperclip_image.rb +17 -0
  27. data/lib/mercury-rails.rb +0 -1
  28. data/lib/mercury/authentication.rb +8 -0
  29. data/spec/javascripts/mercury/dialog_spec.js.coffee +28 -21
  30. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +0 -2
  31. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +0 -2
  32. data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +0 -2
  33. data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +0 -2
  34. data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +0 -2
  35. data/spec/javascripts/mercury/history_buffer_spec.js.coffee +0 -2
  36. data/spec/javascripts/mercury/lightview_spec.js.coffee +42 -21
  37. data/spec/javascripts/mercury/mercury_spec.js.coffee +87 -7
  38. data/spec/javascripts/mercury/modal_spec.js.coffee +53 -23
  39. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +0 -2
  40. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +2 -3
  41. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +0 -2
  42. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +2 -2
  43. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +0 -2
  44. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +2 -4
  45. data/spec/javascripts/mercury/native_extensions_spec.js.coffee +20 -2
  46. data/spec/javascripts/mercury/page_editor_spec.js.coffee +130 -35
  47. data/spec/javascripts/mercury/palette_spec.js.coffee +4 -6
  48. data/spec/javascripts/mercury/panel_spec.js.coffee +44 -6
  49. data/spec/javascripts/mercury/region_spec.js.coffee +42 -8
  50. data/spec/javascripts/mercury/regions/editable_spec.js.coffee +0 -2
  51. data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +0 -2
  52. data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +3 -5
  53. data/spec/javascripts/mercury/select_spec.js.coffee +4 -6
  54. data/spec/javascripts/mercury/snippet_spec.js.coffee +3 -4
  55. data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +2 -4
  56. data/spec/javascripts/mercury/statusbar_spec.js.coffee +0 -2
  57. data/spec/javascripts/mercury/table_editor_spec.js.coffee +2 -4
  58. data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +0 -2
  59. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +34 -15
  60. data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +0 -2
  61. data/spec/javascripts/mercury/toolbar_spec.js.coffee +41 -26
  62. data/spec/javascripts/mercury/tooltip_spec.js.coffee +3 -5
  63. data/spec/javascripts/mercury/uploader_spec.js.coffee +8 -14
  64. data/spec/javascripts/spec_helper.js +1 -0
  65. data/spec/javascripts/templates/mercury/page_editor.html +1 -0
  66. data/spec/javascripts/templates/mercury/region.html +2 -2
  67. data/vendor/assets/images/mercury/missing-image.png +0 -0
  68. data/vendor/assets/javascripts/mercury.js +218 -112
  69. data/vendor/assets/javascripts/mercury/dependencies/{jquery-1.6.js → jquery-1.7.js} +2030 -1595
  70. data/vendor/assets/javascripts/mercury/dependencies/jquery.additions.js +55 -0
  71. data/vendor/assets/javascripts/mercury/dialog.js.coffee +7 -5
  72. data/vendor/assets/javascripts/mercury/dialogs/backcolor.js.coffee +1 -1
  73. data/vendor/assets/javascripts/mercury/dialogs/forecolor.js.coffee +1 -1
  74. data/vendor/assets/javascripts/mercury/dialogs/formatblock.js.coffee +1 -1
  75. data/vendor/assets/javascripts/mercury/dialogs/{objectspanel.js.coffee → snippetpanel.js.coffee} +2 -2
  76. data/vendor/assets/javascripts/mercury/dialogs/style.js.coffee +1 -1
  77. data/vendor/assets/javascripts/mercury/finalize.js.coffee +3 -0
  78. data/vendor/assets/javascripts/mercury/lightview.js.coffee +76 -30
  79. data/vendor/assets/javascripts/mercury/locales/da.locale.js.coffee +211 -0
  80. data/vendor/assets/javascripts/mercury/locales/de.locale.js.coffee +206 -0
  81. data/vendor/assets/javascripts/mercury/locales/es.locale.js.coffee +211 -0
  82. data/vendor/assets/javascripts/mercury/locales/example.local.js.coffee +211 -0
  83. data/vendor/assets/javascripts/mercury/locales/fr.locale.js.coffee +211 -0
  84. data/vendor/assets/javascripts/mercury/locales/it.locale.js.coffee +208 -0
  85. data/vendor/assets/javascripts/mercury/locales/ko.local.js.coffee +206 -0
  86. data/vendor/assets/javascripts/mercury/locales/nl.locale.js.coffee +206 -0
  87. data/vendor/assets/javascripts/mercury/locales/pt.locale.js.coffee +211 -0
  88. data/vendor/assets/javascripts/mercury/locales/sv.local.js.coffee +209 -0
  89. data/vendor/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +213 -0
  90. data/vendor/assets/javascripts/mercury/mercury.js.coffee +62 -17
  91. data/vendor/assets/javascripts/mercury/modal.js.coffee +34 -21
  92. data/vendor/assets/javascripts/mercury/modals/htmleditor.js.coffee +1 -2
  93. data/vendor/assets/javascripts/mercury/modals/insertcharacter.js.coffee +3 -3
  94. data/vendor/assets/javascripts/mercury/modals/insertlink.js.coffee +4 -4
  95. data/vendor/assets/javascripts/mercury/modals/insertmedia.js.coffee +10 -9
  96. data/vendor/assets/javascripts/mercury/modals/insertsnippet.js.coffee +1 -1
  97. data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +8 -9
  98. data/vendor/assets/javascripts/mercury/native_extensions.js.coffee +26 -8
  99. data/vendor/assets/javascripts/mercury/page_editor.js.coffee +68 -46
  100. data/vendor/assets/javascripts/mercury/palette.js.coffee +1 -1
  101. data/vendor/assets/javascripts/mercury/panel.js.coffee +25 -7
  102. data/vendor/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +1 -0
  103. data/vendor/assets/javascripts/mercury/region.js.coffee +21 -17
  104. data/vendor/assets/javascripts/mercury/regions/editable.js.coffee +47 -35
  105. data/vendor/assets/javascripts/mercury/regions/markupable.js.coffee +43 -36
  106. data/vendor/assets/javascripts/mercury/regions/snippetable.js.coffee +22 -24
  107. data/vendor/assets/javascripts/mercury/select.js.coffee +3 -2
  108. data/vendor/assets/javascripts/mercury/snippet.js.coffee +2 -1
  109. data/vendor/assets/javascripts/mercury/snippet_toolbar.js.coffee +10 -7
  110. data/vendor/assets/javascripts/mercury/statusbar.js.coffee +4 -4
  111. data/vendor/assets/javascripts/mercury/table_editor.js.coffee +1 -3
  112. data/vendor/assets/javascripts/mercury/toolbar.button.js.coffee +42 -20
  113. data/vendor/assets/javascripts/mercury/toolbar.button_group.js.coffee +3 -3
  114. data/vendor/assets/javascripts/mercury/toolbar.expander.js.coffee +2 -2
  115. data/vendor/assets/javascripts/mercury/toolbar.js.coffee +8 -6
  116. data/vendor/assets/javascripts/mercury/tooltip.js.coffee +13 -9
  117. data/vendor/assets/javascripts/mercury/uploader.js.coffee +22 -16
  118. data/vendor/assets/javascripts/mercury_loader.js +2 -0
  119. data/vendor/assets/javascripts/mercury_overrides.js +6 -0
  120. data/vendor/assets/stylesheets/mercury/all_images.css.erb +89 -0
  121. data/vendor/assets/stylesheets/mercury/dialog.css +13 -4
  122. data/vendor/assets/stylesheets/mercury/lightview.css +66 -15
  123. data/vendor/assets/stylesheets/mercury/mercury.css +12 -7
  124. data/vendor/assets/stylesheets/mercury/modal.css +9 -5
  125. data/vendor/assets/stylesheets/mercury/toolbar.css +3 -29
  126. metadata +266 -144
  127. data/POST_INSTALL +0 -15
  128. data/README.md +0 -299
  129. data/VERSION +0 -1
  130. data/annotated_source.template +0 -57
  131. data/config/routes.rb +0 -15
  132. data/mercury-rails.gemspec +0 -288
  133. data/spec/javascripts/responses/blank.html +0 -1
  134. data/vendor/assets/javascripts/mercury/lightviews/imageprocessor.js.coffee +0 -2
@@ -0,0 +1,213 @@
1
+ Mercury.I18n['swedish_chef'] =
2
+ # ## Javascript Strings
3
+
4
+ # ### Default Configuration
5
+ "Save": "Sefe-a"
6
+ "Save this page": "Sefe-a thees pege-a"
7
+ "Preview": "Prefeeoo"
8
+ "Preview this page": "Prefeeoo thees pege-a"
9
+ "Undo": "Undu"
10
+ "Undo your last action": "Undu yuoor lest ecshun"
11
+ "Redo": "Redu"
12
+ "Redo your last action": "Redu yuoor lest ecshun"
13
+ "Link": "Leenk"
14
+ "Insert Link": "Insert Leenk"
15
+ "Media": "Medeea"
16
+ "Insert Media (images and videos)": "Insert Medeea (imeges und feedeus)"
17
+ "Table": "Teble-a"
18
+ "Insert Table": "Insert Teble-a"
19
+ "Character": "Cherecter"
20
+ "Special Characters": "Speceeel Cherecters"
21
+ "Snippet": "Sneeppet"
22
+ "Snippet Panel": "Sneeppet Punel"
23
+ "History": "Heestury"
24
+ "Page Version History": "Pege-a Ferseeun Heestury"
25
+ "Notes": "Nutes"
26
+ "Page Notes": "Pege-a Nutes"
27
+ "Style": "Style-a"
28
+ "Block Format": "Bluck Furmet"
29
+ "Background Color": "Beckgruoond Culur"
30
+ "Text Color": "Text Culur"
31
+ "Bold": "Buld"
32
+ "Italicize": "Iteleecize-a"
33
+ "Overline": "Ooferleene-a"
34
+ "Strikethrough": "Streekethruoogh"
35
+ "Underline": "Underleene-a"
36
+ "Subscript": "Soobscreept"
37
+ "Superscript": "Sooperscreept"
38
+ "Align Left": "Eleegn Lefft"
39
+ "Center": "Center"
40
+ "Align Right": "Eleegn Reeght"
41
+ "Justify Full": "Joosteeffy Fooll"
42
+ "Unordered List": "Unurdered Leest"
43
+ "Numbered List": "Noombered Leest"
44
+ "Decrease Indentation": "Decreese-a Indenteshun"
45
+ "Increase Indentation": "Increese-a Indenteshun"
46
+ "Insert Table Row": "Insert Teble-a Roo"
47
+ "Insert a table row before the cursor": "Insert a teble-a roo beffure-a zee coorsur"
48
+ "Insert a table row after the cursor": "Insert a teble-a roo effter zee coorsur"
49
+ "Delete Table Row": "Delete-a Teble-a Roo"
50
+ "Delete this table row": "Delete-a thees teble-a roo"
51
+ "Insert Table Column": "Insert Teble-a Culoomn"
52
+ "Insert a table column before the cursor": "Insert a teble-a culoomn beffure-a zee coorsur"
53
+ "Insert a table column after the cursor": "Insert a teble-a culoomn effter zee coorsur"
54
+ "Delete Table Column": "Delete-a Teble-a Culoomn"
55
+ "Delete this table column": "Delete-a thees teble-a culoomn"
56
+ "Increase Cell Columns": "Increese-a Cell Culoomns"
57
+ "Decrease Cell Columns": "Decreese-a Cell Culoomns"
58
+ "Increase Cell Rows": "Increese-a Cell Roos"
59
+ "Decrease Cell Rows": "Decreese-a Cell Roos"
60
+ "Horizontal Rule": "Hureezuntel Roole-a"
61
+ "Insert a horizontal rule": "Insert a hureezuntel roole-a"
62
+ "Remove Formatting": "Remufe-a Furmetteeng"
63
+ "Remove formatting for the selection": "Remufe-a furmetteeng fur zee selecshun"
64
+ "Edit HTML": "Ideet HTML"
65
+ "Edit the HTML content": "Ideet zee HTML cuntent"
66
+ "Edit Snippet Settings": "Ideet Sneeppet Setteengs"
67
+ "Remove Snippet": "Remufe-a Sneeppet"
68
+
69
+ # ### General
70
+ # Error Messages
71
+ "Mercury.Regions.%s is unsupported in this client. Supported browsers are %s.": "Mercury.Regions.%s is unsooppurted in thees cleeent. Sooppurted broosers ere-a %s Bork Bork Bork!"
72
+ "Mercury.PageEditor can only be instantiated once.": "Mercury.PageEditor cun oonly be-a instunteeeted oonce-a. Bork Bork Bork!"
73
+ "Opera isn't a fully supported browser, your results may not be optimal.": "Opera isn't a foolly sooppurted brooser, yuoor resoolts mey nut be-a oopteemel."
74
+ "Mercury.PageEditor failed to load: %s\n\nPlease try refreshing.": "Mercury.PegeEdeetur feeeled tu lued: %s\n\nPleese-a try reffresheeng."
75
+ "Region type is malformed, no data-type provided, or \"%s\" is unknown for the \"%s\" region.": "Regeeun type-a is melffurmed, nu deta-type-a prufeeded, oor \"%s\" is unknoon fur zee \"%s\" regeeun."
76
+ "Mercury was unable to save to the url: %s": "Mercury ves uneble-a tu sefe-a tu zee url: %s"
77
+ # Confirmations
78
+ "You have unsaved changes. Are you sure you want to leave without saving them first?": "Yuoo hefe-a unsefed chunges. Ere-a yuoo soore-a yuoo vunt tu leefe-a veethuoot sefeeng zeem furst?"
79
+
80
+ # ### Toolbar / Buttons
81
+ # Error Messages
82
+ "Unknown button type \"%s\" used for the \"%s\" button.": "Unknoon boottun type-a \"%s\" used fur zee \"%s\" boottun."
83
+ "Unknown button structure -- please provide an array, object, or string for \"%s\".": "Unknoon boottun strooctoore-a -- pleese-a prufeede-a un errey, oobject, oor streeng fur \"%s\"."
84
+
85
+ # ### Modals / Dialogs / Etc.
86
+ # Error Messages
87
+ "Mercury was unable to load %s for the \"%s\" dialog.": "Mercury ves uneble-a tu lued %s fur zee \"%s\" deeelug."
88
+ "Mercury was unable to load %s for the lightview.": "Mercury ves uneble-a tu lued %s fur zee leeghtfioo."
89
+ "Mercury was unable to load %s for the modal.": "Mercury ves uneble-a tu lued %s fur zee mudel."
90
+
91
+ # ### Snippets
92
+ # Error Messages
93
+ "Error loading the preview for the \"%s\" snippet.": "Irrur luedeeng zee prefeeoo fur zee \"%s\" sneeppet."
94
+ # Misc
95
+ "Snippet Options": "Sneeppet Oopshuns"
96
+
97
+ # ### Uploader
98
+ # Error Messages
99
+ "Unable to process response: %s": "Uneble-a tu prucess respunse-a: %s"
100
+ "Error: Unable to upload the file": "Irrur: Uneble-a tu uplued zee feele-a"
101
+ "Malformed response from server": "Melffurmed respunse-a frum serfer"
102
+ "Too large": "Tuu lerge-a"
103
+ "Unsupported format": "Unsooppurted furmet"
104
+ # Statuses
105
+ "Processing...": "Prucesseeng..."
106
+ "Uploading...": "Upluedeeng..."
107
+ "Aborted": "Eburted"
108
+ "Successfully uploaded...": "Sooccessffoolly uplueded..."
109
+ "Name: %s": "Neme-a: %s"
110
+ "Size: %s": "Seeze-a: %s"
111
+ "Type: %s": "Type-a: %s"
112
+
113
+ # Inserting Media
114
+ "Error: The provided youtube share url was invalid.": "Irrur: Zee prufeeded youtube shere-a url ves infeleed."
115
+ "Error: The provided vimeo url was invalid.": "Irrur: Zee prufeeded vimeo url ves infeleed."
116
+
117
+ # Statusbar
118
+ "Path:": "Pet:"
119
+
120
+
121
+ # ## HTML / Template Strings
122
+
123
+ # ### Modals
124
+ # Insert Link Modal (link.html)
125
+ "Link Content": "Leenk Cuntent"
126
+ "Standard Links": "Stunderd Leenks"
127
+ "URL": "URL"
128
+ "Index / Bookmark Links": "Index / Buukmerk Leenks"
129
+ "Existing Links": "Ixeesting Leenks"
130
+ "Bookmark": "Buukmerk"
131
+ "Options": "Oopshuns"
132
+ "Link Target": "Leenk Terget"
133
+ "Self (the same window or tab)": "Selff (zee seme-a veendoo oor teb)"
134
+ "Blank (a new window or tab)": "Blunk (a noo veendoo oor teb)"
135
+ "Top (removes any frames)": "Tup (remufes uny fremes)"
136
+ "Popup Window (javascript new window popup)": "Pupoop Veendoo (jefescreept noo veendoo pupoop)"
137
+ "Popup Width": "Pupoop Veedt"
138
+ "Popup Height": "Pupoop Heeeght"
139
+ "Insert Link": "Insert Leenk"
140
+
141
+ # Insert Media Modal (media.html)
142
+ "Images": "Imeges"
143
+ "Videos": "Feedeus"
144
+ "YouTube Share URL": "YouTube Shere-a URL"
145
+ "Vimeo URL": "Vimeo URL"
146
+ "Alignment": "Eleegnment"
147
+ "None": "Nune-a"
148
+ "Left": "Lefft"
149
+ "Right": "Reeght"
150
+ "Top": "Tup"
151
+ "Middle": "Meeddle-a"
152
+ "Bottom": "Buttum"
153
+ "Absolute Middle": "Ebsuloote-a Meeddle-a"
154
+ "Absolute Bottom": "Ebsuloote-a Buttum"
155
+ "Width": "Veedt"
156
+ "Height": "Heeeght"
157
+ "Insert Media": "Insert Medeea"
158
+
159
+ # Insert Table Modal (table.html)
160
+ "Rows": "Roos"
161
+ "Add Before": "Edd Beffure-a"
162
+ "Add After": "Edd Effter"
163
+ "Remove": "Remufe-a"
164
+ "Columns": "Culoomns"
165
+ "Row Span": "Roo Spun"
166
+ "Column Span": "Culoomn Spun"
167
+ "Options": "Oopshuns"
168
+ "Alignment": "Eleegnment"
169
+ "Border": "Burder"
170
+ "Spacing": "Speceeng"
171
+ "Insert Table": "Insert Teble-a"
172
+
173
+ # HTML Editor Modal (htmleditor.html)
174
+ "HTML Editor": "HTML Ideetur"
175
+ "Save and Replace": "Sefe-a und Replece-a"
176
+
177
+ # ### Dialogs / Etc.
178
+ # Color Palettes (forecolor.html, backcolor.html)
179
+ "Last Color Picked": "Lest Culur Peecked"
180
+
181
+ # Block Format Select (formatblock.html)
182
+ "Heading 1": "Heedeeng 1"
183
+ "Heading 2": "Heedeeng 2"
184
+ "Heading 3": "Heedeeng 3"
185
+ "Heading 4": "Heedeeng 4"
186
+ "Heading 5": "Heedeeng 5"
187
+ "Heading 6": "Heedeeng 6"
188
+ "Paragraph": "Peregreph"
189
+ "Blockquote": "Bluckqooute-a"
190
+ "Formatted": "Furmetted"
191
+
192
+ # About Mercury Panel (about.html)
193
+ "Project Home": "Pruject Hume-a"
194
+ "Project Source": "Pruject Suoorce-a"
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.": "Zee heestury punel is ixpected tu be-a implemented veet a serfer beck ind. Seence-a thees is a demu, ve-a deedn't incloode-a it."
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.": "Zee nutes punel is ixpected tu be-a implemented veet a serfer beck ind. Seence-a thees is a demu, ve-a deedn't incloode-a it."
200
+
201
+ "Snippet Name": "Sneeppet Neme-a"
202
+ "A one or two line long description of what this snippet does.": "A oone-a oor tvu leene-a lung descreepshun ooff vhet thees sneeppet dues."
203
+
204
+ "First Name": "Furst Neme-a"
205
+ "Favorite Beer": "Fefureete-a Beer"
206
+ "Insert Snippet": "Insert Sneeppet"
207
+
208
+
209
+ # ## Custom Regional Overrides (eg. swedish_chef-BORK)
210
+ _BORK_:
211
+ "Save": "Bork!"
212
+ "Snippet Options": "Bork Oopshuns"
213
+ "Insert Link": "Bork! Leenk"
@@ -1,5 +1,4 @@
1
1
  # ## Require all the dependencies
2
- #= require mercury/dependencies/jquery-1.6
3
2
  #= require mercury/dependencies/jquery-ui-1.8.13.custom
4
3
  #= require mercury/dependencies/jquery.additions
5
4
  #= require mercury/dependencies/jquery.htmlClean
@@ -31,34 +30,80 @@
31
30
  #= require_tree ./regions
32
31
  #= require_tree ./dialogs
33
32
  #= require_tree ./modals
33
+ #= require ./finalize
34
34
  #
35
35
  @Mercury ||= {}
36
- jQuery.extend @Mercury, {
37
- version: '0.2.3'
38
-
39
- # No IE support yet because it doesn't follow the W3C standards for HTML5 contentEditable (aka designMode).
40
- supported: document.getElementById && document.designMode && !jQuery.browser.konqueror && !jQuery.browser.msie
36
+ jQuery.extend @Mercury,
37
+ version: '0.3.0'
41
38
 
42
39
  # Mercury object namespaces
43
- Regions: {}
44
- modalHandlers: {}
45
- lightviewHandlers: {}
46
- dialogHandlers: {}
47
- preloadedViews: {}
40
+ Regions: Mercury.Regions || {}
41
+ modalHandlers: Mercury.modalHandlers || {}
42
+ lightviewHandlers: Mercury.lightviewHandlers || {}
43
+ dialogHandlers: Mercury.dialogHandlers || {}
44
+ preloadedViews: Mercury.preloadedViews || {}
45
+
46
+ # Custom ajax headers
47
+ ajaxHeaders: ->
48
+ headers = {}
49
+ headers[Mercury.config.csrfHeader] = Mercury.csrfToken
50
+ return headers
51
+
48
52
 
49
- # Custom event and logging methods
50
- bind: (eventName, callback) ->
51
- jQuery(top).bind("mercury:#{eventName}", callback)
53
+ # Custom event methods
54
+ on: (eventName, callback) ->
55
+ jQuery(window).on("mercury:#{eventName}", callback)
52
56
 
53
57
 
54
58
  trigger: (eventName, options) ->
55
59
  Mercury.log(eventName, options)
56
- jQuery(top).trigger("mercury:#{eventName}", options)
60
+ jQuery(window).trigger("mercury:#{eventName}", options)
61
+
62
+
63
+ # Alerting and logging methods
64
+ notify: (args...) ->
65
+ window.alert(Mercury.I18n.apply(@, args))
66
+
67
+
68
+ warn: (message, severity = 0) ->
69
+ if console
70
+ try console.warn(message)
71
+ catch e1
72
+ if severity >= 1
73
+ try console.debug(message) catch e2
74
+ else if severity >= 1
75
+ Mercury.notify(message)
76
+
77
+
78
+ deprecated: (message)->
79
+ message = "#{message} -- #{console.trace()}" if console && console.trace
80
+ #throw "deprecated: #{message}"
81
+ Mercury.warn("deprecated: #{message}", 1)
57
82
 
58
83
 
59
84
  log: ->
60
85
  if Mercury.debug && console
61
86
  return if arguments[0] == 'hide:toolbar' || arguments[0] == 'show:toolbar'
62
- try console.debug(arguments) catch e
87
+ try console.debug(arguments)
88
+ catch e
89
+
90
+
91
+ # I18n / Translation methods
92
+ locale: ->
93
+ return Mercury.determinedLocale if Mercury.determinedLocale
94
+ if Mercury.config.localization.enabled
95
+ locale = []
96
+ if navigator.language && (locale = navigator.language.toString().split('-')).length
97
+ topLocale = Mercury.I18n[locale[0]] || {}
98
+ subLocale = if locale.length > 1 then topLocale["_#{locale[1].toUpperCase()}_"]
99
+ if !Mercury.I18n[locale[0]]
100
+ locale = Mercury.config.localization.preferredLocale.split('-')
101
+ topLocale = Mercury.I18n[locale[0]] || {}
102
+ subLocale = if locale.length > 1 then topLocale["_#{locale[1].toUpperCase()}_"]
103
+ return Mercury.determinedLocale = {top: topLocale || {}, sub: subLocale || {}}
104
+
63
105
 
64
- }
106
+ I18n: (sourceString, args...) ->
107
+ locale = Mercury.locale()
108
+ translation = (locale.sub[sourceString] || locale.top[sourceString] || sourceString || '').toString()
109
+ return if args.length then translation.printf.apply(translation, args) else translation
@@ -2,14 +2,15 @@
2
2
  Mercury.modal.show(url, options)
3
3
  return Mercury.modal
4
4
 
5
- jQuery.extend Mercury.modal, {
6
-
5
+ jQuery.extend Mercury.modal,
7
6
  minWidth: 400
8
7
 
9
8
  show: (@url, @options = {}) ->
10
9
  Mercury.trigger('focus:window')
11
10
  @initialize()
12
11
  if @visible then @update() else @appear()
12
+ if @options.content
13
+ setTimeout 500, => @loadContent(@options.content)
13
14
 
14
15
 
15
16
  initialize: ->
@@ -28,23 +29,28 @@ jQuery.extend Mercury.modal, {
28
29
 
29
30
  @titleElement = @element.find('.mercury-modal-title')
30
31
  @contentContainerElement = @element.find('.mercury-modal-content-container')
32
+
31
33
  @contentElement = @element.find('.mercury-modal-content')
32
34
 
33
35
  @element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
34
36
  @overlay.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
35
37
 
36
- @titleElement.find('span').html(@options.title)
37
-
38
38
 
39
39
  bindEvents: ->
40
- Mercury.bind 'refresh', => @resize(true)
41
- Mercury.bind 'resize', => @position()
40
+ Mercury.on 'refresh', => @resize(true)
41
+ Mercury.on 'resize', => @position()
42
42
 
43
- @overlay.click => @hide()
43
+ @overlay.on 'click', =>
44
+ @hide() if @options.allowHideUsingOverlay
44
45
 
45
- @titleElement.find('a').click => @hide()
46
+ @titleElement.find('a').on 'click', =>
47
+ @hide()
46
48
 
47
- jQuery(document).bind 'keydown', (event) =>
49
+ @element.on 'ajax:beforeSend', (event, xhr, options) =>
50
+ options.success = (content) =>
51
+ @loadContent(content)
52
+
53
+ jQuery(document).on 'keydown', (event) =>
48
54
  @hide() if event.keyCode == 27 && @visible
49
55
 
50
56
 
@@ -84,7 +90,7 @@ jQuery.extend Mercury.modal, {
84
90
  @contentElement.css({height: height - titleHeight, overflow: 'visible'})
85
91
  controlHeight = if @contentControl.length then @contentControl.outerHeight() else 0
86
92
  @contentPane.css({height: height - titleHeight - controlHeight - 40})
87
- @contentPane.find('.mercury-modal-pane').css({width: width - 40})
93
+ @contentPane.find('.mercury-display-pane').css({width: width - 40})
88
94
  else
89
95
  @contentElement.css({height: height - titleHeight, overflow: 'auto'})
90
96
 
@@ -107,7 +113,7 @@ jQuery.extend Mercury.modal, {
107
113
  @contentElement.css({height: height - titleHeight, overflow: 'visible'})
108
114
  controlHeight = if @contentControl.length then @contentControl.outerHeight() else 0
109
115
  @contentPane.css({height: height - titleHeight - controlHeight - 40})
110
- @contentPane.find('.mercury-modal-pane').css({width: width - 40})
116
+ @contentPane.find('.mercury-display-pane').css({width: width - 40})
111
117
  else
112
118
  @contentElement.css({height: height - titleHeight, overflow: 'auto'})
113
119
 
@@ -131,15 +137,16 @@ jQuery.extend Mercury.modal, {
131
137
  return unless @url
132
138
  @element.addClass('loading')
133
139
  if Mercury.preloadedViews[@url]
134
- setTimeout((=> @loadContent(Mercury.preloadedViews[@url])), 10)
140
+ setTimeout(10, => @loadContent(Mercury.preloadedViews[@url]))
135
141
  else
136
142
  jQuery.ajax @url, {
137
- type: @options.loadType || 'get'
143
+ headers: Mercury.ajaxHeaders()
144
+ type: @options.loadType || 'GET'
138
145
  data: @options.loadData
139
146
  success: (data) => @loadContent(data)
140
147
  error: =>
141
148
  @hide()
142
- alert("Mercury was unable to load #{@url} for the modal.")
149
+ Mercury.notify("Mercury was unable to load %s for the modal.", @url)
143
150
  }
144
151
 
145
152
 
@@ -153,18 +160,24 @@ jQuery.extend Mercury.modal, {
153
160
  @contentElement.css({display: 'none', visibility: 'hidden'})
154
161
 
155
162
  # for complex modal content, we provide panes and controls
156
- @contentPane = @element.find('.mercury-modal-pane-container')
157
- @contentControl = @element.find('.mercury-modal-controls')
163
+ @contentPane = @element.find('.mercury-display-pane-container')
164
+ @contentControl = @element.find('.mercury-display-controls')
158
165
 
159
166
  @options.afterLoad.call(@) if @options.afterLoad
160
- if @options.handler && Mercury.modalHandlers[@options.handler]
161
- Mercury.modalHandlers[@options.handler].call(@)
167
+ if @options.handler
168
+ if Mercury.modalHandlers[@options.handler]
169
+ Mercury.modalHandlers[@options.handler].call(@)
170
+ else if Mercury.lightviewHandlers[@options.handler]
171
+ Mercury.lightviewHandlers[@options.handler].call(@)
162
172
 
173
+ @element.localize(Mercury.locale()) if Mercury.config.localization.enabled
163
174
  @resize()
164
175
 
165
176
 
166
177
  setTitle: ->
167
- @titleElement.find('span').html(@options.title)
178
+ @titleElement.find('span').html(Mercury.I18n(@options.title))
179
+ closeButton = @titleElement.find('a')
180
+ if @options.closeButton == false then closeButton.hide() else closeButton.show()
168
181
 
169
182
 
170
183
  reset: ->
@@ -174,6 +187,8 @@ jQuery.extend Mercury.modal, {
174
187
 
175
188
  hide: ->
176
189
  return if @showing
190
+ @options = {}
191
+ @initialized = false
177
192
 
178
193
  Mercury.trigger('focus:frame')
179
194
  @element.hide()
@@ -181,5 +196,3 @@ jQuery.extend Mercury.modal, {
181
196
  @reset()
182
197
 
183
198
  @visible = false
184
-
185
- }
@@ -1,11 +1,10 @@
1
1
  @Mercury.modalHandlers.htmlEditor = ->
2
2
  # fill the text area with the content
3
3
  content = Mercury.region.content(null, true, false)
4
- # content = jQuery.htmlClean(content, {format: true, replace: [], allowedClasses: ['mercury-snippet']})
5
4
  @element.find('textarea').val(content)
6
5
 
7
6
  # replace the contents on form submit
8
- @element.find('form').submit (event) =>
7
+ @element.find('form').on 'submit', (event) =>
9
8
  event.preventDefault()
10
9
  value = @element.find('textarea').val().replace(/\n/g, '')
11
10
  Mercury.trigger('action', {action: 'replaceHTML', value: value})