Difference between revisions 338437 and 338532 on plwikiquote

mw.loader.using( "ext.gadget.lib-toolbar", function() {
	toolbarGadget.addButton( {
		title: 'źródło',
		alt: 'źródło',
		icon: '//http://upload.wikimedia.org/wikipedia/commons/4/4c/RomanZ-01.svg/22px-RomanZ-01.svg',
		onclick: function() {
			mw.toolbar.insertTags( '** Źródło: ', '', '', '' )
		},
(contracted; show full)
*/
if ( mw.config.get( 'wgServer' ).indexOf('https://') == 0 ) {
        mw.loader.load( 'https://secure.wikimedia.org/wikipedia/commons/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript' );
} else {
        mw.loader.load( 'http://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript' );
}
 
var hotcat_no_autocommit = true;


// Original version:
// - QuickHistory script by [[:pl:User:ChP94]]
// - Released under the [http://www.gnu.org/licenses/gpl.txt GNU Public License (GPL)]
// Modified by [[:pl:User:Beau]]
 
/* Translatable strings */
mw.messages.set( {
	'quickhistory-close': 'Zamknij.'
} );
 
 
window.quickHistoryGagdet = {
	/** Version of the gadget */
	version: 4,
	limit: 15,
	panel: null,
	timer: null,
	trigger: null,
 
	init: function() {
		var that = this;
 
		var events = {
			mousemove: function() {
				if ( !that.timer ) {
					that.timer = setTimeout( function() {
						that.showHistory()
					}, 500 );
					that.trigger = this;
				}
			},
			mouseout: function() {
				if ( that.timer ) {
					clearTimeout( that.timer );
					that.timer = null;
				}
			}
		};
 
		jQuery( "#ca-history" ).bind( events );
		jQuery( "[rel=archives]" ).bind( events );
	},
 
	showHistory: function() {
		var that = this;
		if ( this.panel ) {
			return;
		}
		this.panel = document.createElement( "div" );
		this.panel.style.cssText = "background-color: #FDF5E6; display: none; position: absolute; z-index: 200";
 
		var divClose = document.createElement( "div" );
		divClose.style.cssText = "background-color: #CD853F; width: 100%; text-align: center; cursor:pointer; color: #FDF5E6;";
		divClose.appendChild( document.createTextNode( mw.msg( 'quickhistory-close' ) ) );
		divClose.onclick = function() {
			that.hideHistory();
		};
		this.panel.appendChild( divClose );
 
		var divHistory = document.createElement( "div" );
		this.panel.appendChild( divHistory );
 
		this.panel.style.top = ( jQuery( this.trigger ).offset().top + jQuery( this.trigger ).height() + 2 ) + "px";
		var width = Math.round( document.body.clientWidth * 0.7 );
 
		var left = jQuery( this.trigger ).offset().left + ( jQuery( this.trigger ).width() / 2 ) - ( width / 2 );
		if ( left < 0 ) {
			left = 0;
		} else if ( left + width > document.body.clientWidth ) {
			left = document.body.clientWidth - width;
		}
		this.panel.style.width = width + "px";
		this.panel.style.left = left + "px";
 
		document.body.appendChild( this.panel );
 
		jQuery( divHistory ).load(
		mw.util.wikiScript() + '?limit=' + this.limit + '&title=' + encodeURIComponent( mw.config.get( "wgPageName" ) ) + '&action=history #mw-history-compare', function() {
			that.panel.style.display = "block";
		} );
	},
 
	hideHistory: function() {
		if ( this.panel ) {
			document.body.removeChild( this.panel );
			this.panel = null;
		}
	}
};
 
jQuery( document ).ready( function() {
	quickHistoryGagdet.init();
} );