summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorserya@google.com <serya@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-03 13:06:07 +0000
committerserya@google.com <serya@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-03 13:06:07 +0000
commitbd070e2f0795ef0661be6be7585a62c81fbf7459 (patch)
tree570447d6aaa8cdacaea0268035e332701992fe41
parent4d26e45813c0089c4f8ebc8102b05ee46aa6f674 (diff)
downloadchromium_src-bd070e2f0795ef0661be6be7585a62c81fbf7459.zip
chromium_src-bd070e2f0795ef0661be6be7585a62c81fbf7459.tar.gz
chromium_src-bd070e2f0795ef0661be6be7585a62c81fbf7459.tar.bz2
Handling click on selecting checkbox in File Manager in a better way.
Currently instead of handling 'click' event we modify 'up'/'down' event on the checkbox and let selection controller to handle it. It's tricky and has side effects. The most annoying is the following. Click on the small area around the checkbox selects the item and immediattely (but visibly) unselects it. BUG=chromium-os:28722 TEST=Manual test. Review URL: https://chromiumcodereview.appspot.com/9963101 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130362 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/file_manager/js/file_manager.js44
1 files changed, 9 insertions, 35 deletions
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 94f7db1..de6f558 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -1813,14 +1813,16 @@ FileManager.prototype = {
* thumbnail list item.
*/
FileManager.prototype.renderCheckbox_ = function(entry) {
+ function stopEventPropagation(event) {
+ event.stopPropagation();
+ }
var input = this.document_.createElement('input');
input.setAttribute('type', 'checkbox');
input.setAttribute('tabindex', -1);
input.className = 'file-checkbox common';
- input.addEventListener('mousedown',
- this.onCheckboxMouseDownUp_.bind(this));
- input.addEventListener('mouseup',
- this.onCheckboxMouseDownUp_.bind(this));
+ input.addEventListener('mousedown', stopEventPropagation);
+ input.addEventListener('mouseup', stopEventPropagation);
+ input.addEventListener('dblclick', stopEventPropagation);
input.addEventListener('click',
this.onCheckboxClick_.bind(this));
@@ -3503,38 +3505,10 @@ FileManager.prototype = {
this.directoryModel_.changeDirectory(event.srcElement.path);
};
- FileManager.prototype.onCheckboxMouseDownUp_ = function(event) {
- // If exactly one file is selected and its checkbox is *not* clicked,
- // then this should be treated as a "normal" click (ie. the previous
- // selection should be cleared).
- if (this.selection.totalCount == 1 && this.selection.entries[0].isFile) {
- var selectedIndex = this.selection.indexes[0];
- var listItem = this.currentList_.getListItemByIndex(selectedIndex);
- var checkbox = listItem.querySelector('input[type="checkbox"]');
- if (!checkbox.checked)
- return;
- }
-
- // Otherwise, treat clicking on a checkbox the same as a ctrl-click.
- // The default properties of event.ctrlKey make it read-only, but
- // don't prevent deletion, so we delete first, then set it true.
- delete event.ctrlKey;
- event.ctrlKey = true;
- };
-
FileManager.prototype.onCheckboxClick_ = function(event) {
- if (event.shiftKey) {
- // Something about the timing of shift-clicks causes the checkbox
- // to get selected and then very quickly unselected. It appears that
- // we forcibly select the checkbox as part of onSelectionChanged, and
- // then the default action of this click event fires and toggles the
- // checkbox back off.
- //
- // Since we're going to force checkboxes into the correct state for any
- // multi-selection, we can prevent this shift click from toggling the
- // checkbox and avoid the trouble.
- event.preventDefault();
- }
+ var sm = this.directoryModel_.fileListSelection;
+ var listItem = this.findListItemForEvent_(event);
+ sm.setIndexSelected(listItem.listIndex, event.target.checked);
};
FileManager.prototype.onPinClick_ = function(checkbox, entry, event) {