##// END OF EJS Templates
wrapped javascript with //<![CDATA[ in my/page_layout...
Jean-Philippe Lang -
r242:10e77d865b6c
parent child
Show More
@@ -1,116 +1,116
1 <script language="JavaScript">
1 <script language="JavaScript">
2
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('/my/order_blocks?group=top', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-top",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, 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('/my/order_blocks?group=top', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-top",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, 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('/my/order_blocks?group=left', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-left",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, 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('/my/order_blocks?group=left', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-left",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, 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('/my/order_blocks?group=right', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-right",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, 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('/my/order_blocks?group=right', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-right",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, 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 $(block).parentNode.removeChild($(block));
31 $(block).parentNode.removeChild($(block));
32 updateSelect();
32 updateSelect();
33 }
33 }
34
34 //]]>
35 </script>
35 </script>
36
36
37 <div class="contextual">
37 <div class="contextual">
38 <span id="indicator" style="display:none"><%= image_tag "loading.gif", :align => "absmiddle" %></span>
38 <span id="indicator" style="display:none"><%= image_tag "loading.gif", :align => "absmiddle" %></span>
39 <% form_tag({:action => "add_block"}, :id => "block-form") do %>
39 <% form_tag({:action => "add_block"}, :id => "block-form") do %>
40 <%= select_tag 'block', "<option></option>" + options_for_select(@block_options), :id => "block-select" %>
40 <%= select_tag 'block', "<option></option>" + options_for_select(@block_options), :id => "block-select" %>
41 <%= link_to_remote l(:button_add),
41 <%= link_to_remote l(:button_add),
42 :url => { :action => "add_block" },
42 :url => { :action => "add_block" },
43 :with => "Form.serialize('block-form')",
43 :with => "Form.serialize('block-form')",
44 :update => "list-top",
44 :update => "list-top",
45 :position => :top,
45 :position => :top,
46 :complete => "afterAddBlock();",
46 :complete => "afterAddBlock();",
47 :loading => "Element.show('indicator')",
47 :loading => "Element.show('indicator')",
48 :loaded => "Element.hide('indicator')"
48 :loaded => "Element.hide('indicator')"
49 %>
49 %>
50 <% end %> |
50 <% end %> |
51 <%= link_to l(:button_save), :action => 'page_layout_save' %> |
51 <%= link_to l(:button_save), :action => 'page_layout_save' %> |
52 <%= link_to l(:button_cancel), :action => 'page' %>
52 <%= link_to l(:button_cancel), :action => 'page' %>
53 </div>
53 </div>
54
54
55 <h2><%=l(:label_my_page)%></h2>
55 <h2><%=l(:label_my_page)%></h2>
56
56
57 <div id="list-top" class="block-receiver">
57 <div id="list-top" class="block-receiver">
58 <% @blocks['top'].each do |b|
58 <% @blocks['top'].each do |b|
59 next unless MyController::BLOCKS.keys.include? b %>
59 next unless MyController::BLOCKS.keys.include? b %>
60 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
60 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
61 <% end if @blocks['top'] %>
61 <% end if @blocks['top'] %>
62 </div>
62 </div>
63
63
64 <div id="list-left" class="splitcontentleft block-receiver">
64 <div id="list-left" class="splitcontentleft block-receiver">
65 <% @blocks['left'].each do |b|
65 <% @blocks['left'].each do |b|
66 next unless MyController::BLOCKS.keys.include? b %>
66 next unless MyController::BLOCKS.keys.include? b %>
67 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
67 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
68 <% end if @blocks['left'] %>
68 <% end if @blocks['left'] %>
69 </div>
69 </div>
70
70
71 <div id="list-right" class="splitcontentright block-receiver">
71 <div id="list-right" class="splitcontentright block-receiver">
72 <% @blocks['right'].each do |b|
72 <% @blocks['right'].each do |b|
73 next unless MyController::BLOCKS.keys.include? b %>
73 next unless MyController::BLOCKS.keys.include? b %>
74 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
74 <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
75 <% end if @blocks['right'] %>
75 <% end if @blocks['right'] %>
76 </div>
76 </div>
77
77
78 <%= sortable_element 'list-top',
78 <%= sortable_element 'list-top',
79 :tag => 'div',
79 :tag => 'div',
80 :only => 'mypage-box',
80 :only => 'mypage-box',
81 :handle => "handle",
81 :handle => "handle",
82 :dropOnEmpty => true,
82 :dropOnEmpty => true,
83 :containment => ['list-top', 'list-left', 'list-right'],
83 :containment => ['list-top', 'list-left', 'list-right'],
84 :constraint => false,
84 :constraint => false,
85 :complete => visual_effect(:highlight, 'list-top'),
85 :complete => visual_effect(:highlight, 'list-top'),
86 :url => { :action => "order_blocks", :group => "top" },
86 :url => { :action => "order_blocks", :group => "top" },
87 :loading => "Element.show('indicator')",
87 :loading => "Element.show('indicator')",
88 :loaded => "Element.hide('indicator')"
88 :loaded => "Element.hide('indicator')"
89 %>
89 %>
90
90
91
91
92 <%= sortable_element 'list-left',
92 <%= sortable_element 'list-left',
93 :tag => 'div',
93 :tag => 'div',
94 :only => 'mypage-box',
94 :only => 'mypage-box',
95 :handle => "handle",
95 :handle => "handle",
96 :dropOnEmpty => true,
96 :dropOnEmpty => true,
97 :containment => ['list-top', 'list-left', 'list-right'],
97 :containment => ['list-top', 'list-left', 'list-right'],
98 :constraint => false,
98 :constraint => false,
99 :complete => visual_effect(:highlight, 'list-left'),
99 :complete => visual_effect(:highlight, 'list-left'),
100 :url => { :action => "order_blocks", :group => "left" },
100 :url => { :action => "order_blocks", :group => "left" },
101 :loading => "Element.show('indicator')",
101 :loading => "Element.show('indicator')",
102 :loaded => "Element.hide('indicator')" %>
102 :loaded => "Element.hide('indicator')" %>
103
103
104 <%= sortable_element 'list-right',
104 <%= sortable_element 'list-right',
105 :tag => 'div',
105 :tag => 'div',
106 :only => 'mypage-box',
106 :only => 'mypage-box',
107 :handle => "handle",
107 :handle => "handle",
108 :dropOnEmpty => true,
108 :dropOnEmpty => true,
109 :containment => ['list-top', 'list-left', 'list-right'],
109 :containment => ['list-top', 'list-left', 'list-right'],
110 :constraint => false,
110 :constraint => false,
111 :complete => visual_effect(:highlight, 'list-right'),
111 :complete => visual_effect(:highlight, 'list-right'),
112 :url => { :action => "order_blocks", :group => "right" },
112 :url => { :action => "order_blocks", :group => "right" },
113 :loading => "Element.show('indicator')",
113 :loading => "Element.show('indicator')",
114 :loaded => "Element.hide('indicator')" %>
114 :loaded => "Element.hide('indicator')" %>
115
115
116 <%= javascript_tag "updateSelect()" %> No newline at end of file
116 <%= javascript_tag "updateSelect()" %>
General Comments 0
You need to be logged in to leave comments. Login now