summaryrefslogtreecommitdiffstats
path: root/app/views/my/page.html.erb
blob: ba150fd790d00dced9aebee37a6f778d75c180d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<div class="contextual">
  <%= form_tag({:action => "add_block"}, :remote => true, :id => "block-form") do %>
    <%= label_tag('block-select', l(:button_add)) %>:
    <%= block_select_tag(@user) %>
  <% end %>
</div>

<h2><%=l(:label_my_page)%></h2>

<div id="my-page">
<% @groups.each do |group| %>
  <div id="list-<%= group %>" class="block-receiver">
    <%= render_blocks(@blocks[group], @user) %>
  </div>
<% end %>
</div>

<%= context_menu %>

<%= javascript_tag do %>
$(document).ready(function(){
  $('#block-select').val('');
  $('.block-receiver').sortable({
    connectWith: '.block-receiver',
    tolerance: 'pointer',
    handle: '.sort-handle',
    start: function(event, ui){$(this).parent().addClass('dragging');},
    stop: function(event, ui){$(this).parent().removeClass('dragging');},
    update: function(event, ui){
      // trigger the call on the list that receives the block only
      if ($(this).find(ui.item).length > 0) {
        $.ajax({
          url: "<%= escape_javascript url_for(:action => "order_blocks") %>",
          type: 'post',
          data: {
            'group': $(this).attr('id').replace(/^list-/, ''),
            'blocks': $.map($(this).children(), function(el){return $(el).attr('id').replace(/^block-/, '');})
          }
        });
      }
    }
  });
});
<% end %>

<% html_title(l(:label_my_page)) -%>