~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/app/javascript/privacy.js

Undo rename. Again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
YUI.add('lp.app.privacy', function(Y) {
2
2
 
3
3
var namespace = Y.namespace('lp.app.privacy');
4
 
 
5
 
var notification_node = null;
6
4
/*
7
5
 * Display privacy notifications
8
6
 *
10
8
 */
11
9
 
12
10
function setup_privacy_notification(config) {
13
 
    if (notification_node !== null) {
14
 
        return;
15
 
    }
16
11
    var notification_text = 'The information on this page is private';
17
12
    var hidden = true;
18
13
    var target_id = "maincontent";
29
24
    }
30
25
    var id_selector = "#" + target_id;
31
26
    var main = Y.one(id_selector);
32
 
    notification_node = Y.Node.create('<div></div>')
 
27
    var notification = Y.Node.create('<div></div>')
33
28
        .addClass('global-notification');
34
29
    if (hidden) {
35
 
        notification_node.addClass('hidden');
 
30
        notification.addClass('hidden');
36
31
    }
37
32
    var notification_span = Y.Node.create('<span></span>')
38
33
        .addClass('sprite')
39
34
        .addClass('notification-private');
40
 
    notification_node.set('text', notification_text);
41
 
 
42
 
    main.appendChild(notification_node);
43
 
    notification_node.appendChild(notification_span);
 
35
    var close_link = Y.Node.create('<a></a>')
 
36
        .addClass('global-notification-close')
 
37
        .set('href', '#');
 
38
    var close_span = Y.Node.create('<span></span>')
 
39
        .addClass('sprite')
 
40
        .addClass('notification-close');
 
41
 
 
42
    notification.set('text', notification_text);
 
43
    close_link.set('text', "Hide");
 
44
 
 
45
    main.appendChild(notification);
 
46
    notification.appendChild(notification_span);
 
47
    notification.appendChild(close_link);
 
48
    close_link.appendChild(close_span);
 
49
 
44
50
}
45
51
namespace.setup_privacy_notification = setup_privacy_notification;
46
52
 
47
 
/**
48
 
 * For unit tests - we need to reset the notification setup.
49
 
 */
50
 
namespace._reset_privacy_notification = function () {
51
 
    notification_node = null;
52
 
};
53
 
 
54
53
function display_privacy_notification() {
55
54
    /* Set a temporary class on the body for the feature flag,
56
55
     this is because we have no way to use feature flags in
61
60
    /* Set the visible flag so that the content moves down. */
62
61
    body.addClass('global-notification-visible');
63
62
 
64
 
    setup_privacy_notification();
65
63
    var global_notification = Y.one('.global-notification');
66
64
    if (global_notification.hasClass('hidden')) {
67
65
        global_notification.addClass('transparent');
89
87
        body_space.run();
90
88
        login_space.run();
91
89
    }
 
90
 
 
91
    Y.one('.global-notification-close').on('click', function(e) {
 
92
        hide_privacy_notification();
 
93
        e.halt();
 
94
    });
92
95
}
93
96
namespace.display_privacy_notification = display_privacy_notification;
94
97
 
98
101
 * This should be called after the page has loaded e.g. on 'domready'.
99
102
 */
100
103
function hide_privacy_notification() {
101
 
    setup_privacy_notification();
102
104
    if (!Y.one('.global-notification').hasClass('hidden')) {
103
105
        var fade_out = new Y.Anim({
104
106
            node: '.global-notification',