PageSourceSearch

https://legacy.theskepticsguide.org/wp-content/themes/grizzly-theme/libs/jquery.retina-0.1.js?ver=3.0.9

js theskepticsguide.org collected 2026-09-24 09:23:34 UTC 5,597 bytes, 155 lines download raw bytes

1;(function($){
2	/**
3	 * @author Ti ($.fn.retina)                http://3apaxi.com/      [email protected]
4	 * @author Martin Angelov (idea, example)  http://tutorialzine.com/2010/06/apple-like-retina-effect-jquery-css/
5	 * @version 0.1 (07.10.2010)
6	 */
7	$.fn.retina = function(options) {
8		options = $.extend(true, {
9			// default options:
10			enable: true,         // false to deattach retina
11			css: {},              // custom css
12			appendTo: 'body',     // 
13			src: null,			  // src of large iamge (else use rel, src or href attrs)
14			radius: null,		  // css radius (null - auto)
15			ie: {
16				css3pie: 'PIE.htc',  // URI of css3pie (for IE)
17				cursor: 'blank.cur' // URI of blank.cur (for IE)
18			},
19			preload: false	 	  // preload large image?
20		}, options)
21		
22		// attach
23		if (options.enable) {
24			this.each(function() {
25				if (this.retina) this.retina.deattach() // reattach retina
26				this.retina = new Retina(this, options.src || $(this).attr('rel') || $(this).attr('src') || $(this).attr('href'), options)
27			})
28		}
29		// deattach
30		else {
31			this.each(function() {
32				if (this.retina) {
33					this.retina.deattach()
34					delete this.retina
35				}
36			})
37		}
38		return this
39	}
40
41	var Retina = function(element, largeImage, options) {
42		var _this = this
43		var node = $(element)
44		var glass
45		var oldIe
46
47		var init = function() {
48			oldIe = $.browser.msie && /^[5-8]\./.test($.browser.version)
49
50			var getCursor = function() {
51				if (oldIe && options.ie.cursor) return 'url('+options.ie.cursor+'),crosshair'
52				if ($.browser.mozilla || $.browser.opera) return 'none'
53				var blankCur = 'AAACAAEAICAAAAAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD//wD/AAAA/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////w=='
54				if ($.browser.webkit) blankCur = blankCur.slice(0, 829)+'P'+blankCur.slice(830,1016)+'f'+blankCur.slice(1017)
55				return 'url(data:text/plain;base64,'+blankCur+'),none'
56			}
57
58			glass = $('<div></div>')
59			glass.css($.extend(true, {
60				display: 'none',
61				
62				background: 'no-repeat center center white url('+largeImage+')',
63				border: '2px solid white',
64				
65				/* Positioned absolutely, so we can move it around */
66				position: 'absolute',
67				top: 0,
68				left: 0,
69				height: 180,
70				width: 180,
71
72				/* CSS3 Box Shadow */
73				boxShadow: '0 0 5px #777, 0 0 10px #aaa inset',
74				'-webkit-box-shadow': '0 0 5px #777',
75				'-moz-box-shadow': '0 0 5px #777, 0 0 10px #aaa inset',
76
77				cursor: getCursor()
78			}, options.css))
79			glass.appendTo(options.appendTo)
80	
81			var radius = options.radius || Math.min(glass.width(),glass.height())/2 +'px'
82			glass.css({
83				/* CSS3 rounded corners */
84				borderRadius: radius,
85				'-webkit-border-radius': radius,
86				'-moz-border-radius': radius
87			})
88
89			if (oldIe && options.ie.css3pie) glass.css('behavior', 'url('+options.ie.css3pie+')')
90
91			$(document).bind('mousemove', _this.move)
92
93			// on load image - recalculate size
94			node.find('img').add(node).load(_this.loadSize)
95			$(window).resize(_this.loadSize)
96
97			init = $.noop
98		}
99
100		var offset, width, height, glassWidth, glassHeight
101		_this.loadSize = function() {
102			offset = node.offset()
103			width = node.width()
104			height = node.height()
105			glassWidth = glass.width()
106			glassHeight = glass.height()
107		}
108
109		_this.show = function(e) {
110			init()
111			_this.loadSize()
112			if (oldIe && options.ie.css3pie) glass.show()
113			else glass.stop(true, true).fadeIn('fast')
114			_this.move(e)
115		}
116		
117		_this.hide = function() {
118			if (oldIe && options.ie.css3pie) glass.hide()
119			else glass.stop(true, true).fadeOut('fast')
120		}
121		
122
123		_this.move = function(e) {
124			// mouse out
125
126			if (e.pageX < offset.left || e.pageY < offset.top) return _this.hide()
127			if (offset.left + width < e.pageX) return _this.hide()
128			if (offset.top + height < e.pageY) return _this.hide()
129
130			glass.css({
131				// moving the retina div with the mouse
132				marginLeft: e.pageX - glassWidth/2, // left and top css not work in ie with css3pie!
133				marginTop: e.pageY - glassHeight/2,
134
135				// scrolling the background
136				backgroundPosition: ( (100/width) * (e.pageX - offset.left) )+'% '+( (100/height) * (e.pageY - offset.top) )+'%'
137			})
138		}
139		
140		_this.deattach = function() {
141			node.unbind('mouseenter', _this.show)
142			if (glass) {
143				glass.remove()
144				$(document).unbind('mousemove', _this.move)
145				node.find('img').add(node).unbind('load', _this.loadSize)
146				$(window).unbind('resize', _this.loadSize)
147			}
148		}
149
150		node.bind('mouseenter', _this.show)
151
152		// preload
153		if (options.preload) $(new Image).attr('src', largeImage)
154	}
155})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.