Fixed up 'clipboard' to be a UMD-style module.

This commit is contained in:
Daniel Rosenwasser
2016-12-24 03:09:18 -05:00
parent 7c90a158de
commit b93be2f7cf
+50 -50
View File
@@ -3,56 +3,56 @@
// Definitions by: Andrei Kurosh <https://github.com/impworks>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'clipboard' {
class Clipboard {
constructor(selector: (string | Element | NodeListOf<Element>), options?: Clipboard.Options);
declare class Clipboard {
constructor(selector: (string | Element | NodeListOf<Element>), options?: Clipboard.Options);
/**
* 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: Clipboard.Event) => void): this;
on(type: "error", handler: (e: Clipboard.Event) => void): this;
on(type: string, handler: (e: Clipboard.Event) => void): this;
/**
* 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: Clipboard.Event) => void): this;
on(type: "error", handler: (e: Clipboard.Event) => void): this;
on(type: string, handler: (e: Clipboard.Event) => void): this;
/**
* Clears all event bindings.
*/
destroy(): void;
}
namespace Clipboard {
interface Options {
/**
* Overwrites default command ('cut' or 'copy').
* @param {Element} elem Current element
* @returns {String} Only 'cut' or 'copy'.
*/
action?: (elem: Element) => string;
/**
* Overwrites default target input element.
* @param {Element} elem Current element
* @returns {Element} <input> element to use.
*/
target?: (elem: Element) => Element;
/**
* Returns the explicit text to copy.
* @param {Element} elem Current element
* @returns {String} Text to be copied.
*/
text?: (elem: Element) => string;
}
interface Event {
action: string;
text: string;
trigger: Element;
clearSelection(): void;
}
}
export = Clipboard;
/**
* Clears all event bindings.
*/
destroy(): void;
}
declare namespace Clipboard {
interface Options {
/**
* Overwrites default command ('cut' or 'copy').
* @param {Element} elem Current element
* @returns {String} Only 'cut' or 'copy'.
*/
action?: (elem: Element) => string;
/**
* Overwrites default target input element.
* @param {Element} elem Current element
* @returns {Element} <input> element to use.
*/
target?: (elem: Element) => Element;
/**
* Returns the explicit text to copy.
* @param {Element} elem Current element
* @returns {String} Text to be copied.
*/
text?: (elem: Element) => string;
}
interface Event {
action: string;
text: string;
trigger: Element;
clearSelection(): void;
}
}
export = Clipboard;
export as namespace Clipboard;