summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources
diff options
context:
space:
mode:
authordhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-24 16:24:27 +0000
committerdhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-24 16:24:27 +0000
commitd3d9b4fb5b36702006f903e2d1ed0aa7e9829d64 (patch)
treebb859a5af7d6bfe028ae750622894fbb59e52065 /chrome/browser/resources
parentb3866e05c2c3fe34c0823d86256833ce78d66f15 (diff)
downloadchromium_src-d3d9b4fb5b36702006f903e2d1ed0aa7e9829d64.zip
chromium_src-d3d9b4fb5b36702006f903e2d1ed0aa7e9829d64.tar.gz
chromium_src-d3d9b4fb5b36702006f903e2d1ed0aa7e9829d64.tar.bz2
Adding copy to the filebrowser. Also fixes a crash bug when the user tries to access a download that no longer exists.
Review URL: http://codereview.chromium.org/2844040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60475 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r--chrome/browser/resources/filebrowse.html155
-rw-r--r--chrome/browser/resources/mediaplayer.html6
-rw-r--r--chrome/browser/resources/playlist.html6
3 files changed, 148 insertions, 19 deletions
diff --git a/chrome/browser/resources/filebrowse.html b/chrome/browser/resources/filebrowse.html
index 4588943..22879dd 100644
--- a/chrome/browser/resources/filebrowse.html
+++ b/chrome/browser/resources/filebrowse.html
@@ -29,6 +29,15 @@ div.header {
color: black;
}
+*:-khtml-drag {
+ background-color: rgba(238,238,238, 0.5);
+}
+
+*[draggable] {
+ -khtml-user-drag: element;
+ cursor: move;
+}
+
.rowlink {
height: 100%;
width: 90%;
@@ -172,7 +181,6 @@ li.filebrowserow div.icon {
}
.menuicon {
- background: url('shared/images/filebrowse_menu.png');
position: absolute;
right: 4px;
top: 5px;
@@ -186,6 +194,17 @@ li.filebrowserow div.icon {
-webkit-transition: opacity 0.2s ease-out ;
}
+.spinicon {
+ position: absolute;
+ right: 4px;
+ top: 5px;
+ height: 100%;
+ width: 15px;
+ margin-left: 0;
+ margin-top: 5px;
+ background-repeat: no-repeat;
+}
+
li.filebrowserow:hover .menuicon {
opacity: 0.75;
-webkit-transition: opacity 0.0s ease-out ;
@@ -826,6 +845,31 @@ function browseFileResult(info, results) {
}
} else if (info.functionCall == 'getChildren') {
var main = getCurrentContainer();
+ main.addEventListener('dragover', function(e) {
+ if (e.preventDefault) e.preventDefault();
+ e.dataTransfer.dropEffect = 'copy';
+ return false;
+ }, false);
+ main.addEventListener('drop', function(e) {
+ if (e.stopPropagation) e.stopPropagation();
+ var src = e.dataTransfer.getData('Text');
+ var path = getPathAndFilenameForPath(src);
+ var dest = currentSavedPath + '/' + path[2];
+ var dirId = $('list/dir/' + currentSavedPath);
+ if (dirId) {
+
+ var element = $(dest);
+ if (!element) {
+ // TODO(dhg): We probably should do some checking for
+ // existance.
+ element = createNewFakeItem(path[2], dest, false, true);
+ }
+ dirId.appendChild(element);
+ element.scrollIntoView();
+ }
+ chrome.send('copyFile', [src, dest]);
+ return false;
+ }, false);
main.id = 'dir/' + info.path;
divArray.push(main);
document.location.hash = info.path;
@@ -1026,6 +1070,7 @@ function deleteFileConfirm(path) {
no.className = 'deleteNo';
askingDiv.appendChild(yes);
askingDiv.appendChild(no);
+ yes.scrollIntoView();
var element = menus[path];
if (element) {
element.firstChild.appendChild(askingDiv);
@@ -1082,6 +1127,7 @@ function newDownload(results) {
var dirId = $('list/dir/' + extracted[1]);
if (dirId) {
element = createNewItem(extracted[2], results[x].file_path, false);
+ downloadList.push(element);
if (dirId.firstChild) {
dirId.insertBefore(element, dirId.firstChild);
} else {
@@ -1093,7 +1139,52 @@ function newDownload(results) {
}
}
+function removeDownload(element) {
+ var status = undefined;
+ var pause = undefined;
+ for (var x = 0; x < element.children.length; x++) {
+ if (element.children[x].className == 'downloadstatus') {
+ var child = element.children[x];
+ status = child;
+ } else if (element.children[x].className == 'downloadpause') {
+ var child = element.children[x];
+ pause = child;
+ }
+ }
+ if (status) {
+ element.removeChild(status);
+ }
+ if (pause) {
+ element.removeChild(pause);
+ }
+ element.className = 'filebrowserow';
+ var elementList = [];
+ for (var x = 0; x < downloadList.length; x++) {
+ if (element != downloadList[x]) {
+ elementList.push(downloadList[x]);
+ }
+ }
+ downloadList = elementList;
+}
+
function downloadUpdated(results) {
+ var removeDownloads = [];
+ for (var y = 0; y < downloadList.length; y++) {
+ var found = false;
+ for (var x = 0; x < results.length; x++) {
+ var element = $(results[x].file_path);
+ if (downloadList[y] == element) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ removeDownloads.push(downloadList[y]);
+ }
+ }
+ for (var x = 0; x < removeDownloads.length; x++) {
+ removeDownload(removeDownloads[x]);
+ }
for (var x = 0; x < results.length; x++) {
var element = $(results[x].file_path);
if (!element && results[x].state != 'CANCELLED') {
@@ -1123,6 +1214,7 @@ function downloadUpdated(results) {
}
}
if (progressDiv == null) {
+ downloadList.push(element);
element.className = 'filebrowserow downloading';
var progressDiv = document.createElement('div');
progressDiv.className = 'downloadstatus';
@@ -1162,24 +1254,7 @@ function downloadUpdated(results) {
}
} else {
- var status = undefined;
- var pause = undefined;
- for (var x = 0; x < element.children.length; x++) {
- if (element.children[x].className == 'downloadstatus') {
- var child = element.children[x];
- status = child;
- } else if (element.children[x].className == 'downloadpause') {
- var child = element.children[x];
- pause = child;
- }
- }
- if (status) {
- element.removeChild(status);
- }
- if (pause) {
- element.removeChild(pause);
- }
- element.className = 'filebrowserow';
+ removeDownload(element);
}
}
}
@@ -1320,6 +1395,7 @@ function showMenu(path) {
element.firstChild.style.display = 'block';
element.style.opacity = '1';
currentMenu = element;
+ currentMenu.scrollIntoView();
}
window.event.stopPropagation();
}
@@ -1452,8 +1528,47 @@ function getDoubleClickForItem(path, id, isDirectory) {
var elementIdCounter = 0;
+function createNewFakeItem(title, path, isDirectory, hasspinner) {
+ var element = document.createElement('li');
+
+ element.className = 'filebrowserow';
+ element.id = path;
+ elementIdCounter++;
+ var link;
+ link = document.createElement('div');
+ link.className = 'rowlink';
+
+ var icon = document.createElement('div');
+ icon.className = getClassForPath(path, isDirectory);
+ link.appendChild(icon);
+
+ var span = document.createElement('span');
+ span.className = 'name';
+ span.textContent = title;
+ link.appendChild(span);
+
+ element.appendChild(link);
+
+ // Setup Menu
+ var currentPath = currentSavedPath;
+ if (hasspinner) {
+ var spinicon = document.createElement('div');
+ spinicon.align = 'right';
+ spinicon.className = 'spinicon';
+ element.appendChild(spinicon);
+ }
+ return element;
+}
+
function createNewItem(title, path, isDirectory) {
var element = document.createElement('li');
+ element.setAttribute('draggable', 'true');
+
+ element.addEventListener('dragstart', function (e) {
+ e.dataTransfer.effectAllowed = 'copy';
+ e.dataTransfer.setData('Text', this.id);
+ }, false);
+
element.className = 'filebrowserow';
element.title = title;
/*element.id = 'listItem' + elementIdCounter;*/
@@ -1540,6 +1655,7 @@ function popout(path) {
}
function createNewList(title, results, main, path) {
+ downloadList = [];
clearChildren(main);
var mainList = document.createElement('div');
@@ -1548,6 +1664,7 @@ function createNewList(title, results, main, path) {
} else {
mainList.className = 'columnlist';
}
+
var list = document.createElement('ul');
list.className = 'filebrowselist';
list.id = 'list/dir/' + path;
diff --git a/chrome/browser/resources/mediaplayer.html b/chrome/browser/resources/mediaplayer.html
index 09f7b1e..f3aae4c 100644
--- a/chrome/browser/resources/mediaplayer.html
+++ b/chrome/browser/resources/mediaplayer.html
@@ -322,6 +322,12 @@ var localStrings;
* Window onload handler, sets up the page.
*/
function load() {
+ document.body.addEventListener('dragover', function(e) {
+ if (e.preventDefault) e.preventDefault();
+ });
+ document.body.addEventListener('drop', function(e) {
+ if (e.preventDefault) e.preventDefault();
+ });
localStrings = new LocalStrings();
chrome.send('getCurrentPlaylist', []);
}
diff --git a/chrome/browser/resources/playlist.html b/chrome/browser/resources/playlist.html
index 52aa594..598844c 100644
--- a/chrome/browser/resources/playlist.html
+++ b/chrome/browser/resources/playlist.html
@@ -76,6 +76,12 @@ function pathIsAudioFile(path) {
var currentPlaylist = null;
var currentOffset = -1;
function load() {
+ document.body.addEventListener('dragover', function(e) {
+ if (e.preventDefault) e.preventDefault();
+ });
+ document.body.addEventListener('drop', function(e) {
+ if (e.preventDefault) e.preventDefault();
+ });
chrome.send("getCurrentPlaylist", []);
};