@@ -108,14 +108,14 class MyController < ApplicationController | |||||
108 | session[:page_layout] = @blocks |
|
108 | session[:page_layout] = @blocks | |
109 | %w(top left right).each {|f| session[:page_layout][f] ||= [] } |
|
109 | %w(top left right).each {|f| session[:page_layout][f] ||= [] } | |
110 | @block_options = [] |
|
110 | @block_options = [] | |
111 | BLOCKS.each {|k, v| @block_options << [l(v), k]} |
|
111 | BLOCKS.each {|k, v| @block_options << [l(v), k.dasherize]} | |
112 | end |
|
112 | end | |
113 |
|
113 | |||
114 | # Add a block to user's page |
|
114 | # Add a block to user's page | |
115 | # The block is added on top of the page |
|
115 | # The block is added on top of the page | |
116 | # params[:block] : id of the block to add |
|
116 | # params[:block] : id of the block to add | |
117 | def add_block |
|
117 | def add_block | |
118 | block = params[:block] |
|
118 | block = params[:block].to_s.underscore | |
119 | render(:nothing => true) and return unless block && (BLOCKS.keys.include? block) |
|
119 | render(:nothing => true) and return unless block && (BLOCKS.keys.include? block) | |
120 | @user = User.current |
|
120 | @user = User.current | |
121 | # remove if already present in a group |
|
121 | # remove if already present in a group | |
@@ -128,7 +128,7 class MyController < ApplicationController | |||||
128 | # Remove a block to user's page |
|
128 | # Remove a block to user's page | |
129 | # params[:block] : id of the block to remove |
|
129 | # params[:block] : id of the block to remove | |
130 | def remove_block |
|
130 | def remove_block | |
131 | block = params[:block] |
|
131 | block = params[:block].to_s.underscore | |
132 | # remove block in all groups |
|
132 | # remove block in all groups | |
133 | %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block } |
|
133 | %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block } | |
134 | render :nothing => true |
|
134 | render :nothing => true | |
@@ -139,13 +139,15 class MyController < ApplicationController | |||||
139 | # params[:list-(top|left|right)] : array of block ids of the group |
|
139 | # params[:list-(top|left|right)] : array of block ids of the group | |
140 | def order_blocks |
|
140 | def order_blocks | |
141 | group = params[:group] |
|
141 | group = params[:group] | |
142 | group_items = params["list-#{group}"] |
|
142 | if group.is_a?(Array) | |
143 | if group_items and group_items.is_a? Array |
|
143 | group_items = params["list-#{group}"].collect(&:underscore) | |
144 | # remove group blocks if they are presents in other groups |
|
144 | if group_items and group_items.is_a? Array | |
145 | %w(top left right).each {|f| |
|
145 | # remove group blocks if they are presents in other groups | |
146 | session[:page_layout][f] = (session[:page_layout][f] || []) - group_items |
|
146 | %w(top left right).each {|f| | |
147 | } |
|
147 | session[:page_layout][f] = (session[:page_layout][f] || []) - group_items | |
148 | session[:page_layout][group] = group_items |
|
148 | } | |
|
149 | session[:page_layout][group] = group_items | |||
|
150 | end | |||
149 | end |
|
151 | end | |
150 | render :nothing => true |
|
152 | render :nothing => true | |
151 | end |
|
153 | end |
@@ -1,9 +1,9 | |||||
1 | <div id="block_<%= block_name %>" class="mypage-box"> |
|
1 | <div id="block_<%= block_name.dasherize %>" class="mypage-box"> | |
2 |
|
2 | |||
3 | <div style="float:right;margin-right:16px;z-index:500;"> |
|
3 | <div style="float:right;margin-right:16px;z-index:500;"> | |
4 | <%= link_to_remote "", { |
|
4 | <%= link_to_remote "", { | |
5 | :url => { :action => "remove_block", :block => block_name }, |
|
5 | :url => { :action => "remove_block", :block => block_name }, | |
6 | :complete => "removeBlock('block_#{block_name}')" }, |
|
6 | :complete => "removeBlock('block_#{block_name.dasherize}')" }, | |
7 | :class => "close-icon" |
|
7 | :class => "close-icon" | |
8 | %> |
|
8 | %> | |
9 | </div> |
|
9 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now