From e918b3b6440463f97ea9c389ec7c3458208ed787 Mon Sep 17 00:00:00 2001
From: Harry Bomrah <harry@rulingcom.com>
Date: Fri, 5 Jun 2015 18:55:28 +0800
Subject: [PATCH] added site bar settings for logo and title in frontend, fixed
 role status disbale enable and also added br to text area

---
 app/assets/images/default-site-logo.png       | Bin 0 -> 928 bytes
 .../admin/role_statuses_controller.rb         |   7 +++++--
 app/helpers/application_helper.rb             |   7 +++++--
 app/models/attribute_value.rb                 |   2 +-
 app/models/member_profile_field_value.rb      |   2 +-
 app/models/site.rb                            |   1 +
 app/views/admin/role_statuses/_index.html.erb |  19 +++++++++++++++++-
 .../admin/role_statuses/_role_status.html.erb |   4 ++--
 app/views/admin/sites/site_info.html.erb      |   9 +++++++++
 config/locales/en.yml                         |   1 +
 config/locales/zh_tw.yml                      |   1 +
 11 files changed, 44 insertions(+), 9 deletions(-)
 create mode 100644 app/assets/images/default-site-logo.png

diff --git a/app/assets/images/default-site-logo.png b/app/assets/images/default-site-logo.png
new file mode 100644
index 0000000000000000000000000000000000000000..56bef4b256f27d9e0d5fd83b6fdb712bdb4a9d97
GIT binary patch
literal 928
zcmaJ=PjAyO9L<<O)1*mUK!OWaCLxe$oTSaVSPiAETNa5_Q&(v{k|u5&b%`^_C23EH
z+r9=8S3Uq7cHzQTfDgfy17bK`({Z3ga{Nc{z26@{UmSN|?(II@l_Y7;KEgdQZ{=g>
zj`%;i_vJ!N4|sdPPw0rJE+bOIr$Ykl&>fQ=asB!ES5lLt?Z-iXzz5DN<k3)ZbBvOO
zv0zJ5t)9iMHzgbl$vB8C`N!u=83ev1pBj$p#4R!jjuwoZEV_MfG4)Jeu0IF03<-gd
za2I6ZS(Kp6l9#$jtn*_igC&GdE%`dBfpZL6lo4PkM#)ok4OC4<GmL6ge+G0_t3XwQ
zTDhc|s8T_y3Ra&iqA`DjdbqQSC3coP;XFnVrfI6AWreaa)J)Tast$F%BoL)!9&tA-
zMah1lfJx%9Am#y$K(6Qx>5N;l$n?5|FkZ_>$*N7FVK8%Js3~e*QUP?F|3kxYjZS!v
z+~oUD;iNy03G9)C&X^}IZnU3=icyOZms8fK^sMOO@q}`kOlS;Rt!3B1lhYvbX_`D;
zavTTQQNrEGBQ~~Vp`rwVkE*y`Q8lxwHV<@7Ya0#y5O>sa+r*UyZsKym#nhXHB;p0v
zzu_Kk<mPq=V-Xn>7Q7*ThtUu$%SOTGT#Su+E3UsemxGO5D3XEs<^FZq#gTAOzFb>Z
zY}V!{k#IZ{*1r63`;&MUcWvD0XWxcDudeFbFWzoRJHKxI{{G&%pT8Nq-Nhf9uiyOv
DsNx&k

literal 0
HcmV?d00001

diff --git a/app/controllers/admin/role_statuses_controller.rb b/app/controllers/admin/role_statuses_controller.rb
index d18d00e..1c95e2b 100644
--- a/app/controllers/admin/role_statuses_controller.rb
+++ b/app/controllers/admin/role_statuses_controller.rb
@@ -42,8 +42,11 @@ class Admin::RoleStatusesController < OrbitMemberController
   end
 
   def toggle
-  	@role_status.disable = @role_status.disable ? false : true
-    @role_status.save!
+    role_status = RoleStatus.find(params[:role_status_id]) rescue nil
+    if !role_status.nil?
+  	  role_status.disable = role_status.disable ? false : true
+      role_status.save!
+    end
     render action: :index
   end
 
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index b64a895..193a990 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -20,10 +20,13 @@ module ApplicationHelper
 		header_file = File.join('../templates', "#{@key}", "/home/header.html.erb")
 		header_file_html = render :file => header_file
 		header = Nokogiri::HTML(header_file_html, nil, "UTF-8")
+		site_logo = header.css("img[src='{{logo_url}}']")[0]
+		site_logo.remove if site.site_logo.url.nil?
 		sub_menu_html = site.sub_menu
 		html = header.to_s
-		html = html.gsub("{{site_name}}",(site.title rescue ""))
-		html = html.gsub("%7B%7Blogo_url%7D%7D",(site.site_logo.url.nil? ? "/assets/site-logo.png" : site.site_logo.url))
+		t = site.title rescue ""
+		html = html.gsub("{{site_name}}",(site.display_title_in_frontend ? t : ""))
+		html = html.gsub("%7B%7Blogo_url%7D%7D",(site.site_logo.url.nil? ? "/assets/default-site-logo.png" : site.site_logo.url))
 		if site.sitemap_menu_in_header
 			sitemap = Page.find_by_key(:sitemap).name rescue "Sitemap"
 			sub_menu_html = sub_menu_html + "<a href='/#{I18n.locale.to_s}#{site.site_map_link}'>#{sitemap}</a>"
diff --git a/app/models/attribute_value.rb b/app/models/attribute_value.rb
index 38316eb..dd6fbbf 100644
--- a/app/models/attribute_value.rb
+++ b/app/models/attribute_value.rb
@@ -46,7 +46,7 @@ class AttributeValue
 
   def get_field_value
     if (self.attribute_field.markup.eql?("text_field") || self.attribute_field.markup.eql?("text_area"))
-        field_value = self.value[I18n.locale]
+        field_value = self.value[I18n.locale].gsub("\r\n","<br>")
       elsif (self.attribute_field.markup.eql?("select") || self.attribute_field.markup.eql?("radio_button"))
         field_value = self.attribute_field.markup_value["#{self.value}"][I18n.locale] rescue nil
       elsif self.attribute_field.markup.eql?("address")
diff --git a/app/models/member_profile_field_value.rb b/app/models/member_profile_field_value.rb
index 4ae345f..0a72a2b 100644
--- a/app/models/member_profile_field_value.rb
+++ b/app/models/member_profile_field_value.rb
@@ -22,7 +22,7 @@ class MemberProfileFieldValue
           index.nil? ? self["val"] : self["val"][index]
           # self.member_profile_field.get_data[:cross_lang] ? Hash[VALID_LOCALES.collect{|lang|  [lang,self[lang.to_sym]]}]  : self["val"] #if !self.member_profile_field.get_data[:cross_lang]
         else
-          self.member_profile_field.get_data["cross_lang"] =="true" ?  self["val"] : Hash[site.valid_locales.collect{|lang|  [lang,self[lang.to_sym]]}]
+          self.member_profile_field.get_data["cross_lang"] =="true" ?  self["val"].gsub("\r\n","<br>") : Hash[site.valid_locales.collect{|lang|  [lang,self[lang.to_sym].gsub("\r\n","<br>")]}]
         end
       when 'select','radio_button','address'
         self["val"]
diff --git a/app/models/site.rb b/app/models/site.rb
index f58d7ba..7a54f66 100644
--- a/app/models/site.rb
+++ b/app/models/site.rb
@@ -31,6 +31,7 @@ class Site
   field :mobile_bar_color, :type => Array, :default=>[]
   field :phone_number, :type => Array,:default=>[]
   field :title_always_on, :type => Boolean, :default => false
+  field :display_title_in_frontend, :type => Boolean, :default => true
   field :sitemap_menu_in_header, :type => Boolean, :default => false
   field :enable_terms_of_use, :type => Boolean, :default => false
   field :search,:type => Hash
diff --git a/app/views/admin/role_statuses/_index.html.erb b/app/views/admin/role_statuses/_index.html.erb
index 9ef07b8..53e7bac 100644
--- a/app/views/admin/role_statuses/_index.html.erb
+++ b/app/views/admin/role_statuses/_index.html.erb
@@ -12,5 +12,22 @@
     <%= render :partial => 'role_status', :collection => @role_statuses %>
 	</tbody>
 </table>
-
+<script type="text/javascript">
+$("document").ready(function(){
+  $(".role_status_checked").on("click",function(){
+    var el = $(this);
+    $.ajax({
+      url : el.data("path"),
+      type : "post"
+    })
+  })
+  $("input.toggle-check").each(function(){
+    var el = $(this),
+        parent = el.parent();
+      if(el.val() == "1"){
+        parent.removeClass("disable");
+      }
+  })
+})
+</script>
 
diff --git a/app/views/admin/role_statuses/_role_status.html.erb b/app/views/admin/role_statuses/_role_status.html.erb
index 09e0925..56cb7a6 100644
--- a/app/views/admin/role_statuses/_role_status.html.erb
+++ b/app/views/admin/role_statuses/_role_status.html.erb
@@ -13,7 +13,7 @@
   </td>
   <% end %>
 
-  <td class="action dsrgsdgsdg">
-    <%= check_box_tag 'accept', role_status.disable ? 'false' : 'true', false ,{ :class => 'toggle-check role_status_checked', :data=>{:deploy=>"right"}, :data=>{:path=> eval("admin_role_status_toggle_path(role_status)")}, :checked=> role_status.disable} %>
+  <td class="action">
+    <%= check_box_tag 'accept', role_status.disable ? '0' : '1', false ,{ :class => 'toggle-check role_status_checked', :data=>{:deploy=>"right"}, :data=>{:path=> eval("admin_role_status_toggle_path(role_status)")}, :checked=> role_status.disable} %>
   </td>
 </tr>
\ No newline at end of file
diff --git a/app/views/admin/sites/site_info.html.erb b/app/views/admin/sites/site_info.html.erb
index 7681ed1..4979cd2 100644
--- a/app/views/admin/sites/site_info.html.erb
+++ b/app/views/admin/sites/site_info.html.erb
@@ -48,6 +48,15 @@
                     </div>
                   </div>
 
+
+                  <!-- Title show in frontend -->
+                  <div class="control-group">
+                    <label class="control-label muted"><%= t :display_title_in_frontend %></label>
+                    <div class="controls">
+                        <input type="checkbox" class="toggle-check" name="site[display_title_in_frontend]" data-disabled="true" <%= @site.display_title_in_frontend ? "checked='checked" : "" %> />
+                    </div>
+                  </div>
+
                   <hr>
                   <!-- CKeditor Site Header -->
                   <% I18n.available_locales.each do |locale|%>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 88a5c7f..bdab678 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -87,6 +87,7 @@ en:
   all_plugin_summary: All plugin summary
   all_plugins: All plugins
   always_display_title: Always displayed in the title bar
+  display_title_in_frontend: Display title in frontend
   apply_change: Apply Change
   applying_change: Applying Change
   app_auth:
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index ed0d5fe..2c7a930 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -73,6 +73,7 @@ zh_tw:
   all_plugin_summary: 所有學術資訊摘要
   all_plugins: 所有學術資訊
   always_display_title: 永遠顯示標題
+  display_title_in_frontend: 顯示在前台頁面
   apply_change: 套用變更
   applying_change: 正在套用變更
   app_auth: