Project

General

Profile

Defect #23224 » revert-native-date-pickers.patch

revert native date pickers patch - Luc Luc, 2016-08-23 18:41

View differences:

app/helpers/application_helper.rb
1172 1172

  
1173 1173
  def calendar_for(field_id)
1174 1174
    include_calendar_headers_tags
1175
    javascript_tag("$(function() { $('##{field_id}').addClass('date').datepickerFallback(datepickerOptions); });")
1175
    javascript_tag("$(function() { $('##{field_id}').addClass('date').datepicker(datepickerOptions); });")
1176 1176
  end
1177 1177

  
1178 1178
  def include_calendar_headers_tags
app/views/custom_fields/formats/_date.html.erb
1
<p><%= f.date_field(:default_value, :value => @custom_field.default_value, :size => 10) %></p>
1
<p><%= f.text_field(:default_value, :size => 10) %></p>
2 2
<%= calendar_for('custom_field_default_value') %>
3 3
<p><%= f.text_field :url_pattern, :size => 50, :label => :label_link_values_to %></p>
app/views/issues/_attributes.html.erb
52 52

  
53 53
<% if @issue.safe_attribute? 'start_date' %>
54 54
<p id="start_date_area">
55
  <%= f.date_field(:start_date, :size => 10, :required => @issue.required_attribute?('start_date')) %>
55
  <%= f.text_field(:start_date, :size => 10, :required => @issue.required_attribute?('start_date')) %>
56 56
  <%= calendar_for('issue_start_date') %>
57 57
</p>
58 58
<% end %>
59 59

  
60 60
<% if @issue.safe_attribute? 'due_date' %>
61 61
<p id="due_date_area">
62
  <%= f.date_field(:due_date, :size => 10, :required => @issue.required_attribute?('due_date')) %>
62
  <%= f.text_field(:due_date, :size => 10, :required => @issue.required_attribute?('due_date')) %>
63 63
  <%= calendar_for('issue_due_date') %>
64 64
</p>
65 65
<% end %>
app/views/issues/bulk_edit.html.erb
147 147
<% if @safe_attributes.include?('start_date') %>
148 148
<p>
149 149
  <label for='issue_start_date'><%= l(:field_start_date) %></label>
150
  <%= date_field_tag 'issue[start_date]', '', :value => @issue_params[:start_date], :size => 10 %><%= calendar_for('issue_start_date') %>
150
  <%= text_field_tag 'issue[start_date]', '', :value => @issue_params[:start_date], :size => 10 %><%= calendar_for('issue_start_date') %>
151 151
  <label class="inline"><%= check_box_tag 'issue[start_date]', 'none', (@issue_params[:start_date] == 'none'), :id => nil, :data => {:disables => '#issue_start_date'} %><%= l(:button_clear) %></label>
152 152
</p>
153 153
<% end %>
......
155 155
<% if @safe_attributes.include?('due_date') %>
156 156
<p>
157 157
  <label for='issue_due_date'><%= l(:field_due_date) %></label>
158
  <%= date_field_tag 'issue[due_date]', '', :value => @issue_params[:due_date], :size => 10 %><%= calendar_for('issue_due_date') %>
158
  <%= text_field_tag 'issue[due_date]', '', :value => @issue_params[:due_date], :size => 10 %><%= calendar_for('issue_due_date') %>
159 159
  <label class="inline"><%= check_box_tag 'issue[due_date]', 'none', (@issue_params[:due_date] == 'none'), :id => nil, :data => {:disables => '#issue_due_date'} %><%= l(:button_clear) %></label>
160 160
</p>
161 161
<% end %>
app/views/timelog/_form.html.erb
17 17
      <span id="time_entry_issue"><%= "#{@time_entry.issue.tracker.name} ##{@time_entry.issue.id}: #{@time_entry.issue.subject}" %></span>
18 18
    <% end %>
19 19
  </p>
20
  <p><%= f.date_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
20
  <p><%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
21 21
  <p><%= f.text_field :hours, :size => 6, :required => true %></p>
22 22
  <p><%= f.text_field :comments, :size => 100, :maxlength => 1024 %></p>
23 23
  <p><%= f.select :activity_id, activity_collection_for_select_options(@time_entry), :required => true %></p>
app/views/timelog/bulk_edit.html.erb
18 18

  
19 19
    <p>
