You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2016/05/16 10:52:39 UTC
[1/2] ambari git commit: AMBARI-16679. Redirect URLs from background
ops / host component logs to LogSearch UI do not work (alexantonenko)
Repository: ambari
Updated Branches:
refs/heads/branch-2.4 a2555378f -> 8fbfd89f6
AMBARI-16679. Redirect URLs from background ops / host component logs to LogSearch UI do not work (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8fbfd89f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8fbfd89f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8fbfd89f
Branch: refs/heads/branch-2.4
Commit: 8fbfd89f652d66522e7e9f77138a6d62bc5bfea8
Parents: 2d8f3f2
Author: Alex Antonenko <hi...@gmail.com>
Authored: Mon May 16 13:08:47 2016 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Mon May 16 13:52:34 2016 +0300
----------------------------------------------------------------------
.../app/controllers/global/update_controller.js | 30 ++++-
.../templates/common/host_progress_popup.hbs | 40 ++++---
ambari-web/app/templates/main/host/logs.hbs | 10 +-
ambari-web/app/views.js | 1 +
.../common/host_progress_popup_body_view.js | 58 ++++++---
.../app/views/common/log_search_ui_link_view.js | 40 +++++++
.../views/common/modal_popups/log_tail_popup.js | 2 +-
ambari-web/app/views/main/host/logs_view.js | 16 +--
.../host_progress_popup_body_view_test.js | 117 ++++++++++++++++++-
9 files changed, 261 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/8fbfd89f/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index 47ec677..f2ca75b 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -643,6 +643,34 @@ App.UpdateController = Em.Controller.extend({
updateWizardWatcher: function(callback) {
App.router.get('wizardWatcherController').getUser().complete(callback);
- }
+ },
+
+ /**
+ * Request to fetch logging info for specified host.
+ *
+ * @method updateLogging
+ * @param {string} hostName
+ * @param {string[]|boolean} fields additional fields to request e.g. ['field1', 'field2']
+ * @param {function} callback execute on when request succeed, json response will be passed to first argument
+ * @returns {$.Deferred.promise()}
+ */
+ updateLogging: function(hostName, fields, callback) {
+ var flds = !!fields ? "," + fields.join(',') : "" ;
+
+ return App.ajax.send({
+ name: 'host.logging',
+ sender: this,
+ data: {
+ hostName: hostName,
+ callback: callback,
+ fields: flds
+ },
+ success: 'updateLoggingSuccess'
+ });
+ },
+ updateLoggingSuccess: function(data, opt, params) {
+ var clbk = params.callback || function() {};
+ clbk(data);
+ }
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/8fbfd89f/ambari-web/app/templates/common/host_progress_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/host_progress_popup.hbs b/ambari-web/app/templates/common/host_progress_popup.hbs
index c457738..223d202 100644
--- a/ambari-web/app/templates/common/host_progress_popup.hbs
+++ b/ambari-web/app/templates/common/host_progress_popup.hbs
@@ -161,22 +161,26 @@
</div>
</div>
<div id="host-log">
- {{#if view.isTasksEmptyList}}
- <div class="log-list-wrap">{{t hostPopup.noTasksToShow}}</div>
- {{else}}
- {{#each taskInfo in view.tasks}}
- <div {{action toggleTaskLog taskInfo}} {{bindAttr class="taskInfo.isVisible::hidden :log-list-wrap"}}>
- <div class="task-list-line-cursor">
- <div class="operation-name-icon-wrap">
- {{view statusIcon servicesInfoBinding="taskInfo"}}
- <a href="#">
- {{taskInfo.commandDetail}}
- </a>
+ {{#if view.hostInfoLoaded}}
+ {{#if view.isTasksEmptyList}}
+ <div class="log-list-wrap">{{t hostPopup.noTasksToShow}}</div>
+ {{else}}
+ {{#each taskInfo in view.tasks}}
+ <div {{action toggleTaskLog taskInfo}} {{bindAttr class="taskInfo.isVisible::hidden :log-list-wrap"}}>
+ <div class="task-list-line-cursor">
+ <div class="operation-name-icon-wrap">
+ {{view statusIcon servicesInfoBinding="taskInfo"}}
+ <a href="#">
+ {{taskInfo.commandDetail}}
+ </a>
+ </div>
+ <div class="show-details"><i class="icon-caret-right"></i></div>
</div>
- <div class="show-details"><i class="icon-caret-right"></i></div>
</div>
- </div>
- {{/each}}
+ {{/each}}
+ {{/if}}
+ {{else}}
+ {{view App.SpinnerView}}
{{/if}}
</div>
</div>
@@ -256,9 +260,11 @@
<p {{bindAttr class="view.isClipBoardActive:hidden"}}>
<span class="text-bold">{{t common.file}}: </span>
<span class="text-bold muted">{{hostLog.fileName}}</span>
- <a class="pull-right" {{bindAttr href="hostLog.url"}} target="_blank">
- <i class="icon-external-link"></i>
- {{t popup.logTail.openInLogSearch}}</a>
+ {{#view App.LogSearchUILinkView linkQueryParamsBinding="hostLog.linkTail" tagName="span"}}
+ <a {{bindAttr href="view.formatedLink" class=":pull-right view.isLodaded::disabled"}} target="_blank">
+ <i class="icon-external-link"></i>
+ {{t popup.logTail.openInLogSearch}}</a>
+ {{/view}}
</p>
<div {{bindAttr class="view.isClipBoardActive:hidden"}}>
{{view view.logTailView contentBinding="hostLog"}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/8fbfd89f/ambari-web/app/templates/main/host/logs.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/logs.hbs b/ambari-web/app/templates/main/host/logs.hbs
index 9728417..c553081 100644
--- a/ambari-web/app/templates/main/host/logs.hbs
+++ b/ambari-web/app/templates/main/host/logs.hbs
@@ -39,10 +39,12 @@
{{#each file in row.fileNamesObject}}
<p>
<a {{action openLogFile row file.filePath target="view.parentView"}} href="#" rel="log-file-name-tooltip" {{bindAttr data-original-title="file.filePath"}}>{{file.fileName}}</a>
- <a {{bindAttr href="file.url"}} target="_blank" rel="log-file-name-tooltip" {{translateAttr title="popup.logTail.openInLogSearch"}} class="pull-right external-link">
- <i class="icon-external-link"></i>
- {{t popup.logTail.openInLogSearch}}
- </a>
+ {{#view App.LogSearchUILinkView linkQueryParamsBinding="file.linkTail" tagName="span"}}
+ <a {{bindAttr href="view.formatedLink"}} target="_blank" rel="log-file-name-tooltip" {{translateAttr title="popup.logTail.openInLogSearch"}} class="pull-right external-link">
+ <i class="icon-external-link"></i>
+ {{t popup.logTail.openInLogSearch}}
+ </a>
+ {{/view}}
</p>
{{/each}}
</td>
http://git-wip-us.apache.org/repos/asf/ambari/blob/8fbfd89f/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index 35f3969..7127420 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -20,6 +20,7 @@
// load all views here
require('views/application');
+require('views/common/log_search_ui_link_view');
require('views/common/log_file_search_view');
require('views/common/log_tail_view');
require('views/common/global/spinner');
http://git-wip-us.apache.org/repos/asf/ambari/blob/8fbfd89f/ambari-web/app/views/common/host_progress_popup_body_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/host_progress_popup_body_view.js b/ambari-web/app/views/common/host_progress_popup_body_view.js
index 96678de..19fabd0 100644
--- a/ambari-web/app/views/common/host_progress_popup_body_view.js
+++ b/ambari-web/app/views/common/host_progress_popup_body_view.js
@@ -95,6 +95,14 @@ App.HostProgressPopupBodyView = App.TableView.extend({
isClipBoardActive: false,
/**
+ * Determines that host information become loaded and mapped with <code>App.hostsMapper</code>.
+ * This property play in only when Log Search service installed.
+ *
+ * @type {boolean}
+ */
+ hostInfoLoaded: true,
+
+ /**
* Alias for <code>controller.hosts</code>
*
* @type {wrappedHost[]}
@@ -835,11 +843,42 @@ App.HostProgressPopupBodyView = App.TableView.extend({
this.set('currentHost.tasks', tasksInfo);
this.set("parentView.isHostListHidden", true);
this.set("parentView.isTaskListHidden", false);
+ this.preloadHostModel(Em.getWithDefault(event.context || {}, 'name', false));
$(".modal").scrollTop(0);
$(".modal-body").scrollTop(0);
},
/**
+ * Will add <code>App.Host</code> model with relevant host info by specified host name only when it missed
+ * and Log Search service installed.
+ * This update needed to get actual status of logs for components located on this host and get appropriate model
+ * for navigation to hosts/:host_id/logs route.
+ *
+ * @method preloadHostModel
+ * @param {string} hostName host name to get info
+ */
+ preloadHostModel: function(hostName) {
+ var self = this,
+ fields;
+ if (!hostName) {
+ self.set('hostInfoLoaded', true);
+ return;
+ }
+ if (this.get('isLogSearchInstalled') && App.get('supports.logSearch') && !App.Host.find().someProperty('hostName', hostName)) {
+ this.set('hostInfoLoaded', false);
+ fields = ['stack_versions/repository_versions/RepositoryVersions/repository_version',
+ 'host_components/HostRoles/host_name'];
+ App.router.get('updateController').updateLogging(hostName, fields, function(data) {
+ App.hostsMapper.map({ items: [data] });
+ }).always(function() {
+ self.set('hostInfoLoaded', true);
+ });
+ } else {
+ self.set('hostInfoLoaded', true);
+ }
+ },
+
+ /**
* @method stopRebalanceHDFS
* @returns {App.ModalPopup}
*/
@@ -956,6 +995,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({
componentName,
hostName,
logFile,
+ linkTailTpl = '?host_name={0}&file_name={1}&component_name={2}',
self = this;
if (this.get('openedTask.id')) {
@@ -979,7 +1019,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({
tabClassName: tabClassName,
tabClassNameSelector: '.' + tabClassName,
displayedFileName: fileUtils.fileNameFromPath(logFileName),
- url: self.get('logSearchUrlTemplate').format(hostName, logFileName, logComponentName),
+ linkTail: linkTailTpl.format(hostName, logFileName, logComponentName),
isActive: false
});
}));
@@ -990,22 +1030,6 @@ App.HostProgressPopupBodyView = App.TableView.extend({
return [];
}.property('openedTaskId', 'isLevelLoaded'),
-
- /**
- * Log Search UI link template used for 'Open In Log Search' links.
- *
- * @property {string}
- */
- logSearchUrlTemplate: function() {
- var quickLink = App.QuickLinks.find().findProperty('site', 'logsearch-env'),
- logSearchServerHost = App.HostComponent.find().findProperty('componentName', 'LOGSEARCH_SERVER').get('host.hostName');
-
- if (quickLink) {
- return quickLink.get('template').fmt('http', logSearchServerHost, quickLink.get('default_http_port')) + '?host_name={0}&file_name={1}&component_name={2}';
- }
- return '#';
- }.property('hostComponentLogsExists'),
-
/**
* Determines if there are component logs for selected component within 'TASK_DETAILS' level.
*
http://git-wip-us.apache.org/repos/asf/ambari/blob/8fbfd89f/ambari-web/app/views/common/log_search_ui_link_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/log_search_ui_link_view.js b/ambari-web/app/views/common/log_search_ui_link_view.js
new file mode 100644
index 0000000..8227b7f
--- /dev/null
+++ b/ambari-web/app/views/common/log_search_ui_link_view.js
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+require('views/common/quick_view_link_view');
+
+/**
+ * This view helps to get and format correct link to LogSearch UI with query params.
+ * Used mostly for navigation to concrete log file.
+ *
+ * @augments App.QuickViewLinks
+ */
+App.LogSearchUILinkView = App.QuickViewLinks.extend({
+ content: function() {
+ return App.Service.find().findProperty('serviceName', 'LOGSEARCH');
+ }.property(),
+
+ formatedLink: function() {
+ if (this.get('quickLinks.length')) {
+ return Em.get(this.get('quickLinks').findProperty('label', 'Log Search UI'), 'url') + this.get('linkQueryParams');
+ }
+ return false;
+ }.property('quickLinks.length', 'linkQueryParams')
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/8fbfd89f/ambari-web/app/views/common/modal_popups/log_tail_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popups/log_tail_popup.js b/ambari-web/app/views/common/modal_popups/log_tail_popup.js
index dbd209b..4dae7a4 100644
--- a/ambari-web/app/views/common/modal_popups/log_tail_popup.js
+++ b/ambari-web/app/views/common/modal_popups/log_tail_popup.js
@@ -39,7 +39,7 @@ App.showLogTailPopup = function(content) {
logSearchUrl: function() {
var quickLink = App.QuickLinks.find().findProperty('site', 'logsearch-env'),
- logSearchServerHost = App.HostComponent.find().findProperty('componentName', 'LOGSEARCH_SERVER').get('host.hostName');
+ logSearchServerHost = App.HostComponent.find().findProperty('componentName', 'LOGSEARCH_SERVER').get('hostName');
if (quickLink) {
return quickLink.get('template').fmt('http', logSearchServerHost, quickLink.get('default_http_port')) + '?host_name=' + this.get('content.hostName') + '&file_name=' + this.get('content.filePath') + '&component_name=' + this.get('content.logComponentName');
http://git-wip-us.apache.org/repos/asf/ambari/blob/8fbfd89f/ambari-web/app/views/main/host/logs_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/logs_view.js b/ambari-web/app/views/main/host/logs_view.js
index bcdb238..239edc7 100644
--- a/ambari-web/app/views/main/host/logs_view.js
+++ b/ambari-web/app/views/main/host/logs_view.js
@@ -37,18 +37,10 @@ App.MainHostLogsView = App.TableView.extend({
return App.HostComponentLog.find().filterProperty('hostName', this.get('host.hostName'));
}.property('App.HostComponentLog.length'),
- logSearchUrlTemplate: function() {
- var quickLink = App.QuickLinks.find().findProperty('site', 'logsearch-env'),
- logSearchServerHost = App.HostComponent.find().findProperty('componentName', 'LOGSEARCH_SERVER').get('host.hostName');
-
- if (quickLink) {
- return quickLink.get('template').fmt('http', logSearchServerHost, quickLink.get('default_http_port')) + '?host_name=' + this.get('host.hostName') + '&file_name={0}&component_name={1}';
- }
- return '#';
- }.property(),
-
content: function() {
- var self = this;
+ var self = this,
+ linkTailTpl = '?host_name={0}&file_name={1}&component_name={2}';
+
return this.get('hostLogs').map(function(i) {
return Em.Object.create({
serviceName: i.get('hostComponent.service.serviceName'),
@@ -61,7 +53,7 @@ App.MainHostLogsView = App.TableView.extend({
return {
fileName: fileUtils.fileNameFromPath(filePath),
filePath: filePath,
- url: self.get('logSearchUrlTemplate').format(filePath, i.get('name'))
+ linkTail: linkTailTpl.format(i.get('hostName'), filePath, i.get('name'))
};
}),
fileNamesFilterValue: i.get('logFileNames').join(',')
http://git-wip-us.apache.org/repos/asf/ambari/blob/8fbfd89f/ambari-web/test/views/common/host_progress_popup_body_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/host_progress_popup_body_view_test.js b/ambari-web/test/views/common/host_progress_popup_body_view_test.js
index 974a23f..282d31c 100644
--- a/ambari-web/test/views/common/host_progress_popup_body_view_test.js
+++ b/ambari-web/test/views/common/host_progress_popup_body_view_test.js
@@ -59,7 +59,7 @@ describe('App.HostProgressPopupBodyView', function () {
var cases;
beforeEach(function() {
- sinon.stub(App.StackServiceComponent, 'find').returns([{componentName: 'DATANODE'}])
+ sinon.stub(App.StackServiceComponent, 'find').returns([{componentName: 'DATANODE'}]);
sinon.stub(App.StackService, 'find').returns([{serviceName: 'HDFS'}])
});
@@ -124,4 +124,119 @@ describe('App.HostProgressPopupBodyView', function () {
});
});
+
+ describe('#preloadHostModel', function() {
+ describe('When Log Search installed', function() {
+ var cases;
+ beforeEach(function() {
+ this.HostModelStub = sinon.stub(App.Host, 'find');
+ this.isLogSearchInstalled = sinon.stub(view, 'get').withArgs('isLogSearchInstalled');
+ this.logSearchSupported = sinon.stub(App, 'get').withArgs('supports.logSearch');
+ this.updateCtrlStub = sinon.stub(App.router.get('updateController'), 'updateLogging');
+ });
+
+ afterEach(function () {
+ App.Host.find.restore();
+ view.get.restore();
+ App.get.restore();
+ App.router.get('updateController').updateLogging.restore();
+ });
+
+ cases = [
+ {
+ hostName: 'host1',
+ logSearchSupported: true,
+ isLogSearchInstalled: true,
+ requestFailed: false,
+ hosts: [
+ {
+ hostName: 'host2'
+ }
+ ],
+ e: {
+ updateLoggingCalled: true
+ },
+ m: 'Host absent, log search installed and supported'
+ },
+ {
+ hostName: 'host1',
+ logSearchSupported: true,
+ isLogSearchInstalled: true,
+ requestFailed: false,
+ hosts: [
+ {
+ hostName: 'host1'
+ }
+ ],
+ e: {
+ updateLoggingCalled: false
+ },
+ m: 'Host present, log search installed and supported'
+ },
+ {
+ hostName: 'host1',
+ logSearchSupported: false,
+ isLogSearchInstalled: true,
+ requestFailed: false,
+ hosts: [
+ {
+ hostName: 'host1'
+ }
+ ],
+ e: {
+ updateLoggingCalled: false
+ },
+ m: 'Host present, log search installed and support is off'
+ },
+ {
+ hostName: 'host1',
+ logSearchSupported: true,
+ isLogSearchInstalled: true,
+ requestFailed: true,
+ hosts: [
+ {
+ hostName: 'host2'
+ }
+ ],
+ e: {
+ updateLoggingCalled: true
+ },
+ m: 'Host is absent, log search installed and supported, update request was failed'
+ },
+ {
+ hostName: 'host1',
+ logSearchSupported: true,
+ isLogSearchInstalled: false,
+ requestFailed: true,
+ hosts: [
+ {
+ hostName: 'host2'
+ }
+ ],
+ e: {
+ updateLoggingCalled: false
+ },
+ m: 'Host is absent, log search not installed and supported'
+ }
+ ];
+
+ cases.forEach(function(test) {
+ it(test.m, function() {
+ assert.equal(Em.get(view, 'hostInfoLoaded'), true, 'hostInfoLoaded should be true on init');
+ this.HostModelStub.returns(test.hosts);
+ this.isLogSearchInstalled.returns(test.isLogSearchInstalled);
+ this.logSearchSupported.returns(test.logSearchSupported);
+ if (test.requestFailed) {
+ this.updateCtrlStub.returns($.Deferred().reject().promise());
+ } else {
+ this.updateCtrlStub.returns($.Deferred().resolve().promise());
+ }
+ Em.set(view, 'hostInfoLoaded', false);
+ view.preloadHostModel(test.hostName);
+ assert.equal(App.router.get('updateController').updateLogging.called, test.e.updateLoggingCalled, 'updateLogging call validation');
+ assert.equal(Em.get(view, 'hostInfoLoaded'), true, 'in result hostInfoLoaded should be always true');
+ });
+ }, this);
+ });
+ });
});
[2/2] ambari git commit: AMBARI-16678. JS error on resize ASW and
assign master popup (alexantonenko)
Posted by al...@apache.org.
AMBARI-16678. JS error on resize ASW and assign master popup (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2d8f3f2e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2d8f3f2e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2d8f3f2e
Branch: refs/heads/branch-2.4
Commit: 2d8f3f2ed5261ca1e2d0c08552adf9cb6d45e048
Parents: a255537
Author: Alex Antonenko <hi...@gmail.com>
Authored: Mon May 16 12:53:05 2016 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Mon May 16 13:52:34 2016 +0300
----------------------------------------------------------------------
ambari-web/app/styles/application.less | 2 +-
ambari-web/app/views/common/modal_popup.js | 18 +++++++++---------
2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2d8f3f2e/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 6d9ed46..5c9e69e 100644
--- a/ambari-web/app/styles/application.less
+++ b/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;
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/2d8f3f2e/ambari-web/app/views/common/modal_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popup.js b/ambari-web/app/views/common/modal_popup.js
index 5e3544a..252604e 100644
--- a/ambari-web/app/views/common/modal_popup.js
+++ b/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();