function load_css_file(filename) {
var css = document.createElement('link');
css.rel = 'stylesheet';
css.type = 'text/css';
css.href = filename;
document.getElementsByTagName('head')[0].appendChild(css);
}
load_css_file("https://www.ittour.com.ua/classes/handlers/ittour_external_modules/ittour_modules/new/css/module_search/style_all_in_file.css?v=8");
function load_css_string(css) {
var style = document.createElement('style');
style.setAttribute("type", "text/css");
if(style.styleSheet) { // IE
style.styleSheet.cssText = css;
} else { // the world
var tt1 = document.createTextNode(css);
style.appendChild(tt1);
}
document.getElementsByTagName('head')[0].appendChild(style);
}
load_css_string('.itt_bg-color, .itt_multiple-sel .scrollbarY .selected, .itt_advanced-search a > em,.itt_col-right .itt_active img { background-color: #1D88D0 !important;}.itt_text-color, .itt_col-right .itt_active a { color: #1D88D0;}.itt_tab-content, .itt_tab-block .itt_tabset, .itt_search-module .itt_tabset li { background-color: #F7F5F5 !important;}#tab-1 .itt_pop-up-place{ border-color: #1D88D0 !important;}#itt_tour_type_chosen .chosen-drop li.highlighted { color: #1D88D0 !important;}#tour_search_module_mod2 .itt_hike_search_result_table tr td{ background-color: #F7F5F5 !important;}.itt_form-tours{ background-color: #F7F5F5 !important;}.itt_bg-color_conten { background-color: #F7F5F5 !important;}a.itt_bg-color_conten_border_bottom.is-active { border-bottom: 1px solid #F7F5F5 !important;}.itt_tour_search_button_with_color,#itt-module-search-mobile button.itt_tour_search_button_with_color { background-color: #1D88D0 !important; color: #FAFAFA !important;}#tour_search_module_mod2 div.itt_custom_select_piptik_small { color: #818181 !important;}#tour_search_module_mod2 div.itt_custom_select_piptik_big { background-color: #818181 !important;}#tour_search_module_mod2 .itt_headt_title_color { color: #1E1E1E !important;}#tour_search_module_mod2 .itt_search_module_tab_head { color: #1E1E1E !important;}#tour_search_module_mod2 .itt_search_module_tab_head a { color: #1E1E1E !important; font-size: inherit;}#tour_search_module_mod2 ul.itt_search_module_tab li.itt_search_module_tab_head div.itt_search_module_calendar_icons { background-color: #818181 !important;}#tour_search_module_mod2 span.itt_top_glyphicon_select,#tour_search_module_mod2 span.itt_down_glyphicon_select { color: #818181 !important;}#itt_tabs_search_result { margin: 15px 0px 0px 0px; padding: 0px 5px 0px 5px; border: 0px; display:none;}#itt_tabs_search_result li.ui-state-default { display: inline; background-color: #F7F5F5 !important; margin: 2px 2px 0px 2px; padding: 8px 10px 9px 8px; -moz-border-radius: 7px 7px 0px 0px;-webkit-border-radius: 7px 7px 0px 0px;-khtml-border-radius: 7px 7px 0px 0px;border-radius: 7px 7px 0px 0px; }#itt_tabs_search_result li.ui-state-default.ui-state-active { display: inline; background-color: #1D88D0 !important;}#itt_tabs_search_result ul li a { color: #000000; text-decoration: none;}#itt_tabs_search_result ul.ui-tabs-nav { border-bottom: #1D88D0 solid 2px; height: 29px; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;}#itt_tabs_search_result ul.ui-helper-reset { line-height: 1.35 !important;}#itt_tabs_search_result ul.ui-tabs-nav { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;}#itt_tabs_search_result ul.ui-tabs-nav li { white-space:nowrap;}#itt_tour_search_load_item_tour { display: none;}#itt_tour_search_load_view_item_tab { text-align: center; margin: 20px auto 0; display: none;}div.itt_head-line > .ui-widget-header { background: none;}#tour_search_module_mod2 div.itt_price_color_in_result_search,#itt-module-search-mobile .itt-msm-result-wrap a.itt_price_color_in_result_search { color: #2EB53C !important;}#itt_issuing_search_package_tours a.itt_issuing_search_tours_name_link_castom,#itt-module-search-mobile .itt-msm-result-wrap a.itt_issuing_search_tours_name_link_castom { color: #2EB53C !important;}#itt_issuing_search_package_tours a.itt_read_more_button,#itt-module-search-mobile .itt-msm-result-wrap .itt_read_more_button_mobile { background: #1D88D0 !important;}#itt_issuing_search_package_tours a.itt_read_more_button:hover,#itt-module-search-mobile .itt-msm-result-wrap .itt_read_more_button_mobile:hover { background: #1D88D0 !important;}#itt-module-search-mobile .itt_main_text_color_mobile { color: #1E1E1E !important;}#itt-module-search-mobile .itt-mms-head-package-hike-switcher { background-color: #1D88D0 !important;}#itt-module-search-mobile div.itt-transportation-selected .prettycheckbox > a.checked { background: #1D88D0 !important;}');
function forEach(data, callback) {
if (data.length > 0) {
for (var key in data) {
if (data.hasOwnProperty(key)) {
callback(key, data[key]);
}
}
}
}
function isset(item) {
if (typeof item == 'undefined') {
return false;
}
return true;
}
var it_tsm_m2 = '';
it_tsm_m2 += '
';
it_tsm_m2 += '
';
it_tsm_m2 += '
';
it_tsm_m2 += '
';
it_tsm_m2 += '';
it_tsm_m2 += '
';
it_tsm_m2 += '
Подождите пожалуйста!';
it_tsm_m2 += '
Поиск туров...
';
it_tsm_m2 += '
';
it_tsm_m2 += '';
it_tsm_m2 += '
';
document.getElementById('tour_search_module_mod2').innerHTML = it_tsm_m2;
function load_js_and_html_for_jsx() {
// Javascript => new loader
ModuleLoader = {
path: null,
items:{
css: [],
js : [],
custom_css: '',
},
events:{
'before_load' : null,
'after_load' : null,
'load_js' : null,
'error' : null
},
setPath: function(path){
this.path = path;
return this;
},
getPath: function(){
return this.path;
},
addCss: function(filename, is_check_old_ver){
is_check_old_ver = isset(is_check_old_ver) ? is_check_old_ver : false;
this.items.css.push({'filename':filename, 'is_check_old_ver': is_check_old_ver});
return this;
},
addJs: function(filename, is_check_old_ver){
is_check_old_ver = isset(is_check_old_ver) ? is_check_old_ver : false;
this.items.js.push({'filename':filename, 'is_check_old_ver': is_check_old_ver});
return this;
},
addCustomCss: function(css){
this.items.custom_css += css;
},
load: function(){
this.triggerEvent('before_load');
this.loadCssFiles();
this.loadCustomCss();
this.loadJsFiles();
},
loadCssFiles: function(){
var links = document.getElementsByTagName('link');
forEach(this.items.css, function(key, file){
filename = ModuleLoader.getPath() + file.filename;
var css = document.createElement('link');
css.rel = 'stylesheet';
css.type = 'text/css';
css.href = filename;
var already_loaded_css = false;
if(file.is_check_old_ver){
for (var i = 0; i < links.length; i++){
if(links[i].getAttribute('href') === filename){
already_loaded_css = true;
return;
}
}
}
if(already_loaded_css == false){
document.getElementsByTagName('head')[0].appendChild(css);
}
});
},
loadJsFiles: function(num){
num = isset(num) ? num : 0;
if(isset(this.items.js[num])){
var do_on_load = function(script){
ModuleLoader.triggerEvent('load_js', script);
ModuleLoader.loadJsFiles(++num);
};
var script = document.createElement('script');
var filename = ModuleLoader.getPath() + this.items.js[num].filename;
var scripts = document.getElementsByTagName('script');
var head = document.getElementsByTagName("head")[0] || document.documentElement;
var already_loaded = false;
// Load js for full path 'https://......', use for google.maps
var filename_tmp = this.items.js[num].filename;
if (filename_tmp.indexOf('https://', 0) == 0) {
filename = this.items.js[num].filename;
}
script.type = 'text/javascript';
script.src = filename;
if(this.items.js[num].is_check_old_ver){
for (var i = 0; i < scripts.length; i++){
if(scripts[i].getAttribute('src') === filename){
already_loaded = true;
do_on_load(script);
return false;
}
}
}
if(already_loaded == false){
script.onload = script.onreadystatechange = function() {
if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete"){
do_on_load(script);
script.onload = script.onreadystatechange = null;
}
};
head.appendChild(script);
}
}else{
this.triggerEvent('after_load');
}
},
/*
* Loading custom css
* @param {string} css
*/
loadCustomCss: function(){
var css = this.items.custom_css;
var style = document.createElement('style');
style.setAttribute("type", "text/css");
if (style.styleSheet) { // IE
style.styleSheet.cssText = css;
} else { // the world
var tt1 = document.createTextNode(css);
style.appendChild(tt1);
}
document.getElementsByTagName('head')[0].appendChild(style);
},
setEvent: function(event, callback){
if(typeof callback == 'function'){
this.events[event] = callback;
}
return this;
},
triggerEvent: function(event, param){
if(this.events && typeof this.events[event] == 'function'){
this.events[event](param);
}
},
}
window.ModuleLoader = ModuleLoader;
//ModuleLoader.addCustomCss('.itt_bg-color, .itt_multiple-sel .scrollbarY .selected, .itt_advanced-search a > em,.itt_col-right .itt_active img { background-color: #1D88D0 !important;}.itt_text-color, .itt_col-right .itt_active a { color: #1D88D0;}.itt_tab-content, .itt_tab-block .itt_tabset, .itt_search-module .itt_tabset li { background-color: #F7F5F5 !important;}#tab-1 .itt_pop-up-place{ border-color: #1D88D0 !important;}#itt_tour_type_chosen .chosen-drop li.highlighted { color: #1D88D0 !important;}#tour_search_module_mod2 .itt_hike_search_result_table tr td{ background-color: #F7F5F5 !important;}.itt_form-tours{ background-color: #F7F5F5 !important;}.itt_bg-color_conten { background-color: #F7F5F5 !important;}a.itt_bg-color_conten_border_bottom.is-active { border-bottom: 1px solid #F7F5F5 !important;}.itt_tour_search_button_with_color,#itt-module-search-mobile button.itt_tour_search_button_with_color { background-color: #1D88D0 !important; color: #FAFAFA !important;}#tour_search_module_mod2 div.itt_custom_select_piptik_small { color: #818181 !important;}#tour_search_module_mod2 div.itt_custom_select_piptik_big { background-color: #818181 !important;}#tour_search_module_mod2 .itt_headt_title_color { color: #1E1E1E !important;}#tour_search_module_mod2 .itt_search_module_tab_head { color: #1E1E1E !important;}#tour_search_module_mod2 .itt_search_module_tab_head a { color: #1E1E1E !important; font-size: inherit;}#tour_search_module_mod2 ul.itt_search_module_tab li.itt_search_module_tab_head div.itt_search_module_calendar_icons { background-color: #818181 !important;}#tour_search_module_mod2 span.itt_top_glyphicon_select,#tour_search_module_mod2 span.itt_down_glyphicon_select { color: #818181 !important;}#itt_tabs_search_result { margin: 15px 0px 0px 0px; padding: 0px 5px 0px 5px; border: 0px; display:none;}#itt_tabs_search_result li.ui-state-default { display: inline; background-color: #F7F5F5 !important; margin: 2px 2px 0px 2px; padding: 8px 10px 9px 8px; -moz-border-radius: 7px 7px 0px 0px;-webkit-border-radius: 7px 7px 0px 0px;-khtml-border-radius: 7px 7px 0px 0px;border-radius: 7px 7px 0px 0px; }#itt_tabs_search_result li.ui-state-default.ui-state-active { display: inline; background-color: #1D88D0 !important;}#itt_tabs_search_result ul li a { color: #000000; text-decoration: none;}#itt_tabs_search_result ul.ui-tabs-nav { border-bottom: #1D88D0 solid 2px; height: 29px; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;}#itt_tabs_search_result ul.ui-helper-reset { line-height: 1.35 !important;}#itt_tabs_search_result ul.ui-tabs-nav { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;}#itt_tabs_search_result ul.ui-tabs-nav li { white-space:nowrap;}#itt_tour_search_load_item_tour { display: none;}#itt_tour_search_load_view_item_tab { text-align: center; margin: 20px auto 0; display: none;}div.itt_head-line > .ui-widget-header { background: none;}#tour_search_module_mod2 div.itt_price_color_in_result_search,#itt-module-search-mobile .itt-msm-result-wrap a.itt_price_color_in_result_search { color: #2EB53C !important;}#itt_issuing_search_package_tours a.itt_issuing_search_tours_name_link_castom,#itt-module-search-mobile .itt-msm-result-wrap a.itt_issuing_search_tours_name_link_castom { color: #2EB53C !important;}#itt_issuing_search_package_tours a.itt_read_more_button,#itt-module-search-mobile .itt-msm-result-wrap .itt_read_more_button_mobile { background: #1D88D0 !important;}#itt_issuing_search_package_tours a.itt_read_more_button:hover,#itt-module-search-mobile .itt-msm-result-wrap .itt_read_more_button_mobile:hover { background: #1D88D0 !important;}#itt-module-search-mobile .itt_main_text_color_mobile { color: #1E1E1E !important;}#itt-module-search-mobile .itt-mms-head-package-hike-switcher { background-color: #1D88D0 !important;}#itt-module-search-mobile div.itt-transportation-selected .prettycheckbox > a.checked { background: #1D88D0 !important;}');
var search_box;
var order_box;
var view_box;
var popupWin;
var search_request_active = false;
var ittour_order_id = '';
var default_serialize_module_form_search = '';
if(typeof(jQueryMod2) == 'undefined') {
jQueryMod2 = jQuery;
}
jQueryMod2(function() {
jQueryMod2('.itt_show_currency_popap').live('click', function(){
jQueryMod2('.itt_currency_popap').show();
});
jQueryMod2('.itt_currency_popap li').live('click', function(){
jQueryMod2('.itt_currency_popap').hide();
jQueryMod2('.itt_active_currency').removeClass('itt_active_currency');
jQueryMod2(this).addClass('itt_active_currency');
jQueryMod2('span[class^=itt_price_cur_list_]').hide();
jQueryMod2('.itt_price_cur_list_'+jQueryMod2(this).attr('show_cur')).show();
jQueryMod2('.itt_currency_popap_currency').text(jQueryMod2(this).text());
});
});
/**
* function set country and region name in input 'Страна, регион'
*
* @returns {undefined}
*/
function setCountryAndRegionNameInInputPackagePart(){
var strRegions = '';
jQueryMod2('#tour_search_module_mod2 .itt_country-region_popup .itt_region label.ui-state-active span').each(function(){
var regionText = jQueryMod2(this).html();
if (strRegions == '') {
strRegions = regionText;
} else {
strRegions = strRegions + ', ' + regionText;
}
});
// Chrck regions not empty
if (strRegions != '') {
// Get current country
var currentCountryText = jQueryMod2('#tour_search_module_mod2 .itt_multiple-sel .overview div.selected span').html();
var finalTextForInput = strRegions;
if (currentCountryText != null) {
finalTextForInput = currentCountryText + ', ' + strRegions;
}
jQueryMod2('#tour_search_module_mod2 #itt_module_search_filter').val(finalTextForInput);
}
}
var itt_mod2_language = "russian";
var path = (itt_mod2_language == 'russian') ? 'new/js/view_tour/validation/localization/messages_ru.js' : 'new/js/view_tour/validation/localization/messages_uk.js';
ModuleLoader
//Установим путь к модулям
.setPath("https://www.ittour.com.ua/classes/handlers/ittour_external_modules/ittour_modules/")
// Use grunt .css => Последовательность загрузки файлов ВАЖНА -> см. в файле .grunt/Gruntfile.js:28-34
//.addCss('new/css/module_search/style_all_in_file.css?v=2', true) // Перенесено в main.js
//Загружаемые js файлы. По очереди
.addJs('new/js/js-all-lib-in-file.js?v=17', true) // Force reload js
.addJs('new/js/module_search/module_search.js?v=7', false)
.addJs(path, true)
// Событие, после загрузки всех файлов
.setEvent('after_load', function(){
ModuleSearch.setOptions({
'modules_url' : "https://www.ittour.com.ua/classes/handlers/ittour_external_modules/ittour_modules/",
'modules_action' : "https://www.ittour.com.ua/tour_search.php?callback=?&module_type=tour_search&id=40D61371578G7884569N530&ver=2&type=2970&theme=40",
'modules_param_action' : "https://www.ittour.com.ua/search_param.php?callback=?&module_type=tour_search&id=40D61371578G7884569N530&ver=2&type=2970&theme=40",
'show_basket' : "0",
'use_hotel_result' : "0",
'preview' : "0",
'extended_search_url' : "",
'modules_popup_result' : true,
'modules_popup_type' : 'div',
'language' : itt_mod2_language,
'is_get_lang_integration_code':"0",
});
//TODO: INIT JS FILE
var hike_path = '.itt_search-module_new .itt_hike ';
var package_path = '.itt_search-module_new .itt_package ';
var hike_mobile_path = '#itt-module-search-mobile .itt-mms-content-hike ';
var package_mobile_path = '#itt-module-search-mobile .itt-mms-content-package ';
/*
* item: путь к элементу
* val : пользовательская функция получения значения(jQueryMod2 object, default value)
* default: значиние по умолчанию
* block: путь к родителю данного элемента. Применимо для списков
*/
/* Hike.setParams({
country:{
item: (hike_path + '.itt_counry_list'),
val : function(this_item, def){return this_item.val()?this_item.val()[0]:def;},
default: 0,
},
tour_city:{
item: (hike_path + '.tour_city .itt_list-checkbox input'),
val : function(this_item, def){
var arr = [];
jQueryMod2.each(this_item.filter(':checked'), function(){
arr.push(jQueryMod2(this).val());
});
return arr.length == 0 ? def : arr;
},
block: (hike_path + '.tour_city .itt_list-checkbox'),
default: [0],
},
transport:{
item: (hike_path + '.itt_transport'),
val : function(this_item, def){
if(this_item.is('ul')) {
this_item = jQueryMod2('.itt_search-module_new .itt_hike .itt_transport');
if(this_item.is('ul')) {
var val = '';
this_item.find('input[type=hidden]').each(function(){
var $tt = jQueryMod2(this);
var tmpval = $tt.val();
if(tmpval && tmpval != ' ') {
val += $tt.val()+' ';
}
});
var strLen = val.length;
if(strLen > 1) {
val = val.slice(0,strLen-1);
}
return val;
}
} else {
return this_item.val();
}
},
default: 0,
},
date_from:{
item: (hike_path + '.itt_date_from'),
},
date_period:{
item: (hike_path + '.itt_date_period'),
},
date_till:{
item: (hike_path + '.itt_date_till'),
},
departure_city:{
item: (hike_path + '.itt_departure_city'),
default: 0,
},
adults:{
item: (hike_path + '.itt_adult'),
},
child1_age:{
item: (hike_path + '.itt_pop-up-children select:eq(0)'),
default: 0,
},
child2_age:{
item: (hike_path + '.itt_pop-up-children select:eq(1)'),
default: 0,
},
child3_age:{
item: (hike_path + '.itt_pop-up-children select:eq(2)'),
default: 0,
},
children:{
item: (hike_path + '.itt_children'),
val: function(this_item, def) {
var _val = this_item.val();
if( _val == null || _val == 'undefined' || typeof(_val) == 'undefined' || typeof(_val) == 'null') {
return 0;
} else {
return _val;
}
},
default: 0,
},
night_from:{
item: (hike_path + '.itt_tour_period'),
val: function(period){return period.val() ? period.val().split('-')[0] : null}
},
night_till:{
item: (hike_path + '.itt_tour_period'),
val: function(period){return period.val() ? period.val().split('-')[1] : null}
},
price_from:{
item: (hike_path + '.itt_price_from'),
},
price_till:{
item: (hike_path + '.itt_price_till'),
},
currency:{
item: (hike_path + '.itt_currency'),
default: 'UAH'
},
tour_count_per_page:{
item: (hike_path + '.itt_tour_count_per_page'),
},
tour_type: {
item: '#itt_tour_type'
},
}); */
Package.setParams({
country:{
item: package_path + '.itt_country',
val : function(this_item, def){
var _val = this_item.val();
if(typeof(_val) == 'object') {
return _val?_val[0]:def;
} else {
return _val;
}
},
default: 0,
},
region:{
item: (package_path + '.itt_region .itt_list-checkbox input'),
val : function(this_item, def){
var arr = [];
jQueryMod2.each(this_item.filter(':checked'), function(){
arr.push(jQueryMod2(this).val());
});
// Если выбрали хоть один регион => 'Все регионы' => off
if (arr.length > 1) {
for (var i=0; i 0) {
refreshCustomCheckboxes();
} else {
initCustomCheckboxes();
}
return arr.length == 0 ? def : arr;
},
block: (package_path + '.itt_region .itt_list-checkbox'),
default: [0],
},
date_from:{
item: (package_path + '.itt_date_from'),
},
date_period:{
item: (package_path + '.itt_date_period'),
},
date_till:{
item: (package_path + '.itt_date_till'),
},
hotel_rating:{
item: (package_path + 'input[name="itt_hotel_rating_total"]'),
val: function(){
var hotel_total_rating = jQueryMod2(package_path + 'input[name="itt_hotel_rating_total"]').val();
if (hotel_total_rating == null || hotel_total_rating == 'undefined' || typeof(hotel_total_rating) == 'undefined' || typeof(hotel_total_rating) == 'null') {
return '4 78';
} else {
return hotel_total_rating;
}
},
},
food:{
item: (package_path + 'input[name="itt_food_package"]'),
val: function(){
var food_rating = jQueryMod2(package_path + 'input[name="itt_food_package"]').val();
if (food_rating == null || food_rating == 'undefined' || typeof(food_rating) == 'undefined' || typeof(food_rating) == 'null') {
return '496 388 498 512 560 1956';
} else {
return food_rating;
}
},
},
price_from:{
item: (package_path + 'input[name="itt_price_from_package"]'),
val: function(){
var price = jQueryMod2(package_path + 'input[name="itt_price_from_package"]').val();
if (price == null || price == 'undefined' || typeof(price) == 'undefined' || typeof(price) == 'null') {
return '0';
} else {
return price;
}
},
},
price_till:{
item: (package_path + 'input[name="itt_price_till_package"]'),
val: function(){
var price = jQueryMod2(package_path + 'input[name="itt_price_till_package"]').val();
if (price == null || price == 'undefined' || typeof(price) == 'undefined' || typeof(price) == 'null') {
return '110000';
} else {
return price;
}
},
},
currency:{
item: (package_path + 'input[name="itt_switch_price_package"]'),
val: function(){
var currency = jQueryMod2(package_path + 'input[name="itt_switch_price_package"]').val();
if (currency == null || currency == 'undefined' || typeof(currency) == 'undefined' || typeof(currency) == 'null') {
return 'UAH';
} else {
return currency;
}
},
default: 'UAH',
},
departure_city:{
item: (package_path + 'input[name="itt_departure_city_package"]'),
val: function() {
var departure_city = jQueryMod2(package_path + 'input[name="itt_departure_city_package"]').val();
if(typeof(departure_city) == 'undefined' || typeof(departure_city) == 'null' || departure_city == 'undefined' || departure_city == null) {
return '2014';
} else {
return departure_city;
}
},
default: '2014',
},
departure_city_1:{
item: (package_path + '.itt_departure_city_1'),
},
departure_city_2:{
item: (package_path + '.itt_departure_city_2'),
},
departure_city_3:{
item: (package_path + '.itt_departure_city_3'),
},
night_from:{
item: (package_path + 'input[name="itt_night_from_package"]'),
val: function(){
var night = jQueryMod2(package_path + 'input[name="itt_night_from_package"]').val();
if (night == null || night == 'undefined' || typeof(night) == 'undefined' || typeof(night) == 'null') {
return '6';
} else {
return night;
}
},
default: '6',
},
night_till:{
item: (package_path + 'input[name="itt_night_till_package"]'),
val: function(){
var night = jQueryMod2(package_path + 'input[name="itt_night_till_package"]').val();
if (night == null || night == 'undefined' || typeof(night) == 'undefined' || typeof(night) == 'null') {
return '8';
} else {
return night;
}
},
default: '8',
},
adults:{
item: (package_path + 'input[name="itt_adult_package"]'),
},
child1_age:{
item: (package_path + 'input[name="itt_child1_age_package"]'),
val: function(){
var children = jQueryMod2(package_path + 'input[name="itt_children_package"]').val();
var returnVar = '0';
if (children == null || children == 'undefined' || typeof(children) == 'undefined' || typeof(children) == 'null') {
returnVar = '0';
} else if(children >=1) {
returnVar = jQueryMod2(package_path + 'input[name="itt_child1_age_package"]').val();
}
return returnVar;
},
},
child2_age:{
item: (package_path + 'input[name="itt_child2_age_package"]'),
val: function(){
var children = jQueryMod2(package_path + 'input[name="itt_children_package"]').val();
var returnVar = '0';
if (children == null || children == 'undefined' || typeof(children) == 'undefined' || typeof(children) == 'null') {
returnVar = '0';
} else if(children >=2) {
returnVar = jQueryMod2(package_path + 'input[name="itt_child2_age_package"]').val();
}
return returnVar;
},
},
child3_age:{
item: (package_path + 'input[name="itt_child3_age_package"]'),
val: function(){
var children = jQueryMod2(package_path + 'input[name="itt_children_package"]').val();
var returnVar = '0';
if (children == null || children == 'undefined' || typeof(children) == 'undefined' || typeof(children) == 'null') {
returnVar = '0';
} else if(children >=3) {
returnVar = jQueryMod2(package_path + 'input[name="itt_child3_age_package"]').val();
}
return returnVar;
},
},
children:{
item: (package_path + 'input[name="itt_children_package"]'),
val: function(){return jQueryMod2(package_path + 'input[name="itt_children_package"]').val();},
default: 0,
},
hotel:{
item: (package_path + 'input[name="itt_hotel_package"]'),
val: function(){
var hotel = jQueryMod2(package_path + 'input[name="itt_hotel_package"]').val();
if (hotel == null || hotel == 'undefined' || typeof(hotel) == 'undefined' || typeof(hotel) == 'null') {
return '';
} else {
return hotel;
}
},
default: '',
},
hotel_1:{
item: (package_path + '.itt_hotel_1'),
},
hotel_2:{
item: (package_path + '.itt_hotel_2'),
},
tour_count_per_page:{
item: (package_path + '.itt_tour_per_page'),
},
tour_type: {
item: '#itt_tour_type'
},
});
/********************** Begin mobile **********************************/
/* PackageMobile */
/* PackageMobile.setParams({
country:{
item: (package_mobile_path + '.itt_country_mobile ul li a.itt-mms-active-country'),
val: function(){
var curentCountry = jQueryMod2(package_mobile_path + '.itt_country_mobile ul li a.itt-mms-active-country').attr('rel');
if (curentCountry == null || curentCountry == 'undefined' || typeof(curentCountry) == 'undefined' || typeof(curentCountry) == 'null') {
return 0;
} else {
return curentCountry;
}
},
default: 0,
},
country_refresh:{
item: (package_mobile_path + '.itt_country_mobile ul'),
},
country_click: {
item: (package_mobile_path + '.itt_country_mobile ul li a'),
},
region:{// @todo: отредоактировать под mobile
item: (package_mobile_path + '.itt_region_mobile input'),
val : function(this_item, def){
var arr = [];
jQueryMod2.each(this_item.filter(':checked'), function(){
arr.push(jQueryMod2(this).val());
});
// Если выбрали хоть один регион => 'Все регионы' => off
if (arr.length > 1) {
for (var i=0; i=1) {
returnVar = jQueryMod2(package_mobile_path + '.itt_child1_age_mobile span').attr('rel');
}
return returnVar;
},
},
child2_age:{
item: (package_mobile_path + '.itt_child2_age_mobile span'),
val: function(){
var children = jQueryMod2(package_mobile_path + '.itt_children_mobile span').attr('rel');
var returnVar = '0';
if (children == null || children == 'undefined' || typeof(children) == 'undefined' || typeof(children) == 'null') {
returnVar = '0';
} else if(children >=2) {
returnVar = jQueryMod2(package_mobile_path + '.itt_child2_age_mobile span').attr('rel');
}
return returnVar;
},
},
child3_age:{
item: (package_mobile_path + '.itt_child3_age_mobile span'),
val: function(){
var children = jQueryMod2(package_mobile_path + '.itt_children_mobile span').attr('rel');
var returnVar = '0';
if (children == null || children == 'undefined' || typeof(children) == 'undefined' || typeof(children) == 'null') {
returnVar = '0';
} else if(children >=3) {
returnVar = jQueryMod2(package_mobile_path + '.itt_child3_age_mobile span').attr('rel');
}
return returnVar;
},
},
tour_count_per_page:{
item: (package_mobile_path + '.itt_tour_per_page_mobile'),
},
tour_type: {
item: '#itt_tour_type_mobile_use_in_submit',
default: '1',
},
tour_type_click: {
item: (package_mobile_path + '.itt_tour_type_mobile a, ' + package_mobile_path + '.itt_tour_type_mobile label'),
},
});
// Поиск туров Mobile
jQueryMod2(package_mobile_path + '.itt_button_search_package_mobile').click(function(){
// Деактивиру кнопку, чтобы небыло нескольких запросов на поиск
var button = jQueryMod2(this);
button.prop('disabled', true);
// Показываем / скрываем блоки => пока идет поиск
jQueryMod2('#itt-module-search-mobile .itt-msm-result-wrap').show();
jQueryMod2('#itt-module-search-mobile .itt-msm-result-load').show();
setHeaderSearchResultMobile(true);
jQueryMod2('#itt-module-search-mobile .itt_tour_search_result_mobile_wrap').hide().html('');
// Scroll top search result
var targetOffset = jQueryMod2('#itt-module-search-mobile .itt-msm-result-wrap').offset().top;
jQueryMod2('html,body').animate({scrollTop: targetOffset}, 700);
//Получение данных
PackageMobile.getSearchFormSubmit({}, function(data){
// Активирую кнопку, (выключал ее чтобы небыло нескольких запросов на поиск)
button.removeProp('disabled');
// Показываем / скрываем блоки => резальтат поиска отработал
jQueryMod2('#itt-module-search-mobile .itt-msm-result-wrap').show();
jQueryMod2('#itt-module-search-mobile .itt-msm-result-load').hide();
jQueryMod2('#itt-module-search-mobile .itt_tour_search_result_mobile_wrap')
.html(data.text)
.show()
.promise().done(function(){
setHeaderSearchResultMobile(false);
});
var targetOffset = jQueryMod2('#itt-module-search-mobile .itt-msm-result-wrap').offset().top;
jQueryMod2('html,body').animate({scrollTop: targetOffset}, 700);
return false;
});
return false;
});
// Country change(click) // изменение страны // подгрузка: региона, отеля и города отправления.
//jQueryMod2(package_mobile_path + '.itt_country_mobile ul li a').click(function(){// Old
var mobile_country_delegate_selector = PackageMobile.params.country_click.item;
jQueryMod2('#itt-module-search-mobile').delegate(mobile_country_delegate_selector, 'click', function(){
// Проверка если юзер кликнул по выбраной ранее стране => 'let's goodbye' :o]
if (jQueryMod2(this).hasClass('itt-mms-active-country')) {
return false;
}
// подсветка активнй страны
jQueryMod2(package_mobile_path + '.itt_country_mobile ul li a').removeClass('itt-mms-active-country');
jQueryMod2(this).addClass('itt-mms-active-country');
// Замена текста на форме: "Страна, Регион".
var textCountry = jQueryMod2(this).text();
var textAllRegion = jQueryMod2(package_mobile_path + '.itt_region_mobile ul li:first').text();
if ((typeof(textCountry) != 'undefined' || typeof(textCountry) != 'null') && (typeof(textAllRegion) != 'undefined' || typeof(textAllRegion) != 'null')) {
var textSetCountryRegion = textCountry + ', ' + textAllRegion;
jQueryMod2(package_mobile_path + '.itt-contry-and-regin-wrap-switcher input[type="text"]')
.val(textSetCountryRegion)
.attr('placeholder', textSetCountryRegion);
}
// Отправка данных и получение новых полей
PackageMobile.getSearchFilteredField({}, function(data){
// Генерация и вставка HTML // region
PackageMobile.setHtml( 'region_refresh',
data.region.html,
function(){
// Переинициализируем заново кастомные чекбоксы
PackageMobile.getItem('region_refresh').find('input.itt-styled-ch').each(function(){
var options;
jQueryMod2(this).prettyCheckable(options);
});
if (PackageMobile.getItem('region_refresh').find('input.itt-styled-ch').length) {
PackageMobile.getItem('region_refresh').find('input.itt-styled-ch').change(function(){
jQueryMod2(this).parent().toggleClass('active');
});
}
}
);
// Генерация и вставка HTML // hotel
PackageMobile.setHtml( 'hotel_refresh',
data.hotel.html,
function(){
// Get param
var hotelObj = PackageMobile.getItem('hotel_refresh');
var rel = hotelObj.find('li:first').attr('rel');
var textVal = hotelObj.find('li:first').text();
// Set new param in span
if ((typeof(rel) != 'undefined' || typeof(rel) != 'null') && (typeof(textVal) != 'undefined' || typeof(textVal) != 'null')) {
hotelObj.parent().find('span').attr('rel', rel).text(textVal);
}
// Reafesh click to new html
setTimeout(function(){initClickToDropDownMenu();}, 150);
}
);
// Генерация и вставка HTML // departure_city
PackageMobile.setHtml( 'departure_city_refresh',
data.departure_city.html,
function(){
// Get param
var departureCityObj = PackageMobile.getItem('departure_city_refresh');
var rel = departureCityObj.find('li:first').attr('rel');
var textVal = departureCityObj.find('li:first').text();
// Set param in span
if ((typeof(rel) != 'undefined' || typeof(rel) != 'null') && (typeof(textVal) != 'undefined' || typeof(textVal) != 'null')) {
departureCityObj.parent().find('span').attr('rel', rel).text(textVal);
}
// Reafesh click to new html
setTimeout(function(){initClickToDropDownMenu();}, 150);
}
);
});
});
// Region change // выбор региона // подгрузка: отелей.
var mobile_hotel_delegate_selector = PackageMobile.params.region.item;
jQueryMod2('#itt-module-search-mobile').delegate(mobile_hotel_delegate_selector, 'change', function(){
// Проверяем на наличие выбора 'Конкретный регион' или 'Все регионы'
var currentReginObj = jQueryMod2(this);
if (currentReginObj.val() == 0 && (currentReginObj.prop('checked') == true)) {
// Выбрали 'Все регионы'. // Выставляем остальные как НЕвыбранные.
jQueryMod2(package_mobile_path + '.itt_region_mobile input').each(function(){
var $this = jQueryMod2(this);
if ($this.val() != 0) {
$this.prop("checked", false);
$this.parent().find('a').removeAttr('class');
}
});
} else {
// Выбрали НЕ 'Все регионы', а конкретный. // Убираем галку на 'Все регионы'.
jQueryMod2(package_mobile_path + '.itt_region_mobile input[value="0"]')
.prop("checked", false)
.parent().find('a').removeAttr('class')
.promise().done(function(){
// Проходим все элементы и если оказалось что нет ни одного выбраного ставим 'Все регионы'.
var countActive = 0;
jQueryMod2(package_mobile_path + '.itt_region_mobile input').each(function(){
var $this = jQueryMod2(this);
if ($this.prop("checked") == true) {
countActive += 1;
}
});
if (countActive == '0') {
// Вынужденое решение т.к. ненайдено место где перекрывает ивент
setTimeout(function(){
// Ставим галку на 'Все регионы'.
jQueryMod2(package_mobile_path + '.itt_region_mobile input[value="0"]').prop("checked", true);
jQueryMod2(package_mobile_path + '.itt_region_mobile input[value="0"]').parent().find('a').addClass('checked');
}, 350);
}
});
}
// Замена текста на форме: "Страна, Регион".
// Get country text
var countryTxt = jQueryMod2(package_mobile_path + '.itt_country_mobile ul li a.itt-mms-active-country').text();
var regionsTxt = '';
// Get region text
jQueryMod2(package_mobile_path + '.itt_region_mobile input').each(function(){
var $this = jQueryMod2(this);
if (regionsTxt == '') {
if ($this.prop("checked") == true) regionsTxt = $this.parent().find('label').text();
} else {
if ($this.prop("checked") == true) regionsTxt = regionsTxt + ', ' + $this.parent().find('label').text();
}
});
if ((typeof(countryTxt) != 'undefined' || typeof(countryTxt) != 'null') && (typeof(regionsTxt) != 'undefined' || typeof(regionsTxt) != 'null')) {
var textSetCountryRegion = countryTxt + ', ' + regionsTxt;
// Set country, region text
jQueryMod2(package_mobile_path + '.itt-contry-and-regin-wrap-switcher input[type="text"]')
.val(textSetCountryRegion)
.attr('placeholder', textSetCountryRegion);
}
// Отправка данных и получение новых полей
PackageMobile.getSearchFilteredField({'event_owner_level':4}, function(data){
// Генерация и вставка HTML // hotel
PackageMobile.setHtml( 'hotel_refresh',
data.hotel.html,
function(){
// Get param
var hotelObj = PackageMobile.getItem('hotel_refresh');
var rel = hotelObj.find('li:first').attr('rel');
var textVal = hotelObj.find('li:first').text();
// Set new param in span
if ((typeof(rel) != 'undefined' || typeof(rel) != 'null') && (typeof(textVal) != 'undefined' || typeof(textVal) != 'null')) {
hotelObj.parent().find('span').attr('rel', rel).text(textVal);
}
// Reafesh click to new html
setTimeout(function(){initClickToDropDownMenu();}, 150);
}
);
});
});
// Hotel rating change // выбор звездности отеля // подгрузка: отелей и городов вылета.
var mobile_hotel_rating_delegate_selector = PackageMobile.params.hotel_rating_click.item;
jQueryMod2('#itt-module-search-mobile').delegate(mobile_hotel_rating_delegate_selector, 'click', function(){
// Отправка данных и получение новых полей
PackageMobile.getSearchFilteredField({'event_owner_level':2}, function(data){
// Генерация и вставка HTML // hotel
PackageMobile.setHtml( 'hotel_refresh',
data.hotel.html,
function(){
// Get param
var hotelObj = PackageMobile.getItem('hotel_refresh');
var rel = hotelObj.find('li:first').attr('rel');
var textVal = hotelObj.find('li:first').text();
// Set new param in span
if ((typeof(rel) != 'undefined' || typeof(rel) != 'null') && (typeof(textVal) != 'undefined' || typeof(textVal) != 'null')) {
hotelObj.parent().find('span').attr('rel', rel).text(textVal);
}
// Reafesh click to new html
setTimeout(function(){initClickToDropDownMenu();}, 150);
}
);
// Генерация и вставка HTML // departure_city
PackageMobile.setHtml( 'departure_city_refresh',
data.departure_city.html,
function(){
// Get param
var departureCityObj = PackageMobile.getItem('departure_city_refresh');
var rel = departureCityObj.find('li:first').attr('rel');
var textVal = departureCityObj.find('li:first').text();
// Set param in span
if ((typeof(rel) != 'undefined' || typeof(rel) != 'null') && (typeof(textVal) != 'undefined' || typeof(textVal) != 'null')) {
departureCityObj.parent().find('span').attr('rel', rel).text(textVal);
}
// Reafesh click to new html
setTimeout(function(){initClickToDropDownMenu();}, 150);
}
);
});
});
// Tour type change // выбор рпоезд вкл/выкл. // подгрузка: стран / регионов / отелей и городов вылета.
var mobile_tour_type_delegate_selector = PackageMobile.params.tour_type_click.item;
jQueryMod2('#itt-module-search-mobile').delegate(mobile_tour_type_delegate_selector, 'click', function(){
// Отправка данных и получение новых полей
PackageMobile.getSearchFilteredField({'event_owner_level':'0'}, function(data){
// Генерация и вставка HTML // country
PackageMobile.setHtml( 'country_refresh',
data.country.html,
function(){
// Переинициализируем заново scroll
jQueryMod2('.itt-country-region-pop-up-content .itt-mms-niceScroll').getNiceScroll().resize();
}
);
// Генерация и вставка HTML // region
PackageMobile.setHtml( 'region_refresh',
data.region.html,
function(){
// Переинициализируем заново кастомные чекбоксы
PackageMobile.getItem('region_refresh').find('input.itt-styled-ch').each(function(){
var options;
jQueryMod2(this).prettyCheckable(options);
});
if (PackageMobile.getItem('region_refresh').find('input.itt-styled-ch').length) {
PackageMobile.getItem('region_refresh').find('input.itt-styled-ch').change(function(){
jQueryMod2(this).parent().toggleClass('active');
});
}
}
);
// Генерация и вставка HTML // hotel
PackageMobile.setHtml( 'hotel_refresh',
data.hotel.html,
function(){
// Get param
var hotelObj = PackageMobile.getItem('hotel_refresh');
var rel = hotelObj.find('li:first').attr('rel');
var textVal = hotelObj.find('li:first').text();
// Set new param in span
if ((typeof(rel) != 'undefined' || typeof(rel) != 'null') && (typeof(textVal) != 'undefined' || typeof(textVal) != 'null')) {
hotelObj.parent().find('span').attr('rel', rel).text(textVal);
}
// Reafesh click to new html
setTimeout(function(){initClickToDropDownMenu();}, 150);
}
);
// Генерация и вставка HTML // departure_city
PackageMobile.setHtml( 'departure_city_refresh',
data.departure_city.html,
function(){
// Get param
var departureCityObj = PackageMobile.getItem('departure_city_refresh');
var rel = departureCityObj.find('li:first').attr('rel');
var textVal = departureCityObj.find('li:first').text();
// Set param in span
if ((typeof(rel) != 'undefined' || typeof(rel) != 'null') && (typeof(textVal) != 'undefined' || typeof(textVal) != 'null')) {
departureCityObj.parent().find('span').attr('rel', rel).text(textVal);
}
// Reafesh click to new html
setTimeout(function(){initClickToDropDownMenu();}, 150);
}
);
});
}); */
/************************ End mobile **********************************/
/*
*
* Экскурсионные туры
*/
//Событие для заполнения: города на маршруте, транспорта и города отправления для Модуля поиска, при переключении страны.
/* Hike.getItem('country').change(function(){
Hike.getSearchFilteredField({}, function(data){
// Шаблоны
var tour_city_template =
''+
''+
''+
'
';
var departure_city_template = '';
var transport_template = '';
// Генерация и вставка HTML
Hike.setHtml('departure_city', Hike.generateHtml(data.city.data, departure_city_template), function(item){item.trigger("chosen:updated");});
Hike.setHtml('transport', Hike.generateHtml(data.transport.data, transport_template), function(item){item.trigger("chosen:updated");});
// Update custom select 'departure_city' and 'hotel'
updateCustomHtmlSelect(jQueryMod2('#tour_search_module_mod2 section.itt_hike .itt_transport').parent(), 'itt_transport');
updateCustomHtmlSelect(jQueryMod2('#tour_search_module_mod2 section.itt_hike .itt_departure_city').parent(), 'itt_departure_city');
// Генерация и вставка HTML для tour_city
Hike.getBlock('tour_city').html(Hike.generateHtml(data.tour_city.data, tour_city_template));
if(Hike.getItem('tour_city').filter(':checked').length == 0){
Hike.getItem('tour_city').first().attr('checked', 'checked');
}
initCustomCheckboxes();
initTinyScrollbar();
});
}); */
/*
*
* Пакетные туры
*/
var package_hotel_template = '';
//Событие для заполнения: региона, отеля и города отправления для Модуля поиска, при переключении страны.
Package.getItem('country').change(function(){
// Очистить регион
jQueryMod2(Package.params.region.item).each(function(){
var _this = jQueryMod2(this);
if(_this.val() == 0) {
_this.attr("checked", "checked");
} else {
_this.attr("checked", false);
}
});
Package.getSearchFilteredField({}, function(data){
// Шаблоны
var region_template =
''+
''+
''+
'
';
var departure_city_template = '';
// Генерация и вставка HTML // New super stretch
Package.setHtml('departure_city_1', Package.generateHtml(data.departure_city.data, departure_city_template), function(){
// Update custom select 'departure_city'
updateCustomHtmlSelect(jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_1').parent(), 'itt_departure_city_1');
});
Package.setHtml('departure_city_2', Package.generateHtml(data.departure_city.data, departure_city_template), function(){
// Update custom select 'departure_city'
updateCustomHtmlSelect(jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_2').parent(), 'itt_departure_city_2');
});
Package.setHtml('departure_city_3', Package.generateHtml(data.departure_city.data, departure_city_template), function(){
// Update custom select 'departure_city'
updateCustomHtmlSelect(jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_3').parent(), 'itt_departure_city_3');
// Обновим скрытое поля по selected 'departure_city'
var depCity = jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_1 option:selected').val();
if(typeof(depCity) != 'undefined' && typeof(depCity) != 'null' && depCity != 'undefined' && depCity != null && depCity != '') {
jQueryMod2('#tour_search_module_mod2 input[name="itt_departure_city_package"]').val(depCity);
} else {
jQueryMod2('#tour_search_module_mod2 input[name="itt_departure_city_package"]').val(2014);
}
});
// Вставка готового html
var hotel_1 = jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_hotel_1').parent();
var hotel_2 = jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_hotel_2').parent();
hotel_1.find('ul.itt_custom_select_options').html(data.hotel.html);
hotel_2.find('ul.itt_custom_select_options').html(data.hotel.html);
// Навешивание обработчиков
updateHotelList(hotel_1);
updateHotelList(hotel_2);
jQueryMod2('#tour_search_module_mod2 input[name="itt_hotel_package"]').val(0);
jQueryMod2('#tour_search_module_mod2 input[name="itt_hotel_package_name"]').val(jQueryMod2('#tour_search_module_mod2 input[name="itt_hotel_package_name_default"]').val());
// Генерация и вставка HTML для region
Package.getBlock('region').html(Package.generateHtml(data.region.data, region_template));
if(Package.getItem('region').filter(':checked').length == 0){
Package.getItem('region').first().attr('checked', 'checked');
}
initCustomCheckboxes();
initTinyScrollbar();
// Add region view in input
setCountryAndRegionNameInInputPackagePart();
});
});
// Begin add custom fix for agency country checkbox // Мер-Ка-Ба (Бурутина И. Г., ФЛП) ID == 12788
if (jQueryMod2('#tour_search_module_mod2 input[name="itt_custom_agency_country_change_handler"]').length > 0) {
jQueryMod2('#itt_tour_search_module').delegate(".itt_search-module_new .itt_row_in_list_region label", 'click', function(){
var label = jQueryMod2(this);
if(label.parent().find('input').is(':checked')) {
label.parent().find('input').prop('checked', false).trigger('change');
} else {
if (label.parent().find('input').val() == 0) {
// Выбрали 'Все регионы'. // Выставляем остальные как НЕвыбранные.
jQueryMod2('#itt_tour_search_module .itt_region input').each(function(){
var $this = jQueryMod2(this);
if ($this.val() != 0) {
$this.prop("checked", false);
$this.parent().find('a').removeAttr('class');
}
});
}
label.parent().find('input').prop('checked', true).trigger('change');
}
});
}
// End add custom fix for agency country checkbox // Мер-Ка-Ба (Бурутина И. Г., ФЛП) ID == 12788
// Сброс выбранных регионов при клике на "Все регионы"
jQueryMod2('#itt_tour_search_module').delegate('.itt_region .itt_list-checkbox .itt_row_in_list_region input[value="0"]', 'click', function(){
jQueryMod2(Package.params.region.item).each(function(){
if(jQueryMod2(this).val() != 0) {
jQueryMod2(this).attr('checked', false);
}
});
if(jQueryMod2('.ui-button').length > 0) {
refreshCustomCheckboxes();
}
});
//Событие для заполнения отеля и городов вылета, при переключении региона, рейтинга отеля и типа тура
var hotel_delegate_selector = Package.params.region.item + ', ' + 'input[name="itt_hotel_rating_total"]';
jQueryMod2('#itt_tour_search_module').delegate(hotel_delegate_selector, 'change', function() {
// Add region view in input
setCountryAndRegionNameInInputPackagePart();
Package.getSearchFilteredField({'event_owner_level': 4 // old - remove after ls implements
, 'event': 'select_region'}, function(data){
// Вставка готового html
var hotel_1 = jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_hotel_1').parent();
var hotel_2 = jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_hotel_2').parent();
hotel_1.find('ul.itt_custom_select_options').html(data.hotel.html);
hotel_2.find('ul.itt_custom_select_options').html(data.hotel.html);
// Навешивание обработчиков
updateHotelList(hotel_1);
updateHotelList(hotel_2);
jQueryMod2('#tour_search_module_mod2 input[name="itt_hotel_package"]').val(0);
// Обновление городов вылета
if(typeof data.departure_city != 'undefined' && typeof data.departure_city.data != 'undefined') {
var departure_city_template = '';
// Генерация и вставка HTML // New super stretch
Package.setHtml('departure_city_1', Package.generateHtml(data.departure_city.data, departure_city_template), function(){
// Update custom select 'departure_city'
updateCustomHtmlSelect(jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_1').parent(), 'itt_departure_city_1');
});
Package.setHtml('departure_city_2', Package.generateHtml(data.departure_city.data, departure_city_template), function(){
// Update custom select 'departure_city'
updateCustomHtmlSelect(jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_2').parent(), 'itt_departure_city_2');
});
Package.setHtml('departure_city_3', Package.generateHtml(data.departure_city.data, departure_city_template), function(){
// Update custom select 'departure_city'
updateCustomHtmlSelect(jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_3').parent(), 'itt_departure_city_3');
// Обновим скрытое поля по selected 'departure_city'
var depCity = jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_1 option:selected').val();
if(typeof(depCity) != 'undefined' && typeof(depCity) != 'null' && depCity != 'undefined' && depCity != null && depCity != '') {
jQueryMod2('#tour_search_module_mod2 input[name="itt_departure_city_package"]').val(depCity);
} else {
jQueryMod2('#tour_search_module_mod2 input[name="itt_departure_city_package"]').val(2014);
}
});
}
});
});
//Событие для заполнения стран, отелей и городов вылета, при переключении типа тура
jQueryMod2('#itt_tour_search_module').delegate('input[name="itt_tour_type"]', 'change', function() {
Package.getSearchFilteredField({'event_owner_level': 4 // old - remove after ls implements
, 'event': 'select_type'}, function(data){
// Вставка готового html
var hotel_1 = jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_hotel_1').parent();
var hotel_2 = jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_hotel_2').parent();
hotel_1.find('ul.itt_custom_select_options').html(data.hotel.html);
hotel_2.find('ul.itt_custom_select_options').html(data.hotel.html);
// Навешивание обработчиков
updateHotelList(hotel_1);
updateHotelList(hotel_2);
jQueryMod2('#tour_search_module_mod2 input[name="itt_hotel_package"]').val(0);
// Обновление городов вылета
if(typeof data.departure_city != 'undefined' && typeof data.departure_city.data != 'undefined') {
var departure_city_template = '';
// Генерация и вставка HTML // New super stretch
Package.setHtml('departure_city_1', Package.generateHtml(data.departure_city.data, departure_city_template), function(){
// Update custom select 'departure_city'
updateCustomHtmlSelect(jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_1').parent(), 'itt_departure_city_1');
});
Package.setHtml('departure_city_2', Package.generateHtml(data.departure_city.data, departure_city_template), function(){
// Update custom select 'departure_city'
updateCustomHtmlSelect(jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_2').parent(), 'itt_departure_city_2');
});
Package.setHtml('departure_city_3', Package.generateHtml(data.departure_city.data, departure_city_template), function(){
// Update custom select 'departure_city'
updateCustomHtmlSelect(jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_3').parent(), 'itt_departure_city_3');
// Обновим скрытое поля по selected 'departure_city'
var depCity = jQueryMod2('#tour_search_module_mod2 section.itt_package .itt_departure_city_1 option:selected').val();
if(typeof(depCity) != 'undefined' && typeof(depCity) != 'null' && depCity != 'undefined' && depCity != null && depCity != '') {
jQueryMod2('#tour_search_module_mod2 input[name="itt_departure_city_package"]').val(depCity);
} else {
jQueryMod2('#tour_search_module_mod2 input[name="itt_departure_city_package"]').val(2014);
}
});
}
// Обновление списка стран
if(typeof data.country != 'undefined' && typeof data.country.data != 'undefined') {
var popular_list = ['318', '338'];
var itt_popular_destinations = '';
var itt_other_destinations = '';
var selected_country = Package.getData('country');
jQueryMod2.each(data.country.data, function() {
var selected = '';
if(this.id == selected_country) selected = 'selected="selected" ';
if(jQueryMod2.inArray(this.id, popular_list) == -1) {
itt_other_destinations += '';
} else {
itt_popular_destinations += '';
}
});
// Вставить стандартные селекты
if(itt_popular_destinations != '') jQueryMod2('#itt_popular_destinations').html(itt_popular_destinations);
if(itt_other_destinations != '') jQueryMod2('#itt_other_destinations').html(itt_other_destinations);
// Перегенерировать кастомные селекты
initCustomMultipleSelect();
initTinyScrollbar();
}
// Обновление регионов
if(typeof data.region != 'undefined' && typeof data.region.data != 'undefined') {
var region_template =
''+
''+
''+
'
';
// Генерация и вставка HTML для region
Package.getBlock('region').html(Package.generateHtml(data.region.data, region_template));
if(Package.getItem('region').filter(':checked').length == 0) {
Package.getItem('region').first().attr('checked', 'checked');
}
initCustomCheckboxes();
initTinyScrollbar();
}
// Add region view in input
setCountryAndRegionNameInInputPackagePart();
});
});
//Поиск среди стран
//var is_popup_opened = true;
var popup = jQueryMod2(package_path + '.itt_pop-up-place');
/*
* Фильтрует страны, скрывая те, которых нету в списке.
*/
var hide_options = function(array){
var options = popup.find('.itt_country + .scrollbarY .overview > div');
options.hide();
jQueryMod2.each(array, function(){
options.filter('[name="'+this+'"]').show().prevAll('.itt_sel-optgroup:first').show();
});
initTinyScrollbar();
};
jQueryMod2('.itt_country').bind('change',function() {
var $tt = jQueryMod2(this);
$tt.parents('.itt_group-place').find('#itt_module_search_filter').val(jQueryMod2('.itt_country option[value='+$tt.val()+']').text());
});
jQueryMod2('#itt_module_search_filter')
// Открывает попап при фокусе
.focus(function(){
var $tt = jQueryMod2(this);
if($tt.attr('data-defval') == $tt.val()) {
$tt.val('');
}
if(!popup.is(':visible')){
//is_popup_opened = false;
jQueryMod2('#itt_module_search_filter_button').trigger('click');
}
})
// Закрывает попап при фокусе
.blur(function(){
var $tt = jQueryMod2(this);
if($tt.val() == '') {
$tt.val($tt.attr('data-defval'));
}
/* if(!is_popup_opened){
if(popup.is(':visible')){
jQueryMod2('#itt_module_search_filter_button').trigger('click');
}
is_popup_opened = true;
}*/
})
// Фильтр по нажатию клавиши
.keyup(function(){
var search_text = jQueryMod2(this).val().toLowerCase();
var match_array = [];
var options = Package.getItem('country').find('option');
// Формирование массива видимых элементов
jQueryMod2.each(options, function(){
var option = jQueryMod2(this);
if(search_text.length > 0){
var text = option.text().toLowerCase();
if(text.indexOf(search_text) != -1 ){
match_array.push(option.val());
}
}else{
match_array.push(option.val());
}
});
// Вызов функции фильтрации
hide_options(match_array);
});
//Поиск туров
jQueryMod2('.itt_tour_search_button').click(function(){
// Деактивиру кнопку, чтобы небыло нескольких запросов на поиск
var button = jQueryMod2(this);
button.prop('disabled', true);
var tabs = jQueryMod2( "#itt_tabs_search_result" ).tabs();// Create tabs
var type = Hike;
if(jQueryMod2(this).hasClass('package')){
type = Package;
}
// Set active tab 'Все туры' => for fix custom bug in load new search
jQueryMod2('#itt_issuing_search_tabs_main_block li#search_result_tab_1 a.itt_issuing_search_links_head_tab').trigger('click');
setHeaderInResultSearch(true);
jQueryMod2('#itt_tour_search_load').show();
jQueryMod2('#itt_tabs_search_result').hide();
jQueryMod2('#itt_issuing_search_package_tours').hide();
jQueryMod2('.itt-pg-loader-holder').remove(); // Удаление прогрессбара
itt_clear_timeouts(); // Очистка таймаутов
//Получение данных
type.getSearchFormSubmit({}, function(data){
// Активирую кнопку, (выключал ее чтобы небыло нескольких запросов на поиск)
button.removeProp('disabled');
jQueryMod2('#itt_tour_search_result').html(data.text).show();
jQueryMod2('#itt_tabs_search_result').show();
jQueryMod2('#itt_issuing_search_package_tours').show();
jQueryMod2('#itt_tour_search_load').hide();
setHeaderInResultSearch(false);
var targetOffset = jQueryMod2('#itt_issuing_search_package_tours').offset().top;
jQueryMod2('html,body').animate({scrollTop: targetOffset}, 700);
});
});
// Методы, для скрытия загрузочного превью, после загрузки для сайта ittour
jQueryMod2('.module_preview_load').hide();
jQueryMod2('#tour_search_module_mod2').show();
// Обработчик для выбора звезности отеля
jQueryMod2('#itt_tour_search_module ul.star').ready(function(){
jQueryMod2('.star input').each(function(){
if (jQueryMod2(this).attr("checked")) {
jQueryMod2(this).attr("checked","checked");
jQueryMod2(this).next('span').addClass('on');
};
});
jQueryMod2('.star input').change(function(){
if (jQueryMod2(this).attr("checked")) {
jQueryMod2(this).attr("checked","checked");
jQueryMod2(this).next('span').addClass('on');
} else {
jQueryMod2(this).attr("checked",false);
jQueryMod2(this).next('span').removeClass('on');
}
});
jQueryMod2('.star span').live("click", function(){
jQueryMod2(this).toggleClass('on');
if (jQueryMod2(this).hasClass('on')) {
jQueryMod2(this).prev('input[type="checkbox"]').attr('checked', 'checked');
} else {
jQueryMod2(this).prev('input[type="checkbox"]').removeAttr('checked');
}
// Set new rating
refresh_hotel_rating_total();
});
/**
* function change value in selecter 'input[name="itt_hotel_rating_total"]'
*
* @param {void}
* @returns {void}
*/
function refresh_hotel_rating_total(){
var hotel_rating_list = '';
jQueryMod2('#itt_hotel_rating_block input:checked').each(function(index){
if (hotel_rating_list == '') {
hotel_rating_list += jQueryMod2(this).val();
} else {
hotel_rating_list += ' ' + jQueryMod2(this).val();
}
});
if (hotel_rating_list == '') {
jQueryMod2('input[name="itt_hotel_rating_total"]').val('4 78');// Default rating *4,*5
} else {
jQueryMod2('input[name="itt_hotel_rating_total"]').val(hotel_rating_list);
}
}
});
// Обработчик для выбора валюты (500x170, 300x500, 200x450, 200x775)
// Package
jQueryMod2('#itt_tour_search_module_package_block #itt_currency_radio_total').ready(function(){
jQueryMod2('#itt_tour_search_module_package_block input[type="radio"].itt_currency_radio').change(function(){
// Get new currency
var current_currency = jQueryMod2(this).val();
// Check value
if (typeof current_currency == 'undefined') current_currency = 'UAH';
// Set new currency in hidden input
jQueryMod2('#itt_tour_search_module_package_block #itt_currency_radio_total').val(current_currency);
});
});
// Hike
/* jQueryMod2('#itt_tour_search_module_hike_block #itt_currency_radio_total').ready(function(){
jQueryMod2('#itt_tour_search_module_hike_block input[type="radio"].itt_currency_radio').change(function(){
// Get new currency
var current_currency = jQueryMod2(this).val();
// Check value
if (typeof current_currency == 'undefined') current_currency = 'UAH';
// Set new currency in hidden input
jQueryMod2('#itt_tour_search_module_hike_block #itt_currency_radio_total').val(current_currency);
});
}); */
// Обработчик для нового мульти выбора питания
jQueryMod2('#itt_tour_search_module ul.star').ready(function(){
jQueryMod2('.food input').each(function(){
if (jQueryMod2(this).attr("checked")) {
jQueryMod2(this).attr("checked","checked");
jQueryMod2(this).next('span').addClass('on');
};
});
jQueryMod2('.food span').live("click", function(){
jQueryMod2(this).toggleClass('on');
if (jQueryMod2(this).hasClass('on')) {
jQueryMod2(this).prev('input[type="checkbox"]').attr('checked', 'checked');
} else {
jQueryMod2(this).prev('input[type="checkbox"]').removeAttr('checked');
}
refresh_food_total();
});
jQueryMod2('.food input').change(function(){
if (jQueryMod2(this).attr("checked")) {
jQueryMod2(this).attr("checked","checked");
jQueryMod2(this).next('span').addClass('on');
} else {
jQueryMod2(this).attr("checked",false);
jQueryMod2(this).next('span').removeClass('on');
}
refresh_food_total();
});
/**
* function change value in selecter 'input[name="itt_food_total"]'
*
* @param {void}
* @returns {void}
*/
function refresh_food_total() {
var food_list = '';
jQueryMod2('#itt_food_block input:checked').each(function(index){
if (food_list == '') {
food_list += jQueryMod2(this).val();
} else {
food_list += ' ' + jQueryMod2(this).val();
}
});
if (food_list == '') {
jQueryMod2('input[name="itt_food_total"]').val('496 512 560');// Default: HB, AI, UAI
} else {
jQueryMod2('input[name="itt_food_total"]').val(food_list);
}
}
});
// Обработчик для 'Проезд включен: да | нет'
jQueryMod2('input[name="itt_tour_type"]').change(function(){
jQueryMod2('#tour_search_module_mod2 #itt_tour_type').val(jQueryMod2(this).val());
});
})
//Событие загрузки js файла
.setEvent('load_js', function(name){
})
// Начинаем загрузку. В добрый путь ^_^ !!!
.load();
// Begin set default handler
jQueryMod2(document).ready(function() {
jQueryMod2(".dropdown img.flag").addClass("flagvisibility");
jQueryMod2(".dropdown dt a").click(function() {
jQueryMod2(".dropdown dd ul").toggle();
});
jQueryMod2(".dropdown dd ul li a").click(function() {
var text = jQueryMod2(this).html();
jQueryMod2(".dropdown dt a span").html(text);
jQueryMod2(".dropdown dd ul").hide();
jQueryMod2("#result").html("Selected value is: " + getSelectedValue("sample"));
});
function getSelectedValue(id) {
return jQueryMod2("#" + id).find("dt a span.value").html();
}
jQueryMod2(document).bind('click', function(e) {
var $clicked = jQueryMod2(e.target);
if (! $clicked.parents().hasClass("dropdown"))
jQueryMod2(".dropdown dd ul").hide();
});
jQueryMod2("#flagSwitcher").click(function() {
jQueryMod2(".dropdown img.flag").toggleClass("flagvisibility");
});
});
// End set default handler
}
// Set variable
var script;
/**
* function load jquery and if file load => load other js =>
* other js load html and new loader for new module search
* @param {string} filename
* @returns {set script in create loader for *.js and *.css file}
*/
function load_script_as_old_mod(filename) {
script = document.createElement('script');
script.type = 'text/javascript';
script.src = filename;
document.getElementsByTagName('head')[0].appendChild(script);
// Onload jquery
script.onload = function() {
load_js_and_html_for_jsx();
}
}
// *** BEGIN MAIN SRC **********************************************************
// Check load js as 'in agency account' or as 'js-integration'
var js_integration = false;
var el_in_account = document.getElementById("constructor");
// Set flag integration
if (el_in_account !== null) {
js_integration = false;
} else {
js_integration = true;
}
// Check flag integration
if (js_integration === true) {
// js-integration
// Load js as 'js-integration'
load_script_as_old_mod('https://www.ittour.com.ua/classes/handlers/ittour_external_modules/ittour_modules/new/js/jquery-1.7.2.min.js');
} else {
// Agency account
// Load js as 'in agency account'
load_js_and_html_for_jsx();
}
// *** END MAIN SRC ************************************************************