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 +4 -4
- data/app/assets/javascripts/timepiece.js +13 -6
- data/app/helpers/timepiece_helper.rb +8 -8
- data/lib/timepiece/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f09636ed48c70100cc202344fc32f3adac95af18
|
4
|
+
data.tar.gz: f4f137ad27e5cb1feb6650956fbb4088ca6d05a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
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
|
data/lib/timepiece/version.rb
CHANGED