timepiece 0.1.10 → 0.1.11

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: 7718e37a2cc914021c28efaae5ec8044540bf8a7
4
- data.tar.gz: 07062cbe1d9bc4771f9fb54e8a6a8f6c7a0b123d
3
+ metadata.gz: f09636ed48c70100cc202344fc32f3adac95af18
4
+ data.tar.gz: f4f137ad27e5cb1feb6650956fbb4088ca6d05a4
5
5
  SHA512:
6
- metadata.gz: c6377ab39f72cfbf29e2c29e4d708fbe0a15bbb6dcb269a9306663c08e63c921215f52276c33393417e7f74d29441833a72c768a0cdfeacfd5f93c509eddf0ef
7
- data.tar.gz: 49bb8b5a5f4ba48a86fd4b7a074bdd551569677e0b8c175304427aa8c19ad56d7940de8be94d888ade476861a4f6ea68373a207048b30f9c53938a2a0ab3287b
6
+ metadata.gz: fdb95e64628c38163014d7996f64cba15746adf748020e65bfa7019da1fedc2c9eeac105ccbba5c811fffaab66e5cce4911dbddcb63620847920b830330f466e
7
+ data.tar.gz: ed01e22633bbe9e315aba8bf55491053257ca3cb7b94522158666b034e8d28c6b7f6c79caf9f0cccf78233ed11396bc8d3bb298c2eb9535cdaf66d097f30c712
@@ -196,12 +196,19 @@ function reset_time(){
196
196
  }
197
197
 
198
198
  $(document).ready(function(){
199
- get_time()
200
- set_timer()
201
- set_countdown()
202
- show_time()
203
- show_timer()
204
- show_countdown()
199
+ // Might want to reformat to move if-statement : should also be performed before 'reset_time' so as not to make a blank AJAX request.
200
+ if ($(".timepiece").length > 0){
201
+ get_time()
202
+ show_time()
203
+ }
204
+ if ($(".timepiece-timer").length > 0){
205
+ set_timer()
206
+ show_timer()
207
+ }
208
+ if ($(".timepiece-countdown").length > 0){
209
+ set_countdown()
210
+ show_countdown()
211
+ }
205
212
  })
206
213
  $(document).on('page:load', function(){
207
214
  clearInterval(clock);
@@ -1,5 +1,5 @@
1
1
  module TimepieceHelper
2
- def timepiece(location = 'UTC', type: '24', lead: 'none', abbr_sep: 'none')
2
+ def timepiece(location = 'UTC', type: '24', lead: 'none', abbr_sep: 'none', id: '')
3
3
  Time.zone = location
4
4
  hours = Time.now.in_time_zone.strftime('%H')
5
5
  minutes = Time.now.in_time_zone.strftime('%M')
@@ -29,17 +29,17 @@ module TimepieceHelper
29
29
  end
30
30
  end
31
31
  time = "<span class='timepiece-hours'>#{hours}</span>"\
32
- "<span class='timepiece-separator tp-separator-1'>:</span>"\
32
+ "<span class='timepiece-separator tp-separator-1 tp-hours-minutes'>:</span>"\
33
33
  "<span class='timepiece-minutes'>#{minutes}</span>"\
34
- "<span class='timepiece-separator tp-separator-2'>:</span>"\
34
+ "<span class='timepiece-separator tp-separator-2 tp-minutes-seconds'>:</span>"\
35
35
  "<span class='timepiece-seconds'>#{seconds}</span>"
36
36
  if type == '12'
37
37
  time = time + "<span class='timepiece-abbr timepiece-abbr-#{var}'>#{var}</span>"
38
38
  end
39
- content_tag(:span, time.html_safe, class: 'timepiece', 'data-timezone' => location, 'data-tptype' => type, 'data-lead' => lead, 'data-abbr_separator' => abbr_sep)
39
+ content_tag(:span, time.html_safe, class: 'timepiece', 'data-timezone' => location, 'data-tptype' => type, 'data-lead' => lead, 'data-abbr_separator' => abbr_sep, 'id' => id)
40
40
  end
41
41
 
42
- def timer(time_since = Time.now)
42
+ def timer(time_since = Time.now, id: '')
43
43
  seconds_diff = (Time.now - time_since).to_i
44
44
 
45
45
  days = seconds_diff / 86400
@@ -63,10 +63,10 @@ module TimepieceHelper
63
63
  "<span class='timepiece-descriptor tp-descriptor-seconds'> seconds </span>"
64
64
  # "<span class='timepiece-seconds'>#{seconds.to_s.rjust(2, '0')}</span>" # Note: rjust; it might be useful.
65
65
 
66
- content_tag(:span, time.html_safe, class: 'timepiece-timer', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds)
66
+ content_tag(:span, time.html_safe, class: 'timepiece-timer', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => id)
67
67
  end
68
68
 
69
- def countdown(time_until = Time.new(2016))
69
+ def countdown(time_until = Time.new(2016), id: '')
70
70
  seconds_diff = (time_until - Time.now).to_i
71
71
 
72
72
  days = seconds_diff / 86400
@@ -90,6 +90,6 @@ module TimepieceHelper
90
90
  "<span class='timepiece-descriptor tp-descriptor-seconds'> seconds </span>"
91
91
  # "<span class='timepiece-seconds'>#{seconds.to_s.rjust(2, '0')}</span>" # Note: rjust; it might be useful.
92
92
 
93
- content_tag(:span, time.html_safe, class: 'timepiece-countdown', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds)
93
+ content_tag(:span, time.html_safe, class: 'timepiece-countdown', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => id)
94
94
  end
95
95
  end
@@ -1,3 +1,3 @@
1
1
  module Timepiece
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timepiece
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom Bruce