Commit c80eda4c authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

[CCA] Convert view.js into ES6 module.

Bug: 141518780
Test: Pass closure compiler check, tast run <DUT> 'camera.CCAUI*' and manually
validate tooltips function of CCA works correctly.

Change-Id: Iaa93362775579fa16e5a2652326bd8fc06c4d53d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1981421
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727411}
parent 1b21ab6e
......@@ -15,4 +15,5 @@ var cca = {
toast: {},
tooltip: {},
util: {},
views: {},
};
......@@ -2,17 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
/**
* Namespace for the Camera app.
*/
var cca = cca || {};
/**
* Namespace for views.
*/
cca.views = cca.views || {};
import {assertInstanceof} from '../chrome_util.js';
import * as toast from '../toast.js';
/* eslint-disable no-unused-vars */
......@@ -24,25 +15,25 @@ cca.views = cca.views || {};
* cancellable: (boolean|undefined),
* }}
*/
cca.views.DialogEnterOptions;
let DialogEnterOptions;
/**
* Warning message name.
* @typedef {string}
*/
cca.views.WarningEnterOptions;
let WarningEnterOptions;
/**
* @typedef {!cca.views.DialogEnterOptions|!cca.views.WarningEnterOptions}
* @typedef {!DialogEnterOptions|!WarningEnterOptions}
*/
cca.views.EnterOptions;
let EnterOptions;
/* eslint-enable no-unused-vars */
/**
* Base controller of a view for views' navigation sessions (cca.nav).
* Base controller of a view for views' navigation sessions (nav.js).
*/
cca.views.View = class {
export class View {
/**
* @param {string} selector Selector text of the view's root element.
* @param {boolean=} dismissByEsc Enable dismissible by Esc-key.
......@@ -55,7 +46,7 @@ cca.views.View = class {
* @protected
*/
this.rootElement_ =
/** @type {!HTMLElement} */ (document.querySelector(selector));
assertInstanceof(document.querySelector(selector), HTMLElement);
/**
* @type {Promise<*>}
......@@ -104,7 +95,7 @@ cca.views.View = class {
return true;
} else if (key === 'Ctrl-V') {
const {version, version_name: versionName} = chrome.runtime.getManifest();
cca.toast.show(versionName || version);
toast.show(versionName || version);
return true;
} else if (this.dismissByEsc_ && key === 'Escape') {
this.leave();
......@@ -125,14 +116,14 @@ cca.views.View = class {
/**
* Hook of the subclass for entering the view.
* @param {cca.views.EnterOptions=} options Optional rest parameters for
* @param {EnterOptions=} options Optional rest parameters for
* entering the view.
*/
entering(options) {}
/**
* Enters the view.
* @param {cca.views.EnterOptions=} options Optional rest parameters for
* @param {EnterOptions=} options Optional rest parameters for
* entering the view.
* @return {!Promise<*>} Promise for the navigation session.
*/
......@@ -175,4 +166,7 @@ cca.views.View = class {
}
return false;
}
};
}
/** @const */
cca.views.View = View;
......@@ -46,7 +46,7 @@
<script type="module" src="../js/mojo/chrome_helper.js"></script>
<script type="module" src="../js/mojo/device_operator.js"></script>
<script defer src="../js/mojo/image_capture.js"></script>
<script defer src="../js/views/view.js"></script>
<script type="module" src="../js/views/view.js"></script>
<script defer src="../js/views/camera.js"></script>
<script defer src="../js/views/camera_intent.js"></script>
<script defer src="../js/views/camera/layout.js"></script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment