]> source.dussan.org Git - redmine.git/commitdiff
User preference for monospaced / variable-width font in textareas (#23653).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 30 Aug 2016 19:59:29 +0000 (19:59 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 30 Aug 2016 19:59:29 +0000 (19:59 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15753 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
app/helpers/users_helper.rb
app/models/user_preference.rb
app/views/users/_preferences.html.erb
config/locales/en.yml
config/locales/fr.yml
public/stylesheets/application.css
test/functional/users_controller_test.rb
test/functional/welcome_controller_test.rb

index aade3cc4d7d5f45debbd61771e65c4cfbf4fa9c1..1b3273838b433a065092a1d9878f27aa3d215916 100644 (file)
@@ -561,6 +561,9 @@ module ApplicationHelper
     css << 'project-' + @project.identifier if @project && @project.identifier.present?
     css << 'controller-' + controller_name
     css << 'action-' + action_name
+    if UserPreference::TEXTAREA_FONT_OPTIONS.include?(User.current.pref.textarea_font)
+      css << "textarea-#{User.current.pref.textarea_font}"
+    end
     css.join(' ')
   end
 
index 8b85e9f501f6fd9c62b09505160351b91fe07e29..97e7a8bd63f45235420170ced296a8f8b86184bf 100644 (file)
@@ -30,6 +30,10 @@ module UsersHelper
     user.valid_notification_options.collect {|o| [l(o.last), o.first]}
   end
 
+  def textarea_font_options
+    [[l(:label_font_default), '']] + UserPreference::TEXTAREA_FONT_OPTIONS.map {|o| [l("label_font_#{o}"), o]}
+  end
+
   def change_status_link(user)
     url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil}
 
index 52d120c7440c9f238844837615eac8df4ca2539c..4a07e990c64c8ef21714eace9e0e8023773fd191 100644 (file)
@@ -29,7 +29,10 @@ class UserPreference < ActiveRecord::Base
     'time_zone',
     'comments_sorting',
     'warn_on_leaving_unsaved',
-    'no_self_notified'
+    'no_self_notified',
+    'textarea_font'
+
+  TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional']
 
   def initialize(attributes=nil, *args)
     super
@@ -76,4 +79,7 @@ class UserPreference < ActiveRecord::Base
 
   def activity_scope; Array(self[:activity_scope]) ; end
   def activity_scope=(value); self[:activity_scope]=value ; end
+
+  def textarea_font; self[:textarea_font] end
+  def textarea_font=(value); self[:textarea_font]=value; end
 end
index fb19bb3e58ba6e625e4dc7db2879665fb54ea49d..f8769125ed8b7657b1e8cb45d5be234506ecdac3 100644 (file)
@@ -3,4 +3,5 @@
 <p><%= pref_fields.time_zone_select :time_zone, nil, :include_blank => true %></p>
 <p><%= pref_fields.select :comments_sorting, [[l(:label_chronological_order), 'asc'], [l(:label_reverse_chronological_order), 'desc']] %></p>
 <p><%= pref_fields.check_box :warn_on_leaving_unsaved %></p>
+<p><%= pref_fields.select :textarea_font, textarea_font_options %></p>
 <% end %>
index a6501c38a4a1144a3a84fd9cba3d1a56ca3d15f9..56a06c7d58d2128dc843288d36dfcf811ff7440b 100644 (file)
@@ -364,6 +364,7 @@ en:
   field_total_estimated_hours: Total estimated time
   field_default_version: Default version
   field_remote_ip: IP address
+  field_textarea_font: Font used for text areas
 
   setting_app_title: Application title
   setting_app_subtitle: Application subtitle
@@ -998,6 +999,9 @@ en:
   label_relations: Relations
   label_new_project_issue_tab_enabled: Display the "New issue" tab
   label_new_object_tab_enabled: Display the "+" drop-down
+  label_font_default: Default font
+  label_font_monospace: Monospaced font
+  label_font_proportional: Proportional font
 
   button_login: Login
   button_submit: Submit
