OLD | NEW |
---|---|
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 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' | 5 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' |
6 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; | 6 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; |
7 | 7 |
8 var g_slideshow_data = null; | 8 var g_slideshow_data = null; |
9 | 9 |
10 const IMAGE_EDITOR_ENABLED = false; | 10 const IMAGE_EDITOR_ENABLED = false; |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 this.previewMetadata_ = this.dialogDom_.querySelector('.preview-metadata'); | 517 this.previewMetadata_ = this.dialogDom_.querySelector('.preview-metadata'); |
518 this.filenameInput_ = this.dialogDom_.querySelector('.filename-input'); | 518 this.filenameInput_ = this.dialogDom_.querySelector('.filename-input'); |
519 this.taskButtons_ = this.dialogDom_.querySelector('.task-buttons'); | 519 this.taskButtons_ = this.dialogDom_.querySelector('.task-buttons'); |
520 this.okButton_ = this.dialogDom_.querySelector('.ok'); | 520 this.okButton_ = this.dialogDom_.querySelector('.ok'); |
521 this.cancelButton_ = this.dialogDom_.querySelector('.cancel'); | 521 this.cancelButton_ = this.dialogDom_.querySelector('.cancel'); |
522 this.newFolderButton_ = this.dialogDom_.querySelector('.new-folder'); | 522 this.newFolderButton_ = this.dialogDom_.querySelector('.new-folder'); |
523 | 523 |
524 this.renameInput_ = this.document_.createElement('input'); | 524 this.renameInput_ = this.document_.createElement('input'); |
525 this.renameInput_.className = 'rename'; | 525 this.renameInput_.className = 'rename'; |
526 | 526 |
527 this.imageEditorFrame_ = this.document_.createElement('div'); | |
528 this.imageEditorFrame_.className = 'image-editor'; | |
529 this.imageEditorFrame_.style.display = 'none'; | |
530 this.dialogDom_.appendChild(this.imageEditorFrame_); | |
531 | |
532 this.renameInput_.addEventListener( | 527 this.renameInput_.addEventListener( |
533 'keydown', this.onRenameInputKeyDown_.bind(this)); | 528 'keydown', this.onRenameInputKeyDown_.bind(this)); |
534 this.renameInput_.addEventListener( | 529 this.renameInput_.addEventListener( |
535 'blur', this.onRenameInputBlur_.bind(this)); | 530 'blur', this.onRenameInputBlur_.bind(this)); |
536 | 531 |
537 this.filenameInput_.addEventListener( | 532 this.filenameInput_.addEventListener( |
538 'keyup', this.onFilenameInputKeyUp_.bind(this)); | 533 'keyup', this.onFilenameInputKeyUp_.bind(this)); |
539 this.filenameInput_.addEventListener( | 534 this.filenameInput_.addEventListener( |
540 'focus', this.onFilenameInputFocus_.bind(this)); | 535 'focus', this.onFilenameInputFocus_.bind(this)); |
541 | 536 |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1357 }; | 1352 }; |
1358 | 1353 |
1359 FileManager.prototype.onFileTaskExecute_ = function(id, details) { | 1354 FileManager.prototype.onFileTaskExecute_ = function(id, details) { |
1360 var urls = details.entries.map(function(entry) { | 1355 var urls = details.entries.map(function(entry) { |
1361 return entry.toURL(); | 1356 return entry.toURL(); |
1362 }); | 1357 }); |
1363 if (id == 'preview') { | 1358 if (id == 'preview') { |
1364 g_slideshow_data = urls; | 1359 g_slideshow_data = urls; |
1365 chrome.tabs.create({url: "slideshow.html"}); | 1360 chrome.tabs.create({url: "slideshow.html"}); |
1366 } else if (id == 'edit') { | 1361 } else if (id == 'edit') { |
1367 this.imageEditorFrame_.style.display = 'block'; | 1362 this.openImageEditor(details.entries[0]); |
1368 this.imageEditor_ = new ImageEditor( | |
1369 this.imageEditorFrame_, | |
1370 this.onImageEditorSave.bind(this, details.entries[0]), | |
1371 this.onImageEditorClose.bind(this)); | |
1372 this.imageEditor_.getBuffer().load(urls[0]); | |
1373 } else if (id == 'play' || id == 'enqueue') { | 1363 } else if (id == 'play' || id == 'enqueue') { |
1374 chrome.fileBrowserPrivate.viewFiles(urls, id); | 1364 chrome.fileBrowserPrivate.viewFiles(urls, id); |
1375 } | 1365 } |
1376 }; | 1366 }; |
1377 | 1367 |
1378 FileManager.prototype.onImageEditorSave = function(entry, canvas) { | 1368 FileManager.prototype.openImageEditor = function(entry) { |
SeRya
2011/08/02 17:53:57
Shouldn't it be a private method?
Vladislav Kaznacheev
2011/08/03 09:46:41
Done.
| |
1379 var self = this; | 1369 var self = this; |
1380 this.cacheMetadata_(entry, function(metadata) { | 1370 |
1381 // The code below modifies the metadata parameter. We assume that this is | 1371 var editorFrame = this.document_.createElement('iframe'); |
1382 // the master copy, otherwise other cacheMetadata_ callers would not | 1372 editorFrame.className = 'overlay-pane'; |
1383 // see our changes. | 1373 editorFrame.scrolling = 'no'; |
1384 // The mime type is hardcoded as the editor only works with jpeg for now. | 1374 |
1385 var blob = ImageEncoder.getBlob(canvas, 'image/jpeg', metadata) | 1375 editorFrame.onload = function() { |
1386 // TODO(kaznacheev): Notify user properly about write failures. | 1376 self.cacheMetadata_(entry, function(metadata) { |
1387 util.writeBlobToFile(entry, blob, function(){}, | 1377 editorFrame.contentWindow.ImageEditor.open( |
1388 util.flog('Error writing to ' + entry.fullPath)); | 1378 self.onImageEditorSave.bind(self, entry), |
1389 self.updatePreview_(); // Metadata may have changed. | 1379 function () { self.dialogDom_.removeChild(editorFrame) }, |
1390 }); | 1380 entry.toURL(), |
1381 metadata); | |
1382 }); | |
1383 }; | |
1384 | |
1385 editorFrame.src = 'js/image_editor/image_editor.html'; | |
1386 | |
1387 this.dialogDom_.appendChild(editorFrame); | |
1391 }; | 1388 }; |
1392 | 1389 |
1393 FileManager.prototype.onImageEditorClose = function() { | 1390 FileManager.prototype.onImageEditorSave = function(entry, blob) { |
SeRya
2011/08/02 17:53:57
as above
Vladislav Kaznacheev
2011/08/03 09:46:41
Done.
| |
1394 this.imageEditorFrame_.style.display = 'none'; | 1391 // TODO(kaznacheev): Notify user properly about write failures. |
1395 this.imageEditor_ = null; | 1392 util.writeBlobToFile(entry, blob, function(){}, |
1393 util.flog('Error writing to ' + entry.fullPath)); | |
1394 this.updatePreview_(); // Metadata may have changed. | |
1396 }; | 1395 }; |
1397 | 1396 |
1398 /** | 1397 /** |
1399 * Update the breadcrumb display to reflect the current directory. | 1398 * Update the breadcrumb display to reflect the current directory. |
1400 */ | 1399 */ |
1401 FileManager.prototype.updateBreadcrumbs_ = function() { | 1400 FileManager.prototype.updateBreadcrumbs_ = function() { |
1402 var bc = this.dialogDom_.querySelector('.breadcrumbs'); | 1401 var bc = this.dialogDom_.querySelector('.breadcrumbs'); |
1403 bc.innerHTML = ''; | 1402 bc.innerHTML = ''; |
1404 | 1403 |
1405 var fullPath = this.currentDirEntry_.fullPath.replace(/\/$/, ''); | 1404 var fullPath = this.currentDirEntry_.fullPath.replace(/\/$/, ''); |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2479 window.alert(str('ERROR_RESERVED_NAME')); | 2478 window.alert(str('ERROR_RESERVED_NAME')); |
2480 return false; | 2479 return false; |
2481 } | 2480 } |
2482 if (this.filterFiles_ && name[0] == '.') { | 2481 if (this.filterFiles_ && name[0] == '.') { |
2483 window.alert(str('ERROR_HIDDEN_NAME')); | 2482 window.alert(str('ERROR_HIDDEN_NAME')); |
2484 return false; | 2483 return false; |
2485 } | 2484 } |
2486 return true; | 2485 return true; |
2487 }; | 2486 }; |
2488 })(); | 2487 })(); |
OLD | NEW |