Your IP : 18.219.40.177
/**
* ScrollController
* requires ScrollHandler!!!
* @param {object} window global object
* @param {function} $ jQuery library
* @param {object} EventMgr EventMgr library
* @param {object} App Application
* @param {object} ScrollHandler Scrollbar library
*/
App.ScrollController = function(window, $, EventMgr, App, ScrollHandler) {
'use strict';
var init = function() {
EventMgr.bind('menuTypeChanged', updateScroll);
EventMgr.obind($window(), 'resize', updateScroll);
EventMgr.bind('updateScroll', updateScroll);
EventMgr.bind('loadPage', attachScrollMenu);
EventMgr.bind('appendForm,appendedFilter', attachScrollTabtoForm);
EventMgr.bind('appendToolbarAce', attachScrollToToolbarAce);
EventMgr.bind('appendReport', attachScrollTabtoForm);
EventMgr.bind('appendList', attachScrollTabtoList);
EventMgr.bind('appendMapDone', attachScrollTabtoRack);
EventMgr.bind('loadLoginForm', attachScrolltoLoginForm);
EventMgr.bind('appendDashboard', attachScrollTabtoDB);
EventMgr.bind('appendDashList', attachScrolltoBlockDB);
EventMgr.bind('closeTabEvent', detachScroll);
EventMgr.bind('scrollTo', scrollTo);
},
$window = function() {
return $(window);
},
updateScroll = function(e, data) {
if (data && data.id) {
ScrollHandler.update(data.id);
} else {
ScrollHandler.update();
}
data = null;
},
detachScroll = function(e, data) {
ScrollHandler.detach(data.tabId);
data = null;
},
attachScrollMenu = function() {
setTimeout(function() {
ScrollHandler.attach('menu-items-wr', 'menu-items', 'tab0');
}, 10);
},
attachScrolltoBlockDB = function(e, data) {
var blockId = data.tabId,
cont = blockId + '-scrollwrapper',
obj = 'lt-' + blockId;
ScrollHandler.attach(cont, obj, blockId, true, true);
data = null;
},
//вешаем сколл на форму
attachScrollTabtoForm = function(e, data) {
setTimeout(function() {
var tabId = data.tabId;
ScrollHandler.attach('form-scroll-' + tabId,
'form-scroll-in-' + tabId, tabId, true);
$('#frm-' + tabId + ' .band-table').each(function() {
var id = this.id;
ScrollHandler.attach(id, 'lt-' + id, tabId, true, true);
});
$('#frm-' + tabId + ' .b-form-list_view_table').each(function() {
var id = this.id;
ScrollHandler.attach(id, 'inner-' + id, tabId, true, true);
});
// for select
$('#frm-' + tabId + ' .b-myselect__select-ul').each(function() {
var id = this.getAttribute('id');
ScrollHandler.attach('cont-' + id, id, tabId, true);
});
// for multiselect
$('#frm-' + tabId + ' .b-mselect__ul-choose').each(function() {
var id = this.getAttribute('data-id');
ScrollHandler.attach(id + '-ms-list',
id + '-ms-list-ul', tabId, true);
});
// for multiselect
$('#frm-' + tabId + ' .b-mselect__view-value').each(function() {
var id = this.getAttribute('data-id');
ScrollHandler.attach(this.id,
id + '-ms-view', tabId, true);
});
//for tree
$('#frm-' + tabId + ' .tree-inner').each(function() {
var id = this.getAttribute('id');
ScrollHandler.attach('cont-' + id, id, tabId, true, true);
});
//for select autocomplite
$('#frm-' + tabId + ' .b-select-ac__list').each(function() {
var id = this.getAttribute('id');
ScrollHandler.attach('cont-' + id, id, tabId, true);
});
// $('#frm-' + tabId + ' .b-textdata').each(function() {
// var id = this.getAttribute('id');
// ScrollHandler.attach(id, id + '-inner', tabId, true, true);
// });
tabId = null;
data = null;
}, 50);
},
attachScrollToToolbarAce = function(e, data) {
var tabId = data.tabId;
$('#frm-' + tabId + ' .b-myselect__select-ul').each(function() {
var id = this.getAttribute('id');
ScrollHandler.attach('cont-' + id, id, tabId, true);
});
},
attachScrollTabtoDB = function(e, data) {
var tabId = 'tab0';
ScrollHandler.attach('cont-' + tabId, 'incont-' + tabId, 'tab0', true);
tabId = null;
},
attachScrolltoLoginForm = function(e, data) {
$('.b-myselect__select-ul').each(function() {
var id = this.getAttribute('id');
ScrollHandler.attach('cont-' + id, id, 'tab1', true);
id = null;
});
},
attachScrollTabtoList = function(e, data) {
var tabId = data.tabId;
ScrollHandler.attach('ltwr-' + tabId, 'lt-' + tabId, tabId, true);
ScrollHandler.attach('cont-' + tabId + '-pager-slist',
tabId + '-pager-slist', tabId, true);
tabId = null;
},
attachScrollTabtoRack = function(e, data) {
if (data.map.type === 'rack') {
var tabId = data.tabId;
ScrollHandler.attach(tabId + '-map', 'b-rack-' + tabId, tabId, true);
}
},
scrollTo = function(e, data) {
var offsetTop = data.offsetTop,
id = data.id,
raw = data.raw,
animate = data.animate;
ScrollHandler.scrollTo(id, offsetTop, raw, animate);
};
return {
init: init
};
}(window, $, EventMgr, App, ScrollHandler);