mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-28 08:17:54 +08:00
Tests & compilation fixes.
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
/// <reference path="clipboard-js.d.ts" />
|
||||
/// <reference path="clipboard.js.d.ts" />
|
||||
|
||||
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
|
||||
});
|
||||
|
||||
17
clipboard.js/clipboard.js.d.ts
vendored
17
clipboard.js/clipboard.js.d.ts
vendored
@@ -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} <input> element to use.
|
||||
*/
|
||||
target?: (elem: Element) => Element;
|
||||
}
|
||||
|
||||
interface ITextOptions extends IOptions {
|
||||
/**
|
||||
* Returns the explicit text to copy.
|
||||
* @param {Element} elem Current element
|
||||
|
||||
Reference in New Issue
Block a user