1/** 2 * @version 2.10.x 3 * @package K2 4 * @author JoomlaWorks https://www.joomlaworks.net 5 * @copyright Copyright (c) 2006 - 2020 JoomlaWorks Ltd. All rights reserved. 6 * @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html 7 */ 8 9var $K2 = jQuery.noConflict(); 10 11$K2(document).ready(function(){ 12 13 // Magnific popup 14 if(typeof($K2.magnificPopup) !== 'undefined') { 15 // Images 16 $K2('[data-k2-modal="image"]').magnificPopup({type:'image', image: {titleSrc: function() {return '';}}}); 17 // Edit links 18 $K2('[data-k2-modal="edit"]').magnificPopup({type:'iframe', modal: true}); 19 // Generic iframe 20 $K2('[data-k2-modal="iframe"]').magnificPopup({type:'iframe'}); 21 } 22 23 // Generic function to get URL params passed in .js script include 24 function getUrlParams(targetScript, varName) { 25 var scripts = document.getElementsByTagName('script'); 26 var scriptCount = scripts.length; 27 for (var a = 0; a < scriptCount; a++) { 28 var scriptSrc = scripts[a].src; 29 if (scriptSrc.indexOf(targetScript) >= 0) { 30 varName = varName.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); 31 var re = new RegExp("[\\?&]" + varName + "=([^&#]*)"); 32 var parsedVariables = re.exec(scriptSrc); 33 if (parsedVariables !== null) { 34 return parsedVariables[1]; 35 } 36 } 37 } 38 } 39 40 // Set the site root path 41 var K2SitePath = getUrlParams('k2.frontend.js', 'sitepath'); 42 43 // Comments 44 $K2('#comment-form').submit(function(event){ 45 event.preventDefault(); 46 $K2('#formLog').empty().addClass('formLogLoading'); 47 $K2.ajax({ 48 url: $K2('#comment-form').attr('action'), 49 type: 'post', 50 dataType: 'json', 51 data: $K2('#comment-form').serialize(), 52 success: function(response){ 53 $K2('#formLog').removeClass('formLogLoading').html(response.message).addClass(response.cssClass); 54 if(typeof(Recaptcha) != "undefined"){ 55 Recaptcha.reload(); 56 } 57 if (response.refresh) { 58 window.location.reload(); 59 } 60 } 61 }); 62 }); 63 64 $K2('.commentRemoveLink').click(function(event){ 65 event.preventDefault(); 66 var element = $K2(this); 67 $K2(element).parent().addClass('commentToolbarLoading'); 68 $K2.ajax({ 69 url: $K2(element).attr('href'), 70 type: 'post', 71 data: $K2('#comment-form input:last').serialize(), 72 success: function(response){ 73 $K2(element).parent().removeClass('commentToolbarLoading'); 74 if(response=='true'){ 75 $K2(element).parent().parent().remove(); 76 } 77 } 78 }); 79 }); 80 81 $K2('.commentApproveLink').click(function(event){ 82 event.preventDefault(); 83 var element = $K2(this); 84 $K2(element).parent().addClass('commentToolbarLoading'); 85 $K2.ajax({ 86 url: $K2(element).attr('href'), 87 type: 'post', 88 data: $K2('#comment-form input:last').serialize(), 89 success: function(response){ 90 $K2(element).parent().removeClass('commentToolbarLoading'); 91 if(response=='true'){ 92 $K2(element).parent().parent().removeClass('unpublishedComment'); 93 } 94 } 95 }); 96 }); 97 98 $K2('.k2ReportUserButton').click(function(event){ 99 event.preventDefault(); 100 if (confirm(K2Language[0])) { 101 var element = $K2(this); 102 $K2(element).parent().addClass('commentToolbarLoading'); 103 $K2.ajax({ 104 url: $K2(element).attr('href'), 105 type: 'GET', 106 success: function(response){ 107 $K2(element).parent().removeClass('commentToolbarLoading'); 108 alert(response); 109 } 110 }); 111 } 112 113 }); 114 115 $K2('#k2ReportCommentForm').submit(function(event){ 116 event.preventDefault(); 117 $K2('#k2ReportCommentFormLog').empty().addClass('formLogLoading'); 118 $K2.ajax({ 119 url: $K2('#k2ReportCommentForm').attr('action'), 120 type: 'post', 121 data: $K2('#k2ReportCommentForm').serialize(), 122 success: function(response){ 123 $K2('#formLog').removeClass('formLogLoading').html(response).css('display','block'); 124 if(typeof(Recaptcha) != "undefined"){ 125 Recaptcha.reload(); 126 } 127 } 128 }); 129 }); 130 131 // Text Resizer 132 $K2('#fontDecrease').click(function(event){ 133 event.preventDefault(); 134 $K2('.itemFullText').removeClass('largerFontSize'); 135 $K2('.itemFullText').addClass('smallerFontSize'); 136 }); 137 $K2('#fontIncrease').click(function(event){ 138 event.preventDefault(); 139 $K2('.itemFullText').removeClass('smallerFontSize'); 140 $K2('.itemFullText').addClass('largerFontSize'); 141 }); 142 143 // Smooth Scroll 144 $K2('.k2Anchor').click(function(event){ 145 event.preventDefault(); 146 var target = this.hash; 147 $K2('html, body').stop().animate({ 148 scrollTop: $K2(target).offset().top 149 }, 500); 150 }); 151 152 // Rating 153 $K2('.itemRatingForm a').click(function(event){ 154 event.preventDefault(); 155 var itemID = $K2(this).attr('rel'); 156 if(!itemID) { 157 itemID = $K2(this).data('id'); 158 } 159 var log = $K2('#itemRatingLog' + itemID).empty().addClass('formLogLoading'); 160 var rating = $K2(this).html(); 161 $K2.ajax({ 162 url: K2SitePath+"index.php?option=com_k2&view=item&task=vote&format=raw&user_rating=" + rating + "&itemID=" + itemID, 163 type: 'get', 164 success: function(response){ 165 log.removeClass('formLogLoading'); 166 log.html(response); 167 $K2.ajax({ 168 url: K2SitePath+"index.php?option=com_k2&view=item&task=getVotesPercentage&format=raw&itemID=" + itemID, 169 type: 'get', 170 success: function(percentage){ 171 $K2('#itemCurrentRating' + itemID).css('width', percentage + "%"); 172 setTimeout(function(){ 173 $K2.ajax({ 174 url: K2SitePath+"index.php?option=com_k2&view=item&task=getVotesNum&format=raw&itemID=" + itemID, 175 type: 'get', 176 success: function(response){ 177 log.html(response); 178 } 179 }); 180 }, 2000); 181 } 182 }); 183 } 184 }); 185 }); 186 187 // Classic popup 188 $K2('.classicPopup').click(function(event){ 189 event.preventDefault(); 190 if($K2(this).attr('rel')){ 191 var json = $K2(this).attr('rel'); 192 json = json.replace(/'/g, '"'); 193 var options = $K2.parseJSON(json); 194 } else { 195 var options = {x:900,y:600}; /* use some default values if not defined */ 196 } 197 window.open($K2(this).attr('href'),'K2PopUpWindow','width='+options.x+',height='+options.y+',menubar=yes,resizable=yes'); 198 }); 199 200 // Live search 201 $K2('div.k2LiveSearchBlock form input[name=searchword]').keyup(function(event){ 202 var parentElement = $K2(this).parent().parent(); 203 if($K2(this).val().length>3 && event.key!='enter'){ 204 $K2(this).addClass('k2SearchLoading'); 205 parentElement.find('.k2LiveSearchResults').css('display','none').empty(); 206 parentElement.find('input[name=t]').val($K2.now()); 207 parentElement.find('input[name=format]').val('raw'); 208 var url = 'index.php?option=com_k2&view=itemlist&task=search&' + parentElement.find('form').serialize(); 209 parentElement.find('input[name=format]').val('html'); 210 $K2.ajax({ 211 url: url, 212 type: 'get', 213 success: function(response){ 214 parentElement.find('.k2LiveSearchResults').html(response); 215 parentElement.find('input[name=searchword]').removeClass('k2SearchLoading'); 216 parentElement.find('.k2LiveSearchResults').css('display', 'block'); 217 } 218 }); 219 } else { 220 parentElement.find('.k2LiveSearchResults').css('display','none').empty(); 221 } 222 }); 223 224 // Calendar 225 if (typeof($K2().live) == "undefined") { 226 $K2('.k2CalendarBlock').on('click', '.calendarNavLink', function(event){ 227 event.preventDefault(); 228 var parentElement = $K2(this).parent().parent().parent().parent(); 229 var url = $K2(this).attr('href'); 230 parentElement.empty().addClass('k2CalendarLoader'); 231 $K2.ajax({ 232 url: url, 233 type: 'post', 234 success: function(response){ 235 parentElement.html(response); 236 parentElement.removeClass('k2CalendarLoader'); 237 } 238 }); 239 }); 240 } 241 else { 242 $K2('a.calendarNavLink').live('click', function(event){ 243 event.preventDefault(); 244 var parentElement = $K2(this).parent().parent().parent().parent(); 245 var url = $K2(this).attr('href'); 246 parentElement.empty().addClass('k2CalendarLoader'); 247 $K2.ajax({ 248 url: url, 249 type: 'post', 250 success: function(response){ 251 parentElement.html(response); 252 parentElement.removeClass('k2CalendarLoader'); 253 } 254 }); 255 }); 256 } 257 258 // Generic Element Scroller (use .k2Scroller in the container and .k2ScrollerElement for each contained element) 259 $K2('.k2Scroller').css('width',($K2('.k2Scroller').find('.k2ScrollerElement:first').outerWidth(true))*$K2('.k2Scroller').children('.k2ScrollerElement').length); 260 261}); 262 263// Equal block heights for the "default" view 264$K2(window).load(function () { 265 var blocks = $K2('.subCategory, .k2EqualHeights'); 266 var maxHeight = 0; 267 blocks.each(function(){ 268 maxHeight = Math.max(maxHeight, parseInt($K2(this).css('height'))); 269 }); 270 blocks.css('height', maxHeight); 271});
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.