Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Yii' into Yii
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Jul 10, 2012
2 parents 4ca0acb + 986c7b3 commit 31c5458
Show file tree
Hide file tree
Showing 20 changed files with 184 additions and 775 deletions.
42 changes: 40 additions & 2 deletions application/helpers/common_helper.php
Expand Up @@ -3724,8 +3724,26 @@ function questionAttributes($returnByName=false)
'default'=>1,
"caption"=>$clang->gT('Show javascript alert'),
"help"=>$clang->gT('Show an alert if answers exceeds the number of max answers'));


$qattributes["samechoiceheight"]=array(
"types"=>"R",
'category'=>$clang->gT('Display'),
'sortorder'=>120,
'inputtype'=>'singleselect',
'options'=>array(0=>$clang->gT('No'),
1=>$clang->gT('Yes')),
'default'=>1,
"caption"=>$clang->gT('Same height for all choice'),
"help"=>$clang->gT('Force each choice to have the same height'));
$qattributes["samelistheight"]=array(
"types"=>"R",
'category'=>$clang->gT('Display'),
'sortorder'=>121,
'inputtype'=>'singleselect',
'options'=>array(0=>$clang->gT('No'),
1=>$clang->gT('Yes')),
'default'=>1,
"caption"=>$clang->gT('Same height for lists'),
"help"=>$clang->gT('Force the choice list and the rank list to have the same height'));

$qattributes["parent_order"]=array(
"types"=>"!ABCEFHKLMOPQRWZ1:;",
Expand Down Expand Up @@ -3886,6 +3904,26 @@ function questionAttributes($returnByName=false)
"help"=>$clang->gT("Set a specific SPSS export scale type for this question"),
"caption"=>$clang->gT('SPSS export scale type'));

$qattributes["choice_title"]=array(
"types"=>"R",
'category'=>$clang->gT('Other'),
'sortorder'=>200,
"inputtype"=>"text",
'i18n'=>true,
'default'=>"",
"help"=>sprintf($clang->gT("Replace choice header (default: \"%s\")",'js'),$clang->gT("Your Choices")),
"caption"=>$clang->gT("Choice header"));

$qattributes["rank_title"]=array(
"types"=>"R",
'category'=>$clang->gT('Other'),
'sortorder'=>201,
"inputtype"=>"text",
'i18n'=>true,
'default'=>"",
"help"=>sprintf($clang->gT("Replace rank header (default: \"%s\")",'js'),$clang->gT("Your Ranking")),
"caption"=>$clang->gT("Rank header"));

