1 <script language="JavaScript">
3 function recreateSortables() {
4 Sortable.destroy('list-top');
5 Sortable.destroy('list-left');
6 Sortable.destroy('list-right');
8 Sortable.create("list-top", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=top', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize("list-top")})}, only:'mypage-box', tag:'div'})
9 Sortable.create("list-left", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=left', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize("list-left")})}, only:'mypage-box', tag:'div'})
10 Sortable.create("list-right", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=right', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize("list-right")})}, only:'mypage-box', tag:'div'})
13 function updateSelect() {
15 for (var i = 0; i < s.options.length; i++) {
16 if ($('block_' + s.options[i].value)) {
17 s.options[i].disabled = true;
19 s.options[i].disabled = false;
22 s.options[0].selected = true;
25 function afterAddBlock() {
30 function removeBlock(block) {
31 Effect.DropOut(block);
37 <div class="contextual">
38 <% form_tag({:action => "add_block"}, :id => "block-form") do %>
39 <%= select_tag 'block', "<option></option>" + options_for_select(@block_options), :id => "block-select" %>
40 <%= link_to_remote l(:button_add),
41 {:url => { :action => "add_block" },
42 :with => "Form.serialize('block-form')",
43 :update => "list-top",
45 :complete => "afterAddBlock();"
46 }, :class => 'icon icon-add'
49 <%= link_to l(:button_save), {:action => 'page_layout_save'}, :class => 'icon icon-save' %>
50 <%= link_to l(:button_cancel), {:action => 'page'}, :class => 'icon icon-cancel' %>
53 <h2><%=l(:label_my_page)%></h2>
55 <div id="list-top" class="block-receiver">
56 <% @blocks['top'].each do |b|
57 next unless MyController::BLOCKS.keys.include? b %>
58 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
59 <% end if @blocks['top'] %>
62 <div id="list-left" class="splitcontentleft block-receiver">
63 <% @blocks['left'].each do |b|
64 next unless MyController::BLOCKS.keys.include? b %>
65 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
66 <% end if @blocks['left'] %>
69 <div id="list-right" class="splitcontentright block-receiver">
70 <% @blocks['right'].each do |b|
71 next unless MyController::BLOCKS.keys.include? b %>
72 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
73 <% end if @blocks['right'] %>
76 <%= sortable_element 'list-top',
78 :only => 'mypage-box',
81 :containment => ['list-top', 'list-left', 'list-right'],
83 :url => { :action => "order_blocks", :group => "top" }
87 <%= sortable_element 'list-left',
89 :only => 'mypage-box',
92 :containment => ['list-top', 'list-left', 'list-right'],
94 :url => { :action => "order_blocks", :group => "left" }
97 <%= sortable_element 'list-right',
99 :only => 'mypage-box',
101 :dropOnEmpty => true,
102 :containment => ['list-top', 'list-left', 'list-right'],
103 :constraint => false,
104 :url => { :action => "order_blocks", :group => "right" }
107 <%= javascript_tag "updateSelect()" %>