[MOV] web,im_livechat: Move clipboard widget to web

This commit is contained in:
Yannick Tivisse
2018-06-27 14:42:04 +02:00
parent a46301419e
commit 15f3bbe594
10 changed files with 145 additions and 178 deletions
@@ -1064,6 +1064,77 @@ var UrlWidget = InputField.extend({
}
});
var CopyClipboard = {
/**
* @override
*/
destroy: function () {
this._super.apply(this, arguments);
this.clipboard.destroy();
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* Instatiates the Clipboad lib.
*/
_initClipboard: function () {
var self = this;
var $clipboardBtn = this.$('.o_clipboard_button');
$clipboardBtn.tooltip({title: _t('Copied !'), trigger: 'manual', placement: 'right'});
this.clipboard = new Clipboard($clipboardBtn.get(0), {
text: function () {
return self.value.trim();
}
});
this.clipboard.on('success', function () {
_.defer(function () {
$clipboardBtn.tooltip('show');
_.delay(function () {
$clipboardBtn.tooltip('hide');
}, 800);
});
});
},
};
var TextCopyClipboard = FieldText.extend(CopyClipboard, {
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* @override
*/
_render: function() {
this._super.apply(this, arguments);
this.$el.addClass('o_field_copy');
this.$el.append($(qweb.render('CopyClipboardText')));
this._initClipboard();
}
});
var CharCopyClipboard = FieldChar.extend(CopyClipboard, {
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* @override
*/
_render: function() {
this._super.apply(this, arguments);
this.$el.addClass('o_field_copy');
this.$el.append($(qweb.render('CopyClipboardChar')));
this._initClipboard();
}
});
var AbstractFieldBinary = AbstractField.extend({
events: _.extend({}, AbstractField.prototype.events, {
'change .o_input_file': 'on_file_change',
@@ -2673,6 +2744,8 @@ return {
PriorityWidget: PriorityWidget,
StatInfo: StatInfo,
UrlWidget: UrlWidget,
TextCopyClipboard: TextCopyClipboard,
CharCopyClipboard: CharCopyClipboard,
JournalDashboardGraph: JournalDashboardGraph,
AceEditor: AceEditor,
};