mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #7642 from impworks/master
Clipboard.js definitions.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/// <reference path="clipboard.d.ts" />
|
||||
|
||||
var cb1 = new clipboard.Clipboard('.btn');
|
||||
var cb2 = new clipboard.Clipboard('.btn', {
|
||||
action: elem => 'copy'
|
||||
});
|
||||
var cb3 = new clipboard.Clipboard('.btn', {
|
||||
text: elem => null
|
||||
});
|
||||
var cb4 = new clipboard.Clipboard('.btn', {
|
||||
target: elem => null
|
||||
});
|
||||
var cb5 = new clipboard.Clipboard('.btn', {
|
||||
action: elem => 'copy',
|
||||
target: elem => null
|
||||
});
|
||||
|
||||
cb1.destroy();
|
||||
|
||||
cb2.on('success', function(e) { });
|
||||
cb2.on('error', function(e) { });
|
||||
|
||||
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
// Type definitions for clipboard.js 1.5.5
|
||||
// Project: https://github.com/zenorocha/clipboard.js
|
||||
// Definitions by: Andrei Kurosh <https://github.com/impworks>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module clipboard {
|
||||
|
||||
export class Clipboard {
|
||||
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): void;
|
||||
on(type: "error", handler: (e: Event) => void): void;
|
||||
on(type: string, handler: (e: Event) => void): void;
|
||||
|
||||
/**
|
||||
* Clears all event bindings.
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
interface IOptions {
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'clipboard' {
|
||||
export = clipboard;
|
||||
}
|
||||
Reference in New Issue
Block a user