How to use the clipboard function in clipboard

To help you get started, we’ve selected a few clipboard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / testpilot / testpilot / frontend / static-src / app / main.js View on Github external
initialize() {
    app.webChannel = webChannel;
    app.me = new Me();
    app.clipboard = new Clipboard('button');
    app.experiments = new ExperimentsCollection();

    app.pageManager = new PageManager({
      pageContainer: document.querySelector('[data-hook=page-container]')
    });

    app.experiments.fetch().then(() => app.me.fetch()).then(() => {
      app.me.updateEnabledExperiments(app.experiments);
      app.startRouter();
    }).catch((err) => {
      console && console.error(err); // eslint-disable-line no-console
      app.startRouter();
      app.router.redirectTo('error');
    });
  },
github WPTT / theme-sniffer / assets / dev / scripts / theme-sniffer.js View on Github external
setupClipboards() {
		let clipboards = document.querySelectorAll( this.reportItemBtn );

		// Create clipboard instance.
		this.clipboardInstance = new Clipboard( clipboards, {
			target: trigger => {
				return trigger.lastElementChild;
			}
		});

		// Clear selection after copy.
		this.clipboardInstance.on( 'success', event => {

			// Store current label.
			let currentLabel = event.trigger.parentElement.getAttribute( 'aria-label' );

			// Set copy success message.
			event.trigger.parentElement.setAttribute( 'aria-label', themeSnifferLocalization.copySuccess );

			// Restore label.
			$( event.trigger.parentElement ).mouseleave( () => {
github johannesjo / super-productivity / src / app / features / worklog / worklog-export / worklog-export.component.ts View on Github external
case 'TIME_STR':
            case 'TIME_CLOCK':
              return 'Worked';
            case 'ESTIMATE_MS':
            case 'ESTIMATE_STR':
            case 'ESTIMATE_CLOCK':
              return 'Estimate';
          }
        });

        this.txt = this._formatText(this.headlineCols, this.formattedRows);
      }
    }));

    // dirty but good enough for now
    const clipboard = new Clipboard('#clipboard-btn');
    clipboard.on('success', (e: any) => {
      this._snackService.open({
        msg: T.GLOBAL_SNACK.COPY_TO_CLIPPBOARD,
        type: 'SUCCESS'
      });
      e.clearSelection();
    });
  }
github ant-design / ant-design-mobile / site / common / clip.js View on Github external
componentDidMount() {
    // Support old API by trying to assign this.props.options first;
    let options = this.props.options || this.propsWith(/^option-/, true);
    this.clipboard = new Clipboard(`#${this.id}`, options);

    let callbacks = this.propsWith(/^on/, true);
    Object.keys(callbacks).forEach(function (callback) {
      this.clipboard.on(callback.toLowerCase(), this.props[`on${callback}`]);
    }, this);
  }
github gardener / dashboard / frontend / src / components / CopyBtn.vue View on Github external
enableCopy () {
      if (this.clipboard) {
        this.clipboard.destroy()
      }
      this.clipboard = new Clipboard(this.$refs.copy.$el, this.clipboardOptions)
      this.clipboard.on('success', (event) => {
        this.snackbar = true
        this.copyFailed = false
        this.$emit('copy')
      })
      this.clipboard.on('error', err => {
        console.error('error', err)
        this.copyFailed = true
        this.snackbar = true
        this.$emit('copyFailed')
      })
    }
  },
github grafana / grafana / public / app / core / directives / misc.ts View on Github external
link: (scope: any, elem: any) => {
      scope.clipboard = new Clipboard(elem[0], {
        text: () => {
          return scope.getText();
        },
      });

      scope.clipboard.on('success', () => {
        appEvents.emit('alert-success', ['Content copied to clipboard']);
      });

      scope.$on('$destroy', () => {
        if (scope.clipboard) {
          scope.clipboard.destroy();
        }
      });
    },
  };
github dodona-edu / dodona / app / assets / javascripts / copy.ts View on Github external
$(() => {
        const selector = ".btn";
        const delay = 1000;
        const clip = new ClipboardJS(selector);
        const targetOf = (e): any => $($(e.trigger).data("clipboard-target"));
        clip.on("success", e => tooltip(targetOf(e), I18n.t("js.copy-success"), delay));
        clip.on("error", e => tooltip(targetOf(e), I18n.t("js.copy-fail"), delay));
    });
}
github SonarSource / sonarqube / server / sonar-web / src / main / js / apps / users / tokens-view.js View on Github external
onRender() {
    Modal.prototype.onRender.apply(this, arguments);
    const copyButton = this.$('.js-copy-to-clipboard');
    if (copyButton.length) {
      const clipboard = new Clipboard(copyButton.get(0));
      clipboard.on('success', () => {
        copyButton
          .tooltip({
            title: translate('users.tokens.copied'),
            placement: 'bottom',
            trigger: 'manual'
          })
          .tooltip('show');
        setTimeout(() => copyButton.tooltip('hide'), 1000);
      });
    }
    this.newToken = null;
  },
github mongodb / design / client / react-components / site / color-chip.jsx View on Github external
componentDidMount() {
    this.clipboard = new Clipboard(this.copyButton);
  }
github Netflix / conductor / ui / src / components / common / Grapher.js View on Github external
import React, {Component} from 'react';
import dagreD3 from 'dagre-d3'
import d3 from 'd3'
import {Tabs, Tab, Table} from 'react-bootstrap';
import Clipboard from 'clipboard';

new Clipboard('.btn');

class Grapher extends Component {
    constructor(props) {
        super(props);

        this.state = {};
        this.state.selectedTask = {};
        this.state.logs = {};
        this.grapher = new dagreD3.render();

        this.setSvgRef = elem => this.svgElem = elem;
        this.setDivRef = elem => this.divElem = elem;
        this.setPropsDivRef = elem => this.propsDivElem = elem;

        let starPoints = function (outerRadius, innerRadius) {
            var results = "";