/** * @version $Id: k2.js 1965 2013-04-29 16:01:44Z lefteris.kavadas $ * @package K2 * @author JoomlaWorks http://www.joomlaworks.net * @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved. * @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html */ var K2JVersion; var selectsInstance; $K2(document).ready(function() { // Set the selects instance to allow inheritance of jQuery chosen bindings if ( typeof (K2JVersion) !== 'undefined' && K2JVersion === '30') { selectsInstance = jQuery; } else { selectsInstance = $K2; } // Generic function to get URL params passed in .js script include function getUrlParams(targetScript, varName) { var scripts = document.getElementsByTagName('script'); var scriptCount = scripts.length; for (var a = 0; a < scriptCount; a++) { var scriptSrc = scripts[a].src; if (scriptSrc.indexOf(targetScript) >= 0) { varName = varName.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var re = new RegExp("[\\?&]" + varName + "=([^&#]*)"); var parsedVariables = re.exec(scriptSrc); if (parsedVariables !== null) { return parsedVariables[1]; } } } } // Set the site root path var K2SitePath = getUrlParams('k2.js', 'sitepath'); // Common functions $K2('#jToggler').click(function() { if ($K2(this).attr('checked')) { $K2('input[id^=cb]').attr('checked', true); $K2('input[name=boxchecked]').val($K2('input[id^=cb]:checked').length); } else { $K2('input[id^=cb]').attr('checked', false); $K2('input[name=boxchecked]').val('0'); } }); $K2('#k2SubmitButton').click(function() { this.form.submit(); }); $K2('#k2ResetButton').click(function(event) { event.preventDefault(); $K2('.k2AdminTableFilters input').val(''); $K2('.k2AdminTableFilters option').removeAttr('selected'); this.form.submit(); }); selectsInstance('.k2AdminTableFilters select').change(function() { this.form.submit(); }); // View specific functions if ($K2('#k2AdminContainer').length > 0) { var view = $K2('#k2AdminContainer input[name=view]').val(); } else { var view = $K2('#k2FrontendContainer input[name=view]').val(); } $K2('.k2ReportUserButton').click(function(event) { event.preventDefault(); if (view == 'comments') { var alert = K2Language[2]; } else { var alert = K2Language[0]; } if (confirm(alert)) { window.location.href = $K2(this).attr('href'); } }); switch(view) { case 'comments': var flag = false; $K2('.editComment').click(function(event) { event.preventDefault(); if (flag) { alert(K2Language[0]); return; } flag = true; var commentID = $K2(this).attr('rel'); var target = $K2('#k2Comment' + commentID + ' .commentText'); var value = target.text(); $K2('#k2Comment' + commentID + ' input').val(value); target.empty(); var textarea = $K2('