CopyPaste¶
-
class
webix.
CopyPaste
()¶ Copypaste mixin
References¶
- helpers
isUndefined()
,template()
.
External references¶
Code¶
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 | webix.CopyPaste = {
clipboard_setter: function(value) {
if (value === true || value === 1) value = "modify";
this.attachEvent("onAfterSelect", function(id) {
if (!this.getEditor || !this.getEditor()){
var item = this.getItem(id);
var text = this.type.templateCopy(item);
webix.clipbuffer.set(text, this);
webix.clipbuffer.focus();
webix.UIManager.setFocus(this);
}
});
this.attachEvent("onPaste", function(text) {
if (!webix.isUndefined(this._paste[this._settings.clipboard]))
this._paste[this._settings.clipboard].call(this, text);
});
this.attachEvent("onFocus", function() {
webix.clipbuffer.focus();
});
// solution for clicks on selected items
this.attachEvent("onItemClick",function(id){
if(!this._selected || this._selected.find(id)!==-1){
webix.clipbuffer.focus();
webix.UIManager.setFocus(this);
}
});
return value;
},
_paste: {
// insert new item with pasted value
insert: function(text) {
this.add({ value: text });
},
// change value of each selected item
modify: function(text) {
var sel = this.getSelectedId(true);
for (var i = 0; i < sel.length; i++) {
this.getItem(sel[i]).value = text;
this.refresh(sel[i]);
}
},
// do nothing
custom: function(text) {}
},
templateCopy_setter: function(value) {
this.type.templateCopy = webix.template(value);
},
type:{
templateCopy: function(item) {
return this.template(item);
}
}
};
|