From edcd348bca03c584fbe7ee268708e2ba47170d4c Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev <simushevds@ossg.ru> Date: Fri, 20 Feb 2015 14:22:59 +0000 Subject: [PATCH] Fix bug with single popup window openning --- src/mibew/js/source/chat_popup.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/mibew/js/source/chat_popup.js b/src/mibew/js/source/chat_popup.js index 315dd9a6..cae32e10 100644 --- a/src/mibew/js/source/chat_popup.js +++ b/src/mibew/js/source/chat_popup.js @@ -260,12 +260,6 @@ var Mibew = Mibew || {}; * @type {Boolean} */ this.modSecurity = options.modSecurity || false; - - /** - * Indicates if the popup is opened. - * @type {Boolean} - */ - this.isOpened = false; } /** @@ -298,8 +292,18 @@ var Mibew = Mibew || {}; // Call parent constructor. BasePopup.call(this, options); + /** + * Popup iframe DOM Element. + * @type {Node} + */ this.iframe = null; + /** + * Indicates if the popup is opened. + * @type {Boolean} + */ + this.isOpened = false; + // Load default styles. These styles hide the popup while real styles // are loading. this.attachDefaultStyles(); @@ -422,11 +426,6 @@ var Mibew = Mibew || {}; * value is omitted, the chat initialization URL will be loaded. */ Mibew.ChatPopup.Window.prototype.open = function(url) { - if (this.isOpened) { - // Do not open the popup twice. - return; - } - this.window = window.open( url || this.buildChatUrl(), 'mibewChat' + this.id, @@ -434,22 +433,19 @@ var Mibew = Mibew || {}; ); this.window.focus(); this.window.opener = window; - - this.isOpened = true; } /** * Closes the popup. */ Mibew.ChatPopup.Window.prototype.close = function() { - if (!this.isOpened) { - // The window was not opened thus it should not be closed. + if (!this.window) { + // There is nothing to close. return; } this.window.close(); this.window = null; - this.isOpened = false; } /**