0001-Introduce-user-preference-to-use-monospaced-variable.patch

Jan from Planio www.plan.io, 2016-08-24 14:40

Download (8.47 KB)

View differences:

app/models/user_preference.rb
29 29
    'time_zone',
30 30
    'comments_sorting',
31 31
    'warn_on_leaving_unsaved',
32
    'no_self_notified'
32
    'no_self_notified',
33
    'monospace_textareas'
33 34

  
34 35
  def initialize(attributes=nil, *args)
35 36
    super
......
76 77

  
77 78
  def activity_scope; Array(self[:activity_scope]) ; end
78 79
  def activity_scope=(value); self[:activity_scope]=value ; end
80

  
81
  def monospace_textareas; (self[:monospace_textareas] == true || self[:monospace_textareas] == '1'); end
82
  def monospace_textareas=(value); self[:monospace_textareas]=value; end
79 83
end
app/views/users/_preferences.html.erb
3 3
<p><%= pref_fields.time_zone_select :time_zone, nil, :include_blank => true %></p>
4 4
<p><%= pref_fields.select :comments_sorting, [[l(:label_chronological_order), 'asc'], [l(:label_reverse_chronological_order), 'desc']] %></p>
5 5
<p><%= pref_fields.check_box :warn_on_leaving_unsaved %></p>
6
<p><%= pref_fields.check_box :monospace_textareas %></p>
6 7
<% end %>
config/locales/de.yml
389 389
  field_version: Version
390 390
  field_visible: Sichtbar
391 391
  field_warn_on_leaving_unsaved: Vor dem Verlassen einer Seite mit ungesichertem Text im Editor warnen
392
  field_monospace_textareas: "Nichtproportionale Schrift für Textfelder verwenden"
392 393
  field_watcher: Beobachter
393 394

  
394 395
  general_csv_decimal_separator: ','
config/locales/en.yml
340 340
  field_text: Text field
341 341
  field_visible: Visible
342 342
  field_warn_on_leaving_unsaved: "Warn me when leaving a page with unsaved text"
343
  field_monospace_textareas: "Use monospaced font for text areas"
343 344
  field_issues_visibility: Issues visibility
344 345
  field_is_private: Private
345 346
  field_commit_logs_encoding: Commit messages encoding
lib/redmine/wiki_formatting.rb
186 186

  
187 187
      module Helper
188 188
        def wikitoolbar_for(field_id)
189
          javascript_tag("$(document).ready(function(){$('##{field_id}').addClass('monospace');});") if User.current.pref.monospace_textareas
189 190
        end
190 191

  
191 192
        def heads_for_wiki_formatter
lib/redmine/wiki_formatting/markdown/helper.rb
22 22
        def wikitoolbar_for(field_id)
23 23
          heads_for_wiki_formatter
24 24
          url = "#{Redmine::Utils.relative_url_root}/help/#{current_language.to_s.downcase}/wiki_syntax_markdown.html"
25
          javascript_tag("var wikiToolbar = new jsToolBar(document.getElementById('#{field_id}')); wikiToolbar.setHelpLink('#{escape_javascript url}'); wikiToolbar.draw();")
25
          t = javascript_tag("var wikiToolbar = new jsToolBar(document.getElementById('#{field_id}')); wikiToolbar.setHelpLink('#{escape_javascript url}'); wikiToolbar.draw();")
26
          t << javascript_tag("$(document).ready(function(){$('##{field_id}').addClass('monospace');});") if User.current.pref.monospace_textareas
27
          t
26 28
        end
27 29

  
28 30
        def initial_page_content(page)
lib/redmine/wiki_formatting/textile/helper.rb
23 23
          heads_for_wiki_formatter
24 24
          # Is there a simple way to link to a public resource?
25 25
          url = "#{Redmine::Utils.relative_url_root}/help/#{current_language.to_s.downcase}/wiki_syntax_textile.html"
26
          javascript_tag("var wikiToolbar = new jsToolBar(document.getElementById('#{field_id}')); wikiToolbar.setHelpLink('#{escape_javascript url}'); wikiToolbar.draw();")
26
          t = javascript_tag("var wikiToolbar = new jsToolBar(document.getElementById('#{field_id}')); wikiToolbar.setHelpLink('#{escape_javascript url}'); wikiToolbar.draw();")
27
          t << javascript_tag("$(document).ready(function(){$('##{field_id}').addClass('monospace');});") if User.current.pref.monospace_textareas
28
          t
27 29
        end
28 30

  
29 31
        def initial_page_content(page)
public/stylesheets/application.css
378 378
blockquote { font-style: italic; border-left: 3px solid #e0e0e0; padding-left: 0.6em; margin-left: 2.4em;}
379 379
blockquote blockquote { margin-left: 0;}
380 380
abbr, span.field-description[title] { border-bottom: 1px dotted #aaa; cursor: help; }
381
textarea.wiki-edit {width:99%; resize:vertical;}
381
textarea.wiki-edit {width:99%; resize:vertical; font-family: Verdana, sans-serif; font-size: 12px;}
382
textarea.wiki-edit.monospace {font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace;}
382 383
li p {margin-top: 0;}
383 384
div.issue {background:#ffffdd; padding:6px; margin-bottom:6px; border: 1px solid #d7d7d7; border-radius:3px;}
384 385
p.breadcrumb { font-size: 0.9em; margin: 4px 0 4px 0;}
test/functional/projects_controller_test.rb
672 672
    get :show, :id => 1
673 673
    assert_select 'body.project-ecookbook'
674 674
  end
675

  
676
  def test_monospace_textareas_turned_on
677
    user = User.find(1)
678
    user.pref.monospace_textareas = '1'
679
    user.pref.save!
680
    @request.session[:user_id] = 1
681

  
682
    get :settings, :id => 1
683
    assert_select 'script', :text => %r{addClass\('monospace'\)}
684
  end
685

  
686
  def test_monospace_textareas_turned_off
687
    user = User.find(1)
688
    user.pref.monospace_textareas = '0'
689
    user.pref.save!
690
    @request.session[:user_id] = 1
691

  
692
    get :settings, :id => 1
693
    assert_select 'script', :text => %r{addClass\('monospace'\)}, :count => 0
694
  end
675 695
end
test/functional/users_controller_test.rb
202 202
          'hide_mail' => '1',
203 203
          'time_zone' => 'Paris',
204 204
          'comments_sorting' => 'desc',
205
          'warn_on_leaving_unsaved' => '0'
205
          'warn_on_leaving_unsaved' => '0',
206
          'monospace_textareas' => '1'
206 207
        }
207 208
      }
208 209
    end
......
212 213
    assert_equal 'Paris', user.pref.time_zone
213 214
    assert_equal 'desc', user.pref[:comments_sorting]
214 215
    assert_equal '0', user.pref[:warn_on_leaving_unsaved]
216
    assert_equal true, user.pref.monospace_textareas
215 217
  end
216 218

  
217 219
  def test_create_with_generate_password_should_email_the_password
218
-