]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/NodeList-fx.js
2 Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
8 if(!dojo
._hasResource
["dojo.NodeList-fx"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
9 dojo
._hasResource
["dojo.NodeList-fx"] = true;
10 dojo
.provide("dojo.NodeList-fx");
11 dojo
.require("dojo.fx");
15 dojo["NodeList-fx"] = {
16 // summary: Adds dojo.fx animation support to dojo.query()
20 dojo
.extend(dojo
.NodeList
, {
21 _anim: function(obj
, method
, args
){
23 var a
= dojo
.fx
.combine(
24 this.map(function(item
){
25 var tmpArgs
= { node
: item
};
26 dojo
.mixin(tmpArgs
, args
);
27 return obj
[method
](tmpArgs
);
30 return args
.auto
? a
.play() && this : a
; // dojo.Animation|dojo.NodeList
33 wipeIn: function(args
){
35 // wipe in all elements of this NodeList via `dojo.fx.wipeIn`
38 // Additional dojo.Animation arguments to mix into this set with the addition of
39 // an `auto` parameter.
41 // returns: dojo.Animation|dojo.NodeList
42 // A special args member `auto` can be passed to automatically play the animation.
43 // If args.auto is present, the original dojo.NodeList will be returned for further
44 // chaining. Otherwise the dojo.Animation instance is returned and must be .play()'ed
47 // Fade in all tables with class "blah":
48 // | dojo.query("table.blah").wipeIn().play();
51 // Utilizing `auto` to get the NodeList back:
52 // | dojo.query(".titles").wipeIn({ auto:true }).onclick(someFunction);
54 return this._anim(dojo
.fx
, "wipeIn", args
); // dojo.Animation|dojo.NodeList
57 wipeOut: function(args
){
59 // wipe out all elements of this NodeList via `dojo.fx.wipeOut`
62 // Additional dojo.Animation arguments to mix into this set with the addition of
63 // an `auto` parameter.
65 // returns: dojo.Animation|dojo.NodeList
66 // A special args member `auto` can be passed to automatically play the animation.
67 // If args.auto is present, the original dojo.NodeList will be returned for further
68 // chaining. Otherwise the dojo.Animation instance is returned and must be .play()'ed
71 // Wipe out all tables with class "blah":
72 // | dojo.query("table.blah").wipeOut().play();
73 return this._anim(dojo
.fx
, "wipeOut", args
); // dojo.Animation|dojo.NodeList
76 slideTo: function(args
){
78 // slide all elements of the node list to the specified place via `dojo.fx.slideTo`
81 // Additional dojo.Animation arguments to mix into this set with the addition of
82 // an `auto` parameter.
84 // returns: dojo.Animation|dojo.NodeList
85 // A special args member `auto` can be passed to automatically play the animation.
86 // If args.auto is present, the original dojo.NodeList will be returned for further
87 // chaining. Otherwise the dojo.Animation instance is returned and must be .play()'ed
90 // | Move all tables with class "blah" to 300/300:
91 // | dojo.query("table.blah").slideTo({
95 return this._anim(dojo
.fx
, "slideTo", args
); // dojo.Animation|dojo.NodeList
99 fadeIn: function(args
){
101 // fade in all elements of this NodeList via `dojo.fadeIn`
104 // Additional dojo.Animation arguments to mix into this set with the addition of
105 // an `auto` parameter.
107 // returns: dojo.Animation|dojo.NodeList
108 // A special args member `auto` can be passed to automatically play the animation.
109 // If args.auto is present, the original dojo.NodeList will be returned for further
110 // chaining. Otherwise the dojo.Animation instance is returned and must be .play()'ed
113 // Fade in all tables with class "blah":
114 // | dojo.query("table.blah").fadeIn().play();
115 return this._anim(dojo
, "fadeIn", args
); // dojo.Animation|dojo.NodeList
118 fadeOut: function(args
){
120 // fade out all elements of this NodeList via `dojo.fadeOut`
123 // Additional dojo.Animation arguments to mix into this set with the addition of
124 // an `auto` parameter.
126 // returns: dojo.Animation|dojo.NodeList
127 // A special args member `auto` can be passed to automatically play the animation.
128 // If args.auto is present, the original dojo.NodeList will be returned for further
129 // chaining. Otherwise the dojo.Animation instance is returned and must be .play()'ed
132 // Fade out all elements with class "zork":
133 // | dojo.query(".zork").fadeOut().play();
135 // Fade them on a delay and do something at the end:
136 // | var fo = dojo.query(".zork").fadeOut();
137 // | dojo.connect(fo, "onEnd", function(){ /*...*/ });
141 // | dojo.query("li").fadeOut({ auto:true }).filter(filterFn).forEach(doit);
143 return this._anim(dojo
, "fadeOut", args
); // dojo.Animation|dojo.NodeList
146 animateProperty: function(args
){
148 // Animate all elements of this NodeList across the properties specified.
149 // syntax identical to `dojo.animateProperty`
151 // returns: dojo.Animation|dojo.NodeList
152 // A special args member `auto` can be passed to automatically play the animation.
153 // If args.auto is present, the original dojo.NodeList will be returned for further
154 // chaining. Otherwise the dojo.Animation instance is returned and must be .play()'ed
157 // | dojo.query(".zork").animateProperty({
160 // | color: { start: "black", end: "white" },
161 // | left: { end: 300 }
166 // | dojo.query(".grue").animateProperty({
171 // | }).onclick(handler);
172 return this._anim(dojo
, "animateProperty", args
); // dojo.Animation|dojo.NodeList
175 anim: function( /*Object*/ properties
,
176 /*Integer?*/ duration
,
177 /*Function?*/ easing
,
181 // Animate one or more CSS properties for all nodes in this list.
182 // The returned animation object will already be playing when it
183 // is returned. See the docs for `dojo.anim` for full details.
184 // properties: Object
185 // the properties to animate. does NOT support the `auto` parameter like other
186 // NodeList-fx methods.
187 // duration: Integer?
188 // Optional. The time to run the animations for
190 // Optional. The easing function to use.
192 // A function to be called when the animation ends
194 // how long to delay playing the returned animation
196 // Another way to fade out:
197 // | dojo.query(".thinger").anim({ opacity: 0 });
199 // animate all elements with the "thigner" class to a width of 500
200 // pixels over half a second
201 // | dojo.query(".thinger").anim({ width: 500 }, 700);
202 var canim
= dojo
.fx
.combine(
203 this.map(function(item
){
204 return dojo
.animateProperty({
206 properties
: properties
,
207 duration
: duration
||350,
213 dojo
.connect(canim
, "onEnd", onEnd
);
215 return canim
.play(delay
||0); // dojo.Animation