|
@@ -19,10 +19,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
});
|
|
|
exports.SecondaryToolbar = undefined;
|
|
|
|
|
|
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
+
|
|
|
var _ui_utils = require('./ui_utils');
|
|
|
|
|
|
-var SecondaryToolbar = function SecondaryToolbarClosure() {
|
|
|
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
+
|
|
|
+var SecondaryToolbar = function () {
|
|
|
function SecondaryToolbar(options, mainContainer, eventBus) {
|
|
|
+ _classCallCheck(this, SecondaryToolbar);
|
|
|
+
|
|
|
this.toolbar = options.toolbar;
|
|
|
this.toggleButton = options.toggleButton;
|
|
|
this.toolbarButtonContainer = options.toolbarButtonContainer;
|
|
@@ -87,31 +93,37 @@ var SecondaryToolbar = function SecondaryToolbarClosure() {
|
|
|
this._bindHandToolListener(options.toggleHandToolButton);
|
|
|
this.eventBus.on('resize', this._setMaxHeight.bind(this));
|
|
|
}
|
|
|
- SecondaryToolbar.prototype = {
|
|
|
- get isOpen() {
|
|
|
- return this.opened;
|
|
|
- },
|
|
|
- setPageNumber: function SecondaryToolbar_setPageNumber(pageNumber) {
|
|
|
+
|
|
|
+ _createClass(SecondaryToolbar, [{
|
|
|
+ key: 'setPageNumber',
|
|
|
+ value: function setPageNumber(pageNumber) {
|
|
|
this.pageNumber = pageNumber;
|
|
|
this._updateUIState();
|
|
|
- },
|
|
|
- setPagesCount: function SecondaryToolbar_setPagesCount(pagesCount) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'setPagesCount',
|
|
|
+ value: function setPagesCount(pagesCount) {
|
|
|
this.pagesCount = pagesCount;
|
|
|
this._updateUIState();
|
|
|
- },
|
|
|
- reset: function SecondaryToolbar_reset() {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'reset',
|
|
|
+ value: function reset() {
|
|
|
this.pageNumber = 0;
|
|
|
this.pagesCount = 0;
|
|
|
this._updateUIState();
|
|
|
- },
|
|
|
- _updateUIState: function SecondaryToolbar_updateUIState() {
|
|
|
- var items = this.items;
|
|
|
- items.firstPage.disabled = this.pageNumber <= 1;
|
|
|
- items.lastPage.disabled = this.pageNumber >= this.pagesCount;
|
|
|
- items.pageRotateCw.disabled = this.pagesCount === 0;
|
|
|
- items.pageRotateCcw.disabled = this.pagesCount === 0;
|
|
|
- },
|
|
|
- _bindClickListeners: function SecondaryToolbar_bindClickListeners() {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: '_updateUIState',
|
|
|
+ value: function _updateUIState() {
|
|
|
+ this.items.firstPage.disabled = this.pageNumber <= 1;
|
|
|
+ this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
|
|
|
+ this.items.pageRotateCw.disabled = this.pagesCount === 0;
|
|
|
+ this.items.pageRotateCcw.disabled = this.pagesCount === 0;
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: '_bindClickListeners',
|
|
|
+ value: function _bindClickListeners() {
|
|
|
var _this = this;
|
|
|
|
|
|
this.toggleButton.addEventListener('click', this.toggle.bind(this));
|
|
@@ -135,14 +147,16 @@ var SecondaryToolbar = function SecondaryToolbarClosure() {
|
|
|
for (var button in this.buttons) {
|
|
|
_loop(button);
|
|
|
}
|
|
|
- },
|
|
|
- _bindHandToolListener: function SecondaryToolbar_bindHandToolListener(toggleHandToolButton) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: '_bindHandToolListener',
|
|
|
+ value: function _bindHandToolListener(toggleHandToolButton) {
|
|
|
var isHandToolActive = false;
|
|
|
- this.eventBus.on('handtoolchanged', function (e) {
|
|
|
- if (isHandToolActive === e.isActive) {
|
|
|
+ this.eventBus.on('handtoolchanged', function (evt) {
|
|
|
+ if (isHandToolActive === evt.isActive) {
|
|
|
return;
|
|
|
}
|
|
|
- isHandToolActive = e.isActive;
|
|
|
+ isHandToolActive = evt.isActive;
|
|
|
if (isHandToolActive) {
|
|
|
toggleHandToolButton.title = _ui_utils.mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
|
|
|
toggleHandToolButton.firstElementChild.textContent = _ui_utils.mozL10n.get('hand_tool_disable_label', null, 'Disable hand tool');
|
|
@@ -151,8 +165,10 @@ var SecondaryToolbar = function SecondaryToolbarClosure() {
|
|
|
toggleHandToolButton.firstElementChild.textContent = _ui_utils.mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
|
|
|
}
|
|
|
});
|
|
|
- },
|
|
|
- open: function SecondaryToolbar_open() {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'open',
|
|
|
+ value: function open() {
|
|
|
if (this.opened) {
|
|
|
return;
|
|
|
}
|
|
@@ -160,23 +176,29 @@ var SecondaryToolbar = function SecondaryToolbarClosure() {
|
|
|
this._setMaxHeight();
|
|
|
this.toggleButton.classList.add('toggled');
|
|
|
this.toolbar.classList.remove('hidden');
|
|
|
- },
|
|
|
- close: function SecondaryToolbar_close() {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'close',
|
|
|
+ value: function close() {
|
|
|
if (!this.opened) {
|
|
|
return;
|
|
|
}
|
|
|
this.opened = false;
|
|
|
this.toolbar.classList.add('hidden');
|
|
|
this.toggleButton.classList.remove('toggled');
|
|
|
- },
|
|
|
- toggle: function SecondaryToolbar_toggle() {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'toggle',
|
|
|
+ value: function toggle() {
|
|
|
if (this.opened) {
|
|
|
this.close();
|
|
|
} else {
|
|
|
this.open();
|
|
|
}
|
|
|
- },
|
|
|
- _setMaxHeight: function SecondaryToolbar_setMaxHeight() {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: '_setMaxHeight',
|
|
|
+ value: function _setMaxHeight() {
|
|
|
if (!this.opened) {
|
|
|
return;
|
|
|
}
|
|
@@ -187,7 +209,14 @@ var SecondaryToolbar = function SecondaryToolbarClosure() {
|
|
|
this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
|
|
|
this.previousContainerHeight = this.containerHeight;
|
|
|
}
|
|
|
- };
|
|
|
+ }, {
|
|
|
+ key: 'isOpen',
|
|
|
+ get: function get() {
|
|
|
+ return this.opened;
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
return SecondaryToolbar;
|
|
|
}();
|
|
|
+
|
|
|
exports.SecondaryToolbar = SecondaryToolbar;
|