From c4193a4d81b914dd8f233583131dc57fbb136d91 Mon Sep 17 00:00:00 2001 From: Andrey Kurosh Date: Fri, 15 Jan 2016 17:24:43 +0300 Subject: [PATCH] Tests & compilation fixes. --- clipboard.js/clipboard.js-tests.ts | 6 ++++-- clipboard.js/clipboard.js.d.ts | 17 +++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/clipboard.js/clipboard.js-tests.ts b/clipboard.js/clipboard.js-tests.ts index 5adbeda27..962bf34e0 100644 --- a/clipboard.js/clipboard.js-tests.ts +++ b/clipboard.js/clipboard.js-tests.ts @@ -1,14 +1,16 @@ -/// +/// var cb1 = new clipboardjs.Clipboard('.btn'); var cb2 = new clipboardjs.Clipboard('.btn', { action: elem => 'copy' }); var cb3 = new clipboardjs.Clipboard('.btn', { - action: elem => 'copy', text: elem => null }); var cb4 = new clipboardjs.Clipboard('.btn', { + target: elem => null +}); +var cb5 = new clipboardjs.Clipboard('.btn', { action: elem => 'copy', target: elem => null }); diff --git a/clipboard.js/clipboard.js.d.ts b/clipboard.js/clipboard.js.d.ts index 26b1a9201..6a8af8519 100644 --- a/clipboard.js/clipboard.js.d.ts +++ b/clipboard.js/clipboard.js.d.ts @@ -6,22 +6,21 @@ declare module clipboardjs { export class Clipboard { - constructor (selector: string, options?: ITargetOptions); - constructor (selector: string, options?: ITextOptions); + constructor(selector: string, options?: IOptions); /** * Subscribes to events that indicate the result of a copy/cut operation. * @param type {String} Event type ('success' or 'error'). * @param handler Callback function. */ - on(type: "success", handler: (e: Event) => void); - on(type: "error", handler: (e: Event) => void); - on(type: string, handler: (e: Event) => void); + on(type: "success", handler: (e: Event) => void): void; + on(type: "error", handler: (e: Event) => void): void; + on(type: string, handler: (e: Event) => void): void; /** * Clears all event bindings. */ - destroy(); + destroy(): void; } interface IOptions { @@ -31,20 +30,14 @@ declare module clipboardjs { * @returns {String} Only 'cut' or 'copy'. */ action?: (elem: Element) => string; - } - // Two different interfaces, because 'target' and 'text' attributes cannot be used together. - - interface ITargetOptions extends IOptions { /** * Overwrites default target input element. * @param {Element} elem Current element * @returns {Element} element to use. */ target?: (elem: Element) => Element; - } - interface ITextOptions extends IOptions { /** * Returns the explicit text to copy. * @param {Element} elem Current element