Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 10391184: [FileBrowser] Migrated ComboButton to menu as dropdown. (Closed) Base URL: improved-actions-menu-126927
Patch Set: Removed shared/menu stuff changes. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * FileManager constructor. 6 * FileManager constructor.
7 * 7 *
8 * FileManager objects encapsulate the functionality of the file selector 8 * FileManager objects encapsulate the functionality of the file selector
9 * dialogs, as well as the full screen file manager application (though the 9 * dialogs, as well as the full screen file manager application (though the
10 * latter is not yet implemented). 10 * latter is not yet implemented).
(...skipping 2117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 if (!entry) 2128 if (!entry)
2129 continue; 2129 continue;
2130 2130
2131 selection.entries.push(entry); 2131 selection.entries.push(entry);
2132 selection.urls.push(entry.toURL()); 2132 selection.urls.push(entry.toURL());
2133 2133
2134 if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) { 2134 if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) {
2135 var box = this.document_.createElement('div'); 2135 var box = this.document_.createElement('div');
2136 box.className = 'thumbnail'; 2136 box.className = 'thumbnail';
2137 function imageLoadCalback(index, box, img, transform) { 2137 function imageLoadCalback(index, box, img, transform) {
2138 if (index == 0) 2138 if (index == 0) {
dgozman 2012/05/18 13:15:14 Merge these changes.
Dmitry Zvorygin 2012/05/21 10:51:01 Done.
2139 thumbnails.insertBefore(self.renderThumbnailZoom_(img, transform), 2139 var thumbnailZoom = self.renderThumbnailZoom_(img, transform);
2140 thumbnails.firstChild); 2140 if (thumbnailZoom) {
2141 thumbnails.insertBefore(thumbnailZoom, thumbnails.firstChild);
2142 }
2143 }
2141 onThumbnailLoaded(); 2144 onThumbnailLoaded();
2142 } 2145 }
2143 var thumbnail = this.renderThumbnailBox_(entry, true, 2146 var thumbnail = this.renderThumbnailBox_(entry, true,
2144 imageLoadCalback.bind(null, thumbnailCount, box)); 2147 imageLoadCalback.bind(null, thumbnailCount, box));
2145 thumbnailCount++; 2148 thumbnailCount++;
2146 box.appendChild(thumbnail); 2149 box.appendChild(thumbnail);
2147 box.style.zIndex = MAX_PREVIEW_THUMBAIL_COUNT + 1 - i; 2150 box.style.zIndex = MAX_PREVIEW_THUMBAIL_COUNT + 1 - i;
2148 box.addEventListener('click', 2151 box.addEventListener('click',
2149 this.dispatchDefaultTask_.bind(this, selection)); 2152 this.dispatchDefaultTask_.bind(this, selection));
2150 2153
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 * @param {HTMLElement} img Loaded image. 2232 * @param {HTMLElement} img Loaded image.
2230 * @param {Object} transform Image transformation description. 2233 * @param {Object} transform Image transformation description.
2231 * @return {Element} Created element. 2234 * @return {Element} Created element.
2232 */ 2235 */
2233 FileManager.prototype.renderThumbnailZoom_ = function(img, transform) { 2236 FileManager.prototype.renderThumbnailZoom_ = function(img, transform) {
2234 var width = img.width; 2237 var width = img.width;
2235 var height = img.height; 2238 var height = img.height;
2236 var THUMBNAIL_SIZE = 45; 2239 var THUMBNAIL_SIZE = 45;
2237 2240
2238 if (width < THUMBNAIL_SIZE * 2 && height < THUMBNAIL_SIZE * 2) 2241 if (width < THUMBNAIL_SIZE * 2 && height < THUMBNAIL_SIZE * 2)
2239 return; 2242 return null;
2240 2243
2241 var scale = Math.min(1, 2244 var scale = Math.min(1,
2242 IMAGE_HOVER_PREVIEW_SIZE / Math.max(width, height)); 2245 IMAGE_HOVER_PREVIEW_SIZE / Math.max(width, height));
2243 2246
2244 var imageWidth = Math.round(width * scale); 2247 var imageWidth = Math.round(width * scale);
2245 var imageHeight = Math.round(height * scale); 2248 var imageHeight = Math.round(height * scale);
2246 2249
2247 var largeImage = this.document_.createElement('img'); 2250 var largeImage = this.document_.createElement('img');
2248 if (scale < 0.3) { 2251 if (scale < 0.3) {
2249 // Scaling large images kills animation. Downscale it in advance. 2252 // Scaling large images kills animation. Downscale it in advance.
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 } else if (task_parts[1] == 'view-in-browser') { 2426 } else if (task_parts[1] == 'view-in-browser') {
2424 task.iconUrl = 2427 task.iconUrl =
2425 chrome.extension.getURL('images/filetype_generic.png'); 2428 chrome.extension.getURL('images/filetype_generic.png');
2426 task.title = str('ACTION_VIEW'); 2429 task.title = str('ACTION_VIEW');
2427 } else if (task_parts[1] == 'install-crx') { 2430 } else if (task_parts[1] == 'install-crx') {
2428 task.iconUrl = 2431 task.iconUrl =
2429 chrome.extension.getURL('images/filetype_generic.png'); 2432 chrome.extension.getURL('images/filetype_generic.png');
2430 task.title = str('INSTALL_CRX'); 2433 task.title = str('INSTALL_CRX');
2431 } 2434 }
2432 } 2435 }
2433 this.taskItems_.addItem(this.renderTaskItem_(task)); 2436 if (tasksList.length > 1)
dgozman 2012/05/18 13:15:14 This is wrong. tasksList.length is not equal to ta
Dmitry Zvorygin 2012/05/21 10:51:01 Good point! Fixed.
2437 this.taskItems_.addItem({label: task.title,
2438 iconUrl: task.iconUrl, task: task});
2434 tasksCount++; 2439 tasksCount++;
2435 if (defaultTask == null) defaultTask = task; 2440 if (defaultTask == null) defaultTask = task;
2436 } 2441 }
2437 2442
2438 this.taskItems_.hidden = tasksCount == 0; 2443 this.taskItems_.hidden = tasksCount == 0;
2439 if (tasksCount > 1) { 2444 if (defaultTask != null) {
2440 // Duplicate default task in drop-down list. 2445 this.taskItems_.defaultItem = ({label: defaultTask.title,
2441 this.taskItems_.addItem(this.renderTaskItem_(defaultTask)); 2446 iconUrl: defaultTask.iconUrl, task: defaultTask});
2442 } 2447 }
2443 2448
2444 selection.tasksList = tasksList; 2449 selection.tasksList = tasksList;
2445 if (selection.dispatchDefault) { 2450 if (selection.dispatchDefault) {
2446 // We got a request to dispatch the default task for the selection. 2451 // We got a request to dispatch the default task for the selection.
2447 selection.dispatchDefault = false; 2452 selection.dispatchDefault = false;
2448 this.dispatchDefaultTask_(selection); 2453 this.dispatchDefaultTask_(selection);
2449 } 2454 }
2450 }; 2455 };
2451 2456
2452 FileManager.prototype.renderTaskItem_ = function(task) {
2453 var item = this.document_.createElement('div');
2454 item.className = 'task-item';
2455 item.task = task;
2456
2457 var img = this.document_.createElement('img');
2458 img.src = task.iconUrl;
2459 item.appendChild(img);
2460
2461 var label = this.document_.createElement('div');
2462 label.appendChild(this.document_.createTextNode(task.title));
2463 item.appendChild(label);
2464
2465 return item;
2466 };
2467
2468 FileManager.prototype.getExtensionId_ = function() { 2457 FileManager.prototype.getExtensionId_ = function() {
2469 return chrome.extension.getURL('').split('/')[2]; 2458 return chrome.extension.getURL('').split('/')[2];
2470 }; 2459 };
2471 2460
2472 FileManager.prototype.onExternalLinkClick_ = function(url) { 2461 FileManager.prototype.onExternalLinkClick_ = function(url) {
2473 chrome.tabs.create({url: url}); 2462 chrome.tabs.create({url: url});
2474 if (this.dialogType_ != FileManager.DialogType.FULL_PAGE) { 2463 if (this.dialogType_ != FileManager.DialogType.FULL_PAGE) {
2475 this.onCancel_(); 2464 this.onCancel_();
2476 } 2465 }
2477 }; 2466 };
(...skipping 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after
4482 4471
4483 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner); 4472 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner);
4484 this.directoryModel_.addEventListener('rescan-completed', maybeShowBanner); 4473 this.directoryModel_.addEventListener('rescan-completed', maybeShowBanner);
4485 4474
4486 var style = this.document_.createElement('link'); 4475 var style = this.document_.createElement('link');
4487 style.rel = 'stylesheet'; 4476 style.rel = 'stylesheet';
4488 style.href = 'css/gdrive_welcome.css'; 4477 style.href = 'css/gdrive_welcome.css';
4489 this.document_.head.appendChild(style); 4478 this.document_.head.appendChild(style);
4490 }; 4479 };
4491 })(); 4480 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698