Stable release of v2.0.20

First step to resolve getBible/support#8 so that the selection works on mobile browsers. Fixed the scrolling for mobiles.
This commit is contained in:
Robot 2023-08-14 06:35:37 +02:00
parent 5806bba7f3
commit c42df2d720
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
10 changed files with 160 additions and 88 deletions

View File

@ -98,3 +98,8 @@
- Adds metadata to each Bible page to resolve getBible/support#6
- Adds option to force chapter hash checking.
# v2.0.20
- First step to resolve getBible/support#8 so that the selection works on mobile browsers.
- Fixed the scrolling for mobiles.

View File

@ -1,4 +1,4 @@
# Get Bible (2.0.19)
# Get Bible (2.0.20)
![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible")
@ -18,8 +18,8 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Get Bible](https://getbible.net)
+ *First Build*: 3rd December, 2015
+ *Last Build*: 13th August, 2023
+ *Version*: 2.0.19
+ *Last Build*: 14th August, 2023
+ *Version*: 2.0.20
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
@ -31,11 +31,11 @@ due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))
> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
> never making one mistake or taking any coffee break.)
+ *Line count*: **198087**
+ *File count*: **1718**
+ *Line count*: **198159**
+ *File count*: **1719**
+ *Folder count*: **163**
**364 Hours** or **46 Eight Hour Days** (the actual time the author spent)
**365 Hours** or **46 Eight Hour Days** (the actual time the author spent)
> (with the following break down:
> **debugging @138hours** = codingtime / 4;
@ -43,7 +43,7 @@ due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))
> **mapping @55hours** = codingtime / 10;
> **office @92hours** = codingtime / 6;)
**917 Hours** or **115 Eight Hour Days**
**918 Hours** or **115 Eight Hour Days**
(a total of the realistic time frame for this project)
> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,

View File

@ -1,4 +1,4 @@
# Get Bible (2.0.19)
# Get Bible (2.0.20)
![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible")
@ -18,8 +18,8 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Get Bible](https://getbible.net)
+ *First Build*: 3rd December, 2015
+ *Last Build*: 13th August, 2023
+ *Version*: 2.0.19
+ *Last Build*: 14th August, 2023
+ *Version*: 2.0.20
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
@ -31,11 +31,11 @@ due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))
> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
> never making one mistake or taking any coffee break.)
+ *Line count*: **198087**
+ *File count*: **1718**
+ *Line count*: **198159**
+ *File count*: **1719**
+ *Folder count*: **163**
**364 Hours** or **46 Eight Hour Days** (the actual time the author spent)
**365 Hours** or **46 Eight Hour Days** (the actual time the author spent)
> (with the following break down:
> **debugging @138hours** = codingtime / 4;
@ -43,7 +43,7 @@ due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))
> **mapping @55hours** = codingtime / 10;
> **office @92hours** = codingtime / 6;)
**917 Hours** or **115 Eight Hour Days**
**918 Hours** or **115 Eight Hour Days**
(a total of the realistic time frame for this project)
> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,

View File

