bootstrap_builders 0.0.31 → 0.0.32

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: c73b088ae63b76eb9d62f67d98c2a18469416ff1
4
- data.tar.gz: 9975a59c34e40fb79fe4d4af30ceeac8240c0c03
3
+ metadata.gz: cb7c7644e9b3fb61308f5c91ce4721f6c919af49
4
+ data.tar.gz: 4a5fe3886d8bebd03dde534cd3c84f3df7716702
5
5
  SHA512:
6
- metadata.gz: 6259b2239a6376c22ef972dce0cdea3d079799590753d6c268d7459c6b932704ce1e0e84c444a7d53d1fa6a456602c2777feb6e4147f3163c1d70344e5a8610f
7
- data.tar.gz: dfdce2da009cae24e1e959c11f03b72f8cf79715e4f536419f3668e98d32b71623c59b416c86792eb5c24e0b3a0655b5c87125f8885382a1877098e8d2d99b14
6
+ metadata.gz: 3a6f4c9f052c961c38d0cbb34c1704aa6b5e9350f047995c4ea7eb9898f58bd1a1a7b52c91e63402e94cac7d8e0cafd50cb77bc54b570ae1701995cc37fef796
7
+ data.tar.gz: 21927109d19fdd8320065a4168344f503328a693843e42201ef7e94bcf4ed5c3bac02f7f91e1d3d96d2c6721570a4cff6e8edee90a53e91e0f3e6c54efd6fb88
@@ -1,85 +1,59 @@
1
1
  (($, window, document) ->
2
- $this = undefined
3
- $text_ele = undefined
4
- $form = undefined
5
- $year_ele = undefined
6
- $month_ele = undefined
7
- $day_ele = undefined
8
- $hour_ele = undefined
9
- $min_ele = undefined
10
-
11
2
  methods = {
12
3
  # Constructor.
13
4
  init: (options) ->
14
- $this = $(@)
15
- throw "Invalid element given." if $this.length <= 0
16
-
17
5
  # The hidden Rails-inputs that will get the actual values like year, month, date, hour and minute.
18
- $text_ele = $("input.bb_date_picker, input.bb_date_time_picker", $this)
19
- $form = $(this).parents("form").first()
20
- $year_ele = $(".bb-date-picker-input-year", $this).first()
21
- $month_ele = $(".bb-date-picker-input-moth", $this).first()
22
- $day_ele = $(".bb-date-picker-input-day", $this).first()
23
- $hour_ele = $(".bb-date-picker-input-hour", $this).first()
24
- $min_ele = $(".bb-date-picker-input-min", $this).first()
25
-
26
- throw "Could not find the year element." if $year_ele.length <= 0
6
+ text_ele = $("input.bb_date_picker, input.bb_date_time_picker", $(@))
7
+ form = text_ele.parents("form").first()
27
8
 
28
9
  # Update values on form-submit.
29
- if $form.length > 0 && $form.data("bb-date-picker-input") != "true"
30
- $form.data("bb-date-picker-input", "true")
10
+ if form.length > 0 && form.data("bb-date-picker-input") != "true"
11
+ form.data("bb-date-picker-input", "true")
31
12
 
32
- $form.submit ->
13
+ form.submit ->
33
14
  $(".bb-date-picker-input", this).each ->
34
15
  $(this).bbDatePickerInput("updateValues")
35
16
  return true
36
17
 
37
18
  # Update the values when the date is changed or upon blur
38
- $text_ele.on "changeDate blur", ->
39
- console.log "changeDate blur"
40
- $(this).parents(".bb-date-picker-input").first().bbDatePickerInput("updateValues")
41
-
42
- return $this
19
+ text_ele.on "changeDate blur", ->
20
+ parents = $(this).parents(".bb-date-picker")
21
+ throw "No parents were found" if parents.length <= 0
22
+ parents.first().bbDatePickerInput("updateValues")
43
23
 
44
24
  # Parses the date in the input-field and updates all the hidden Rails-inputs from the parsed values.
45
25
  updateValues: ->
46
- # The hidden Rails-inputs that will get the actual values like year, month, date, hour and minute.
47
- $text_ele = $("input.bb_date_picker, input.bb_date_time_picker", $this)
48
- throw "No text element?" if $text_ele.length <= 0
49
-
50
- $form = $(this).parents("form").first()
51
- $year_ele = $(".bb-date-picker-input-year", $this).first()
52
- $month_ele = $(".bb-date-picker-input-month", $this).first()
53
- $day_ele = $(".bb-date-picker-input-day", $this).first()
54
- $hour_ele = $(".bb-date-picker-input-hour", $this).first()
55
- $min_ele = $(".bb-date-picker-input-min", $this).first()
26
+ text_ele = $("input.bb_date_picker, input.bb_date_time_picker", $(@))
27
+ year_ele = $(".bb-date-picker-input-year", $(@)).first()
28
+ month_ele = $(".bb-date-picker-input-moth", $(@)).first()
29
+ day_ele = $(".bb-date-picker-input-day", $(@)).first()
30
+ hour_ele = $(".bb-date-picker-input-hour", $(@)).first()
31
+ min_ele = $(".bb-date-picker-input-min", $(@)).first()
56
32
 
57
- if $.trim($text_ele.val()) == ""
58
- $year_ele.val("")
59
- $month_ele.val("")
60
- $day_ele.val("")
61
- $hour_ele.val("")
62
- $min_ele.val("")
63
- else if match = $text_ele.val().match(/^\s*(\d+)-(\d+)-(\d+)\s+(\d+):(\d+)\s*$/)
64
- $year_ele.val(match[1])
65
- $month_ele.val(match[2])
66
- $day_ele.val(match[3])
67
- $hour_ele.val(match[4])
68
- $min_ele.val(match[5])
69
- else if match = $text_ele.val().match(/^\s*(\d+)-(\d+)-(\d+)\s*$/)
70
- $year_ele.val(match[1])
71
- $month_ele.val(match[2])
72
- $day_ele.val(match[3])
73
- $hour_ele.val(0)
74
- $min_ele.val(0)
33
+ if $.trim(text_ele.val()) == ""
34
+ year_ele.val("")
35
+ month_ele.val("")
36
+ day_ele.val("")
37
+ hour_ele.val("")
38
+ min_ele.val("")
39
+ else if match = text_ele.val().match(/^\s*(\d+)-(\d+)-(\d+)\s+(\d+):(\d+)\s*$/)
40
+ year_ele.val(match[1])
41
+ month_ele.val(match[2])
42
+ day_ele.val(match[3])
43
+ hour_ele.val(match[4])
44
+ min_ele.val(match[5])
45
+ else if match = text_ele.val().match(/^\s*(\d+)-(\d+)-(\d+)\s*$/)
46
+ year_ele.val(match[1])
47
+ month_ele.val(match[2])
48
+ day_ele.val(match[3])
49
+ hour_ele.val(0)
50
+ min_ele.val(0)
75
51
  else
76
- throw "Invalid date-format: '" + $text_ele.val() + "'."
52
+ throw "Invalid date-format: '" + text_ele.val() + "'."
77
53
 
78
54
  # Set the content to be a date, if this is a date-input-picker.
79
- if match && $text_ele.hasClass("bb_date_picker")
80
- $text_ele.val(match[1] + "-" + match[2] + "-" + match[3])
81
-
82
- return $this
55
+ if match && text_ele.hasClass("bb_date_picker")
56
+ text_ele.val(match[1] + "-" + match[2] + "-" + match[3])
83
57
  }
84
58
 
85
59
  # Initialize the plugin.
@@ -93,5 +67,4 @@
93
67
  ) jQuery, window, document
94
68
 
95
69
  $ ->
96
- $(".bb-date-picker").each ->
97
- $(this).bbDatePickerInput()
70
+ $(".bb-date-picker").each -> $(this).bbDatePickerInput()
@@ -1,3 +1,3 @@
1
1
  module BootstrapBuilders
2
- VERSION = "0.0.31".freeze
2
+ VERSION = "0.0.32".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_builders
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-24 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails