/usr/share/maas/web/static/js/morph.js is in maas-region-controller-min 1.5+bzr2252-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | /* Copyright 2012 Canonical Ltd. This software is licensed under the
* GNU Affero General Public License version 3 (see the file LICENSE).
*
* Widget to fade and resize between two DOM nodes.
*
* @module Y.maas.morph
*/
YUI.add('maas.morph', function(Y) {
Y.log('loading maas.morph');
var module = Y.namespace('maas.morph');
var Morph;
Morph = function(config) {
Morph.superclass.constructor.apply(this, arguments);
};
Morph.NAME = 'morph';
Morph.ATTRS = {
/**
* The DOM node to be morphed from.
*
* @attribute targetNode
* @type string
*/
targetNode: {
value: null,
setter: function(val) {
return Y.one(val);
}
}
};
/**
* Create the animation for morphing out the original content and
* morphing in the new content.
*
* @method _create_morph
*/
module._create_morph = function(srcNode, targetNode, publisher) {
var self = this;
var morph = module._create_morph_out(targetNode);
morph.on('end', function () {
var anim = module._create_morph_in(srcNode, targetNode);
anim.on('end', function () {
publisher.fire('morphed');
});
anim.run();
});
return morph;
};
/**
* Create the animation for morphing out the original content.
*
* @method _create_morph_out
*/
module._create_morph_out = function(targetNode) {
var morph_out = new Y.Anim({
node: targetNode,
to: {opacity: 0},
duration: 0.2,
easing: 'easeOut'
});
morph_out.on('end', function () {
targetNode.addClass('hidden');
});
return morph_out;
};
/**
* Create an animation for morphing in the new content.
*
* @method _create_morph_in
*/
module._create_morph_in = function(srcNode, targetNode) {
var self = this;
srcNode.setStyle('opacity', 0);
srcNode.removeClass('hidden');
var src_height = srcNode.getComputedStyle('height')
.replace('px', '');
var target_height = targetNode.getComputedStyle('height');
srcNode.setStyle('height', target_height);
var morph_in = new Y.Anim({
node: srcNode,
to: {opacity: 1},
duration: 1,
easing: 'easeIn'
});
// Resize the srcNode to its original size.
var resize_anim = module._create_resize(srcNode, src_height);
morph_in.on('start', function () {
resize_anim.run();
});
return morph_in;
};
/**
* Create an animation for resizing the given node.
*
* @method _create_resize
*/
module._create_resize = function(srcNode, height) {
var resize = new Y.Anim({
node: srcNode,
to: {height: height},
duration: 0.5,
easing: 'easeOut'
});
resize.on('end', function () {
srcNode.setStyle('height', 'auto');
resize.fire('resized');
});
return resize;
};
Y.extend(Morph, Y.Widget, {
initializer: function(cfg) {
if (Y.Lang.isValue(cfg.animate)) {
this._animate = cfg.animate;
}
else {
this._animate = true;
}
},
/**
* Animate between the original and new content.
*
* @method morph
* @param {Boolean} reverse: whether or not the widget should morph in the
new content or return to the original content.
*/
morph: function(reverse) {
if (!Y.Lang.isValue(reverse)) {
reverse = false;
}
var srcNode = this.get(reverse ? 'targetNode' : 'srcNode');
var targetNode = this.get(reverse ? 'srcNode' : 'targetNode');
if (this._animate) {
module._create_morph(srcNode, targetNode, this).run();
}
else {
targetNode.addClass('hidden');
srcNode.removeClass('hidden');
}
}
});
module.Morph = Morph;
}, '0.1', {'requires': ['widget', 'node', 'anim']});
|