Fix Ask popup bug (#231)

This commit is contained in:
RainLoop Team 2014-07-10 18:44:45 +04:00
parent aa7e198f3c
commit c155a6c200
10 changed files with 251 additions and 183 deletions

View file

@ -198,6 +198,15 @@ Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters)
} }
}; };
/**
* @param {Function} ViewModelClassToShow
* @return {boolean}
*/
Knoin.prototype.isPopupVisible = function (ViewModelClassToShow)
{
return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false;
};
/** /**
* @param {string} sScreenName * @param {string} sScreenName
* @param {string} sSubPart * @param {string} sSubPart

View file

@ -103,5 +103,10 @@ PopupsAskViewModel.prototype.onBuild = function ()
} }
return false; return false;
}, this)); }, this));
key('esc', Enums.KeyState.PopupAsk, _.bind(function () {
this.noClick();
return false;
}, this));
}; };

View file

@ -359,6 +359,8 @@ function PopupsComposeViewModel()
this.bDisabeCloseOnEsc = true; this.bDisabeCloseOnEsc = true;
this.sDefaultKeyScope = Enums.KeyState.Compose; this.sDefaultKeyScope = Enums.KeyState.Compose;
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
Knoin.constructorEnd(this); Knoin.constructorEnd(this);
} }
@ -912,12 +914,15 @@ PopupsComposeViewModel.prototype.editorResize = function ()
PopupsComposeViewModel.prototype.tryToClosePopup = function () PopupsComposeViewModel.prototype.tryToClosePopup = function ()
{ {
var self = this; var self = this;
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () { if (!kn.isPopupVisible(PopupsAskViewModel))
if (self.modalVisibility()) {
{ kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () {
Utils.delegateRun(self, 'closeCommand'); if (self.modalVisibility())
} {
}]); Utils.delegateRun(self, 'closeCommand');
}
}]);
}
}; };
PopupsComposeViewModel.prototype.onBuild = function () PopupsComposeViewModel.prototype.onBuild = function ()
@ -945,7 +950,10 @@ PopupsComposeViewModel.prototype.onBuild = function ()
}); });
key('esc', Enums.KeyState.Compose, function () { key('esc', Enums.KeyState.Compose, function () {
self.tryToClosePopup(); if (self.modalVisibility())
{
self.tryToClosePopup();
}
return false; return false;
}); });

View file

@ -62,6 +62,8 @@ function PopupsPluginViewModel()
this.bDisabeCloseOnEsc = true; this.bDisabeCloseOnEsc = true;
this.sDefaultKeyScope = Enums.KeyState.All; this.sDefaultKeyScope = Enums.KeyState.All;
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
Knoin.constructorEnd(this); Knoin.constructorEnd(this);
} }
@ -118,12 +120,15 @@ PopupsPluginViewModel.prototype.onShow = function (oPlugin)
PopupsPluginViewModel.prototype.tryToClosePopup = function () PopupsPluginViewModel.prototype.tryToClosePopup = function ()
{ {
var self = this; var self = this;
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () { if (!kn.isPopupVisible(PopupsAskViewModel))
if (self.modalVisibility()) {
{ kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () {
Utils.delegateRun(self, 'cancelCommand'); if (self.modalVisibility())
} {
}]); Utils.delegateRun(self, 'cancelCommand');
}
}]);
}
}; };
PopupsPluginViewModel.prototype.onBuild = function () PopupsPluginViewModel.prototype.onBuild = function ()
@ -132,7 +137,7 @@ PopupsPluginViewModel.prototype.onBuild = function ()
if (this.modalVisibility()) if (this.modalVisibility())
{ {
this.tryToClosePopup(); this.tryToClosePopup();
return false;
} }
return false;
}, this)); }, this));
}; };

View file

@ -4551,6 +4551,15 @@ Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters)
} }
}; };
/**
* @param {Function} ViewModelClassToShow
* @return {boolean}
*/
Knoin.prototype.isPopupVisible = function (ViewModelClassToShow)
{
return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false;
};
/** /**
* @param {string} sScreenName * @param {string} sScreenName
* @param {string} sSubPart * @param {string} sSubPart
@ -5531,6 +5540,8 @@ function PopupsPluginViewModel()
this.bDisabeCloseOnEsc = true; this.bDisabeCloseOnEsc = true;
this.sDefaultKeyScope = Enums.KeyState.All; this.sDefaultKeyScope = Enums.KeyState.All;
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
Knoin.constructorEnd(this); Knoin.constructorEnd(this);
} }
@ -5587,12 +5598,15 @@ PopupsPluginViewModel.prototype.onShow = function (oPlugin)
PopupsPluginViewModel.prototype.tryToClosePopup = function () PopupsPluginViewModel.prototype.tryToClosePopup = function ()
{ {
var self = this; var self = this;
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () { if (!kn.isPopupVisible(PopupsAskViewModel))
if (self.modalVisibility()) {
{ kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () {
Utils.delegateRun(self, 'cancelCommand'); if (self.modalVisibility())
} {
}]); Utils.delegateRun(self, 'cancelCommand');
}
}]);
}
}; };
PopupsPluginViewModel.prototype.onBuild = function () PopupsPluginViewModel.prototype.onBuild = function ()
@ -5601,8 +5615,8 @@ PopupsPluginViewModel.prototype.onBuild = function ()
if (this.modalVisibility()) if (this.modalVisibility())
{ {
this.tryToClosePopup(); this.tryToClosePopup();
return false;
} }
return false;
}, this)); }, this));
}; };
@ -5891,6 +5905,11 @@ PopupsAskViewModel.prototype.onBuild = function ()
} }
return false; return false;
}, this)); }, this));
key('esc', Enums.KeyState.PopupAsk, _.bind(function () {
this.noClick();
return false;
}, this));
}; };

File diff suppressed because one or more lines are too long

View file

@ -5504,6 +5504,15 @@ Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters)
} }
}; };
/**
* @param {Function} ViewModelClassToShow
* @return {boolean}
*/
Knoin.prototype.isPopupVisible = function (ViewModelClassToShow)
{
return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false;
};
/** /**
* @param {string} sScreenName * @param {string} sScreenName
* @param {string} sSubPart * @param {string} sSubPart
@ -9065,6 +9074,8 @@ function PopupsComposeViewModel()
this.bDisabeCloseOnEsc = true; this.bDisabeCloseOnEsc = true;
this.sDefaultKeyScope = Enums.KeyState.Compose; this.sDefaultKeyScope = Enums.KeyState.Compose;
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
Knoin.constructorEnd(this); Knoin.constructorEnd(this);
} }
@ -9618,12 +9629,15 @@ PopupsComposeViewModel.prototype.editorResize = function ()
PopupsComposeViewModel.prototype.tryToClosePopup = function () PopupsComposeViewModel.prototype.tryToClosePopup = function ()
{ {
var self = this; var self = this;
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () { if (!kn.isPopupVisible(PopupsAskViewModel))
if (self.modalVisibility()) {
{ kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () {
Utils.delegateRun(self, 'closeCommand'); if (self.modalVisibility())
} {
}]); Utils.delegateRun(self, 'closeCommand');
}
}]);
}
}; };
PopupsComposeViewModel.prototype.onBuild = function () PopupsComposeViewModel.prototype.onBuild = function ()
@ -9651,7 +9665,10 @@ PopupsComposeViewModel.prototype.onBuild = function ()
}); });
key('esc', Enums.KeyState.Compose, function () { key('esc', Enums.KeyState.Compose, function () {
self.tryToClosePopup(); if (self.modalVisibility())
{
self.tryToClosePopup();
}
return false; return false;
}); });
@ -12013,6 +12030,11 @@ PopupsAskViewModel.prototype.onBuild = function ()
} }
return false; return false;
}, this)); }, this));
key('esc', Enums.KeyState.PopupAsk, _.bind(function () {
this.noClick();
return false;
}, this));
}; };

File diff suppressed because one or more lines are too long