diff --git a/clipboard/clipboard-tests.ts b/clipboard/clipboard-tests.ts
index de6e9fc1a..1a19fbf23 100644
--- a/clipboard/clipboard-tests.ts
+++ b/clipboard/clipboard-tests.ts
@@ -1,22 +1,28 @@
///
-var cb1 = new clipboard.Clipboard('.btn');
-var cb2 = new clipboard.Clipboard('.btn', {
+var cb1 = new Clipboard('.btn');
+var cb2 = new Clipboard(document.getElementById('id'), {
action: elem => 'copy'
});
-var cb3 = new clipboard.Clipboard('.btn', {
+var cb3 = new Clipboard(document.querySelectorAll('query'), {
text: elem => null
});
-var cb4 = new clipboard.Clipboard('.btn', {
+var cb4 = new Clipboard('.btn', {
target: elem => null
});
-var cb5 = new clipboard.Clipboard('.btn', {
+var cb5 = new Clipboard('.btn', {
action: elem => 'copy',
target: elem => null
});
cb1.destroy();
-cb2.on('success', function(e) { });
+cb2.on('success', function(e) {
+ console.info('Action:', e.action);
+ console.info('Text:', e.text);
+ console.info('Trigger:', e.trigger);
+
+ e.clearSelection();
+});
cb2.on('error', function(e) { });
diff --git a/clipboard/clipboard.d.ts b/clipboard/clipboard.d.ts
index ddba32b06..89f29488b 100644
--- a/clipboard/clipboard.d.ts
+++ b/clipboard/clipboard.d.ts
@@ -1,52 +1,56 @@
-// Type definitions for clipboard.js 1.5.5
+// Type definitions for clipboard.js 1.5.9
// Project: https://github.com/zenorocha/clipboard.js
// Definitions by: Andrei Kurosh
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-declare module clipboard {
+declare class Clipboard {
+ constructor(selector: (string | Element | NodeListOf), options?: ClipboardOptions);
- 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: ClipboardEvent) => void): this;
+ on(type: "error", handler: (e: ClipboardEvent) => void): this;
+ on(type: string, handler: (e: ClipboardEvent) => 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: 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;
+}
- /**
- * Clears all event bindings.
- */
- destroy(): void;
- }
+interface ClipboardOptions {
+ /**
+ * Overwrites default command ('cut' or 'copy').
+ * @param {Element} elem Current element
+ * @returns {String} Only 'cut' or 'copy'.
+ */
+ action?: (elem: Element) => string;
- 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} element to use.
+ */
+ target?: (elem: Element) => Element;
- /**
- * Overwrites default target input element.
- * @param {Element} elem Current element
- * @returns {Element} 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;
+}
- /**
- * Returns the explicit text to copy.
- * @param {Element} elem Current element
- * @returns {String} Text to be copied.
- */
- text?: (elem: Element) => string;
- }
+interface ClipboardEvent {
+ action: string;
+ text: string;
+ trigger: Element;
+ clearSelection(): void;
}
declare module 'clipboard' {
- export = clipboard;
-}
\ No newline at end of file
+ export = Clipboard;
+}