MediaWiki:Common.js: Difference between revisions

From Rinchen Terdzö
((by SublimeText.Mediawiker))
((by SublimeText.Mediawiker))
 
(56 intermediate revisions by the same user not shown)
Line 1: Line 1:
mw.loader.load( 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css', 'text/css' );
$('#bios-trigger').hover( function() { $('#bios-back').show(); }, function() { $('#bios-back').hide(); });
mw.loader.load( 'https://fonts.googleapis.com/css?family=EB+Garamond', 'text/css' );
$('#bios-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Biographies'; })
mw.loader.load( 'https://pro.fontawesome.com/releases/v5.5.0/css/all.css', 'text/css' );
$('#indexes-trigger').hover( function() { $('#indexes-back').show(); }, function() { $('#indexes-back').hide(); });
mw.loader.load( 'mediawiki.ui.button' );
$('#indexes-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Indexes_and_Lineage_Histories'; })
 
$('#maha-trigger').hover( function() { $('#maha-back').show(); }, function() { $('#maha-back').hide(); });
// Download Unicode RTF functions
$('#maha-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Mahayoga'; })
$(document).ready(function(){
$('#anu-trigger').hover( function() { $('#anu-back').show(); }, function() { $('#anu-back').hide(); });
    $( '#rightSpanExpand' ).prepend('<a href="#" id="downloadUnicode">Download Tibetan Text</a>&nbsp;-&nbsp;');
$('#anu-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Anuyoga'; })
});
$('#ati-trigger').hover( function() { $('#ati-back').show(); }, function() { $('#ati-back').hide(); });
 
$('#ati-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Atiyoga'; })
/*    RTZ Main Page Functions    */
$('#sup-trigger').hover( function() { $('#sup-back').show(); }, function() { $('#sup-back').hide(); });
 
$('#sup-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Supplementary_Volumes'; })
$(document).ready(function(){
$('#ill-trigger').hover( function() { $('#ill-back').show(); }, function() { $('#ill-back').hide(); });
$('#section-links').hover(
$('#ill-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/RTZ_Volume_72'; })
function(){ $('#tsdlogo').addClass('hide') },
$('#out-trigger').hover( function() { $('#out-back').show(); }, function() { $('#out-back').hide(); });
function(){ $('#tsdlogo').removeClass('hide') }
$('#out-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/RTZ_Outline'; })
);
$('#bios-trigger').click(function() {
window.location = "Biographies";
}).hover(
function(){ $('#bios-back').css('z-index','999').addClass('animated fadeIn') },
function(){ $('#bios-back').css('z-index','-999').removeClass('animated fadeIn') }
);
$('#indexes-trigger').click(function() {
window.location = "Indexes and Lineage Histories";
}).hover(
function(){ $('#indexes-back').css('z-index','999').addClass('animated fadeIn') },
function(){ $('#indexes-back').css('z-index','-999').removeClass('animated fadeIn') }
);
$('#maha-trigger').click(function() {
window.location = "Mahayoga";
}).hover(
function(){ $('#maha-back').css('z-index','999').addClass('animated fadeIn') },
function(){ $('#maha-back').css('z-index','-999').removeClass('animated fadeIn') }
);
$('#anu-trigger').click(function() {
window.location = "Anuyoga";
}).hover(
function(){ $('#anu-back').css('z-index','999').addClass('animated fadeIn') },
function(){ $('#anu-back').css('z-index','-999').removeClass('animated fadeIn') }
);
$('#ati-trigger').click(function() {
window.location = "Atiyoga";
}).hover(
function(){ $('#ati-back').css('z-index','999').addClass('animated fadeIn') },
function(){ $('#ati-back').css('z-index','-999').removeClass('animated fadeIn') }
);
$('#sup-trigger').click(function() {
window.location = "Supplementary Volumes";
}).hover(
function(){ $('#sup-back').css('z-index','999').addClass('animated fadeIn') },
function(){ $('#sup-back').css('z-index','-999').removeClass('animated fadeIn') }
);
$('#out-trigger').click(function() {
window.location = "RTZ Outline";
}).hover(
function(){ $('#out-back').css('z-index','999').addClass('animated fadeIn') },
function(){ $('#out-back').css('z-index','-999').removeClass('animated fadeIn') }
);
$('.more-trigger').click(function() {
$(this).siblings('div#more-text').toggleClass('more-text-display');
$(this).toggleClass('fa-ellipsis-h fa-ellipsis-v');
});
});
 
