mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-26 10:28:40 -06:00
first set of fix in js
This commit is contained in:
parent
e64c6fd2f7
commit
a60267bfcd
@ -34,8 +34,7 @@ odoo.define('attachment_preview.attachment_preview', function(require) {
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
var AttachementPreview = core.Class.extend({
|
||||
show_preview : function(
|
||||
function show_preview(
|
||||
attachment_id, attachment_url, attachment_extension,
|
||||
attachment_title)
|
||||
{
|
||||
@ -45,9 +44,9 @@ odoo.define('attachment_preview.attachment_preview', function(require) {
|
||||
'&title=' + encodeURIComponent(attachment_title) +
|
||||
'&ext=.' + encodeURIComponent(attachment_extension);
|
||||
window.open(url);
|
||||
},
|
||||
};
|
||||
|
||||
can_preview : function(extension)
|
||||
function can_preview(extension)
|
||||
{
|
||||
return jQuery.inArray(
|
||||
extension,
|
||||
@ -55,8 +54,7 @@ odoo.define('attachment_preview.attachment_preview', function(require) {
|
||||
'odt', 'odp', 'ods', 'fodt', 'pdf', 'ott', 'fodp', 'otp',
|
||||
'fods', 'ots'
|
||||
]) > -1;
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Sidebar.include({
|
||||
on_attachments_loaded: function(attachments)
|
||||
@ -79,7 +77,7 @@ odoo.define('attachment_preview.attachment_preview', function(require) {
|
||||
attachment_title = $target.attr('data-original-title');
|
||||
if(attachment_extension)
|
||||
{
|
||||
AttachementPreview.show_preview(
|
||||
show_preview(
|
||||
attachment_id, attachment_url, attachment_extension,
|
||||
attachment_title);
|
||||
}
|
||||
@ -89,7 +87,7 @@ odoo.define('attachment_preview.attachment_preview', function(require) {
|
||||
'get_attachment_extension', [attachment_id], {})
|
||||
.then(function(extension)
|
||||
{
|
||||
AttachementPreview.show_preview(
|
||||
show_preview(
|
||||
attachment_id, attachment_url, extension);
|
||||
});
|
||||
}
|
||||
@ -115,7 +113,7 @@ odoo.define('attachment_preview.attachment_preview', function(require) {
|
||||
var $element = jQuery(
|
||||
'a.oe-sidebar-attachment-preview[data-id="'
|
||||
+ id + '"]');
|
||||
if(AttachementPreview.can_preview(extension))
|
||||
if(can_preview(extension))
|
||||
{
|
||||
$element.attr('data-extension', extension);
|
||||
}
|
||||
@ -146,7 +144,7 @@ odoo.define('attachment_preview.attachment_preview', function(require) {
|
||||
var $target = jQuery(e.currentTarget),
|
||||
attachment_id = parseInt($target.attr('data-id')),
|
||||
attachment_extension = $target.attr('data-extension');
|
||||
AttachementPreview.show_preview(
|
||||
show_preview(
|
||||
attachment_id,
|
||||
$target.siblings('a').attr('href'),
|
||||
attachment_extension,
|
||||
@ -172,7 +170,7 @@ odoo.define('attachment_preview.attachment_preview', function(require) {
|
||||
{
|
||||
var $element = $elements.filter(
|
||||
'[data-id="' + id + '"]');
|
||||
if(AttachementPreview.can_preview(extension))
|
||||
if(can_preview(extension))
|
||||
{
|
||||
$element.attr('data-extension', extension);
|
||||
}
|
||||
@ -225,11 +223,11 @@ odoo.define('attachment_preview.attachment_preview', function(require) {
|
||||
_(extensions).each(function(extension)
|
||||
{
|
||||
var $element = self.$el.find('.oe-binary-preview');
|
||||
if(AttachementPreview.can_preview(extension))
|
||||
if(can_preview(extension))
|
||||
{
|
||||
$element.click(function()
|
||||
{
|
||||
AttachementPreview.show_preview(
|
||||
show_preview(
|
||||
null,
|
||||
_.str.sprintf(
|
||||
'/web/binary/saveas?session_id=%s&model=%s&field=%s&id=%d',
|
||||
|
Loading…
Reference in New Issue
Block a user