1// Simple Download Monitor frontend scripts 2 3function sdm_is_ie() { 4 5 var ua = window.navigator.userAgent; 6 var msie = ua.indexOf("MSIE "); 7 8 if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) 9 { 10 return true; 11 } 12 13 return false; 14} 15 16jQuery(document).ready(function ($) { 17 18 // Populate all nested titles and links 19 $('li.sdm_cat').each(function () { 20 21 var $this = $(this); 22 this_slug = $this.attr('id'); 23 this_id = $this.children('.sdm_cat_title').attr('id'); 24 25 // Run ajax 26 $.post( 27 sdm_ajax_script.ajaxurl, 28 { 29 action: 'sdm_pop_cats', 30 cat_slug: this_slug, 31 parent_id: this_id 32 }, 33 function (response) { 34 35 // Loop array returned from ajax function 36 $.each(response.final_array, function (key, value) { 37 38 // Populate each matched post title and permalink 39 $this.children('.sdm_placeholder').append('<a href="' + value['permalink'] + '"><span class="sdm_post_title" style="cursor:pointer;">' + value['title'] + '</span></a>'); 40 }); 41 42 $this.children('span').append('<span style="margin-left:5px;" class="sdm_arrow">↨</span>'); 43 } 44 ); 45 }); 46 47 // Hide results on page load 48 $('li.sdm_cat').children('.sdm_placeholder').hide(); 49 50 // Slide toggle for each list item 51 $('body').on('click', '.sdm_cat_title', function (e) { 52 53 // If there is any html.. then we have more elements 54 if ($(this).next().html() != '') { 55 56 $(this).next().slideToggle(); // toggle div titles 57 } 58 }); 59 60 // Download buttons with terms or captcha has this class applied to it 61 $('.sdm_download_with_condition').on('click', function (e) { 62 e.preventDefault(); 63 $(this).closest('form').trigger('submit'); 64 }); 65 66 // Check if terms checkbox is enabled. 67 if ($('.sdm-termscond-checkbox').length) { 68 69 $.each($('.sdm-termscond-checkbox'), function () { 70 if (!$(this).is(':checked')) { 71 var cur = $(this).children(':checkbox'); 72 var btn = $(cur).closest('form').find('a.sdm_download,a.sdm_download_with_condition'); 73 $(btn).addClass('sdm_disabled_button'); 74 } 75 }); 76 77 $.each($('.sdm-download-form'), function () { 78 var form = $(this); 79 form.on('submit', function () { 80 if ($('.agree_termscond', form).is(':checked')) { 81 $('.sdm-termscond-checkbox', form).removeClass('sdm_general_error_msg'); 82 return true; 83 } else { 84 $('.sdm-termscond-checkbox', form).addClass('sdm_general_error_msg'); 85 } 86 return false; 87 }); 88 }); 89 90 $.each($('.agree_termscond'), function () { 91 var element = $(this); 92 var form = element.closest('form'); 93 element.on('click', function () { 94 if (element.is(':checked')) { 95 $('.sdm_download_with_condition', form).removeClass('sdm_disabled_button'); 96 $('.sdm-termscond-checkbox', form).removeClass('sdm_general_error_msg'); 97 } else { 98 $('.sdm_download_with_condition', form).addClass('sdm_disabled_button'); 99 $('.sdm-termscond-checkbox', form).addClass('sdm_general_error_msg'); 100 } 101 }); 102 }); 103 } 104});
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.