index 50fe2b923e454b575b32d4d69b72fdbcf181ee7c..d0ef34c46c107ecb3e33ea50a89e3a1400f497ae 100644 (file)
@@ -376,6 +376,7 @@ fr:
   field_time_entries_visibility: Visibilité du temps passé
   field_total_estimated_hours: Temps estimé total
   field_default_version: Version par défaut
+  field_textarea_font: Police utilisée pour les champs texte
 
   setting_app_title: Titre de l'application
   setting_app_subtitle: Sous-titre de l'application
@@ -1007,6 +1008,9 @@ fr:
   label_relations: Relations
   label_new_project_issue_tab_enabled: Afficher l'onglet "Nouvelle demande"
   label_new_object_tab_enabled: Afficher le menu déroulant "+"
+  label_font_default: Police par défaut
+  label_font_monospace: Police non proportionnelle
+  label_font_proportional: Police proportionnelle
 
   button_login: Connexion
   button_submit: Soumettre
index da89fe245dee6d5c9e04bcda06b243f6bb386abf..bbc32992e55d661a269f23925888d61d71edbecb 100644 (file)
@@ -379,6 +379,8 @@ blockquote { font-style: italic; border-left: 3px solid #e0e0e0; padding-left: 0
 blockquote blockquote { margin-left: 0;}
 abbr, span.field-description[title] { border-bottom: 1px dotted #aaa; cursor: help; }
 textarea.wiki-edit {width:99%; resize:vertical;}
+body.textarea-monospace textarea.wiki-edit {font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace; font-size: 12px;}
+body.textarea-proportional textarea.wiki-edit {font-family: Verdana, sans-serif; font-size: 12px;}
 li p {margin-top: 0;}
 div.issue {background:#ffffdd; padding:6px; margin-bottom:6px; border: 1px solid #d7d7d7; border-radius:3px;}
 p.breadcrumb { font-size: 0.9em; margin: 4px 0 4px 0;}
index 78a8b6c39523a4b8c9f67ed2a3f41e6217859ca8..f899e631a0f7ea533ea477780ca09593213ae252 100644 (file)
@@ -202,7 +202,8 @@ class UsersControllerTest < Redmine::ControllerTest
           'hide_mail' => '1',
           'time_zone' => 'Paris',
           'comments_sorting' => 'desc',
-          'warn_on_leaving_unsaved' => '0'
+          'warn_on_leaving_unsaved' => '0',
+          'textarea_font' => 'proportional'
         }
       }
     end
@@ -212,6 +213,7 @@ class UsersControllerTest < Redmine::ControllerTest
     assert_equal 'Paris', user.pref.time_zone
     assert_equal 'desc', user.pref[:comments_sorting]
     assert_equal '0', user.pref[:warn_on_leaving_unsaved]
+    assert_equal 'proportional', user.pref[:textarea_font]
   end
 
   def test_create_with_generate_password_should_email_the_password
index 88b160bc9e9d7785cf76a0af23259a4ab3e02372..004fb674a8a6424562cb26fdf42f89feae9f8e4b 100644 (file)
@@ -104,6 +104,24 @@ class WelcomeControllerTest < Redmine::ControllerTest
     assert_select 'script', :text => %r{warnLeavingUnsaved}, :count => 0
   end
 
+  def test_textarea_font_set_to_monospace
+    user = User.find(1)
+    user.pref.textarea_font = 'monospace'
+    user.pref.save!
+    @request.session[:user_id] = 1
+    get :index
+    assert_select 'body.textarea-monospace'
+  end
+
+  def test_textarea_font_set_to_proportional
+    user = User.find(1)
+    user.pref.textarea_font = 'proportional'
+    user.pref.save!
+    @request.session[:user_id] = 1
+    get :index
+    assert_select 'body.textarea-proportional'
+  end
+
   def test_logout_link_should_post
     @request.session[:user_id] = 2