| 1 |
'use strict'; |
| 2 |
|
| 3 |
|
| 4 |
jQuery(function ($) { |
| 5 |
|
| 6 |
extaStyle(); |
| 7 |
|
| 8 |
$('#wowp-settings').on('submit', function (e) { |
| 9 |
|
| 10 |
const id = $('#tool_id').val(); |
| 11 |
let activeTab = { |
| 12 |
[id]: { |
| 13 |
tabs: {}, |
| 14 |
item: {} |
| 15 |
} |
| 16 |
}; |
| 17 |
|
| 18 |
$('.wowp-tabs-link').each(function (index, element) { |
| 19 |
activeTab[id].tabs[index] = $(element).find('a.is-active').index(); |
| 20 |
}); |
| 21 |
|
| 22 |
$('.wowp-settings details.wowp-item').each(function (index, element) { |
| 23 |
activeTab[id].item[index] = $(element).attr('open') ? 1 : 0; |
| 24 |
}); |
| 25 |
|
| 26 |
sessionStorage.setItem("wowpActiveTab", JSON.stringify(activeTab)); |
| 27 |
}) |
| 28 |
|
| 29 |
$('#settings-tab').on('click', 'a', chooseTabs); |
| 30 |
|
| 31 |
function chooseTabs() { |
| 32 |
const attr = $(this).attr('data-tab'); |
| 33 |
$('#settings-tab a').removeClass('nav-tab-active'); |
| 34 |
$(this).addClass('nav-tab-active'); |
| 35 |
$('#settings-content .tab-content').removeClass('tab-content-active'); |
| 36 |
$('[data-content=' + attr + ']').addClass('tab-content-active'); |
| 37 |
sessionStorage.setItem("wowpTab", attr); |
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
setTabs(); |
| 42 |
|
| 43 |
function setTabs() { |
| 44 |
const id = $('#tool_id').val(); |
| 45 |
if (id === "0") { |
| 46 |
sessionStorage.removeItem('wowpTab'); |
| 47 |
} |
| 48 |
const attr = sessionStorage.getItem("wowpTab"); |
| 49 |
if (attr === null) { |
| 50 |
return false; |
| 51 |
} |
| 52 |
$('#settings-tab a').removeClass('nav-tab-active'); |
| 53 |
$('a[data-tab="' + attr + '"]').addClass('nav-tab-active'); |
| 54 |
$('#settings-content .tab-content').removeClass('tab-content-active'); |
| 55 |
$('[data-content=' + attr + ']').addClass('tab-content-active'); |
| 56 |
} |
| 57 |
|
| 58 |
setActiveTabs(); |
| 59 |
|
| 60 |
function setActiveTabs() { |
| 61 |
const tool_id = $('#tool_id').val(); |
| 62 |
const url_id = getUrlParameter('id'); |
| 63 |
const store = JSON.parse(sessionStorage.getItem("wowpActiveTab")); |
| 64 |
if (store === null) { |
| 65 |
return false; |
| 66 |
} |
| 67 |
if (url_id === null) { |
| 68 |
return false; |
| 69 |
} |
| 70 |
|
| 71 |
let obj = store[tool_id]; |
| 72 |
|
| 73 |
if(obj === undefined) { |
| 74 |
return false; |
| 75 |
} |
| 76 |
|
| 77 |
$('.wowp-tabs-link').each(function (index, element) { |
| 78 |
const linkIndex = obj.tabs[index]; |
| 79 |
$(element).find('a').removeClass('is-active'); |
| 80 |
$(element).find('a').eq(linkIndex).addClass('is-active'); |
| 81 |
const parent = $(element).closest('.wowp-tabs'); |
| 82 |
$(parent).find('.wowp-tabs-content').removeClass('is-active'); |
| 83 |
$(parent).find('.wowp-tabs-content').eq(linkIndex).addClass('is-active'); |
| 84 |
}); |
| 85 |
|
| 86 |
|
| 87 |
$('.wowp-settings details.wowp-item').each(function (index, element) { |
| 88 |
const att = obj.item[index]; |
| 89 |
if (att === 1) { |
| 90 |
$(element).attr('open', ''); |
| 91 |
} |
| 92 |
}); |
| 93 |
} |
| 94 |
|
| 95 |
function getUrlParameter(name) { |
| 96 |
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); |
| 97 |
const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); |
| 98 |
const results = regex.exec(location.search); |
| 99 |
return results === null ? null : decodeURIComponent(results[1].replace(/\+/g, ' ')); |
| 100 |
}; |
| 101 |
|
| 102 |
|
| 103 |
$(".wowp-settings").on("click", '.wowp-tabs .wowp-tabs-link a', function (e) { |
| 104 |
e.preventDefault(); |
| 105 |
const index = $(this).index(); |
| 106 |
const parent = $(this).closest(".wowp-tabs"); |
| 107 |
$(parent).find('.wowp-tabs-link a').removeClass('is-active'); |
| 108 |
$(this).addClass('is-active'); |
| 109 |
$(parent).find('.wowp-tabs-content').removeClass('is-active'); |
| 110 |
$(parent).find('.wowp-tabs-content').eq(index).addClass('is-active'); |
| 111 |
}); |
| 112 |
|
| 113 |
|
| 114 |
// Set value in input hidden for checkbox |
| 115 |
$('.checkbox-helper').each(function() { |
| 116 |
const check = $(this).val(); |
| 117 |
if(check == '1') { |
| 118 |
$(this).prev('input:checkbox').prop('checked', true); |
| 119 |
} else { |
| 120 |
$(this).prev('input:checkbox').prop('checked', false); |
| 121 |
} |
| 122 |
}); |
| 123 |
|
| 124 |
$('.wowp-settings').on('click', 'input:checkbox', function() { |
| 125 |
checkboxchecked(this); |
| 126 |
}); |
| 127 |
|
| 128 |
function checkboxchecked(el) { |
| 129 |
if ($(el).prop('checked')) { |
| 130 |
$(el).next('input[type="hidden"]').val('1'); |
| 131 |
} else { |
| 132 |
$(el).next('input[type="hidden"]').val(''); |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
// Pro page |
| 138 |
$('.w_card-description').on('click', function () { |
| 139 |
$(this).toggleClass('is-open'); |
| 140 |
}) |
| 141 |
|
| 142 |
$('.menu-items').sortable(); |
| 143 |
|
| 144 |
$('.choose-icon select[name^="param["]').each(setIcons); |
| 145 |
|
| 146 |
function setIcons() { |
| 147 |
$(this).fontIconPicker({ |
| 148 |
emptyIcon: false, |
| 149 |
allCategoryText: 'Show all', |
| 150 |
}); |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
$(".wowp-settings").on("change", '.choose-icon select', chooseIcon); |
| 155 |
$('.choose-icon select').each(chooseIcon); |
| 156 |
|
| 157 |
function chooseIcon() { |
| 158 |
const item = $(this).parents('.wowp-item'); |
| 159 |
const icon = $(item).find('.wowp-item_heading_icon'); |
| 160 |
const choose = $(this).val(); |
| 161 |
if (choose !== '') { |
| 162 |
$(icon).html(`<i class="${choose}"></i>`); |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
$('[data-option="close_button_icon"] select').fontIconPicker({ |
| 168 |
emptyIcon: false, |
| 169 |
allCategoryText: 'Show all', |
| 170 |
}); |
| 171 |
|
| 172 |
$('.wowp-field-color').wpColorPicker({ |
| 173 |
change: function (event, ui) { |
| 174 |
changeIconColor(this, ui.color.toString()); |
| 175 |
}, |
| 176 |
}); |
| 177 |
|
| 178 |
$(".item-icon-bg input, .item-icon-color input").each(function (index, element) { |
| 179 |
changeIconColor(element); |
| 180 |
}); |
| 181 |
|
| 182 |
function changeIconColor(element, color = null) { |
| 183 |
if (color === null) { |
| 184 |
color = $(element).val(); |
| 185 |
} |
| 186 |
const parent = $(element).parents('.wowp-field'); |
| 187 |
const item = $(element).parents('.wowp-item'); |
| 188 |
const icon = $(item).find('.wowp-item_heading_icon'); |
| 189 |
|
| 190 |
if ($(parent).hasClass("item-icon-bg")) { |
| 191 |
$(icon).css('background-color', color); |
| 192 |
} |
| 193 |
|
| 194 |
if ($(parent).hasClass("item-icon-color")) { |
| 195 |
$(icon).css('color', color); |
| 196 |
} |
| 197 |
} |
| 198 |
|
| 199 |
$('.label-text input').each(label); |
| 200 |
$(".wowp-settings").on("keyup", '.label-text input', label); |
| 201 |
|
| 202 |
function label() { |
| 203 |
const item = $(this).parents('.wowp-item'); |
| 204 |
const label = $(item).find('.wowp-item_heading_label'); |
| 205 |
let text = $(this).val(); |
| 206 |
if (text === '') { |
| 207 |
text = '(no label)'; |
| 208 |
} |
| 209 |
$(label).text(text); |
| 210 |
} |
| 211 |
|
| 212 |
// Tooltip options |
| 213 |
$('.tooltip-checkbox input').each(tooltip); |
| 214 |
$(".wowp-settings").on("click", '.tooltip-checkbox input', tooltip); |
| 215 |
|
| 216 |
function tooltip() { |
| 217 |
const chekbox = $(this); |
| 218 |
const parent = $(this).parent(); |
| 219 |
const sibling = $(parent).siblings(".tooltip-open"); |
| 220 |
if ($(chekbox).is(':checked')) { |
| 221 |
$(sibling).removeClass('is-hidden'); |
| 222 |
} else { |
| 223 |
$(sibling).addClass('is-hidden'); |
| 224 |
} |
| 225 |
} |
| 226 |
|
| 227 |
customSize(); |
| 228 |
$('[name="param[size]"]').on('change', customSize); |
| 229 |
|
| 230 |
function customSize() { |
| 231 |
const type = $('[name="param[size]"]').val(); |
| 232 |
const custom = $('.custom-font-size'); |
| 233 |
$(custom).fadeOut(); |
| 234 |
if (type === 'flBtn-custom') { |
| 235 |
$(custom).fadeIn(); |
| 236 |
} |
| 237 |
} |
| 238 |
|
| 239 |
tooltipSize(); |
| 240 |
$('[name="param[tooltip_size_check]"]').on('change', tooltipSize); |
| 241 |
|
| 242 |
function tooltipSize() { |
| 243 |
const type = $('[name="param[tooltip_size_check]"]').val(); |
| 244 |
const custom = $('.tooltip-size'); |
| 245 |
$(custom).fadeOut(); |
| 246 |
if (type === 'custom') { |
| 247 |
$(custom).fadeIn(); |
| 248 |
} |
| 249 |
} |
| 250 |
|
| 251 |
// Button type |
| 252 |
$('.button-type select').each(buttonType); |
| 253 |
$(".wowp-settings").on("change", '.button-type select', buttonType); |
| 254 |
|
| 255 |
function buttonType() { |
| 256 |
const type = $(this).val(); |
| 257 |
const text = $(this).find('option:selected').text(); |
| 258 |
const parent = $(this).closest('.wowp-tabs-content'); |
| 259 |
$(parent).find('div:not(.button-type)').addClass('is-hidden'); |
| 260 |
|
| 261 |
switch (type) { |
| 262 |
case 'main': |
| 263 |
$(parent).find('.button-type-main').removeClass('is-hidden'); |
| 264 |
break; |
| 265 |
case 'link': |
| 266 |
$(parent).find('.button-type-link').removeClass('is-hidden'); |
| 267 |
$(parent).find('.button-type-link-open').removeClass('is-hidden'); |
| 268 |
break; |
| 269 |
case 'share': |
| 270 |
$(parent).find('.button-type-share').removeClass('is-hidden'); |
| 271 |
break; |
| 272 |
case 'smoothscroll': |
| 273 |
case 'login': |
| 274 |
case 'logout': |
| 275 |
case 'lostpassword': |
| 276 |
$(parent).find('.button-type-link').removeClass('is-hidden'); |
| 277 |
break; |
| 278 |
case 'translate': |
| 279 |
$(parent).find('.button-type-gtranslate').removeClass('is-hidden'); |
| 280 |
break; |
| 281 |
case 'menu': |
| 282 |
$(parent).find('.button-type-menus').removeClass('is-hidden'); |
| 283 |
break; |
| 284 |
|
| 285 |
} |
| 286 |
|
| 287 |
const item = $(this).closest('.wowp-item'); |
| 288 |
$(item).find('.wowp-item_heading_type').text(text); |
| 289 |
} |
| 290 |
|
| 291 |
// Check Icon type |
| 292 |
$('.icon-type select').each(iconType); |
| 293 |
$(".wowp-settings").on("change", '.icon-type select', iconType); |
| 294 |
|
| 295 |
function iconType() { |
| 296 |
const type = $(this).val(); |
| 297 |
const parent = $(this).closest('.wowp-tabs-content'); |
| 298 |
$(parent).find('.icon-type-default, .icon-type-img, .icon-type-emoji, .icon-type-class').addClass('is-hidden'); |
| 299 |
switch (type) { |
| 300 |
case 'default': |
| 301 |
$(parent).find('.icon-type-default').removeClass('is-hidden'); |
| 302 |
selectIcons(type, parent); |
| 303 |
break; |
| 304 |
case 'img': |
| 305 |
$(parent).find('.icon-type-img').removeClass('is-hidden'); |
| 306 |
selectIcons(type, parent); |
| 307 |
break; |
| 308 |
case 'emoji': |
| 309 |
$(parent).find('.icon-type-emoji').removeClass('is-hidden'); |
| 310 |
selectIcons(type, parent); |
| 311 |
break; |
| 312 |
case 'class': |
| 313 |
$(parent).find('.icon-type-class').removeClass('is-hidden'); |
| 314 |
selectIcons(type, parent); |
| 315 |
break; |
| 316 |
} |
| 317 |
|
| 318 |
} |
| 319 |
|
| 320 |
$(".wowp-settings").on("keyup input", '.icon-type-emoji input', chooseEmoji); |
| 321 |
|
| 322 |
function chooseEmoji() { |
| 323 |
const emoji = $(this).val(); |
| 324 |
changeIconPreview($(this), emoji); |
| 325 |
} |
| 326 |
|
| 327 |
$(".wowp-settings").on("keyup input", '.icon-type-img-url input', chooseImg); |
| 328 |
|
| 329 |
function chooseImg() { |
| 330 |
const imgVal = $(this).val(); |
| 331 |
const img = `<img src="${imgVal}">`; |
| 332 |
changeIconPreview($(this), img); |
| 333 |
} |
| 334 |
|
| 335 |
function selectIcons(type, parent) { |
| 336 |
let icon; |
| 337 |
switch (type) { |
| 338 |
case 'default': |
| 339 |
icon = $(parent).find('.selected-icon').html(); |
| 340 |
break; |
| 341 |
case 'img': |
| 342 |
const img_url = $(parent).find('.icon-type-img-url input').val(); |
| 343 |
icon = `<img src="${img_url}">`; |
| 344 |
break; |
| 345 |
case 'emoji': |
| 346 |
const emoji = $(parent).find('.icon-type-emoji input').val(); |
| 347 |
icon = emoji; |
| 348 |
break; |
| 349 |
case 'class': |
| 350 |
icon = '<span class="dashicons dashicons-format-image"></span>'; |
| 351 |
break; |
| 352 |
} |
| 353 |
changeIconPreview(parent, icon); |
| 354 |
} |
| 355 |
|
| 356 |
function changeIconPreview(child, icon) { |
| 357 |
const parent = $(child).closest('.wowp-item'); |
| 358 |
const iconBox = $(parent).find('.wowp-item_heading_icon'); |
| 359 |
$(iconBox).html(icon); |
| 360 |
} |
| 361 |
|
| 362 |
|
| 363 |
//Check Icon close |
| 364 |
// Tooltip options |
| 365 |
$('.icon-type-close input').each(iconClose); |
| 366 |
$(".wowp-settings").on("click", '.icon-type-close input', iconClose); |
| 367 |
|
| 368 |
function iconClose() { |
| 369 |
const chekbox = $(this); |
| 370 |
const parent = $(this).parent(); |
| 371 |
const sibling = $(parent).siblings(".icon-type-close-choose"); |
| 372 |
if ($(chekbox).is(':checked')) { |
| 373 |
$(sibling).removeClass('is-hidden'); |
| 374 |
} else { |
| 375 |
$(sibling).addClass('is-hidden'); |
| 376 |
} |
| 377 |
} |
| 378 |
|
| 379 |
// Upload the image |
| 380 |
let upload_button; |
| 381 |
|
| 382 |
$(".wowp-settings").on("click", '.icon-type-img-url label', uploadImage); |
| 383 |
|
| 384 |
function uploadImage(event) { |
| 385 |
upload_button = $(this); |
| 386 |
let frame; |
| 387 |
event.preventDefault(); |
| 388 |
if (frame) { |
| 389 |
frame.open(); |
| 390 |
return; |
| 391 |
} |
| 392 |
const parent = $(this).closest('.wowp-tabs-content'); |
| 393 |
const imgUrl = $(parent).find('.icon-type-img-url input'); |
| 394 |
const imgAlt = $(parent).find('.icon-type-img-alt input'); |
| 395 |
|
| 396 |
frame = wp.media(); |
| 397 |
frame.on('select', function () { |
| 398 |
// Grab the selected attachment. |
| 399 |
const attachment = frame.state().get('selection').first(); |
| 400 |
let attachmentUrl = attachment.attributes.url; |
| 401 |
attachmentUrl = attachmentUrl.replace('-scaled.', '.'); |
| 402 |
const altText = attachment.attributes.alt; |
| 403 |
|
| 404 |
frame.close(); |
| 405 |
|
| 406 |
$(imgUrl).val(attachmentUrl); |
| 407 |
$(imgAlt).val(altText); |
| 408 |
const img = `<img src="${attachmentUrl}">`; |
| 409 |
changeIconPreview($(imgUrl), img); |
| 410 |
}); |
| 411 |
frame.open(); |
| 412 |
|
| 413 |
} |
| 414 |
|
| 415 |
// Delete Item |
| 416 |
$(".wowp-settings").on("click", '.wowp-item_heading .dashicons-trash', removeItem); |
| 417 |
|
| 418 |
function removeItem() { |
| 419 |
const userConfirmed = confirm("Are you sure you want to remove this element?"); |
| 420 |
if (userConfirmed) { |
| 421 |
const parent = $(this).closest('.wowp-item'); |
| 422 |
$(parent).remove(); |
| 423 |
} |
| 424 |
} |
| 425 |
|
| 426 |
function isNumber(value) { |
| 427 |
return !isNaN(parseFloat(value)) && isFinite(value); |
| 428 |
} |
| 429 |
|
| 430 |
function refreashel() { |
| 431 |
$('.choose-icon select[name^="param["]').each(setIcons); |
| 432 |
|
| 433 |
$('.wowp-field-color').wpColorPicker({ |
| 434 |
change: function (event, ui) { |
| 435 |
changeIconColor(this, ui.color.toString()); |
| 436 |
}, |
| 437 |
}); |
| 438 |
|
| 439 |
$(".item-icon-bg input, .item-icon-color input").each(function (index, element) { |
| 440 |
changeIconColor(element); |
| 441 |
}); |
| 442 |
|
| 443 |
$('.tooltip-checkbox input').each(tooltip); |
| 444 |
$('.button-type select').each(buttonType); |
| 445 |
$('.icon-type select').each(iconType); |
| 446 |
$('.icon-type-close input').each(iconClose); |
| 447 |
} |
| 448 |
|
| 449 |
$('#add_menu_1, #add_menu_2').on('click', function (e) { |
| 450 |
e.preventDefault(); |
| 451 |
const id = $(this).attr('id'); |
| 452 |
if (id === 'add_menu_1') { |
| 453 |
const temlate = $('#clone-menu-1').clone().html(); |
| 454 |
$('#wowp-menu-1').append(temlate); |
| 455 |
} |
| 456 |
|
| 457 |
if (id === 'add_menu_2') { |
| 458 |
const temlate = $('#clone-menu-2').clone().html(); |
| 459 |
$('#wowp-menu-2').append(temlate); |
| 460 |
} |
| 461 |
|
| 462 |
refreashel(); |
| 463 |
}); |
| 464 |
|
| 465 |
$('#add_display').on('click', function (e) { |
| 466 |
e.preventDefault(); |
| 467 |
|
| 468 |
const temlate = $('#template-display').clone().html(); |
| 469 |
|
| 470 |
$(temlate).insertBefore('#display-rules .btn-add-display'); |
| 471 |
$('#display-rules .display-option select').each(displayRules); |
| 472 |
}); |
| 473 |
|
| 474 |
$('#display-rules').on('click', '.dashicons-trash', function () { |
| 475 |
const parent = $(this).closest('.wowp-fields-group'); |
| 476 |
$(parent).remove(); |
| 477 |
}); |
| 478 |
|
| 479 |
$('#display-rules .display-option select').each(displayRules); |
| 480 |
$('#display-rules').on('change', '.display-option select', displayRules); |
| 481 |
|
| 482 |
function displayRules() { |
| 483 |
let type = $(this).val(); |
| 484 |
const parent = $(this).closest('.wowp-fields-group'); |
| 485 |
$(parent).find('.display-operator, .display-ids, .display-pages').addClass('is-hidden'); |
| 486 |
if(type.indexOf('custom_post_selected') !== -1) { |
| 487 |
type = 'post_selected'; |
| 488 |
} |
| 489 |
if(type.indexOf('custom_post_tax') !== -1) { |
| 490 |
type = 'post_category'; |
| 491 |
} |
| 492 |
switch (type) { |
| 493 |
case 'post_selected': |
| 494 |
case 'post_category': |
| 495 |
case 'page_selected': |
| 496 |
$(parent).find('.display-operator, .display-ids').removeClass('is-hidden'); |
| 497 |
break; |
| 498 |
case 'page_type': |
| 499 |
$(parent).find('.display-operator, .display-pages').removeClass('is-hidden'); |
| 500 |
break; |
| 501 |
|
| 502 |
} |
| 503 |
|
| 504 |
} |
| 505 |
|
| 506 |
$('[data-option="include_more_screen"] input[type="checkbox"], [data-option="include_mobile"] input[type="checkbox"]').each(devicesRules); |
| 507 |
$('[data-option="include_more_screen"] input[type="checkbox"], [data-option="include_mobile"] input[type="checkbox"]').on('click', devicesRules); |
| 508 |
|
| 509 |
function devicesRules() { |
| 510 |
const parent = $(this).parents('.wowp-field'); |
| 511 |
const sibling = $(parent).siblings(".wowp-field"); |
| 512 |
if ($(this).is(':checked')) { |
| 513 |
$(sibling).removeClass('is-hidden'); |
| 514 |
} else { |
| 515 |
$(sibling).addClass('is-hidden'); |
| 516 |
} |
| 517 |
} |
| 518 |
|
| 519 |
$('[name="param[item_user]"]').each(usersRule); |
| 520 |
$('[name="param[item_user]"]').on('change', usersRule); |
| 521 |
|
| 522 |
function usersRule() { |
| 523 |
const user = $(this).val(); |
| 524 |
const parent = $(this).closest('fieldset'); |
| 525 |
const boxRoles = $(parent).find('.wowp-users-roles'); |
| 526 |
$(boxRoles).addClass('is-hidden'); |
| 527 |
if (user === '2') { |
| 528 |
$(boxRoles).removeClass('is-hidden'); |
| 529 |
} |
| 530 |
} |
| 531 |
|
| 532 |
$('.wowp-users-roles .wowp-field:first input:first').each(checkAllRoles); |
| 533 |
$('.wowp-users-roles .wowp-field:first input:first').on('change', checkAllRoles); |
| 534 |
|
| 535 |
function checkAllRoles() { |
| 536 |
const checkboxes = $('.wowp-users-roles input[type="checkbox"]'); |
| 537 |
if ($(this).is(':checked')) { |
| 538 |
$(checkboxes).prop('checked', true); |
| 539 |
} |
| 540 |
} |
| 541 |
|
| 542 |
// Schedule options |
| 543 |
$('.wowp-dates input[type="checkbox"]').each(datesSchedule); |
| 544 |
$('#schedule').on('click', '.wowp-dates input', datesSchedule); |
| 545 |
|
| 546 |
function datesSchedule() { |
| 547 |
const parent = $(this).closest('.wowp-fields-group'); |
| 548 |
if ($(this).is(':checked')) { |
| 549 |
$(parent).find('.wowp-date-input').removeClass('is-hidden'); |
| 550 |
} else { |
| 551 |
$(parent).find('.wowp-date-input').addClass('is-hidden'); |
| 552 |
} |
| 553 |
} |
| 554 |
|
| 555 |
$('#add-schedule').on('click', function (e) { |
| 556 |
e.preventDefault(); |
| 557 |
|
| 558 |
const temlate = $('#clone-schedule').clone().html(); |
| 559 |
|
| 560 |
$(temlate).insertBefore('#schedule .wowp-btn-actions'); |
| 561 |
$('.wowp-dates input[type="checkbox"]').each(datesSchedule); |
| 562 |
}); |
| 563 |
|
| 564 |
$('#schedule').on('click', '.dashicons-trash', function () { |
| 565 |
const parent = $(this).closest('.wowp-fields-group'); |
| 566 |
$(parent).remove(); |
| 567 |
}); |
| 568 |
|
| 569 |
// Main button animation |
| 570 |
$('#button_animation').on('change', mainBtnAnim); |
| 571 |
mainBtnAnim(); |
| 572 |
|
| 573 |
function mainBtnAnim() { |
| 574 |
const type = $('#button_animation').val(); |
| 575 |
$('.btn-animation').addClass('is-hidden'); |
| 576 |
if (type !== '') { |
| 577 |
$('.btn-animation').removeClass('is-hidden'); |
| 578 |
} |
| 579 |
} |
| 580 |
|
| 581 |
|
| 582 |
// Languages options |
| 583 |
$('[data-option="depending_language"] input[type="checkbox"]').each(languageOn); |
| 584 |
$('[data-option="depending_language"] input[type="checkbox"]').on('click', languageOn); |
| 585 |
|
| 586 |
function languageOn() { |
| 587 |
const languages = $(this).parents('.wowp-field').siblings('.wowp-field'); |
| 588 |
if ($(this).is(':checked')) { |
| 589 |
$(languages).removeClass('is-hidden'); |
| 590 |
} else { |
| 591 |
$(languages).addClass('is-hidden'); |
| 592 |
} |
| 593 |
} |
| 594 |
|
| 595 |
function extaStyle() { |
| 596 |
|
| 597 |
|
| 598 |
if(!$('#paramextra_style').length) { |
| 599 |
return false; |
| 600 |
} |
| 601 |
|
| 602 |
const editorSettings = wp.codeEditor.defaultSettings ? _.clone(wp.codeEditor.defaultSettings) : {}; |
| 603 |
const codemirror_gen = |
| 604 |
{ |
| 605 |
"mode": 'css', |
| 606 |
"indentUnit": 2, |
| 607 |
"indentWithTabs": true, |
| 608 |
"inputStyle": "contenteditable", |
| 609 |
"lineNumbers": true, |
| 610 |
"lineWrapping": true, |
| 611 |
"styleActiveLine": true, |
| 612 |
"continueComments": true, |
| 613 |
"extraKeys": { |
| 614 |
"Ctrl-Space": "autocomplete", |
| 615 |
"Ctrl-\/": "toggleComment", |
| 616 |
"Cmd-\/": "toggleComment", |
| 617 |
"Alt-F": "findPersistent", |
| 618 |
"Ctrl-F": "findPersistent", |
| 619 |
"Cmd-F": "findPersistent" |
| 620 |
}, |
| 621 |
"direction": "ltr", |
| 622 |
"gutters": ["CodeMirror-lint-markers"], |
| 623 |
"lint": true, |
| 624 |
"autoCloseBrackets": true, |
| 625 |
"autoCloseTags": true, |
| 626 |
"matchTags": { |
| 627 |
"bothTags": true |
| 628 |
}, |
| 629 |
"tabSize": 2, |
| 630 |
|
| 631 |
}; |
| 632 |
|
| 633 |
const css_code = $('#paramextra_style'); |
| 634 |
editorSettings.codemirror = _.extend({}, editorSettings.codemirror, codemirror_gen); |
| 635 |
const tabStyle = $('.tab-content[data-content="style"]'); |
| 636 |
$(tabStyle).addClass('tab-content-active'); |
| 637 |
wp.codeEditor.initialize($(css_code), editorSettings); |
| 638 |
$(tabStyle).removeClass('tab-content-active'); |
| 639 |
} |
| 640 |
|
| 641 |
}); |
| 642 |
|