<!-- jquery.min.js -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js" ></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.1/js/ion.rangeSlider.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
<!-- sharethis -->
<script type='text/javascript' src='https://platform-api.sharethis.com/js/sharethis.js#property=63110b5e560f0d00125e74b9&product=sop' async='async'></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<!-- script.js -->
<script src="{{ asset('/assets/js/ckeditor4.23/ckeditor.js') }}"></script>
<script src="{{ asset('/assets/js/main.js') }}"></script>
<script>
$(document).ready(function () {
if ($('.bulleted_list_textarea').length) {
$('.bulleted_list_textarea').each(function (index, object) {
let placeholder = $(object).attr('placeholder');
CKEDITOR.replace(object, {
editorplaceholder: placeholder,
enterMode: CKEDITOR.ENTER_LIST,
shiftEnterMode: CKEDITOR.ENTER_BR,
autoParagraph: false,
allowedContent: 'ul ol li[*]', // Tylko listy, * oznacza usunięcie atrybutów
disallowedContent: '*[!ul,!ol,!li]', // Usunięcie innych elementów
versionCheck: false,
selector: '.bulleted_list_textarea',
height: "280",
content_style: "@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300;400&family=Roboto:wght@300&display=swap'); body {margin-top: 4px; margin-left: 10px; height: 100% !important; font-family: 'Roboto Condensed', sans-serif !important; font-size: 14px; font-weight: 400; color: #20262d;}" + "ul {margin: 0px; padding: 0.375rem 0.75rem;}" + "body > p {display:none;}" + ".mce-content-body[data-mce-placeholder]{ margin-top: 10px;position: relative;}",
mobile: {
height: "150",
content_style: "@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300;400&family=Roboto:wght@300&display=swap'); body {margin-top: 4px; margin-left: 10px; height: 100% !important; font-family: 'Roboto Condensed', sans-serif !important; font-size: 14px; font-weight: 400; color: #20262d}" + "ul {margin: 0px; padding-left: 0px; padding: 0.375rem 0.75rem;}" + "body > p {display:none;}" + ".mce-content-body[data-mce-placeholder]{ margin-top: 10px;position: relative;}",
},
extraPlugins: "editorplaceholder",
toolbar: [{name: 'basicstyles', items: ['BulletedList']}],
removePlugins: "elementspath,save,magicline,image,flash,iframe,link,smiley,find,pagebreak,templates,about,maximize,showblocks,newpage,language,blockquote,save,flash,iframe,pagebreak,templates,about,showblocks,newpage,language,print,div'",
on: {
instanceReady: function (ckeditor) {
var idtext = ckeditor.editor.name;
let editor = ckeditor.editor;
let value = editor.getData();
let id = object.id;
if(value == ''){
editor.setData('<ul><li></li></ul>');
$('<textarea id="'+idtext+'" />').html('<ul><li></li></ul>')
}
createBulletedInput(value, idtext);
},
paste: function (ckeditor) {
/*var idtext = ckeditor.editor.name;
let editor = ckeditor.editor;
let valuePaste = ckeditor.data.dataValue;
let value = editor.getData();
let id = object.id;
valuePaste = cleanListHtml(valuePaste);
if (valuePaste.includes('<ul data-test="aggregate-bullet-model">') != false) {
valuePaste = valuePaste.replaceAll('<ul data-test="aggregate-bullet-model">', '<ul>');
}
if(valuePaste.includes('<ul data-stringify-type="unordered-list" data-list-tree="true" data-indent="0" data-border="0"><li data-stringify-indent="0" data-stringify-border="0">') != false){
valuePaste = valuePaste.replaceAll('<ul data-stringify-type="unordered-list" data-list-tree="true" data-indent="0" data-border="0"><li data-stringify-indent="0" data-stringify-border="0">', '<ul>');
}
if(valuePaste.includes('<li data-stringify-indent="0" data-stringify-border="0">') != false){
valuePaste = valuePaste.replaceAll('<li data-stringify-indent="0" data-stringify-border="0">', '<li>');
}
if (valuePaste.includes('<li') == false) {
valuePaste = '<li>'+ckeditor.data.dataValue+'</li>';
}
console.log(valuePaste);
valuePaste = removeAttributesFromHTML(valuePaste);
console.log(valuePaste);
if(valuePaste.includes('<br>') != false){
valuePaste = valuePaste.replaceAll('<br>', '</li><li>');
}
if (valuePaste.includes('</ul><ul>') != false) {
valuePaste = valuePaste.replaceAll('</ul><ul>', '');
}
if (valuePaste.includes('<li><ul>') != false) {
valuePaste = valuePaste.replaceAll('<li><ul>', '');
}
if (valuePaste.includes('</ul></li>') != false) {
valuePaste = valuePaste.replaceAll('</ul></li>', '');
}
if (valuePaste.includes('<br/>') != false){
valuePaste = valuePaste.replaceAll('<br/>', '</li><li>');
}
if (valuePaste.includes('<br data-cke-eol="1">') != false){
valuePaste = valuePaste.replaceAll('<br data-cke-eol="1">', '');
}
if (valuePaste.includes('<br />') != false) {
valuePaste = valuePaste.replaceAll('<br />', '</li><li>');
}
if (valuePaste.includes('<div>') != false) {
valuePaste = valuePaste.replaceAll('<div>', '');
}
if (valuePaste.includes('</div>') != false) {
valuePaste = valuePaste.replaceAll('</div>', '');
}
//value += valuePaste;
value = value.replaceAll('</ul>', '');
value = value.replaceAll('<li><br></li>', '');
value = value.replaceAll('<li><br/></li>', '');
value = value.replaceAll('<li><br /></li>', '');
value = value.replaceAll('<li> </li>', '');
value = value.replaceAll('<ul>', '');
editor.setData(value);
createBulletedInput(value, idtext);*/
},
change: function (ckeditor) {
var idtext = ckeditor.editor.name;
let editor = ckeditor.editor;
let value = editor.getData();
let id = object.id;
if (value.includes('<ul data-test="aggregate-bullet-model">') != false) {
value = value.replaceAll('<ul data-test="aggregate-bullet-model">', '<ul>');
}
if(value.includes('<br>') != false){
value = value.replaceAll('<br>', '</li><li>');
}
console.log(value);
value = removeAttributesFromHTML(value);
console.log(value);
if(value.includes('<ul data-stringify-type="unordered-list" data-list-tree="true" data-indent="0" data-border="0"><li data-stringify-indent="0" data-stringify-border="0">') != false){
value = value.replaceAll('<ul data-stringify-type="unordered-list" data-list-tree="true" data-indent="0" data-border="0"><li data-stringify-indent="0" data-stringify-border="0">', '<ul>');
}
if(value.includes('<li data-stringify-indent="0" data-stringify-border="0">') != false){
value = value.replaceAll('<li data-stringify-indent="0" data-stringify-border="0">', '<li>');
}
if (value.includes('</ul><ul>') != false) {
value = value.replaceAll('</ul><ul>', '');
}
if (value.includes('<li><ul>') != false) {
value = value.replaceAll('<li><ul>', '');
}
if (value.includes('</ul></li>') != false) {
value = value.replaceAll('</ul></li>', '');
}
if (value.includes('<div>') != false) {
value = value.replaceAll('<div>', '');
}
if (value.includes('</div>') != false) {
value = value.replaceAll('</div>', '');
}
if (value.includes('<br/>') != false){
value = value.replaceAll('<br/>', '</li><li>');
}
if (value.includes('<br data-cke-eol="1">') != false){
value = value.replaceAll('<br data-cke-eol="1">', '');
}
if (value.includes('<li> </li><li>') != false) {
value = value.replaceAll('<li> </li><li>', '<li>');
editor.setData(value);
}
if (value.includes('<br />') != false) {
value = value.replaceAll('<br />', '</li><li>');
}
let decodeText = $('<textarea id="'+idtext+'" />').html(value).text();
createBulletedInput(decodeText, idtext);
},
key: function (ckeditor) {
if (ckeditor.data.keyCode == 9 || ckeditor.data.keyCode == (CKEDITOR.SHIFT + 9)) {
ckeditor.cancel();
ckeditor.stop();
}
let editor = ckeditor.editor;
let value = editor.getData();
var idtext = ckeditor.editor.name;
if(ckeditor.data.keyCode == 13 && value.includes('<li> </li>') != false){
}else{
if(ckeditor.data.keyCode != 1114129 && ckeditor.data.keyCode != 1114198 && ckeditor.data.keyCode != 9){
if ($('.'+editor.name).find('.cke_button__bulletedlist').hasClass('cke_button_off')) {
$('.'+editor.name).find('.cke_button__bulletedlist').click();
}
let id = object.id;
value = removeAttributesFromHTML(value);
if (value.includes('<br>') != false) {
value = value.replaceAll('<br>', '</li><li>');
editor.setData(value);
}
if (value.includes('<div> </div>') != false) {
value = value.replaceAll('<div> </div>', '');
editor.setData(value);
}
if (value.includes('</ul><ul>') != false) {
value = value.replaceAll('</ul><ul>', '');
editor.setData(value);
}
if (value.includes('<p>') != false) {
value = value.replaceAll('<p>', '<li>').replaceAll('</p>', '</li>').replaceAll('<div>', '<li>').replaceAll('</div>', '</li>').replaceAll('<li><br></li>', '');
editor.setData(value);
}
if (value.includes('<div>') != false) {
value = value.replaceAll('<div>', '<li>').replaceAll('</div>', '</li>').replaceAll('<li><br></li>', '');
editor.setData(value);
}
if (value.includes('<ul>') == false) {
editor.setData('<ul><li>'+ value +'</li></ul>');
}
let decodeText = $('<textarea id="'+idtext+'" />').html(value).text();
createBulletedInput(decodeText, idtext);
}
}
}
}
});
});
}
});
const INPUT_HIDDENS = (i, name, value) => {
return `<input type="hidden" name="offer[`+ name +`][selected][`+ i +`]" value="custom_input`+ value +`" class="input-list-point_`+ name +` input_bulleted_list_`+name+`_`+ i +`">`;
};
const BUTTON_NO_CLICK = () => {
return `
<button class="navbar-toggler navbar_click_to_change navbar_button_no_clicked" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-line"></span>
<span class="navbar-toggler-line"></span>
<span class="navbar-toggler-line"></span>
</button>
`;
}
let rand = function() {
return Math.random().toString(36).substr(2); // remove `0.`
};
let generateToken = function() {
return rand() + rand(); // to make it longer
};
const BUTTON_CLICK = () => {
return `
<button class="navbar-toggler navbar_click_to_change navbar_button_clicked" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<img src="{{ asset('assets/img/x-white.svg') }}">
</button>
`;
};
function alertMessage(response, reloadPage = false, waitReloadPage = 600)
{
$('.alert').removeClass('alert-danger alert-success');
$('.alert').addClass('alert-'+response.type);
$('.alert').show();
$('.alert_message').html(response.message);
if(reloadPage){
setTimeout(function (){
location.reload();
}, waitReloadPage)
}else{
setTimeout(function (){
$('.alert').hide();
}, waitReloadPage)
}
}
function removeAttributesFromHTML(htmlString) {
// Tworzymy tymczasowy element do sparsowania HTML
const tempDiv = document.createElement('div');
tempDiv.innerHTML = htmlString;
// Funkcja rekurencyjna do czyszczenia atrybutów
function cleanAttributes(element) {
if (element.nodeType === 1) { // tylko elementy HTML
// Usuwamy wszystkie atrybuty
while (element.attributes.length > 0) {
element.removeAttribute(element.attributes[0].name);
}
}
// Przechodzimy rekurencyjnie przez dzieci
for (let child of element.childNodes) {
cleanAttributes(child);
}
}
// Czyścimy wszystkie dzieci tymczasowego elementu
for (let child of tempDiv.childNodes) {
cleanAttributes(child);
}
return tempDiv.innerHTML;
}
function cleanListHtml(html) {
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const allowedTags = ['UL', 'OL', 'LI'];
function cleanElement(el) {
// Only process element nodes
if (el.nodeType !== 1) return;
// If tag is not allowed, unwrap its children
if (!allowedTags.includes(el.tagName)) {
const parent = el.parentNode;
while (el.firstChild) {
parent.insertBefore(el.firstChild, el);
}
parent.removeChild(el);
return;
}
// If tag is allowed, remove all attributes
while (el.attributes.length > 0) {
el.removeAttribute(el.attributes[0].name);
}
// Recursively clean children
Array.from(el.childNodes).forEach(child => cleanElement(child));
}
Array.from(doc.body.childNodes).forEach(child => cleanElement(child));
return doc.body.innerHTML;
}
function createBulletedInput(value_data, NameType)
{
let clearString = '';
let R = 0;
let k = 0;
let value = value_data.replaceAll('<ul>','').replaceAll('</ul>', '').replaceAll('<li>', '').replaceAll('\n', '').replaceAll(' ', '').replaceAll('</li>', '\n').replaceAll('<br>', '\n').replaceAll('<br />', '\n').replaceAll('<div>', '').replaceAll('</div>', '');
let length = value.length;
$('.input-list-point_'+NameType).remove();
ListData = [];
ResponseData[NameType] = [];
for (k; k <= length; k++) {
if (value.charAt(k) != '\n') {
if (value.charAt(k) != '') {
clearString += value.charAt(k);
ListData[R] = {"id": R, "text": clearString};
ResponseData[NameType] = ListData;
ResponseData[NameType].forEach((val,key)=>{
if(typeof ResponseData[NameType][key].text){
if($('.input_bulleted_list_'+NameType+'_'+ResponseData[NameType][key].id).length <= 0){
$('.box-bulleted_list_'+NameType).append(INPUT_HIDDENS(ResponseData[NameType][key].id, NameType, ResponseData[NameType][key].text));
}else{
$('.input_bulleted_list_'+NameType+'_'+ResponseData[NameType][key].id).val('custom_input'+ResponseData[NameType][key].text);
}
}
});
}
} else {
clearString = '';
R ++;
}
}
}
$(document).on('click', '.check-wrapper img', function(){
$(this).closest('.check-wrapper').find('label').click();
});
$(document).on('click', '.check-wrapper label', function(e){
e.stopPropagation();
});
if (jQuery(window).innerWidth() < 600) {
$(document).on('click', '.package_range_switch_box img', function(){
$(this).closest('.package_range_switch_box').find('label.bold').click();
});
}
$(document).on('click', '.navbar_click_to_change', function(){
if($(this).hasClass('navbar_button_no_clicked')){
$('.navbar_button_no_clicked').remove();
$('.navbar-box-button').append(BUTTON_CLICK());
}else{
$('.navbar_button_clicked').remove();
$('.navbar-box-button').append(BUTTON_NO_CLICK());
}
});
$(document).on('click', '.package_box_selected', function (){
let element = $(this).data('package');
$('.package_box_selected').removeClass('package_selected');
$('.package_checkbox_selected').prop('checked', false);
$('label[data-package="'+element+'"]').addClass('package_selected');
})
// GGRZ 2022-10-26
$(window).bind('beforeunload', function(){
$('.box-spinner').css("display","block");
});
$(window).bind('unload', function(){
$('.box-spinner').css("display","none");
});
</script>