Difference between revisions of "MediaWiki:Mobile.js"
Jump to navigation
Jump to search
(Created page with " var id, timeOut, timeOutShow, origin, mouseWhere='', container = $("body"), count=0; // endvar function clickClose(i) { $('#close-'+ i).trig...") |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 6: | Line 6: | ||
function clickClose(i) { $('#close-'+ i).trigger('click'); } | function clickClose(i) { $('#close-'+ i).trigger('click'); } | ||
| − | function getID(el) { return el.text().replace( | + | function getID(el) { return el.text().replace(/ /g, '').replace(':','').replace('-',''); } |
function showHover(hover, lnk) { | function showHover(hover, lnk) { | ||
var postop = lnk.offset().top; postop = postop <= 200 ? 10 : postop - 200; | var postop = lnk.offset().top; postop = postop <= 200 ? 10 : postop - 200; | ||
| Line 19: | Line 19: | ||
setTimeout(function(){ | setTimeout(function(){ | ||
timeOutShow = null; | timeOutShow = null; | ||
| − | verse = lnk.text(); | + | if (lnk.data('verse')) verse = lnk.data('verse'); |
| + | else verse = lnk.text(); | ||
id = getID(lnk); | id = getID(lnk); | ||
var hover = $('#' + id); | var hover = $('#' + id); | ||
| Line 25: | Line 26: | ||
if (hover.length === 0) { | if (hover.length === 0) { | ||
$.ajax({ | $.ajax({ | ||
| − | url: ' | + | url: '/chronology/index.php?route=common/home/sa', |
type: 'get', | type: 'get', | ||
data: '&verse=' + verse, | data: '&verse=' + verse, | ||
Latest revision as of 10:09, 14 June 2020
var id, timeOut, timeOutShow, origin, mouseWhere='',
container = $("body"),
count=0;
// endvar
function clickClose(i) { $('#close-'+ i).trigger('click'); }
function getID(el) { return el.text().replace(/ /g, '').replace(':','').replace('-',''); }
function showHover(hover, lnk) {
var postop = lnk.offset().top; postop = postop <= 200 ? 10 : postop - 200;
hover.css({"z-index":count,
"top":postop+"px",
"visibility":"visible"})
.addClass("mwe-popups-fade-in-up");
}
function processHover (lnk) {
// delay showing the verse hover box
setTimeout(function(){
timeOutShow = null;
if (lnk.data('verse')) verse = lnk.data('verse');
else verse = lnk.text();
id = getID(lnk);
var hover = $('#' + id);
count++;
if (hover.length === 0) {
$.ajax({
url: '/chronology/index.php?route=common/home/sa',
type: 'get',
data: '&verse=' + verse,
dataType: 'html',
beforeSend: function() {
// set the verse hover box: content is loading
lnk.after('<div id="' + id +'" class="hover"><div id="'+ id +'header" class="hvr-header">' + verse + '<div id="close-' + id + '" class="close">×</div></div><div class="hvr-content"><img src="/natnee/images/6.gif" /></div></div>');
},
success: function(json) {
// verse hover box: content is the verse
$('#' + id + ' .hvr-content').html(json);
// important to redefine the hover; it becomes null if it isn't defined
hover = $('#' + id);
origin = 'top';
showHover(hover, lnk);
// when [x] of verse hover is clicked
$('#close-'+id).on('click', function() {
if (origin == 'top') hover.removeClass("mwe-popups-fade-in-up").addClass("mwe-popups-fade-out-down");
else hover.removeClass("mwe-popups-fade-in-down").hover.addClass("mwe-popups-fade-out-up");
hover.on("animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd", function(e){ hover.off(e);
if (hover.attr('class').indexOf('mwe-popups-fade-out') >= 0 ) {
hover.removeClass("mwe-popups-fade-out-down").css({'visibility':'hidden','top':'0', 'z-index':'0'});
}
});//end hover animation
});//end close on click
return false;
}, error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
} else if (hover.css('visibility') == 'hidden') { showHover(hover, lnk); }
}, 700);
}
$('.verse').on('click', function(){ processHover($(this)); });