Skip to content

Commit

Permalink
Dev: rework a little index system (group by group)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Oct 7, 2016
1 parent 66667fb commit e7c93b0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 30 deletions.
9 changes: 6 additions & 3 deletions application/config/internal.php
Expand Up @@ -42,7 +42,7 @@
'aliases' => array(
// Third party path
'third_party' => realpath(__DIR__ . '/../../third_party'),
'limesurvey-core' => realpath(__DIR__ . '/../../application/core/packages'),
'core' => realpath(__DIR__ . '/../../application/core/packages'),

// yiistrap configuration
'bootstrap' => realpath(__DIR__ . '/../extensions/bootstrap'),
Expand Down Expand Up @@ -100,9 +100,12 @@
require('third_party.php'),
array(
'limesurvey-public'=>array(
'basePath' => 'limesurvey-core.limesurvey',
'basePath' => 'core.limesurvey',
'css'=> array(
'ls-public.css'
'survey.css',
),
'js'=>array(
'survey.js',
),
'depends' => array(
'bootstrap',
Expand Down
Expand Up @@ -15,6 +15,17 @@
*/
.js .ls-js-hidden{display: none !important;}
.no-js .ls-no-js-hidden{display: none !important;}

/* Using http://webaim.org/techniques/css/invisiblecontent/ technique : better with less part (to be more easily updatable by template ? : can use initial) */
.js .ls-js-hidden-sr{
position:absolute;
left:-10000px;
top:auto;
width:1px;
height:1px;
overflow:hidden;
}

/* For relanceOnOff ? */
.ls-irrelevant {display: none !important;}

Expand Down
24 changes: 24 additions & 0 deletions application/core/packages/limesurvey/survey.js
@@ -0,0 +1,24 @@
/**
* @file Javascript core function for public survey
* @description loaded before template javascript : allow template to use own function (if function is called after template.js)
* @copyright LimeSurvey <http://www.limesurvey.org/>
* @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
*/

/**
* Manage the index
*/
function manageIndex(){
$("#index").on('click','li,.row',function(e){
if(!$(e.target).is('button')){
$(this).children("[name='move']").click();
}
});
$(".outerframe").addClass("withindex");// Did we need it ? Another class name ? Can not be added directly to body like showprogress showqnumcode- etc ?
//~ Don't know what this part done : comment before remove
//~ var idx = $("#index");
//~ var row = $("#index .row.current");
//~ if(row.length)
//~ idx.scrollTop(row.position().top - idx.height() / 2 - row.height() / 2);

}
16 changes: 7 additions & 9 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -33,30 +33,26 @@ protected function createFullQuestionIndexByGroupMenu($LEMsessid)
$htmlButtons = array();
$html = '';
$html .= "\n\n<!-- PRESENT THE INDEX MENU (full) -->\n";
$html .= CHtml::openTag('li', array('id' => 'index-menu', 'class'=>'dropdown index-menu-incremental-full'));
$html .= CHtml::openTag('li', array('id' => 'index-menu', 'class'=>'dropdown ls-no-js-hidden index-menu-incremental-full'));
$html .= CHtml::link(gT("Question index").'&nbsp;<span class="caret"></span>', array('#'), array('class'=>'dropdown-toggle', 'data-toggle'=>"dropdown", 'role'=>"button", 'aria-haspopup'=>"true", 'aria-expanded'=>"false"));
$html .= CHtml::openTag('ul', array('class'=>'dropdown-menu'));
foreach ($_SESSION[$LEMsessid]['grouplist'] as $key => $group)
{

if (LimeExpressionManager::GroupIsRelevant($group['gid']))
{
$group['step'] = $key + 1;
$active = ($_SESSION[$LEMsessid]['step'] == $group['step']) ? 'current active' : '';
$classes = ' linkToButton ';
$sButtonSubmit=CHtml::htmlButton(gT('Go to this group'),array('id'=>'button-'.$group['gid'],'type'=>'submit','value'=>$group['step'],'name'=>'move','class'=>'jshide'));

$sButtonSubmit=CHtml::htmlButton(gT('Go to this group'),array('id'=>'button-'.$group['gid'],'type'=>'submit','value'=>$group['step'],'name'=>'move','class'=>'btn btn-default btn-sm ls-js-hidden-sr'));
// Button
$htmlButtons[] = CHtml::tag('li', array(
'data-gid' => $group['gid'],
'title' => $group['description'],
'class' => $classes,
), $group['group_name'].$sButtonSubmit);



$html .= CHtml::openTag('li', array('class'=>$active));
$html .= CHtml::link($group['group_name'], array('#'), array('class'=>$classes, 'data-button-to-click'=>'#button-'.$group['gid'], ));
$html .= CHtml::link($group['group_name'], array("survey/index",'sid'=>str_replace("survey_","",$LEMsessid),'move'=>$group['step']), array('class'=>$classes, 'data-button-to-click'=>'#button-'.$group['gid'], ));
$html .= CHtml::closeTag('li');

}
Expand Down Expand Up @@ -333,13 +329,15 @@ protected function createIncrementalQuestionIndex($LEMsessid, $surveyMode)
echo "<div class=\"row $class\">";
echo "<span class=\"hdr\">$v</span>";
echo "<span title=\"$sText\">$sText</span>";
echo CHtml::htmlButton($sButtonText,array('type'=>'submit','value'=>$s,'name'=>'move','class'=>'jshide', 'id'=> 'button-'.$g['gid']));
if($n != $_SESSION[$LEMsessid]['step'] - 1){
echo CHtml::htmlButton($sButtonText,array('type'=>'submit','value'=>$s,'name'=>'move','class'=>'btn btn-default btn-sm ls-js-hidden-sr', 'id'=> 'button-'.$g['gid']));
}
echo "</div>";
}

if ($_SESSION[$LEMsessid]['maxstep'] == $_SESSION[$LEMsessid]['totalsteps'])
{
echo CHtml::htmlButton(gT('Submit'),array('type'=>'submit','value'=>'movesubmit','name'=>'move','class'=>'submit button'));
echo CHtml::htmlButton(gT('Submit'),array('type'=>'submit','value'=>'movesubmit','name'=>'move','class'=>'btn submit button'));
}

echo '</div></div>';
Expand Down
19 changes: 1 addition & 18 deletions scripts/survey_runtime.js
Expand Up @@ -324,24 +324,7 @@ function activateLanguageChanger(){
$(".changelang.jshide").hide();
});
}
/**
* Manage the index
*/
function manageIndex(){
$("#index .jshide").hide();
$("#index").on('click','li,.row',function(e){
if(!$(e.target).is('button')){
$(this).children("[name='move']").click();
}
});
$(function() {
$(".outerframe").addClass("withindex");
var idx = $("#index");
var row = $("#index .row.current");
if(row.length)
idx.scrollTop(row.position().top - idx.height() / 2 - row.height() / 2);
});
}

/**
* Put a empty class on empty answer text item (limit to answers part)
* @author Denis Chenu / Shnoulle
Expand Down

0 comments on commit e7c93b0

Please sign in to comment.