Jump to content

User:Jrajav/myskin.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jrajav (talk | contribs) at 13:18, 15 October 2012. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$(function () {
	$('div.tright, div.tleft').each(function () {
		var fullWidth = $('#column-content').width();
		var originalImage = $(this).find('img').first();
		if (originalImage.length === 0) console.log('What the heck');
		var originalImageWidth = originalImage.width();
		var overlayAnchor = $('<a/>');
		var overlayImage = $('<img/>');

		overlayImage
			.addClass('jrajav-image-overlay')
			.css({
				'position': 'absolute',
				'top': originalImage.offset().top + 'px'
			})
			.css(
				$(this).is('.tright')
				? { 'right': ($(window).width() - (originalImage.offset().left + originalImageWidth)) + 'px' }
				: { 'left': originalImage.offset().left + 'px' } // this is .tleft
			)
			.mouseover(function () { $(this).css({'z-index': 1, 'width': fullWidth}) )
			.mouseout(function () { $(this).css({'z-index': 2, 'width': originalImageWidth}) )
			.load(function () {	
				fullWidth = ((this.width < fullWidth) ? this.width : fullWidth);
				overlayImage.width(originalImageWidth);
				overlayAnchor.show();
				//overlayImage.delay(0).trigger('mouseover');
			});


		overlayAnchor
			.hide()
			.attr('href', $(this).find('a').first().attr('href'))
			.append(overlayImage);
			
		$('body').prepend(overlayAnchor);

		originalImage.mouseover(function () {
			overlayImage.attr('src', originalImage.attr('src').replace('/thumb/', '/').replace(/\/\d*px.*$/, ''));
			$(this).off('mouseover');
		});
	});

	$('#searchInput')
		.attr('tabindex', 1)
		.attr('placeholder', 'Search');
});