~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/docs/dd/anim-drop-example.html

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html>
2
 
<html lang="en" class="yui3-loading">
3
 
<head>
4
 
    <meta charset="utf-8">
5
 
    <title>Animated Drop Targets</title>
6
 
    <script src="../../build/yui/yui-min.js"></script>
7
 
    <style>
8
 
        .anim {
9
 
        position: relative;
10
 
        height: 50px;
11
 
        width: 100px;
12
 
        border: 1px solid black;
13
 
        background-color: #00B8BF;
14
 
        top: 100px;
15
 
}
16
 
#drag {
17
 
        height: 50px;
18
 
        width: 50px;
19
 
        border: 1px solid black;
20
 
        background-color: #004C6D;
21
 
        color: white;
22
 
        cursor: move;
23
 
        z-index: 5;
24
 
}
25
 
#dock {
26
 
        height: 600px;
27
 
        width: 75px;
28
 
        background-color: #D00050;
29
 
        border: 1px solid black;
30
 
        position: absolute;
31
 
        top: 5px;
32
 
        right: 0px;
33
 
}
34
 
.anim.yui3-dd-drop-over {
35
 
        background-color: #EDFF9F;
36
 
}
37
 
.anim.done {
38
 
        background-color: white;
39
 
}
40
 
#drag1.yui3-dd-drag-over {
41
 
        opacity: .5;
42
 
        filter: alpha(opacity=50);
43
 
}
44
 
 
45
 
 
46
 
    </style>
47
 
</head>
48
 
<body class="yui3-skin-sam">
49
 
 
50
 
<div id="dock"></div>
51
 
 
52
 
<div id="drag">Drag #1</div>
53
 
 
54
 
<div id="anim1" class="anim">Anim #1</div>
55
 
<div id="anim2" class="anim">Anim #2</div>
56
 
<div id="anim3" class="anim">Anim #3</div>
57
 
<div id="anim4" class="anim">Anim #4</div>
58
 
<div id="anim5" class="anim">Anim #5</div>
59
 
 
60
 
 
61
 
 
62
 
<script type="text/javascript">
63
 
    YUI().use('dd', 'dd-plugin', 'dd-drop-plugin', 'anim', function(Y) {
64
 
        //Get the node #drag
65
 
        var d = Y.one('#drag');
66
 
        d.plug(Y.Plugin.Drag, { dragMode: 'intersect' });
67
 
        
68
 
        //Get all the divs with the class anim
69
 
        var anims = Y.Node.all('div.anim');
70
 
        var counter = 0;
71
 
        anims.each(function(v, k) {
72
 
            //Get a reference to the Node instance
73
 
            var a = v;
74
 
            counter++;
75
 
            //Add the FX plugin
76
 
            a.plug(Y.Plugin.NodeFX);
77
 
            //Add the Drop plugin
78
 
            a.plug(Y.Plugin.Drop);
79
 
 
80
 
            //Set the attributes on the animation
81
 
            a.fx.setAttrs({
82
 
                from: {
83
 
                    left: 0
84
 
                },
85
 
                to: {
86
 
                    curve: function() {
87
 
                        var points = [],
88
 
                            n = 10;
89
 
 
90
 
                        for (var i = 0; i < n; ++i) {
91
 
                            points.push([
92
 
                                Math.floor(Math.random()*Y.DOM.winWidth() - 60 - a.get('offsetWidth')),
93
 
                                Math.floor(Math.random()*Y.DOM.winHeight() - a.get('offsetHeight'))
94
 
                            ]);
95
 
                        }
96
 
                        return points;
97
 
                    }
98
 
                },
99
 
                //Do the animation 20 times
100
 
                iterations: 20,
101
 
                //Alternate it so it "bounces" across the screen
102
 
                direction: 'alternate',
103
 
                //Give all of them a different duration so we get different speeds.
104
 
                duration: ((counter * 1.75) + 1)
105
 
            });
106
 
 
107
 
            //When this drop is entered, pause the fx
108
 
            a.drop.on('drop:enter', function() {
109
 
                this.fx.pause();
110
 
            }, a);
111
 
            //When the drop is exited, run the fx again
112
 
            a.drop.on('drop:exit', function() {
113
 
                this.fx.run();
114
 
            }, a);
115
 
            //When a drop is on the node, do something special
116
 
            a.drop.on('drop:hit', function(e) {
117
 
                //Stop the animation
118
 
                this.fx.stop();
119
 
                //remove the tween listener
120
 
                this.fx.unsubscribeAll('tween');
121
 
                //move it to the dock
122
 
                this.fx.setAttrs({
123
 
                    from: {
124
 
                        opacity: 1
125
 
                    },
126
 
                    to: {
127
 
                        height: 50,
128
 
                        width: 50,
129
 
                        left: function() {
130
 
                            var dW = Y.one('body').get('viewportRegion').right;
131
 
                            return ((dW - 60)); //Minus 60 for the dock
132
 
                        },
133
 
                        top: 15,
134
 
                        opacity: .5
135
 
                    },
136
 
                    direction: 'normal',
137
 
                    iterations: 1,
138
 
                    duration: .5,
139
 
                    //We are using reverse above for the "bouncing", reset it here.
140
 
                    reverse: false
141
 
                });
142
 
 
143
 
                //On end, add a class and destroy the target
144
 
                this.fx.on('end', function() {
145
 
                    this.drop.get('node').addClass('done');
146
 
                    this.drop.destroy();
147
 
                }, this);
148
 
                //Run this animation
149
 
                this.fx.run();
150
 
                
151
 
                //others that were dropped on.
152
 
                Y.each(e.others, function(v, k) {
153
 
                    var node = v.get('node');
154
 
                    node.fx.run();
155
 
                });
156
 
 
157
 
            }, a);
158
 
            
159
 
            //on tween of the original anim, we need to sync the drop's shim.
160
 
            a.fx.on('tween', function() {
161
 
                //Do we have an active Drag?
162
 
                if (Y.DD.DDM.activeDrag) {
163
 
                    //Size this shim
164
 
                    this.drop.sizeShim();
165
 
                    //Force an over target check since we might not be moving the mouse.
166
 
                    Y.Lang.later(0, a, function() {
167
 
                        this.drop._handleTargetOver();
168
 
                    });
169
 
                }
170
 
            }, a);
171
 
 
172
 
            a.fx.run();
173
 
        });
174
 
    });
175
 
 
176
 
 
177
 
</script>
178
 
 
179
 
 
180
 
</body>
181
 
</html>