From 5c7b6cceb4d670c61a44bc634b1f5da716904b63 Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Sat, 2 Mar 2013 22:48:49 -0500 Subject: [PATCH] Type definitions for Livestamp.js --- .../jquery.livestampjs-tests.ts | 15 +++++++++++ jquery.livestampjs/jquery.livestampjs.d.ts | 27 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 jquery.livestampjs/jquery.livestampjs-tests.ts create mode 100644 jquery.livestampjs/jquery.livestampjs.d.ts diff --git a/jquery.livestampjs/jquery.livestampjs-tests.ts b/jquery.livestampjs/jquery.livestampjs-tests.ts new file mode 100644 index 0000000000..72dc968cbc --- /dev/null +++ b/jquery.livestampjs/jquery.livestampjs-tests.ts @@ -0,0 +1,15 @@ +// Tests for Livestamp.js type definitions +/// +/// +/// + +$('#test1').livestamp(new Date('June 18, 1987')); +$('#test2').livestamp(1362282933); +$('#test3').livestamp('destroy'); +$('#test4').livestamp(moment(new Date('June 18, 1987'))); + +$.livestamp.update(); +$.livestamp.pause(); +$.livestamp.resume(); +$.livestamp.interval(340); +var result:number = $.livestamp.interval(); \ No newline at end of file diff --git a/jquery.livestampjs/jquery.livestampjs.d.ts b/jquery.livestampjs/jquery.livestampjs.d.ts new file mode 100644 index 0000000000..d460b888d4 --- /dev/null +++ b/jquery.livestampjs/jquery.livestampjs.d.ts @@ -0,0 +1,27 @@ +// Type definitions for Livestamp.js +// A simple, unobtrusive jQuery plugin that provides auto-updating timeago text to your timestamped HTML elements using Moment.js. +// Project: http://http://mattbradley.github.com/livestampjs/ +// Definitions by: Vincent Bortone +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +interface LivestampGlobal { + update(): void; + pause(): void; + resume(): void; + interval(): number; + interval(interval: number): void; +} + +interface JQueryStatic { + livestamp: LivestampGlobal; +} + +interface JQuery { + livestamp(date: Date): JQuery; + livestamp(moment: Moment): JQuery; + livestamp(timestamp: number): JQuery; + livestamp(timestamp: string): JQuery; +} \ No newline at end of file