Umstellung auf Events für simple-ajax

This commit is contained in:
Carsten Götzinger 2018-02-14 09:32:24 +01:00
parent 7915541c6e
commit 02cf727e11
5 changed files with 132 additions and 120 deletions

View File

@ -31,8 +31,8 @@
namespace cgoIT\rateit; namespace cgoIT\rateit;
use cgoIT\rateit\RateItFrontend; use cgoIT\rateit\RateItFrontend;
use SimpleAjax\Event\SimpleAjax;
define(RETURN_AJAX_HEADER, 'Content-Type: text/html'); use Symfony\Component\HttpFoundation\JsonResponse;
class RateIt extends \Frontend { class RateIt extends \Frontend {
@ -65,7 +65,7 @@ class RateIt extends \Frontend {
* @param integer id - The id of key to register a rating for. * @param integer id - The id of key to register a rating for.
* @param integer percent - The rating in percentages. * @param integer percent - The rating in percentages.
*/ */
function doVote() { public function doVote(SimpleAjax $event) {
if ($this->Input->get('do') == 'rateit') { if ($this->Input->get('do') == 'rateit') {
$ip = $_SERVER['REMOTE_ADDR']; $ip = $_SERVER['REMOTE_ADDR'];
@ -78,9 +78,10 @@ class RateIt extends \Frontend {
$arrRkey = explode('|', $rkey); $arrRkey = explode('|', $rkey);
foreach ($arrRkey as $key) { foreach ($arrRkey as $key) {
if (!is_numeric($key)) { if (!is_numeric($key)) {
header(RETURN_AJAX_HEADER); $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']];
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']; $response = new JsonResponse($return);
exit; $event->setResponse($response);
return;
} }
$id = $rkey; $id = $rkey;
} }
@ -88,9 +89,10 @@ class RateIt extends \Frontend {
if (is_numeric($rkey)) { if (is_numeric($rkey)) {
$id = $rkey; $id = $rkey;
} else { } else {
header(RETURN_AJAX_HEADER); $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']];
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']; $response = new JsonResponse($return);
exit; $event->setResponse($response);
return;
} }
} }
@ -98,16 +100,18 @@ class RateIt extends \Frontend {
if (is_numeric($percent) && $percent < 101) { if (is_numeric($percent) && $percent < 101) {
$rating = $percent; $rating = $percent;
} else { } else {
header(RETURN_AJAX_HEADER); $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']];
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']; $response = new JsonResponse($return);
exit; $event->setResponse($response);
return;
} }
//Make sure that the ratable type is 'page' or 'ce' or 'module' //Make sure that the ratable type is 'page' or 'ce' or 'module'
if (!($type === 'page' || $type === 'article' || $type === 'ce' || $type === 'module' || $type === 'news' || $type === 'faq' || $type === 'galpic' || $type === 'news4ward')) { if (!($type === 'page' || $type === 'article' || $type === 'ce' || $type === 'module' || $type === 'news' || $type === 'faq' || $type === 'galpic' || $type === 'news4ward')) {
header(RETURN_AJAX_HEADER); $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_type']];
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_type']; $response = new JsonResponse($return);
exit; $event->setResponse($response);
return;
} }
$strHash = sha1(session_id() . (!$GLOBALS['TL_CONFIG']['disableIpCheck'] ? \Environment::get('ip') : '') . 'FE_USER_AUTH'); $strHash = sha1(session_id() . (!$GLOBALS['TL_CONFIG']['disableIpCheck'] ? \Environment::get('ip') : '') . 'FE_USER_AUTH');
@ -156,7 +160,7 @@ class RateIt extends \Frontend {
$arrSet = array('pid' => $ratableKeyId['id'], $arrSet = array('pid' => $ratableKeyId['id'],
'tstamp' => time(), 'tstamp' => time(),
'ip_address' => $ip, 'ip_address' => $ip,
'memberid' => isset($userId) ? $userId : null, 'memberid' => isset($userId) ? $userId : null,
'rating' => $rating, 'rating' => $rating,
'createdat'=> time() 'createdat'=> time()
); );
@ -171,9 +175,9 @@ class RateIt extends \Frontend {
$rating = $this->rateItFrontend->loadRating($id, $type); $rating = $this->rateItFrontend->loadRating($id, $type);
header(RETURN_AJAX_HEADER); $return = [$this->rateItFrontend->getStarMessage($rating)];
echo $this->rateItFrontend->getStarMessage($rating); $response = new JsonResponse($return);
exit; $event->setResponse($response);
} }
} }

View File

@ -34,7 +34,6 @@ use cgoIT\rateit\RateItBackend;
* Hooks * Hooks
*/ */
$GLOBALS['TL_HOOKS']['generatePage'][] = array('cgoIT\\rateit\\RateItPage', 'generatePage'); $GLOBALS['TL_HOOKS']['generatePage'][] = array('cgoIT\\rateit\\RateItPage', 'generatePage');
$GLOBALS['TL_HOOKS']['simpleAjax'][] = array('cgoIT\\rateit\\RateIt', 'doVote');
$GLOBALS['TL_HOOKS']['parseArticles'][] = array('cgoIT\\rateit\\RateItNews', 'parseArticle'); $GLOBALS['TL_HOOKS']['parseArticles'][] = array('cgoIT\\rateit\\RateItNews', 'parseArticle');
$GLOBALS['TL_HOOKS']['getContentElement'][] = array('cgoIT\\rateit\\RateItFaq', 'getContentElementRateIt'); $GLOBALS['TL_HOOKS']['getContentElement'][] = array('cgoIT\\rateit\\RateItFaq', 'getContentElementRateIt');
$GLOBALS['TL_HOOKS']['parseTemplate'][] = array('cgoIT\\rateit\\RateItArticle', 'parseTemplateRateIt'); $GLOBALS['TL_HOOKS']['parseTemplate'][] = array('cgoIT\\rateit\\RateItArticle', 'parseTemplateRateIt');
@ -45,7 +44,7 @@ $GLOBALS['TL_HOOKS']['parseTemplate'][] = array('cgoIT\\rateit\\RateItA
array_insert($GLOBALS['BE_MOD']['content'], count($GLOBALS['BE_MOD']['content']), array_insert($GLOBALS['BE_MOD']['content'], count($GLOBALS['BE_MOD']['content']),
array('rateit' => array ( array('rateit' => array (
'callback' => 'cgoIT\\rateit\\RateItBackendModule', 'callback' => 'cgoIT\\rateit\\RateItBackendModule',
'icon' => rateit\RateItBackend::image('icon'), 'icon' => rateit\RateItBackend::image('icon'),
'stylesheet' => rateit\RateItBackend::css('backend'), 'stylesheet' => rateit\RateItBackend::css('backend'),
'javascript' => rateit\RateItBackend::js('RateItBackend') 'javascript' => rateit\RateItBackend::js('RateItBackend')
) )

View File

@ -0,0 +1,9 @@
<?php
use cgoIT\rateit\RateIt;
return array(
'contao.simpleajax' => array(
array(new RateIt(), 'doVote')
),
);

View File

@ -271,7 +271,7 @@ function doRateIt() {
}); });
window.addEvent('domready', function(e) { window.addEvent('domready', function(e) {
RateItRating = new RateItRatings({url:'bundles/cgoitrateit/public/php/rateit-ajax.php?do=rateit'}); RateItRating = new RateItRatings({url:'SimpleAjaxFrontend.php?do=rateit'});
}); });
} else if (window.jQuery) { } else if (window.jQuery) {
// the rateit plugin as an Object // the rateit plugin as an Object
@ -579,7 +579,7 @@ function doRateIt() {
async: false, async: false,
cache: true cache: true
}); });
RateItRating = Object.create(RateItRatings).initialize({url:'bundles/cgoitrateit/public/php/rateit-ajax.php?do=rateit'}); RateItRating = Object.create(RateItRatings).initialize({url:'SimpleAjaxFrontend.php?do=rateit'});
}); });
var jEscape = function(jquery) { var jEscape = function(jquery) {

View File

@ -9,7 +9,7 @@ var votePercent=this.getVotePercent(el.newFill);if(this.options.url!=null){new R
el.textEl.set('text',text);if(typeof($('.mbrateItRating'))!='undefined'&&el.id.indexOf('mb')==0){var mbid=el.getAttribute('id');mbid=mbid.replace('mb','');if(typeof(arrRatings)=='object'){for(var ri=0;ri<arrRatings.length;ri++){if(arrRatings[ri].rateItID==mbid){arrRatings[ri].description=text;break;}}} el.textEl.set('text',text);if(typeof($('.mbrateItRating'))!='undefined'&&el.id.indexOf('mb')==0){var mbid=el.getAttribute('id');mbid=mbid.replace('mb','');if(typeof(arrRatings)=='object'){for(var ri=0;ri<arrRatings.length;ri++){if(arrRatings[ri].rateItID==mbid){arrRatings[ri].description=text;break;}}}
if(typeof($(mbid))!='undefined'){$(mbid).getElement('.ratingText').set('text',text);}}else{if(typeof(arrRatings)=='object'){for(var ri=0;ri<arrRatings.length;ri++){if(arrRatings[ri].rateItID==el.id){arrRatings[ri].description=text;break;}}}}};} if(typeof($(mbid))!='undefined'){$(mbid).getElement('.ratingText').set('text',text);}}else{if(typeof(arrRatings)=='object'){for(var ri=0;ri<arrRatings.length;ri++){if(arrRatings[ri].rateItID==el.id){arrRatings[ri].description=text;break;}}}}};}
el.showError=function(error){el.textEl.addClass('ratingError');el.textEl.set('text',error);(function(){el.textEl.set('text',el.textEl.oldTxt);el.textEl.removeClass('ratingError');}).delay(2000);};}else{el.getElement('.ratingText').inject(el,'before');el.remove();}},fillVote:function(percent,el){el.newFill=this.getFillPercent(percent);if(this.getVotePercent(el.newFill)>100){el.newFill=this.getFillPercent(100);} el.showError=function(error){el.textEl.addClass('ratingError');el.textEl.set('text',error);(function(){el.textEl.set('text',el.textEl.oldTxt);el.textEl.removeClass('ratingError');}).delay(2000);};}else{el.getElement('.ratingText').inject(el,'before');el.remove();}},fillVote:function(percent,el){el.newFill=this.getFillPercent(percent);if(this.getVotePercent(el.newFill)>100){el.newFill=this.getFillPercent(100);}
el.selected.setStyle('width',el.newFill);},getStarPercent:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);if(stars!=null){var score=stars[3].toFloat();var scale=stars[4].toFloat();var percent=(score/scale)*100;return percent;}else{return 0;}},getFillPercent:function(starPercent){return(starPercent/100)*(this.options.starwidth*this.options.max);},getVotePercent:function(actVote){var starsWidth=this.options.starwidth*this.options.max;var percent=(actVote/starsWidth*100).round(2);return percent;},getRatableId:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?stars[1]:'';},getRatableType:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?stars[2]:'';},getRatableMaxValue:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?stars[4].toInt():0;},setBackgroundPosition:function(el,pos){el.setStyle('background-position','0% '+pos+'px');},getBackgroundImagePath:function(el){return el.getStyle('background-image');},getBackgroundImage:function(el){var reg_imgFile=/url\s*\(["']?(.*)["']?\)/i;var dummy=document.createElement('img');var string=this.getBackgroundImagePath(el);string=string.match(reg_imgFile)[1];string=string.replace('\"','');dummy.src=string;return dummy;}});window.addEvent('domready',function(e){RateItRating=new RateItRatings({url:'bundles/cgoitrateit/public/php/rateit-ajax.php?do=rateit'});});}else if(window.jQuery){(function(){RateItRatings={options:{step:0.1,readonly:false,resetable:false},initialize:function(options){if(typeof options=='object'&&typeof options['url']!='undefined') el.selected.setStyle('width',el.newFill);},getStarPercent:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);if(stars!=null){var score=stars[3].toFloat();var scale=stars[4].toFloat();var percent=(score/scale)*100;return percent;}else{return 0;}},getFillPercent:function(starPercent){return(starPercent/100)*(this.options.starwidth*this.options.max);},getVotePercent:function(actVote){var starsWidth=this.options.starwidth*this.options.max;var percent=(actVote/starsWidth*100).round(2);return percent;},getRatableId:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?stars[1]:'';},getRatableType:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?stars[2]:'';},getRatableMaxValue:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?stars[4].toInt():0;},setBackgroundPosition:function(el,pos){el.setStyle('background-position','0% '+pos+'px');},getBackgroundImagePath:function(el){return el.getStyle('background-image');},getBackgroundImage:function(el){var reg_imgFile=/url\s*\(["']?(.*)["']?\)/i;var dummy=document.createElement('img');var string=this.getBackgroundImagePath(el);string=string.match(reg_imgFile)[1];string=string.replace('\"','');dummy.src=string;return dummy;}});window.addEvent('domready',function(e){RateItRating=new RateItRatings({url:'SimpleAjaxFrontend.php?do=rateit'});});}else if(window.jQuery){(function(){RateItRatings={options:{step:0.1,readonly:false,resetable:false},initialize:function(options){if(typeof options=='object'&&typeof options['url']!='undefined')
this.options.url=options['url'];var self=this;jQuery('.rateItRating').each(function(i,element){self.initMe(element);});return this;},initMe:function(element){var self=this;if(!Browser.Engine.trident4){var el=jQuery(element);el.data('id',el.attr('id'));el.data('rateable',el.attr('rel')=='not-rateable'?false:true);el.data('wrapper',el.find('.wrapper'));el.data('textEl',el.find('.ratingText'));el.data('selected',el.find('.rateItRating-selected'));el.data('hover',el.find('.rateItRating-hover'));jQuery.when(self.getBackgroundImage(el.data('wrapper'))).done(function(backgroundImageSize){self.options.starwidth=backgroundImageSize[0];self.options.starheight=backgroundImageSize[1]/3;});if(self.options.starwidth===undefined||self.options.starwidth<16){self.options.starwidth=16;} this.options.url=options['url'];var self=this;jQuery('.rateItRating').each(function(i,element){self.initMe(element);});return this;},initMe:function(element){var self=this;if(!Browser.Engine.trident4){var el=jQuery(element);el.data('id',el.attr('id'));el.data('rateable',el.attr('rel')=='not-rateable'?false:true);el.data('wrapper',el.find('.wrapper'));el.data('textEl',el.find('.ratingText'));el.data('selected',el.find('.rateItRating-selected'));el.data('hover',el.find('.rateItRating-hover'));jQuery.when(self.getBackgroundImage(el.data('wrapper'))).done(function(backgroundImageSize){self.options.starwidth=backgroundImageSize[0];self.options.starheight=backgroundImageSize[1]/3;});if(self.options.starwidth===undefined||self.options.starwidth<16){self.options.starwidth=16;}
if(self.options.starheight===undefined||self.options.starheight<16){self.options.starheight=16;} if(self.options.starheight===undefined||self.options.starheight<16){self.options.starheight=16;}
self.setBackgroundPosition(el.data('selected'),-1*self.options.starheight);self.setBackgroundPosition(el.data('hover'),-1*2*self.options.starheight);el.data('starPercent',self.getStarPercent(el.data('id')));el.data('ratableId',self.getRatableId(el.data('id')));el.data('ratableType',self.getRatableType(el.data('id')));self.options.max=self.getRatableMaxValue(el.data('id'));el.data('selected').css('height',self.options.starheight);el.data('hover').css('height',self.options.starheight);el.data('wrapper').css('width',self.options.starwidth*self.options.max);el.data('wrapper').css('height',self.options.starheight);self.fillVote(el.data('starPercent'),el);el.data('currentFill',self.getFillPercent(el.data('starPercent')));if(el.data('rateable')){el.data('wrapper').mouseenter(function(event){el.data('selected').hide(500,"easeInOutQuad");el.data('hover').show();el.data('wrapper').mousemove({'el':el,'self':self},self.mouseCrap);});el.data('wrapper').mouseleave(function(event){el.data('wrapper').unbind('mousemove');el.data('hover').hide();el.data('selected').show();el.data('selected').animate({width:el.data('currentFill')},500);});el.data('wrapper').click(function(event){el.data('currentFill',el.data('newFill'));el.data('wrapper').unbind();el.data('oldTxt',el.data('textEl').text());el.data('textEl').html('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');el.data('textEl').addClass('loading');if(typeof(jQuery('.mbrateItRating'))!='undefined'&&el.data('id').indexOf('mb')==0){var mbid=el.data('id');mbid=mbid.replace('mb','');if(typeof(arrRatings)=='object'){for(var ri=0;ri<arrRatings.length;ri++){if(arrRatings[ri].rateItID==mbid){arrRatings[ri].rated=true;arrRatings[ri].width=el.data('hover').css('width');break;}}} self.setBackgroundPosition(el.data('selected'),-1*self.options.starheight);self.setBackgroundPosition(el.data('hover'),-1*2*self.options.starheight);el.data('starPercent',self.getStarPercent(el.data('id')));el.data('ratableId',self.getRatableId(el.data('id')));el.data('ratableType',self.getRatableType(el.data('id')));self.options.max=self.getRatableMaxValue(el.data('id'));el.data('selected').css('height',self.options.starheight);el.data('hover').css('height',self.options.starheight);el.data('wrapper').css('width',self.options.starwidth*self.options.max);el.data('wrapper').css('height',self.options.starheight);self.fillVote(el.data('starPercent'),el);el.data('currentFill',self.getFillPercent(el.data('starPercent')));if(el.data('rateable')){el.data('wrapper').mouseenter(function(event){el.data('selected').hide(500,"easeInOutQuad");el.data('hover').show();el.data('wrapper').mousemove({'el':el,'self':self},self.mouseCrap);});el.data('wrapper').mouseleave(function(event){el.data('wrapper').unbind('mousemove');el.data('hover').hide();el.data('selected').show();el.data('selected').animate({width:el.data('currentFill')},500);});el.data('wrapper').click(function(event){el.data('currentFill',el.data('newFill'));el.data('wrapper').unbind();el.data('oldTxt',el.data('textEl').text());el.data('textEl').html('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');el.data('textEl').addClass('loading');if(typeof(jQuery('.mbrateItRating'))!='undefined'&&el.data('id').indexOf('mb')==0){var mbid=el.data('id');mbid=mbid.replace('mb','');if(typeof(arrRatings)=='object'){for(var ri=0;ri<arrRatings.length;ri++){if(arrRatings[ri].rateItID==mbid){arrRatings[ri].rated=true;arrRatings[ri].width=el.data('hover').css('width');break;}}}
@ -20,5 +20,5 @@ el.data('selected').css('width',el.data('newFill'));},mouseCrap:function(event){
var fillPercent=self.getVotePercent(fill);var nextStep=Math.ceil((fillPercent/100)*self.options.max);var w=nextStep*self.options.starwidth;if(parseInt(el.data('hover').css('width'))!=w){el.data('selected').css('display','none');el.data('hover').css('width',Math.min(w,self.options.starwidth*self.options.max));el.data('hover').css('display','block');} var fillPercent=self.getVotePercent(fill);var nextStep=Math.ceil((fillPercent/100)*self.options.max);var w=nextStep*self.options.starwidth;if(parseInt(el.data('hover').css('width'))!=w){el.data('selected').css('display','none');el.data('hover').css('width',Math.min(w,self.options.starwidth*self.options.max));el.data('hover').css('display','block');}
var newFill=nextStep/self.options.max*100;self.fillVote(newFill,el);},getStarPercent:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);if(stars!=null){var score=parseFloat(stars[3]);var scale=parseFloat(stars[4]);var percent=(score/scale)*100;return percent;}else{return 0;}},getFillPercent:function(starPercent){return(starPercent/100)*(this.options.starwidth*this.options.max);},getVotePercent:function(actVote){var starsWidth=this.options.starwidth*this.options.max;var percent=(actVote/starsWidth*100).toFixed(2);return percent;},getRatableId:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?stars[1]:'';},getRatableType:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?stars[2]:'';},getRatableMaxValue:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?parseInt(stars[4]):0;},setBackgroundPosition:function(el,pos){el.css('background-position','0% '+pos+'px');},getBackgroundImagePath:function(el){return el.css("background-image");},getBackgroundImage:function(el){var dfd=jQuery.Deferred();var backgroundImageSize=new Array();var reg_imgFile=/url\s*\(["']?(.*)["']?\)/i;var string=this.getBackgroundImagePath(el);string=string.match(reg_imgFile)[1];string=string.replace('\"','');jQuery('<img/>').attr('src',string).load(function(){backgroundImageSize.push(this.width);backgroundImageSize.push(this.height);dfd.resolve(backgroundImageSize);});return dfd.promise();},updateText:function(el,text){error=text.split('ERROR:')[1];el.data('textEl').removeClass('loading');if(error){this.RateItRating.showError(el,error);return false;} var newFill=nextStep/self.options.max*100;self.fillVote(newFill,el);},getStarPercent:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);if(stars!=null){var score=parseFloat(stars[3]);var scale=parseFloat(stars[4]);var percent=(score/scale)*100;return percent;}else{return 0;}},getFillPercent:function(starPercent){return(starPercent/100)*(this.options.starwidth*this.options.max);},getVotePercent:function(actVote){var starsWidth=this.options.starwidth*this.options.max;var percent=(actVote/starsWidth*100).toFixed(2);return percent;},getRatableId:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?stars[1]:'';},getRatableType:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?stars[2]:'';},getRatableMaxValue:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);return stars!=null?parseInt(stars[4]):0;},setBackgroundPosition:function(el,pos){el.css('background-position','0% '+pos+'px');},getBackgroundImagePath:function(el){return el.css("background-image");},getBackgroundImage:function(el){var dfd=jQuery.Deferred();var backgroundImageSize=new Array();var reg_imgFile=/url\s*\(["']?(.*)["']?\)/i;var string=this.getBackgroundImagePath(el);string=string.match(reg_imgFile)[1];string=string.replace('\"','');jQuery('<img/>').attr('src',string).load(function(){backgroundImageSize.push(this.width);backgroundImageSize.push(this.height);dfd.resolve(backgroundImageSize);});return dfd.promise();},updateText:function(el,text){error=text.split('ERROR:')[1];el.data('textEl').removeClass('loading');if(error){this.RateItRating.showError(el,error);return false;}
el.data('textEl').text(text);if(typeof(jQuery('.mbrateItRating'))!='undefined'&&el.data('id').indexOf('mb')==0){var mbid=el.attr('id');mbid=mbid.replace('mb','');if(typeof(arrRatings)=='object'){for(var ri=0;ri<arrRatings.length;ri++){if(arrRatings[ri].rateItID==mbid){arrRatings[ri].description=text;break;}}} el.data('textEl').text(text);if(typeof(jQuery('.mbrateItRating'))!='undefined'&&el.data('id').indexOf('mb')==0){var mbid=el.attr('id');mbid=mbid.replace('mb','');if(typeof(arrRatings)=='object'){for(var ri=0;ri<arrRatings.length;ri++){if(arrRatings[ri].rateItID==mbid){arrRatings[ri].description=text;break;}}}
if(typeof(jQuery('#'+jEscape(mbid)))!='undefined'){jQuery('#'+jEscape(mbid)).find('.ratingText').text(text);}}else{if(typeof(arrRatings)=='object'){for(var ri=0;ri<arrRatings.length;ri++){if(arrRatings[ri].rateItID==el.data('id')){arrRatings[ri].description=text;break;}}}}},showError:function(el,error){el.data('textEl').addClass('ratingError');el.data('textEl').text(error);setTimeout(function(){el.data('textEl').text(el.data('oldTxt'));el.data('textEl').removeClass('ratingError');},2000);}};})(jQuery);jQuery(document).ready(function(){jQuery.ajax({type:"GET",url:"bundles/cgoitrateit/public/js/jquery-ui-effects.custom.min.js",dataType:"script",async:false,cache:true});jQuery.ajax({type:"GET",url:"bundles/cgoitrateit/public/js/helper.min.js",dataType:"script",async:false,cache:true});RateItRating=Object.create(RateItRatings).initialize({url:'bundles/cgoitrateit/public/php/rateit-ajax.php?do=rateit'});});var jEscape=function(jquery){jquery=jquery.replace(new RegExp("\\$","g"),"\\$");jquery=jquery.replace(new RegExp("\~","g"),"\\~");jquery=jquery.replace(new RegExp("\\[","g"),"\\[");jquery=jquery.replace(new RegExp("\\]","g"),"\\]");jquery=jquery.replace(new RegExp("\\|","g"),"\\|");jquery=jquery.replace(new RegExp("\\.","g"),"\\.");jquery=jquery.replace(new RegExp("#","g"),"\\#");return jquery;};}} if(typeof(jQuery('#'+jEscape(mbid)))!='undefined'){jQuery('#'+jEscape(mbid)).find('.ratingText').text(text);}}else{if(typeof(arrRatings)=='object'){for(var ri=0;ri<arrRatings.length;ri++){if(arrRatings[ri].rateItID==el.data('id')){arrRatings[ri].description=text;break;}}}}},showError:function(el,error){el.data('textEl').addClass('ratingError');el.data('textEl').text(error);setTimeout(function(){el.data('textEl').text(el.data('oldTxt'));el.data('textEl').removeClass('ratingError');},2000);}};})(jQuery);jQuery(document).ready(function(){jQuery.ajax({type:"GET",url:"bundles/cgoitrateit/public/js/jquery-ui-effects.custom.min.js",dataType:"script",async:false,cache:true});jQuery.ajax({type:"GET",url:"bundles/cgoitrateit/public/js/helper.min.js",dataType:"script",async:false,cache:true});RateItRating=Object.create(RateItRatings).initialize({url:'SimpleAjaxFrontend.php?do=rateit'});});var jEscape=function(jquery){jquery=jquery.replace(new RegExp("\\$","g"),"\\$");jquery=jquery.replace(new RegExp("\~","g"),"\\~");jquery=jquery.replace(new RegExp("\\[","g"),"\\[");jquery=jquery.replace(new RegExp("\\]","g"),"\\]");jquery=jquery.replace(new RegExp("\\|","g"),"\\|");jquery=jquery.replace(new RegExp("\\.","g"),"\\.");jquery=jquery.replace(new RegExp("#","g"),"\\#");return jquery;};}}
onReadyRateIt(function(){doRateIt();}); onReadyRateIt(function(){doRateIt();});