jquery_datepick 1.0.2 → 1.0.3
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 +4 -4
- data/lib/jquery_datepick/form_helper.rb +22 -5
- data/lib/jquery_datepick/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 564a6cbbfcc8604a0ea3d4012e8b0a660f9eaa42
|
4
|
+
data.tar.gz: e733230a81a58a17bff818b5f6516d50fcf1124d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 084f975167a51077edd80ad6cb4dae6a6e70d173fc8d12cbdfdca7aa2e6f0df0bdf9fbe94b3a3a15fa4d0f0f403df695e6be489ebd96ac3d2c758f983955bb93
|
7
|
+
data.tar.gz: fa6ede8accc59361a89c0600828c73ad50de043186137de055d4818b1931841def10cbd2e30ae91eea0f39d10e66cf58f41ff15c5f8fe8f648e06db49a05f097
|
@@ -7,11 +7,17 @@ module JqueryDatepick
|
|
7
7
|
|
8
8
|
# Mehtod that generates datepicker input field inside a form
|
9
9
|
def datepicker(object_name, method, options = {})
|
10
|
-
|
10
|
+
options.delete(:object) if options[:object]
|
11
|
+
input_tag = JqueryDatepick::InstanceTag.new(object_name, method, self, options)
|
11
12
|
dp_options, tf_options = input_tag.split_options(options)
|
12
13
|
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)
|
13
|
-
html
|
14
|
-
|
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}']))});")
|
15
21
|
html.html_safe
|
16
22
|
end
|
17
23
|
|
@@ -25,7 +31,7 @@ module JqueryDatepick::FormBuilder
|
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
28
|
-
|
34
|
+
module JqueryDatepick_instance
|
29
35
|
|
30
36
|
FORMAT_REPLACEMENTES = { "yy" => "%Y", "mm" => "%m", "dd" => "%d", "d" => "%-d", "m" => "%-m", "y" => "%y", "M" => "%b"}
|
31
37
|
|
@@ -58,4 +64,15 @@ class JqueryDatepick::InstanceTag < ActionView::Helpers::InstanceTag
|
|
58
64
|
def translate_format(format)
|
59
65
|
format.gsub!(/#{FORMAT_REPLACEMENTES.keys.join("|")}/) { |match| FORMAT_REPLACEMENTES[match] }
|
60
66
|
end
|
61
|
-
end
|
67
|
+
end
|
68
|
+
|
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
|
+
end
|