mercury-rails 0.3.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/POST_INSTALL +15 -0
- data/{vendor → app}/assets/images/mercury/button.png +0 -0
- data/{vendor → app}/assets/images/mercury/close.png +0 -0
- data/app/assets/images/mercury/default-snippet.png +0 -0
- data/{vendor → app}/assets/images/mercury/loading-dark.gif +0 -0
- data/{vendor → app}/assets/images/mercury/loading-light.gif +0 -0
- data/{vendor → app}/assets/images/mercury/missing-image.png +0 -0
- data/{vendor → app}/assets/images/mercury/search-icon.png +0 -0
- data/{vendor → app}/assets/images/mercury/temp-logo.png +0 -0
- data/app/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/action.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/app/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
- data/{vendor → app}/assets/javascripts/mercury.js +4 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery-1.7.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.additions.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/liquidmetal.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/showdown.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialog.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/finalize.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/lightview.js.coffee +0 -0
- data/app/assets/javascripts/mercury/locales/ar.locale.js.coffee +207 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/da.locale.js.coffee +7 -7
- data/{vendor → app}/assets/javascripts/mercury/locales/de.locale.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/es.locale.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/example.local.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/fr.locale.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/it.locale.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/ko.local.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/nl.locale.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/pt.locale.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/sv.local.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +0 -0
- data/app/assets/javascripts/mercury/locales/zh.local.js.coffee +209 -0
- data/{vendor → app}/assets/javascripts/mercury/mercury.js.coffee +9 -1
- data/{vendor → app}/assets/javascripts/mercury/modal.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/htmleditor.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/insertlink.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/insertmedia.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +1 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/inserttable.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/native_extensions.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/page_editor.js.coffee +46 -19
- data/{vendor → app}/assets/javascripts/mercury/palette.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/panel.js.coffee +2 -2
- data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +2 -2
- data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/region.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/regions/editable.js.coffee +5 -5
- data/app/assets/javascripts/mercury/regions/image.js.coffee +114 -0
- data/{vendor → app}/assets/javascripts/mercury/regions/markupable.js.coffee +0 -0
- data/app/assets/javascripts/mercury/regions/simple.js.coffee +325 -0
- data/{vendor → app}/assets/javascripts/mercury/regions/snippetable.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/select.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/snippet.js.coffee +23 -7
- data/{vendor → app}/assets/javascripts/mercury/snippet_toolbar.js.coffee +16 -4
- data/{vendor → app}/assets/javascripts/mercury/statusbar.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/support/history.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/table_editor.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/toolbar.button.js.coffee +8 -8
- data/{vendor → app}/assets/javascripts/mercury/toolbar.button_group.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/toolbar.expander.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/toolbar.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/tooltip.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/uploader.js.coffee +35 -17
- data/{vendor → app}/assets/javascripts/mercury_loader.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury_overrides.js +0 -0
- data/{vendor → app}/assets/stylesheets/mercury.css +0 -0
- data/{vendor → app}/assets/stylesheets/mercury/all_images.css.erb +0 -0
- data/app/assets/stylesheets/mercury/buttons.css +73 -0
- data/{vendor → app}/assets/stylesheets/mercury/dialog.css +13 -4
- data/app/assets/stylesheets/mercury/form.css +125 -0
- data/{vendor → app}/assets/stylesheets/mercury/lightview.css +0 -0
- data/app/assets/stylesheets/mercury/mercury.css +45 -0
- data/{vendor → app}/assets/stylesheets/mercury/modal.css +1 -1
- data/{vendor → app}/assets/stylesheets/mercury/statusbar.css +0 -0
- data/{vendor → app}/assets/stylesheets/mercury/toolbar.css +0 -0
- data/{vendor → app}/assets/stylesheets/mercury/tooltip.css +0 -0
- data/{vendor → app}/assets/stylesheets/mercury/uploader.css +0 -0
- data/{vendor → app}/assets/stylesheets/mercury_overrides.css +0 -0
- data/app/views/mercury/modals/character.html +1 -1
- data/app/views/mercury/modals/htmleditor.html +1 -1
- data/app/views/mercury/modals/link.html +1 -1
- data/app/views/mercury/modals/media.html +1 -1
- data/app/views/mercury/modals/table.html +1 -1
- data/app/views/mercury/snippets/example/options.html.erb +1 -1
- data/features/generators/authentication.feature +10 -0
- data/features/generators/images.feature +41 -0
- data/features/generators/install.feature +21 -0
- data/features/loading/loading.feature +4 -1
- data/features/loading/user_interface.feature +9 -7
- data/features/regions/editable/basic_editing.feature +27 -26
- data/features/regions/editable/inserting_links.feature +8 -7
- data/features/regions/editable/inserting_snippets.feature +7 -7
- data/features/regions/image/uploading_images.feature +0 -0
- data/features/regions/simple/basic_editing.feature +5 -0
- data/features/step_definitions/generator_steps.rb +27 -0
- data/features/step_definitions/mercury_steps.rb +1 -0
- data/features/support/aruba.rb +28 -0
- data/features/support/env.rb +12 -2
- data/features/support/mercury_contents.rb +2 -2
- data/lib/generators/mercury/install/authentication/authentication_generator.rb +15 -0
- data/lib/generators/mercury/install/images/images_generator.rb +44 -0
- data/{app/models/mercury/image.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image.rb} +3 -1
- data/{db/migrate/20110526035601_create_mercury_images.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image_migration.rb} +0 -0
- data/{app/controllers/mercury → lib/generators/mercury/install/images/templates}/images_controller.rb +0 -0
- data/lib/generators/mercury/install/{templates → images/templates}/mongoid_paperclip_image.rb +0 -0
- data/lib/generators/mercury/install/install_generator.rb +3 -20
- data/lib/mercury-rails.rb +1 -2
- data/lib/mercury/authentication.rb +1 -0
- data/lib/mercury/engine.rb +17 -0
- data/lib/mercury/rails.rb +4 -0
- data/lib/mercury/version.rb +3 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +57 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.example.yml +25 -0
- data/spec/dummy/config/database.travisci.yml +4 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/evergreen.rb +47 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/blank.html +1 -0
- data/spec/dummy/public/canvastest.html +103 -0
- data/spec/dummy/public/distro.html +349 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/frame.html +15 -0
- data/spec/dummy/public/images/bunny.gif +0 -0
- data/spec/dummy/public/images/bunny2.jpg +0 -0
- data/spec/dummy/public/index.html +392 -0
- data/spec/dummy/public/prototype.js +6082 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +55 -16
- data/spec/javascripts/mercury/panel_spec.js.coffee +2 -4
- data/spec/javascripts/mercury/regions/image_spec.js.coffee +34 -0
- data/spec/javascripts/mercury/regions/simple_spec.js.coffee +33 -0
- data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/snippet_spec.js.coffee +27 -2
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +20 -4
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +30 -0
- data/spec/javascripts/mercury/uploader_spec.js.coffee +16 -0
- data/spec/javascripts/templates/mercury/regions/image.html +1 -0
- data/spec/javascripts/templates/mercury/regions/simple.html +3 -0
- metadata +310 -158
- data/config/engine.rb +0 -41
- data/vendor/assets/images/mercury/default-snippet.png +0 -0
- data/vendor/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/vendor/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
- data/vendor/assets/stylesheets/mercury/mercury.css +0 -151
File without changes
|
File without changes
|
@@ -2,17 +2,23 @@ class @Mercury.Snippet
|
|
2
2
|
|
3
3
|
@all: []
|
4
4
|
|
5
|
-
@displayOptionsFor: (name) ->
|
6
|
-
Mercury.modal Mercury.config.snippets.optionsUrl.replace(':name', name), {
|
5
|
+
@displayOptionsFor: (name, options = {}) ->
|
6
|
+
Mercury.modal Mercury.config.snippets.optionsUrl.replace(':name', name), jQuery.extend({
|
7
7
|
title: 'Snippet Options'
|
8
8
|
handler: 'insertSnippet'
|
9
9
|
snippetName: name
|
10
|
-
}
|
10
|
+
}, options)
|
11
11
|
Mercury.snippet = null
|
12
12
|
|
13
13
|
|
14
14
|
@create: (name, options) ->
|
15
|
-
|
15
|
+
if @all.length > 0
|
16
|
+
identity = "snippet_0"
|
17
|
+
for snippet, i in @all
|
18
|
+
identity = "snippet_#{i+1}" if snippet.identity == identity
|
19
|
+
else
|
20
|
+
identity = "snippet_#{@all.length}"
|
21
|
+
|
16
22
|
instance = new Mercury.Snippet(name, identity, options)
|
17
23
|
@all.push(instance)
|
18
24
|
return instance
|
@@ -30,17 +36,26 @@ class @Mercury.Snippet
|
|
30
36
|
@all.push(instance)
|
31
37
|
|
32
38
|
|
39
|
+
@clearAll = ->
|
40
|
+
delete @all
|
41
|
+
@all = []
|
42
|
+
|
43
|
+
|
33
44
|
constructor: (@name, @identity, options = {}) ->
|
34
45
|
@version = 0
|
35
46
|
@data = ''
|
47
|
+
@wrapperTag = 'div'
|
36
48
|
@history = new Mercury.HistoryBuffer()
|
37
49
|
@setOptions(options)
|
38
50
|
|
39
51
|
|
40
52
|
getHTML: (context, callback = null) ->
|
41
|
-
element = jQuery(
|
42
|
-
|
43
|
-
|
53
|
+
element = jQuery("<#{@wrapperTag}>", {
|
54
|
+
class: "mercury-snippet #{@name}-snippet"
|
55
|
+
contenteditable: "false"
|
56
|
+
'data-snippet': @identity
|
57
|
+
'data-version': @version
|
58
|
+
}, context)
|
44
59
|
element.html("[#{@identity}]")
|
45
60
|
@loadPreview(element, callback)
|
46
61
|
return element
|
@@ -77,6 +92,7 @@ class @Mercury.Snippet
|
|
77
92
|
setOptions: (@options) ->
|
78
93
|
delete(@options['authenticity_token'])
|
79
94
|
delete(@options['utf8'])
|
95
|
+
@wrapperTag = @options.wrapperTag if @options.wrapperTag
|
80
96
|
@version += 1
|
81
97
|
@history.push(@options)
|
82
98
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
class @Mercury.SnippetToolbar extends Mercury.Toolbar
|
2
2
|
|
3
3
|
constructor: (@document, @options = {}) ->
|
4
|
+
@_boundEvents = []
|
4
5
|
super(@options)
|
5
6
|
|
6
7
|
|
@@ -14,23 +15,28 @@ class @Mercury.SnippetToolbar extends Mercury.Toolbar
|
|
14
15
|
|
15
16
|
|
16
17
|
bindEvents: ->
|
17
|
-
Mercury
|
18
|
+
@bindReleasableEvent Mercury, 'show:toolbar', (event, options) =>
|
18
19
|
return unless options.snippet
|
19
20
|
options.snippet.mouseout => @hide()
|
20
21
|
@show(options.snippet)
|
21
22
|
|
22
|
-
Mercury
|
23
|
+
@bindReleasableEvent Mercury, 'hide:toolbar', (event, options) =>
|
23
24
|
return unless options.type && options.type == 'snippet'
|
24
25
|
@hide(options.immediately)
|
25
26
|
|
27
|
+
@bindReleasableEvent jQuery(@document), 'scroll', =>
|
28
|
+
@position() if @visible
|
29
|
+
|
26
30
|
@element.mousemove =>
|
27
31
|
clearTimeout(@hideTimeout)
|
28
32
|
|
29
33
|
@element.mouseout =>
|
30
34
|
@hide()
|
31
35
|
|
32
|
-
|
33
|
-
|
36
|
+
|
37
|
+
bindReleasableEvent: (target, eventName, handler)->
|
38
|
+
target.on eventName, handler
|
39
|
+
@_boundEvents.push [target, eventName, handler]
|
34
40
|
|
35
41
|
|
36
42
|
show: (@snippet) ->
|
@@ -70,3 +76,9 @@ class @Mercury.SnippetToolbar extends Mercury.Toolbar
|
|
70
76
|
@element.hide()
|
71
77
|
@visible = false
|
72
78
|
|
79
|
+
release: ->
|
80
|
+
@element.off()
|
81
|
+
@element.remove()
|
82
|
+
target.off(eventName, handler) for [target, eventName, handler] in @_boundEvents
|
83
|
+
@_boundEvents = []
|
84
|
+
|
File without changes
|
File without changes
|
File without changes
|
@@ -34,25 +34,25 @@ class @Mercury.Toolbar.Button
|
|
34
34
|
|
35
35
|
when 'palette'
|
36
36
|
@element.addClass("mercury-button-palette")
|
37
|
-
|
38
|
-
@handled[type] = new Mercury.Palette(
|
37
|
+
result = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
|
38
|
+
@handled[type] = if typeof result is 'string' then new Mercury.Palette(result, @name, @defaultDialogOptions()) else result
|
39
39
|
|
40
40
|
when 'select'
|
41
41
|
@element.addClass("mercury-button-select").find('em').html(@title)
|
42
|
-
|
43
|
-
@handled[type] = new Mercury.Select(
|
42
|
+
result = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
|
43
|
+
@handled[type] = if typeof result is 'string' then new Mercury.Select(result, @name, @defaultDialogOptions()) else result
|
44
44
|
|
45
45
|
when 'panel'
|
46
46
|
@element.addClass('mercury-button-panel')
|
47
|
-
url = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
|
48
47
|
@handled['toggle'] = true
|
49
|
-
|
48
|
+
result = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
|
49
|
+
@handled[type] = if typeof result is 'string' then new Mercury.Panel(result, @name, @defaultDialogOptions()) else result
|
50
50
|
|
51
51
|
when 'modal'
|
52
|
-
@handled[type] = if jQuery.isFunction(mixed) then mixed.
|
52
|
+
@handled[type] = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
|
53
53
|
|
54
54
|
when 'lightview'
|
55
|
-
@handled[type] = if jQuery.isFunction(mixed) then mixed.
|
55
|
+
@handled[type] = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
|
56
56
|
|
57
57
|
else throw Mercury.I18n('Unknown button type \"%s\" used for the \"%s\" button.', type, @name)
|
58
58
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -25,7 +25,6 @@ jQuery.extend Mercury.uploader,
|
|
25
25
|
|
26
26
|
supported: ->
|
27
27
|
xhr = new XMLHttpRequest
|
28
|
-
fileReader = window.FileReader
|
29
28
|
|
30
29
|
if window.Uint8Array && window.ArrayBuffer && !XMLHttpRequest.prototype.sendAsBinary
|
31
30
|
XMLHttpRequest::sendAsBinary = (datastr) ->
|
@@ -33,8 +32,13 @@ jQuery.extend Mercury.uploader,
|
|
33
32
|
ui8a[index] = (datastr.charCodeAt(index) & 0xff) for data, index in datastr
|
34
33
|
@send(ui8a.buffer)
|
35
34
|
|
36
|
-
return !!(xhr.upload && xhr.sendAsBinary &&
|
35
|
+
return !!(xhr.upload && xhr.sendAsBinary && (Mercury.uploader.fileReaderSupported() || Mercury.uploader.formDataSupported()))
|
37
36
|
|
37
|
+
fileReaderSupported: ->
|
38
|
+
!!(window.FileReader)
|
39
|
+
|
40
|
+
formDataSupported: ->
|
41
|
+
!!(window.FormData)
|
38
42
|
|
39
43
|
build: ->
|
40
44
|
@element = jQuery('<div>', {class: 'mercury-uploader', style: 'display:none'})
|
@@ -86,8 +90,11 @@ jQuery.extend Mercury.uploader,
|
|
86
90
|
|
87
91
|
|
88
92
|
loadImage: ->
|
89
|
-
|
90
|
-
@
|
93
|
+
if Mercury.uploader.fileReaderSupported()
|
94
|
+
@file.readAsDataURL (result) =>
|
95
|
+
@element.find('.mercury-uploader-preview b').html(jQuery('<img>', {src: result}))
|
96
|
+
@upload()
|
97
|
+
else
|
91
98
|
@upload()
|
92
99
|
|
93
100
|
|
@@ -121,16 +128,28 @@ jQuery.extend Mercury.uploader,
|
|
121
128
|
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
122
129
|
xhr.setRequestHeader(Mercury.config.csrfHeader, Mercury.csrfToken)
|
123
130
|
|
124
|
-
|
125
|
-
|
126
|
-
|
131
|
+
# Homespun multipart uploads. Chrome 18, Firefox 11.
|
132
|
+
#
|
133
|
+
if Mercury.uploader.fileReaderSupported()
|
134
|
+
@file.readAsBinaryString (result) =>
|
135
|
+
|
136
|
+
multipart = new Mercury.uploader.MultiPartPost(Mercury.config.uploading.inputName, @file, result)
|
127
137
|
|
128
|
-
|
129
|
-
|
138
|
+
# update the content size so we can calculate
|
139
|
+
@file.updateSize(multipart.delta)
|
140
|
+
|
141
|
+
# set the content type and send
|
142
|
+
xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + multipart.boundary)
|
143
|
+
xhr.sendAsBinary(multipart.body)
|
144
|
+
|
145
|
+
# FormData based. Safari 5.1.2.
|
146
|
+
#
|
147
|
+
else
|
148
|
+
formData = new FormData()
|
149
|
+
formData.append(Mercury.config.uploading.inputName, @file.file, @file.file.name)
|
150
|
+
|
151
|
+
xhr.send(formData)
|
130
152
|
|
131
|
-
# set the content type and send
|
132
|
-
xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + multipart.boundary)
|
133
|
-
xhr.sendAsBinary(multipart.body)
|
134
153
|
|
135
154
|
|
136
155
|
updateStatus: (message, loaded) ->
|
@@ -180,11 +199,10 @@ jQuery.extend Mercury.uploader,
|
|
180
199
|
class Mercury.uploader.File
|
181
200
|
|
182
201
|
constructor: (@file) ->
|
183
|
-
@size = @file.size
|
184
|
-
@
|
185
|
-
@
|
186
|
-
@
|
187
|
-
@type = @file.type
|
202
|
+
@fullSize = @size = @file.size || @file.fileSize
|
203
|
+
@readableSize = @size.toBytes()
|
204
|
+
@name = @file.name || @file.fileName
|
205
|
+
@type = @file.type || @file.fileType
|
188
206
|
|
189
207
|
# add any errors if we need to
|
190
208
|
errors = []
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,73 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Buttons TODO: Refactor to a more generic button
|
4
|
+
*----------------------------------------------------------------------------*/
|
5
|
+
.btn {
|
6
|
+
-webkit-background-clip: padding;
|
7
|
+
-moz-background-clip: padding;
|
8
|
+
background-clip: padding-box;
|
9
|
+
border-radius: 0.4em;
|
10
|
+
display: block;
|
11
|
+
font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', sans-serif;
|
12
|
+
font-size: 1.2em;
|
13
|
+
background: #f5f5f5;
|
14
|
+
border: 1px solid #a9a9a9;
|
15
|
+
color: #666;
|
16
|
+
cursor: pointer;
|
17
|
+
line-height: normal;
|
18
|
+
text-shadow: 0 -1px 0 rgba(255, 255, 255, 0.75);
|
19
|
+
padding: 0.4em 0.8em;
|
20
|
+
}
|
21
|
+
.btn:visited {
|
22
|
+
color: #666;
|
23
|
+
}
|
24
|
+
.btn:hover,
|
25
|
+
.btn:focus,
|
26
|
+
.btn.active {
|
27
|
+
color: #666;
|
28
|
+
background: #ededed;
|
29
|
+
}
|
30
|
+
.btn:hover,
|
31
|
+
.btn.active {
|
32
|
+
border: 1px solid #8f8f8f;
|
33
|
+
}
|
34
|
+
.btn:hover {
|
35
|
+
-webkit-box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.7);
|
36
|
+
-moz-box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.7);
|
37
|
+
box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.7);
|
38
|
+
}
|
39
|
+
.btn:focus {
|
40
|
+
-webkit-box-shadow: 0 0 8px rgba(82, 168, 236, 0.6), inset 0 1px 4px rgba(255, 255, 255, 0.7);
|
41
|
+
-moz-box-shadow: 0 0 8px rgba(82, 168, 236, 0.6), inset 0 1px 4px rgba(255, 255, 255, 0.7);
|
42
|
+
box-shadow: 0 0 8px rgba(82, 168, 236, 0.6), inset 0 1px 4px rgba(255, 255, 255, 0.7);
|
43
|
+
border: 1px solid rgba(82, 168, 236, 0.8);
|
44
|
+
outline: 0;
|
45
|
+
}
|
46
|
+
.btn:active,
|
47
|
+
.btn.active {
|
48
|
+
-webkit-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3);
|
49
|
+
-moz-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3);
|
50
|
+
box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3);
|
51
|
+
}
|
52
|
+
|
53
|
+
/* Overrides for the blue "important" button */
|
54
|
+
.btn.important {
|
55
|
+
background: #268bd2;
|
56
|
+
border: 1px solid #16527c;
|
57
|
+
color: #fff;
|
58
|
+
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
59
|
+
}
|
60
|
+
.btn.important:visited {
|
61
|
+
color: #fff;
|
62
|
+
}
|
63
|
+
.btn.important:hover,
|
64
|
+
.btn.important:focus,
|
65
|
+
.btn.important.active {
|
66
|
+
color: #fff;
|
67
|
+
background: #2482c5;
|
68
|
+
}
|
69
|
+
.btn.important:hover,
|
70
|
+
.btn.important.active {
|
71
|
+
border: 1px solid #0f3550;
|
72
|
+
}
|
73
|
+
|
@@ -42,13 +42,13 @@
|
|
42
42
|
.mercury-panel {
|
43
43
|
position: absolute;
|
44
44
|
z-index: 10011;
|
45
|
-
background-color: #
|
45
|
+
background-color: #f5f5f5;
|
46
46
|
opacity: .9;
|
47
47
|
box-shadow: 1px 1px 4px rgba(0,0,0, .5);
|
48
48
|
-moz-box-shadow: 1px 1px 4px rgba(0,0,0, .5);
|
49
49
|
border-radius: 4px;
|
50
50
|
-moz-border-radius: 4px;
|
51
|
-
color: #
|
51
|
+
color: #333;
|
52
52
|
font-family: Helvetica, Tahoma, Arial, sans-serif;
|
53
53
|
font-size: 9.5pt;
|
54
54
|
max-width: 500px;
|
@@ -69,14 +69,23 @@
|
|
69
69
|
-webkit-user-select: none;
|
70
70
|
-moz-user-select: none;
|
71
71
|
user-select: none;
|
72
|
-
|
72
|
+
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
73
|
+
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
74
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
73
75
|
-moz-border-radius-topleft: 4px;
|
74
76
|
-moz-border-radius-topright: 4px;
|
75
77
|
border-top-left-radius: 4px;
|
76
78
|
border-top-right-radius: 4px;
|
79
|
+
color: #f5f5f5;
|
80
|
+
font-size: 10pt;
|
81
|
+
text-shadow: 1px 1px 2px rgba(0,0,0, .9);
|
82
|
+
border-bottom: 1px solid #222;
|
77
83
|
height: 15px;
|
78
84
|
cursor: move;
|
79
|
-
|
85
|
+
}
|
86
|
+
.mercury-panel h1 span {
|
87
|
+
display: block;
|
88
|
+
width: 100%;
|
80
89
|
}
|
81
90
|
.mercury-panel h1 a.mercury-panel-close {
|
82
91
|
position: absolute;
|
@@ -0,0 +1,125 @@
|
|
1
|
+
/*
|
2
|
+
* Forms
|
3
|
+
*---------------------------------------------------------------------------*/
|
4
|
+
.mercury-form,
|
5
|
+
.mercury-form ul,
|
6
|
+
.mercury-form ol,
|
7
|
+
.mercury-form li,
|
8
|
+
.mercury-form fieldset,
|
9
|
+
.mercury-form p {
|
10
|
+
margin: 0;
|
11
|
+
padding: 0;
|
12
|
+
}
|
13
|
+
.mercury-form abbr {
|
14
|
+
border: 0;
|
15
|
+
font-variant: normal;
|
16
|
+
}
|
17
|
+
.mercury-form fieldset {
|
18
|
+
margin-bottom: 10px;
|
19
|
+
background: #F6F6F6;
|
20
|
+
border: 1px solid #CCC;
|
21
|
+
border-radius: 7px;
|
22
|
+
-moz-border-radius: 7px;
|
23
|
+
}
|
24
|
+
.mercury-form fieldset:last-child {
|
25
|
+
margin-bottom: 0;
|
26
|
+
}
|
27
|
+
.mercury-form fieldset legend {
|
28
|
+
font-weight: bold;
|
29
|
+
margin-left: 10px;
|
30
|
+
margin-bottom: -4px;
|
31
|
+
}
|
32
|
+
.mercury-form ol {
|
33
|
+
margin: 12px 9px;
|
34
|
+
}
|
35
|
+
.mercury-form ol li {
|
36
|
+
display: block;
|
37
|
+
margin-bottom: 10px;
|
38
|
+
}
|
39
|
+
.mercury-form label {
|
40
|
+
display: block;
|
41
|
+
float: left;
|
42
|
+
width: 23%;
|
43
|
+
margin-right: 9px;
|
44
|
+
text-align: right;
|
45
|
+
line-height: 27px;
|
46
|
+
font-size: 1.1em;
|
47
|
+
overflow: hidden;
|
48
|
+
text-overflow: ellipsis;
|
49
|
+
white-space: nowrap;
|
50
|
+
}
|
51
|
+
.mercury-form label input {
|
52
|
+
width: auto !important;
|
53
|
+
margin: 0 5px 0 2px !important;
|
54
|
+
}
|
55
|
+
.mercury-form select,
|
56
|
+
.mercury-form input[type=text],
|
57
|
+
.mercury-form input[type=password],
|
58
|
+
.mercury-form textarea,
|
59
|
+
.mercury-form input.text {
|
60
|
+
margin: 0;
|
61
|
+
border: 2px solid #CCC;
|
62
|
+
padding: 2px 4px;
|
63
|
+
font-family: Arial, Geneva, sans-serif;
|
64
|
+
font-size: 1.5em;
|
65
|
+
width: 74%;
|
66
|
+
box-sizing: border-box;
|
67
|
+
-moz-box-sizing: border-box;
|
68
|
+
-webkit-box-sizing: border-box;
|
69
|
+
}
|
70
|
+
.mercury-form li.boolean {
|
71
|
+
margin-left: 23%;
|
72
|
+
padding-left: 9px;
|
73
|
+
}
|
74
|
+
.mercury-form li.boolean label {
|
75
|
+
width: auto;
|
76
|
+
}
|
77
|
+
.mercury-form fieldset.buttons,
|
78
|
+
.mercury-form fieldset.actions {
|
79
|
+
clear: both;
|
80
|
+
padding: 0;
|
81
|
+
background: none;
|
82
|
+
border: none;
|
83
|
+
text-align: left;
|
84
|
+
}
|
85
|
+
.mercury-form fieldset.buttons ol,
|
86
|
+
.mercury-form fieldset.actions ol {
|
87
|
+
margin: 0 -2px 0 0;
|
88
|
+
float: right;
|
89
|
+
}
|
90
|
+
.mercury-form fieldset.buttons ol li,
|
91
|
+
.mercury-form fieldset.actions ol li {
|
92
|
+
float: left;
|
93
|
+
padding-left: 0.5em;
|
94
|
+
padding-right: 0;
|
95
|
+
}
|
96
|
+
.mercury-form fieldset.buttons .commit,
|
97
|
+
.mercury-form fieldset.actions .action {
|
98
|
+
margin: 0;
|
99
|
+
}
|
100
|
+
.mercury-form fieldset.buttons .commit input,
|
101
|
+
.mercury-form fieldset.actions .action input {
|
102
|
+
-webkit-background-clip: padding;
|
103
|
+
-moz-background-clip: padding;
|
104
|
+
background-clip: padding-box;
|
105
|
+
border-radius: 0.4em;
|
106
|
+
display: block;
|
107
|
+
font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', sans-serif;
|
108
|
+
font-size: 1.2em;
|
109
|
+
background: #268bd2;
|
110
|
+
border: 1px solid #16527c;
|
111
|
+
color: #fff;
|
112
|
+
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
113
|
+
cursor: pointer;
|
114
|
+
line-height: normal;
|
115
|
+
padding: 0.4em 0.8em;
|
116
|
+
}
|
117
|
+
.mercury-form fieldset.buttons .commit input:hover,
|
118
|
+
.mercury-form fieldset.actions .action input:hover {
|
119
|
+
color: #fff;
|
120
|
+
background: #2482c5;
|
121
|
+
border: 1px solid #0f3550;
|
122
|
+
-webkit-box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.7);
|
123
|
+
-moz-box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.7);
|
124
|
+
box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.7);
|
125
|
+
}
|