13646.6.4
by Ian Booth
Wire up new answers contacts portal |
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.answercontacts', function(Y) { |
|
11 |
||
12 |
var namespace = Y.namespace('lp.answers.answercontacts'); |
|
13 |
||
14 |
/**
|
|
15 |
* Create the SubscribersLoader instance which will load answer contacts for
|
|
16 |
* a question and put them in the web page.
|
|
17 |
*/
|
|
18 |
function createQuestionAnswerContactsLoader(setup_config) { |
|
13646.6.6
by Ian Booth
Allow multiple answer contact portlets on the same page and fix doc tests |
19 |
var url_data = LP.cache.context; |
20 |
if (Y.Lang.isValue(setup_config) && |
|
21 |
setup_config.context_name !== undefined) { |
|
22 |
url_data = LP.cache[ |
|
23 |
setup_config.context_name + '_answer_portlet_url_data']; |
|
24 |
}
|
|
13646.6.4
by Ian Booth
Wire up new answers contacts portal |
25 |
var questiontarget = { |
13646.6.6
by Ian Booth
Allow multiple answer contact portlets on the same page and fix doc tests |
26 |
self_link: url_data.self_link, |
27 |
web_link: url_data.web_link }; |
|
13646.6.4
by Ian Booth
Wire up new answers contacts portal |
28 |
var default_config = { |
29 |
container_box: '#answer-contacts', |
|
30 |
subscribers_details_view: |
|
31 |
'/+portlet-answercontacts-details', |
|
32 |
subscriber_levels: {}, |
|
33 |
context: questiontarget, |
|
34 |
display_me_in_list: true, |
|
35 |
subscribers_label: 'answer contacts', |
|
36 |
unsubscribe_label: 'Remove', |
|
37 |
unsubscribe_api: 'removeAnswerContact' |
|
38 |
};
|
|
39 |
var module = Y.lp.app.subscribers.subscribers_list; |
|
40 |
||
41 |
if (Y.Lang.isValue(setup_config)) { |
|
42 |
setup_config = Y.mix(setup_config, default_config); |
|
43 |
} else { |
|
44 |
setup_config = default_config; |
|
45 |
}
|
|
46 |
return new module.SubscribersLoader(setup_config); |
|
47 |
}
|
|
48 |
namespace.createQuestionAnswerContactsLoader |
|
49 |
= createQuestionAnswerContactsLoader; |
|
50 |
||
51 |
}, "0.1", {"requires": ["lp.app.subscribers.subscribers_list"]}); |