Commit f9b20af91abfb155d60675308737005f3cf9ebb0
1 parent
61fb5948
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Move block store javascript into a separated file
Showing
4 changed files
with
44 additions
and
31 deletions
Show diff stats
app/helpers/boxes_helper.rb
... | ... | @@ -203,7 +203,7 @@ module BoxesHelper |
203 | 203 | def block_handle(block) |
204 | 204 | return "" unless modifiable?(block) |
205 | 205 | block_draggable("block-#{block.id}", |
206 | - :helper => "function(){$(this).addClass('ui-draggable-dragging'); return '#{display_icon(block.class)}'}") | |
206 | + :helper => "function() {return cloneDraggableBlock($(this), '#{display_icon(block.class)}')}") | |
207 | 207 | end |
208 | 208 | |
209 | 209 | def block_draggable(element_id, options={}) |
... | ... | @@ -213,8 +213,8 @@ module BoxesHelper |
213 | 213 | :helper => '"clone"', |
214 | 214 | :revertDuration => 200, |
215 | 215 | :scroll => false, |
216 | - :start => "function() {$('#box-organizer').addClass('shadow')}", | |
217 | - :stop => "function() {$('#box-organizer').removeClass('shadow'); $('.ui-draggable-dragging').removeClass('ui-draggable-dragging')}" | |
216 | + :start => "startDragBlock", | |
217 | + :stop => "stopDragBlock", | |
218 | 218 | }.merge(options) |
219 | 219 | draggable_element(element_id, draggable_options) |
220 | 220 | end | ... | ... |
app/views/box_organizer/index.html.erb
... | ... | @@ -26,30 +26,3 @@ |
26 | 26 | </div> |
27 | 27 | </div> |
28 | 28 | <div id="block-store-draggables"></div> |
29 | - | |
30 | -<script> | |
31 | -var store = $('#block-store #block-types').slick({ | |
32 | - infinite: true, | |
33 | - dots: true, | |
34 | - draggable: false, | |
35 | - respondTo: 'slider', | |
36 | - slidesToShow: 7, | |
37 | - slidesToScroll: 4, | |
38 | - responsive: [ | |
39 | - { | |
40 | - breakpoint: 2048, | |
41 | - settings: { | |
42 | - slidesToShow: 10, | |
43 | - slidesToScroll: 4, | |
44 | - } | |
45 | - }, | |
46 | - { | |
47 | - breakpoint: 1024, | |
48 | - settings: { | |
49 | - slidesToShow: 8, | |
50 | - slidesToScroll: 4, | |
51 | - } | |
52 | - } | |
53 | - ] | |
54 | -}); | |
55 | -</script> | ... | ... |
app/views/layouts/_javascript.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | 'jquery-timepicker-addon/dist/jquery-ui-timepicker-addon', 'inputosaurus.js', 'select-or-die/_src/selectordie', |
6 | 6 | 'slick.js', |
7 | 7 | # noosfero libraries |
8 | - 'application.js', 'modal.js', | |
8 | + 'application.js', 'modal.js', 'block-store.js', | |
9 | 9 | 'add-and-join', 'report-abuse', 'catalog', 'manage-products', 'autogrow', |
10 | 10 | :cache => 'cache/application' %> |
11 | 11 | ... | ... |
... | ... | @@ -0,0 +1,40 @@ |
1 | +function cloneDraggableBlock(el, blockIcon) { | |
2 | + el.addClass('ui-draggable-dragging'); | |
3 | + return blockIcon; | |
4 | +} | |
5 | + | |
6 | +function startDragBlock() { | |
7 | + $('#box-organizer').addClass('shadow'); | |
8 | +} | |
9 | + | |
10 | +function stopDragBlock() { | |
11 | + $('#box-organizer').removeClass('shadow'); | |
12 | + $('.ui-draggable-dragging').removeClass('ui-draggable-dragging'); | |
13 | +} | |
14 | + | |
15 | +jQuery(document).ready(function($) { | |
16 | + var store = $('#block-store #block-types').slick({ | |
17 | + infinite: true, | |
18 | + dots: true, | |
19 | + draggable: false, | |
20 | + respondTo: 'slider', | |
21 | + slidesToShow: 7, | |
22 | + slidesToScroll: 4, | |
23 | + responsive: [ | |
24 | + { | |
25 | + breakpoint: 2048, | |
26 | + settings: { | |
27 | + slidesToShow: 10, | |
28 | + slidesToScroll: 4, | |
29 | + } | |
30 | + }, | |
31 | + { | |
32 | + breakpoint: 1024, | |
33 | + settings: { | |
34 | + slidesToShow: 8, | |
35 | + slidesToScroll: 4, | |
36 | + } | |
37 | + } | |
38 | + ] | |
39 | + }); | |
40 | +}); | ... | ... |