jquery_datepick 1.0.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 564a6cbbfcc8604a0ea3d4012e8b0a660f9eaa42
4
- data.tar.gz: e733230a81a58a17bff818b5f6516d50fcf1124d
3
+ metadata.gz: 4fd443bcb10031b5085a63d1b7453c49f5f65cfd
4
+ data.tar.gz: 044088ba8d3a51978df3a0e62f05ffab0a0bb8cf
5
5
  SHA512:
6
- metadata.gz: 084f975167a51077edd80ad6cb4dae6a6e70d173fc8d12cbdfdca7aa2e6f0df0bdf9fbe94b3a3a15fa4d0f0f403df695e6be489ebd96ac3d2c758f983955bb93
7
- data.tar.gz: fa6ede8accc59361a89c0600828c73ad50de043186137de055d4818b1931841def10cbd2e30ae91eea0f39d10e66cf58f41ff15c5f8fe8f648e06db49a05f097
6
+ metadata.gz: 06dcfaea5a40dda5e2f03c28930e624b3224dddc80f816237e02ed5e0a2470b64e67c8c42c9fa8a9ce70b07893dd294142e11018d7dbb255559394cc73a68a16
7
+ data.tar.gz: 8d7773a86a3810bb9beda1a131031c46f67eb6b21433031dd4a2eabfe85ef7caf4ccbb8df2ba8ab78c157aa31493c7da67cb029c4ac3dd0609b78cf6a2c00eb6
@@ -16,6 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
- gem.add_development_dependency "railties", "~> 3.1"
19
+ gem.add_development_dependency "railties", "~> 4"
20
20
  gem.license = 'MIT'
21
21
  end
@@ -2,25 +2,18 @@ require 'date'
2
2
 
3
3
  module JqueryDatepick
4
4
  module FormHelper
5
-
6
5
  include ActionView::Helpers::JavaScriptHelper
7
6
 
8
7
  # Mehtod that generates datepicker input field inside a form
9
- def datepicker(object_name, method, options = {})
10
- options.delete(:object) if options[:object]
11
- input_tag = JqueryDatepick::InstanceTag.new(object_name, method, self, options)
8
+ def datepicker(object_name, method, options = {}, timepicker = false)
9
+ input_tag = JqueryDatepick::Tags.new(object_name, method, self, options)
12
10
  dp_options, tf_options = input_tag.split_options(options)
13
11
  tf_options[:value] = input_tag.format_date(tf_options[:value], String.new(dp_options[:dateFormat])) if tf_options[:value] && !tf_options[:value].empty? && dp_options.has_key?(:dateFormat)
14
- html= if defined?(ActionView::Helpers::InstanceTag) && ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
15
- input_tag.to_input_field_tag("text", tf_options)
16
- else
17
- ActionView::Helpers::Tags::TextField.new(object_name, method, tf_options).render
18
- end
19
-
20
- html += javascript_tag("jQuery(document).ready(function(){jQuery('##{input_tag.get_name_and_id["id"]}').datepick($.extend(#{dp_options.to_json},$.datepick.regional['#{I18n.locale}']))});")
12
+ html = input_tag.render
13
+ method = timepicker ? "datetimepicker" : "datepicker"
14
+ html += javascript_tag("jQuery(document).ready(function(){jQuery('##{input_tag.get_name_and_id(tf_options.stringify_keys)["id"]}').#{method}(#{dp_options.to_json})});")
21
15
  html.html_safe
22
16
  end
23
-
24
17
  end
25
18
 
26
19
  end
@@ -29,29 +22,33 @@ module JqueryDatepick::FormBuilder
29
22
  def datepicker(method, options = {})
30
23
  @template.datepicker(@object_name, method, objectify_options(options))
31
24
  end
25
+
26
+ def datetime_picker(method, options = {})
27
+ @template.datepicker(@object_name, method, objectify_options(options), true)
28
+ end
32
29
  end
33
30
 
34
- module JqueryDatepick_instance
31
+ class JqueryDatepick::Tags < ActionView::Helpers::Tags::TextField
35
32
 
