Split expand switch into two: setttings switch and one-time switch
This commit is contained in:
parent
00330d288b
commit
20e8f32100
4 changed files with 89 additions and 73 deletions
|
@ -1,7 +1,7 @@
|
|||
document.addEventListener('DOMContentLoaded', addCollapsibleOnClick(), false);
|
||||
document.addEventListener('DOMContentLoaded', expandAllCollapsedElements(), false);
|
||||
|
||||
function addCollapsibleOnClick(){
|
||||
function addCollapsibleOnClick() {
|
||||
var coll = document.getElementsByClassName("collapsible");
|
||||
var i;
|
||||
for (i = 0; i < coll.length; i++) {
|
||||
|
@ -16,23 +16,39 @@ function addCollapsibleOnClick(){
|
|||
});
|
||||
}
|
||||
}
|
||||
function expandAllCollapsedElements(){
|
||||
function expandAllCollapsedElements() {
|
||||
if (localStorage.getItem('switchExpand') === true || localStorage.getItem('switchExpand') === 'true') {
|
||||
document.getElementById("expandCB").checked = true;
|
||||
var expandSwitchCB = document.getElementById("expandCB");
|
||||
if ( expandSwitchCB != null ){
|
||||
expandSwitchCB.checked = true;
|
||||
}
|
||||
var expandSwitchSettingsCB = document.getElementById("expandSettingsCB");
|
||||
if ( expandSwitchSettingsCB != null ){
|
||||
expandSwitchSettingsCB.checked = true;
|
||||
}
|
||||
|
||||
$('.autoExpand').show();
|
||||
} else {
|
||||
$('.autoExpand').hide();
|
||||
}
|
||||
|
||||
}
|
||||
function switchExpand(){
|
||||
|
||||
function switchExpand() {
|
||||
var checkBox = document.getElementById("expandCB");
|
||||
if (checkBox.checked == true){
|
||||
if (checkBox.checked == true) {
|
||||
$('.autoExpand').show();
|
||||
localStorage.setItem('switchExpand',true);
|
||||
localStorage.setItem('switchExpand', true);
|
||||
} else {
|
||||
$('.autoExpand').hide();
|
||||
localStorage.setItem('switchExpand',false);
|
||||
}
|
||||
localStorage.setItem('switchExpand', false);
|
||||
}
|
||||
}
|
||||
|
||||
function switchExpandSettings() {
|
||||
var checkBox = document.getElementById("expandSettingsCB");
|
||||
if (checkBox.checked == true) {
|
||||
localStorage.setItem('switchExpand', true);
|
||||
} else {
|
||||
localStorage.setItem('switchExpand', false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,12 +120,8 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/themes/iph/js/co
|
|||
|
||||
</#if>
|
||||
|
||||
<@expandSwitch />
|
||||
|
||||
<div class="expandSwitch">
|
||||
<label class="switch">Раскрыть статью
|
||||
<input id="expandCB" type="checkbox" onclick="switchExpand();">
|
||||
</label>
|
||||
</div>
|
||||
<div id="TOC"></div>
|
||||
<#assign firstPub = propertyGroups.pullProperty("https://litvinovg.pro/text_structures#firstPublication")!>
|
||||
<#if firstPub.statements?has_content && firstPub.type == "data">
|
||||
|
@ -152,7 +148,7 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/themes/iph/js/co
|
|||
</#list>
|
||||
</#if>
|
||||
|
||||
<@showRubrics />
|
||||
<@documentRubrics />
|
||||
|
||||
<div class="articleParts" style="display:block;">
|
||||
<#list paths as order>
|
||||
|
|
|
@ -11,6 +11,8 @@ ${scripts.add('<script async type="text/javascript" src="${urls.base}/themes/iph
|
|||
${scripts.add('<script type="text/javascript" src="${urls.base}/themes/iph/js/collapsible_elements.js"></script>')}
|
||||
<#import "individual-qrCodeGenerator.ftl" as qr>
|
||||
<#import "lib-vivo-properties.ftl" as vp>
|
||||
<#include "text-lib.ftl">
|
||||
|
||||
<#--Number of labels present-->
|
||||
<#if !labelCount??>
|
||||
<#assign labelCount = 0 >
|
||||
|
@ -94,11 +96,9 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/themes/iph/js/co
|
|||
<#assign skipThis = propertyGroups.pullProperty("http://xmlns.com/foaf/0.1/firstName")!>
|
||||
<#assign skipThis = propertyGroups.pullProperty("http://xmlns.com/foaf/0.1/lastName")!>
|
||||
</#if>
|
||||
<div class="expandSwitch">
|
||||
<label class="switch">Раскрыть статью
|
||||
<input id="expandCB" type="checkbox" onclick="switchExpand();">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<@expandSwitch />
|
||||
|
||||
<#assign firstPub = propertyGroups.pullProperty("https://litvinovg.pro/text_structures#firstPublication")!>
|
||||
<#if firstPub.statements?has_content && firstPub.type == "data">
|
||||
<div class="firstPub" style="list-style:none;">
|
||||
|
@ -108,23 +108,6 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/themes/iph/js/co
|
|||
</div>
|
||||
</#if>
|
||||
|
||||
<#--
|
||||
<#assign issue = propertyGroups.pullProperty("https://litvinovg.pro/text_structures#issue")!>
|
||||
<#if issue.statements?has_content && issue.type == "data">
|
||||
<div class="issue" style="list-style:none;">
|
||||
<div class="label">Выпуск</div>
|
||||
<@p.dataPropertyList issue editable />
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
<#assign year = propertyGroups.pullProperty("https://litvinovg.pro/text_structures#year")!>
|
||||
<#if year.statements?has_content && year.type == "data">
|
||||
<div class="year" style="list-style:none;">
|
||||
<div class="label">Год</div>
|
||||
<@p.dataPropertyList year editable />
|
||||
</div>
|
||||
</#if>
|
||||
-->
|
||||
|
||||
<#if authors??>
|
||||
<#list authors as author>
|
||||
|
@ -142,18 +125,7 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/themes/iph/js/co
|
|||
</#list>
|
||||
</#if>
|
||||
|
||||
<#assign articleRubrics = propertyGroups.pullProperty("https://iph.ras.ru/relationships#belongsTo")!>
|
||||
<#if articleRubrics?? && articleRubrics?has_content>
|
||||
<div class="label">Относится к рубрикам: <@p.addLink articleRubrics editable /> <@p.verboseDisplay articleRubrics /></div>
|
||||
<#if rubrics?? && rubrics?has_content>
|
||||
<#list rubrics as rubric>
|
||||
<li role="listitem" style="list-style:none;">
|
||||
<a href="${urls.base}/individual?uri=${rubric.rubricID?url}"">${rubric.rubricName}</a>
|
||||
</li>
|
||||
</#list>
|
||||
</#if>
|
||||
<br/>
|
||||
</#if>
|
||||
<@documentRubrics />
|
||||
|
||||
<div class="articleParts" style="display:block;">
|
||||
<#list paths as order>
|
||||
|
|
|
@ -33,6 +33,38 @@
|
|||
</div>
|
||||
</#if>
|
||||
</#macro>
|
||||
<#macro showWorks works >
|
||||
|
||||
<#macro documentRubrics >
|
||||
<#assign docRubrics = propertyGroups.pullProperty("https://iph.ras.ru/relationships#belongsTo")!>
|
||||
<#if ( docRubrics?? && docRubrics?has_content ) || (rubrics?? && rubrics?has_content)>
|
||||
<div class="label">Относится к рубрикам:
|
||||
<#if docRubrics?? && docRubrics?has_content >
|
||||
<@p.addLink docRubrics editable /> <@p.verboseDisplay docRubrics /><br/>
|
||||
</#if>
|
||||
</div>
|
||||
</#if>
|
||||
<#if rubrics?? && rubrics?has_content>
|
||||
<#list rubrics as rubric>
|
||||
<li role="listitem" style="list-style:none;">
|
||||
<a href="${urls.base}/individual?uri=${rubric.rubricID?url}"">${rubric.rubricName}</a>
|
||||
</li>
|
||||
</#list>
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
|
||||
<#macro expandSettingsSwitch >
|
||||
<div class="expandSettingsSwitch">
|
||||
<label class="switch">Раскрывать документы по умолчанию
|
||||
<input id="expandSettingsCB" type="checkbox" onclick="switchExpandSettings();">
|
||||
</label>
|
||||
</div>
|
||||
</#macro>
|
||||
|
||||
<#macro expandSwitch>
|
||||
<div class="expandSwitch">
|
||||
<label class="switch">Раскрыть все главы документа
|
||||
<input id="expandCB" type="checkbox" onclick="switchExpand();">
|
||||
</label>
|
||||
</div>
|
||||
</#macro>
|
Loading…
Add table
Reference in a new issue