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