PageSourceSearch

http://cwgland.cz/core/moo.fx.js

js cwgland.cz collected 2026-10-08 07:44:11 UTC 3,267 bytes, 133 lines download raw bytes

1/*
2moo.fx, simple effects library built with prototype.js (http://prototype.conio.net).
3by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE.
4for more info (http://moofx.mad4milk.net).
5Sunday, March 05, 2006
6v 1.2.3
7*/
8
9var fx = new Object();
10//base
11fx.Base = function(){};
12fx.Base.prototype = {
13	setOptions: function(options) {
14	this.options = {
15		duration: 500,
16		onComplete: '',
17		transition: fx.sinoidal
18	}
19	Object.extend(this.options, options || {});
20	},
21
22	step: function() {
23		var time  = (new Date).getTime();
24		if (time >= this.options.duration+this.startTime) {
25			this.now = this.to;
26			clearInterval (this.timer);
27			this.timer = null;
28			if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10);
29		}
30		else {
31			var Tpos = (time - this.startTime) / (this.options.duration);
32			this.now = this.options.transition(Tpos) * (this.to-this.from) + this.from;
33		}
34		this.increase();
35	},
36
37	custom: function(from, to) {
38		if (this.timer != null) return;
39		this.from = from;
40		this.to = to;
41		this.startTime = (new Date).getTime();
42		this.timer = setInterval (this.step.bind(this), 13);
43	},
44
45	hide: function() {
46		this.now = 0;
47		this.increase();
48	},
49
50	clearTimer: function() {
51		clearInterval(this.timer);
52		this.timer = null;
53	}
54}
55
56//stretchers
57fx.Layout = Class.create();
58fx.Layout.prototype = Object.extend(new fx.Base(), {
59	initialize: function(el, options) {
60		this.el = $(el);
61		this.el.style.overflow = "hidden";
62		this.iniWidth = this.el.offsetWidth;
63		this.iniHeight = this.el.offsetHeight;
64		this.setOptions(options);
65	}
66});
67
68fx.Height = Class.create();
69Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), {	
70	increase: function() {
71		this.el.style.height = this.now + "px";
72	},
73
74	toggle: function() {
75		if (this.el.offsetHeight > 0) this.custom(this.el.offsetHeight, 0);
76		else this.custom(0, this.el.scrollHeight);
77	}
78});
79
80fx.Width = Class.create();
81Object.extend(Object.extend(fx.Width.prototype, fx.Layout.prototype), {	
82	increase: function() {
83		this.el.style.width = this.now + "px";
84	},
85
86	toggle: function(){
87		if (this.el.offsetWidth > 0) this.custom(this.el.offsetWidth, 0);
88		else this.custom(0, this.iniWidth);
89	}
90});
91
92//fader
93fx.Opacity = Class.create();
94fx.Opacity.prototype = Object.extend(new fx.Base(), {
95	initialize: function(el, options) {
96		this.el = $(el);
97		this.now = 1;
98		this.increase();
99		this.setOptions(options);
100	},
101
102	increase: function() {
103		if (this.now == 1 && (/Firefox/.test(navigator.userAgent))) this.now = 0.9999;
104		this.setOpacity(this.now);
105	},
106	
107	setOpacity: function(opacity) {
108		if (opacity == 0 && this.el.style.visibility != "hidden") this.el.style.visibility = "hidden";
109		else if (this.el.style.visibility != "visible") this.el.style.visibility = "visible";
110		if (window.ActiveXObject) this.el.style.filter = "alpha(opacity=" + opacity*100 + ")";
111		this.el.style.opacity = opacity;
112	},
113
114	toggle: function() {
115		if (this.now > 0) this.custom(1, 0);
116		else this.custom(0, 1);
117	}
118});
119
120//transitions
121fx.sinoidal = function(pos){
122	return ((-Math.cos(pos*Math.PI)/2) + 0.5);
123	//this transition is from script.aculo.us
124}
125fx.linear = function(pos){
126	return pos;
127}
128fx.cubic = function(pos){
129	return Math.pow(pos, 3);
130}
131fx.circ = function(pos){
132	return Math.sqrt(pos);
133}

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.