mercredi 18 février 2015

5 star image review system, div placement and image scale


I have a 5 star review widget div that I wanted to place into the top caption slider of an image but it doesn't seem to work. I was using a span tag inside of the caption and it will show up sometimes but not properly and I can't seem to get it to scale to 30% of the caption or fix it to the top left of the caption.On the bottom caption I will have a buy button but that should be easy to fix once I get the top div sorted.


Here's a link to the fiddle: http://ift.tt/1zofcGg



<head>
<title>review image system</title>
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
<script src="modernizr.custom.js"></script>
<script src="jquery.js"></script>
<script src="newjavascript.js"></script>
<script src="toucheffects.js"></script>
</head>

<body>
<div class="wrapper">

<header>
<h1 class="main_head">blub</h1>

</header>
<hr />

<div class="container left">

<img src="http://ift.tt/TqWtKq" alt="image" />
<article class="text css3-4">
<h1><a href="#" class="css3-4">space1</a></h1>
</article>
<article class="text css3-3 css3-4">
<h1><a href="#" class="css3-3 css3-4">space2</a> </h1>
<span><div class='movie_choice'>
<div id="r1" class="rate_widget">
<div class="star_1 ratings_stars"></div>
<div class="star_2 ratings_stars"></div>
<div class="star_3 ratings_stars"></div>
<div class="star_4 ratings_stars"></div>
<div class="star_5 ratings_stars"></div>
<div class="total_votes">vote data</div>
</div>
</div>
</span>
</article>
</div>

<hr />

</div>

<script>


// first thing added
$(document).ready(function() {

$('.rate_widget').each(function(i) {
var widget = this;
var out_data = {
widget_id : $(widget).attr('id'),
fetch: 1
};
$.post({
url:'ratings.php',
data: out_data,
success:function(INFO) {
$(widget).data( 'fsr', INFO );
set_votes(widget);
},
dataType:'json'
});
});


$('.ratings_stars').hover(
// Handles mouseover
function() {
$(this).prevAll().andSelf().addClass('ratings_over');
$(this).nextAll().removeClass('ratings_vote');
},
// Handles mouseout
function() {
$(this).prevAll().andSelf().removeClass('ratings_over');
// can't use 'this' because it wont contain the updated data
set_votes($(this).parent());
}
);


// records the vote
$('.ratings_stars').bind('click', function() {
var star = this;
var widget = $(this).parent();

var clicked_data = {
clicked_on : $(star).attr('class'),
widget_id : $(star).parent().attr('id')
};
$.post(
{
url:'ratings.php',
data: clicked_data,
success:function(INFO) {
widget.data( 'fsr', INFO );
set_votes(widget);
},
dataType:'json'
});



});

function set_votes(widget) {

var avg = $(widget).data('fsr').whole_avg;
var votes = $(widget).data('fsr').number_votes;
var exact = $(widget).data('fsr').dec_avg;

window.console && console.log('and now in set_votes, it thinks the fsr is ' + $(widget).data('fsr').number_votes);

$(widget).find('.star_' + avg).prevAll().andSelf().addClass('ratings_vote');
$(widget).find('.star_' + avg).nextAll().removeClass('ratings_vote');
$(widget).find('.total_votes').text( votes + ' votes recorded (' + exact + ' rating)' );
}

});
</script>
</body>
</html>




Aucun commentaire:

Enregistrer un commentaire