1jQuery(function ($) { 2 // user login 3 $("#login-form").on('submit',function (e) { 4 e.preventDefault(); 5 $("#login-status").slideUp(); 6 $('#login-button').addClass('button-progress').prop('disabled', true); 7 var form_data = { 8 action: 'ajaxlogin', 9 username: $("#username").val(), 10 password: $("#password").val(), 11 is_ajax: 1 12 }; 13 $.ajax({ 14 type: "POST", 15 url: ajaxurl, 16 data: form_data, 17 success: function (response) { 18 $('#login-button').removeClass('button-progress').prop('disabled', false); 19 if (response == "success") { 20 $("#login-status").addClass('success').removeClass('error').html('<p>'+LANG_LOGGED_IN_SUCCESS+'</p>').slideDown(); 21 location.reload(); 22 } 23 else { 24 $("#login-status").removeClass('success').addClass('error').html('<p>'+response+'</p>').slideDown(); 25 } 26 } 27 }); 28 return false; 29 }); 30 31 // set button fav 32 $('.set-item-fav').on('click', function (e) { 33 e.stopPropagation(); 34 e.preventDefault(); 35 36 var adId = $(this).data('item-id'); 37 var userId = $(this).data('userid'); 38 var postType = $(this).data('post-type'); 39 var action = $(this).data('action'); 40 var $item = $(this).closest('.fav-listing'); 41 var $this = $(this); 42 43 if (userId == 0) { 44 //window.location.href = loginurl; 45 $('[href="#sign-in-dialog"]').trigger('click'); 46 return; 47 } 48 $this.addClass('button-loader'); 49 var data = {action: action, id: adId, userId: userId, post_type: postType}; 50 $.ajax({ 51 type: "POST", 52 url: ajaxurl, 53 data: data, 54 success: function (result) { 55 if (result == 1) { 56 if (action == 'removeFavAd') { 57 $item.remove(); 58 var val = $('.fav-ad-count').text(); 59 var favcount = val - 1; 60 $('.fav-ad-count').html(favcount); 61 } 62 else { 63 $this.removeClass('button-loader').addClass('added'); 64 } 65 66 } 67 else if (result == 2) { 68 $this.removeClass('button-loader').removeClass('added'); 69 } 70 else { 71 //alert("else"); 72 } 73 } 74 }); 75 }); 76 77 // set user fav 78 $('.set-user-fav').on('click', function (e) { 79 e.stopPropagation(); 80 e.preventDefault(); 81 82 var adId = $(this).data('favuser-id'); 83 var userId = $(this).data('userid'); 84 var action = $(this).data('action'); 85 var $item = $(this).closest('.fav-listing'); 86 var $this = $(this); 87 88 if (userId == 0) { 89 //window.location.href = loginurl; 90 $('[href="#sign-in-dialog"]').trigger('click'); 91 return; 92 } 93 $this.addClass('button-loader'); 94 var data = {action: action, id: adId, userId: userId}; 95 $.ajax({ 96 type: "POST", 97 url: ajaxurl, 98 data: data, 99 success: function (result) { 100 if (result == 1) { 101 if (action == 'removeFavAd') { 102 $item.remove(); 103 var val = $('.fav-user-count').text(); 104 var favcount = val - 1; 105 $('.fav-user-count').html(favcount); 106 } 107 else { 108 $this.removeClass('button-loader').addClass('added'); 109 } 110 } 111 else if (result == 2) { 112 $this.removeClass('button-loader').removeClass('added'); 113 if ($item != undefined) { 114 $item.remove(); 115 var val = $('.fav-user-count').text(); 116 var favcount = val - 1; 117 $('.fav-user-count').html(favcount); 118 } 119 } 120 else { 121 //alert("else"); 122 } 123 } 124 }); 125 }); 126 127 /* === Search city === */ 128 $('#country-popup').on('click', '#getCities ul li .statedata', function (e) { 129 e.stopPropagation(); 130 e.preventDefault(); 131 $('#getCities #results').hide(); 132 $('#getCities .loader').show(); 133 var $item = $(this).closest('.statedata'); 134 var id = $item.data('id'); 135 var action = "ModelGetCityByStateID"; 136 var data = {action: action, id: id}; 137 138 $.post(ajaxurl, data, function (result) { 139 $("#getCities #results").html(result); 140 $('#getCities .loader').hide(); 141 $('#getCities #results').show(); 142 }); 143 }); 144 145 $('#country-popup').on('click', '#getCities ul li #changeState', function (e) { 146 // Keep ads item click from being executed. 147 e.stopPropagation(); 148 // Prevent navigating to '#'. 149 e.preventDefault(); 150 // Ask user if he is sure. 151 $('#getCities #results').hide(); 152 $('#getCities .loader').show(); 153 var $item = $(this).closest('.quick-states'); 154 var id = $item.data('country-id'); 155 var action = "ModelGetStateByCountryID"; 156 var data = {action: action, id: id}; 157 158 $.post(ajaxurl, data, function (result) { 159 $("#getCities #results").html(result); 160 $('#getCities .loader').hide(); 161 $('#getCities #results').show(); 162 }); 163 }); 164 165 $('#country-popup').on('click', 'ul li .selectme', function (e) { 166 e.stopPropagation(); 167 e.preventDefault(); 168 var id = $(this).data('id'); 169 var name = $(this).data('name'); 170 var type = $(this).data('type'); 171 var country = $('.quick-states').data('country-id'); 172 $('#inputStateCity').val(name); 173 $('#searchStateCity').val(name); 174 $('#headerStateCity').html(name + ' <i class="fa fa-pencil"></i>'); 175 $('#searchPlaceType').val(type); 176 $('#searchPlaceId').val(id); 177 if ($('#countryModal').length) { 178 $.magnificPopup.close(); 179 } 180 181 localStorage.Quick_placeText = name; 182 localStorage.Quick_PlaceId = id; 183 localStorage.Quick_PlaceType = type; 184 localStorage.Quick_Country = country; 185 $("#searchDisplay").html('').hide(); 186 }); 187 188 $('.category-dropdown').on('click', '#category-change a', function (ev) { 189 if ("#" === $(this).attr('href')) { 190 ev.preventDefault(); 191 var parent = $(this).parents('.category-dropdown'); 192 parent.find('.change-text').html($(this).html()); 193 var id = $(this).data('ajax-id'); 194 var type = $(this).data('cat-type'); 195 196 if (type == "all") { 197 $('#input-subcat').val(''); 198 $('#input-maincat').val(''); 199 } 200 else if (type == "maincat") { 201 $('#input-subcat').val(''); 202 } 203 else { 204 $('#input-maincat').val(''); 205 } 206 $('#input-' + type).val(id); 207 } 208 }).on('click', '#category-change .dropdown-arrow', function (e) { 209 e.preventDefault(); 210 $(this).parent().toggleClass('open'); 211 return false;
212 }); 213 214 $('#searchStateCity').on('click', function () { 215 $('#change-city').trigger('click'); 216 }); 217 218 var country = $('.quick-states').data('country-id'); 219 if (localStorage.Quick_placeText != "") { 220 if(localStorage.Quick_Country == country) { 221 var placeText = localStorage.Quick_placeText; 222 var PlaceId = localStorage.Quick_PlaceId; 223 var PlaceType = localStorage.Quick_PlaceType; 224 225 if (placeText != null) { 226 $('#inputStateCity').val(placeText); 227 $('#searchStateCity').val(placeText); 228 $('#headerStateCity').html(placeText + ' <i class="fa fa-pencil"></i>'); 229 $('#searchPlaceId').val(PlaceId); 230 $('#searchPlaceType').val(PlaceType); 231 } 232 } 233 } 234 235 var searchCityAjax = null; 236 $("#inputStateCity").keyup(function () { 237 if (searchCityAjax) { 238 searchCityAjax.abort(); 239 } 240 var searchbox = $(this).val(); 241 var dataString = 'searchword1=' + searchbox; 242 243 var action = "searchStateCountry"; 244 var data = {action: action, dataString: searchbox}; 245 246 if (searchbox == '') { 247 $('#searchDisplay').hide(); 248 } 249 else { 250 $('#searchDisplay').show(); 251 searchCityAjax = $.post(ajaxurl, data, function (result) { 252 $("#searchDisplay").html(result).show(); 253 }); 254 } 255 return false; 256 }); 257 258 259 var inputField = jQuery('.qucikad-ajaxsearch-input'); 260 var inputSubcatField = jQuery('#input-subcat'); 261 var inputCatField = jQuery('#input-maincat'); 262 var inputKeywordsField = jQuery('#input-keywords'); 263 var myDropDown = jQuery("#qucikad-ajaxsearch-dropdown"); 264 var myDropDown1 = jQuery("#qucikad-ajaxsearch-dropdown ul li"); 265 var myDropOption = jQuery('#qucikad-ajaxsearch-dropdown > option'); 266 var html = jQuery('html'); 267 var select = jQuery('.qucikad-ajaxsearch-input, #qucikad-ajaxsearch-dropdown > option'); 268 var lps_tag = jQuery('.qucikad-as-tag'); 269 var lps_cat = jQuery('.qucikad-as-cat'); 270 271 272 jQuery("#def-cats").append(jQuery('#qucikad-ajaxsearch-dropdown ul').html()); 273 274 var length = myDropOption.length; 275 inputField.on('click', function (event) { 276 //event.preventDefault(); 277 myDropDown.attr('size', length); 278 myDropDown.css('display', 'block'); 279 }); 280 281 //myDropDown1.on('click', function(event) { 282 jQuery(document).on('click', '#qucikad-ajaxsearch-dropdown ul li', function (event) { 283 myDropDown.attr('size', 0); 284 var dropValue = jQuery.trim(jQuery(this).text()); 285 var tagVal = jQuery(this).data('tagid'); 286 var catVal = jQuery(this).data('catid'); 287 var moreVal = jQuery(this).data('moreval'); 288 289 inputField.val(dropValue); 290 inputSubcatField.val(tagVal); 291 inputCatField.val(catVal); 292 inputKeywordsField.val(""); 293 if (tagVal == null && catVal == null && moreVal != null) { 294 inputField.val(moreVal); 295 inputKeywordsField.val(moreVal); 296 } 297 jQuery("form i.qucikad-ajaxsearch-close").css("display", "block"); 298 myDropDown.css('display', 'none'); 299 }); 300 301 jQuery('form i.qucikad-ajaxsearch-close').on('click', function () { 302 jQuery("form i.qucikad-ajaxsearch-close").css("display", "none"); 303 jQuery('form .qucikad-ajaxsearch-input').val(''); 304 jQuery("img.loadinerSearch").css("display", "block"); 305 var qString = ''; 306 307 jQuery.ajax({ 308 type: 'POST', 309 dataType: 'json', 310 url: ajaxurl, 311 data: { 312 'action': 'quickad_ajax_home_search', 313 'tagID': qString 314 }, 315 success: function (data) { 316 if (data) { 317 jQuery("#qucikad-ajaxsearch-dropdown ul").empty(); 318 var resArray = []; 319 if (data.suggestions.cats) { 320 jQuery.each(data.suggestions.cats, function (i, v) { 321 resArray.push(v); 322 }); 323 324 } 325 jQuery('img.loadinerSearch').css('display', 'none'); 326 jQuery("#qucikad-ajaxsearch-dropdown ul").append(resArray); 327 myDropDown.css('display', 'block'); 328 } 329 } 330 }); 331 jQuery('img.loadinerSearch').css('display', 'none'); 332 }); 333 334 html.on('click', function (event) { 335 //event.preventDefault(); 336 myDropDown.attr('size', 0); 337 myDropDown.css('display', 'none'); 338 //$("#searchDisplay").attr('size', 0); 339 jQuery("#searchDisplay").css('display', 'none'); 340 }); 341 342 select.on('click', function (event) { 343 event.stopPropagation(); 344 }); 345 346 var resArray = []; 347 var newResArray = []; 348 var bufferedResArray = []; 349 var prevQString = '?'; 350 351 function trimAttributes(node) { 352 jQuery.each(node.attributes, function () { 353 var attrName = this.name; 354 var attrValue = this.value; 355 // remove attribute name start with "on", possible unsafe, 356 // for example: onload, onerror... 357 // 358 // remvoe attribute value start with "javascript:" pseudo protocol, possible unsafe, 359 // for example href="javascript:alert(1)" 360 if (attrName.indexOf('on') == 0 || attrValue.indexOf('javascript:') == 0) { 361 jQuery(node).removeAttr(attrName); 362 } 363 }); 364 } 365 366 function sanitize(html) { 367 var output = jQuery($.parseHTML('<div>' + html + '</div>', null, false));
368 output.find('*').each(function () { 369 trimAttributes(this); 370 }); 371 return output.html(); 372 } 373 374 inputField.on('input', function () { 375 var $this = jQuery(this); 376 var qString = sanitize(this.value); 377 lpsearchmode = jQuery('body').data('lpsearchmode'); 378 lpsearchmode = "titlematch"; 379 noresultMSG = jQuery(this).data('noresult'); 380 jQuery("#qucikad-ajaxsearch-dropdown ul").empty(); 381 jQuery("#qucikad-ajaxsearch-dropdown ul li").remove(); 382 prevQuery = $this.data('prev-value'); 383 $this.data("prev-value", qString.length); 384 inputKeywordsField.val(qString); 385 386 if (qString.length == 0) { 387 388 defCats = jQuery('#def-cats').html(); 389 myDropDown.css('display', 'none'); 390 jQuery("#qucikad-ajaxsearch-dropdown ul").empty(); 391 392 jQuery("#qucikad-ajaxsearch-dropdown ul").append(defCats); 393 myDropDown.css('display', 'block'); 394 $this.data("prev-value", qString.length); 395 inputKeywordsField.val(""); 396 jQuery("form i.qucikad-ajaxsearch-close").css("display", "none"); 397 } 398 else if ((qString.length == 1 && prevQString != qString) || (qString.length == 1 && prevQuery < qString.length)) { 399 400 myDropDown.css('display', 'none'); 401 jQuery("#qucikad-ajaxsearch-dropdown ul").empty(); 402 resArray = []; 403 //jQuery('#selector').val().length 404 jQuery("form i.qucikad-ajaxsearch-close").css("display", "block"); 405 jQuery("img.loadinerSearch").css("display", "block"); 406 //jQuery(this).addClass('loaderimg'); 407 jQuery.ajax({ 408 type: 'POST', 409 dataType: 'json', 410 url: ajaxurl, 411 data: { 412 'action': 'quickad_ajax_home_search', 413 'tagID': qString 414 }, 415 success: function (data) { 416 if (data) { 417 418 if (data.suggestions.tag || data.suggestions.tagsncats || data.suggestions.cats || data.suggestions.titles) { 419 420 if (data.suggestions.tag) { 421 jQuery.each(data.suggestions.tag, function (i, v) { 422 resArray.push(v); 423 }); 424 } 425 426 if (data.suggestions.tagsncats) { 427 jQuery.each(data.suggestions.tagsncats, function (i, v) { 428 resArray.push(v); 429 }); 430 431 } 432 433 434 if (data.suggestions.cats) { 435 jQuery.each(data.suggestions.cats, function (i, v) { 436 437 resArray.push(v); 438 439 }); 440 441 if (data.suggestions.tag == null && data.suggestions.tagsncats == null && data.suggestions.titles == null) { 442 resArray = resArray; 443 } 444 else { 445 } 446 } 447 448 if (data.suggestions.titles) { 449 jQuery.each(data.suggestions.titles, function (i, v) { 450 451 resArray.push(v); 452 453 }); 454 455 } 456 457 } 458 else { 459 if (data.suggestions.more) { 460 jQuery.each(data.suggestions.more, function (i, v) { 461 resArray.push(v); 462 }); 463 464 } 465 } 466 467 prevQString = data.tagID; 468 469 jQuery('img.loadinerSearch').css('display', 'none'); 470 if (jQuery('form #select').val() == '') { 471 jQuery("form i.qucikad-ajaxsearch-close").css("display", "none"); 472 } 473 else { 474 jQuery("form i.qucikad-ajaxsearch-close").css("display", "block"); 475 } 476 477 bufferedResArray = resArray; 478 filteredRes = [];
479 qStringNow = jQuery('.qucikad-ajaxsearch-input').val(); 480 jQuery.each(resArray, function (key, value) { 481 482 if (jQuery(value).find('a').length == "1") { 483 rText = jQuery(value).find('a').text(); 484 } 485 else { 486 rText = jQuery(value).text(); 487 } 488 489 if (lpsearchmode == "keyword") { 490 491 qStringNow = qStringNow.toUpperCase(); 492 rText = rText.toUpperCase(); 493 var regxString = new RegExp(qStringNow, 'g'); 494 var lpregxRest = rText.match(regxString); 495 if (lpregxRest) { 496 filteredRes.push(value); 497 } 498 499 } else { 500 if (rText.substr(0, qStringNow.length).toUpperCase() == qStringNow.toUpperCase()) { 501 filteredRes.push(value); 502 } 503 } 504 }); 505 506 if (filteredRes.length > 0) { 507 myDropDown.css('display', 'none'); 508 jQuery("#qucikad-ajaxsearch-dropdown ul").empty(); 509 510 jQuery("#qucikad-ajaxsearch-dropdown ul").append(filteredRes); 511 myDropDown.css('display', 'block'); 512 $this.data("prev-value", qString.length); 513 514 } 515 516 else if (filteredRes.length < 1 && qStringNow.length < 2) { 517 myDropDown.css('display', 'none'); 518 jQuery("#qucikad-ajaxsearch-dropdown ul").empty(); 519 jQuery('#qucikad-ajaxsearch-dropdown ul li').remove(); 520 $mResults = '<strong>' + noresultMSG + ' </strong>'; 521 $mResults = $mResults + qString; 522 var defRes = '<li class="qucikad-ajaxsearch-li-more-results" data-moreval="' + qString + '">' + $mResults + '</li>'; 523 newResArray.push(defRes); 524 jQuery("#qucikad-ajaxsearch-dropdown ul").append(newResArray); 525 myDropDown.css('display', 'block'); 526 $this.data("prev-value", qString.length); 527 } 528 } 529 } 530 531 }); 532 } 533 /* get results from buffered data */ 534 else { 535 newResArray = []; 536 myDropDown.css('display', 'none'); 537 jQuery("#qucikad-ajaxsearch-dropdown ul").empty(); 538 jQuery.each(bufferedResArray, function (key, value) { 539 var stringToCheck = jQuery(value).find('span').first().text(); 540 541 if (lpsearchmode == "keyword") { 542 543 qString = qString.toUpperCase(); 544 stringToCheck = stringToCheck.toUpperCase(); 545 546 var regxString = new RegExp(qString, 'g'); 547 var lpregxRest = stringToCheck.match(regxString); 548 if (lpregxRest) { 549 newResArray.push(value); 550 } 551 552 } else { 553 554 if (stringToCheck.substr(0, qString.length).toUpperCase() == qString.toUpperCase()) { 555 newResArray.push(value); 556 } 557 } 558 }); 559 if (newResArray.length == 0) { 560 jQuery("#qucikad-ajaxsearch-dropdown ul").empty(); 561 jQuery('#qucikad-ajaxsearch-dropdown ul li').remove(); 562 $mResults = '<strong>' + noresultMSG + ' </strong>'; 563 $mResults = $mResults + qString; 564 var defRes = '<li class="qucikad-ajaxsearch-li-more-results" data-moreval="' + qString + '">' + $mResults + '</li>'; 565 newResArray.push(defRes); 566 } 567 568 jQuery("#qucikad-ajaxsearch-dropdown ul").append(newResArray); 569 myDropDown.css('display', 'block'); 570 jQuery("form i.qucikad-ajaxsearch-close").css("display", "block"); 571 } 572 }); 573 574 575 jQuery('.qucikad-ajaxsearch-input').on('click', function (event) { 576 577 jQuery("#qucikad-ajaxsearch-dropdown").niceScroll({ 578 cursorcolor: "#c9c9c9", 579 cursoropacitymax: 1, 580 boxzoom: false, 581 cursorwidth: "8px",
582 cursorborderradius: "0", 583 cursorborder: "0", 584 touchbehavior: true, 585 preventmultitouchscrolling: false, 586 cursordragontouch: true, 587 background: "#fff", 588 horizrailenabled: false, 589 autohidemode: false, 590 zindex: "999999" 591 }); 592 }); 593 594 <!-- Bid Acceptance Ajax --> 595 $(document).on('click', ".accept-offer" ,function(e){ 596 e.stopPropagation(); 597 e.preventDefault(); 598 599 var bidid = $(this).data('bidid'), 600 amount = $(this).data('amount'), 601 userid = $(this).data('userid'), 602 username = $(this).data('username'), 603 fullname = $(this).data('fullname'), 604 action = 'accept_bid'; 605 $('.bidder-name').text(fullname); 606 $('.bid-acceptance').text(amount); 607 $('.bid-id').val(bidid); 608 $.magnificPopup.open({ 609 items: { 610 src: '#small-dialog-1', 611 type: 'inline', 612 fixedContentPos: false, 613 fixedBgPos: true, 614 overflowY: 'auto', 615 closeBtnInside: true, 616 preloader: false, 617 midClick: true, 618 removalDelay: 300, 619 mainClass: 'my-mfp-zoom-in' 620 } 621 }); 622 }); 623 624 $("#accept-bid-form").on('submit',function (e) { 625 e.preventDefault(); 626 var form_data = { 627 action: 'accept_bid', 628 id: $(".bid-id").val() 629 }; 630 631 $('#accept-bid-button').addClass('button-progress').prop('disabled', true); 632 $.ajax({ 633 type: "POST", 634 url: ajaxurl, 635 data: form_data, 636 dataType: 'json', 637 success: function (response) { 638 if(response.success){ 639 $("#accept-bid-status").addClass('success').removeClass('error').html('<p>'+response.message+'</p>').slideDown(); 640 location.reload(); 641 } 642 else { 643 $("#accept-bid-status").removeClass('success').addClass('error').html('<p>'+response.message+'</p>').slideDown(); 644 } 645 $('#accept-bid-button').removeClass('button-progress').prop('disabled', false); 646 } 647 }); 648 return false; 649 }); 650 <!-- Bid Acceptance Ajax --> 651 652 $("#cancel-order-form").on('submit',function (e) { 653 e.preventDefault(); 654 var form_data = { 655 action: 'cancel_order', 656 id: $(".order_id").val(), 657 reason: $(".cancel_reason").val(), 658 }; 659 660 $('#cancel-order-button').addClass('button-progress').prop('disabled', true); 661 $.ajax({ 662 type: "POST", 663 url: ajaxurl, 664 data: form_data, 665 dataType: 'json', 666 success: function (response) { 667 if(response.success){ 668 $("#cancel-order-status").addClass('success').removeClass('error').html('<p>'+response.message+'</p>').slideDown(); 669 location.reload(); 670 } 671 else { 672 $("#cancel-order-status").removeClass('success').addClass('error').html('<p>'+response.message+'</p>').slideDown(); 673 } 674 $('#cancel-order-button').removeClass('button-progress').prop('disabled', false); 675 } 676 }); 677 return false; 678 }); 679 680 $("#create-milestone-form").on('submit',function (e) { 681 e.preventDefault(); 682 var action = 'create_milestone'; 683 var data = $(this).serialize(); 684 685 $('#create-milestone-button').addClass('button-progress').prop('disabled', true); 686 $.ajax({ 687 type: "POST", 688 url: ajaxurl+'?action='+action, 689 data: data, 690 dataType: 'json', 691 success: function (response) { 692 if(response.success){ 693 $("#create-milestone-status").addClass('success').removeClass('error').html('<p>'+response.message+'</p>').slideDown(); 694 location.reload(); 695 } 696 else { 697 $("#create-milestone-status").removeClass('success').addClass('error').html('<p>'+response.message+'</p>').slideDown(); 698 } 699 $('#create-milestone-button').removeClass('button-progress').prop('disabled', false); 700 } 701 }); 702 return false;
703 }); 704 705 $('#js-table-list').on('click', '.item-ajax-button', function (e) { 706 // Keep ads item click from being executed. 707 e.stopPropagation(); 708 // Prevent navigating to '#'. 709 e.preventDefault(); 710 // Ask user if he is sure. 711 var action = $(this).data('ajax-action'); 712 var alert_mesg = $(this).data('alert-message'); 713 var $item = $(this).closest('.ajax-item-listing'); 714 var data = {action: action, id: $item.data('item-id')}; 715 if (confirm(alert_mesg)) { 716 $.ajax({ 717 type: "POST", 718 url: ajaxurl+'?action='+action, 719 data: data, 720 dataType: 'json', 721 success: function (response) { 722 if(response.success){ 723 Snackbar.show({text: response.message}); 724 location.reload(); 725 }else{ 726 Snackbar.show({text: response.message}); 727 } 728 } 729 }); 730 } 731 }); 732 $('#js-table-list').on('click', '.item-js-close', function (e) { 733 // Keep ads item click from being executed. 734 e.stopPropagation(); 735 // Prevent navigating to '#'. 736 e.preventDefault(); 737 // Ask user if he is sure. 738 var action = $(this).data('ajax-action'); 739 var $item = $(this).closest('.ajax-item-listing'); 740 var data = {action: action, id: $item.data('item-id')}; 741 if (confirm(LANG_ARE_YOU_SURE)) { 742 $.post(ajaxurl + '?action=' + action, data, function (response) { 743 if (response != 0) { 744 $item.remove(); 745 Snackbar.show({text: LANG_PROJECT_CLOSED}); 746 } else { 747 Snackbar.show({text: LANG_ERROR_TRY_AGAIN}); 748 } 749 }); 750 } 751 }); 752 $('#js-table-list').on('click', '.item-js-delete', function (e) { 753 // Keep ads item click from being executed. 754 e.stopPropagation(); 755 // Prevent navigating to '#'. 756 e.preventDefault(); 757 // Ask user if he is sure. 758 var action = $(this).data('ajax-action'); 759 var $item = $(this).closest('.ajax-item-listing'); 760 var data = {action: action, id: $item.data('item-id')}; 761 if (confirm(LANG_ARE_YOU_SURE)) { 762 $.post(ajaxurl + '?action=' + action, data, function (response) { 763 if (response != 0) { 764 $item.remove(); 765 Snackbar.show({text: LANG_PROJECT_DELETED}); 766 } else { 767 Snackbar.show({text: LANG_ERROR_TRY_AGAIN}); 768 } 769 }); 770 } 771 }); 772 773 $('#js-table-list').on('click', '.item-js-hide', function (e) { 774 e.stopPropagation(); 775 e.preventDefault(); 776 var action = $(this).data('ajax-action'); 777 var $item = $(this).closest('.ajax-item-listing'); 778 var data = {action: action, id: $item.data('item-id')}; 779 780 $.post(ajaxurl + '?action=' + action, data, function (response) { 781 if (response == 1) { 782 $item.addClass('opapcityLight'); 783 $item.find('.label-hidden').html(LANG_HIDDEN) 784 $item.find('.item-js-hide').attr('title', LANG_SHOW); 785 $item.find('.item-js-hide').html('<i class="icon-feather-eye"></i>'); 786 } 787 else if (response == 2) { 788 $item.removeClass('opapcityLight'); 789 $item.find('.label-hidden').html(LANG_SHOW) 790 $item.find('.item-js-hide').attr('title', LANG_HIDE); 791 $item.find('.item-js-hide').html('<i class="icon-feather-eye-off"></i>'); 792 } 793 else { 794 Snackbar.show({text: LANG_ERROR_TRY_AGAIN}); 795 } 796 }); 797 }); 798 799 $('.ajax-delete-resume').on('click', function (e) { 800 // Keep ads item click from being executed. 801 e.stopPropagation(); 802 // Prevent navigating to '#'. 803 e.preventDefault(); 804 // Ask user if he is sure. 805 var action = 'deleteResume'; 806 var $item = $(this).closest('.resume-row'); 807 var data = {action: action, id: $item.data('item-id')}; 808 if (confirm(LANG_ARE_YOU_SURE)) { 809 $.post(ajaxurl + '?action=' + action, data, function (response) { 810 if (response != 0) { 811 $item.remove(); 812 Snackbar.show({text: LANG_RESUME_DELETED}); 813 } else { 814 Snackbar.show({text: LANG_ERROR_TRY_AGAIN}); 815 } 816 }); 817 } 818 }); 819 820 $('.ajax-delete-experience').on('click', function (e) { 821 // Keep ads item click from being executed. 822 e.stopPropagation(); 823 // Prevent navigating to '#'. 824 e.preventDefault(); 825 // Ask user if he is sure. 826 var action = 'deleteExperience'; 827 var $item = $(this).closest('.experience-row'); 828 var data = {action: action, id: $item.data('item-id')}; 829 if (confirm(LANG_ARE_YOU_SURE)) { 830 $.post(ajaxurl + '?action=' + action, data, function (response) { 831 if (response != 0) { 832 $item.remove(); 833 Snackbar.show({text: LANG_EXPERIENCE_DELETED}); 834 } else { 835 Snackbar.show({text: LANG_ERROR_TRY_AGAIN}); 836 } 837 }); 838 } 839 }); 840 841 $('.ajax-delete-company').on('click', function (e) { 842 // Keep ads item click from being executed. 843 e.stopPropagation(); 844 // Prevent navigating to '#'. 845 e.preventDefault(); 846 // Ask user if he is sure. 847 var action = 'deleteCompany'; 848 var $item = $(this).closest('.company-row'); 849 var data = {action: action, id: $item.data('item-id')}; 850 if (confirm(LANG_ARE_YOU_SURE)) { 851 $.post(ajaxurl + '?action=' + action, data, function (response) { 852 if (response != 0) { 853 $item.remove(); 854 Snackbar.show({text: LANG_COMPANY_DELETED}); 855 } else { 856 Snackbar.show({text: LANG_ERROR_TRY_AGAIN}); 857 } 858 }); 859 } 860 }); 861 862 // blog comment with ajax 863 $('.blog-comment-form').on('submit', function (e) { 864 e.preventDefault(); 865 var action = 'submitBlogComment'; 866 var data = $(this).serialize(); 867 var $parent_cmnt = $(this).find('#comment_parent').val(); 868 var $cmnt_field = $(this).find('#comment-field'); 869 var $btn = $(this).find('.button'); 870 $btn.addClass('button-loader').prop('disabled',true); 871 $.ajax({ 872 type: "POST", 873 url: ajaxurl+'?action='+action, 874 data: data, 875 dataType: 'json', 876 success: function (response) { 877 $btn.removeClass('button-loader').prop('disabled',false); 878 if(response.success){ 879 if($parent_cmnt == 0){ 880 $('.latest-comments > ul').prepend(response.html); 881 }else{ 882 $('#li-comment-'+$parent_cmnt).after(response.html); 883 } 884 $('html, body').animate({ 885 scrollTop: $("#li-comment-"+response.id).offset().top 886 }, 2000); 887 $cmnt_field.val(''); 888 }else{ 889 $('#respond > .widget-content').prepend('<div class="notification error"><p>'+response.error+'</p></div>'); 890 } 891 } 892 }); 893 }); 894}); 895 896/* Live Location Detect 897 /* ========================================================================== */ 898jQuery(document).ready(function($) { 899 var loc = jQuery('.loc-tracking').data('option'); 900 var apiType = jQuery('#page').data('ipapi'); 901 var currentlocationswitch = '1'; 902 currentlocationswitch = jQuery('#page').data('showlocationicon'); 903 904 if (currentlocationswitch == "0") { 905 loc = 'locationifoff'; 906 jQuery('.loc-tracking > i').fadeOut('fast'); 907 } 908 909 if (loc == 'yes') { 910 if (jQuery('.intro-search-field').is('.live-location-search')) { 911 if (apiType === "geo_ip_db") { 912 jQuery.getJSON('https://geoip-db.com/json/geoip.php?jsonp=?') 913 .done(function (location) { 914 915 getCityidByCityName(location.country_code, location.state, location.city); 916 jQuery('input[name=location]').val(location.city); 917 918 jQuery('.live-location-search .loc-tracking > i').fadeOut('slow'); 919 }); 920 } 921 else if (apiType === "ip_api") { 922 jQuery.get("https://ipapi.co/json", function (location) { 923 924 getCityidByCityName(location.country, location.region, location.city); 925 jQuery('input[name=location]').val(location.city); 926 927 jQuery('.live-location-search .loc-tracking > i').fadeOut('slow'); 928 }, "json"); 929 } 930 else { 931 GetCurrentGpsLoc(function (GpsLocationCityData) { 932 myCurrentGpsLocation = GpsLocationCityData; 933 getCityidByCityName(myCurrentGpsLocation.country, myCurrentGpsLocation.region, myCurrentGpsLocation.city); 934 jQuery('input[name=location]').val(myCurrentGpsLocation.city); 935 936 jQuery('.live-location-search .loc-tracking > i').fadeOut('slow'); 937 }); 938 } 939 940 } 941 } 942 else if (loc == 'no') { 943 jQuery('.live-location-search .loc-tracking > i').on('click', function (event) { 944 event.preventDefault(); 945 jQuery(this).addClass('fa fa-circle-o-notch fa-spin'); 946 jQuery(this).removeClass('la la-crosshairs'); 947 if (jQuery('.intro-search-field').is('.live-location-search')) { 948 if (apiType === "geo_ip_db") { 949 jQuery.getJSON('https://geoip-db.com/json/geoip.php?jsonp=?') 950 .done(function (location) { 951 952 if (location.city == null) { 953 } 954 else { 955 getCityidByCityName(location.country_code, location.state, location.city); 956 jQuery('input[name=latitude]').val(location.latitude); 957 jQuery('input[name=longitude]').val(location.longitude); 958 jQuery('input[name=location]').val(location.city); 959 } 960 jQuery('.live-location-search .loc-tracking > i').fadeOut('slow'); 961 }); 962 } 963 else if (apiType === "ip_api") { 964 jQuery.get("https://ipapi.co/json", function (location) { 965 if (location.city == null) { 966 } 967 else { 968 getCityidByCityName(location.country, location.region, location.city); 969 970 jQuery('input[name=latitude]').val(location.latitude); 971 jQuery('input[name=longitude]').val(location.longitude); 972 jQuery('input[name=location]').val(location.city); 973 } 974 jQuery('.live-location-search .loc-tracking > i').fadeOut('slow'); 975 976 }, "json"); 977 } 978 else { 979 980 GetCurrentGpsLoc(function (GpsLocationCityData) { 981 myCurrentGpsLocation = GpsLocationCityData; 982 getCityidByCityName(myCurrentGpsLocation.country, myCurrentGpsLocation.region, myCurrentGpsLocation.city); 983 jQuery('input[name=location]').val(myCurrentGpsLocation.city); 984 jQuery('.live-location-search .loc-tracking > i').fadeOut('slow'); 985 }); 986 987 } 988 } 989 }); 990 } 991}); 992 993//GPS LIVE LOCATION 994var geocoderr; 995function GetCurrentGpsLoc(lpcalback){ 996 if (navigator.geolocation) { 997 navigator.geolocation.getCurrentPosition(function(position){ 998 var clat = position.coords.latitude; 999 var clong = position.coords.longitude; 1000 jpCodeLatLng(clat,clong, function(citynamevalue){ 1001 1002 lpcalback(citynamevalue); 1003 1004 }); 1005 }); 1006 1007 } else { 1008 alert("Geolocation is not supported by this browser."); 1009 } 1010 1011} 1012 1013function lpgeocodeinitialize() { 1014 geocoderr = new google.maps.Geocoder(); 1015} 1016 1017function jpCodeLatLng(lat, lng, lpcitycallback) { 1018 1019 latlng = new google.maps.LatLng(lat, lng), 1020 geocoderrr = new google.maps.Geocoder(); 1021 geocoderrr.geocode({'latLng': latlng}, function(results, status) { 1022 if (status == google.maps.GeocoderStatus.OK) { 1023 if (results[1]) { 1024 for (var i = 0; i < results.length; i++) { 1025 if (results[i].types[0] === "locality") { 1026 var city = results[i].address_components[0].short_name; 1027 var region = results[i].address_components[2].long_name; 1028 var country = results[i].address_components[3].short_name; 1029 1030 var $citydata = {}; 1031 $citydata['city'] = city; 1032 $citydata['region'] = region; 1033 $citydata['country'] = country; 1034 lpcitycallback($citydata); 1035 } 1036 } 1037 } 1038 else {console.log("No reverse geocode results.")} 1039 } 1040 else {console.log("Geocoder failed: " + status)} 1041 }); 1042} 1043 1044function getCityidByCityName(country,state,city) { 1045 var data = {action: "getCityidByCityName", city: city, state: state, country: country}; 1046 $.ajax({ 1047 type: "POST", 1048 url: ajaxurl, 1049 data: data, 1050 success: function (result) { 1051 $('#searchPlaceType').val("city"); 1052 $('#searchPlaceId').val(result); 1053 } 1054 }); 1055}
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.