Skip to content

Commit

Permalink
Merge pull request #147 from STEPBible/showVariants
Browse files Browse the repository at this point in the history
Show variants
  • Loading branch information
patricksptang authored Mar 6, 2024
2 parents 0768119 + 1b2b4cc commit 9e7ea3a
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -841,29 +841,65 @@
<xsl:variable name="lemma" select="conversion:getStrongPaddedKey(@lemma)"/>
<xsl:choose>
<xsl:when test="@morph">
<span class="{$colorClass}" strong="{$lemma}" morph="{@morph}">
<xsl:apply-templates/>
</span>
<xsl:choose>
<xsl:when test="@var">
<span class="{$colorClass}" strong="{$lemma}" morph="{@morph}" var="{@var}">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:otherwise>
<span class="{$colorClass}" strong="{$lemma}" morph="{@morph}">
<xsl:apply-templates/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<span class="{$colorClass}" strong="{$lemma}">
<xsl:apply-templates/>
</span>
<xsl:choose>
<xsl:when test="@var">
<span class="{$colorClass}" strong="{$lemma}" var="{@var}">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:otherwise>
<span class="{$colorClass}" strong="{$lemma}">
<xsl:apply-templates/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="lemma" select="conversion:getStrongPaddedKey(@lemma)"/>
<xsl:choose>
<xsl:when test="@morph">
<span strong="{$lemma}" morph="{@morph}">
<xsl:apply-templates/>
</span>
<xsl:choose>
<xsl:when test="@var">
<span strong="{$lemma}" morph="{@morph}" var="{@var}">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:otherwise>
<span strong="{$lemma}" morph="{@morph}">
<xsl:apply-templates/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<span strong="{$lemma}">
<xsl:apply-templates/>
</span>
<xsl:choose>
<xsl:when test="@var">
<span strong="{$lemma}" var="{@var}">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:otherwise>
<span strong="{$lemma}">
<xsl:apply-templates/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,9 @@
</xsl:choose>
</xsl:variable>

