function getDayList(num){ var result = []; for(var i = 1; i <= num; i++){ result.push({'name' : i.toString(), 'value' : i.toString()}); } return result; } ////////////////////////////////ПЕРЕКЛЮЧЕНИЕ ОТОБРАЖЕНИЯ ТУДА ОБРАТНО И ТОЛЬКО ТУДА/////////////////////////// //var blocks = ['mapBlockId','calendarThereBlockId','calendarBlockId']; function toggleBlocks(id, blocks, backBlockId, changedBlockWrapper) { var otherBlocks = jQuery.grep(blocks, function(value) { return value != id; });//все блоки кроме id if (jQuery('#'+id).is(':visible')) { hideBlock(id, backBlockId);//скрываем блок } else{ var anotherBlockWasVisible = false; jQuery.each(otherBlocks,function(index, value){//обход остальных блоков if (jQuery('#'+value).is(':visible')) { //если другой блок виден anotherBlockWasVisible = true; toggleFadeBlock(value, id, changedBlockWrapper);//переключаем видимость и выходим return false; } }); if(!anotherBlockWasVisible)showBlock(id, backBlockId);//если ни один из других блоко в не виден, то показываем } } function toggleFadeBlock(id1,id2, backBlockId, changedBlockWrapper){ var sizeStart = jQuery('#'+id1).outerHeight({margin:true}); var sizeStop = jQuery('#'+id2).outerHeight({margin:true}); if(sizeStart != sizeStop){ jQuery('#' + changedBlockWrapper).animate({height:sizeStop+'px'}, aniSpeed, function(){}); } jQuery("#" + backBlockId + ".params-segment-back-open").switchClass('params-segment-back-open', 'params-segment-back-close', aniSpeed); setTimeout(function() { jQuery("#" + backBlockId + ".params-segment-back-close").switchClass('params-segment-back-close', 'params-segment-back-open', aniSpeed) }, aniSpeed) jQuery('#'+id1).fadeOut(aniSpeed, function(){ jQuery('#'+id2).fadeIn(aniSpeed, function(){ jQuery('#' + changedBlockWrapper).css({height:'auto'}); }) }); return false; } function hideBlock(id, backBlockId){ jQuery('#'+id).effect('slidev',{direction: 'up',mode:'hide'}, aniSpeed, function (){}); return false; } function showBlock(id, backBlockId){ //showDirectionBack(true, backBlockId); jQuery('#'+id).effect('slidev',{direction: 'up',mode:'show'}, aniSpeed, function (){}); return false; } function toggleThereAndBack(o, backBlockId, changedBlockWrapper) { if (o.val() == 'ThereAndBack') { if(jQuery('#calendarThereBlockId').is(':visible')) toggleFadeBlock("calendarThereBlockId","calendarBlockId", backBlockId, changedBlockWrapper); jQuery('#thereTable').hide(); jQuery('#thereAndBackTable').show(); } else { if(jQuery('#calendarBlockId').is(':visible')) toggleFadeBlock("calendarBlockId","calendarThereBlockId", changedBlockWrapper); jQuery('#thereAndBackTable').hide(); jQuery('#thereTable').show(); } } function toggleThereAndBackDouble(o, backBlockId, changedBlockWrapper) { if (o.val() == 'ThereAndBack') { if(jQuery('#calendarThereBlockId').is(':visible')) toggleFadeBlock("calendarThereBlockId","doubleCalendarBlockIdThere", backBlockId, changedBlockWrapper); jQuery('#thereTable').hide(); jQuery('#thereAndBackTable').show(); } else { if(jQuery('#doubleCalendarBlockId').is(':visible')) toggleFadeBlock("doubleCalendarBlockId","calendarThereBlockId", changedBlockWrapper); if(jQuery('#doubleCalendarBlockIdThere').is(':visible')) toggleFadeBlock("doubleCalendarBlockIdThere","calendarThereBlockId", changedBlockWrapper); jQuery('#thereAndBackTable').hide(); jQuery('#thereTable').show(); } } ////////////////////////////////END ПЕРЕКЛЮЧЕНИЕ ОТОБРАЖЕНИЯ ТУДА ОБРАТНО И ТОЛЬКО ТУДА/////////////////////////// function calendarThereAndBackClick() { if (!jQuery('#calendarBlockId').is(':visible')) { toggleBlocks('calendarBlockId'); } } function calendarThereOnlyClick() { if (!jQuery('#calendarThereBlockId').is(':visible')) { toggleBlocks('calendarThereBlockId'); } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // функция устанавливает иконки времени суток + устанавливает в комбобокс значение времени суток function setTimeDirectionPeriod(dayInput, monthInput, timeInputId2, timeString, timeStringFull) { var date = timeStringFull.split("."); var date1 = timeString.split("."); if(date[0].charAt(0)=="0") date[0] = date[0].substring(1); //"1", "Январь", "2012" if(date1[1].charAt(0)=="0") date1[1] = date1[1].substring(1); // "01", "1", "2012" dayInput.selectValue({'name' : date[0], 'value' : date[0]}); monthInput.selectValue({'name' : date[1]+" "+date[2], 'value' : parseInt(date1[1])-1+" "+date[2]}); //alert(parseInt(date1[1])); jQuery(timeInputId2).val(timeString); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // функция возвращает дату по строке удовлетворяющей паттерну dd.mm.yyyy function parseDirectionDate(dateString) { var d = dateString; var t = d.split('.'); var tmp = t[1]; t[1] = t[0]; t[0] = tmp; var xxx = t.join('/'); return new Date(xxx); } function setTimeDirectionPeriodDouble(dayInput, monthInput, timeInputId2, timeString, timeStringFull) { var date = timeStringFull.split("."); dayInput.selectValue({'name' : date[0], 'value' : date[0]}); monthInput.selectValue({'name' : date[1]+" "+date[2], 'value' : date[1]+" "+date[2]}); jQuery('#' + timeInputId2).val(timeString); }