container.rhtml
1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<% edit_mode = @controller.send(:boxes_editor?) && @controller.send(:uses_design_blocks?) %>
<% box_decorator = edit_mode ? self : BoxesHelper::DontMoveBlocks %>
<% box_decorator.select_blocks(block.blocks, { :article => @page, :request_path => request.path, :locale => locale }).each do |child| %>
<div class="container_block_child">
<%= display_block(child, '') %>
</div>
<style>#block-<%=child.id%> { width: <%= block.child_width(child.id) %>px; }</style>
<% end %>
<div class="clear"></div>
<% if edit_mode %>
<div class="button-bar">
<a href="#" onclick="toggleMoveContainerChildren(<%= block.id %>); return false;" class="button icon-resize"></a>
<%= link_to_remote '', :url => { :controller => @controller.boxes_holder.kind_of?(Environment) ? 'container_block_plugin_admin' : 'container_block_plugin_myprofile', :action => 'saveWidths', :id => block.id },
:with => "containerChildrenWidth(#{block.id})",
:html => {:class => "button icon-save container_block_save", :id => "container_block_save_#{block.id}" },
:loading => "",
:loaded => "" %>
</div>
<script>
function saveWidth(container) {
}
function toggleMoveContainerChildren(container) {
var containerDiv = jQuery('#block-'+container+' .container_block_child .block');
if(containerDiv.is('.ui-resizable')) {
containerDiv.resizable('destroy');
} else {
containerDiv.resizable({handles: 'e, w'});
}
}
function containerChildrenWidth(container) {
widths = "";
jQuery('#block-'+container+' .container_block_child .block').each(function(i) {
//childId = jQuery(this).attr('id').substring(6);
childId = jQuery(this).attr('id').match(/block-(\d+)/)[1];
widths+=childId+","+jQuery(this).width()+"|";
});
return "widths="+widths;
}
</script>
<% end %>