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.

71 lines
2.5 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.PreviewDialog', function (require) {
  20. "use strict";
  21. var core = require('web.core');
  22. var utils = require('web.utils');
  23. var session = require('web.session');
  24. var PreviewManager = require('muk_preview.PreviewManager');
  25. var QWeb = core.qweb;
  26. var _t = core._t;
  27. var PreviewDialog = PreviewManager.extend({
  28. template: "muk_preview.PreviewDialog",
  29. events: _.extend({}, PreviewManager.prototype.events, {
  30. 'click .mk_preview_maximize_btn': '_onMaximizeClick',
  31. 'click .mk_preview_minimize_btn': '_onMinimizeClick',
  32. }),
  33. start: function () {
  34. this.$el.modal('show');
  35. this.$el.on('hidden.bs.modal', _.bind(this._onDestroy, this));
  36. this.$('[data-toggle="tooltip"]').tooltip({delay: 0});
  37. return this._super.apply(this, arguments);
  38. },
  39. destroy: function () {
  40. if (this.isDestroyed()) {
  41. return;
  42. }
  43. this.$el.modal('hide');
  44. this.$el.remove();
  45. return this._super.apply(this, arguments);
  46. },
  47. _renderPreview: function (element) {
  48. this._super.apply(this, arguments);
  49. this.$('.modal-title').text(this.activeFile.filename || "Preview");
  50. },
  51. _onDestroy: function () {
  52. this.destroy();
  53. },
  54. _onMaximizeClick: function(event) {
  55. this.$('.mk_preview_dialog').addClass("mk_preview_maximize");
  56. this._notifyPreviewResize();
  57. },
  58. _onMinimizeClick: function(event) {
  59. this.$('.mk_preview_dialog').removeClass("mk_preview_maximize");
  60. this._notifyPreviewResize();
  61. },
  62. });
  63. return PreviewDialog;
  64. });