- Posts: 16
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<!-- Star Rating Stuff --> <script type="text/javascript" src="{TEMPLATEURL}jquery.rating.js" charset="utf-8"></script> <script type="text/javascript" src="{TEMPLATEURL}jquery.MetaData.js" charset="utf-8"></script> <link rel="stylesheet" type="text/css" href="{TEMPLATEURL}jquery.rating.css" />
function handleRatingArrayNumeric (sgq) { // Identify the question var qID = sgq.split('X')[2]; var thisQuestion = $('#question'+qID+''); // Hide the numeric inputs $('input[type="text"]', thisQuestion).hide(); // Move the fake radios into the array cells and apply the star rating plugin var starContainer = $('#starContainer', thisQuestion).clone(); $('#starContainer', thisQuestion).remove(); $('td.answer-item', thisQuestion).each(function(i) { var inputID = $('input[type="text"]', this).attr('id'); $(this).append(starContainer.clone()); $('#starContainer', this).attr('id', 'starContainer-'+sgq+'-'+i).addClass('starContainer').append('<div style="clear:both" />');; $('input.arrayStar', this).each(function(i) { $(this).attr('class', $(this).attr('class').replace(/arrayStar/, 'arrayStar-'+inputID+'')); }); // Apply the stars plugin $('.arrayStar-'+inputID+'').rating(); }); // Get a previous rating (if any) and use it to initialize the star display $('input[type="text"]', thisQuestion).each(function(i) { var thisCell = $(this).closest('td'); if ($(this).val() != '') { $('input.star-rating-applied', thisCell).rating('select', $(this).val()); } }); // Listener on the star rating cancel element $('div.rating-cancel', thisQuestion).click(function(event) { var thisCell = $(this).closest('td'); // Empty the text input $('input[type="text"]', thisCell).val(''); }); // Listener on the star rating elements $('div.star-rating', thisQuestion).click(function(event) { var thisCell = $(this).closest('td'); // Load the value of the highest clicked star into the associated text input $('input[type="text"]', thisCell).val($('div.star-rating-on:last a', thisCell).text()); }); }
Some question text... <div id="starContainer"> <input type="radio" class="arrayStar { split:2 }" title="1" value="1" name="q1Rate" /> <input type="radio" class="arrayStar { split:2 }" title="2" value="2" name="q1Rate" /> <input type="radio" class="arrayStar { split:2 }" title="3" value="3" name="q1Rate" /> <input type="radio" class="arrayStar { split:2 }" title="4" value="4" name="q1Rate" /> <input type="radio" class="arrayStar { split:2 }" title="5" value="5" name="q1Rate" /> <input type="radio" class="arrayStar { split:2 }" title="6" value="6" name="q1Rate" /> <input type="radio" class="arrayStar { split:2 }" title="7" value="7" name="q1Rate" /> <input type="radio" class="arrayStar { split:2 }" title="8" value="8" name="q1Rate" /> <input type="radio" class="arrayStar { split:2 }" title="9" value="9" name="q1Rate" /> <input type="radio" class="arrayStar { split:2 }" title="10" value="10" name="q1Rate" /> </div>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { handleRatingArrayNumeric ('{SGQ}'); }); </script>
Can you assist in what needs to be changed to have the area that could, for example, accomodate «a star» with 32x32px?
/* jQuery.Rating Plugin CSS - https://www.fyneworks.com/jquery/star-rating/ */ div.rating-cancel,div.star-rating{float:left;width:33px;height:31px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden} div.rating-cancel,div.rating-cancel a{background:url(delete_x32.gif) no-repeat 0 -32px} div.star-rating,div.star-rating a{background:url(star_x32.gif) no-repeat 0 0px} div.rating-cancel a,div.star-rating a{display:block;width:32px;height:100%;background-position:0 0px;border:0} div.star-rating-on a{background-position:0 -32px!important} div.star-rating-hover a{background-position:0 -64px} /* Read Only CSS */ div.star-rating-readonly a{cursor:default !important} /* Partial Star CSS */ div.star-rating{background:transparent!important;overflow:hidden!important} /* END jQuery.Rating Plugin CSS */
I would really like a 10 point star option...
<div id="starContainer"> <input type="radio" class="arrayStar" title="1" value="1" name="q1Rate" /> <input type="radio" class="arrayStar" title="2" value="2" name="q1Rate" /> <input type="radio" class="arrayStar" title="3" value="3" name="q1Rate" /> <input type="radio" class="arrayStar" title="4" value="4" name="q1Rate" /> <input type="radio" class="arrayStar" title="5" value="5" name="q1Rate" /> <input type="radio" class="arrayStar" title="6" value="6" name="q1Rate" /> <input type="radio" class="arrayStar" title="7" value="7" name="q1Rate" /> <input type="radio" class="arrayStar" title="8" value="8" name="q1Rate" /> <input type="radio" class="arrayStar" title="9" value="9" name="q1Rate" /> <input type="radio" class="arrayStar" title="10" value="10" name="q1Rate" /> </div>