Fix bug with single popup window openning

This commit is contained in:
Dmitriy Simushev 2015-02-20 14:22:59 +00:00
parent 21ae86958d
commit edcd348bca

View File

@ -260,12 +260,6 @@ var Mibew = Mibew || {};
* @type {Boolean} * @type {Boolean}
*/ */
this.modSecurity = options.modSecurity || false; 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. // Call parent constructor.
BasePopup.call(this, options); BasePopup.call(this, options);
/**
* Popup iframe DOM Element.
* @type {Node}
*/
this.iframe = null; 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 // Load default styles. These styles hide the popup while real styles
// are loading. // are loading.
this.attachDefaultStyles(); this.attachDefaultStyles();
@ -422,11 +426,6 @@ var Mibew = Mibew || {};
* value is omitted, the chat initialization URL will be loaded. * value is omitted, the chat initialization URL will be loaded.
*/ */
Mibew.ChatPopup.Window.prototype.open = function(url) { Mibew.ChatPopup.Window.prototype.open = function(url) {
if (this.isOpened) {
// Do not open the popup twice.
return;
}
this.window = window.open( this.window = window.open(
url || this.buildChatUrl(), url || this.buildChatUrl(),
'mibewChat' + this.id, 'mibewChat' + this.id,
@ -434,22 +433,19 @@ var Mibew = Mibew || {};
); );
this.window.focus(); this.window.focus();
this.window.opener = window; this.window.opener = window;
this.isOpened = true;
} }
/** /**
* Closes the popup. * Closes the popup.
*/ */
Mibew.ChatPopup.Window.prototype.close = function() { Mibew.ChatPopup.Window.prototype.close = function() {
if (!this.isOpened) { if (!this.window) {
// The window was not opened thus it should not be closed. // There is nothing to close.
return; return;
} }
this.window.close(); this.window.close();
this.window = null; this.window = null;
this.isOpened = false;
} }
/** /**