Refactoring expand scripts

This commit is contained in:
Georgy Litvinov 2021-03-02 15:01:26 +01:00
parent e9597bc1c0
commit 91bb723cbe
2 changed files with 11 additions and 8 deletions

View file

@ -169,11 +169,11 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/themes/iph/js/co
</#list> </#list>
<#if excerptText?? && excerptTextName?? && excerptTextName?has_content && excerptText?has_content> <#if excerptText?? && excerptTextName?? && excerptTextName?has_content && excerptText?has_content>
<button type="button" style="border:none;padding: 18px;width: 100%; text-align:left;" class="collapsible">${excerptTextName}</button> <button type="button" style="border:none;padding: 18px;width: 100%; text-align:left;" class="collapsible">${excerptTextName}</button>
<div class="htmlExcerpt" style="list-style:none; display:none;"> <div class="autoExpand htmlExcerpt" style="list-style:none; display:none;">
${excerptText} ${excerptText}
<#if works?? && works?has_content && worksCounter?number &gt; 0 > <#if works?? && works?has_content && worksCounter?number &gt; 0 >
<button type="button" class="collapsible" style="background-color:white;border:none;padding: 18px;width: 100%;text-align:left; background-image: url(${urls.base}/themes/iph/images/book_icon.png); background-repeat: no-repeat; background-position: left center;">Источники</button> <button type="button" class="collapsible" style="background-color:white;border:none;padding: 18px;width: 100%;text-align:left; background-image: url(${urls.base}/themes/iph/images/book_icon.png); background-repeat: no-repeat; background-position: left center;">Источники</button>
<div class="works" style="display:none;"> <div class="autoExpand works" style="display:none;">
<#list works as work> <#list works as work>
<#if work.elenphExcerpt == order.elenphExcerpt > <#if work.elenphExcerpt == order.elenphExcerpt >
<div class="work" style="display:list-item;list-style-image:url(${urls.base}/themes/iph/images/bullet_icon.png); font-style: italic; font-family: PT Serif;"> <div class="work" style="display:list-item;list-style-image:url(${urls.base}/themes/iph/images/bullet_icon.png); font-style: italic; font-family: PT Serif;">
@ -186,7 +186,7 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/themes/iph/js/co
<#if bibliography?? && bibliography?has_content && bibliographyCounter?number &gt; 0> <#if bibliography?? && bibliography?has_content && bibliographyCounter?number &gt; 0>
<button type="button" class="collapsible" style="background-color:white;border:none;padding: 18px;width: 100%; text-align: left; background-image: url(${urls.base}/themes/iph/images/book_icon.png); background-repeat: no-repeat; background-position: left center;">Литература</button> <button type="button" class="collapsible" style="background-color:white;border:none;padding: 18px;width: 100%; text-align: left; background-image: url(${urls.base}/themes/iph/images/book_icon.png); background-repeat: no-repeat; background-position: left center;">Литература</button>
<div class="bibliography" style="display:none;"> <div class="autoExpand bibliography" style="display:none;">
<#list bibliography as one_bibliography> <#list bibliography as one_bibliography>
<#if one_bibliography.elenphExcerpt == order.elenphExcerpt > <#if one_bibliography.elenphExcerpt == order.elenphExcerpt >
<div class="bibliography_entry" style="display:list-item;list-style-image:url(${urls.base}/themes/iph/images/bullet_icon.png); font-style: italic; font-family: PT Serif;"> <div class="bibliography_entry" style="display:list-item;list-style-image:url(${urls.base}/themes/iph/images/bullet_icon.png); font-style: italic; font-family: PT Serif;">
@ -206,7 +206,7 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/themes/iph/js/co
<#if works?? && works?has_content> <#if works?? && works?has_content>
<button type="button" class="collapsible" style="border: none; color: #8B4513; padding: 18px;width: 100%;text-align:left; background-color: #ffffff; background-image: url(${urls.base}/themes/iph/images/book_icon.png); background-repeat: no-repeat; background-position: left center;">Источники</button> <button type="button" class="collapsible" style="border: none; color: #8B4513; padding: 18px;width: 100%;text-align:left; background-color: #ffffff; background-image: url(${urls.base}/themes/iph/images/book_icon.png); background-repeat: no-repeat; background-position: left center;">Источники</button>
<div class="works" style="display:block;"> <div class="autoExpand works" style="display:block;">
<#list works as work> <#list works as work>
<div class="work" style="display:list-item;list-style-image:url(${urls.base}/themes/iph/images/bullet_icon.png); font-style: italic; font-family: PT Serif;"> <div class="work" style="display:list-item;list-style-image:url(${urls.base}/themes/iph/images/bullet_icon.png); font-style: italic; font-family: PT Serif;">
<p> ${work.works} </p> <p> ${work.works} </p>
@ -217,7 +217,7 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/themes/iph/js/co
<#if bibliography?? && bibliography?has_content> <#if bibliography?? && bibliography?has_content>
<button type="button" class="collapsible" style="border:none; color: #8B4513; padding: 18px;width: 100%; text-align: left; background-color: #ffffff; background-image: url(${urls.base}/themes/iph/images/book_icon.png); background-repeat: no-repeat; background-position: left center;">Литература</button> <button type="button" class="collapsible" style="border:none; color: #8B4513; padding: 18px;width: 100%; text-align: left; background-color: #ffffff; background-image: url(${urls.base}/themes/iph/images/book_icon.png); background-repeat: no-repeat; background-position: left center;">Литература</button>
<div class="bibliography" style="display:block;"> <div class="autoExpand bibliography" style="display:block;">
<#list bibliography as one_bibliography> <#list bibliography as one_bibliography>
<div class="bibliography_entry" style="display:list-item;list-style-image:url(${urls.base}/themes/iph/images/bullet_icon.png); font-style: italic; font-family: PT Serif;"> <div class="bibliography_entry" style="display:list-item;list-style-image:url(${urls.base}/themes/iph/images/bullet_icon.png); font-style: italic; font-family: PT Serif;">
<p> ${one_bibliography.bibliography} </p> <p> ${one_bibliography.bibliography} </p>

View file

@ -19,16 +19,19 @@ function addCollapsibleOnClick(){
function expandAllCollapsedElements(){ function expandAllCollapsedElements(){
console.log(localStorage.getItem('switchExpand')); console.log(localStorage.getItem('switchExpand'));
if (localStorage.getItem('switchExpand') === true || localStorage.getItem('switchExpand') === 'true') { if (localStorage.getItem('switchExpand') === true || localStorage.getItem('switchExpand') === 'true') {
$('.htmlExcerpt').show(); $('.autoExpand').show();
} else {
$('.autoExpand').hide();
} }
} }
function switchExpand(){ function switchExpand(){
var checkBox = document.getElementById("expandlCB"); var checkBox = document.getElementById("expandlCB");
if (checkBox.checked == true){ if (checkBox.checked == true){
$('.htmlExcerpt').show(); $('.autoExpand').show();
localStorage.setItem('switchExpand',true); localStorage.setItem('switchExpand',true);
} else { } else {
$('.htmlExcerpt').hide(); $('.autoExpand').hide();
localStorage.setItem('switchExpand',false); localStorage.setItem('switchExpand',false);
} }
} }