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,12 +1326,35 @@ 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)
if start_day.nil?
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', firstDay: #{start_of_week}, " +
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
path_to_image('/images/calendar.png') +
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};")
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
else
unless @calendar_headers_tags_included unless @calendar_headers_tags_included
@calendar_headers_tags_included = true @calendar_headers_tags_included = true
content_for :header_tags do content_for :header_tags do
@ -1355,6 +1378,8 @@ module ApplicationHelper
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.
# Examples: # Examples:
# stylesheet_link_tag('styles') # => picks styles.css from the current theme or defaults # stylesheet_link_tag('styles') # => picks styles.css from the current theme or defaults

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' %>