MediaWiki:Mobile.js: Difference between revisions

From Whonix
Jump to navigation Jump to search
Content added Content deleted
(Created page with "→‎Any JavaScript here will be loaded for users using the mobile site: // begin sd widget js function sdShowDetailed(container) { $(container).addClass('sd-s...")
 
No edit summary
Line 1:
/* Any JavaScript here will be loaded for users using the mobile site */
// begin sd widget js
function sdShowDetailed(container) {
$(container).addClass('sd-short-hidden').removeClass('sd-detailed-hidden');
$(container).find('.sd-btn-short').first().removeClass('active');
$(container).find('.sd-btn-detailed').first().addClass('active');
}
function sdShowShort(container) {
$(container).findaddClass('.sd-btndetailed-detailedhidden').first().removeClass('activesd-short-hidden');
$(container).find('.sd-btn-detailed').first().removeClass('active');
$(container).find('.sd-btn-short').first().addClass('active');
}
function sdJumpsdExpandParents(element) {
var parents = $(element).parentsUntil('.sd-container');
var box = $(parents[parents.length - 1]); // should be a .sd-short or a .sd-detailed
var container = box.parent(); // should be a .sd-container
if (box!container.hasClass('sd-detailedcontainer')) {
// parent of box is no .sd-container
return;
}
if } else { // (box.hasClass('sd-shortdetailed')) {
function sdShowShort(container) {
$sdShowDetailed(container).addClass('sd-detailed-hidden').removeClass('sd-short-hidden');
} else { // box.hasClass('sd-short')
$(container).find('.sd-btn-detailed').first().removeClass('active');
$sdShowShort(container).find('.sd-btn-short').first().addClass('active');
}
function sdExpandParents(elementcontainer) {;
}
var parents = $(element).parentsUntil('.sd-container');
function sdJump(element) {
var box = $(parents[parents.length - 1]); // should be a .sd-short or a .sd-detailed
var jqElement = $(element);
var container = box.parent(); // should be a .sd-container
if (!containerjqElement.hasClass('sd-container')length === 0) {
return;
// parent of box is no .sd-container
return;
}
if (box.hasClass('sd-detailed')) {
sdShowDetailed(container);
} else { // box.hasClass('sd-short')
sdShowShort(container);
}
sdExpandParents(container);
}
sdExpandParents(containerjqElement);
function sdJump(element) {
var jqElementoffset = $jqElement.offset(element);
$(window).scrollTop(offset.top).scrollLeft(offset.left);
if (jqElement.length === 0) {
}
$(document).ready(function () {
var hash = window.location.hash;
var sdContainers = $('.sd-container');
// if fragment identifier is given, open the matching tab
if (jqElementwindow.location.hash.length ===> 01) {
sdJump($(hash));
}
// add functionality to buttons
sdContainers.find('.sd-btn-short').on('click', function () {
sdShowShort($(this).closest('.sd-container'));
});
sdContainers.find('.sd-btn-detailed').on('click', function () {
sdShowDetailed($(this).closest('.sd-container'));
});
// watch window for change to expand tabs for fragments later
$(window).on('hashchange', (function () {
if (hash === window.location.hash) {
return;
}
sdExpandParents(jqElement)hash = window.location.hash;
var offset = jqElement.offsetsdJump($(hash));
}));
$(window).scrollTop(offset.top).scrollLeft(offset.left);
// make fragment links work
}
$(document'a[href]').readyfilter(function (i, e) {
varreturn hash$(e).attr('href')[0] === window.location.hash'#';
}).on('click', function () {
var sdContainers = $('.sd-container');
sdJump($(this).attr('href'));
// if fragment identifier is given, open the matching tab
if (window.location.hash.length > 1) {
sdJump($(hash));
}
// add functionality to buttons
sdContainers.find('.sd-btn-short').on('click', function () {
sdShowShort($(this).closest('.sd-container'));
});
sdContainers.find('.sd-btn-detailed').on('click', function () {
sdShowDetailed($(this).closest('.sd-container'));
});
// watch window for change to expand tabs for fragments later
$(window).on('hashchange', (function () {
if (hash === window.location.hash) {
return;
}
hash = window.location.hash;
sdJump($(hash));
}));
// make fragment links work
$('a[href]').filter(function (i, e) {
return $(e).attr('href')[0] === '#';
}).on('click', function () {
sdJump($(this).attr('href'));
});
});
});
// end sd widget js

Revision as of 22:42, 10 July 2016

/* Any JavaScript here will be loaded for users using the mobile site */
// begin sd widget js
function sdShowDetailed(container) {
    $(container).addClass('sd-short-hidden').removeClass('sd-detailed-hidden');
    $(container).find('.sd-btn-short').first().removeClass('active');
    $(container).find('.sd-btn-detailed').first().addClass('active');
}
function sdShowShort(container) {
    $(container).addClass('sd-detailed-hidden').removeClass('sd-short-hidden');
    $(container).find('.sd-btn-detailed').first().removeClass('active');
    $(container).find('.sd-btn-short').first().addClass('active');
}
function sdExpandParents(element) {
    var parents = $(element).parentsUntil('.sd-container');
    var box = $(parents[parents.length - 1]); // should be a .sd-short or a .sd-detailed
    var container = box.parent(); // should be a .sd-container
    if (!container.hasClass('sd-container')) {
        // parent of box is no .sd-container
        return;
    }
    if (box.hasClass('sd-detailed')) {
        sdShowDetailed(container);
    } else { // box.hasClass('sd-short')
        sdShowShort(container);
    }
    sdExpandParents(container);
}
function sdJump(element) {
    var jqElement = $(element);
    if (jqElement.length === 0) {
        return;
    }
    sdExpandParents(jqElement);
    var offset = jqElement.offset();
    $(window).scrollTop(offset.top).scrollLeft(offset.left);
}
$(document).ready(function () {
    var hash = window.location.hash;
    var sdContainers = $('.sd-container');
    // if fragment identifier is given, open the matching tab
    if (window.location.hash.length > 1) {
        sdJump($(hash));
    }
    // add functionality to buttons
    sdContainers.find('.sd-btn-short').on('click', function () {
        sdShowShort($(this).closest('.sd-container'));
    });
    sdContainers.find('.sd-btn-detailed').on('click', function () {
        sdShowDetailed($(this).closest('.sd-container'));
    });
    // watch window for change to expand tabs for fragments later
    $(window).on('hashchange', (function () {
        if (hash === window.location.hash) {
            return;
        }
        hash = window.location.hash;
        sdJump($(hash));
    }));
    // make fragment links work
    $('a[href]').filter(function (i, e) {
        return $(e).attr('href')[0] === '#';
    }).on('click', function () {
        sdJump($(this).attr('href'));
    });
});
// end sd widget js