Commit afe871491edeab93fab64a35ebd65abba7c0e9a4
1 parent
4d7e2198
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Display loading message when add/move blocks
Showing
2 changed files
with
15 additions
and
3 deletions
Show diff stats
app/helpers/boxes_helper.rb
@@ -191,9 +191,8 @@ module BoxesHelper | @@ -191,9 +191,8 @@ module BoxesHelper | ||
191 | "before-block-#{block.id}" | 191 | "before-block-#{block.id}" |
192 | end | 192 | end |
193 | if block.nil? or modifiable?(block) | 193 | if block.nil? or modifiable?(block) |
194 | - draggable_id = "encodeURIComponent(jQuery(ui.draggable).attr('id'))" | ||
195 | - draggable_type = "encodeURIComponent(jQuery(ui.draggable).attr('data-block-type'))" | ||
196 | - content_tag('div', _('Drop Here'), :id => id, :class => 'block-target' ) + drop_receiving_element(id, :url => { :action => 'move_block', :target => id }, :accept => box.acceptable_blocks, :hoverclass => 'block-target-hover', :with => "'type='+"+draggable_type+"+'&id=' + "+draggable_id, :activeClass => 'block-target-active', :tolerance => 'pointer') | 194 | + url = url_for(:action => 'move_block', :target => id) |
195 | + content_tag('div', _('Drop Here'), :id => id, :class => 'block-target' ) + drop_receiving_element(id, :accept => box.acceptable_blocks, :hoverclass => 'block-target-hover', :activeClass => 'block-target-active', :tolerance => 'pointer', :onDrop => "function(ev, ui) { dropBlock('#{url}', '#{_('loading...')}', ev, ui);}") | ||
197 | else | 196 | else |
198 | "" | 197 | "" |
199 | end | 198 | end |
public/javascripts/block-store.js
@@ -48,3 +48,16 @@ function initBlockStore() { | @@ -48,3 +48,16 @@ function initBlockStore() { | ||
48 | }); | 48 | }); |
49 | jQuery('#block-store #block-store-filter').keyup(filterBlocks); | 49 | jQuery('#block-store #block-store-filter').keyup(filterBlocks); |
50 | } | 50 | } |
51 | + | ||
52 | +function dropBlock(url, loadingMessage, ev, ui) { | ||
53 | + var blockType = jQuery(ui.draggable).attr('data-block-type'); | ||
54 | + var blockId = jQuery(ui.draggable).attr('id'); | ||
55 | + open_loading(loadingMessage); | ||
56 | + jQuery.ajax({ | ||
57 | + data: 'type='+encodeURIComponent(blockType)+'&id=' + encodeURIComponent(blockId), | ||
58 | + dataType: 'script', | ||
59 | + type: 'post', | ||
60 | + url: url, | ||
61 | + complete: close_loading, | ||
62 | + }) | ||
63 | +} |