2019-06-21 10:42:40 +00:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
|
2020-05-12 12:36:03 +00:00
|
|
|
export default Component.extend({
|
2019-06-21 10:42:40 +00:00
|
|
|
clipboard: service('clipboard/os'),
|
2020-05-12 12:36:03 +00:00
|
|
|
dom: service('dom'),
|
|
|
|
tagName: '',
|
|
|
|
init: function() {
|
|
|
|
this._super(...arguments);
|
|
|
|
this.guid = this.dom.guid(this);
|
|
|
|
this._listeners = this.dom.listeners();
|
|
|
|
},
|
|
|
|
willDestroyElement: function() {
|
|
|
|
this._super(...arguments);
|
|
|
|
this._listeners.remove();
|
|
|
|
},
|
2019-06-21 10:42:40 +00:00
|
|
|
didInsertElement: function() {
|
|
|
|
this._super(...arguments);
|
2020-05-12 12:36:03 +00:00
|
|
|
const component = this;
|
|
|
|
this._listeners.add(this.clipboard.execute(`#${this.guid}`), {
|
|
|
|
success: function() {
|
|
|
|
component.success(...arguments);
|
|
|
|
},
|
|
|
|
error: function() {
|
|
|
|
component.error(...arguments);
|
|
|
|
},
|
2019-06-21 10:42:40 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|