OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 cr.define('feedback', function() { | |
afakhry
2016/08/11 23:31:31
First, thank you for the detailed comments and the
apacible
2016/08/12 01:46:41
The snippet is definitely much simpler!
The style
afakhry
2016/08/12 19:22:38
Bear in mind that the webui doc you pointed out is
apacible
2016/08/29 17:00:20
+dbeam for thoughts (and/or future of WebUI guidel
Dan Beam
2016/09/14 05:11:21
what do you want my specific thoughts on? 'use st
| |
6 'use strict'; | |
7 | |
8 /** | |
9 * The feedback-container element. Initialized after Polymer is ready. | |
10 * @type {?FeedbackContainer} | |
11 */ | |
12 var container = null; | |
13 | |
14 /** | |
15 * Initialize the Feedback WebUI by requesting data to populate the current | |
16 * feedback form. | |
17 */ | |
18 function initialize() { | |
19 container = /** @type {!FeedbackContainerElement} */ | |
20 ($('container')); | |
21 | |
22 feedback.browserApi.requestData(); | |
23 } | |
24 | |
25 return { | |
26 initialize: initialize, | |
27 }; | |
28 }); | |
29 | |
30 // API invoked by the browser MdFeedbackWebUIMessageHandler to communicate | |
31 // with this UI. | |
32 cr.define('feedback.ui', function() { | |
33 'use strict'; | |
34 | |
35 /** | |
36 * Populates the feedback form with data. | |
37 * | |
38 * @param {{email: string|undefined, | |
39 * url: string|undefined}} data | |
40 * Parameters in data: | |
41 * email - user's email, if available. | |
42 * url - url of the tab the user was on before triggering feedback. | |
43 */ | |
44 function setData(data) { | |
45 container.email = data['email']; | |
46 container.url = data['url']; | |
47 } | |
48 | |
49 return { | |
50 setData: setData, | |
51 }; | |
52 }); | |
53 | |
54 // API invoked by this UI to communicate with the browser WebUI message | |
55 // handler. | |
56 cr.define('feedback.browserApi', function() { | |
57 'use strict'; | |
58 | |
59 /** | |
60 * Requests data to initialize the WebUI with. | |
61 * The data will be returned via feedback.ui.setData. | |
62 */ | |
63 function requestData() { | |
64 chrome.send('requestData'); | |
65 } | |
66 | |
67 return { | |
68 requestData: requestData, | |
69 }; | |
70 }); | |
71 | |
72 window.addEventListener('load', feedback.initialize); | |
afakhry
2016/08/11 23:31:31
Do you need to wait for the page to fully load (DO
apacible
2016/08/12 01:46:41
Done.
| |
OLD | NEW |