Skip to content

Commit

Permalink
Possible fix for #1160 & #1024 Show title on any new content added to…
Browse files Browse the repository at this point in the history
… accordion & carousel navigators will work as expected. Existing content added to these navigators will continue to work strangely (video & audio titles always on and other content type titles always off) so that existing projects won't suddenly show titles appearing / disappearing
  • Loading branch information
FayCross committed Sep 8, 2022
1 parent f5c8770 commit 6790dc9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 29 deletions.
33 changes: 22 additions & 11 deletions modules/site/parent_templates/site/common/js/application.js
Expand Up @@ -1799,9 +1799,9 @@ function loadSection(thisSection, section, sectionIndex, page, pageHash, pageInd

//add the section contents
$(thisSection).children().each( function(itemIndex, value){
if (($(this).attr('name') != '' && $(this).attr('name') != undefined && $(this).attr('showTitle') == 'true') || ($(this).attr('showTitle') == undefined && (this.nodeName == 'audio' || this.nodeName == 'video'))) {
if ($(this).attr('name') != '' && $(this).attr('name') != undefined && ($(this).attr('showTitle') == 'true' || $(this).attr('showTitleFix') == 'true')) {

if ($(this).attr('showTitle') == 'true') {
if ($(this).attr('showTitle') == 'true' || $(this).attr('showTitleFix') == 'true') {
var subLinkName = $(this).attr('name');

// remove size & background color styles from links on toc
Expand Down Expand Up @@ -2400,9 +2400,9 @@ function makeNav(node,section,type, sectionIndex, itemIndex){
var i = index;

$(this).children().each( function(x, value){

if ($(this).attr('showTitle') == 'true' || ($(this).attr('showTitle') == undefined && (this.nodeName == 'audio' || this.nodeName == 'video'))) {
tab.append('<p><b>' + $(this).attr('name') + '</b></p>');
if ($(this).attr('name') != '' && $(this).attr('name') != undefined && ($(this).attr('showTitle') == 'true' || $(this).attr('showTitleFix') == 'true')) {
tab.append('<h3>' + $(this).attr('name') + '</h3>');
}

if (this.nodeName == 'text'){
Expand Down Expand Up @@ -2551,6 +2551,12 @@ function makeAccordion(node,section, sectionIndex, itemIndex){
var inner = $('<div class="accordion-inner" tabindex="0">');

$(this).children().each( function(i, value){

// there was a bug in versions before 3.12 which meant audio & video on accordion always showed title & other content never did (regardless of whether show titles ticked or not)
// fix here for new content added to accordions - it doesn't fix for old content as then titles may unexpectedly appear / disappear after upgrade without the author editing
if ($(this).attr('name') != '' && $(this).attr('name') != undefined && (($(this).attr('showTitle') == 'true' && (this.nodeName == 'audio' || this.nodeName == 'video')) || $(this).attr('showTitleFix') == 'true' || ($(this).attr('showTitleFix') == undefined && (this.nodeName == 'audio' || this.nodeName == 'video')))) {
inner.append('<h3>' + $(this).attr('name') + '</h3>');
}

if (this.nodeName == 'text'){
inner.append( '<p>' + $(this).text() + '</p>');
Expand All @@ -2561,12 +2567,12 @@ function makeAccordion(node,section, sectionIndex, itemIndex){
}

if (this.nodeName == 'audio'){
inner.append('<p><b>' + $(this).attr('name') + '</b></p><p><audio src="' + $(this).attr('url') + '" type="audio/mp3" id="player1" controls="controls" preload="none" width="100%"></audio></p>')
inner.append('<p><audio src="' + $(this).attr('url') + '" type="audio/mp3" id="player1" controls="controls" preload="none" width="100%"></audio></p>')
}

if (this.nodeName == 'video'){
var videoInfo = setUpVideo($(this).attr('url'), $(this).attr('iframeRatio'), currentPage + '_' + sectionIndex + '_' + itemIndex + '_' + index);
inner.append('<p><b>' + $(this).attr('name') + '</b></p><p>' + videoInfo[0] + '</p>');
inner.append('<p>' + videoInfo[0] + '</p>');

if (videoInfo[1] != undefined) {
inner.find('.vidHolder').last().data('iframeRatio', videoInfo[1]);
Expand Down Expand Up @@ -2625,7 +2631,7 @@ function makeCarousel(node, section, sectionIndex, itemIndex){
var itemIndex = itemIndex;

var carDiv = $('<div id="car' + sectionIndex + '_' + itemIndex + '" class="navigator carousel slide" data-interval="false"/>');
debugger

if (node.attr('autoPlay') == 'true') {
carDiv = $('<div id="car' + sectionIndex + '_' + itemIndex + '" class="navigator carousel slide"/>');
if ($.isNumeric(node.attr('delaySecs')) && node.attr('delaySecs') != '4') {
Expand Down Expand Up @@ -2661,6 +2667,12 @@ function makeCarousel(node, section, sectionIndex, itemIndex){
}

$(this).children().each( function(i, value){

// there was a bug in versions before 3.12 which meant audio & video on carousel always showed title & other content never did (regardless of whether show titles ticked or not)
// fix here for new content added to carousel - it doesn't fix for old content as then titles may unexpectedly appear / disappear after upgrade without the author editing
if ($(this).attr('name') != '' && $(this).attr('name') != undefined && (($(this).attr('showTitle') == 'true' && (this.nodeName == 'audio' || this.nodeName == 'video')) || $(this).attr('showTitleFix') == 'true' || ($(this).attr('showTitleFix') == undefined && (this.nodeName == 'audio' || this.nodeName == 'video')))) {
pane.append('<h3>' + $(this).attr('name') + '</h3>');
}

if (this.nodeName == 'text'){
pane.append( '<p>' + $(this).text() + '</p>');
Expand All @@ -2671,12 +2683,12 @@ function makeCarousel(node, section, sectionIndex, itemIndex){
}

if (this.nodeName == 'audio'){
pane.append('<p><b>' + $(this).attr('name') + '</b></p><p><audio src="' + $(this).attr('url') + '" type="audio/mp3" id="player1" controls="controls" preload="none" width="100%"></audio></p>')
pane.append('<p><audio src="' + $(this).attr('url') + '" type="audio/mp3" id="player1" controls="controls" preload="none" width="100%"></audio></p>')
}

if (this.nodeName == 'video'){
var videoInfo = setUpVideo($(this).attr('url'), $(this).attr('iframeRatio'), currentPage + '_' + sectionIndex + '_' + itemIndex + '_' + index);
pane.append('<p><b>' + $(this).attr('name') + '</b></p><p>' + videoInfo[0] + '</p>');
pane.append('<p>' + videoInfo[0] + '</p>');

if (videoInfo[1] != undefined) {
pane.find('.vidHolder').last().data('iframeRatio', videoInfo[1]);
Expand Down Expand Up @@ -2740,7 +2752,6 @@ function makeCarousel(node, section, sectionIndex, itemIndex){

function loadXotContent($this) {
// get link & store url parameters to add back in later if not overridden
debugger;
var xotLink = $this.attr('link'),
params = [],
separator = xotLink.indexOf('.php?template_id') == -1 ? '?' : '&';
Expand Down
42 changes: 24 additions & 18 deletions src/site/wizards/en-GB/page.xwd
Expand Up @@ -48,17 +48,17 @@
<filter type="CategoryList" label="Filter Categories" target="categoryInfo" defaultValue="" optional="true" tooltip="Use in conjunction with the project-level 'Search' optional property. Tick the relevant filter terms used in category searches"/>

<newNodes>
<xot><![CDATA[<xot name="Title" showTitle="true" link="Xerte XOT Project URL" header="false" footer="false"/>]]></xot>
<pdf><![CDATA[<pdf name="Title" showTitle="true" url="Select a PDF File" width="500" height="350" openPDF="Open PDF in new tab"/>]]></pdf>
<xot><![CDATA[<xot name="Title" showTitleFix="true" link="Xerte XOT Project URL" header="false" footer="false"/>]]></xot>
<pdf><![CDATA[<pdf name="Title" showTitleFix="true" url="Select a PDF File" width="500" height="350" openPDF="Open PDF in new tab"/>]]></pdf>
<markup><![CDATA[<markup name="Title" showTitle="true">&lt;!--Enter HTML Code--&gt;</markup>]]></markup>
<canvas><![CDATA[<canvas name="Title" showTitle="true" id="EnterID" width="500" height="350"/>]]></canvas>
<script><![CDATA[<script name="Title">//javascript</script>]]></script>
<link><![CDATA[<link name="Title" url="Link URL"/>]]></link>
<navigator><![CDATA[<navigator name="Title" showTitle="true" type="Tabs"/>]]></navigator>
<video><![CDATA[<video name="Title" showTitle="true" url="Select a Video"/>]]></video>
<audio><![CDATA[<audio name="Title" showTitle="true" url="Select a Sound File"/>]]></audio>
<image><![CDATA[<image name="Title" showTitle="true" url="Select an Image" alt="Enter a Description for Accessibility"/>]]></image>
<text><![CDATA[<text name="Title" showTitle="true">Enter Text Here</text>]]></text>
<video><![CDATA[<video name="Title" showTitleFix="true" url="Select a Video"/>]]></video>
<audio><![CDATA[<audio name="Title" showTitleFix="true" url="Select a Sound File"/>]]></audio>
<image><![CDATA[<image name="Title" showTitleFix="true" url="Select an Image" alt="Enter a Description for Accessibility"/>]]></image>
<text><![CDATA[<text name="Title" showTitleFix="true">Enter Text Here</text>]]></text>
</newNodes>

</section>
Expand Down Expand Up @@ -93,7 +93,8 @@
<text icon="icFont" type="text" height="300" menuItem="Text" label="Text" remove="true">

<name type="TextInput" label="Title" wysiwyg="true"/>
<showTitle label="Show Title" type="CheckBox" defaultValue="false" mandatory="true"/>
<showTitle label="Show Title" type="CheckBox"/>
<showTitleFix label="Show Title" type="CheckBox"/>

<disableGlossary label="Disable Glossary" defaultValue="false" type="CheckBox" optional="true"/>

Expand All @@ -103,7 +104,8 @@

<name type="TextInput" label="Title" wysiwyg="true"/>
<url type="Media" label="PDF File"/>
<showTitle label="Show Title" type="CheckBox" defaultValue="false" mandatory="true"/>
<showTitle label="Show Title" type="CheckBox"/>
<showTitleFix label="Show Title" type="CheckBox"/>
<openPDF type="TextInput" label="Open PDF Label" defaultValue="Open PDF in new tab" wysiwyg="true" mandatory="true" language="true"/>

</pdf>
Expand Down Expand Up @@ -132,23 +134,26 @@
<name type="TextInput" label="Title" wysiwyg="true"/>
<url type="Media" label="Image"/>
<alt type="TextInput" label="Image Description"/>
<showTitle label="Show Title" type="CheckBox" defaultValue="false" mandatory="true"/>
<showTitle label="Show Title" type="CheckBox"/>
<showTitleFix label="Show Title" type="CheckBox"/>

</image>

<audio icon="icSound" height="250" menuItem="Audio" remove="true">

<name type="TextInput" label="Title" wysiwyg="true"/>
<url type="Media" label="Sound"/>
<showTitle label="Show Title" type="CheckBox" defaultValue="false" mandatory="true"/>
<showTitle label="Show Title" type="CheckBox"/>
<showTitleFix label="Show Title" type="CheckBox"/>

</audio>

<video icon="icFilm" height="250" menuItem="Video" remove="true">

<name type="TextInput" label="Title" wysiwyg="true"/>
<url type="Media" label="Video"/>
<showTitle label="Show Title" type="CheckBox" defaultValue="false" mandatory="true"/>
<showTitle label="Show Title" type="CheckBox"/>
<showTitleFix label="Show Title" type="CheckBox"/>

<iframeRatio label="iframe Aspect Ratio" type="TextInput" defaultValue="16:9" tooltip="Aspect ratio for videos from external sites (e.g. YouTube)" optional="true" />

Expand Down Expand Up @@ -180,13 +185,13 @@

<newNodes>

<xot><![CDATA[<xot name="Title" showTitle="true" link="Xerte XOT Project URL" header="false" footer="false"/>]]></xot>
<pdf><![CDATA[<pdf name="Title" showTitle="true" url="Select a PDF File" width="500" height="350"/>]]></pdf>
<xot><![CDATA[<xot name="Title" showTitleFix="true" link="Xerte XOT Project URL" header="false" footer="false"/>]]></xot>
<pdf><![CDATA[<pdf name="Title" showTitleFix="true" url="Select a PDF File" width="500" height="350"/>]]></pdf>
<link><![CDATA[<link name="Title" url="Link URL"/>]]></link>
<video><![CDATA[<video name="Title" showTitle="true" url="Select a Video"/>]]></video>
<audio><![CDATA[<audio name="Title" showTitle="true" url="Select a Sound File"/>]]></audio>
<image><![CDATA[<image name="Title" showTitle="true" url="Select an Image" alt="Enter a Description for Accessibility"/>]]></image>
<text><![CDATA[<text name="Title" showTitle="true">Enter Text Here</text>]]></text>
<video><![CDATA[<video name="Title" showTitleFix="true" url="Select a Video"/>]]></video>
<audio><![CDATA[<audio name="Title" showTitleFix="true" url="Select a Sound File"/>]]></audio>
<image><![CDATA[<image name="Title" showTitleFix="true" url="Select an Image" alt="Enter a Description for Accessibility"/>]]></image>
<text><![CDATA[<text name="Title" showTitleFix="true">Enter Text Here</text>]]></text>

</newNodes>
</pane>
Expand All @@ -197,7 +202,8 @@
<link type="TextInput" label="Xerte Project Link"/>
<header label="Hide Header" type="CheckBox"/>
<footer label="Hide Footer" type="CheckBox"/>
<showTitle label="Show Title" type="CheckBox" defaultValue="false" mandatory="true"/>
<showTitle label="Show Title" type="CheckBox"/>
<showTitleFix label="Show Title" type="CheckBox"/>

<pageNum label="Page" type="TextInput" defaultValue="1" optional="true"/>
<width label="Width" type="TextInput" defaultValue="100%" optional="true"/>
Expand Down

0 comments on commit 6790dc9

Please sign in to comment.