Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 FileManager.initStrings = function(callback) { | 260 FileManager.initStrings = function(callback) { |
| 261 chrome.fileBrowserPrivate.getStrings(function(strings) { | 261 chrome.fileBrowserPrivate.getStrings(function(strings) { |
| 262 localStrings = new LocalStrings(strings); | 262 localStrings = new LocalStrings(strings); |
| 263 if (callback) | 263 if (callback) |
| 264 callback(); | 264 callback(); |
| 265 }); | 265 }); |
| 266 }; | 266 }; |
| 267 | 267 |
| 268 // Instance methods. | 268 // Instance methods. |
| 269 | 269 |
| 270 FileManager.prototype.$ = function(id) { | |
|
dgozman
2012/05/15 13:12:39
Don't like this :(
Vladislav Kaznacheev
2012/05/15 13:38:13
Oh no.
Oleg Eterevsky
2012/05/15 13:55:28
Done.
Oleg Eterevsky
2012/05/15 13:55:28
Done.
| |
| 271 return this.document_.getElementById(id); | |
| 272 }; | |
| 273 | |
| 270 /** | 274 /** |
| 271 * Request local file system, resolve roots and init_ after that. | 275 * Request local file system, resolve roots and init_ after that. |
| 272 * @private | 276 * @private |
| 273 */ | 277 */ |
| 274 FileManager.prototype.initFileSystem_ = function() { | 278 FileManager.prototype.initFileSystem_ = function() { |
| 275 util.installFileErrorToString(); | 279 util.installFileErrorToString(); |
| 276 // Replace the default unit in util to translated unit. | 280 // Replace the default unit in util to translated unit. |
| 277 util.UNITS = [str('SIZE_KB'), | 281 util.UNITS = [str('SIZE_KB'), |
| 278 str('SIZE_MB'), | 282 str('SIZE_MB'), |
| 279 str('SIZE_GB'), | 283 str('SIZE_GB'), |
| (...skipping 4050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4330 event.target.setAttribute('checked', 'checked'); | 4334 event.target.setAttribute('checked', 'checked'); |
| 4331 else | 4335 else |
| 4332 event.target.removeAttribute('checked'); | 4336 event.target.removeAttribute('checked'); |
| 4333 | 4337 |
| 4334 var changeInfo = {}; | 4338 var changeInfo = {}; |
| 4335 changeInfo[pref] = inverted ? !newValue : newValue; | 4339 changeInfo[pref] = inverted ? !newValue : newValue; |
| 4336 chrome.fileBrowserPrivate.setGDataPreferences(changeInfo); | 4340 chrome.fileBrowserPrivate.setGDataPreferences(changeInfo); |
| 4337 }; | 4341 }; |
| 4338 | 4342 |
| 4339 FileManager.prototype.onSearchBoxUpdate_ = function(event) { | 4343 FileManager.prototype.onSearchBoxUpdate_ = function(event) { |
| 4340 var searchString = this.dialogDom_.querySelector('#search-box').value; | 4344 var searchString = this.$('search-box').value; |
| 4341 if (searchString) { | 4345 if (searchString) { |
| 4342 this.directoryModel_.addFilter( | 4346 this.directoryModel_.addFilter( |
| 4343 'searchbox', | 4347 'searchbox', |
| 4344 function(e) { | 4348 function(e) { |
| 4345 return e.name.substr(0, searchString.length) == searchString; | 4349 return e.name.substr(0, searchString.length) == searchString; |
| 4346 }); | 4350 }); |
| 4351 | |
| 4352 var self = this; | |
| 4353 | |
| 4354 this.reportEmptySearchResults_ = function() { | |
| 4355 if (self.directoryModel_.getFileList().length === 0) { | |
| 4356 var template = str('SEARCH_NO_MATCHING_FILES'); | |
| 4357 var index = template.indexOf('$1'); | |
|
dgozman
2012/05/15 13:12:39
You can just use <b>$1</b> inside the localized st
Oleg Eterevsky
2012/05/15 13:55:28
Done.
| |
| 4358 self.$('no-search-results-prefix').textContent = | |
| 4359 template.substring(0, index - 1); | |
| 4360 self.$('no-search-results-suffix').textContent = | |
| 4361 template.substring(index + 3); | |
| 4362 var quotedSearchString = template.substring(index - 1, index + 3); | |
| 4363 self.$('no-search-results-query').textContent = | |
| 4364 quotedSearchString.replace('$1', searchString); | |
| 4365 | |
| 4366 self.$('list-container').setAttribute('no-search-results', 'true'); | |
| 4367 } | |
|
Vladislav Kaznacheev
2012/05/15 13:38:13
add .bind(this) and you do not need var self
Oleg Eterevsky
2012/05/15 13:55:28
Done.
Oleg Eterevsky
2012/05/15 13:55:28
Done.
| |
| 4368 }; | |
| 4369 | |
| 4370 this.directoryModel_.addEventListener( | |
| 4371 'rescan-completed', this.reportEmptySearchResults_); | |
| 4347 } else { | 4372 } else { |
| 4348 this.directoryModel_.removeFilter('searchbox'); | 4373 this.directoryModel_.removeFilter('searchbox'); |
| 4374 this.$('list-container').setAttribute('no-search-results', 'false'); | |
| 4375 this.directoryModel_.removeEventListener( | |
| 4376 'rescan-completed', this.reportEmptySearchResults_); | |
| 4349 } | 4377 } |
| 4350 }; | 4378 }; |
| 4351 | 4379 |
| 4352 FileManager.prototype.decorateSplitter = function(splitterElement) { | 4380 FileManager.prototype.decorateSplitter = function(splitterElement) { |
| 4353 var self = this; | 4381 var self = this; |
| 4354 | 4382 |
| 4355 var Splitter = cr.ui.Splitter; | 4383 var Splitter = cr.ui.Splitter; |
| 4356 | 4384 |
| 4357 var customSplitter = cr.ui.define('div'); | 4385 var customSplitter = cr.ui.define('div'); |
| 4358 | 4386 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4479 | 4507 |
| 4480 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner); | 4508 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner); |
| 4481 this.directoryModel_.addEventListener('rescan-completed', maybeShowBanner); | 4509 this.directoryModel_.addEventListener('rescan-completed', maybeShowBanner); |
| 4482 | 4510 |
| 4483 var style = this.document_.createElement('link'); | 4511 var style = this.document_.createElement('link'); |
| 4484 style.rel = 'stylesheet'; | 4512 style.rel = 'stylesheet'; |
| 4485 style.href = 'css/gdrive_welcome.css'; | 4513 style.href = 'css/gdrive_welcome.css'; |
| 4486 this.document_.head.appendChild(style); | 4514 this.document_.head.appendChild(style); |
| 4487 }; | 4515 }; |
| 4488 })(); | 4516 })(); |
| OLD | NEW |