Your IP : 18.219.40.177
/**
* Модуль обрабатывает запросы с листа
* ваш К.О.
* @param {object} window global object
* @param {function} $ jQuery library
* @param {object} EventMgr EventMgr library
* @param {object} App Application
*/
/*global App:true*/
App.ActionHandlerList = function(window, $, EventMgr, App) {
'use strict';
var dummyToolbtn = '.i-toolbtn-type-dummy',
actionBannerSelector = '.i-message__more-link, .i-wizard__step-link',
backBtnListSelector = '.back-btn-row',
breadcrumbSelector = '.breadcrumb',
controlPropSelector = '.controlprop',
pageNumListSelector = '.pager-list_type_list .pager-list__item_act',
tSettingSel = '.tsetting',
rowTableSel = '.list_table tr',
pagerInputSel = '.pager-list__input',
pagerBtnSelector = '.pager-list__input-submit',
pagerSlistSel = 'input[name="pager-slist"]',
toolBarBtnGroupActSel = '.toolbar-button.active span.action.group,' +
' .toolbar-button.active span.action.groupdownload',
toolBarBtnSel = '.toolbar-button.active span.action:not(".group")',
toolBarBtnPreviewSel = '.toolbar-button.active span.action-preview',
dashboardButtonSel = '.dashboard-button',
modalActive = false,
storage = App.u.storage,
nestedListSel = '.i-nestedlist',
editFormSel = '.i-editform',
//selected elems from not list view
selectedElems = {},
// selected items
$selectedItems = function() {
return $('.tab-content_st_active .list_table .selected:not(".filtred")');
},
$firstListItem = function() {
return $('.tab-content_st_active .b-list__table-row:not(".back-btn")')
.get(0);
},
$content = function() {
return $('#main-wrapper');
};
//update selected elems object from not list view
function updateSelectedElems(e, data) {
var tabId = data.tabId,
elems = data.elems;
selectedElems[tabId] = elems;
}
//add elid for toolbar &
function updateSelectedElemsForForm(e, data) {
var tabId = data.tabId;
if (App.Dom.byId('toolbar-' + tabId)) {
selectedElems[tabId] = [{
elid: $('#frm-' + tabId).find('input[name="elid"]').val()
}];
//maybe dangeours
EventMgr.trigger('listSelect', { tabId: 'cont-' + tabId, len: 1 });
}
}
function removeSelectedElems(e, data) {
var tabId = data.tabId;
delete selectedElems[tabId];
}
/**
* Banner/Wizard Link handler
* @param {object} e
* @this {elem}
*/
function bannerAction(e) {
var href = this.getAttribute('data-href'),
wizardLink = App.Dom.hasClass(this, 'i-wizard__step-link'),
outerLink = App.Dom.hasClass(this, 'i-message__outer-link'),
iType = wizardLink ? 'replace' : false,
src = wizardLink ? 'wizardLink' : '',
param = App.Common.parseParams(href),
tabId = $(this).parents('.tab-content').attr('data-tabid'),
parent = App.Dom.hasClass(this, 'i-wizard__step-link') ? false : tabId,
targetTabId = App.Dom.hasClass(this, 'i-wizard__step-link') ?
tabId : false,
formParam = $('#frm-' + tabId).serializeObject();
if (!outerLink) {
if (e) { e.preventDefault(); }
} else {
return true;
}
if (formParam) {
delete formParam.func;
delete formParam.snext;
//delete formParam.elid;
delete formParam.sfrom;
$.extend(param, formParam);
}
EventMgr.trigger('ajaxRequest', {
param: param,
trfunc: 'ajaxResponse',
invar: {
dataSaved: true,
parent: parent,
iType: iType,
__src: src,
targetTabId: targetTabId },
queue: 'noqueue',
outtype: 'json',
failfunc: 'failCommonAjaxResponse' });
EventMgr.trigger('tabLoading', { tabId: tabId });
}
function nestedListHandler(e) {
e.preventDefault();
var $self = $(this),
elid = $self.closest('.b-list__table-row').attr('data-elid'),
index = $self.closest('td').index(),
th = $self.closest('table').find('th')[index],
colname = th.getAttribute('data-colname'),
nested = th.getAttribute('data-nestedlist'),
blank = th.getAttribute('data-nestedlist-blank'),
tabCont = $self.closest('.tab-content'),
tabId = tabCont.attr('data-tabid'),
pfunc = tabCont.attr('data-func'),
toolbarNode = App.Dom.byId('toolbar-' + tabId),
plid,
form = $('#frm-' + tabId),
filterParamString = form.serialize(),
param = {};
param.parentfilter = filterParamString;
param.func = 'nestedlist';
param.elid = elid;
param.col = colname;
param.nestedlist = nested;
/* jslint camelcase: false */
param.col_value = this.innerHTML;
/* jslint camelcase: true */
param.pfunc = pfunc;
if (toolbarNode) {
plid = filterXSS.friendlyAttrValue(toolbarNode.getAttribute('data-plid') || '');
if (plid) {
param.plid = plid;
}
}
EventMgr.trigger('ajaxRequest', {
param: param,
invar: {
newtab: blank,
__src: 'nestedList'
},
type: 'get',
outtype: 'json',
trfunc: 'ajaxResponse',
queue: 'nested-' + tabId,
failfunc: 'failCommonAjaxResponse' });
if (!blank) {
EventMgr.trigger('tabLoading', { tabId: tabId });
}
}
/**
* Back button in 1st list row handler
* @param {object} e
* @this {elem}
*/
function backBtnHandlerList(e) {
e.preventDefault();
var tabId = this.getAttribute('data-tabid');
$('#cont-' + tabId +
' .toolbar-button__item-img.back.img-link').trigger('click');
}
//breacrumb link handler
function breadcrumbHandler(e) {
e.preventDefault();
var id = this.getAttribute('data-id'),
tabId = $(this).parents('.tab-content').attr('data-tabid'),
param = storage.breadcrumb[tabId][id],
targetTabId = tabId;
EventMgr.trigger('ajaxRequest', {
url: pageInfo.url,
param: param,
invar: { targetTabId: targetTabId, iType: 'replace' },
type: 'get',
outtype: 'json',
trfunc: 'ajaxResponse',
failfunc: 'failCommonAjaxResponse',
queue: 'noqueue' });
EventMgr.trigger('tabLoading', { tabId: tabId });
}
//do if confirm
function confirmOk(confirmObj) {
modalActive = false;
var paramString = confirmObj.param,
tabId = confirmObj.tabId,
url = confirmObj.cgi ? pageInfo.host + confirmObj.cgi :
pageInfo.url,
param = (typeof paramString === 'object') ?
paramString : App.Common.parseParams(paramString),
progressid, param1;
if (confirmObj.progressbar) {
param.progressid = confirmObj.progressbar;
progressid = confirmObj.progressbar;
}
if (confirmObj.download) {
paramString = (typeof paramString === 'object') ?
App.Common.serializeForAttr(paramString) : paramString;
//for show error in new window #17646
window.open(url + '?' + paramString);
return;
} else {
EventMgr.trigger('ajaxRequest', {
url: url,
param: param,
invar: { tabId: tabId, tabs: confirmObj.to, __from: confirmObj.__from, __blockId: confirmObj.__blockId, '__src': 'groupAction' },
type: 'get',
trfunc: 'ajaxGroupComplete',
outtype: 'json',
queue: 'noqueue',
failfunc: 'failCommonAjaxResponse' });
}
if (confirmObj.progressbar) {
param1 = { elid: progressid, func: 'progress.get', sfrom: 'ajax' };
setTimeout(function() {
EventMgr.trigger('ajaxRequest', {
url: pageInfo.url,
param: param1,
invar: { tabId: tabId,
param: param1,
type: '',
progresstype: confirmObj.progressbar },
type: 'get',
outtype: 'json',
trfunc: 'progressBarResponse',
queue: 'noqueue' });
param1 = null;
tabId = null;
}, 700);
} else if (!confirmObj.download) {
EventMgr.trigger('tabLoading', { tabId: tabId });
}
}
//handler for group action, open confirm msg
function groupActionHandler(e, data) {
var confirmText = data.confirm,
self = data.self,
rows = data.rows,
tabId = data.tabId,
param = data.params,
progressbar = data.progressbar,
download = data.download,
delimiter = new RegExp(', ', 'g'),
lb = new RegExp('\n', 'g'),
dataText, confirmObj = {};
if (typeof rows === 'string' && data.confirmDelimiter) {
if (data.confirmDelimiter === '\n') {
data.confirmDelimiter = '<br/>';
}
rows = rows.replace(delimiter, data.confirmDelimiter);
}
if (typeof confirmText === 'string') {
confirmText = confirmText.replace(lb, '<br>');
}
dataText = confirmText + ' ' + rows + '?';
confirmObj.data = dataText;
confirmObj.tabId = tabId;
confirmObj.param = param;
confirmObj.progressbar = progressbar;
confirmObj.download = download;
confirmObj.cgi = data.cgi;
confirmObj.to = data.to;
confirmObj.__from = data.__from;
confirmObj.__blockId = data.__blockId;
EventMgr.trigger('confirmBoxShow', {
callbackOk: confirmOk,
callbackCancel: null,
self: data.self,
text: dataText,
warning: data.warning,
args: [confirmObj]
});
}
//group action
function groupAction(e) {
if (e) { e.preventDefault(); }
var self = $(this),
toolbar = self.parent(),
confirm = toolbar.attr('data-confirm'),
confirmDelimiter = toolbar.attr('data-confirm-d'),
itemId = self.attr('data-itemid'),
progressbar = self.attr('data-progressid') || false,
classes = self.attr('class'),
cgi = self.attr('data-cgi'),
//tabId = this.getAttribute('data-parent'),
tabId = self.attr('data-parent'),
params = App.Common.parseParams(self.attr('data-url')),
warning = App.Dom.hasClass(self[0], 'i-confirm-warning'),
download = App.Dom.hasClass(self[0], 'groupdownload'),
invar = { confirm: confirm,
params: params,
tabId: tabId,
progressbar: progressbar ? progressbar + itemId : false,
download: download,
confirmDelimiter: confirmDelimiter,
warning: warning,
cgi: cgi,
self: this
};
EventMgr.trigger('clickedGroupItem', {
invar: invar,
tabId: tabId,
classes: classes });
}
//relaod after group actions
function reloadAfterGroupAction(e, data) {
var tabId = data.tabId,
//check for user.su
newLocation = data.location,
newWin = data.newwin,
newFormParams = data.formParam,
newListParams = data.listParam,
parent = data.parent || '',
tabs = data.tabs,
error = data.error,
param;
App.Common.checkRefreshMenu(data);
//check for open as child
if (data.openAsChild) {
parent = data.tabId;
}
if (data.reload) {
window.location = pageInfo.url;
} else if (newLocation && newWin) {
window.open(newLocation, '_blank');
} else if (newLocation) {
window.location = newLocation;
} else if (newFormParams) {
param = App.Common.parseParams(newFormParams);
EventMgr.trigger('ajaxRequest', {
noesc: true,
param: param,
invar: { parent: parent, srcTabId: tabId },
type: 'get',
outtype: 'json',
trfunc: 'ajaxResponse',
queue: 'noqueue' });
return false;
} else if (newListParams) {
param = App.Common.parseParams(newListParams);
EventMgr.trigger('ajaxRequest', {
noesc: true,
param: param,
invar: { parent: parent, srcTabId: tabId },
type: 'get',
outtype: 'json',
trfunc: 'ajaxResponse',
queue: 'noqueue' });
return false;
} else if (error) {
EventMgr.trigger('ajaxResponse', data);
return;
} else if (data.__from === 'dashboard' && data.__blockId) {
$('#tblock-' + data.__blockId + ' .dashblock-reload').trigger('click');
return;
}
if (data.message && data.message.length) {
App.Global.bannerHtml = data.message;
App.Global.warning = data.warning;
App.Global.targetId = tabId;
}
if (tabId !== undefined) {
EventMgr.trigger('reloadTab', { tabId: tabId, filter: true });
} else {
param = tabs[0][0];
EventMgr.trigger('ajaxRequest', {
param: param,
type: 'get',
outtype: 'json',
trfunc: 'ajaxResponse',
queue: 'noqueue',
failfunc: 'failCommonAjaxResponse' });
}
}
//control props handler
function controlPropHandler(e) {
e.preventDefault();
e.stopPropagation();
var type = this.getAttribute('data-type'),
func = this.getAttribute('data-func'),
cgi = this.getAttribute('data-cgi'),
self = $(this),
tr = self.parents('tr'),
blockId = self.closest('.b-form-page_view_dblock').attr('data-tabid'),
elid = tr.attr('data-elid'),
keyName = tr.attr('data-elkeyname'),
param = [],
paramString = '',
url = cgi ? pageInfo.host + cgi : pageInfo.url,
parent = self.parents('.content').attr('data-tabid'),
confirm = {}, tabs,
toolbar = $('#cont-' + parent + ' .toolbar'),
plid = filterXSS.friendlyAttrValue(toolbar.attr('data-plid') || ''),
convert = toolbar.attr('data-convert'),
value = this.getAttribute('data-value');
paramString += 'elid=' + encodeURIComponent(elid);
if (plid) {
param.plid = plid;
// plid already encode
paramString += '&plid=' + plid;
}
if (convert) {
param.tconvert = convert;
paramString += '&tconvert=' + encodeURIComponent(convert);
}
if (value) {
param.value = value;
paramString += '&value=' + value;
}
param.func = func;
param.elid = elid;
if (type === 'list' || type === 'form' || type === 'edit') {
EventMgr.trigger('ajaxRequest', {
url: url,
param: param,
invar: { parent: parent },
type: 'get',
outtype: 'json',
trfunc: 'ajaxResponse',
queue: 'noqueue' });
} else if (type === 'url') {
//how it does work?
App.u.openInNewWindow(func, '_blank');
} else if (type === 'group') {
confirm = this.getAttribute('data-confirm');
tabs = { 0: [param] };
param.sok = 'ok';
var grActParam = {
confirm: confirm,
rows: keyName,
tabId: parent,
params: param,
to: tabs,
// __from: 'dashboard',
self: this,
cgi: cgi };
if (blockId) {
grActParam.__from = 'dashboard';
grActParam.__blockId = blockId;
}
groupActionHandler.apply(window, [{}, grActParam ]);
} else if (type === 'window') {
paramString += '&func=' + func;
window.open(url + '?' + paramString + '&newwindow=yes', '_blank');
}
}
//handler for modules with param elid plid
function actionControllerWithParam(e, data) {
var i = 0, paramString,
self = $(this),
type = this.getAttribute('data-type'),
cgi = this.getAttribute('data-cgi'),
name = this.getAttribute('data-name'),
updateTab = App.Dom.hasClass(this, 'updatetab'),
newTab = App.Dom.hasClass(this, 'newtab'),
classes = self.attr('class'),
href, parent, re, url, param = {}, targetTabId, plid,
moreOne = false,
hasProgressBar = false,
tabId, tconvert, progressid, iType, rParent, elems, l, rl;
param.plid = '';
href = this.getAttribute('data-url');
parent = this.getAttribute('data-parent');
tabId = parent;
if (type !== 'new' && type !== 'list' && type !== 'url' && type !== 'windownosel') {
if (self.parents('.toolbar').attr('data-plid') !== undefined) {
param.plid = filterXSS.friendlyAttrValue(self.parents('.toolbar').attr('data-plid') || '');
}
//check for map selected
if (selectedElems[tabId]) {
elems = selectedElems[tabId];
l = elems.length;
rl = l - 1;
while (l--) {
if (l !== rl) {
param.elid += ', ';
if (elems[l].name) {
param.name += ', ';
}
} else {
param.elid = '';
if (elems[l].name) {
param.name = '';
}
}
param.elid += elems[l].elid;
if (elems[l].name) {
param.name += elems[l].name;
}
}
//get form list
} else {
$selectedItems().each(function() {
if (i !== 0) {
param.elid += ', ';
moreOne = true;
} else {
param.elid = '';
}
param.elid += this.getAttribute('data-elid');
if (i === 0) {
param.elname = this.getAttribute('data-elkeyname');
} else if (param.elname) {
delete param.elname;
}
i++;
});
}
//check for elid for groupformnosel
if (type === 'groupformnosel') {
if (!param.elid) {
var firstRow = $firstListItem();
if (firstRow) {
param.elid = firstRow.getAttribute('data-elid');
}
}
}
tconvert = self.parents('.toolbar').attr('data-convert');
if (tconvert) {
param.tconvert = tconvert;
}
} else {
plid = filterXSS.friendlyAttrValue(self.parents('.toolbar').attr('data-plid') || '');
param.plid = plid || '';
}
re = new RegExp('/?func=+');
if (href.match(re)) {
url = cgi ? pageInfo.host + cgi : pageInfo.url;
href = href.replace('?', '');
paramString = href + '&elid=' + encodeURIComponent(param.elid) +
'&plid=' + encodeURIComponent(param.plid);
param.func = href.replace('func=', '');
//check for progressbar
progressid = this.getAttribute('data-progressid') + this.getAttribute('data-itemid');
if (this.getAttribute('data-progressbar')) {
hasProgressBar = true;
}
//choose type
if (type === 'window' || type === 'groupwindow' || type === 'windownosel') {
window.open(url + '?' + paramString + '&newwindow=yes', '_blank');
return false;
//groupedit
} else if (type === 'edit' && moreOne) {
param.faction = param.func;
param.func = 'groupedit';
hasProgressBar = true;
EventMgr.trigger('clickedGroupItem', {
invar: {
url: url,
tabId: tabId,
params: param,
newTab: newTab,
parent: parent,
type: type,
updateTab: updateTab,
name: name,
hasProgressBar: hasProgressBar,
progressid: progressid
},
tabId: tabId,
classes: classes,
triggerAction: 'requestListAction'
});
return false;
} else if (type === 'url') {
if (cgi) {
App.u.openInNewWindow(url, '_blank');
} else {
App.u.openInNewWindow(param.func, '_blank');
}
return false;
}
//trigger requestAction here
EventMgr.trigger('requestListAction', {
url: url,
params: param,
newTab: newTab,
parent: parent,
tabId: tabId,
type: type,
updateTab: updateTab,
name: name,
hasProgressBar: hasProgressBar,
progressid: progressid
});
} else {
//what else?
console.log(href);
}
//call progressbar if needed
if (e) { e.preventDefault(); }
}
function requestAction(e, data) {
var url = data.url,
param = data.params,
tabId = data.tabId,
newTab = data.newTab,
parent = data.parent,
type = data.type,
name = data.name,
updateTab = data.updateTab,
hasProgressBar = data.hasProgressBar,
progressid = data.progressid,
iType,
rParent,
targetTabId;
if (hasProgressBar) {
param.progressid = progressid;
setTimeout(function() {
var param1 = {
elid: progressid,
func: 'progress.get',
sfrom: 'ajax' };
EventMgr.trigger('ajaxRequest', {
param: param1,
invar: {
tabId: tabId,
param: param1,
type: '',
progresstype: undefined },
type: 'get',
outtype: 'json',
trfunc: 'progressBarResponse',
queue: 'noqueue' });
}, 700);
}
//call function and refresh list after (like group action)
if (type === 'refresh' || type === 'action') {
EventMgr.trigger('ajaxRequest', {
url: url,
param: param,
invar: { tabId: tabId, __src: 'toolbarAction-refresh' },
type: 'get',
trfunc: 'ajaxGroupComplete',
outtype: 'json',
queue: 'noqueue',
failfunc: 'failCommonAjaxResponse' });
EventMgr.trigger('tabLoading', { tabId: tabId });
return false;
} else if (updateTab) {
targetTabId = parent;
iType = 'replace';
//flag for remember parent
rParent = true;
parent = null;
}
if (newTab) {
parent = null;
}
//param = APP.common.parseParams(param);
EventMgr.trigger('ajaxRequest', {
url: url,
param: param,
invar: {
dataSaved: true,
newtab: newTab,
parent: parent,
targetTabId: targetTabId,
iType: iType,
__srcBtn: name,
__src: 'toolbarAction',
rParent: rParent },
type: 'get',
outtype: 'json',
trfunc: 'ajaxResponse',
failfunc: 'failCommonAjaxResponse',
queue: 'noqueue' });
if (!newTab) {
EventMgr.trigger('tabLoading', { tabId: tabId });
}
}
function actionPreviewHandler(e) {
var $self = $(this),
plid = '',
elid = '',
i = 0,
href = this.getAttribute('data-url'),
$fakeNode = $('#b-lightbox-fake-link');
if ($self.parents('.toolbar').attr('data-plid') !== undefined) {
plid = filterXSS.friendlyAttrValue($self.parents('.toolbar').attr('data-plid') || '');
}
$selectedItems().each(function() {
if (i !== 0) {
elid += ', ';
} else {
elid = '';
}
elid += this.getAttribute('data-elid');
i++;
});
$fakeNode.attr('href', '?' + href + '&elid=' + elid + '&plid=' + plid);
$fakeNode.trigger('click');
}
//hotkey handler for toolbtn
function hotKeysHandler(e, d) {
if (d && d.key && d.keys && d.len) {
if (window.document.activeElement && window.document.activeElement.getAttribute('type')) {
return;
}
var hotKeyClass = 'hotkey-';
//check for CTRL
if (d.ctrl) {
hotKeyClass += 'Ctrl-';
}
//check for SHIFT
if (d.shift) {
hotKeyClass += 'Shift-'
}
hotKeyClass += d.key;
var $toolbtn = $('.tab-content_st_active .' + hotKeyClass);
if ($toolbtn.length) {
$toolbtn.find('.img-link').trigger('click');
}
}
}
//DbClick on table row
function actionDbClickController(e) {
if (e) { e.preventDefault(); }
blockSelection();
var $toolBarBtn = $('.tab-content_st_active' +
' .toolbar-button.active .img-link.default');
if ($toolBarBtn.length > 0) {
if ($toolBarBtn.hasClass('group')) {
groupAction.apply($toolBarBtn);
} else if ($toolBarBtn.hasClass('action-preview')) {
actionPreviewHandler.apply($toolBarBtn[0]);
} else {
actionControllerWithParam.apply($toolBarBtn[0]);
}
EventMgr.trigger('hideContextIcon');
}
}
//list pager handler
function pagerHandler(e, data) {
var tabCont = $(this).parents('.tab-content'),
tabId = tabCont.attr('data-tabid'),
pCnt = $('#cont-' + tabId + ' .page_cnt .cnt').val(),
pNum = this.getAttribute('data-n'),
/* jslint camelcase: false */
param = { p_num: pNum, p_cnt: pCnt };
/* jslint camelcase: true */
EventMgr.trigger('reloadTab', { tabId: tabId, param: param });
}
function slistPagerHandler(e, data) {
var pNum = $(this).val(),
//@todo move to variable
tabCont = $('.tab-content_st_active'),
tabId = tabCont.attr('data-tabid'),
pCnt = $('#cont-' + tabId + ' .page_cnt .cnt').val(),
/* jslint camelcase: false */
param = {
p_num: pNum,
p_cnt: pCnt
};
/* jslint camelcase: true */
EventMgr.trigger('reloadTab', { tabId: tabId, param: param });
}
//pager input in list
function pagerInputHandler(e, data) {
var code = e.keyCode || e.which,
select;
if (code === 13) {
select = $('.tab-content_st_active ' +
'.pager-wrapper input[name="pager-slist"]');
if (select.val() !== 1) {
select.val(1);
}
slistPagerHandler.apply(select);
e.preventDefault();
}
}
//pager ok button handler
function pagerBtnHandler(e) {
var select = $('.tab-content_st_active ' +
'.pager-wrapper input[name="pager-slist"]');
if (select.val() !== 1) {
select.val(1);
}
slistPagerHandler.apply(select);
e.preventDefault();
}
//handler for tsetting button in list
function actionControllerTsetting(e) {
var href = this.getAttribute('data-url'),
parent = this.getAttribute('data-parent'),
re = new RegExp('/?func=+'),
queue = 'menu',
newtab = false,
url, param;
if (href) {
if (href.match(re)) {
url = pageInfo.url;
href = href.replace('?', '');
// convert string to object
param = App.Common.parseParams(href);
//noesc param
EventMgr.trigger('ajaxRequest', {
url: url,
param: param,
noesc: true,
invar: {
parent: parent,
newtab: newtab,
__src: 'tSetting',
__srcBtn: 'tsetting'
},
type: 'get',
outtype: 'json',
trfunc: 'ajaxResponse',
queue: queue,
failfunc: 'failCommonAjaxResponse'});
EventMgr.trigger('tabLoading', { tabId: parent });
} else {
//what else?
console.log(url);
}
}
if (e) { e.preventDefault(); }
}
//open list and form form dashboard
function dashBoardButtonHandler(e) {
e.preventDefault();
var type = this.getAttribute('data-type'),
func = this.getAttribute('data-func'),
form = this.getAttribute('data-form'),
name = this.getAttribute('data-name'),
tabs, self, rows, tabid, confirm, blockId,
funcParam = App.Common.parseParams(func),
funcForm = App.Common.parseParams(form);
if (type === 'group') {
self = $(this);
blockId = self.closest('.b-form-page_view_dblock').attr('data-tabid'),
rows = self.parents('tr').attr('data-elid');
tabid = undefined;
confirm = self.parents('table.list_table')
.find('div[data-confirm-' + name + ']')
.attr('data-confirm-' + name);
tabs = [
[
{ status: 1, title: '', params: funcParam }
]
];
var grActParam = {
confirm: confirm,
rows: rows,
tabId: tabid,
to: tabs,
self: this,
params: funcForm };
if (blockId) {
grActParam.__from = 'dashboard';
grActParam.__blockId = blockId;
}
groupActionHandler.apply(window, [{}, grActParam]);
return;
} else {
//if not defined func list open only form
if (!funcParam.func) {
tabs = [
[
{ status: 1, title: '', params: funcForm }
]
];
} else {
tabs = [
[
{ status: 1, title: '', params: funcParam },
{ status: 1, title: '', params: funcForm }
]
];
}
//tabs = { 0 : [funcParam, funcForm] };
}
EventMgr.trigger('multiLoadTab', { tabs: tabs, isNotInit: true });
}
function editFormHandler(e) {
e.preventDefault();
var $self = $(this),
elid = $self.closest('.b-list__table-row').attr('data-elid'),
index = $self.closest('td').index(),
th = $self.closest('table').find('th')[index],
editFunc = th.getAttribute('data-editform'),
tabCont = $self.closest('.tab-content'),
tabId = tabCont.attr('data-tabid'),
toolbarNode = App.Dom.byId('toolbar-' + tabId),
invar = {},
param = {
func: editFunc,
elid: elid
},
plid;
if (toolbarNode) {
plid = filterXSS.friendlyAttrValue(toolbarNode.getAttribute('data-plid') || '');
if (plid) {
param.plid = plid;
}
}
if (tabId !== 'tab0') {
invar.parent = tabId;
}
EventMgr.trigger('ajaxRequest', {
param: param,
invar: invar,
type: 'get',
outtype: 'json',
trfunc: 'ajaxResponse',
queue: 'dashboard',
failfunc: 'failCommonAjaxResponse' });
}
function dummyToolbtnHandler(e) {
if (e) {
e.preventDefault();
}
}
function init() {
EventMgr.on($content(), actionBannerSelector, 'click', bannerAction);
EventMgr.on($content(), backBtnListSelector, 'click', backBtnHandlerList);
EventMgr.on($content(), breadcrumbSelector, 'click', breadcrumbHandler);
EventMgr.bind('listSelectedData', groupActionHandler);
EventMgr.bind('requestListAction', requestAction);
EventMgr.on($content(), controlPropSelector, 'click', controlPropHandler);
EventMgr.on($content(), toolBarBtnGroupActSel, 'click', groupAction);
EventMgr.on($content(), toolBarBtnSel, 'click', actionControllerWithParam);
EventMgr.on($content(), toolBarBtnPreviewSel, 'click', actionPreviewHandler);
EventMgr.on($content(), pageNumListSelector, 'click', pagerHandler);
EventMgr.bind('updateSelectedElems', updateSelectedElems);
EventMgr.bind('appendForm', updateSelectedElemsForForm);
EventMgr.bind('closeTabEvent', removeSelectedElems);
EventMgr.on($content(), tSettingSel, 'click', actionControllerTsetting);
EventMgr.bind('ajaxGroupComplete', reloadAfterGroupAction);
EventMgr.on($content(), rowTableSel, 'dblclick', actionDbClickController);
EventMgr.on($content(), pagerInputSel, 'keydown', pagerInputHandler);
EventMgr.on($content(), pagerBtnSelector, 'click', pagerBtnHandler);
EventMgr.on($content(), pagerSlistSel, 'change', slistPagerHandler);
EventMgr.on($content(), dashboardButtonSel, 'click', dashBoardButtonHandler);
EventMgr.on($content(), nestedListSel, 'click', nestedListHandler);
EventMgr.on($content(), editFormSel, 'click', editFormHandler);
EventMgr.on($content(), dummyToolbtn, 'click', dummyToolbtnHandler);
EventMgr.bind('otherKeyUp', hotKeysHandler);
}
var api = {
init: init
};
return api;
}(window, $, EventMgr, App);