nov-ruby-openid 2.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +215 -0
- data/CHANGES-2.1.0 +36 -0
- data/INSTALL +47 -0
- data/LICENSE +210 -0
- data/NOTICE +2 -0
- data/README +81 -0
- data/Rakefile +98 -0
- data/UPGRADE +127 -0
- data/VERSION +1 -0
- data/contrib/google/ruby-openid-apps-discovery-1.0.gem +0 -0
- data/contrib/google/ruby-openid-apps-discovery-1.01.gem +0 -0
- data/examples/README +32 -0
- data/examples/active_record_openid_store/README +58 -0
- data/examples/active_record_openid_store/XXX_add_open_id_store_to_db.rb +24 -0
- data/examples/active_record_openid_store/XXX_upgrade_open_id_store.rb +26 -0
- data/examples/active_record_openid_store/init.rb +8 -0
- data/examples/active_record_openid_store/lib/association.rb +10 -0
- data/examples/active_record_openid_store/lib/nonce.rb +3 -0
- data/examples/active_record_openid_store/lib/open_id_setting.rb +4 -0
- data/examples/active_record_openid_store/lib/openid_ar_store.rb +57 -0
- data/examples/active_record_openid_store/test/store_test.rb +212 -0
- data/examples/discover +49 -0
- data/examples/rails_openid/README +153 -0
- data/examples/rails_openid/Rakefile +10 -0
- data/examples/rails_openid/app/controllers/application.rb +4 -0
- data/examples/rails_openid/app/controllers/consumer_controller.rb +122 -0
- data/examples/rails_openid/app/controllers/login_controller.rb +45 -0
- data/examples/rails_openid/app/controllers/server_controller.rb +265 -0
- data/examples/rails_openid/app/helpers/application_helper.rb +3 -0
- data/examples/rails_openid/app/helpers/login_helper.rb +2 -0
- data/examples/rails_openid/app/helpers/server_helper.rb +9 -0
- data/examples/rails_openid/app/views/consumer/index.rhtml +81 -0
- data/examples/rails_openid/app/views/layouts/server.rhtml +68 -0
- data/examples/rails_openid/app/views/login/index.rhtml +56 -0
- data/examples/rails_openid/app/views/server/decide.rhtml +26 -0
- data/examples/rails_openid/config/boot.rb +19 -0
- data/examples/rails_openid/config/database.yml +74 -0
- data/examples/rails_openid/config/environment.rb +54 -0
- data/examples/rails_openid/config/environments/development.rb +19 -0
- data/examples/rails_openid/config/environments/production.rb +19 -0
- data/examples/rails_openid/config/environments/test.rb +19 -0
- data/examples/rails_openid/config/routes.rb +24 -0
- data/examples/rails_openid/doc/README_FOR_APP +2 -0
- data/examples/rails_openid/public/.htaccess +40 -0
- data/examples/rails_openid/public/404.html +8 -0
- data/examples/rails_openid/public/500.html +8 -0
- data/examples/rails_openid/public/dispatch.cgi +12 -0
- data/examples/rails_openid/public/dispatch.fcgi +26 -0
- data/examples/rails_openid/public/dispatch.rb +12 -0
- data/examples/rails_openid/public/favicon.ico +0 -0
- data/examples/rails_openid/public/images/openid_login_bg.gif +0 -0
- data/examples/rails_openid/public/javascripts/controls.js +750 -0
- data/examples/rails_openid/public/javascripts/dragdrop.js +584 -0
- data/examples/rails_openid/public/javascripts/effects.js +854 -0
- data/examples/rails_openid/public/javascripts/prototype.js +1785 -0
- data/examples/rails_openid/public/robots.txt +1 -0
- data/examples/rails_openid/script/about +3 -0
- data/examples/rails_openid/script/breakpointer +3 -0
- data/examples/rails_openid/script/console +3 -0
- data/examples/rails_openid/script/destroy +3 -0
- data/examples/rails_openid/script/generate +3 -0
- data/examples/rails_openid/script/performance/benchmarker +3 -0
- data/examples/rails_openid/script/performance/profiler +3 -0
- data/examples/rails_openid/script/plugin +3 -0
- data/examples/rails_openid/script/process/reaper +3 -0
- data/examples/rails_openid/script/process/spawner +3 -0
- data/examples/rails_openid/script/process/spinner +3 -0
- data/examples/rails_openid/script/runner +3 -0
- data/examples/rails_openid/script/server +3 -0
- data/examples/rails_openid/test/functional/login_controller_test.rb +18 -0
- data/examples/rails_openid/test/functional/server_controller_test.rb +18 -0
- data/examples/rails_openid/test/test_helper.rb +28 -0
- data/lib/hmac/hmac.rb +112 -0
- data/lib/hmac/sha1.rb +11 -0
- data/lib/hmac/sha2.rb +25 -0
- data/lib/openid.rb +20 -0
- data/lib/openid/association.rb +249 -0
- data/lib/openid/consumer.rb +395 -0
- data/lib/openid/consumer/associationmanager.rb +344 -0
- data/lib/openid/consumer/checkid_request.rb +186 -0
- data/lib/openid/consumer/discovery.rb +497 -0
- data/lib/openid/consumer/discovery_manager.rb +123 -0
- data/lib/openid/consumer/html_parse.rb +134 -0
- data/lib/openid/consumer/idres.rb +523 -0
- data/lib/openid/consumer/responses.rb +148 -0
- data/lib/openid/cryptutil.rb +115 -0
- data/lib/openid/dh.rb +89 -0
- data/lib/openid/extension.rb +39 -0
- data/lib/openid/extensions/ax.rb +539 -0
- data/lib/openid/extensions/oauth.rb +91 -0
- data/lib/openid/extensions/pape.rb +179 -0
- data/lib/openid/extensions/sreg.rb +277 -0
- data/lib/openid/extensions/ui.rb +53 -0
- data/lib/openid/extras.rb +11 -0
- data/lib/openid/fetchers.rb +258 -0
- data/lib/openid/kvform.rb +136 -0
- data/lib/openid/kvpost.rb +58 -0
- data/lib/openid/message.rb +553 -0
- data/lib/openid/protocolerror.rb +8 -0
- data/lib/openid/server.rb +1544 -0
- data/lib/openid/store/filesystem.rb +271 -0
- data/lib/openid/store/interface.rb +75 -0
- data/lib/openid/store/memcache.rb +107 -0
- data/lib/openid/store/memory.rb +84 -0
- data/lib/openid/store/nonce.rb +68 -0
- data/lib/openid/trustroot.rb +349 -0
- data/lib/openid/urinorm.rb +75 -0
- data/lib/openid/util.rb +110 -0
- data/lib/openid/yadis/accept.rb +148 -0
- data/lib/openid/yadis/constants.rb +21 -0
- data/lib/openid/yadis/discovery.rb +153 -0
- data/lib/openid/yadis/filters.rb +205 -0
- data/lib/openid/yadis/htmltokenizer.rb +305 -0
- data/lib/openid/yadis/parsehtml.rb +45 -0
- data/lib/openid/yadis/services.rb +42 -0
- data/lib/openid/yadis/xrds.rb +155 -0
- data/lib/openid/yadis/xri.rb +90 -0
- data/lib/openid/yadis/xrires.rb +99 -0
- data/setup.rb +1551 -0
- data/test/data/accept.txt +124 -0
- data/test/data/dh.txt +29 -0
- data/test/data/example-xrds.xml +14 -0
- data/test/data/linkparse.txt +587 -0
- data/test/data/n2b64 +650 -0
- data/test/data/test1-discover.txt +137 -0
- data/test/data/test1-parsehtml.txt +152 -0
- data/test/data/test_discover/malformed_meta_tag.html +19 -0
- data/test/data/test_discover/openid.html +11 -0
- data/test/data/test_discover/openid2.html +11 -0
- data/test/data/test_discover/openid2_xrds.xml +12 -0
- data/test/data/test_discover/openid2_xrds_no_local_id.xml +11 -0
- data/test/data/test_discover/openid_1_and_2.html +11 -0
- data/test/data/test_discover/openid_1_and_2_xrds.xml +16 -0
- data/test/data/test_discover/openid_1_and_2_xrds_bad_delegate.xml +17 -0
- data/test/data/test_discover/openid_and_yadis.html +12 -0
- data/test/data/test_discover/openid_no_delegate.html +10 -0
- data/test/data/test_discover/openid_utf8.html +11 -0
- data/test/data/test_discover/yadis_0entries.xml +12 -0
- data/test/data/test_discover/yadis_2_bad_local_id.xml +15 -0
- data/test/data/test_discover/yadis_2entries_delegate.xml +22 -0
- data/test/data/test_discover/yadis_2entries_idp.xml +21 -0
- data/test/data/test_discover/yadis_another_delegate.xml +14 -0
- data/test/data/test_discover/yadis_idp.xml +12 -0
- data/test/data/test_discover/yadis_idp_delegate.xml +13 -0
- data/test/data/test_discover/yadis_no_delegate.xml +11 -0
- data/test/data/test_xrds/=j3h.2007.11.14.xrds +25 -0
- data/test/data/test_xrds/README +12 -0
- data/test/data/test_xrds/delegated-20060809-r1.xrds +34 -0
- data/test/data/test_xrds/delegated-20060809-r2.xrds +34 -0
- data/test/data/test_xrds/delegated-20060809.xrds +34 -0
- data/test/data/test_xrds/no-xrd.xml +7 -0
- data/test/data/test_xrds/not-xrds.xml +2 -0
- data/test/data/test_xrds/prefixsometimes.xrds +34 -0
- data/test/data/test_xrds/ref.xrds +109 -0
- data/test/data/test_xrds/sometimesprefix.xrds +34 -0
- data/test/data/test_xrds/spoof1.xrds +25 -0
- data/test/data/test_xrds/spoof2.xrds +25 -0
- data/test/data/test_xrds/spoof3.xrds +37 -0
- data/test/data/test_xrds/status222.xrds +9 -0
- data/test/data/test_xrds/subsegments.xrds +58 -0
- data/test/data/test_xrds/valid-populated-xrds.xml +39 -0
- data/test/data/trustroot.txt +153 -0
- data/test/data/urinorm.txt +79 -0
- data/test/discoverdata.rb +131 -0
- data/test/test_accept.rb +170 -0
- data/test/test_association.rb +266 -0
- data/test/test_associationmanager.rb +917 -0
- data/test/test_ax.rb +690 -0
- data/test/test_checkid_request.rb +294 -0
- data/test/test_consumer.rb +257 -0
- data/test/test_cryptutil.rb +119 -0
- data/test/test_dh.rb +86 -0
- data/test/test_discover.rb +852 -0
- data/test/test_discovery_manager.rb +262 -0
- data/test/test_extension.rb +46 -0
- data/test/test_extras.rb +35 -0
- data/test/test_fetchers.rb +565 -0
- data/test/test_filters.rb +270 -0
- data/test/test_idres.rb +963 -0
- data/test/test_kvform.rb +165 -0
- data/test/test_kvpost.rb +65 -0
- data/test/test_linkparse.rb +101 -0
- data/test/test_message.rb +1116 -0
- data/test/test_nonce.rb +89 -0
- data/test/test_oauth.rb +175 -0
- data/test/test_openid_yadis.rb +178 -0
- data/test/test_pape.rb +247 -0
- data/test/test_parsehtml.rb +80 -0
- data/test/test_responses.rb +63 -0
- data/test/test_server.rb +2457 -0
- data/test/test_sreg.rb +479 -0
- data/test/test_stores.rb +298 -0
- data/test/test_trustroot.rb +113 -0
- data/test/test_ui.rb +93 -0
- data/test/test_urinorm.rb +35 -0
- data/test/test_util.rb +145 -0
- data/test/test_xrds.rb +169 -0
- data/test/test_xri.rb +48 -0
- data/test/test_xrires.rb +63 -0
- data/test/test_yadis_discovery.rb +220 -0
- data/test/testutil.rb +127 -0
- data/test/util.rb +53 -0
- metadata +336 -0
@@ -0,0 +1,854 @@
|
|
1
|
+
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
2
|
+
// Contributors:
|
3
|
+
// Justin Palmer (http://encytemedia.com/)
|
4
|
+
// Mark Pilgrim (http://diveintomark.org/)
|
5
|
+
// Martin Bialasinki
|
6
|
+
//
|
7
|
+
// See scriptaculous.js for full license.
|
8
|
+
|
9
|
+
/* ------------- element ext -------------- */
|
10
|
+
|
11
|
+
// converts rgb() and #xxx to #xxxxxx format,
|
12
|
+
// returns self (or first argument) if not convertable
|
13
|
+
String.prototype.parseColor = function() {
|
14
|
+
var color = '#';
|
15
|
+
if(this.slice(0,4) == 'rgb(') {
|
16
|
+
var cols = this.slice(4,this.length-1).split(',');
|
17
|
+
var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
|
18
|
+
} else {
|
19
|
+
if(this.slice(0,1) == '#') {
|
20
|
+
if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();
|
21
|
+
if(this.length==7) color = this.toLowerCase();
|
22
|
+
}
|
23
|
+
}
|
24
|
+
return(color.length==7 ? color : (arguments[0] || this));
|
25
|
+
}
|
26
|
+
|
27
|
+
Element.collectTextNodesIgnoreClass = function(element, ignoreclass) {
|
28
|
+
var children = $(element).childNodes;
|
29
|
+
var text = '';
|
30
|
+
var classtest = new RegExp('^([^ ]+ )*' + ignoreclass+ '( [^ ]+)*$','i');
|
31
|
+
|
32
|
+
for (var i = 0; i < children.length; i++) {
|
33
|
+
if(children[i].nodeType==3) {
|
34
|
+
text+=children[i].nodeValue;
|
35
|
+
} else {
|
36
|
+
if((!children[i].className.match(classtest)) && children[i].hasChildNodes())
|
37
|
+
text += Element.collectTextNodesIgnoreClass(children[i], ignoreclass);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
return text;
|
42
|
+
}
|
43
|
+
|
44
|
+
Element.setStyle = function(element, style) {
|
45
|
+
element = $(element);
|
46
|
+
for(k in style) element.style[k.camelize()] = style[k];
|
47
|
+
}
|
48
|
+
|
49
|
+
Element.setContentZoom = function(element, percent) {
|
50
|
+
Element.setStyle(element, {fontSize: (percent/100) + 'em'});
|
51
|
+
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
|
52
|
+
}
|
53
|
+
|
54
|
+
Element.getOpacity = function(element){
|
55
|
+
var opacity;
|
56
|
+
if (opacity = Element.getStyle(element, 'opacity'))
|
57
|
+
return parseFloat(opacity);
|
58
|
+
if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/))
|
59
|
+
if(opacity[1]) return parseFloat(opacity[1]) / 100;
|
60
|
+
return 1.0;
|
61
|
+
}
|
62
|
+
|
63
|
+
Element.setOpacity = function(element, value){
|
64
|
+
element= $(element);
|
65
|
+
if (value == 1){
|
66
|
+
Element.setStyle(element, { opacity:
|
67
|
+
(/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ?
|
68
|
+
0.999999 : null });
|
69
|
+
if(/MSIE/.test(navigator.userAgent))
|
70
|
+
Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});
|
71
|
+
} else {
|
72
|
+
if(value < 0.00001) value = 0;
|
73
|
+
Element.setStyle(element, {opacity: value});
|
74
|
+
if(/MSIE/.test(navigator.userAgent))
|
75
|
+
Element.setStyle(element,
|
76
|
+
{ filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
|
77
|
+
'alpha(opacity='+value*100+')' });
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
Element.getInlineOpacity = function(element){
|
82
|
+
return $(element).style.opacity || '';
|
83
|
+
}
|
84
|
+
|
85
|
+
Element.childrenWithClassName = function(element, className) {
|
86
|
+
return $A($(element).getElementsByTagName('*')).select(
|
87
|
+
function(c) { return Element.hasClassName(c, className) });
|
88
|
+
}
|
89
|
+
|
90
|
+
Array.prototype.call = function() {
|
91
|
+
var args = arguments;
|
92
|
+
this.each(function(f){ f.apply(this, args) });
|
93
|
+
}
|
94
|
+
|
95
|
+
/*--------------------------------------------------------------------------*/
|
96
|
+
|
97
|
+
var Effect = {
|
98
|
+
tagifyText: function(element) {
|
99
|
+
var tagifyStyle = 'position:relative';
|
100
|
+
if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1';
|
101
|
+
element = $(element);
|
102
|
+
$A(element.childNodes).each( function(child) {
|
103
|
+
if(child.nodeType==3) {
|
104
|
+
child.nodeValue.toArray().each( function(character) {
|
105
|
+
element.insertBefore(
|
106
|
+
Builder.node('span',{style: tagifyStyle},
|
107
|
+
character == ' ' ? String.fromCharCode(160) : character),
|
108
|
+
child);
|
109
|
+
});
|
110
|
+
Element.remove(child);
|
111
|
+
}
|
112
|
+
});
|
113
|
+
},
|
114
|
+
multiple: function(element, effect) {
|
115
|
+
var elements;
|
116
|
+
if(((typeof element == 'object') ||
|
117
|
+
(typeof element == 'function')) &&
|
118
|
+
(element.length))
|
119
|
+
elements = element;
|
120
|
+
else
|
121
|
+
elements = $(element).childNodes;
|
122
|
+
|
123
|
+
var options = Object.extend({
|
124
|
+
speed: 0.1,
|
125
|
+
delay: 0.0
|
126
|
+
}, arguments[2] || {});
|
127
|
+
var masterDelay = options.delay;
|
128
|
+
|
129
|
+
$A(elements).each( function(element, index) {
|
130
|
+
new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
|
131
|
+
});
|
132
|
+
}
|
133
|
+
};
|
134
|
+
|
135
|
+
var Effect2 = Effect; // deprecated
|
136
|
+
|
137
|
+
/* ------------- transitions ------------- */
|
138
|
+
|
139
|
+
Effect.Transitions = {}
|
140
|
+
|
141
|
+
Effect.Transitions.linear = function(pos) {
|
142
|
+
return pos;
|
143
|
+
}
|
144
|
+
Effect.Transitions.sinoidal = function(pos) {
|
145
|
+
return (-Math.cos(pos*Math.PI)/2) + 0.5;
|
146
|
+
}
|
147
|
+
Effect.Transitions.reverse = function(pos) {
|
148
|
+
return 1-pos;
|
149
|
+
}
|
150
|
+
Effect.Transitions.flicker = function(pos) {
|
151
|
+
return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
|
152
|
+
}
|
153
|
+
Effect.Transitions.wobble = function(pos) {
|
154
|
+
return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
|
155
|
+
}
|
156
|
+
Effect.Transitions.pulse = function(pos) {
|
157
|
+
return (Math.floor(pos*10) % 2 == 0 ?
|
158
|
+
(pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10)));
|
159
|
+
}
|
160
|
+
Effect.Transitions.none = function(pos) {
|
161
|
+
return 0;
|
162
|
+
}
|
163
|
+
Effect.Transitions.full = function(pos) {
|
164
|
+
return 1;
|
165
|
+
}
|
166
|
+
|
167
|
+
/* ------------- core effects ------------- */
|
168
|
+
|
169
|
+
Effect.Queue = {
|
170
|
+
effects: [],
|
171
|
+
_each: function(iterator) {
|
172
|
+
this.effects._each(iterator);
|
173
|
+
},
|
174
|
+
interval: null,
|
175
|
+
add: function(effect) {
|
176
|
+
var timestamp = new Date().getTime();
|
177
|
+
|
178
|
+
switch(effect.options.queue) {
|
179
|
+
case 'front':
|
180
|
+
// move unstarted effects after this effect
|
181
|
+
this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
|
182
|
+
e.startOn += effect.finishOn;
|
183
|
+
e.finishOn += effect.finishOn;
|
184
|
+
});
|
185
|
+
break;
|
186
|
+
case 'end':
|
187
|
+
// start effect after last queued effect has finished
|
188
|
+
timestamp = this.effects.pluck('finishOn').max() || timestamp;
|
189
|
+
break;
|
190
|
+
}
|
191
|
+
|
192
|
+
effect.startOn += timestamp;
|
193
|
+
effect.finishOn += timestamp;
|
194
|
+
this.effects.push(effect);
|
195
|
+
if(!this.interval)
|
196
|
+
this.interval = setInterval(this.loop.bind(this), 40);
|
197
|
+
},
|
198
|
+
remove: function(effect) {
|
199
|
+
this.effects = this.effects.reject(function(e) { return e==effect });
|
200
|
+
if(this.effects.length == 0) {
|
201
|
+
clearInterval(this.interval);
|
202
|
+
this.interval = null;
|
203
|
+
}
|
204
|
+
},
|
205
|
+
loop: function() {
|
206
|
+
var timePos = new Date().getTime();
|
207
|
+
this.effects.invoke('loop', timePos);
|
208
|
+
}
|
209
|
+
}
|
210
|
+
Object.extend(Effect.Queue, Enumerable);
|
211
|
+
|
212
|
+
Effect.Base = function() {};
|
213
|
+
Effect.Base.prototype = {
|
214
|
+
position: null,
|
215
|
+
setOptions: function(options) {
|
216
|
+
this.options = Object.extend({
|
217
|
+
transition: Effect.Transitions.sinoidal,
|
218
|
+
duration: 1.0, // seconds
|
219
|
+
fps: 25.0, // max. 25fps due to Effect.Queue implementation
|
220
|
+
sync: false, // true for combining
|
221
|
+
from: 0.0,
|
222
|
+
to: 1.0,
|
223
|
+
delay: 0.0,
|
224
|
+
queue: 'parallel'
|
225
|
+
}, options || {});
|
226
|
+
},
|
227
|
+
start: function(options) {
|
228
|
+
this.setOptions(options || {});
|
229
|
+
this.currentFrame = 0;
|
230
|
+
this.state = 'idle';
|
231
|
+
this.startOn = this.options.delay*1000;
|
232
|
+
this.finishOn = this.startOn + (this.options.duration*1000);
|
233
|
+
this.event('beforeStart');
|
234
|
+
if(!this.options.sync) Effect.Queue.add(this);
|
235
|
+
},
|
236
|
+
loop: function(timePos) {
|
237
|
+
if(timePos >= this.startOn) {
|
238
|
+
if(timePos >= this.finishOn) {
|
239
|
+
this.render(1.0);
|
240
|
+
this.cancel();
|
241
|
+
this.event('beforeFinish');
|
242
|
+
if(this.finish) this.finish();
|
243
|
+
this.event('afterFinish');
|
244
|
+
return;
|
245
|
+
}
|
246
|
+
var pos = (timePos - this.startOn) / (this.finishOn - this.startOn);
|
247
|
+
var frame = Math.round(pos * this.options.fps * this.options.duration);
|
248
|
+
if(frame > this.currentFrame) {
|
249
|
+
this.render(pos);
|
250
|
+
this.currentFrame = frame;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
},
|
254
|
+
render: function(pos) {
|
255
|
+
if(this.state == 'idle') {
|
256
|
+
this.state = 'running';
|
257
|
+
this.event('beforeSetup');
|
258
|
+
if(this.setup) this.setup();
|
259
|
+
this.event('afterSetup');
|
260
|
+
}
|
261
|
+
if(this.state == 'running') {
|
262
|
+
if(this.options.transition) pos = this.options.transition(pos);
|
263
|
+
pos *= (this.options.to-this.options.from);
|
264
|
+
pos += this.options.from;
|
265
|
+
this.position = pos;
|
266
|
+
this.event('beforeUpdate');
|
267
|
+
if(this.update) this.update(pos);
|
268
|
+
this.event('afterUpdate');
|
269
|
+
}
|
270
|
+
},
|
271
|
+
cancel: function() {
|
272
|
+
if(!this.options.sync) Effect.Queue.remove(this);
|
273
|
+
this.state = 'finished';
|
274
|
+
},
|
275
|
+
event: function(eventName) {
|
276
|
+
if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
|
277
|
+
if(this.options[eventName]) this.options[eventName](this);
|
278
|
+
},
|
279
|
+
inspect: function() {
|
280
|
+
return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>';
|
281
|
+
}
|
282
|
+
}
|
283
|
+
|
284
|
+
Effect.Parallel = Class.create();
|
285
|
+
Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
|
286
|
+
initialize: function(effects) {
|
287
|
+
this.effects = effects || [];
|
288
|
+
this.start(arguments[1]);
|
289
|
+
},
|
290
|
+
update: function(position) {
|
291
|
+
this.effects.invoke('render', position);
|
292
|
+
},
|
293
|
+
finish: function(position) {
|
294
|
+
this.effects.each( function(effect) {
|
295
|
+
effect.render(1.0);
|
296
|
+
effect.cancel();
|
297
|
+
effect.event('beforeFinish');
|
298
|
+
if(effect.finish) effect.finish(position);
|
299
|
+
effect.event('afterFinish');
|
300
|
+
});
|
301
|
+
}
|
302
|
+
});
|
303
|
+
|
304
|
+
Effect.Opacity = Class.create();
|
305
|
+
Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
|
306
|
+
initialize: function(element) {
|
307
|
+
this.element = $(element);
|
308
|
+
// make this work on IE on elements without 'layout'
|
309
|
+
if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
|
310
|
+
Element.setStyle(this.element, {zoom: 1});
|
311
|
+
var options = Object.extend({
|
312
|
+
from: Element.getOpacity(this.element) || 0.0,
|
313
|
+
to: 1.0
|
314
|
+
}, arguments[1] || {});
|
315
|
+
this.start(options);
|
316
|
+
},
|
317
|
+
update: function(position) {
|
318
|
+
Element.setOpacity(this.element, position);
|
319
|
+
}
|
320
|
+
});
|
321
|
+
|
322
|
+
Effect.MoveBy = Class.create();
|
323
|
+
Object.extend(Object.extend(Effect.MoveBy.prototype, Effect.Base.prototype), {
|
324
|
+
initialize: function(element, toTop, toLeft) {
|
325
|
+
this.element = $(element);
|
326
|
+
this.toTop = toTop;
|
327
|
+
this.toLeft = toLeft;
|
328
|
+
this.start(arguments[3]);
|
329
|
+
},
|
330
|
+
setup: function() {
|
331
|
+
// Bug in Opera: Opera returns the "real" position of a static element or
|
332
|
+
// relative element that does not have top/left explicitly set.
|
333
|
+
// ==> Always set top and left for position relative elements in your stylesheets
|
334
|
+
// (to 0 if you do not need them)
|
335
|
+
Element.makePositioned(this.element);
|
336
|
+
this.originalTop = parseFloat(Element.getStyle(this.element,'top') || '0');
|
337
|
+
this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0');
|
338
|
+
},
|
339
|
+
update: function(position) {
|
340
|
+
Element.setStyle(this.element, {
|
341
|
+
top: this.toTop * position + this.originalTop + 'px',
|
342
|
+
left: this.toLeft * position + this.originalLeft + 'px'
|
343
|
+
});
|
344
|
+
}
|
345
|
+
});
|
346
|
+
|
347
|
+
Effect.Scale = Class.create();
|
348
|
+
Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
|
349
|
+
initialize: function(element, percent) {
|
350
|
+
this.element = $(element)
|
351
|
+
var options = Object.extend({
|
352
|
+
scaleX: true,
|
353
|
+
scaleY: true,
|
354
|
+
scaleContent: true,
|
355
|
+
scaleFromCenter: false,
|
356
|
+
scaleMode: 'box', // 'box' or 'contents' or {} with provided values
|
357
|
+
scaleFrom: 100.0,
|
358
|
+
scaleTo: percent
|
359
|
+
}, arguments[2] || {});
|
360
|
+
this.start(options);
|
361
|
+
},
|
362
|
+
setup: function() {
|
363
|
+
this.restoreAfterFinish = this.options.restoreAfterFinish || false;
|
364
|
+
this.elementPositioning = Element.getStyle(this.element,'position');
|
365
|
+
|
366
|
+
this.originalStyle = {};
|
367
|
+
['top','left','width','height','fontSize'].each( function(k) {
|
368
|
+
this.originalStyle[k] = this.element.style[k];
|
369
|
+
}.bind(this));
|
370
|
+
|
371
|
+
this.originalTop = this.element.offsetTop;
|
372
|
+
this.originalLeft = this.element.offsetLeft;
|
373
|
+
|
374
|
+
var fontSize = Element.getStyle(this.element,'font-size') || '100%';
|
375
|
+
['em','px','%'].each( function(fontSizeType) {
|
376
|
+
if(fontSize.indexOf(fontSizeType)>0) {
|
377
|
+
this.fontSize = parseFloat(fontSize);
|
378
|
+
this.fontSizeType = fontSizeType;
|
379
|
+
}
|
380
|
+
}.bind(this));
|
381
|
+
|
382
|
+
this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
|
383
|
+
|
384
|
+
this.dims = null;
|
385
|
+
if(this.options.scaleMode=='box')
|
386
|
+
this.dims = [this.element.offsetHeight, this.element.offsetWidth];
|
387
|
+
if(/^content/.test(this.options.scaleMode))
|
388
|
+
this.dims = [this.element.scrollHeight, this.element.scrollWidth];
|
389
|
+
if(!this.dims)
|
390
|
+
this.dims = [this.options.scaleMode.originalHeight,
|
391
|
+
this.options.scaleMode.originalWidth];
|
392
|
+
},
|
393
|
+
update: function(position) {
|
394
|
+
var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
|
395
|
+
if(this.options.scaleContent && this.fontSize)
|
396
|
+
Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType });
|
397
|
+
this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
|
398
|
+
},
|
399
|
+
finish: function(position) {
|
400
|
+
if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle);
|
401
|
+
},
|
402
|
+
setDimensions: function(height, width) {
|
403
|
+
var d = {};
|
404
|
+
if(this.options.scaleX) d.width = width + 'px';
|
405
|
+
if(this.options.scaleY) d.height = height + 'px';
|
406
|
+
if(this.options.scaleFromCenter) {
|
407
|
+
var topd = (height - this.dims[0])/2;
|
408
|
+
var leftd = (width - this.dims[1])/2;
|
409
|
+
if(this.elementPositioning == 'absolute') {
|
410
|
+
if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
|
411
|
+
if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
|
412
|
+
} else {
|
413
|
+
if(this.options.scaleY) d.top = -topd + 'px';
|
414
|
+
if(this.options.scaleX) d.left = -leftd + 'px';
|
415
|
+
}
|
416
|
+
}
|
417
|
+
Element.setStyle(this.element, d);
|
418
|
+
}
|
419
|
+
});
|
420
|
+
|
421
|
+
Effect.Highlight = Class.create();
|
422
|
+
Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
|
423
|
+
initialize: function(element) {
|
424
|
+
this.element = $(element);
|
425
|
+
var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
|
426
|
+
this.start(options);
|
427
|
+
},
|
428
|
+
setup: function() {
|
429
|
+
// Prevent executing on elements not in the layout flow
|
430
|
+
if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; }
|
431
|
+
// Disable background image during the effect
|
432
|
+
this.oldStyle = {
|
433
|
+
backgroundImage: Element.getStyle(this.element, 'background-image') };
|
434
|
+
Element.setStyle(this.element, {backgroundImage: 'none'});
|
435
|
+
if(!this.options.endcolor)
|
436
|
+
this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff');
|
437
|
+
if(!this.options.restorecolor)
|
438
|
+
this.options.restorecolor = Element.getStyle(this.element, 'background-color');
|
439
|
+
// init color calculations
|
440
|
+
this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
|
441
|
+
this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
|
442
|
+
},
|
443
|
+
update: function(position) {
|
444
|
+
Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){
|
445
|
+
return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
|
446
|
+
},
|
447
|
+
finish: function() {
|
448
|
+
Element.setStyle(this.element, Object.extend(this.oldStyle, {
|
449
|
+
backgroundColor: this.options.restorecolor
|
450
|
+
}));
|
451
|
+
}
|
452
|
+
});
|
453
|
+
|
454
|
+
Effect.ScrollTo = Class.create();
|
455
|
+
Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
|
456
|
+
initialize: function(element) {
|
457
|
+
this.element = $(element);
|
458
|
+
this.start(arguments[1] || {});
|
459
|
+
},
|
460
|
+
setup: function() {
|
461
|
+
Position.prepare();
|
462
|
+
var offsets = Position.cumulativeOffset(this.element);
|
463
|
+
if(this.options.offset) offsets[1] += this.options.offset;
|
464
|
+
var max = window.innerHeight ?
|
465
|
+
window.height - window.innerHeight :
|
466
|
+
document.body.scrollHeight -
|
467
|
+
(document.documentElement.clientHeight ?
|
468
|
+
document.documentElement.clientHeight : document.body.clientHeight);
|
469
|
+
this.scrollStart = Position.deltaY;
|
470
|
+
this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
|
471
|
+
},
|
472
|
+
update: function(position) {
|
473
|
+
Position.prepare();
|
474
|
+
window.scrollTo(Position.deltaX,
|
475
|
+
this.scrollStart + (position*this.delta));
|
476
|
+
}
|
477
|
+
});
|
478
|
+
|
479
|
+
/* ------------- combination effects ------------- */
|
480
|
+
|
481
|
+
Effect.Fade = function(element) {
|
482
|
+
var oldOpacity = Element.getInlineOpacity(element);
|
483
|
+
var options = Object.extend({
|
484
|
+
from: Element.getOpacity(element) || 1.0,
|
485
|
+
to: 0.0,
|
486
|
+
afterFinishInternal: function(effect) { with(Element) {
|
487
|
+
if(effect.options.to!=0) return;
|
488
|
+
hide(effect.element);
|
489
|
+
setStyle(effect.element, {opacity: oldOpacity}); }}
|
490
|
+
}, arguments[1] || {});
|
491
|
+
return new Effect.Opacity(element,options);
|
492
|
+
}
|
493
|
+
|
494
|
+
Effect.Appear = function(element) {
|
495
|
+
var options = Object.extend({
|
496
|
+
from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0),
|
497
|
+
to: 1.0,
|
498
|
+
beforeSetup: function(effect) { with(Element) {
|
499
|
+
setOpacity(effect.element, effect.options.from);
|
500
|
+
show(effect.element); }}
|
501
|
+
}, arguments[1] || {});
|
502
|
+
return new Effect.Opacity(element,options);
|
503
|
+
}
|
504
|
+
|
505
|
+
Effect.Puff = function(element) {
|
506
|
+
element = $(element);
|
507
|
+
var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') };
|
508
|
+
return new Effect.Parallel(
|
509
|
+
[ new Effect.Scale(element, 200,
|
510
|
+
{ sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
|
511
|
+
new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
|
512
|
+
Object.extend({ duration: 1.0,
|
513
|
+
beforeSetupInternal: function(effect) { with(Element) {
|
514
|
+
setStyle(effect.effects[0].element, {position: 'absolute'}); }},
|
515
|
+
afterFinishInternal: function(effect) { with(Element) {
|
516
|
+
hide(effect.effects[0].element);
|
517
|
+
setStyle(effect.effects[0].element, oldStyle); }}
|
518
|
+
}, arguments[1] || {})
|
519
|
+
);
|
520
|
+
}
|
521
|
+
|
522
|
+
Effect.BlindUp = function(element) {
|
523
|
+
element = $(element);
|
524
|
+
Element.makeClipping(element);
|
525
|
+
return new Effect.Scale(element, 0,
|
526
|
+
Object.extend({ scaleContent: false,
|
527
|
+
scaleX: false,
|
528
|
+
restoreAfterFinish: true,
|
529
|
+
afterFinishInternal: function(effect) { with(Element) {
|
530
|
+
[hide, undoClipping].call(effect.element); }}
|
531
|
+
}, arguments[1] || {})
|
532
|
+
);
|
533
|
+
}
|
534
|
+
|
535
|
+
Effect.BlindDown = function(element) {
|
536
|
+
element = $(element);
|
537
|
+
var oldHeight = Element.getStyle(element, 'height');
|
538
|
+
var elementDimensions = Element.getDimensions(element);
|
539
|
+
return new Effect.Scale(element, 100,
|
540
|
+
Object.extend({ scaleContent: false,
|
541
|
+
scaleX: false,
|
542
|
+
scaleFrom: 0,
|
543
|
+
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
|
544
|
+
restoreAfterFinish: true,
|
545
|
+
afterSetup: function(effect) { with(Element) {
|
546
|
+
makeClipping(effect.element);
|
547
|
+
setStyle(effect.element, {height: '0px'});
|
548
|
+
show(effect.element);
|
549
|
+
}},
|
550
|
+
afterFinishInternal: function(effect) { with(Element) {
|
551
|
+
undoClipping(effect.element);
|
552
|
+
setStyle(effect.element, {height: oldHeight});
|
553
|
+
}}
|
554
|
+
}, arguments[1] || {})
|
555
|
+
);
|
556
|
+
}
|
557
|
+
|
558
|
+
Effect.SwitchOff = function(element) {
|
559
|
+
element = $(element);
|
560
|
+
var oldOpacity = Element.getInlineOpacity(element);
|
561
|
+
return new Effect.Appear(element, {
|
562
|
+
duration: 0.4,
|
563
|
+
from: 0,
|
564
|
+
transition: Effect.Transitions.flicker,
|
565
|
+
afterFinishInternal: function(effect) {
|
566
|
+
new Effect.Scale(effect.element, 1, {
|
567
|
+
duration: 0.3, scaleFromCenter: true,
|
568
|
+
scaleX: false, scaleContent: false, restoreAfterFinish: true,
|
569
|
+
beforeSetup: function(effect) { with(Element) {
|
570
|
+
[makePositioned,makeClipping].call(effect.element);
|
571
|
+
}},
|
572
|
+
afterFinishInternal: function(effect) { with(Element) {
|
573
|
+
[hide,undoClipping,undoPositioned].call(effect.element);
|
574
|
+
setStyle(effect.element, {opacity: oldOpacity});
|
575
|
+
}}
|
576
|
+
})
|
577
|
+
}
|
578
|
+
});
|
579
|
+
}
|
580
|
+
|
581
|
+
Effect.DropOut = function(element) {
|
582
|
+
element = $(element);
|
583
|
+
var oldStyle = {
|
584
|
+
top: Element.getStyle(element, 'top'),
|
585
|
+
left: Element.getStyle(element, 'left'),
|
586
|
+
opacity: Element.getInlineOpacity(element) };
|
587
|
+
return new Effect.Parallel(
|
588
|
+
[ new Effect.MoveBy(element, 100, 0, { sync: true }),
|
589
|
+
new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
|
590
|
+
Object.extend(
|
591
|
+
{ duration: 0.5,
|
592
|
+
beforeSetup: function(effect) { with(Element) {
|
593
|
+
makePositioned(effect.effects[0].element); }},
|
594
|
+
afterFinishInternal: function(effect) { with(Element) {
|
595
|
+
[hide, undoPositioned].call(effect.effects[0].element);
|
596
|
+
setStyle(effect.effects[0].element, oldStyle); }}
|
597
|
+
}, arguments[1] || {}));
|
598
|
+
}
|
599
|
+
|
600
|
+
Effect.Shake = function(element) {
|
601
|
+
element = $(element);
|
602
|
+
var oldStyle = {
|
603
|
+
top: Element.getStyle(element, 'top'),
|
604
|
+
left: Element.getStyle(element, 'left') };
|
605
|
+
return new Effect.MoveBy(element, 0, 20,
|
606
|
+
{ duration: 0.05, afterFinishInternal: function(effect) {
|
607
|
+
new Effect.MoveBy(effect.element, 0, -40,
|
608
|
+
{ duration: 0.1, afterFinishInternal: function(effect) {
|
609
|
+
new Effect.MoveBy(effect.element, 0, 40,
|
610
|
+
{ duration: 0.1, afterFinishInternal: function(effect) {
|
611
|
+
new Effect.MoveBy(effect.element, 0, -40,
|
612
|
+
{ duration: 0.1, afterFinishInternal: function(effect) {
|
613
|
+
new Effect.MoveBy(effect.element, 0, 40,
|
614
|
+
{ duration: 0.1, afterFinishInternal: function(effect) {
|
615
|
+
new Effect.MoveBy(effect.element, 0, -20,
|
616
|
+
{ duration: 0.05, afterFinishInternal: function(effect) { with(Element) {
|
617
|
+
undoPositioned(effect.element);
|
618
|
+
setStyle(effect.element, oldStyle);
|
619
|
+
}}}) }}) }}) }}) }}) }});
|
620
|
+
}
|
621
|
+
|
622
|
+
Effect.SlideDown = function(element) {
|
623
|
+
element = $(element);
|
624
|
+
Element.cleanWhitespace(element);
|
625
|
+
// SlideDown need to have the content of the element wrapped in a container element with fixed height!
|
626
|
+
var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
|
627
|
+
var elementDimensions = Element.getDimensions(element);
|
628
|
+
return new Effect.Scale(element, 100, Object.extend({
|
629
|
+
scaleContent: false,
|
630
|
+
scaleX: false,
|
631
|
+
scaleFrom: 0,
|
632
|
+
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
|
633
|
+
restoreAfterFinish: true,
|
634
|
+
afterSetup: function(effect) { with(Element) {
|
635
|
+
makePositioned(effect.element);
|
636
|
+
makePositioned(effect.element.firstChild);
|
637
|
+
if(window.opera) setStyle(effect.element, {top: ''});
|
638
|
+
makeClipping(effect.element);
|
639
|
+
setStyle(effect.element, {height: '0px'});
|
640
|
+
show(element); }},
|
641
|
+
afterUpdateInternal: function(effect) { with(Element) {
|
642
|
+
setStyle(effect.element.firstChild, {bottom:
|
643
|
+
(effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
|
644
|
+
afterFinishInternal: function(effect) { with(Element) {
|
645
|
+
undoClipping(effect.element);
|
646
|
+
undoPositioned(effect.element.firstChild);
|
647
|
+
undoPositioned(effect.element);
|
648
|
+
setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
|
649
|
+
}, arguments[1] || {})
|
650
|
+
);
|
651
|
+
}
|
652
|
+
|
653
|
+
Effect.SlideUp = function(element) {
|
654
|
+
element = $(element);
|
655
|
+
Element.cleanWhitespace(element);
|
656
|
+
var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
|
657
|
+
return new Effect.Scale(element, 0,
|
658
|
+
Object.extend({ scaleContent: false,
|
659
|
+
scaleX: false,
|
660
|
+
scaleMode: 'box',
|
661
|
+
scaleFrom: 100,
|
662
|
+
restoreAfterFinish: true,
|
663
|
+
beforeStartInternal: function(effect) { with(Element) {
|
664
|
+
makePositioned(effect.element);
|
665
|
+
makePositioned(effect.element.firstChild);
|
666
|
+
if(window.opera) setStyle(effect.element, {top: ''});
|
667
|
+
makeClipping(effect.element);
|
668
|
+
show(element); }},
|
669
|
+
afterUpdateInternal: function(effect) { with(Element) {
|
670
|
+
setStyle(effect.element.firstChild, {bottom:
|
671
|
+
(effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
|
672
|
+
afterFinishInternal: function(effect) { with(Element) {
|
673
|
+
[hide, undoClipping].call(effect.element);
|
674
|
+
undoPositioned(effect.element.firstChild);
|
675
|
+
undoPositioned(effect.element);
|
676
|
+
setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
|
677
|
+
}, arguments[1] || {})
|
678
|
+
);
|
679
|
+
}
|
680
|
+
|
681
|
+
// Bug in opera makes the TD containing this element expand for a instance after finish
|
682
|
+
Effect.Squish = function(element) {
|
683
|
+
return new Effect.Scale(element, window.opera ? 1 : 0,
|
684
|
+
{ restoreAfterFinish: true,
|
685
|
+
beforeSetup: function(effect) { with(Element) {
|
686
|
+
makeClipping(effect.element); }},
|
687
|
+
afterFinishInternal: function(effect) { with(Element) {
|
688
|
+
hide(effect.element);
|
689
|
+
undoClipping(effect.element); }}
|
690
|
+
});
|
691
|
+
}
|
692
|
+
|
693
|
+
Effect.Grow = function(element) {
|
694
|
+
element = $(element);
|
695
|
+
var options = Object.extend({
|
696
|
+
direction: 'center',
|
697
|
+
moveTransistion: Effect.Transitions.sinoidal,
|
698
|
+
scaleTransition: Effect.Transitions.sinoidal,
|
699
|
+
opacityTransition: Effect.Transitions.full
|
700
|
+
}, arguments[1] || {});
|
701
|
+
var oldStyle = {
|
702
|
+
top: element.style.top,
|
703
|
+
left: element.style.left,
|
704
|
+
height: element.style.height,
|
705
|
+
width: element.style.width,
|
706
|
+
opacity: Element.getInlineOpacity(element) };
|
707
|
+
|
708
|
+
var dims = Element.getDimensions(element);
|
709
|
+
var initialMoveX, initialMoveY;
|
710
|
+
var moveX, moveY;
|
711
|
+
|
712
|
+
switch (options.direction) {
|
713
|
+
case 'top-left':
|
714
|
+
initialMoveX = initialMoveY = moveX = moveY = 0;
|
715
|
+
break;
|
716
|
+
case 'top-right':
|
717
|
+
initialMoveX = dims.width;
|
718
|
+
initialMoveY = moveY = 0;
|
719
|
+
moveX = -dims.width;
|
720
|
+
break;
|
721
|
+
case 'bottom-left':
|
722
|
+
initialMoveX = moveX = 0;
|
723
|
+
initialMoveY = dims.height;
|
724
|
+
moveY = -dims.height;
|
725
|
+
break;
|
726
|
+
case 'bottom-right':
|
727
|
+
initialMoveX = dims.width;
|
728
|
+
initialMoveY = dims.height;
|
729
|
+
moveX = -dims.width;
|
730
|
+
moveY = -dims.height;
|
731
|
+
break;
|
732
|
+
case 'center':
|
733
|
+
initialMoveX = dims.width / 2;
|
734
|
+
initialMoveY = dims.height / 2;
|
735
|
+
moveX = -dims.width / 2;
|
736
|
+
moveY = -dims.height / 2;
|
737
|
+
break;
|
738
|
+
}
|
739
|
+
|
740
|
+
return new Effect.MoveBy(element, initialMoveY, initialMoveX, {
|
741
|
+
duration: 0.01,
|
742
|
+
beforeSetup: function(effect) { with(Element) {
|
743
|
+
hide(effect.element);
|
744
|
+
makeClipping(effect.element);
|
745
|
+
makePositioned(effect.element);
|
746
|
+
}},
|
747
|
+
afterFinishInternal: function(effect) {
|
748
|
+
new Effect.Parallel(
|
749
|
+
[ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
|
750
|
+
new Effect.MoveBy(effect.element, moveY, moveX, { sync: true, transition: options.moveTransition }),
|
751
|
+
new Effect.Scale(effect.element, 100, {
|
752
|
+
scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
|
753
|
+
sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
|
754
|
+
], Object.extend({
|
755
|
+
beforeSetup: function(effect) { with(Element) {
|
756
|
+
setStyle(effect.effects[0].element, {height: '0px'});
|
757
|
+
show(effect.effects[0].element); }},
|
758
|
+
afterFinishInternal: function(effect) { with(Element) {
|
759
|
+
[undoClipping, undoPositioned].call(effect.effects[0].element);
|
760
|
+
setStyle(effect.effects[0].element, oldStyle); }}
|
761
|
+
}, options)
|
762
|
+
)
|
763
|
+
}
|
764
|
+
});
|
765
|
+
}
|
766
|
+
|
767
|
+
Effect.Shrink = function(element) {
|
768
|
+
element = $(element);
|
769
|
+
var options = Object.extend({
|
770
|
+
direction: 'center',
|
771
|
+
moveTransistion: Effect.Transitions.sinoidal,
|
772
|
+
scaleTransition: Effect.Transitions.sinoidal,
|
773
|
+
opacityTransition: Effect.Transitions.none
|
774
|
+
}, arguments[1] || {});
|
775
|
+
var oldStyle = {
|
776
|
+
top: element.style.top,
|
777
|
+
left: element.style.left,
|
778
|
+
height: element.style.height,
|
779
|
+
width: element.style.width,
|
780
|
+
opacity: Element.getInlineOpacity(element) };
|
781
|
+
|
782
|
+
var dims = Element.getDimensions(element);
|
783
|
+
var moveX, moveY;
|
784
|
+
|
785
|
+
switch (options.direction) {
|
786
|
+
case 'top-left':
|
787
|
+
moveX = moveY = 0;
|
788
|
+
break;
|
789
|
+
case 'top-right':
|
790
|
+
moveX = dims.width;
|
791
|
+
moveY = 0;
|
792
|
+
break;
|
793
|
+
case 'bottom-left':
|
794
|
+
moveX = 0;
|
795
|
+
moveY = dims.height;
|
796
|
+
break;
|
797
|
+
case 'bottom-right':
|
798
|
+
moveX = dims.width;
|
799
|
+
moveY = dims.height;
|
800
|
+
break;
|
801
|
+
case 'center':
|
802
|
+
moveX = dims.width / 2;
|
803
|
+
moveY = dims.height / 2;
|
804
|
+
break;
|
805
|
+
}
|
806
|
+
|
807
|
+
return new Effect.Parallel(
|
808
|
+
[ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
|
809
|
+
new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
|
810
|
+
new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: options.moveTransition })
|
811
|
+
], Object.extend({
|
812
|
+
beforeStartInternal: function(effect) { with(Element) {
|
813
|
+
[makePositioned, makeClipping].call(effect.effects[0].element) }},
|
814
|
+
afterFinishInternal: function(effect) { with(Element) {
|
815
|
+
[hide, undoClipping, undoPositioned].call(effect.effects[0].element);
|
816
|
+
setStyle(effect.effects[0].element, oldStyle); }}
|
817
|
+
}, options)
|
818
|
+
);
|
819
|
+
}
|
820
|
+
|
821
|
+
Effect.Pulsate = function(element) {
|
822
|
+
element = $(element);
|
823
|
+
var options = arguments[1] || {};
|
824
|
+
var oldOpacity = Element.getInlineOpacity(element);
|
825
|
+
var transition = options.transition || Effect.Transitions.sinoidal;
|
826
|
+
var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
|
827
|
+
reverser.bind(transition);
|
828
|
+
return new Effect.Opacity(element,
|
829
|
+
Object.extend(Object.extend({ duration: 3.0, from: 0,
|
830
|
+
afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); }
|
831
|
+
}, options), {transition: reverser}));
|
832
|
+
}
|
833
|
+
|
834
|
+
Effect.Fold = function(element) {
|
835
|
+
element = $(element);
|
836
|
+
var oldStyle = {
|
837
|
+
top: element.style.top,
|
838
|
+
left: element.style.left,
|
839
|
+
width: element.style.width,
|
840
|
+
height: element.style.height };
|
841
|
+
Element.makeClipping(element);
|
842
|
+
return new Effect.Scale(element, 5, Object.extend({
|
843
|
+
scaleContent: false,
|
844
|
+
scaleX: false,
|
845
|
+
afterFinishInternal: function(effect) {
|
846
|
+
new Effect.Scale(element, 1, {
|
847
|
+
scaleContent: false,
|
848
|
+
scaleY: false,
|
849
|
+
afterFinishInternal: function(effect) { with(Element) {
|
850
|
+
[hide, undoClipping].call(effect.element);
|
851
|
+
setStyle(effect.element, oldStyle);
|
852
|
+
}} });
|
853
|
+
}}, arguments[1] || {}));
|
854
|
+
}
|