Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home for chromium.org
« Groups Home
r149442 - trunk/src/chrome/browser/resou rces/file_manager/js
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
se...@chromium.org  
View profile  
 More options Aug 1 2012, 1:50 pm
From: se...@chromium.org
Date: Wed, 1 Aug 2012 10:50:51 -0700 (PDT)
Local: Wed, Aug 1 2012 1:50 pm
Subject: r149442 - trunk/src/chrome/browser/resources/file_ manager/js
Author: se...@chromium.org
Date: Wed Aug  1 10:50:51 2012
New Revision: 149442

Log:
Enable drag and drop on breadcrumbs

BUG=137983
TEST=Manual test.

Review URL: https://chromiumcodereview.appspot.com/10823119

Modified:
   trunk/src/chrome/browser/resources/file_manager/js/breadcrumbs_controller.j s   (contents, props changed)
   trunk/src/chrome/browser/resources/file_manager/js/file_manager.js
   trunk/src/chrome/browser/resources/file_manager/js/file_transfer_controller .js

Modified: trunk/src/chrome/browser/resources/file_manager/js/breadcrumbs_controller.j s
=========================================================================== ===
--- trunk/src/chrome/browser/resources/file_manager/js/breadcrumbs_controller.j s       (original)
+++ trunk/src/chrome/browser/resources/file_manager/js/breadcrumbs_controller.j s       Wed Aug  1 10:50:51 2012
@@ -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.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 @@
     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 @@
  * @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++) {
+      path += '/' + items[i].textContent;
+    }
+  }
+  return path;
+};
+
+/**
+ * Returns the breadcrumbs container.
+ * @return {HTMLElement} Breadcumbs container HTML element.
+ */
+BreadcrumbsController.prototype.getContainer = function() {
+  return this.bc_;
+};
+

Modified: trunk/src/chrome/browser/resources/file_manager/js/file_manager.js
=========================================================================== ===
--- trunk/src/chrome/browser/resources/file_manager/js/file_manager.js  (original)
+++ trunk/src/chrome/browser/resources/file_manager/js/file_manager.js  Wed Aug  1 10:50:51 2012
@@ -536,6 +536,7 @@
     controller.attachDragSource(this.grid_);
     controller.attachDropTarget(this.grid_);
     controller.attachDropTarget(this.rootsList_, true);
+    controller.attachBreadcrumbsDropTarget(this.breadcrumbs_);
     controller.attachCopyPasteHandlers(this.document_);
     controller.addEventListener('selection-copied',
         this.blinkSelection.bind(this));

Modified: trunk/src/chrome/browser/resources/file_manager/js/file_transfer_controller .js
=========================================================================== ===
--- trunk/src/chrome/browser/resources/file_manager/js/file_transfer_controller .js     (original)
+++ trunk/src/chrome/browser/resources/file_manager/js/file_transfer_controller .js     Wed Aug  1 10:50:51 2012
@@ -71,14 +71,15 @@
                           !!opt_onlyIntoDirectories));
   },

-  attachBreadcrumbsDropTarget: function(breadcrumbs) {
-    breadcrumbs.addEventListener('dragover',
+  attachBreadcrumbsDropTarget: function(breadcrumbsController) {
+    var container = breadcrumbsController.getContainer();
+    container.addEventListener('dragover',
         this.onDragOver_.bind(this, true, null));
-    breadcrumbs.addEventListener('dragenter',
-        this.onDragEnterBreadcrumbs_.bind(this, breadcrumbs));
-    breadcrumbs.addEventListener('dragleave',
+    container.addEventListener('dragenter',
+        this.onDragEnterBreadcrumbs_.bind(this, breadcrumbsController));
+    container.addEventListener('dragleave',
         this.onDragLeave_.bind(this, null));
-    breadcrumbs.addEventListener('drop', this.onDrop_.bind(this, true));
+    container.addEventListener('drop', this.onDrop_.bind(this, true));
   },

   /**
@@ -268,20 +269,12 @@
     }
   },

-  onDragEnterBreadcrumbs_: function(breadcrumbs, event) {
-    if (!event.target.classList.contains('breadcrumb-path'))
+  onDragEnterBreadcrumbs_: function(breadcrumbsContainer, event) {
+    var path = breadcrumbsContainer.getTargetPath(event);
+    if (!path)
       return;
-    this.dragEnterCount_++;
-
-    var items = breadcrumbs.querySelectorAll('.breadcrumb-path');
-    var path = this.directoryModel_.getCurrentRootPath();
-
-    if (event.target != items[0]) {
-      for (var i = 1; items[i - 1] != event.target; i++) {
-        path += '/' + items[i].textContent;
-      }
-    }

+    this.dragEnterCount_++;
     this.setDropTarget_(event.target, true, event.dataTransfer, path);
   },


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »