Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Unified Diff: remoting/webapp/base/js/input_dialog.js

Issue 1066283002: [Webapp Refactor] Implements remoting.MessageDialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/modal_dialogs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/base/js/input_dialog.js
diff --git a/remoting/webapp/base/js/input_dialog.js b/remoting/webapp/base/js/input_dialog.js
deleted file mode 100644
index a55e016923e0114166d5e57e08e98aa008728729..0000000000000000000000000000000000000000
--- a/remoting/webapp/base/js/input_dialog.js
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/** @suppress {duplicate} */
-var remoting = remoting || {};
-
-(function() {
-
-'use strict';
-
-/**
- * A helper class for implementing dialogs with an input field using
- * remoting.setMode().
- *
- * @param {remoting.AppMode} mode
- * @param {HTMLElement} formElement
- * @param {HTMLElement} inputField
- * @param {HTMLElement} cancelButton
- *
- * @constructor
- */
-remoting.InputDialog = function(mode, formElement, inputField, cancelButton) {
- /** @private */
- this.appMode_ = mode;
- /** @private */
- this.formElement_ = formElement;
- /** @private */
- this.cancelButton_ = cancelButton;
- /** @private */
- this.inputField_ = inputField;
- /** @private {base.Deferred} */
- this.deferred_ = null;
- /** @private {base.Disposables} */
- this.eventHooks_ = null;
-};
-
-/**
- * @return {Promise<string>} Promise that resolves with the value of the
- * inputField or rejects with |remoting.Error.CANCELLED| if the user clicks
- * on the cancel button.
- */
-remoting.InputDialog.prototype.show = function() {
- var onCancel = this.createFormEventHandler_(this.onCancel_.bind(this));
- var onOk = this.createFormEventHandler_(this.onSubmit_.bind(this));
-
- this.eventHooks_ = new base.Disposables(
- new base.DomEventHook(this.formElement_, 'submit', onOk, false),
- new base.DomEventHook(this.cancelButton_, 'click', onCancel, false));
- base.debug.assert(this.deferred_ === null);
- this.deferred_ = new base.Deferred();
- remoting.setMode(this.appMode_);
- return this.deferred_.promise();
-};
-
-/** @return {HTMLElement} */
-remoting.InputDialog.prototype.inputField = function() {
- return this.inputField_;
-}
-
-/** @private */
-remoting.InputDialog.prototype.onSubmit_ = function() {
- this.deferred_.resolve(this.inputField_.value);
-}
-
-/** @private */
-remoting.InputDialog.prototype.onCancel_ = function() {
- this.deferred_.reject(new remoting.Error(remoting.Error.Tag.CANCELLED));
-}
-
-/**
- * @param {function():void} handler
- * @return {Function}
- * @private
- */
-remoting.InputDialog.prototype.createFormEventHandler_ = function(handler) {
- var that = this;
- return function (/** Event */ e) {
- // Prevents form submission from reloading the v1 app.
- e.preventDefault();
-
- // Set the focus away from the password field. This has to be done
- // before the password field gets hidden, to work around a Blink
- // clipboard-handling bug - http://crbug.com/281523.
- that.cancelButton_.focus();
- handler();
- base.dispose(that.eventHooks_);
- that.eventHooks_ = null;
- that.deferred_ = null;
- };
-};
-
-})();
Jamie 2015/04/08 20:07:29 Did you intend to remove this? I don't see any cha
kelvinp 2015/04/08 20:10:20 This is renamed to modal_dialog.js as it now also
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/modal_dialogs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698