Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New feature #06880: Allow adaptation of 5 point slider
Dev: Allow for slider and star Dev: Think script can be adapted for 5 point array too Dev: surely some css fix but tested in IE7 Dev: surely some js optimisation
- Loading branch information
Showing
15 changed files
with
187 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* @license This file is part of LimeSurvey | ||
* See COPYRIGHT.php for copyright notices and details. | ||
* | ||
*/ | ||
|
||
/** | ||
* Update answers part for rating slider | ||
* | ||
* @author Denis Chenu (Shnoulle) | ||
* @param {number} qId The qid of the question where apply. | ||
*/ | ||
function doRatingSlider(qID) { | ||
|
||
var answersList=$('#question'+qID+' .answers-list.radio-list:not(.slidered-list)'); | ||
if(!answersList){return;} | ||
// See to http://www.visualjquery.com/rating/rating_redux.html | ||
if ((!$.support.opacity && !$.support.style)) try { document.execCommand("BackgroundImageCache", false, true)} catch(e) { }; | ||
|
||
var openValue=answersList.find("input:radio:checked").val(); | ||
var sliderHtmlElement = "<div class='slider-wrapper slider-5'><div class='slider-labels'>"; | ||
for (i=1; i<6; i++) { | ||
sliderHtmlElement= sliderHtmlElement+"<div class='slider-label slider-label-"+i+"'>"+i+"</div>"; | ||
} | ||
sliderHtmlElement= sliderHtmlElement+"</div>" | ||
+ "<div class='slider-background'><div class='slider slider-rating'></div></div>" | ||
+ "</div>" | ||
+ "<div class='slider-emoticon-wrapper'><div class='slider-emoticon'></div></div>"; | ||
answersList.after(sliderHtmlElement); | ||
|
||
$("#question"+qID+" .slider").slider({ | ||
min: 1, | ||
max: 5, | ||
range: "min", | ||
step: 1, | ||
value: openValue, | ||
slide: function( event, ui ) { | ||
$('#question'+qID+' .answers-list.radio-list').find(".radio[value='"+ui.value+"']").click(); | ||
$('#question'+qID+' .slider-emoticon').attr('class', 'slider-emoticon slider-emoticon-'+ui.value); | ||
} | ||
}); | ||
answersList.addClass("slidered-list hide read"); | ||
if(openValue){ | ||
$('#question'+qID+' .slider-emoticon').attr('class', 'slider-emoticon slider-emoticon-'+openValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* @license This file is part of LimeSurvey | ||
* See COPYRIGHT.php for copyright notices and details. | ||
* | ||
*/ | ||
|
||
/** | ||
* Update answers part for Star rating | ||
* | ||
* @author Denis Chenu (Shnoulle) | ||
* @param {number} qId The qid of the question where apply. | ||
*/ | ||
function doRatingStar(qID) { | ||
|
||
|
||
// Return quick | ||
var answersList=$('#question'+qID+' .answers-list.radio-list:not(.starred-list)'); | ||
if(!answersList){return;} | ||
// See to http://www.visualjquery.com/rating/rating_redux.html | ||
if ((!$.support.opacity && !$.support.style)) try { document.execCommand("BackgroundImageCache", false, true)} catch(e) { }; | ||
|
||
|
||
var asNoAnswer=$('#question'+qID+' .noanswer-item input.radio').length; | ||
var starsHtmlElement="<div class='stars-list answers-list noread'>"; | ||
if(asNoAnswer){ starsHtmlElement= starsHtmlElement+"<div class='star-rating star-cancel' title='"+$('#question'+qID+' .noanswer-item label').html()+"'></div>";} | ||
for (i=1; i<6; i++) { | ||
starsHtmlElement= starsHtmlElement+"<div class='star-rating star star-"+i+"' title='"+i+"'></div>" | ||
} | ||
starsHtmlElement= starsHtmlElement+"</div>"; | ||
answersList.after(starsHtmlElement); | ||
|
||
var starsElement=$('#question'+qID+' .stars-list'); | ||
starsElement.on("mouseout mouseover", ".star-rating", function(event){ | ||
var thisnum=$(this).index(); | ||
if(event.type=='mouseover'){ | ||
starsElement.children('.star-rating').removeClass("star-rated-on"); | ||
starsElement.children('.star-rating:lt('+thisnum+')').addClass("star-drained"); | ||
starsElement.children('.star-rating:eq('+thisnum+')').addClass("star-drained star-hover"); | ||
}else{ | ||
starsElement.children('.star-rated').addClass("star-rated-on"); | ||
starsElement.children('.star-rating:lt('+thisnum+')').removeClass("star-drained"); | ||
starsElement.children('.star-rating:eq('+thisnum+')').removeClass("star-drained star-hover"); | ||
} | ||
}); | ||
starsElement.on("click", ".star-rating.star", function(event){ | ||
var thischoice=thisnum=$(this).index(); | ||
if(!asNoAnswer){thischoice++;} | ||
answersList.find("input.radio[value='"+thischoice+"']").click(); | ||
starsElement.children('.star-rating').removeClass("star-rated") | ||
starsElement.children('.star-rating:lt('+thisnum+')').addClass("star-rated"); | ||
starsElement.children('.star-rating:eq('+thisnum+')').addClass("star-rated star-thisrated"); | ||
}); | ||
starsElement.on("click", ".star-rating.star-cancel", function(event){ | ||
starsElement.children('.star-rating').removeClass("star-rated") | ||
answersList.find("input.radio[value='']").click(); | ||
|
||
}); | ||
answersList.addClass("starred-list hide read"); | ||
var openValue=answersList.find("input:radio:checked").val(); | ||
if(openValue){ | ||
var thisnum=openValue-1; | ||
if(asNoAnswer){thisnum++;} | ||
starsElement.children('.star-rating:lt('+thisnum+')').addClass("star-rated"); | ||
starsElement.children('.star-rating:eq('+thisnum+')').addClass("star-rated star-thisrated"); | ||
starsElement.children('.star-rated').addClass("star-rated-on"); | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.slider-wrapper{width:396px;float:left;margin:3px 20px 3px 0} | ||
.slider-labels{padding:1px 0 8px 13px;height:1em;} | ||
.slider-label{display:inline-block;width:91px;text-indent:0;} | ||
.slider-label{ | ||
*float:left; | ||
} | ||
.slider-label-1{text-indent:0;} | ||
.slider-label-5{width:auto;} | ||
.slider-background{clear:both;display:block;background:transparent url(img/slider-background.png) no-repeat 0 0;padding:0 15px 0 13px;height:22px;} | ||
.slider-background .slider-rating | ||
,.page-odd .slider-background .slider-rating | ||
{visibility:hidden;height:22px;} | ||
.slider-rating a.ui-slider-handle | ||
,.page-odd .slider-rating a.ui-slider-handle | ||
{ | ||
visibility:visible; | ||
background:transparent url(img/slider.png) no-repeat 50% 50%; | ||
width:15px; | ||
height:30px; | ||
border:0 none #016cb3; | ||
margin-left: -5px; | ||
top: -6px; | ||
border-radius: 2px; | ||
outline: none; | ||
} | ||
.slider-emoticon-wrapper{padding:1em 0 0} | ||
.slider-emoticon{width:32px;height:32px;background:transparent url(emotes/faces.png) no-repeat 0 0;float:left;} | ||
.slider-emoticon-1{background-position:0 -32px;} | ||
.slider-emoticon-2{background-position:0 -64px;} | ||
.slider-emoticon-3{background-position:0 -96px;} | ||
.slider-emoticon-4{background-position:0 -128px;} | ||
.slider-emoticon-5{background-position:0 -160px;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.star-rating{ | ||
background: url("img/stars.png") no-repeat scroll 0 0 transparent; | ||
cursor: pointer; | ||
display: block; | ||
float: left; | ||
height: 36px; | ||
overflow: hidden; | ||
width: 36px; | ||
} | ||
.star-cancel{background-position:0 0;} | ||
.star-cancel.star-drained{background-position:0 0;} | ||
.star-cancel.star-hover{background-position:0 -36px;} | ||
.star-1{background-position:-36px 0} | ||
.star-1.star-rated-on{background-position:-36px -72px} | ||
.star-1.star-drained{background-position:-36px -36px} | ||
.star-2{background-position:-72px 0} | ||
.star-2.star-rated-on{background-position:-72px -72px} | ||
.star-2.star-drained{background-position:-72px -36px} | ||
.star-3{background-position:-108px 0} | ||
.star-3.star-rated-on{background-position:-108px -72px} | ||
.star-3.star-drained{background-position:-108px -36px} | ||
.star-4{background-position:-144px 0} | ||
.star-4.star-rated-on{background-position:-144px -72px} | ||
.star-4.star-drained{background-position:-144px -36px} | ||
.star-5{background-position:-180px 0} | ||
.star-5.star-rated-on{background-position:-180px -72px} | ||
.star-5.star-drained{background-position:-180px -36px} |
e5765fb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New icon are from Tango project : http://tango.freedesktop.org/
Have some xcf file for png construction: did i put it somewhere in https://github.com/LimeSurvey/Original-art ?
PD licence but "we ask that you still please attribute the Tango Desktop Project"