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

Unified Diff: chrome/browser/resources/file_manager/js/breadcrumbs_controller.js

Issue 10823119: Enable drag and drop on breadcrumbs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/breadcrumbs_controller.js
diff --git a/chrome/browser/resources/file_manager/js/breadcrumbs_controller.js b/chrome/browser/resources/file_manager/js/breadcrumbs_controller.js
index c43ce0bb06df42d53838845c0f87f50dd5190463..ae5be6d00c11c08cb522eaf2879dfbe0a66f108d 100644
--- a/chrome/browser/resources/file_manager/js/breadcrumbs_controller.js
+++ b/chrome/browser/resources/file_manager/js/breadcrumbs_controller.js
@@ -10,6 +10,7 @@
function BreadcrumbsController(div) {
this.bc_ = div;
this.hideLast_ = false;
+ div.addEventListener('click', this.onClick_.bind(this));
}
/**
@@ -32,6 +33,7 @@ BreadcrumbsController.prototype.setHideLast = function(value) {
*/
BreadcrumbsController.prototype.update = function(rootPath, path) {
this.bc_.textContent = '';
+ this.rootPath_ = rootPath;
var relativePath = path.substring(rootPath.length).replace(/\/$/, '');
var pathNames = relativePath.split('/');
@@ -64,15 +66,11 @@ BreadcrumbsController.prototype.update = function(rootPath, path) {
div.textContent = i == 0 ? PathUtil.getRootLabel(path) : pathName;
path = path + '/';
- div.path = path;
this.bc_.appendChild(div);
- if (i == pathNames.length - 1) {
+ if (i == pathNames.length - 1)
div.classList.add('breadcrumb-last');
- } else {
- div.addEventListener('click', this.onClick_.bind(this));
- }
}
this.truncate();
};
@@ -188,8 +186,43 @@ BreadcrumbsController.prototype.hide = function() {
* @param {Event} event The click event.
*/
BreadcrumbsController.prototype.onClick_ = function(event) {
+ var path = this.getTargetPath(event);
+ if (!path)
+ return;
+
var newEvent = new cr.Event('pathclick');
- newEvent.path = event.srcElement.path;
+ newEvent.path = path;
this.dispatchEvent(newEvent);
};
+/**
+ * Returns path associated with the event target. Returns empty string for
+ * inactive elements: separators, empty space and the last chunk.
+ * @param {Event} event The UI event.
+ * @return {string} Full path or empty string.
+ */
+BreadcrumbsController.prototype.getTargetPath = function(event) {
+ if (!event.target.classList.contains('breadcrumb-path') ||
+ event.target.classList.contains('breadcrumb-last')) {
+ return '';
+ }
+
+ var items = this.bc_.querySelectorAll('.breadcrumb-path');
+ var path = this.rootPath_;
+
+ if (event.target != items[0]) {
+ for (var i = 1; items[i - 1] != event.target; i++) {
Oleg Eterevsky 2012/08/01 14:56:52 You can use PathUtil.join() instead of this loop.
SeRya 2012/08/01 15:23:44 Join is not enough, textContent also need to be re
+ path += '/' + items[i].textContent;
+ }
+ }
+ return path;
+};
+
+/**
+ * Returns the breadcrumbs container.
+ * @return {HTMLElement} Breadcumbs container HTML element.
+ */
+BreadcrumbsController.prototype.getContainer = function() {
+ return this.bc_;
+};
+
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698