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, onComplete:function(request){new Effect.Highlight("list-top",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, 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, onComplete:function(request){new Effect.Highlight("list-left",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, 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, onComplete:function(request){new Effect.Highlight("list-right",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, 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 $(block).parentNode.removeChild($(block));
37 <div class="contextual">
38 <span id="indicator" style="display:none"><%= image_tag "loading.gif", :align => "absmiddle" %></span>
39 <% form_tag({:action => "add_block"}, :id => "block-form") do %>
40 <%= select_tag 'block', "<option></option>" + options_for_select(@block_options), :id => "block-select" %>
41 <%= link_to_remote l(:button_add),
42 {:url => { :action => "add_block" },
43 :with => "Form.serialize('block-form')",
44 :update => "list-top",
46 :complete => "afterAddBlock();",
47 :loading => "Element.show('indicator')",
48 :loaded => "Element.hide('indicator')"
49 }, :class => 'icon icon-add'
52 <%= link_to l(:button_save), {:action => 'page_layout_save'}, :class => 'icon icon-save' %>
53 <%= link_to l(:button_cancel), {:action => 'page'}, :class => 'icon icon-cancel' %>
56 <h2><%=l(:label_my_page)%></h2>
58 <div id="list-top" class="block-receiver">
59 <% @blocks['top'].each do |b|
60 next unless MyController::BLOCKS.keys.include? b %>
61 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
62 <% end if @blocks['top'] %>
65 <div id="list-left" class="splitcontentleft block-receiver">
66 <% @blocks['left'].each do |b|
67 next unless MyController::BLOCKS.keys.include? b %>
68 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
69 <% end if @blocks['left'] %>
72 <div id="list-right" class="splitcontentright block-receiver">
73 <% @blocks['right'].each do |b|
74 next unless MyController::BLOCKS.keys.include? b %>
75 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
76 <% end if @blocks['right'] %>
79 <%= sortable_element 'list-top',
81 :only => 'mypage-box',
84 :containment => ['list-top', 'list-left', 'list-right'],
86 :complete => visual_effect(:highlight, 'list-top'),
87 :url => { :action => "order_blocks", :group => "top" },
88 :loading => "Element.show('indicator')",
89 :loaded => "Element.hide('indicator')"
93 <%= sortable_element 'list-left',
95 :only => 'mypage-box',
98 :containment => ['list-top', 'list-left', 'list-right'],
100 :complete => visual_effect(:highlight, 'list-left'),
101 :url => { :action => "order_blocks", :group => "left" },
102 :loading => "Element.show('indicator')",
103 :loaded => "Element.hide('indicator')" %>
105 <%= sortable_element 'list-right',
107 :only => 'mypage-box',
109 :dropOnEmpty => true,
110 :containment => ['list-top', 'list-left', 'list-right'],
111 :constraint => false,
112 :complete => visual_effect(:highlight, 'list-right'),
113 :url => { :action => "order_blocks", :group => "right" },
114 :loading => "Element.show('indicator')",
115 :loaded => "Element.hide('indicator')" %>
117 <%= javascript_tag "updateSelect()" %>