From e7c93b07665cf9e1e78f4a94648f59aff3fd093b Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Fri, 7 Oct 2016 10:01:16 +0200 Subject: [PATCH] Dev: rework a little index system (group by group) --- application/config/internal.php | 9 ++++--- .../limesurvey/{ls-public.css => survey.css} | 11 +++++++++ .../core/packages/limesurvey/survey.js | 24 +++++++++++++++++++ application/helpers/SurveyRuntimeHelper.php | 16 ++++++------- scripts/survey_runtime.js | 19 +-------------- 5 files changed, 49 insertions(+), 30 deletions(-) rename application/core/packages/limesurvey/{ls-public.css => survey.css} (85%) create mode 100644 application/core/packages/limesurvey/survey.js diff --git a/application/config/internal.php b/application/config/internal.php index 6aad22e2df4..f0b0c67c087 100644 --- a/application/config/internal.php +++ b/application/config/internal.php @@ -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'), @@ -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', diff --git a/application/core/packages/limesurvey/ls-public.css b/application/core/packages/limesurvey/survey.css similarity index 85% rename from application/core/packages/limesurvey/ls-public.css rename to application/core/packages/limesurvey/survey.css index d5159ff41ee..2fcbece8e8c 100644 --- a/application/core/packages/limesurvey/ls-public.css +++ b/application/core/packages/limesurvey/survey.css @@ -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;} diff --git a/application/core/packages/limesurvey/survey.js b/application/core/packages/limesurvey/survey.js new file mode 100644 index 00000000000..64588f09e16 --- /dev/null +++ b/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 + * @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); + +} diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index 9cbd3c85d83..74f317a2268 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -33,19 +33,17 @@ protected function createFullQuestionIndexByGroupMenu($LEMsessid) $htmlButtons = array(); $html = ''; $html .= "\n\n\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").' ', 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'], @@ -53,10 +51,8 @@ protected function createFullQuestionIndexByGroupMenu($LEMsessid) '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'); } @@ -333,13 +329,15 @@ protected function createIncrementalQuestionIndex($LEMsessid, $surveyMode) echo "
"; echo "$v"; echo "$sText"; - 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 "
"; } 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 ''; diff --git a/scripts/survey_runtime.js b/scripts/survey_runtime.js index 502061f45d3..1179ee67425 100644 --- a/scripts/survey_runtime.js +++ b/scripts/survey_runtime.js @@ -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