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 | var div = jQuery('#box-'+box+' > .block-outer > .block'); | 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 | div.find("a").live("click", function(e) { | 4 | div.find("a").live("click", function(e) { |
8 | e.preventDefault(); | 5 | e.preventDefault(); |
9 | }); | 6 | }); |
@@ -17,6 +14,14 @@ function toggleMoveContainerChildren(container, box) { | @@ -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 | function containerChildrenWidth(container, box) { | 25 | function containerChildrenWidth(container, box) { |
21 | widths = ""; | 26 | widths = ""; |
22 | jQuery('#box-'+box+' > .block-outer > .block').each(function(i) { | 27 | jQuery('#box-'+box+' > .block-outer > .block').each(function(i) { |
plugins/container_block/public/style.css
@@ -46,6 +46,7 @@ | @@ -46,6 +46,7 @@ | ||
46 | #box-organizer .block .container-block-button-bar { | 46 | #box-organizer .block .container-block-button-bar { |
47 | right: 0px; | 47 | right: 0px; |
48 | bottom: 0px; | 48 | bottom: 0px; |
49 | + height: auto; | ||
49 | } | 50 | } |
50 | 51 | ||
51 | #box-organizer .container-block-plugin_container-block:hover .block { | 52 | #box-organizer .container-block-plugin_container-block:hover .block { |
plugins/container_block/views/blocks/container.rhtml
@@ -15,8 +15,18 @@ | @@ -15,8 +15,18 @@ | ||
15 | </style> | 15 | </style> |
16 | 16 | ||
17 | <% if edit_mode %> | 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 | <div class="container-block-button-bar button-bar"> | 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 | <%= link_to_remote '', :url => { :controller => @controller.boxes_holder.kind_of?(Environment) ? 'container_block_plugin_admin' : 'container_block_plugin_myprofile', :action => 'saveWidths', :id => block.id }, | 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 | :with => "containerChildrenWidth(#{block.id}, #{block.container_box.id})", | 31 | :with => "containerChildrenWidth(#{block.id}, #{block.container_box.id})", |
22 | :html => {:class => "button icon-save container_block_save", :id => "container_block_save_#{block.id}", :title => _('Save') }, | 32 | :html => {:class => "button icon-save container_block_save", :id => "container_block_save_#{block.id}", :title => _('Save') }, |