flashgrid-ext 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/flashgrid-ext.gemspec +1 -1
- data/lib/flashgrid/ext/version.rb +1 -1
- data/vendor/assets/javascripts/time_ago.js +99 -84
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ed628cb8936e8d19cab4e0c388121df2bc0520c
|
4
|
+
data.tar.gz: e5311ff2be65c4ca95db9674af1138d2acad4b27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 161b2d472b3cbc2f06f650baedac4dfa3a2fdb62347e7ab5aa877b51c79df01e97aa25de79ae0391b784170634c5f5fc406f84bd882a890e64399f192e37c1b5
|
7
|
+
data.tar.gz: 6dda2282b70093662a65c5f1d0a9fbf999e103f8471423929210c79f360b3d0e2d08c9394bf1c540df9a369238ce3c59c7973dce053dde0060807455740b111f
|
data/flashgrid-ext.gemspec
CHANGED
@@ -18,6 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
end
|
@@ -3,25 +3,21 @@
|
|
3
3
|
|
4
4
|
TimeAgo = (function() {
|
5
5
|
function TimeAgo(element, options) {
|
6
|
-
this.startInterval = 60000;
|
7
|
-
this.init(element, options);
|
8
|
-
}
|
9
|
-
|
10
|
-
TimeAgo.prototype.init = function(element, options) {
|
11
6
|
this.$element = $(element);
|
12
7
|
this.options = $.extend({}, $.fn.timeago.defaults, options);
|
13
|
-
this.
|
14
|
-
|
15
|
-
};
|
8
|
+
this.refresh();
|
9
|
+
}
|
16
10
|
|
17
11
|
TimeAgo.prototype.startTimer = function() {
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
return this.interval = setTimeout((function(_this) {
|
13
|
+
return function() {
|
14
|
+
return _this.refresh();
|
15
|
+
};
|
16
|
+
})(this), this.startInterval);
|
21
17
|
};
|
22
18
|
|
23
19
|
TimeAgo.prototype.stopTimer = function() {
|
24
|
-
return
|
20
|
+
return clearTimeout(this.interval);
|
25
21
|
};
|
26
22
|
|
27
23
|
TimeAgo.prototype.restartTimer = function() {
|
@@ -35,53 +31,50 @@
|
|
35
31
|
};
|
36
32
|
|
37
33
|
TimeAgo.prototype.updateTime = function() {
|
38
|
-
var
|
39
|
-
|
40
|
-
return this.$element.
|
41
|
-
var $el, text, timeAgoInWords;
|
42
|
-
$el = $(this);
|
43
|
-
timeAgoInWords = self.timeAgoInWords($el.attr(self.options.attr));
|
44
|
-
if (!$el.prop('title')) {
|
45
|
-
text = $el.text();
|
46
|
-
if (text) {
|
47
|
-
$el.prop('title', $el.text());
|
48
|
-
}
|
49
|
-
}
|
50
|
-
return $el.html(timeAgoInWords);
|
51
|
-
});
|
34
|
+
var timeAgoInWords;
|
35
|
+
timeAgoInWords = this.timeAgoInWords(this.$element.attr(this.options.attr));
|
36
|
+
return this.$element.html(timeAgoInWords);
|
52
37
|
};
|
53
38
|
|
54
39
|
TimeAgo.prototype.updateInterval = function() {
|
55
|
-
var
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
40
|
+
var dis, newestTime, newestTimeSrc;
|
41
|
+
newestTimeSrc = this.$element.attr(this.options.attr);
|
42
|
+
newestTime = this.parse(newestTimeSrc);
|
43
|
+
dis = this.getTimeDistanceInSeconds(newestTime);
|
44
|
+
if (this.options.maxRelative && dis >= this.options.maxRelative) {
|
45
|
+
return this.stopTimer();
|
46
|
+
} else if (this.options.showNow && dis < this.options.showNow) {
|
47
|
+
this.startInterval = (this.options.showNow - dis) * 1000;
|
48
|
+
return this.restartTimer();
|
49
|
+
} else if (this.options.showSeconds && dis < 60) {
|
50
|
+
this.startInterval = 1000;
|
51
|
+
return this.restartTimer();
|
52
|
+
} else if (dis < 2700) {
|
53
|
+
this.startInterval = (60 - dis % 60) * 1000;
|
54
|
+
return this.restartTimer();
|
55
|
+
} else if (dis < 5400) {
|
56
|
+
this.startInterval = (5400 - dis) * 1000;
|
57
|
+
return this.restartTimer();
|
58
|
+
} else if (dis < 151200) {
|
59
|
+
this.startInterval = (3600 - dis % 3600) * 1000;
|
60
|
+
return this.restartTimer();
|
61
|
+
} else {
|
62
|
+
this.startInterval = (86400 - dis % 86400) * 1000;
|
63
|
+
return this.restartTimer();
|
78
64
|
}
|
79
65
|
};
|
80
66
|
|
81
67
|
TimeAgo.prototype.timeAgoInWords = function(timeString) {
|
82
|
-
var absolutTime;
|
68
|
+
var absolutTime, dis;
|
83
69
|
absolutTime = this.parse(timeString);
|
84
|
-
|
70
|
+
dis = this.getTimeDistanceInSeconds(absolutTime);
|
71
|
+
if (this.options.showNow && this.options.showNow > dis) {
|
72
|
+
return this.options.lang.prefixes.now;
|
73
|
+
} else if (this.options.maxRelative && this.options.maxRelative <= dis) {
|
74
|
+
return this.options.absoluteDate(absolutTime, timeString);
|
75
|
+
} else {
|
76
|
+
return this.options.relativeDate(this.options.lang.prefixes.ago, this.distanceOfTimeInWords(dis), this.options.suffix || this.options.lang.suffix);
|
77
|
+
}
|
85
78
|
};
|
86
79
|
|
87
80
|
TimeAgo.prototype.parse = function(iso8601) {
|
@@ -94,41 +87,49 @@
|
|
94
87
|
return new Date(timeStr);
|
95
88
|
};
|
96
89
|
|
97
|
-
TimeAgo.prototype.
|
90
|
+
TimeAgo.prototype.getTimeDistanceInSeconds = function(absolutTime) {
|
98
91
|
var timeDistance;
|
99
92
|
timeDistance = new Date().getTime() - absolutTime.getTime();
|
100
|
-
return Math.round(
|
93
|
+
return Math.round(Math.abs(timeDistance) / 1000);
|
101
94
|
};
|
102
95
|
|
103
|
-
TimeAgo.prototype.distanceOfTimeInWords = function(
|
104
|
-
var
|
105
|
-
|
106
|
-
if (
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
} else if (
|
117
|
-
return "1
|
118
|
-
} else if (
|
119
|
-
return "" + (Math.round(
|
120
|
-
} else if (
|
121
|
-
return "" + this.options.lang.prefixes.about + "
|
122
|
-
} else if (
|
123
|
-
return "" + (Math.round(
|
124
|
-
} else if (
|
125
|
-
return "" +
|
126
|
-
} else if (
|
127
|
-
return "" +
|
128
|
-
} else if (
|
129
|
-
return "" + this.options.lang.prefixes.
|
96
|
+
TimeAgo.prototype.distanceOfTimeInWords = function(dis) {
|
97
|
+
var space;
|
98
|
+
space = this.options.spacing ? ' ' : '';
|
99
|
+
if (dis < 60) {
|
100
|
+
if (this.options.showSeconds) {
|
101
|
+
if (dis === 0 || dis === 1) {
|
102
|
+
return "1" + space + this.options.lang.units.second;
|
103
|
+
} else {
|
104
|
+
return "" + dis + space + this.options.lang.units.seconds;
|
105
|
+
}
|
106
|
+
} else {
|
107
|
+
return "" + (this.options.approximate ? this.options.lang.prefixes.lt + " " : "1" + space) + this.options.lang.units.minute;
|
108
|
+
}
|
109
|
+
} else if (dis < 120) {
|
110
|
+
return "1" + space + this.options.lang.units.minute;
|
111
|
+
} else if (dis < 2700) {
|
112
|
+
return "" + (Math.round(dis / 60)) + space + this.options.lang.units.minutes;
|
113
|
+
} else if (dis < 5400) {
|
114
|
+
return "" + (this.options.approximate ? this.options.lang.prefixes.about + " " : "") + "1" + space + this.options.lang.units.hour;
|
115
|
+
} else if (dis < 86400) {
|
116
|
+
return "" + (this.options.approximate ? this.options.lang.prefixes.about + " " : "") + (Math.round(dis / 3600)) + space + this.options.lang.units.hours;
|
117
|
+
} else if (dis < 151200) {
|
118
|
+
return "1" + space + this.options.lang.units.day;
|
119
|
+
} else if (dis < 2592000) {
|
120
|
+
return "" + (Math.round(dis / 86400)) + space + this.options.lang.units.days;
|
121
|
+
} else if (dis < 5184000) {
|
122
|
+
return "" + (this.options.approximate ? this.options.lang.prefixes.about + " " : "") + "1" + space + this.options.lang.units.month;
|
123
|
+
} else if (dis < 31536000) {
|
124
|
+
return "" + (Math.round(dis / 2592000)) + space + this.options.lang.units.months;
|
125
|
+
} else if (dis < 39312000) {
|
126
|
+
return "" + (this.options.approximate ? this.options.lang.prefixes.about + " " : "") + "1" + space + this.options.lang.units.year;
|
127
|
+
} else if (dis < 54864000) {
|
128
|
+
return "" + (this.options.approximate ? this.options.lang.prefixes.over + " " : "") + "1" + space + this.options.lang.units.year;
|
129
|
+
} else if (dis < 63072000) {
|
130
|
+
return "" + (this.options.approximate ? this.options.lang.prefixes.almost + " " : "") + "2" + space + this.options.lang.units.years;
|
130
131
|
} else {
|
131
|
-
return "" + this.options.lang.prefixes.about + " " + (Math.round(
|
132
|
+
return "" + (this.options.approximate ? this.options.lang.prefixes.about + " " : "") + (Math.round(dis / 31536000)) + space + this.options.lang.units.years;
|
132
133
|
}
|
133
134
|
};
|
134
135
|
|
@@ -141,8 +142,12 @@
|
|
141
142
|
options = {};
|
142
143
|
}
|
143
144
|
return this.each(function() {
|
144
|
-
var $this, data;
|
145
|
+
var $this, attr, data;
|
145
146
|
$this = $(this);
|
147
|
+
attr = $this.attr(options.attr || $.fn.timeago.defaults.attr);
|
148
|
+
if (attr === void 0 || attr === false) {
|
149
|
+
return;
|
150
|
+
}
|
146
151
|
data = $this.data("timeago");
|
147
152
|
if (!data) {
|
148
153
|
return $this.data("timeago", new TimeAgo(this, options));
|
@@ -159,9 +164,18 @@
|
|
159
164
|
$.fn.timeago.Constructor = TimeAgo;
|
160
165
|
|
161
166
|
$.fn.timeago.defaults = {
|
162
|
-
selector: 'time.timeago',
|
163
167
|
attr: 'datetime',
|
164
|
-
|
168
|
+
spacing: true,
|
169
|
+
approximate: true,
|
170
|
+
showSeconds: false,
|
171
|
+
showNow: false,
|
172
|
+
maxRelative: false,
|
173
|
+
absoluteDate: function(date, datetime) {
|
174
|
+
return datetime;
|
175
|
+
},
|
176
|
+
relativeDate: function(prefix, distance, suffix) {
|
177
|
+
return "" + prefix + distance + suffix;
|
178
|
+
},
|
165
179
|
lang: {
|
166
180
|
units: {
|
167
181
|
second: "second",
|
@@ -178,6 +192,7 @@
|
|
178
192
|
years: "years"
|
179
193
|
},
|
180
194
|
prefixes: {
|
195
|
+
now: "just now",
|
181
196
|
lt: "less than a",
|
182
197
|
about: "about",
|
183
198
|
over: "over",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flashgrid-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.4.
|
89
|
+
rubygems_version: 2.4.2
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: Flashgrid Extensions
|