Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.05' into 2.05
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Apr 5, 2013
2 parents bf33247 + b025559 commit eaef9ba
Show file tree
Hide file tree
Showing 16 changed files with 194 additions and 91 deletions.
105 changes: 15 additions & 90 deletions application/helpers/qanda_helper.php
Expand Up @@ -978,100 +978,25 @@ function do_5pointchoice($ia)
}
$answer .= "</ul>\n<input type=\"hidden\" name=\"java$ia[1]\" id=\"java$ia[1]\" value=\"".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]."\" />\n";
$inputnames[]=$ia[1];
if($aQuestionAttributes['slider_rating']==1){
header_includes('jquery.rating.css','css');
header_includes('jquery.rating.js','js');
$answer.="
<script type=\"text/javascript\">
document.write('";
$answer.='<ul id="'.$id.'div" class="answers-list stars-wrapper"><li class="item-list answer-star"><input type="radio" id="stars1" name="stars" class="'.$id.'st" value="1"/></li><li class="item-list answer-star"><input type="radio" id="stars2" name="stars" class="'.$id.'st" value="2"/></li><li class="item-list answer-star"><input type="radio" name="stars" id="stars3" class="'.$id.'st" value="3"/></li><li class="item-list answer-star"><input type="radio" id="stars4" name="stars" class="'.$id.'st" value="4"/></li><li class="item-list answer-star"><input type="radio" name="stars" id="stars5" class="'.$id.'st" value="5"/></li><li class="item-list answer-star"></u>';
$answer.="');
</script>
";
$answer.="
<script type=\"text/javascript\">
$('#$id').hide();
var checked = $('#$id input:checked').attr('value');
if(checked!=''){
$('#stars'+checked).attr('checked','checked');
}
$('.{$id}st').rating({
callback: function(value,link){
if(value==undefined || value==''){
$('#$id input').each(function(){ $(this).removeAttr('checked');});
$('#{$id} #NoAnswer').attr('checked','checked');
}
else{
$('#$id input').each(function(){ $(this).removeAttr('checked');});
$('#answer$ia[1]'+value).attr('checked','checked');
}
checkconditions(value,'$ia[1]','radio');
}

});
</script>
";
if($aQuestionAttributes['slider_rating']==1){
header_includes('star-rating.css','css');
header_includes('star-rating.js','js');
$answer .= "<script type='text/javascript'>\n"
. " <!--\n"
." doRatingStar({$ia[0]});\n"
." -->\n"
."</script>\n";
}

if($aQuestionAttributes['slider_rating']==2){
if(!isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]) OR $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]==''){
$value=1;
}else{
$value=$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]];
}
$answer.="
<script type=\"text/javascript\">
document.write('";
$answer.="<div style=\"float:left;\">'+
'<div style=\"text-align:center; margin-bottom:6px; width:370px;\"><div style=\"width:2%; float:left;\">1</div><div style=\"width:46%;float:left;\">2</div><div style=\"width:4%;float:left;\">3</div><div style=\"width:46%;float:left;\">4</div><div style=\"width:2%;float:left;\">5</div></div><br/>'+
'<div id=\"{$id}sliderBg\" style=\"background-image:url(\'{$imageurl}/sliderBg.png\'); text-align:center; background-repeat:no-repeat; height:22px; width:396px;\">'+
'<center>'+
'<div id=\"{$id}slider\" style=\"width:365px;\"></div>'+
'</center>'+
'</div></div>'+
'<div id=\"{$id}emoticon\" style=\"text-align:left; margin:10px; padding-left:10px;\"><img id=\"{$id}img1\" style=\"margin-left:10px;\" src=\".{$imageurl}/emoticons/{$value}.png\"/><img id=\"{$id}img2\" style=\"margin-left:-31px;margin-top:-31px;\" src=\"{$imageurl}/emoticons/{$value}.png\" />'+
'</div>";
$answer.="');
</script>
";
$answer.="
<script type=\"text/javascript\">
$('#$id').hide();
var value=$value;
var checked = $('#$id input:checked').attr('value');
if(checked!=''){
value=checked;
}
var time=200;
var old=value;
$('#{$id}slider').slider({
value: value,
min: 1,
max: 5,
step: 1,
slide: function(event,ui){
$('#{$id}img2').attr('src','{$imageurl}/emoticons/'+ui.value+'.png');
$('#{$id}img2').fadeIn(time);
$('#$id input').each(function(){ $(this).removeAttr('checked');});
$('#answer$ia[1]'+ui.value).attr('checked','checked');
$('#{$id}img1').fadeOut(time,function(){
$('#{$id}img1').attr('src',$('#{$id}img2').attr('src'));
$('#{$id}img1').show();
$('#{$id}img2').hide();
});
$checkconditionFunction(ui.value,'$ia[1]','radio');
}
});
$('#{$id}slider a').css('background-image', 'url(\'{$imageurl}/slider.png\')');
$('#{$id}slider a').css('width', '11px');
$('#{$id}slider a').css('height', '28px');
$('#{$id}slider a').css('border', 'none');
//$('#{$id}slider').css('background-image', 'url(\'{$imageurl}/sliderBg.png\')');
$('#{$id}slider').css('visibility','hidden');
$('#{$id}slider a').css('visibility', 'visible');
</script>
";

header_includes('slider-rating.css','css');
header_includes('slider-rating.js','js');
$answer .= "<script type='text/javascript'>\n"
. " <!--\n"
." doRatingSlider({$ia[0]});\n"
." -->\n"
."</script>\n";
}
return array($answer, $inputnames);
}
Expand Down
8 changes: 7 additions & 1 deletion application/views/admin/htmleditor/pop_editor_view.php
Expand Up @@ -4,7 +4,13 @@
<title><?php printf($clang->gT('Editing %s'), $sFieldText); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script type="text/javascript" src="<?php echo Yii::app()->getConfig('generalscripts') . 'jquery/jquery.js'; ?>"></script>
<?php
App()->getClientScript()->registerPackage('jqueryui');
App()->getClientScript()->registerPackage('jquery-superfish');
App()->getClientScript()->registerCoreScript('ckeditor');
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl') . "jquery-ui/jquery-ui.css" );
?>
<!-- <script type="text/javascript" src="<?php echo Yii::app()->getConfig('generalscripts') . 'jquery/jquery.js'; ?>"></script> -->
<script type="text/javascript" src="<?php echo Yii::app()->getConfig('sCKEditorURL') . '/ckeditor.js'; ?>"></script>
</head>

Expand Down
46 changes: 46 additions & 0 deletions scripts/slider-rating.js
@@ -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);
}
}
67 changes: 67 additions & 0 deletions scripts/star-rating.js
@@ -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");
}
}
Binary file added styles-public/emotes/faces.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added styles-public/img/slider-background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added styles-public/img/slider.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added styles-public/img/stars.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed styles-public/rating-img/star.gif
Binary file not shown.
Binary file removed styles-public/rating-img/star1.gif
Binary file not shown.
Binary file removed styles-public/rating-img/star2.gif
Binary file not shown.
Binary file removed styles-public/rating-img/star3.gif
Binary file not shown.
Binary file removed styles-public/rating-img/star4.gif
Binary file not shown.
Binary file removed styles-public/rating-img/star5.gif
Binary file not shown.
32 changes: 32 additions & 0 deletions styles-public/slider-rating.css
@@ -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;width:366px;}
.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;}
27 changes: 27 additions & 0 deletions styles-public/star-rating.css
@@ -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}

0 comments on commit eaef9ba

Please sign in to comment.