app/helpers/timepiece_helper.rb in timepiece-0.1.11 vs app/helpers/timepiece_helper.rb in timepiece-0.1.12
- old
+ new
@@ -1,7 +1,8 @@
module TimepieceHelper
def timepiece(location = 'UTC', type: '24', lead: 'none', abbr_sep: 'none', id: '')
+ # Note: On the inclusion of IDs, you should /not/ display them if none is given - HTML compliance.
Time.zone = location
hours = Time.now.in_time_zone.strftime('%H')
minutes = Time.now.in_time_zone.strftime('%M')
seconds = Time.now.in_time_zone.strftime('%S')
if type == '12'
@@ -34,11 +35,11 @@
"<span class='timepiece-separator tp-separator-2 tp-minutes-seconds'>:</span>"\
"<span class='timepiece-seconds'>#{seconds}</span>"
if type == '12'
time = time + "<span class='timepiece-abbr timepiece-abbr-#{var}'>#{var}</span>"
end
- content_tag(:span, time.html_safe, class: 'timepiece', 'data-timezone' => location, 'data-tptype' => type, 'data-lead' => lead, 'data-abbr_separator' => abbr_sep, 'id' => id)
+ content_tag(:span, time.html_safe, class: 'timepiece', 'data-timezone' => location, 'data-tptype' => type, 'data-lead' => lead, 'data-abbr_separator' => abbr_sep, 'id' => (id unless id.blank?))
end
def timer(time_since = Time.now, id: '')
seconds_diff = (Time.now - time_since).to_i
@@ -61,11 +62,11 @@
"<span class='timepiece-descriptor tp-descriptor-minutes'> minutes </span>"\
"<span class='timepiece-seconds'>#{seconds.to_s}</span>"\
"<span class='timepiece-descriptor tp-descriptor-seconds'> seconds </span>"
# "<span class='timepiece-seconds'>#{seconds.to_s.rjust(2, '0')}</span>" # Note: rjust; it might be useful.
- content_tag(:span, time.html_safe, class: 'timepiece-timer', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => id)
+ content_tag(:span, time.html_safe, class: 'timepiece-timer', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => (id unless id.blank?))
end
def countdown(time_until = Time.new(2016), id: '')
seconds_diff = (time_until - Time.now).to_i
@@ -88,8 +89,8 @@
"<span class='timepiece-descriptor tp-descriptor-minutes'> minutes </span>"\
"<span class='timepiece-seconds'>#{seconds.to_s}</span>"\
"<span class='timepiece-descriptor tp-descriptor-seconds'> seconds </span>"
# "<span class='timepiece-seconds'>#{seconds.to_s.rjust(2, '0')}</span>" # Note: rjust; it might be useful.
- content_tag(:span, time.html_safe, class: 'timepiece-countdown', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => id)
+ content_tag(:span, time.html_safe, class: 'timepiece-countdown', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => (id unless id.blank?))
end
end
\ No newline at end of file