| Index: chrome/browser/resources/md_bookmarks/item.js
|
| diff --git a/chrome/browser/resources/md_bookmarks/item.js b/chrome/browser/resources/md_bookmarks/item.js
|
| index c0be4847f2849e7449f9dea0103cdba3555ad008..1a0b8bcc2a47e644ff8188d8e26a957126e185c8 100644
|
| --- a/chrome/browser/resources/md_bookmarks/item.js
|
| +++ b/chrome/browser/resources/md_bookmarks/item.js
|
| @@ -37,7 +37,10 @@ Polymer({
|
|
|
| listeners: {
|
| 'click': 'onClick_',
|
| + 'auxclick': 'onMiddleClick_',
|
| 'dblclick': 'onDblClick_',
|
| + 'mousedown': 'cancelMiddleMouseBehavior_',
|
| + 'mouseup': 'cancelMiddleMouseBehavior_',
|
| 'contextmenu': 'onContextMenu_',
|
| },
|
|
|
| @@ -58,16 +61,23 @@ Polymer({
|
| return this;
|
| },
|
|
|
| + /**
|
| + * Change selection so that only this item is selected.
|
| + * @private
|
| + */
|
| + selectItem_: function() {
|
| + this.dispatch(bookmarks.actions.selectItem(
|
| + this.itemId, false, false, this.getState()));
|
| + },
|
| +
|
| /**
|
| * @param {Event} e
|
| * @private
|
| */
|
| onContextMenu_: function(e) {
|
| e.preventDefault();
|
| - if (!this.isSelectedItem_) {
|
| - this.dispatch(bookmarks.actions.selectItem(
|
| - this.itemId, false, false, this.getState()));
|
| - }
|
| + if (!this.isSelectedItem_)
|
| + this.selectItem_();
|
| this.fire('open-item-menu', {
|
| x: e.clientX,
|
| y: e.clientY,
|
| @@ -80,8 +90,7 @@ Polymer({
|
| */
|
| onMenuButtonClick_: function(e) {
|
| e.stopPropagation();
|
| - this.dispatch(bookmarks.actions.selectItem(
|
| - this.itemId, false, false, this.getState()));
|
| + this.selectItem_();
|
| this.fire('open-item-menu', {
|
| targetElement: e.target,
|
| });
|
| @@ -109,28 +118,63 @@ Polymer({
|
| },
|
|
|
| /**
|
| - * @param {Event} e
|
| + * @param {MouseEvent} e
|
| * @private
|
| */
|
| onClick_: function(e) {
|
| - this.dispatch(bookmarks.actions.selectItem(
|
| - this.itemId, e.ctrlKey, e.shiftKey, this.getState()));
|
| + if (e.detail == 1) {
|
| + this.dispatch(bookmarks.actions.selectItem(
|
| + this.itemId, e.ctrlKey, e.shiftKey, this.getState()));
|
| + }
|
| e.stopPropagation();
|
| },
|
|
|
| /**
|
| - * @param {Event} e
|
| + * @param {MouseEvent} e
|
| * @private
|
| */
|
| - onDblClick_: function(e) {
|
| - if (!this.item_.url) {
|
| - this.dispatch(
|
| - bookmarks.actions.selectFolder(this.item_.id, this.getState().nodes));
|
| + onMiddleClick_: function(e) {
|
| + if (e.button != 1)
|
| + return;
|
| +
|
| + this.selectItem_();
|
| + if (this.isFolder_)
|
| + return;
|
| +
|
| + var commandManager = bookmarks.CommandManager.getInstance();
|
| + var itemSet = this.getState().selection.items;
|
| + if (e.shiftKey) {
|
| + if (commandManager.canExecute(Command.OPEN, itemSet))
|
| + commandManager.handle(Command.OPEN, itemSet)
|
| } else {
|
| - chrome.tabs.create({url: this.item_.url});
|
| + if (commandManager.canExecute(Command.OPEN_NEW_TAB, itemSet))
|
| + commandManager.handle(Command.OPEN_NEW_TAB, itemSet)
|
| + }
|
| + },
|
| +
|
| + /**
|
| + * Prevent default middle-mouse behavior. On Windows, this prevents autoscroll
|
| + * (during mousedown), and on Linux this prevents paste (during mouseup).
|
| + * @param {MouseEvent} e
|
| + * @private
|
| + */
|
| + cancelMiddleMouseBehavior_: function(e) {
|
| + if (e.button == 1) {
|
| + e.preventDefault();
|
| }
|
| },
|
|
|
| + /**
|
| + * @param {MouseEvent} e
|
| + * @private
|
| + */
|
| + onDblClick_: function(e) {
|
| + var commandManager = bookmarks.CommandManager.getInstance();
|
| + var itemSet = this.getState().selection.items;
|
| + if (commandManager.canExecute(Command.OPEN, itemSet))
|
| + commandManager.handle(Command.OPEN, itemSet);
|
| + },
|
| +
|
| /**
|
| * @param {string} url
|
| * @private
|
|
|