MediaWiki:BibleGet.js: Difference between revisions
no edit summary
Johnrdorazio (talk | contribs) No edit summary |
Johnrdorazio (talk | contribs) No edit summary |
||
Line 57: | Line 57: | ||
if(data.hasOwnProperty('html')){ | if(data.hasOwnProperty('html')){ | ||
let $bGetTIP = $('<div>', { | let $bGetTIP = $('<div>', { | ||
"class": "bibleGetQuote | "class": "bibleGetQuote", | ||
"data-version": version, | "data-version": version, | ||
"data-ref": ref, | "data-ref": ref, | ||
Line 133: | Line 133: | ||
}; | }; | ||
let doFurtherDomManipulation = function(){ | let doFurtherDomManipulation = function(){ | ||
jQuery('.versesParagraph .verseText').each(function(){ | jQuery('.bibleGetQuote').each(function(){ | ||
jQuery(this).find('.versesParagraph .verseText').each(function(){ | |||
return ( | jQuery(this).contents().first().filter(function(){ | ||
this.nodeType === 1 && ( | return ( | ||
this.nodeType === 1 && ( | |||
jQuery(this).hasClass('pof') || jQuery(this).hasClass('po') || jQuery(this).hasClass('pol') || jQuery(this).hasClass('pos') || jQuery(this).hasClass('poif') || jQuery(this).hasClass('poi') || jQuery(this).hasClass('poil') | |||
) | |||
) | |||
}).css({"display":"inline-block","position":"relative","left":function(index){ return "-"+jQuery(this).parent('.verseText').prev('.verseNum').outerWidth(true)+"px"; } }); | |||
//HERE IS THE LOGIC: | |||
//IF the (first node) following a .verseText node is not a text node, | |||
//AND it IS an element node with class pof,poif,po,poi,poil... | |||
//THEN change the css display of that (first node) to "inline-block" and left position it removing the width of the span with the verse number | |||
//TODO: shouldn't we do this any time it's the first node within a verseText node, since it follows a verseNum? | |||
jQuery(this).contents().first().filter(function(){ | |||
return ( | |||
this.nodeType === 1 && ( | |||
( jQuery(this).hasClass('pof') || jQuery(this).hasClass('po') || jQuery(this).hasClass('pol') || jQuery(this).hasClass('pos') || jQuery(this).hasClass('poif') || jQuery(this).hasClass('poi') || jQuery(this).hasClass('poil') ) | |||
&& jQuery(this).parent('.verseText').prevAll('.verseText').length > 0 | |||
&& jQuery(this).parent('.verseText').prevAll('.verseText:first').contents().last().css('display') == 'inline-block' | |||
) | |||
) | ) | ||
}).parent('.verseText').prev('.verseNum').before('<br>'); | |||
//HERE IS THE LOGIC: | |||
//IF the (first node) following a .verseText node is not a text node, | |||
//AND it IS an element node with class po | |||
//AND this is not the first .verseText node of a chapter | |||
//AND the last node of the previous .verseText node has css display:inline-block | |||
//THEN add a newline before the preceding .verseNum node containing the verse number | |||
//HERE INSTEAD WE REMOVE ANY EXTRA SPACES AT THE BEGINNING OF A VERSE... | |||
jQuery(this).html( jQuery(this).html().replace( /^\s/, '' ) ); | |||
}); | |||
//Let's also make the poetic verses that have speaker tags line up a little better by removing a tad bit of the indent... | |||
jQuery(this).find(".pof,.po,.pol,.pos,.poif,.poi,.poil").filter(function(){ return jQuery(this).children('.speaker').length !== 0 }) | |||
.css("left",function(i,current){ | |||
return (parseInt(current) - 4 || -15 ); | |||
}).css("position","relative"); | |||
//AND HERE WE ADD A SPACE BETWEEN NUMBER AND REST OF BOOK NAME TO THOSE BIBLE BOOKS THAT HAVE AN INITIAL NUMBER | |||
jQuery(this).find('.bookChapter').each(function(){ | |||
if( unicodeChrClass.test( jQuery(this).html() ) ){ | |||
jQuery(this).html( jQuery(this).html().replace( unicodeChrClass, '$1 $2' ) ); | |||
} | |||
}); | |||
jQuery(this).addClass('hidden'); | |||
} | |||
}); | }); | ||
}; | }; |