1
YUI.add('lp.app.privacy', function(Y) {
3
var namespace = Y.namespace('lp.app.privacy');
5
var notification_node = null;
7
* Display privacy notifications
9
* This should be called after the page has loaded e.g. on 'domready'.
12
function setup_privacy_notification(config) {
13
if (notification_node !== null) {
16
var notification_text = 'The information on this page is private';
18
var target_id = "maincontent";
19
if (config !== undefined) {
20
if (config.notification_text !== undefined) {
21
notification_text = config.notification_text;
23
if (config.hidden !== undefined) {
24
hidden = config.hidden;
26
if (config.target_id !== undefined) {
27
target_id = config.target_id;
30
var id_selector = "#" + target_id;
31
var main = Y.one(id_selector);
32
notification_node = Y.Node.create('<div></div>')
33
.addClass('global-notification');
35
notification_node.addClass('hidden');
37
var notification_span = Y.Node.create('<span></span>')
39
.addClass('notification-private');
40
notification_node.set('text', notification_text);
42
main.appendChild(notification_node);
43
notification_node.appendChild(notification_span);
45
namespace.setup_privacy_notification = setup_privacy_notification;
48
* For unit tests - we need to reset the notification setup.
50
namespace._reset_privacy_notification = function () {
51
notification_node = null;
54
function display_privacy_notification() {
55
/* Set a temporary class on the body for the feature flag,
56
this is because we have no way to use feature flags in
57
css directly. This should be removed if the feature
59
var body = Y.one('body');
60
body.addClass('feature-flag-bugs-private-notification-enabled');
61
/* Set the visible flag so that the content moves down. */
62
body.addClass('global-notification-visible');
64
setup_privacy_notification();
65
var global_notification = Y.one('.global-notification');
66
if (global_notification.hasClass('hidden')) {
67
global_notification.addClass('transparent');
68
global_notification.removeClass('hidden');
70
var fade_in = new Y.Anim({
71
node: global_notification,
75
var body_space = new Y.Anim({
77
to: {'paddingTop': '40px'},
79
easing: Y.Easing.easeOut
81
var login_space = new Y.Anim({
82
node: '.login-logout',
85
easing: Y.Easing.easeOut
93
namespace.display_privacy_notification = display_privacy_notification;
96
* Hide privacy notifications
98
* This should be called after the page has loaded e.g. on 'domready'.
100
function hide_privacy_notification() {
101
setup_privacy_notification();
102
if (!Y.one('.global-notification').hasClass('hidden')) {
103
var fade_out = new Y.Anim({
104
node: '.global-notification',
108
var body_space = new Y.Anim({
110
to: {'paddingTop': 0},
112
easing: Y.Easing.easeOut
114
var login_space = new Y.Anim({
115
node: '.login-logout',
118
easing: Y.Easing.easeOut
120
fade_out.on('end', function() {
121
fade_out.get('node').addClass('hidden');
123
body_space.on('end', function() {
124
Y.one('body').removeClass('global-notification-visible');
131
var privacy_portlet = Y.one('.portlet.private');
132
if (privacy_portlet !== null) {
133
var portlet_colour = new Y.Anim({
134
node: privacy_portlet,
137
backgroundColor:'#8d1f1f'
141
portlet_colour.run();
145
namespace.hide_privacy_notification = hide_privacy_notification;
148
}, "0.1", {"requires": ["base", "node", "anim"]});