Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

page_layout.rhtml 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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('/my/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('/my/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('/my/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. <%= select_tag 'block', "<option></option>" + options_for_select(@block_options), :id => "block-select" %>
  35. <%= link_to_remote l(:button_add),
  36. {:url => { :action => "add_block" },
  37. :with => "Form.serialize('block-form')",
  38. :update => "list-top",
  39. :position => :top,
  40. :complete => "afterAddBlock();"
  41. }, :class => 'icon icon-add'
  42. %>
  43. <% end %>
  44. <%= link_to l(:button_save), {:action => 'page_layout_save'}, :class => 'icon icon-save' %>
  45. <%= link_to l(:button_cancel), {:action => 'page'}, :class => 'icon icon-cancel' %>
  46. </div>
  47. <h2><%=l(:label_my_page)%></h2>
  48. <div id="list-top" class="block-receiver">
  49. <% @blocks['top'].each do |b|
  50. next unless MyController::BLOCKS.keys.include? b %>
  51. <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
  52. <% end if @blocks['top'] %>
  53. </div>
  54. <div id="list-left" class="splitcontentleft block-receiver">
  55. <% @blocks['left'].each do |b|
  56. next unless MyController::BLOCKS.keys.include? b %>
  57. <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
  58. <% end if @blocks['left'] %>
  59. </div>
  60. <div id="list-right" class="splitcontentright block-receiver">
  61. <% @blocks['right'].each do |b|
  62. next unless MyController::BLOCKS.keys.include? b %>
  63. <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
  64. <% end if @blocks['right'] %>
  65. </div>
  66. <%= sortable_element 'list-top',
  67. :tag => 'div',
  68. :only => 'mypage-box',
  69. :handle => "handle",
  70. :dropOnEmpty => true,
  71. :containment => ['list-top', 'list-left', 'list-right'],
  72. :constraint => false,
  73. :url => { :action => "order_blocks", :group => "top" }
  74. %>
  75. <%= sortable_element 'list-left',
  76. :tag => 'div',
  77. :only => 'mypage-box',
  78. :handle => "handle",
  79. :dropOnEmpty => true,
  80. :containment => ['list-top', 'list-left', 'list-right'],
  81. :constraint => false,
  82. :url => { :action => "order_blocks", :group => "left" }
  83. %>
  84. <%= sortable_element 'list-right',
  85. :tag => 'div',
  86. :only => 'mypage-box',
  87. :handle => "handle",
  88. :dropOnEmpty => true,
  89. :containment => ['list-top', 'list-left', 'list-right'],
  90. :constraint => false,
  91. :url => { :action => "order_blocks", :group => "right" }
  92. %>
  93. <%= javascript_tag "updateSelect()" %>