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