|
|
Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for users using the mobile site */ | | /* Any JavaScript here will be loaded for users using the mobile site */ |
| (function($,mw){
| | mw.loader.load( '/w/index.php?title=MediaWiki:BibleGet.js&action=raw&ctype=text/javascript' ); |
| $(document).ready(function(){
| |
| if( $('.bibleQuoteRef').length > 0 ){
| |
| //console.log("There are bible quotes on this page!");
| |
| $('.bibleQuoteRef').each(function(){
| |
| let $span = $(this);
| |
| let version = $(this).attr('data-version');
| |
| let ref = $(this).attr('data-ref');
| |
| $.ajax({
| |
| method: 'POST',
| |
| url: '../w/bgetHelper.php',
| |
| data: {
| |
| "version": version,
| |
| "ref": ref
| |
| },
| |
| success: function(data){
| |
| //console.log("data returned from ajax request:");
| |
| //console.log(data);
| |
| if(data.hasOwnProperty('html')){
| |
| let $bGetTIP = $('<div>', {
| |
| "class": "bibleGetQuote",
| |
| "data-ref": ref,
| |
| "html": data.html
| |
| });
| |
| $bGetTIP.append($('<p>',{"text": " — powered by BibleGet I/O","css":{"font-size":".9em","text-align":"right","font-style":"italic","font-weight":"bold","color":"gray"}}));
| |
| $('body').append($bGetTIP);
| |
|
| |
| $span.on('click touchstart', function(){
| |
| let toppos = ($(window).height()/2) - ($bGetTIP.height()/2);
| |
| let leftpos = ($(window).width()/2) - ($bGetTIP.width()/2);
| |
| $bGetTIP.show();
| |
| $bGetTIP.css("top", toppos).css("left",leftpos);
| |
| });
| |
|
| |
| $bGetTIP.on('click touchstart', function(){
| |
| $(this).hide();
| |
| });
| |
|
| |
| /*
| |
| $span.on('mousemove', function(){
| |
| let top = $span.offset().top;
| |
| let left = $span.offset().left + $span.outerWidth();
| |
| $bGetTIP.css({"top":top,"left":left});
| |
| });
| |
| */
| |
| /*
| |
| $span.on('mouseleave', function(){
| |
| setTimeout(function(){ $bGetTIP.fadeOut('slow') },500);
| |
| });
| |
| */
| |
| }
| |
| //console.log("Injected Bible quote for ref = " + ref + " with value obtained from BibleGet service:");
| |
| },
| |
| error: function(jqXHR, textStatus, errorThrown){
| |
| //console.log("There was an error while trying to communicate with the BibleGet server:")
| |
| //console.log(errorThrown + ' ' + textStatus + ': ' + jqXHR.responseText);
| |
| }
| |
| });
| |
| });
| |
| }
| |
| });
| |
| }(jQuery,mw));
| |