/******************************************************************** ******* scrollbox.js ********************************************************************/ /********************************************************* * Scrollbox control ************************ * by Kozyuck Alexander, 2008 ************************ * kolexander@gmail.com ************************ *********************************************************/ var Scrollbox = Class.create(); Scrollbox.prototype = { initialize: function(parameters) { this.cont = $(parameters.contId); this.list = $(parameters.listId); if(typeof parameters.insertTo == 'undefined') this.insertTo = $('scrollrows') else this.insertTo = $(parameters.insertTo) if(typeof parameters.gauge == 'undefined') this.gauge = $('regauge'); else this.gauge = $(parameters.gauge); if(typeof parameters.scrollLeft == 'undefined') this.scrollLeft = 0; else this.scrollLeft = parameters.scrollLeft; this.offsetDiv = 10; this.repeatTm = 5; this.timer = null; this.downButton = false; this.nomoreRows = false; this.countFetchRows = 20; this.fromVal = 0; if(typeof parameters.prevButton == 'undefined') this.prevButton = $('prev'); else this.prevButton = $(parameters.prevButton); if(typeof parameters.nextButton == 'undefined') this.nextButton = $('next'); else this.nextButton = $(parameters.nextButton); if(typeof parameters.fetching == 'undefined') this.fetching = false; else this.fetching = parameters.fetching; if(typeof parameters.fromUrl == 'undefined') this.fromUrl = '/main/fetch'; else this.fromUrl = parameters.fromUrl; if(typeof parameters.fetchParams == 'undefined') this.fetchParams = null; else this.fetchParams = parameters.fetchParams; if(typeof parameters.direction == 'undefined') this.direction = 'vertical'; else this.direction = parameters.direction; try { if(typeof parameters.prevButton != 'undefined') { this.prevButton.onmousedown = this.pressPrevButton.bindAsEventListener(this); this.prevButton.onmouseup = this.releaseButton.bindAsEventListener(this); this.prevButton.onmouseout = this.releaseButton.bindAsEventListener(this); } if(typeof parameters.nextButton != 'undefined') { this.nextButton.onmousedown = this.pressNextButton.bindAsEventListener(this); this.nextButton.onmouseup = this.releaseButton.bindAsEventListener(this); this.nextButton.onmouseout = this.releaseButton.bindAsEventListener(this); } } catch(error) {} }, setGaugeHidden: function(){ this.gauge.style.visibility = 'hidden'; }, setGaugeVisible: function(){ this.gauge.style.left = this.cont.offsetLeft+Math.round((this.cont.offsetWidth-this.gauge.offsetWidth)/2)+'px'; this.gauge.style.top = this.cont.offsetTop+Math.round((this.cont.offsetHeight-this.gauge.offsetHeight)/2)+'px'; this.gauge.style.visibility = 'visible'; }, dec: function(val) { var par = parseInt(val); val = (isNaN(par))?0:par - this.offsetDiv; return val+"px"; }, inc: function(val) { var par = parseInt(val); val = (isNaN(par))?0:par + this.offsetDiv; return val+"px"; }, pressPrevButton: function() { this.downButton = true; this.scrollPrev(); }, pressNextButton: function() { this.downButton = true; this.scrollNext(); }, releaseButton: function() { this.downButton = false; }, scrollPrev: function() { if(this.downButton) { //если долистали в начало if((this.direction=='horizontal'&&parseInt(this.list.style.left) >= this.scrollLeft) || (this.direction=='vertical'&&parseInt(this.list.style.top) >= this.scrollLeft)) { this.downButton = false; clearTimeout(this.timer); this.onAfterScroll(); return; } if(this.direction=='horizontal') this.list.style.left = this.inc(this.list.style.left); if(this.direction=='vertical') this.list.style.top = this.inc(this.list.style.top); this.timer = setTimeout( function(){ this.scrollPrev() ; }.bind(this), this.repeatTm) } else clearTimeout(this.timer); }, scrollNext: function() { if(this.downButton) { //если долистали до конца if((this.direction=='horizontal' && ((-1)*parseInt(this.list.offsetLeft) > (parseInt(this.list.offsetWidth) - parseInt(this.cont.offsetWidth) - this.scrollLeft))) || (this.direction=='vertical' && ((-1)*parseInt(this.list.offsetTop) > (parseInt(this.list.offsetHeight) - parseInt(this.cont.offsetHeight))) )) { this.downButton = false; clearTimeout(this.timer); this.fromVal += this.countFetchRows; if(!this.nomoreRows && this.fetching) this.fetchNextBlock(); this.scrollLeft = 0; this.onAfterScroll(); return; } if(this.direction=='horizontal') this.list.style.left = this.dec(this.list.style.left); else this.list.style.top = this.dec(this.list.style.top); this.timer = setTimeout( function(){ this.scrollNext(); }.bind(this), this.repeatTm); } else clearTimeout(this.timer); }, scrollBegin: function() { this.downButton = true; this.scrollPrev(); }, scrollEnd: function() { this.downButton = true; this.scrollNext(); }, fetchNextBlock: function() { this.setGaugeVisible(); var sfparm = ''; for(fparm in this.fetchParams) { sfparm += '&'+fparm+'='+this.fetchParams[fparm] } new Ajax.Updater(this.insertTo.id, this.fromUrl,{ method: "post", parameters:sfparm+"&offset=" + this.fromVal + "&rowcount=" + this.countFetchRows, //&light=1 insertion: Insertion.Bottom, onComplete: this.handleResponse.bind(this), onFailure: this.reportError.bind(this) } ); }, onAfterScroll: function (){ }, handleResponse: function(response) { if(response.responseText.length == 0) this.nomoreRows = true; this.setGaugeHidden(); }, reportError: function(err) { } } /******************************************************************** ******* main.js ********************************************************************/ initCommon(); var curl = '/'+curlang+'/'; var ajaxExecuting = false; function pressAjaxTab(tab, tabname){ var tab = $('a'+tabname); tab = tab.parentNode.parentNode.parentNode.parentNode.parentNode; var points = document.getElementsByClassName('ajaxtab-act',tab.parentNode); if(points.length > 0) points[0].className = 'ajaxtab'; tab.className = 'ajaxtab-act clrsbg'; switch(tabname) { case '7days': $('allmaps_7days').show(); $('allmaps_satellite').hide(); $('allmaps_water').hide(); $('allmaps_maps').hide(); $('allmaps_road').hide(); break; case 'satellite': //status = $('allmaps_satellite_img').width + ',' + $('allmaps_satellite_img').height; $('allmaps_7days').hide(); $('allmaps_satellite').show(); $('allmaps_water').hide(); $('allmaps_maps').hide(); $('allmaps_road').hide(); $('allmaps_satellite_img').src = allmaps_satellite_imgsrc; break; case 'water': //status = $('allmaps_water_img').width + ',' + $('allmaps_water_img').height; $('allmaps_7days').hide(); $('allmaps_satellite').hide(); $('allmaps_water').show(); $('allmaps_maps').hide(); $('allmaps_road').hide(); $('allmaps_water_img').src = ''; $('allmaps_water_img').src = allmaps_water_imgsrc; break; case 'maps': //status = $('allmaps_water_img').width + ',' + $('allmaps_water_img').height; $('allmaps_7days').hide(); $('allmaps_satellite').hide(); $('allmaps_water').hide(); $('allmaps_road').hide(); $('allmaps_maps').show(); $('allmaps_maps_img').src = ''; $('allmaps_maps_img').src = allmaps_maps_imgsrc; break; case 'road': $('allmaps_7days').hide(); $('allmaps_satellite').hide(); $('allmaps_water').hide(); $('allmaps_maps').hide(); $('allmaps_road').show(); $('allmaps_road_img').src = ''; $('allmaps_road_img').src = allmaps_road_imgsrc; break; } // fix(); } function getAjaxWeather(obj, daynum, block, city_name_url) { if(ajaxExecuting) return; var divblock = $('cwblock_'+block); var calpoints = document.getElementsByClassName('calday-act',divblock); if(calpoints.length > 0) { for(var i=0; i 0){ seq = unserialize2array(seq); //add to show block var seq2 = new Array(); seq2[0] ='cwblock_7'; var mark = false; for(var i = 0, m =1; i < seq.length; i++) { if(seq[i]=='cwblock_7') mark = true; seq2[m++] =seq[i]; } if(!mark) seq = seq2; for(var i = 0; i < seq.length; i++) { if(String(seq[i]) != 'undefined' && String(seq[i]).length > 0) { doWidget(portal, seq[i]); } } } else { doWidget(portal, 'cwblock_7'); doWidget(portal, 'cwblock_0'); doWidget(portal, 'cwblock_1'); doWidget(portal, 'cwblock_2'); doWidget(portal, 'cwblock_6'); doWidget(portal, 'cwblock_3'); doWidget(portal, 'cwblock_4'); doWidget(portal, 'cwblock_5'); } try { $('offsets').update(''); $('offsets').setStyle({height:'0px'}); $('offsets').remove();//очищаем сдвиги для главных блоков } catch(error) {} try { $('list1').hide(); $('list1').show(); } catch(error) {} } //Event.observe(window, "load", init); var scroller = new Scrollbox({ contId:'cont1', listId:'list1', insertTo:'scrollrows1', prevButton:'prev', nextButton:'next' //,fetching:true, //fromUrl:'/main/fetchcities/' }); /*function bindHeadersOver(){ for(var i=0;i<=6;i++) { // Event.observe($('cwblock_'+i+'_hdr'), 'mouseover', function(event) { var el = Event.element(event); if((el.tagName=='TABLE')&&el.hasClassName("block-hdr")) { hdrOver(el); } }); Event.observe($('cwblock_'+i+'_hdr'), 'mouseout', function(event) { var el = Event.element(event); if((el.tagName=='TABLE')&&el.hasClassName("block-hdr")) { hdrOut(el); } }); } }*/ function bindPressAjaxTabs() { try{ $('aroad').onclick = function() {pressAjaxTab($('aroad'),'road')}; $('a7days').onclick = function() {pressAjaxTab($('a7days'),'7days')}; $('asatellite').onclick = function() {pressAjaxTab($('asatellite'),'satellite')}; $('awater').onclick = function() {pressAjaxTab($('awater'),'water')}; $('amaps').onclick = function() {pressAjaxTab($('amaps'),'maps')}; } catch(error) {} } try {bindPressAjaxTabs(); } catch(error) {} try { bindMainBlocksHeadersOver(); } catch(error) {} try {doMainWeatherBlocks(); } catch(error) {} try { doMainBlockOptions(); } catch(error) {}