You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

page_layout.html.erb 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <script language="JavaScript">
  2. //<![CDATA[
  3. function recreateSortables() {
  4. Sortable.destroy('list-top');
  5. Sortable.destroy('list-left');
  6. Sortable.destroy('list-right');
  7. 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'})
  8. 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'})
  9. 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'})
  10. }
  11. function updateSelect() {
  12. s = $('block-select')
  13. for (var i = 0; i < s.options.length; i++) {
  14. if ($('block_' + s.options[i].value)) {
  15. s.options[i].disabled = true;
  16. } else {
  17. s.options[i].disabled = false;
  18. }
  19. }
  20. s.options[0].selected = true;
  21. }
  22. function afterAddBlock() {
  23. recreateSortables();
  24. updateSelect();
  25. }
  26. function removeBlock(block) {
  27. Effect.DropOut(block);
  28. updateSelect();
  29. }
  30. //]]>
  31. </script>
  32. <div class="contextual">
  33. <%= form_tag({:action => "add_block"}, :id => "block-form") do %>
  34. <%= label_tag('block-select', l(:label_my_page_block)) %>:
  35. <%= select_tag 'block',
  36. "<option></option>".html_safe + options_for_select(@block_options),
  37. :id => "block-select" %>
  38. <%= link_to_remote l(:button_add),
  39. {:url => { :action => "add_block" },
  40. :with => "Form.serialize('block-form')",
  41. :update => "list-top",
  42. :position => :top,
  43. :complete => "afterAddBlock();"
  44. }, :class => 'icon icon-add'
  45. %>
  46. <% end %>
  47. <%= link_to l(:button_back), {:action => 'page'}, :class => 'icon icon-cancel' %>
  48. </div>
  49. <h2><%=l(:label_my_page)%></h2>
  50. <div id="list-top" class="block-receiver">
  51. <% @blocks['top'].each do |b|
  52. next unless MyController::BLOCKS.keys.include? b %>
  53. <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
  54. <% end if @blocks['top'] %>
  55. </div>
  56. <div id="list-left" class="splitcontentleft block-receiver">
  57. <% @blocks['left'].each do |b|
  58. next unless MyController::BLOCKS.keys.include? b %>
  59. <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
  60. <% end if @blocks['left'] %>
  61. </div>
  62. <div id="list-right" class="splitcontentright block-receiver">
  63. <% @blocks['right'].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['right'] %>
  67. </div>
  68. <%= sortable_element 'list-top',
  69. :tag => 'div',
  70. :only => 'mypage-box',
  71. :handle => "handle",
  72. :dropOnEmpty => true,
  73. :containment => ['list-top', 'list-left', 'list-right'],
  74. :constraint => false,
  75. :url => { :action => "order_blocks", :group => "top" }
  76. %>
  77. <%= sortable_element 'list-left',
  78. :tag => 'div',
  79. :only => 'mypage-box',
  80. :handle => "handle",
  81. :dropOnEmpty => true,
  82. :containment => ['list-top', 'list-left', 'list-right'],
  83. :constraint => false,
  84. :url => { :action => "order_blocks", :group => "left" }
  85. %>
  86. <%= sortable_element 'list-right',
  87. :tag => 'div',
  88. :only => 'mypage-box',
  89. :handle => "handle",
  90. :dropOnEmpty => true,
  91. :containment => ['list-top', 'list-left', 'list-right'],
  92. :constraint => false,
  93. :url => { :action => "order_blocks", :group => "right" }
  94. %>
  95. <%= javascript_tag "updateSelect()" %>
  96. <% html_title(l(:label_my_page)) -%>