Merge branch 'szzh' into develop

This commit is contained in:
sw 2014-08-23 14:21:19 +08:00
commit 8f28d0dd71
2 changed files with 47 additions and 22 deletions

View File

@ -1326,33 +1326,58 @@ module ApplicationHelper
javascript_tag "contextMenuInit('#{ url_for(url) }')" javascript_tag "contextMenuInit('#{ url_for(url) }')"
end end
def calendar_for(field_id) def calendar_for(field_id,start_day=nil)
include_calendar_headers_tags include_calendar_headers_tags(start_day)
javascript_tag("$(function() { $('##{field_id}').datepicker(datepickerOptions); });") javascript_tag("$(function() { $('##{field_id}').datepicker(datepickerOptions); });")
end end
def include_calendar_headers_tags def include_calendar_headers_tags(start_day=nil)
unless @calendar_headers_tags_included if start_day.nil?
@calendar_headers_tags_included = true unless @calendar_headers_tags_included
content_for :header_tags do @calendar_headers_tags_included = true
start_of_week = Setting.start_of_week content_for :header_tags do
start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank? start_of_week = Setting.start_of_week
# Redmine uses 1..7 (monday..sunday) in settings and locales start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank?
# JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0 # Redmine uses 1..7 (monday..sunday) in settings and locales
start_of_week = start_of_week.to_i % 7 # JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
start_of_week = start_of_week.to_i % 7
tags = javascript_tag( tags = javascript_tag(
"var datepickerOptions={dateFormat: 'yy-mm-dd',minDate: new Date(), firstDay: #{start_of_week}, " + "var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
"showOn: 'button', buttonImageOnly: true, buttonImage: '" + "showOn: 'button', buttonImageOnly: true, buttonImage: '" +
path_to_image('/images/calendar.png') + path_to_image('/images/calendar.png') +
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true, onClose: function(dateText, inst) {TimeClose(dateText,inst);}, beforeShow : function(input){TimeBeforeShow(input);} };") "', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};")
jquery_locale = l('jquery.locale', :default => current_language.to_s) jquery_locale = l('jquery.locale', :default => current_language.to_s)
unless jquery_locale == 'en' unless jquery_locale == 'en'
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js") tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
end
tags
end
end
else
unless @calendar_headers_tags_included
@calendar_headers_tags_included = true
content_for :header_tags do
start_of_week = Setting.start_of_week
start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank?
# Redmine uses 1..7 (monday..sunday) in settings and locales
# JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
start_of_week = start_of_week.to_i % 7
tags = javascript_tag(
"var datepickerOptions={dateFormat: 'yy-mm-dd',minDate: new Date(), firstDay: #{start_of_week}, " +
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
path_to_image('/images/calendar.png') +
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true, onClose: function(dateText, inst) {TimeClose(dateText,inst);}, beforeShow : function(input){TimeBeforeShow(input);} };")
jquery_locale = l('jquery.locale', :default => current_language.to_s)
unless jquery_locale == 'en'
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
end
tags
end end
tags
end end
end end
end end
# Overrides Rails' stylesheet_link_tag with themes and plugins support. # Overrides Rails' stylesheet_link_tag with themes and plugins support.

View File

@ -35,11 +35,11 @@
<div class="splitcontentright"> <div class="splitcontentright">
<% if @issue.safe_attribute? 'start_date' %> <% if @issue.safe_attribute? 'start_date' %>
<p><%= f.text_field :start_date, :size => 10, :disabled => !@issue.leaf?, :required => @issue.required_attribute?('start_date') %><%= calendar_for('issue_start_date') if @issue.leaf? %></p> <p><%= f.text_field :start_date, :size => 10, :disabled => !@issue.leaf?, :required => @issue.required_attribute?('start_date') %><%= calendar_for('issue_start_date','start_date') if @issue.leaf? %></p>
<% end %> <% end %>
<% if @issue.safe_attribute? 'due_date' %> <% if @issue.safe_attribute? 'due_date' %>
<p><%= f.text_field :due_date, :size => 10, :disabled => !@issue.leaf?, :required => @issue.required_attribute?('due_date') %><%= calendar_for('issue_due_date') if @issue.leaf? %></p> <p><%= f.text_field :due_date, :size => 10, :disabled => !@issue.leaf?, :required => @issue.required_attribute?('due_date') %><%= calendar_for('issue_due_date','start_date') if @issue.leaf? %></p>
<% end %> <% end %>
<% if @issue.safe_attribute? 'estimated_hours' %> <% if @issue.safe_attribute? 'estimated_hours' %>