| 1 |
(function ($) { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
// Event click Change Color Palette in preview |
| 5 |
$(function () { |
| 6 |
|
| 7 |
// Link solacewp |
| 8 |
const solacewp = 'https://solacewp.com/'; |
| 9 |
|
| 10 |
// Getting the value of the 'demo' parameter using JavaScript |
| 11 |
var params = new URLSearchParams(window.location.search); |
| 12 |
var demoValue = params.get('demo'); |
| 13 |
|
| 14 |
// Cleaning the demoValue to contain only lowercase letters, numbers, hyphens, and spaces |
| 15 |
demoValue = demoValue.toLowerCase().replace(/[^a-z0-9- ]/g, ''); |
| 16 |
|
| 17 |
// Link demo |
| 18 |
let linkDemo = solacewp + demoValue + '/wp-json/elementor-api/v1/settings'; |
| 19 |
|
| 20 |
// Make AJAX request to the API |
| 21 |
$.ajax({ |
| 22 |
url: linkDemo, |
| 23 |
method: 'GET', |
| 24 |
success: function (response) { |
| 25 |
// $('body.solace_page_dashboard-step5 .colorlist a').click(function () { |
| 26 |
$('body.solace_page_dashboard-step5 .colorlist a').click(function () { |
| 27 |
// Get index color |
| 28 |
// var index = $(this).index(); |
| 29 |
// const colorValue = this.getAttribute('data-styles'); |
| 30 |
// console.log(colorValue); |
| 31 |
|
| 32 |
// const jsonString = JSON.stringify(colorValue); |
| 33 |
// localStorage.setItem('solace_step5_color', jsonString); |
| 34 |
|
| 35 |
// // Active class |
| 36 |
// $('body.solace_page_dashboard-step5 .colorlist a').removeClass('active'); |
| 37 |
// $(this).addClass('active'); |
| 38 |
|
| 39 |
// Get container preview |
| 40 |
|
| 41 |
// if (0 === index && typeof index === 'number' && !isNaN(index)) { |
| 42 |
|
| 43 |
// console.log(colorValue); |
| 44 |
// var jsonString = JSON.stringify(colorValue); |
| 45 |
// localStorage.setItem('solace_step5_color', jsonString); |
| 46 |
|
| 47 |
// } else if (0 !== index && index < 5 && typeof index === 'number' && !isNaN(index)) { |
| 48 |
// let colorsIndex = index; |
| 49 |
// let responseColors = response.color_scheme['solace_colors_elementor_' + (colorsIndex + 1)]; |
| 50 |
// // console.log('BaseColor2:'+responseColors.base_color); |
| 51 |
|
| 52 |
// // BASE FONT base_color |
| 53 |
// previewElement.style.setProperty('--sol-color-base-font', responseColors.base_color); |
| 54 |
// previewElement.style.setProperty('--e-global-color-text', responseColors.base_color); |
| 55 |
// previewElement.style.setProperty('--e-global-color-solcolorbasefont', responseColors.base_color); |
| 56 |
|
| 57 |
// // HEADING |
| 58 |
// previewElement.style.setProperty('--e-global-color-solcolorheading', responseColors.heading_color); |
| 59 |
// previewElement.style.setProperty('--sol-color-heading', responseColors.heading_color); |
| 60 |
|
| 61 |
// // LINK BUTTON |
| 62 |
// previewElement.style.setProperty('--e-global-color-primary', responseColors.link_button_color); |
| 63 |
// previewElement.style.setProperty('--e-global-color-solcolorlinkbuttoninitial', responseColors.link_button_color); |
| 64 |
// previewElement.style.setProperty('--sol-color-link-button-initial', responseColors.link_button_color); |
| 65 |
|
| 66 |
// // LINK BUTTON HOVER |
| 67 |
// previewElement.style.setProperty('--e-global-color-solcolorlinkbuttonhover', responseColors.link_button_hover_color); |
| 68 |
// previewElement.style.setProperty('--sol-color-link-button-hover', responseColors.link_button_hover_color); |
| 69 |
|
| 70 |
// // BUTTON / INITIAL |
| 71 |
// previewElement.style.setProperty('--e-global-color-solcolorbuttoninitial', responseColors.button_color); |
| 72 |
// previewElement.style.setProperty('--sol-color-button-initial', responseColors.button_color); |
| 73 |
// previewElement.style.setProperty('--e-global-color-accent', responseColors.button_color); |
| 74 |
|
| 75 |
// // BUTTON HOVER |
| 76 |
// previewElement.style.setProperty('--e-global-color-solcolorbuttonhover', responseColors.button_hover_color); |
| 77 |
// previewElement.style.setProperty('--sol-color-button-hover', responseColors.button_hover_color); |
| 78 |
|
| 79 |
// // TEXT SELECTION |
| 80 |
// previewElement.style.setProperty('--e-global-color-solcolorselectioninitial', responseColors.text_selection_color); |
| 81 |
// previewElement.style.setProperty('--sol-color-selection-initial', responseColors.text_selection_color); |
| 82 |
|
| 83 |
// // TEXT SELECTION BACKGROUND |
| 84 |
// previewElement.style.setProperty('--e-global-color-solcolorselectionhigh', responseColors.text_selection_bg_color); |
| 85 |
// previewElement.style.setProperty('--sol-color-selection-high', responseColors.text_selection_bg_color); |
| 86 |
|
| 87 |
// // BORDER |
| 88 |
// previewElement.style.setProperty('--e-global-color-solcolorborder', responseColors.border_color); |
| 89 |
|
| 90 |
// // BACKGORUND |
| 91 |
// previewElement.style.setProperty('--e-global-color-solcolorbackground', responseColors.background_color); |
| 92 |
// previewElement.style.setProperty('--sol-color-background', responseColors.background_color); |
| 93 |
|
| 94 |
// // PAGE TITLE TEXT COLOR |
| 95 |
// previewElement.style.setProperty('--e-global-color-solcolorheadpagetitletexting', responseColors.page_title_text_color); |
| 96 |
// previewElement.style.setProperty('--sol-color-page-title-text', responseColors.page_title_text_color); |
| 97 |
// previewElement.style.setProperty('--e-global-color-solcolorpagetitletext', responseColors.page_title_text_color); |
| 98 |
|
| 99 |
// // PAGE TITLE BACKGROUND |
| 100 |
// previewElement.style.setProperty('--e-global-color-solcolorpagetitlebackground', responseColors.page_title_bg_color); |
| 101 |
// previewElement.style.setProperty('--sol-color-page-title-background', responseColors.page_title_bg_color); |
| 102 |
// previewElement.style.setProperty('--e-global-color-secondary', responseColors.page_title_bg_color); |
| 103 |
|
| 104 |
// // BACKGROUND MENU DROPDOWN |
| 105 |
// previewElement.style.setProperty('--sol-color-bg-menu-dropdown', responseColors.bg_menu_dropdown_color); |
| 106 |
// previewElement.style.setProperty('--sol-color-border', responseColors.bg_menu_dropdown_color); |
| 107 |
|
| 108 |
// var colorValue = { |
| 109 |
// new_base_color: responseColors.base_color, |
| 110 |
// new_heading_color: responseColors.heading_color, |
| 111 |
// new_link_button_color: responseColors.link_button_color, |
| 112 |
// new_link_button_hover_color: responseColors.link_button_hover_color, |
| 113 |
// new_button_color: responseColors.button_color, |
| 114 |
// new_button_hover_color: responseColors.button_hover_color, |
| 115 |
// new_text_selection_color: responseColors.text_selection_color, |
| 116 |
// new_text_selection_bg_color: responseColors.text_selection_bg_color, |
| 117 |
// new_border_color: responseColors.border_color, |
| 118 |
// new_background_color: responseColors.background_color, |
| 119 |
// new_page_title_text_color: responseColors.page_title_text_color, |
| 120 |
// new_page_title_bg_color: responseColors.page_title_bg_color, |
| 121 |
// new_bg_menu_dropdown_color: responseColors.bg_menu_dropdown_color |
| 122 |
// }; |
| 123 |
// console.log(colorValue); |
| 124 |
// var jsonString = JSON.stringify(colorValue); |
| 125 |
// localStorage.setItem('solace_step5_color', jsonString); |
| 126 |
// } |
| 127 |
}); |
| 128 |
}, |
| 129 |
error: function (xhr, status, error) { |
| 130 |
console.error('Failed to make request to the API settings. Status:', status); |
| 131 |
} |
| 132 |
}); |
| 133 |
}); |
| 134 |
|
| 135 |
$(function () { |
| 136 |
$(window).on('load', function() { |
| 137 |
// Event listener for the 'load' event on the window. |
| 138 |
setTimeout(function() { |
| 139 |
// Set a timeout to execute the function after 1500ms (1.5 seconds) |
| 140 |
const boxPreview = $('body.solace_page_dashboard-step5 .col-right'); |
| 141 |
if (boxPreview.length) { |
| 142 |
// Get and double the width of the element |
| 143 |
let boxPreviewWidth = boxPreview.width(); |
| 144 |
boxPreviewWidth = Math.round(boxPreviewWidth); |
| 145 |
boxPreviewWidth = boxPreviewWidth * 2; |
| 146 |
|
| 147 |
const imgBar = $('body.solace_page_dashboard-step5 .col-right img.urlbar'); |
| 148 |
const getImgBarWidth = window.getComputedStyle(imgBar[0]).width; |
| 149 |
|
| 150 |
if ( '100%' === getImgBarWidth ) { |
| 151 |
// Set the width of the 'preview' element based on the calculated value. |
| 152 |
// console.log('Width img toolbar: ', getImgBarWidth); |
| 153 |
// alert('Width img toolbar: ' + getImgBarWidth); |
| 154 |
$('body.solace_page_dashboard-step5 .col-right .pre-preview > .preview').css('width', boxPreviewWidth - 700 + 'px'); |
| 155 |
} else { |
| 156 |
// Set the width of the 'preview' element based on the calculated value. |
| 157 |
$('body.solace_page_dashboard-step5 .col-right .pre-preview > .preview').css('width', boxPreviewWidth + 'px'); |
| 158 |
} |
| 159 |
} |
| 160 |
}, 2100); |
| 161 |
}); |
| 162 |
|
| 163 |
let resizeTimeout; |
| 164 |
// Event listener for the 'resize' event on the window |
| 165 |
$(window).on('resize', function() { |
| 166 |
const boxPreview = $('body.solace_page_dashboard-step5 .col-right'); |
| 167 |
if (boxPreview.length) { |
| 168 |
// Get and double the width of the element |
| 169 |
let boxPreviewWidth = boxPreview.width(); |
| 170 |
boxPreviewWidth = Math.round(boxPreviewWidth); |
| 171 |
boxPreviewWidth = boxPreviewWidth * 2; |
| 172 |
|
| 173 |
// Set the width of the 'preview' element based on the calculated value |
| 174 |
$('body.solace_page_dashboard-step5 .col-right .pre-preview > .preview').css('width', boxPreviewWidth + 'px'); |
| 175 |
} |
| 176 |
// Clear any existing resize timeout |
| 177 |
clearTimeout(resizeTimeout); |
| 178 |
}); |
| 179 |
}); |
| 180 |
|
| 181 |
})(jQuery); |
| 182 |
|