PageSourceSearch

https://sharpheels.com/wp-content/themes/sharpheels/js/jquery.ppflip.js?ver=1.8

js sharpheels.com collected 2026-10-03 23:27:37 UTC 13,626 bytes, 429 lines download raw bytes

1var imf = function () {
2	/* //////////// ==== private methods ==== //////////// */
3	var lf = 0;
4	var instances = [];
5	/* ===== read file ==== */
6	var AJAX = (function(AJAX){
7		return function(url){ 
8			var ajax = AJAX();
9			ajax.open("GET", url, false);
10			ajax.send("");
11			return ajax;
12		};
13	})(this.XMLHttpRequest ?
14		function() {return new XMLHttpRequest;} :
15		function() {return new ActiveXObject("Microsoft.XMLHTTP");}
16	);
17	/* ===== custom getElementsByClass ==== */
18	function getElementsByClass (object, tag, className) {
19		var o = object.getElementsByTagName(tag);
20		for ( var i = 0, n = o.length, ret = []; i < n; i++)
21			if (o[i].className == className) ret.push(o[i]);
22		if (ret.length == 1) ret = ret[0];
23		return ret;
24	}
25	/* ===== crossbrowsers addEvent ==== */
26	function addEvent (o, e, f) {
27		if (window.addEventListener) o.addEventListener(e, f, false);
28		else if (window.attachEvent) r = o.attachEvent('on' + e, f);
29	}
30	/* ===== create image reflexion ==== */
31	function createReflexion (cont, img) {
32		var flx = false;
33		
34		if (document.createElement("canvas").getContext) {
35			/* ---- canvas ---- */
36			flx = document.createElement("canvas");
37			flx.width = img.width;
38			flx.height = img.height;
39			var context = flx.getContext("2d");
40			context.translate(0, img.height);
41			context.scale(1, -1);
42			context.drawImage(img, 0, 0, img.width, img.height);
43			
44			flx.style.opacity = '0';
45			
46		} else {
47			/* ---- DXImageTransform ---- */
48			flx     = document.createElement('img');
49			flx.src = img.src;
50			flx.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(' +
51			                   'opacity=50, style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy=' +
52							   (img.height * .25) + ')';
53		}
54		/* ---- insert Reflexion ---- */
55		flx.style.position = 'absolute';
56		flx.style.left     = '-4000px';
57		cont.appendChild(flx);
58		return flx;
59	}
60	/* //////////// ==== ImageFlow Constructor ==== //////////// */
61	function ImageFlow(oCont, xmlfile, horizon, size, zoom, border, start, interval) {
62		this.diapos     = [];
63		this.scr        = false;
64		this.size       = size;
65		this.zoom       = zoom;
66		this.horizon    = horizon;
67		this.bdw        = border;
68		this.oCont      = oCont;
69		this.oc         = document.getElementById(oCont);
70		this.scrollbar  = getElementsByClass(this.oc,   'div', 'scrollbar');
71		this.text       = getElementsByClass(this.oc,   'div', 'text');
72		this.title      = getElementsByClass(this.text, 'div', 'title');
73		this.legend     = getElementsByClass(this.text, 'div', 'legend');
74		this.bar        = getElementsByClass(this.oc,   'img', 'bar');
75		this.arL        = getElementsByClass(this.oc,   'img', 'arrow-left');
76		this.arR        = getElementsByClass(this.oc,   'img', 'arrow-right');
77		this.bw         = this.bar.width;
78		this.alw        = this.arL.width - 5;
79		this.arw        = this.arR.width - 5;
80		this.bar.parent = this.oc.parent  = this;
81		this.arL.parent = this.arR.parent = this;
82		this.view       = this.back       = -1;
83		this.time_start = start * 62.5 || 0;
84		this.time_inter = interval * 62.5 || 0;
85		this.time_out   = this.time_start;
86		this.time       = 0;
87		this.time_dir   = 1;
88		this.resize();
89		this.oc.onselectstart = function () { return false; }
90		/* ---- parse xml ---- */
91		var bank = AJAX(xmlfile).responseXML.getElementsByTagName("bank").item(0).getElementsByTagName("img");
92		this.NF = bank.length;
93		for (var i = 0; i < this.NF; i++) {
94			var img = bank.item(i);
95			var val = function (tag) {
96				var t = img.getElementsByTagName(tag);
97				return (t.length && t[0].firstChild) ? t[0].firstChild.nodeValue : '';
98			}
99			/* ---- create images ---- */
100			this.diapos[i] = new Diapo(this, i, val("src"), val("title"), val("caption"), val("link"), val("target") || '_self');
101		}
102		/* ==== add mouse wheel events ==== */
103		if (window.addEventListener)
104			this.oc.addEventListener('DOMMouseScroll', function(e) {
105				if (e.preventDefault) e.preventDefault();
106				this.parent.scroll(-e.detail);
107				return false;
108			}, false);
109		this.oc.onmousewheel = function () {
110			this.parent.scroll(event.wheelDelta);
111			return false;
112		}
113		/* ==== scrollbar drag N drop ==== */
114		this.bar.onmousedown = function (e) {
115			if (!e) e = window.event;
116			var scl = e.screenX - this.offsetLeft;
117			var self = this.parent;
118			/* ---- move bar ---- */
119			this.parent.oc.onmousemove = function (e) {
120				if (!e) e = window.event;
121				self.bar.style.left = Math.round(Math.min((self.ws - self.arw - self.bw), Math.max(self.alw, e.screenX - scl))) + 'px';
122				self.view = Math.round(((e.screenX - scl) ) / (self.ws - self.alw - self.arw - self.bw) * (self.NF-1));
123				if (self.view != self.back) self.calc();
124				return false;
125			}
126			/* ---- release scrollbar ---- */
127			this.parent.oc.onmouseup = function (e) {
128				self.oc.onmousemove = null;
129				return false;
130			}
131			return false;
132		}
133		/* ==== right arrow ==== */
134		this.arR.onclick = this.arR.ondblclick = function () {
135			if (this.parent.view < this.parent.NF - 1)
136				this.parent.calc(1);
137		}
138		/* ==== Left arrow ==== */
139		this.arL.onclick = this.arL.ondblclick = function () {
140			if (this.parent.view > 0)
141				this.parent.calc(-1);
142		}
143		
144		var flipImf = this;
145		jQuery('#imageFlow').touchwipe({
146        	wipeLeft: function(){ 
147            	flipImf.calc(1);
148          	},
149           	wipeRight: function(){ 
150               flipImf.calc(-1);
151           	}
152      	});
153      	
154      	jQuery("body").keydown(function(e) {
155		  if(e.keyCode == 37) { // left
156			  flipImf.calc(-1);		  }
157		  else if(e.keyCode == 39) { // right
158		  	  flipImf.calc(1);
159		  }
160		});
161	}
162	/* //////////// ==== ImageFlow prototype ==== //////////// */
163	ImageFlow.prototype = {
164		/* ==== targets ==== */
165		calc : function (inc) {
166			if (inc) {
167				this.view += inc;
168				/* ---- stop autoscroll ---- */
169				this.time = 0;
170				this.time_out = this.time_start;
171			}
172			var tw = 0;
173			var lw = 0;
174			var o = this.diapos[this.view];
175			if (o && o.loaded) {
176				/* ---- reset ---- */
177				var ob = this.diapos[this.back];
178				if (ob && ob != o) {
179					ob.img.className = 'diapo';
180					ob.z1 = 1;
181				}
182				/* ---- update legend ---- */
183				this.title.innerHTML = o.title;
184				this.legend.innerHTML = o.text;
185				/* ---- update hyperlink ---- */
186				if (o.url) {
187					o.img.className = 'diapo';
188					window.status = 'hyperlink: ' + o.url;
189				} else {
190					o.img.className = 'diapo current';
191					window.status = '';
192				}
193				/* ---- calculate target sizes & positions ---- */
194				if(o.r < 1) o.w1 = Math.min(o.iw, this.wh * .8, Math.round(this.ht * this.horizon / o.r)) * o.z1;
195				else o.w1 = Math.round(this.ht * this.horizon / o.r) * o.z1;
196				var x0 = o.x1 = (this.wh * .5) - (o.w1 * .5);
197				var x = x0 + o.w1 + this.bdw;
198				for (var i = this.view + 1, o; o = this.diapos[i]; i++) {
199					if (o.loaded) {
200						o.x1 = x;
201						o.w1 = (this.ht / o.r) * this.size;
202						x   += o.w1 + this.bdw;
203						tw  += o.w1 + this.bdw;
204					}
205				}
206				x = x0 - this.bdw;
207				for (var i = this.view - 1, o; o = this.diapos[i]; i--) {
208					if (o.loaded) {
209						o.w1 = (this.ht / o.r) * this.size;
210						o.x1 = x - o.w1;
211						x   -= o.w1 + this.bdw;
212						tw  += o.w1 + this.bdw;
213						lw  += o.w1 + this.bdw;
214					}
215				}
216				/* ---- move scrollbar ---- */
217				/*if (!this.scr && tw) {
218					var r = (this.ws - this.alw - this.arw - this.bw) / tw;
219					this.bar.style.left = Math.round(this.alw + lw * r) + 'px';
220				}*/
221				/* ---- save preview view ---- */
222				this.back = this.view;
223			}
224		},
225		/* ==== mousewheel scrolling ==== */
226		scroll : function (sc) {
227			if (sc < 0) {
228				if (this.view < this.NF - 1) this.calc(1);
229			} else {
230				if (this.view > 0) this.calc(-1);
231			}
232		},
233		/* ==== resize  ==== */
234		resize : function () {
235			this.wh = this.oc.clientWidth;
236			this.ht = this.oc.clientHeight;
237			this.ws = this.scrollbar.offsetWidth;
238			this.calc();
239			this.run(true);
240		},
241		/* ==== animation loop ==== */
242		run : function (res) {
243			/* ---- move all images ---- */
244			var i = this.NF;
245			while (i--) this.diapos[i].move(res);
246			/* ---- autoscroll ---- */
247			/*if (this.time_out) {
248				this.time++;
249				if (this.time > this.time_out) {
250					this.view += this.time_dir;
251					if (this.view >= this.NF || this.view < 0) {
252						this.time_dir = -this.time_dir;
253						this.view += this.time_dir * 2;
254					}
255					this.calc();
256					this.time = 0;
257					this.time_out = this.time_inter;
258				}
259			}*/
260		}
261	}
262	/* //////////// ==== Diapo Constructor ==== //////////// */
263	Diapo = function (parent, N, src, title, text, url, target) {
264		this.parent        = parent;
265		this.loaded        = false;
266		this.title         = title;
267		this.text          = text;
268		this.url           = url;
269		this.target        = target;
270		this.N             = N;
271		this.img           = document.createElement('img');
272		this.img.src       = src;
273		this.img.parent    = this;
274		this.img.className = 'diapo';
275		this.x0            = this.parent.oc.clientWidth;
276		this.x1            = this.x0;
277		this.w0            = 0;
278		this.w1            = 0;
279		this.z1            = 1;
280		this.z2            = 0;
281		this.img.parent    = this;
282		this.img.onclick   = function() { this.parent.click(); }
283		this.parent.oc.appendChild(this.img); 
284		/* ---- display external link ---- */
285		if (url) {
286			this.img.onmouseover = function () { this.className = 'diapo';	}
287			this.img.onmouseout  = function () { this.className = 'diapo'; }
288		}
289	}
290	/* //////////// ==== Diapo prototype ==== //////////// */
291	Diapo.prototype = {
292		/* ==== HTML rendering ==== */
293		move : function (res) {
294			var that = this.parent;
295			if (this.loaded) {
296				var sx = this.x1 - this.x0;
297				var sw = this.w1 - this.w0;
298				if (Math.abs(sx) > 2 || Math.abs(sw) > 2 || res) {
299					/* ---- paint only when moving ---- */
300					this.x0 += sx * .1;
301					this.w0 += sw * .1;
302					var h = this.w0 * this.r;
303					this.z2 = (that.ht * that.horizon + 1 - this.z2 - h) *.5;
304					if (this.x0 < that.wh && this.x0 + this.w0 > 0) {
305						/* ---- paint only visible images ---- */
306						this.visible = true;
307						var o = this.img.style;
308						/* ---- diapo ---- */
309						o.left   = Math.round(this.x0) + 'px';
310						o.bottom = Math.floor(that.ht * (1 - that.horizon) + this.z2) + 'px';
311						o.width  = Math.round(this.w0) + 'px';
312						o.height = Math.floor(h) + 'px';
313						/* ---- reflexion ---- */
314						if (this.flx) {
315							var o = this.flx.style;
316							o.left   = Math.round(this.x0) + 'px';
317							o.top    = Math.ceil(that.ht * that.horizon + 1 - this.z2) + 'px';
318							o.width  = Math.round(this.w0) + 'px';
319							o.height = Math.floor(h) + 'px';
320						}
321					} else {
322						/* ---- disable invisible images ---- */
323						if (this.visible) {
324							this.visible = false;
325							this.img.style.width = '0px';
326							if (this.flx) this.flx.style.width = '0px';
327						}
328					}
329				}
330			} else {
331				/* ==== image onload ==== */
332				if (this.img.complete && this.img.width) {
333					/* ---- get size image ---- */
334					this.iw     = this.img.width;
335					this.ih     = this.img.height;
336					this.r      = this.ih / this.iw;
337					this.loaded = true;
338					/* ---- create reflexion ---- */
339					//this.flx    = createReflexion(that.oc, this.img); 
340					if (that.view < 0) that.view = this.N;
341					else if (this.N == 0) 
342					{
343						/*if($j('#pp_auto_start').val() == 'true' && that.view > 2)
344						{
345							that.view = 2;
346						}
347						else
348						{
349							that.view = this.N;
350						}*/
351						
352						that.view = 1; /* Set auto start to 3rd items */
353					}
354					that.calc();
355				}
356			}
357		},
358		/* ==== diapo onclick ==== */
359		click : function () {
360			/* ---- stop autoscroll ---- */
361			this.parent.time = 0;
362			this.parent.time_out = this.parent.time_start;
363			if (this.parent.view == this.N) {
364				/* ---- click on zoomed diapo ---- */
365				if (this.url) {
366					/* ---- open hyperlink ---- */
367					//$j('#fancy_gallery'+this.N).trigger('click');
368					//window.open(this.url, this.target);
369				} else {
370					/* ---- zoom in/out ---- */
371					/*this.z1 = this.z1 == 1 ? this.parent.zoom : 1;
372					this.parent.calc();*/
373				}
374			} else {
375				/* ---- select diapo ---- */
376				this.parent.view = this.N;
377				this.parent.calc();
378			}
379			return false;
380		}
381	}
382	/* //////////// ==== public methods ==== //////////// */
383	return {
384		/* ==== initialize script ==== */
385		create : function (div, xmlfile, horizon, size, zoom, border, start, interval) {
386			/* ---- instanciate imageFlow ---- */
387			var load = function () {
388				var loaded = false;
389				var i = instances.length;
390				while (i--) if (instances[i].oCont == div) loaded = true;
391				if (!loaded) {
392					/* ---- push new imageFlow instance ---- */
393					instances.push(
394						new ImageFlow(div, xmlfile, horizon, size, zoom, border, start, interval)
395					);
396					/* ---- init script (once) ---- */
397					if (!imf.initialized) {
398						imf.initialized = true;
399						/* ---- window resize event ---- */
400						addEvent(window, 'resize', function () {
401							var i = instances.length;
402							while (i--) instances[i].resize();
403						});
404						/* ---- stop drag N drop ---- */
405						addEvent(document.getElementById(div), 'mouseout', function (e) {
406							if (!e) e = window.event;
407							var tg = e.relatedTarget || e.toElement;
408							if (tg && tg.tagName == 'HTML') {
409								var i = instances.length;
410								while (i--) instances[i].oc.onmousemove = null;
411							}
412							return false;
413						});
414						/* ---- set interval loop ---- */
415						setInterval(function () {
416							var i = instances.length;
417							while (i--) instances[i].run();
418						}, 1);
419					}
420				}
421			}
422			/* ---- window onload event ---- */
423			addEvent(window, 'load', function () { 
424				load(); 
425
426			});
427		}
428	}
429}();

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.