diff --git a/muk_web_preview/__manifest__.py b/muk_web_preview/__manifest__.py index 206587a..1e13dfd 100644 --- a/muk_web_preview/__manifest__.py +++ b/muk_web_preview/__manifest__.py @@ -29,7 +29,7 @@ - Portable Document Format (.pdf) - Open Document (.odt, .odp, .ods, .otp) """, - "version": "10.0.1.0.1", + "version": "10.0.1.0.2", "category": "Extra Tools", "license": "AGPL-3", "website": "http://www.mukit.at", diff --git a/muk_web_preview/static/src/js/preview_generator.js b/muk_web_preview/static/src/js/preview_generator.js index 2b4b944..a56375e 100644 --- a/muk_web_preview/static/src/js/preview_generator.js +++ b/muk_web_preview/static/src/js/preview_generator.js @@ -27,45 +27,13 @@ var PreviewHandler = require('muk_preview.PreviewHandler'); var QWeb = core.qweb; var _t = core._t; -var PDFHandler = PreviewHandler.extend({ - checkExtension: function(extension) { - return ['.pdf', 'pdf'].includes(extension); - }, - checkType: function(mimetype) { - return ['application/pdf'].includes(mimetype); - }, - createHtml: function(url, mimetype, extension, title) { - var result = $.Deferred(); - var viewerUrlTempalte = _.template('/muk_web_preview/static/lib/ViewerJS/index.html#<%= url %>'); - result.resolve($(QWeb.render('ViewerJSFrame', {url: viewerUrlTempalte({url})}))); - return $.when(result); - }, -}); - -var OpenOfficeHandler = PreviewHandler.extend({ - checkExtension: function(extension) { - return ['.odt', '.odp', '.ods', '.fodt', '.ott', '.fodp', '.otp', '.fods', '.ots', - 'odt', 'odp', 'ods', 'fodt', 'ott', 'fodp', 'otp', 'fods', 'ots'].includes(extension); - }, - checkType: function(mimetype) { - return ['application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.presentation', - 'application/vnd.oasis.opendocument.spreadsheet'].includes(mimetype); - }, - createHtml: function(url, mimetype, extension, title) { - var result = $.Deferred(); - var viewerUrlTempalte = _.template('/muk_web_preview/static/lib/ViewerJS/index.html#<%= url %>'); - result.resolve($(QWeb.render('ViewerJSFrame', {url: viewerUrlTempalte({url})}))); - return $.when(result); - }, -}); - var PreviewGenerator = core.Class.extend({ handler: {}, init: function(widget, additional_handler) { this.widget = widget; this.handler = _.extend(this.handler, { - "PDFHandler": new PDFHandler(widget), - "OpenOfficeHandler": new OpenOfficeHandler(widget) + "PDFHandler": new PreviewHandler.PDFHandler(widget), + "OpenOfficeHandler": new PreviewHandler.OpenOfficeHandler(widget) }); this.handler = _.extend(this.handler, additional_handler); }, diff --git a/muk_web_preview/static/src/js/preview_handler.js b/muk_web_preview/static/src/js/preview_handler.js index c6d0d0f..05af3c8 100644 --- a/muk_web_preview/static/src/js/preview_handler.js +++ b/muk_web_preview/static/src/js/preview_handler.js @@ -22,7 +22,10 @@ odoo.define('muk_preview.PreviewHandler', function (require) { var core = require('web.core'); -var Handler = core.Class.extend({ +var QWeb = core.qweb; +var _t = core._t; + +var BaseHandler = core.Class.extend({ init: function(widget) { this.widget = widget; }, @@ -37,6 +40,42 @@ var Handler = core.Class.extend({ }, }); -return Handler; +var PDFHandler = BaseHandler.extend({ + checkExtension: function(extension) { + return ['.pdf', 'pdf'].includes(extension); + }, + checkType: function(mimetype) { + return ['application/pdf'].includes(mimetype); + }, + createHtml: function(url, mimetype, extension, title) { + var result = $.Deferred(); + var viewerUrlTempalte = _.template('/muk_web_preview/static/lib/ViewerJS/index.html#<%= url %>'); + result.resolve($(QWeb.render('ViewerJSFrame', {url: viewerUrlTempalte({url})}))); + return $.when(result); + }, +}); + +var OpenOfficeHandler = BaseHandler.extend({ + checkExtension: function(extension) { + return ['.odt', '.odp', '.ods', '.fodt', '.ott', '.fodp', '.otp', '.fods', '.ots', + 'odt', 'odp', 'ods', 'fodt', 'ott', 'fodp', 'otp', 'fods', 'ots'].includes(extension); + }, + checkType: function(mimetype) { + return ['application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.presentation', + 'application/vnd.oasis.opendocument.spreadsheet'].includes(mimetype); + }, + createHtml: function(url, mimetype, extension, title) { + var result = $.Deferred(); + var viewerUrlTempalte = _.template('/muk_web_preview/static/lib/ViewerJS/index.html#<%= url %>'); + result.resolve($(QWeb.render('ViewerJSFrame', {url: viewerUrlTempalte({url})}))); + return $.when(result); + }, +}); + +return { + BaseHandler: BaseHandler, + PDFHandler: PDFHandler, + OpenOfficeHandler: OpenOfficeHandler, +} }); \ No newline at end of file diff --git a/muk_web_preview/static/src/less/preview_content.less b/muk_web_preview/static/src/less/preview_content.less index f6577b1..d3cadf7 100644 --- a/muk_web_preview/static/src/less/preview_content.less +++ b/muk_web_preview/static/src/less/preview_content.less @@ -56,3 +56,110 @@ } } +/* Based on a CodePen Snippet by Dave McCarthy */ +.loader { + height: 20px; + width: 250px; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + margin: auto; + + .loader--dot { + animation-name: loader; + animation-timing-function: ease-in-out; + animation-duration: 3s; + animation-iteration-count: infinite; + height: 20px; + width: 20px; + border-radius: 100%; + background-color: black; + position: absolute; + border: 2px solid white; + } + + .loader--dot:first-child { + background-color: #8cc759; + animation-delay: 0.5s; + } + + .loader--dot:nth-child(2) { + background-color: #8c6daf; + animation-delay: 0.4s; + } + + .loader--dot:nth-child(3) { + background-color: #ef5d74; + animation-delay: 0.3s; + } + + .loader--dot:nth-child(4) { + background-color: #f9a74b; + animation-delay: 0.2s; + } + + .loader--dot:nth-child(5) { + background-color: #60beeb; + animation-delay: 0.1s; + } + + .loader--dot:nth-child(6) { + background-color: #fbef5a; + animation-delay: 0s; + } + + .loader--text { + position: absolute; + top: 200%; + left: 0; + right: 0; + width: 4rem; + margin: auto; + } + + .loader--text:after { + content: "Loading"; + font-weight: bold; + animation-name: loading-text; + animation-duration: 3s; + animation-iteration-count: infinite; + } + + @keyframes loader { + 15% { + transform: translateX(0); + } + + 45% { + transform: translateX(230px); + } + + 65% { + transform: translateX(230px); + } + + 95% { + transform: translateX(0); + } + } + + @keyframes loading-text { + 0% { + content: "Loading"; + } + + 25% { + content: "Loading."; + } + + 50% { + content: "Loading.."; + } + + 75% { + content: "Loading..."; + } + } +} diff --git a/muk_web_preview_attachment/__manifest__.py b/muk_web_preview_attachment/__manifest__.py index a3c477f..6d07240 100644 --- a/muk_web_preview_attachment/__manifest__.py +++ b/muk_web_preview_attachment/__manifest__.py @@ -26,7 +26,7 @@ Adds a button to the Attachment Sidebar to preview the content directly in the browser.. """, - "version": "10.0.1.0.0", + "version": "10.0.1.0.1", "category": "Extra Tools", "license": "AGPL-3", "website": "http://www.mukit.at", @@ -36,6 +36,14 @@ ], "depends": [ "muk_web_preview", + "muk_web_preview_audio", + "muk_web_preview_csv", + "muk_web_preview_image", + "muk_web_preview_mail", + "muk_web_preview_msoffice", + "muk_web_preview_text", + "muk_web_preview_vector", + "muk_web_preview_video", ], "data": [ "template/assets.xml", @@ -55,4 +63,4 @@ "application": False, "installable": True, -} +} \ No newline at end of file diff --git a/muk_web_preview_audio/__manifest__.py b/muk_web_preview_audio/__manifest__.py index dfb2b63..4734cbc 100644 --- a/muk_web_preview_audio/__manifest__.py +++ b/muk_web_preview_audio/__manifest__.py @@ -29,7 +29,7 @@ - Ogg Theora Vorbis (*.ogg, audio/ogg) - MP3 (*.mp3, audio/mpeg) """, - "version": "10.0.1.0.1", + "version": "10.0.1.0.2", "category": "Extra Tools", "license": "AGPL-3", "website": "http://www.mukit.at", diff --git a/muk_web_preview_audio/static/src/js/preview_generator.js b/muk_web_preview_audio/static/src/js/preview_generator.js index d9bdba1..f0c9a4b 100644 --- a/muk_web_preview_audio/static/src/js/preview_generator.js +++ b/muk_web_preview_audio/static/src/js/preview_generator.js @@ -22,44 +22,17 @@ odoo.define('muk_preview_audio.PreviewGenerator', function (require) { var core = require('web.core'); -var PreviewHandler = require('muk_preview.PreviewHandler'); var PreviewGenerator = require('muk_preview.PreviewGenerator'); +var PreviewHandler = require('muk_preview_audio.PreviewHandler'); var QWeb = core.qweb; var _t = core._t; -var AudioHandler = PreviewHandler.extend({ - mimetypeMap: { - '.wav': 'audio/wav', - '.ogg': 'audio/ogg', - '.mp3': 'audio/mpeg', - 'wav': 'audio/wav', - 'ogg': 'audio/ogg', - 'mp3': 'audio/mpeg', - }, - checkExtension: function(extension) { - return ['.wav', '.ogg', '.mp3', 'wav', 'ogg', 'mp3'].includes(extension); - }, - checkType: function(mimetype) { - return ['audio/wav', ' audio/ogg', 'audio/mpeg'].includes(mimetype); - }, - createHtml: function(url, mimetype, extension, title) { - var result = $.Deferred(); - if(!mimetype || mimetype === 'application/octet-stream') { - mimetype = this.mimetypeMap[extension]; - } - var $content = $(QWeb.render('AudioHTMLContent', {url: url, type: mimetype, title: title})); - var visualizer = new Visualizer($content.find('audio'), $content.find('.visualizer'), $content.find('canvas')); - result.resolve($content); - return $.when(result); - }, -}); - PreviewGenerator.include({ init: function(widget, additional_handler) { this._super(widget, additional_handler); this.handler = _.extend(this.handler, { - "AudioHandler": new AudioHandler(widget), + "AudioHandler": new PreviewHandler.AudioHandler(widget), }); }, }); diff --git a/muk_web_preview_audio/static/src/js/preview_handler.js b/muk_web_preview_audio/static/src/js/preview_handler.js new file mode 100644 index 0000000..bf98de2 --- /dev/null +++ b/muk_web_preview_audio/static/src/js/preview_handler.js @@ -0,0 +1,61 @@ +/********************************************************************************** +* +* Copyright (C) 2017 MuK IT GmbH +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License as +* published by the Free Software Foundation, either version 3 of the +* License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +* +**********************************************************************************/ + +odoo.define('muk_preview_audio.PreviewHandler', function (require) { +"use strict"; + +var core = require('web.core'); + +var PreviewHandler = require('muk_preview.PreviewHandler'); + +var QWeb = core.qweb; +var _t = core._t; + +var AudioHandler = PreviewHandler.BaseHandler.extend({ + mimetypeMap: { + '.wav': 'audio/wav', + '.ogg': 'audio/ogg', + '.mp3': 'audio/mpeg', + 'wav': 'audio/wav', + 'ogg': 'audio/ogg', + 'mp3': 'audio/mpeg', + }, + checkExtension: function(extension) { + return ['.wav', '.ogg', '.mp3', 'wav', 'ogg', 'mp3'].includes(extension); + }, + checkType: function(mimetype) { + return ['audio/wav', ' audio/ogg', 'audio/mpeg'].includes(mimetype); + }, + createHtml: function(url, mimetype, extension, title) { + var result = $.Deferred(); + if(!mimetype || mimetype === 'application/octet-stream') { + mimetype = this.mimetypeMap[extension]; + } + var $content = $(QWeb.render('AudioHTMLContent', {url: url, type: mimetype, title: title})); + var visualizer = new Visualizer($content.find('audio'), $content.find('.visualizer'), $content.find('canvas')); + result.resolve($content); + return $.when(result); + }, +}); + +return { + AudioHandler: AudioHandler, +} + +}); \ No newline at end of file diff --git a/muk_web_preview_audio/template/assets.xml b/muk_web_preview_audio/template/assets.xml index fc691be..8014ad0 100644 --- a/muk_web_preview_audio/template/assets.xml +++ b/muk_web_preview_audio/template/assets.xml @@ -23,6 +23,7 @@