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

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

Issue 8727028: Eliminate use of assignments to innerHTML in File Browser (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Deleted another redundant file Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/image_editor/gallery.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Setting the src of an img to an empty string can crash the browser, so we 5 // Setting the src of an img to an empty string can crash the browser, so we
6 // use an empty 1x1 gif instead. 6 // use an empty 1x1 gif instead.
7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' 7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,'
8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; 8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D';
9 9
10 var g_slideshow_data = null; 10 var g_slideshow_data = null;
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 }, opt_errorCallback); 427 }, opt_errorCallback);
428 } 428 }
429 } 429 }
430 430
431 function isSystemDirEntry(dirEntry) { 431 function isSystemDirEntry(dirEntry) {
432 return dirEntry.fullPath == '/' || 432 return dirEntry.fullPath == '/' ||
433 dirEntry.fullPath == REMOVABLE_DIRECTORY || 433 dirEntry.fullPath == REMOVABLE_DIRECTORY ||
434 dirEntry.fullPath == ARCHIVE_DIRECTORY; 434 dirEntry.fullPath == ARCHIVE_DIRECTORY;
435 } 435 }
436 436
437 function removeChildren(element) {
438 element.textContent = '';
439 };
440
437 // Public statics. 441 // Public statics.
438 442
439 /** 443 /**
440 * List of dialog types. 444 * List of dialog types.
441 * 445 *
442 * Keep this in sync with FileManagerDialog::GetDialogTypeAsString, except 446 * Keep this in sync with FileManagerDialog::GetDialogTypeAsString, except
443 * FULL_PAGE which is specific to this code. 447 * FULL_PAGE which is specific to this code.
444 * 448 *
445 * @enum {string} 449 * @enum {string}
446 */ 450 */
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 urls: [], 1825 urls: [],
1822 totalCount: 0, 1826 totalCount: 0,
1823 fileCount: 0, 1827 fileCount: 0,
1824 directoryCount: 0, 1828 directoryCount: 0,
1825 bytes: 0, 1829 bytes: 0,
1826 iconType: null, 1830 iconType: null,
1827 indexes: this.currentList_.selectionModel.selectedIndexes 1831 indexes: this.currentList_.selectionModel.selectedIndexes
1828 }; 1832 };
1829 1833
1830 this.previewSummary_.textContent = str('COMPUTING_SELECTION'); 1834 this.previewSummary_.textContent = str('COMPUTING_SELECTION');
1831 this.taskButtons_.innerHTML = ''; 1835 removeChildren(this.taskButtons_);
1832 this.previewThumbnails_.innerHTML = ''; 1836 removeChildren(this.previewThumbnails_);
1833 1837
1834 if (!selection.indexes.length) { 1838 if (!selection.indexes.length) {
1835 this.updateCommonActionButtons_(); 1839 this.updateCommonActionButtons_();
1836 this.updatePreviewPanelVisibility_(); 1840 this.updatePreviewPanelVisibility_();
1837 cr.dispatchSimpleEvent(this, 'selection-summarized'); 1841 cr.dispatchSimpleEvent(this, 'selection-summarized');
1838 return; 1842 return;
1839 } 1843 }
1840 1844
1841 var fileCount = 0; 1845 var fileCount = 0;
1842 var byteCount = 0; 1846 var byteCount = 0;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 } 1910 }
1907 1911
1908 if (pendingFiles.length) { 1912 if (pendingFiles.length) {
1909 cacheEntrySize(pendingFiles.pop(), cacheNextFile); 1913 cacheEntrySize(pendingFiles.pop(), cacheNextFile);
1910 } else { 1914 } else {
1911 self.dispatchEvent(new cr.Event('selection-summarized')); 1915 self.dispatchEvent(new cr.Event('selection-summarized'));
1912 } 1916 }
1913 } 1917 }
1914 1918
1915 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { 1919 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) {
1916 this.taskButtons_.innerHTML = ''; 1920 removeChildren(this.taskButtons_);
1917 // Some internal tasks cannot be defined in terms of file patterns, 1921 // Some internal tasks cannot be defined in terms of file patterns,
1918 // so we pass selection to check for them manually. 1922 // so we pass selection to check for them manually.
1919 if (selection.directoryCount == 0 && selection.fileCount > 0) { 1923 if (selection.directoryCount == 0 && selection.fileCount > 0) {
1920 // Only files, not directories, are supported for external tasks. 1924 // Only files, not directories, are supported for external tasks.
1921 chrome.fileBrowserPrivate.getFileTasks( 1925 chrome.fileBrowserPrivate.getFileTasks(
1922 selection.urls, 1926 selection.urls,
1923 this.onTasksFound_.bind(this, selection)); 1927 this.onTasksFound_.bind(this, selection));
1924 } else { 1928 } else {
1925 // There may be internal tasks for directories. 1929 // There may be internal tasks for directories.
1926 this.onTasksFound_(selection, []); 1930 this.onTasksFound_(selection, []);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 this.metadataProvider_ = new TestAwareMetadataProvider(); 2066 this.metadataProvider_ = new TestAwareMetadataProvider();
2063 }; 2067 };
2064 2068
2065 /** 2069 /**
2066 * Callback called when tasks for selected files are determined. 2070 * Callback called when tasks for selected files are determined.
2067 * @param {Object} selection Selection is passed here, since this.selection 2071 * @param {Object} selection Selection is passed here, since this.selection
2068 * can change before tasks were found, and we should be accurate. 2072 * can change before tasks were found, and we should be accurate.
2069 * @param {Array.<Task>} tasksList The tasks list. 2073 * @param {Array.<Task>} tasksList The tasks list.
2070 */ 2074 */
2071 FileManager.prototype.onTasksFound_ = function(selection, tasksList) { 2075 FileManager.prototype.onTasksFound_ = function(selection, tasksList) {
2072 this.taskButtons_.innerHTML = ''; 2076 removeChildren(this.taskButtons_);
2073 2077
2074 for (var i = 0; i < tasksList.length; i++) { 2078 for (var i = 0; i < tasksList.length; i++) {
2075 var task = tasksList[i]; 2079 var task = tasksList[i];
2076 2080
2077 // Tweak images, titles of internal tasks. 2081 // Tweak images, titles of internal tasks.
2078 var task_parts = task.taskId.split('|'); 2082 var task_parts = task.taskId.split('|');
2079 if (task_parts[0] == this.getExtensionId_()) { 2083 if (task_parts[0] == this.getExtensionId_()) {
2080 task.internal = true; 2084 task.internal = true;
2081 if (task_parts[1] == 'preview') { 2085 if (task_parts[1] == 'preview') {
2082 // TODO(serya): This hack needed until task.iconUrl get working 2086 // TODO(serya): This hack needed until task.iconUrl get working
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 galleryFrame.src = 'js/image_editor/gallery.html'; 2386 galleryFrame.src = 'js/image_editor/gallery.html';
2383 this.dialogDom_.appendChild(galleryFrame); 2387 this.dialogDom_.appendChild(galleryFrame);
2384 galleryFrame.focus(); 2388 galleryFrame.focus();
2385 }; 2389 };
2386 2390
2387 /** 2391 /**
2388 * Update the breadcrumb display to reflect the current directory. 2392 * Update the breadcrumb display to reflect the current directory.
2389 */ 2393 */
2390 FileManager.prototype.updateBreadcrumbs_ = function() { 2394 FileManager.prototype.updateBreadcrumbs_ = function() {
2391 var bc = this.dialogDom_.querySelector('.breadcrumbs'); 2395 var bc = this.dialogDom_.querySelector('.breadcrumbs');
2392 bc.innerHTML = ''; 2396 removeChildren(bc);
2393 2397
2394 var fullPath = this.currentDirEntry_.fullPath.replace(/\/$/, ''); 2398 var fullPath = this.currentDirEntry_.fullPath.replace(/\/$/, '');
2395 var pathNames = fullPath.split('/'); 2399 var pathNames = fullPath.split('/');
2396 var path = ''; 2400 var path = '';
2397 2401
2398 for (var i = 0; i < pathNames.length; i++) { 2402 for (var i = 0; i < pathNames.length; i++) {
2399 var pathName = pathNames[i]; 2403 var pathName = pathNames[i];
2400 path += pathName + '/'; 2404 path += pathName + '/';
2401 2405
2402 var div = this.document_.createElement('div'); 2406 var div = this.document_.createElement('div');
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
3950 }); 3954 });
3951 }, onError); 3955 }, onError);
3952 3956
3953 function onError(err) { 3957 function onError(err) {
3954 console.log('Error while checking free space: ' + err); 3958 console.log('Error while checking free space: ' + err);
3955 setTimeout(doCheck, 1000 * 60); 3959 setTimeout(doCheck, 1000 * 60);
3956 } 3960 }
3957 } 3961 }
3958 } 3962 }
3959 })(); 3963 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/image_editor/gallery.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698