usertime-rails 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +5 -1
- data/README.md +1 -1
- data/app/assets/javascripts/usertime.js +33 -13
- data/lib/usertime-rails/engine.rb +1 -1
- data/lib/usertime-rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2aab5a758c2b205663ab60bab12d6c469e325d6
|
4
|
+
data.tar.gz: 01b678c5a0db7bd14c3ed7a48647b4e36458e8d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c9209b9abdc81faf362f479f10ee31317a253274b607a4e89e883e26fa664ebd42a26fa88aedc1683787fc6b7bfe01c4726ee4e4cccae759cfae4dee830a28c
|
7
|
+
data.tar.gz: feb2641a568d4320d73b96a39cce6a06bcccb0c4c0469c91f04d022794b308655b78eef32a6e8b12ec7bedeff838f87e80735c839b69da355877a4f721996097
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,36 +1,37 @@
|
|
1
|
-
|
2
|
-
* usertime.js
|
3
|
-
* https://github.com/emn178/usertime.js
|
1
|
+
/**
|
2
|
+
* [usertime.js]{@link https://github.com/emn178/usertime.js}
|
4
3
|
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
4
|
+
* @version 0.1.2
|
5
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
6
|
+
* @copyright Chen, Yi-Cyuan 2015-2016
|
7
|
+
* @license MIT
|
9
8
|
*/
|
10
|
-
|
9
|
+
(function ($) {
|
11
10
|
'use strict';
|
12
11
|
|
13
12
|
var TAG = 'usertime';
|
14
13
|
var FORMAT = 'format';
|
14
|
+
var MUTATION = window.MutationObserver !== undefined;
|
15
15
|
|
16
16
|
window.UserTime = {
|
17
|
-
DefaultFormat: 'YYYY-MM-DD HH:mm:ss'
|
17
|
+
DefaultFormat: 'YYYY-MM-DD HH:mm:ss',
|
18
|
+
convert: convert
|
18
19
|
};
|
19
20
|
|
20
21
|
function convert() {
|
21
22
|
var element = $(this);
|
22
23
|
var time = element.text();
|
23
|
-
if(!time) {
|
24
|
+
if (!time) {
|
24
25
|
return;
|
25
26
|
}
|
26
27
|
time = /^[0-9]+$/.test(time) ? parseInt(time) : time;
|
27
28
|
time = new Date(time);
|
28
|
-
if(time.toString() == 'Invalid Date') {
|
29
|
+
if (time.toString() == 'Invalid Date') {
|
29
30
|
return;
|
30
31
|
}
|
31
32
|
time = moment(time);
|
32
33
|
var format = element.attr(FORMAT);
|
33
|
-
if(format === undefined) {
|
34
|
+
if (format === undefined) {
|
34
35
|
format = UserTime.DefaultFormat;
|
35
36
|
}
|
36
37
|
element.replaceWith(time.format(format));
|
@@ -40,5 +41,24 @@
|
|
40
41
|
$(TAG).each(convert);
|
41
42
|
}
|
42
43
|
|
44
|
+
if (MUTATION) {
|
45
|
+
var observer = new MutationObserver(function (records) {
|
46
|
+
records.forEach(function (record) {
|
47
|
+
if (!record.addedNodes.length) {
|
48
|
+
return;
|
49
|
+
}
|
50
|
+
Array.from(record.addedNodes).forEach(function (node) {
|
51
|
+
if (node.tagName == 'USERTIME') {
|
52
|
+
convert.call(node);
|
53
|
+
}
|
54
|
+
});
|
55
|
+
});
|
56
|
+
});
|
57
|
+
observer.observe(document, {
|
58
|
+
childList: true,
|
59
|
+
subtree: true
|
60
|
+
});
|
61
|
+
}
|
62
|
+
|
43
63
|
$(document).on('ready page:load', convertAll);
|
44
|
-
})(jQuery
|
64
|
+
})(jQuery);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usertime-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chen Yi-Cyuan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.5.1
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: A jQuery plugin provides to display time in user's timezone.
|