You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.9 KiB

  1. /**********************************************************************************
  2. *
  3. * Copyright (C) 2017 MuK IT GmbH
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as
  7. * published by the Free Software Foundation, either version 3 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. **********************************************************************************/
  19. odoo.define('muk_preview_markdown.PreviewContentImage', function (require) {
  20. "use strict";
  21. var core = require('web.core');
  22. var ajax = require('web.ajax');
  23. var utils = require('web.utils');
  24. var session = require('web.session');
  25. var registry = require('muk_preview.registry');
  26. var AbstractPreviewContent = require('muk_preview.AbstractPreviewContent');
  27. var QWeb = core.qweb;
  28. var _t = core._t;
  29. var PreviewContentImage = AbstractPreviewContent.extend({
  30. template: "muk_preview.PreviewContentImage",
  31. cssLibs: [
  32. '/muk_web_preview_image/static/lib/viewer/viewer.css',
  33. ],
  34. jsLibs: [
  35. '/muk_web_preview_image/static/lib/viewer/viewer.js',
  36. '/muk_web_preview_image/static/lib/viewer/jquery-viewer.js',
  37. ],
  38. renderPreviewContent: function() {
  39. this.$('img').viewer({
  40. inline: true,
  41. button: false,
  42. navbar: false,
  43. title: false,
  44. toolbar: {
  45. zoomIn: 1,
  46. zoomOut: 1,
  47. oneToOne: 1,
  48. reset: 1,
  49. prev: 0,
  50. next: 0,
  51. play: {
  52. show: 1,
  53. size: 'large',
  54. },
  55. rotateLeft: 1,
  56. rotateRight: 1,
  57. flipHorizontal: 1,
  58. flipVertical: 1,
  59. },
  60. });
  61. },
  62. downloadable: true,
  63. printable: true,
  64. });
  65. _.each([
  66. 'cod', 'ras', 'fif', 'gif', 'ief', 'jpeg', 'jpg', 'jpe', 'png', 'tiff',
  67. 'tif', 'mcf', 'wbmp', 'fh4', 'fh5', 'fhc', 'ico', 'pnm', 'pbm', 'pgm',
  68. 'ppm', 'rgb', 'xwd', 'xbm', 'xpm'
  69. ], function(extension) {
  70. registry.add(extension, PreviewContentImage);
  71. registry.add("." + extension, PreviewContentImage);
  72. });
  73. _.each([
  74. 'image/cis-cod', 'image/cmu-raster', 'image/fif', 'image/gif', 'image/ief',
  75. 'image/png', 'image/tiff', 'image/vasa', 'image/vnd.wap.wbmp', 'image/x-freehand',
  76. 'image/x-portable-anymap', 'image/x-portable-bitmap', 'image/x-portable-graymap',
  77. 'image/x-portable-pixmap', 'image/x-rgb', 'image/x-windowdump', 'image/x-xbitmap',
  78. 'image/jpeg', 'image/x-icon', 'image/x-xpixmap'
  79. ], function(mimetype) {
  80. registry.add(mimetype, PreviewContentImage);
  81. });
  82. return PreviewContentImage;
  83. });