OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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('extensions', function() { | |
6 'use strict'; | |
7 | |
8 function ExtensionOptionsOverlay() {} | |
not at google - send to devlin
2014/08/14 15:33:20
/**
* Comment.
* @constructor
*/
Devlin
2014/08/14 15:37:51
docs
ericzeng
2014/08/14 18:11:54
Done.
| |
9 | |
10 cr.addSingletonGetter(ExtensionOptionsOverlay); | |
11 | |
12 ExtensionOptionsOverlay.prototype = { | |
13 /** | |
14 * The extension whose options are being displayed | |
15 * @type {??} | |
not at google - send to devlin
2014/08/14 15:33:20
@type {string}
Devlin
2014/08/14 15:37:52
type {??} is probably bad :P
ericzeng
2014/08/14 18:11:54
Done.
| |
16 * @private | |
17 */ | |
18 extensionId_: undefined, | |
not at google - send to devlin
2014/08/14 15:33:20
Weak nit: I prefer null over undefined when you're
Devlin
2014/08/14 15:40:36
dbeam will be able to confirm, but I think I've be
| |
19 | |
20 /** | |
21 * Initialize the page. | |
22 * @param {function(HTMLDivElement)} showOverlay The function to show or | |
23 * hide the ExtensionOptionsOverlay; this should take a single parameter | |
24 * which is either the overlay Div if the overlay should be displayed, | |
25 * or null if the overlay should be hidden. | |
26 */ | |
27 initializePage: function(showOverlay) { | |
28 console.log('initializePage'); | |
not at google - send to devlin
2014/08/14 15:33:20
Remove logging .: logging.
Devlin
2014/08/14 15:37:51
leftover from testing?
ericzeng
2014/08/14 18:11:54
Yeeeuuup
| |
29 var overlay = $('overlay'); | |
30 cr.ui.overlay.setupOverlay(overlay); | |
31 cr.ui.overlay.globalInitialization(); | |
32 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this)); | |
33 | |
34 /** | |
35 * The element of the full overlay. | |
36 * @type {HTMLDivElement} | |
37 * @private | |
38 */ | |
39 this.overlayDiv_ = $('extension-options-overlay'); | |
not at google - send to devlin
2014/08/14 15:33:20
Define this as a class property under |extensionId
Devlin
2014/08/14 15:40:36
again, dbeam to confirm, but he's told me in the p
ericzeng
2014/08/14 18:11:54
The extension error overlay initializes it here so
| |
40 | |
41 this.setVisible = function(isVisible) { | |
Devlin
2014/08/14 15:37:51
docs
ericzeng
2014/08/14 18:11:54
Done.
Dan Beam
2014/08/14 19:01:27
move to prototype, make @private e.g.
/**
*
ericzeng
2014/08/14 22:34:13
Done.
| |
42 console.log('setVisible'); | |
Devlin
2014/08/14 15:37:52
leftover?
ericzeng
2014/08/14 18:11:54
leftover.
| |
43 showOverlay(isVisible ? this.overlayDiv_ : null); | |
44 }; | |
45 }, | |
46 | |
47 handleDismiss_: function(event) { | |
Devlin
2014/08/14 15:37:52
docs
ericzeng
2014/08/14 18:11:54
Done.
| |
48 this.setVisible(false); | |
49 if (!this.extensionId_) | |
50 return; | |
51 var extensionoptions = document.querySelector('extensionoptions'); | |
52 this.overlayDiv_.removeChild(extensionoptions); | |
53 this.extensionId_ = undefined; | |
54 }, | |
55 | |
56 setExtensionAndShowOverlay: function(extensionId, extensionName) { | |
Devlin
2014/08/14 15:37:52
docs
ericzeng
2014/08/14 18:11:54
Done.
| |
57 console.log('setExtensionAndShowOverlay'); | |
Devlin
2014/08/14 15:37:51
leftover?
ericzeng
2014/08/14 18:11:54
affirmative
| |
58 this.extensionId_ = extensionId; | |
59 var extensionoptions = new ExtensionOptions(); | |
Dan Beam
2014/08/14 19:01:27
nit: extensionOptions
| |
60 extensionoptions.extension = this.extensionId_; | |
61 extensionoptions.autosize = 'on'; | |
62 | |
63 extensionoptions.onsizechanged = function(evt) { | |
not at google - send to devlin
2014/08/14 15:33:20
TODO(ericzeng): Resize in a non-jarring way.
I do
ericzeng
2014/08/14 18:11:54
Done (but not the todo).
Dan Beam
2014/08/14 19:01:27
just keep the current JS and just add:
transiti
ericzeng
2014/08/14 22:34:13
Unfortunately that doesn't really help with the po
not at google - send to devlin
2014/08/15 15:51:06
I think you could get some kind of decent approxim
| |
64 console.log(evt.width + 'x' + evt.height); | |
Devlin
2014/08/14 15:37:52
leftover?
ericzeng
2014/08/14 18:11:54
yes
| |
65 this.overlayDiv_.style.width = evt.width; | |
66 this.overlayDiv_.style.height = evt.height; | |
67 }.bind(this); | |
68 | |
69 this.overlayDiv_.appendChild(extensionoptions); | |
70 | |
71 document.querySelector( | |
72 '#extension-options-overlay .extension-options-overlay-title') | |
Devlin
2014/08/14 15:37:51
do we need the "#extension-options-overlay"? How
not at google - send to devlin
2014/08/14 15:40:53
The extension-options-overlay ID is nice, but Devl
Dan Beam
2014/08/14 19:01:27
if there's only ever going to be 1, use an #id. i
ericzeng
2014/08/14 22:34:13
Done.
| |
73 .textContent = extensionName; | |
74 | |
75 this.setVisible(true); | |
76 } | |
77 }; | |
78 | |
79 // Export | |
80 return { | |
81 ExtensionOptionsOverlay: ExtensionOptionsOverlay | |
82 }; | |
83 }); | |
OLD | NEW |