$.hotelform_loader = { block: '', lite: false, process: false, arg: {}, loaded: -1, scripts: [ 'styles/_generic/scripts/jquery.cms', 'styles/_generic/scripts/jquery.cms.popup', 'styles/_generic/popup/jquery.cms.popup.flybox', 'styles/_generic/scripts/jquery.cms.ajax', 'styles/_generic/scripts/jquery.cms.ajax.cache', 'setup', 'styles/hotelform/main/scripts', 'styles/hotelform/main/currency', 'styles/hotelform/main/form' ], scriptsBase: [ 'https://hotel-booker.ru/plugins/jquery/jquery.form.min.js', 'https://hotel-booker.ru/plugins/jquery/jquery.flybox/jquery.flybox.min.js' ], load: function(arg) { arg = arg || {}; datepicker = arg.datepicker || 'ru'; if (!$.ui || !$.datepicker) { $.hotelform_loader.scripts.unshift('https://hotel-booker.ru/plugins/jquery/jquery.ui/jquery-ui.min.js'); } if ((datepicker != 'en') && (!$.datepicker || !$.datepicker.regional || !$.datepicker.regional[datepicker])) { $.hotelform_loader.scripts.unshift('https://hotel-booker.ru/plugins/jquery/jquery.ui/i18n/jquery.ui.datepicker-' + datepicker + '.min.js'); } $.hotelform_loader.arg.hotel = arg.hotel || false; $.hotelform_loader.arg.agent = arg.agent || false; $.hotelform_loader.arg.language = arg.language || false; $.hotelform_loader.arg.next_link = arg.next_link || false; $.hotelform_loader.arg.descriptions = arg.descriptions || false; $.hotelform_loader.block = arg.block || 'main'; $('#'+$.hotelform_loader.block).html('Loading...'); $.hotelform_loader.lite = arg.lite || false; if ($.hotelform_loader.loaded >= $.hotelform_loader.scripts.length) { return $.hotelform_loader.show(); } if (!$.hotelform_loader.lite) { $.hotelform_loader.scripts = $.hotelform_loader.scriptsBase.concat($.hotelform_loader.scripts); } $.hotelform_loader.next(); }, next: function() { $.hotelform_loader.loaded++; if ($.hotelform_loader.loaded < $.hotelform_loader.scripts.length) { var script = $.hotelform_loader.scripts[$.hotelform_loader.loaded]; if (script == 'setup') { var settings = { root:'https://hotels-booker.ru/', path:'/', uri:'uri:/', popup:'flybox', paths:{plugins:'https://hotel-booker.ru/plugins/', style_generic:'https://hotels-booker.ru/styles/_generic/'}, enabled:{ajax:true, ajax_cache:true} }; if ($.hotelform_loader.lite) { $.hotelform.setup(settings); } else { $.cms.setup(settings); } return $.hotelform_loader.next(); } if (script.substr(0,7)=='styles/') { if ($.hotelform_loader.lite) { script = 'https://hotels-booker.ru/?module=page&call=script&filter=$.cms&replace=$.hotelform&file=' + script.substr(7); } else { script = 'https://hotels-booker.ru/' + script + '.js'; } } return $.ajax({ dataType: 'script', scriptCharset: 'utf-8', url: script, success: $.hotelform_loader.next }); } return $.hotelform_loader.insert(); }, insert: function() { if (!$.hotelform_loader.lite) { $.hotelform = $.cms; } $.hotelform_loader.process = $.hotelform.ajax.process; $.hotelform.html_equals = function(a,b) { return false; }; $.hotelform.ajax.process = function(data) { for (var i=0; i','g'),' href="!'+$.hotelform_loader.arg.next_link+'" onclick="return $.extern-cms.ajax.go(this.href);">') } return text .replace(/ id="content"/g,' id="hotel-content"') .replace(/src="\//g,'src="'+$.hotelform.config.root) .replace(/href="\//g,'href="'+$.hotelform.config.root) .replace(/action="\//g,'action="'+$.hotelform.config.root) //.replace(/ class="popup"/g, ' onclick="return $.hotelform.ajax.go(\'/contact_popup\');"') .replace(/ onclick="return \$\.cms\.ajax\.go_form\(this\);"/g,' onclick="return $.hotelform_loader.go_form(this);"') .replace(/\$\.cms/g,'$.hotelform') .replace(/\$\.extern-cms/g,'$.cms') .replace(/href="!/g,'href="'); }; $.hotelform.ajax.dataType = 'jsonp'; $.hotelform.ajax.animate = '#' + $.hotelform_loader.block; $.hotelform.ajax.prepost = function(post) { post.is_external = true; if ($.hotelform_loader.arg.language) { post.use_language = $.hotelform_loader.arg.language; } if ($.hotelform_loader.arg.hotel) { post.hotel = $.hotelform_loader.arg.hotel; } if ($.hotelform_loader.arg.agent) { post.agent = $.hotelform_loader.arg.agent; } if ($.hotelform_loader.arg.next_link) { post.next_link = $.hotelform_loader.arg.next_link; } if ($.hotelform_loader.arg.descriptions) { post.descriptions = $.hotelform_loader.arg.descriptions; } }; $.hotelform.ajax.go_raw = $.hotelform.ajax.go; $.hotelform.ajax.go = function(url,post,id,use_uri) { $.hotelform.ajax.go_raw(('$h' + url).replace('$h/','https://hotels-booker.ru/').replace('$h',''), post, id, use_uri); }; $.hotelform_loader.show(); }, go_form: function(element) { post = {}; if ($.hotelform_loader.arg.language) { post.h_lang = $.hotelform_loader.arg.language; } var vform = $(element).parents('form'); var buff = ''; for (var i in post) { buff += ''; } vform.append(buff).get(0).clk = element; }, show: function() { $.hotelform.ajax.cache.clear(); $(function() {$.hotelform.ajax.go('/booking');}); return false; }, autobind: function() { $('div.hotelform-place:not(.hotelform-loaded)').addClass('hotelform-loaded').each(function() { var form = $(this); $.hotelform_loader.load({ hotel: form.data('hotel'), agent: form.data('agent'), language: form.data('language'), datepicker: form.data('datepicker'), descriptions: form.data('descriptions'), next_link: form.data('nextlink'), block: form.attr('id'), lite: form.data('lite') }); }); }, init: function() { if ($.cms && $.cms.onPageLoad) { $.cms.onPageLoad($.hotelform_loader.autobind); } else { $.hotelform_loader.autobind(); } } }; $($.hotelform_loader.init);