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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8bf3121e32168d7561798fe965096bbf55ce2f2
4
- data.tar.gz: 55da78137742ff6b953c01888f0f747b86e74380
3
+ metadata.gz: c2aab5a758c2b205663ab60bab12d6c469e325d6
4
+ data.tar.gz: 01b678c5a0db7bd14c3ed7a48647b4e36458e8d2
5
5
  SHA512:
6
- metadata.gz: 719a576213a884f671b865a50298f8c1091ab1bd16d1fe70a7877021df63662ce236423fd4950aa97474679aaf5506a637e591ead65622ac9dd1b159c6d9903a
7
- data.tar.gz: c9d361b962b0a3cfd54bcd30e49d112ac95f02e0c8457e1700c4c124da86eee513eef322cb2e30a43355e03d09b568e69eb8754c37083923883e55f0af81ea05
6
+ metadata.gz: 3c9209b9abdc81faf362f479f10ee31317a253274b607a4e89e883e26fa664ebd42a26fa88aedc1683787fc6b7bfe01c4726ee4e4cccae759cfae4dee830a28c
7
+ data.tar.gz: feb2641a568d4320d73b96a39cce6a06bcccb0c4c0469c91f04d022794b308655b78eef32a6e8b12ec7bedeff838f87e80735c839b69da355877a4f721996097
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
3
+ - 2.3.1
4
4
  before_install: gem install bundler
5
5
  branches:
6
6
  only:
7
7
  - master
8
8
  env:
9
- - COVERALLS=1
9
+ - COVERALLS=1
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
+ # v0.1.2 / 2016-08-23
2
+
3
+ Upgraded usertime.js to v0.1.2
4
+
1
5
  # v0.1.1 / 2015-10-24
2
6
 
3
- Update uesrtime.js for support turbolink.
7
+ Update usertime.js for support turbolink.
4
8
 
5
9
  # v0.1.0 / 2015-10-02
6
10
 
data/README.md CHANGED
@@ -56,4 +56,4 @@ The gem is available as open source under the terms of the [MIT License](http://
56
56
 
57
57
  ## Contact
58
58
  The project's website is located at https://github.com/emn178/usertime-rails
59
- Author: emn178@gmail.com
59
+ Author: Chen, Yi-Cyuan (emn178@gmail.com)
@@ -1,36 +1,37 @@
1
- /*
2
- * usertime.js v0.1.1
3
- * https://github.com/emn178/usertime.js
1
+ /**
2
+ * [usertime.js]{@link https://github.com/emn178/usertime.js}
4
3
  *
5
- * Copyright 2015, emn178@gmail.com
6
- *
7
- * Licensed under the MIT license:
8
- * http://www.opensource.org/licenses/MIT
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
- ;(function($, window, document, undefined) {
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, window, document);
64
+ })(jQuery);
@@ -8,4 +8,4 @@ if defined?(::Rails::Engine)
8
8
  end
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module UsertimeRails
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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: 2015-10-24 00:00:00.000000000 Z
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.4.5
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.