MediaWiki:Bugfix MulitmediaViewer T64266Prototype.js
Aus Offene Naturführer BiolFlor
Version vom 19. Februar 2016, 15:07 Uhr von Andreas Plank (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „// MultimediaViewer T64266 Prototype D // This script is licensed under GPL v2 or any later version. Parts of this script // are from the MultimediaViewer proj…“)
Hinweis - Leere nach dem Speichern den Browser-Cache, um die Änderungen sehen zu können: Mozilla/Firefox/Safari: Shift gedrückt halten und auf Aktualisieren klicken oder alternativ entweder Strg-F5 oder Strg-R (Befehlstaste-R bei Macintosh) drücken; Konqueror: Auf Aktualisieren klicken oder F5 drücken; Opera: Cache unter Extras → Internetspuren löschen…; Internet Explorer: Strg-F5 drücken oder Strg gedrückt halten und dabei Aktualisieren anklicken.
// MultimediaViewer T64266 Prototype D
// This script is licensed under GPL v2 or any later version. Parts of this script
// are from the MultimediaViewer project licensed under GPLv2 or any later version.
// See https://www.mediawiki.org/wiki/Extension:MultimediaViewer
mw.loader.using( ['mmv.bootstrap.autostart'], function () {
console.log('MultimediaViewer prototype loaded.');
var MMVB = mw.mmv.bootstrap;
// replace MMVB.internalHashChange
MMVB.internalHashChange = function ( e ) {
var hash = e.hash,
title = e.title;
// The advantage of using pushState when it's available is that it has to ability to truly
// clear the hash, not leaving "#" in the history
// An entry with "#" in the history has the side-effect of resetting the scroll position when navigating the history
if ( this.browserHistory && this.browserHistory.pushState ) {
// In order to truly clear the hash, we need to reconstruct the hash-free URL
var cleared = false;
if ( hash === '#' ) {
cleared = true;
hash = window.location.href.replace( /#.*$/, '' );
}
// Only add history entry when entering the lightbox (option D, T64266)
if ( e.target.URL.indexOf( '#mediaviewer/' ) !== -1 && !cleared ) {
this.browserHistory.replaceState( null, title, hash );
} else {
this.browserHistory.pushState( null, title, hash );
}
} else {
// Since we voluntarily changed the hash, we don't want MMVB.hash (which will trigger on hashchange event) to treat it
this.skipNextHashHandling = true;
window.location.hash = hash;
}
document.title = title;
};
} );