Revert "Enable RTL direction in emails."

This commit is contained in:
Robin Ward 2014-08-06 15:30:07 -04:00
parent 417d287813
commit 6783565d8f
5 changed files with 18 additions and 27 deletions

View File

@ -32,7 +32,7 @@ module ApplicationHelper
end end
def html_classes def html_classes
"#{mobile_view? ? 'mobile-view' : 'desktop-view'} #{mobile_device? ? 'mobile-device' : 'not-mobile-device'} #{RTL.html_class}" "#{mobile_view? ? 'mobile-view' : 'desktop-view'} #{mobile_device? ? 'mobile-device' : 'not-mobile-device'} #{rtl_view? ? 'rtl' : ''}"
end end
def escape_unicode(javascript) def escape_unicode(javascript)
@ -124,6 +124,21 @@ module ApplicationHelper
MobileDetection.mobile_device?(request.user_agent) MobileDetection.mobile_device?(request.user_agent)
end end
def rtl_view?
site_default_rtl? || current_user_rtl?
end
def current_user_rtl?
SiteSetting.allow_user_locale && current_user.try(:locale).in?(rtl_locales)
end
def site_default_rtl?
!SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(rtl_locales)
end
def rtl_locales
%w(he ar)
end
def customization_disabled? def customization_disabled?
controller.class.name.split("::").first == "Admin" || session[:disable_customization] controller.class.name.split("::").first == "Admin" || session[:disable_customization]

View File

@ -198,7 +198,7 @@ class UserNotifications < ActionMailer::Base
html = UserNotificationRenderer.new(Rails.configuration.paths["app/views"]).render( html = UserNotificationRenderer.new(Rails.configuration.paths["app/views"]).render(
template: 'email/notification', template: 'email/notification',
format: :html, format: :html,
locals: { context_posts: context_posts, post: post, top: top ? PrettyText.cook(top).html_safe : nil, classes: RTL.html_class } locals: { context_posts: context_posts, post: post, top: top ? PrettyText.cook(top).html_safe : nil }
) )
template = "user_notifications.user_#{notification_type}" template = "user_notifications.user_#{notification_type}"

View File

@ -1,23 +0,0 @@
class RTL
def self.enabled?
site_locale_rtl? || current_user_rtl?
end
def self.current_user_rtl?
SiteSetting.allow_user_locale && current_user.try(:locale).in?(rtl_locales)
end
def self.site_locale_rtl?
!SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(rtl_locales)
end
def self.rtl_locales
%w(he ar)
end
def self.html_class
enabled? ? 'rtl' : ''
end
end

View File

@ -1,4 +1,4 @@
<div id='main' class=<%= classes %>> <div id='main'>
<% if top.present? %> <% if top.present? %>
<div><%= top %></div> <div><%= top %></div>

View File

@ -53,7 +53,6 @@ module Email
style('.user-avatar', 'vertical-align:top;width:55px;') style('.user-avatar', 'vertical-align:top;width:55px;')
style('.user-avatar img', nil, width: '45', height: '45') style('.user-avatar img', nil, width: '45', height: '45')
style('hr', 'background-color: #ddd; height: 1px; border: 1px;') style('hr', 'background-color: #ddd; height: 1px; border: 1px;')
style('.rtl', 'direction: rtl;')
# we can do this but it does not look right # we can do this but it does not look right
# style('#main', 'font-family:"Helvetica Neue", Helvetica, Arial, sans-serif') # style('#main', 'font-family:"Helvetica Neue", Helvetica, Arial, sans-serif')
style('td.body', 'padding-top:5px;', colspan: "2") style('td.body', 'padding-top:5px;', colspan: "2")