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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcc89df1e21908d1166b9abfb674a9a588445628
4
- data.tar.gz: 7b2ad282561fc736e41da20638d5aff89674acd9
3
+ metadata.gz: 49693dc7849afe540aa873ce5c1c9543e72d50d6
4
+ data.tar.gz: 30ee4f95788beb90a6ce84b06d67b4e765a3680a
5
5
  SHA512:
6
- metadata.gz: a4d897e6b0c2f3790be0dd6850057d3544136dde7d567dd20e7bd3b138249420b74f28183f1ccb3dcf9757cceeaf20b0a74ab125be8bc9f6cf0eb9c7924f1a31
7
- data.tar.gz: 8a025eea31f6cb494eb8bb8e6c7e99bcce966bb6350a8ab33fb2b0cdae7575fb73443f85562717e599c3d3b317910bae94974eae7e4f1a356d9f79c2620dddc6
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.delete(:object))
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 = input_tag.to_input_field_tag("text", tf_options)
26
- html += javascript_tag("jQuery(document).ready(function(){jQuery('##{input_tag.get_name_and_id["id"]}').datetimepicker(#{json})});")
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
- class JqueryDatetimepick::InstanceTag < ActionView::Helpers::InstanceTag
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
+
@@ -1,3 +1,3 @@
1
1
  module JqueryDatetimepick
2
- VERSION = "1.3.3"
2
+ VERSION = "1.3.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery_datetimepick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Herman verschooten