countdowner 0.2.2 → 0.2.3
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.
@@ -1,25 +1,27 @@
|
|
1
1
|
(function() {
|
2
2
|
|
3
3
|
$(function() {
|
4
|
-
var $countdowner,
|
4
|
+
var $countdowner, updateCountdowner,
|
5
5
|
_this = this;
|
6
6
|
$countdowner = $('#countdowner');
|
7
7
|
if ($countdowner.length) {
|
8
|
-
|
9
|
-
|
8
|
+
updateCountdowner = function() {
|
9
|
+
var now;
|
10
|
+
console.log('updateCountdowner');
|
11
|
+
now = new Date().toISOString();
|
12
|
+
if ($countdowner.data('start_at') <= now) {
|
13
|
+
$countdowner.show();
|
14
|
+
}
|
15
|
+
if ($countdowner.data('end_at') < now) {
|
10
16
|
$countdowner.remove();
|
11
|
-
if (_this.
|
12
|
-
clearInterval(_this.
|
17
|
+
if (_this.updateCountdownerTimer != null) {
|
18
|
+
return clearInterval(_this.updateCountdownerTimer);
|
13
19
|
}
|
14
|
-
return true;
|
15
20
|
}
|
16
21
|
};
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
$countdowner.show();
|
21
|
-
return this.checkEnd = setInterval(removeAfterEnd, 60000);
|
22
|
-
}
|
22
|
+
$.timeago.settings.allowFuture = true;
|
23
|
+
$countdowner.find('time').timeago();
|
24
|
+
return this.updateCountdownerTimer = setInterval(updateCountdowner, 2000);
|
23
25
|
}
|
24
26
|
});
|
25
27
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
$ ->
|
2
2
|
$countdowner = $('#countdowner')
|
3
3
|
if $countdowner.length
|
4
|
-
|
5
|
-
|
4
|
+
updateCountdowner = =>
|
5
|
+
now = new Date().toISOString()
|
6
|
+
if $countdowner.data('start_at') <= now
|
7
|
+
$countdowner.show()
|
8
|
+
if $countdowner.data('end_at') < now
|
6
9
|
$countdowner.remove()
|
7
|
-
clearInterval(@
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
$countdowner.find('time').timeago()
|
12
|
-
$countdowner.show()
|
13
|
-
@checkEnd = setInterval(removeAfterEnd, 60000)
|
10
|
+
clearInterval(@updateCountdownerTimer) if @updateCountdownerTimer?
|
11
|
+
$.timeago.settings.allowFuture = true
|
12
|
+
$countdowner.find('time').timeago()
|
13
|
+
@updateCountdownerTimer = setInterval(updateCountdowner, 30000)
|
@@ -1,9 +1,12 @@
|
|
1
1
|
module Countdowner
|
2
2
|
module ActionView
|
3
3
|
def countdowner(options = {})
|
4
|
-
message = Countdowner::Message.current or return
|
5
|
-
options
|
6
|
-
|
4
|
+
message = Countdowner::Message.current.first or return
|
5
|
+
options.merge!(
|
6
|
+
:id => 'countdowner',
|
7
|
+
:'data-end_at' => Countdowner::Datetime.new(message.end_at).iso,
|
8
|
+
:'data-start_at' => Countdowner::Datetime.new(message.start_at).iso
|
9
|
+
)
|
7
10
|
options[:style] = 'display:none' if options.delete(:hidden_initially)
|
8
11
|
content_tag(:div, options) do
|
9
12
|
time = Countdowner::Datetime.new(message.target)
|
data/lib/countdowner/message.rb
CHANGED
@@ -6,8 +6,7 @@ module Countdowner
|
|
6
6
|
validate :ensure_valid_periods
|
7
7
|
|
8
8
|
def self.current
|
9
|
-
find(:
|
10
|
-
:conditions => ["target > :now and end_at > :now and start_at < :now", {:now => Time.now.utc}])
|
9
|
+
find(:all, :order => "target", :conditions => ["target > :now and end_at > :now", {:now => Time.now.utc}])
|
11
10
|
end
|
12
11
|
|
13
12
|
private
|
data/lib/countdowner/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: countdowner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -156,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
156
|
version: '0'
|
157
157
|
segments:
|
158
158
|
- 0
|
159
|
-
hash:
|
159
|
+
hash: 3910419754330681090
|
160
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
161
|
none: false
|
162
162
|
requirements:
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
segments:
|
167
167
|
- 0
|
168
|
-
hash:
|
168
|
+
hash: 3910419754330681090
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
171
|
rubygems_version: 1.8.24
|