Commit fd1ffa3ad1b81f05320c2043a77888fdb3a9240e
1 parent
c0e02028
Exists in
master
and in
29 other branches
container_block: toggle move of children on hover
Showing
3 changed files
with
22 additions
and
6 deletions
Show diff stats
plugins/container_block/public/container_block.js
1 | -function toggleMoveContainerChildren(container, box) { | |
1 | +function enableMoveContainerChildren(container, box) { | |
2 | 2 | var div = jQuery('#box-'+box+' > .block-outer > .block'); |
3 | - if(div.is('.ui-resizable')) { | |
4 | - div.find("a").die("click"); | |
5 | - div.resizable('destroy'); | |
6 | - } else { | |
3 | + if(!div.is('.ui-resizable')) { | |
7 | 4 | div.find("a").live("click", function(e) { |
8 | 5 | e.preventDefault(); |
9 | 6 | }); |
... | ... | @@ -17,6 +14,14 @@ function toggleMoveContainerChildren(container, box) { |
17 | 14 | } |
18 | 15 | } |
19 | 16 | |
17 | +function disableMoveContainerChildren(container, box) { | |
18 | + var div = jQuery('#box-'+box+' > .block-outer > .block'); | |
19 | + if(div.is('.ui-resizable')) { | |
20 | + div.find("a").die("click"); | |
21 | + div.resizable('destroy'); | |
22 | + } | |
23 | +} | |
24 | + | |
20 | 25 | function containerChildrenWidth(container, box) { |
21 | 26 | widths = ""; |
22 | 27 | jQuery('#box-'+box+' > .block-outer > .block').each(function(i) { | ... | ... |
plugins/container_block/public/style.css
plugins/container_block/views/blocks/container.rhtml
... | ... | @@ -15,8 +15,18 @@ |
15 | 15 | </style> |
16 | 16 | |
17 | 17 | <% if edit_mode %> |
18 | + | |
19 | + <script> | |
20 | + jQuery("#block-<%= block.id %>").hover( | |
21 | + function() { | |
22 | + enableMoveContainerChildren(<%= block.id %>, <%= block.container_box.id %>); | |
23 | + }, function() { | |
24 | + disableMoveContainerChildren(<%= block.id %>, <%= block.container_box.id %>); | |
25 | + } | |
26 | + ); | |
27 | + </script> | |
28 | + | |
18 | 29 | <div class="container-block-button-bar button-bar"> |
19 | - <a href="#" onclick="toggleMoveContainerChildren(<%= block.id %>, <%= block.container_box.id %>); return false;" class="button icon-resize" title=<%= _('Resize blocks').to_json %>></a> | |
20 | 30 | <%= link_to_remote '', :url => { :controller => @controller.boxes_holder.kind_of?(Environment) ? 'container_block_plugin_admin' : 'container_block_plugin_myprofile', :action => 'saveWidths', :id => block.id }, |
21 | 31 | :with => "containerChildrenWidth(#{block.id}, #{block.container_box.id})", |
22 | 32 | :html => {:class => "button icon-save container_block_save", :id => "container_block_save_#{block.id}", :title => _('Save') }, | ... | ... |