| Server IP : 89.108.64.180 / Your IP : 216.73.217.92 Web Server : Apache/2.4.41 (Ubuntu) System : Linux 89-108-64-180.cloudvps.regruhosting.ru 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-root ( 1010) PHP Version : 8.0.30 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/apartadler.ru/wp-content/plugins/wp-hotelier/assets/js/admin/ |
Upload File : |
jQuery(function ($) {
'use strict';
/* global jQuery, wp */
/* eslint-disable no-multi-assign */
var HTL_Settings = {
init: function () {
this.show_uploader();
this.seasonal_dates_datepicker();
this.add_seasonal_rule();
this.navigation();
},
show_uploader: function () {
var uploader_button = $('.htl-ui-button--upload');
var field = uploader_button.closest('.htl-ui-setting').find('input.htl-ui-input--upload');
var file_frame;
uploader_button.on('click', function (e) {
e.preventDefault();
// If the media frame already exists, reopen it.
if (file_frame) {
file_frame.open();
return;
}
// Create the media frame.
file_frame = wp.media.frames.file_frame = wp.media({
states: [
new wp.media.controller.Library({
filterable: 'all',
multiple: false
})
]
});
// When an image is selected, run a callback.
file_frame.on('select', function () {
var selection = file_frame.state().get('selection');
var file_path = '';
selection.map(function (attachment) {
attachment = attachment.toJSON();
if (attachment.url) {
file_path = attachment.url;
}
});
field.val(file_path);
});
// Finally, open the modal.
file_frame.open();
});
},
add_seasonal_rule: function () {
$('#hotelier-seasonal-schema-table').on('htl_multi_text_before_clone_row', function (e) {
// Destroy datepicker
e.row.find('.htl-ui-input--start-date').datepicker('destroy').removeAttr('id');
e.row.find('.htl-ui-input--end-date').datepicker('destroy').removeAttr('id');
});
$('#hotelier-seasonal-schema-table').on('htl_multi_text_after_add_row', function () {
// Init datepicker again
HTL_Settings.seasonal_dates_datepicker();
});
},
seasonal_dates_datepicker: function () {
var table = $('#hotelier-seasonal-schema-table');
var from_inputs = table.find('.htl-ui-input--start-date');
var to_inputs = table.find('.htl-ui-input--end-date');
from_inputs.datepicker({
dateFormat: 'yy-mm-dd',
minDate: 0,
changeMonth: true,
onClose: function () {
var date = $(this).datepicker('getDate');
if (date) {
date.setDate(date.getDate() + 1);
$(this).closest('tr').find('.htl-ui-input--end-date').datepicker('option', 'minDate', date);
}
},
beforeShow: function () {
$('#ui-datepicker-div').addClass('htl-ui-custom-datepicker');
}
});
to_inputs.datepicker({
dateFormat: 'yy-mm-dd',
minDate: 1,
changeMonth: true,
beforeShow: function () {
$('#ui-datepicker-div').addClass('htl-ui-custom-datepicker');
}
});
},
navigation: function () {
var nav_button = $('.htl-ui-text-icon--show-settings-navigation');
var nav = $('.hotelier-settings-navigation__list');
var default_text = nav_button.text();
var hide_text = nav_button.attr('data-hide-text');
nav_button.on('click', function () {
if (nav_button.hasClass('active')) {
nav.hide();
nav_button.removeClass('active').text(default_text);
} else {
nav.show();
nav_button.addClass('active').text(hide_text);
}
});
}
};
$(document).ready(function () {
HTL_Settings.init();
});
});