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

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

Issue 10829121: Fix file type filter in Chrome OS Open/Save dialogs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 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 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 this.fileTypeSelector_.addEventListener('change', 1418 this.fileTypeSelector_.addEventListener('change',
1419 this.updateFileTypeFilter_.bind(this)); 1419 this.updateFileTypeFilter_.bind(this));
1420 }; 1420 };
1421 1421
1422 /** 1422 /**
1423 * Filters file according to the selected file type. 1423 * Filters file according to the selected file type.
1424 */ 1424 */
1425 FileManager.prototype.updateFileTypeFilter_ = function() { 1425 FileManager.prototype.updateFileTypeFilter_ = function() {
1426 this.directoryModel_.removeFilter('fileType'); 1426 this.directoryModel_.removeFilter('fileType');
1427 var selectedIndex = Number(this.fileTypeSelector_.selectedIndex); 1427 var selectedIndex = Number(this.fileTypeSelector_.selectedIndex);
1428 if (selectedIndex < 1) // 'All files' or nothing selected. 1428 if (selectedIndex >= 1) { // Specific filter selected.
1429 return; 1429 var regexp = new RegExp('.*(' +
1430 var regexp = new RegExp('.*(' + 1430 this.fileTypes_[selectedIndex - 1].extensions.join('|') + ')$', 'i');
1431 this.fileTypes_[selectedIndex - 1].extensions.join('|') + ')$', 'i'); 1431 function filter(entry) {
1432 function filter(entry) { 1432 return entry.isDirectory || regexp.test(entry.name);
1433 return entry.isDirectory || regexp.test(entry.name); 1433 }
1434 this.directoryModel_.addFilter('fileType', filter);
1434 } 1435 }
1435 this.directoryModel_.addFilter('fileType', filter); 1436 this.directoryModel_.rescan();
1436 }; 1437 };
1437 1438
1438 /** 1439 /**
1439 * Respond to a command being executed. 1440 * Respond to a command being executed.
1440 */ 1441 */
1441 FileManager.prototype.onCommand_ = function(event) { 1442 FileManager.prototype.onCommand_ = function(event) {
1442 switch (event.command.id) { 1443 switch (event.command.id) {
1443 case 'cut': 1444 case 'cut':
1444 case 'copy': 1445 case 'copy':
1445 case 'paste': 1446 case 'paste':
(...skipping 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after
4231 } 4232 }
4232 4233
4233 var defaultActionSeparator = 4234 var defaultActionSeparator =
4234 this.dialogDom_.querySelector('#default-action-separator'); 4235 this.dialogDom_.querySelector('#default-action-separator');
4235 4236
4236 this.defaultActionMenuItem_.hidden = !taskItem; 4237 this.defaultActionMenuItem_.hidden = !taskItem;
4237 defaultActionSeparator.hidden = !taskItem; 4238 defaultActionSeparator.hidden = !taskItem;
4238 } 4239 }
4239 })(); 4240 })();
4240 4241
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698