• [MOD] Ajax Star Rating. Rate images without page reload, like on youtube etc. 4 0 5 1
Currently:  

Author Topic: [MOD] Ajax Star Rating. Rate images without page reload, like on youtube etc.  (Read 124117 times)

0 Members and 1 Guest are viewing this topic.

Offline coloresonline

  • Newbie
  • *
  • Posts: 10
    • View Profile
I have this mod working perfectly in Firefox and Chrome,.. but i have problems in IE8. I thinks it doesn´t load js libraries. (I hate ie8.)

The problem is that stars are not working..are fixed with the last vote.

Can anyone tell me where can be the solution? Specially to load js in internet exploreer correctly,. It gives a lot of problems.

Thanks in advance.

D.

Offline diehard

  • Newbie
  • *
  • Posts: 11
    • View Profile
And my stars not working on IE  :? I update to ajaxrating.js v1.1 but nothing happened ....

Offline exceLLency

  • Newbie
  • *
  • Posts: 12
    • View Profile
Not working a Internet explorer :(

Offline coloresonline

  • Newbie
  • *
  • Posts: 10
    • View Profile
Please, any solution to fix this???

Offline dp

  • Newbie
  • *
  • Posts: 37
    • View Profile
Thanx very much for sharing this!
Works perfectly, both with Firefox 3.6 and IE 8.

Offline coloresonline

  • Newbie
  • *
  • Posts: 10
    • View Profile
Can you say if you did something to work correctly on IE8, because to me it doesn´t works on IE8.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Ist es denn eigentlich möglich, dass man in einzelnen Templates extra bewerten kann?
z.B ich lege eine seite an index.php?template=xtra-image
Ist es möglich auch dort zu bewerten?

Offline coloresonline

  • Newbie
  • *
  • Posts: 10
    • View Profile
Can someone give a solution for this solution to works properly on IE8.
Thanks in advance...

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Ich habe ein Problem mit dem Javascript von hier und dem Tooltip Javascript welches ich verwende, beides zusammen funktioniert nicht.

Tooltip-Javascript
/*
Script: TipsX3.js
	
Tooltips, BubbleTips, whatever they are, they will appear on mouseover

License:
	
MIT-style license.

Credits:
	
The idea behind Tips.js is based on Bubble Tooltips (<http://web-graphics.com/mtarchive/001717.php>) by Alessandro Fulcitiniti <http://web-graphics.com>
	
TipsX3.js is based on Tips.js, with slight modifications, by razvan@e-magine.ro
*/

/*
Class: TipsX3
	
Display a tip on any element with a title and/or href.

Note:
	
Tips requires an XHTML doctype.

Arguments:
	
elements - a collection of elements to apply the tooltips to on mouseover.
	
options - an object. See options Below.

Options:
	
maxTitleChars - the maximum number of characters to display in the title of the tip. defaults to 30.

	
onShow - optionally you can alter the default onShow behaviour with this option (like displaying a fade in effect);
	
onHide - optionally you can alter the default onHide behaviour with this option (like displaying a fade out effect);

	
showDelay - the delay the onShow method is called. (defaults to 100 ms)
	
hideDelay - the delay the onHide method is called. (defaults to 100 ms)

	
className - the prefix for your tooltip classNames. defaults to 'tool'.

	
	
the whole tooltip will have as classname: tool-tip

	
	
the title will have as classname: tool-title

	
	
the text will have as classname: tool-text

	
offsets - the distance of your tooltip from the mouse. an Object with x/y properties.
	
fixed - if set to true, the toolTip will not follow the mouse.
	

	
loadingText - text to display as a title while loading an AJAX tooltip.
	

	
errTitle, errText - text to display when there's a problem with the AJAX request.

Example:
	
(start code)
	
<img src="/images/i.png" title="The body of the tooltip is stored in the title" class="toolTipImg"/>
	
<script>
	
	
var myTips = new Tips($$('.toolTipImg'), {
	
	
	
maxTitleChars: 50
	
//I like my captions a little long
	
	
});
	
</script>
	
(end)

Note:
	
The title of the element will always be used as the tooltip body. If you put :: on your title, the text before :: will become the tooltip title.
	
If you put DOM:someElementID in your title, $('someElementID').innerHTML will be used as your tooltip contents (same syntax as above).
	
If you put AJAX:http://www.example.com/path/to/ajax_file.php in your title, the response text will be used as tooltip contents (same syntax as above). Either absolute or relative paths are ok.
*/

var TipsX3 = new Class({

	
options: { // modded for X3
	
	
onShow: function(tip){
	
	
	
tip.setStyle('visibility''visible');
	
	
},
	
	
onHide: function(tip){
	
	
	
tip.setStyle('visibility''hidden');
	
	
},
	
	
maxTitleChars30,
	
	
showDelay100,
	
	
hideDelay100,
	
	
className'tool',
	
	
offsets: {'x'16'y'16},
	
	
fixedfalse,
	
	
loadingText'Loading...',
	
	
errTitle'Oops..',
	
	
errText'There was a problem retrieving the tooltip.'
	
},

	
initialize: function(elementsoptions){
	
	
this.setOptions(options);
	
	
this.toolTip = new Element('div', {
	
	
	
'class'this.options.className '-tip',
	
	
	
'styles': {
	
	
	
	
'position''absolute',
	
	
	
	
'top''0',
	
	
	
	
'left''0',
	
	
	
	
'visibility''hidden'
	
	
	
}
	
	
}).
inject(document.body);
	
	
this.wrapper = new Element('div').inject(this.toolTip);
	
	
$$(
elements).each(this.buildthis);
	
	
if (
this.options.initializethis.options.initialize.call(this);
	
},

	
build: function(el){ // modded for X3
	
	
el.$tmp.myTitle = (el.href && el.getTag() == 'a') ? el.href.replace('http://''') : (el.rel || false);
	
	
if (
el.title){
	
	
	

	
	
	
// check if we need to extract contents from a DOM element
	
	
	
if (
el.title.test('^DOM:''i')) {
	
	
	
	
el.title = $(el.title.split(':')[1].trim()).innerHTML;
	
	
	
	

	
	
	
}
	
	
	

	
	
	
// check for an URL to retrieve content from
	
	
	
if (
el.title.test('^AJAX:''i')) {
	
	
	
	
el.title this.options.loadingText '::' el.title;
	
	
	
}
	
	
	
	
	

	
	
	
var 
dual el.title.split('::');
	
	
	
if (
dual.length 1) {
	
	
	
	
el.$tmp.myTitle dual[0].trim();
	
	
	
	
el.$tmp.myText dual[1].trim();
	
	
	
} else {
	
	
	
	
el.$tmp.myText el.title;
	
	
	
}
	
	
	
	
	

	
	
	
el.removeAttribute('title');
	
	
} else {
	
	
	
el.$tmp.myText false;
	
	
}
	
	
if (
el.$tmp.myTitle && el.$tmp.myTitle.length this.options.maxTitleCharsel.$tmp.myTitle el.$tmp.myTitle.substr(0this.options.maxTitleChars 1) + "&hellip;";
	
	
el.addEvent('mouseenter', function(event){
	
	
	
this.start(el);
	
	
	
if (!
this.options.fixedthis.locate(event);
	
	
	
else 
this.position(el);
	
	
}.
bind(this));
	
	
if (!
this.options.fixedel.addEvent('mousemove'this.locate.bindWithEvent(this));
	
	
var 
end this.end.bind(this);
	
	
el.addEvent('mouseleave'end);
	
	
el.addEvent('trash'end);
	
},

	
start: function(el){ // modded for X3
	
	
this.wrapper.empty();
	
	

	
	
// check if we have an AJAX request - if so, show a loading animation and launch the request
	
	

	
	
if (
el.$tmp.myText && el.$tmp.myText.test('^AJAX:''i')) {
	
	
	
//if (this.ajax) this.ajax.cancel();
	
	
	
this.ajax = new Ajax (el.$tmp.myText.replace(/AJAX:/i,''), {
	
	
	
	
onComplete: function (responseTextresponseXML) {
	
	
	
	
	
el.title responseText;
	
	
	
	
	
this.build(el);
	
	
	
	
	
this.start(el);
	
	
	
	
	
}.
bind(this),
	
	
	
	
onFailure: function () {
	
	
	
	
	
el.title this.options.errTitle '::' this.options.errText;
	
	
	
	
	
this.build(el);
	
	
	
	
	
this.start(el);
	
	
	
	
	
}.
bind(this),
	
	
	
	
method'get'
	
	
	
	
}).
request();
	
	
	
	

	
	
	
el.$tmp.myText '<div class="' this.options.className '-loading">&nbsp;</div>';
	
	
	

	
	
}
	
	

	
	
if (
el.$tmp.myTitle){
	
	
	
this.title = new Element('span').inject(
	
	
	
	
new 
Element('div', {'class'this.options.className '-title'}).inject(this.wrapper)
	
	
	
).
setHTML(el.$tmp.myTitle);
	
	
}
	
	
if (
el.$tmp.myText){
	
	
	
this.text = new Element('span').inject(
	
	
	
	
new 
Element('div', {'class'this.options.className '-text'}).inject(this.wrapper)
	
	
	
).
setHTML(el.$tmp.myText);
	
	
}
	
	
$clear(this.timer);
	
	
this.timer this.show.delay(this.options.showDelaythis);
	
},

	
end: function(event){
	
	
$clear(this.timer);
	
	
this.timer this.hide.delay(this.options.hideDelaythis);
	
},

	
position: function(element){
	
	
var 
pos element.getPosition();
	
	
this.toolTip.setStyles({
	
	
	
'left'pos.this.options.offsets.x,
	
	
	
'top'pos.this.options.offsets.y
	
	
});
	
},

	
locate: function(event){
	
	
var 
win = {'x'window.getWidth(), 'y'window.getHeight()};
	
	
var 
scroll = {'x'window.getScrollLeft(), 'y'window.getScrollTop()};
	
	
var 
tip = {'x'this.toolTip.offsetWidth'y'this.toolTip.offsetHeight};
	
	
var 
prop = {'x''left''y''top'};
	
	
for (var 
z in prop){
	
	
	
var 
pos event.page[z] + this.options.offsets[z];
	
	
	
if ((
pos tip[z] - scroll[z]) > win[z]) pos event.page[z] - this.options.offsets[z] - tip[z];
	
	
	
this.toolTip.setStyle(prop[z], pos);
	
	
};
	
},

	
show: function(){
	
	
if (
this.options.timeoutthis.timer this.hide.delay(this.options.timeoutthis);
	
	
this.fireEvent('onShow', [this.toolTip]);
	
},

	
hide: function(){
	
	
this.fireEvent('onHide', [this.toolTip]);
	
}

});

TipsX3.implement(new Events, new Options);


ajaxrating.js
//-----------------------------------------------------
//--- [MOD] Ajax Star Rating --------------by Bash-T---
//-----------------------------------------------------
function submitRatingRequest(frm) {
	
var 
ajax_rating_rate YAHOO.util.Dom.get('ajax_rating_rate');
	
var 
ajax_rating_count YAHOO.util.Dom.get('ajax_rating_count');
	
var 
rating_msg YAHOO.util.Dom.get('star_rating_msg');
	
var 
rating_value YAHOO.util.Dom.get('starCur0');
	
var 
stars YAHOO.util.Dom.get('star0');

	
var 
handleSuccess = function(o){
	
	
if(
o.responseText !== undefined){
	
	
	
var 
response YAHOO.lang.JSON.parse(o.responseText);
	
	
	
var 
rating parseFloat(response.Result.rating);
	
	
	
rating_msg.innerHTML YAHOO.rating.star.msgs[response.Result.msgKey];
	
	
	
rating_value.title rating;
	
	
	
YAHOO.rating.star.revert();
	
	
	

	
	
	
ajax_rating_count.innerHTML response.Result.votes;
	
	
	
ajax_rating_rate.innerHTML rating;
	
	
	
if(
response.Result.successfully_voted == 1)
	
	
	
{
	
	
	
	
YAHOO.rating.star.successfully_voted true;
	
	
	
	
YAHOO.util.Dom.setStyle(stars "cursor" "default" );
	
	
	
}
	
	
}
	
};

	
var 
handleFailure = function(o){
	
};
	

	
var 
callback = {
	
  
success:handleSuccess,
	
  
failure:handleFailure
	
};

	
YAHOO.util.Connect.setForm(frm);
	
YAHOO.util.Connect.asyncRequest("POST""ajaxrating.php"callback);
}


function $(
v,o) { return((typeof(o)=='object'?o:document).getElementById(v)); }
function 
$S(o) { return((typeof(o)=='object'?o:$(o)).style); }
function 
agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function 
abPos(o) { var o=(typeof(o)=='object'?o:$(o)), z={X:0,Y:0}; while(o!=null) { z.X+=o.offsetLeftz.Y+=o.offsetTopo=o.offsetParent; }; return(z); }
function 
XY(e,v) { var o=agent('msie')?{'X':event.clientX+document.body.scrollLeft,'Y':event.clientY+document.body.scrollTop}:{'X':e.pageX,'Y':e.pageY}; return(v?o[v]:o); }


YAHOO.rating.star.mouse=function(e,o) { 
	
if((
YAHOO.rating.star.stop || isNaN(YAHOO.rating.star.stop)) 
	
	
&& !
YAHOO.rating.star.successfully_voted) { 
	
	
YAHOO.rating.star.stop=0;
	
	
document.onmousemove=function(e) { 
	
	
	
var 
n=YAHOO.rating.star.num;
	
	
	
var 
pos=abPos($('star'+n)), 
	
	
	
	
x=XY(e), 
	
	
	
	
oX=x.X-pos.X
	
	
	
	
oY=x.Y-pos.Y
	
	
	
	
YAHOO.rating.star.num=o.id.substr(4);

	
	
	
if(
oX<|| oX>84 || oY<|| oY>19) { 
	
	
	
	
YAHOO.rating.star.stop=1YAHOO.rating.star.revert(); 
	
	
	
}
	
	
	

	
	
	
else {
	
	
	
	
$S('starCur'+n).width=oX+'px';
	
	
	
	
$S('starUser'+n).color='#111';
	
	
	
	
var 
Math.round(oX/84*100); //percent
	
	
	
	
YAHOO.util.Dom.setAttribute($('starUser'+n), "percent"p);
	
	
	
	

	
	
	
	
if(
YAHOO.rating.star.display_percentage) {
	
	
	
	
	
$(
'starUser'+n).innerHTML=percent+'%';
	
	
	
	
}
	
	
	
	

	
	
	
	
if(
YAHOO.rating.star.display_lables) {
	
	
	
	
	
var 
YAHOO.rating.star.labels;
	
	
	
	
	
YAHOO.util.Dom.get('star_rating_label').innerHTML = (p>=1&&p<=20)?l[1]:(p>=21&&p<=40)?l[2]:(p>=41&&p<=60)?l[3]:(p>=61&&p<=80)?l[4]:(p>=81&&p<=100)?l[5]:'';
	
	
	
	
}
	
	
	
}
	
	
};
	

};

YAHOO.rating.star.update=function(e,o) {
	
if(!
YAHOO.rating.star.successfully_voted)
	
{
	
 var 
n=YAHOO.rating.star.num
	
	
 
v=parseInt(YAHOO.util.Dom.getAttribute($('starUser'+n), "percent"));
	
	
 
n=o.id.substr(4); 
	
	
 
targetForm document.getElementById('ajax_rate_form');
	
	
 
factor parseFloat('0.05');
	
	
 
rating 1+v*factor-factor;
	
	
 
targetForm.rating.value rating;
	
	
 
submitRatingRequest(targetForm);
	
 }
};

YAHOO.rating.star.revert=function() { 
	
var 
n=YAHOO.rating.star.num
	
v=parseFloat($('starCur'+n).title);
	
factor parseFloat('0.05');
	
percent = (v>0)? (v+factor-1)/factor 0;

	
$S('starCur'+n).width=Math.round(percent*84/100)+'px';
	
if(
YAHOO.rating.star.display_percentage) {
	
	
$(
'starUser'+n).innerHTML=(percent>0?Math.round(percent)+'%':'');
	
}
	
$(
'starUser'+n).percent=(percent>0?Math.round(percent):'');
	
$(
'starUser'+n).style.color='#888';
	

	
if(
YAHOO.rating.star.display_lables) {
	
	
YAHOO.util.Dom.get('star_rating_label').innerHTML=(percent==0)?YAHOO.rating.star.labels[0]:'';
	
}
	

	
document.onmousemove='';
};

YAHOO.util.Event.onDOMReady(function() {
	
YAHOO.rating.star.revert();
});



bash-t, kannst du das irgendwie abgleichen? Ich bekomme es nicht hin!

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Keiner eine Idee?
Ich weis nicht was ich umändern muss damit es harmoniert

Offline Saschilys

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Keiner eine Idee?
Ich weis nicht was ich umändern muss damit es harmoniert

Ich habe auch das Problem, das diese JS sich mit einem meiner anderen Js´s nicht verträgt.
Wie ich haber heirim Forum gesehen habe, scheint es noch jemand zu geben, der das Problem hat http://www.4homepages.de/forum/index.php?topic=26728.0
Eine Lösung würde mir auch gefallen

Offline weili61

  • Pre-Newbie
  • Posts: 2
    • View Profile
Why not run in the 1.7.8 version?

Offline x23piracy

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • FHG
Hi,

has anybody running that MOD under 1.7.8?
any other code changes made exhaust the first post?


Greetz X23
« Last Edit: December 11, 2010, 02:15:52 PM by x23piracy »

Don't trust in md5 it's unsafe change your 4i galerys password hash algorythm! second pw db field, create new hashes over some time, deny old hash. Help members that cry, send informationen mail to the rest. Camouflage new pw hash in cookie. Done!

--(◔̯◔)--

Offline Nosferatu

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Project-Firepower
läuft der mod in 1.7.9 ??? möchte nicht umbedingt ewig installieren und dann funkt er nicht ...

Offline x23piracy

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • FHG
Hi,

bei meinen Versuchen mit 1.7.8 und 1.7.9 und Iceberg Template gabs
immer irgendeinen css Stress, technisch funktioniert der MOD aber es
ist durchaus möglich das es aktuell in jedem Template das Problem gibt.

Ich hab mal versucht den Fehler zu finden und zu beheben aber erfolglos,
habe dann irgendwann aufgegeben.

Außerdem zickt das yahoo script evtl. mit einem deiner bestehenden js.


Gruß Jens

Don't trust in md5 it's unsafe change your 4i galerys password hash algorythm! second pw db field, create new hashes over some time, deny old hash. Help members that cry, send informationen mail to the rest. Camouflage new pw hash in cookie. Done!

--(◔̯◔)--