// Avoid `console` errors in browsers that lack a console.
(function() {
var method;
var noop = function noop() {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeStamp', 'trace', 'warn'
];
var length = methods.length;
var console = (window.console = window.console || {});
while (length--) {
method = methods[length];
// Only stub undefined methods.
if (!console[method]) {
console[method] = noop;
}
}
}());
$(document).ready(function() {
tinymce.init({
selector: "textarea:not(.noPanel)",
theme: "modern",
height: 250,
language : LC,
plugins: [
"advlist autolink link image lists charmap preview hr anchor pagebreak code",
"searchreplace wordcount visualblocks visualchars media nonbreaking",
"table contextmenu directionality paste textcolor responsivefilemanager fullscreen"
],
toolbar: "undo redo | styleselect | bold removeformat italic underline | alignleft aligncenter alignjustify alignright | bullist numlist | paste | forecolor backcolor | responsivefilemanager image | link unlink | code | fullscreen",
contextmenu: "link image inserttable | cell row column deletetable | copy paste",
image_advtab: true,
menubar: false,
content_css: '/includes/css/reset.css, '+ iucs +', https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css',
relative_urls: false,
external_filemanager_path: urlEx +"/includes/filemanager/",
filemanager_title:"Filemanager" ,
external_plugins: { "filemanager" : "http://panel.rolinesystem.com/includes/filemanager/plugin.js"},
setup: function(ed) {
ed.on('keydown', function(event) {
if (event.keyCode == 9) { // tab pressed
if (event.shiftKey) {
ed.execCommand('Outdent');
}
else {
ed.execCommand('Indent');
}
event.preventDefault();
return false;
}
});
}
});
});
function open_popup(url) {
var w = 880;
var h = 570;
var l = Math.floor((screen.width-w)/2);
var t = Math.floor((screen.height-h)/2);
var win = window.open(url, 'Filemanager4tinyMCE', "width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
}
function close_window() {
parent.$.fancybox.close();
}
function receiveMessage(event){
var base_url = event.data;
var alt_name = base_url.substr(base_url.lastIndexOf('/')+1, base_url.lastIndexOf('.'));
var ext = base_url.split('.').pop();
ext=ext.toLowerCase();
var ext_img=new Array('jpg','jpeg','png','gif','bmp','tiff','svg');
var ext_audio=new Array('ogg','mp3','wav');
var ext_video=new Array('mp4','ogg','webm');
var ext_doc=new Array('pdf','xls','xlsx','doc','docx','txt','ppt','pptx');
if($.inArray(ext, ext_img) > -1){
tinymce.activeEditor.insertContent('');
}else{
if($.inArray( ext, ext_doc) > -1){
if(tinymce.activeEditor.selection.getContent() !=''){
tinymce.activeEditor.insertContent(''+ tinymce.activeEditor.selection.getContent() +'');
}else{
tinymce.activeEditor.insertContent(''+ ext.toUpperCase() +'');
}
}else if($.inArray(ext, ext_video) > -1){
tinymce.activeEditor.insertContent('');
}else{
if($.inArray(ext, ext_audio) > -1 ){
if (ext=='mp3') { ext='mpeg'; }
tinymce.activeEditor.insertContent('');
}else{
tinymce.activeEditor.insertContent(''+ alt_name +'');
}
}
}
tinymce.activeEditor.windowManager.close();
}
window.addEventListener("message", receiveMessage, false);
function updateCheckOutDate(checkinInput, checkoutInput, nightsInput, numberNights ){
if(!checkinInput){ checkinInput = 'CheckInDate'; }
if(!checkoutInput){ checkoutInput = 'CheckOutDate'; }
if(!nightsInput){ nightsInput = 'Nights'; numberNights = 1; }
else{ if(parseInt($('.'+nightsInput).val()) < numberNights) $('.'+nightsInput).val(numberNights); }
utcCheckInDateTab = $('.'+checkinInput).val().split("/");
utcCheckOutDateTab = $('.'+checkoutInput).val().split("/");
utcCheckInDate = utcCheckInDateTab[1] + "/" + utcCheckInDateTab[0] + "/" + utcCheckInDateTab[2];
utcCheckOutDate = utcCheckOutDateTab[1] + "/" + utcCheckOutDateTab[0] + "/" + utcCheckOutDateTab[2];
utcDateDiff = dateDiff("d", utcCheckInDate, utcCheckOutDate, 2);
if (utcDateDiff > 0 && nightsInput) {
utcNewCheckOutDate = dateAdd("d", parseInt($('.'+nightsInput).val()), utcCheckInDate);
if (parseInt(utcNewCheckOutDate.getDate()) < 10 ) utcNewCheckOutDay = "0" + parseInt(utcNewCheckOutDate.getDate()); else utcNewCheckOutDay = parseInt(utcNewCheckOutDate.getDate());
if (parseInt(utcNewCheckOutDate.getMonth() + 1) < 10 ) utcNewCheckOutMonth = "0" + parseInt(utcNewCheckOutDate.getMonth() + 1); else utcNewCheckOutMonth = parseInt(utcNewCheckOutDate.getMonth() + 1);
$('#'+checkoutInput).val( utcNewCheckOutDay + "/" + utcNewCheckOutMonth + "/" + utcNewCheckOutDate.getFullYear());
$('#'+checkoutInput).datepicker( "option", "minDate", dateAdd("d", 0, utcCheckInDate) );
} else {
utcNewCheckOutDate = dateAdd("d", numberNights, utcCheckInDate);
if (parseInt(utcNewCheckOutDate.getDate()) < 10 ) utcNewCheckOutDay = "0" + parseInt(utcNewCheckOutDate.getDate()); else utcNewCheckOutDay = parseInt(utcNewCheckOutDate.getDate());
if (parseInt(utcNewCheckOutDate.getMonth() + 1) < 10 ) utcNewCheckOutMonth = "0" + parseInt(utcNewCheckOutDate.getMonth() + 1); else utcNewCheckOutMonth = parseInt(utcNewCheckOutDate.getMonth() + 1);
$('.'+checkoutInput).val( utcNewCheckOutDay + "/" + utcNewCheckOutMonth + "/" + utcNewCheckOutDate.getFullYear());
$('.'+checkoutInput).datepicker( "option", "minDate", dateAdd("d", 0, utcCheckInDate) );
if(nightsInput){ $('.'+nightsInput).val(numberNights); }
}
}
function updateNights(checkinInput, checkoutInput, nightsInput ){
if(!checkinInput){ checkinInput = 'CheckInDate'; }
if(!checkoutInput){ checkoutInput = 'CheckOutDate'; }
if(!nightsInput){ nightsInput = 'Nights'; }
utcCheckInDateTab = $('.'+checkinInput).val().split("/");
utcCheckOutDateTab = $('.'+checkoutInput).val().split("/");
utcCheckInDate = utcCheckInDateTab[1] + "/" + utcCheckInDateTab[0] + "/" + utcCheckInDateTab[2];
utcCheckOutDate = utcCheckOutDateTab[1] + "/" + utcCheckOutDateTab[0] + "/" + utcCheckOutDateTab[2];
utcDateDiff = dateDiff("d", utcCheckInDate, utcCheckOutDate, 2);
if (utcDateDiff > 0) {
$('.'+nightsInput).val(utcDateDiff);
} else {
$('.'+nightsInput).val('1');
utcNewCheckOutDate = dateAdd("d", 1, utcCheckInDate);
if (parseInt(utcNewCheckOutDate.getDate()) < 10 ) utcNewCheckOutDay = "0" + parseInt(utcNewCheckOutDate.getDate()); else utcNewCheckOutDay = parseInt(utcNewCheckOutDate.getDate());
if (parseInt(utcNewCheckOutDate.getMonth() + 1) < 10 ) utcNewCheckOutMonth = "0" + parseInt(utcNewCheckOutDate.getMonth() + 1); else utcNewCheckOutMonth = parseInt(utcNewCheckOutDate.getMonth() + 1);
$('.'+checkoutInput).val(utcNewCheckOutDay + "/" + utcNewCheckOutMonth + "/" + utcNewCheckOutDate.getFullYear());
}
}
function jPost(cData, divResult){
$.ajax({
type: 'POST',
url: '/includes/process',
data: cData,
async: false
}).done(function( msg ) {
if (divResult != '') $(divResult).html(msg);
});
}
$(function() {
$('.calendar').datepicker( $.extend({minDate: 0, numberOfMonths: 2}, $.datepicker.regional[LC] ));
$('.datepicker').datepicker( $.datepicker.regional[LC]);
$('textarea').each(function(){
if($('.accordion').length) { $(this).css('width', parseInt($('.accordion').css('width').replace('px', '')) - 120 + 'px').css('height', '250px'); }
});
$('.accordion').accordion();
$('.ui-accordion-content').each(function(){
$(this).css('height', parseInt($(this).css('height').replace('px', '')) + 20 + 'px');
});
$('#tabs').tabs();
$('#imgHotelPicts, #imgApartPicts, #imgPicts').sortable({
stop: function(event, ui) {
var data = '';
$('#imgHotelPicts div').each(function(i, el){
data += $(el).attr('id')+'-'+$(el).index()+',';
});
if(data!=''){
$.post('/booking-engine/process', 'action=changePictsOrder&NoWait=1&taborder='+ data);
}
data = '';
$('#imgPicts div').each(function(i, el){
data += $(el).attr('id')+'-'+$(el).index()+',';
});
if(data!=''){
$.post('/booking-engine/process', 'action=changePictsOrder&NoWait=1&taborder='+ data);
}
data = '';
$('#imgApartPicts div').each(function(i, el){
data += $(el).attr('id')+'-'+$(el).index()+',';
});
if(data!=''){
$.post('/apartments/process', 'action=changePictsOrder&NoWait=1&taborder='+ data);
}
}
});
$('#imgGalleries, #imgHeaders').sortable({
stop: function(event, ui) {
var data = '';
$('#imgGalleries div').each(function(i, el){
data += $(el).attr('id')+'-'+$(el).index()+',';
});
if(data!=''){
$.post('/website/process', 'action=changeImgGalleriesOrder&NoWait=1&taborder='+ data);
}
}
});
$('#imgHeaders').sortable({
stop: function(event, ui) {
var data = '';
$('#imgHeaders div.img_image').each(function(i, el){
data += $(el).attr('id')+'-'+$(el).index()+',';
});
if(data!=''){
$.post('/website/process', 'action=changeImgHeadersOrder&NoWait=1&taborder='+ data);
}
}
});
$('.tablesorter').tablesorter({
headers: { 4: { sorter: false } },
sortList: [[3,0], [1,0]]
});
$('.agenda, .news').tablesorter({
dateFormat: 'uk',
sortList: [[1,1], [6,1]]
});
$('.bookings').tablesorter({
dateFormat: 'uk',
sortList: [[1,1], [7,1]]
});
$(".dragglist").sortable({
placeholder: "ui-state-highlight",
cursor: 'move',
change: function(e, li){
var id = li.item.attr('id');
$('.'+id).hide();
$('.'+id+' span').html('+');
},
update: function(e, li) {
var currentLi = li.item;
var id = currentLi.attr('id')
var idparent = currentLi.next('li:visible').attr('idparent');
var nivel = currentLi.next('li:visible').attr('nivel');
var reltable = currentLi.parent('ul').attr('reltable');
currentLi.css('margin-left', currentLi.next('li:visible').css('margin-left'));
$.post('/includes/process', 'action=changeParent&table='+reltable+'&id='+id.replace('_', '')+'&idparent='+idparent.replace('_', '')+'&nivel='+nivel+'&NoWait='+1, function(theResponse){
//$("#contentRight").html(theResponse);
});
currentLi.find('span').html('+');
currentLi.after($('.'+id));
}
});
$(".dragglist").disableSelection();
$(".draggtable tbody").sortable({
placeholder: "ui-state-highlight",
opacity: 0.6,
cursor: 'move',
helper: function(e, tr){
var $originals = tr.children();
var $helper = tr.clone();
$helper.children().each(function(index) {
$(this).width($originals.eq(index).width())
});
$helper.find('.table_buttons a').disabled;
return $helper;
},
update: function(e, tr) {
var order = ''; var table = ''; var ordertd = 0; var classoe = 'odd'; var idparent = tr.item.attr('idparent');
$(this).find('tr.canmove').each(function(){
table = $(this).attr('reltable');
order += $(this).attr('id') + ';';
ordertd ++;
order += ordertd + '#';
if(classoe == 'odd') classoe = 'even'; else classoe = 'odd';
$(this).attr('class', classoe);
$(this).find('td.order').html(ordertd);
});
$.post('/includes/process', 'action=orderTable&table='+table+'&order='+order+'&NoWait='+1, function(theResponse){
//$("#contentRight").html(theResponse);
});
$('.tablesorter').tablesorter({
headers: { 4: { sorter: false } }
});
}
});
$(".draggtable tbody").disableSelection();
});
// Accordion movimiento
/*$(function() {
$('#accordion li').hover(function(){
// over
$(this).children('a').stop().animate({ marginLeft: "20" }, "fast");
} , function(){
// out
$(this).children('a').stop().animate({marginLeft: "5"}, "fast");
});
});*/
// Upload
$(function() {
var count = 0, id, auto, multi, folder, table, ext, btn;
$('.formUpload').each(function(){
count++;
if($(this).attr('idpage')) idpage = $(this).attr('idpage'); else idpage = 0;
if($(this).attr('idevent')) idevent = $(this).attr('idevent'); else idevent = 0;
if($(this).attr('idarticle')) idarticle = $(this).attr('idarticle'); else idarticle = 0;
if($(this).attr('idapart')) idapart = $(this).attr('idapart'); else idapart = 0;
if($(this).attr('idroom')) idroom = $(this).attr('idroom'); else idroom = 0;
if($(this).attr('idhotel')) idhotel = $(this).attr('idhotel'); else idhotel = 0;
if($(this).attr('idboard')) idboard = $(this).attr('idboard'); else idboard = 0;
if($(this).attr('idoffer')) idoffer = $(this).attr('idoffer'); else idoffer = 0;
if($(this).attr('idextra')) idextra = $(this).attr('idextra'); else idextra = 0;
if($(this).attr('idproduct')) idproduct = $(this).attr('idproduct'); else idproduct = 0;
if($(this).attr('auto') == 'true') {
auto = true;
btn = '';
} else {
auto = false;
btn = '';
}
if($(this).attr('multi') == 'true') multi = true; else multi = false;
$(this).html('