diff options
author | yosin@chromium.org <yosin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-22 04:50:39 +0000 |
---|---|---|
committer | yosin@chromium.org <yosin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-22 04:50:39 +0000 |
commit | 9edda0202024e4b263bb7da38abda11adf754a37 (patch) | |
tree | c2b97a1c581b519e03997a323674f01f7ffa7011 | |
parent | 1efbf3f7cf8fa8aaee6120d64157a1e2176d1539 (diff) | |
download | chromium_src-9edda0202024e4b263bb7da38abda11adf754a37.zip chromium_src-9edda0202024e4b263bb7da38abda11adf754a37.tar.gz chromium_src-9edda0202024e4b263bb7da38abda11adf754a37.tar.bz2 |
In handleDragOver, when drop over target element is TreeItem, we set true to TreeItem.expanded property.
BUG=113433
TEST=Drag and hover on collapsed folder in tree view.
Review URL: https://codereview.chromium.org/11299096
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169220 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/bookmark_manager/js/main.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/chrome/browser/resources/bookmark_manager/js/main.js b/chrome/browser/resources/bookmark_manager/js/main.js index 2338eb8..5add381 100644 --- a/chrome/browser/resources/bookmark_manager/js/main.js +++ b/chrome/browser/resources/bookmark_manager/js/main.js @@ -43,6 +43,16 @@ chrome.bookmarkManagerPrivate.getStrings(function(data) { */ var ROOT_ID = '0'; +/** + * Delay for expanding folder when pointer hovers on folder in tree view in + * milliseconds. + * @type {number} + * @const + */ +// TODO(yosin): EXPAND_FOLDER_DELAY should follow system settings. 400ms is +// taken from Windows default settings. +var EXPAND_FOLDER_DELAY = 400; + var splitter = document.querySelector('.main > .splitter'); Splitter.decorate(splitter); @@ -54,6 +64,14 @@ Splitter.decorate(splitter); var lastDeletedNodes; /** + * + * Holds the last DOMTimeStamp when mouse pointer hovers on folder in tree + * view. Zero means pointer doesn't hover on folder. + * @type {number} + */ +var lastHoverOnFolderTimeStamp = 0; + +/** * Holds a function that will undo that last action, if global undo is enabled. * @type {Function} */ @@ -587,6 +605,22 @@ var dnd = { var overBookmarkNode = overElement.bookmarkNode; + // Expands a folder in tree view when pointer hovers on it longer than + // EXPAND_FOLDER_DELAY. + var hoverOnFolderTimeStamp = lastHoverOnFolderTimeStamp; + lastHoverOnFolderTimeStamp = 0; + if (hoverOnFolderTimeStamp) { + if (e.timeStamp - hoverOnFolderTimeStamp >= EXPAND_FOLDER_DELAY) + overElement.expanded = true; + else + lastHoverOnFolderTimeStamp = hoverOnFolderTimeStamp; + } else if (overElement instanceof TreeItem && + bmm.isFolder(overBookmarkNode) && + overElement.hasChildren && + !overElement.expanded) { + lastHoverOnFolderTimeStamp = e.timeStamp; + } + if (!this.canDrop(overBookmarkNode, overElement)) return; |