@ -19,15 +19,22 @@ Object.defineProperty(exports, "__esModule", {
@@ -19,15 +19,22 @@ Object.defineProperty(exports, "__esModule", {
} ) ;
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' ) ;
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 SCALE _SELECT _CONTAINER _PADDING = 8 ;
var SCALE _SELECT _PADDING = 22 ;
var Toolbar = function ToolbarClosure ( ) {
var Toolbar = function ( ) {
function Toolbar ( options , mainContainer , eventBus ) {
var l10n = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : _ui _utils . NullL10n ;
_classCallCheck ( this , Toolbar ) ;
this . toolbar = options . container ;
this . mainContainer = mainContainer ;
this . eventBus = eventBus ;
@ -37,23 +44,31 @@ var Toolbar = function ToolbarClosure() {
@@ -37,23 +44,31 @@ var Toolbar = function ToolbarClosure() {
this . reset ( ) ;
this . _bindListeners ( ) ;
}
Toolbar . prototype = {
setPageNumber : function setPageNumber ( pageNumber , pageLabel ) {
_createClass ( Toolbar , [ {
key : 'setPageNumber' ,
value : function setPageNumber ( pageNumber , pageLabel ) {
this . pageNumber = pageNumber ;
this . pageLabel = pageLabel ;
this . _updateUIState ( false ) ;
} ,
setPagesCount : function setPagesCount ( pagesCount , hasPageLabels ) {
}
} , {
key : 'setPagesCount' ,
value : function setPagesCount ( pagesCount , hasPageLabels ) {
this . pagesCount = pagesCount ;
this . hasPageLabels = hasPageLabels ;
this . _updateUIState ( true ) ;
} ,
setPageScale : function setPageScale ( pageScaleValue , pageScale ) {
}
} , {
key : 'setPageScale' ,
value : function setPageScale ( pageScaleValue , pageScale ) {
this . pageScaleValue = pageScaleValue ;
this . pageScale = pageScale ;
this . _updateUIState ( false ) ;
} ,
reset : function reset ( ) {
}
} , {
key : 'reset' ,
value : function reset ( ) {
this . pageNumber = 0 ;
this . pageLabel = null ;
this . hasPageLabels = false ;
@ -61,9 +76,10 @@ var Toolbar = function ToolbarClosure() {
@@ -61,9 +76,10 @@ var Toolbar = function ToolbarClosure() {
this . pageScaleValue = _ui _utils . DEFAULT _SCALE _VALUE ;
this . pageScale = _ui _utils . DEFAULT _SCALE ;
this . _updateUIState ( true ) ;
} ,
_bindListeners : function Toolbar _bindClickListeners ( ) {
}
} , {
key : '_bindListeners' ,
value : function _bindListeners ( ) {
var _this = this ;
var eventBus = this . eventBus ;
@ -99,31 +115,37 @@ var Toolbar = function ToolbarClosure() {
@@ -99,31 +115,37 @@ var Toolbar = function ToolbarClosure() {
value : this . value
} ) ;
} ) ;
items . presentationModeButton . addEventListener ( 'click' , function ( e ) {
items . presentationModeButton . addEventListener ( 'click' , function ( ) {
eventBus . dispatch ( 'presentationmode' ) ;
} ) ;
items . openFile . addEventListener ( 'click' , function ( e ) {
items . openFile . addEventListener ( 'click' , function ( ) {
eventBus . dispatch ( 'openfile' ) ;
} ) ;
items . print . addEventListener ( 'click' , function ( e ) {
items . print . addEventListener ( 'click' , function ( ) {
eventBus . dispatch ( 'print' ) ;
} ) ;
items . download . addEventListener ( 'click' , function ( e ) {
items . download . addEventListener ( 'click' , function ( ) {
eventBus . dispatch ( 'download' ) ;
} ) ;
items . scaleSelect . oncontextmenu = _ui _utils . noContextMenuHandler ;
eventBus . on ( 'localized' , function ( evt ) {
eventBus . on ( 'localized' , function ( ) {
_this . _localized ( ) ;
} ) ;
} ,
_localized : function Toolbar _localized ( ) {
}
} , {
key : '_localized' ,
value : function _localized ( ) {
this . _wasLocalized = true ;
this . _adjustScaleWidth ( ) ;
this . _updateUIState ( true ) ;
} ,
_updateUIState : function Toolbar _updateUIState ( resetNumPages ) {
}
} , {
key : '_updateUIState' ,
value : function _updateUIState ( ) {
var _this2 = this ;
var resetNumPages = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : false ;
if ( ! this . _wasLocalized ) {
return ;
}
@ -179,16 +201,22 @@ var Toolbar = function ToolbarClosure() {
@@ -179,16 +201,22 @@ var Toolbar = function ToolbarClosure() {
items . zoomOut . disabled = scale <= _ui _utils . MIN _SCALE ;
items . zoomIn . disabled = scale >= _ui _utils . MAX _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 ;
if ( loading ) {
pageNumberInput . classList . add ( PAGE _NUMBER _LOADING _INDICATOR ) ;
} else {
pageNumberInput . classList . remove ( PAGE _NUMBER _LOADING _INDICATOR ) ;
}
} ,
_adjustScaleWidth : function Toolbar _adjustScaleWidth ( ) {
}
} , {
key : '_adjustScaleWidth' ,
value : function _adjustScaleWidth ( ) {
var container = this . items . scaleSelectContainer ;
var select = this . items . scaleSelect ;
_ui _utils . animationStarted . then ( function ( ) {
@ -203,7 +231,9 @@ var Toolbar = function ToolbarClosure() {
@@ -203,7 +231,9 @@ var Toolbar = function ToolbarClosure() {
}
} ) ;
}
} ;
} ] ) ;
return Toolbar ;
} ( ) ;
exports . Toolbar = Toolbar ;