Browse Source

publish muk_web_utils - 12.0

pull/35/head
MuK IT GmbH 6 years ago
parent
commit
2f7c541a8e
  1. 2
      muk_web_utils/__manifest__.py
  2. 59
      muk_web_utils/static/src/js/fields/copy.js

2
muk_web_utils/__manifest__.py

@ -20,7 +20,7 @@
{ {
"name": "MuK Web Utils", "name": "MuK Web Utils",
"summary": """Utility Features""", "summary": """Utility Features""",
"version": "12.0.2.4.0",
"version": "12.0.2.4.1",
"category": "Extra Tools", "category": "Extra Tools",
"license": "AGPL-3", "license": "AGPL-3",
"author": "MuK IT", "author": "MuK IT",

59
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(); var def = this.value && this.res_id ? this._fetchShareUrl() : $.when();
return $.when(this._super.apply(this, arguments), def); 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() { _fetchShareUrl: function() {
var self = this; var self = this;
var def = $.Deferred(); var def = $.Deferred();
@ -110,15 +82,44 @@ var BinaryFileCopy = fields.FieldBinaryFile.extend({
def.resolve(); def.resolve();
} }
return def; 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 () { _renderReadonly: function () {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.$el.addClass('mk_field_copy'); this.$el.addClass('mk_field_copy');
this.$el.append($(QWeb.render('muk_web_utils.BinaryFieldCopy'))); this.$el.append($(QWeb.render('muk_web_utils.BinaryFieldCopy')));
this._setUpClipboad();
}, },
destroy: function () { destroy: function () {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.clipboard.destroy();
if (this.clipboard) {
this.clipboard.destroy();
}
}, },
}); });

Loading…
Cancel
Save