2007-03-12 20:59:02 +03:00
|
|
|
<script language="JavaScript">
|
|
|
|
//<![CDATA[
|
|
|
|
function recreateSortables() {
|
|
|
|
Sortable.destroy('list-top');
|
|
|
|
Sortable.destroy('list-left');
|
|
|
|
Sortable.destroy('list-right');
|
2011-05-30 22:52:25 +04:00
|
|
|
|
2010-11-07 15:36:19 +03:00
|
|
|
Sortable.create("list-top", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('<%= url_for(:controller => 'my', :action => 'order_blocks', :group => 'top') %>', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize("list-top")})}, only:'mypage-box', tag:'div'})
|
|
|
|
Sortable.create("list-left", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('<%= url_for(:controller => 'my', :action => 'order_blocks', :group => 'left') %>', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize("list-left")})}, only:'mypage-box', tag:'div'})
|
|
|
|
Sortable.create("list-right", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('<%= url_for(:controller => 'my', :action => 'order_blocks', :group => 'right') %>', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize("list-right")})}, only:'mypage-box', tag:'div'})
|
2007-03-12 20:59:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateSelect() {
|
|
|
|
s = $('block-select')
|
|
|
|
for (var i = 0; i < s.options.length; i++) {
|
|
|
|
if ($('block_' + s.options[i].value)) {
|
|
|
|
s.options[i].disabled = true;
|
|
|
|
} else {
|
|
|
|
s.options[i].disabled = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s.options[0].selected = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function afterAddBlock() {
|
|
|
|
recreateSortables();
|
|
|
|
updateSelect();
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeBlock(block) {
|
2007-04-30 13:09:45 +04:00
|
|
|
Effect.DropOut(block);
|
2007-03-12 20:59:02 +03:00
|
|
|
updateSelect();
|
|
|
|
}
|
|
|
|
//]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="contextual">
|
|
|
|
<% form_tag({:action => "add_block"}, :id => "block-form") do %>
|
2011-01-15 17:04:11 +03:00
|
|
|
<%= label_tag('block-select', l(:label_my_page_block)) %>:
|
2007-03-12 20:59:02 +03:00
|
|
|
<%= select_tag 'block', "<option></option>" + options_for_select(@block_options), :id => "block-select" %>
|
|
|
|
<%= link_to_remote l(:button_add),
|
|
|
|
{:url => { :action => "add_block" },
|
|
|
|
:with => "Form.serialize('block-form')",
|
|
|
|
:update => "list-top",
|
|
|
|
:position => :top,
|
2007-04-27 23:32:57 +04:00
|
|
|
:complete => "afterAddBlock();"
|
2007-03-12 20:59:02 +03:00
|
|
|
}, :class => 'icon icon-add'
|
|
|
|
%>
|
|
|
|
<% end %>
|
2009-12-19 16:32:21 +03:00
|
|
|
<%= link_to l(:button_back), {:action => 'page'}, :class => 'icon icon-cancel' %>
|
2007-03-12 20:59:02 +03:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<h2><%=l(:label_my_page)%></h2>
|
|
|
|
|
|
|
|
<div id="list-top" class="block-receiver">
|
2011-05-30 22:52:25 +04:00
|
|
|
<% @blocks['top'].each do |b|
|
2007-03-12 20:59:02 +03:00
|
|
|
next unless MyController::BLOCKS.keys.include? b %>
|
|
|
|
<%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
|
|
|
|
<% end if @blocks['top'] %>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="list-left" class="splitcontentleft block-receiver">
|
2011-05-30 22:52:25 +04:00
|
|
|
<% @blocks['left'].each do |b|
|
2007-03-12 20:59:02 +03:00
|
|
|
next unless MyController::BLOCKS.keys.include? b %>
|
|
|
|
<%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
|
|
|
|
<% end if @blocks['left'] %>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="list-right" class="splitcontentright block-receiver">
|
2011-05-30 22:52:25 +04:00
|
|
|
<% @blocks['right'].each do |b|
|
2007-03-12 20:59:02 +03:00
|
|
|
next unless MyController::BLOCKS.keys.include? b %>
|
|
|
|
<%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
|
|
|
|
<% end if @blocks['right'] %>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<%= sortable_element 'list-top',
|
|
|
|
:tag => 'div',
|
|
|
|
:only => 'mypage-box',
|
|
|
|
:handle => "handle",
|
|
|
|
:dropOnEmpty => true,
|
|
|
|
:containment => ['list-top', 'list-left', 'list-right'],
|
|
|
|
:constraint => false,
|
2007-04-27 23:32:57 +04:00
|
|
|
:url => { :action => "order_blocks", :group => "top" }
|
2007-03-12 20:59:02 +03:00
|
|
|
%>
|
2011-05-30 22:52:25 +04:00
|
|
|
|
|
|
|
|
|
|
|
<%= sortable_element 'list-left',
|
2007-03-12 20:59:02 +03:00
|
|
|
:tag => 'div',
|
|
|
|
:only => 'mypage-box',
|
|
|
|
:handle => "handle",
|
|
|
|
:dropOnEmpty => true,
|
|
|
|
:containment => ['list-top', 'list-left', 'list-right'],
|
|
|
|
:constraint => false,
|
2007-04-27 23:32:57 +04:00
|
|
|
:url => { :action => "order_blocks", :group => "left" }
|
|
|
|
%>
|
2011-05-30 22:52:25 +04:00
|
|
|
|
|
|
|
<%= sortable_element 'list-right',
|
2007-03-12 20:59:02 +03:00
|
|
|
:tag => 'div',
|
|
|
|
:only => 'mypage-box',
|
|
|
|
:handle => "handle",
|
|
|
|
:dropOnEmpty => true,
|
|
|
|
:containment => ['list-top', 'list-left', 'list-right'],
|
|
|
|
:constraint => false,
|
2007-04-27 23:32:57 +04:00
|
|
|
:url => { :action => "order_blocks", :group => "right" }
|
|
|
|
%>
|
2011-05-30 22:52:25 +04:00
|
|
|
|
2007-04-27 23:32:57 +04:00
|
|
|
<%= javascript_tag "updateSelect()" %>
|
2010-05-27 01:52:03 +04:00
|
|
|
<% html_title(l(:label_my_page)) -%>
|