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