mirror of
https://github.com/scratchfoundation/jquery-timeago.git
synced 2025-04-05 09:10:09 -04:00
Compare commits
119 commits
Author | SHA1 | Date | |
---|---|---|---|
|
b5a364d3a2 | ||
|
05a85b77f9 | ||
|
0d2a2145b2 | ||
|
0399e804db | ||
|
98d000543c | ||
|
c8b5b9365c | ||
|
14ff438930 | ||
|
2409c9f88d | ||
|
74736c8d07 | ||
|
4af2cf7135 | ||
|
f7c9c359cd | ||
|
bf9d361e4e | ||
|
66d0ef5277 | ||
|
dd17e5598f | ||
|
6822da82d9 | ||
|
cb1b0fe977 | ||
|
9b32f8cba6 | ||
|
2245c795d0 | ||
|
ec51ad8132 | ||
|
570327cf15 | ||
|
3a73f0fab1 | ||
|
5d7684fbf8 | ||
|
dc570fed47 | ||
|
9fac817b07 | ||
|
b374bd6dfb | ||
|
81f072ebb2 | ||
|
dceed3b1d9 | ||
|
fc90536dac | ||
|
61baa07698 | ||
|
4138f62c2b | ||
|
c72634b73d | ||
|
cca5898e18 | ||
|
2780816e44 | ||
|
300555d699 | ||
|
ed44a62689 | ||
|
500b808f7b | ||
|
c4a132d6b2 | ||
|
d0e161a164 | ||
|
9d6c2c6b64 | ||
|
873f0f7c10 | ||
|
8946a5eb49 | ||
|
f6c1dd4d0f | ||
|
61e23e15a7 | ||
|
96d4406fcc | ||
|
ef0ffa0df0 | ||
|
54a466d81b | ||
|
9128386996 | ||
|
ad8e3d0e64 | ||
|
694074d374 | ||
|
e3c239d5a4 | ||
|
36f4640018 | ||
|
5b7b9f7c85 | ||
|
eb71dbca5b | ||
|
a6bf461d1f | ||
|
2f2260cee8 | ||
|
c7251759fd | ||
|
d5ab36adcb | ||
|
9dc7ae6c8e | ||
|
53a64c0322 | ||
|
f512100060 | ||
|
5a989f4b2b | ||
|
38de8b99a9 | ||
|
a018eaa5f0 | ||
|
ea347d24c6 | ||
|
61980c6e22 | ||
|
1a763d5e46 | ||
|
3b895714a6 | ||
|
49aeb6bf07 | ||
|
60369ec505 | ||
|
ea26675d40 | ||
|
f799625f8d | ||
|
658893df50 | ||
|
f41cfd0c6c | ||
|
9dab7dbc5a | ||
|
30d5b47d5b | ||
|
eee58806aa | ||
|
d52af89018 | ||
|
f2afbeaf78 | ||
|
2f2fb8f39a | ||
|
efdbae1c1f | ||
|
e69b93c378 | ||
|
0893f9d4f2 | ||
|
6b2314815d | ||
|
3a6c719328 | ||
|
c212eb3f46 | ||
|
7c1496f0a8 | ||
|
c4884c8b54 | ||
|
2773b7e4be | ||
|
c04bd3181b | ||
|
e21aad7fe1 | ||
|
9944acbad9 | ||
|
335dac0d63 | ||
|
4dad17f90e | ||
|
fb4035864d | ||
|
783066c2d9 | ||
|
83e05ef694 | ||
|
72c9a9fa77 | ||
|
ef05c3ea33 | ||
|
7373b70c3b | ||
|
ed6487a801 | ||
|
c499fe9a9d | ||
|
fcca1b70e2 | ||
|
ad19edc9b5 | ||
|
db9651b797 | ||
|
5be224e370 | ||
|
5f346ef5d4 | ||
|
ed4b94d8e0 | ||
|
082301b769 | ||
|
de2fbdae3f | ||
|
2c40976eac | ||
|
a20a2c863c | ||
|
4c37962663 | ||
|
f9a31fcafc | ||
|
8425e598c3 | ||
|
6664d31831 | ||
|
47936fedfc | ||
|
14d4fd4b79 | ||
|
3d04ead09a | ||
|
0dda6d92a1 |
41 changed files with 892 additions and 1749 deletions
.gitignoreCONTRIBUTING.mdGemfileGemfile.lockLICENSE.txtREADME.markdownRakefilebower.json
contrib
index.htmljquery.timeago.jslocales
jquery.timeago.ar.jsjquery.timeago.cs.jsjquery.timeago.cz.jsjquery.timeago.es-short.jsjquery.timeago.et.jsjquery.timeago.fr-short.jsjquery.timeago.gl.jsjquery.timeago.he.jsjquery.timeago.id.jsjquery.timeago.is.jsjquery.timeago.ja.jsjquery.timeago.jv.jsjquery.timeago.lt.jsjquery.timeago.pt-br.jsjquery.timeago.ro.jsjquery.timeago.rs.jsjquery.timeago.sk.jsjquery.timeago.sl.jsjquery.timeago.tr.jsjquery.timeago.vi.jsjquery.timeago.zh-CN.jsjquery.timeago.zh-TW.js
publictest
timeago.jquery.json
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
.bundle
|
||||
vendor/ruby
|
||||
public
|
||||
|
|
37
CONTRIBUTING.md
Normal file
37
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
## Want to Contribute?
|
||||
|
||||
Found an issue? Thank you for helping out by reporting it. Please describe the
|
||||
problem, what you tried, what you expected to see, and what you actually
|
||||
experienced. Please [re-read the documentation](http://timeago.yarp.com/) to
|
||||
make sure you're using the API as designed, but if you found something that's
|
||||
broken, we really appreciate your efforts in letting us know. Bonus points for
|
||||
submitting a failing test case to help us diagnose and potentially fix the
|
||||
issue.
|
||||
|
||||
## Want to Contribute?
|
||||
|
||||
Awesome. We love help, but before getting started, please read:
|
||||
|
||||
**[Don't "Push" Your Pull Requests](http://www.igvita.com/2011/12/19/dont-push-your-pull-requests/)**
|
||||
|
||||
## Ready for a Pull-Request?
|
||||
|
||||
1. Fork the repo.
|
||||
|
||||
2. Run the tests. Run `rake` or open `open test/index.html`. We only take pull
|
||||
requests with passing tests, and it's great to know that you started from a
|
||||
clean slate.
|
||||
|
||||
3. Add a test for your change. Only refactoring and documentation change
|
||||
require no new tests. If you are adding functionality or fixing a bug, we
|
||||
need a test!
|
||||
|
||||
4. Make the test pass.
|
||||
|
||||
5. Push to your fork (hopefully this comes from a topical branch) and submit a
|
||||
pull request.
|
||||
|
||||
At this point you're waiting on us. Please keep in mind that OSS maintainers
|
||||
are often very busy. We'll do our best to at least comment on issues and
|
||||
pull-requests as soon as possible, but sometimes life gets in the way. We may
|
||||
also suggest some changes or improvements or alternatives.
|
3
Gemfile
3
Gemfile
|
@ -1,3 +0,0 @@
|
|||
source "http://rubygems.org"
|
||||
|
||||
gem "fssm", "0.2.0"
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -1,10 +0,0 @@
|
|||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
fssm (0.2.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
fssm (= 0.2.0)
|
22
LICENSE.txt
Normal file
22
LICENSE.txt
Normal file
|
@ -0,0 +1,22 @@
|
|||
Copyright (c) 2008-2013 Ryan McGeary
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -4,6 +4,27 @@ Timeago is a jQuery plugin that makes it easy to support automatically updating
|
|||
fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago") from ISO 8601
|
||||
formatted dates and times embedded in your HTML (à la microformats).
|
||||
|
||||
## How You Can Help
|
||||
|
||||
**If you like this project, please help. [Donate via Gittip][gittip] or [buy me a coffee with Bitcoin][bitcoin].**<br>
|
||||
[][gittip]
|
||||
[][bitcoin]
|
||||
|
||||
**[Bitcoin][bitcoin]**: `1rmm5tv6f997JK5bLcGbRCZyVjZUPkQ2m`<br>
|
||||
[![Bitcoin Donation][bitcoin-qr-small]][bitcoin-qr-big]
|
||||
|
||||
## Need Help?
|
||||
|
||||
**You can [book a session with me on Codementor][codementor].**<br>
|
||||
[][codementor]
|
||||
|
||||
[gittip]: https://www.gittip.com/rmm5t/ "Donate to rmm5t for open source!"
|
||||
[bitcoin]: https://blockchain.info/address/1rmm5tv6f997JK5bLcGbRCZyVjZUPkQ2m "Buy rmm5t a coffee for open source!"
|
||||
[bitcoin-scheme]: bitcoin:1rmm5tv6f997JK5bLcGbRCZyVjZUPkQ2m?amount=0.01&label=Coffee%20to%20rmm5t%20for%20Open%20Source "Buy rmm5t a coffee for open source!"
|
||||
[bitcoin-qr-small]: http://chart.apis.google.com/chart?cht=qr&chs=150x150&chl=bitcoin%3A1rmm5tv6f997JK5bLcGbRCZyVjZUPkQ2m%3Famount%3D0.01%26label%3DCoffee%2520to%2520rmm5t%2520for%2520Open%2520Source
|
||||
[bitcoin-qr-big]: http://chart.apis.google.com/chart?cht=qr&chs=500x500&chl=bitcoin%3A1rmm5tv6f997JK5bLcGbRCZyVjZUPkQ2m%3Famount%3D0.01%26label%3DCoffee%2520to%2520rmm5t%2520for%2520Open%2520Source
|
||||
[codementor]: https://www.codementor.io/rmm5t?utm_campaign=profile&utm_source=button-rmm5t&utm_medium=shields "Book a session with rmm5t on Codementor!"
|
||||
|
||||
## Usage
|
||||
|
||||
First, load jQuery and the plugin:
|
||||
|
@ -13,7 +34,8 @@ First, load jQuery and the plugin:
|
|||
<script src="jquery.timeago.js" type="text/javascript"></script>
|
||||
```
|
||||
|
||||
Now, let's attach it to your timestamps on DOM ready - put this in the head section:
|
||||
Now, let's attach it to your timestamps on DOM ready - put this in the head
|
||||
section:
|
||||
|
||||
```html
|
||||
<script type="text/javascript">
|
||||
|
@ -49,6 +71,33 @@ As time passes, the timestamps will automatically update.
|
|||
|
||||
**For different language configurations**: visit the [`locales`](https://github.com/rmm5t/jquery-timeago/tree/master/locales) directory.
|
||||
|
||||
## Changes
|
||||
|
||||
| Version | Notes |
|
||||
|---------|---------------------------------------------------------------------------------|
|
||||
| 1.4.x | ([compare][compare-1.4]) Added allowPast setting |
|
||||
| 1.3.x | ([compare][compare-1.3]) Added updateFromDOM function; bug fixes; bower support |
|
||||
| 1.2.x | ([compare][compare-1.2]) Added cutoff setting |
|
||||
| 1.1.x | ([compare][compare-1.1]) Added update function |
|
||||
| 1.0.x | ([compare][compare-1.0]) locale updates; bug fixes; AMD wrapper |
|
||||
| 0.11.x | ([compare][compare-0.11]) natural rounding; locale updates; |
|
||||
| 0.10.x | ([compare][compare-0.10]) locale updates |
|
||||
| 0.9.x | ([compare][compare-0.9]) microsecond support; bug fixes |
|
||||
| 0.8.x | ([compare][compare-0.8]) `<time>` element support; bug fixes |
|
||||
| 0.7.x | ([compare][compare-0.7]) locale function overrides; unit tests |
|
||||
| ... | ... |
|
||||
|
||||
[compare-1.4]: https://github.com/rmm5t/jquery-timeago/compare/v1.3.2...v1.4.1
|
||||
[compare-1.3]: https://github.com/rmm5t/jquery-timeago/compare/v1.2.0...v1.3.2
|
||||
[compare-1.2]: https://github.com/rmm5t/jquery-timeago/compare/v1.1.0...v1.2.0
|
||||
[compare-1.1]: https://github.com/rmm5t/jquery-timeago/compare/v1.0.2...v1.1.0
|
||||
[compare-1.0]: https://github.com/rmm5t/jquery-timeago/compare/v0.11.4...v1.0.2
|
||||
[compare-0.11]: https://github.com/rmm5t/jquery-timeago/compare/v0.10.1...v0.11.4
|
||||
[compare-0.10]: https://github.com/rmm5t/jquery-timeago/compare/v0.9.3...v0.10.1
|
||||
[compare-0.9]: https://github.com/rmm5t/jquery-timeago/compare/v0.8.2...v0.9.3
|
||||
[compare-0.8]: https://github.com/rmm5t/jquery-timeago/compare/v0.7.2...v0.8.2
|
||||
[compare-0.7]: https://github.com/rmm5t/jquery-timeago/compare/v0.6.2...v0.7.2
|
||||
|
||||
## Author
|
||||
|
||||
[Ryan McGeary](http://ryan.mcgeary.org) ([@rmm5t](http://twitter.com/rmm5t))
|
||||
|
|
31
Rakefile
31
Rakefile
|
@ -1,6 +1,6 @@
|
|||
require "bundler/setup"
|
||||
|
||||
task :default => :watch
|
||||
task :default => :test
|
||||
|
||||
desc "Publish \"marketing\" docs"
|
||||
task :publish do
|
||||
|
@ -11,36 +11,7 @@ task :publish do
|
|||
sh("git push --tags")
|
||||
end
|
||||
|
||||
desc "Build everything"
|
||||
task :build do
|
||||
rebuild_coffee
|
||||
end
|
||||
|
||||
desc "Watch for changes and test the site"
|
||||
task :watch => :build do
|
||||
sh("open test/index.html")
|
||||
monitor
|
||||
end
|
||||
|
||||
desc "Open your default browser with the test page"
|
||||
task :test do
|
||||
sh("open test/index.html")
|
||||
end
|
||||
|
||||
def rebuild_coffee(base = nil, relative = "**/*.coffee")
|
||||
sh("coffee -c #{relative}")
|
||||
end
|
||||
|
||||
def monitor
|
||||
require "fssm"
|
||||
puts ">>> Monitoring for changes. Press Ctrl-C to Stop."
|
||||
FSSM.monitor do
|
||||
path "." do
|
||||
glob "**/*.coffee"
|
||||
update &method(:rebuild_coffee)
|
||||
delete &method(:rebuild_coffee)
|
||||
create &method(:rebuild_coffee)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
13
bower.json
Normal file
13
bower.json
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "jquery-timeago",
|
||||
"version": "1.4.1",
|
||||
"license": "MIT",
|
||||
"main": "jquery.timeago.js",
|
||||
"ignore": [
|
||||
"test",
|
||||
"vendor"
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">=1.4"
|
||||
}
|
||||
}
|
14
contrib/timeago-koext.js
Normal file
14
contrib/timeago-koext.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
ko.bindingHandlers.timeago = {
|
||||
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
|
||||
var value = valueAccessor();
|
||||
var valueUnwrapped = ko.unwrap(value);
|
||||
element.title = moment(valueUnwrapped).toISOString();
|
||||
$(element).timeago();
|
||||
},
|
||||
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
|
||||
var value = valueAccessor();
|
||||
var valueUnwrapped = ko.unwrap(value);
|
||||
element.title = moment(valueUnwrapped).toISOString();
|
||||
$(element).timeago('update', element.title);
|
||||
}
|
||||
}
|
|
@ -116,6 +116,15 @@ jQuery.timeago(jQuery("abbr#some_id")); //=> "<span id="prog_element"></spa
|
|||
<pre>
|
||||
jQuery.timeago.settings.allowFuture = true;</pre>
|
||||
|
||||
<p class="how">
|
||||
To disable timestamps in the past, use the <tt>allowPast</tt> setting.
|
||||
This setting is set to true by default. When set to false, if the time is in the past then instead of displaying a message like "5 minutes ago" a static message will be displayed.
|
||||
The staic message displayed can be configured with the <tt>strings.inPast</tt> setting:
|
||||
</p>
|
||||
<pre>
|
||||
jQuery.timeago.settings.strings.inPast = "time has elapsed";
|
||||
jQuery.timeago.settings.allowPast = false;</pre>
|
||||
|
||||
<h3>Excusez-moi?</h3>
|
||||
<p>
|
||||
Yes, timeago has locale/i18n/language support. Here are some <a href="https://github.com/rmm5t/jquery-timeago/tree/master/locales">configuration examples</a>. Please submit a <a href="https://github.com/rmm5t/jquery-timeago">GitHub pull request</a> for corrections or additional languages.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
|
||||
*
|
||||
* @name timeago
|
||||
* @version 1.0.0
|
||||
* @version 1.4.1
|
||||
* @requires jQuery v1.2.3+
|
||||
* @author Ryan McGeary
|
||||
* @license MIT License - http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -13,7 +13,16 @@
|
|||
*
|
||||
* Copyright (c) 2008-2013, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
$.timeago = function(timestamp) {
|
||||
if (timestamp instanceof Date) {
|
||||
return inWords(timestamp);
|
||||
|
@ -30,12 +39,16 @@
|
|||
$.extend($.timeago, {
|
||||
settings: {
|
||||
refreshMillis: 60000,
|
||||
allowPast: true,
|
||||
allowFuture: false,
|
||||
localeTitle: false,
|
||||
cutoff: 0,
|
||||
strings: {
|
||||
prefixAgo: null,
|
||||
prefixFromNow: null,
|
||||
suffixAgo: "ago",
|
||||
suffixFromNow: "from now",
|
||||
inPast: 'any moment now',
|
||||
seconds: "less than a minute",
|
||||
minute: "about a minute",
|
||||
minutes: "%d minutes",
|
||||
|
@ -51,7 +64,12 @@
|
|||
numbers: []
|
||||
}
|
||||
},
|
||||
|
||||
inWords: function(distanceMillis) {
|
||||
if(!this.settings.allowPast && ! this.settings.allowFuture) {
|
||||
throw 'timeago allowPast and allowFuture settings can not both be set to false.';
|
||||
}
|
||||
|
||||
var $l = this.settings.strings;
|
||||
var prefix = $l.prefixAgo;
|
||||
var suffix = $l.suffixAgo;
|
||||
|
@ -62,6 +80,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
if(!this.settings.allowPast && distanceMillis >= 0) {
|
||||
return this.settings.strings.inPast;
|
||||
}
|
||||
|
||||
var seconds = Math.abs(distanceMillis) / 1000;
|
||||
var minutes = seconds / 60;
|
||||
var hours = minutes / 60;
|
||||
|
@ -90,12 +112,14 @@
|
|||
if ($l.wordSeparator === undefined) { separator = " "; }
|
||||
return $.trim([prefix, words, suffix].join(separator));
|
||||
},
|
||||
|
||||
parse: function(iso8601) {
|
||||
var s = $.trim(iso8601);
|
||||
s = s.replace(/\.\d+/,""); // remove milliseconds
|
||||
s = s.replace(/-/,"/").replace(/-/,"/");
|
||||
s = s.replace(/T/," ").replace(/Z/," UTC");
|
||||
s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
|
||||
s = s.replace(/([\+\-]\d\d)$/," $100"); // +09 -> +0900
|
||||
return new Date(s);
|
||||
},
|
||||
datetime: function(elem) {
|
||||
|
@ -108,21 +132,63 @@
|
|||
}
|
||||
});
|
||||
|
||||
$.fn.timeago = function() {
|
||||
var self = this;
|
||||
self.each(refresh);
|
||||
|
||||
var $s = $t.settings;
|
||||
if ($s.refreshMillis > 0) {
|
||||
setInterval(function() { self.each(refresh); }, $s.refreshMillis);
|
||||
// functions that can be called via $(el).timeago('action')
|
||||
// init is default when no action is given
|
||||
// functions are called with context of a single element
|
||||
var functions = {
|
||||
init: function(){
|
||||
var refresh_el = $.proxy(refresh, this);
|
||||
refresh_el();
|
||||
var $s = $t.settings;
|
||||
if ($s.refreshMillis > 0) {
|
||||
this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis);
|
||||
}
|
||||
},
|
||||
update: function(time){
|
||||
var parsedTime = $t.parse(time);
|
||||
$(this).data('timeago', { datetime: parsedTime });
|
||||
if($t.settings.localeTitle) $(this).attr("title", parsedTime.toLocaleString());
|
||||
refresh.apply(this);
|
||||
},
|
||||
updateFromDOM: function(){
|
||||
$(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });
|
||||
refresh.apply(this);
|
||||
},
|
||||
dispose: function () {
|
||||
if (this._timeagoInterval) {
|
||||
window.clearInterval(this._timeagoInterval);
|
||||
this._timeagoInterval = null;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
};
|
||||
|
||||
$.fn.timeago = function(action, options) {
|
||||
var fn = action ? functions[action] : functions.init;
|
||||
if(!fn){
|
||||
throw new Error("Unknown function name '"+ action +"' for timeago");
|
||||
}
|
||||
// each over objects here and call the requested function
|
||||
this.each(function(){
|
||||
fn.call(this, options);
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
function refresh() {
|
||||
//check if it's still visible
|
||||
if(!$.contains(document.documentElement,this)){
|
||||
//stop if it has been removed
|
||||
$(this).timeago("dispose");
|
||||
return this;
|
||||
}
|
||||
|
||||
var data = prepareData(this);
|
||||
var $s = $t.settings;
|
||||
|
||||
if (!isNaN(data.datetime)) {
|
||||
$(this).text(inWords(data.datetime));
|
||||
if ( $s.cutoff == 0 || Math.abs(distance(data.datetime)) < $s.cutoff) {
|
||||
$(this).text(inWords(data.datetime));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -132,7 +198,9 @@
|
|||
if (!element.data("timeago")) {
|
||||
element.data("timeago", { datetime: $t.datetime(element) });
|
||||
var text = $.trim(element.text());
|
||||
if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
|
||||
if ($t.settings.localeTitle) {
|
||||
element.attr("title", element.data('timeago').datetime.toLocaleString());
|
||||
} else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
|
||||
element.attr("title", text);
|
||||
}
|
||||
}
|
||||
|
@ -150,4 +218,4 @@
|
|||
// fix for IE6 suckage
|
||||
document.createElement("abbr");
|
||||
document.createElement("time");
|
||||
}(jQuery));
|
||||
}));
|
||||
|
|
|
@ -1,32 +1,96 @@
|
|||
// Language: Arabic
|
||||
// Translated By Khaled Attia < Khal3d.com >
|
||||
(function() {
|
||||
function numpf(num, w, x, y, z) {
|
||||
if( num == 0 ) {
|
||||
return w;
|
||||
} else if( num == 2 ) {
|
||||
return x;
|
||||
} else if( num >= 3 && num <= 10) {
|
||||
return y; // 3:10
|
||||
} else {
|
||||
return z; // 11+
|
||||
}
|
||||
function numpf(n, a) {
|
||||
return a[plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5];
|
||||
}
|
||||
jQuery.timeago.settings.strings = {
|
||||
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: "منذ",
|
||||
prefixFromNow: "يتبقى",
|
||||
prefixFromNow: "بعد",
|
||||
suffixAgo: null,
|
||||
suffixFromNow: null, // null OR "من الآن"
|
||||
seconds: function(value) { return numpf(value, "لحظات", "ثانيتين", "%d ثواني", "%d ثانيه"); },
|
||||
minute: "دقيقة",
|
||||
minutes: function(value) { return numpf(value, null, "دقيقتين", "%d دقائق", "%d دقيقة"); },
|
||||
hour: "ساعة",
|
||||
hours: function(value) { return numpf(value, null, "ساعتين", "%d ساعات", "%d ساعة"); },
|
||||
day: "يوم",
|
||||
days: function(value) { return numpf(value, null, "يومين", "%d أيام", "%d يوم"); },
|
||||
month: "شهر",
|
||||
months: function(value) { return numpf(value, null, "شهرين", "%d أشهر", "%d شهر"); },
|
||||
year: "سنه",
|
||||
years: function(value) { return numpf(value, null, "سنتين", "%d سنوات", "%d سنه"); }
|
||||
second: function(value) { return numpf(value, [
|
||||
'أقل من ثانية',
|
||||
'ثانية واحدة',
|
||||
'ثانيتين',
|
||||
'%d ثوانٍ',
|
||||
'%d ثانية',
|
||||
'%d ثانية']); },
|
||||
seconds: function(value) { return numpf(value, [
|
||||
'أقل من ثانية',
|
||||
'ثانية واحدة',
|
||||
'ثانيتين',
|
||||
'%d ثوانٍ',
|
||||
'%d ثانية',
|
||||
'%d ثانية']); },
|
||||
minute: function(value) { return numpf(value, [
|
||||
'أقل من دقيقة',
|
||||
'دقيقة واحدة',
|
||||
'دقيقتين',
|
||||
'%d دقائق',
|
||||
'%d دقيقة',
|
||||
'دقيقة']); },
|
||||
minutes: function(value) { return numpf(value, [
|
||||
'أقل من دقيقة',
|
||||
'دقيقة واحدة',
|
||||
'دقيقتين',
|
||||
'%d دقائق',
|
||||
'%d دقيقة',
|
||||
'دقيقة']); },
|
||||
hour: function(value) { return numpf(value, [
|
||||
'أقل من ساعة',
|
||||
'ساعة واحدة',
|
||||
'ساعتين',
|
||||
'%d ساعات',
|
||||
'%d ساعة',
|
||||
'%d ساعة']); },
|
||||
hours: function(value) { return numpf(value, [
|
||||
'أقل من ساعة',
|
||||
'ساعة واحدة',
|
||||
'ساعتين',
|
||||
'%d ساعات',
|
||||
'%d ساعة',
|
||||
'%d ساعة']); },
|
||||
day: function(value) { return numpf(value, [
|
||||
'أقل من يوم',
|
||||
'يوم واحد',
|
||||
'يومين',
|
||||
'%d أيام',
|
||||
'%d يومًا',
|
||||
'%d يوم']); },
|
||||
days: function(value) { return numpf(value, [
|
||||
'أقل من يوم',
|
||||
'يوم واحد',
|
||||
'يومين',
|
||||
'%d أيام',
|
||||
'%d يومًا',
|
||||
'%d يوم']); },
|
||||
month: function(value) { return numpf(value, [
|
||||
'أقل من شهر',
|
||||
'شهر واحد',
|
||||
'شهرين',
|
||||
'%d أشهر',
|
||||
'%d شهرًا',
|
||||
'%d شهر']); },
|
||||
months: function(value) { return numpf(value, [
|
||||
'أقل من شهر',
|
||||
'شهر واحد',
|
||||
'شهرين',
|
||||
'%d أشهر',
|
||||
'%d شهرًا',
|
||||
'%d شهر']); },
|
||||
year: function(value) { return numpf(value, [
|
||||
'أقل من عام',
|
||||
'عام واحد',
|
||||
'%d عامين',
|
||||
'%d أعوام',
|
||||
'%d عامًا']);
|
||||
},
|
||||
years: function(value) { return numpf(value, [
|
||||
'أقل من عام',
|
||||
'عام واحد',
|
||||
'عامين',
|
||||
'%d أعوام',
|
||||
'%d عامًا',
|
||||
'%d عام']);}
|
||||
};
|
||||
})();
|
||||
})();
|
||||
|
|
24
locales/jquery.timeago.cs.js
Normal file
24
locales/jquery.timeago.cs.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Czech
|
||||
(function() {
|
||||
function f(n, d, a) {
|
||||
return a[d>=0 ? 0 : a.length==2 || n<5 ? 1 : 2];
|
||||
}
|
||||
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: 'před',
|
||||
prefixFromNow: 'za',
|
||||
suffixAgo: null,
|
||||
suffixFromNow: null,
|
||||
seconds: function(n, d) {return f(n, d, ['méně než minutou', 'méně než minutu'])},
|
||||
minute: function(n, d) {return f(n, d, ['minutou', 'minutu'])},
|
||||
minutes: function(n, d) {return f(n, d, ['%d minutami', '%d minuty', '%d minut'])},
|
||||
hour: function(n, d) {return f(n, d, ['hodinou', 'hodinu'])},
|
||||
hours: function(n, d) {return f(n, d, ['%d hodinami', '%d hodiny', '%d hodin'])},
|
||||
day: function(n, d) {return f(n, d, ['%d dnem', '%d den'])},
|
||||
days: function(n, d) {return f(n, d, ['%d dny', '%d dny', '%d dní'])},
|
||||
month: function(n, d) {return f(n, d, ['%d měsícem', '%d měsíc'])},
|
||||
months: function(n, d) {return f(n, d, ['%d měsící', '%d měsíce', '%d měsíců'])},
|
||||
year: function(n, d) {return f(n, d, ['%d rokem', '%d rok'])},
|
||||
years: function(n, d) {return f(n, d, ['%d lety', '%d roky', '%d let'])}
|
||||
};
|
||||
})();
|
|
@ -1,18 +0,0 @@
|
|||
// Czech
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: "před",
|
||||
prefixFromNow: null,
|
||||
suffixAgo: null,
|
||||
suffixFromNow: null,
|
||||
seconds: "méně než minutou",
|
||||
minute: "minutou",
|
||||
minutes: "%d minutami",
|
||||
hour: "hodinou",
|
||||
hours: "%d hodinami",
|
||||
day: "1 dnem",
|
||||
days: "%d dny",
|
||||
month: "1 měsícem",
|
||||
months: "%d měsíci",
|
||||
year: "1 rokem",
|
||||
years: "%d roky"
|
||||
};
|
20
locales/jquery.timeago.es-short.js
Normal file
20
locales/jquery.timeago.es-short.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Spanish shortened
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: null,
|
||||
prefixFromNow: null,
|
||||
suffixAgo: "",
|
||||
suffixFromNow: "",
|
||||
seconds: "1m",
|
||||
minute: "1m",
|
||||
minutes: "%dm",
|
||||
hour: "1h",
|
||||
hours: "%dh",
|
||||
day: "1d",
|
||||
days: "%dd",
|
||||
month: "1me",
|
||||
months: "%dme",
|
||||
year: "1a",
|
||||
years: "%da",
|
||||
wordSeparator: " ",
|
||||
numbers: []
|
||||
};
|
18
locales/jquery.timeago.et.js
Normal file
18
locales/jquery.timeago.et.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Estonian
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: null,
|
||||
prefixFromNow: null,
|
||||
suffixAgo: "tagasi",
|
||||
suffixFromNow: "pärast",
|
||||
seconds: function(n, d) { return d < 0 ? "vähem kui minuti aja" : "vähem kui minut aega" },
|
||||
minute: function(n, d) { return d < 0 ? "umbes minuti aja" : "umbes minut aega" },
|
||||
minutes: function(n, d) { return d < 0 ? "%d minuti" : "%d minutit" },
|
||||
hour: function(n, d) { return d < 0 ? "umbes tunni aja" : "umbes tund aega" },
|
||||
hours: function(n, d) { return d < 0 ? "%d tunni" : "%d tundi" },
|
||||
day: function(n, d) { return d < 0 ? "umbes päeva" : "umbes päev" },
|
||||
days: function(n, d) { return d < 0 ? "%d päeva" : "%d päeva" },
|
||||
month: function(n, d) { return d < 0 ? "umbes kuu aja" : "umbes kuu aega" },
|
||||
months: function(n, d) { return d < 0 ? "%d kuu" : "%d kuud" },
|
||||
year: function(n, d) { return d < 0 ? "umbes aasta aja" : "umbes aasta aega" },
|
||||
years: function(n, d) { return d < 0 ? "%d aasta" : "%d aastat" }
|
||||
};
|
16
locales/jquery.timeago.fr-short.js
Normal file
16
locales/jquery.timeago.fr-short.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
// French shortened
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: "il y a",
|
||||
prefixFromNow: "d'ici",
|
||||
seconds: "moins d'une minute",
|
||||
minute: "une minute",
|
||||
minutes: "%d minutes",
|
||||
hour: "une heure",
|
||||
hours: "%d heures",
|
||||
day: "un jour",
|
||||
days: "%d jours",
|
||||
month: "un mois",
|
||||
months: "%d mois",
|
||||
year: "un an",
|
||||
years: "%d ans"
|
||||
};
|
18
locales/jquery.timeago.gl.js
Normal file
18
locales/jquery.timeago.gl.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Galician
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: "hai",
|
||||
prefixFromNow: "dentro de",
|
||||
suffixAgo: "",
|
||||
suffixFromNow: "",
|
||||
seconds: "menos dun minuto",
|
||||
minute: "un minuto",
|
||||
minutes: "uns %d minutos",
|
||||
hour: "unha hora",
|
||||
hours: "%d horas",
|
||||
day: "un día",
|
||||
days: "%d días",
|
||||
month: "un mes",
|
||||
months: "%d meses",
|
||||
year: "un ano",
|
||||
years: "%d anos"
|
||||
};
|
|
@ -1,7 +1,7 @@
|
|||
// Hebrew
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: "לפני",
|
||||
prefixFromNow: "מעכשיו",
|
||||
prefixFromNow: "עוד",
|
||||
suffixAgo: "",
|
||||
suffixFromNow: "",
|
||||
seconds: "פחות מדקה",
|
||||
|
@ -15,4 +15,4 @@ jQuery.timeago.settings.strings = {
|
|||
months: "%d חודשים",
|
||||
year: "שנה",
|
||||
years: "%d שנים"
|
||||
};
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ jQuery.timeago.settings.strings = {
|
|||
day: "sehari",
|
||||
days: "%d hari",
|
||||
month: "sekitar sebulan",
|
||||
months: "%d tahun",
|
||||
months: "%d bulan",
|
||||
year: "sekitar setahun",
|
||||
years: "%d tahun"
|
||||
};
|
||||
};
|
||||
|
|
19
locales/jquery.timeago.is.js
Normal file
19
locales/jquery.timeago.is.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: "fyrir",
|
||||
prefixFromNow: "eftir",
|
||||
suffixAgo: "síðan",
|
||||
suffixFromNow: null,
|
||||
seconds: "minna en mínútu",
|
||||
minute: "mínútu",
|
||||
minutes: "%d mínútum",
|
||||
hour: "klukkutíma",
|
||||
hours: "um %d klukkutímum",
|
||||
day: "degi",
|
||||
days: "%d dögum",
|
||||
month: "mánuði",
|
||||
months: "%d mánuðum",
|
||||
year: "ári",
|
||||
years: "%d árum",
|
||||
wordSeparator: " ",
|
||||
numbers: []
|
||||
};
|
|
@ -4,16 +4,16 @@ jQuery.timeago.settings.strings = {
|
|||
prefixFromNow: "今から",
|
||||
suffixAgo: "前",
|
||||
suffixFromNow: "後",
|
||||
seconds: "ほんの数秒",
|
||||
minute: "約一分",
|
||||
seconds: "1 分未満",
|
||||
minute: "約 1 分",
|
||||
minutes: "%d 分",
|
||||
hour: "大体一時間",
|
||||
hours: "大体 %d 時間位",
|
||||
day: "一日",
|
||||
days: "%d 日ほど",
|
||||
month: "大体一ヶ月",
|
||||
months: "%d ヶ月ほど",
|
||||
year: "1年前",
|
||||
years: "%d 年",
|
||||
hour: "約 1 時間",
|
||||
hours: "約 %d 時間",
|
||||
day: "約 1 日",
|
||||
days: "約 %d 日",
|
||||
month: "約 1 月",
|
||||
months: "約 %d 月",
|
||||
year: "約 1 年",
|
||||
years: "約 %d 年",
|
||||
wordSeparator: ""
|
||||
};
|
||||
};
|
||||
|
|
18
locales/jquery.timeago.jv.js
Normal file
18
locales/jquery.timeago.jv.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Javanesse (Boso Jowo)
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: null,
|
||||
prefixFromNow: null,
|
||||
suffixAgo: "kepungkur",
|
||||
suffixFromNow: "seko saiki",
|
||||
seconds: "kurang seko sakmenit",
|
||||
minute: "kurang luwih sakmenit",
|
||||
minutes: "%d menit",
|
||||
hour: "kurang luwih sakjam",
|
||||
hours: "kurang luwih %d jam",
|
||||
day: "sedina",
|
||||
days: "%d dina",
|
||||
month: "kurang luwih sewulan",
|
||||
months: "%d wulan",
|
||||
year: "kurang luwih setahun",
|
||||
years: "%d tahun"
|
||||
};
|
20
locales/jquery.timeago.lt.js
Normal file
20
locales/jquery.timeago.lt.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
//Lithuanian
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: "prieš",
|
||||
prefixFromNow: null,
|
||||
suffixAgo: null,
|
||||
suffixFromNow: "nuo dabar",
|
||||
seconds: "%d sek.",
|
||||
minute: "min.",
|
||||
minutes: "%d min.",
|
||||
hour: "val.",
|
||||
hours: "%d val.",
|
||||
day: "1 d.",
|
||||
days: "%d d.",
|
||||
month: "mėn.",
|
||||
months: "%d mėn.",
|
||||
year: "metus",
|
||||
years: "%d metus",
|
||||
wordSeparator: " ",
|
||||
numbers: []
|
||||
};
|
|
@ -1,16 +1,18 @@
|
|||
// Brazilian Portuguese
|
||||
jQuery.timeago.settings.strings = {
|
||||
suffixAgo: "atrás",
|
||||
suffixFromNow: "nesse momento",
|
||||
prefixAgo: "há",
|
||||
prefixFromNow: "em",
|
||||
suffixAgo: null,
|
||||
suffixFromNow: null,
|
||||
seconds: "alguns segundos",
|
||||
minute: "há um minuto",
|
||||
minutes: "há %d minutos",
|
||||
hour: "há uma hora",
|
||||
hours: "há %d horas",
|
||||
day: "há um dia",
|
||||
days: "há %d dias",
|
||||
month: "há um mês",
|
||||
months: "há %d meses",
|
||||
year: "há um ano",
|
||||
years: "há %d anos"
|
||||
minute: "um minuto",
|
||||
minutes: "%d minutos",
|
||||
hour: "uma hora",
|
||||
hours: "%d horas",
|
||||
day: "um dia",
|
||||
days: "%d dias",
|
||||
month: "um mês",
|
||||
months: "%d meses",
|
||||
year: "um ano",
|
||||
years: "%d anos"
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Romanian
|
||||
$.timeago.settings.strings = {
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: "acum",
|
||||
prefixFromNow: "in timp de",
|
||||
suffixAgo: "",
|
||||
|
@ -15,4 +15,4 @@ $.timeago.settings.strings = {
|
|||
months: "%d luni",
|
||||
year: "un an",
|
||||
years: "%d ani"
|
||||
};
|
||||
};
|
||||
|
|
49
locales/jquery.timeago.rs.js
Normal file
49
locales/jquery.timeago.rs.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Serbian
|
||||
(function () {
|
||||
var numpf;
|
||||
|
||||
numpf = function (n, f, s, t) {
|
||||
var n10;
|
||||
n10 = n % 10;
|
||||
if (n10 === 1 && (n === 1 || n > 20)) {
|
||||
return f;
|
||||
} else if (n10 > 1 && n10 < 5 && (n > 20 || n < 10)) {
|
||||
return s;
|
||||
} else {
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: "pre",
|
||||
prefixFromNow: "za",
|
||||
suffixAgo: null,
|
||||
suffixFromNow: null,
|
||||
second: "sekund",
|
||||
seconds: function (value) {
|
||||
return numpf(value, "%d sekund", "%d sekunde", "%d sekundi");
|
||||
},
|
||||
minute: "oko minut",
|
||||
minutes: function (value) {
|
||||
return numpf(value, "%d minut", "%d minuta", "%d minuta");
|
||||
},
|
||||
hour: "oko jedan sat",
|
||||
hours: function (value) {
|
||||
return numpf(value, "%d sat", "%d sata", "%d sati");
|
||||
},
|
||||
day: "jedan dan",
|
||||
days: function (value) {
|
||||
return numpf(value, "%d dan", "%d dana", "%d dana");
|
||||
},
|
||||
month: "mesec dana",
|
||||
months: function (value) {
|
||||
return numpf(value, "%d mesec", "%d meseca", "%d meseci");
|
||||
},
|
||||
year: "godinu dana",
|
||||
years: function (value) {
|
||||
return numpf(value, "%d godinu", "%d godine", "%d godina");
|
||||
},
|
||||
wordSeparator: " "
|
||||
};
|
||||
|
||||
}).call(this);
|
18
locales/jquery.timeago.sk.js
Normal file
18
locales/jquery.timeago.sk.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Slovak
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: "pred",
|
||||
prefixFromNow: null,
|
||||
suffixAgo: null,
|
||||
suffixFromNow: null,
|
||||
seconds: "menej než minútou",
|
||||
minute: "minútou",
|
||||
minutes: "%d minútami",
|
||||
hour: "hodinou",
|
||||
hours: "%d hodinami",
|
||||
day: "1 dňom",
|
||||
days: "%d dňami",
|
||||
month: "1 mesiacom",
|
||||
months: "%d mesiacmi",
|
||||
year: "1 rokom",
|
||||
years: "%d rokmi"
|
||||
};
|
44
locales/jquery.timeago.sl.js
Normal file
44
locales/jquery.timeago.sl.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
// Slovenian with support for dual
|
||||
(function () {
|
||||
var numpf;
|
||||
numpf = function (n, d, m) {
|
||||
if (n == 2) {
|
||||
return d;
|
||||
} else {
|
||||
return m;
|
||||
}
|
||||
};
|
||||
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: "pred",
|
||||
prefixFromNow: "čez",
|
||||
suffixAgo: null,
|
||||
suffixFromNow: null,
|
||||
second: "sekundo",
|
||||
seconds: function (value) {
|
||||
return numpf(value, "%d sekundama", "%d sekundami");
|
||||
},
|
||||
minute: "minuto",
|
||||
minutes: function (value) {
|
||||
return numpf(value, "%d minutama", "%d minutami");
|
||||
},
|
||||
hour: "uro",
|
||||
hours: function (value) {
|
||||
return numpf(value, "%d urama", "%d urami");
|
||||
},
|
||||
day: "dnevom",
|
||||
days: function (value) {
|
||||
return numpf(value, "%d dnevi", "%d dnevi");
|
||||
},
|
||||
month: "enim mescem",
|
||||
months: function (value) {
|
||||
return numpf(value, "%d mesecema", "%d meseci");
|
||||
},
|
||||
year: "enim letom",
|
||||
years: function (value) {
|
||||
return numpf(value, "%d letoma", "%d leti");
|
||||
},
|
||||
wordSeparator: " "
|
||||
};
|
||||
|
||||
}).call(this);
|
|
@ -1,5 +1,5 @@
|
|||
// Turkish
|
||||
jQuery.extend($.timeago.settings.strings, {
|
||||
jQuery.timeago.settings.strings = {
|
||||
suffixAgo: 'önce',
|
||||
suffixFromNow: null,
|
||||
seconds: '1 dakikadan',
|
||||
|
@ -13,4 +13,4 @@ jQuery.extend($.timeago.settings.strings, {
|
|||
months: '%d ay',
|
||||
year: '1 yıl',
|
||||
years: '%d yıl'
|
||||
});
|
||||
};
|
||||
|
|
20
locales/jquery.timeago.vi.js
Normal file
20
locales/jquery.timeago.vi.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Vietnamese
|
||||
jQuery.timeago.settings.strings = {
|
||||
prefixAgo: 'cách đây',
|
||||
prefixFromNow: null,
|
||||
suffixAgo: null,
|
||||
suffixFromNow: "trước",
|
||||
seconds: "chưa đến một phút",
|
||||
minute: "khoảng một phút",
|
||||
minutes: "%d phút",
|
||||
hour: "khoảng một tiếng",
|
||||
hours: "khoảng %d tiếng",
|
||||
day: "một ngày",
|
||||
days: "%d ngày",
|
||||
month: "khoảng một tháng",
|
||||
months: "%d tháng",
|
||||
year: "khoảng một năm",
|
||||
years: "%d năm",
|
||||
wordSeparator: " ",
|
||||
numbers: []
|
||||
};
|
|
@ -4,17 +4,17 @@ jQuery.timeago.settings.strings = {
|
|||
prefixFromNow: "从现在开始",
|
||||
suffixAgo: "之前",
|
||||
suffixFromNow: null,
|
||||
seconds: "不到 1 分钟",
|
||||
minute: "大约 1 分钟",
|
||||
minutes: "%d 分钟",
|
||||
hour: "大约 1 小时",
|
||||
hours: "大约 %d 小时",
|
||||
day: "1 天",
|
||||
days: "%d 天",
|
||||
month: "大约 1 个月",
|
||||
months: "%d 月",
|
||||
year: "大约 1 年",
|
||||
years: "%d 年",
|
||||
seconds: "不到1分钟",
|
||||
minute: "大约1分钟",
|
||||
minutes: "%d分钟",
|
||||
hour: "大约1小时",
|
||||
hours: "大约%d小时",
|
||||
day: "1天",
|
||||
days: "%d天",
|
||||
month: "大约1个月",
|
||||
months: "%d月",
|
||||
year: "大约1年",
|
||||
years: "%d年",
|
||||
numbers: [],
|
||||
wordSeparator: ""
|
||||
};
|
||||
};
|
||||
|
|
|
@ -4,17 +4,17 @@ jQuery.timeago.settings.strings = {
|
|||
prefixFromNow: "從現在開始",
|
||||
suffixAgo: "之前",
|
||||
suffixFromNow: null,
|
||||
seconds: "不到 1 分鐘",
|
||||
minute: "大約 1 分鐘",
|
||||
minutes: "%d 分鐘",
|
||||
hour: "大約 1 小時",
|
||||
hours: "大約 %d 小時",
|
||||
day: "1 天",
|
||||
days: "%d 天",
|
||||
month: "大約 1 個月",
|
||||
months: "%d 月",
|
||||
year: "大約 1 年",
|
||||
years: "%d 年",
|
||||
seconds: "不到1分鐘",
|
||||
minute: "大約1分鐘",
|
||||
minutes: "%d分鐘",
|
||||
hour: "大約1小時",
|
||||
hours: "%d小時",
|
||||
day: "大約1天",
|
||||
days: "%d天",
|
||||
month: "大約1個月",
|
||||
months: "%d個月",
|
||||
year: "大約1年",
|
||||
years: "%d年",
|
||||
numbers: [],
|
||||
wordSeparator: ""
|
||||
};
|
||||
};
|
||||
|
|
1
public
1
public
|
@ -1 +0,0 @@
|
|||
.
|
223
test/index.html
223
test/index.html
|
@ -1,26 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>JavaScript unit test file</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
|
||||
<!-- use http://code.jquery.com/jquery-latest.js for the latest jQuery -->
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
|
||||
|
||||
<!-- http://dev.jquery.com/view/trunk/qunit/testrunner.js -->
|
||||
<script src="qunit.js" type="text/javascript"></script>
|
||||
|
||||
<script src="../jquery.timeago.js" type="text/javascript"></script>
|
||||
|
||||
<!-- http://dev.jquery.com/view/trunk/qunit/testsuite.css -->
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery-Timeago Test Suite</title>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.11.0.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">jquery-timeago Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
|
||||
<div id="main">
|
||||
<h2>Short term</h2>
|
||||
|
@ -76,6 +63,16 @@
|
|||
<p><time id="testTimeTitle" class="timeago" datetime="2012-05-07T10:06:02+02:00" title="May 10, 2012 10:06">May 10, 2012</time></p>
|
||||
<p><time id="testTimeTitle2" class="timeago" datetime="2012-05-07T10:06:02+02:00">May 10, 2012</time></p>
|
||||
|
||||
<h2>Cutoff</h2>
|
||||
|
||||
<p>Date that is before a past cutoff: <abbr class="timeago cutoff doCutoffPast" title="1978-12-18">(this should be displayed)</abbr></p>
|
||||
|
||||
<p>Date that is after a past cutoff: <abbr class="timeago loaded cutoff dontCutoffPast">(you shouldn't see this)</abbr></p>
|
||||
|
||||
<p>Date that is past a future cutoff: <abbr class="timeago cutoff doCutoffFuture" title="2999-12-18">(this should be displayed)</abbr></p>
|
||||
|
||||
<p>Date that is before a future cutoff: <abbr class="timeago loaded cutoff dontCutoffFuture">(you shouldn't see this)</abbr></p>
|
||||
|
||||
<h2>Errors</h2>
|
||||
|
||||
<p>Bad (letters): <abbr class="bad timeago" title="bleh">(this should be displayed)</abbr>.</p>
|
||||
|
@ -97,6 +94,7 @@
|
|||
<li><abbr id="testParsing9" class="todate" title="1978-12-18 17:17:00.021432Z"></abbr> [from Z with microseconds]</li>
|
||||
<li><abbr id="testParsing10" class="todate" title="1978-12-18 17:17:00.0Z"></abbr> [from Z with tenths of a second]</li>
|
||||
<li><abbr id="testParsing11" class="todate" title="1978-12-18 17:17:00.02Z"></abbr> [from Z with hundreths of a second]</li>
|
||||
<li><abbr id="testParsing12" class="todate" title="1978-12-19T02:17:00+09"></abbr> [from +09]</li>
|
||||
</ul>
|
||||
|
||||
<h2>Wording</h2>
|
||||
|
@ -195,8 +193,28 @@
|
|||
<li><abbr id="testMillisSettings8" class="tomillis" title="90"></abbr> [90 sec]</li>
|
||||
<li><abbr id="testMillisSettings9" class="tomillis" title="120"></abbr> [120 sec]</li>
|
||||
</ul>
|
||||
|
||||
<h2>Do Not Allow Future</h2>
|
||||
|
||||
<ul>
|
||||
<li><abbr id="testAllowFutureFalse1" class="doNotAllowFuture" title="2012-01-01T09:24:17Z">(you shouldn't see this)</abbr></li>
|
||||
</ul>
|
||||
|
||||
<h2>Do Not Allow Past</h2>
|
||||
|
||||
<ul>
|
||||
<li><abbr id="testAllowPastFalse1" class="doNotAllowPast" title="2008-01-01T09:24:17Z">(you shouldn't see this)</abbr></li>
|
||||
<li><abbr id="testAllowPastAndFutureFalse" title="2008-01-01T09:24:17Z"></abbr></li>
|
||||
</ul>
|
||||
|
||||
<h2>Disposal</h2>
|
||||
<p><abbr class="disposal disposed"></abbr></p>
|
||||
<p><abbr class="disposal notDisposed"></abbr></p>
|
||||
</div>
|
||||
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
|
||||
<script src="http://code.jquery.com/qunit/qunit-1.11.0.js"></script>
|
||||
<script src="../jquery.timeago.js"></script>
|
||||
<script src="test_helpers.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
|
@ -222,9 +240,13 @@
|
|||
|
||||
prepareDynamicDates();
|
||||
|
||||
$("abbr.timeago").timeago();
|
||||
$("abbr.timeago").not("abbr.cutoff").timeago();
|
||||
$("time.timeago").timeago();
|
||||
|
||||
loadCutoffSetting();
|
||||
$("abbr.cutoff").timeago();
|
||||
unloadCutoffSetting();
|
||||
|
||||
var tooltip = $("#testTooltip").data("timeago");
|
||||
|
||||
$("abbr.todate").each(function () {
|
||||
|
@ -238,6 +260,16 @@
|
|||
$("abbr.tonumbers").each(toWords);
|
||||
unloadNumbers();
|
||||
|
||||
loadDoNotAllowFuture();
|
||||
$("abbr.doNotAllowFuture").timeago();
|
||||
unloadDoNotAllowFuture();
|
||||
|
||||
loadDoNotAllowPast();
|
||||
$("abbr.doNotAllowPast").timeago();
|
||||
unloadDoNotAllowPast();
|
||||
|
||||
setupDisposal();
|
||||
|
||||
loadYoungOldYears();
|
||||
$("abbr.toyoungold").each(toWords);
|
||||
|
||||
|
@ -301,6 +333,32 @@
|
|||
ok(tooltip.datetime, "datetime set");
|
||||
});
|
||||
|
||||
module("Cutoff");
|
||||
|
||||
test("should not change dates older than cutoff setting", function () {
|
||||
ok(testElements("abbr.doCutoffPast", function (element) {
|
||||
return (element.html() === "(this should be displayed)");
|
||||
}), "Cutoff setting working fine");
|
||||
});
|
||||
|
||||
test("should change dates newer than cutoff setting", function () {
|
||||
ok(testElements("abbr.dontCutoffPast", function (element) {
|
||||
return (element.html() === "less than a minute ago");
|
||||
}), "Cutoff setting working fine");
|
||||
});
|
||||
|
||||
test("should not change dates older than cutoff setting", function () {
|
||||
ok(testElements("abbr.doCutoffFuture", function (element) {
|
||||
return (element.html() === "(this should be displayed)");
|
||||
}), "Cutoff setting working fine");
|
||||
});
|
||||
|
||||
test("should change dates newer than cutoff setting", function () {
|
||||
ok(testElements("abbr.dontCutoffFuture", function (element) {
|
||||
return (element.html() === "less than a minute ago");
|
||||
}), "Cutoff setting working fine");
|
||||
});
|
||||
|
||||
module("Tooltip");
|
||||
|
||||
test("should set title to original text contents", function () {
|
||||
|
@ -326,154 +384,159 @@
|
|||
|
||||
test("From Z", function () {
|
||||
var time = $("#testParsing1");
|
||||
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
test("From -00:00", function () {
|
||||
var time = $("#testParsing2");
|
||||
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
test("From -05:00", function () {
|
||||
var time = $("#testParsing3");
|
||||
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
test("From -0500", function () {
|
||||
var time = $("#testParsing4");
|
||||
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
test("From +09:00", function () {
|
||||
var time = $("#testParsing5");
|
||||
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
test("From +0900", function () {
|
||||
var time = $("#testParsing6");
|
||||
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
test("From blank TZ", function () {
|
||||
var time = $("#testParsing7");
|
||||
var correctMatch = /Mon, 18 Dec 1978 \d\d:17:00 (GMT|UTC)/;
|
||||
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
test("From Z with milliseconds", function () {
|
||||
var time = $("#testParsing8");
|
||||
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
test("From Z with microseconds", function () {
|
||||
var time = $("#testParsing9");
|
||||
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
test("From Z with tenths of a second", function () {
|
||||
var time = $("#testParsing10");
|
||||
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
test("From Z with hundreths of a second", function () {
|
||||
var time = $("#testParsing11");
|
||||
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
test("From +09", function () {
|
||||
var time = $("#testParsing12");
|
||||
ok((time.html().match(correctMatch)), "Incorrectly parsed " + time.attr("title"));
|
||||
});
|
||||
|
||||
module("Wording");
|
||||
|
||||
test("-120 min", function () {
|
||||
ok(($("#testWording1").html() === "about 2 hours from now"), "Correctly parsed");
|
||||
ok(($("#testWording1").html() === "about 2 hours from now"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("-60 sec", function () {
|
||||
ok(($("#testWording2").html() === "about a minute from now"), "Correctly parsed");
|
||||
ok(($("#testWording2").html() === "about a minute from now"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("-30 sec", function () {
|
||||
ok(($("#testWording3").html() === "less than a minute from now"), "Correctly parsed");
|
||||
ok(($("#testWording3").html() === "less than a minute from now"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("-1 sec", function () {
|
||||
ok(($("#testWording4").html() === "less than a minute from now"), "Correctly parsed");
|
||||
ok(($("#testWording4").html() === "less than a minute from now"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("0 sec", function () {
|
||||
ok(($("#testWording5").html() === "less than a minute ago"), "Correctly parsed");
|
||||
ok(($("#testWording5").html() === "less than a minute ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("30 sec", function () {
|
||||
ok(($("#testWording6").html() === "less than a minute ago"), "Correctly parsed");
|
||||
ok(($("#testWording6").html() === "less than a minute ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("45 sec", function () {
|
||||
ok(($("#testWording7").html() === "about a minute ago"), "Correctly parsed");
|
||||
ok(($("#testWording7").html() === "about a minute ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("90 sec", function () {
|
||||
ok(($("#testWording8").html() === "2 minutes ago"), "Correctly parsed");
|
||||
ok(($("#testWording8").html() === "2 minutes ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("120 sec", function () {
|
||||
ok(($("#testWording9").html() === "2 minutes ago"), "Correctly parsed");
|
||||
ok(($("#testWording9").html() === "2 minutes ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("45 min", function () {
|
||||
ok(($("#testWording10").html() === "about an hour ago"), "Correctly parsed");
|
||||
ok(($("#testWording10").html() === "about an hour ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("89 min", function () {
|
||||
ok(($("#testWording11").html() === "about an hour ago"), "Correctly parsed");
|
||||
ok(($("#testWording11").html() === "about an hour ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("90 min", function () {
|
||||
ok(($("#testWording12").html() === "about 2 hours ago"), "Correctly parsed");
|
||||
ok(($("#testWording12").html() === "about 2 hours ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("120 min", function () {
|
||||
ok(($("#testWording13").html() === "about 2 hours ago"), "Correctly parsed");
|
||||
ok(($("#testWording13").html() === "about 2 hours ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("1380 min", function () {
|
||||
ok(($("#testWording14").html() === "about 23 hours ago"), "Correctly parsed");
|
||||
ok(($("#testWording14").html() === "about 23 hours ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("25 hours", function () {
|
||||
ok(($("#testWording15").html() === "a day ago"), "Correctly parsed");
|
||||
ok(($("#testWording15").html() === "a day ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("41 hour", function () {
|
||||
ok(($("#testWording16a").html() === "a day ago"), "Correctly parsed");
|
||||
ok(($("#testWording16a").html() === "a day ago"), "Incorrectly parsed");
|
||||
});
|
||||
test("42 hours", function () {
|
||||
ok(($("#testWording16b").html() === "2 days ago"), "Correctly parsed");
|
||||
ok(($("#testWording16b").html() === "2 days ago"), "Incorrectly parsed");
|
||||
});
|
||||
test("48 hours", function () {
|
||||
ok(($("#testWording16c").html() === "2 days ago"), "Correctly parsed");
|
||||
ok(($("#testWording16c").html() === "2 days ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("696 hours", function () {
|
||||
ok(($("#testWording17").html() === "29 days ago"), "Correctly parsed");
|
||||
ok(($("#testWording17").html() === "29 days ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("30 days", function () {
|
||||
ok(($("#testWording18").html() === "about a month ago"), "Correctly parsed");
|
||||
ok(($("#testWording18").html() === "about a month ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("190 days", function () {
|
||||
ok(($("#testWording19").html() === "6 months ago"), "Correctly parsed");
|
||||
ok(($("#testWording19").html() === "6 months ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("366 days", function () {
|
||||
ok(($("#testWording20").html() === "about a year ago"), "Correctly parsed");
|
||||
ok(($("#testWording20").html() === "about a year ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("725 days", function () {
|
||||
ok(($("#testWording21").html() === "2 years ago"), "Correctly parsed");
|
||||
ok(($("#testWording21").html() === "2 years ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
test("1095 days", function () {
|
||||
ok(($("#testWording22").html() === "3 years ago"), "Correctly parsed");
|
||||
ok(($("#testWording22").html() === "3 years ago"), "Incorrectly parsed");
|
||||
});
|
||||
|
||||
module("Settings");
|
||||
|
@ -568,6 +631,58 @@
|
|||
ok($("#testNoSpaces1").html().match(/^2minutesago$/), "Settings correctly applied");
|
||||
ok($("#testNullSpaces1").html().match(/^2minutesago$/), "Settings correctly applied");
|
||||
});
|
||||
|
||||
module("Allow Future and Past");
|
||||
|
||||
// if allowFuture is false, then a minute into the future is actually reported as a minute in the past.
|
||||
// we did not want to alter the current behavior and break backwards compatability
|
||||
test("allow future false with a future date moves time backwards", function () {
|
||||
equal($("#testAllowFutureFalse1").html(), "2 years ago");
|
||||
});
|
||||
|
||||
test("allow future false with a future date moves time backwards", function () {
|
||||
equal($("#testAllowPastFalse1").html(), "in the past");
|
||||
});
|
||||
|
||||
test("throws if allowPast and allowFuture are both false", function () {
|
||||
// setup
|
||||
var origAllowFuture = $.timeago.settings.allowFuture;
|
||||
var origAllowPast = $.timeago.settings.allowPast;
|
||||
$.timeago.settings.allowFuture = false;
|
||||
$.timeago.settings.allowPast = false;
|
||||
|
||||
try {
|
||||
throws(function () {
|
||||
$("#testAllowPastAndFutureFalse").timeago();
|
||||
});
|
||||
} finally {
|
||||
// teardown
|
||||
$.timeago.settings.allowFuture = origAllowFuture;
|
||||
$.timeago.settings.allowPast = origAllowPast;
|
||||
}
|
||||
});
|
||||
|
||||
module("Disposal");
|
||||
|
||||
asyncTest("disposal", function() {
|
||||
$(".disposal.disposed").timeago('dispose');
|
||||
var initialTime_disposedTimeago = $(".disposal.disposed").html();
|
||||
var initialTime_activeTimeago = $(".disposal.notDisposed").html();
|
||||
|
||||
expect(2);
|
||||
setTimeout(function() {
|
||||
var updatedTime_disposedTimeago = $(".disposal.disposed").html();
|
||||
var updatedTime_activeTimeago = $(".disposal.notDisposed").html();
|
||||
|
||||
ok(initialTime_disposedTimeago === updatedTime_disposedTimeago, "A disposed timeago didn't get updated");
|
||||
ok(initialTime_activeTimeago !== updatedTime_activeTimeago, "A non-disposed timeago continued to be updated");
|
||||
|
||||
// Dispose still-active timeago
|
||||
$(".disposal.notDisposed").timeago('dispose');
|
||||
resetRefreshMillis();
|
||||
start();
|
||||
}, 50);
|
||||
});
|
||||
})(jQuery);
|
||||
//]]>
|
||||
</script>
|
||||
|
|
196
test/qunit.css
196
test/qunit.css
|
@ -1,196 +0,0 @@
|
|||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #8699a4;
|
||||
background-color: #0d3349;
|
||||
|
||||
font-size: 1.5em;
|
||||
line-height: 1em;
|
||||
font-weight: normal;
|
||||
|
||||
border-radius: 15px 15px 0 0;
|
||||
-moz-border-radius: 15px 15px 0 0;
|
||||
-webkit-border-top-right-radius: 15px;
|
||||
-webkit-border-top-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: #c2ccd1;
|
||||
}
|
||||
|
||||
#qunit-header a:hover,
|
||||
#qunit-header a:focus {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0em 0 0.5em 2em;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 0 0.5em 2.5em;
|
||||
background-color: #2b81af;
|
||||
color: #fff;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 0.5em 0.4em 2.5em;
|
||||
border-bottom: 1px solid #fff;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests ol {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
-webkit-border-radius: 15px;
|
||||
|
||||
box-shadow: inset 0px 2px 13px #999;
|
||||
-moz-box-shadow: inset 0px 2px 13px #999;
|
||||
-webkit-box-shadow: inset 0px 2px 13px #999;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
border-collapse: collapse;
|
||||
margin-top: .2em;
|
||||
}
|
||||
|
||||
#qunit-tests th {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 0 .5em 0 0;
|
||||
}
|
||||
|
||||
#qunit-tests td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#qunit-tests pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#qunit-tests del {
|
||||
background-color: #e0f2be;
|
||||
color: #374e0c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests ins {
|
||||
background-color: #ffcaca;
|
||||
color: #500;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: black; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
margin: 0.5em;
|
||||
padding: 0.4em 0.5em 0.4em 0.5em;
|
||||
background-color: #fff;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #5E740B;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #EE5757;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: green; }
|
||||
|
||||
#qunit-banner.qunit-fail,
|
||||
#qunit-testrunner-toolbar { background-color: #EE5757; }
|
||||
|
||||
|
||||
/** Footer */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 0.5em 0.5em 2.5em;
|
||||
|
||||
color: #2b81af;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-radius: 0 0 15px 15px;
|
||||
-moz-border-radius: 0 0 15px 15px;
|
||||
-webkit-border-bottom-right-radius: 15px;
|
||||
-webkit-border-bottom-left-radius: 15px;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
}
|
1280
test/qunit.js
1280
test/qunit.js
File diff suppressed because it is too large
Load diff
|
@ -1,23 +0,0 @@
|
|||
setupFn = -> null
|
||||
window.setup = (fn) ->
|
||||
setupFn = fn
|
||||
window.moreSetup = (fn) ->
|
||||
origSetup = setupFn
|
||||
setup ->
|
||||
origSetup.call(this)
|
||||
fn.call(this)
|
||||
window.clearSetup = ->
|
||||
setup -> null
|
||||
|
||||
originalModule = window.module
|
||||
window.module = (description) ->
|
||||
clearSetup()
|
||||
originalModule(description)
|
||||
|
||||
originalTest = window.test
|
||||
window.test = (description, testFn) ->
|
||||
setupSnapshot = setupFn
|
||||
originalTest description, ->
|
||||
context = {}
|
||||
setupSnapshot.call(context)
|
||||
testFn.call(context)
|
|
@ -1,38 +0,0 @@
|
|||
(function() {
|
||||
var originalModule, originalTest, setupFn;
|
||||
setupFn = function() {
|
||||
return null;
|
||||
};
|
||||
window.setup = function(fn) {
|
||||
return (setupFn = fn);
|
||||
};
|
||||
window.moreSetup = function(fn) {
|
||||
var origSetup;
|
||||
origSetup = setupFn;
|
||||
return setup(function() {
|
||||
origSetup.call(this);
|
||||
return fn.call(this);
|
||||
});
|
||||
};
|
||||
window.clearSetup = function() {
|
||||
return setup(function() {
|
||||
return null;
|
||||
});
|
||||
};
|
||||
originalModule = window.module;
|
||||
window.module = function(description) {
|
||||
clearSetup();
|
||||
return originalModule(description);
|
||||
};
|
||||
originalTest = window.test;
|
||||
window.test = function(description, testFn) {
|
||||
var setupSnapshot;
|
||||
setupSnapshot = setupFn;
|
||||
return originalTest(description, function() {
|
||||
var context;
|
||||
context = {};
|
||||
setupSnapshot.call(context);
|
||||
return testFn.call(context);
|
||||
});
|
||||
};
|
||||
}).call(this);
|
|
@ -22,6 +22,19 @@ function unloadNumbers() {
|
|||
jQuery.timeago.settings.strings.numbers = [];
|
||||
}
|
||||
|
||||
function loadCutoffSetting() {
|
||||
jQuery.timeago.settings.cutoff = 7*24*60*60*1000;
|
||||
}
|
||||
|
||||
function unloadCutoffSetting() {
|
||||
jQuery.timeago.settings.cutoff = 0;
|
||||
}
|
||||
|
||||
function setupDisposal() {
|
||||
jQuery.timeago.settings.refreshMillis = 50;
|
||||
$('abbr.disposal').attr("title", iso8601(new Date())).timeago();
|
||||
}
|
||||
|
||||
function loadPigLatin() {
|
||||
jQuery.timeago.settings.strings = {
|
||||
suffixAgo: "ago-hay",
|
||||
|
@ -76,6 +89,10 @@ function loadRussian() {
|
|||
})();
|
||||
}
|
||||
|
||||
function resetRefreshMillis() {
|
||||
jQuery.timeago.settings.refreshMillis = 60000;
|
||||
}
|
||||
|
||||
function loadMillis() {
|
||||
var millisSubstitution = function(number, millis) { return millis + " milliseconds"; };
|
||||
jQuery.timeago.settings.strings = {
|
||||
|
@ -114,3 +131,49 @@ function loadYoungOldYears() {
|
|||
years: function(value) { return (value < 21) ? "%d young years" : "%d old years"; }
|
||||
});
|
||||
}
|
||||
|
||||
function loadDoNotAllowFuture() {
|
||||
var mockDateToUse = "2010-01-01";
|
||||
$.timeago.settings.allowFuture = false;
|
||||
enableMockedDate(mockDateToUse);
|
||||
}
|
||||
|
||||
function unloadDoNotAllowFuture() {
|
||||
$.timeago.settings.allowFuture = true;
|
||||
disableMockedDate();
|
||||
}
|
||||
|
||||
function loadDoNotAllowPast() {
|
||||
var mockDateToUse = "2010-01-01";
|
||||
$.timeago.settings.allowFuture = true;
|
||||
$.timeago.settings.allowPast = false;
|
||||
$.timeago.settings.strings.inPast = "in the past";
|
||||
enableMockedDate(mockDateToUse);
|
||||
}
|
||||
|
||||
function unloadDoNotAllowPast() {
|
||||
$.timeago.settings.allowFuture = true;
|
||||
$.timeago.settings.allowPast = true;
|
||||
disableMockedDate();
|
||||
}
|
||||
|
||||
function enableMockedDate(dateToReturn) {
|
||||
var mockDate = dateToReturn;
|
||||
window.NativeDate = Date;
|
||||
window.Date = function () {
|
||||
if(arguments.length === 0) {
|
||||
return new window.NativeDate(mockDate);
|
||||
} else if(arguments.length === 1) {
|
||||
return new window.NativeDate(arguments[0]);
|
||||
} else if(arguments.length === 7) {
|
||||
return new window.NativeDate(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]);
|
||||
} else {
|
||||
throw "Mocking Date with this number of parameters is not implemented.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function disableMockedDate() {
|
||||
window.Date = window.NativeDate;
|
||||
delete window.NativeDate;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "timeago",
|
||||
"version": "1.0.0",
|
||||
"version": "1.4.1",
|
||||
"title": "jQuery Timeago",
|
||||
"author": {
|
||||
"name": "Ryan McGeary",
|
Loading…
Add table
Reference in a new issue