<xsl:variable name="lemma" select="conversion:getStrongPaddedKey(@lemma)" />
<span class="{$classes} {$colorClass}" strong="{$lemma}" morph="{@morph}">
<xsl:variable name="lemma" select="conversion:getStrongPaddedKey(@lemma)" />
<xsl:variable name="variant" select="@var" />
<span class="{$classes} {$colorClass}" strong="{$lemma}" morph="{@morph}" var="{$variant}">
<xsl:if test="normalize-space($remainingText) != ''">
<!-- 1st - Output first line or a blank if no text available. -->
<xsl:variable name="outputText">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ var PassageDisplayView = DisplayView.extend({
reference + '\')" title="Show summary information" class="select-version stepButton">' + __s.book_summary + '</button>');
}
if (!justLoadedTOS) step.util.addGrammar();
var elmntsWithCaretChar = $("span:contains(^)");
for (var ii = 0; ii < elmntsWithCaretChar.length; ii++ ) {
if (elmntsWithCaretChar[ii].outerText.length == 1) {
$($("span:contains(^)")[ii]).css("vertical-align", "sub");
$($("span:contains(^)")[ii]).attr("var", "other")
}
}
},
scrollToTargetLocation: function (passageContainer) {
var self = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ var QuickLexicon = Backbone.View.extend({
'<% if ((item.versionCountOT != null) && (item.versionCountNT != null)) { showClickWord = true; %><span class="strongCount"> (<%= sprintf(__s.stats_occurs_times_in_specific_ot_nt_bible, item.versionCountOT, item.versionCountNT, view.version) %>.) <% } %>' +
'<% if ((item.versionCountOT != null) && (!showClickWord)) { showClickWord = true; %><span class="strongCount"> (<%= sprintf(__s.stats_occurs_times_in_specific_bible, item.versionCountOT, view.version) %>.) <% } %>' +
'<% if ((item.versionCountNT != null) && (!showClickWord)) { showClickWord = true; %><span class="strongCount"> (<%= sprintf(__s.stats_occurs_times_in_specific_bible, item.versionCountNT, view.version) %>.) <% } %>' +
'<% if ((item.count != null) && (!showClickWord)) { showClickWord = true; %><span class="strongCount"> (<%= sprintf(__s.stats_occurs_times_in_bible, item.count) %>.) <% } %>' +
'<% if ((item.count != null) && (!showClickWord)) { showClickWord = true; %><span class="strongCount"> (<%= sprintf(__s.stats_occurs_times_in_bible, item.count) %>.)<% } %>' +
'<% if (brief_morph_info[data_index] != null) { %> ' +
'&nbsp;&nbsp;<span><%= brief_morph_info[data_index] %></span> ' +
',&nbsp;&nbsp;<span><%= brief_morph_info[data_index] %></span> ' +
'<% var currentVariant = view.variant[data_index]; %> ' +
'<% if ((typeof currentVariant !== "string") && (typeof view.variant[0] === "string")) currentVariant = view.variant[0]; %> ' +
'<% if ((typeof currentVariant === "string") && (currentVariant !== "")) { %> <span>, (in <%= currentVariant %> manuscript)</span> <% } %>' +
'<% if (showClickWord) { %> - <span class="clickMoreInfo"><%= __s.more_info_on_click_of_word %></span></span> <% } %>' +
'</div>' +
'<% } %>' +
Expand All @@ -57,6 +60,7 @@ var QuickLexicon = Backbone.View.extend({
this.type = opts.type;
this.touchEvent = opts.touchEvent || false;
this.passageContainer = step.util.getPassageContainer(opts.target);
this.variant = opts.variant.split(";");
if(this.passageContainer.length == 0) {
this.passageContainer = step.util.getPassageContainer(opts.passageId);
}
Expand Down
21 changes: 16 additions & 5 deletions step-web/src/main/webapp/js/backbone/views/view_sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ var SidebarView = Backbone.View.extend({
var allVersions = this.model.get("allVersions");
var strong = this.model.get("strong");
var morph = this.model.get("morph");
var variant = this.model.get("variant") || "";
variant = variant.split(";");
if (typeof allVersions !== "string") {
if (typeof version === "string")
allVersions = version;
Expand All @@ -85,7 +87,7 @@ var SidebarView = Backbone.View.extend({
return;
}
callBackCreateDefParams = [ ref, allVersions ];
callBackLoadDefFromAPIParams = [ version, ref, strong, morph, allVersions, self.createDefinition];
callBackLoadDefFromAPIParams = [ version, ref, strong, morph, allVersions, variant, self.createDefinition];
step.util.getVocabMorphInfoFromJson(strong, morph, version, self.createDefinition, callBackCreateDefParams, self.loadDefinitionFromRestAPI, callBackLoadDefFromAPIParams);
}
else if (this.model.get("mode") == 'analysis') {
Expand All @@ -110,14 +112,15 @@ var SidebarView = Backbone.View.extend({
var strong = parameters[2];
var morph = parameters[3];
var allVersions = parameters[4];
var callBackCreateDef = parameters[5];
var variant = parameters[5];
var callBackCreateDef = parameters[6];
$.getSafe(MODULE_GET_INFO, [version, ref, strong, morph, step.userLanguageCode], function (data) {
callBackCreateDef(data, [ ref, allVersions ]);
callBackCreateDef(data, [ ref, allVersions, variant ]);
//return false;
}).error(function() {
if (changeBaseURL())
$.getSafe(MODULE_GET_INFO, [version, ref, strong, morph, step.userLanguageCode], function (data) {
callBackCreateDef(data, [ ref, allVersions ]);
callBackCreateDef(data, [ ref, allVersions, variant ]);
})
});
//return false;
Expand Down Expand Up @@ -171,6 +174,7 @@ var SidebarView = Backbone.View.extend({
createDefinition: function (data, parameters) {
var ref = parameters[0];
var allVersions = parameters[1];
var variant = parameters[2];
var displayLexicalRelatedWords = (($(".detailLex:visible").length > 0) || (step.util.localStorageGetItem("sidebar.detailLex") === "true"));
//get definition tab
this.lexicon.detach();
Expand Down Expand Up @@ -219,7 +223,12 @@ var SidebarView = Backbone.View.extend({
if (!step.touchDevice || step.touchWideDevice)
panelContentContainer.append(panelBody);
this._createBriefWordPanel(panelBody, item, currentUserLang, allVersions);
// need to handle multiple morphInfo (array)
var currentVariant = variant[i];
if ((typeof currentVariant !== "string") && (typeof variant[0] === "string"))
currentVariant = variant[0];
if ((typeof currentVariant === "string") && (currentVariant !== ""))
panelBody.append("<div>in " + currentVariant + " manuscript</div>");
// need to handle multiple morphInfo (array)
if ((lastMorphCode != '') && (data.morphInfos.length == 0)) {
data.morphInfos = cf.getTOSMorphologyInfo(lastMorphCode);
}
Expand Down Expand Up @@ -253,6 +262,8 @@ var SidebarView = Backbone.View.extend({
else {
var panelBody = $('<div class="panel-body"></div>');
this._createBriefWordPanel(panelBody, data.vocabInfos[0], currentUserLang, allVersions);
if (variant[0] !== "")
panelBody.append("<div>Only in " + variant[0] + " manuscript</div>");
// need to handle multiple morphInfo (array)
if ((lastMorphCode != '') && (data.morphInfos.length == 0)) {
data.morphInfos = cf.getTOSMorphologyInfo(lastMorphCode);
Expand Down
18 changes: 11 additions & 7 deletions step-web/src/main/webapp/js/step.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1383,8 +1383,7 @@ step.util = {
* called when click on a piece of text.
*/
showDef: function (source, sourceVersion) {
var strong, morph, ref, version, allVersions;

var strong, morph, ref, version, allVersions, variant;
if (typeof source === "string") {
strong = source;
if (typeof sourceVersion === "string")
Expand All @@ -1394,10 +1393,12 @@ step.util = {
ref = source.ref;
morph = source.morph;
version = source.version;
variant = source.variant;
} else {
var s = $(source);
strong = s.attr("strong");
morph = s.attr("morph");
variant = s.attr("var") || "";
var verseAndVersion = step.util.ui.getVerseNumberAndVersion(s);
ref = verseAndVersion[0];
if (ref !== '')
Expand All @@ -1409,9 +1410,9 @@ step.util = {
allVersions = firstVersion + "," + step.passages.findWhere({ passageId: step.passage.getPassageId(s) }).get("extraVersions");
}

step.util.ui.initSidebar('lexicon', { strong: strong, morph: morph, ref: ref, version: version, allVersions: allVersions });
step.util.ui.initSidebar('lexicon', { strong: strong, morph: morph, ref: ref, variant: variant, version: version, allVersions: allVersions });
require(["sidebar"], function (module) {
step.util.ui.openStrongNumber(strong, morph, ref, version, allVersions);
step.util.ui.openStrongNumber(strong, morph, ref, version, allVersions, variant);
});
},
initSidebar: function (mode, data) {
Expand All @@ -1427,6 +1428,7 @@ step.util = {
strong: data.strong,
morph: data.morph,
ref: data.ref,
variant: data.variant,
version: data.version,
allVersions: data.allVersions,
mode: mode == null ? 'analysis' : mode
Expand All @@ -1447,7 +1449,7 @@ step.util = {
}
});
},
openStrongNumber: function (strong, morph, reference, version, allVersions) {
openStrongNumber: function (strong, morph, reference, version, allVersions, variant) {
if (step.sidebar != null) {
if (!step.touchDevice || step.touchWideDevice)
step.sidebar.save({
Expand All @@ -1456,7 +1458,8 @@ step.util = {
mode: 'lexicon',
ref: reference,
version: version,
allVersions: allVersions
allVersions: allVersions,
variant: variant
});
else
step.sidebar = null;
Expand Down Expand Up @@ -1584,6 +1587,7 @@ step.util = {
_displayNewQuickLexicon: function (hoverContext, passageId, touchEvent, pageYParam) {
var strong = $(hoverContext).attr('strong');
var morph = $(hoverContext).attr('morph');
var variant = $(hoverContext).attr('var') || "";
var verseAndVersion = step.util.ui.getVerseNumberAndVersion(hoverContext);
var reference = verseAndVersion[0];
var version = verseAndVersion[1];
Expand All @@ -1601,7 +1605,7 @@ step.util = {
if (quickLexiconEnabled == true || quickLexiconEnabled == null) {
new QuickLexicon({
strong: strong, morph: morph,
version: version, reference: reference,
version: version, reference: reference, variant: variant,
target: hoverContext, position: pageY, touchEvent: touchEvent,
height: $(window).height(),
passageId: passageId
Expand Down

0 comments on commit 9e7ea3a

Please sign in to comment.