/*    RTZ Outline Page Functions    */
 
$(document).ready(function(){
$('.mw-customtoggle-textQuery .fa-plus-circle').click(function(){
    $(this).toggleClass("rotated");
    });
});
 
 
 
 
 
/*    RTZ Biographies Page Functions    */
 
$(document).ready(function(){
$('.info-tab-header').click(function() {
$(this).siblings('#info-text').css('display','block');
$(this).removeClass('inactive-header');
$(this).siblings('#tibetan-text').css('display', 'none');
$(this).siblings('#wylie-text').css('display', 'none');
$(this).siblings('.tibetan-tab-header').addClass('inactive-header');
$(this).siblings('.wylie-tab-header').addClass('inactive-header')
});
$('.wylie-tab-header').click(function() {
$(this).siblings('#wylie-text').css('display','block');
$(this).removeClass('inactive-header');
$(this).siblings('#info-text').css('display', 'none');
$(this).siblings('#tibetan-text').css('display', 'none');
$(this).siblings('.info-tab-header').addClass('inactive-header');
$(this).siblings('.tibetan-tab-header').addClass('inactive-header')
});
$('.tibetan-tab-header').click(function() {
$(this).siblings('#tibetan-text').css('display','block');
$(this).removeClass('inactive-header');
$(this).siblings('#info-text').css('display', 'none');
$(this).siblings('#wylie-text').css('display', 'none');
$(this).siblings('.info-tab-header').addClass('inactive-header');
$(this).siblings('.wylie-tab-header').addClass('inactive-header')
});
$('.smw-template-furtherresults').addClass('plainlinks')
});
 
// To change the site's favicon:
function change_favicon(img) {
    var favicon = document.querySelector('link[rel="shortcut icon"]');
   
    if (!favicon) {
        favicon = document.createElement('link');
        favicon.setAttribute('rel', 'shortcut icon');
        var head = document.querySelector('head');
        head.appendChild(favicon);
    }
   
   
    favicon.setAttribute('type', 'image/png');
    favicon.setAttribute('href', img);
}
change_favicon('/images-rtz/6/6b/Tsadra_Logo_Favicon_-_Jeremi.png');
 
// Download Unicode RTF functions
function downloadInnerHtml(filename, elId, mimeType) {
    var elHtml = document.getElementById(elId).innerHTML;
    var link = document.createElement('a');
    mimeType = mimeType || 'text/plain';
 
    link.setAttribute('download', filename);
    link.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(elHtml));
    link.click();
}
 
var fileName =  'UnicodeContent.txt'; // You can use the .html extension if you want
 
$('#downloadUnicode').click(function(){
    downloadInnerHtml(fileName, 'tibetan','text/html');
});
 
 
 
 
// Delay hiding the loader overlay
$("#loaderOutline").load("RTZ_Outline/content #outlineContent", function() {
    $(this).children("#loader").fadeOut("fast");
    $(this).css('min-height', '0px');
});
 
$("#loaderAtiyoga").load("Atiyoga/content #atiyogaContent", function() {
    $(this).children("#loader").fadeOut("fast");
    $(this).css('min-height', '0px');
});
 
 
 
 
 
/**
* Collapsible tables
*
* Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
*
* @version 2.0.3 (2014-03-14)
* @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
* @author [[User:R. Koot]]
* @author [[User:Krinkle]]
* @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
* is supported in MediaWiki core.
*/
 