//Timer attributes
$qattributes["time_limit"]=array(
"types"=>"STUXL!",
Expand Down
24 changes: 20 additions & 4 deletions application/helpers/qanda_helper.php
Expand Up @@ -2132,14 +2132,30 @@ function do_ranking($ia)
$answer .="</div>";
header_includes("ranking.js");
header_includes("ranking.css","css");


if(trim($aQuestionAttributes['choice_title'][$clang->langcode]) != '')
{
$choice_title=htmlspecialchars(trim($aQuestionAttributes['choice_title'][$clang->langcode]), ENT_QUOTES);
}
else
{
$choice_title=$clang->gT("Your Choices",'js');
}
if(trim($aQuestionAttributes['rank_title'][$clang->langcode]) != '')
{
$rank_title=htmlspecialchars(trim($aQuestionAttributes['rank_title'][$clang->langcode]), ENT_QUOTES);
}
else
{
$rank_title=$clang->gT("Your Ranking",'js');
}
$answer .= "<script type='text/javascript'>\n"
. " <!--\n"
. "var translt = {
choicetitle: '".$clang->gT("Your Choices",'js')."',
ranktitle: '".$clang->gT("Your Ranking",'js')."'
choicetitle: '{$choice_title}',
ranktitle: '{$rank_title}'
};\n"
." doDragDropRank({$ia[0]},{$aQuestionAttributes["showpopups"]});\n"
." doDragDropRank({$ia[0]},{$aQuestionAttributes["showpopups"]},{$aQuestionAttributes["samechoiceheight"]},{$aQuestionAttributes["samelistheight"]});\n"
." -->\n"
."</script>\n";
return array($answer, $inputnames);
Expand Down
26 changes: 16 additions & 10 deletions scripts/ranking.js
Expand Up @@ -3,7 +3,7 @@ function doDragDropRank(qID, showpopups, samechoiceheight, samelistheight) {
if (typeof showpopups === 'undefined'){showpopups=true;}
if (typeof samechoiceheight === 'undefined'){samechoiceheight=true;}
if (typeof samelistheight === 'undefined'){samelistheight=true;}

maxanswers= parseInt($("#ranking-"+qID+"-maxans").text(),10);
//Add a class to the question
$('#question'+qID+'').addClass('dragDropRanking');
// Hide the default answers list
Expand Down Expand Up @@ -39,15 +39,15 @@ if (typeof samelistheight === 'undefined'){samelistheight=true;}
if($(this).val()!=''){
ranked.push($(this).val());
htmloption=$("#htmlblock-"+qID+'-'+$(this).val()).html();
var liCode = '<li class="ui-widget-content choice" id="choice_'+$(this).val()+'">' + htmloption + '</li>'
var liCode = '<li class="ui-state-default choice" id="choice_'+$(this).val()+'">' + htmloption + '</li>'
$(liCode).appendTo('#sortable-rank-'+qID+'');
}
});
$('#question'+qID+' .answers-list .select-item:first option').each(function(index, Element) {
var thisvalue=$(this).val();
if(thisvalue!='' && jQuery.inArray(thisvalue,ranked)<0){
htmloption=$("#htmlblock-"+qID+'-'+$(this).val()).html();
var liCode = '<li class="ui-widget-content choice" id="choice_'+$(this).val()+'">' + htmloption + '</li>'
var liCode = '<li class="ui-state-default choice" id="choice_'+$(this).val()+'">' + htmloption + '</li>'
$(liCode).appendTo('#sortable-choice-'+qID+'');
}
});
Expand All @@ -56,14 +56,15 @@ if (typeof samelistheight === 'undefined'){samelistheight=true;}
// Set up the connected sortable
$('#sortable-choice-'+qID+', #sortable-rank-'+qID+'').sortable({
connectWith: '.connectedSortable'+qID+'',
forceHelperSize: true,
forcePlaceholderSize: true,
placeholder: 'ui-sortable-placeholder',
helper: 'clone',
revert: 50,
receive: function(event, ui) {
maxanswers= parseInt($("#ranking-"+qID+"-maxans").text(),10);
if($(this).attr("id")=='sortable-rank-'+qID && $(maxanswers>0 && '#sortable-rank-'+qID+' li').length > maxanswers) {
sortableAlert (qID,showpopups);
$(ui.sender).sortable('cancel');
sortableAlert (qID,showpopups,maxanswers);
if(showpopups){$(ui.sender).sortable('cancel');}
}
},
stop: function(event, ui) {
Expand All @@ -78,10 +79,9 @@ if (typeof samelistheight === 'undefined'){samelistheight=true;}

// Allow users to double click to move to selections from list to list
$('#sortable-choice-'+qID+' li').live('dblclick', function() {
maxanswers= parseInt($("#ranking-"+qID+"-maxans").text(),10);
if($(maxanswers>0 && '#sortable-rank-'+qID+' li').length >= maxanswers) {
sortableAlert (qID,showpopups);
return false;
sortableAlert (qID,showpopups,maxanswers);
if(showpopups){return false;}
}
else {
$(this).appendTo('#sortable-rank-'+qID+'');
Expand Down Expand Up @@ -109,6 +109,9 @@ function updateDragDropRank(qID){
$('#question'+qID+' .select-item select').each(function(){
checkconditions($(this).val(),$(this).attr("name"),'select-one','onchange');
});
$('#sortable-rank-'+qID+' li').removeClass("error");
$('#sortable-choice-'+qID+' li').removeClass("error");
$('#sortable-rank-'+qID+' li:gt('+(maxanswers*1-1)+')').addClass("error");
}

function sortableAlert (qID,showpopups)
Expand All @@ -124,6 +127,9 @@ function loadDragDropRank(qID){
$('#sortable-choice-'+qID+' li#choice_'+$(this).val()).appendTo('#sortable-rank-'+qID);
}
});
$('#sortable-rank-'+qID+' li').removeClass("error");
$('#sortable-choice-'+qID+' li').removeClass("error");
$('#sortable-rank-'+qID+' li:gt('+(maxanswers*1-1)+')').addClass("error");
}

// All choice at same height
Expand All @@ -140,7 +146,7 @@ function fixChoiceHeight(qID){
function fixListHeight(qID){
totalHeight=0;
$('.connectedSortable'+qID+' li').each(function(){
totalHeight=totalHeight+$(this).outerHeight();
totalHeight=totalHeight+$(this).outerHeight(true);
});
$('.connectedSortable'+qID).height(totalHeight);
}
Expand Down
21 changes: 14 additions & 7 deletions styles-public/ranking.css
Expand Up @@ -16,23 +16,30 @@
background: transparent none;
}

.dragDropTable .dragDropChoiceList,
.dragDropTable .dragDropRankList {
.dragDropTable ul.dragDropChoiceList,
.dragDropTable ol.dragDropRankList {
margin: 0;
padding: 0;
padding: 3px 0;
padding-bottom:2em;
list-style-type: none;
border: 1px solid #CCCCCC;
display: block; /* Force the li to full width */
}

.dragDropTable .dragDropChoiceList li,
.dragDropTable .dragDropRankList li {
.dragDropTable ul.dragDropChoiceList li,
.dragDropTable ol.dragDropRankList li {
margin: 3px;
margin-top:0;
padding: 3px;
min-height: 1.3em;
font-weight: normal;
cursor: move;
clear:both;
background-image: none;
}
.dragDropTable ul.dragDropChoiceList li.ui-sortable-placeholder,
.dragDropTable ol.dragDropRankList li.ui-sortable-placeholder {
border: 1px dotted #CCC;
}
.dragDropTable .error {
border-color: fuchsia;
}

84 changes: 37 additions & 47 deletions styles/blobblueish/attributeMap.css
Expand Up @@ -2,88 +2,78 @@ html, body{
height: 100%;
}
.main{
width: 1200px;
margin: 0 auto;
width: 1200px;
margin: 0 auto;
}
#sep{
margin-top: 10px;
}
#newcreated{

float : left;
background-color: #D2E0F2;
}
#centralattribute {
float : left;

.newcreate, .csvatt, .cpdbatt {
min-height: 100px;
padding-bottom: 50px;
}

#newcreated, #centralattribute, #tokenattribute{
float: left;
background-color: #D2E0F2;
height: 100%;

}
#tokenattribute {
float : left;
margin-top:10px;
margin-left: 30px;
margin-right: 30px;
margin-bottom: 20px;
border-color: blue;
border-style: solid;
border-radius: 10px;
border-width: 1px;
overflow : auto;
text-align:center;
width: 27%;
}
#newcreated, #tokenattribute {
height: 100%;
background-color: #D2E0F2;

}
.attrcol_3 {
width:27%;
}
.attrcol_2 {
width:44%;
.heading{
background: #EAF2FF;
text-decoration: none;
color:#5670A1;
border-width: 1px;
vertical-align: middle;
height: 23px;
padding-top: 7px;
font-weight: bold;
}


#controllingarea {
text-align: right;
margin-right: 30px;
}

.ui-sortable{
padding-left: 2% !important;
padding-right: 2% !important;
}
.tokenatt li{
border-color: #696565;
border-style:solid;
border-width:1px;
border-width:1px;
padding : 4px;
}
.newcreate ul{
padding : 100px;
}

#newcreated,#centralattribute,#tokenattribute{
margin-top:10px;
height: 100%;
margin-left: 30px;
margin-right: 30px;
margin-bottom: 20px;
border-color: blue;
border-style:solid;
border-width: 1px;
overflow : auto;
text-align:center;
}

.heading{
background: #EAF2FF;
text-decoration: none;
color:#5670A1;
border-width: 1px;
vertical-align: middle;

}
li{
border:solid 2px #DEDEDE;
background:#FFFFFF ;
color:#222222;
width : 200px;
margin-top: 2px;
margin-left: 10%;
margin-bottom: 2px;
list-style: none;
padding:4px;
text-align:center;
cursor: pointer;
}
.notsortable li{
background:#696565;
color: white;
}

0 comments on commit 31c5458

Please sign in to comment.