Skip to content

Commit

Permalink
Dev: edit subquestion, few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Mar 3, 2016
1 parent e6e426b commit b2c6cfe
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 38 deletions.
10 changes: 5 additions & 5 deletions application/views/admin/htmleditor/pop_editor_view.php
Expand Up @@ -35,10 +35,10 @@ function closeme()
var sReplacementFieldButton = '<?php eT('Insert/edit LimeSurvey replacement field','js');?>';
$(document).ready(function(){
//console.log('iGroupId: '+iGroupId);
// Better use try/catch to not crash JS completely
/*
try{ console.log('iGroupId: '+iGroupId); } catch (e){ console.log(e); }
*/
// Better use try/catch to not crash JS completely
/*
try{ console.log('iGroupId: '+iGroupId); } catch (e){ console.log(e); }
*/
CKEDITOR.on('instanceReady',CKeditor_OnComplete);
var oCKeditor = CKEDITOR.replace( 'MyTextarea' , { height : '350',
width : '98%',
Expand Down Expand Up @@ -98,7 +98,7 @@ function close_editor()
html_transfert();

window.opener.document.getElementsByName('<?php echo $sFieldName; ?>')[0].readOnly= false;
window.opener.document.getElementsByName('<?php echo $sFieldName; ?>')[0].className='htmlinput form-control ';
window.opener.document.getElementsByName('<?php echo $sFieldName; ?>')[0].className='htmlinput form-control input-lg';
window.opener.document.getElementById('<?php echo $sControlIdEna; ?>').style.display='';
window.opener.document.getElementById('<?php echo $sControlIdDis; ?>').style.display='none';
window.opener.focus();
Expand Down
Expand Up @@ -97,7 +97,7 @@
<!-- Headers -->
<thead>
<tr>
<th>
<th class="col-md-1">
<?php if( $first && $activated != 'Y'): ?>
<?php eT("Position");?>
<?php else: ?>
Expand All @@ -111,14 +111,13 @@
<th>
<?php eT("Subquestion"); ?>
</th>
<?php if ($activated != 'Y' && $first): ?>
<th>
<?php if ($first): ?>
<th class="col-md-1">
<?php eT("Action"); ?>
</th>
<?php endif; ?>
<?php if ($scale_id==0): ?>
<th class="relevancehead">
<?php // eT("Edit subquestion relevance") ?>
<th class="relevancehead" class="col-md-1">
<span class="icon-conditions"></span>
<span style="display: none" class="relevance">
<?php eT("Relevance"); ?>
Expand Down
Expand Up @@ -48,7 +48,7 @@ function start_popup_editor(fieldname, fieldtext, sid, gid, qid, fieldtype, acti
if (activepopup == null)
{
document.getElementsByName(fieldname)[0].readOnly=true;
document.getElementsByName(fieldname)[0].className='readonly form-control';
document.getElementsByName(fieldname)[0].className='readonly form-control input-lg';
document.getElementById(controlidena).style.display='none';
document.getElementById(controliddis).style.display='';

Expand Down
47 changes: 20 additions & 27 deletions scripts/admin/subquestions.js
Expand Up @@ -108,43 +108,36 @@ function addinput()
var sID=$('input[name=sid]').val();
var gID=$('input[name=gid]').val();
var qID=$('input[name=qid]').val();

var x;
console.log('classes: '+$(this).parent().parent().attr('class'));
classes=$(this).parent().parent().attr('class').split(' ');


for (x in classes)
{
if (classes[x].substr(0,3)=='row'){
position=classes[x].substr(4);
}
}
console.log('position:'+position);

scale_id=removechars($(this).closest('table').attr('id'));
newposition = Number($(this).closest('tr').parent().children().index($(this).closest('tr')))+1;

languages=langs.split(';');
sNextCode=getNextCode($(this).data('code'));

console.log('sNextCode: '+sNextCode);
console.log('before while');

sNextCode=getNextCode($(this).parent().parent().find('.code').val());

console.log('sNextCode: '+sNextCode);
console.log('languages: '+languages);
classes=$(this).parent().parent().attr('class').split(' ');
for (x in classes)
{
if (classes[x].substr(0,3)=='row')
{
position=classes[x].substr(4);
}
}

console.log('position:'+position);
//newposition = Number($(this).closest('tr').parent().children().index($(this).closest('tr')))+1;
newposition = Number($('#rowcontainer').find('tr').index($(this).closest('tr')))+1;
console.log('newposition: '+newposition);
info=$(this).closest('table').attr('id').split("_");
language=info[1];
scale_id=info[2];
newposition=Number(position)+1;


languages=langs.split(';');

sNextCode=getNextCode($(this).parent().parent().find('.code').val());
Expand All @@ -171,7 +164,7 @@ function addinput()
}

// Line insertion
inserthtml= '<tr id="row_'+newposition+'" style="">';
inserthtml= '<tr id="row_'+newposition+'" class="row_'+newposition+'" style="">';
inserthtml+=' <td style="vertical-align: middle;">';
inserthtml+=' <span class="glyphicon glyphicon-move"></span>';
inserthtml+=' </td>';
Expand All @@ -180,7 +173,7 @@ function addinput()
inserthtml+=' </td>';

inserthtml+=' <td style="vertical-align: middle;">';
inserthtml+=' <div class="col-sm-12">';
inserthtml+=' <div class="">';
inserthtml+=' <input type="text" size="20" id="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" name="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" class="answer form-control input-lg" placeholder="'+htmlspecialchars(newansweroption_text)+'" value=""></input>';
inserthtml+=' </div>';
inserthtml+=' </td>';
Expand Down Expand Up @@ -216,12 +209,12 @@ function addinput()
relbutton+=' </a>';
relbutton+='</td>';
}
inserthtml ='<tr id="row_'+newposition+'" style="display:none;">';
inserthtml ='<tr id="row_'+newposition+'" class="row_'+newposition+'" style="display:none;">';
inserthtml+=' <td>&nbsp;</td>';
inserthtml+=' <td>'+htmlspecialchars(sNextCode)+'</td>';

inserthtml+=' <td style="vertical-align: middle;">';
inserthtml+=' <div class="col-sm-12">';
inserthtml+=' <div class="">';
inserthtml+=' <input type="text" size="0" id="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" name="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" class="answer form-control input-lg" placeholder="'+htmlspecialchars(newansweroption_text)+'" value="" />';
inserthtml+=' </div>';
inserthtml+=' </td>' + relbutton + '</tr>';
Expand Down Expand Up @@ -673,7 +666,7 @@ function transferlabels()
' </td>'+

' <td>'+
' <div class="col-sm-12">'+
' <div class="">'+
' <input type="text" size="20" id="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" name="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" class="answer form-control input-lg" value="'+htmlspecialchars(lsrows[k].title)+'"></input>'+
' </div>'+
' </td>'+
Expand All @@ -699,7 +692,7 @@ function transferlabels()
' <td>'+htmlspecialchars(lsrows[k].code)+'</td>'+

' <td style="vertical-align: middle;">'+
' <div class="col-sm-12">'+
' <div class="">'+
' <input type="text" size="20" id="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" name="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" class="answer form-control input-lg" value="'+htmlspecialchars(lsrows[k].title)+'"></input>'+
' </div>'+
' </td>'+
Expand Down Expand Up @@ -729,7 +722,7 @@ function transferlabels()
' <td>'+htmlspecialchars(lsrows[k].code)+'</td>'+

' <td style="vertical-align: middle;">'+
' <div class="col-sm-12">'+
' <div class="">'+
' <input type="text" size="20" id="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" name="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" class="answer form-control input-lg" value="'+htmlspecialchars(lsrows[k].title)+'"></input>'+
' </div>'+
' </td>'+
Expand Down Expand Up @@ -830,7 +823,7 @@ function quickaddlabels()
if (x==0)
{
tablerows=tablerows+
'<tr id="row_'+k+'" >'+
'<tr id="row_'+k+'" class="row_'+k+'">'+
' <td>'+
' <span class="glyphicon glyphicon-move text-success"></span>'+
' </td>'+
Expand All @@ -847,7 +840,7 @@ function quickaddlabels()
' </td>'+

' <td style="vertical-align: middle;">'+
' <div class="col-sm-12">'+
' <div class="">'+
' <input type="text" size="20" id="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" name="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" class="answer form-control input-lg" value="'+htmlspecialchars(thisrow[parseInt(x)+1],'ENT_QUOTES')+'"></input>'+
' </div>'+
' </td>'+
Expand All @@ -870,12 +863,12 @@ function quickaddlabels()
{

tablerows=tablerows+
'<tr id="row_'+k+'" >'+
'<tr id="row_'+k+'" class="row_'+k+'" >'+
' <td>&nbsp;</td>'+
' <td>&nbsp;</td>'+

' <td style="vertical-align: middle;">'+
' <div class="col-sm-12">'+
' <div class="">'+
' <input type="text" size="20" id="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" name="answer_'+languages[x]+'_'+randomid+'_'+scale_id+'" class="answer form-control input-lg" value="'+htmlspecialchars(thisrow[parseInt(x)+1],'ENT_QUOTES')+'"></input>'+
' </div>'+
' </td>'+
Expand Down

0 comments on commit b2c6cfe

Please sign in to comment.