define('application/components/modals/service', [
'application/components/modals/error',
'application/managers/halo',
'rofl/lib/l10n',
'antie/runtimecontext',
'rofl/lib/utils'
], function (
Error,
HaloManager,
L10N,
RuntimeContext,
Utils
) {
'use strict';
var application = RuntimeContext.getCurrentApplication(),
halo = HaloManager.getInstance();
return Error.extend({
/**
* Initialises the modal.
*/
init: function init () {
init.base.call(this);
this._onBlurBound = Utils.bind(this.onBlur, this);
},
/**
* BeforeShow event.
*
* @param {Object} e - The event data.
*/
onBeforeShow: function onBeforeShow (e) {
e.args = {
fullscreen: false,
title: halo.getServiceTitle(),
text: halo.getServiceText(),
button: [{
id: 'error-close-button',
label: L10N.getInstance().get('servicemessage.button')
}],
okButton: true,
callback: function () {
if (application.getComponent('detail').outputElement.style.display === 'block') {
application.getComponent('detail').focus();
application.getComponent('detail').getChildWidget(0).focus();
} else {
application.getComponent('main').focus();
application.getComponent('main').getChildWidget(0).focus();
}
}
};
this._preventBlur = true;
this.addEventListener('blur', this._onBlurBound);
onBeforeShow.base.call(this, e);
},
/**
* BeforeHide event.
*/
onBeforeHide: function () {
this.removeEventListener('blur', this._onBlurBound);
},
/**
* Blur event.
*
* @param {Object} e - The event data.
*/
onBlur: function (e) {
var self = this;
if (this._preventBlur) {
e.preventDefault();
e.stopPropagation();
setTimeout(function () {
self._buttonsList.getChildWidgetByIndex(0).focus();
}, 0);
}
},
/**
* Closes the modal.
*
* @private
*/
_onClose: function _onClose () {
this._preventBlur = false;
_onClose.base.call(this);
}
});
});