new file input behaviour (for now just on editable_file)
This commit is contained in:
parent
0b7cc6ebd2
commit
b2a5e1de85
6
Gemfile
6
Gemfile
@ -61,9 +61,9 @@ group :development do
|
|||||||
end
|
end
|
||||||
|
|
||||||
group :test, :development do
|
group :test, :development do
|
||||||
gem 'linecache', '0.43', :platforms => :mri_18
|
# gem 'linecache', '0.43', :platforms => :mri_18
|
||||||
gem 'ruby-debug', :platforms => :mri_18
|
# gem 'ruby-debug', :platforms => :mri_18
|
||||||
gem 'ruby-debug19', :platforms => :mri_19, :require => 'ruby-debug'
|
# gem 'ruby-debug19', :platforms => :mri_19, :require => 'ruby-debug'
|
||||||
gem 'cucumber-rails'
|
gem 'cucumber-rails'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
23
Gemfile.lock
23
Gemfile.lock
@ -82,7 +82,6 @@ GEM
|
|||||||
activesupport (3.1.1)
|
activesupport (3.1.1)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
addressable (2.2.6)
|
addressable (2.2.6)
|
||||||
archive-tar-minitar (0.5.2)
|
|
||||||
arel (2.2.1)
|
arel (2.2.1)
|
||||||
autotest (4.4.6)
|
autotest (4.4.6)
|
||||||
ZenTest (>= 4.4.1)
|
ZenTest (>= 4.4.1)
|
||||||
@ -119,7 +118,6 @@ GEM
|
|||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.1.3)
|
coffee-script-source (1.1.3)
|
||||||
columnize (0.3.4)
|
|
||||||
cucumber (1.1.1)
|
cucumber (1.1.1)
|
||||||
builder (>= 2.1.2)
|
builder (>= 2.1.2)
|
||||||
diff-lcs (>= 1.1.2)
|
diff-lcs (>= 1.1.2)
|
||||||
@ -188,9 +186,6 @@ GEM
|
|||||||
kgio (2.6.0)
|
kgio (2.6.0)
|
||||||
launchy (2.0.5)
|
launchy (2.0.5)
|
||||||
addressable (~> 2.2.6)
|
addressable (~> 2.2.6)
|
||||||
linecache (0.43)
|
|
||||||
linecache19 (0.5.12)
|
|
||||||
ruby_core_source (>= 0.1.4)
|
|
||||||
locomotive_liquid (2.2.2)
|
locomotive_liquid (2.2.2)
|
||||||
mail (2.3.0)
|
mail (2.3.0)
|
||||||
i18n (>= 0.4.0)
|
i18n (>= 0.4.0)
|
||||||
@ -268,22 +263,7 @@ GEM
|
|||||||
activesupport (~> 3.0)
|
activesupport (~> 3.0)
|
||||||
railties (~> 3.0)
|
railties (~> 3.0)
|
||||||
rspec (~> 2.6.0)
|
rspec (~> 2.6.0)
|
||||||
ruby-debug (0.10.4)
|
|
||||||
columnize (>= 0.1)
|
|
||||||
ruby-debug-base (~> 0.10.4.0)
|
|
||||||
ruby-debug-base (0.10.4)
|
|
||||||
linecache (>= 0.3)
|
|
||||||
ruby-debug-base19 (0.11.25)
|
|
||||||
columnize (>= 0.3.1)
|
|
||||||
linecache19 (>= 0.5.11)
|
|
||||||
ruby_core_source (>= 0.1.4)
|
|
||||||
ruby-debug19 (0.11.6)
|
|
||||||
columnize (>= 0.3.1)
|
|
||||||
linecache19 (>= 0.5.11)
|
|
||||||
ruby-debug-base19 (>= 0.11.19)
|
|
||||||
ruby-hmac (0.4.0)
|
ruby-hmac (0.4.0)
|
||||||
ruby_core_source (0.1.5)
|
|
||||||
archive-tar-minitar (>= 0.5.2)
|
|
||||||
rubyzip (0.9.4)
|
rubyzip (0.9.4)
|
||||||
sanitize (2.0.3)
|
sanitize (2.0.3)
|
||||||
nokogiri (>= 1.4.4, < 1.6)
|
nokogiri (>= 1.4.4, < 1.6)
|
||||||
@ -361,7 +341,6 @@ DEPENDENCIES
|
|||||||
jquery-rails (~> 1.0.16)
|
jquery-rails (~> 1.0.16)
|
||||||
kaminari
|
kaminari
|
||||||
launchy
|
launchy
|
||||||
linecache (= 0.43)
|
|
||||||
locomotive_liquid (= 2.2.2)
|
locomotive_liquid (= 2.2.2)
|
||||||
locomotive_mongoid_acts_as_tree!
|
locomotive_mongoid_acts_as_tree!
|
||||||
mimetype-fu (~> 0.1.2)
|
mimetype-fu (~> 0.1.2)
|
||||||
@ -376,8 +355,6 @@ DEPENDENCIES
|
|||||||
rmagick (= 2.12.2)
|
rmagick (= 2.12.2)
|
||||||
rspec-cells
|
rspec-cells
|
||||||
rspec-rails (= 2.6.1)
|
rspec-rails (= 2.6.1)
|
||||||
ruby-debug
|
|
||||||
ruby-debug19
|
|
||||||
rubyzip
|
rubyzip
|
||||||
sanitize (~> 2.0.3)
|
sanitize (~> 2.0.3)
|
||||||
sass-rails (~> 3.1.4)
|
sass-rails (~> 3.1.4)
|
||||||
|
@ -9,15 +9,16 @@ class Locomotive.Views.EditableElements.EditAllView extends Backbone.View
|
|||||||
_editable_elements_views: []
|
_editable_elements_views: []
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
window.foo = @collection
|
if @collection.isEmpty()
|
||||||
|
$(@el).hide()
|
||||||
|
else
|
||||||
|
@blocks = @collection.blocks()
|
||||||
|
|
||||||
@blocks = @collection.blocks()
|
$(@el).html(ich.editable_elements_edit(blocks: @blocks))
|
||||||
|
|
||||||
$(@el).html(ich.editable_elements_edit(blocks: @blocks))
|
@render_elements()
|
||||||
|
|
||||||
@render_elements()
|
@enable_nav()
|
||||||
|
|
||||||
@enable_nav()
|
|
||||||
|
|
||||||
return @
|
return @
|
||||||
|
|
||||||
|
@ -6,7 +6,66 @@ class Locomotive.Views.EditableElements.FileView extends Backbone.View
|
|||||||
|
|
||||||
className: 'file input'
|
className: 'file input'
|
||||||
|
|
||||||
|
states:
|
||||||
|
change: false
|
||||||
|
delete: false
|
||||||
|
|
||||||
|
events:
|
||||||
|
'click a.change': 'toggle_change'
|
||||||
|
'click a.delete': 'toggle_delete'
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
$(@el).html(ich.editable_file_input(@model.toJSON()))
|
$(@el).html(ich.editable_file_input(@model.toJSON()))
|
||||||
|
|
||||||
return @
|
return @
|
||||||
|
|
||||||
|
toggle_change: (event) ->
|
||||||
|
@_toggle event, 'change',
|
||||||
|
on_change: =>
|
||||||
|
@$('a:first').hide() & @$('input[type=file]').show() & @$('a.delete').hide()
|
||||||
|
on_cancel: =>
|
||||||
|
@$('a:first').show() & @$('input[type=file]').hide() & @$('a.delete').show()
|
||||||
|
|
||||||
|
toggle_delete: (event) ->
|
||||||
|
@_toggle event, 'delete',
|
||||||
|
on_change: =>
|
||||||
|
@$('a:first').addClass('deleted') & @$('a.change').hide()
|
||||||
|
@$('input[type=hidden].remove-flag').val('1')
|
||||||
|
on_cancel: =>
|
||||||
|
@$('a:first').removeClass('deleted') & @$('a.change').show()
|
||||||
|
@$('input[type=hidden].remove-flag').val('0')
|
||||||
|
|
||||||
|
_toggle: (event, state, options) ->
|
||||||
|
event.stopPropagation() & event.preventDefault()
|
||||||
|
|
||||||
|
button = $(event.target)
|
||||||
|
label = button.attr('data-alt-label')
|
||||||
|
|
||||||
|
unless @states[state]
|
||||||
|
options.on_change()
|
||||||
|
else
|
||||||
|
options.on_cancel()
|
||||||
|
|
||||||
|
button.attr('data-alt-label', button.html())
|
||||||
|
|
||||||
|
button.html(label)
|
||||||
|
|
||||||
|
@states[state] = !@states[state]
|
||||||
|
|
||||||
|
|
||||||
|
# toggle_change: (event) ->
|
||||||
|
# event.stopPropagation() & event.preventDefault()
|
||||||
|
#
|
||||||
|
# button = $(event.target)
|
||||||
|
# label = button.attr('data-cancel-label')
|
||||||
|
#
|
||||||
|
# unless @changing
|
||||||
|
# @$('a:first').hide() & @$('input[type=file]').show() & @$('a.delete').hide()
|
||||||
|
# else
|
||||||
|
# @$('a:first').show() & @$('input[type=file]').hide() & @$('a.delete').show()
|
||||||
|
#
|
||||||
|
# button.attr('data-alt-label', button.html())
|
||||||
|
#
|
||||||
|
# button.html(label)
|
||||||
|
#
|
||||||
|
# @changing = !@changing
|
@ -105,4 +105,35 @@
|
|||||||
&:active, &.active {
|
&:active, &.active {
|
||||||
top: 1px;
|
top: 1px;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin blue-button {
|
||||||
|
display: inline-block;
|
||||||
|
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.4);
|
||||||
|
@include border-radius(5px);
|
||||||
|
|
||||||
|
line-height: 19px !important;
|
||||||
|
|
||||||
|
padding: 0px 7px;
|
||||||
|
|
||||||
|
@include background-image(linear-gradient(top, #2abaf1, #228dda));
|
||||||
|
@include box-shadow(rgba(0, 0, 0, 0.3) 1px 1px 0px 0px, rgba(255, 255, 255, 0.5) 0px 1px 0px 0px inset);
|
||||||
|
|
||||||
|
font-size: 12px;
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
@include text-shadow(rgba(0, 0, 0, 0.8), 0px, 1px, 0px);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
@include background-image(linear-gradient(top, #26a1e9, #0d6893));
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
top: 1px;
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,6 +2,8 @@
|
|||||||
@import "compass/css3/border-radius";
|
@import "compass/css3/border-radius";
|
||||||
@import "compass/css3/text-shadow";
|
@import "compass/css3/text-shadow";
|
||||||
@import "compass/css3/box-shadow";
|
@import "compass/css3/box-shadow";
|
||||||
|
@import "buttons";
|
||||||
|
@import "helpers";
|
||||||
|
|
||||||
#editable-elements {
|
#editable-elements {
|
||||||
|
|
||||||
@ -12,8 +14,6 @@
|
|||||||
|
|
||||||
border-bottom: 1px solid #ccced7;
|
border-bottom: 1px solid #ccced7;
|
||||||
|
|
||||||
// padding: 5px 0px;
|
|
||||||
|
|
||||||
@include border-top-radius(8px);
|
@include border-top-radius(8px);
|
||||||
@include background-image(linear-gradient(#ebedf4, #d7dbe7));
|
@include background-image(linear-gradient(#ebedf4, #d7dbe7));
|
||||||
|
|
||||||
@ -21,8 +21,6 @@
|
|||||||
float: left;
|
float: left;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
||||||
// margin-left: 20px;
|
|
||||||
|
|
||||||
line-height: 31px;
|
line-height: 31px;
|
||||||
padding: 0px 20px 0 20px;
|
padding: 0px 20px 0 20px;
|
||||||
|
|
||||||
@ -61,6 +59,28 @@
|
|||||||
fieldset {
|
fieldset {
|
||||||
ol {
|
ol {
|
||||||
border-top: none;
|
border-top: none;
|
||||||
|
|
||||||
|
li.file {
|
||||||
|
span.file {
|
||||||
|
a:first-child {
|
||||||
|
@include hover-link;
|
||||||
|
|
||||||
|
margin-right: 20px;
|
||||||
|
|
||||||
|
color: #1F82BC;
|
||||||
|
|
||||||
|
&.deleted {
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
a.change, a.delete {
|
||||||
|
@include blue-button;
|
||||||
|
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // fieldset
|
} // fieldset
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
module Locomotive
|
module Locomotive
|
||||||
class EditableFilePresenter < EditableElementPresenter
|
class EditableFilePresenter < EditableElementPresenter
|
||||||
|
|
||||||
delegate :url, :to => :source
|
delegate :content, :to => :source
|
||||||
|
|
||||||
def filename
|
def filename
|
||||||
File.basename(self.source.url)
|
File.basename(self.content)
|
||||||
end
|
end
|
||||||
|
|
||||||
def included_methods
|
def included_methods
|
||||||
super + %w(filename url)
|
super + %w(filename content url)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -30,7 +30,20 @@
|
|||||||
|
|
||||||
%label{ :for => 'page_editable_elements_attributes_{{index}}_content' } {{label}}
|
%label{ :for => 'page_editable_elements_attributes_{{index}}_content' } {{label}}
|
||||||
|
|
||||||
= file_field_tag 'page[editable_elements_attributes][{{index}}][source]', :id => 'page_editable_elements_attributes_{{index}}_source'
|
%span.file
|
||||||
|
{{#if content}}
|
||||||
|
= link_to '{{filename}}', '{{content}}', :target => '_blank'
|
||||||
|
|
||||||
|
= file_field_tag 'page[editable_elements_attributes][{{index}}][source]', :id => 'page_editable_elements_attributes_{{index}}_source', :style => 'display: none'
|
||||||
|
|
||||||
|
= link_to t('locomotive.pages.form.change_file'), '#', :class => 'change', :'data-alt-label' => t('locomotive.pages.form.cancel')
|
||||||
|
= link_to t('locomotive.pages.form.delete_file'), '#', :class => 'delete', :'data-alt-label' => t('locomotive.pages.form.cancel')
|
||||||
|
|
||||||
|
= hidden_field_tag 'page[editable_elements_attributes][{{index}}][remove_source]', '0', :class => 'remove-flag'
|
||||||
|
|
||||||
|
{{else}}
|
||||||
|
= file_field_tag 'page[editable_elements_attributes][{{index}}][source]', :id => 'page_editable_elements_attributes_{{index}}_source'
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#if hint}}
|
{{#if hint}}
|
||||||
%p.inline-hints {{hint}}
|
%p.inline-hints {{hint}}
|
||||||
|
@ -113,7 +113,9 @@ en:
|
|||||||
help: "The page title can be updated by clicking it. To apply your changes, click on the \"Save\" button."
|
help: "The page title can be updated by clicking it. To apply your changes, click on the \"Save\" button."
|
||||||
ask_for_title: "Please type the new page title"
|
ask_for_title: "Please type the new page title"
|
||||||
form:
|
form:
|
||||||
delete_file: Delete file
|
change_file: change
|
||||||
|
delete_file: delete
|
||||||
|
cancel: cancel
|
||||||
default_block: Default
|
default_block: Default
|
||||||
cache_strategy:
|
cache_strategy:
|
||||||
none: None
|
none: None
|
||||||
|
@ -112,7 +112,9 @@ fr:
|
|||||||
help: "Le titre de la page est modifiable en cliquant dessus. Pour appliquer votre modification, cliquez après sur le bouton \"Modifier\""
|
help: "Le titre de la page est modifiable en cliquant dessus. Pour appliquer votre modification, cliquez après sur le bouton \"Modifier\""
|
||||||
ask_for_title: "Veuillez entrer le nouveau titre"
|
ask_for_title: "Veuillez entrer le nouveau titre"
|
||||||
form:
|
form:
|
||||||
delete_file: Supprimer fichier
|
change_file: changer
|
||||||
|
delete_file: supprimer
|
||||||
|
cancel: annuler
|
||||||
default_block: Défaut
|
default_block: Défaut
|
||||||
cache_strategy:
|
cache_strategy:
|
||||||
none: Aucun
|
none: Aucun
|
||||||
|
Loading…
Reference in New Issue
Block a user