Skip to content

Commit

Permalink
Update for mobile display, ESV morph and other enhancments
Browse files Browse the repository at this point in the history
  • Loading branch information
patricksptang committed Dec 23, 2023
1 parent 725591d commit cacd2ba
Show file tree
Hide file tree
Showing 25 changed files with 896 additions and 717 deletions.
19 changes: 14 additions & 5 deletions step-web/src/main/webapp/js/backbone/step_router.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var StepRouter = Backbone.Router.extend({
this.navigate(url, { trigger: false, replace: true});
},

navigatePreserveVersions: function (partial, stripCommentaries, skipPage, skipQFilter) {
navigatePreserveVersions: function (partial, stripCommentaries, skipPage, skipQFilter, startNewPageForPhone) {
//get versions of current active passage
//add versions from current active passage
var activePassage = step.util.activePassage();
Expand Down Expand Up @@ -51,7 +51,10 @@ var StepRouter = Backbone.Router.extend({
skipPage = (skipPage) ? true : false;
skipQFilter = (skipQFilter) ? true : false;
if ((allVersions !== "") && (searchParameters !== "")) searchParameters = allVersions + "|" + searchParameters;
this.navigateSearch(searchParameters, skipQFilter, skipPage);
if (step.touchDevice && !step.touchWideDevice && startNewPageForPhone)
window.open("/?q=" + searchParameters.split(" ")[0], "_blank");
else
this.navigateSearch(searchParameters, skipQFilter, skipPage);
},
navigateSearch: function (args, skipQFilter, skipPage) {
var activePassageId = step.util.activePassageId();
Expand Down Expand Up @@ -200,7 +203,7 @@ var StepRouter = Backbone.Router.extend({
}
});
},
handleRenderModel: function (passageModel, partRendered, queryArgs) {
handleRenderModel: function (passageModel, partRendered, queryArgs, doNotScroll) {
passageModel.save({
args: queryArgs != null ? decodeURIComponent(queryArgs) : "",
urlFragment: Backbone.history.getFragment()
Expand All @@ -224,8 +227,8 @@ var StepRouter = Backbone.Router.extend({
} else {
this.handleSearchResults(passageModel, partRendered);
}

this._renderSummary(passageModel);
step.util.hideNavBarOnPhones(doNotScroll);
},

_renderSummary: function (passageModel) {
Expand Down Expand Up @@ -321,7 +324,13 @@ var StepRouter = Backbone.Router.extend({
$("#nextChapterWordle").hide();
$("#newLineWordle").show();
$("#nextChapterInputLine").show();
self.handleRenderModel(passageModel, false, query);
var doNotScroll = false;
if ( ((typeof pageNumber === "string") && (!isNaN(pageNumber))) ||
(typeof pageNumber === "number") ) {
if (parseInt(pageNumber) > 1)
doNotScroll = true;
}
self.handleRenderModel(passageModel, false, query, doNotScroll);
},
passageId: activePassageId,
level: 'error'
Expand Down
17 changes: 0 additions & 17 deletions step-web/src/main/webapp/js/backbone/views/view_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,6 @@ var DisplayView = Backbone.View.extend({

//reset the 'clear' values
interlinearBlocks.not(".verseStart").css("clear", "none");
/*var previousElementOffset = undefined;
for (var i = 0; i < interlinearBlocks.length; i++) {
var element = interlinearBlocks.eq(i);
var elementOffset = element.offset();
//skip the first element
if (previousElementOffset) {
//check that previous element is either left or higher up
var currentPadding = 0;
if (previousElementOffset.top < elementOffset.top) {
element.css("clear", "left");
}
elementOffset = element.offset();
}
previousElementOffset = elementOffset;
}*/
},
/**
* Estimates the height of each block in an interlinear like way
Expand Down
94 changes: 48 additions & 46 deletions step-web/src/main/webapp/js/backbone/views/view_display_passage.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ var PassageDisplayView = DisplayView.extend({
cv[C_colorCodeGrammarAvailableAndSelected] = (options.indexOf("C") > -1) && (availableOptions.indexOf("C") > -1);
if ((cv[C_colorCodeGrammarAvailableAndSelected]) && (typeof c4 === "undefined")) cf.initCanvasAndCssForClrCodeGrammar(); //c4 is currentClrCodeConfig. It is called to c4 to save space
var passageHtml, ntCSSOnThisPage = '', otCSSOnThisPage = '', pch, hasTOS = false, hasNTMorph = false;
var bibleVersions = this.model.attributes.masterVersion.toUpperCase() + "," + this.model.attributes.extraVersions.toUpperCase();
if ((bibleVersions.indexOf('THOT') > -1)) {
var reference = this.model.get("osisId");
var version = this.model.get("masterVersion");
var extraVersions = this.model.get("extraVersions");
var bibleVersions = version.toUpperCase() + "," + extraVersions.toUpperCase();
// check if OT or NT 12/13/2023 PT
// console.log("place to add NT OT check: "+reference+ " " +bibleVersions);
if ((bibleVersions.indexOf('ESV_MORPH') > -1) || (bibleVersions.indexOf('THOT') > -1)) {
if (cv[C_otMorph] == null) {
var notIE = !(false || !!document.documentMode);
// If browser is not IE, use "cache: true". If IE, use "cache: false"
// This is required because of an IE and Jquery issue.
jQuery.ajax({
dataType: "script",
cache: notIE,
cache: true,
url: "js/tos_morph.js",
error: function (jqXHR, exception) {
console.log('load tos_morph.js Failed: ' + exception);
Expand All @@ -49,7 +51,7 @@ var PassageDisplayView = DisplayView.extend({
}
hasTOS = true;
}
if ((bibleVersions.indexOf('KJV') > -1) || (bibleVersions.indexOf('SBLG') > -1) || (bibleVersions.indexOf('CUN') > -1)) hasNTMorph = true;
if ((bibleVersions.indexOf('ESV_MORPH') > -1) || (bibleVersions.indexOf('KJV') > -1) || (bibleVersions.indexOf('SBLG') > -1) || (bibleVersions.indexOf('CUN') > -1)) hasNTMorph = true;
if (this.partRendered) {
if (cv[C_colorCodeGrammarAvailableAndSelected]) {
if (hasTOS) {
Expand Down Expand Up @@ -78,17 +80,14 @@ var PassageDisplayView = DisplayView.extend({
}
var passageId = this.model.get("passageId");
var interlinearMode = this.model.get("interlinearMode");
var extraVersions = this.model.get("extraVersions");
var reference = this.model.get("osisId");
var version = this.model.get("masterVersion");
var languages = this.model.get("languageCode");
var passageContainer = this.$el.closest(".passageContainer");
if (this._isPassageValid(passageHtml, reference)) {
passageContainer.find(".resultsLabel").html("");
this._warnIfNoStrongs(version);
this._warnIfFirstTimeCompare(interlinearMode);
this._warnIfInterlinearFirstTime(interlinearMode);
this._warnFirstTimeColourCoding();
this._warnFirstTimeColorCoding();
this._warnCommentaryLookupVersion(version, extraVersions);
this.doFonts(passageHtml, options, interlinearMode, languages);
this.doSwapInterlinearLink(passageHtml);
Expand All @@ -108,16 +107,17 @@ var PassageDisplayView = DisplayView.extend({
if (!this.partRendered) {
step.util.ui.emptyOffDomAndPopulate(this.$el, passageHtml);
}
$(this.$el).find(".passageContentHolder").scroll(function(){
var monitorElement = (step.touchDevice && !step.touchWideDevice) ? $(document) : $(this.$el).find(".passageContentHolder");
monitorElement.scroll(function(){
$(".versePopup").hide();
if ($(this).find(".resultsLabel").text() !== "") // This is search result
return;
var allVerseNumbers = $(this).find(".verseNumber");
var thisTop = $(this).offset().top;
var thisTop = (step.touchDevice && !step.touchWideDevice) ? $(window).scrollTop() + 21 : $(this).offset().top;
for (var i = 0; i < allVerseNumbers.length; i++) {
var curVerse = allVerseNumbers[i];
if ($(curVerse).offset().top > thisTop) {
var refButton = $(this).parent().parent().find("button.select-reference");
var refButton = (step.touchDevice && !step.touchWideDevice) ? $("button.select-reference") : $(this).parent().parent().find("button.select-reference");
var newText = curVerse.innerHTML;
var isInterLinear = $(this).find('.interlinear').length > 0;
if ( ((isInterLinear) && (newText.indexOf(":") > -1)) ||
Expand All @@ -130,7 +130,10 @@ var PassageDisplayView = DisplayView.extend({
if (curVerseParts.length > 1)
newText = curVerseParts[1];
}
newText = origText[0].trim() + ":" + newText;
if (origText[0].trim() === "")
newText = "Ref";
else
newText = origText[0].trim() + ":" + newText;
}
$(refButton).text(newText);
break;
Expand All @@ -140,7 +143,7 @@ var PassageDisplayView = DisplayView.extend({

//needs to happen after appending to DOM

this.updateColor();
this.updateSTEPColor();

this._doChromeHack(passageHtml, interlinearMode, options);
this.doInterlinearVerseNumbers(passageHtml, interlinearMode, options);
Expand Down Expand Up @@ -252,7 +255,7 @@ var PassageDisplayView = DisplayView.extend({
});
}
},
_warnFirstTimeColourCoding: function () {
_warnFirstTimeColorCoding: function () {
var options = this.model.get("options") || "";
if (options.indexOf("D") != -1) {
step.util.raiseOneTimeOnly("display_divide_hebrew_explanation", "info");
Expand Down Expand Up @@ -463,30 +466,31 @@ var PassageDisplayView = DisplayView.extend({
}
},

keepNotesInSync: function (passageContent) {
var currentHeight = passageContent.height();
passageContent.find(".notesPane").height(currentHeight);
$(passageContent).on('scroll', function () {
//find top verse - 1.
var allVerses = $(".verse", passageContent);
var lastVerse = undefined;
for (var ii = 0; ii < allVerses.length; ii++) {
var currentVerse = $(allVerses[ii]);
var versePosition = currentVerse.position().top;
if (top >= 0) {
break;
}
lastVerse = currentVerse;
}

if (lastVerse == undefined) {
passageContent.find(".notesPane").scrollTop(0);
}
else {

}
});
},
// Does not seem to be in used. 11/30/2023 PT
// keepNotesInSync: function (passageContent) {
// var currentHeight = passageContent.height();
// passageContent.find(".notesPane").height(currentHeight);
// $(passageContent).on('scroll', function () {
// //find top verse - 1.
// var allVerses = $(".verse", passageContent);
// var lastVerse = undefined;
// for (var ii = 0; ii < allVerses.length; ii++) {
// var currentVerse = $(allVerses[ii]);
// var versePosition = currentVerse.position().top;
// if (top >= 0) {
// break;
// }
// lastVerse = currentVerse;
// }

// if (lastVerse == undefined) {
// passageContent.find(".notesPane").scrollTop(0);
// }
// else {

// }
// });
// },

/**
* Creates a QTIP for a particular xref
Expand Down Expand Up @@ -528,12 +532,10 @@ var PassageDisplayView = DisplayView.extend({
}
}
}

$.getSafe(BIBLE_GET_BIBLE_TEXT + chosenVersion + "/" + encodeURIComponent(xref), function (data) {
var text2Display = data.value;
if (data.value.length > 1200) {
text2Display = $(data.value).text().substring(0,1000) + " ...";
}
if (data.value.length > 1100)
text2Display = $(data.value).text().substring(0,900) + " ...";
api.set('content.title.text', data.longName);
api.set('content.text', text2Display);
api.set('content.osisId', data.osisId)
Expand Down Expand Up @@ -676,7 +678,7 @@ var PassageDisplayView = DisplayView.extend({
step.util.ui.addStrongHandlers(passageId, passageContent)
},

updateColor: function () {
updateSTEPColor: function () {
this.updateSpecificColor("clrHighlight", "#17758F");
this.updateSpecificColor("clrHighlightBg", "#17758F");
this.updateSpecificColor("clrText", "#5d5d5d");
Expand Down
36 changes: 18 additions & 18 deletions step-web/src/main/webapp/js/backbone/views/view_display_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,11 @@ var SearchDisplayView = DisplayView.extend({
if ((cv[C_colorCodeGrammarAvailableAndSelected]) && (typeof c4 === "undefined")) cf.initCanvasAndCssForClrCodeGrammar(); //c4 is currentClrCodeConfig. It is called to c4 to save space
var passageHtml, ntCSSOnThisPage = '', otCSSOnThisPage = '', hasTOS = false, hasNTMorph = false;
var bibleVersions = this.model.attributes.masterVersion.toUpperCase() + "," + this.model.attributes.extraVersions.toUpperCase();
if ((bibleVersions.indexOf('THOT') > -1)) {
if ((bibleVersions.indexOf('ESV_MORPH') > -1) || (bibleVersions.indexOf('THOT') > -1)) {
if (cv[C_otMorph] == null) {
var notIE = !(false || !!document.documentMode);
// If browser is not IE, use "cache: true". If IE, use "cache: false"
// This is required because of an IE and Jquery issue.
jQuery.ajax({
dataType: "script",
cache: notIE,
cache: true,
url: "js/tos_morph.js",
error: function (jqXHR, exception) {
console.log('load tos_morph.js Failed: ' + exception);
Expand All @@ -90,7 +87,7 @@ var SearchDisplayView = DisplayView.extend({
}
hasTOS = true;
}
if ((bibleVersions.indexOf('KJV') > -1) || (bibleVersions.indexOf('SBLG') > -1) || (bibleVersions.indexOf('CUN') > -1)) hasNTMorph = true;
if ((bibleVersions.indexOf('ESV_MORPH') > -1) || (bibleVersions.indexOf('KJV') > -1) || (bibleVersions.indexOf('SBLG') > -1) || (bibleVersions.indexOf('CUN') > -1)) hasNTMorph = true;

results = this.options.partRendered ? this.$el.find("> span") : this.renderSearch(append, this.$el.find(".searchResults"));

Expand Down Expand Up @@ -190,6 +187,8 @@ var SearchDisplayView = DisplayView.extend({
}

this._doChromeHack(this.$el, this.model.get("interlinearMode"), this.model.get("options"));
if (step.touchDevice && !step.touchWideDevice)
$(".copyrightInfo").removeClass("copyrightInfo").addClass("crInfoX");
},
_getErrorMessage: function () {
var errorMessage = $("<span>");
Expand Down Expand Up @@ -243,8 +242,11 @@ var SearchDisplayView = DisplayView.extend({
* @returns {*}
*/
getScrollableArea: function () {
if (step.touchDevice && !step.touchWideDevice)
return $(document);
return this.$el.closest(".passageContent").find("> span");
}, getMoreResults: function () {
},
getMoreResults: function () {
var self = this;

//never load new pages
Expand All @@ -258,20 +260,18 @@ var SearchDisplayView = DisplayView.extend({

var scrollableArea = this.getScrollableArea();


//visible height
var clientHeight = scrollableArea.prop("clientHeight");
if (typeof clientHeight !== "number")
clientHeight = $(window).height();

//how far down we are
var scrollTop = scrollableArea.prop("scrollTop");

//total scrollable height
var scrollHeight = scrollableArea.prop("scrollHeight");

var leftToScroll = scrollHeight - scrollTop - clientHeight;

var scrollDownProportion = scrollableArea.scrollTop() / scrollableArea.prop("scrollHeight");
if (scrollDownProportion > 0.7 || scrollDownProportion == scrollableArea.height() || leftToScroll < 800) {
var numOfSearchRows = $(".searchResultRow").length;
if (numOfSearchRows == 0)
return;
var thirtyPercentRowsPerPage = (numOfSearchRows / this.pageNumber) * .3;
var checkRow = Math.floor(numOfSearchRows - thirtyPercentRowsPerPage);
var posOf70PercentRowInLastPage = $($(".searchResultRow")[checkRow])[0].getBoundingClientRect().top;
if (posOf70PercentRowInLastPage < clientHeight) {
var currentPageNumber = this.pageNumber;
var newPageNumber = parseInt(currentPageNumber) + 1;
var pageSize = this.model.get("pageSize");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ var SubjectDisplayView = SearchDisplayView.extend({
* @private
*/
_doSimpleSubjectSearchResults: function (searchResults) {
var results = $("<span>").addClass("subjectSection searchResults simpleSubjectSearch");
var cssForTouchDevice = (step.touchDevice && !step.touchWideDevice) ? " style='overflow-y:hidden;height:auto' " : "";
var results = $("<span id='srchRslts'" + cssForTouchDevice + ">").addClass("subjectSection searchResults simpleSubjectSearch");
var headingsSearch = searchResults[0].headingsSearch;
var headingsResults = headingsSearch.results;

Expand All @@ -54,7 +55,6 @@ var SubjectDisplayView = SearchDisplayView.extend({
* @private
*/
_doSpecificSearchRequirements: function (query, results) {
var self = this;
var passageId = this.model.get("passageId");
var searchType = this.model.get("searchType");

Expand Down Expand Up @@ -90,8 +90,8 @@ var SubjectDisplayView = SearchDisplayView.extend({

},
_doNaveSearchResults: function (searchResults) {
var self = this;
var results = $("<span>").addClass("searchResults");
var cssForTouchDevice = (step.touchDevice && !step.touchWideDevice) ? " style='overflow-y:hidden;height:auto' " : "";
var results = $("<span id='srchRslts'" + cssForTouchDevice + ">").addClass("searchResults");

var lastHeader = "";
if (!searchResults || searchResults.length == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ var TextDisplayView = SearchDisplayView.extend({
titleFragment : __s.search_text,
renderSearch: function (append, existingResults) {
console.log("Rendering text search results");

var results = $("<span>");
var cssForTouchDevice = (step.touchDevice && !step.touchWideDevice) ? " style='overflow-y:hidden;height:auto' " : "";
var results = $("<span id='srchRslts'" + cssForTouchDevice + ">");
var searchResults = this.model.get("results");
var sortOrder = this.model.get("order");

Expand Down
Loading

0 comments on commit cacd2ba

Please sign in to comment.