20 20
      <label><%= l(:field_spent_on) %></label>
21
      <%= date_field :time_entry, :spent_on, :size => 10 %><%= calendar_for('time_entry_spent_on') %>
21
      <%= text_field :time_entry, :spent_on, :size => 10 %><%= calendar_for('time_entry_spent_on') %>
22 22
    </p>
23 23

  
24 24
    <p>
app/views/versions/_form.html.erb
6 6
<p><%= f.text_field :description, :size => 60 %></p>
7 7
<p><%= f.select :status, Version::VERSION_STATUSES.collect {|s| [l("version_status_#{s}"), s]} %></p>
8 8
<p><%= f.text_field :wiki_page_title, :label => :label_wiki_page, :size => 60, :disabled => @project.wiki.nil? %></p>
9
<p><%= f.date_field :effective_date, :size => 10 %><%= calendar_for('version_effective_date') %></p>
9
<p><%= f.text_field :effective_date, :size => 10 %><%= calendar_for('version_effective_date') %></p>
10 10
<p><%= f.select :sharing, @version.allowed_sharings.collect {|v| [format_version_sharing(v), v]} %></p>
11 11

  
12 12
<% @version.custom_field_values.each do |value| %>
lib/redmine/field_format.rb
476 476
      end
477 477

  
478 478
      def edit_tag(view, tag_id, tag_name, custom_value, options={})
479
        view.date_field_tag(tag_name, custom_value.value, options.merge(:id => tag_id, :size => 10)) +
479
        view.text_field_tag(tag_name, custom_value.value, options.merge(:id => tag_id, :size => 10)) +
480 480
          view.calendar_for(tag_id)
481 481
      end
482 482

  
483 483
      def bulk_edit_tag(view, tag_id, tag_name, custom_field, objects, value, options={})
484
        view.date_field_tag(tag_name, value, options.merge(:id => tag_id, :size => 10)) +
484
        view.text_field_tag(tag_name, value, options.merge(:id => tag_id, :size => 10)) +
485 485
          view.calendar_for(tag_id) +
486 486
          bulk_clear_tag(view, tag_id, tag_name, custom_field, value)
487 487
      end
public/javascripts/application.js
185 185
  case "date":
186 186
  case "date_past":
187 187
    tr.find('td.values').append(
188
      '<span style="display:none;"><input type="date" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' +
189
      ' <span style="display:none;"><input type="date" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' +
188
      '<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' +
189
      ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' +
190 190
      ' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="3" class="value" /> '+labelDayPlural+'</span>'
191 191
    );
192
    $('#values_'+fieldId+'_1').val(values[0]).datepickerFallback(datepickerOptions);
193
    $('#values_'+fieldId+'_2').val(values[1]).datepickerFallback(datepickerOptions);
192
    $('#values_'+fieldId+'_1').val(values[0]).datepicker(datepickerOptions);
193
    $('#values_'+fieldId+'_2').val(values[1]).datepicker(datepickerOptions);
194 194
    $('#values_'+fieldId).val(values[0]);
195 195
    break;
196 196
  case "string":
......
587 587
      }
588 588
      break;
589 589
  }
590
  $(input).datepickerFallback("option", "defaultDate", default_date);
590
  $(input).datepicker("option", "defaultDate", default_date);
591 591
}
592 592

  
593 593
(function($){
......
733 733
    dropdown.addClass('visible');
734 734
  }
735 735
}
736

  
737
(function ( $ ) {
738

  
739
  // detect if native date input is supported
740
  var nativeDateInputSupported = true;
741

  
742
  var input = document.createElement('input');
743
  input.setAttribute('type','date');
744
  if (input.type === 'text') {
745
    nativeDateInputSupported = false;
746
  }
747

  
748
  var notADateValue = 'not-a-date';
749
  input.setAttribute('value', notADateValue);
750
  if (input.value === notADateValue) {
751
    nativeDateInputSupported = false;
752
  }
753

  
754
  $.fn.datepickerFallback = function( options ) {
755
    if (nativeDateInputSupported) {
756
      return this;
757
    } else {
758
      return this.datepicker( options );
759
    }
760
  };
761
}( jQuery ));
762

  
763 736
$(document).ready(function(){
764 737
  $('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
765 738
  toggleDisabledInit();
(7-7/7)