var autoCollapse = 2;
var collapseCaption = 'hide';
var expandCaption = 'show';
var tableIndex = 0;
 
function collapseTable( tableIndex ) {
var Button = document.getElementById( 'collapseButton' + tableIndex );
var Table = document.getElementById( 'collapsibleTable' + tableIndex );
 
if ( !Table || !Button ) {
return false;
}
 
var Rows = Table.rows;
var i;
var $row0 = $(Rows[0]);
 
if ( Button.firstChild.data === collapseCaption ) {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = 'none';
}
Button.firstChild.data = expandCaption;
} else {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = $row0.css( 'display' );
}
Button.firstChild.data = collapseCaption;
}
}
 
function createClickHandler( tableIndex ) {
return function ( e ) {
e.preventDefault();
collapseTable( tableIndex );
};
}
 
function createCollapseButtons( $content ) {
var NavigationBoxes = {};
var $Tables = $content.find( 'table' );
var i;
 
$Tables.each( function( i, table ) {
if ( $(table).hasClass( 'collapsible' ) ) {
 
/* only add button and increment count if there is a header row to work with */
var HeaderRow = table.getElementsByTagName( 'tr' )[0];
if ( !HeaderRow ) {
return;
}
var Header = table.getElementsByTagName( 'th' )[0];
if ( !Header ) {
return;
}
 
NavigationBoxes[ tableIndex ] = table;
table.setAttribute( 'id', 'collapsibleTable' + tableIndex );
 
var Button    = document.createElement( 'span' );
var ButtonLink = document.createElement( 'a' );
var ButtonText = document.createTextNode( collapseCaption );
// Styles are declared in [[MediaWiki:Common.css]]
Button.className = 'collapseButton';
 
ButtonLink.style.color = Header.style.color;
ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
ButtonLink.setAttribute( 'href', '#' );
$( ButtonLink ).on( 'click', createClickHandler( tableIndex ) );
ButtonLink.appendChild( ButtonText );
 
Button.appendChild( document.createTextNode( '[' ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( ']' ) );
 
Header.insertBefore( Button, Header.firstChild );
tableIndex++;
}
} );
 
for ( i = 0;  i < tableIndex; i++ ) {
if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||
( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) )
) {
collapseTable( i );
}
}
}
 
mw.hook( 'wikipage.content' ).add( createCollapseButtons );

Latest revision as of 16:47, 6 March 2024

$('#bios-trigger').hover( function() { $('#bios-back').show(); }, function() { $('#bios-back').hide(); });
$('#bios-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Biographies'; })
$('#indexes-trigger').hover( function() { $('#indexes-back').show(); }, function() { $('#indexes-back').hide(); });
$('#indexes-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Indexes_and_Lineage_Histories'; })
$('#maha-trigger').hover( function() { $('#maha-back').show(); }, function() { $('#maha-back').hide(); });
$('#maha-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Mahayoga'; })
$('#anu-trigger').hover( function() { $('#anu-back').show(); }, function() { $('#anu-back').hide(); });
$('#anu-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Anuyoga'; })
$('#ati-trigger').hover( function() { $('#ati-back').show(); }, function() { $('#ati-back').hide(); });
$('#ati-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Atiyoga'; })
$('#sup-trigger').hover( function() { $('#sup-back').show(); }, function() { $('#sup-back').hide(); });
$('#sup-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/Supplementary_Volumes'; })
$('#ill-trigger').hover( function() { $('#ill-back').show(); }, function() { $('#ill-back').hide(); });
$('#ill-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/RTZ_Volume_72'; })
$('#out-trigger').hover( function() { $('#out-back').show(); }, function() { $('#out-back').hide(); });
$('#out-trigger').click( function() { window.location.href = 'https://rtz.tsadra.org/index.php/RTZ_Outline'; })