1jQuery(document).ready(function () { 2 jQuery('#dwpp_woo_metaboxes').hide(); 3 jQuery('.options_group.pricing').addClass('show_if_listing_pricing_plans').show(); 4 jQuery('._dwpp_listings_limit_field ').hide(); 5 jQuery('._dwpp_unl_listings_field').hide(); 6 jQuery('._dwpp_hide_listings_field').hide(); 7 jQuery('._dwpp_featured_limit_field').hide(); 8 jQuery('._dwpp_unl_featured_field').hide(); 9 jQuery('._dwpp_hide_featured_field').hide(); 10 11 jQuery('#product-type').on('change', function () { 12 if (jQuery(this).val() == 'listing_pricing_plans') { 13 jQuery('.inventory_options').addClass('show_if_listing_pricing_plans').show(); 14 jQuery('#inventory_product_data ._sold_individually_field').parent().addClass('show_if_listing_pricing_plans').show(); 15 jQuery('#inventory_product_data ._sold_individually_field').addClass('show_if_listing_pricing_plans').show(); 16 jQuery('#dwpp_woo_metaboxes').show(); 17 } else { 18 jQuery('#dwpp_woo_metaboxes').hide(); 19 } 20 }); 21 jQuery('#product-type').trigger('change'); 22 23 var selectedVal = jQuery('[name="_dwpp_plan_type"]:checked').val(); 24 //get the plan type 25 jQuery('._dwpp_listings_limit_field').hide(); 26 jQuery('._dwpp_featured_limit_field').hide(); 27 jQuery('[name="_dwpp_plan_type"]').on('click', function () { 28 29 //hide unnecessary fields if click on PPL 30 if (jQuery(this).val() === 'package') { 31 alert('Please Make sure to add number of Regular and Featured listings in this package'); 32 jQuery('._dwpp_listings_limit_field ').fadeIn(300); 33 jQuery('._dwpp_unl_listings_field').fadeIn(300); 34 jQuery('._dwpp_hide_listings_field').fadeIn(300); 35 jQuery('._dwpp_featured_limit_field').fadeIn(300); 36 jQuery('._dwpp_unl_featured_field').fadeIn(300); 37 jQuery('._dwpp_hide_featured_field').fadeIn(300); 38 jQuery('._dwpp_featured_field').fadeOut(300); 39 jQuery('._dwpp_featured').hide(); 40 jQuery('._dwpp_hide_listing_featured_field').hide(); 41 42 43 } else { 44 jQuery('._dwpp_listings_limit_field ').fadeOut(300); 45 jQuery('._dwpp_unl_listings_field').fadeOut(300); 46 jQuery('._dwpp_hide_listings_field').fadeOut(300); 47 jQuery('._dwpp_featured_limit_field').fadeOut(300); 48 jQuery('._dwpp_unl_featured_field').fadeOut(300); 49 jQuery('._dwpp_hide_featured_field').fadeOut(300); 50 jQuery('._dwpp_featured_field').fadeIn(300); 51 jQuery('._dwpp_featured').fadeIn(300); 52 jQuery('._dwpp_hide_listing_featured_field').fadeIn(300); 53 } 54 }); 55 56 if (selectedVal === 'pay_per_listng') { 57 jQuery('._dwpp_listings_limit_field ').hide(); 58 jQuery('._dwpp_unl_listings_field').hide(); 59 jQuery('._dwpp_hide_listings_field').hide(); 60 jQuery('._dwpp_featured_limit_field').hide(); 61 jQuery('._dwpp_unl_featured_field').hide(); 62 jQuery('._dwpp_hide_featured_field').hide(); 63 jQuery('._dwpp_featured_field').fadeIn(300); 64 } 65 if (selectedVal === 'package') { 66 jQuery('._dwpp_listings_limit_field ').show(); 67 jQuery('._dwpp_unl_listings_field').show(); 68 jQuery('._dwpp_hide_listings_field').show(); 69 jQuery('._dwpp_featured_limit_field').show(); 70 jQuery('._dwpp_unl_featured_field').show(); 71 jQuery('._dwpp_hide_featured_field').show(); 72 jQuery('._dwpp_featured_field').hide(); 73 jQuery('._dwpp_featured').hide(); 74 jQuery('._dwpp_hide_listing_featured_field').hide(); 75 } 76 77 var $ = jQuery; 78 79 $('#is_listing_featured').hide(); 80 var package = $('#package'); 81 var pay_per_listing = $('#pay_per_listng'); 82 var pay_per_package = $('#pay_per_package'); 83 var plan_tax_area = $('.plan_tax_area'); 84 85 $('body').on('change', 'input[name="plan_type"]', function () { 86 if ($(this).val() == "package") { 87 88 $(this).prop("checked", false); 89 let target_class = $(this).data('target'); 90 $('.' + target_class).toggleClass('active'); 91 } else if ($(this).val() == "pay_per_listng") { 92 93 $('#regular_listing').fadeOut(300); 94 $('#featured_listing').fadeOut(300); 95 $('#is_listing_featured').fadeIn(300); 96 } 97 }); 98 99 // Auto Subscription 100 let autoSubsCheckbox = $('.directorist-auto-subscription .directorist-switch-Yn input[type=checkbox]'); 101 let linkSubscription = $('.directorist-input-box .directorist-link-subscription'); 102 let linkDuration = $('.directorist-input-box .directorist-listing-duration'); 103 let wooPricingInput = $('.product_data .woocommerce_options_panel .pricing input'); 104 let wooProductType = $('#woocommerce-product-data #product-type[name="product-type"]'); 105 $(autoSubsCheckbox).on('change', function (event) { 106 if ($(this).prop('checked')) { 107 $(linkSubscription).addClass('directorist-visible'); 108 $(linkDuration).addClass('directorist-hidden'); 109 $(wooPricingInput).attr("disabled", true); 110 if ($(wooProductType).val() === 'listing_pricing_plans') { 111 $(wooPricingInput).attr("disabled", true); 112 } 113 } else { 114 $(linkSubscription).removeClass('directorist-visible'); 115 $(linkDuration).removeClass('directorist-hidden'); 116 $(wooPricingInput).attr("disabled", false); 117 } 118 }); 119 120 $(wooProductType).on('change', function (event) { 121 if ($(this).val() === 'listing_pricing_plans' && $(autoSubsCheckbox).prop('checked')) { 122 $(wooPricingInput).attr("disabled", true); 123 } else { 124 $(wooPricingInput).attr("disabled", false); 125 } 126 }); 127 128 if ($(autoSubsCheckbox).prop('checked')) { 129 $(linkSubscription).addClass('directorist-visible'); 130 $(wooPricingInput).attr("disabled", true); 131 132 if ($(wooProductType).val() === 'listing_pricing_plans') { 133 $(wooPricingInput).attr("disabled", true); 134 } 135 } else { 136 $(linkSubscription).removeClass('directorist-visible'); 137 $(wooPricingInput).attr("disabled", false); 138 } 139 140 // load admin add listing form 141 const directory_type = $('select[name="directory_type"]').val(); 142 143 if (directory_type) { 144 admin_listing_form(directory_type); 145 } 146 $('body').on('change', 'select[name="directory_type"]', function () { 147 admin_listing_form($(this).val()); 148 }); 149 150 function admin_listing_form(directory_type) { 151 $.ajax({ 152 type: 'post', 153 url: woo_pricing_admin_js.ajaxurl, 154 data: { 155 action: 'atbdp_dynamic_plan', 156 directory_type: directory_type, 157 listing_id: $('#directiost-listing-fields_wrapper').data('id'), 158 user_id: $('select[name=post_author_override]').val(), 159 160 }, 161 success(response) { 162 if (response) { 163 $('.directorist-admin-form-plan-container') 164 .empty() 165 .html(response); 166 } 167 }, 168 }); 169 } 170 171 // Switch Control 172 $('body').on('click', '.directorist-switch-Yn', function () { 173 if ($(this).children('input').is(':checked')) { 174 $(this).siblings('.directorist-switch-Yn-content').addClass('directorist-visible'); 175 $(this).parent('td').siblings('td').children('.directorist-switch-Yn-content').addClass('directorist-visible'); 176 } else { 177 $(this).siblings('.directorist-switch-Yn-content').removeClass('directorist-visible'); 178 $(this).parent('td').siblings('td').children('.directorist-switch-Yn-content').removeClass('directorist-visible'); 179 } 180 }); 181 182 // Renew Check 183 $('body').on('change', '#directorist_auto-renew-check', function () { 184 if ($(this).is(':checked')) { 185 $(this).closest('.directorist-renew-check-content').addClass('directorist-auto-renew-active'); 186 } else { 187 $(this).closest('.directorist-renew-check-content').removeClass('directorist-auto-renew-active'); 188 } 189 }); 190 191
192 // Input Control 193 $('body').on('click', '.directorist-input-control', function () { 194 if ($(this).children('input').is(':checked')) { 195 $(this).siblings('.directorist-handle-input').removeClass('directorist-visible'); 196 } else { 197 $(this).siblings('.directorist-handle-input').addClass('directorist-visible'); 198 } 199 }); 200 201 // Price Set 202 $('body').on('click', '.directorist_free-plan #free_plan', function () { 203 if ($(this).is(':checked')) { 204 $(this).parent('.directorist_free-plan').siblings('.directorist_tax-wrap, .directorist_price-input').fadeOut(); 205 } else { 206 $(this).parent('.directorist_free-plan').siblings('.directorist_tax-wrap, .directorist_price-input').fadeIn(); 207 } 208 }); 209 210 211 $('body').on('click', '.atpp_modal-ok', function (e) { 212 e.preventDefault(); 213 214 $('#pay_per_package').prop("checked", true); 215 $('.atpp_seelct-plan-modal').removeClass('active'); 216 $('.atbdp-directory-delete-cancel-link').removeClass('atpp_cptm-modal-toggle'); 217 218 let target_class = $(this).data('target'); 219 $('.' + target_class).removeClass('active'); 220 $('#regular_listing').fadeIn(300); 221 $('#featured_listing').fadeIn(300); 222 $('#is_listing_featured').fadeOut(300); 223 }); 224 225 $('body').on('click', '.atpp_modal-cancel', function (e) { 226 e.preventDefault(); 227 228 $('#pay_per_listng').prop("checked", true); 229 let target_class = $(this).data('target'); 230 $('.' + target_class).removeClass('active'); 231 }); 232 233 234 window.onload = function () { 235 var selectedVal = ""; 236 var selected = $("input[type='radio'][name='plan_type']:checked"); 237 if (selected.length > 0) { 238 selectedVal = selected.val(); 239 } 240 if (selectedVal === 'pay_per_listng') { 241 $('#regular_listing').fadeOut(); 242 $('#featured_listing').fadeOut(); 243 $('#is_listing_featured').fadeIn(300); 244 } else if (selectedVal === 'package') { 245 $('#regular_listing').show(); 246 $('#featured_listing').show(); 247 $('#is_listing_featured').hide(); 248 } 249 250 //Pricing Width on Resize Fixed 251 if ($('#fm_plans_container').innerWidth() < 768) { 252 $('#fm_plans_container .atbd_plans_row .atbd_plan_col').addClass('atbd_plan_col--res-fix'); 253 } 254 255 // Switch Control 256 $('.directorist-switch-Yn').each((index, element) => { 257 if ($(element).children('input').is(':checked')) { 258 $(element).siblings('.directorist-switch-Yn-content').addClass('directorist-visible'); 259 $(element).parent('td').siblings('td').children('.directorist-switch-Yn-content').addClass('directorist-visible'); 260 } else { 261 $(element).siblings('.directorist-switch-Yn-content').removeClass('directorist-visible'); 262 $(element).parent('td').siblings('td').children('.directorist-switch-Yn-content').removeClass('directorist-visible'); 263 } 264 }); 265 266 // Renew Check 267 $('#directorist_auto-renew-check').each((index, element) => { 268 if ($(element).is(':checked')) { 269 $(element).closest('.directorist-renew-check-content').addClass('directorist-auto-renew-active'); 270 } else { 271 $(element).closest('.directorist-renew-check-content').removeClass('directorist-auto-renew-active'); 272 } 273 }); 274 275 // Input Control 276 $('.directorist-input-control').each((index, element) => { 277 if ($(element).children('input').is(':checked')) { 278 $(element).siblings('.directorist-handle-input').removeClass('directorist-visible'); 279 } else { 280 $(element).siblings('.directorist-handle-input').addClass('directorist-visible'); 281 } 282 }); 283 // Price Set 284 $('.directorist_free-plan #free_plan').each((index, element) => { 285 if ($(element).is(':checked')) { 286 $(element).parent('.directorist_free-plan').siblings('.directorist_tax-wrap, .directorist_price-input').fadeOut(); 287 } else { 288 $(element).parent('.directorist_free-plan').siblings('.directorist_tax-wrap, .directorist_price-input').fadeIn(); 289 } 290 }); 291 }; 292 293 // load dynamic field 294 $('body').on('change', 'input[name=assign_to_directory]', function () { 295 var form_data = new FormData(); 296 var listing_type = $(this).val(); 297 var post_id = $('input[name="post_id"]').val(); 298 form_data.append('action', 'directorist_plan_dynamic_fields'); 299 form_data.append('post_id', post_id); 300 form_data.append('listing_type', listing_type); 301 $.ajax({ 302 method: 'POST', 303 processData: false, 304 contentType: false, 305 url: woo_pricing_admin_js.ajaxurl, 306 data: form_data, 307 beforeSend: function () { 308 $('#directorist-type-preloader').show(); 309 }, 310 success: function (response) { 311 $('.directorist-plan-dynamic-field').empty().append(response); 312 }, 313 error: function (error) { 314 //console.log(error); 315 }, 316 complete: function () { 317 $('#directorist-type-preloader').hide(); 318 } 319 }); 320 }); 321 322 /* Description character limit: WPEditor */ 323 function checkTextareaLimit(textEditorSelector, type) { 324 textEditorDoms = document.querySelectorAll(`${textEditorSelector}`); 325 if (textEditorDoms.length) {
326 textEditorDoms.forEach((textEditorElment) => { 327 328 if (type === "editor") { 329 if(document.getElementById('directorist_listing_content_max') === null){ 330 return; 331 } 332 var textEditorElmentId = textEditorElment.querySelector('textarea').id; 333 var textareaMaxChar = document.getElementById('directorist_listing_content_max').value; 334 } else if (type === "textarea") { 335 if ( ! textEditorElment.getAttribute("maxlength") || ( textEditorElment.getAttribute("maxlength") === null ) ) { 336 return; 337 } 338 var textEditorElmentId = textEditorElment.id; 339 var textareaMaxChar = Number(textEditorElment.getAttribute("maxlength")); 340 textEditorElment.setAttribute("maxlength", textareaMaxChar); 341 } 342 343 var remainingCharCount = textareaMaxChar; 344 remainingDom = document.createElement('p'); 345 remainingDom.classList.add('directorist-remaining-count'); 346 remainingDom.innerText = plan_validator.remaining_text + " " + textareaMaxChar; 347 textEditorElment.insertAdjacentElement('afterend', remainingDom); 348 var maxCharAlertDom = document.createElement('p'); 349 maxCharAlertDom.classList.add('directorist-textarea-max-alert'); 350 maxCharAlertDom.innerText = plan_validator.max_exit; 351 /* get editor text contents character & word counts */ 352 function getStats(id) { 353 if (type === "editor") { 354 var body = tinymce.get(id).getBody(), 355 text = tinymce.trim(body.innerText || body.textContent) 356 } else if (type === "textarea") { 357 var text = textEditorElment.value 358 } 359 return { 360 chars: text.length, 361 words: text.split(/[\w\u2019\'-]+/).length 362 }; 363 } 364 /* append alert */ 365 function appendAlert() { 366 if (!maxCharAlertDom.length) { 367 if (type === "editor") { 368 textEditorElment.nextSibling.insertAdjacentElement('afterend', maxCharAlertDom) 369 } else { 370 textEditorElment.nextSibling.insertAdjacentElement('afterend', maxCharAlertDom); 371 } 372 } 373 } 374 if (type === "editor") { 375 tinymce.activeEditor.on('keypress', function (e) { 376 if (remainingCharCount > 0) { 377 textEditorElment.nextSibling.innerText = `${plan_validator.remaining_text} ${textareaMaxChar - getStats(textEditorElmentId).chars}`; 378 } 379 380 /* append/remove max limit alert */ 381 if (getStats(textEditorElmentId).chars >= textareaMaxChar) { 382 appendAlert() 383 e.preventDefault(); 384 } else if (getStats(textEditorElmentId).chars < textareaMaxChar + 2) { 385 maxCharAlertDom.remove(); 386 } 387 }); 388 tinymce.activeEditor.on('keydown', function (e) { 389 if (e.keyCode == 8) { 390 /* remove alert */ 391 if (getStats(textEditorElmentId).chars < textareaMaxChar + 2) { 392 maxCharAlertDom.remove(); 393 } 394 setTimeout(() => { 395 if (getStats(textEditorElmentId).chars === 0) { 396 remainingCharCount = textareaMaxChar; 397 textEditorElment.nextSibling.innerText = `${plan_validator.remaining_text} ${textareaMaxChar}`; 398 } 399 let remChar = getStats(textEditorElmentId).chars; 400 let remCharCount = textareaMaxChar - remChar;
401 textEditorElment.nextSibling.innerText = `${plan_validator.remaining_text} ${remCharCount}`; 402 }, 0); 403 if (remainingCharCount >= 0 && remainingCharCount < textareaMaxChar) { 404 remainingCharCount++; 405 textEditorElment.nextSibling.innerText = `${plan_validator.remaining_text} ${remainingCharCount}`; 406 } 407 } 408 }); 409 tinymce.activeEditor.on('paste', function (e) { 410 var currentText = tinymce.activeEditor.contentDocument.body.innerText; 411 let currentTextSanitize = currentText.replace(/%MCEPASTEBIN%/g, ''); 412 var textLength = textareaMaxChar - currentTextSanitize.length + 3; 413 let clipTextLength = e.clipboardData.getData('text').length; 414 remainingCharCount = textareaMaxChar - (clipTextLength + currentTextSanitize.trim().length); 415 textEditorElment.nextSibling.innerText = `${plan_validator.remaining_text} ${remainingCharCount}`; 416 if (clipTextLength >= textLength) { 417 var sliceCopiedData = e.clipboardData.getData('text').slice(0, textLength); 418 tinymce.activeEditor.contentDocument.body.innerText = currentTextSanitize.trim() + ' ' + sliceCopiedData; 419 appendAlert(); 420 remainingCharCount = 0; 421 textEditorElment.nextSibling.innerText = `${plan_validator.remaining_text} 0`; 422 e.preventDefault(); 423 } else { 424 if (maxCharAlertDom.length) { 425 maxCharAlertDom.remove(); 426 } 427 } 428 }); 429 tinymce.activeEditor.on('cut', function (e) { 430 setTimeout(() => { 431 if (getStats(textEditorElmentId).chars === 0) { 432 remainingCharCount = textareaMaxChar; 433 textEditorElment.nextSibling.innerText = `${plan_validator.remaining_text} ${textareaMaxChar}`; 434 } 435 let remChar = getStats(textEditorElmentId).chars; 436 let remCharCount = textareaMaxChar - remChar; 437 textEditorElment.nextSibling.innerText = `${plan_validator.remaining_text} ${remCharCount}`; 438 }, 100); 439 if (remainingCharCount >= 0 && remainingCharCount < textareaMaxChar) { 440 remainingCharCount++; 441 textEditorElment.nextSibling.innerText = `${plan_validator.remaining_text} ${remainingCharCount}`; 442 } 443 }); 444 } else { 445 function letterCountWithAlert() { 446 if (remainingCharCount > 0) { 447 let remainingNumber = textareaMaxChar - getStats(textEditorElmentId).chars; 448 if (remainingNumber < 0) { 449 remainingNumber = 0; 450 } 451 textEditorElment.closest('.directorist-form-group').querySelector('.directorist-remaining-count').innerText = `${plan_validator.remaining_text} ${remainingNumber}`; 452 } 453 /* append/remove max limit alert */ 454 if (getStats(textEditorElmentId).chars >= textareaMaxChar) { 455 appendAlert() 456 } else if (getStats(textEditorElmentId).chars < textareaMaxChar + 2) { 457 maxCharAlertDom.remove(); 458 } 459 } 460 textEditorElment.addEventListener('keydown', function () { 461 letterCountWithAlert(); 462 }); 463 textEditorElment.addEventListener('keyup', function () { 464 letterCountWithAlert(); 465 }); 466 textEditorElment.addEventListener('paste', function () { 467 setTimeout(() => { 468 letterCountWithAlert(); 469 }, 100); 470 }); 471 textEditorElment.addEventListener('cut', function () { 472 setTimeout(() => { 473 letterCountWithAlert(); 474 }, 100); 475 }); 476 textEditorElment.addEventListener('focus', function () { 477 let editorSliceText = textEditorElment.value.slice(0, textareaMaxChar); 478 textEditorElment.value = editorSliceText; 479 letterCountWithAlert(); 480 }); 481 } 482 }); 483 } 484 } 485 486 checkTextareaLimit('#wp-listing_content-wrap', 'editor'); 487 checkTextareaLimit('.directorist-custom-field-textarea textarea', 'textarea'); 488 checkTextareaLimit('.directorist-form-description-field textarea.directorist-form-element', 'textarea'); 489});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.