jquery_datetimepick 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jquery_datetimepick/form_helper.rb +20 -6
- data/lib/jquery_datetimepick/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: 49693dc7849afe540aa873ce5c1c9543e72d50d6
|
4
|
+
data.tar.gz: 30ee4f95788beb90a6ce84b06d67b4e765a3680a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c4dc1d5bb28f80d590a471ac974a005a1a3278d3ec68db84111dfbcd02859656a4a7272255300d14f6638722ca7a5e001c668df853c2b1a75bb12ecce3f0831
|
7
|
+
data.tar.gz: f92a586e8caddd8f4139588fc6b5bac5e899d1bb30aa8027f1779a2adf62530e7f6a8e37b4523ce5c401525fa26beea9513268c593348d5577d6e4d8a2273a68
|
@@ -7,7 +7,7 @@ module JqueryDatetimepick
|
|
7
7
|
|
8
8
|
# Mehtod that generates datetimepicker input field inside a form
|
9
9
|
def datetimepicker(object_name, method, options = {})
|
10
|
-
input_tag = JqueryDatetimepick::InstanceTag.new(object_name, method, self, options
|
10
|
+
input_tag = JqueryDatetimepick::InstanceTag.new(object_name, method, self, options)
|
11
11
|
dp_options, tf_options = input_tag.split_options(options)
|
12
12
|
tf_options[:value] = input_tag.format_datetime(tf_options[:value], String.new(dp_options[:dateFormat])) if tf_options[:value] && !tf_options[:value].empty? && dp_options.has_key?(:dateFormat)
|
13
13
|
[ :minDateTime, :maxDateTime ].each do |var|
|
@@ -22,8 +22,12 @@ module JqueryDatetimepick
|
|
22
22
|
json = dp_options.to_json
|
23
23
|
json.gsub! /"(new Date\([^\)]*\))"/, '\1'
|
24
24
|
json.gsub! /"(function\(\) \{[^\}]*\})"/, '\1'
|
25
|
-
html
|
26
|
-
|
25
|
+
html= if defined?(ActionView::Helpers::InstanceTag) && ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
|
26
|
+
input_tag.to_input_field_tag("text", tf_options)
|
27
|
+
else
|
28
|
+
ActionView::Helpers::Tags::TextField.new(object_name, method, tf_options).render
|
29
|
+
end
|
30
|
+
html += javascript_tag("jQuery(document).ready(function(){jQuery('##{input_tag.get_name_and_id["id"]}').datetimepicker($.extend(#{json}, $.timepicker.regional[#{I18n.locale}]))});")
|
27
31
|
html.html_safe
|
28
32
|
end
|
29
33
|
|
@@ -37,8 +41,7 @@ module JqueryDatetimepick::FormBuilder
|
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
40
|
-
|
41
|
-
|
44
|
+
module JqueryDatetimepick_instance
|
42
45
|
FORMAT_REPLACEMENTES = { "yy" => "%Y", "mm" => "%m", "dd" => "%d", "d" => "%-d", "m" => "%-m", "y" => "%y", "M" => "%b", "hh" => "%H", "h" => "%I", "mm" => "%M"}
|
43
46
|
|
44
47
|
# Extending ActionView::Helpers::InstanceTag module to make Rails build the name and id
|
@@ -90,4 +93,15 @@ class JqueryDatetimepick::InstanceTag < ActionView::Helpers::InstanceTag
|
|
90
93
|
def translate_format(format)
|
91
94
|
format.gsub!(/#{FORMAT_REPLACEMENTES.keys.join("|")}/) { |match| FORMAT_REPLACEMENTES[match] }
|
92
95
|
end
|
93
|
-
end
|
96
|
+
end
|
97
|
+
|
98
|
+
if defined?(ActionView::Helpers::InstanceTag) && ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
|
99
|
+
class JqueryDatetimepick::InstanceTag < ActionView::Helpers::InstanceTag
|
100
|
+
include JqueryDatetimepick_instance
|
101
|
+
end
|
102
|
+
else
|
103
|
+
class JqueryDatetimepick::InstanceTag < ActionView::Helpers::Tags::Base
|
104
|
+
include JqueryDatetimepick_instance
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|