| 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 // 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 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 this[methodName].apply(this, data.arguments); | 1611 this[methodName].apply(this, data.arguments); |
| 1612 }; | 1612 }; |
| 1613 | 1613 |
| 1614 /** | 1614 /** |
| 1615 * Callback called when tasks for selected files are determined. | 1615 * Callback called when tasks for selected files are determined. |
| 1616 * @param {Object} selection Selection is passed here, since this.selection | 1616 * @param {Object} selection Selection is passed here, since this.selection |
| 1617 * can change before tasks were found, and we should be accurate. | 1617 * can change before tasks were found, and we should be accurate. |
| 1618 * @param {Array.<Task>} tasksList The tasks list. | 1618 * @param {Array.<Task>} tasksList The tasks list. |
| 1619 */ | 1619 */ |
| 1620 FileManager.prototype.onTasksFound_ = function(selection, tasksList) { | 1620 FileManager.prototype.onTasksFound_ = function(selection, tasksList) { |
| 1621 this.taskButtons_.innerHTML = ''; |
| 1622 |
| 1621 for (var i = 0; i < tasksList.length; i++) { | 1623 for (var i = 0; i < tasksList.length; i++) { |
| 1622 var task = tasksList[i]; | 1624 var task = tasksList[i]; |
| 1623 | 1625 |
| 1624 // Tweak images, titles of internal tasks. | 1626 // Tweak images, titles of internal tasks. |
| 1625 var task_parts = task.taskId.split('|'); | 1627 var task_parts = task.taskId.split('|'); |
| 1626 if (task_parts[0] == this.getExtensionId_()) { | 1628 if (task_parts[0] == this.getExtensionId_()) { |
| 1627 if (task_parts[1] == 'preview') { | 1629 if (task_parts[1] == 'preview') { |
| 1628 // TODO(serya): This hack needed until task.iconUrl get working | 1630 // TODO(serya): This hack needed until task.iconUrl get working |
| 1629 // (see GetFileTasksFileBrowserFunction::RunImpl). | 1631 // (see GetFileTasksFileBrowserFunction::RunImpl). |
| 1630 task.iconUrl = | 1632 task.iconUrl = |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1646 } else if (task_parts[1] == 'mount-archive') { | 1648 } else if (task_parts[1] == 'mount-archive') { |
| 1647 task.iconUrl = | 1649 task.iconUrl = |
| 1648 chrome.extension.getURL('images/icon_mount_archive_16x16.png'); | 1650 chrome.extension.getURL('images/icon_mount_archive_16x16.png'); |
| 1649 task.title = str('MOUNT_ARCHIVE'); | 1651 task.title = str('MOUNT_ARCHIVE'); |
| 1650 if (str('ENABLE_ARCHIVES') != 'true') | 1652 if (str('ENABLE_ARCHIVES') != 'true') |
| 1651 continue; | 1653 continue; |
| 1652 } | 1654 } |
| 1653 } | 1655 } |
| 1654 this.renderTaskButton_(task); | 1656 this.renderTaskButton_(task); |
| 1655 } | 1657 } |
| 1658 |
| 1659 // These are done in separate functions, as the checks require |
| 1660 // asynchronous function calls. |
| 1656 this.maybeRenderUnmountTask_(selection); | 1661 this.maybeRenderUnmountTask_(selection); |
| 1657 // This needs to be done in separate function, as check requires | |
| 1658 // asynchronous function calls. | |
| 1659 this.maybeRenderFormattingTask_(selection); | 1662 this.maybeRenderFormattingTask_(selection); |
| 1660 }; | 1663 }; |
| 1661 | 1664 |
| 1662 FileManager.prototype.renderTaskButton_ = function(task) { | 1665 FileManager.prototype.renderTaskButton_ = function(task) { |
| 1663 var button = this.document_.createElement('button'); | 1666 var button = this.document_.createElement('button'); |
| 1664 button.addEventListener('click', this.onTaskButtonClicked_.bind(this)); | 1667 button.addEventListener('click', this.onTaskButtonClicked_.bind(this)); |
| 1665 button.className = 'task-button'; | 1668 button.className = 'task-button'; |
| 1666 button.task = task; | 1669 button.task = task; |
| 1667 | 1670 |
| 1668 var img = this.document_.createElement('img'); | 1671 var img = this.document_.createElement('img'); |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2432 // that are no longer there. | 2435 // that are no longer there. |
| 2433 continue; | 2436 continue; |
| 2434 } | 2437 } |
| 2435 | 2438 |
| 2436 if (!event.changes[i].selected) { | 2439 if (!event.changes[i].selected) { |
| 2437 var checkbox = listItem.querySelector('input[type="checkbox"]'); | 2440 var checkbox = listItem.querySelector('input[type="checkbox"]'); |
| 2438 checkbox.checked = false; | 2441 checkbox.checked = false; |
| 2439 } | 2442 } |
| 2440 } | 2443 } |
| 2441 | 2444 |
| 2442 if (this.selection.fileCount > 1) { | 2445 if (this.selection.totalCount > 0) { |
| 2443 // If more than one file is selected, make sure all checkboxes are lit | 2446 // If more than one file is selected, make sure all checkboxes are lit |
| 2444 // up. | 2447 // up. |
| 2445 for (var i = 0; i < this.selection.entries.length; i++) { | 2448 for (var i = 0; i < this.selection.entries.length; i++) { |
| 2446 if (!this.selection.entries[i].isFile) | |
| 2447 continue; | |
| 2448 | |
| 2449 var selectedIndex = this.selection.indexes[i]; | 2449 var selectedIndex = this.selection.indexes[i]; |
| 2450 var listItem = this.currentList_.getListItemByIndex(selectedIndex); | 2450 var listItem = this.currentList_.getListItemByIndex(selectedIndex); |
| 2451 if (listItem) | 2451 if (listItem) |
| 2452 listItem.querySelector('input[type="checkbox"]').checked = true; | 2452 listItem.querySelector('input[type="checkbox"]').checked = true; |
| 2453 } | 2453 } |
| 2454 } | 2454 } |
| 2455 }; | 2455 }; |
| 2456 | 2456 |
| 2457 FileManager.prototype.updateOkButton_ = function(event) { | 2457 FileManager.prototype.updateOkButton_ = function(event) { |
| 2458 var selectable; | 2458 var selectable; |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3160 | 3160 |
| 3161 if (msg) { | 3161 if (msg) { |
| 3162 console.log('no no no'); | 3162 console.log('no no no'); |
| 3163 this.alert.show(msg, onAccept); | 3163 this.alert.show(msg, onAccept); |
| 3164 return false; | 3164 return false; |
| 3165 } | 3165 } |
| 3166 | 3166 |
| 3167 return true; | 3167 return true; |
| 3168 }; | 3168 }; |
| 3169 })(); | 3169 })(); |
| OLD | NEW |