picktastic 0.0.1 → 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b23369dd19dba9cb24d2bae9ed971d50d972629d
4
+ data.tar.gz: 714c8447df98111f49ce40ae239d9a53ce514cda
5
+ SHA512:
6
+ metadata.gz: 33629bf759dd8aafe058bd3ad840057a4ad41a852207f20f0fc5c7f40f8176eef7e12feedf167b1c576366045a04c2b13c7cb0911494d581b20ab44063ff5017
7
+ data.tar.gz: c7d2402802ee8234114c860b6f313a1eb60206d28c66f0df85f28cc3fdec26eef07b7ee95d75e9a8774508af78584f6ac69f797164b89e68cb64a396cd27ee69
@@ -1,9 +1,37 @@
1
- class PicktasticDatePickerInput < Formtastic::Inputs::StringInput
1
+ class PicktasticDatePickerInput < FormtasticBootstrap::Inputs::StringInput
2
2
 
3
- cattr_accessor :format
3
+ cattr_accessor :format, :week_start, :language, :auto_close, :input_value_format, :today_button, :data
4
+
5
+ @@week_start = 1
6
+ @@format = I18n.t("date.formats.picktastic")
7
+ @@input_value_format = I18n.t("date.formats.picktastic_input_value_format")
8
+ @@language = I18n.locale
9
+ @@auto_close = true
10
+ @@today_button = "linked"
11
+ @@data = { format: @@format,
12
+ todaybtn: @@today_button,
13
+ weekstart: @@week_start,
14
+ autoclose: @@auto_close,
15
+ language: @@language.to_s }
16
+
17
+ def self.format_value value
18
+ if value.present?
19
+ I18n.l(value, format: @@input_value_format)
20
+ end
21
+ end
4
22
 
5
23
  def input_html_options
6
- super.merge(:class => "picktastic_date_picker", :'data-dateformat' => PicktasticDatePickerInput.format)
24
+ parent_options = super
25
+ parent_data = parent_options[:data] || {}
26
+ data = @@data.merge(parent_data)
27
+ parent_options.merge(:class => "picktastic_date_picker",
28
+ :value => value,
29
+ :data => data)
7
30
  end
8
- end
9
31
 
32
+ def value
33
+ if @object && @object.respond_to?(@method) && value = @object.send(@method)
34
+ PicktasticDatePickerInput.format_value value
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module Picktastic
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,14 +1,27 @@
1
- $(picktastic_init)
2
-
3
- function picktastic_init() {
4
- var inputs = $('input.picktastic_date_picker');
5
- if (inputs.length > 0) {
6
-
7
- var format = $(inputs[0]).data('dateformat');
8
- var options = {};
9
- if (format != '') {
10
- options = { dateFormat: format}
11
- }
12
- inputs.datepicker(options);
1
+ $(picktastic_init);
2
+
3
+ picktasticProperties = ['format', 'weekStart', 'autoclose', 'language', 'todayBtn'];
4
+ var addProperty = function(object, input, key) {
5
+ // haml lowercases all attribute-names so we need to look up the data attributes lowercased
6
+ var value = input.data(key.toLowerCase());
7
+ if (value !== undefined) {
8
+ object[key] = value;
13
9
  }
14
- }
10
+ };
11
+
12
+ function initPicktasticForElement(elem) {
13
+ var input = $(elem);
14
+ var options = {};
15
+
16
+ $.each(picktasticProperties, function(idx, key) {
17
+ addProperty(options, input, key);
18
+ });
19
+ return input.datepicker(options);
20
+ };
21
+
22
+ function picktastic_init() {
23
+ $('input.picktastic_date_picker').each(function(idx, elem) {
24
+ initPicktasticForElement(elem);
25
+ });
26
+ };
27
+
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picktastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Axel Tetzlaff
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-08 00:00:00.000000000 Z
11
+ date: 2016-02-18 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Provides a formtastc input that binds the jquery datepicker to the input
15
14
  field
@@ -19,7 +18,7 @@ executables: []
19
18
  extensions: []
20
19
  extra_rdoc_files: []
21
20
  files:
22
- - .gitignore
21
+ - ".gitignore"
23
22
  - Gemfile
24
23
  - LICENSE.txt
25
24
  - README.md
@@ -32,27 +31,26 @@ files:
32
31
  - vendor/assets/javascripts/picktastic/onload.js
33
32
  homepage: ''
34
33
  licenses: []
34
+ metadata: {}
35
35
  post_install_message:
36
36
  rdoc_options: []
37
37
  require_paths:
38
38
  - lib
39
39
  required_ruby_version: !ruby/object:Gem::Requirement
40
- none: false
41
40
  requirements:
42
- - - ! '>='
41
+ - - ">="
43
42
  - !ruby/object:Gem::Version
44
43
  version: '0'
45
44
  required_rubygems_version: !ruby/object:Gem::Requirement
46
- none: false
47
45
  requirements:
48
- - - ! '>='
46
+ - - ">="
49
47
  - !ruby/object:Gem::Version
50
48
  version: '0'
51
49
  requirements: []
52
50
  rubyforge_project:
53
- rubygems_version: 1.8.23
51
+ rubygems_version: 2.4.5.1
54
52
  signing_key:
55
- specification_version: 3
53
+ specification_version: 4
56
54
  summary: Adds a custom input picktastic_date_picker and supplies a js file that will
57
55
  bind the jquery datepicker widget to these inputs
58
56
  test_files: []