36
33
  FORMAT_REPLACEMENTES = { "yy" => "%Y", "mm" => "%m", "dd" => "%d", "d" => "%-d", "m" => "%-m", "y" => "%y", "M" => "%b"}
37
-
38
- # Extending ActionView::Helpers::InstanceTag module to make Rails build the name and id
34
+
35
+ # Extending ActionView::Helpers::Tags module to make Rails build the name and id
39
36
  # Just returns the options before generate the HTML in order to use the same id and name (see to_input_field_tag mehtod)
40
-
37
+
41
38
  def get_name_and_id(options = {})
42
39
  add_default_name_and_id(options)
43
40
  options
44
41
  end
45
-
42
+
46
43
  def available_datepicker_options
47
44
  [:disabled, :altField, :altFormat, :appendText, :autoSize, :buttonImage, :buttonImageOnly, :buttonText, :calculateWeek, :changeMonth, :changeYear, :closeText, :constrainInput, :currentText, :dateFormat, :dayNames, :dayNamesMin, :dayNamesShort, :defaultDate, :duration, :firstDay, :gotoCurrent, :hideIfNoPrevNext, :isRTL, :maxDate, :minDate, :monthNames, :monthNamesShort, :navigationAsDateFormat, :nextText, :numberOfMonths, :prevText, :selectOtherMonths, :shortYearCutoff, :showAnim, :showButtonPanel, :showCurrentAtPos, :showMonthAfterYear, :showOn, :showOptions, :showOtherMonths, :showWeek, :stepMonths, :weekHeader, :yearRange, :yearSuffix]
48
45
  end
49
-
46
+
50
47
  def split_options(options)
51
48
  tf_options = options.slice!(*available_datepicker_options)
52
49
  return options, tf_options
53
50
  end
54
-
51
+
55
52
  def format_date(tb_formatted, format)
56
53
  new_format = translate_format(format)
57
54
  Date.parse(tb_formatted).strftime(new_format)
@@ -60,19 +57,9 @@ module JqueryDatepick_instance
60
57
  # Method that translates the datepicker date formats, defined in (http://docs.jquery.com/UI/Datepicker/formatDate)
61
58
  # to the ruby standard format (http://www.ruby-doc.org/core-1.9.3/Time.html#method-i-strftime).
62
59
  # This gem is not going to support all the options, just the most used.
63
-
60
+
64
61
  def translate_format(format)
65
62
  format.gsub!(/#{FORMAT_REPLACEMENTES.keys.join("|")}/) { |match| FORMAT_REPLACEMENTES[match] }
66
63
  end
67
- end
68
64
 
69
-
70
- if defined?(ActionView::Helpers::InstanceTag) && ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
71
- class JqueryDatepick::InstanceTag < ActionView::Helpers::InstanceTag
72
- include JqueryDatepick_instance
73
- end
74
- else
75
- class JqueryDatepick::InstanceTag < ActionView::Helpers::Tags::Base
76
- include JqueryDatepick_instance
77
- end
78
65
  end
@@ -1,3 +1,3 @@
1
1
  module JqueryDatepick
2
- VERSION = "1.0.3"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery_datepick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Herman verschooten
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-25 00:00:00.000000000 Z
11
+ date: 2014-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
26
+ version: '4'
27
27
  description: View helper that allows to select dates from a calendar using jQuery
28
28
  DatePick (http://keith-wood.name/datepick.html)
29
29
  email:
@@ -32,7 +32,7 @@ executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - .gitignore
35
+ - ".gitignore"
36
36
  - Gemfile
37
37
  - LICENSE.txt
38
38
  - README.md
@@ -168,17 +168,17 @@ require_paths:
168
168
  - lib
169
169
  required_ruby_version: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '>='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  requirements:
176
- - - '>='
176
+ - - ">="
177
177
  - !ruby/object:Gem::Version
178
178
  version: '0'
179
179
  requirements: []
180
180
  rubyforge_project:
181
- rubygems_version: 2.0.3
181
+ rubygems_version: 2.2.2
182
182
  signing_key:
183
183
  specification_version: 4
184
184
  summary: Gem with helpers for jQuery DatePick (http://keith-wood.name/datepick.html)