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.

66 lines
1.9 KiB

  1. odoo.define('web_dialog_size.web_dialog_size', function (require) {
  2. 'use strict';
  3. var rpc = require('web.rpc');
  4. var Dialog = require('web.Dialog');
  5. var config = rpc.query({
  6. model: 'ir.config_parameter',
  7. method: 'get_web_dialog_size_config',
  8. });
  9. Dialog.include({
  10. willStart: function () {
  11. var self = this;
  12. return this._super.apply(this, arguments).then(function () {
  13. self.$modal.find('.dialog_button_extend').on('click', self.proxy('_extending'));
  14. self.$modal.find('.dialog_button_restore').on('click', self.proxy('_restore'));
  15. return config.done(function(r) {
  16. if (r.default_maximize) {
  17. self._extending();
  18. } else {
  19. self._restore();
  20. }
  21. });
  22. });
  23. },
  24. opened: function(handler) {
  25. return this._super.apply(this, arguments).then(function(){
  26. if (this.$modal) {
  27. this.$modal.draggable({
  28. handle: '.modal-header',
  29. helper: false
  30. });
  31. }
  32. }.bind(this));
  33. },
  34. close: function() {
  35. if (this.$modal) {
  36. var draggable = this.$modal.draggable("instance");
  37. if (draggable) {
  38. this.$modal.draggable("destroy");
  39. }
  40. }
  41. return this._super.apply(this, arguments);
  42. },
  43. _extending: function() {
  44. var dialog = this.$modal.find('.modal-dialog');
  45. dialog.addClass('dialog_full_screen');
  46. dialog.find('.dialog_button_extend').hide();
  47. dialog.find('.dialog_button_restore').show();
  48. },
  49. _restore: function() {
  50. var dialog = this.$modal.find('.modal-dialog');
  51. dialog.removeClass('dialog_full_screen');
  52. dialog.find('.dialog_button_restore').hide();
  53. dialog.find('.dialog_button_extend').show();
  54. },
  55. });
  56. });