MediaWiki:BibleGet.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 57: Line 57:
if(data.hasOwnProperty('html')){
if(data.hasOwnProperty('html')){
let $bGetTIP = $('<div>', {
let $bGetTIP = $('<div>', {
"class": "bibleGetQuote hidden",
"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).contents().first().filter(function(){  
jQuery(this).find('.versesParagraph .verseText').each(function(){
return (  
jQuery(this).contents().first().filter(function(){  
this.nodeType === 1 && (  
return (
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')  
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>');  
}).css({"display":"inline-block","position":"relative","left":function(index){ return "-"+jQuery(this).parent('.verseText').prev('.verseNum').outerWidth(true)+"px"; } });   
//HERE IS THE LOGIC:
//HERE IS THE LOGIC:
//IF the (first node) following a .verseText node is not a text node,
//IF the (first node) following a .verseText node is not a text node,
//AND it IS an element node with class po    
//AND it IS an element node with class pof,poif,po,poi,poil...  
//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 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
//THEN add a newline before the preceding .verseNum node containing 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?
 
//HERE INSTEAD WE REMOVE ANY EXTRA SPACES AT THE BEGINNING OF A VERSE...
jQuery(this).contents().first().filter(function(){
jQuery(this).html( jQuery(this).html().replace( /^\s/, '' ) );
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') )
//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).parent('.verseText').prevAll('.verseText').length > 0
jQuery(this).find(".pof,.po,.pol,.pos,.poif,.poi,.poil").filter(function(){ return jQuery(this).children('.speaker').length !== 0 })
&& jQuery(this).parent('.verseText').prevAll('.verseText:first').contents().last().css('display') == 'inline-block'
.css("left",function(i,current){
)
return (parseInt(current) - 4 || -15 );
)
}).css("position","relative");
}).parent('.verseText').prev('.verseNum').before('<br>');  
//HERE IS THE LOGIC:
//AND HERE WE ADD A SPACE BETWEEN NUMBER AND REST OF BOOK NAME TO THOSE BIBLE BOOKS THAT HAVE AN INITIAL NUMBER
//IF the (first node) following a .verseText node is not a text node,
jQuery(this).find('.bookChapter').each(function(){
//AND it IS an element node with class po    
if( unicodeChrClass.test( jQuery(this).html() ) ){
//AND this is not the first .verseText node of a chapter
jQuery(this).html( jQuery(this).html().replace( unicodeChrClass, '$1 $2' ) );
//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).addClass('hidden');
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(".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('.bibleQuote .bookChapter').each(function(){
if( unicodeChrClass.test( jQuery(this).html() ) ){
jQuery(this).html( jQuery(this).html().replace( unicodeChrClass, '$1 $2' ) );
}
});
});
};
};