| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * Slide mode displays a single image and has a set of controls to navigate | 6 * Slide mode displays a single image and has a set of controls to navigate |
| 7 * between the images and to edit an image. | 7 * between the images and to edit an image. |
| 8 * | 8 * |
| 9 * @param {!HTMLElement} container Main container element. | 9 * @param {!HTMLElement} container Main container element. |
| 10 * @param {!HTMLElement} content Content container element. | 10 * @param {!HTMLElement} content Content container element. |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 */ | 180 */ |
| 181 this.slideHint_ = null; | 181 this.slideHint_ = null; |
| 182 | 182 |
| 183 /** | 183 /** |
| 184 * @type {boolean} | 184 * @type {boolean} |
| 185 * @private | 185 * @private |
| 186 */ | 186 */ |
| 187 this.active_ = false; | 187 this.active_ = false; |
| 188 | 188 |
| 189 /** | 189 /** |
| 190 * @private {Gallery.SubMode} | 190 * @private {GallerySubMode} |
| 191 */ | 191 */ |
| 192 this.subMode_ = Gallery.SubMode.BROWSE; | 192 this.subMode_ = GallerySubMode.BROWSE; |
| 193 | 193 |
| 194 /** | 194 /** |
| 195 * @type {boolean} | 195 * @type {boolean} |
| 196 * @private | 196 * @private |
| 197 */ | 197 */ |
| 198 this.leaveAfterSlideshow_ = false; | 198 this.leaveAfterSlideshow_ = false; |
| 199 | 199 |
| 200 /** | 200 /** |
| 201 * @type {boolean} | 201 * @type {boolean} |
| 202 * @private | 202 * @private |
| (...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 // These are workarounds. Mouseout event is not dispatched when window becomes | 1461 // These are workarounds. Mouseout event is not dispatched when window becomes |
| 1462 // fullscreen and cursor gets out of the element | 1462 // fullscreen and cursor gets out of the element |
| 1463 // TODO(yawano): Find better implementation. | 1463 // TODO(yawano): Find better implementation. |
| 1464 this.dimmableUIController_.setCursorOutOfTools(); | 1464 this.dimmableUIController_.setCursorOutOfTools(); |
| 1465 document.querySelector('files-tooltip').hideTooltip(); | 1465 document.querySelector('files-tooltip').hideTooltip(); |
| 1466 | 1466 |
| 1467 this.resumeSlideshow_(opt_interval); | 1467 this.resumeSlideshow_(opt_interval); |
| 1468 | 1468 |
| 1469 this.setSubMode_(Gallery.SubMode.SLIDESHOW); | 1469 this.setSubMode_(GallerySubMode.SLIDESHOW); |
| 1470 }; | 1470 }; |
| 1471 | 1471 |
| 1472 /** | 1472 /** |
| 1473 * Stops the slideshow. | 1473 * Stops the slideshow. |
| 1474 * @param {Event=} opt_event Event. | 1474 * @param {Event=} opt_event Event. |
| 1475 * @private | 1475 * @private |
| 1476 */ | 1476 */ |
| 1477 SlideMode.prototype.stopSlideshow_ = function(opt_event) { | 1477 SlideMode.prototype.stopSlideshow_ = function(opt_event) { |
| 1478 if (!this.isSlideshowOn_()) | 1478 if (!this.isSlideshowOn_()) |
| 1479 return; | 1479 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1492 toggleModeDelay = SlideMode.FULLSCREEN_TOGGLE_DELAY; | 1492 toggleModeDelay = SlideMode.FULLSCREEN_TOGGLE_DELAY; |
| 1493 } | 1493 } |
| 1494 if (this.leaveAfterSlideshow_) { | 1494 if (this.leaveAfterSlideshow_) { |
| 1495 this.leaveAfterSlideshow_ = false; | 1495 this.leaveAfterSlideshow_ = false; |
| 1496 setTimeout(this.toggleMode_.bind(this), toggleModeDelay); | 1496 setTimeout(this.toggleMode_.bind(this), toggleModeDelay); |
| 1497 } | 1497 } |
| 1498 | 1498 |
| 1499 // Re-enable touch operation. | 1499 // Re-enable touch operation. |
| 1500 this.touchHandlers_.enabled = true; | 1500 this.touchHandlers_.enabled = true; |
| 1501 | 1501 |
| 1502 this.setSubMode_(Gallery.SubMode.BROWSE); | 1502 this.setSubMode_(GallerySubMode.BROWSE); |
| 1503 }; | 1503 }; |
| 1504 | 1504 |
| 1505 /** | 1505 /** |
| 1506 * @return {boolean} True if the slideshow is playing (not paused). | 1506 * @return {boolean} True if the slideshow is playing (not paused). |
| 1507 * @private | 1507 * @private |
| 1508 */ | 1508 */ |
| 1509 SlideMode.prototype.isSlideshowPlaying_ = function() { | 1509 SlideMode.prototype.isSlideshowPlaying_ = function() { |
| 1510 return this.container_.getAttribute('slideshow') === 'playing'; | 1510 return this.container_.getAttribute('slideshow') === 'playing'; |
| 1511 }; | 1511 }; |
| 1512 | 1512 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 * Stops editing. | 1572 * Stops editing. |
| 1573 * @private | 1573 * @private |
| 1574 */ | 1574 */ |
| 1575 SlideMode.prototype.stopEditing_ = function() { | 1575 SlideMode.prototype.stopEditing_ = function() { |
| 1576 if (this.isEditing()) | 1576 if (this.isEditing()) |
| 1577 this.toggleEditor(); | 1577 this.toggleEditor(); |
| 1578 }; | 1578 }; |
| 1579 | 1579 |
| 1580 /** | 1580 /** |
| 1581 * Sets current sub mode. | 1581 * Sets current sub mode. |
| 1582 * @param {Gallery.SubMode} subMode | 1582 * @param {GallerySubMode} subMode |
| 1583 * @private | 1583 * @private |
| 1584 */ | 1584 */ |
| 1585 SlideMode.prototype.setSubMode_ = function(subMode) { | 1585 SlideMode.prototype.setSubMode_ = function(subMode) { |
| 1586 if (this.subMode_ === subMode) | 1586 if (this.subMode_ === subMode) |
| 1587 return; | 1587 return; |
| 1588 | 1588 |
| 1589 this.subMode_ = subMode; | 1589 this.subMode_ = subMode; |
| 1590 | 1590 |
| 1591 var event = new Event('sub-mode-change'); | 1591 var event = new Event('sub-mode-change'); |
| 1592 event.subMode = this.subMode_; | 1592 event.subMode = this.subMode_; |
| 1593 this.dispatchEvent(event); | 1593 this.dispatchEvent(event); |
| 1594 }; | 1594 }; |
| 1595 | 1595 |
| 1596 /** | 1596 /** |
| 1597 * Returns current sub mode. | 1597 * Returns current sub mode. |
| 1598 * @return {Gallery.SubMode} | 1598 * @return {GallerySubMode} |
| 1599 */ | 1599 */ |
| 1600 SlideMode.prototype.getSubMode = function() { | 1600 SlideMode.prototype.getSubMode = function() { |
| 1601 return this.subMode_; | 1601 return this.subMode_; |
| 1602 }; | 1602 }; |
| 1603 | 1603 |
| 1604 /** | 1604 /** |
| 1605 * Activate/deactivate editor. | 1605 * Activate/deactivate editor. |
| 1606 * @param {Event=} opt_event Event. | 1606 * @param {Event=} opt_event Event. |
| 1607 */ | 1607 */ |
| 1608 SlideMode.prototype.toggleEditor = function(opt_event) { | 1608 SlideMode.prototype.toggleEditor = function(opt_event) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 | 1645 |
| 1646 // Show overwrite original bubble if it hasn't been shown for max times. | 1646 // Show overwrite original bubble if it hasn't been shown for max times. |
| 1647 this.getOverwriteBubbleCount_().then(function(count) { | 1647 this.getOverwriteBubbleCount_().then(function(count) { |
| 1648 if (count >= SlideMode.OVERWRITE_BUBBLE_MAX_TIMES) | 1648 if (count >= SlideMode.OVERWRITE_BUBBLE_MAX_TIMES) |
| 1649 return; | 1649 return; |
| 1650 | 1650 |
| 1651 this.setOverwriteBubbleCount_(count + 1); | 1651 this.setOverwriteBubbleCount_(count + 1); |
| 1652 this.bubble_.hidden = false; | 1652 this.bubble_.hidden = false; |
| 1653 }.bind(this)); | 1653 }.bind(this)); |
| 1654 | 1654 |
| 1655 this.setSubMode_(Gallery.SubMode.EDIT); | 1655 this.setSubMode_(GallerySubMode.EDIT); |
| 1656 this.editor_.onStartEditing(); | 1656 this.editor_.onStartEditing(); |
| 1657 } else { | 1657 } else { |
| 1658 this.editor_.getPrompt().hide(); | 1658 this.editor_.getPrompt().hide(); |
| 1659 this.editor_.leaveMode(false /* not to switch mode */); | 1659 this.editor_.leaveMode(false /* not to switch mode */); |
| 1660 | 1660 |
| 1661 this.viewport_.setScreenTop(0); | 1661 this.viewport_.setScreenTop(0); |
| 1662 this.viewport_.setScreenBottom(0); | 1662 this.viewport_.setScreenBottom(0); |
| 1663 this.imageView_.applyViewportChange(); | 1663 this.imageView_.applyViewportChange(); |
| 1664 | 1664 |
| 1665 this.bubble_.hidden = true; | 1665 this.bubble_.hidden = true; |
| 1666 | 1666 |
| 1667 this.touchHandlers_.enabled = true; | 1667 this.touchHandlers_.enabled = true; |
| 1668 | 1668 |
| 1669 this.setSubMode_(Gallery.SubMode.BROWSE); | 1669 this.setSubMode_(GallerySubMode.BROWSE); |
| 1670 } | 1670 } |
| 1671 }; | 1671 }; |
| 1672 | 1672 |
| 1673 /** | 1673 /** |
| 1674 * Gets count of overwrite bubble. | 1674 * Gets count of overwrite bubble. |
| 1675 * @return {!Promise<number>} | 1675 * @return {!Promise<number>} |
| 1676 * @private | 1676 * @private |
| 1677 */ | 1677 */ |
| 1678 SlideMode.prototype.getOverwriteBubbleCount_ = function() { | 1678 SlideMode.prototype.getOverwriteBubbleCount_ = function() { |
| 1679 return new Promise(function(resolve, reject) { | 1679 return new Promise(function(resolve, reject) { |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 /** | 2144 /** |
| 2145 * Handles mouse up events. | 2145 * Handles mouse up events. |
| 2146 * @param {!Event} event Wheel event. | 2146 * @param {!Event} event Wheel event. |
| 2147 * @private | 2147 * @private |
| 2148 */ | 2148 */ |
| 2149 TouchHandler.prototype.onMouseUp_ = function(event) { | 2149 TouchHandler.prototype.onMouseUp_ = function(event) { |
| 2150 if (event.button !== 0) | 2150 if (event.button !== 0) |
| 2151 return; | 2151 return; |
| 2152 this.clickStarted_ = false; | 2152 this.clickStarted_ = false; |
| 2153 }; | 2153 }; |
| OLD | NEW |