|
|
@ -19,15 +19,22 @@ Object.defineProperty(exports, "__esModule", { |
|
|
|
}); |
|
|
|
}); |
|
|
|
exports.Toolbar = undefined; |
|
|
|
exports.Toolbar = 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 _ui_utils = require('./ui_utils'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
|
|
|
|
|
|
|
|
|
|
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading'; |
|
|
|
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading'; |
|
|
|
var SCALE_SELECT_CONTAINER_PADDING = 8; |
|
|
|
var SCALE_SELECT_CONTAINER_PADDING = 8; |
|
|
|
var SCALE_SELECT_PADDING = 22; |
|
|
|
var SCALE_SELECT_PADDING = 22; |
|
|
|
var Toolbar = function ToolbarClosure() { |
|
|
|
|
|
|
|
|
|
|
|
var Toolbar = function () { |
|
|
|
function Toolbar(options, mainContainer, eventBus) { |
|
|
|
function Toolbar(options, mainContainer, eventBus) { |
|
|
|
var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n; |
|
|
|
var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_classCallCheck(this, Toolbar); |
|
|
|
|
|
|
|
|
|
|
|
this.toolbar = options.container; |
|
|
|
this.toolbar = options.container; |
|
|
|
this.mainContainer = mainContainer; |
|
|
|
this.mainContainer = mainContainer; |
|
|
|
this.eventBus = eventBus; |
|
|
|
this.eventBus = eventBus; |
|
|
@ -37,23 +44,31 @@ var Toolbar = function ToolbarClosure() { |
|
|
|
this.reset(); |
|
|
|
this.reset(); |
|
|
|
this._bindListeners(); |
|
|
|
this._bindListeners(); |
|
|
|
} |
|
|
|
} |
|
|
|
Toolbar.prototype = { |
|
|
|
|
|
|
|
setPageNumber: function setPageNumber(pageNumber, pageLabel) { |
|
|
|
_createClass(Toolbar, [{ |
|
|
|
|
|
|
|
key: 'setPageNumber', |
|
|
|
|
|
|
|
value: function setPageNumber(pageNumber, pageLabel) { |
|
|
|
this.pageNumber = pageNumber; |
|
|
|
this.pageNumber = pageNumber; |
|
|
|
this.pageLabel = pageLabel; |
|
|
|
this.pageLabel = pageLabel; |
|
|
|
this._updateUIState(false); |
|
|
|
this._updateUIState(false); |
|
|
|
}, |
|
|
|
} |
|
|
|
setPagesCount: function setPagesCount(pagesCount, hasPageLabels) { |
|
|
|
}, { |
|
|
|
|
|
|
|
key: 'setPagesCount', |
|
|
|
|
|
|
|
value: function setPagesCount(pagesCount, hasPageLabels) { |
|
|
|
this.pagesCount = pagesCount; |
|
|
|
this.pagesCount = pagesCount; |
|
|
|
this.hasPageLabels = hasPageLabels; |
|
|
|
this.hasPageLabels = hasPageLabels; |
|
|
|
this._updateUIState(true); |
|
|
|
this._updateUIState(true); |
|
|
|
}, |
|
|
|
} |
|
|
|
setPageScale: function setPageScale(pageScaleValue, pageScale) { |
|
|
|
}, { |
|
|
|
|
|
|
|
key: 'setPageScale', |
|
|
|
|
|
|
|
value: function setPageScale(pageScaleValue, pageScale) { |
|
|
|
this.pageScaleValue = pageScaleValue; |
|
|
|
this.pageScaleValue = pageScaleValue; |
|
|
|
this.pageScale = pageScale; |
|
|
|
this.pageScale = pageScale; |
|
|
|
this._updateUIState(false); |
|
|
|
this._updateUIState(false); |
|
|
|
}, |
|
|
|
} |
|
|
|
reset: function reset() { |
|
|
|
}, { |
|
|
|
|
|
|
|
key: 'reset', |
|
|
|
|
|
|
|
value: function reset() { |
|
|
|
this.pageNumber = 0; |
|
|
|
this.pageNumber = 0; |
|
|
|
this.pageLabel = null; |
|
|
|
this.pageLabel = null; |
|
|
|
this.hasPageLabels = false; |
|
|
|
this.hasPageLabels = false; |
|
|
@ -61,9 +76,10 @@ var Toolbar = function ToolbarClosure() { |
|
|
|
this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE; |
|
|
|
this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE; |
|
|
|
this.pageScale = _ui_utils.DEFAULT_SCALE; |
|
|
|
this.pageScale = _ui_utils.DEFAULT_SCALE; |
|
|
|
this._updateUIState(true); |
|
|
|
this._updateUIState(true); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
}, { |
|
|
|
_bindListeners: function Toolbar_bindClickListeners() { |
|
|
|
key: '_bindListeners', |
|
|
|
|
|
|
|
value: function _bindListeners() { |
|
|
|
var _this = this; |
|
|
|
var _this = this; |
|
|
|
|
|
|
|
|
|
|
|
var eventBus = this.eventBus; |
|
|
|
var eventBus = this.eventBus; |
|
|
@ -99,31 +115,37 @@ var Toolbar = function ToolbarClosure() { |
|
|
|
value: this.value |
|
|
|
value: this.value |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
items.presentationModeButton.addEventListener('click', function (e) { |
|
|
|
items.presentationModeButton.addEventListener('click', function () { |
|
|
|
eventBus.dispatch('presentationmode'); |
|
|
|
eventBus.dispatch('presentationmode'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
items.openFile.addEventListener('click', function (e) { |
|
|
|
items.openFile.addEventListener('click', function () { |
|
|
|
eventBus.dispatch('openfile'); |
|
|
|
eventBus.dispatch('openfile'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
items.print.addEventListener('click', function (e) { |
|
|
|
items.print.addEventListener('click', function () { |
|
|
|
eventBus.dispatch('print'); |
|
|
|
eventBus.dispatch('print'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
items.download.addEventListener('click', function (e) { |
|
|
|
items.download.addEventListener('click', function () { |
|
|
|
eventBus.dispatch('download'); |
|
|
|
eventBus.dispatch('download'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler; |
|
|
|
items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler; |
|
|
|
eventBus.on('localized', function (evt) { |
|
|
|
eventBus.on('localized', function () { |
|
|
|
_this._localized(); |
|
|
|
_this._localized(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
} |
|
|
|
_localized: function Toolbar_localized() { |
|
|
|
}, { |
|
|
|
|
|
|
|
key: '_localized', |
|
|
|
|
|
|
|
value: function _localized() { |
|
|
|
this._wasLocalized = true; |
|
|
|
this._wasLocalized = true; |
|
|
|
this._adjustScaleWidth(); |
|
|
|
this._adjustScaleWidth(); |
|
|
|
this._updateUIState(true); |
|
|
|
this._updateUIState(true); |
|
|
|
}, |
|
|
|
} |
|
|
|
_updateUIState: function Toolbar_updateUIState(resetNumPages) { |
|
|
|
}, { |
|
|
|
|
|
|
|
key: '_updateUIState', |
|
|
|
|
|
|
|
value: function _updateUIState() { |
|
|
|
var _this2 = this; |
|
|
|
var _this2 = this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
|
|
|
|
|
|
|
|
|
|
|
if (!this._wasLocalized) { |
|
|
|
if (!this._wasLocalized) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -179,16 +201,22 @@ var Toolbar = function ToolbarClosure() { |
|
|
|
items.zoomOut.disabled = scale <= _ui_utils.MIN_SCALE; |
|
|
|
items.zoomOut.disabled = scale <= _ui_utils.MIN_SCALE; |
|
|
|
items.zoomIn.disabled = scale >= _ui_utils.MAX_SCALE; |
|
|
|
items.zoomIn.disabled = scale >= _ui_utils.MAX_SCALE; |
|
|
|
selectScaleOption(scaleValue, scale); |
|
|
|
selectScaleOption(scaleValue, scale); |
|
|
|
}, |
|
|
|
} |
|
|
|
updateLoadingIndicatorState: function Toolbar_updateLoadingIndicatorState(loading) { |
|
|
|
}, { |
|
|
|
|
|
|
|
key: 'updateLoadingIndicatorState', |
|
|
|
|
|
|
|
value: function updateLoadingIndicatorState() { |
|
|
|
|
|
|
|
var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
|
|
|
|
|
|
|
|
|
|
|
var pageNumberInput = this.items.pageNumber; |
|
|
|
var pageNumberInput = this.items.pageNumber; |
|
|
|
if (loading) { |
|
|
|
if (loading) { |
|
|
|
pageNumberInput.classList.add(PAGE_NUMBER_LOADING_INDICATOR); |
|
|
|
pageNumberInput.classList.add(PAGE_NUMBER_LOADING_INDICATOR); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR); |
|
|
|
pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
_adjustScaleWidth: function Toolbar_adjustScaleWidth() { |
|
|
|
}, { |
|
|
|
|
|
|
|
key: '_adjustScaleWidth', |
|
|
|
|
|
|
|
value: function _adjustScaleWidth() { |
|
|
|
var container = this.items.scaleSelectContainer; |
|
|
|
var container = this.items.scaleSelectContainer; |
|
|
|
var select = this.items.scaleSelect; |
|
|
|
var select = this.items.scaleSelect; |
|
|
|
_ui_utils.animationStarted.then(function () { |
|
|
|
_ui_utils.animationStarted.then(function () { |
|
|
@ -203,7 +231,9 @@ var Toolbar = function ToolbarClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}]); |
|
|
|
|
|
|
|
|
|
|
|
return Toolbar; |
|
|
|
return Toolbar; |
|
|
|
}(); |
|
|
|
}(); |
|
|
|
|
|
|
|
|
|
|
|
exports.Toolbar = Toolbar; |
|
|
|
exports.Toolbar = Toolbar; |