Your IP : 18.219.40.177
/**
* Alert module
* shows alert message
* @param {object} window global object
* @param {function} $ jQuery library
* @param {object} EventMgr EventMgr library
* @return {object} api
*/
App.Alert = function(window, $, EventMgr) {
'use strict';
var init = function() {
EventMgr.bind('showAlert', showAlert);
EventMgr.obind($modalBtn(), 'click', hideAlert);
},
$body = function() {
return $('body');
},
$modalMsg = function() {
return $('#modal_alert_message');
},
$modalBtn = function() {
return $('#modal_alert_ok');
},
callback = null,
himself = null,
param = null,
activeClass = 'active-modal-alert',
showAlert = function(e, data) {
var msg = data.msg,
closeTimeout = data.closeTimeout,
modalMsg = $modalMsg(),
textarea;
callback = data.callback || null;
himself = data.himself || window;
param = data.param;
modalMsg.html(msg);
$body().addClass(activeClass);
setTimeout(function() {
textarea = modalMsg.find('.b-textarea');
if (textarea.length) {
textarea.select();
} else {
$modalBtn().focus();
}
}, 1);
if (closeTimeout) {
setTimeout(function() {
hideAlert();
}, closeTimeout);
}
},
hideAlert = function() {
$body().removeClass(activeClass);
if (callback !== null) {
callback.apply(himself, [param]);
}
};
return {
init: init
};
}(window, $, EventMgr);