1(function ($) { 2 3 function getCurrentPostIdFromBody() { 4 var nag_loc = ''; 5 var bodyClasses = ($('body').attr('class') || '').split(' '); 6 7 $.each(bodyClasses, function(i, value) { 8 9 if ( !value.search('postid' ) ) { 10 11 var classArray = value.split('-'); 12 13 var post_id = parseInt( classArray[1] ); 14 15 if ( post_id > 0 ) { 16 17 nag_loc = post_id; 18 19 } 20 21 } 22 23 // for pages 24 if ( !value.search('page-id' ) ) { 25 26 var classArray = value.split('-'); 27 var post_id = parseInt( classArray[2] ); 28 29 if ( post_id > 0 ) { 30 31 nag_loc = post_id; 32 33 } 34 35 } 36 37 }); 38 39 return nag_loc; 40 } 41 42 function storeNagLocationThenNavigate(url) { 43 var data = { 44 action: 'leaky_paywall_store_nag_location', 45 post_id: getCurrentPostIdFromBody() 46 }; 47 48 $.get(leaky_paywall_script_ajax.ajaxurl, data, function(resp) { 49 window.location.href = url; 50 }); 51 } 52 53 $(document).ready(function () { 54 55 56 $('.lpshowlogin').click(function(e) { 57 e.preventDefault(); 58 $('.leaky-paywall-form-login').slideToggle(); 59 }); 60 61 62 $(document).on('click', '.leaky_paywall_message_wrap a', function(e) { 63 e.preventDefault(); 64 storeNagLocationThenNavigate($(this).attr('href')); 65 }); 66 67 // List Builder upgrade modal: capture nag location when a logged-in 68 // subscriber clicks the upgrade button so the resulting paid transaction 69 // is attributed to the post they came from. 70 $(document).on('click', '#lplb-upgrade-panel .Slider__ExpandedButton', function(e) { 71 e.preventDefault(); 72 storeNagLocationThenNavigate($(this).attr('href')); 73 }); 74 75 }); 76})(jQuery);
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.