@ -0,0 +1 @@

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="4" method="upgrade">
<name>COM_GETBIBLE</name>
<creationDate>13th August, 2023</creationDate>
<creationDate>14th August, 2023</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://getbible.net</authorUrl>
<copyright>Copyright (C) 2015. All Rights Reserved</copyright>
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
<version>2.0.19</version>
<version>2.0.20</version>
<description><![CDATA[
<h1>Get Bible (v.2.0.19)</h1>
<h1>Get Bible (v.2.0.20)</h1>
<div style="clear: both;"></div>
<p>Welcome to the next level of scripture engagement - The Bible for Joomla! Our purpose is to bring the Word of God to every person, in their native language, entirely free. This isn't just a typical extension; it's a groundbreaking tool developed to span language divides and deliver a rich, customizable Bible study experience to users worldwide.

View File

@ -1539,7 +1539,7 @@ class com_getbibleInstallerScript
echo '<a target="_blank" href="https://getbible.net" title="Get Bible">
<img src="components/com_getbible/assets/images/vdm-component.jpg"/>
</a>
<h3>Upgrade to Version 2.0.19 Was Successful! Let us know if anything is not working as expected.</h3>';
<h3>Upgrade to Version 2.0.20 Was Successful! Let us know if anything is not working as expected.</h3>';
// Set db if not set already.
if (!isset($db))

View File

@ -982,9 +982,16 @@ const removeChildrenElements = (parentId) => {
list.innerHTML = '';
};
/**
* JS Function for smooth scrolling to
* JS Function to scrolling directly
*/
const smoothScrollTo = (element, offset = 0, duration = 400) => {
const directScrollTo = (element, offset = 0) => {
const elementY = window.pageYOffset + element.getBoundingClientRect().top - offset;
window.scrollTo(0, elementY);
};
/**
* JS Function custom smooth scrolling to
*/
const customSmoothScrollTo = (element, offset = 0, duration = 400) => {
const startingY = window.pageYOffset;
const elementY = window.pageYOffset + element.getBoundingClientRect().top - offset;
const diff = elementY - startingY;
@ -1002,3 +1009,39 @@ const smoothScrollTo = (element, offset = 0, duration = 400) => {
}
});
};
/**
* JS Function the check if we scrolled
*/
const hasScrolledTo = (element, offset = 0) => {
const targetY = window.pageYOffset + element.getBoundingClientRect().top - offset;
return Math.abs(window.pageYOffset - targetY) <= 5; // tolerance of 5 pixels
};
/**
* JS Function for smooth scrolling to
*/
const smoothScrollTo = (element, offset = 0) => {
if ('scrollBehavior' in document.documentElement.style) {
// Try using native smooth scroll
const elementY = window.pageYOffset + element.getBoundingClientRect().top - offset;
window.scroll({
top: elementY,
behavior: 'smooth'
});
// Fallback to custom smooth scroll after a short delay, if native scroll didn't work
setTimeout(() => {
if (!hasScrolledTo(element, offset)) {
customSmoothScrollTo(element, offset);
}
}, 700); // 700ms should be sufficient time to see if native scroll worked
} else {
customSmoothScrollTo(element, offset);
}
// Last resort, direct scroll after a longer delay, if no other method worked
setTimeout(() => {
if (!hasScrolledTo(element, offset)) {
directScrollTo(element, offset);
}
}, 1000); // Giving 1 second for other methods to work
};

View File

@ -43,78 +43,80 @@ document.addEventListener('DOMContentLoaded', function() {
var mainArea = document.getElementById('getbible-holy-scripture');
if (mainArea) {
let startedInWord = false;
mainArea.addEventListener('mousedown', function(event) {
let target = event.target;
function handleTextSelectionStart(event) {
let target = (event.target) ? event.target : event.touches[0].target;
if (target.nodeType === Node.TEXT_NODE) {
target = target.parentNode;
}
startedInWord = target.classList.contains('getbible-word');
});
mainArea.addEventListener('mouseup', function (event) {
var selection = window.getSelection();
if (!selection.rangeCount || !startedInWord) return;
var range = selection.getRangeAt(0);
var startContainer = range.startContainer;
var endContainer = range.endContainer;
// If the startContainer or endContainer is a Text node, use its parent
if (startContainer.nodeType === Node.TEXT_NODE) {
startContainer = startContainer.parentNode;
}
if (endContainer.nodeType === Node.TEXT_NODE) {
endContainer = endContainer.parentNode;
}
var wordElements = Array.from(document.querySelectorAll('.getbible-word'));
var startIdx = wordElements.indexOf(startContainer);
var endIdx = wordElements.indexOf(endContainer);
var selectedWordElements = wordElements.slice(startIdx, endIdx + 1);
var selectedWords = selectedWordElements.reduce(function(acc, wordElement) {
var verse = wordElement.getAttribute('data-verse');
var nr = wordElement.getAttribute('data-word-nr');
if (!acc[verse]) {
acc[verse] = {};
}
function handleTextSelectionEnd(event) {
// Use a delay for mobile to ensure text selection has completed
const isTouch = event.type === 'touchend';
setTimeout(() => {
var selection = window.getSelection();
if (!selection.rangeCount || !startedInWord) return;
var range = selection.getRangeAt(0);
var startContainer = range.startContainer;
var endContainer = range.endContainer;
// If the startContainer or endContainer is a Text node, use its parent
if (startContainer.nodeType === Node.TEXT_NODE) {
startContainer = startContainer.parentNode;
}
acc[verse][nr] = {
urlWord: wordElement.getAttribute('data-url-word'),
word: wordElement.getAttribute('data-word'),
wordNr: nr,
verseNr: verse
};
return acc;
}, {});
if (Object.keys(selectedWords).length == 1) {
// get the words
let verseWord = getBibleWordsFromSingleVerse(selectedWords, 'word');
let verseUrlWord = getBibleWordsFromSingleVerse(selectedWords, 'urlWord');
let wordNumber = getBibleWordsFromSingleVerse(selectedWords, 'wordNr', '-');
let verseNumber = getBibleWordsFromSingleVerse(selectedWords, 'verseNr', '-');
// open the model
getBibleWord(verseWord, verseUrlWord, wordNumber, verseNumber);
// Clear the selection
selection.removeAllRanges();
}
<?php if ($this->params->get('activate_sharing') == 1): ?>else if (Object.keys(selectedWords).length > 1)
{
// get the range
let numbers = getBibleFirstAndLastVerseNumbers(selectedWords);
// set the active verse
setActiveVerse(numbers.start);
// update the share verse slider
getbibleShareVerseSlider.noUiSlider.set([numbers.start, numbers.end]);
// Clear the selection
selection.removeAllRanges();
// open the module
UIkit.modal('#getbible-app-sharing').show();
}<?php endif; ?>
});
if (endContainer.nodeType === Node.TEXT_NODE) {
endContainer = endContainer.parentNode;
}
var wordElements = Array.from(document.querySelectorAll('.getbible-word'));
var startIdx = wordElements.indexOf(startContainer);
var endIdx = wordElements.indexOf(endContainer);
var selectedWordElements = wordElements.slice(startIdx, endIdx + 1);
var selectedWords = selectedWordElements.reduce(function(acc, wordElement) {
var verse = wordElement.getAttribute('data-verse');
var nr = wordElement.getAttribute('data-word-nr');
if (!acc[verse]) {
acc[verse] = {};
}
acc[verse][nr] = {
urlWord: wordElement.getAttribute('data-url-word'),
word: wordElement.getAttribute('data-word'),
wordNr: nr,
verseNr: verse
};
return acc;
}, {});
if (Object.keys(selectedWords).length == 1) {
// get the words
let verseWord = getBibleWordsFromSingleVerse(selectedWords, 'word');
let verseUrlWord = getBibleWordsFromSingleVerse(selectedWords, 'urlWord');
let wordNumber = getBibleWordsFromSingleVerse(selectedWords, 'wordNr', '-');
let verseNumber = getBibleWordsFromSingleVerse(selectedWords, 'verseNr', '-');
// open the model
getBibleWord(verseWord, verseUrlWord, wordNumber, verseNumber);
// Clear the selection
selection.removeAllRanges();
}
<?php if ($this->params->get('activate_sharing') == 1): ?>
else if (Object.keys(selectedWords).length > 1)
{
// get the range
let numbers = getBibleFirstAndLastVerseNumbers(selectedWords);
// set the active verse
setActiveVerse(numbers.start);
// update the share verse slider
getbibleShareVerseSlider.noUiSlider.set([numbers.start, numbers.end]);
// Clear the selection
selection.removeAllRanges();
// open the module
UIkit.modal('#getbible-app-sharing').show();
}
<?php endif; ?>
}, isTouch ? 300 : 0);
}
// Attach events
mainArea.addEventListener('mousedown', handleTextSelectionStart);
mainArea.addEventListener('touchstart', handleTextSelectionStart);
mainArea.addEventListener('mouseup', handleTextSelectionEnd);
mainArea.addEventListener('touchend', handleTextSelectionEnd);
}
});
var getbible_active_word = '';

View File

@ -854,6 +854,9 @@ class GetbibleViewApp extends HtmlView
font-weight: bolder;
color: $verse_selected_color;
}
html {
scroll-behavior: smooth;
}
");
// Set the Custom JS script to view
$this->document->addScriptDeclaration("

View File

@ -323,4 +323,22 @@
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="3.*"/>
</update>
<update>
<name>Get Bible</name>
<description>The Bible for Joomla</description>
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>2.0.20</version>
<infourl title="Get Bible!">https://getbible.net</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v2.0.20.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="3.*"/>
</update>
</updates>