summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/file_manager/file_manager/background/js/app_window_wrapper.js5
-rw-r--r--ui/file_manager/file_manager/background/js/drive_sync_handler.js4
-rw-r--r--ui/file_manager/file_manager/background/js/file_operation_manager.js2
-rw-r--r--ui/file_manager/file_manager/background/js/volume_manager.js2
-rw-r--r--ui/file_manager/file_manager/foreground/js/app_installer.js2
-rw-r--r--ui/file_manager/file_manager/foreground/js/directory_contents.js2
-rw-r--r--ui/file_manager/file_manager/foreground/js/file_manager.js2
-rw-r--r--ui/file_manager/file_manager/foreground/js/folder_shortcuts_data_model.js2
-rw-r--r--ui/file_manager/file_manager/foreground/js/search_controller.js2
-rw-r--r--ui/file_manager/gallery/js/image_editor/image_editor.js4
-rw-r--r--ui/webui/resources/js/cr/ui/dialogs.js97
11 files changed, 88 insertions, 36 deletions
diff --git a/ui/file_manager/file_manager/background/js/app_window_wrapper.js b/ui/file_manager/file_manager/background/js/app_window_wrapper.js
index 229fae3..d3dc479 100644
--- a/ui/file_manager/file_manager/background/js/app_window_wrapper.js
+++ b/ui/file_manager/file_manager/background/js/app_window_wrapper.js
@@ -23,7 +23,8 @@ function AppWindowWrapper(url, id, options) {
this.url_ = url;
this.id_ = id;
// Do deep copy for the template of options to assign customized params later.
- this.options_ = JSON.parse(JSON.stringify(options));
+ this.options_ = /** @type chrome.app.window.CreateWindowOptions */(
+ JSON.parse(JSON.stringify(options)));
this.window_ = null;
this.appState_ = null;
this.openingOrOpened_ = false;
@@ -304,7 +305,7 @@ SingletonAppWindowWrapper.prototype.reopen = function(opt_callback) {
}
try {
- var appState = JSON.parse(value);
+ var appState = assertInstanceof(JSON.parse(value), Object);
} catch (e) {
console.error('Corrupt launch data for ' + this.id_, value);
opt_callback && opt_callback();
diff --git a/ui/file_manager/file_manager/background/js/drive_sync_handler.js b/ui/file_manager/file_manager/background/js/drive_sync_handler.js
index 2c413d8..a89a559 100644
--- a/ui/file_manager/file_manager/background/js/drive_sync_handler.js
+++ b/ui/file_manager/file_manager/background/js/drive_sync_handler.js
@@ -174,8 +174,8 @@ DriveSyncHandler.prototype.updateItem_ = function(status) {
else
this.item_.message = strf('SYNC_FILE_NAME', entry.name);
this.item_.cancelCallback = this.requestCancel_.bind(this, entry);
- this.item_.progressValue = status.processed;
- this.item_.progressMax = status.total;
+ this.item_.progressValue = status.processed || 0;
+ this.item_.progressMax = status.total || 0;
this.progressCenter_.updateItem(this.item_);
callback();
}.bind(this), function(error) {
diff --git a/ui/file_manager/file_manager/background/js/file_operation_manager.js b/ui/file_manager/file_manager/background/js/file_operation_manager.js
index 6cf88d6..b6fc719 100644
--- a/ui/file_manager/file_manager/background/js/file_operation_manager.js
+++ b/ui/file_manager/file_manager/background/js/file_operation_manager.js
@@ -351,7 +351,7 @@ FileOperationManager.prototype.serviceAllDeleteTasks_ = function() {
/**
* Performs the deletion.
*
- * @param {Object} task The delete task (see deleteEntries function).
+ * @param {!Object} task The delete task (see deleteEntries function).
* @param {function()} callback Callback run on task end.
* @private
*/
diff --git a/ui/file_manager/file_manager/background/js/volume_manager.js b/ui/file_manager/file_manager/background/js/volume_manager.js
index 3e31aaa..d7a0d5e 100644
--- a/ui/file_manager/file_manager/background/js/volume_manager.js
+++ b/ui/file_manager/file_manager/background/js/volume_manager.js
@@ -687,7 +687,7 @@ VolumeManager.prototype.onMountCompleted_ = function(event) {
case 'mount':
var requestKey = this.makeRequestKey_(
'mount',
- event.volumeMetadata.sourcePath);
+ event.volumeMetadata.sourcePath || '');
if (event.status === 'success' ||
event.status ===
diff --git a/ui/file_manager/file_manager/foreground/js/app_installer.js b/ui/file_manager/file_manager/foreground/js/app_installer.js
index 39cf862..a637c8d 100644
--- a/ui/file_manager/file_manager/foreground/js/app_installer.js
+++ b/ui/file_manager/file_manager/foreground/js/app_installer.js
@@ -54,7 +54,7 @@ AppInstaller.prototype.install = function(callback) {
/**
* Called when the installation is completed.
*
- * @param {{message: string}?} error Null if the installation is success,
+ * @param {!Object|undefined} error Undefined if the installation is success,
* otherwise an object which contains error message.
* @private
*/
diff --git a/ui/file_manager/file_manager/foreground/js/directory_contents.js b/ui/file_manager/file_manager/foreground/js/directory_contents.js
index 9340115..9fbab18 100644
--- a/ui/file_manager/file_manager/foreground/js/directory_contents.js
+++ b/ui/file_manager/file_manager/foreground/js/directory_contents.js
@@ -628,7 +628,7 @@ DirectoryContents.prototype.__proto__ = cr.EventTarget.prototype;
/**
* Create the copy of the object, but without scan started.
- * @return {DirectoryContents} Object copy.
+ * @return {!DirectoryContents} Object copy.
*/
DirectoryContents.prototype.clone = function() {
return new DirectoryContents(
diff --git a/ui/file_manager/file_manager/foreground/js/file_manager.js b/ui/file_manager/file_manager/foreground/js/file_manager.js
index 4083d1d..18e244a 100644
--- a/ui/file_manager/file_manager/foreground/js/file_manager.js
+++ b/ui/file_manager/file_manager/foreground/js/file_manager.js
@@ -439,7 +439,7 @@ FileManager.prototype = /** @struct */ {
/** @type {!importer.ImportRunner} */ (
this.mediaImportHandler_),
new importer.RuntimeCommandWidget(),
- this.tracker_);
+ assert(this.tracker_));
}
}.bind(this));
diff --git a/ui/file_manager/file_manager/foreground/js/folder_shortcuts_data_model.js b/ui/file_manager/file_manager/foreground/js/folder_shortcuts_data_model.js
index 0e46532..bd5ef71 100644
--- a/ui/file_manager/file_manager/foreground/js/folder_shortcuts_data_model.js
+++ b/ui/file_manager/file_manager/foreground/js/folder_shortcuts_data_model.js
@@ -207,7 +207,7 @@ FolderShortcutsDataModel.prototype = {
* Reloads the model and loads the shortcuts.
* @private
*/
- reload_: function(ev) {
+ reload_: function() {
var shortcutPaths;
this.queue_.run(function(callback) {
chrome.storage.sync.get(FolderShortcutsDataModel.NAME, function(value) {
diff --git a/ui/file_manager/file_manager/foreground/js/search_controller.js b/ui/file_manager/file_manager/foreground/js/search_controller.js
index 8713797..ae12d88 100644
--- a/ui/file_manager/file_manager/foreground/js/search_controller.js
+++ b/ui/file_manager/file_manager/foreground/js/search_controller.js
@@ -151,7 +151,7 @@ SearchController.prototype.requestAutocompleteSuggestions_ = function() {
// Discard results for previous requests and fire a new search
// for the most recent query.
if (searchString != this.lastAutocompleteQuery_) {
- this.requestAutocompleteSuggestions_(this.lastAutocompleteQuery_);
+ this.requestAutocompleteSuggestions_();
return;
}
diff --git a/ui/file_manager/gallery/js/image_editor/image_editor.js b/ui/file_manager/gallery/js/image_editor/image_editor.js
index 0726007..4f32337 100644
--- a/ui/file_manager/gallery/js/image_editor/image_editor.js
+++ b/ui/file_manager/gallery/js/image_editor/image_editor.js
@@ -12,7 +12,7 @@
* @param {!Object} DOMContainers Various DOM containers required for the
* editor.
* @param {!Array.<!ImageEditor.Mode>} modes Available editor modes.
- * @param {function(string, ...[string])} displayStringFunction String
+ * @param {function(string, ...string)} displayStringFunction String
* formatting function.
* @param {function()} onToolsVisibilityChanged Callback to be called, when
* some of the UI elements have been dimmed or revealed.
@@ -1200,7 +1200,7 @@ ImageEditor.Toolbar.prototype.show = function(on) {
/** A prompt panel for the editor.
*
* @param {!HTMLElement} container Container element.
- * @param {function(string, ...[string])} displayStringFunction A formatting
+ * @param {function(string, ...string)} displayStringFunction A formatting
* function.
* @constructor
* @struct
diff --git a/ui/webui/resources/js/cr/ui/dialogs.js b/ui/webui/resources/js/cr/ui/dialogs.js
index 5c9cc8c..eb37f1d 100644
--- a/ui/webui/resources/js/cr/ui/dialogs.js
+++ b/ui/webui/resources/js/cr/ui/dialogs.js
@@ -35,6 +35,7 @@ cr.define('cr.ui.dialogs', function() {
*/
BaseDialog.ANIMATE_STABLE_DURATION = 500;
+ /** @private */
BaseDialog.prototype.initDom_ = function() {
var doc = this.document_;
this.container_ = doc.createElement('div');
@@ -88,9 +89,13 @@ cr.define('cr.ui.dialogs', function() {
this.initialFocusElement_ = this.okButton_;
};
+ /** @private {Function|undefined} */
BaseDialog.prototype.onOk_ = null;
+
+ /** @private {Function|undefined} */
BaseDialog.prototype.onCancel_ = null;
+ /** @private */
BaseDialog.prototype.onContainerKeyDown_ = function(event) {
// Handle Escape.
if (event.keyCode == 27 && !this.cancelButton_.disabled) {
@@ -102,6 +107,7 @@ cr.define('cr.ui.dialogs', function() {
}
};
+ /** @private */
BaseDialog.prototype.onContainerMouseDown_ = function(event) {
if (event.target == this.container_) {
var classList = this.frame_.classList;
@@ -112,22 +118,26 @@ cr.define('cr.ui.dialogs', function() {
}
};
+ /** @private */
BaseDialog.prototype.onOkClick_ = function(event) {
this.hide();
if (this.onOk_)
this.onOk_();
};
+ /** @private */
BaseDialog.prototype.onCancelClick_ = function(event) {
this.hide();
if (this.onCancel_)
this.onCancel_();
};
+ /** @param {string} label */
BaseDialog.prototype.setOkLabel = function(label) {
this.okButton_.textContent = label;
};
+ /** @param {string} label */
BaseDialog.prototype.setCancelLabel = function(label) {
this.cancelButton_.textContent = label;
};
@@ -136,16 +146,31 @@ cr.define('cr.ui.dialogs', function() {
this.initialFocusElement_ = this.cancelButton_;
};
- BaseDialog.prototype.show = function(message, onOk, onCancel, onShow) {
- this.showWithTitle(null, message, onOk, onCancel, onShow);
+ /**
+ * @param {string} message
+ * @param {Function=} opt_onOk
+ * @param {Function=} opt_onCancel
+ * @param {Function=} opt_onShow
+ */
+ BaseDialog.prototype.show = function(
+ message, opt_onOk, opt_onCancel, opt_onShow) {
+ this.showWithTitle('', message, opt_onOk, opt_onCancel, opt_onShow);
};
+ /**
+ * @param {string} title
+ * @param {string} message
+ * @param {Function=} opt_onOk
+ * @param {Function=} opt_onCancel
+ * @param {Function=} opt_onShow
+ */
BaseDialog.prototype.showHtml = function(title, message,
- onOk, onCancel, onShow) {
+ opt_onOk, opt_onCancel, opt_onShow) {
this.text_.innerHTML = message;
- this.show_(title, onOk, onCancel, onShow);
+ this.show_(title, opt_onOk, opt_onCancel, opt_onShow);
};
+ /** @private */
BaseDialog.prototype.findFocusableElements_ = function(doc) {
var elements = Array.prototype.filter.call(
doc.querySelectorAll('*'),
@@ -166,13 +191,28 @@ cr.define('cr.ui.dialogs', function() {
return elements;
};
+ /**
+ * @param {string} title
+ * @param {string} message
+ * @param {Function=} opt_onOk
+ * @param {Function=} opt_onCancel
+ * @param {Function=} opt_onShow
+ */
BaseDialog.prototype.showWithTitle = function(title, message,
- onOk, onCancel, onShow) {
+ opt_onOk, opt_onCancel, opt_onShow) {
this.text_.textContent = message;
- this.show_(title, onOk, onCancel, onShow);
+ this.show_(title, opt_onOk, opt_onCancel, opt_onShow);
};
- BaseDialog.prototype.show_ = function(title, onOk, onCancel, onShow) {
+ /**
+ * @param {string} title
+ * @param {Function=} opt_onOk
+ * @param {Function=} opt_onCancel
+ * @param {Function=} opt_onShow
+ * @private
+ */
+ BaseDialog.prototype.show_ = function(
+ title, opt_onOk, opt_onCancel, opt_onShow) {
// Make all outside nodes unfocusable while the dialog is active.
this.deactivatedNodes_ = this.findFocusableElements_(this.document_);
this.tabIndexes_ = this.deactivatedNodes_.map(
@@ -183,8 +223,8 @@ cr.define('cr.ui.dialogs', function() {
this.previousActiveElement_ = this.document_.activeElement;
this.parentNode_.appendChild(this.container_);
- this.onOk_ = onOk;
- this.onCancel_ = onCancel;
+ this.onOk_ = opt_onOk;
+ this.onCancel_ = opt_onCancel;
if (title) {
this.title_.textContent = title;
@@ -201,15 +241,13 @@ cr.define('cr.ui.dialogs', function() {
self.container_.classList.add('shown');
self.initialFocusElement_.focus();
setTimeout(function() {
- if (onShow)
- onShow();
+ if (opt_onShow)
+ opt_onShow();
}, BaseDialog.ANIMATE_STABLE_DURATION);
}, 0);
};
- /**
- * @param {Function=} opt_onHide
- */
+ /** @param {Function=} opt_onHide */
BaseDialog.prototype.hide = function(opt_onHide) {
// Restore focusability.
for (var i = 0; i < this.deactivatedNodes_.length; i++) {
@@ -248,14 +286,20 @@ cr.define('cr.ui.dialogs', function() {
* @extends {cr.ui.dialogs.BaseDialog}
*/
function AlertDialog(parentNode) {
- BaseDialog.apply(this, [parentNode]);
+ BaseDialog.call(this, parentNode);
this.cancelButton_.style.display = 'none';
}
AlertDialog.prototype = {__proto__: BaseDialog.prototype};
- AlertDialog.prototype.show = function(message, onOk, onShow) {
- return BaseDialog.prototype.show.apply(this, [message, onOk, onOk, onShow]);
+ /**
+ * @param {Function=} opt_onOk
+ * @param {Function=} opt_onShow
+ * @override
+ */
+ AlertDialog.prototype.show = function(message, opt_onOk, opt_onShow) {
+ return BaseDialog.prototype.show.call(
+ this, message, opt_onOk, opt_onOk, opt_onShow);
};
/**
@@ -264,7 +308,7 @@ cr.define('cr.ui.dialogs', function() {
* @extends {cr.ui.dialogs.BaseDialog}
*/
function ConfirmDialog(parentNode) {
- BaseDialog.apply(this, [parentNode]);
+ BaseDialog.call(this, parentNode);
}
ConfirmDialog.prototype = {__proto__: BaseDialog.prototype};
@@ -276,7 +320,7 @@ cr.define('cr.ui.dialogs', function() {
* @extends {cr.ui.dialogs.BaseDialog}
*/
function PromptDialog(parentNode) {
- BaseDialog.apply(this, [parentNode]);
+ BaseDialog.call(this, parentNode);
this.input_ = this.document_.createElement('input');
this.input_.setAttribute('type', 'text');
this.input_.addEventListener('focus', this.onInputFocus.bind(this));
@@ -291,6 +335,7 @@ cr.define('cr.ui.dialogs', function() {
this.input_.select();
};
+ /** @private */
PromptDialog.prototype.onKeyDown_ = function(event) {
if (event.keyCode == 13) { // Enter
this.onOkClick_(event);
@@ -299,21 +344,27 @@ cr.define('cr.ui.dialogs', function() {
};
/**
+ * @param {string} message
+ * @param {?} defaultValue
+ * @param {Function=} opt_onOk
+ * @param {Function=} opt_onCancel
+ * @param {Function=} opt_onShow
* @suppress {checkTypes}
* TODO(fukino): remove suppression if there is a better way to avoid warning
* about overriding method with different signature.
*/
- PromptDialog.prototype.show = function(message, defaultValue, onOk, onCancel,
- onShow) {
+ PromptDialog.prototype.show = function(
+ message, defaultValue, opt_onOk, opt_onCancel, opt_onShow) {
this.input_.value = defaultValue || '';
- return BaseDialog.prototype.show.apply(this, [message, onOk, onCancel,
- onShow]);
+ return BaseDialog.prototype.show.call(
+ this, message, opt_onOk, opt_onCancel, opt_onShow);
};
PromptDialog.prototype.getValue = function() {
return this.input_.value;
};
+ /** @private */
PromptDialog.prototype.onOkClick_ = function(event) {
this.hide();
if (this.onOk_)