فهرست منبع

AMBARI-16678. JS error on resize ASW and assign master popup (alexantonenko)

Alex Antonenko 9 سال پیش
والد
کامیت
2d8f3f2ed5
2فایلهای تغییر یافته به همراه10 افزوده شده و 10 حذف شده
  1. 1 1
      ambari-web/app/styles/application.less
  2. 9 9
      ambari-web/app/views/common/modal_popup.js

+ 1 - 1
ambari-web/app/styles/application.less

@@ -5040,7 +5040,7 @@ i.icon-asterisks {
   //when screen is wide, the modal width is fixed
   .full-width-modal {
     .modal{
-      width: 1155px;
+      width: 1180px;
       margin: -350px 0 0 -583px;
     }
   }

+ 9 - 9
ambari-web/app/views/common/modal_popup.js

@@ -71,22 +71,21 @@ App.ModalPopup = Ember.View.extend({
     this.fitZIndex();
     var firstInputElement = this.$('#modal').find(':input').not(':disabled, .no-autofocus').first();
     this.focusElement(firstInputElement);
-    this.resizeHandler();
-    $(window).on('resize', this.resizeHandler.bind(this));
+    this.subscribeResize();
   },
 
-  resizeHandler: function() {
-    if (this.autoHeight && !$.mocho) {
-      var block = this.$().find('#modal > .modal-body').first();
-      if(block.offset()) {
-        block.css('max-height', $(window).height() - block.offset().top - this.marginBottom + $(window).scrollTop()); // fix popup height
-      }
+  subscribeResize: function() {
+    if (this.get('autoHeight') && !$.mocho) {
+      this.fitHeight();
+      $(window).on('resize', this.fitHeight.bind(this));
     }
   },
 
   willDestroyElement: function() {
     this.$().find('#modal').off('enter-key-pressed').off('escape-key-pressed');
-    $(window).off('resize', this.resizeHandler);
+    if (this.get('autoHeight') && !$.mocho) {
+      $(window).off('resize', this.fitHeight);
+    }
   },
 
   escapeKeyPressed: function (event) {
@@ -132,6 +131,7 @@ App.ModalPopup = Ember.View.extend({
   },
 
   fitHeight: function () {
+    if (this.get('state') === 'destroyed') return;
     var popup = this.$().find('#modal');
     var block = this.$().find('#modal > .modal-body');
     var wh = $(window).height();