本文整理汇总了TypeScript中clipboard.on函数的典型用法代码示例。如果您正苦于以下问题:TypeScript on函数的具体用法?TypeScript on怎么用?TypeScript on使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了on函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: attachDomNode
export function attachDomNode(domNode: HTMLElement, callback: () => string): void {
const clipboard = new Clipboard(domNode, {
text: trigger => callback()
});
clipboard.on("success", e => {
Tooltip.show(nlsHPCC.Copied, domNode);
on.once(domNode, mouse.leave, () => {
Tooltip.hide(domNode);
});
});
clipboard.on("error", e => {
});
}
示例2: attach
export function attach(domID: string): void {
const clipboard: Clipboard = new Clipboard(`#${domID}`);
clipboard.on("success", e => {
e.clearSelection();
const node: HTMLElement = dom.byId(domID);
Tooltip.show("Copied!", node);
on.once(node, mouse.leave, () => {
Tooltip.hide(node);
});
});
clipboard.on("error", e => {
const node: HTMLElement = dom.byId(domID);
Tooltip.show("Press ctrl+c to copy.", node);
on.once(node, mouse.leave, () => {
Tooltip.hide(node);
});
});
}
示例3: buildUi
private buildUi() {
this.registerHandlebarHelpers();
let dataContainer = document.getElementById("data-container");
let template = Handlebars.compile(dataContainer.innerHTML);
let data = template(vm);
dataContainer.innerHTML = data;
let clipboard = new ClipboardJS(".copy-action");
clipboard.on("error", e => {
pbia.admin("Copy to clipboard", "Error");
log.error("Unable to copy view configuration to the clipboard.");
});
clipboard.on("success", e => {
pbia.admin("Copy to clipboard", "Success");
log.debug("View configuration successfully copied to the clipboard.");
e.clearSelection();
});
dataContainer.style.visibility = "visible";
}
示例4: Clipboard
import * as Clipboard from 'clipboard';
var cb1 = new Clipboard('.btn');
var cb2 = new Clipboard(document.getElementById('id'), {
action: elem => 'copy'
});
var cb3 = new Clipboard(document.querySelectorAll('query'), {
text: elem => null
});
var cb4 = new Clipboard('.btn', {
target: elem => null
});
var cb5 = new Clipboard('.btn', {
action: elem => 'copy',
target: elem => null
});
cb1.destroy();
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) { });
示例5: ClipboardJS
import * as ClipboardJS from "clipboard";
const cb1 = new ClipboardJS(".btn");
const cb2 = new ClipboardJS(document.getElementById("id"), {
action: elem => "copy"
});
const cb3 = new ClipboardJS(document.querySelectorAll("query"), {
text: elem => null
});
const cb4 = new ClipboardJS(".btn", {
target: elem => null
});
const cb5 = new ClipboardJS(".btn", {
action: elem => "copy",
target: elem => null
});
cb1.destroy();
ClipboardJS.isSupported();
cb2.on("success", e => {
console.info("Action:", e.action);
console.info("Text:", e.text);
console.info("Trigger:", e.trigger);
e.clearSelection();
});
cb2.on("error", e => {});
示例6: _copyToClipboard
private _copyToClipboard() {
const clipboard = new Clipboard(this._element.nativeElement, { text: () => this.text });
clipboard.on('success', (e) => { clipboard.destroy(); });
}