~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/build/widget-anim/widget-anim.js

  • 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
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('widget-anim', function(Y) {
8
 
 
9
 
/**
10
 
 * Provides a plugin which can be used to animate widget visibility changes.
11
 
 *
12
 
 * @module widget-anim
13
 
 */
14
 
var BOUNDING_BOX = "boundingBox",
15
 
    HOST = "host",
16
 
    NODE = "node",
17
 
    OPACITY = "opacity",
18
 
    EMPTY_STR = "",
19
 
    VISIBLE = "visible",
20
 
    DESTROY = "destroy",
21
 
    HIDDEN = "hidden",
22
 
 
23
 
    RENDERED = "rendered",
24
 
    
25
 
    START = "start",
26
 
    END = "end",
27
 
 
28
 
    DURATION = "duration",
29
 
    ANIM_SHOW = "animShow",
30
 
    ANIM_HIDE = "animHide",
31
 
 
32
 
    _UI_SET_VISIBLE = "_uiSetVisible",
33
 
    
34
 
    ANIM_SHOW_CHANGE = "animShowChange",
35
 
    ANIM_HIDE_CHANGE = "animHideChange";
36
 
 
37
 
/**
38
 
 * A plugin class which can be used to animate widget visibility changes.
39
 
 *
40
 
 * @class WidgetAnim
41
 
 * @extends Plugin.Base
42
 
 * @namespace Plugin
43
 
 */
44
 
function WidgetAnim(config) {
45
 
    WidgetAnim.superclass.constructor.apply(this, arguments);
46
 
}
47
 
 
48
 
/**
49
 
 * The namespace for the plugin. This will be the property on the widget, which will 
50
 
 * reference the plugin instance, when it's plugged in.
51
 
 *
52
 
 * @property NS
53
 
 * @static
54
 
 * @type String
55
 
 * @default "anim"
56
 
 */
57
 
WidgetAnim.NS = "anim";
58
 
 
59
 
/**
60
 
 * The NAME of the WidgetAnim class. Used to prefix events generated
61
 
 * by the plugin class.
62
 
 *
63
 
 * @property NAME
64
 
 * @static
65
 
 * @type String
66
 
 * @default "pluginWidgetAnim"
67
 
 */
68
 
WidgetAnim.NAME = "pluginWidgetAnim";
69
 
 
70
 
/**
71
 
 * Pre-Packaged Animation implementations, which can be used for animShow and animHide attribute 
72
 
 * values.
73
 
 *
74
 
 * @property ANIMATIONS
75
 
 * @static
76
 
 * @type Object
77
 
 * @default "pluginWidgetAnim"
78
 
 */
79
 
WidgetAnim.ANIMATIONS = {
80
 
 
81
 
    fadeIn : function() {
82
 
 
83
 
        var widget = this.get(HOST),
84
 
            boundingBox = widget.get(BOUNDING_BOX),
85
 
            
86
 
            anim = new Y.Anim({
87
 
                node: boundingBox,
88
 
                to: { opacity: 1 },
89
 
                duration: this.get(DURATION)
90
 
            });
91
 
 
92
 
        // Set initial opacity, to avoid initial flicker
93
 
        if (!widget.get(VISIBLE)) {
94
 
            boundingBox.setStyle(OPACITY, 0);
95
 
        }
96
 
 
97
 
        // Clean up, on destroy. Where supported, remove
98
 
        // opacity set using style. Else make 100% opaque
99
 
        anim.on(DESTROY, function() {
100
 
            this.get(NODE).setStyle(OPACITY, (Y.UA.ie) ? 1 : EMPTY_STR);
101
 
        });
102
 
 
103
 
        return anim;
104
 
    },
105
 
 
106
 
    fadeOut : function() {
107
 
        return new Y.Anim({
108
 
            node: this.get(HOST).get(BOUNDING_BOX),
109
 
            to: { opacity: 0 },
110
 
            duration: this.get(DURATION)
111
 
        });
112
 
    }
113
 
};
114
 
 
115
 
/**
116
 
 * Static property used to define the default attribute 
117
 
 * configuration for the plugin.
118
 
 *
119
 
 * @property ATTRS
120
 
 * @type Object
121
 
 * @static
122
 
 */
123
 
WidgetAnim.ATTRS = {
124
 
 
125
 
    /**
126
 
     * Default duration in seconds. Used as the default duration for the default animation implementations
127
 
     *
128
 
     * @attribute duration
129
 
     * @type Number
130
 
     * @default 0.2 (seconds 
131
 
     */
132
 
    duration : {
133
 
        value: 0.2
134
 
    },
135
 
 
136
 
    /**
137
 
     * Default animation instance used for showing the widget (opacity fade-in)
138
 
     * 
139
 
     * @attribute animShow
140
 
     * @type Anim
141
 
     * @default WidgetAnim.ANIMATIONS.fadeIn
142
 
     */
143
 
    animShow : {
144
 
        valueFn: WidgetAnim.ANIMATIONS.fadeIn
145
 
    },
146
 
 
147
 
    /**
148
 
     * Default animation instance used for hiding the widget (opacity fade-out)
149
 
     *
150
 
     * @attribute animHide
151
 
     * @type Anim
152
 
     * @default WidgetAnim.ANIMATIONS.fadeOut
153
 
     */
154
 
    animHide : {
155
 
        valueFn: WidgetAnim.ANIMATIONS.fadeOut
156
 
    }
157
 
};
158
 
 
159
 
Y.extend(WidgetAnim, Y.Plugin.Base, {
160
 
 
161
 
    /**
162
 
     * The initializer lifecycle implementation. Modifies the host widget's 
163
 
     * visibililty implementation to add animation.
164
 
     *
165
 
     * @method initializer
166
 
     * @param {Object} config The user configuration for the plugin  
167
 
     */
168
 
    initializer : function(config) {
169
 
        this._bindAnimShow();
170
 
        this._bindAnimHide();
171
 
 
172
 
        this.after(ANIM_SHOW_CHANGE, this._bindAnimShow);
173
 
        this.after(ANIM_HIDE_CHANGE, this._bindAnimHide);
174
 
 
175
 
        // Override default _uiSetVisible method, with custom animated method
176
 
        this.beforeHostMethod(_UI_SET_VISIBLE, this._uiAnimSetVisible);
177
 
    },
178
 
 
179
 
    /**
180
 
     * The initializer destructor implementation. Responsible for destroying the configured
181
 
     * animation instances.
182
 
     * 
183
 
     * @method destructor
184
 
     */
185
 
    destructor : function() {
186
 
        this.get(ANIM_SHOW).destroy();
187
 
        this.get(ANIM_HIDE).destroy();
188
 
    },
189
 
 
190
 
    /**
191
 
     * The injected method used to override the host widget's _uiSetVisible implementation with
192
 
     * an animated version of the same.
193
 
     *
194
 
     * <p>This method replaces the default _uiSetVisible handler
195
 
     * Widget provides, by injecting itself before _uiSetVisible,
196
 
     * and preventing the default behavior. </p>
197
 
     *
198
 
     * @method _uiAnimSetVisible
199
 
     * @protected
200
 
     * @param {boolean} val true, if making the widget visible. false, if hiding it.
201
 
     */
202
 
    _uiAnimSetVisible : function(val) {
203
 
        if (this.get(HOST).get(RENDERED)) {
204
 
            if (val) {
205
 
                this.get(ANIM_HIDE).stop();
206
 
                this.get(ANIM_SHOW).run();
207
 
            } else {
208
 
                this.get(ANIM_SHOW).stop();
209
 
                this.get(ANIM_HIDE).run();
210
 
            }
211
 
            return new Y.Do.Prevent();
212
 
        }
213
 
    },
214
 
 
215
 
    /**
216
 
     * The original Widget _uiSetVisible implementation. This currently needs to be replicated,
217
 
     * so it can be invoked before or after the animation starts or stops, since the original
218
 
     * methods is not available to the AOP implementation.
219
 
     *
220
 
     * @method _uiSetVisible
221
 
     * @param {boolean} val true, if making the widget visible. false, if hiding it.
222
 
     * @private
223
 
     */
224
 
    _uiSetVisible : function(val) {
225
 
        var host = this.get(HOST),
226
 
            hiddenClass = host.getClassName(HIDDEN);
227
 
 
228
 
        host.get(BOUNDING_BOX).toggleClass(hiddenClass, !val);
229
 
    },
230
 
 
231
 
    /**
232
 
     * Binds a listener to invoke the original visibility handling when the animShow animation is started
233
 
     *
234
 
     * @method _bindAnimShow
235
 
     * @private
236
 
     */
237
 
    _bindAnimShow : function() {
238
 
        // Setup original visibility handling (for show) before starting to animate
239
 
        this.get(ANIM_SHOW).on(START, 
240
 
            Y.bind(function() {
241
 
                this._uiSetVisible(true);
242
 
            }, this));
243
 
    },
244
 
 
245
 
    /**
246
 
     * Binds a listener to invoke the original visibility handling when the animHide animation is complete
247
 
     *
248
 
     * @method _bindAnimHide
249
 
     * @private
250
 
     */
251
 
    _bindAnimHide : function() {
252
 
        // Setup original visibility handling (for hide) after completing animation
253
 
        this.get(ANIM_HIDE).after(END, 
254
 
            Y.bind(function() {
255
 
                this._uiSetVisible(false);
256
 
            }, this));
257
 
    }
258
 
});
259
 
 
260
 
Y.namespace("Plugin").WidgetAnim = WidgetAnim;
261
 
 
262
 
 
263
 
}, '3.4.1' ,{requires:['plugin', 'anim-base', 'widget']});