Index: ui/file_manager/file_manager/foreground/js/ui/cws_widget_container_error_dialog.js |
diff --git a/ui/file_manager/file_manager/foreground/js/ui/cws_widget_container_error_dialog.js b/ui/file_manager/file_manager/foreground/js/ui/cws_widget_container_error_dialog.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..28efbb432ce727495ccb43e48d174a424fff7f64 |
--- /dev/null |
+++ b/ui/file_manager/file_manager/foreground/js/ui/cws_widget_container_error_dialog.js |
@@ -0,0 +1,58 @@ |
+// 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. |
+ |
+/** |
+ * @param {HTMLElement} parentNode Node to be parent for this dialog. |
+ * @constructor |
+ * @extends {cr.ui.dialogs.BaseDialog} |
+ */ |
+function CWSWidgetContainerErrorDialog(parentNode) { |
+ cr.ui.dialogs.BaseDialog.call(this, parentNode); |
+} |
+ |
+CWSWidgetContainerErrorDialog.prototype = { |
+ __proto__: cr.ui.dialogs.BaseDialog.prototype |
+}; |
+ |
+/** |
+ * Whether the dialog is showm. |
+ * @return {boolean} |
+ */ |
+CWSWidgetContainerErrorDialog.prototype.shown = function() { |
+ return this.container_.classList.contains('shown'); |
+}; |
+ |
+/** |
+ * One-time initialization of DOM. |
+ * @private |
+ */ |
+CWSWidgetContainerErrorDialog.prototype.initDom_ = function() { |
+ cr.ui.dialogs.BaseDialog.prototype.initDom_.call(this); |
+ this.frame_.classList.add('cws-widget-error-dialog-frame'); |
+ var img = this.document_.createElement('div'); |
+ img.className = 'cws-widget-error-dialog-img'; |
+ this.frame_.insertBefore(img, this.text_); |
+ |
+ this.title_.hidden = true; |
+ this.closeButton_.hidden = true; |
+ this.cancelButton_.hidden = true; |
+ this.text_.classList.add('cws-widget-error-dialog-text'); |
+ |
+ // Don't allow OK button to lose focus, in order to prevent webview content |
+ // from stealing focus. |
+ // BaseDialog keeps focus by removing all other focusable elements from tab |
+ // order (by setting their tabIndex to -1). This doesn't work for webviews |
+ // because the webview embedder cannot access the webview DOM tree, and thus |
+ // fails to remove elements in the webview from tab order. |
+ this.okButton_.addEventListener('blur', this.refocusOkButton_.bind(this)); |
+}; |
+ |
+/** |
+ * Focuses OK button. |
+ * @private |
+ */ |
+CWSWidgetContainerErrorDialog.prototype.refocusOkButton_ = function() { |
+ if (this.shown()) |
+ this.okButton_.focus(); |
+}; |