-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClipboardMixin.js
70 lines (62 loc) · 1.84 KB
/
ClipboardMixin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
define([
'dojo/_base/declare',
'dojo/_base/lang',
'dojo/dom-construct',
'dojo/dom-attr',
'dojo/on'
], function(
declare,
lang,
domConstruct,
domAttr,
on
){
return declare(null, {
copyType: null,
clipBoard: {},
_copyButton: null,
_pasteButton: null,
postCreate: function() {
this.inherited(arguments);
this._doLayout();
},
enable: function() {
this.inherited(arguments);
domAttr.remove(this._copyButton, 'disabled');
domAttr.remove(this._pasteButton, 'disabled');
},
disable: function() {
this.inherited(arguments);
domAttr.set(this._copyButton, 'disabled', true);
domAttr.set(this._pasteButton, 'disabled', true);
},
copy: function(type) {
try {
this.clipBoard[type] = this.getData();
} catch (e) {
console.error(e);
throw new TypeError('Geen getData beschikbaar voor copy in de widget');
}
},
paste: function(type) {
try {
this.setData(this.clipBoard[type]);
} catch (e) {
console.error(e);
throw new TypeError('Geen setData beschikbaar voor copy in de widget');
}
},
_doLayout: function() {
this._copyButton = domConstruct.create('button', { 'class': 'clipBoardButton copyButton button tiny',
innerHTML: '<i class="fa fa-copy"></i>', title: 'Kopiëren'}, this.domNode, 'first');
on(this._copyButton, 'click', lang.hitch(this, function() {
this.copy(this.copyType);
}));
this._pasteButton = domConstruct.create('button', { 'class': 'clipBoardButton pasteButton button tiny',
innerHTML: '<i class="fa fa-paste"></i>', title: 'Plakken', style: 'margin-left: 5px;'}, this.domNode, 'first');
on(this._pasteButton, 'click', lang.hitch(this, function() {
this.paste(this.copyType);
}));
}
});
});