diff --git a/muk_web_utils/__manifest__.py b/muk_web_utils/__manifest__.py index 3a8ab64..08355c5 100644 --- a/muk_web_utils/__manifest__.py +++ b/muk_web_utils/__manifest__.py @@ -20,7 +20,7 @@ { "name": "MuK Web Utils", "summary": """Utility Features""", - "version": "12.0.2.4.0", + "version": "12.0.2.4.1", "category": "Extra Tools", "license": "AGPL-3", "author": "MuK IT", diff --git a/muk_web_utils/static/src/js/fields/copy.js b/muk_web_utils/static/src/js/fields/copy.js index 07553b8..63c3f9e 100644 --- a/muk_web_utils/static/src/js/fields/copy.js +++ b/muk_web_utils/static/src/js/fields/copy.js @@ -43,34 +43,6 @@ var BinaryFileCopy = fields.FieldBinaryFile.extend({ var def = this.value && this.res_id ? this._fetchShareUrl() : $.when(); return $.when(this._super.apply(this, arguments), def); }, - start: function() { - var self = this; - var res = this._super.apply(this, arguments); - var $clipboardBtn = this.$('.mk_copy_binary'); - this.clipboard = new ClipboardJS($clipboardBtn[0], { - text: function (trigger) { - return self.shareUrl; - }, - container: self.$el[0] - }); - this.clipboard.on('success', function (event) { - _.defer(function () { - $clipboardBtn.tooltip('show'); - _.delay(function () { - $clipboardBtn.tooltip('hide'); - }, 800); - }); - }); - $clipboardBtn.click(function(event) { - event.stopPropagation(); - }); - $clipboardBtn.tooltip({ - title: _t('Link Copied!'), - trigger: 'manual', - placement: 'bottom' - }); - return res; - }, _fetchShareUrl: function() { var self = this; var def = $.Deferred(); @@ -110,15 +82,44 @@ var BinaryFileCopy = fields.FieldBinaryFile.extend({ def.resolve(); } return def; + }, + _setUpClipboad: function() { + var self = this; + var $clipboardBtn = this.$('.mk_copy_binary'); + this.clipboard = new ClipboardJS($clipboardBtn[0], { + text: function (trigger) { + return self.shareUrl; + }, + container: self.$el[0] + }); + this.clipboard.on('success', function (event) { + _.defer(function () { + $clipboardBtn.tooltip('show'); + _.delay(function () { + $clipboardBtn.tooltip('hide'); + }, 800); + }); + }); + $clipboardBtn.click(function(event) { + event.stopPropagation(); + }); + $clipboardBtn.tooltip({ + title: _t('Link Copied!'), + trigger: 'manual', + placement: 'bottom' + }); }, _renderReadonly: function () { this._super.apply(this, arguments); this.$el.addClass('mk_field_copy'); this.$el.append($(QWeb.render('muk_web_utils.BinaryFieldCopy'))); + this._setUpClipboad(); }, destroy: function () { this._super.apply(this, arguments); - this.clipboard.destroy(); + if (this.clipboard) { + this.clipboard.destroy(); + } }, });