Add onFocus callback to popups

This commit is contained in:
RainLoop Team 2013-12-29 00:42:07 +04:00
parent fd2c2346a8
commit 04932fce63
28 changed files with 412 additions and 336 deletions

View file

@ -1,5 +1,5 @@
/*! RainLoop Webmail Admin Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (window, $, ko, crossroads, hasher, _) {
/*! RainLoop Webmail Admin Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (window, $, ko, crossroads, hasher, _) {
'use strict';
@ -70,14 +70,14 @@ var
$document = $(window.document),
NotificationClass = window.Notification && window.Notification.requestPermission ? window.Notification : null
;
;
/*jshint onevar: false*/
/**
* @type {?AdminApp}
*/
var RL = null;
/*jshint onevar: true*/
/**
* @type {?}
*/
@ -138,7 +138,7 @@ Globals.bDisableNanoScroll = Globals.bMobileDevice;
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
Globals.sAnimationType = '';
Consts.Defaults = {};
Consts.Values = {};
Consts.DataImages = {};
@ -256,7 +256,7 @@ Consts.DataImages.UserDotPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA
* @type {string}
*/
Consts.DataImages.TranspPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=';
/**
* @enum {string}
*/
@ -590,7 +590,7 @@ Enums.Notification = {
'UnknownNotification': 999,
'UnknownError': 999
};
Utils.trim = $.trim;
Utils.inArray = $.inArray;
Utils.isArray = _.isArray;
@ -1225,6 +1225,19 @@ Utils.getUploadErrorDescByCode = function (mCode)
return sResult;
};
/**
* @param {?} oObject
* @param {string} sMethodName
* @param {Array=} aParameters
*/
Utils.delegateRun = function (oObject, sMethodName, aParameters)
{
if (oObject && oObject[sMethodName])
{
oObject[sMethodName].apply(oObject, Utils.isArray(aParameters) ? aParameters : []);
}
};
/**
* @param {?} oEvent
*/
@ -2099,7 +2112,7 @@ Utils.computedPagenatorHelper = function (koCurrentPage, koPageCount)
return aResult;
};
};
// Base64 encode / decode
// http://www.webtoolkit.info/
@ -2262,7 +2275,7 @@ Base64 = {
}
};
/*jslint bitwise: false*/
/*jslint bitwise: false*/
ko.bindingHandlers.tooltip = {
'init': function (oElement, fValueAccessor) {
if (!Globals.bMobileDevice)
@ -2884,7 +2897,7 @@ ko.observable.fn.validateFunc = function (fFunc)
return this;
};
/**
* @constructor
*/
@ -3157,7 +3170,7 @@ LinkBuilder.prototype.socialFacebook = function ()
{
return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
};
/**
* @type {Object}
*/
@ -3251,7 +3264,7 @@ Plugins.settingsGet = function (sPluginSection, sName)
};
/**
* @constructor
*/
@ -3325,7 +3338,7 @@ CookieDriver.prototype.get = function (sKey)
return mResult;
};
/**
* @constructor
*/
@ -3397,7 +3410,7 @@ LocalStorageDriver.prototype.get = function (sKey)
return mResult;
};
/**
* @constructor
*/
@ -3440,7 +3453,7 @@ LocalStorage.prototype.get = function (iKey)
{
return this.oDriver ? this.oDriver.get('p' + iKey) : null;
};
/**
* @constructor
*/
@ -3453,7 +3466,7 @@ KnoinAbstractBoot.prototype.bootstart = function ()
{
};
/**
* @param {string=} sPosition = ''
* @param {string=} sTemplate = ''
@ -3513,7 +3526,7 @@ KnoinAbstractViewModel.prototype.viewModelPosition = function ()
KnoinAbstractViewModel.prototype.cancelCommand = KnoinAbstractViewModel.prototype.closeCommand = function ()
{
};
/**
* @param {string} sScreenName
* @param {?=} aViewModels = []
@ -3589,7 +3602,7 @@ KnoinAbstractScreen.prototype.__start = function ()
this.oCross = oRoute;
}
};
/**
* @constructor
*/
@ -3664,19 +3677,6 @@ Knoin.prototype.screen = function (sScreenName)
return ('' !== sScreenName && !Utils.isUnd(this.oScreens[sScreenName])) ? this.oScreens[sScreenName] : null;
};
/**
* @param {?} oViewModel
* @param {string} sDelegateName
* @param {Array=} aParameters
*/
Knoin.prototype.delegateRun = function (oViewModel, sDelegateName, aParameters)
{
if (oViewModel && oViewModel[sDelegateName])
{
oViewModel[sDelegateName].apply(oViewModel, Utils.isArray(aParameters) ? aParameters : []);
}
};
/**
* @param {Function} ViewModelClass
* @param {Object=} oScreen
@ -3717,7 +3717,7 @@ Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen)
Plugins.runHook('view-model-pre-build', [ViewModelClass.__name, oViewModel, oViewModelDom]);
ko.applyBindings(oViewModel, oViewModelDom[0]);
this.delegateRun(oViewModel, 'onBuild', [oViewModelDom]);
Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]);
Plugins.runHook('view-model-post-build', [ViewModelClass.__name, oViewModel, oViewModelDom]);
}
@ -3750,7 +3750,7 @@ Knoin.prototype.hideScreenPopup = function (ViewModelClassToHide)
if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom)
{
ViewModelClassToHide.__vm.modalVisibility(false);
this.delegateRun(ViewModelClassToHide.__vm, 'onHide');
Utils.delegateRun(ViewModelClassToHide.__vm, 'onHide');
this.popupVisibility(false);
Plugins.runHook('view-model-on-hide', [ViewModelClassToHide.__name, ViewModelClassToHide.__vm]);
@ -3775,10 +3775,14 @@ Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters)
{
ViewModelClassToShow.__dom.show();
ViewModelClassToShow.__vm.modalVisibility(true);
this.delegateRun(ViewModelClassToShow.__vm, 'onShow', aParameters || []);
Utils.delegateRun(ViewModelClassToShow.__vm, 'onShow', aParameters || []);
this.popupVisibility(true);
Plugins.runHook('view-model-on-show', [ViewModelClassToShow.__name, ViewModelClassToShow.__vm, aParameters || []]);
_.delay(function () {
Utils.delegateRun(ViewModelClassToShow.__vm, 'onFocus');
}, 500);
}
}
};
@ -3826,7 +3830,7 @@ Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart)
}, this);
}
this.delegateRun(oScreen, 'onBuild');
Utils.delegateRun(oScreen, 'onBuild');
}
_.defer(function () {
@ -3834,7 +3838,7 @@ Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart)
// hide screen
if (self.oCurrentScreen)
{
self.delegateRun(self.oCurrentScreen, 'onHide');
Utils.delegateRun(self.oCurrentScreen, 'onHide');
if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels()))
{
@ -3845,7 +3849,7 @@ Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart)
{
ViewModelClass.__dom.hide();
ViewModelClass.__vm.viewModelVisibility(false);
self.delegateRun(ViewModelClass.__vm, 'onHide');
Utils.delegateRun(ViewModelClass.__vm, 'onHide');
}
});
@ -3859,7 +3863,7 @@ Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart)
if (self.oCurrentScreen)
{
self.delegateRun(self.oCurrentScreen, 'onShow');
Utils.delegateRun(self.oCurrentScreen, 'onShow');
Plugins.runHook('screen-on-show', [self.oCurrentScreen.screenName(), self.oCurrentScreen]);
@ -3872,7 +3876,7 @@ Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart)
{
ViewModelClass.__dom.show();
ViewModelClass.__vm.viewModelVisibility(true);
self.delegateRun(ViewModelClass.__vm, 'onShow');
Utils.delegateRun(ViewModelClass.__vm, 'onShow');
Plugins.runHook('view-model-on-show', [ViewModelClass.__name, ViewModelClass.__vm]);
}
@ -3928,7 +3932,7 @@ Knoin.prototype.startScreens = function (aScreensClasses)
oScreen.__start();
Plugins.runHook('screen-pre-start', [oScreen.screenName(), oScreen]);
this.delegateRun(oScreen, 'onStart');
Utils.delegateRun(oScreen, 'onStart');
Plugins.runHook('screen-post-start', [oScreen.screenName(), oScreen]);
}
}, this);
@ -3989,7 +3993,7 @@ Knoin.prototype.bootstart = function ()
};
kn = new Knoin();
/**
* @param {string=} sEmail
* @param {string=} sName
@ -4353,7 +4357,7 @@ EmailModel.prototype.inputoTagLine = function ()
{
return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email;
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -4547,7 +4551,7 @@ PopupsDomainViewModel.prototype.onBuild = function ()
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
kn.delegateRun(self, 'cancelCommand');
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
@ -4573,7 +4577,7 @@ PopupsDomainViewModel.prototype.clearForm = function ()
this.smtpAuth(true);
this.whiteList('');
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -4692,7 +4696,7 @@ PopupsPluginViewModel.prototype.tryToClosePopup = function ()
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () {
if (self.modalVisibility())
{
kn.delegateRun(self, 'cancelCommand');
Utils.delegateRun(self, 'cancelCommand');
}
}]);
};
@ -4710,7 +4714,7 @@ PopupsPluginViewModel.prototype.onBuild = function ()
return bResult;
});
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -4808,7 +4812,13 @@ PopupsActivateViewModel.prototype.onShow = function ()
this.activateText('');
this.activateText.isError(false);
this.activationSuccessed(false);
}
};
PopupsActivateViewModel.prototype.onFocus = function ()
{
if (!this.activateProcess())
{
this.key.focus(true);
}
};
@ -4820,7 +4830,7 @@ PopupsActivateViewModel.prototype.validateSubscriptionKey = function ()
{
var sValue = this.key();
return '' === sValue || !!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(Utils.trim(sValue));
};
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -4882,7 +4892,7 @@ PopupsLanguagesViewModel.prototype.onBuild = function ()
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
kn.delegateRun(self, 'cancelCommand');
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
@ -4894,7 +4904,7 @@ PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang)
RL.data().mainLanguage(sLang);
this.cancelCommand();
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -4975,7 +4985,10 @@ PopupsAskViewModel.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYe
{
this.yesButton(sNoButton);
}
};
PopupsAskViewModel.prototype.onFocus = function ()
{
this.yesFocus(true);
};
@ -5009,7 +5022,7 @@ PopupsAskViewModel.prototype.onBuild = function ()
});
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -5096,7 +5109,7 @@ AdminLoginViewModel.prototype.onHide = function ()
{
this.loginFocus(false);
};
/**
* @param {?} oScreen
*
@ -5118,7 +5131,7 @@ AdminMenuViewModel.prototype.link = function (sRoute)
{
return '#/' + sRoute;
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -5140,7 +5153,7 @@ AdminPaneViewModel.prototype.logoutClick = function ()
RL.remote().adminLogout(function () {
RL.loginAndLogoutReload();
});
};
};
/**
* @constructor
*/
@ -5259,7 +5272,7 @@ AdminGeneral.prototype.selectLanguage = function ()
{
kn.showScreenPopup(PopupsLanguagesViewModel);
};
/**
* @constructor
*/
@ -5311,7 +5324,7 @@ AdminLogin.prototype.onBuild = function ()
}, 50);
};
/**
* @constructor
*/
@ -5531,7 +5544,7 @@ AdminContacts.prototype.onBuild = function ()
}, 50);
};
/**
* @constructor
*/
@ -5620,7 +5633,7 @@ AdminDomains.prototype.onDomainListChangeRequest = function ()
{
RL.reloadDomainList();
};
/**
* @constructor
*/
@ -5701,7 +5714,7 @@ AdminSecurity.prototype.phpInfoLink = function ()
{
return RL.link().phpInfo();
};
/**
* @constructor
*/
@ -5817,7 +5830,7 @@ AdminSocial.prototype.onBuild = function ()
}, 50);
};
/**
* @constructor
*/
@ -5914,7 +5927,7 @@ AdminPlugins.prototype.onPluginDisableRequest = function (sResult, oData)
RL.reloadPluginList();
};
/**
* @constructor
*/
@ -6018,7 +6031,7 @@ AdminPackages.prototype.installPackage = function (oPackage)
RL.remote().packageInstall(this.requestHelper(oPackage, true), oPackage);
}
};
/**
* @constructor
*/
@ -6069,7 +6082,7 @@ AdminLicensing.prototype.licenseExpiredMomentValue = function ()
{
var oDate = moment.unix(this.licenseExpired());
return oDate.format('LL') + ' (' + oDate.from(moment()) + ')';
};
};
/**
* @constructor
*/
@ -6138,7 +6151,7 @@ AbstractData.prototype.populateDataOnStart = function()
this.contactsIsAllowed(!!RL.settingsGet('ContactsIsAllowed'));
};
/**
* @constructor
* @extends AbstractData
@ -6172,7 +6185,7 @@ _.extend(AdminDataStorage.prototype, AbstractData.prototype);
AdminDataStorage.prototype.populateDataOnStart = function()
{
AbstractData.prototype.populateDataOnStart.call(this);
};
};
/**
* @constructor
*/
@ -6446,7 +6459,7 @@ AbstractAjaxRemoteStorage.prototype.jsVersion = function (fCallback, sVersion)
'Version': sVersion
});
};
/**
* @constructor
* @extends AbstractAjaxRemoteStorage
@ -6690,7 +6703,7 @@ AdminAjaxRemoteStorage.prototype.adminPing = function (fCallback)
{
this.defaultRequest(fCallback, 'AdminPing');
};
/**
* @constructor
*/
@ -6756,7 +6769,7 @@ AbstractCacheStorage.prototype.setEmailsPicsHashesData = function (oData)
{
this.oEmailsPicsHashes = oData;
};
/**
* @constructor
* @extends AbstractCacheStorage
@ -6767,7 +6780,7 @@ function AdminCacheStorage()
}
_.extend(AdminCacheStorage.prototype, AbstractCacheStorage.prototype);
/**
* @param {Array} aViewModels
* @constructor
@ -6846,7 +6859,7 @@ AbstractSettings.prototype.onRoute = function (sSubName)
RoutedSettingsViewModel.__vm = oSettingsScreen;
ko.applyBindings(oSettingsScreen, oViewModelDom[0]);
kn.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
}
else
{
@ -6860,7 +6873,7 @@ AbstractSettings.prototype.onRoute = function (sSubName)
// hide
if (self.oCurrentSubScreen)
{
kn.delegateRun(self.oCurrentSubScreen, 'onHide');
Utils.delegateRun(self.oCurrentSubScreen, 'onHide');
self.oCurrentSubScreen.viewModelDom.hide();
}
// --
@ -6871,7 +6884,7 @@ AbstractSettings.prototype.onRoute = function (sSubName)
if (self.oCurrentSubScreen)
{
self.oCurrentSubScreen.viewModelDom.show();
kn.delegateRun(self.oCurrentSubScreen, 'onShow');
Utils.delegateRun(self.oCurrentSubScreen, 'onShow');
_.each(self.menu(), function (oItem) {
oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route);
@ -6895,7 +6908,7 @@ AbstractSettings.prototype.onHide = function ()
{
if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom)
{
kn.delegateRun(this.oCurrentSubScreen, 'onHide');
Utils.delegateRun(this.oCurrentSubScreen, 'onHide');
this.oCurrentSubScreen.viewModelDom.hide();
}
};
@ -6944,7 +6957,7 @@ AbstractSettings.prototype.routes = function ()
['', oRules]
];
};
/**
* @constructor
* @extends KnoinAbstractScreen
@ -6959,7 +6972,7 @@ _.extend(AdminLoginScreen.prototype, KnoinAbstractScreen.prototype);
AdminLoginScreen.prototype.onShow = function ()
{
RL.setTitle('');
};
};
/**
* @constructor
* @extends AbstractSettings
@ -6979,7 +6992,7 @@ AdminSettingsScreen.prototype.onShow = function ()
// AbstractSettings.prototype.onShow.call(this);
RL.setTitle('');
};
};
/**
* @constructor
* @extends KnoinAbstractBoot
@ -7241,7 +7254,7 @@ AbstractApp.prototype.bootstart = function ()
Utils.windowResize();
}, 1000);
};
/**
* @constructor
* @extends AbstractApp
@ -7488,7 +7501,7 @@ AdminApp.prototype.bootstart = function ()
* @type {AdminApp}
*/
RL = new AdminApp();
$html.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile');
$window.keydown(Utils.killCtrlAandS).keyup(Utils.killCtrlAandS);
@ -7535,9 +7548,9 @@ window['__RLBOOT'] = function (fCall) {
window['__RLBOOT'] = null;
});
};
if (window.SimplePace) {
window.SimplePace.add(10);
}
}
}(window, jQuery, ko, crossroads, hasher, _));