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