1ddffb4162
* ui: Renames CopyButtonFeedback to CopyButton and use it everywhere * Uncapitalize output * Remove the ability to set the contents via an attr, and.. ..change the attribute for the string that gets copied to be called 'value' so it feels like HTML
30 lines
772 B
JavaScript
30 lines
772 B
JavaScript
import Component from '@ember/component';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
export default Component.extend({
|
|
clipboard: service('clipboard/os'),
|
|
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();
|
|
},
|
|
didInsertElement: function() {
|
|
this._super(...arguments);
|
|
const component = this;
|
|
this._listeners.add(this.clipboard.execute(`#${this.guid}`), {
|
|
success: function() {
|
|
component.success(...arguments);
|
|
},
|
|
error: function() {
|
|
component.error(...arguments);
|
|
},
|
|
});
|
|
},
|
|
});
|