diff options
| author | Yannick Tivisse <yti@odoo.com> | 2018-06-20 13:38:08 +0200 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2018-06-27 14:42:04 +0200 |
| commit | 15f3bbe5942eee23039d0b40d2bcc0eb274ba129 (patch) | |
| tree | c6dc9215990841cb51aca8608cad373a4ce1d4d5 /addons/web/static/src/js/fields/basic_fields.js | |
| parent | a46301419efe73804a3c0ec6967e7cf5808f86fb (diff) | |
[MOV] web,im_livechat: Move clipboard widget to web
Diffstat (limited to 'addons/web/static/src/js/fields/basic_fields.js')
| -rw-r--r-- | addons/web/static/src/js/fields/basic_fields.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 0cf9271de9d..aa66439143d 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -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, }; |
