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
|
YUI.add('lp.app.beta_features', function(Y) {
var namespace = Y.namespace('lp.app.beta_features');
var beta_notification_node = null;
/**
* For unit tests - we need to reset the notification setup to run more than
one test.
*/
namespace._reset_beta_notification = function () {
notification_node = null;
};
/*
* Display beta feature notifications.
*
* This should be called after the page has loaded e.g. on 'domready'.
*/
function display_beta_notification() {
if (LP.cache.beta_features.length === 0) {
return;
}
var beta_features = LP.cache.beta_features;
var body = Y.one('body');
body.addClass('global-notification-visible');
var main = Y.one('#maincontent');
beta_notification_node = Y.Node.create('<div></div>')
.addClass('beta-banner');
main.appendChild(beta_notification_node);
var beta_warning = Y.Node.create(
'<span class="beta-warning">BETA</span>');
beta_notification_node.appendChild(beta_warning);
var close_box = Y.Node.create(
'<a href="#" class="global-notification-close">Hide' +
'<span class="notification-close sprite" /></a>');
beta_notification_node.appendChild(close_box);
beta_notification_node.append('Some parts of this page are in beta: ');
var index;
for (index = 0; index < beta_features.length; index++) {
var feature_name = beta_features[index][4];
var info_link = beta_features[index][5];
if (info_link.length > 0) {
info_link =
' (<a href="' + info_link + '" class="info-link">' +
'read more</a>)';
}
beta_notification_node.appendChild(Y.Node.create(
'<span class="beta-feature"> ' + feature_name + info_link +
'</span>'));
}
close_box.on('click', function(e) {
e.halt();
var fade_out = new Y.Anim({
node: '.beta-banner',
to: {opacity: 0},
duration: 0.3
});
var body_space = new Y.Anim({
node: 'body',
to: {'paddingTop': 0},
duration: 0.2,
easing: Y.Easing.easeOut
});
var login_space = new Y.Anim({
node: '.login-logout',
to: {'top': '6px'},
duration: 0.2,
easing: Y.Easing.easeOut
});
fade_out.on('end', function() {
fade_out.get('node').addClass('hidden');
});
body_space.on('end', function() {
Y.one('body').removeClass('global-notification-visible');
});
fade_out.run();
body_space.run();
login_space.run();
});
}
namespace.display_beta_notification = display_beta_notification;
}, "0.1", {"requires": ["base", "node", "anim"]});
|