~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/answers/javascript/subscribers.js

  • Committer: Julian Edwards
  • Date: 2011-07-28 20:46:18 UTC
  • mfrom: (13553 devel)
  • mto: This revision was merged to the branch mainline in revision 13555.
  • Revision ID: julian.edwards@canonical.com-20110728204618-tivj2wx2oa9s32bx
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2011 Canonical Ltd.  This software is licensed under the
2
 
 * GNU Affero General Public License version 3 (see the file LICENSE).
3
 
 *
4
 
 * Setup for managing subscribers list for questions.
5
 
 *
6
 
 * @module answers
7
 
 * @submodule subscribers
8
 
 */
9
 
 
10
 
YUI.add('lp.answers.subscribers', function(Y) {
11
 
 
12
 
var namespace = Y.namespace('lp.answers.subscribers');
13
 
 
14
 
/**
15
 
 * Possible subscriber levels with descriptive headers for
16
 
 * sections that will hold them.
17
 
 */
18
 
var subscriber_levels = {
19
 
    'Direct': 'Direct subscribers',
20
 
    'Indirect': 'Also notified'
21
 
};
22
 
 
23
 
/**
24
 
 * Order of subscribers sections.
25
 
 */
26
 
var subscriber_level_order = ['Direct', 'Indirect'];
27
 
 
28
 
 
29
 
/**
30
 
 * Create the SubscribersLoader instance which will load subscribers for
31
 
 * a question and put them in the web page.
32
 
 */
33
 
function createQuestionSubscribersLoader(setup_config) {
34
 
    var question = {
35
 
        self_link: LP.cache.context.self_link,
36
 
        web_link: LP.cache.context.web_link };
37
 
    var default_config = {
38
 
        container_box: '#other-question-subscribers',
39
 
        question: question,
40
 
        subscribers_details_view:
41
 
            '/+portlet-subscribers-details',
42
 
        subscribe_someone_else_link: '.menu-link-addsubscriber',
43
 
        subscribe_me_link: '.menu-link-subscription',
44
 
        subscribed_help_text: 'You will stop receiving email notifications ' +
45
 
            'about updates to this question',
46
 
        unsubscribed_help_text: 'You will receive email notifications ' +
47
 
            'about updates to this question',
48
 
        subscriber_levels: subscriber_levels,
49
 
        subscriber_level_order: subscriber_level_order,
50
 
        context: question,
51
 
        subscribe_me_level: 'Direct',
52
 
        subscribe_someone_else_level: 'Direct',
53
 
        default_subscriber_level: 'Indirect'};
54
 
    var module = Y.lp.app.subscribers.subscribers_list;
55
 
 
56
 
    if (Y.Lang.isValue(setup_config)) {
57
 
        setup_config = Y.mix(setup_config, default_config);
58
 
    } else {
59
 
        setup_config = default_config;
60
 
    }
61
 
    return new module.SubscribersLoader(setup_config);
62
 
}
63
 
namespace.createQuestionSubscribersLoader = createQuestionSubscribersLoader;
64
 
 
65
 
}, "0.1", {"requires": ["lp.app.subscribers.subscribers_list"]});