Commit fd88eead authored by Chenu Denis's avatar Chenu Denis
Browse files

[dev] Allow default in twig options (radio currently)

parent feda516d
......@@ -16,10 +16,10 @@
<supportUrl>https://extensions.sondages.pro/themes-and-templates/skelvanilla-a11y-and-usuability/</supportUrl>
<copyright>Copyright (C) 2018-2019 Denis Chenu / Sondages Pro</copyright>
<license>GNU General Public License version 3 or later</license>
<version>6.1.0</version>
<version>6.1.2</version>
<apiVersion>3</apiVersion>
<description><![CDATA[<strong>LimeSurvey Bootstrap Vanilla Survey Theme with Accessibility and Options</strong><br>Base on vanilla theme, usage of more aria, fix some role and aria from core.<br>Allow usage of a lot of variations, list of variation can be updated. Some decoration option using boostrap class.]]></description>
<last_update>2019-10-03 09:50:38</last_update>
<last_update>2019-10-07 08:54:59</last_update>
<extends>vanilla</extends>
</metadata>
......@@ -440,7 +440,7 @@
</navigation>
<token>
<screen_title type="data" role="title" twig="on"><![CDATA[ {{gT('Token')}} ]]></screen_title>
<screen_title type="data" role="title" twig="on"><![CDATA[ {{gT('Token')}} ]]></screen_title>
<file type="view" role="layout">layout_user_forms.twig</file>
<file type="view" role="content">./subviews/content/userforms.twig</file>
<file type="view" role="subview">./subviews/logincomponents/token.twig</file>
......@@ -454,8 +454,8 @@
<survey type="core">
<name type="data" twig="on"><![CDATA[ {{ gT("Template Sample") }} ]]></name>
<description type="data" twig="on"><![CDATA[<p>{{ gT('This is a sample survey description. It could be quite long.') }}</p><p>{{ gT("But this one isn't.") }}<p>]]></description>
<welcome type="data" twig="on"><![CDATA[<p>{{ gT('Welcome to this sample survey')}} <p> <p> {{ gT('You should have a great time doing this') }} <p> ]]></welcome>
<therearexquestions type="data" twig="on"><![CDATA[gT('There is 2 question in this survey'])]]></therearexquestions>
<welcome type="data" twig="on"><![CDATA[<p>{{ gT('Welcome to this sample survey')}} <p> <p> {{ gT('You should have a great time doing this') }} <p> ]]></welcome>
<therearexquestions type="data" twig="on"><![CDATA[gT('There is 2 question in this survey'])]]></therearexquestions>
<surveyls_url type="data" twig="on">"https://www.sondages.pro"</surveyls_url>
<surveyls_urldescription type="data" twig="on"><![CDATA[ gT("Some URL description") ]]></surveyls_urldescription>
<showsurveypolicynotice>2</showsurveypolicynotice>
......@@ -467,16 +467,16 @@
<description type="data" twig="on"><![CDATA[ {{ gT("This group description is fairly vacuous, but quite important.") }} ]]></description>
</group>
<question_1 type="core">
<code type="data" >'Q1 '</code>
<code type="data">'Q1 '</code>
<text type="data" twig="on"><![CDATA[ {{ gT("How many roads must a man walk down?") }} ]]></text>
<valid_message type="data" twig="on"><![CDATA[ <div id="vmsg_4496_num_answers" class="em_num_answers emtip error"><span class="fa fa-exclamation-circle" aria-hidden="true"></span> {{ gT("Choose one of the following answers") }} </div> ]]></valid_message>
</question_1>
<question_2 type="core">
<code type="data" >'Q2 '</code>
<code type="data">'Q2 '</code>
<text type="data" twig="on"><![CDATA[ {{ gT("Please explain something in detail:") }} ]]></text>
<valid_message type="data" twig="on"><![CDATA[<div id="vmsg_4496_num_answers" class="em_num_answers emtip error"><span class="fa fa-exclamation-circle" aria-hidden="true"></span> {{ gT("Hint when response is not valid") }} </div> ]]></valid_message>
</question_2>
<assessments type="core">
<assessments type="core">
<name type="data" twig="on"><![CDATA[ {{ gT("Welcome to the Assessment") }} ]]></name>
<message type="data" twig="on"><![CDATA[ {{ gT("You got {TOTAL} points out of 3 possible points.") }} ]]></message>
</assessments>
......
......@@ -39,7 +39,6 @@ var ThemeOptions = function(){
// Show/Hide fields on generalInherit
// To hide a simple option on generalInherit: just add the class "action_hide_on_inherit" to the rows continaing it
var startupGeneralInherit = function(){
if(!inheritPossible) return false;
if (generalInherit()){
......@@ -47,6 +46,7 @@ var ThemeOptions = function(){
$('.action_hide_on_inherit').addClass('hidden');
} else {
$('#general_inherit_off').prop('checked',true).trigger('change').closest('label').addClass('active');
}
};
......@@ -108,7 +108,6 @@ var ThemeOptions = function(){
fallbackValue = fallbackValue || false;
// If general inherit, then the value of the dropdown is inherit, else it's the value defined in advanced options
var itemValue = generalInherit() ? 'inherit' : optionObject[$(item).attr('name')];
// If anything goes wrong (manual edit or anything else), we make sure it will have a correct value
if(itemValue == null || itemValue == undefined){
itemValue = inheritPossible ? 'inherit' : fallbackValue;
......@@ -149,11 +148,13 @@ var ThemeOptions = function(){
// Generate the state of switches (On/Off/Inherit)
var parseParentSwitchFields = function(){
globalForm.find('.selector_option_radio_field').each(function(i,item){
var itemValue = parseOptionValue(item, 'off');
var defaultValue = 'off';
if($(item).closest('[role="radiogroup"]').length && $(item).closest('[role="radiogroup"]').data("default")) {
defaultValue = $(item).closest('[role="radiogroup"]').data("default");
}
var itemValue = parseOptionValue(item, defaultValue);
//if it is a radio selector, check it and propagate the change to bootstrapSwitch
if($(item).val() == itemValue){
if($(item).val() == itemValue || (itemValue == '' && $(item).data('default') ==1) ){
setAndPropageteToSwitch(item);
}
});
......@@ -179,7 +180,6 @@ var ThemeOptions = function(){
// If an option is set to off, the attached selectors are disabled
$('.selector_radio_childfield').each(function(i, selectorItem){
$('input[name='+$(selectorItem).data('parent')+']').on('change', function(){
if($(this).val() == 'on' && $(this).prop('checked') == true){
$(selectorItem).prop('disabled', false);
} else {
......@@ -215,6 +215,8 @@ var ThemeOptions = function(){
$('#general_inherit_off').on('change', function(evt){
$('.action_hide_on_inherit').removeClass('hidden');
updateFieldSettings();
// Didn't know where is set … remove it …
$("#theme-option-sidebody").height('auto');
});
};
......@@ -286,6 +288,7 @@ var ThemeOptions = function(){
parseParentSwitchFields();
//prepareFontField();
bind();
$("#theme-option-sidebody").height('auto');
};
return run;
......
......@@ -22,6 +22,30 @@
<div class="row">
{# Begin template option form #}
<form class='form action_update_options_string_form' action=''>
{# If this is a surveyspecific settings page, offer the possibility to do a full inheritance of the parent template #}
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
<h3 class="h3">{{ gT("Inherit") }}</h3>
<div class='row' id="general_inherit_active">
<div class='form-group row'>
<label for='simple_edit_options_general_inherit' class='control-label'>{{gT("Inherit everything" )}}</label>
<div class='col-sm-12'>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input id="general_inherit_on" name='general_inherit' type='radio' value='on' class='selector_option_general_inherit ' data-id='simple_edit_options_general_inherit'/>
{{ gT("Yes") }}
</label>
<label class="btn btn-default">
<input id="general_inherit_off" name='general_inherit' type='radio' value='off' class='selector_option_general_inherit ' data-id='simple_edit_options_general_inherit'/>
{{ gT("No") }}
</label>
</div>
</div>
</div>
</div>
<div class="row">
<hr/>
</div>
{% endif %}
{# If this is a surveyspecific settings page, offer the possibility to do a full inheritance of the parent template #}
{# CSS variation : #}
{% if oParentOptions.availablevariations is null %}
......@@ -30,9 +54,9 @@
{% set sAvailableVariations = oParentOptions.availablevariations %}
{% endif %}
{# Functionnal #}
<h3 class="h3">{{ gT("Functionnal") }}</h3>
<h3 class="h3 action_hide_on_inherit">{{ gT("Functionnal") }}</h3>
{# First settings row #}
<div class='row'>
<div class="row action_hide_on_inherit">
{# hideprivacyinfo #}
<div class='col-sm-12 col-md-6 col-lg-3'>
<div class='form-group row'>
......@@ -96,7 +120,7 @@
<div class='col-xs-8'>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input type='radio' name='questionhtag' value='on' class='selector_option_radio_field simple_edit_options_questionhtag ' data-id='questionhtag'/>
<input type='radio' name='questionhtag' value='on' class='selector_option_radio_field simple_edit_options_questionhtag ' data-id='questionhtag' data-default='1'/>
{{ gT("Yes") }}
</label>
<label class="btn btn-default">
......@@ -134,7 +158,7 @@
</div>
</div>
</div>
<div class ="row">
<div class ="row action_hide_on_inherit">
{# Set hash to disable previous navigator#}
<div class='col-sm-12 col-md-6 col-lg-3'>
<div class='form-group row'>
......@@ -196,25 +220,25 @@
</div>
</div>
</div>
<h3 class="h4">{{ gT("Top link actions") }}</h3>
<div class='row'>
<h3 class="h4 action_hide_on_inherit">{{ gT("Top link actions") }}</h3>
<div class="row action_hide_on_inherit">
<div class='col-sm-12 col-md-6 col-lg-3'>
<div class='form-group row'>
<label for='simple_edit_options_savelink' class='control-label col-xs-4'> {{ gT("Save header link") }} </label>
<div id='simple_edit_options_savelink' class='control-label col-xs-4'> {{ gT("Save header link") }} </div>
<div class='col-xs-8'>
<div class="btn-group" data-toggle="buttons">
<div class="btn-group" data-toggle="buttons" role='radiogroup' aria-labelledby='simple_edit_options_savelink' data-default='on'>
<label class="btn btn-default">
<input type='radio' name='savelink' value='on' class='selector_option_radio_field simple_edit_options_savelink ' data-id='savelink'/>
<input type='radio' name='savelink' value='on' class='selector_option_radio_field simple_edit_options_savelink ' data-id='savelink'>
{{ gT("Yes") }}
</label>
<label class="btn btn-default">
<input type='radio' name='savelink' value='off' class='selector_option_radio_field simple_edit_options_savelink ' data-id='savelink'/>
<input type='radio' name='savelink' value='off' class='selector_option_radio_field simple_edit_options_savelink ' data-id='savelink'>
{{ gT("No") }}
</label>
{# If this is a root template setting, don't show the inherit button #}
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
<label class="btn btn-default">
<input type='radio' name='savelink' value='inherit' class='selector_option_radio_field simple_edit_options_savelink ' data-id='savelink'/>
<input type='radio' name='savelink' value='inherit' class='selector_option_radio_field simple_edit_options_savelink ' data-id='savelink'>
{{ gT("Inherit") }}
</label>
{% endif %}
......@@ -224,21 +248,21 @@
</div>
<div class='col-sm-12 col-md-6 col-lg-3'>
<div class='form-group row'>
<label for='simple_edit_options_clearalllink' class='control-label col-xs-4'> {{ gT("Clear all header link") }} </label>
<label id='simple_edit_options_clearalllink' class='control-label col-xs-4'> {{ gT("Clear all header link") }} </label>
<div class='col-xs-8'>
<div class="btn-group" data-toggle="buttons">
<div class="btn-group" data-toggle="buttons" role='radiogroup' aria-labelledby='simple_edit_options_clearalllink' data-default='on'>
<label class="btn btn-default">
<input type='radio' name='clearalllink' value='on' class='selector_option_radio_field simple_edit_options_clearalllink ' data-id='clearalllink'/>
<input type='radio' name='clearalllink' value='on' class='selector_option_radio_field simple_edit_options_clearalllink ' data-id='clearalllink'>
{{ gT("Yes") }}
</label>
<label class="btn btn-default">
<input type='radio' name='clearalllink' value='off' class='selector_option_radio_field simple_edit_options_clearalllink ' data-id='clearalllink'/>
<input type='radio' name='clearalllink' value='off' class='selector_option_radio_field simple_edit_options_clearalllink ' data-id='clearalllink'>
{{ gT("No") }}
</label>
{# If this is a root template setting, don't show the inherit button #}
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
<label class="btn btn-default">
<input type='radio' name='clearalllink' value='inherit' class='selector_option_radio_field simple_edit_options_clearalllink ' data-id='clearalllink'/>
<input type='radio' name='clearalllink' value='inherit' class='selector_option_radio_field simple_edit_options_clearalllink ' data-id='clearalllink'>
{{ gT("Inherit") }}
</label>
{% endif %}
......@@ -248,21 +272,21 @@
</div>
<div class='col-sm-12 col-md-6 col-lg-3'>
<div class='form-group row'>
<label for='simple_edit_options_indexlink' class='control-label col-xs-4'> {{ gT("Index header links") }} </label>
<label id='simple_edit_options_indexlink' class='control-label col-xs-4'> {{ gT("Index header links") }} </label>
<div class='col-xs-8'>
<div class="btn-group" data-toggle="buttons">
<div class="btn-group" data-toggle="buttons" role='radiogroup' aria-labelledby='simple_edit_options_indexlink' data-default='on'>
<label class="btn btn-default">
<input type='radio' name='indexlink' value='on' class='selector_option_radio_field simple_edit_options_indexlink ' data-id='indexlink'/>
<input type='radio' name='indexlink' value='on' class='selector_option_radio_field simple_edit_options_indexlink ' data-id='indexlink'>
{{ gT("Yes") }}
</label>
<label class="btn btn-default">
<input type='radio' name='indexlink' value='off' class='selector_option_radio_field simple_edit_options_indexlink ' data-id='indexlink'/>
<input type='radio' name='indexlink' value='off' class='selector_option_radio_field simple_edit_options_indexlink ' data-id='indexlink'>
{{ gT("No") }}
</label>
{# If this is a root template setting, don't show the inherit button #}
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
<label class="btn btn-default">
<input type='radio' name='indexlink' value='inherit' class='selector_option_radio_field simple_edit_options_indexlink ' data-id='indexlink'/>
<input type='radio' name='indexlink' value='inherit' class='selector_option_radio_field simple_edit_options_indexlink ' data-id='indexlink'>
{{ gT("Inherit") }}
</label>
{% endif %}
......@@ -272,21 +296,21 @@
</div>
<div class='col-sm-12 col-md-6 col-lg-3'>
<div class='form-group row'>
<label for='simple_edit_options_languagelink' class='control-label col-xs-4'> {{ gT("Langage changer header links") }} </label>
<label id='simple_edit_options_languagelink' class='control-label col-xs-4'> {{ gT("Langage changer header links") }} </label>
<div class='col-xs-8'>
<div class="btn-group" data-toggle="buttons">
<div class="btn-group" data-toggle="buttons" role='radiogroup' aria-labelledby='simple_edit_options_languagelink' data-default='on'>
<label class="btn btn-default">
<input type='radio' name='languagelink' value='on' class='selector_option_radio_field simple_edit_options_languagelink ' data-id='languagelink'/>
<input type='radio' name='languagelink' value='on' class='selector_option_radio_field simple_edit_options_languagelink ' data-id='languagelink'>
{{ gT("Yes") }}
</label>
<label class="btn btn-default">
<input type='radio' name='languagelink' value='off' class='selector_option_radio_field simple_edit_options_languagelink ' data-id='languagelink'/>
<input type='radio' name='languagelink' value='off' class='selector_option_radio_field simple_edit_options_languagelink ' data-id='languagelink'>
{{ gT("No") }}
</label>
{# If this is a root template setting, don't show the inherit button #}
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
<label class="btn btn-default">
<input type='radio' name='languagelink' value='inherit' class='selector_option_radio_field simple_edit_options_languagelink ' data-id='languagelink'/>
<input type='radio' name='languagelink' value='inherit' class='selector_option_radio_field simple_edit_options_languagelink ' data-id='languagelink'>
{{ gT("Inherit") }}
</label>
{% endif %}
......@@ -295,12 +319,12 @@
</div>
</div>
</div>
<div class='row'>
<div class="row action_hide_on_inherit">
<hr/>
</div>
<h3 class="h3">{{ gT("Visual") }}</h3>
<div class='row'>
<h3 class="h3 action_hide_on_inherit">{{ gT("Visual") }}</h3>
<div class="row action_hide_on_inherit">
<div class='col-sm-12'>
<div class='panel panel-default'>
<div class='panel-heading'>{{ sprintf( gT("%s variations"), templateConfiguration.template_name) }} </div>
......@@ -340,7 +364,7 @@
</div>
</div>
</div>
<div class='row'>
<div class="row action_hide_on_inherit">
{# Container #}
<div class='col-sm-12 col-md-6 col-lg-3'>
<div class='form-group row'>
......@@ -423,7 +447,7 @@
</div>
</div>
</div>
<div class='row'>
<div class="row action_hide_on_inherit">
{# Help color #}
<div class='col-sm-12 col-md-6 col-lg-3'>
<div class='form-group row'>
......@@ -464,7 +488,7 @@
</div>
</div>
<div class='row'>
<div class="row action_hide_on_inherit">
{# Fixed header #}
<div class='col-sm-12 col-md-6 col-lg-3'>
<div class='form-group row'>
......@@ -521,13 +545,13 @@
</div>
</div>
<div class='row'>
<div class="row action_hide_on_inherit">
<hr/>
</div>
<!-- Brand Logo -->
<h3 class="h3">{{ gT("Logos") }}</h3>
<div class='row'>
<h3 class="h3 action_hide_on_inherit">{{ gT("Logos") }}</h3>
<div class="row action_hide_on_inherit">
<div class='col-sm-12 col-md-4'>
{# Brandlogo #}
<div class='form-group row'>
......@@ -588,7 +612,7 @@
</div>
<!-- Survey list Logo -->
<div class='row'>
<div class="row action_hide_on_inherit">
<div class='col-sm-12 col-md-4'>
{# Survey list #}
<div class='form-group row'>
......@@ -648,7 +672,7 @@
</div>
<!-- Powered Logo -->
<div class='row'>
<div class="row action_hide_on_inherit">
<div class='col-sm-12 col-md-4'>
{# Survey list #}
<div class='form-group row'>
......@@ -707,7 +731,7 @@
</div>
</div>
<!-- Powered link , leave it for allowing usage in footer for example -->
<div class='row'>
<div class="row action_hide_on_inherit">
<div class='col-xs-12 col-sm-6'>
<div class='form-group row'>
<label for='simple_edit_options_poweredlink' class='control-label col-xs-6'>Powered link</label>
......@@ -735,10 +759,10 @@
</div>
</form>
</div>
<div class='row'>
<div class="row action_hide_on_inherit">
<hr/>
</div>
<div class='row'>
<div class="row action_hide_on_inherit">
{# Upload an image #}
<div class="container-fluid ls-space margin bottom-15">
<div class="row ls-space margin bottom-15">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment