jquery_datepicker 0.3.4 → 0.4

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.
@@ -33,6 +33,14 @@ Rails 3.1:
33
33
  //= require jquery-ujs
34
34
  //= require jquery-ui
35
35
 
36
+ (if you are using datetime picker, add also)
37
+
38
+ //= require jquery-ui-timepicker-addon.js
39
+
40
+ You can find it here:
41
+
42
+ https://github.com/trentrichardson/jQuery-Timepicker-Addon
43
+
36
44
 
37
45
  == Usage
38
46
 
@@ -63,7 +71,28 @@ You can pass options as it would be a normal text_field, plus all the datepicker
63
71
 
64
72
  <%= datepicker_input(:foo, :att1, :minDate => -20, :maxDate => "+1M +10D", :tabindex => 70) %>
65
73
 
66
-
74
+ == Use DateTime picker
75
+
76
+ If you want to use a datatime picker, download this plugin
77
+
78
+ https://github.com/trentrichardson/jQuery-Timepicker-Addon
79
+
80
+ and add it to your project (in the assets pipeline if you are using Rails 3.1 or manually otherwise).
81
+ Don't forget the CSS! This plugin assume you have installed a jquery-ui theme.
82
+
83
+ Then you can use in your views:
84
+
85
+ <%= datetime_picker_input "user","loged_in", :dateFormat => "yy-mm-dd" %>
86
+
87
+ or
88
+
89
+ <% form_for(@user) do |f| %>
90
+ <%= f.datetime_picker 'loged_in', :dateFormat => "yy-mm-dd" %>
91
+ <%= f.submit 'Create' %>
92
+ <% end %>
93
+
94
+ Important! Be aware the way Rails stores the datetime fields cause you'll need to specify the dateFormat to "yy-mm-dd" or pre-process your field value on the controller. The default format won't work.
95
+
67
96
  == Support
68
97
 
69
98
  Open an issue in https://github.com/albertopq/jquery_datepicker if you need further support or want to report a bug
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake'
3
3
  require 'echoe'
4
4
  require 'rspec/core/rake_task'
5
5
 
6
- Echoe.new('jquery_datepicker', '0.3.4') do |p|
6
+ Echoe.new('jquery_datepicker', '0.4') do |p|
7
7
  p.description = "View helper that allows to select dates from a calendar (using jQuery Ui plugin)"
8
8
  p.url = "http://github.com/albertopq/jquery_datepicker"
9
9
  p.author = "Alberto Pastor"
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "jquery_datepicker"
5
- s.version = "0.3.4"
5
+ s.version = "0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Alberto Pastor"]
@@ -9,6 +9,10 @@ module JqueryDatepicker
9
9
  def datepicker_input(object_name, method, options = {})
10
10
  datepicker(object_name, method, options)
11
11
  end
12
+
13
+ def datetime_picker_input(object_name, method, options = {})
14
+ datepicker(object_name, method, options, true)
15
+ end
12
16
 
13
17
  end
14
18
  end
@@ -6,15 +6,16 @@ module JqueryDatepicker
6
6
  include ActionView::Helpers::JavaScriptHelper
7
7
 
8
8
  # Mehtod that generates datepicker input field inside a form
9
- def datepicker(object_name, method, options = {})
9
+ def datepicker(object_name, method, options = {}, timepicker = false)
10
10
  input_tag = JqueryDatepicker::InstanceTag.new(object_name, method, self, options.delete(:object))
11
11
  dp_options, tf_options = input_tag.split_options(options)
12
12
  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
13
  html = input_tag.to_input_field_tag("text", tf_options)
14
- html += javascript_tag("jQuery(document).ready(function(){jQuery('##{input_tag.get_name_and_id["id"]}').datepicker(#{dp_options.to_json})});")
14
+ method = timepicker ? "datetimepicker" : "datepicker"
15
+ html += javascript_tag("jQuery(document).ready(function(){jQuery('##{input_tag.get_name_and_id["id"]}').#{method}(#{dp_options.to_json})});")
15
16
  html.html_safe
16
17
  end
17
-
18
+
18
19
  end
19
20
 
20
21
  end
@@ -23,6 +24,10 @@ module JqueryDatepicker::FormBuilder
23
24
  def datepicker(method, options = {})
24
25
  @template.datepicker(@object_name, method, objectify_options(options))
25
26
  end
27
+
28
+ def datetime_picker(method, options = {})
29
+ @template.datepicker(@object_name, method, objectify_options(options), true)
30
+ end
26
31
  end
27
32
 
28
33
  class JqueryDatepicker::InstanceTag < ActionView::Helpers::InstanceTag
metadata CHANGED
@@ -1,27 +1,34 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jquery_datepicker
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.4
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 4
8
+ version: "0.4"
6
9
  platform: ruby
7
- authors:
10
+ authors:
8
11
  - Alberto Pastor
9
12
  autorequire:
10
13
  bindir: bin
11
14
  cert_chain: []
12
- date: 2011-11-07 00:00:00.000000000 Z
15
+
16
+ date: 2011-11-07 00:00:00 +00:00
17
+ default_executable:
13
18
  dependencies: []
14
- description: View helper that allows to select dates from a calendar (using jQuery
15
- Ui plugin)
19
+
20
+ description: View helper that allows to select dates from a calendar (using jQuery Ui plugin)
16
21
  email: albert.pastor@gmail.com
17
22
  executables: []
23
+
18
24
  extensions: []
19
- extra_rdoc_files:
25
+
26
+ extra_rdoc_files:
20
27
  - README.rdoc
21
28
  - lib/app/helpers/datepicker_helper.rb
22
29
  - lib/app/helpers/form_helper.rb
23
30
  - lib/jquery_datepicker.rb
24
- files:
31
+ files:
25
32
  - README.rdoc
26
33
  - Rakefile
27
34
  - init.rb
@@ -29,35 +36,41 @@ files:
29
36
  - lib/app/helpers/datepicker_helper.rb
30
37
  - lib/app/helpers/form_helper.rb
31
38
  - lib/jquery_datepicker.rb
39
+ has_rdoc: true
32
40
  homepage: http://github.com/albertopq/jquery_datepicker
33
41
  licenses: []
42
+
34
43
  post_install_message:
35
- rdoc_options:
44
+ rdoc_options:
36
45
  - --line-numbers
37
46
  - --inline-source
38
47
  - --title
39
48
  - Jquery_datepicker
40
49
  - --main
41
50
  - README.rdoc
42
- require_paths:
51
+ require_paths:
43
52
  - lib
44
- required_ruby_version: !ruby/object:Gem::Requirement
45
- none: false
46
- requirements:
47
- - - ! '>='
48
- - !ruby/object:Gem::Version
49
- version: '0'
50
- required_rubygems_version: !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ! '>='
54
- - !ruby/object:Gem::Version
55
- version: '1.2'
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ segments:
65
+ - 1
66
+ - 2
67
+ version: "1.2"
56
68
  requirements: []
69
+
57
70
  rubyforge_project: jquery_datepicker
58
- rubygems_version: 1.8.16
71
+ rubygems_version: 1.3.6
59
72
  signing_key:
60
73
  specification_version: 3
61
- summary: View helper that allows to select dates from a calendar (using jQuery Ui
62
- plugin)
74
+ summary: View helper that allows to select dates from a calendar (using jQuery Ui plugin)
63
75
  test_files: []
76
+