Warning on leaving a page with unsaved content in textarea (#2910).
The warning can be turned off in the user's preference. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4900 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -894,6 +894,15 @@ module ApplicationHelper
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the javascript tags that are included in the html layout head
|
||||
def javascript_heads
|
||||
tags = javascript_include_tag(:defaults)
|
||||
unless User.current.pref.warn_on_leaving_unsaved == '0'
|
||||
tags << "\n" + javascript_tag("Event.observe(window, 'load', function(){ new WarnLeavingUnsaved('#{escape_javascript( l(:text_warn_on_leaving_unsaved) )}'); });")
|
||||
end
|
||||
tags
|
||||
end
|
||||
|
||||
def favicon
|
||||
"<link rel='shortcut icon' href='#{image_path('/favicon.ico')}' />"
|
||||
|
||||
@@ -51,4 +51,7 @@ class UserPreference < ActiveRecord::Base
|
||||
|
||||
def comments_sorting; self[:comments_sorting] end
|
||||
def comments_sorting=(order); self[:comments_sorting]=order end
|
||||
|
||||
def warn_on_leaving_unsaved; self[:warn_on_leaving_unsaved] || '1'; end
|
||||
def warn_on_leaving_unsaved=(value); self[:warn_on_leaving_unsaved]=value; end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<%= favicon %>
|
||||
<%= stylesheet_link_tag 'application', :media => 'all' %>
|
||||
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
|
||||
<%= javascript_include_tag :defaults %>
|
||||
<%= javascript_heads %>
|
||||
<%= heads_for_theme %>
|
||||
<%= heads_for_wiki_formatter %>
|
||||
<!--[if IE 6]>
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
<p><%= pref_fields.check_box :hide_mail %></p>
|
||||
<p><%= pref_fields.select :time_zone, ActiveSupport::TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :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>
|
||||
<% end %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user