officeToHtml.js 613 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748
  1. /**
  2. * officeToHtml.js
  3. * Ver. : 1.2.1
  4. * last update: 15/02/2019
  5. * Author: meshesha , https://github.com/meshesha
  6. * LICENSE: MIT
  7. * url:https://officetohtml.js.org/
  8. */
  9. (function ($) {
  10. $.event.special.destroyed = {
  11. remove: function (o) {
  12. if (o.handler) {
  13. o.handler()
  14. }
  15. }
  16. }
  17. $.fn.officeToHtml = function (options) {
  18. var $result = $(this);
  19. var divId = $result.attr("id");
  20. var defaults = {
  21. // These are the defaults.
  22. url: "",
  23. inputObjId: "",
  24. pdfSetting: {
  25. thumbnailViewBtn: true,
  26. searchBtn: true,
  27. nextPreviousBtn: true,
  28. pageNumberTxt: true,
  29. totalPagesLabel: true,
  30. zoomBtns: true,
  31. scaleSelector: true,
  32. presantationModeBtn: true,
  33. openFileBtn: true,
  34. printBtn: true,
  35. downloadBtn: true,
  36. bookmarkBtn: true,
  37. secondaryToolbarBtn: true,
  38. firstPageBtn: true,
  39. lastPageBtn: true,
  40. pageRotateCwBtn: true,
  41. pageRotateCcwBtn: true,
  42. cursorSelectTextToolbarBtn: true,
  43. cursorHandToolbarBtn: true,
  44. setLang: "",
  45. setLangFilesPath: ""
  46. },
  47. docxSetting: {
  48. styleMap: null,
  49. includeEmbeddedStyleMap: true,
  50. includeDefaultStyleMap: true,
  51. convertImage: null,
  52. ignoreEmptyParagraphs: false,
  53. idPrefix: "",
  54. isRtl: "auto"
  55. },
  56. pptxSetting: {
  57. slidesScale: "", //Change Slides scale by percent
  58. slideMode: true /** true,false*/,
  59. keyBoardShortCut: false /** true,false ,condition: slideMode: true*/,
  60. mediaProcess: true /** true,false: if true then process video and audio files */,
  61. jsZipV2: false,
  62. slideModeConfig: {
  63. first: 1,
  64. nav: true /** true,false : show or not nav buttons*/,
  65. navTxtColor: "black" /** color */,
  66. keyBoardShortCut: true /** true,false ,condition: */,
  67. showSlideNum: true /** true,false */,
  68. showTotalSlideNum: true /** true,false */,
  69. autoSlide: 1 /** false or seconds , F8 to active ,keyBoardShortCut: true */,
  70. randomAutoSlide: false /** true,false ,autoSlide: > 1 */,
  71. loop: false /** true,false */,
  72. background: false /** false or color*/,
  73. transition:
  74. "default" /** transition type: "slid","fade","default","random" , to show transition efects :transitionTime > 0.5 */,
  75. transitionTime: 1 /** transition time between slides in seconds */
  76. }
  77. },
  78. sheetSetting: {
  79. jqueryui: false,
  80. activeHeaderClassName: "",
  81. allowEmpty: true,
  82. autoColumnSize: true,
  83. autoRowSize: false,
  84. columns: false,
  85. columnSorting: true,
  86. contextMenu: false,
  87. copyable: true,
  88. customBorders: false,
  89. fixedColumnsLeft: 0,
  90. fixedRowsTop: 0,
  91. language: "en-US",
  92. search: false,
  93. selectionMode: "single",
  94. sortIndicator: false,
  95. readOnly: false,
  96. startRows: 1,
  97. startCols: 1,
  98. rowHeaders: true,
  99. colHeaders: true,
  100. width: false,
  101. height: false
  102. },
  103. imageSetting: {
  104. frame: ["100%", "100%", false],
  105. maxZoom: "900%",
  106. zoomFactor: "10%",
  107. mouse: true,
  108. keyboard: true,
  109. toolbar: true,
  110. rotateToolbar: false
  111. }
  112. };
  113. var settings = $.extend(true, {}, defaults, options);
  114. //1.get file memeType
  115. //2.load all js file needed to read the file
  116. var file = settings.url;
  117. var inputId = settings.inputObjId;
  118. var fileObj = null;
  119. //var pdfScale = settings.pdfScale;
  120. $("#" + divId).addClass("main_officejs_container");
  121. if (file != "") {
  122. fileObj = {
  123. Obj: file,
  124. ext: file.split('.').pop().toLowerCase()
  125. }
  126. getContent(fileObj, divId, settings.pdfSetting, settings.docxSetting, settings.pptxSetting, settings.sheetSetting, settings.imageSetting);
  127. }
  128. if (inputId != "") {
  129. //TODO
  130. $("#" + inputId).on("change", function (e) {
  131. //var inputFileObj = $(this)[0].files[0];
  132. var inputFileObj = e.target.files[0];
  133. if (inputFileObj !== undefined) {
  134. var fName = inputFileObj.name;
  135. fileBlob = URL.createObjectURL(inputFileObj);
  136. fileObj = {
  137. Obj: fileBlob,
  138. ext: fName.split('.').pop().toLowerCase()
  139. }
  140. }
  141. getContent(fileObj, divId, settings.pdfSetting, settings.docxSetting, settings.pptxSetting, settings.sheetSetting, settings.imageSetting);
  142. });
  143. }
  144. }
  145. function getContent(fObj, divId, pdfSet, docxSet, pptxSet, sheetSet, imgSet) {
  146. var ext = fObj.ext;
  147. var file = fObj.file;
  148. switch (ext) {
  149. case "pdf":
  150. //handel pdf file (https://mozilla.github.io/pdf.js/) -- V
  151. getPdfContent(fObj, divId, pdfSet);
  152. break;
  153. case "docx":
  154. //handel docx (https://github.com/mwilliamson/mammoth.js) -- V
  155. getDocxContent(fObj, divId, docxSet);
  156. break;
  157. case "doc":
  158. //handel doc file () -- X
  159. getDocContent(fObj, divId, docxSet);
  160. break;
  161. case "pptx":
  162. //handel pptx file (https://meshesha.github.io/pptxjs/) -- V
  163. getPptxContent(fObj, divId, pptxSet);
  164. break;
  165. case "ppt":
  166. //handel ppt file () -- X
  167. getPptContent(fObj, divId, pptxSet);
  168. break;
  169. case "xlsx":
  170. case "xls":
  171. case "xlw":
  172. case "xlsb":
  173. case "xlsm":
  174. case "csv":
  175. case "dbf":
  176. case "dif":
  177. case "slk":
  178. case "sylk":
  179. case "prn":
  180. case "ods":
  181. case "fods":
  182. //handel sheet file (https://github.com/sheetjs/js-xlsx) -- V
  183. getSheetContent(fObj, divId, sheetSet);
  184. break;
  185. case "gif":
  186. case "jpg":
  187. case "jpeg":
  188. case "bmp":
  189. case "tiff":
  190. case "tif":
  191. case "png":
  192. case "svg":
  193. //handel imge -- V
  194. getImgContent(fObj, divId, imgSet);
  195. break;
  196. default:
  197. unknownMsg(divId);
  198. }
  199. return
  200. }
  201. /////////////////////////////////////////////////PDF//////////////////////////////////////////
  202. function getPdfContent(fObj, divId, pdfSet) {
  203. $("#" + divId).html("");
  204. //console.log(pdfSet)
  205. //bug to fix : add to <html> dir if not exists- TODO
  206. //var htmldir = $("html").attr("dir");
  207. //console.log(htmldir)
  208. var thumbnailViewOpt = (pdfSet.thumbnailViewBtn) ? "" : "hidden",
  209. searchOpt = (pdfSet.searchBtn) ? "" : "hidden",
  210. nextPreviousOpt = (pdfSet.nextPreviousBtn) ? "" : "hidden",
  211. pageNumberOpt = (pdfSet.pageNumberTxt) ? "" : "hidden",
  212. totalPagesOpt = (pdfSet.totalPagesLabel) ? "" : "hidden",
  213. zoomOpt = (pdfSet.zoomBtns) ? "" : "hidden",
  214. scaleSelectOpt = (pdfSet.scaleSelector) ? "" : "hidden",
  215. presentationModeOpt = (pdfSet.presantationModeBtn) ? "" : "hidden",
  216. openFileOpt = (pdfSet.openFileBtn) ? "" : "hidden",
  217. printOpt = (pdfSet.printBtn) ? "" : "hidden",
  218. downloadOpt = (pdfSet.downloadBtn) ? "" : "hidden",
  219. bookmarkOpt = (pdfSet.bookmarkBtn) ? "" : "hidden",
  220. secondaryToolbarOpt = (pdfSet.secondaryToolbarBtn) ? "" : "hidden",
  221. firstPageOpt = (pdfSet.firstPageBtn) ? "" : "hidden",
  222. lastPageOpt = (pdfSet.lastPageBtn) ? "" : "hidden",
  223. pageRotateCwOpt = (pdfSet.pageRotateCwBtn) ? "" : "hidden",
  224. pageRotateCcwOpt = (pdfSet.pageRotateCcwBtn) ? "" : "hidden",
  225. cursorSelectTextOpt = (pdfSet.cursorSelectTextToolbarBtn) ? "" : "hidden",
  226. cursorHandOpt = (pdfSet.cursorHandToolbarBtn) ? "" : "hidden";
  227. setLang = pdfSet.setLang;
  228. setLangFilesPath = pdfSet.setLangFilesPath;
  229. ////////////////////////////////////////////
  230. $("<div></div>", {
  231. class: "loadingInProgress",
  232. id: "mainPdfWarrper"
  233. }).appendTo('div#' + divId);
  234. ////////////////////////////////////////////
  235. $("<div></div>", {
  236. id: "outerContainer"
  237. }).appendTo('div#' + divId + " .loadingInProgress");
  238. $("<div></div>", {
  239. id: "printContainer"
  240. }).appendTo('div#' + divId + " .loadingInProgress");
  241. ///////////////////////////////////////////////////////
  242. $("<div></div>", {
  243. id: "sidebarContainer"
  244. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer");
  245. $("<div></div>", {
  246. id: "mainContainer"
  247. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer");
  248. $("<div></div>", {
  249. id: "overlayContainer",
  250. class: "hidden"
  251. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer");
  252. ///////////////////////////////////////////////////////
  253. $("<div></div>", {
  254. id: "toolbarSidebar"
  255. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer");
  256. $("<div></div>", {
  257. id: "sidebarContent"
  258. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer");
  259. ///////////////////////////////////////////////////////
  260. $("<div></div>", {
  261. class: "splitToolbarButton toggled"
  262. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer #toolbarSidebar");
  263. ///////////////////////////////////////////////////////
  264. $("<button></button>", {
  265. id: "viewThumbnail",
  266. class: "toolbarButton toggled",
  267. title: "Show Thumbnails",
  268. tabindex: "2",
  269. "data-l10n-id": "thumbs"
  270. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer #toolbarSidebar .splitToolbarButton");
  271. $("<span></span>", {
  272. "data-l10n-id": "thumbs_label",
  273. text: "Thumbnails"
  274. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer #toolbarSidebar .splitToolbarButton #viewThumbnail");
  275. $("<button></button>", {
  276. id: "viewOutline",
  277. class: "toolbarButton",
  278. title: "Show Document Outline (double-click to expand/collapse all items)",
  279. tabindex: "3",
  280. "data-l10n-id": "document_outline"
  281. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer #toolbarSidebar .splitToolbarButton");
  282. $("<span></span>", {
  283. "data-l10n-id": "document_outline_label",
  284. text: "Document Outline"
  285. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer #toolbarSidebar .splitToolbarButton #viewOutline");
  286. $("<button></button>", {
  287. id: "viewAttachments",
  288. class: "toolbarButton",
  289. title: "Show Attachments",
  290. tabindex: "4",
  291. "data-l10n-id": "attachments"
  292. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer #toolbarSidebar .splitToolbarButton");
  293. $("<span></span>", {
  294. "data-l10n-id": "attachments_label",
  295. text: "Attachments"
  296. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer #toolbarSidebar .splitToolbarButton #viewAttachments");
  297. ///////////////////////////////////////////////////////////////////////////////////////////
  298. $("<div></div>", {
  299. id: "thumbnailView"
  300. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer #sidebarContent");
  301. $("<div></div>", {
  302. id: "outlineView",
  303. class: "hidden"
  304. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer #sidebarContent");
  305. $("<div></div>", {
  306. id: "attachmentsView",
  307. class: "hidden"
  308. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #sidebarContainer #sidebarContent");
  309. ////////////////////////////////////////////////////////////////////////////////////////////////
  310. $("<div></div>", {
  311. id: "findbar",
  312. class: "findbar hidden doorHanger"
  313. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer");
  314. $("<div></div>", {
  315. id: "findbarInputContainer"
  316. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar");
  317. $("<input></input>", {
  318. id: "findInput",
  319. class: "toolbarField",
  320. title: "Find",
  321. placeholder: "Find in document…",
  322. tabindex: "91",
  323. "data-l10n-id": "find_input"
  324. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarInputContainer");
  325. $("<div></div>", {
  326. class: "splitToolbarButton"
  327. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarInputContainer");
  328. $("<button></button>", {
  329. id: "findPrevious",
  330. class: "toolbarButton findPrevious",
  331. title: "Find the previous occurrence of the phrase",
  332. tabindex: "92",
  333. "data-l10n-id": "find_previous"
  334. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarInputContainer .splitToolbarButton");
  335. $("<span></span>", {
  336. "data-l10n-id": "find_previous_label",
  337. text: "Previous"
  338. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarInputContainer .splitToolbarButton #findPrevious");
  339. $("<div></div>", {
  340. class: "splitToolbarButtonSeparator"
  341. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarInputContainer .splitToolbarButton");
  342. $("<button></button>", {
  343. id: "findNext",
  344. class: "toolbarButton findNext",
  345. title: "Find the next occurrence of the phrase",
  346. tabindex: "93",
  347. "data-l10n-id": "find_next"
  348. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarInputContainer .splitToolbarButton");
  349. $("<span></span>", {
  350. "data-l10n-id": "find_next_label",
  351. text: "Next"
  352. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarInputContainer .splitToolbarButton #findNext");
  353. $("<div></div>", {
  354. id: "findbarOptionsContainer"
  355. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar");
  356. $("<input></input>", {
  357. id: "findHighlightAll",
  358. type: "checkbox",
  359. class: "toolbarField",
  360. tabindex: "94"
  361. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarOptionsContainer");
  362. $("<label></label>", {
  363. for: "findHighlightAll",
  364. class: "toolbarLabel",
  365. "data-l10n-id": "find_highlight",
  366. text: "Highlight all"
  367. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarOptionsContainer");
  368. $("<input></input>", {
  369. id: "findMatchCase",
  370. type: "checkbox",
  371. class: "toolbarField",
  372. tabindex: "95"
  373. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarOptionsContainer");
  374. $("<label></label>", {
  375. for: "findMatchCase",
  376. class: "toolbarLabel",
  377. "data-l10n-id": "find_match_case_label",
  378. text: "Match case"
  379. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarOptionsContainer");
  380. $("<span></span>", {
  381. id: "findResultsCount",
  382. class: "toolbarLabel hidden"
  383. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarOptionsContainer");
  384. $("<div></div>", {
  385. id: "findbarMessageContainer"
  386. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar");
  387. $("<span></span>", {
  388. id: "findMsg",
  389. class: "toolbarLabel"
  390. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #findbar #findbarMessageContainer");
  391. $("<div></div>", {
  392. id: "secondaryToolbar",
  393. class: "secondaryToolbar hidden doorHangerRight"
  394. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer");
  395. $("<div></div>", {
  396. id: "secondaryToolbarButtonContainer"
  397. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar");
  398. $("<button></button>", {
  399. id: "secondaryPresentationMode",
  400. class: "secondaryToolbarButton presentationMode visibleLargeView",
  401. title: "Switch to Presentation Mode",
  402. tabindex: "51",
  403. "data-l10n-id": "presentation_mode"
  404. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  405. $("<span></span>", {
  406. "data-l10n-id": "presentation_mode_label",
  407. text: "Presentation Mode"
  408. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #secondaryPresentationMode");
  409. $("<button></button>", {
  410. id: "secondaryOpenFile",
  411. class: "secondaryToolbarButton openFile visibleLargeView",
  412. title: "Open File",
  413. tabindex: "52",
  414. "data-l10n-id": "open_file"
  415. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  416. $("<span></span>", {
  417. "data-l10n-id": "open_file_label",
  418. text: "Open"
  419. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #secondaryOpenFile");
  420. $("<button></button>", {
  421. id: "secondaryPrint",
  422. class: "secondaryToolbarButton print visibleMediumView",
  423. title: "Print",
  424. tabindex: "53",
  425. "data-l10n-id": "print"
  426. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  427. $("<span></span>", {
  428. "data-l10n-id": "print_label",
  429. text: "Print"
  430. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #secondaryPrint");
  431. $("<button></button>", {
  432. id: "secondaryDownload",
  433. class: "secondaryToolbarButton download visibleMediumView",
  434. title: "Download",
  435. tabindex: "54",
  436. "data-l10n-id": "download"
  437. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  438. $("<span></span>", {
  439. "data-l10n-id": "download_label",
  440. text: "Download"
  441. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #secondaryDownload");
  442. $("<a></a>", {
  443. href: "#",
  444. id: "secondaryViewBookmark",
  445. class: "secondaryToolbarButton bookmark visibleSmallView",
  446. title: "Current view (copy or open in new window)",
  447. tabindex: "55",
  448. "data-l10n-id": "bookmark"
  449. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  450. $("<span></span>", {
  451. "data-l10n-id": "bookmark_label",
  452. text: "Current View"
  453. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #secondaryViewBookmark");
  454. $("<div></div>", {
  455. class: "horizontalToolbarSeparator visibleLargeView"
  456. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  457. $("<button></button>", {
  458. id: "firstPage",
  459. class: "secondaryToolbarButton firstPage " + firstPageOpt,
  460. title: "Go to First Page",
  461. tabindex: "56",
  462. "data-l10n-id": "first_page"
  463. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  464. $("<span></span>", {
  465. "data-l10n-id": "first_page_label",
  466. text: "Go to First Page"
  467. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #firstPage");
  468. $("<button></button>", {
  469. id: "lastPage",
  470. class: "secondaryToolbarButton lastPage " + lastPageOpt,
  471. title: "Go to Last Page",
  472. tabindex: "57",
  473. "data-l10n-id": "last_page"
  474. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  475. $("<span></span>", {
  476. "data-l10n-id": "last_page_label",
  477. text: "Go to Last Page"
  478. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #lastPage");
  479. $("<div></div>", {
  480. class: "horizontalToolbarSeparator"
  481. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  482. $("<button></button>", {
  483. id: "pageRotateCw",
  484. class: "secondaryToolbarButton rotateCw " + pageRotateCwOpt,
  485. title: "Rotate Clockwise",
  486. tabindex: "58",
  487. "data-l10n-id": "page_rotate_cw"
  488. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  489. $("<span></span>", {
  490. "data-l10n-id": "page_rotate_cw_label",
  491. text: "Rotate Clockwise"
  492. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #pageRotateCw");
  493. $("<button></button>", {
  494. id: "pageRotateCcw",
  495. class: "secondaryToolbarButton rotateCcw " + pageRotateCcwOpt,
  496. title: "Rotate Counterclockwise",
  497. tabindex: "59",
  498. "data-l10n-id": "page_rotate_ccw"
  499. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  500. $("<span></span>", {
  501. "data-l10n-id": "page_rotate_ccw_label",
  502. text: "Rotate Counterclockwise"
  503. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #pageRotateCcw");
  504. $("<div></div>", {
  505. class: "horizontalToolbarSeparator"
  506. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  507. $("<button></button>", {
  508. id: "cursorSelectTool",
  509. class: "secondaryToolbarButton selectTool toggled " + cursorSelectTextOpt,
  510. title: "Enable Text Selection Tool",
  511. tabindex: "60",
  512. "data-l10n-id": "cursor_text_select_tool"
  513. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  514. $("<span></span>", {
  515. "data-l10n-id": "cursor_text_select_tool_label",
  516. text: "Text Selection Tool"
  517. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #cursorSelectTool");
  518. $("<button></button>", {
  519. id: "cursorHandTool",
  520. class: "secondaryToolbarButton handTool " + cursorHandOpt,
  521. title: "Enable Hand Tool",
  522. tabindex: "61",
  523. "data-l10n-id": "cursor_hand_tool"
  524. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  525. $("<span></span>", {
  526. "data-l10n-id": "cursor_hand_tool_label",
  527. text: "Hand Tool"
  528. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #cursorHandTool");
  529. $("<div></div>", {
  530. class: "horizontalToolbarSeparator hidden"
  531. }).appendTo("div#" + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  532. $("<button></button>", {
  533. id: "pdfDocumentProperties",
  534. class: "secondaryToolbarButton pdfDocumentProperties hidden",
  535. title: "Document Properties…",
  536. tabindex: "62",
  537. "data-l10n-id": "document_properties"
  538. }).appendTo("div#" + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer");
  539. $("<span></span>", {
  540. "data-l10n-id": "document_properties_label",
  541. text: "Document Properties…"
  542. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #secondaryToolbar #secondaryToolbarButtonContainer #pdfDocumentProperties");
  543. $("<div></div>", {
  544. class: "toolbar"
  545. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer");
  546. $("<div></div>", {
  547. id: "toolbarContainer"
  548. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar");
  549. $("<div></div>", {
  550. id: "toolbarViewer"
  551. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer");
  552. $("<div></div>", {
  553. id: "toolbarViewerLeft"
  554. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer");
  555. $("<button></button>", {
  556. id: "sidebarToggle",
  557. class: "toolbarButton " + thumbnailViewOpt,
  558. title: "Toggle Sidebar",
  559. tabindex: "11",
  560. "data-l10n-id": "toggle_sidebar"
  561. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft");
  562. $("<span></span>", {
  563. "data-l10n-id": "toggle_sidebar_label",
  564. title: "Toggle Sidebar"
  565. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft #sidebarToggle");
  566. $("<div></div>", {
  567. class: "toolbarButtonSpacer",
  568. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft");
  569. $("<button></button>", {
  570. id: "viewFind",
  571. class: "toolbarButton " + searchOpt,
  572. title: "Find in Document",
  573. tabindex: "12",
  574. "data-l10n-id": "findbar"
  575. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft");
  576. $("<span></span>", {
  577. "data-l10n-id": "findbar_label",
  578. title: "Find"
  579. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft #viewFind");
  580. $("<div></div>", {
  581. class: "splitToolbarButton hiddenSmallView " + nextPreviousOpt,
  582. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft");
  583. $("<button></button>", {
  584. class: "toolbarButton pageUp",
  585. title: "Previous Page",
  586. id: "previous",
  587. tabindex: "13",
  588. "data-l10n-id": "previous"
  589. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft .hiddenSmallView");
  590. $("<span></span>", {
  591. "data-l10n-id": "previous_label",
  592. text: "Previous"
  593. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft .hiddenSmallView #previous");
  594. $("<div></div>", {
  595. class: "splitToolbarButtonSeparator"
  596. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft .hiddenSmallView");
  597. $("<button></button>", {
  598. class: "toolbarButton pageDown",
  599. title: "Next Pagee",
  600. id: "next",
  601. tabindex: "14",
  602. "data-l10n-id": "next"
  603. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft .hiddenSmallView");
  604. $("<span></span>", {
  605. "data-l10n-id": "next_label",
  606. text: "Next"
  607. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft .hiddenSmallView #next");
  608. $("<input></input>", {
  609. type: "number",
  610. id: "pageNumber",
  611. class: "toolbarField pageNumber " + pageNumberOpt,
  612. title: "Page",
  613. value: "1",
  614. size: "4",
  615. min: "1",
  616. tabindex: "15",
  617. "data-l10n-id": "page"
  618. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft");
  619. $("<span></span>", {
  620. id: "numPages",
  621. class: "toolbarLabel " + totalPagesOpt
  622. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerLeft");
  623. $("<div></div>", {
  624. id: "toolbarViewerRight"
  625. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer");
  626. $("<button></button>", {
  627. id: "presentationMode",
  628. class: "toolbarButton presentationMode hiddenLargeView " + presentationModeOpt,
  629. title: "Switch to Presentation Mode",
  630. tabindex: "31",
  631. "data-l10n-id": "presentation_mode"
  632. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight");
  633. $("<span></span>", {
  634. "data-l10n-id": "presentation_mode_label",
  635. text: "Presentation Mode"
  636. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight #presentationMode");
  637. $("<button></button>", {
  638. id: "openFile",
  639. class: "toolbarButton openFile hiddenLargeView " + openFileOpt,
  640. title: "Open File",
  641. tabindex: "32",
  642. "data-l10n-id": "open_file"
  643. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight");
  644. $("<span></span>", {
  645. "data-l10n-id": "open_file_label",
  646. text: "Open"
  647. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight #openFile");
  648. $("<button></button>", {
  649. id: "print",
  650. class: "toolbarButton print hiddenMediumView " + printOpt,
  651. title: "Print",
  652. tabindex: "33",
  653. "data-l10n-id": "print"
  654. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight");
  655. $("<span></span>", {
  656. "data-l10n-id": "print_label",
  657. text: "Print"
  658. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight #print");
  659. $("<button></button>", {
  660. id: "download",
  661. class: "toolbarButton download hiddenMediumView " + downloadOpt,
  662. title: "Download",
  663. tabindex: "34",
  664. "data-l10n-id": "download"
  665. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight");
  666. $("<span></span>", {
  667. "data-l10n-id": "download_label",
  668. text: "Download"
  669. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight #download");
  670. $("<a></a>", {
  671. href: "#",
  672. id: "viewBookmark",
  673. class: "toolbarButton bookmark hiddenSmallView " + bookmarkOpt,
  674. title: "Current view (copy or open in new window)",
  675. tabindex: "35",
  676. "data-l10n-id": "bookmark",
  677. target: "_blank"
  678. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight");
  679. $("<span></span>", {
  680. "data-l10n-id": "bookmark_label",
  681. text: "Current View"
  682. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight #viewBookmark");
  683. $("<div></div>", {
  684. class: "verticalToolbarSeparator hiddenSmallView"
  685. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight");
  686. $("<button></button>", {
  687. id: "secondaryToolbarToggle",
  688. class: "toolbarButton " + secondaryToolbarOpt,
  689. title: "Tools",
  690. tabindex: "35",
  691. "data-l10n-id": "tools"
  692. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight");
  693. $("<span></span>", {
  694. "data-l10n-id": "tools_label",
  695. text: "Tools"
  696. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerRight #secondaryToolbarToggle");
  697. $("<div></div>", {
  698. id: "toolbarViewerMiddle"
  699. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer");
  700. $("<div></div>", {
  701. class: "splitToolbarButton " + zoomOpt
  702. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle");
  703. $("<button></button>", {
  704. id: "zoomOut",
  705. class: "toolbarButton zoomOut",
  706. title: "Zoom Out",
  707. tabindex: "21",
  708. "data-l10n-id": "zoom_out"
  709. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle .splitToolbarButton");
  710. $("<span></span>", {
  711. "data-l10n-id": "zoom_out_label",
  712. text: "Zoom Out"
  713. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle .splitToolbarButton #zoomOut");
  714. $("<div></div>", {
  715. class: "splitToolbarButtonSeparator"
  716. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle .splitToolbarButton");
  717. $("<button></button>", {
  718. id: "zoomIn",
  719. class: "toolbarButton zoomIn",
  720. title: "Zoom In",
  721. tabindex: "22",
  722. "data-l10n-id": "zoom_in"
  723. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle .splitToolbarButton");
  724. $("<span></span>", {
  725. "data-l10n-id": "zoom_in_label",
  726. text: "Zoom In"
  727. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle .splitToolbarButton #zoomIn");
  728. $("<span></span>", {
  729. id: "scaleSelectContainer",
  730. class: "dropdownToolbarButton"
  731. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle");
  732. $("<select></select>", {
  733. id: "scaleSelect",
  734. title: "Zoom",
  735. tabindex: "23",
  736. "data-l10n-id": "zoom",
  737. class: scaleSelectOpt
  738. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer");
  739. $("<option></option>", {
  740. id: "pageAutoOption",
  741. title: "",
  742. value: "auto",
  743. selected: "selected",
  744. "data-l10n-id": "page_scale_auto",
  745. text: "Automatic Zoom"
  746. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  747. $("<option></option>", {
  748. id: "pageActualOption",
  749. title: "",
  750. value: "page-actual",
  751. "data-l10n-id": "page_scale_actual",
  752. text: "Actual Size"
  753. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  754. $("<option></option>", {
  755. id: "pageFitOption",
  756. title: "",
  757. value: "page-fit",
  758. "data-l10n-id": "page_scale_fit",
  759. text: "Page Fit"
  760. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  761. $("<option></option>", {
  762. id: "pageWidthOption",
  763. title: "",
  764. value: "page-width",
  765. "data-l10n-id": "page_scale_width",
  766. text: "Page Width"
  767. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  768. $("<option></option>", {
  769. id: "customScaleOption",
  770. title: "",
  771. value: "custom",
  772. disabled: "disabled",
  773. hidden: "true"
  774. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  775. $("<option></option>", {
  776. title: "",
  777. value: "0.5",
  778. "data-l10n-id": "page_scale_percent",
  779. "data-l10n-args": '{ "scale": 50 }',
  780. text: "50%"
  781. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  782. $("<option></option>", {
  783. title: "",
  784. value: "0.75",
  785. "data-l10n-id": "page_scale_percent",
  786. "data-l10n-args": '{ "scale": 75 }',
  787. text: "75%"
  788. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  789. $("<option></option>", {
  790. title: "",
  791. value: "1",
  792. "data-l10n-id": "page_scale_percent",
  793. "data-l10n-args": '{ "scale": 100 }',
  794. text: "100%"
  795. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  796. $("<option></option>", {
  797. title: "",
  798. value: "1.25",
  799. "data-l10n-id": "page_scale_percent",
  800. "data-l10n-args": '{ "scale": 125 }',
  801. text: "125%"
  802. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  803. $("<option></option>", {
  804. title: "",
  805. value: "1.5",
  806. "data-l10n-id": "page_scale_percent",
  807. "data-l10n-args": '{ "scale": 150 }',
  808. text: "150%"
  809. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  810. $("<option></option>", {
  811. title: "",
  812. value: "2",
  813. "data-l10n-id": "page_scale_percent",
  814. "data-l10n-args": '{ "scale": 200 }',
  815. text: "200%"
  816. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  817. $("<option></option>", {
  818. title: "",
  819. value: "3",
  820. "data-l10n-id": "page_scale_percent",
  821. "data-l10n-args": '{ "scale": 300 }',
  822. text: "300%"
  823. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  824. $("<option></option>", {
  825. title: "",
  826. value: "4",
  827. "data-l10n-id": "page_scale_percent",
  828. "data-l10n-args": '{ "scale": 400 }',
  829. text: "400%"
  830. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #toolbarViewer #toolbarViewerMiddle #scaleSelectContainer #scaleSelect");
  831. $("<div></div>", {
  832. id: "loadingBar"
  833. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer");
  834. $("<div></div>", {
  835. class: "progress"
  836. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #loadingBar");
  837. $("<div></div>", {
  838. class: "glimmer"
  839. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer .toolbar #toolbarContainer #loadingBar .progress");
  840. $("<menu></menu>", {
  841. id: "viewerContextMenu",
  842. type: "context"
  843. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer");
  844. $("<menuitem></menuitem>", {
  845. id: "contextFirstPage",
  846. label: "First Page",
  847. "data-l10n-id": "first_page"
  848. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #viewerContextMenu");
  849. $("<menuitem></menuitem>", {
  850. id: "contextLastPage",
  851. label: "Last Page",
  852. "data-l10n-id": "last_page"
  853. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #viewerContextMenu");
  854. $("<menuitem></menuitem>", {
  855. id: "contextPageRotateCw",
  856. label: "Rotate Clockwise",
  857. "data-l10n-id": "page_rotate_cw"
  858. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #viewerContextMenu");
  859. $("<menuitem></menuitem>", {
  860. id: "contextPageRotateCcw",
  861. label: "Rotate Counter-Clockwise",
  862. "data-l10n-id": "page_rotate_ccw"
  863. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #viewerContextMenu");
  864. $("<div></div>", {
  865. id: "viewerContainer",
  866. tabindex: "0"
  867. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer");
  868. $("<div></div>", {
  869. id: "viewer",
  870. class: "pdfViewer"
  871. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #viewerContainer");
  872. $("<div></div>", {
  873. id: "errorWrapper",
  874. hidden: "true"
  875. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer");
  876. $("<div></div>", {
  877. id: "errorMessageLeft"
  878. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #errorWrapper");
  879. $("<span></span>", {
  880. id: "errorMessage"
  881. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #errorWrapper #errorMessageLeft");
  882. $("<button></button>", {
  883. id: "errorShowMore",
  884. "data-l10n-id": "error_more_info",
  885. text: "More Information"
  886. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #errorWrapper #errorMessageLeft");
  887. $("<button></button>", {
  888. id: "errorShowLess",
  889. "data-l10n-id": "error_less_info",
  890. text: "Less Information",
  891. hidden: "true"
  892. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #errorWrapper #errorMessageLeft");
  893. $("<div></div>", {
  894. id: "errorMessageRight"
  895. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #errorWrapper");
  896. $("<button></button>", {
  897. id: "errorClose",
  898. "data-l10n-id": "error_close",
  899. text: "Close"
  900. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #errorWrapper #errorMessageRight");
  901. $("<div></div>", {
  902. class: "clearBoth"
  903. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #errorWrapper");
  904. $("<textarea></textarea>", {
  905. id: "errorMoreInfo",
  906. hidden: 'true',
  907. readonly: "readonly"
  908. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #mainContainer #errorWrapper");
  909. $("<div></div>", {
  910. id: "passwordOverlay",
  911. class: "container hidden"
  912. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer");
  913. $("<div></div>", {
  914. class: "dialog"
  915. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #passwordOverlay");
  916. $("<div></div>", {
  917. class: "row",
  918. id: "firstRow"
  919. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #passwordOverlay .dialog");
  920. $("<p></p>", {
  921. id: "passwordText",
  922. "data-l10n-id": "password_label",
  923. text: "Enter the password to open this PDF file:"
  924. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #passwordOverlay .dialog #firstRow");
  925. $("<div></div>", {
  926. class: "row",
  927. id: "midleRow"
  928. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #passwordOverlay .dialog");
  929. $("<input/>", {
  930. type: "password",
  931. id: "password",
  932. class: "toolbarField"
  933. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #passwordOverlay .dialog #midleRow");
  934. $("<div></div>", {
  935. class: "buttonRow"
  936. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #passwordOverlay .dialog");
  937. $("<button></button>", {
  938. id: "passwordCancel",
  939. class: "overlayButton"
  940. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #passwordOverlay .dialog .buttonRow");
  941. $("<span></span>", {
  942. "data-l10n-id": "password_cancel",
  943. text: "Cancel"
  944. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #passwordOverlay .dialog .buttonRow #passwordCancel");
  945. $("<button></button>", {
  946. id: "passwordSubmit",
  947. class: "overlayButton"
  948. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #passwordOverlay .dialog .buttonRow");
  949. $("<span></span>", {
  950. "data-l10n-id": "password_ok",
  951. text: "OK"
  952. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #passwordOverlay .dialog .buttonRow #passwordSubmit");
  953. $("<div></div>", {
  954. id: "documentPropertiesOverlay",
  955. class: "container hidden"
  956. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer");
  957. $("<div></div>", {
  958. id: "printServiceOverlay",
  959. class: "container hidden"
  960. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer");
  961. $("<div></div>", {
  962. class: "dialog"
  963. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #printServiceOverlay");
  964. $("<div></div>", {
  965. class: "row",
  966. id: "printFirsRwo"
  967. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #printServiceOverlay .dialog");
  968. $("<span></span>", {
  969. "data-l10n-id": "print_progress_message",
  970. text: "Preparing document for printing…"
  971. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #printServiceOverlay .dialog #printFirsRwo");
  972. $("<div></div>", {
  973. class: "row",
  974. id: "printSecondRwo"
  975. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #printServiceOverlay .dialog");
  976. $("<progress></progress>", {
  977. value: "0",
  978. max: "100"
  979. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #printServiceOverlay .dialog #printSecondRwo");
  980. $("<span></span>", {
  981. "data-l10n-id": "print_progress_percent",
  982. "data-l10n-args": '{ "progress": 0 }',
  983. class: "relative-progress",
  984. text: "0%"
  985. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #printServiceOverlay .dialog #printSecondRwo");
  986. $("<div></div>", {
  987. class: "buttonRow",
  988. id: "printThirdRwo"
  989. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #printServiceOverlay .dialog");
  990. $("<button></button>", {
  991. class: "overlayButton",
  992. id: "printCancel"
  993. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #printServiceOverlay .dialog #printThirdRwo");
  994. $("<span></span>", {
  995. "data-l10n-id": "print_progress_close",
  996. text: "Cancel"
  997. }).appendTo('div#' + divId + " .loadingInProgress #outerContainer #overlayContainer #printServiceOverlay .dialog #printThirdRwo");
  998. var my_pdf_file = fObj.Obj;
  999. var currentScriptPath = function () {
  1000. var dir = document.querySelector('script[src$="pdf.js"]').getAttribute('src');
  1001. var name = dir.split('/').pop();
  1002. return dir.replace('/' + name, "");
  1003. };
  1004. function diff2(a, b) {
  1005. var i, la = a.length, lb = b.length, res = [];
  1006. if (!la) return b;
  1007. else if (!lb) return a;
  1008. for (i = 0; i < la; i++) {
  1009. if (b.indexOf(a[i]) === -1) res.push(a[i]);
  1010. }
  1011. for (i = 0; i < lb; i++) {
  1012. if (a.indexOf(b[i]) === -1) res.push(b[i]);
  1013. }
  1014. return res;
  1015. }
  1016. var full_path = location.href;
  1017. var pdfScriptPath = currentScriptPath();
  1018. if (pdfScriptPath.indexOf(full_path) > -1) {
  1019. var link_a_array = pdfScriptPath.split("/");
  1020. var link_b_array = full_path.split("/");
  1021. var link_diff = diff2(link_a_array, link_b_array).join("/");
  1022. pdfScriptPath = link_diff;
  1023. /*
  1024. console.log(
  1025. "\nscript path: ", currentScriptPath(),
  1026. "\nfull path:", full_path,
  1027. "\nlink_diff: ", link_diff,
  1028. "\nsetLangFilesPath: ", setLangFilesPath
  1029. );
  1030. */
  1031. }
  1032. setLangFilesPath = (setLangFilesPath != "") ? full_path + setLangFilesPath + "/locale.properties" : "";
  1033. $("<link>", {
  1034. rel: "resource",
  1035. type: "application/l10n",
  1036. href: (setLangFilesPath != "") ? setLangFilesPath : pdfScriptPath + "/locale/locale.properties"
  1037. }).appendTo("#" + divId);
  1038. $("#mainPdfWarrper").bind('destroyed', function () {
  1039. //if exit from pdf viewer mode
  1040. //return orginal Warrper dir
  1041. var orgnlHtmldir = sessionStorage.getItem("o2h_orginal_html_dir");
  1042. if (orgnlHtmldir !== undefined) {
  1043. $("#mainPdfWarrper").attr("dir", orgnlHtmldir);
  1044. }
  1045. });
  1046. /* Copyright 2017 Mozilla Foundation
  1047. *
  1048. * Licensed under the Apache License, Version 2.0 (the "License");
  1049. * you may not use this file except in compliance with the License.
  1050. * You may obtain a copy of the License at
  1051. *
  1052. * http://www.apache.org/licenses/LICENSE-2.0
  1053. *
  1054. * Unless required by applicable law or agreed to in writing, software
  1055. * distributed under the License is distributed on an "AS IS" BASIS,
  1056. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1057. * See the License for the specific language governing permissions and
  1058. * limitations under the License.
  1059. */
  1060. /******/ (function (modules) { // webpackBootstrap
  1061. /******/ // The module cache
  1062. /******/ var installedModules = {};
  1063. /******/
  1064. /******/ // The require function
  1065. /******/ function __webpack_require__(moduleId) {
  1066. /******/
  1067. /******/ // Check if module is in cache
  1068. /******/ if (installedModules[moduleId]) {
  1069. /******/ return installedModules[moduleId].exports;
  1070. /******/
  1071. }
  1072. /******/ // Create a new module (and put it into the cache)
  1073. /******/ var module = installedModules[moduleId] = {
  1074. /******/ i: moduleId,
  1075. /******/ l: false,
  1076. /******/ exports: {}
  1077. /******/
  1078. };
  1079. /******/
  1080. /******/ // Execute the module function
  1081. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  1082. /******/
  1083. /******/ // Flag the module as loaded
  1084. /******/ module.l = true;
  1085. /******/
  1086. /******/ // Return the exports of the module
  1087. /******/ return module.exports;
  1088. /******/
  1089. }
  1090. /******/
  1091. /******/
  1092. /******/ // expose the modules object (__webpack_modules__)
  1093. /******/ __webpack_require__.m = modules;
  1094. /******/
  1095. /******/ // expose the module cache
  1096. /******/ __webpack_require__.c = installedModules;
  1097. /******/
  1098. /******/ // identity function for calling harmony imports with the correct context
  1099. /******/ __webpack_require__.i = function (value) { return value; };
  1100. /******/
  1101. /******/ // define getter function for harmony exports
  1102. /******/ __webpack_require__.d = function (exports, name, getter) {
  1103. /******/ if (!__webpack_require__.o(exports, name)) {
  1104. /******/ Object.defineProperty(exports, name, {
  1105. /******/ configurable: false,
  1106. /******/ enumerable: true,
  1107. /******/ get: getter
  1108. /******/
  1109. });
  1110. /******/
  1111. }
  1112. /******/
  1113. };
  1114. /******/
  1115. /******/ // getDefaultExport function for compatibility with non-harmony modules
  1116. /******/ __webpack_require__.n = function (module) {
  1117. /******/ var getter = module && module.__esModule ?
  1118. /******/ function getDefault() { return module['default']; } :
  1119. /******/ function getModuleExports() { return module; };
  1120. /******/ __webpack_require__.d(getter, 'a', getter);
  1121. /******/ return getter;
  1122. /******/
  1123. };
  1124. /******/
  1125. /******/ // Object.prototype.hasOwnProperty.call
  1126. /******/ __webpack_require__.o = function (object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  1127. /******/
  1128. /******/ // __webpack_public_path__
  1129. /******/ __webpack_require__.p = "";
  1130. /******/
  1131. /******/ // Load entry module and return exports
  1132. /******/ return __webpack_require__(__webpack_require__.s = 33);
  1133. /******/
  1134. })
  1135. /************************************************************************/
  1136. /******/([
  1137. /* 0 */
  1138. /***/ (function (module, exports, __webpack_require__) {
  1139. "use strict";
  1140. Object.defineProperty(exports, "__esModule", {
  1141. value: true
  1142. });
  1143. exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
  1144. 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; }; }();
  1145. var _pdfjsLib = __webpack_require__(1);
  1146. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1147. var CSS_UNITS = 96.0 / 72.0;
  1148. var DEFAULT_SCALE_VALUE = 'auto';
  1149. var DEFAULT_SCALE = 1.0;
  1150. var MIN_SCALE = 0.25;
  1151. var MAX_SCALE = 10.0;
  1152. var UNKNOWN_SCALE = 0;
  1153. var MAX_AUTO_SCALE = 1.25;
  1154. var SCROLLBAR_PADDING = 40;
  1155. var VERTICAL_PADDING = 5;
  1156. var RendererType = {
  1157. CANVAS: 'canvas',
  1158. SVG: 'svg'
  1159. };
  1160. function formatL10nValue(text, args) {
  1161. if (!args) {
  1162. return text;
  1163. }
  1164. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  1165. return name in args ? args[name] : '{{' + name + '}}';
  1166. });
  1167. }
  1168. var NullL10n = {
  1169. get: function get(property, args, fallback) {
  1170. return Promise.resolve(formatL10nValue(fallback, args));
  1171. },
  1172. translate: function translate(element) {
  1173. return Promise.resolve();
  1174. }
  1175. };
  1176. _pdfjsLib.PDFJS.disableFullscreen = _pdfjsLib.PDFJS.disableFullscreen === undefined ? false : _pdfjsLib.PDFJS.disableFullscreen;
  1177. _pdfjsLib.PDFJS.useOnlyCssZoom = _pdfjsLib.PDFJS.useOnlyCssZoom === undefined ? false : _pdfjsLib.PDFJS.useOnlyCssZoom;
  1178. _pdfjsLib.PDFJS.maxCanvasPixels = _pdfjsLib.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjsLib.PDFJS.maxCanvasPixels;
  1179. _pdfjsLib.PDFJS.disableHistory = _pdfjsLib.PDFJS.disableHistory === undefined ? false : _pdfjsLib.PDFJS.disableHistory;
  1180. _pdfjsLib.PDFJS.disableTextLayer = _pdfjsLib.PDFJS.disableTextLayer === undefined ? false : _pdfjsLib.PDFJS.disableTextLayer;
  1181. _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom = _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom === undefined ? false : _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom;
  1182. {
  1183. //_pdfjsLib.PDFJS.locale = _pdfjsLib.PDFJS.locale === undefined && typeof navigator !== 'undefined' ? navigator.language : _pdfjsLib.PDFJS.locale;
  1184. if (_pdfjsLib.PDFJS.locale === undefined && typeof navigator !== 'undefined') {
  1185. if (setLang != "") {
  1186. _pdfjsLib.PDFJS.locale = setLang;
  1187. } else {
  1188. _pdfjsLib.PDFJS.locale = navigator.language; //set lang here - TODO
  1189. }
  1190. //console.log("_pdfjsLib.PDFJS.locale (lang)= " + _pdfjsLib.PDFJS.locale);
  1191. }
  1192. }
  1193. function getOutputScale(ctx) {
  1194. var devicePixelRatio = window.devicePixelRatio || 1;
  1195. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  1196. var pixelRatio = devicePixelRatio / backingStoreRatio;
  1197. return {
  1198. sx: pixelRatio,
  1199. sy: pixelRatio,
  1200. scaled: pixelRatio !== 1
  1201. };
  1202. }
  1203. function scrollIntoView(element, spot) {
  1204. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  1205. var parent = element.offsetParent;
  1206. if (!parent) {
  1207. console.error('offsetParent is not set -- cannot scroll');
  1208. return;
  1209. }
  1210. var offsetY = element.offsetTop + element.clientTop;
  1211. var offsetX = element.offsetLeft + element.clientLeft;
  1212. while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  1213. if (parent.dataset._scaleY) {
  1214. offsetY /= parent.dataset._scaleY;
  1215. offsetX /= parent.dataset._scaleX;
  1216. }
  1217. offsetY += parent.offsetTop;
  1218. offsetX += parent.offsetLeft;
  1219. parent = parent.offsetParent;
  1220. if (!parent) {
  1221. return;
  1222. }
  1223. }
  1224. if (spot) {
  1225. if (spot.top !== undefined) {
  1226. offsetY += spot.top;
  1227. }
  1228. if (spot.left !== undefined) {
  1229. offsetX += spot.left;
  1230. parent.scrollLeft = offsetX;
  1231. }
  1232. }
  1233. parent.scrollTop = offsetY;
  1234. }
  1235. function watchScroll(viewAreaElement, callback) {
  1236. var debounceScroll = function debounceScroll(evt) {
  1237. if (rAF) {
  1238. return;
  1239. }
  1240. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  1241. rAF = null;
  1242. var currentY = viewAreaElement.scrollTop;
  1243. var lastY = state.lastY;
  1244. if (currentY !== lastY) {
  1245. state.down = currentY > lastY;
  1246. }
  1247. state.lastY = currentY;
  1248. callback(state);
  1249. });
  1250. };
  1251. var state = {
  1252. down: true,
  1253. lastY: viewAreaElement.scrollTop,
  1254. _eventHandler: debounceScroll
  1255. };
  1256. var rAF = null;
  1257. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  1258. return state;
  1259. }
  1260. function parseQueryString(query) {
  1261. var parts = query.split('&');
  1262. var params = Object.create(null);
  1263. for (var i = 0, ii = parts.length; i < ii; ++i) {
  1264. var param = parts[i].split('=');
  1265. var key = param[0].toLowerCase();
  1266. var value = param.length > 1 ? param[1] : null;
  1267. params[decodeURIComponent(key)] = decodeURIComponent(value);
  1268. }
  1269. return params;
  1270. }
  1271. function binarySearchFirstItem(items, condition) {
  1272. var minIndex = 0;
  1273. var maxIndex = items.length - 1;
  1274. if (items.length === 0 || !condition(items[maxIndex])) {
  1275. return items.length;
  1276. }
  1277. if (condition(items[minIndex])) {
  1278. return minIndex;
  1279. }
  1280. while (minIndex < maxIndex) {
  1281. var currentIndex = minIndex + maxIndex >> 1;
  1282. var currentItem = items[currentIndex];
  1283. if (condition(currentItem)) {
  1284. maxIndex = currentIndex;
  1285. } else {
  1286. minIndex = currentIndex + 1;
  1287. }
  1288. }
  1289. return minIndex;
  1290. }
  1291. function approximateFraction(x) {
  1292. if (Math.floor(x) === x) {
  1293. return [x, 1];
  1294. }
  1295. var xinv = 1 / x;
  1296. var limit = 8;
  1297. if (xinv > limit) {
  1298. return [1, limit];
  1299. } else if (Math.floor(xinv) === xinv) {
  1300. return [1, xinv];
  1301. }
  1302. var x_ = x > 1 ? xinv : x;
  1303. var a = 0,
  1304. b = 1,
  1305. c = 1,
  1306. d = 1;
  1307. while (true) {
  1308. var p = a + c,
  1309. q = b + d;
  1310. if (q > limit) {
  1311. break;
  1312. }
  1313. if (x_ <= p / q) {
  1314. c = p;
  1315. d = q;
  1316. } else {
  1317. a = p;
  1318. b = q;
  1319. }
  1320. }
  1321. var result = void 0;
  1322. if (x_ - a / b < c / d - x_) {
  1323. result = x_ === x ? [a, b] : [b, a];
  1324. } else {
  1325. result = x_ === x ? [c, d] : [d, c];
  1326. }
  1327. return result;
  1328. }
  1329. function roundToDivide(x, div) {
  1330. var r = x % div;
  1331. return r === 0 ? x : Math.round(x - r + div);
  1332. }
  1333. function getVisibleElements(scrollEl, views) {
  1334. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  1335. var top = scrollEl.scrollTop,
  1336. bottom = top + scrollEl.clientHeight;
  1337. var left = scrollEl.scrollLeft,
  1338. right = left + scrollEl.clientWidth;
  1339. function isElementBottomBelowViewTop(view) {
  1340. var element = view.div;
  1341. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  1342. return elementBottom > top;
  1343. }
  1344. var visible = [],
  1345. view = void 0,
  1346. element = void 0;
  1347. var currentHeight = void 0,
  1348. viewHeight = void 0,
  1349. hiddenHeight = void 0,
  1350. percentHeight = void 0;
  1351. var currentWidth = void 0,
  1352. viewWidth = void 0;
  1353. var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
  1354. for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {
  1355. view = views[i];
  1356. element = view.div;
  1357. currentHeight = element.offsetTop + element.clientTop;
  1358. viewHeight = element.clientHeight;
  1359. if (currentHeight > bottom) {
  1360. break;
  1361. }
  1362. currentWidth = element.offsetLeft + element.clientLeft;
  1363. viewWidth = element.clientWidth;
  1364. if (currentWidth + viewWidth < left || currentWidth > right) {
  1365. continue;
  1366. }
  1367. hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);
  1368. percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;
  1369. visible.push({
  1370. id: view.id,
  1371. x: currentWidth,
  1372. y: currentHeight,
  1373. view: view,
  1374. percent: percentHeight
  1375. });
  1376. }
  1377. var first = visible[0];
  1378. var last = visible[visible.length - 1];
  1379. if (sortByVisibility) {
  1380. visible.sort(function (a, b) {
  1381. var pc = a.percent - b.percent;
  1382. if (Math.abs(pc) > 0.001) {
  1383. return -pc;
  1384. }
  1385. return a.id - b.id;
  1386. });
  1387. }
  1388. return {
  1389. first: first,
  1390. last: last,
  1391. views: visible
  1392. };
  1393. }
  1394. function noContextMenuHandler(evt) {
  1395. evt.preventDefault();
  1396. }
  1397. function isDataSchema(url) {
  1398. var i = 0,
  1399. ii = url.length;
  1400. while (i < ii && url[i].trim() === '') {
  1401. i++;
  1402. }
  1403. return url.substr(i, 5).toLowerCase() === 'data:';
  1404. }
  1405. function getPDFFileNameFromURL(url) {
  1406. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  1407. if (isDataSchema(url)) {
  1408. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  1409. return defaultFilename;
  1410. }
  1411. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  1412. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  1413. var splitURI = reURI.exec(url);
  1414. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  1415. if (suggestedFilename) {
  1416. suggestedFilename = suggestedFilename[0];
  1417. if (suggestedFilename.indexOf('%') !== -1) {
  1418. try {
  1419. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  1420. } catch (ex) { }
  1421. }
  1422. }
  1423. return suggestedFilename || defaultFilename;
  1424. }
  1425. function normalizeWheelEventDelta(evt) {
  1426. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  1427. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  1428. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  1429. delta = -delta;
  1430. }
  1431. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  1432. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  1433. var MOUSE_PIXELS_PER_LINE = 30;
  1434. var MOUSE_LINES_PER_PAGE = 30;
  1435. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  1436. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  1437. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  1438. delta /= MOUSE_LINES_PER_PAGE;
  1439. }
  1440. return delta;
  1441. }
  1442. function cloneObj(obj) {
  1443. var result = Object.create(null);
  1444. for (var i in obj) {
  1445. if (Object.prototype.hasOwnProperty.call(obj, i)) {
  1446. result[i] = obj[i];
  1447. }
  1448. }
  1449. return result;
  1450. }
  1451. var animationStarted = new Promise(function (resolve) {
  1452. window.requestAnimationFrame(resolve);
  1453. });
  1454. var mozL10n = void 0;
  1455. var localized = Promise.resolve();
  1456. var EventBus = function () {
  1457. function EventBus() {
  1458. _classCallCheck(this, EventBus);
  1459. this._listeners = Object.create(null);
  1460. }
  1461. _createClass(EventBus, [{
  1462. key: 'on',
  1463. value: function on(eventName, listener) {
  1464. var eventListeners = this._listeners[eventName];
  1465. if (!eventListeners) {
  1466. eventListeners = [];
  1467. this._listeners[eventName] = eventListeners;
  1468. }
  1469. eventListeners.push(listener);
  1470. }
  1471. }, {
  1472. key: 'off',
  1473. value: function off(eventName, listener) {
  1474. var eventListeners = this._listeners[eventName];
  1475. var i = void 0;
  1476. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  1477. return;
  1478. }
  1479. eventListeners.splice(i, 1);
  1480. }
  1481. }, {
  1482. key: 'dispatch',
  1483. value: function dispatch(eventName) {
  1484. var eventListeners = this._listeners[eventName];
  1485. if (!eventListeners || eventListeners.length === 0) {
  1486. return;
  1487. }
  1488. var args = Array.prototype.slice.call(arguments, 1);
  1489. eventListeners.slice(0).forEach(function (listener) {
  1490. listener.apply(null, args);
  1491. });
  1492. }
  1493. }]);
  1494. return EventBus;
  1495. }();
  1496. function clamp(v, min, max) {
  1497. return Math.min(Math.max(v, min), max);
  1498. }
  1499. var ProgressBar = function () {
  1500. function ProgressBar(id) {
  1501. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1502. height = _ref.height,
  1503. width = _ref.width,
  1504. units = _ref.units;
  1505. _classCallCheck(this, ProgressBar);
  1506. this.visible = true;
  1507. this.div = document.querySelector(id + ' .progress');
  1508. this.bar = this.div.parentNode;
  1509. this.height = height || 100;
  1510. this.width = width || 100;
  1511. this.units = units || '%';
  1512. this.div.style.height = this.height + this.units;
  1513. this.percent = 0;
  1514. }
  1515. _createClass(ProgressBar, [{
  1516. key: '_updateBar',
  1517. value: function _updateBar() {
  1518. if (this._indeterminate) {
  1519. this.div.classList.add('indeterminate');
  1520. this.div.style.width = this.width + this.units;
  1521. return;
  1522. }
  1523. this.div.classList.remove('indeterminate');
  1524. var progressSize = this.width * this._percent / 100;
  1525. this.div.style.width = progressSize + this.units;
  1526. }
  1527. }, {
  1528. key: 'setWidth',
  1529. value: function setWidth(viewer) {
  1530. if (!viewer) {
  1531. return;
  1532. }
  1533. var container = viewer.parentNode;
  1534. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  1535. if (scrollbarWidth > 0) {
  1536. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  1537. }
  1538. }
  1539. }, {
  1540. key: 'hide',
  1541. value: function hide() {
  1542. if (!this.visible) {
  1543. return;
  1544. }
  1545. this.visible = false;
  1546. this.bar.classList.add('hidden');
  1547. document.body.classList.remove('loadingInProgress');
  1548. }
  1549. }, {
  1550. key: 'show',
  1551. value: function show() {
  1552. if (this.visible) {
  1553. return;
  1554. }
  1555. this.visible = true;
  1556. document.body.classList.add('loadingInProgress');
  1557. this.bar.classList.remove('hidden');
  1558. }
  1559. }, {
  1560. key: 'percent',
  1561. get: function get() {
  1562. return this._percent;
  1563. },
  1564. set: function set(val) {
  1565. this._indeterminate = isNaN(val);
  1566. this._percent = clamp(val, 0, 100);
  1567. this._updateBar();
  1568. }
  1569. }]);
  1570. return ProgressBar;
  1571. }();
  1572. exports.CSS_UNITS = CSS_UNITS;
  1573. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  1574. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  1575. exports.MIN_SCALE = MIN_SCALE;
  1576. exports.MAX_SCALE = MAX_SCALE;
  1577. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  1578. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  1579. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  1580. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  1581. exports.cloneObj = cloneObj;
  1582. exports.RendererType = RendererType;
  1583. exports.mozL10n = mozL10n;
  1584. exports.NullL10n = NullL10n;
  1585. exports.EventBus = EventBus;
  1586. exports.ProgressBar = ProgressBar;
  1587. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  1588. exports.noContextMenuHandler = noContextMenuHandler;
  1589. exports.parseQueryString = parseQueryString;
  1590. exports.getVisibleElements = getVisibleElements;
  1591. exports.roundToDivide = roundToDivide;
  1592. exports.approximateFraction = approximateFraction;
  1593. exports.getOutputScale = getOutputScale;
  1594. exports.scrollIntoView = scrollIntoView;
  1595. exports.watchScroll = watchScroll;
  1596. exports.binarySearchFirstItem = binarySearchFirstItem;
  1597. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  1598. exports.animationStarted = animationStarted;
  1599. exports.localized = localized;
  1600. /***/
  1601. }),
  1602. /* 1 */
  1603. /***/ (function (module, exports, __webpack_require__) {
  1604. "use strict";
  1605. var pdfjsLib;
  1606. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  1607. pdfjsLib = window['pdfjs-dist/build/pdf'];
  1608. } else {
  1609. pdfjsLib = require('./' + link_diff + '/pdf/pdf.js');
  1610. }
  1611. module.exports = pdfjsLib;
  1612. /***/
  1613. }),
  1614. /* 2 */
  1615. /***/ (function (module, exports, __webpack_require__) {
  1616. "use strict";
  1617. Object.defineProperty(exports, "__esModule", {
  1618. value: true
  1619. });
  1620. exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
  1621. var _ui_utils = __webpack_require__(0);
  1622. function attachDOMEventsToEventBus(eventBus) {
  1623. eventBus.on('documentload', function () {
  1624. var event = document.createEvent('CustomEvent');
  1625. event.initCustomEvent('documentload', true, true, {});
  1626. window.dispatchEvent(event);
  1627. });
  1628. eventBus.on('pagerendered', function (evt) {
  1629. var event = document.createEvent('CustomEvent');
  1630. event.initCustomEvent('pagerendered', true, true, {
  1631. pageNumber: evt.pageNumber,
  1632. cssTransform: evt.cssTransform
  1633. });
  1634. evt.source.div.dispatchEvent(event);
  1635. });
  1636. eventBus.on('textlayerrendered', function (evt) {
  1637. var event = document.createEvent('CustomEvent');
  1638. event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber });
  1639. evt.source.textLayerDiv.dispatchEvent(event);
  1640. });
  1641. eventBus.on('pagechange', function (evt) {
  1642. var event = document.createEvent('UIEvents');
  1643. event.initUIEvent('pagechange', true, true, window, 0);
  1644. event.pageNumber = evt.pageNumber;
  1645. evt.source.container.dispatchEvent(event);
  1646. });
  1647. eventBus.on('pagesinit', function (evt) {
  1648. var event = document.createEvent('CustomEvent');
  1649. event.initCustomEvent('pagesinit', true, true, null);
  1650. evt.source.container.dispatchEvent(event);
  1651. });
  1652. eventBus.on('pagesloaded', function (evt) {
  1653. var event = document.createEvent('CustomEvent');
  1654. event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount });
  1655. evt.source.container.dispatchEvent(event);
  1656. });
  1657. eventBus.on('scalechange', function (evt) {
  1658. var event = document.createEvent('UIEvents');
  1659. event.initUIEvent('scalechange', true, true, window, 0);
  1660. event.scale = evt.scale;
  1661. event.presetValue = evt.presetValue;
  1662. evt.source.container.dispatchEvent(event);
  1663. });
  1664. eventBus.on('updateviewarea', function (evt) {
  1665. var event = document.createEvent('UIEvents');
  1666. event.initUIEvent('updateviewarea', true, true, window, 0);
  1667. event.location = evt.location;
  1668. evt.source.container.dispatchEvent(event);
  1669. });
  1670. eventBus.on('find', function (evt) {
  1671. if (evt.source === window) {
  1672. return;
  1673. }
  1674. var event = document.createEvent('CustomEvent');
  1675. event.initCustomEvent('find' + evt.type, true, true, {
  1676. query: evt.query,
  1677. phraseSearch: evt.phraseSearch,
  1678. caseSensitive: evt.caseSensitive,
  1679. highlightAll: evt.highlightAll,
  1680. findPrevious: evt.findPrevious
  1681. });
  1682. window.dispatchEvent(event);
  1683. });
  1684. eventBus.on('attachmentsloaded', function (evt) {
  1685. var event = document.createEvent('CustomEvent');
  1686. event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount });
  1687. evt.source.container.dispatchEvent(event);
  1688. });
  1689. eventBus.on('sidebarviewchanged', function (evt) {
  1690. var event = document.createEvent('CustomEvent');
  1691. event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view });
  1692. evt.source.outerContainer.dispatchEvent(event);
  1693. });
  1694. eventBus.on('pagemode', function (evt) {
  1695. var event = document.createEvent('CustomEvent');
  1696. event.initCustomEvent('pagemode', true, true, { mode: evt.mode });
  1697. evt.source.pdfViewer.container.dispatchEvent(event);
  1698. });
  1699. eventBus.on('namedaction', function (evt) {
  1700. var event = document.createEvent('CustomEvent');
  1701. event.initCustomEvent('namedaction', true, true, { action: evt.action });
  1702. evt.source.pdfViewer.container.dispatchEvent(event);
  1703. });
  1704. eventBus.on('presentationmodechanged', function (evt) {
  1705. var event = document.createEvent('CustomEvent');
  1706. event.initCustomEvent('presentationmodechanged', true, true, {
  1707. active: evt.active,
  1708. switchInProgress: evt.switchInProgress
  1709. });
  1710. window.dispatchEvent(event);
  1711. });
  1712. eventBus.on('outlineloaded', function (evt) {
  1713. var event = document.createEvent('CustomEvent');
  1714. event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });
  1715. evt.source.container.dispatchEvent(event);
  1716. });
  1717. }
  1718. var globalEventBus = null;
  1719. function getGlobalEventBus() {
  1720. if (globalEventBus) {
  1721. return globalEventBus;
  1722. }
  1723. globalEventBus = new _ui_utils.EventBus();
  1724. attachDOMEventsToEventBus(globalEventBus);
  1725. return globalEventBus;
  1726. }
  1727. exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
  1728. exports.getGlobalEventBus = getGlobalEventBus;
  1729. /***/
  1730. }),
  1731. /* 3 */
  1732. /***/ (function (module, exports, __webpack_require__) {
  1733. "use strict";
  1734. Object.defineProperty(exports, "__esModule", {
  1735. value: true
  1736. });
  1737. 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; }; }();
  1738. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1739. var CLEANUP_TIMEOUT = 30000;
  1740. var RenderingStates = {
  1741. INITIAL: 0,
  1742. RUNNING: 1,
  1743. PAUSED: 2,
  1744. FINISHED: 3
  1745. };
  1746. var PDFRenderingQueue = function () {
  1747. function PDFRenderingQueue() {
  1748. _classCallCheck(this, PDFRenderingQueue);
  1749. this.pdfViewer = null;
  1750. this.pdfThumbnailViewer = null;
  1751. this.onIdle = null;
  1752. this.highestPriorityPage = null;
  1753. this.idleTimeout = null;
  1754. this.printing = false;
  1755. this.isThumbnailViewEnabled = false;
  1756. }
  1757. _createClass(PDFRenderingQueue, [{
  1758. key: "setViewer",
  1759. value: function setViewer(pdfViewer) {
  1760. this.pdfViewer = pdfViewer;
  1761. }
  1762. }, {
  1763. key: "setThumbnailViewer",
  1764. value: function setThumbnailViewer(pdfThumbnailViewer) {
  1765. this.pdfThumbnailViewer = pdfThumbnailViewer;
  1766. }
  1767. }, {
  1768. key: "isHighestPriority",
  1769. value: function isHighestPriority(view) {
  1770. return this.highestPriorityPage === view.renderingId;
  1771. }
  1772. }, {
  1773. key: "renderHighestPriority",
  1774. value: function renderHighestPriority(currentlyVisiblePages) {
  1775. if (this.idleTimeout) {
  1776. clearTimeout(this.idleTimeout);
  1777. this.idleTimeout = null;
  1778. }
  1779. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  1780. return;
  1781. }
  1782. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  1783. if (this.pdfThumbnailViewer.forceRendering()) {
  1784. return;
  1785. }
  1786. }
  1787. if (this.printing) {
  1788. return;
  1789. }
  1790. if (this.onIdle) {
  1791. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  1792. }
  1793. }
  1794. }, {
  1795. key: "getHighestPriority",
  1796. value: function getHighestPriority(visible, views, scrolledDown) {
  1797. var visibleViews = visible.views;
  1798. var numVisible = visibleViews.length;
  1799. if (numVisible === 0) {
  1800. return false;
  1801. }
  1802. for (var i = 0; i < numVisible; ++i) {
  1803. var view = visibleViews[i].view;
  1804. if (!this.isViewFinished(view)) {
  1805. return view;
  1806. }
  1807. }
  1808. if (scrolledDown) {
  1809. var nextPageIndex = visible.last.id;
  1810. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  1811. return views[nextPageIndex];
  1812. }
  1813. } else {
  1814. var previousPageIndex = visible.first.id - 2;
  1815. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  1816. return views[previousPageIndex];
  1817. }
  1818. }
  1819. return null;
  1820. }
  1821. }, {
  1822. key: "isViewFinished",
  1823. value: function isViewFinished(view) {
  1824. return view.renderingState === RenderingStates.FINISHED;
  1825. }
  1826. }, {
  1827. key: "renderView",
  1828. value: function renderView(view) {
  1829. var _this = this;
  1830. switch (view.renderingState) {
  1831. case RenderingStates.FINISHED:
  1832. return false;
  1833. case RenderingStates.PAUSED:
  1834. this.highestPriorityPage = view.renderingId;
  1835. view.resume();
  1836. break;
  1837. case RenderingStates.RUNNING:
  1838. this.highestPriorityPage = view.renderingId;
  1839. break;
  1840. case RenderingStates.INITIAL:
  1841. this.highestPriorityPage = view.renderingId;
  1842. var continueRendering = function continueRendering() {
  1843. _this.renderHighestPriority();
  1844. };
  1845. view.draw().then(continueRendering, continueRendering);
  1846. break;
  1847. }
  1848. return true;
  1849. }
  1850. }]);
  1851. return PDFRenderingQueue;
  1852. }();
  1853. exports.RenderingStates = RenderingStates;
  1854. exports.PDFRenderingQueue = PDFRenderingQueue;
  1855. /***/
  1856. }),
  1857. /* 4 */
  1858. /***/ (function (module, exports, __webpack_require__) {
  1859. "use strict";
  1860. Object.defineProperty(exports, "__esModule", {
  1861. value: true
  1862. });
  1863. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = undefined;
  1864. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  1865. var _ui_utils = __webpack_require__(0);
  1866. var _pdfjsLib = __webpack_require__(1);
  1867. var _pdf_cursor_tools = __webpack_require__(6);
  1868. var _pdf_rendering_queue = __webpack_require__(3);
  1869. var _pdf_sidebar = __webpack_require__(24);
  1870. var _pdf_viewer = __webpack_require__(27);
  1871. var _dom_events = __webpack_require__(2);
  1872. var _overlay_manager = __webpack_require__(15);
  1873. var _password_prompt = __webpack_require__(16);
  1874. var _pdf_attachment_viewer = __webpack_require__(17);
  1875. var _pdf_document_properties = __webpack_require__(18);
  1876. var _pdf_find_bar = __webpack_require__(19);
  1877. var _pdf_find_controller = __webpack_require__(7);
  1878. var _pdf_history = __webpack_require__(20);
  1879. var _pdf_link_service = __webpack_require__(5);
  1880. var _pdf_outline_viewer = __webpack_require__(21);
  1881. var _pdf_presentation_mode = __webpack_require__(23);
  1882. var _pdf_thumbnail_viewer = __webpack_require__(26);
  1883. var _secondary_toolbar = __webpack_require__(29);
  1884. var _toolbar = __webpack_require__(31);
  1885. var _view_history = __webpack_require__(32);
  1886. var DEFAULT_SCALE_DELTA = 1.1;
  1887. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  1888. function configure(PDFJS) {
  1889. PDFJS.imageResourcesPath = "./images/";
  1890. PDFJS.workerSrc = pdfScriptPath + "/pdf.worker.js";
  1891. PDFJS.cMapUrl = pdfScriptPath + "/cmaps/";
  1892. PDFJS.cMapPacked = true;
  1893. }
  1894. var DefaultExternalServices = {
  1895. updateFindControlState: function updateFindControlState(data) { },
  1896. initPassiveLoading: function initPassiveLoading(callbacks) { },
  1897. fallback: function fallback(data, callback) { },
  1898. reportTelemetry: function reportTelemetry(data) { },
  1899. createDownloadManager: function createDownloadManager() {
  1900. throw new Error('Not implemented: createDownloadManager');
  1901. },
  1902. createPreferences: function createPreferences() {
  1903. throw new Error('Not implemented: createPreferences');
  1904. },
  1905. createL10n: function createL10n() {
  1906. throw new Error('Not implemented: createL10n');
  1907. },
  1908. supportsIntegratedFind: false,
  1909. supportsDocumentFonts: true,
  1910. supportsDocumentColors: true,
  1911. supportedMouseWheelZoomModifierKeys: {
  1912. ctrlKey: true,
  1913. metaKey: true
  1914. }
  1915. };
  1916. var PDFViewerApplication = {
  1917. initialBookmark: document.location.hash.substring(1),
  1918. initialDestination: null,
  1919. initialized: false,
  1920. fellback: false,
  1921. appConfig: null,
  1922. pdfDocument: null,
  1923. pdfLoadingTask: null,
  1924. printService: null,
  1925. pdfViewer: null,
  1926. pdfThumbnailViewer: null,
  1927. pdfRenderingQueue: null,
  1928. pdfPresentationMode: null,
  1929. pdfDocumentProperties: null,
  1930. pdfLinkService: null,
  1931. pdfHistory: null,
  1932. pdfSidebar: null,
  1933. pdfOutlineViewer: null,
  1934. pdfAttachmentViewer: null,
  1935. pdfCursorTools: null,
  1936. store: null,
  1937. downloadManager: null,
  1938. overlayManager: null,
  1939. preferences: null,
  1940. toolbar: null,
  1941. secondaryToolbar: null,
  1942. eventBus: null,
  1943. l10n: null,
  1944. isInitialViewSet: false,
  1945. downloadComplete: false,
  1946. viewerPrefs: {
  1947. sidebarViewOnLoad: _pdf_sidebar.SidebarView.NONE,
  1948. pdfBugEnabled: false,
  1949. showPreviousViewOnLoad: true,
  1950. defaultZoomValue: '',
  1951. disablePageMode: false,
  1952. disablePageLabels: false,
  1953. renderer: 'canvas',
  1954. enhanceTextSelection: false,
  1955. renderInteractiveForms: false,
  1956. enablePrintAutoRotate: false
  1957. },
  1958. isViewerEmbedded: window.parent !== window,
  1959. url: '',
  1960. baseUrl: '',
  1961. externalServices: DefaultExternalServices,
  1962. _boundEvents: {},
  1963. initialize: function initialize(appConfig) {
  1964. var _this = this;
  1965. this.preferences = this.externalServices.createPreferences();
  1966. configure(_pdfjsLib.PDFJS);
  1967. this.appConfig = appConfig;
  1968. return this._readPreferences().then(function () {
  1969. return _this._initializeL10n();
  1970. }).then(function () {
  1971. return _this._initializeViewerComponents();
  1972. }).then(function () {
  1973. _this.bindEvents();
  1974. _this.bindWindowEvents();
  1975. var appContainer = appConfig.appContainer || document.documentElement;
  1976. _this.l10n.translate(appContainer).then(function () {
  1977. _this.eventBus.dispatch('localized');
  1978. });
  1979. if (_this.isViewerEmbedded && !_pdfjsLib.PDFJS.isExternalLinkTargetSet()) {
  1980. _pdfjsLib.PDFJS.externalLinkTarget = _pdfjsLib.PDFJS.LinkTarget.TOP;
  1981. }
  1982. _this.initialized = true;
  1983. });
  1984. },
  1985. _readPreferences: function _readPreferences() {
  1986. var preferences = this.preferences,
  1987. viewerPrefs = this.viewerPrefs;
  1988. return Promise.all([preferences.get('enableWebGL').then(function resolved(value) {
  1989. _pdfjsLib.PDFJS.disableWebGL = !value;
  1990. }), preferences.get('sidebarViewOnLoad').then(function resolved(value) {
  1991. viewerPrefs['sidebarViewOnLoad'] = value;
  1992. }), preferences.get('pdfBugEnabled').then(function resolved(value) {
  1993. viewerPrefs['pdfBugEnabled'] = value;
  1994. }), preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
  1995. viewerPrefs['showPreviousViewOnLoad'] = value;
  1996. }), preferences.get('defaultZoomValue').then(function resolved(value) {
  1997. viewerPrefs['defaultZoomValue'] = value;
  1998. }), preferences.get('enhanceTextSelection').then(function resolved(value) {
  1999. viewerPrefs['enhanceTextSelection'] = value;
  2000. }), preferences.get('disableTextLayer').then(function resolved(value) {
  2001. if (_pdfjsLib.PDFJS.disableTextLayer === true) {
  2002. return;
  2003. }
  2004. _pdfjsLib.PDFJS.disableTextLayer = value;
  2005. }), preferences.get('disableRange').then(function resolved(value) {
  2006. if (_pdfjsLib.PDFJS.disableRange === true) {
  2007. return;
  2008. }
  2009. _pdfjsLib.PDFJS.disableRange = value;
  2010. }), preferences.get('disableStream').then(function resolved(value) {
  2011. if (_pdfjsLib.PDFJS.disableStream === true) {
  2012. return;
  2013. }
  2014. _pdfjsLib.PDFJS.disableStream = value;
  2015. }), preferences.get('disableAutoFetch').then(function resolved(value) {
  2016. _pdfjsLib.PDFJS.disableAutoFetch = value;
  2017. }), preferences.get('disableFontFace').then(function resolved(value) {
  2018. if (_pdfjsLib.PDFJS.disableFontFace === true) {
  2019. return;
  2020. }
  2021. _pdfjsLib.PDFJS.disableFontFace = value;
  2022. }), preferences.get('useOnlyCssZoom').then(function resolved(value) {
  2023. _pdfjsLib.PDFJS.useOnlyCssZoom = value;
  2024. }), preferences.get('externalLinkTarget').then(function resolved(value) {
  2025. if (_pdfjsLib.PDFJS.isExternalLinkTargetSet()) {
  2026. return;
  2027. }
  2028. _pdfjsLib.PDFJS.externalLinkTarget = value;
  2029. }), preferences.get('renderer').then(function resolved(value) {
  2030. viewerPrefs['renderer'] = value;
  2031. }), preferences.get('renderInteractiveForms').then(function resolved(value) {
  2032. viewerPrefs['renderInteractiveForms'] = value;
  2033. }), preferences.get('disablePageMode').then(function resolved(value) {
  2034. viewerPrefs['disablePageMode'] = value;
  2035. }), preferences.get('disablePageLabels').then(function resolved(value) {
  2036. viewerPrefs['disablePageLabels'] = value;
  2037. }), preferences.get('enablePrintAutoRotate').then(function resolved(value) {
  2038. viewerPrefs['enablePrintAutoRotate'] = value;
  2039. })]).catch(function (reason) { });
  2040. },
  2041. _initializeL10n: function _initializeL10n() {
  2042. if (this.viewerPrefs['pdfBugEnabled']) {
  2043. var hash = document.location.hash.substring(1);
  2044. var hashParams = (0, _ui_utils.parseQueryString)(hash);
  2045. if ('locale' in hashParams) {
  2046. _pdfjsLib.PDFJS.locale = hashParams['locale'];
  2047. }
  2048. }
  2049. this.l10n = this.externalServices.createL10n();
  2050. return this.l10n.getDirection().then(function (dir) {
  2051. var orginalHtmlDir = $("#mainPdfWarrper").attr("dir");
  2052. //console.log("orginal html dir: " + orginalHtmlDir + ", new html dir: " + dir)
  2053. if (orginalHtmlDir !== undefined) {
  2054. sessionStorage.setItem("o2h_orginal_html_dir", orginalHtmlDir);
  2055. } else {
  2056. sessionStorage.setItem("o2h_orginal_html_dir", "");
  2057. }
  2058. document.getElementById('mainPdfWarrper').dir = dir;
  2059. });
  2060. },
  2061. _initializeViewerComponents: function _initializeViewerComponents() {
  2062. var _this2 = this;
  2063. var appConfig = this.appConfig;
  2064. return new Promise(function (resolve, reject) {
  2065. _this2.overlayManager = new _overlay_manager.OverlayManager();
  2066. var eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)();
  2067. _this2.eventBus = eventBus;
  2068. var pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  2069. pdfRenderingQueue.onIdle = _this2.cleanup.bind(_this2);
  2070. _this2.pdfRenderingQueue = pdfRenderingQueue;
  2071. var pdfLinkService = new _pdf_link_service.PDFLinkService({ eventBus: eventBus });
  2072. _this2.pdfLinkService = pdfLinkService;
  2073. var downloadManager = _this2.externalServices.createDownloadManager();
  2074. _this2.downloadManager = downloadManager;
  2075. var container = appConfig.mainContainer;
  2076. var viewer = appConfig.viewerContainer;
  2077. _this2.pdfViewer = new _pdf_viewer.PDFViewer({
  2078. container: container,
  2079. viewer: viewer,
  2080. eventBus: eventBus,
  2081. renderingQueue: pdfRenderingQueue,
  2082. linkService: pdfLinkService,
  2083. downloadManager: downloadManager,
  2084. renderer: _this2.viewerPrefs['renderer'],
  2085. l10n: _this2.l10n,
  2086. enhanceTextSelection: _this2.viewerPrefs['enhanceTextSelection'],
  2087. renderInteractiveForms: _this2.viewerPrefs['renderInteractiveForms'],
  2088. enablePrintAutoRotate: _this2.viewerPrefs['enablePrintAutoRotate']
  2089. });
  2090. pdfRenderingQueue.setViewer(_this2.pdfViewer);
  2091. pdfLinkService.setViewer(_this2.pdfViewer);
  2092. var thumbnailContainer = appConfig.sidebar.thumbnailView;
  2093. _this2.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  2094. container: thumbnailContainer,
  2095. renderingQueue: pdfRenderingQueue,
  2096. linkService: pdfLinkService,
  2097. l10n: _this2.l10n
  2098. });
  2099. pdfRenderingQueue.setThumbnailViewer(_this2.pdfThumbnailViewer);
  2100. _this2.pdfHistory = new _pdf_history.PDFHistory({
  2101. linkService: pdfLinkService,
  2102. eventBus: eventBus
  2103. });
  2104. pdfLinkService.setHistory(_this2.pdfHistory);
  2105. _this2.findController = new _pdf_find_controller.PDFFindController({ pdfViewer: _this2.pdfViewer });
  2106. _this2.findController.onUpdateResultsCount = function (matchCount) {
  2107. if (_this2.supportsIntegratedFind) {
  2108. return;
  2109. }
  2110. _this2.findBar.updateResultsCount(matchCount);
  2111. };
  2112. _this2.findController.onUpdateState = function (state, previous, matchCount) {
  2113. if (_this2.supportsIntegratedFind) {
  2114. _this2.externalServices.updateFindControlState({
  2115. result: state,
  2116. findPrevious: previous
  2117. });
  2118. } else {
  2119. _this2.findBar.updateUIState(state, previous, matchCount);
  2120. }
  2121. };
  2122. _this2.pdfViewer.setFindController(_this2.findController);
  2123. var findBarConfig = Object.create(appConfig.findBar);
  2124. findBarConfig.findController = _this2.findController;
  2125. findBarConfig.eventBus = eventBus;
  2126. _this2.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig, _this2.l10n);
  2127. _this2.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.pdfDocumentProperties, _this2.overlayManager, _this2.l10n);
  2128. _this2.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  2129. container: container,
  2130. eventBus: eventBus,
  2131. preferences: _this2.preferences
  2132. });
  2133. _this2.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus, _this2.l10n);
  2134. _this2.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  2135. if (_this2.supportsFullscreen) {
  2136. _this2.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  2137. container: container,
  2138. viewer: viewer,
  2139. pdfViewer: _this2.pdfViewer,
  2140. eventBus: eventBus,
  2141. contextMenuItems: appConfig.fullscreen
  2142. });
  2143. }
  2144. _this2.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this2.overlayManager, _this2.l10n);
  2145. _this2.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  2146. container: appConfig.sidebar.outlineView,
  2147. eventBus: eventBus,
  2148. linkService: pdfLinkService
  2149. });
  2150. _this2.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  2151. container: appConfig.sidebar.attachmentsView,
  2152. eventBus: eventBus,
  2153. downloadManager: downloadManager
  2154. });
  2155. var sidebarConfig = Object.create(appConfig.sidebar);
  2156. sidebarConfig.pdfViewer = _this2.pdfViewer;
  2157. sidebarConfig.pdfThumbnailViewer = _this2.pdfThumbnailViewer;
  2158. sidebarConfig.pdfOutlineViewer = _this2.pdfOutlineViewer;
  2159. sidebarConfig.eventBus = eventBus;
  2160. _this2.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, _this2.l10n);
  2161. _this2.pdfSidebar.onToggled = _this2.forceRendering.bind(_this2);
  2162. resolve(undefined);
  2163. });
  2164. },
  2165. run: function run(config) {
  2166. this.initialize(config).then(webViewerInitialized);
  2167. },
  2168. zoomIn: function zoomIn(ticks) {
  2169. var newScale = this.pdfViewer.currentScale;
  2170. do {
  2171. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  2172. newScale = Math.ceil(newScale * 10) / 10;
  2173. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  2174. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  2175. this.pdfViewer.currentScaleValue = newScale;
  2176. },
  2177. zoomOut: function zoomOut(ticks) {
  2178. var newScale = this.pdfViewer.currentScale;
  2179. do {
  2180. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  2181. newScale = Math.floor(newScale * 10) / 10;
  2182. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  2183. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  2184. this.pdfViewer.currentScaleValue = newScale;
  2185. },
  2186. get pagesCount() {
  2187. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  2188. },
  2189. get pageRotation() {
  2190. return this.pdfViewer.pagesRotation;
  2191. },
  2192. set page(val) {
  2193. this.pdfViewer.currentPageNumber = val;
  2194. },
  2195. get page() {
  2196. return this.pdfViewer.currentPageNumber;
  2197. },
  2198. get printing() {
  2199. return !!this.printService;
  2200. },
  2201. get supportsPrinting() {
  2202. return PDFPrintServiceFactory.instance.supportsPrinting;
  2203. },
  2204. get supportsFullscreen() {
  2205. var support = void 0;
  2206. var doc = document.documentElement;
  2207. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  2208. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  2209. support = false;
  2210. }
  2211. if (support && _pdfjsLib.PDFJS.disableFullscreen === true) {
  2212. support = false;
  2213. }
  2214. return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support);
  2215. },
  2216. get supportsIntegratedFind() {
  2217. return this.externalServices.supportsIntegratedFind;
  2218. },
  2219. get supportsDocumentFonts() {
  2220. return this.externalServices.supportsDocumentFonts;
  2221. },
  2222. get supportsDocumentColors() {
  2223. return this.externalServices.supportsDocumentColors;
  2224. },
  2225. get loadingBar() {
  2226. var bar = new _ui_utils.ProgressBar('#loadingBar');
  2227. return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar);
  2228. },
  2229. get supportedMouseWheelZoomModifierKeys() {
  2230. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  2231. },
  2232. initPassiveLoading: function initPassiveLoading() {
  2233. throw new Error('Not implemented: initPassiveLoading');
  2234. },
  2235. setTitleUsingUrl: function setTitleUsingUrl(url) {
  2236. this.url = url;
  2237. this.baseUrl = url.split('#')[0];
  2238. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  2239. if (!title) {
  2240. try {
  2241. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  2242. } catch (ex) {
  2243. title = url;
  2244. }
  2245. }
  2246. this.setTitle(title);
  2247. },
  2248. setTitle: function setTitle(title) {
  2249. if (this.isViewerEmbedded) {
  2250. return;
  2251. }
  2252. document.title = title;
  2253. },
  2254. close: function close() {
  2255. var errorWrapper = this.appConfig.errorWrapper.container;
  2256. errorWrapper.setAttribute('hidden', 'true');
  2257. if (!this.pdfLoadingTask) {
  2258. return Promise.resolve();
  2259. }
  2260. var promise = this.pdfLoadingTask.destroy();
  2261. this.pdfLoadingTask = null;
  2262. if (this.pdfDocument) {
  2263. this.pdfDocument = null;
  2264. this.pdfThumbnailViewer.setDocument(null);
  2265. this.pdfViewer.setDocument(null);
  2266. this.pdfLinkService.setDocument(null, null);
  2267. this.pdfDocumentProperties.setDocument(null, null);
  2268. }
  2269. this.store = null;
  2270. this.isInitialViewSet = false;
  2271. this.downloadComplete = false;
  2272. this.pdfSidebar.reset();
  2273. this.pdfOutlineViewer.reset();
  2274. this.pdfAttachmentViewer.reset();
  2275. this.findController.reset();
  2276. this.findBar.reset();
  2277. this.toolbar.reset();
  2278. this.secondaryToolbar.reset();
  2279. if (typeof PDFBug !== 'undefined') {
  2280. PDFBug.cleanup();
  2281. }
  2282. return promise;
  2283. },
  2284. open: function open(file, args) {
  2285. var _this3 = this;
  2286. if (arguments.length > 2 || typeof args === 'number') {
  2287. return Promise.reject(new Error('Call of open() with obsolete signature.'));
  2288. }
  2289. if (this.pdfLoadingTask) {
  2290. return this.close().then(function () {
  2291. _this3.preferences.reload();
  2292. return _this3.open(file, args);
  2293. });
  2294. }
  2295. var parameters = Object.create(null),
  2296. scale = void 0;
  2297. if (typeof file === 'string') {
  2298. this.setTitleUsingUrl(file);
  2299. parameters.url = file;
  2300. } else if (file && 'byteLength' in file) {
  2301. parameters.data = file;
  2302. } else if (file.url && file.originalUrl) {
  2303. this.setTitleUsingUrl(file.originalUrl);
  2304. parameters.url = file.url;
  2305. }
  2306. if (args) {
  2307. for (var prop in args) {
  2308. parameters[prop] = args[prop];
  2309. }
  2310. if (args.scale) {
  2311. scale = args.scale;
  2312. }
  2313. if (args.length) {
  2314. this.pdfDocumentProperties.setFileSize(args.length);
  2315. }
  2316. }
  2317. var loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  2318. this.pdfLoadingTask = loadingTask;
  2319. loadingTask.onPassword = function (updateCallback, reason) {
  2320. _this3.passwordPrompt.setUpdateCallback(updateCallback, reason);
  2321. _this3.passwordPrompt.open();
  2322. };
  2323. loadingTask.onProgress = function (_ref) {
  2324. var loaded = _ref.loaded,
  2325. total = _ref.total;
  2326. _this3.progress(loaded / total);
  2327. };
  2328. loadingTask.onUnsupportedFeature = this.fallback.bind(this);
  2329. return loadingTask.promise.then(function (pdfDocument) {
  2330. _this3.load(pdfDocument, scale);
  2331. }, function (exception) {
  2332. var message = exception && exception.message;
  2333. var loadingErrorMessage = void 0;
  2334. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  2335. loadingErrorMessage = _this3.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
  2336. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  2337. loadingErrorMessage = _this3.l10n.get('missing_file_error', null, 'Missing PDF file.');
  2338. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  2339. loadingErrorMessage = _this3.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
  2340. } else {
  2341. loadingErrorMessage = _this3.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
  2342. }
  2343. return loadingErrorMessage.then(function (msg) {
  2344. _this3.error(msg, { message: message });
  2345. throw new Error(msg);
  2346. });
  2347. });
  2348. },
  2349. download: function download() {
  2350. var _this4 = this;
  2351. function downloadByUrl() {
  2352. downloadManager.downloadUrl(url, filename);
  2353. }
  2354. var url = this.baseUrl;
  2355. var filename = (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  2356. var downloadManager = this.downloadManager;
  2357. downloadManager.onerror = function (err) {
  2358. _this4.error('PDF failed to download: ' + err);
  2359. };
  2360. if (!this.pdfDocument || !this.downloadComplete) {
  2361. downloadByUrl();
  2362. return;
  2363. }
  2364. this.pdfDocument.getData().then(function (data) {
  2365. var blob = (0, _pdfjsLib.createBlob)(data, 'application/pdf');
  2366. downloadManager.download(blob, url, filename);
  2367. }).catch(downloadByUrl);
  2368. },
  2369. fallback: function fallback(featureId) { },
  2370. error: function error(message, moreInfo) {
  2371. var moreInfoText = [this.l10n.get('error_version_info', {
  2372. version: _pdfjsLib.version || '?',
  2373. build: _pdfjsLib.build || '?'
  2374. }, 'PDF.js v{{version}} (build: {{build}})')];
  2375. if (moreInfo) {
  2376. moreInfoText.push(this.l10n.get('error_message', { message: moreInfo.message }, 'Message: {{message}}'));
  2377. if (moreInfo.stack) {
  2378. moreInfoText.push(this.l10n.get('error_stack', { stack: moreInfo.stack }, 'Stack: {{stack}}'));
  2379. } else {
  2380. if (moreInfo.filename) {
  2381. moreInfoText.push(this.l10n.get('error_file', { file: moreInfo.filename }, 'File: {{file}}'));
  2382. }
  2383. if (moreInfo.lineNumber) {
  2384. moreInfoText.push(this.l10n.get('error_line', { line: moreInfo.lineNumber }, 'Line: {{line}}'));
  2385. }
  2386. }
  2387. }
  2388. var errorWrapperConfig = this.appConfig.errorWrapper;
  2389. var errorWrapper = errorWrapperConfig.container;
  2390. errorWrapper.removeAttribute('hidden');
  2391. var errorMessage = errorWrapperConfig.errorMessage;
  2392. errorMessage.textContent = message;
  2393. var closeButton = errorWrapperConfig.closeButton;
  2394. closeButton.onclick = function () {
  2395. errorWrapper.setAttribute('hidden', 'true');
  2396. };
  2397. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  2398. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  2399. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  2400. moreInfoButton.onclick = function () {
  2401. errorMoreInfo.removeAttribute('hidden');
  2402. moreInfoButton.setAttribute('hidden', 'true');
  2403. lessInfoButton.removeAttribute('hidden');
  2404. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
  2405. };
  2406. lessInfoButton.onclick = function () {
  2407. errorMoreInfo.setAttribute('hidden', 'true');
  2408. moreInfoButton.removeAttribute('hidden');
  2409. lessInfoButton.setAttribute('hidden', 'true');
  2410. };
  2411. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  2412. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  2413. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  2414. moreInfoButton.removeAttribute('hidden');
  2415. lessInfoButton.setAttribute('hidden', 'true');
  2416. Promise.all(moreInfoText).then(function (parts) {
  2417. errorMoreInfo.value = parts.join('\n');
  2418. });
  2419. },
  2420. progress: function progress(level) {
  2421. var _this5 = this;
  2422. if (this.downloadComplete) {
  2423. return;
  2424. }
  2425. var percent = Math.round(level * 100);
  2426. if (percent > this.loadingBar.percent || isNaN(percent)) {
  2427. this.loadingBar.percent = percent;
  2428. if (_pdfjsLib.PDFJS.disableAutoFetch && percent) {
  2429. if (this.disableAutoFetchLoadingBarTimeout) {
  2430. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  2431. this.disableAutoFetchLoadingBarTimeout = null;
  2432. }
  2433. this.loadingBar.show();
  2434. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  2435. _this5.loadingBar.hide();
  2436. _this5.disableAutoFetchLoadingBarTimeout = null;
  2437. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  2438. }
  2439. }
  2440. },
  2441. load: function load(pdfDocument, scale) {
  2442. var _this6 = this;
  2443. scale = scale || _ui_utils.UNKNOWN_SCALE;
  2444. this.pdfDocument = pdfDocument;
  2445. pdfDocument.getDownloadInfo().then(function () {
  2446. _this6.downloadComplete = true;
  2447. _this6.loadingBar.hide();
  2448. firstPagePromise.then(function () {
  2449. _this6.eventBus.dispatch('documentload', { source: _this6 });
  2450. });
  2451. });
  2452. var pageModePromise = pdfDocument.getPageMode().catch(function () { });
  2453. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  2454. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  2455. var id = this.documentFingerprint = pdfDocument.fingerprint;
  2456. var store = this.store = new _view_history.ViewHistory(id);
  2457. var baseDocumentUrl = void 0;
  2458. baseDocumentUrl = null;
  2459. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  2460. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  2461. var pdfViewer = this.pdfViewer;
  2462. pdfViewer.setDocument(pdfDocument);
  2463. var firstPagePromise = pdfViewer.firstPagePromise;
  2464. var pagesPromise = pdfViewer.pagesPromise;
  2465. var onePageRendered = pdfViewer.onePageRendered;
  2466. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  2467. pdfThumbnailViewer.setDocument(pdfDocument);
  2468. firstPagePromise.then(function (pdfPage) {
  2469. _this6.loadingBar.setWidth(_this6.appConfig.viewerContainer);
  2470. if (!_pdfjsLib.PDFJS.disableHistory && !_this6.isViewerEmbedded) {
  2471. if (!_this6.viewerPrefs['showPreviousViewOnLoad']) {
  2472. _this6.pdfHistory.clearHistoryState();
  2473. }
  2474. _this6.pdfHistory.initialize(_this6.documentFingerprint);
  2475. if (_this6.pdfHistory.initialDestination) {
  2476. _this6.initialDestination = _this6.pdfHistory.initialDestination;
  2477. } else if (_this6.pdfHistory.initialBookmark) {
  2478. _this6.initialBookmark = _this6.pdfHistory.initialBookmark;
  2479. }
  2480. }
  2481. var initialParams = {
  2482. destination: _this6.initialDestination,
  2483. bookmark: _this6.initialBookmark,
  2484. hash: null
  2485. };
  2486. var storePromise = store.getMultiple({
  2487. exists: false,
  2488. page: '1',
  2489. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  2490. scrollLeft: '0',
  2491. scrollTop: '0',
  2492. sidebarView: _pdf_sidebar.SidebarView.NONE
  2493. }).catch(function () { });
  2494. Promise.all([storePromise, pageModePromise]).then(function (_ref2) {
  2495. var _ref3 = _slicedToArray(_ref2, 2),
  2496. _ref3$ = _ref3[0],
  2497. values = _ref3$ === undefined ? {} : _ref3$,
  2498. pageMode = _ref3[1];
  2499. var hash = _this6.viewerPrefs['defaultZoomValue'] ? 'zoom=' + _this6.viewerPrefs['defaultZoomValue'] : null;
  2500. var sidebarView = _this6.viewerPrefs['sidebarViewOnLoad'];
  2501. if (values.exists && _this6.viewerPrefs['showPreviousViewOnLoad']) {
  2502. hash = 'page=' + values.page + '&zoom=' + (_this6.viewerPrefs['defaultZoomValue'] || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop;
  2503. sidebarView = sidebarView || values.sidebarView | 0;
  2504. }
  2505. if (pageMode && !_this6.viewerPrefs['disablePageMode']) {
  2506. sidebarView = sidebarView || apiPageModeToSidebarView(pageMode);
  2507. }
  2508. return {
  2509. hash: hash,
  2510. sidebarView: sidebarView
  2511. };
  2512. }).then(function (_ref4) {
  2513. var hash = _ref4.hash,
  2514. sidebarView = _ref4.sidebarView;
  2515. _this6.setInitialView(hash, {
  2516. sidebarView: sidebarView,
  2517. scale: scale
  2518. });
  2519. initialParams.hash = hash;
  2520. if (!_this6.isViewerEmbedded) {
  2521. pdfViewer.focus();
  2522. }
  2523. return pagesPromise;
  2524. }).then(function () {
  2525. if (!initialParams.destination && !initialParams.bookmark && !initialParams.hash) {
  2526. return;
  2527. }
  2528. if (pdfViewer.hasEqualPageSizes) {
  2529. return;
  2530. }
  2531. _this6.initialDestination = initialParams.destination;
  2532. _this6.initialBookmark = initialParams.bookmark;
  2533. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  2534. _this6.setInitialView(initialParams.hash);
  2535. }).then(function () {
  2536. pdfViewer.update();
  2537. });
  2538. });
  2539. pdfDocument.getPageLabels().then(function (labels) {
  2540. if (!labels || _this6.viewerPrefs['disablePageLabels']) {
  2541. return;
  2542. }
  2543. var i = 0,
  2544. numLabels = labels.length;
  2545. if (numLabels !== _this6.pagesCount) {
  2546. console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
  2547. return;
  2548. }
  2549. while (i < numLabels && labels[i] === (i + 1).toString()) {
  2550. i++;
  2551. }
  2552. if (i === numLabels) {
  2553. return;
  2554. }
  2555. pdfViewer.setPageLabels(labels);
  2556. pdfThumbnailViewer.setPageLabels(labels);
  2557. _this6.toolbar.setPagesCount(pdfDocument.numPages, true);
  2558. _this6.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2559. });
  2560. pagesPromise.then(function () {
  2561. if (!_this6.supportsPrinting) {
  2562. return;
  2563. }
  2564. pdfDocument.getJavaScript().then(function (javaScript) {
  2565. if (javaScript.length) {
  2566. console.warn('Warning: JavaScript is not supported');
  2567. _this6.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  2568. }
  2569. var regex = /\bprint\s*\(/;
  2570. for (var i = 0, ii = javaScript.length; i < ii; i++) {
  2571. var js = javaScript[i];
  2572. if (js && regex.test(js)) {
  2573. setTimeout(function () {
  2574. window.print();
  2575. });
  2576. return;
  2577. }
  2578. }
  2579. });
  2580. });
  2581. Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () {
  2582. pdfDocument.getOutline().then(function (outline) {
  2583. _this6.pdfOutlineViewer.render({ outline: outline });
  2584. });
  2585. pdfDocument.getAttachments().then(function (attachments) {
  2586. _this6.pdfAttachmentViewer.render({ attachments: attachments });
  2587. });
  2588. });
  2589. pdfDocument.getMetadata().then(function (_ref5) {
  2590. var info = _ref5.info,
  2591. metadata = _ref5.metadata;
  2592. _this6.documentInfo = info;
  2593. _this6.metadata = metadata;
  2594. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib.version || '-') + (!_pdfjsLib.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')');
  2595. var pdfTitle = void 0;
  2596. if (metadata && metadata.has('dc:title')) {
  2597. var title = metadata.get('dc:title');
  2598. if (title !== 'Untitled') {
  2599. pdfTitle = title;
  2600. }
  2601. }
  2602. if (!pdfTitle && info && info['Title']) {
  2603. pdfTitle = info['Title'];
  2604. }
  2605. if (pdfTitle) {
  2606. _this6.setTitle(pdfTitle + ' - ' + document.title);
  2607. }
  2608. if (info.IsAcroFormPresent) {
  2609. console.warn('Warning: AcroForm/XFA is not supported');
  2610. _this6.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  2611. }
  2612. });
  2613. },
  2614. setInitialView: function setInitialView(storedHash) {
  2615. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2616. var _options$scale = options.scale,
  2617. scale = _options$scale === undefined ? 0 : _options$scale,
  2618. _options$sidebarView = options.sidebarView,
  2619. sidebarView = _options$sidebarView === undefined ? _pdf_sidebar.SidebarView.NONE : _options$sidebarView;
  2620. this.isInitialViewSet = true;
  2621. this.pdfSidebar.setInitialView(sidebarView);
  2622. if (this.initialDestination) {
  2623. this.pdfLinkService.navigateTo(this.initialDestination);
  2624. this.initialDestination = null;
  2625. } else if (this.initialBookmark) {
  2626. this.pdfLinkService.setHash(this.initialBookmark);
  2627. this.pdfHistory.push({ hash: this.initialBookmark }, true);
  2628. this.initialBookmark = null;
  2629. } else if (storedHash) {
  2630. this.pdfLinkService.setHash(storedHash);
  2631. } else if (scale) {
  2632. this.pdfViewer.currentScaleValue = scale;
  2633. this.page = 1;
  2634. }
  2635. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  2636. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  2637. if (!this.pdfViewer.currentScaleValue) {
  2638. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2639. }
  2640. },
  2641. cleanup: function cleanup() {
  2642. if (!this.pdfDocument) {
  2643. return;
  2644. }
  2645. this.pdfViewer.cleanup();
  2646. this.pdfThumbnailViewer.cleanup();
  2647. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  2648. this.pdfDocument.cleanup();
  2649. }
  2650. },
  2651. forceRendering: function forceRendering() {
  2652. this.pdfRenderingQueue.printing = this.printing;
  2653. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  2654. this.pdfRenderingQueue.renderHighestPriority();
  2655. },
  2656. beforePrint: function beforePrint() {
  2657. var _this7 = this;
  2658. if (this.printService) {
  2659. return;
  2660. }
  2661. if (!this.supportsPrinting) {
  2662. this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
  2663. _this7.error(printMessage);
  2664. });
  2665. return;
  2666. }
  2667. if (!this.pdfViewer.pageViewsReady) {
  2668. this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
  2669. window.alert(notReadyMessage);
  2670. });
  2671. return;
  2672. }
  2673. var pagesOverview = this.pdfViewer.getPagesOverview();
  2674. var printContainer = this.appConfig.printContainer;
  2675. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  2676. this.printService = printService;
  2677. this.forceRendering();
  2678. printService.layout();
  2679. },
  2680. afterPrint: function pdfViewSetupAfterPrint() {
  2681. if (this.printService) {
  2682. this.printService.destroy();
  2683. this.printService = null;
  2684. }
  2685. this.forceRendering();
  2686. },
  2687. rotatePages: function rotatePages(delta) {
  2688. if (!this.pdfDocument) {
  2689. return;
  2690. }
  2691. var pdfViewer = this.pdfViewer,
  2692. pdfThumbnailViewer = this.pdfThumbnailViewer;
  2693. var pageNumber = pdfViewer.currentPageNumber;
  2694. var newRotation = (pdfViewer.pagesRotation + 360 + delta) % 360;
  2695. pdfViewer.pagesRotation = newRotation;
  2696. pdfThumbnailViewer.pagesRotation = newRotation;
  2697. this.forceRendering();
  2698. pdfViewer.currentPageNumber = pageNumber;
  2699. },
  2700. requestPresentationMode: function requestPresentationMode() {
  2701. if (!this.pdfPresentationMode) {
  2702. return;
  2703. }
  2704. this.pdfPresentationMode.request();
  2705. },
  2706. bindEvents: function bindEvents() {
  2707. var eventBus = this.eventBus,
  2708. _boundEvents = this._boundEvents;
  2709. _boundEvents.beforePrint = this.beforePrint.bind(this);
  2710. _boundEvents.afterPrint = this.afterPrint.bind(this);
  2711. eventBus.on('resize', webViewerResize);
  2712. eventBus.on('hashchange', webViewerHashchange);
  2713. eventBus.on('beforeprint', _boundEvents.beforePrint);
  2714. eventBus.on('afterprint', _boundEvents.afterPrint);
  2715. eventBus.on('pagerendered', webViewerPageRendered);
  2716. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  2717. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  2718. eventBus.on('pagechanging', webViewerPageChanging);
  2719. eventBus.on('scalechanging', webViewerScaleChanging);
  2720. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  2721. eventBus.on('pagemode', webViewerPageMode);
  2722. eventBus.on('namedaction', webViewerNamedAction);
  2723. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  2724. eventBus.on('presentationmode', webViewerPresentationMode);
  2725. eventBus.on('openfile', webViewerOpenFile);
  2726. eventBus.on('print', webViewerPrint);
  2727. eventBus.on('download', webViewerDownload);
  2728. eventBus.on('firstpage', webViewerFirstPage);
  2729. eventBus.on('lastpage', webViewerLastPage);
  2730. eventBus.on('nextpage', webViewerNextPage);
  2731. eventBus.on('previouspage', webViewerPreviousPage);
  2732. eventBus.on('zoomin', webViewerZoomIn);
  2733. eventBus.on('zoomout', webViewerZoomOut);
  2734. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  2735. eventBus.on('scalechanged', webViewerScaleChanged);
  2736. eventBus.on('rotatecw', webViewerRotateCw);
  2737. eventBus.on('rotateccw', webViewerRotateCcw);
  2738. eventBus.on('documentproperties', webViewerDocumentProperties);
  2739. eventBus.on('find', webViewerFind);
  2740. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  2741. eventBus.on('fileinputchange', webViewerFileInputChange);
  2742. },
  2743. bindWindowEvents: function bindWindowEvents() {
  2744. var eventBus = this.eventBus,
  2745. _boundEvents = this._boundEvents;
  2746. _boundEvents.windowResize = function () {
  2747. eventBus.dispatch('resize');
  2748. };
  2749. _boundEvents.windowHashChange = function () {
  2750. eventBus.dispatch('hashchange', { hash: document.location.hash.substring(1) });
  2751. };
  2752. _boundEvents.windowBeforePrint = function () {
  2753. eventBus.dispatch('beforeprint');
  2754. };
  2755. _boundEvents.windowAfterPrint = function () {
  2756. eventBus.dispatch('afterprint');
  2757. };
  2758. window.addEventListener('wheel', webViewerWheel);
  2759. window.addEventListener('click', webViewerClick);
  2760. window.addEventListener('keydown', webViewerKeyDown);
  2761. window.addEventListener('resize', _boundEvents.windowResize);
  2762. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  2763. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  2764. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  2765. _boundEvents.windowChange = function (evt) {
  2766. var files = evt.target.files;
  2767. if (!files || files.length === 0) {
  2768. return;
  2769. }
  2770. eventBus.dispatch('fileinputchange', { fileInput: evt.target });
  2771. };
  2772. window.addEventListener('change', _boundEvents.windowChange);
  2773. },
  2774. unbindEvents: function unbindEvents() {
  2775. var eventBus = this.eventBus,
  2776. _boundEvents = this._boundEvents;
  2777. eventBus.off('resize', webViewerResize);
  2778. eventBus.off('hashchange', webViewerHashchange);
  2779. eventBus.off('beforeprint', _boundEvents.beforePrint);
  2780. eventBus.off('afterprint', _boundEvents.afterPrint);
  2781. eventBus.off('pagerendered', webViewerPageRendered);
  2782. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  2783. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  2784. eventBus.off('pagechanging', webViewerPageChanging);
  2785. eventBus.off('scalechanging', webViewerScaleChanging);
  2786. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  2787. eventBus.off('pagemode', webViewerPageMode);
  2788. eventBus.off('namedaction', webViewerNamedAction);
  2789. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  2790. eventBus.off('presentationmode', webViewerPresentationMode);
  2791. eventBus.off('openfile', webViewerOpenFile);
  2792. eventBus.off('print', webViewerPrint);
  2793. eventBus.off('download', webViewerDownload);
  2794. eventBus.off('firstpage', webViewerFirstPage);
  2795. eventBus.off('lastpage', webViewerLastPage);
  2796. eventBus.off('nextpage', webViewerNextPage);
  2797. eventBus.off('previouspage', webViewerPreviousPage);
  2798. eventBus.off('zoomin', webViewerZoomIn);
  2799. eventBus.off('zoomout', webViewerZoomOut);
  2800. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  2801. eventBus.off('scalechanged', webViewerScaleChanged);
  2802. eventBus.off('rotatecw', webViewerRotateCw);
  2803. eventBus.off('rotateccw', webViewerRotateCcw);
  2804. eventBus.off('documentproperties', webViewerDocumentProperties);
  2805. eventBus.off('find', webViewerFind);
  2806. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  2807. eventBus.off('fileinputchange', webViewerFileInputChange);
  2808. _boundEvents.beforePrint = null;
  2809. _boundEvents.afterPrint = null;
  2810. },
  2811. unbindWindowEvents: function unbindWindowEvents() {
  2812. var _boundEvents = this._boundEvents;
  2813. window.removeEventListener('wheel', webViewerWheel);
  2814. window.removeEventListener('click', webViewerClick);
  2815. window.removeEventListener('keydown', webViewerKeyDown);
  2816. window.removeEventListener('resize', _boundEvents.windowResize);
  2817. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  2818. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  2819. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  2820. window.removeEventListener('change', _boundEvents.windowChange);
  2821. _boundEvents.windowChange = null;
  2822. _boundEvents.windowResize = null;
  2823. _boundEvents.windowHashChange = null;
  2824. _boundEvents.windowBeforePrint = null;
  2825. _boundEvents.windowAfterPrint = null;
  2826. }
  2827. };
  2828. var validateFileURL = void 0;
  2829. {
  2830. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  2831. validateFileURL = function validateFileURL(file) {
  2832. if (file === undefined) {
  2833. return;
  2834. }
  2835. try {
  2836. var viewerOrigin = new URL(window.location.href).origin || 'null';
  2837. if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) {
  2838. return;
  2839. }
  2840. var fileOrigin = new URL(file, window.location.href).origin;
  2841. if (fileOrigin !== viewerOrigin) {
  2842. throw new Error('file origin does not match viewer\'s');
  2843. }
  2844. } catch (ex) {
  2845. var message = ex && ex.message;
  2846. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
  2847. PDFViewerApplication.error(loadingErrorMessage, { message: message });
  2848. });
  2849. throw ex;
  2850. }
  2851. };
  2852. }
  2853. function loadAndEnablePDFBug(enabledTabs) {
  2854. return new Promise(function (resolve, reject) {
  2855. var appConfig = PDFViewerApplication.appConfig;
  2856. var script = document.createElement('script');
  2857. script.src = appConfig.debuggerScriptPath;
  2858. script.onload = function () {
  2859. PDFBug.enable(enabledTabs);
  2860. PDFBug.init({
  2861. PDFJS: _pdfjsLib.PDFJS,
  2862. OPS: _pdfjsLib.OPS
  2863. }, appConfig.mainContainer);
  2864. resolve();
  2865. };
  2866. script.onerror = function () {
  2867. reject(new Error('Cannot load debugger at ' + script.src));
  2868. };
  2869. (document.getElementsByTagName('head')[0] || document.body).appendChild(script);
  2870. });
  2871. }
  2872. function webViewerInitialized() {
  2873. var appConfig = PDFViewerApplication.appConfig;
  2874. var file = void 0;
  2875. var queryString = document.location.search.substring(1);
  2876. var params = (0, _ui_utils.parseQueryString)(queryString);
  2877. file = 'file' in params ? params.file : appConfig.defaultUrl;
  2878. validateFileURL(file);
  2879. var waitForBeforeOpening = [];
  2880. var fileInput = document.createElement('input');
  2881. fileInput.id = appConfig.openFileInputName;
  2882. fileInput.className = 'fileInput';
  2883. fileInput.setAttribute('type', 'file');
  2884. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  2885. document.body.appendChild(fileInput);
  2886. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  2887. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  2888. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
  2889. } else {
  2890. fileInput.value = null;
  2891. }
  2892. if (PDFViewerApplication.viewerPrefs['pdfBugEnabled']) {
  2893. var hash = document.location.hash.substring(1);
  2894. var hashParams = (0, _ui_utils.parseQueryString)(hash);
  2895. if ('disableworker' in hashParams) {
  2896. pdfjsLib.PDFJS.disableWorker = hashParams['disableworker'] === 'true';
  2897. }
  2898. if ('disablerange' in hashParams) {
  2899. _pdfjsLib.PDFJS.disableRange = hashParams['disablerange'] === 'true';
  2900. }
  2901. if ('disablestream' in hashParams) {
  2902. _pdfjsLib.PDFJS.disableStream = hashParams['disablestream'] === 'true';
  2903. }
  2904. if ('disableautofetch' in hashParams) {
  2905. _pdfjsLib.PDFJS.disableAutoFetch = hashParams['disableautofetch'] === 'true';
  2906. }
  2907. if ('disablefontface' in hashParams) {
  2908. _pdfjsLib.PDFJS.disableFontFace = hashParams['disablefontface'] === 'true';
  2909. }
  2910. if ('disablehistory' in hashParams) {
  2911. _pdfjsLib.PDFJS.disableHistory = hashParams['disablehistory'] === 'true';
  2912. }
  2913. if ('webgl' in hashParams) {
  2914. _pdfjsLib.PDFJS.disableWebGL = hashParams['webgl'] !== 'true';
  2915. }
  2916. if ('useonlycsszoom' in hashParams) {
  2917. _pdfjsLib.PDFJS.useOnlyCssZoom = hashParams['useonlycsszoom'] === 'true';
  2918. }
  2919. if ('verbosity' in hashParams) {
  2920. _pdfjsLib.PDFJS.verbosity = hashParams['verbosity'] | 0;
  2921. }
  2922. if ('ignorecurrentpositiononzoom' in hashParams) {
  2923. _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true';
  2924. }
  2925. if ('textlayer' in hashParams) {
  2926. switch (hashParams['textlayer']) {
  2927. case 'off':
  2928. _pdfjsLib.PDFJS.disableTextLayer = true;
  2929. break;
  2930. case 'visible':
  2931. case 'shadow':
  2932. case 'hover':
  2933. var viewer = appConfig.viewerContainer;
  2934. viewer.classList.add('textLayer-' + hashParams['textlayer']);
  2935. break;
  2936. }
  2937. }
  2938. if ('pdfbug' in hashParams) {
  2939. _pdfjsLib.PDFJS.pdfBug = true;
  2940. var pdfBug = hashParams['pdfbug'];
  2941. var enabled = pdfBug.split(',');
  2942. waitForBeforeOpening.push(loadAndEnablePDFBug(enabled));
  2943. }
  2944. }
  2945. if (!PDFViewerApplication.supportsPrinting) {
  2946. appConfig.toolbar.print.classList.add('hidden');
  2947. appConfig.secondaryToolbar.printButton.classList.add('hidden');
  2948. }
  2949. if (!PDFViewerApplication.supportsFullscreen) {
  2950. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  2951. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
  2952. }
  2953. if (PDFViewerApplication.supportsIntegratedFind) {
  2954. appConfig.toolbar.viewFind.classList.add('hidden');
  2955. }
  2956. appConfig.sidebar.mainContainer.addEventListener('transitionend', function (evt) {
  2957. if (evt.target === this) {
  2958. PDFViewerApplication.eventBus.dispatch('resize');
  2959. }
  2960. }, true);
  2961. appConfig.sidebar.toggleButton.addEventListener('click', function () {
  2962. PDFViewerApplication.pdfSidebar.toggle();
  2963. });
  2964. Promise.all(waitForBeforeOpening).then(function () {
  2965. webViewerOpenFileViaURL(file);
  2966. }).catch(function (reason) {
  2967. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while opening.').then(function (msg) {
  2968. PDFViewerApplication.error(msg, reason);
  2969. });
  2970. });
  2971. }
  2972. var webViewerOpenFileViaURL = void 0;
  2973. {
  2974. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  2975. if (file && file.lastIndexOf('file:', 0) === 0) {
  2976. PDFViewerApplication.setTitleUsingUrl(file);
  2977. var xhr = new XMLHttpRequest();
  2978. xhr.onload = function () {
  2979. PDFViewerApplication.open(new Uint8Array(xhr.response));
  2980. };
  2981. try {
  2982. xhr.open('GET', file);
  2983. xhr.responseType = 'arraybuffer';
  2984. xhr.send();
  2985. } catch (ex) {
  2986. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
  2987. PDFViewerApplication.error(msg, ex);
  2988. });
  2989. }
  2990. return;
  2991. }
  2992. if (file) {
  2993. PDFViewerApplication.open(file);
  2994. }
  2995. };
  2996. }
  2997. function webViewerPageRendered(evt) {
  2998. var pageNumber = evt.pageNumber;
  2999. var pageIndex = pageNumber - 1;
  3000. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  3001. if (pageNumber === PDFViewerApplication.page) {
  3002. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  3003. }
  3004. if (!pageView) {
  3005. return;
  3006. }
  3007. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  3008. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  3009. thumbnailView.setImage(pageView);
  3010. }
  3011. if (_pdfjsLib.PDFJS.pdfBug && Stats.enabled && pageView.stats) {
  3012. Stats.add(pageNumber, pageView.stats);
  3013. }
  3014. if (pageView.error) {
  3015. PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
  3016. PDFViewerApplication.error(msg, pageView.error);
  3017. });
  3018. }
  3019. }
  3020. function webViewerTextLayerRendered(evt) { }
  3021. function webViewerPageMode(evt) {
  3022. var mode = evt.mode,
  3023. view = void 0;
  3024. switch (mode) {
  3025. case 'thumbs':
  3026. view = _pdf_sidebar.SidebarView.THUMBS;
  3027. break;
  3028. case 'bookmarks':
  3029. case 'outline':
  3030. view = _pdf_sidebar.SidebarView.OUTLINE;
  3031. break;
  3032. case 'attachments':
  3033. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  3034. break;
  3035. case 'none':
  3036. view = _pdf_sidebar.SidebarView.NONE;
  3037. break;
  3038. default:
  3039. console.error('Invalid "pagemode" hash parameter: ' + mode);
  3040. return;
  3041. }
  3042. PDFViewerApplication.pdfSidebar.switchView(view, true);
  3043. }
  3044. function webViewerNamedAction(evt) {
  3045. var action = evt.action;
  3046. switch (action) {
  3047. case 'GoToPage':
  3048. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3049. break;
  3050. case 'Find':
  3051. if (!PDFViewerApplication.supportsIntegratedFind) {
  3052. PDFViewerApplication.findBar.toggle();
  3053. }
  3054. break;
  3055. }
  3056. }
  3057. function webViewerPresentationModeChanged(evt) {
  3058. var active = evt.active,
  3059. switchInProgress = evt.switchInProgress;
  3060. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _pdf_viewer.PresentationModeState.CHANGING : active ? _pdf_viewer.PresentationModeState.FULLSCREEN : _pdf_viewer.PresentationModeState.NORMAL;
  3061. }
  3062. function webViewerSidebarViewChanged(evt) {
  3063. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  3064. var store = PDFViewerApplication.store;
  3065. if (store && PDFViewerApplication.isInitialViewSet) {
  3066. store.set('sidebarView', evt.view).catch(function () { });
  3067. }
  3068. }
  3069. function webViewerUpdateViewarea(evt) {
  3070. var location = evt.location,
  3071. store = PDFViewerApplication.store;
  3072. if (store && PDFViewerApplication.isInitialViewSet) {
  3073. store.setMultiple({
  3074. 'exists': true,
  3075. 'page': location.pageNumber,
  3076. 'zoom': location.scale,
  3077. 'scrollLeft': location.left,
  3078. 'scrollTop': location.top
  3079. }).catch(function () { });
  3080. }
  3081. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  3082. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  3083. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  3084. PDFViewerApplication.pdfHistory.updateCurrentBookmark(location.pdfOpenParams, location.pageNumber);
  3085. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  3086. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  3087. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  3088. }
  3089. function webViewerResize() {
  3090. var pdfDocument = PDFViewerApplication.pdfDocument,
  3091. pdfViewer = PDFViewerApplication.pdfViewer;
  3092. if (!pdfDocument) {
  3093. return;
  3094. }
  3095. var currentScaleValue = pdfViewer.currentScaleValue;
  3096. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
  3097. pdfViewer.currentScaleValue = currentScaleValue;
  3098. }
  3099. pdfViewer.update();
  3100. }
  3101. function webViewerHashchange(evt) {
  3102. if (PDFViewerApplication.pdfHistory.isHashChangeUnlocked) {
  3103. var hash = evt.hash;
  3104. if (!hash) {
  3105. return;
  3106. }
  3107. if (!PDFViewerApplication.isInitialViewSet) {
  3108. PDFViewerApplication.initialBookmark = hash;
  3109. } else {
  3110. PDFViewerApplication.pdfLinkService.setHash(hash);
  3111. }
  3112. }
  3113. }
  3114. var webViewerFileInputChange = void 0;
  3115. {
  3116. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  3117. var file = evt.fileInput.files[0];
  3118. if (!_pdfjsLib.PDFJS.disableCreateObjectURL && URL.createObjectURL) {
  3119. PDFViewerApplication.open(URL.createObjectURL(file));
  3120. } else {
  3121. var fileReader = new FileReader();
  3122. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  3123. var buffer = evt.target.result;
  3124. PDFViewerApplication.open(new Uint8Array(buffer));
  3125. };
  3126. fileReader.readAsArrayBuffer(file);
  3127. }
  3128. PDFViewerApplication.setTitleUsingUrl(file.name);
  3129. var appConfig = PDFViewerApplication.appConfig;
  3130. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  3131. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  3132. appConfig.toolbar.download.setAttribute('hidden', 'true');
  3133. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
  3134. };
  3135. }
  3136. function webViewerPresentationMode() {
  3137. PDFViewerApplication.requestPresentationMode();
  3138. }
  3139. function webViewerOpenFile() {
  3140. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  3141. document.getElementById(openFileInputName).click();
  3142. }
  3143. function webViewerPrint() {
  3144. window.print();
  3145. }
  3146. function webViewerDownload() {
  3147. PDFViewerApplication.download();
  3148. }
  3149. function webViewerFirstPage() {
  3150. if (PDFViewerApplication.pdfDocument) {
  3151. PDFViewerApplication.page = 1;
  3152. }
  3153. }
  3154. function webViewerLastPage() {
  3155. if (PDFViewerApplication.pdfDocument) {
  3156. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3157. }
  3158. }
  3159. function webViewerNextPage() {
  3160. PDFViewerApplication.page++;
  3161. }
  3162. function webViewerPreviousPage() {
  3163. PDFViewerApplication.page--;
  3164. }
  3165. function webViewerZoomIn() {
  3166. PDFViewerApplication.zoomIn();
  3167. }
  3168. function webViewerZoomOut() {
  3169. PDFViewerApplication.zoomOut();
  3170. }
  3171. function webViewerPageNumberChanged(evt) {
  3172. var pdfViewer = PDFViewerApplication.pdfViewer;
  3173. pdfViewer.currentPageLabel = evt.value;
  3174. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  3175. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  3176. }
  3177. }
  3178. function webViewerScaleChanged(evt) {
  3179. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  3180. }
  3181. function webViewerRotateCw() {
  3182. PDFViewerApplication.rotatePages(90);
  3183. }
  3184. function webViewerRotateCcw() {
  3185. PDFViewerApplication.rotatePages(-90);
  3186. }
  3187. function webViewerDocumentProperties() {
  3188. PDFViewerApplication.pdfDocumentProperties.open();
  3189. }
  3190. function webViewerFind(evt) {
  3191. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  3192. query: evt.query,
  3193. phraseSearch: evt.phraseSearch,
  3194. caseSensitive: evt.caseSensitive,
  3195. highlightAll: evt.highlightAll,
  3196. findPrevious: evt.findPrevious
  3197. });
  3198. }
  3199. function webViewerFindFromUrlHash(evt) {
  3200. PDFViewerApplication.findController.executeCommand('find', {
  3201. query: evt.query,
  3202. phraseSearch: evt.phraseSearch,
  3203. caseSensitive: false,
  3204. highlightAll: true,
  3205. findPrevious: false
  3206. });
  3207. }
  3208. function webViewerScaleChanging(evt) {
  3209. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  3210. PDFViewerApplication.pdfViewer.update();
  3211. }
  3212. function webViewerPageChanging(evt) {
  3213. var page = evt.pageNumber;
  3214. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  3215. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  3216. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  3217. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  3218. }
  3219. if (_pdfjsLib.PDFJS.pdfBug && Stats.enabled) {
  3220. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  3221. if (pageView.stats) {
  3222. Stats.add(page, pageView.stats);
  3223. }
  3224. }
  3225. }
  3226. var zoomDisabled = false,
  3227. zoomDisabledTimeout = void 0;
  3228. function webViewerWheel(evt) {
  3229. var pdfViewer = PDFViewerApplication.pdfViewer;
  3230. if (pdfViewer.isInPresentationMode) {
  3231. return;
  3232. }
  3233. if (evt.ctrlKey || evt.metaKey) {
  3234. var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  3235. if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
  3236. return;
  3237. }
  3238. evt.preventDefault();
  3239. if (zoomDisabled) {
  3240. return;
  3241. }
  3242. var previousScale = pdfViewer.currentScale;
  3243. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  3244. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  3245. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  3246. if (ticks < 0) {
  3247. PDFViewerApplication.zoomOut(-ticks);
  3248. } else {
  3249. PDFViewerApplication.zoomIn(ticks);
  3250. }
  3251. var currentScale = pdfViewer.currentScale;
  3252. if (previousScale !== currentScale) {
  3253. var scaleCorrectionFactor = currentScale / previousScale - 1;
  3254. var rect = pdfViewer.container.getBoundingClientRect();
  3255. var dx = evt.clientX - rect.left;
  3256. var dy = evt.clientY - rect.top;
  3257. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  3258. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  3259. }
  3260. } else {
  3261. zoomDisabled = true;
  3262. clearTimeout(zoomDisabledTimeout);
  3263. zoomDisabledTimeout = setTimeout(function () {
  3264. zoomDisabled = false;
  3265. }, 1000);
  3266. }
  3267. }
  3268. function webViewerClick(evt) {
  3269. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  3270. return;
  3271. }
  3272. var appConfig = PDFViewerApplication.appConfig;
  3273. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  3274. PDFViewerApplication.secondaryToolbar.close();
  3275. }
  3276. }
  3277. function webViewerKeyDown(evt) {
  3278. if (PDFViewerApplication.overlayManager.active) {
  3279. return;
  3280. }
  3281. var handled = false,
  3282. ensureViewerFocused = false;
  3283. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  3284. var pdfViewer = PDFViewerApplication.pdfViewer;
  3285. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  3286. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  3287. switch (evt.keyCode) {
  3288. case 70:
  3289. if (!PDFViewerApplication.supportsIntegratedFind) {
  3290. PDFViewerApplication.findBar.open();
  3291. handled = true;
  3292. }
  3293. break;
  3294. case 71:
  3295. if (!PDFViewerApplication.supportsIntegratedFind) {
  3296. var findState = PDFViewerApplication.findController.state;
  3297. if (findState) {
  3298. PDFViewerApplication.findController.executeCommand('findagain', {
  3299. query: findState.query,
  3300. phraseSearch: findState.phraseSearch,
  3301. caseSensitive: findState.caseSensitive,
  3302. highlightAll: findState.highlightAll,
  3303. findPrevious: cmd === 5 || cmd === 12
  3304. });
  3305. }
  3306. handled = true;
  3307. }
  3308. break;
  3309. case 61:
  3310. case 107:
  3311. case 187:
  3312. case 171:
  3313. if (!isViewerInPresentationMode) {
  3314. PDFViewerApplication.zoomIn();
  3315. }
  3316. handled = true;
  3317. break;
  3318. case 173:
  3319. case 109:
  3320. case 189:
  3321. if (!isViewerInPresentationMode) {
  3322. PDFViewerApplication.zoomOut();
  3323. }
  3324. handled = true;
  3325. break;
  3326. case 48:
  3327. case 96:
  3328. if (!isViewerInPresentationMode) {
  3329. setTimeout(function () {
  3330. pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  3331. });
  3332. handled = false;
  3333. }
  3334. break;
  3335. case 38:
  3336. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3337. PDFViewerApplication.page = 1;
  3338. handled = true;
  3339. ensureViewerFocused = true;
  3340. }
  3341. break;
  3342. case 40:
  3343. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3344. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3345. handled = true;
  3346. ensureViewerFocused = true;
  3347. }
  3348. break;
  3349. }
  3350. }
  3351. if (cmd === 1 || cmd === 8) {
  3352. switch (evt.keyCode) {
  3353. case 83:
  3354. PDFViewerApplication.download();
  3355. handled = true;
  3356. break;
  3357. }
  3358. }
  3359. if (cmd === 3 || cmd === 10) {
  3360. switch (evt.keyCode) {
  3361. case 80:
  3362. PDFViewerApplication.requestPresentationMode();
  3363. handled = true;
  3364. break;
  3365. case 71:
  3366. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3367. handled = true;
  3368. break;
  3369. }
  3370. }
  3371. if (handled) {
  3372. if (ensureViewerFocused && !isViewerInPresentationMode) {
  3373. pdfViewer.focus();
  3374. }
  3375. evt.preventDefault();
  3376. return;
  3377. }
  3378. var curElement = document.activeElement || document.querySelector(':focus');
  3379. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  3380. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
  3381. if (evt.keyCode !== 27) {
  3382. return;
  3383. }
  3384. }
  3385. if (cmd === 0) {
  3386. switch (evt.keyCode) {
  3387. case 38:
  3388. case 33:
  3389. case 8:
  3390. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  3391. break;
  3392. }
  3393. case 37:
  3394. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3395. break;
  3396. }
  3397. case 75:
  3398. case 80:
  3399. if (PDFViewerApplication.page > 1) {
  3400. PDFViewerApplication.page--;
  3401. }
  3402. handled = true;
  3403. break;
  3404. case 27:
  3405. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  3406. PDFViewerApplication.secondaryToolbar.close();
  3407. handled = true;
  3408. }
  3409. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  3410. PDFViewerApplication.findBar.close();
  3411. handled = true;
  3412. }
  3413. break;
  3414. case 40:
  3415. case 34:
  3416. case 32:
  3417. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  3418. break;
  3419. }
  3420. case 39:
  3421. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3422. break;
  3423. }
  3424. case 74:
  3425. case 78:
  3426. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3427. PDFViewerApplication.page++;
  3428. }
  3429. handled = true;
  3430. break;
  3431. case 36:
  3432. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3433. PDFViewerApplication.page = 1;
  3434. handled = true;
  3435. ensureViewerFocused = true;
  3436. }
  3437. break;
  3438. case 35:
  3439. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3440. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3441. handled = true;
  3442. ensureViewerFocused = true;
  3443. }
  3444. break;
  3445. case 83:
  3446. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  3447. break;
  3448. case 72:
  3449. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  3450. break;
  3451. case 82:
  3452. PDFViewerApplication.rotatePages(90);
  3453. break;
  3454. }
  3455. }
  3456. if (cmd === 4) {
  3457. switch (evt.keyCode) {
  3458. case 32:
  3459. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  3460. break;
  3461. }
  3462. if (PDFViewerApplication.page > 1) {
  3463. PDFViewerApplication.page--;
  3464. }
  3465. handled = true;
  3466. break;
  3467. case 82:
  3468. PDFViewerApplication.rotatePages(-90);
  3469. break;
  3470. }
  3471. }
  3472. if (!handled && !isViewerInPresentationMode) {
  3473. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
  3474. ensureViewerFocused = true;
  3475. }
  3476. }
  3477. if (cmd === 2) {
  3478. switch (evt.keyCode) {
  3479. case 37:
  3480. if (isViewerInPresentationMode) {
  3481. PDFViewerApplication.pdfHistory.back();
  3482. handled = true;
  3483. }
  3484. break;
  3485. case 39:
  3486. if (isViewerInPresentationMode) {
  3487. PDFViewerApplication.pdfHistory.forward();
  3488. handled = true;
  3489. }
  3490. break;
  3491. }
  3492. }
  3493. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  3494. pdfViewer.focus();
  3495. }
  3496. if (handled) {
  3497. evt.preventDefault();
  3498. }
  3499. }
  3500. function apiPageModeToSidebarView(mode) {
  3501. switch (mode) {
  3502. case 'UseNone':
  3503. return _pdf_sidebar.SidebarView.NONE;
  3504. case 'UseThumbs':
  3505. return _pdf_sidebar.SidebarView.THUMBS;
  3506. case 'UseOutlines':
  3507. return _pdf_sidebar.SidebarView.OUTLINE;
  3508. case 'UseAttachments':
  3509. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  3510. case 'UseOC':
  3511. }
  3512. return _pdf_sidebar.SidebarView.NONE;
  3513. }
  3514. var PDFPrintServiceFactory = {
  3515. instance: {
  3516. supportsPrinting: false,
  3517. createPrintService: function createPrintService() {
  3518. throw new Error('Not implemented: createPrintService');
  3519. }
  3520. }
  3521. };
  3522. exports.PDFViewerApplication = PDFViewerApplication;
  3523. exports.DefaultExternalServices = DefaultExternalServices;
  3524. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  3525. /***/
  3526. }),
  3527. /* 5 */
  3528. /***/ (function (module, exports, __webpack_require__) {
  3529. "use strict";
  3530. Object.defineProperty(exports, "__esModule", {
  3531. value: true
  3532. });
  3533. exports.SimpleLinkService = exports.PDFLinkService = undefined;
  3534. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  3535. 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; }; }();
  3536. var _dom_events = __webpack_require__(2);
  3537. var _ui_utils = __webpack_require__(0);
  3538. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3539. var PDFLinkService = function () {
  3540. function PDFLinkService() {
  3541. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  3542. eventBus = _ref.eventBus;
  3543. _classCallCheck(this, PDFLinkService);
  3544. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  3545. this.baseUrl = null;
  3546. this.pdfDocument = null;
  3547. this.pdfViewer = null;
  3548. this.pdfHistory = null;
  3549. this._pagesRefCache = null;
  3550. }
  3551. _createClass(PDFLinkService, [{
  3552. key: 'setDocument',
  3553. value: function setDocument(pdfDocument, baseUrl) {
  3554. this.baseUrl = baseUrl;
  3555. this.pdfDocument = pdfDocument;
  3556. this._pagesRefCache = Object.create(null);
  3557. }
  3558. }, {
  3559. key: 'setViewer',
  3560. value: function setViewer(pdfViewer) {
  3561. this.pdfViewer = pdfViewer;
  3562. }
  3563. }, {
  3564. key: 'setHistory',
  3565. value: function setHistory(pdfHistory) {
  3566. this.pdfHistory = pdfHistory;
  3567. }
  3568. }, {
  3569. key: 'navigateTo',
  3570. value: function navigateTo(dest) {
  3571. var _this = this;
  3572. var goToDestination = function goToDestination(_ref2) {
  3573. var namedDest = _ref2.namedDest,
  3574. explicitDest = _ref2.explicitDest;
  3575. var destRef = explicitDest[0],
  3576. pageNumber = void 0;
  3577. if (destRef instanceof Object) {
  3578. pageNumber = _this._cachedPageNumber(destRef);
  3579. if (pageNumber === null) {
  3580. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  3581. _this.cachePageRef(pageIndex + 1, destRef);
  3582. goToDestination({
  3583. namedDest: namedDest,
  3584. explicitDest: explicitDest
  3585. });
  3586. }).catch(function () {
  3587. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'));
  3588. });
  3589. return;
  3590. }
  3591. } else if ((destRef | 0) === destRef) {
  3592. pageNumber = destRef + 1;
  3593. } else {
  3594. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));
  3595. return;
  3596. }
  3597. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  3598. console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));
  3599. return;
  3600. }
  3601. _this.pdfViewer.scrollPageIntoView({
  3602. pageNumber: pageNumber,
  3603. destArray: explicitDest
  3604. });
  3605. if (_this.pdfHistory) {
  3606. _this.pdfHistory.push({
  3607. dest: explicitDest,
  3608. hash: namedDest,
  3609. page: pageNumber
  3610. });
  3611. }
  3612. };
  3613. new Promise(function (resolve, reject) {
  3614. if (typeof dest === 'string') {
  3615. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  3616. resolve({
  3617. namedDest: dest,
  3618. explicitDest: destArray
  3619. });
  3620. });
  3621. return;
  3622. }
  3623. resolve({
  3624. namedDest: '',
  3625. explicitDest: dest
  3626. });
  3627. }).then(function (data) {
  3628. if (!(data.explicitDest instanceof Array)) {
  3629. console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));
  3630. return;
  3631. }
  3632. goToDestination(data);
  3633. });
  3634. }
  3635. }, {
  3636. key: 'getDestinationHash',
  3637. value: function getDestinationHash(dest) {
  3638. if (typeof dest === 'string') {
  3639. return this.getAnchorUrl('#' + escape(dest));
  3640. }
  3641. if (dest instanceof Array) {
  3642. var str = JSON.stringify(dest);
  3643. return this.getAnchorUrl('#' + escape(str));
  3644. }
  3645. return this.getAnchorUrl('');
  3646. }
  3647. }, {
  3648. key: 'getAnchorUrl',
  3649. value: function getAnchorUrl(anchor) {
  3650. return (this.baseUrl || '') + anchor;
  3651. }
  3652. }, {
  3653. key: 'setHash',
  3654. value: function setHash(hash) {
  3655. var pageNumber = void 0,
  3656. dest = void 0;
  3657. if (hash.indexOf('=') >= 0) {
  3658. var params = (0, _ui_utils.parseQueryString)(hash);
  3659. if ('search' in params) {
  3660. this.eventBus.dispatch('findfromurlhash', {
  3661. source: this,
  3662. query: params['search'].replace(/"/g, ''),
  3663. phraseSearch: params['phrase'] === 'true'
  3664. });
  3665. }
  3666. if ('nameddest' in params) {
  3667. if (this.pdfHistory) {
  3668. this.pdfHistory.updateNextHashParam(params.nameddest);
  3669. }
  3670. this.navigateTo(params.nameddest);
  3671. return;
  3672. }
  3673. if ('page' in params) {
  3674. pageNumber = params.page | 0 || 1;
  3675. }
  3676. if ('zoom' in params) {
  3677. var zoomArgs = params.zoom.split(',');
  3678. var zoomArg = zoomArgs[0];
  3679. var zoomArgNumber = parseFloat(zoomArg);
  3680. if (zoomArg.indexOf('Fit') === -1) {
  3681. dest = [null, { name: 'XYZ' }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  3682. } else {
  3683. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  3684. dest = [null, { name: zoomArg }];
  3685. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  3686. dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  3687. } else if (zoomArg === 'FitR') {
  3688. if (zoomArgs.length !== 5) {
  3689. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  3690. } else {
  3691. dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  3692. }
  3693. } else {
  3694. console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.');
  3695. }
  3696. }
  3697. }
  3698. if (dest) {
  3699. this.pdfViewer.scrollPageIntoView({
  3700. pageNumber: pageNumber || this.page,
  3701. destArray: dest,
  3702. allowNegativeOffset: true
  3703. });
  3704. } else if (pageNumber) {
  3705. this.page = pageNumber;
  3706. }
  3707. if ('pagemode' in params) {
  3708. this.eventBus.dispatch('pagemode', {
  3709. source: this,
  3710. mode: params.pagemode
  3711. });
  3712. }
  3713. } else {
  3714. if (/^\d+$/.test(hash) && hash <= this.pagesCount) {
  3715. console.warn('PDFLinkService_setHash: specifying a page number ' + 'directly after the hash symbol (#) is deprecated, ' + ('please use the "#page=' + hash + '" form instead.'));
  3716. this.page = hash | 0;
  3717. }
  3718. dest = unescape(hash);
  3719. try {
  3720. dest = JSON.parse(dest);
  3721. if (!(dest instanceof Array)) {
  3722. dest = dest.toString();
  3723. }
  3724. } catch (ex) { }
  3725. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  3726. if (this.pdfHistory) {
  3727. this.pdfHistory.updateNextHashParam(dest);
  3728. }
  3729. this.navigateTo(dest);
  3730. return;
  3731. }
  3732. console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.');
  3733. }
  3734. }
  3735. }, {
  3736. key: 'executeNamedAction',
  3737. value: function executeNamedAction(action) {
  3738. switch (action) {
  3739. case 'GoBack':
  3740. if (this.pdfHistory) {
  3741. this.pdfHistory.back();
  3742. }
  3743. break;
  3744. case 'GoForward':
  3745. if (this.pdfHistory) {
  3746. this.pdfHistory.forward();
  3747. }
  3748. break;
  3749. case 'NextPage':
  3750. if (this.page < this.pagesCount) {
  3751. this.page++;
  3752. }
  3753. break;
  3754. case 'PrevPage':
  3755. if (this.page > 1) {
  3756. this.page--;
  3757. }
  3758. break;
  3759. case 'LastPage':
  3760. this.page = this.pagesCount;
  3761. break;
  3762. case 'FirstPage':
  3763. this.page = 1;
  3764. break;
  3765. default:
  3766. break;
  3767. }
  3768. this.eventBus.dispatch('namedaction', {
  3769. source: this,
  3770. action: action
  3771. });
  3772. }
  3773. }, {
  3774. key: 'onFileAttachmentAnnotation',
  3775. value: function onFileAttachmentAnnotation(_ref3) {
  3776. var id = _ref3.id,
  3777. filename = _ref3.filename,
  3778. content = _ref3.content;
  3779. this.eventBus.dispatch('fileattachmentannotation', {
  3780. source: this,
  3781. id: id,
  3782. filename: filename,
  3783. content: content
  3784. });
  3785. }
  3786. }, {
  3787. key: 'cachePageRef',
  3788. value: function cachePageRef(pageNum, pageRef) {
  3789. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  3790. this._pagesRefCache[refStr] = pageNum;
  3791. }
  3792. }, {
  3793. key: '_cachedPageNumber',
  3794. value: function _cachedPageNumber(pageRef) {
  3795. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  3796. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  3797. }
  3798. }, {
  3799. key: 'pagesCount',
  3800. get: function get() {
  3801. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  3802. }
  3803. }, {
  3804. key: 'page',
  3805. get: function get() {
  3806. return this.pdfViewer.currentPageNumber;
  3807. },
  3808. set: function set(value) {
  3809. this.pdfViewer.currentPageNumber = value;
  3810. }
  3811. }]);
  3812. return PDFLinkService;
  3813. }();
  3814. function isValidExplicitDestination(dest) {
  3815. if (!(dest instanceof Array)) {
  3816. return false;
  3817. }
  3818. var destLength = dest.length,
  3819. allowNull = true;
  3820. if (destLength < 2) {
  3821. return false;
  3822. }
  3823. var page = dest[0];
  3824. if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && typeof page.num === 'number' && (page.num | 0) === page.num && typeof page.gen === 'number' && (page.gen | 0) === page.gen) && !(typeof page === 'number' && (page | 0) === page && page >= 0)) {
  3825. return false;
  3826. }
  3827. var zoom = dest[1];
  3828. if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
  3829. return false;
  3830. }
  3831. switch (zoom.name) {
  3832. case 'XYZ':
  3833. if (destLength !== 5) {
  3834. return false;
  3835. }
  3836. break;
  3837. case 'Fit':
  3838. case 'FitB':
  3839. return destLength === 2;
  3840. case 'FitH':
  3841. case 'FitBH':
  3842. case 'FitV':
  3843. case 'FitBV':
  3844. if (destLength !== 3) {
  3845. return false;
  3846. }
  3847. break;
  3848. case 'FitR':
  3849. if (destLength !== 6) {
  3850. return false;
  3851. }
  3852. allowNull = false;
  3853. break;
  3854. default:
  3855. return false;
  3856. }
  3857. for (var i = 2; i < destLength; i++) {
  3858. var param = dest[i];
  3859. if (!(typeof param === 'number' || allowNull && param === null)) {
  3860. return false;
  3861. }
  3862. }
  3863. return true;
  3864. }
  3865. var SimpleLinkService = function () {
  3866. function SimpleLinkService() {
  3867. _classCallCheck(this, SimpleLinkService);
  3868. }
  3869. _createClass(SimpleLinkService, [{
  3870. key: 'navigateTo',
  3871. value: function navigateTo(dest) { }
  3872. }, {
  3873. key: 'getDestinationHash',
  3874. value: function getDestinationHash(dest) {
  3875. return '#';
  3876. }
  3877. }, {
  3878. key: 'getAnchorUrl',
  3879. value: function getAnchorUrl(hash) {
  3880. return '#';
  3881. }
  3882. }, {
  3883. key: 'setHash',
  3884. value: function setHash(hash) { }
  3885. }, {
  3886. key: 'executeNamedAction',
  3887. value: function executeNamedAction(action) { }
  3888. }, {
  3889. key: 'onFileAttachmentAnnotation',
  3890. value: function onFileAttachmentAnnotation(_ref4) {
  3891. var id = _ref4.id,
  3892. filename = _ref4.filename,
  3893. content = _ref4.content;
  3894. }
  3895. }, {
  3896. key: 'cachePageRef',
  3897. value: function cachePageRef(pageNum, pageRef) { }
  3898. }, {
  3899. key: 'page',
  3900. get: function get() {
  3901. return 0;
  3902. },
  3903. set: function set(value) { }
  3904. }]);
  3905. return SimpleLinkService;
  3906. }();
  3907. exports.PDFLinkService = PDFLinkService;
  3908. exports.SimpleLinkService = SimpleLinkService;
  3909. /***/
  3910. }),
  3911. /* 6 */
  3912. /***/ (function (module, exports, __webpack_require__) {
  3913. "use strict";
  3914. Object.defineProperty(exports, "__esModule", {
  3915. value: true
  3916. });
  3917. exports.PDFCursorTools = exports.CursorTool = undefined;
  3918. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  3919. 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; }; }();
  3920. var _grab_to_pan = __webpack_require__(14);
  3921. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3922. var CursorTool = {
  3923. SELECT: 0,
  3924. HAND: 1,
  3925. ZOOM: 2
  3926. };
  3927. var PDFCursorTools = function () {
  3928. function PDFCursorTools(_ref) {
  3929. var _this = this;
  3930. var container = _ref.container,
  3931. eventBus = _ref.eventBus,
  3932. preferences = _ref.preferences;
  3933. _classCallCheck(this, PDFCursorTools);
  3934. this.container = container;
  3935. this.eventBus = eventBus;
  3936. this.active = CursorTool.SELECT;
  3937. this.activeBeforePresentationMode = null;
  3938. this.handTool = new _grab_to_pan.GrabToPan({ element: this.container });
  3939. this._addEventListeners();
  3940. Promise.all([preferences.get('cursorToolOnLoad'), preferences.get('enableHandToolOnLoad')]).then(function (_ref2) {
  3941. var _ref3 = _slicedToArray(_ref2, 2),
  3942. cursorToolPref = _ref3[0],
  3943. handToolPref = _ref3[1];
  3944. if (handToolPref === true) {
  3945. preferences.set('enableHandToolOnLoad', false);
  3946. if (cursorToolPref === CursorTool.SELECT) {
  3947. cursorToolPref = CursorTool.HAND;
  3948. preferences.set('cursorToolOnLoad', cursorToolPref).catch(function () { });
  3949. }
  3950. }
  3951. _this.switchTool(cursorToolPref);
  3952. }).catch(function () { });
  3953. }
  3954. _createClass(PDFCursorTools, [{
  3955. key: 'switchTool',
  3956. value: function switchTool(tool) {
  3957. var _this2 = this;
  3958. if (this.activeBeforePresentationMode !== null) {
  3959. return;
  3960. }
  3961. if (tool === this.active) {
  3962. return;
  3963. }
  3964. var disableActiveTool = function disableActiveTool() {
  3965. switch (_this2.active) {
  3966. case CursorTool.SELECT:
  3967. break;
  3968. case CursorTool.HAND:
  3969. _this2.handTool.deactivate();
  3970. break;
  3971. case CursorTool.ZOOM:
  3972. }
  3973. };
  3974. switch (tool) {
  3975. case CursorTool.SELECT:
  3976. disableActiveTool();
  3977. break;
  3978. case CursorTool.HAND:
  3979. disableActiveTool();
  3980. this.handTool.activate();
  3981. break;
  3982. case CursorTool.ZOOM:
  3983. default:
  3984. console.error('switchTool: "' + tool + '" is an unsupported value.');
  3985. return;
  3986. }
  3987. this.active = tool;
  3988. this._dispatchEvent();
  3989. }
  3990. }, {
  3991. key: '_dispatchEvent',
  3992. value: function _dispatchEvent() {
  3993. this.eventBus.dispatch('cursortoolchanged', {
  3994. source: this,
  3995. tool: this.active
  3996. });
  3997. }
  3998. }, {
  3999. key: '_addEventListeners',
  4000. value: function _addEventListeners() {
  4001. var _this3 = this;
  4002. this.eventBus.on('switchcursortool', function (evt) {
  4003. _this3.switchTool(evt.tool);
  4004. });
  4005. this.eventBus.on('presentationmodechanged', function (evt) {
  4006. if (evt.switchInProgress) {
  4007. return;
  4008. }
  4009. var previouslyActive = void 0;
  4010. if (evt.active) {
  4011. previouslyActive = _this3.active;
  4012. _this3.switchTool(CursorTool.SELECT);
  4013. _this3.activeBeforePresentationMode = previouslyActive;
  4014. } else {
  4015. previouslyActive = _this3.activeBeforePresentationMode;
  4016. _this3.activeBeforePresentationMode = null;
  4017. _this3.switchTool(previouslyActive);
  4018. }
  4019. });
  4020. }
  4021. }, {
  4022. key: 'activeTool',
  4023. get: function get() {
  4024. return this.active;
  4025. }
  4026. }]);
  4027. return PDFCursorTools;
  4028. }();
  4029. exports.CursorTool = CursorTool;
  4030. exports.PDFCursorTools = PDFCursorTools;
  4031. /***/
  4032. }),
  4033. /* 7 */
  4034. /***/ (function (module, exports, __webpack_require__) {
  4035. "use strict";
  4036. Object.defineProperty(exports, "__esModule", {
  4037. value: true
  4038. });
  4039. exports.PDFFindController = exports.FindState = undefined;
  4040. 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; }; }();
  4041. var _pdfjsLib = __webpack_require__(1);
  4042. var _ui_utils = __webpack_require__(0);
  4043. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4044. var FindState = {
  4045. FOUND: 0,
  4046. NOT_FOUND: 1,
  4047. WRAPPED: 2,
  4048. PENDING: 3
  4049. };
  4050. var FIND_SCROLL_OFFSET_TOP = -50;
  4051. var FIND_SCROLL_OFFSET_LEFT = -400;
  4052. var FIND_TIMEOUT = 250;
  4053. var CHARACTERS_TO_NORMALIZE = {
  4054. '\u2018': '\'',
  4055. '\u2019': '\'',
  4056. '\u201A': '\'',
  4057. '\u201B': '\'',
  4058. '\u201C': '"',
  4059. '\u201D': '"',
  4060. '\u201E': '"',
  4061. '\u201F': '"',
  4062. '\xBC': '1/4',
  4063. '\xBD': '1/2',
  4064. '\xBE': '3/4'
  4065. };
  4066. var PDFFindController = function () {
  4067. function PDFFindController(_ref) {
  4068. var pdfViewer = _ref.pdfViewer;
  4069. _classCallCheck(this, PDFFindController);
  4070. this.pdfViewer = pdfViewer;
  4071. this.onUpdateResultsCount = null;
  4072. this.onUpdateState = null;
  4073. this.reset();
  4074. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  4075. this.normalizationRegex = new RegExp('[' + replace + ']', 'g');
  4076. }
  4077. _createClass(PDFFindController, [{
  4078. key: 'reset',
  4079. value: function reset() {
  4080. var _this = this;
  4081. this.startedTextExtraction = false;
  4082. this.extractTextPromises = [];
  4083. this.pendingFindMatches = Object.create(null);
  4084. this.active = false;
  4085. this.pageContents = [];
  4086. this.pageMatches = [];
  4087. this.pageMatchesLength = null;
  4088. this.matchCount = 0;
  4089. this.selected = {
  4090. pageIdx: -1,
  4091. matchIdx: -1
  4092. };
  4093. this.offset = {
  4094. pageIdx: null,
  4095. matchIdx: null
  4096. };
  4097. this.pagesToSearch = null;
  4098. this.resumePageIdx = null;
  4099. this.state = null;
  4100. this.dirtyMatch = false;
  4101. this.findTimeout = null;
  4102. this._firstPagePromise = new Promise(function (resolve) {
  4103. _this.resolveFirstPage = resolve;
  4104. });
  4105. }
  4106. }, {
  4107. key: 'normalize',
  4108. value: function normalize(text) {
  4109. return text.replace(this.normalizationRegex, function (ch) {
  4110. return CHARACTERS_TO_NORMALIZE[ch];
  4111. });
  4112. }
  4113. }, {
  4114. key: '_prepareMatches',
  4115. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  4116. function isSubTerm(matchesWithLength, currentIndex) {
  4117. var currentElem = matchesWithLength[currentIndex];
  4118. var nextElem = matchesWithLength[currentIndex + 1];
  4119. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  4120. currentElem.skipped = true;
  4121. return true;
  4122. }
  4123. for (var i = currentIndex - 1; i >= 0; i--) {
  4124. var prevElem = matchesWithLength[i];
  4125. if (prevElem.skipped) {
  4126. continue;
  4127. }
  4128. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  4129. break;
  4130. }
  4131. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  4132. currentElem.skipped = true;
  4133. return true;
  4134. }
  4135. }
  4136. return false;
  4137. }
  4138. matchesWithLength.sort(function (a, b) {
  4139. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  4140. });
  4141. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  4142. if (isSubTerm(matchesWithLength, i)) {
  4143. continue;
  4144. }
  4145. matches.push(matchesWithLength[i].match);
  4146. matchesLength.push(matchesWithLength[i].matchLength);
  4147. }
  4148. }
  4149. }, {
  4150. key: 'calcFindPhraseMatch',
  4151. value: function calcFindPhraseMatch(query, pageIndex, pageContent) {
  4152. var matches = [];
  4153. var queryLen = query.length;
  4154. var matchIdx = -queryLen;
  4155. while (true) {
  4156. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  4157. if (matchIdx === -1) {
  4158. break;
  4159. }
  4160. matches.push(matchIdx);
  4161. }
  4162. this.pageMatches[pageIndex] = matches;
  4163. }
  4164. }, {
  4165. key: 'calcFindWordMatch',
  4166. value: function calcFindWordMatch(query, pageIndex, pageContent) {
  4167. var matchesWithLength = [];
  4168. var queryArray = query.match(/\S+/g);
  4169. for (var i = 0, len = queryArray.length; i < len; i++) {
  4170. var subquery = queryArray[i];
  4171. var subqueryLen = subquery.length;
  4172. var matchIdx = -subqueryLen;
  4173. while (true) {
  4174. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  4175. if (matchIdx === -1) {
  4176. break;
  4177. }
  4178. matchesWithLength.push({
  4179. match: matchIdx,
  4180. matchLength: subqueryLen,
  4181. skipped: false
  4182. });
  4183. }
  4184. }
  4185. if (!this.pageMatchesLength) {
  4186. this.pageMatchesLength = [];
  4187. }
  4188. this.pageMatchesLength[pageIndex] = [];
  4189. this.pageMatches[pageIndex] = [];
  4190. this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex]);
  4191. }
  4192. }, {
  4193. key: 'calcFindMatch',
  4194. value: function calcFindMatch(pageIndex) {
  4195. var pageContent = this.normalize(this.pageContents[pageIndex]);
  4196. var query = this.normalize(this.state.query);
  4197. var caseSensitive = this.state.caseSensitive;
  4198. var phraseSearch = this.state.phraseSearch;
  4199. var queryLen = query.length;
  4200. if (queryLen === 0) {
  4201. return;
  4202. }
  4203. if (!caseSensitive) {
  4204. pageContent = pageContent.toLowerCase();
  4205. query = query.toLowerCase();
  4206. }
  4207. if (phraseSearch) {
  4208. this.calcFindPhraseMatch(query, pageIndex, pageContent);
  4209. } else {
  4210. this.calcFindWordMatch(query, pageIndex, pageContent);
  4211. }
  4212. this.updatePage(pageIndex);
  4213. if (this.resumePageIdx === pageIndex) {
  4214. this.resumePageIdx = null;
  4215. this.nextPageMatch();
  4216. }
  4217. if (this.pageMatches[pageIndex].length > 0) {
  4218. this.matchCount += this.pageMatches[pageIndex].length;
  4219. this.updateUIResultsCount();
  4220. }
  4221. }
  4222. }, {
  4223. key: 'extractText',
  4224. value: function extractText() {
  4225. var _this2 = this;
  4226. if (this.startedTextExtraction) {
  4227. return;
  4228. }
  4229. this.startedTextExtraction = true;
  4230. this.pageContents.length = 0;
  4231. var promise = Promise.resolve();
  4232. var _loop = function _loop(i, ii) {
  4233. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  4234. _this2.extractTextPromises[i] = extractTextCapability.promise;
  4235. promise = promise.then(function () {
  4236. return _this2.pdfViewer.getPageTextContent(i).then(function (textContent) {
  4237. var textItems = textContent.items;
  4238. var strBuf = [];
  4239. for (var j = 0, jj = textItems.length; j < jj; j++) {
  4240. strBuf.push(textItems[j].str);
  4241. }
  4242. _this2.pageContents[i] = strBuf.join('');
  4243. extractTextCapability.resolve(i);
  4244. }, function (reason) {
  4245. console.error('Unable to get page ' + (i + 1) + ' text content', reason);
  4246. _this2.pageContents[i] = '';
  4247. extractTextCapability.resolve(i);
  4248. });
  4249. });
  4250. };
  4251. for (var i = 0, ii = this.pdfViewer.pagesCount; i < ii; i++) {
  4252. _loop(i, ii);
  4253. }
  4254. }
  4255. }, {
  4256. key: 'executeCommand',
  4257. value: function executeCommand(cmd, state) {
  4258. var _this3 = this;
  4259. if (this.state === null || cmd !== 'findagain') {
  4260. this.dirtyMatch = true;
  4261. }
  4262. this.state = state;
  4263. this.updateUIState(FindState.PENDING);
  4264. this._firstPagePromise.then(function () {
  4265. _this3.extractText();
  4266. clearTimeout(_this3.findTimeout);
  4267. if (cmd === 'find') {
  4268. _this3.findTimeout = setTimeout(_this3.nextMatch.bind(_this3), FIND_TIMEOUT);
  4269. } else {
  4270. _this3.nextMatch();
  4271. }
  4272. });
  4273. }
  4274. }, {
  4275. key: 'updatePage',
  4276. value: function updatePage(index) {
  4277. if (this.selected.pageIdx === index) {
  4278. this.pdfViewer.currentPageNumber = index + 1;
  4279. }
  4280. var page = this.pdfViewer.getPageView(index);
  4281. if (page.textLayer) {
  4282. page.textLayer.updateMatches();
  4283. }
  4284. }
  4285. }, {
  4286. key: 'nextMatch',
  4287. value: function nextMatch() {
  4288. var _this4 = this;
  4289. var previous = this.state.findPrevious;
  4290. var currentPageIndex = this.pdfViewer.currentPageNumber - 1;
  4291. var numPages = this.pdfViewer.pagesCount;
  4292. this.active = true;
  4293. if (this.dirtyMatch) {
  4294. this.dirtyMatch = false;
  4295. this.selected.pageIdx = this.selected.matchIdx = -1;
  4296. this.offset.pageIdx = currentPageIndex;
  4297. this.offset.matchIdx = null;
  4298. this.hadMatch = false;
  4299. this.resumePageIdx = null;
  4300. this.pageMatches = [];
  4301. this.matchCount = 0;
  4302. this.pageMatchesLength = null;
  4303. for (var i = 0; i < numPages; i++) {
  4304. this.updatePage(i);
  4305. if (!(i in this.pendingFindMatches)) {
  4306. this.pendingFindMatches[i] = true;
  4307. this.extractTextPromises[i].then(function (pageIdx) {
  4308. delete _this4.pendingFindMatches[pageIdx];
  4309. _this4.calcFindMatch(pageIdx);
  4310. });
  4311. }
  4312. }
  4313. }
  4314. if (this.state.query === '') {
  4315. this.updateUIState(FindState.FOUND);
  4316. return;
  4317. }
  4318. if (this.resumePageIdx) {
  4319. return;
  4320. }
  4321. var offset = this.offset;
  4322. this.pagesToSearch = numPages;
  4323. if (offset.matchIdx !== null) {
  4324. var numPageMatches = this.pageMatches[offset.pageIdx].length;
  4325. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  4326. this.hadMatch = true;
  4327. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  4328. this.updateMatch(true);
  4329. return;
  4330. }
  4331. this.advanceOffsetPage(previous);
  4332. }
  4333. this.nextPageMatch();
  4334. }
  4335. }, {
  4336. key: 'matchesReady',
  4337. value: function matchesReady(matches) {
  4338. var offset = this.offset;
  4339. var numMatches = matches.length;
  4340. var previous = this.state.findPrevious;
  4341. if (numMatches) {
  4342. this.hadMatch = true;
  4343. offset.matchIdx = previous ? numMatches - 1 : 0;
  4344. this.updateMatch(true);
  4345. return true;
  4346. }
  4347. this.advanceOffsetPage(previous);
  4348. if (offset.wrapped) {
  4349. offset.matchIdx = null;
  4350. if (this.pagesToSearch < 0) {
  4351. this.updateMatch(false);
  4352. return true;
  4353. }
  4354. }
  4355. return false;
  4356. }
  4357. }, {
  4358. key: 'updateMatchPosition',
  4359. value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
  4360. if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
  4361. var spot = {
  4362. top: FIND_SCROLL_OFFSET_TOP,
  4363. left: FIND_SCROLL_OFFSET_LEFT
  4364. };
  4365. (0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
  4366. }
  4367. }
  4368. }, {
  4369. key: 'nextPageMatch',
  4370. value: function nextPageMatch() {
  4371. if (this.resumePageIdx !== null) {
  4372. console.error('There can only be one pending page.');
  4373. }
  4374. var matches = null;
  4375. do {
  4376. var pageIdx = this.offset.pageIdx;
  4377. matches = this.pageMatches[pageIdx];
  4378. if (!matches) {
  4379. this.resumePageIdx = pageIdx;
  4380. break;
  4381. }
  4382. } while (!this.matchesReady(matches));
  4383. }
  4384. }, {
  4385. key: 'advanceOffsetPage',
  4386. value: function advanceOffsetPage(previous) {
  4387. var offset = this.offset;
  4388. var numPages = this.extractTextPromises.length;
  4389. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  4390. offset.matchIdx = null;
  4391. this.pagesToSearch--;
  4392. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  4393. offset.pageIdx = previous ? numPages - 1 : 0;
  4394. offset.wrapped = true;
  4395. }
  4396. }
  4397. }, {
  4398. key: 'updateMatch',
  4399. value: function updateMatch() {
  4400. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4401. var state = FindState.NOT_FOUND;
  4402. var wrapped = this.offset.wrapped;
  4403. this.offset.wrapped = false;
  4404. if (found) {
  4405. var previousPage = this.selected.pageIdx;
  4406. this.selected.pageIdx = this.offset.pageIdx;
  4407. this.selected.matchIdx = this.offset.matchIdx;
  4408. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  4409. if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
  4410. this.updatePage(previousPage);
  4411. }
  4412. }
  4413. this.updateUIState(state, this.state.findPrevious);
  4414. if (this.selected.pageIdx !== -1) {
  4415. this.updatePage(this.selected.pageIdx);
  4416. }
  4417. }
  4418. }, {
  4419. key: 'updateUIResultsCount',
  4420. value: function updateUIResultsCount() {
  4421. if (this.onUpdateResultsCount) {
  4422. this.onUpdateResultsCount(this.matchCount);
  4423. }
  4424. }
  4425. }, {
  4426. key: 'updateUIState',
  4427. value: function updateUIState(state, previous) {
  4428. if (this.onUpdateState) {
  4429. this.onUpdateState(state, previous, this.matchCount);
  4430. }
  4431. }
  4432. }]);
  4433. return PDFFindController;
  4434. }();
  4435. exports.FindState = FindState;
  4436. exports.PDFFindController = PDFFindController;
  4437. /***/
  4438. }),
  4439. /* 8 */
  4440. /***/ (function (module, exports, __webpack_require__) {
  4441. "use strict";
  4442. Object.defineProperty(exports, "__esModule", {
  4443. value: true
  4444. });
  4445. exports.GenericCom = undefined;
  4446. 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; }; }();
  4447. var _app = __webpack_require__(4);
  4448. var _preferences = __webpack_require__(28);
  4449. var _download_manager = __webpack_require__(12);
  4450. var _genericl10n = __webpack_require__(13);
  4451. var _pdfjsLib = __webpack_require__(1);
  4452. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4453. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4454. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4455. ;
  4456. var GenericCom = {};
  4457. var GenericPreferences = function (_BasePreferences) {
  4458. _inherits(GenericPreferences, _BasePreferences);
  4459. function GenericPreferences() {
  4460. _classCallCheck(this, GenericPreferences);
  4461. return _possibleConstructorReturn(this, (GenericPreferences.__proto__ || Object.getPrototypeOf(GenericPreferences)).apply(this, arguments));
  4462. }
  4463. _createClass(GenericPreferences, [{
  4464. key: '_writeToStorage',
  4465. value: function _writeToStorage(prefObj) {
  4466. return new Promise(function (resolve) {
  4467. localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
  4468. resolve();
  4469. });
  4470. }
  4471. }, {
  4472. key: '_readFromStorage',
  4473. value: function _readFromStorage(prefObj) {
  4474. return new Promise(function (resolve) {
  4475. var readPrefs = JSON.parse(localStorage.getItem('pdfjs.preferences'));
  4476. resolve(readPrefs);
  4477. });
  4478. }
  4479. }]);
  4480. return GenericPreferences;
  4481. }(_preferences.BasePreferences);
  4482. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  4483. GenericExternalServices.createDownloadManager = function () {
  4484. return new _download_manager.DownloadManager();
  4485. };
  4486. GenericExternalServices.createPreferences = function () {
  4487. return new GenericPreferences();
  4488. };
  4489. GenericExternalServices.createL10n = function () {
  4490. return new _genericl10n.GenericL10n(_pdfjsLib.PDFJS.locale);
  4491. };
  4492. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  4493. exports.GenericCom = GenericCom;
  4494. /***/
  4495. }),
  4496. /* 9 */
  4497. /***/ (function (module, exports, __webpack_require__) {
  4498. "use strict";
  4499. Object.defineProperty(exports, "__esModule", {
  4500. value: true
  4501. });
  4502. exports.PDFPrintService = undefined;
  4503. var _ui_utils = __webpack_require__(0);
  4504. var _app = __webpack_require__(4);
  4505. var _pdfjsLib = __webpack_require__(1);
  4506. var activeService = null;
  4507. var overlayManager = null;
  4508. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  4509. var scratchCanvas = activeService.scratchCanvas;
  4510. var PRINT_RESOLUTION = 150;
  4511. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  4512. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  4513. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  4514. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  4515. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  4516. var ctx = scratchCanvas.getContext('2d');
  4517. ctx.save();
  4518. ctx.fillStyle = 'rgb(255, 255, 255)';
  4519. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  4520. ctx.restore();
  4521. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  4522. var renderContext = {
  4523. canvasContext: ctx,
  4524. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  4525. viewport: pdfPage.getViewport(1, size.rotation),
  4526. intent: 'print'
  4527. };
  4528. return pdfPage.render(renderContext).promise;
  4529. }).then(function () {
  4530. return {
  4531. width: width,
  4532. height: height
  4533. };
  4534. });
  4535. }
  4536. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  4537. this.pdfDocument = pdfDocument;
  4538. this.pagesOverview = pagesOverview;
  4539. this.printContainer = printContainer;
  4540. this.l10n = l10n || _ui_utils.NullL10n;
  4541. this.currentPage = -1;
  4542. this.scratchCanvas = document.createElement('canvas');
  4543. }
  4544. PDFPrintService.prototype = {
  4545. layout: function layout() {
  4546. this.throwIfInactive();
  4547. var body = document.querySelector('body');
  4548. body.setAttribute('data-pdfjsprinting', true);
  4549. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  4550. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  4551. }, this);
  4552. if (!hasEqualPageSizes) {
  4553. console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!');
  4554. }
  4555. this.pageStyleSheet = document.createElement('style');
  4556. var pageSize = this.pagesOverview[0];
  4557. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  4558. body.appendChild(this.pageStyleSheet);
  4559. },
  4560. destroy: function destroy() {
  4561. if (activeService !== this) {
  4562. return;
  4563. }
  4564. this.printContainer.textContent = '';
  4565. if (this.pageStyleSheet && this.pageStyleSheet.parentNode) {
  4566. this.pageStyleSheet.parentNode.removeChild(this.pageStyleSheet);
  4567. this.pageStyleSheet = null;
  4568. }
  4569. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  4570. this.scratchCanvas = null;
  4571. activeService = null;
  4572. ensureOverlay().then(function () {
  4573. if (overlayManager.active !== 'printServiceOverlay') {
  4574. return;
  4575. }
  4576. overlayManager.close('printServiceOverlay');
  4577. });
  4578. },
  4579. renderPages: function renderPages() {
  4580. var _this = this;
  4581. var pageCount = this.pagesOverview.length;
  4582. var renderNextPage = function renderNextPage(resolve, reject) {
  4583. _this.throwIfInactive();
  4584. if (++_this.currentPage >= pageCount) {
  4585. renderProgress(pageCount, pageCount, _this.l10n);
  4586. resolve();
  4587. return;
  4588. }
  4589. var index = _this.currentPage;
  4590. renderProgress(index, pageCount, _this.l10n);
  4591. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
  4592. renderNextPage(resolve, reject);
  4593. }, reject);
  4594. };
  4595. return new Promise(renderNextPage);
  4596. },
  4597. useRenderedPage: function useRenderedPage(printItem) {
  4598. this.throwIfInactive();
  4599. var img = document.createElement('img');
  4600. img.style.width = printItem.width;
  4601. img.style.height = printItem.height;
  4602. var scratchCanvas = this.scratchCanvas;
  4603. if ('toBlob' in scratchCanvas && !_pdfjsLib.PDFJS.disableCreateObjectURL) {
  4604. scratchCanvas.toBlob(function (blob) {
  4605. img.src = URL.createObjectURL(blob);
  4606. });
  4607. } else {
  4608. img.src = scratchCanvas.toDataURL();
  4609. }
  4610. var wrapper = document.createElement('div');
  4611. wrapper.appendChild(img);
  4612. this.printContainer.appendChild(wrapper);
  4613. return new Promise(function (resolve, reject) {
  4614. img.onload = resolve;
  4615. img.onerror = reject;
  4616. });
  4617. },
  4618. performPrint: function performPrint() {
  4619. var _this2 = this;
  4620. this.throwIfInactive();
  4621. return new Promise(function (resolve) {
  4622. setTimeout(function () {
  4623. if (!_this2.active) {
  4624. resolve();
  4625. return;
  4626. }
  4627. print.call(window);
  4628. setTimeout(resolve, 20);
  4629. }, 0);
  4630. });
  4631. },
  4632. get active() {
  4633. return this === activeService;
  4634. },
  4635. throwIfInactive: function throwIfInactive() {
  4636. if (!this.active) {
  4637. throw new Error('This print request was cancelled or completed.');
  4638. }
  4639. }
  4640. };
  4641. var print = window.print;
  4642. window.print = function print() {
  4643. if (activeService) {
  4644. console.warn('Ignored window.print() because of a pending print job.');
  4645. return;
  4646. }
  4647. ensureOverlay().then(function () {
  4648. if (activeService) {
  4649. overlayManager.open('printServiceOverlay');
  4650. }
  4651. });
  4652. try {
  4653. dispatchEvent('beforeprint');
  4654. } finally {
  4655. if (!activeService) {
  4656. console.error('Expected print service to be initialized.');
  4657. ensureOverlay().then(function () {
  4658. if (overlayManager.active === 'printServiceOverlay') {
  4659. overlayManager.close('printServiceOverlay');
  4660. }
  4661. });
  4662. return;
  4663. }
  4664. var activeServiceOnEntry = activeService;
  4665. activeService.renderPages().then(function () {
  4666. return activeServiceOnEntry.performPrint();
  4667. }).catch(function () { }).then(function () {
  4668. if (activeServiceOnEntry.active) {
  4669. abort();
  4670. }
  4671. });
  4672. }
  4673. };
  4674. function dispatchEvent(eventType) {
  4675. var event = document.createEvent('CustomEvent');
  4676. event.initCustomEvent(eventType, false, false, 'custom');
  4677. window.dispatchEvent(event);
  4678. }
  4679. function abort() {
  4680. if (activeService) {
  4681. activeService.destroy();
  4682. dispatchEvent('afterprint');
  4683. }
  4684. }
  4685. function renderProgress(index, total, l10n) {
  4686. var progressContainer = document.getElementById('printServiceOverlay');
  4687. var progress = Math.round(100 * index / total);
  4688. var progressBar = progressContainer.querySelector('progress');
  4689. var progressPerc = progressContainer.querySelector('.relative-progress');
  4690. progressBar.value = progress;
  4691. l10n.get('print_progress_percent', { progress: progress }, progress + '%').then(function (msg) {
  4692. progressPerc.textContent = msg;
  4693. });
  4694. }
  4695. var hasAttachEvent = !!document.attachEvent;
  4696. window.addEventListener('keydown', function (event) {
  4697. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  4698. window.print();
  4699. if (hasAttachEvent) {
  4700. return;
  4701. }
  4702. event.preventDefault();
  4703. if (event.stopImmediatePropagation) {
  4704. event.stopImmediatePropagation();
  4705. } else {
  4706. event.stopPropagation();
  4707. }
  4708. return;
  4709. }
  4710. }, true);
  4711. if (hasAttachEvent) {
  4712. document.attachEvent('onkeydown', function (event) {
  4713. event = event || window.event;
  4714. if (event.keyCode === 80 && event.ctrlKey) {
  4715. event.keyCode = 0;
  4716. return false;
  4717. }
  4718. });
  4719. }
  4720. if ('onbeforeprint' in window) {
  4721. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  4722. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  4723. event.stopImmediatePropagation();
  4724. }
  4725. };
  4726. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  4727. window.addEventListener('afterprint', stopPropagationIfNeeded);
  4728. }
  4729. var overlayPromise;
  4730. function ensureOverlay() {
  4731. if (!overlayPromise) {
  4732. overlayManager = _app.PDFViewerApplication.overlayManager;
  4733. if (!overlayManager) {
  4734. throw new Error('The overlay manager has not yet been initialized.');
  4735. }
  4736. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
  4737. document.getElementById('printCancel').onclick = abort;
  4738. }
  4739. return overlayPromise;
  4740. }
  4741. _app.PDFPrintServiceFactory.instance = {
  4742. supportsPrinting: true,
  4743. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  4744. if (activeService) {
  4745. throw new Error('The print service is created and active.');
  4746. }
  4747. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  4748. return activeService;
  4749. }
  4750. };
  4751. exports.PDFPrintService = PDFPrintService;
  4752. /***/
  4753. }),
  4754. /* 10 */
  4755. /***/ (function (module, exports, __webpack_require__) {
  4756. "use strict";
  4757. document.webL10n = function (window, document, undefined) {
  4758. var gL10nData = {};
  4759. var gTextData = '';
  4760. var gTextProp = 'textContent';
  4761. var gLanguage = '';
  4762. var gMacros = {};
  4763. var gReadyState = 'loading';
  4764. var gAsyncResourceLoading = true;
  4765. function getL10nResourceLinks() {
  4766. return document.querySelectorAll('link[type="application/l10n"]');
  4767. }
  4768. function getL10nDictionary() {
  4769. var script = document.querySelector('script[type="application/l10n"]');
  4770. return script ? JSON.parse(script.innerHTML) : null;
  4771. }
  4772. function getTranslatableChildren(element) {
  4773. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  4774. }
  4775. function getL10nAttributes(element) {
  4776. if (!element) return {};
  4777. var l10nId = element.getAttribute('data-l10n-id');
  4778. var l10nArgs = element.getAttribute('data-l10n-args');
  4779. var args = {};
  4780. if (l10nArgs) {
  4781. try {
  4782. args = JSON.parse(l10nArgs);
  4783. } catch (e) {
  4784. console.warn('could not parse arguments for #' + l10nId);
  4785. }
  4786. }
  4787. return {
  4788. id: l10nId,
  4789. args: args
  4790. };
  4791. }
  4792. function fireL10nReadyEvent(lang) {
  4793. var evtObject = document.createEvent('Event');
  4794. evtObject.initEvent('localized', true, false);
  4795. evtObject.language = lang;
  4796. document.dispatchEvent(evtObject);
  4797. }
  4798. function xhrLoadText(url, onSuccess, onFailure) {
  4799. onSuccess = onSuccess || function _onSuccess(data) { };
  4800. onFailure = onFailure || function _onFailure() { };
  4801. var xhr = new XMLHttpRequest();
  4802. xhr.open('GET', url, gAsyncResourceLoading);
  4803. if (xhr.overrideMimeType) {
  4804. xhr.overrideMimeType('text/plain; charset=utf-8');
  4805. }
  4806. xhr.onreadystatechange = function () {
  4807. if (xhr.readyState == 4) {
  4808. if (xhr.status == 200 || xhr.status === 0) {
  4809. onSuccess(xhr.responseText);
  4810. } else {
  4811. onFailure();
  4812. }
  4813. }
  4814. };
  4815. xhr.onerror = onFailure;
  4816. xhr.ontimeout = onFailure;
  4817. try {
  4818. xhr.send(null);
  4819. } catch (e) {
  4820. onFailure();
  4821. }
  4822. }
  4823. function parseResource(href, lang, successCallback, failureCallback) {
  4824. var baseURL = href.replace(/[^\/]*$/, '') || './';
  4825. function evalString(text) {
  4826. if (text.lastIndexOf('\\') < 0) return text;
  4827. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
  4828. }
  4829. function parseProperties(text, parsedPropertiesCallback) {
  4830. var dictionary = {};
  4831. var reBlank = /^\s*|\s*$/;
  4832. var reComment = /^\s*#|^\s*$/;
  4833. var reSection = /^\s*\[(.*)\]\s*$/;
  4834. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  4835. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  4836. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  4837. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  4838. var currentLang = '*';
  4839. var genericLang = lang.split('-', 1)[0];
  4840. var skipLang = false;
  4841. var match = '';
  4842. function nextEntry() {
  4843. while (true) {
  4844. if (!entries.length) {
  4845. parsedRawLinesCallback();
  4846. return;
  4847. }
  4848. var line = entries.shift();
  4849. if (reComment.test(line)) continue;
  4850. if (extendedSyntax) {
  4851. match = reSection.exec(line);
  4852. if (match) {
  4853. currentLang = match[1].toLowerCase();
  4854. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  4855. continue;
  4856. } else if (skipLang) {
  4857. continue;
  4858. }
  4859. match = reImport.exec(line);
  4860. if (match) {
  4861. loadImport(baseURL + match[1], nextEntry);
  4862. return;
  4863. }
  4864. }
  4865. var tmp = line.match(reSplit);
  4866. if (tmp && tmp.length == 3) {
  4867. dictionary[tmp[1]] = evalString(tmp[2]);
  4868. }
  4869. }
  4870. }
  4871. nextEntry();
  4872. }
  4873. function loadImport(url, callback) {
  4874. xhrLoadText(url, function (content) {
  4875. parseRawLines(content, false, callback);
  4876. }, function () {
  4877. console.warn(url + ' not found.');
  4878. callback();
  4879. });
  4880. }
  4881. parseRawLines(text, true, function () {
  4882. parsedPropertiesCallback(dictionary);
  4883. });
  4884. }
  4885. xhrLoadText(href, function (response) {
  4886. gTextData += response;
  4887. parseProperties(response, function (data) {
  4888. for (var key in data) {
  4889. var id,
  4890. prop,
  4891. index = key.lastIndexOf('.');
  4892. if (index > 0) {
  4893. id = key.substring(0, index);
  4894. prop = key.substr(index + 1);
  4895. } else {
  4896. id = key;
  4897. prop = gTextProp;
  4898. }
  4899. if (!gL10nData[id]) {
  4900. gL10nData[id] = {};
  4901. }
  4902. gL10nData[id][prop] = data[key];
  4903. }
  4904. if (successCallback) {
  4905. successCallback();
  4906. }
  4907. });
  4908. }, failureCallback);
  4909. }
  4910. function loadLocale(lang, callback) {
  4911. if (lang) {
  4912. lang = lang.toLowerCase();
  4913. }
  4914. callback = callback || function _callback() { };
  4915. clear();
  4916. gLanguage = lang;
  4917. var langLinks = getL10nResourceLinks();
  4918. var langCount = langLinks.length;
  4919. if (langCount === 0) {
  4920. var dict = getL10nDictionary();
  4921. if (dict && dict.locales && dict.default_locale) {
  4922. console.log('using the embedded JSON directory, early way out');
  4923. gL10nData = dict.locales[lang];
  4924. if (!gL10nData) {
  4925. var defaultLocale = dict.default_locale.toLowerCase();
  4926. for (var anyCaseLang in dict.locales) {
  4927. anyCaseLang = anyCaseLang.toLowerCase();
  4928. if (anyCaseLang === lang) {
  4929. gL10nData = dict.locales[lang];
  4930. break;
  4931. } else if (anyCaseLang === defaultLocale) {
  4932. gL10nData = dict.locales[defaultLocale];
  4933. }
  4934. }
  4935. }
  4936. callback();
  4937. } else {
  4938. console.log('no resource to load, early way out');
  4939. }
  4940. fireL10nReadyEvent(lang);
  4941. gReadyState = 'complete';
  4942. return;
  4943. }
  4944. var onResourceLoaded = null;
  4945. var gResourceCount = 0;
  4946. onResourceLoaded = function onResourceLoaded() {
  4947. gResourceCount++;
  4948. if (gResourceCount >= langCount) {
  4949. callback();
  4950. fireL10nReadyEvent(lang);
  4951. gReadyState = 'complete';
  4952. }
  4953. };
  4954. function L10nResourceLink(link) {
  4955. var href = link.href;
  4956. this.load = function (lang, callback) {
  4957. parseResource(href, lang, callback, function () {
  4958. console.warn(href + ' not found.');
  4959. console.warn('"' + lang + '" resource not found');
  4960. gLanguage = '';
  4961. callback();
  4962. });
  4963. };
  4964. }
  4965. for (var i = 0; i < langCount; i++) {
  4966. var resource = new L10nResourceLink(langLinks[i]);
  4967. resource.load(lang, onResourceLoaded);
  4968. }
  4969. }
  4970. function clear() {
  4971. gL10nData = {};
  4972. gTextData = '';
  4973. gLanguage = '';
  4974. }
  4975. function getPluralRules(lang) {
  4976. var locales2rules = {
  4977. 'af': 3,
  4978. 'ak': 4,
  4979. 'am': 4,
  4980. 'ar': 1,
  4981. 'asa': 3,
  4982. 'az': 0,
  4983. 'be': 11,
  4984. 'bem': 3,
  4985. 'bez': 3,
  4986. 'bg': 3,
  4987. 'bh': 4,
  4988. 'bm': 0,
  4989. 'bn': 3,
  4990. 'bo': 0,
  4991. 'br': 20,
  4992. 'brx': 3,
  4993. 'bs': 11,
  4994. 'ca': 3,
  4995. 'cgg': 3,
  4996. 'chr': 3,
  4997. 'cs': 12,
  4998. 'cy': 17,
  4999. 'da': 3,
  5000. 'de': 3,
  5001. 'dv': 3,
  5002. 'dz': 0,
  5003. 'ee': 3,
  5004. 'el': 3,
  5005. 'en': 3,
  5006. 'eo': 3,
  5007. 'es': 3,
  5008. 'et': 3,
  5009. 'eu': 3,
  5010. 'fa': 0,
  5011. 'ff': 5,
  5012. 'fi': 3,
  5013. 'fil': 4,
  5014. 'fo': 3,
  5015. 'fr': 5,
  5016. 'fur': 3,
  5017. 'fy': 3,
  5018. 'ga': 8,
  5019. 'gd': 24,
  5020. 'gl': 3,
  5021. 'gsw': 3,
  5022. 'gu': 3,
  5023. 'guw': 4,
  5024. 'gv': 23,
  5025. 'ha': 3,
  5026. 'haw': 3,
  5027. 'he': 2,
  5028. 'hi': 4,
  5029. 'hr': 11,
  5030. 'hu': 0,
  5031. 'id': 0,
  5032. 'ig': 0,
  5033. 'ii': 0,
  5034. 'is': 3,
  5035. 'it': 3,
  5036. 'iu': 7,
  5037. 'ja': 0,
  5038. 'jmc': 3,
  5039. 'jv': 0,
  5040. 'ka': 0,
  5041. 'kab': 5,
  5042. 'kaj': 3,
  5043. 'kcg': 3,
  5044. 'kde': 0,
  5045. 'kea': 0,
  5046. 'kk': 3,
  5047. 'kl': 3,
  5048. 'km': 0,
  5049. 'kn': 0,
  5050. 'ko': 0,
  5051. 'ksb': 3,
  5052. 'ksh': 21,
  5053. 'ku': 3,
  5054. 'kw': 7,
  5055. 'lag': 18,
  5056. 'lb': 3,
  5057. 'lg': 3,
  5058. 'ln': 4,
  5059. 'lo': 0,
  5060. 'lt': 10,
  5061. 'lv': 6,
  5062. 'mas': 3,
  5063. 'mg': 4,
  5064. 'mk': 16,
  5065. 'ml': 3,
  5066. 'mn': 3,
  5067. 'mo': 9,
  5068. 'mr': 3,
  5069. 'ms': 0,
  5070. 'mt': 15,
  5071. 'my': 0,
  5072. 'nah': 3,
  5073. 'naq': 7,
  5074. 'nb': 3,
  5075. 'nd': 3,
  5076. 'ne': 3,
  5077. 'nl': 3,
  5078. 'nn': 3,
  5079. 'no': 3,
  5080. 'nr': 3,
  5081. 'nso': 4,
  5082. 'ny': 3,
  5083. 'nyn': 3,
  5084. 'om': 3,
  5085. 'or': 3,
  5086. 'pa': 3,
  5087. 'pap': 3,
  5088. 'pl': 13,
  5089. 'ps': 3,
  5090. 'pt': 3,
  5091. 'rm': 3,
  5092. 'ro': 9,
  5093. 'rof': 3,
  5094. 'ru': 11,
  5095. 'rwk': 3,
  5096. 'sah': 0,
  5097. 'saq': 3,
  5098. 'se': 7,
  5099. 'seh': 3,
  5100. 'ses': 0,
  5101. 'sg': 0,
  5102. 'sh': 11,
  5103. 'shi': 19,
  5104. 'sk': 12,
  5105. 'sl': 14,
  5106. 'sma': 7,
  5107. 'smi': 7,
  5108. 'smj': 7,
  5109. 'smn': 7,
  5110. 'sms': 7,
  5111. 'sn': 3,
  5112. 'so': 3,
  5113. 'sq': 3,
  5114. 'sr': 11,
  5115. 'ss': 3,
  5116. 'ssy': 3,
  5117. 'st': 3,
  5118. 'sv': 3,
  5119. 'sw': 3,
  5120. 'syr': 3,
  5121. 'ta': 3,
  5122. 'te': 3,
  5123. 'teo': 3,
  5124. 'th': 0,
  5125. 'ti': 4,
  5126. 'tig': 3,
  5127. 'tk': 3,
  5128. 'tl': 4,
  5129. 'tn': 3,
  5130. 'to': 0,
  5131. 'tr': 0,
  5132. 'ts': 3,
  5133. 'tzm': 22,
  5134. 'uk': 11,
  5135. 'ur': 3,
  5136. 've': 3,
  5137. 'vi': 0,
  5138. 'vun': 3,
  5139. 'wa': 4,
  5140. 'wae': 3,
  5141. 'wo': 0,
  5142. 'xh': 3,
  5143. 'xog': 3,
  5144. 'yo': 0,
  5145. 'zh': 0,
  5146. 'zu': 3
  5147. };
  5148. function isIn(n, list) {
  5149. return list.indexOf(n) !== -1;
  5150. }
  5151. function isBetween(n, start, end) {
  5152. return start <= n && n <= end;
  5153. }
  5154. var pluralRules = {
  5155. '0': function _(n) {
  5156. return 'other';
  5157. },
  5158. '1': function _(n) {
  5159. if (isBetween(n % 100, 3, 10)) return 'few';
  5160. if (n === 0) return 'zero';
  5161. if (isBetween(n % 100, 11, 99)) return 'many';
  5162. if (n == 2) return 'two';
  5163. if (n == 1) return 'one';
  5164. return 'other';
  5165. },
  5166. '2': function _(n) {
  5167. if (n !== 0 && n % 10 === 0) return 'many';
  5168. if (n == 2) return 'two';
  5169. if (n == 1) return 'one';
  5170. return 'other';
  5171. },
  5172. '3': function _(n) {
  5173. if (n == 1) return 'one';
  5174. return 'other';
  5175. },
  5176. '4': function _(n) {
  5177. if (isBetween(n, 0, 1)) return 'one';
  5178. return 'other';
  5179. },
  5180. '5': function _(n) {
  5181. if (isBetween(n, 0, 2) && n != 2) return 'one';
  5182. return 'other';
  5183. },
  5184. '6': function _(n) {
  5185. if (n === 0) return 'zero';
  5186. if (n % 10 == 1 && n % 100 != 11) return 'one';
  5187. return 'other';
  5188. },
  5189. '7': function _(n) {
  5190. if (n == 2) return 'two';
  5191. if (n == 1) return 'one';
  5192. return 'other';
  5193. },
  5194. '8': function _(n) {
  5195. if (isBetween(n, 3, 6)) return 'few';
  5196. if (isBetween(n, 7, 10)) return 'many';
  5197. if (n == 2) return 'two';
  5198. if (n == 1) return 'one';
  5199. return 'other';
  5200. },
  5201. '9': function _(n) {
  5202. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  5203. if (n == 1) return 'one';
  5204. return 'other';
  5205. },
  5206. '10': function _(n) {
  5207. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  5208. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  5209. return 'other';
  5210. },
  5211. '11': function _(n) {
  5212. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  5213. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  5214. if (n % 10 == 1 && n % 100 != 11) return 'one';
  5215. return 'other';
  5216. },
  5217. '12': function _(n) {
  5218. if (isBetween(n, 2, 4)) return 'few';
  5219. if (n == 1) return 'one';
  5220. return 'other';
  5221. },
  5222. '13': function _(n) {
  5223. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  5224. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  5225. if (n == 1) return 'one';
  5226. return 'other';
  5227. },
  5228. '14': function _(n) {
  5229. if (isBetween(n % 100, 3, 4)) return 'few';
  5230. if (n % 100 == 2) return 'two';
  5231. if (n % 100 == 1) return 'one';
  5232. return 'other';
  5233. },
  5234. '15': function _(n) {
  5235. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  5236. if (isBetween(n % 100, 11, 19)) return 'many';
  5237. if (n == 1) return 'one';
  5238. return 'other';
  5239. },
  5240. '16': function _(n) {
  5241. if (n % 10 == 1 && n != 11) return 'one';
  5242. return 'other';
  5243. },
  5244. '17': function _(n) {
  5245. if (n == 3) return 'few';
  5246. if (n === 0) return 'zero';
  5247. if (n == 6) return 'many';
  5248. if (n == 2) return 'two';
  5249. if (n == 1) return 'one';
  5250. return 'other';
  5251. },
  5252. '18': function _(n) {
  5253. if (n === 0) return 'zero';
  5254. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  5255. return 'other';
  5256. },
  5257. '19': function _(n) {
  5258. if (isBetween(n, 2, 10)) return 'few';
  5259. if (isBetween(n, 0, 1)) return 'one';
  5260. return 'other';
  5261. },
  5262. '20': function _(n) {
  5263. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
  5264. if (n % 1000000 === 0 && n !== 0) return 'many';
  5265. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  5266. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  5267. return 'other';
  5268. },
  5269. '21': function _(n) {
  5270. if (n === 0) return 'zero';
  5271. if (n == 1) return 'one';
  5272. return 'other';
  5273. },
  5274. '22': function _(n) {
  5275. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  5276. return 'other';
  5277. },
  5278. '23': function _(n) {
  5279. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  5280. return 'other';
  5281. },
  5282. '24': function _(n) {
  5283. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  5284. if (isIn(n, [2, 12])) return 'two';
  5285. if (isIn(n, [1, 11])) return 'one';
  5286. return 'other';
  5287. }
  5288. };
  5289. var index = locales2rules[lang.replace(/-.*$/, '')];
  5290. if (!(index in pluralRules)) {
  5291. console.warn('plural form unknown for [' + lang + ']');
  5292. return function () {
  5293. return 'other';
  5294. };
  5295. }
  5296. return pluralRules[index];
  5297. }
  5298. gMacros.plural = function (str, param, key, prop) {
  5299. var n = parseFloat(param);
  5300. if (isNaN(n)) return str;
  5301. if (prop != gTextProp) return str;
  5302. if (!gMacros._pluralRules) {
  5303. gMacros._pluralRules = getPluralRules(gLanguage);
  5304. }
  5305. var index = '[' + gMacros._pluralRules(n) + ']';
  5306. if (n === 0 && key + '[zero]' in gL10nData) {
  5307. str = gL10nData[key + '[zero]'][prop];
  5308. } else if (n == 1 && key + '[one]' in gL10nData) {
  5309. str = gL10nData[key + '[one]'][prop];
  5310. } else if (n == 2 && key + '[two]' in gL10nData) {
  5311. str = gL10nData[key + '[two]'][prop];
  5312. } else if (key + index in gL10nData) {
  5313. str = gL10nData[key + index][prop];
  5314. } else if (key + '[other]' in gL10nData) {
  5315. str = gL10nData[key + '[other]'][prop];
  5316. }
  5317. return str;
  5318. };
  5319. function getL10nData(key, args, fallback) {
  5320. var data = gL10nData[key];
  5321. if (!data) {
  5322. console.warn('#' + key + ' is undefined.');
  5323. if (!fallback) {
  5324. return null;
  5325. }
  5326. data = fallback;
  5327. }
  5328. var rv = {};
  5329. for (var prop in data) {
  5330. var str = data[prop];
  5331. str = substIndexes(str, args, key, prop);
  5332. str = substArguments(str, args, key);
  5333. rv[prop] = str;
  5334. }
  5335. return rv;
  5336. }
  5337. function substIndexes(str, args, key, prop) {
  5338. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  5339. var reMatch = reIndex.exec(str);
  5340. if (!reMatch || !reMatch.length) return str;
  5341. var macroName = reMatch[1];
  5342. var paramName = reMatch[2];
  5343. var param;
  5344. if (args && paramName in args) {
  5345. param = args[paramName];
  5346. } else if (paramName in gL10nData) {
  5347. param = gL10nData[paramName];
  5348. }
  5349. if (macroName in gMacros) {
  5350. var macro = gMacros[macroName];
  5351. str = macro(str, param, key, prop);
  5352. }
  5353. return str;
  5354. }
  5355. function substArguments(str, args, key) {
  5356. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  5357. return str.replace(reArgs, function (matched_text, arg) {
  5358. if (args && arg in args) {
  5359. return args[arg];
  5360. }
  5361. if (arg in gL10nData) {
  5362. return gL10nData[arg];
  5363. }
  5364. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  5365. return matched_text;
  5366. });
  5367. }
  5368. function translateElement(element) {
  5369. var l10n = getL10nAttributes(element);
  5370. if (!l10n.id) return;
  5371. var data = getL10nData(l10n.id, l10n.args);
  5372. if (!data) {
  5373. console.warn('#' + l10n.id + ' is undefined.');
  5374. return;
  5375. }
  5376. if (data[gTextProp]) {
  5377. if (getChildElementCount(element) === 0) {
  5378. element[gTextProp] = data[gTextProp];
  5379. } else {
  5380. var children = element.childNodes;
  5381. var found = false;
  5382. for (var i = 0, l = children.length; i < l; i++) {
  5383. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  5384. if (found) {
  5385. children[i].nodeValue = '';
  5386. } else {
  5387. children[i].nodeValue = data[gTextProp];
  5388. found = true;
  5389. }
  5390. }
  5391. }
  5392. if (!found) {
  5393. var textNode = document.createTextNode(data[gTextProp]);
  5394. element.insertBefore(textNode, element.firstChild);
  5395. }
  5396. }
  5397. delete data[gTextProp];
  5398. }
  5399. for (var k in data) {
  5400. element[k] = data[k];
  5401. }
  5402. }
  5403. function getChildElementCount(element) {
  5404. if (element.children) {
  5405. return element.children.length;
  5406. }
  5407. if (typeof element.childElementCount !== 'undefined') {
  5408. return element.childElementCount;
  5409. }
  5410. var count = 0;
  5411. for (var i = 0; i < element.childNodes.length; i++) {
  5412. count += element.nodeType === 1 ? 1 : 0;
  5413. }
  5414. return count;
  5415. }
  5416. function translateFragment(element) {
  5417. element = element || document.documentElement;
  5418. var children = getTranslatableChildren(element);
  5419. var elementCount = children.length;
  5420. for (var i = 0; i < elementCount; i++) {
  5421. translateElement(children[i]);
  5422. }
  5423. translateElement(element);
  5424. }
  5425. return {
  5426. get: function get(key, args, fallbackString) {
  5427. var index = key.lastIndexOf('.');
  5428. var prop = gTextProp;
  5429. if (index > 0) {
  5430. prop = key.substr(index + 1);
  5431. key = key.substring(0, index);
  5432. }
  5433. var fallback;
  5434. if (fallbackString) {
  5435. fallback = {};
  5436. fallback[prop] = fallbackString;
  5437. }
  5438. var data = getL10nData(key, args, fallback);
  5439. if (data && prop in data) {
  5440. return data[prop];
  5441. }
  5442. return '{{' + key + '}}';
  5443. },
  5444. getData: function getData() {
  5445. return gL10nData;
  5446. },
  5447. getText: function getText() {
  5448. return gTextData;
  5449. },
  5450. getLanguage: function getLanguage() {
  5451. return gLanguage;
  5452. },
  5453. setLanguage: function setLanguage(lang, callback) {
  5454. loadLocale(lang, function () {
  5455. if (callback) callback();
  5456. });
  5457. },
  5458. getDirection: function getDirection() {
  5459. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  5460. var shortCode = gLanguage.split('-', 1)[0];
  5461. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  5462. },
  5463. translate: translateFragment,
  5464. getReadyState: function getReadyState() {
  5465. return gReadyState;
  5466. },
  5467. ready: function ready(callback) {
  5468. if (!callback) {
  5469. return;
  5470. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  5471. window.setTimeout(function () {
  5472. callback();
  5473. });
  5474. } else if (document.addEventListener) {
  5475. document.addEventListener('localized', function once() {
  5476. document.removeEventListener('localized', once);
  5477. callback();
  5478. });
  5479. }
  5480. }
  5481. };
  5482. }(window, document);
  5483. /***/
  5484. }),
  5485. /* 11 */
  5486. /***/ (function (module, exports, __webpack_require__) {
  5487. "use strict";
  5488. Object.defineProperty(exports, "__esModule", {
  5489. value: true
  5490. });
  5491. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
  5492. 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; }; }();
  5493. var _pdfjsLib = __webpack_require__(1);
  5494. var _ui_utils = __webpack_require__(0);
  5495. var _pdf_link_service = __webpack_require__(5);
  5496. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5497. var AnnotationLayerBuilder = function () {
  5498. function AnnotationLayerBuilder(_ref) {
  5499. var pageDiv = _ref.pageDiv,
  5500. pdfPage = _ref.pdfPage,
  5501. linkService = _ref.linkService,
  5502. downloadManager = _ref.downloadManager,
  5503. _ref$renderInteractiv = _ref.renderInteractiveForms,
  5504. renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv,
  5505. _ref$l10n = _ref.l10n,
  5506. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  5507. _classCallCheck(this, AnnotationLayerBuilder);
  5508. this.pageDiv = pageDiv;
  5509. this.pdfPage = pdfPage;
  5510. this.linkService = linkService;
  5511. this.downloadManager = downloadManager;
  5512. this.renderInteractiveForms = renderInteractiveForms;
  5513. this.l10n = l10n;
  5514. this.div = null;
  5515. }
  5516. _createClass(AnnotationLayerBuilder, [{
  5517. key: 'render',
  5518. value: function render(viewport) {
  5519. var _this = this;
  5520. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  5521. this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
  5522. var parameters = {
  5523. viewport: viewport.clone({ dontFlip: true }),
  5524. div: _this.div,
  5525. annotations: annotations,
  5526. page: _this.pdfPage,
  5527. renderInteractiveForms: _this.renderInteractiveForms,
  5528. linkService: _this.linkService,
  5529. downloadManager: _this.downloadManager
  5530. };
  5531. if (_this.div) {
  5532. _pdfjsLib.AnnotationLayer.update(parameters);
  5533. } else {
  5534. if (annotations.length === 0) {
  5535. return;
  5536. }
  5537. _this.div = document.createElement('div');
  5538. _this.div.className = 'annotationLayer';
  5539. _this.pageDiv.appendChild(_this.div);
  5540. parameters.div = _this.div;
  5541. _pdfjsLib.AnnotationLayer.render(parameters);
  5542. _this.l10n.translate(_this.div);
  5543. }
  5544. });
  5545. }
  5546. }, {
  5547. key: 'hide',
  5548. value: function hide() {
  5549. if (!this.div) {
  5550. return;
  5551. }
  5552. this.div.setAttribute('hidden', 'true');
  5553. }
  5554. }]);
  5555. return AnnotationLayerBuilder;
  5556. }();
  5557. var DefaultAnnotationLayerFactory = function () {
  5558. function DefaultAnnotationLayerFactory() {
  5559. _classCallCheck(this, DefaultAnnotationLayerFactory);
  5560. }
  5561. _createClass(DefaultAnnotationLayerFactory, [{
  5562. key: 'createAnnotationLayerBuilder',
  5563. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  5564. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5565. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  5566. return new AnnotationLayerBuilder({
  5567. pageDiv: pageDiv,
  5568. pdfPage: pdfPage,
  5569. renderInteractiveForms: renderInteractiveForms,
  5570. linkService: new _pdf_link_service.SimpleLinkService(),
  5571. l10n: l10n
  5572. });
  5573. }
  5574. }]);
  5575. return DefaultAnnotationLayerFactory;
  5576. }();
  5577. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  5578. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  5579. /***/
  5580. }),
  5581. /* 12 */
  5582. /***/ (function (module, exports, __webpack_require__) {
  5583. "use strict";
  5584. Object.defineProperty(exports, "__esModule", {
  5585. value: true
  5586. });
  5587. exports.DownloadManager = undefined;
  5588. 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; }; }();
  5589. var _pdfjsLib = __webpack_require__(1);
  5590. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5591. ;
  5592. function _download(blobUrl, filename) {
  5593. var a = document.createElement('a');
  5594. if (a.click) {
  5595. a.href = blobUrl;
  5596. a.target = '_parent';
  5597. if ('download' in a) {
  5598. a.download = filename;
  5599. }
  5600. (document.body || document.documentElement).appendChild(a);
  5601. a.click();
  5602. a.parentNode.removeChild(a);
  5603. } else {
  5604. if (window.top === window && blobUrl.split('#')[0] === window.location.href.split('#')[0]) {
  5605. var padCharacter = blobUrl.indexOf('?') === -1 ? '?' : '&';
  5606. blobUrl = blobUrl.replace(/#|$/, padCharacter + '$&');
  5607. }
  5608. window.open(blobUrl, '_parent');
  5609. }
  5610. }
  5611. var DownloadManager = function () {
  5612. function DownloadManager() {
  5613. _classCallCheck(this, DownloadManager);
  5614. }
  5615. _createClass(DownloadManager, [{
  5616. key: 'downloadUrl',
  5617. value: function downloadUrl(url, filename) {
  5618. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  5619. return;
  5620. }
  5621. _download(url + '#pdfjs.action=download', filename);
  5622. }
  5623. }, {
  5624. key: 'downloadData',
  5625. value: function downloadData(data, filename, contentType) {
  5626. if (navigator.msSaveBlob) {
  5627. return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
  5628. }
  5629. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _pdfjsLib.PDFJS.disableCreateObjectURL);
  5630. _download(blobUrl, filename);
  5631. }
  5632. }, {
  5633. key: 'download',
  5634. value: function download(blob, url, filename) {
  5635. if (navigator.msSaveBlob) {
  5636. if (!navigator.msSaveBlob(blob, filename)) {
  5637. this.downloadUrl(url, filename);
  5638. }
  5639. return;
  5640. }
  5641. if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
  5642. this.downloadUrl(url, filename);
  5643. return;
  5644. }
  5645. var blobUrl = URL.createObjectURL(blob);
  5646. _download(blobUrl, filename);
  5647. }
  5648. }]);
  5649. return DownloadManager;
  5650. }();
  5651. exports.DownloadManager = DownloadManager;
  5652. /***/
  5653. }),
  5654. /* 13 */
  5655. /***/ (function (module, exports, __webpack_require__) {
  5656. "use strict";
  5657. Object.defineProperty(exports, "__esModule", {
  5658. value: true
  5659. });
  5660. exports.GenericL10n = undefined;
  5661. var _createClass = function () {
  5662. function defineProperties(target, props) {
  5663. for (var i = 0; i < props.length; i++) {
  5664. var descriptor = props[i];
  5665. descriptor.enumerable = descriptor.enumerable || false;
  5666. descriptor.configurable = true;
  5667. if ("value" in descriptor) descriptor.writable = true;
  5668. Object.defineProperty(target, descriptor.key, descriptor);
  5669. }
  5670. }
  5671. return function (Constructor, protoProps, staticProps) {
  5672. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  5673. if (staticProps) defineProperties(Constructor, staticProps);
  5674. return Constructor;
  5675. };
  5676. }();
  5677. __webpack_require__(10);
  5678. function _classCallCheck(instance, Constructor) {
  5679. if (!(instance instanceof Constructor)) {
  5680. throw new TypeError("Cannot call a class as a function");
  5681. }
  5682. }
  5683. var webL10n = document.webL10n;
  5684. var GenericL10n = function () {
  5685. function GenericL10n(lang) {
  5686. _classCallCheck(this, GenericL10n);
  5687. this._lang = lang;
  5688. this._ready = new Promise(function (resolve, reject) {
  5689. webL10n.setLanguage(lang, function () {
  5690. resolve(webL10n);
  5691. });
  5692. });
  5693. }
  5694. _createClass(GenericL10n, [{
  5695. key: 'getDirection',
  5696. value: function getDirection() {
  5697. return this._ready.then(function (l10n) {
  5698. return l10n.getDirection();
  5699. });
  5700. }
  5701. }, {
  5702. key: 'get',
  5703. value: function get(property, args, fallback) {
  5704. return this._ready.then(function (l10n) {
  5705. return l10n.get(property, args, fallback);
  5706. });
  5707. }
  5708. }, {
  5709. key: 'translate',
  5710. value: function translate(element) {
  5711. return this._ready.then(function (l10n) {
  5712. return l10n.translate(element);
  5713. });
  5714. }
  5715. }]);
  5716. return GenericL10n;
  5717. }();
  5718. exports.GenericL10n = GenericL10n;
  5719. /***/
  5720. }),
  5721. /* 14 */
  5722. /***/ (function (module, exports, __webpack_require__) {
  5723. "use strict";
  5724. Object.defineProperty(exports, "__esModule", {
  5725. value: true
  5726. });
  5727. function GrabToPan(options) {
  5728. this.element = options.element;
  5729. this.document = options.element.ownerDocument;
  5730. if (typeof options.ignoreTarget === 'function') {
  5731. this.ignoreTarget = options.ignoreTarget;
  5732. }
  5733. this.onActiveChanged = options.onActiveChanged;
  5734. this.activate = this.activate.bind(this);
  5735. this.deactivate = this.deactivate.bind(this);
  5736. this.toggle = this.toggle.bind(this);
  5737. this._onmousedown = this._onmousedown.bind(this);
  5738. this._onmousemove = this._onmousemove.bind(this);
  5739. this._endPan = this._endPan.bind(this);
  5740. var overlay = this.overlay = document.createElement('div');
  5741. overlay.className = 'grab-to-pan-grabbing';
  5742. }
  5743. GrabToPan.prototype = {
  5744. CSS_CLASS_GRAB: 'grab-to-pan-grab',
  5745. activate: function GrabToPan_activate() {
  5746. if (!this.active) {
  5747. this.active = true;
  5748. this.element.addEventListener('mousedown', this._onmousedown, true);
  5749. this.element.classList.add(this.CSS_CLASS_GRAB);
  5750. if (this.onActiveChanged) {
  5751. this.onActiveChanged(true);
  5752. }
  5753. }
  5754. },
  5755. deactivate: function GrabToPan_deactivate() {
  5756. if (this.active) {
  5757. this.active = false;
  5758. this.element.removeEventListener('mousedown', this._onmousedown, true);
  5759. this._endPan();
  5760. this.element.classList.remove(this.CSS_CLASS_GRAB);
  5761. if (this.onActiveChanged) {
  5762. this.onActiveChanged(false);
  5763. }
  5764. }
  5765. },
  5766. toggle: function GrabToPan_toggle() {
  5767. if (this.active) {
  5768. this.deactivate();
  5769. } else {
  5770. this.activate();
  5771. }
  5772. },
  5773. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  5774. return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option');
  5775. },
  5776. _onmousedown: function GrabToPan__onmousedown(event) {
  5777. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  5778. return;
  5779. }
  5780. if (event.originalTarget) {
  5781. try {
  5782. event.originalTarget.tagName;
  5783. } catch (e) {
  5784. return;
  5785. }
  5786. }
  5787. this.scrollLeftStart = this.element.scrollLeft;
  5788. this.scrollTopStart = this.element.scrollTop;
  5789. this.clientXStart = event.clientX;
  5790. this.clientYStart = event.clientY;
  5791. this.document.addEventListener('mousemove', this._onmousemove, true);
  5792. this.document.addEventListener('mouseup', this._endPan, true);
  5793. this.element.addEventListener('scroll', this._endPan, true);
  5794. event.preventDefault();
  5795. event.stopPropagation();
  5796. var focusedElement = document.activeElement;
  5797. if (focusedElement && !focusedElement.contains(event.target)) {
  5798. focusedElement.blur();
  5799. }
  5800. },
  5801. _onmousemove: function GrabToPan__onmousemove(event) {
  5802. this.element.removeEventListener('scroll', this._endPan, true);
  5803. if (isLeftMouseReleased(event)) {
  5804. this._endPan();
  5805. return;
  5806. }
  5807. var xDiff = event.clientX - this.clientXStart;
  5808. var yDiff = event.clientY - this.clientYStart;
  5809. var scrollTop = this.scrollTopStart - yDiff;
  5810. var scrollLeft = this.scrollLeftStart - xDiff;
  5811. if (this.element.scrollTo) {
  5812. this.element.scrollTo({
  5813. top: scrollTop,
  5814. left: scrollLeft,
  5815. behavior: 'instant'
  5816. });
  5817. } else {
  5818. this.element.scrollTop = scrollTop;
  5819. this.element.scrollLeft = scrollLeft;
  5820. }
  5821. if (!this.overlay.parentNode) {
  5822. document.body.appendChild(this.overlay);
  5823. }
  5824. },
  5825. _endPan: function GrabToPan__endPan() {
  5826. this.element.removeEventListener('scroll', this._endPan, true);
  5827. this.document.removeEventListener('mousemove', this._onmousemove, true);
  5828. this.document.removeEventListener('mouseup', this._endPan, true);
  5829. this.overlay.remove();
  5830. }
  5831. };
  5832. var matchesSelector;
  5833. ['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function (prefix) {
  5834. var name = prefix + 'atches';
  5835. if (name in document.documentElement) {
  5836. matchesSelector = name;
  5837. }
  5838. name += 'Selector';
  5839. if (name in document.documentElement) {
  5840. matchesSelector = name;
  5841. }
  5842. return matchesSelector;
  5843. });
  5844. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  5845. var chrome = window.chrome;
  5846. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  5847. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  5848. function isLeftMouseReleased(event) {
  5849. if ('buttons' in event && isNotIEorIsIE10plus) {
  5850. return !(event.buttons & 1);
  5851. }
  5852. if (isChrome15OrOpera15plus || isSafari6plus) {
  5853. return event.which === 0;
  5854. }
  5855. }
  5856. exports.GrabToPan = GrabToPan;
  5857. /***/
  5858. }),
  5859. /* 15 */
  5860. /***/ (function (module, exports, __webpack_require__) {
  5861. "use strict";
  5862. Object.defineProperty(exports, "__esModule", {
  5863. value: true
  5864. });
  5865. 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; }; }();
  5866. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5867. var OverlayManager = function () {
  5868. function OverlayManager() {
  5869. _classCallCheck(this, OverlayManager);
  5870. this._overlays = {};
  5871. this._active = null;
  5872. this._keyDownBound = this._keyDown.bind(this);
  5873. }
  5874. _createClass(OverlayManager, [{
  5875. key: 'register',
  5876. value: function register(name, element) {
  5877. var _this = this;
  5878. var callerCloseMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5879. var canForceClose = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5880. return new Promise(function (resolve) {
  5881. var container = void 0;
  5882. //console.log("name: ",name,",element: ",element ,",container: ",container);
  5883. if (!name || !element || !(container = element.parentNode)) {
  5884. throw new Error('Not enough parameters.');
  5885. } else if (_this._overlays[name]) {
  5886. throw new Error('The overlay is already registered.');
  5887. }
  5888. _this._overlays[name] = {
  5889. element: element,
  5890. container: container,
  5891. callerCloseMethod: callerCloseMethod,
  5892. canForceClose: canForceClose
  5893. };
  5894. resolve();
  5895. });
  5896. }
  5897. }, {
  5898. key: 'unregister',
  5899. value: function unregister(name) {
  5900. var _this2 = this;
  5901. return new Promise(function (resolve) {
  5902. if (!_this2._overlays[name]) {
  5903. throw new Error('The overlay does not exist.');
  5904. } else if (_this2._active === name) {
  5905. throw new Error('The overlay cannot be removed while it is active.');
  5906. }
  5907. delete _this2._overlays[name];
  5908. resolve();
  5909. });
  5910. }
  5911. }, {
  5912. key: 'open',
  5913. value: function open(name) {
  5914. var _this3 = this;
  5915. return new Promise(function (resolve) {
  5916. if (!_this3._overlays[name]) {
  5917. throw new Error('The overlay does not exist.');
  5918. } else if (_this3._active) {
  5919. if (_this3._overlays[name].canForceClose) {
  5920. _this3._closeThroughCaller();
  5921. } else if (_this3._active === name) {
  5922. throw new Error('The overlay is already active.');
  5923. } else {
  5924. throw new Error('Another overlay is currently active.');
  5925. }
  5926. }
  5927. _this3._active = name;
  5928. _this3._overlays[_this3._active].element.classList.remove('hidden');
  5929. _this3._overlays[_this3._active].container.classList.remove('hidden');
  5930. window.addEventListener('keydown', _this3._keyDownBound);
  5931. resolve();
  5932. });
  5933. }
  5934. }, {
  5935. key: 'close',
  5936. value: function close(name) {
  5937. var _this4 = this;
  5938. return new Promise(function (resolve) {
  5939. if (!_this4._overlays[name]) {
  5940. throw new Error('The overlay does not exist.');
  5941. } else if (!_this4._active) {
  5942. throw new Error('The overlay is currently not active.');
  5943. } else if (_this4._active !== name) {
  5944. throw new Error('Another overlay is currently active.');
  5945. }
  5946. _this4._overlays[_this4._active].container.classList.add('hidden');
  5947. _this4._overlays[_this4._active].element.classList.add('hidden');
  5948. _this4._active = null;
  5949. window.removeEventListener('keydown', _this4._keyDownBound);
  5950. resolve();
  5951. });
  5952. }
  5953. }, {
  5954. key: '_keyDown',
  5955. value: function _keyDown(evt) {
  5956. if (this._active && evt.keyCode === 27) {
  5957. this._closeThroughCaller();
  5958. evt.preventDefault();
  5959. }
  5960. }
  5961. }, {
  5962. key: '_closeThroughCaller',
  5963. value: function _closeThroughCaller() {
  5964. if (this._overlays[this._active].callerCloseMethod) {
  5965. this._overlays[this._active].callerCloseMethod();
  5966. }
  5967. if (this._active) {
  5968. this.close(this._active);
  5969. }
  5970. }
  5971. }, {
  5972. key: 'active',
  5973. get: function get() {
  5974. return this._active;
  5975. }
  5976. }]);
  5977. return OverlayManager;
  5978. }();
  5979. exports.OverlayManager = OverlayManager;
  5980. /***/
  5981. }),
  5982. /* 16 */
  5983. /***/ (function (module, exports, __webpack_require__) {
  5984. "use strict";
  5985. Object.defineProperty(exports, "__esModule", {
  5986. value: true
  5987. });
  5988. exports.PasswordPrompt = undefined;
  5989. 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; }; }();
  5990. var _ui_utils = __webpack_require__(0);
  5991. var _pdfjsLib = __webpack_require__(1);
  5992. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5993. var PasswordPrompt = function () {
  5994. function PasswordPrompt(options, overlayManager) {
  5995. var _this = this;
  5996. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5997. _classCallCheck(this, PasswordPrompt);
  5998. this.overlayName = options.overlayName;
  5999. this.container = options.container;
  6000. this.label = options.label;
  6001. this.input = options.input;
  6002. this.submitButton = options.submitButton;
  6003. this.cancelButton = options.cancelButton;
  6004. this.overlayManager = overlayManager;
  6005. this.l10n = l10n;
  6006. this.updateCallback = null;
  6007. this.reason = null;
  6008. this.submitButton.addEventListener('click', this.verify.bind(this));
  6009. this.cancelButton.addEventListener('click', this.close.bind(this));
  6010. this.input.addEventListener('keydown', function (e) {
  6011. if (e.keyCode === 13) {
  6012. _this.verify();
  6013. }
  6014. });
  6015. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  6016. }
  6017. _createClass(PasswordPrompt, [{
  6018. key: 'open',
  6019. value: function open() {
  6020. var _this2 = this;
  6021. this.overlayManager.open(this.overlayName).then(function () {
  6022. _this2.input.focus();
  6023. var promptString = void 0;
  6024. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  6025. promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
  6026. } else {
  6027. promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
  6028. }
  6029. promptString.then(function (msg) {
  6030. _this2.label.textContent = msg;
  6031. });
  6032. });
  6033. }
  6034. }, {
  6035. key: 'close',
  6036. value: function close() {
  6037. var _this3 = this;
  6038. this.overlayManager.close(this.overlayName).then(function () {
  6039. _this3.input.value = '';
  6040. });
  6041. }
  6042. }, {
  6043. key: 'verify',
  6044. value: function verify() {
  6045. var password = this.input.value;
  6046. if (password && password.length > 0) {
  6047. this.close();
  6048. return this.updateCallback(password);
  6049. }
  6050. }
  6051. }, {
  6052. key: 'setUpdateCallback',
  6053. value: function setUpdateCallback(updateCallback, reason) {
  6054. this.updateCallback = updateCallback;
  6055. this.reason = reason;
  6056. }
  6057. }]);
  6058. return PasswordPrompt;
  6059. }();
  6060. exports.PasswordPrompt = PasswordPrompt;
  6061. /***/
  6062. }),
  6063. /* 17 */
  6064. /***/ (function (module, exports, __webpack_require__) {
  6065. "use strict";
  6066. Object.defineProperty(exports, "__esModule", {
  6067. value: true
  6068. });
  6069. exports.PDFAttachmentViewer = undefined;
  6070. 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; }; }();
  6071. var _pdfjsLib = __webpack_require__(1);
  6072. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6073. var PDFAttachmentViewer = function () {
  6074. function PDFAttachmentViewer(_ref) {
  6075. var container = _ref.container,
  6076. eventBus = _ref.eventBus,
  6077. downloadManager = _ref.downloadManager;
  6078. _classCallCheck(this, PDFAttachmentViewer);
  6079. this.attachments = null;
  6080. this.container = container;
  6081. this.eventBus = eventBus;
  6082. this.downloadManager = downloadManager;
  6083. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  6084. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
  6085. }
  6086. _createClass(PDFAttachmentViewer, [{
  6087. key: 'reset',
  6088. value: function reset() {
  6089. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6090. this.attachments = null;
  6091. this.container.textContent = '';
  6092. if (!keepRenderedCapability) {
  6093. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  6094. }
  6095. }
  6096. }, {
  6097. key: '_dispatchEvent',
  6098. value: function _dispatchEvent(attachmentsCount) {
  6099. this.eventBus.dispatch('attachmentsloaded', {
  6100. source: this,
  6101. attachmentsCount: attachmentsCount
  6102. });
  6103. this._renderedCapability.resolve();
  6104. }
  6105. }, {
  6106. key: '_bindPdfLink',
  6107. value: function _bindPdfLink(button, content, filename) {
  6108. if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
  6109. throw new Error('bindPdfLink: ' + 'Unsupported "PDFJS.disableCreateObjectURL" value.');
  6110. }
  6111. var blobUrl = void 0;
  6112. button.onclick = function () {
  6113. if (!blobUrl) {
  6114. blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf');
  6115. }
  6116. var viewerUrl = void 0;
  6117. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
  6118. window.open(viewerUrl);
  6119. return false;
  6120. };
  6121. }
  6122. }, {
  6123. key: '_bindLink',
  6124. value: function _bindLink(button, content, filename) {
  6125. var _this = this;
  6126. button.onclick = function () {
  6127. _this.downloadManager.downloadData(content, filename, '');
  6128. return false;
  6129. };
  6130. }
  6131. }, {
  6132. key: 'render',
  6133. value: function render(_ref2) {
  6134. var attachments = _ref2.attachments,
  6135. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  6136. keepRenderedCapability = _ref2$keepRenderedCap === undefined ? false : _ref2$keepRenderedCap;
  6137. var attachmentsCount = 0;
  6138. if (this.attachments) {
  6139. this.reset(keepRenderedCapability === true);
  6140. }
  6141. this.attachments = attachments || null;
  6142. if (!attachments) {
  6143. this._dispatchEvent(attachmentsCount);
  6144. return;
  6145. }
  6146. var names = Object.keys(attachments).sort(function (a, b) {
  6147. return a.toLowerCase().localeCompare(b.toLowerCase());
  6148. });
  6149. attachmentsCount = names.length;
  6150. for (var i = 0; i < attachmentsCount; i++) {
  6151. var item = attachments[names[i]];
  6152. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  6153. var div = document.createElement('div');
  6154. div.className = 'attachmentsItem';
  6155. var button = document.createElement('button');
  6156. button.textContent = filename;
  6157. if (/\.pdf$/i.test(filename) && !_pdfjsLib.PDFJS.disableCreateObjectURL) {
  6158. this._bindPdfLink(button, item.content, filename);
  6159. } else {
  6160. this._bindLink(button, item.content, filename);
  6161. }
  6162. div.appendChild(button);
  6163. this.container.appendChild(div);
  6164. }
  6165. this._dispatchEvent(attachmentsCount);
  6166. }
  6167. }, {
  6168. key: '_appendAttachment',
  6169. value: function _appendAttachment(_ref3) {
  6170. var _this2 = this;
  6171. var id = _ref3.id,
  6172. filename = _ref3.filename,
  6173. content = _ref3.content;
  6174. this._renderedCapability.promise.then(function () {
  6175. var attachments = _this2.attachments;
  6176. if (!attachments) {
  6177. attachments = Object.create(null);
  6178. } else {
  6179. for (var name in attachments) {
  6180. if (id === name) {
  6181. return;
  6182. }
  6183. }
  6184. }
  6185. attachments[id] = {
  6186. filename: filename,
  6187. content: content
  6188. };
  6189. _this2.render({
  6190. attachments: attachments,
  6191. keepRenderedCapability: true
  6192. });
  6193. });
  6194. }
  6195. }]);
  6196. return PDFAttachmentViewer;
  6197. }();
  6198. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  6199. /***/
  6200. }),
  6201. /* 18 */
  6202. /***/ (function (module, exports, __webpack_require__) {
  6203. "use strict";
  6204. Object.defineProperty(exports, "__esModule", {
  6205. value: true
  6206. });
  6207. exports.PDFDocumentProperties = undefined;
  6208. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  6209. 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; }; }();
  6210. var _ui_utils = __webpack_require__(0);
  6211. var _pdfjsLib = __webpack_require__(1);
  6212. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6213. var DEFAULT_FIELD_CONTENT = '-';
  6214. var PDFDocumentProperties = function () {
  6215. function PDFDocumentProperties(_ref, overlayManager) {
  6216. var overlayName = _ref.overlayName,
  6217. fields = _ref.fields,
  6218. container = _ref.container,
  6219. closeButton = _ref.closeButton;
  6220. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  6221. _classCallCheck(this, PDFDocumentProperties);
  6222. this.overlayName = overlayName;
  6223. this.fields = fields;
  6224. this.container = container;
  6225. this.overlayManager = overlayManager;
  6226. this.l10n = l10n;
  6227. this._reset();
  6228. if (closeButton) {
  6229. closeButton.addEventListener('click', this.close.bind(this));
  6230. }
  6231. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  6232. }
  6233. _createClass(PDFDocumentProperties, [{
  6234. key: 'open',
  6235. value: function open() {
  6236. var _this = this;
  6237. var freezeFieldData = function freezeFieldData(data) {
  6238. Object.defineProperty(_this, 'fieldData', {
  6239. value: Object.freeze(data),
  6240. writable: false,
  6241. enumerable: true,
  6242. configurable: true
  6243. });
  6244. };
  6245. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  6246. if (_this.fieldData) {
  6247. _this._updateUI();
  6248. return;
  6249. }
  6250. _this.pdfDocument.getMetadata().then(function (_ref2) {
  6251. var info = _ref2.info,
  6252. metadata = _ref2.metadata;
  6253. return Promise.all([info, metadata, _this._parseFileSize(_this.maybeFileSize), _this._parseDate(info.CreationDate), _this._parseDate(info.ModDate)]);
  6254. }).then(function (_ref3) {
  6255. var _ref4 = _slicedToArray(_ref3, 5),
  6256. info = _ref4[0],
  6257. metadata = _ref4[1],
  6258. fileSize = _ref4[2],
  6259. creationDate = _ref4[3],
  6260. modificationDate = _ref4[4];
  6261. freezeFieldData({
  6262. 'fileName': (0, _ui_utils.getPDFFileNameFromURL)(_this.url),
  6263. 'fileSize': fileSize,
  6264. 'title': info.Title,
  6265. 'author': info.Author,
  6266. 'subject': info.Subject,
  6267. 'keywords': info.Keywords,
  6268. 'creationDate': creationDate,
  6269. 'modificationDate': modificationDate,
  6270. 'creator': info.Creator,
  6271. 'producer': info.Producer,
  6272. 'version': info.PDFFormatVersion,
  6273. 'pageCount': _this.pdfDocument.numPages
  6274. });
  6275. _this._updateUI();
  6276. return _this.pdfDocument.getDownloadInfo();
  6277. }).then(function (_ref5) {
  6278. var length = _ref5.length;
  6279. return _this._parseFileSize(length);
  6280. }).then(function (fileSize) {
  6281. var data = (0, _ui_utils.cloneObj)(_this.fieldData);
  6282. data['fileSize'] = fileSize;
  6283. freezeFieldData(data);
  6284. _this._updateUI();
  6285. });
  6286. });
  6287. }
  6288. }, {
  6289. key: 'close',
  6290. value: function close() {
  6291. this.overlayManager.close(this.overlayName);
  6292. }
  6293. }, {
  6294. key: 'setDocument',
  6295. value: function setDocument(pdfDocument, url) {
  6296. if (this.pdfDocument) {
  6297. this._reset();
  6298. this._updateUI(true);
  6299. }
  6300. if (!pdfDocument) {
  6301. return;
  6302. }
  6303. this.pdfDocument = pdfDocument;
  6304. this.url = url;
  6305. this._dataAvailableCapability.resolve();
  6306. }
  6307. }, {
  6308. key: 'setFileSize',
  6309. value: function setFileSize(fileSize) {
  6310. if (typeof fileSize === 'number' && fileSize > 0) {
  6311. this.maybeFileSize = fileSize;
  6312. }
  6313. }
  6314. }, {
  6315. key: '_reset',
  6316. value: function _reset() {
  6317. this.pdfDocument = null;
  6318. this.url = null;
  6319. this.maybeFileSize = 0;
  6320. delete this.fieldData;
  6321. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  6322. }
  6323. }, {
  6324. key: '_updateUI',
  6325. value: function _updateUI() {
  6326. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6327. //console.log(DEFAULT_FIELD_CONTENT);
  6328. if (reset || !this.fieldData) {
  6329. for (var id in this.fields) {
  6330. if (this.fields[id] !== null) {
  6331. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  6332. }
  6333. }
  6334. return;
  6335. }
  6336. if (this.overlayManager.active !== this.overlayName) {
  6337. return;
  6338. }
  6339. for (var _id in this.fields) {
  6340. var content = this.fieldData[_id];
  6341. if (this.fields[_id] !== null) {
  6342. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  6343. }
  6344. }
  6345. }
  6346. }, {
  6347. key: '_parseFileSize',
  6348. value: function _parseFileSize() {
  6349. var fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  6350. var kb = fileSize / 1024;
  6351. if (!kb) {
  6352. return Promise.resolve(undefined);
  6353. } else if (kb < 1024) {
  6354. return this.l10n.get('document_properties_kb', {
  6355. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  6356. size_b: fileSize.toLocaleString()
  6357. }, '{{size_kb}} KB ({{size_b}} bytes)');
  6358. }
  6359. return this.l10n.get('document_properties_mb', {
  6360. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  6361. size_b: fileSize.toLocaleString()
  6362. }, '{{size_mb}} MB ({{size_b}} bytes)');
  6363. }
  6364. }, {
  6365. key: '_parseDate',
  6366. value: function _parseDate(inputDate) {
  6367. if (!inputDate) {
  6368. return;
  6369. }
  6370. var dateToParse = inputDate;
  6371. if (dateToParse.substring(0, 2) === 'D:') {
  6372. dateToParse = dateToParse.substring(2);
  6373. }
  6374. var year = parseInt(dateToParse.substring(0, 4), 10);
  6375. var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
  6376. var day = parseInt(dateToParse.substring(6, 8), 10);
  6377. var hours = parseInt(dateToParse.substring(8, 10), 10);
  6378. var minutes = parseInt(dateToParse.substring(10, 12), 10);
  6379. var seconds = parseInt(dateToParse.substring(12, 14), 10);
  6380. var utRel = dateToParse.substring(14, 15);
  6381. var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
  6382. var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
  6383. if (utRel === '-') {
  6384. hours += offsetHours;
  6385. minutes += offsetMinutes;
  6386. } else if (utRel === '+') {
  6387. hours -= offsetHours;
  6388. minutes -= offsetMinutes;
  6389. }
  6390. var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
  6391. var dateString = date.toLocaleDateString();
  6392. var timeString = date.toLocaleTimeString();
  6393. return this.l10n.get('document_properties_date_string', {
  6394. date: dateString,
  6395. time: timeString
  6396. }, '{{date}}, {{time}}');
  6397. }
  6398. }]);
  6399. return PDFDocumentProperties;
  6400. }();
  6401. exports.PDFDocumentProperties = PDFDocumentProperties;
  6402. /***/
  6403. }),
  6404. /* 19 */
  6405. /***/ (function (module, exports, __webpack_require__) {
  6406. "use strict";
  6407. Object.defineProperty(exports, "__esModule", {
  6408. value: true
  6409. });
  6410. exports.PDFFindBar = undefined;
  6411. 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; }; }();
  6412. var _pdf_find_controller = __webpack_require__(7);
  6413. var _ui_utils = __webpack_require__(0);
  6414. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6415. var PDFFindBar = function () {
  6416. function PDFFindBar(options) {
  6417. var _this = this;
  6418. var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
  6419. _classCallCheck(this, PDFFindBar);
  6420. this.opened = false;
  6421. this.bar = options.bar || null;
  6422. this.toggleButton = options.toggleButton || null;
  6423. this.findField = options.findField || null;
  6424. this.highlightAll = options.highlightAllCheckbox || null;
  6425. this.caseSensitive = options.caseSensitiveCheckbox || null;
  6426. this.findMsg = options.findMsg || null;
  6427. this.findResultsCount = options.findResultsCount || null;
  6428. this.findStatusIcon = options.findStatusIcon || null;
  6429. this.findPreviousButton = options.findPreviousButton || null;
  6430. this.findNextButton = options.findNextButton || null;
  6431. this.findController = options.findController || null;
  6432. this.eventBus = options.eventBus;
  6433. this.l10n = l10n;
  6434. if (this.findController === null) {
  6435. throw new Error('PDFFindBar cannot be used without a ' + 'PDFFindController instance.');
  6436. }
  6437. this.toggleButton.addEventListener('click', function () {
  6438. _this.toggle();
  6439. });
  6440. this.findField.addEventListener('input', function () {
  6441. _this.dispatchEvent('');
  6442. });
  6443. this.bar.addEventListener('keydown', function (e) {
  6444. switch (e.keyCode) {
  6445. case 13:
  6446. if (e.target === _this.findField) {
  6447. _this.dispatchEvent('again', e.shiftKey);
  6448. }
  6449. break;
  6450. case 27:
  6451. _this.close();
  6452. break;
  6453. }
  6454. });
  6455. this.findPreviousButton.addEventListener('click', function () {
  6456. _this.dispatchEvent('again', true);
  6457. });
  6458. this.findNextButton.addEventListener('click', function () {
  6459. _this.dispatchEvent('again', false);
  6460. });
  6461. this.highlightAll.addEventListener('click', function () {
  6462. _this.dispatchEvent('highlightallchange');
  6463. });
  6464. this.caseSensitive.addEventListener('click', function () {
  6465. _this.dispatchEvent('casesensitivitychange');
  6466. });
  6467. this.eventBus.on('resize', this._adjustWidth.bind(this));
  6468. }
  6469. _createClass(PDFFindBar, [{
  6470. key: 'reset',
  6471. value: function reset() {
  6472. this.updateUIState();
  6473. }
  6474. }, {
  6475. key: 'dispatchEvent',
  6476. value: function dispatchEvent(type, findPrev) {
  6477. this.eventBus.dispatch('find', {
  6478. source: this,
  6479. type: type,
  6480. query: this.findField.value,
  6481. caseSensitive: this.caseSensitive.checked,
  6482. phraseSearch: true,
  6483. highlightAll: this.highlightAll.checked,
  6484. findPrevious: findPrev
  6485. });
  6486. }
  6487. }, {
  6488. key: 'updateUIState',
  6489. value: function updateUIState(state, previous, matchCount) {
  6490. var _this2 = this;
  6491. var notFound = false;
  6492. var findMsg = '';
  6493. var status = '';
  6494. switch (state) {
  6495. case _pdf_find_controller.FindState.FOUND:
  6496. break;
  6497. case _pdf_find_controller.FindState.PENDING:
  6498. status = 'pending';
  6499. break;
  6500. case _pdf_find_controller.FindState.NOT_FOUND:
  6501. findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
  6502. notFound = true;
  6503. break;
  6504. case _pdf_find_controller.FindState.WRAPPED:
  6505. if (previous) {
  6506. findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
  6507. } else {
  6508. findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
  6509. }
  6510. break;
  6511. }
  6512. if (notFound) {
  6513. this.findField.classList.add('notFound');
  6514. } else {
  6515. this.findField.classList.remove('notFound');
  6516. }
  6517. this.findField.setAttribute('data-status', status);
  6518. Promise.resolve(findMsg).then(function (msg) {
  6519. _this2.findMsg.textContent = msg;
  6520. _this2._adjustWidth();
  6521. });
  6522. this.updateResultsCount(matchCount);
  6523. }
  6524. }, {
  6525. key: 'updateResultsCount',
  6526. value: function updateResultsCount(matchCount) {
  6527. if (!this.findResultsCount) {
  6528. return;
  6529. }
  6530. if (!matchCount) {
  6531. this.findResultsCount.classList.add('hidden');
  6532. this.findResultsCount.textContent = '';
  6533. } else {
  6534. this.findResultsCount.textContent = matchCount.toLocaleString();
  6535. this.findResultsCount.classList.remove('hidden');
  6536. }
  6537. this._adjustWidth();
  6538. }
  6539. }, {
  6540. key: 'open',
  6541. value: function open() {
  6542. if (!this.opened) {
  6543. this.opened = true;
  6544. this.toggleButton.classList.add('toggled');
  6545. this.bar.classList.remove('hidden');
  6546. }
  6547. this.findField.select();
  6548. this.findField.focus();
  6549. this._adjustWidth();
  6550. }
  6551. }, {
  6552. key: 'close',
  6553. value: function close() {
  6554. if (!this.opened) {
  6555. return;
  6556. }
  6557. this.opened = false;
  6558. this.toggleButton.classList.remove('toggled');
  6559. this.bar.classList.add('hidden');
  6560. this.findController.active = false;
  6561. }
  6562. }, {
  6563. key: 'toggle',
  6564. value: function toggle() {
  6565. if (this.opened) {
  6566. this.close();
  6567. } else {
  6568. this.open();
  6569. }
  6570. }
  6571. }, {
  6572. key: '_adjustWidth',
  6573. value: function _adjustWidth() {
  6574. if (!this.opened) {
  6575. return;
  6576. }
  6577. this.bar.classList.remove('wrapContainers');
  6578. var findbarHeight = this.bar.clientHeight;
  6579. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  6580. if (findbarHeight > inputContainerHeight) {
  6581. this.bar.classList.add('wrapContainers');
  6582. }
  6583. }
  6584. }]);
  6585. return PDFFindBar;
  6586. }();
  6587. exports.PDFFindBar = PDFFindBar;
  6588. /***/
  6589. }),
  6590. /* 20 */
  6591. /***/ (function (module, exports, __webpack_require__) {
  6592. "use strict";
  6593. Object.defineProperty(exports, "__esModule", {
  6594. value: true
  6595. });
  6596. exports.PDFHistory = undefined;
  6597. var _dom_events = __webpack_require__(2);
  6598. function PDFHistory(options) {
  6599. this.linkService = options.linkService;
  6600. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  6601. this.initialized = false;
  6602. this.initialDestination = null;
  6603. this.initialBookmark = null;
  6604. }
  6605. PDFHistory.prototype = {
  6606. initialize: function pdfHistoryInitialize(fingerprint) {
  6607. this.initialized = true;
  6608. this.reInitialized = false;
  6609. this.allowHashChange = true;
  6610. this.historyUnlocked = true;
  6611. this.isViewerInPresentationMode = false;
  6612. this.previousHash = window.location.hash.substring(1);
  6613. this.currentBookmark = '';
  6614. this.currentPage = 0;
  6615. this.updatePreviousBookmark = false;
  6616. this.previousBookmark = '';
  6617. this.previousPage = 0;
  6618. this.nextHashParam = '';
  6619. this.fingerprint = fingerprint;
  6620. this.currentUid = this.uid = 0;
  6621. this.current = {};
  6622. var state = window.history.state;
  6623. if (this._isStateObjectDefined(state)) {
  6624. if (state.target.dest) {
  6625. this.initialDestination = state.target.dest;
  6626. } else {
  6627. this.initialBookmark = state.target.hash;
  6628. }
  6629. this.currentUid = state.uid;
  6630. this.uid = state.uid + 1;
  6631. this.current = state.target;
  6632. } else {
  6633. if (state && state.fingerprint && this.fingerprint !== state.fingerprint) {
  6634. this.reInitialized = true;
  6635. }
  6636. this._pushOrReplaceState({ fingerprint: this.fingerprint }, true);
  6637. }
  6638. var self = this;
  6639. window.addEventListener('popstate', function pdfHistoryPopstate(evt) {
  6640. if (!self.historyUnlocked) {
  6641. return;
  6642. }
  6643. if (evt.state) {
  6644. self._goTo(evt.state);
  6645. return;
  6646. }
  6647. if (self.uid === 0) {
  6648. var previousParams = self.previousHash && self.currentBookmark && self.previousHash !== self.currentBookmark ? {
  6649. hash: self.currentBookmark,
  6650. page: self.currentPage
  6651. } : { page: 1 };
  6652. replacePreviousHistoryState(previousParams, function () {
  6653. updateHistoryWithCurrentHash();
  6654. });
  6655. } else {
  6656. updateHistoryWithCurrentHash();
  6657. }
  6658. });
  6659. function updateHistoryWithCurrentHash() {
  6660. self.previousHash = window.location.hash.slice(1);
  6661. self._pushToHistory({ hash: self.previousHash }, false, true);
  6662. self._updatePreviousBookmark();
  6663. }
  6664. function replacePreviousHistoryState(params, callback) {
  6665. self.historyUnlocked = false;
  6666. self.allowHashChange = false;
  6667. window.addEventListener('popstate', rewriteHistoryAfterBack);
  6668. history.back();
  6669. function rewriteHistoryAfterBack() {
  6670. window.removeEventListener('popstate', rewriteHistoryAfterBack);
  6671. window.addEventListener('popstate', rewriteHistoryAfterForward);
  6672. self._pushToHistory(params, false, true);
  6673. history.forward();
  6674. }
  6675. function rewriteHistoryAfterForward() {
  6676. window.removeEventListener('popstate', rewriteHistoryAfterForward);
  6677. self.allowHashChange = true;
  6678. self.historyUnlocked = true;
  6679. callback();
  6680. }
  6681. }
  6682. function pdfHistoryBeforeUnload() {
  6683. var previousParams = self._getPreviousParams(null, true);
  6684. if (previousParams) {
  6685. var replacePrevious = !self.current.dest && self.current.hash !== self.previousHash;
  6686. self._pushToHistory(previousParams, false, replacePrevious);
  6687. self._updatePreviousBookmark();
  6688. }
  6689. window.removeEventListener('beforeunload', pdfHistoryBeforeUnload);
  6690. }
  6691. window.addEventListener('beforeunload', pdfHistoryBeforeUnload);
  6692. window.addEventListener('pageshow', function pdfHistoryPageShow(evt) {
  6693. window.addEventListener('beforeunload', pdfHistoryBeforeUnload);
  6694. });
  6695. self.eventBus.on('presentationmodechanged', function (e) {
  6696. self.isViewerInPresentationMode = e.active;
  6697. });
  6698. },
  6699. clearHistoryState: function pdfHistory_clearHistoryState() {
  6700. this._pushOrReplaceState(null, true);
  6701. },
  6702. _isStateObjectDefined: function pdfHistory_isStateObjectDefined(state) {
  6703. return state && state.uid >= 0 && state.fingerprint && this.fingerprint === state.fingerprint && state.target && state.target.hash ? true : false;
  6704. },
  6705. _pushOrReplaceState: function pdfHistory_pushOrReplaceState(stateObj, replace) {
  6706. if (replace) {
  6707. window.history.replaceState(stateObj, '', document.URL);
  6708. } else {
  6709. window.history.pushState(stateObj, '', document.URL);
  6710. }
  6711. },
  6712. get isHashChangeUnlocked() {
  6713. if (!this.initialized) {
  6714. return true;
  6715. }
  6716. return this.allowHashChange;
  6717. },
  6718. _updatePreviousBookmark: function pdfHistory_updatePreviousBookmark() {
  6719. if (this.updatePreviousBookmark && this.currentBookmark && this.currentPage) {
  6720. this.previousBookmark = this.currentBookmark;
  6721. this.previousPage = this.currentPage;
  6722. this.updatePreviousBookmark = false;
  6723. }
  6724. },
  6725. updateCurrentBookmark: function pdfHistoryUpdateCurrentBookmark(bookmark, pageNum) {
  6726. if (this.initialized) {
  6727. this.currentBookmark = bookmark.substring(1);
  6728. this.currentPage = pageNum | 0;
  6729. this._updatePreviousBookmark();
  6730. }
  6731. },
  6732. updateNextHashParam: function pdfHistoryUpdateNextHashParam(param) {
  6733. if (this.initialized) {
  6734. this.nextHashParam = param;
  6735. }
  6736. },
  6737. push: function pdfHistoryPush(params, isInitialBookmark) {
  6738. if (!(this.initialized && this.historyUnlocked)) {
  6739. return;
  6740. }
  6741. if (params.dest && !params.hash) {
  6742. params.hash = this.current.hash && this.current.dest && this.current.dest === params.dest ? this.current.hash : this.linkService.getDestinationHash(params.dest).split('#')[1];
  6743. }
  6744. if (params.page) {
  6745. params.page |= 0;
  6746. }
  6747. if (isInitialBookmark) {
  6748. var target = window.history.state.target;
  6749. if (!target) {
  6750. this._pushToHistory(params, false);
  6751. this.previousHash = window.location.hash.substring(1);
  6752. }
  6753. this.updatePreviousBookmark = this.nextHashParam ? false : true;
  6754. if (target) {
  6755. this._updatePreviousBookmark();
  6756. }
  6757. return;
  6758. }
  6759. if (this.nextHashParam) {
  6760. if (this.nextHashParam === params.hash) {
  6761. this.nextHashParam = null;
  6762. this.updatePreviousBookmark = true;
  6763. return;
  6764. }
  6765. this.nextHashParam = null;
  6766. }
  6767. if (params.hash) {
  6768. if (this.current.hash) {
  6769. if (this.current.hash !== params.hash) {
  6770. this._pushToHistory(params, true);
  6771. } else {
  6772. if (!this.current.page && params.page) {
  6773. this._pushToHistory(params, false, true);
  6774. }
  6775. this.updatePreviousBookmark = true;
  6776. }
  6777. } else {
  6778. this._pushToHistory(params, true);
  6779. }
  6780. } else if (this.current.page && params.page && this.current.page !== params.page) {
  6781. this._pushToHistory(params, true);
  6782. }
  6783. },
  6784. _getPreviousParams: function pdfHistory_getPreviousParams(onlyCheckPage, beforeUnload) {
  6785. if (!(this.currentBookmark && this.currentPage)) {
  6786. return null;
  6787. } else if (this.updatePreviousBookmark) {
  6788. this.updatePreviousBookmark = false;
  6789. }
  6790. if (this.uid > 0 && !(this.previousBookmark && this.previousPage)) {
  6791. return null;
  6792. }
  6793. if (!this.current.dest && !onlyCheckPage || beforeUnload) {
  6794. if (this.previousBookmark === this.currentBookmark) {
  6795. return null;
  6796. }
  6797. } else if (this.current.page || onlyCheckPage) {
  6798. if (this.previousPage === this.currentPage) {
  6799. return null;
  6800. }
  6801. } else {
  6802. return null;
  6803. }
  6804. var params = {
  6805. hash: this.currentBookmark,
  6806. page: this.currentPage
  6807. };
  6808. if (this.isViewerInPresentationMode) {
  6809. params.hash = null;
  6810. }
  6811. return params;
  6812. },
  6813. _stateObj: function pdfHistory_stateObj(params) {
  6814. return {
  6815. fingerprint: this.fingerprint,
  6816. uid: this.uid,
  6817. target: params
  6818. };
  6819. },
  6820. _pushToHistory: function pdfHistory_pushToHistory(params, addPrevious, overwrite) {
  6821. if (!this.initialized) {
  6822. return;
  6823. }
  6824. if (!params.hash && params.page) {
  6825. params.hash = 'page=' + params.page;
  6826. }
  6827. if (addPrevious && !overwrite) {
  6828. var previousParams = this._getPreviousParams();
  6829. if (previousParams) {
  6830. var replacePrevious = !this.current.dest && this.current.hash !== this.previousHash;
  6831. this._pushToHistory(previousParams, false, replacePrevious);
  6832. }
  6833. }
  6834. this._pushOrReplaceState(this._stateObj(params), overwrite || this.uid === 0);
  6835. this.currentUid = this.uid++;
  6836. this.current = params;
  6837. this.updatePreviousBookmark = true;
  6838. },
  6839. _goTo: function pdfHistory_goTo(state) {
  6840. if (!(this.initialized && this.historyUnlocked && this._isStateObjectDefined(state))) {
  6841. return;
  6842. }
  6843. if (!this.reInitialized && state.uid < this.currentUid) {
  6844. var previousParams = this._getPreviousParams(true);
  6845. if (previousParams) {
  6846. this._pushToHistory(this.current, false);
  6847. this._pushToHistory(previousParams, false);
  6848. this.currentUid = state.uid;
  6849. window.history.back();
  6850. return;
  6851. }
  6852. }
  6853. this.historyUnlocked = false;
  6854. if (state.target.dest) {
  6855. this.linkService.navigateTo(state.target.dest);
  6856. } else {
  6857. this.linkService.setHash(state.target.hash);
  6858. }
  6859. this.currentUid = state.uid;
  6860. if (state.uid > this.uid) {
  6861. this.uid = state.uid;
  6862. }
  6863. this.current = state.target;
  6864. this.updatePreviousBookmark = true;
  6865. var currentHash = window.location.hash.substring(1);
  6866. if (this.previousHash !== currentHash) {
  6867. this.allowHashChange = false;
  6868. }
  6869. this.previousHash = currentHash;
  6870. this.historyUnlocked = true;
  6871. },
  6872. back: function pdfHistoryBack() {
  6873. this.go(-1);
  6874. },
  6875. forward: function pdfHistoryForward() {
  6876. this.go(1);
  6877. },
  6878. go: function pdfHistoryGo(direction) {
  6879. if (this.initialized && this.historyUnlocked) {
  6880. var state = window.history.state;
  6881. if (direction === -1 && state && state.uid > 0) {
  6882. window.history.back();
  6883. } else if (direction === 1 && state && state.uid < this.uid - 1) {
  6884. window.history.forward();
  6885. }
  6886. }
  6887. }
  6888. };
  6889. exports.PDFHistory = PDFHistory;
  6890. /***/
  6891. }),
  6892. /* 21 */
  6893. /***/ (function (module, exports, __webpack_require__) {
  6894. "use strict";
  6895. Object.defineProperty(exports, "__esModule", {
  6896. value: true
  6897. });
  6898. exports.PDFOutlineViewer = undefined;
  6899. 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; }; }();
  6900. var _pdfjsLib = __webpack_require__(1);
  6901. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6902. var DEFAULT_TITLE = '\u2013';
  6903. var PDFOutlineViewer = function () {
  6904. function PDFOutlineViewer(_ref) {
  6905. var container = _ref.container,
  6906. linkService = _ref.linkService,
  6907. eventBus = _ref.eventBus;
  6908. _classCallCheck(this, PDFOutlineViewer);
  6909. this.outline = null;
  6910. this.lastToggleIsShow = true;
  6911. this.container = container;
  6912. this.linkService = linkService;
  6913. this.eventBus = eventBus;
  6914. }
  6915. _createClass(PDFOutlineViewer, [{
  6916. key: 'reset',
  6917. value: function reset() {
  6918. this.outline = null;
  6919. this.lastToggleIsShow = true;
  6920. this.container.textContent = '';
  6921. this.container.classList.remove('outlineWithDeepNesting');
  6922. }
  6923. }, {
  6924. key: '_dispatchEvent',
  6925. value: function _dispatchEvent(outlineCount) {
  6926. this.eventBus.dispatch('outlineloaded', {
  6927. source: this,
  6928. outlineCount: outlineCount
  6929. });
  6930. }
  6931. }, {
  6932. key: '_bindLink',
  6933. value: function _bindLink(element, item) {
  6934. var _this = this;
  6935. if (item.url) {
  6936. (0, _pdfjsLib.addLinkAttributes)(element, {
  6937. url: item.url,
  6938. target: item.newWindow ? _pdfjsLib.PDFJS.LinkTarget.BLANK : undefined
  6939. });
  6940. return;
  6941. }
  6942. var destination = item.dest;
  6943. element.href = this.linkService.getDestinationHash(destination);
  6944. element.onclick = function () {
  6945. if (destination) {
  6946. _this.linkService.navigateTo(destination);
  6947. }
  6948. return false;
  6949. };
  6950. }
  6951. }, {
  6952. key: '_setStyles',
  6953. value: function _setStyles(element, item) {
  6954. var styleStr = '';
  6955. if (item.bold) {
  6956. styleStr += 'font-weight: bold;';
  6957. }
  6958. if (item.italic) {
  6959. styleStr += 'font-style: italic;';
  6960. }
  6961. if (styleStr) {
  6962. element.setAttribute('style', styleStr);
  6963. }
  6964. }
  6965. }, {
  6966. key: '_addToggleButton',
  6967. value: function _addToggleButton(div) {
  6968. var _this2 = this;
  6969. var toggler = document.createElement('div');
  6970. toggler.className = 'outlineItemToggler';
  6971. toggler.onclick = function (evt) {
  6972. evt.stopPropagation();
  6973. toggler.classList.toggle('outlineItemsHidden');
  6974. if (evt.shiftKey) {
  6975. var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
  6976. _this2._toggleOutlineItem(div, shouldShowAll);
  6977. }
  6978. };
  6979. div.insertBefore(toggler, div.firstChild);
  6980. }
  6981. }, {
  6982. key: '_toggleOutlineItem',
  6983. value: function _toggleOutlineItem(root, show) {
  6984. this.lastToggleIsShow = show;
  6985. var togglers = root.querySelectorAll('.outlineItemToggler');
  6986. for (var i = 0, ii = togglers.length; i < ii; ++i) {
  6987. togglers[i].classList[show ? 'remove' : 'add']('outlineItemsHidden');
  6988. }
  6989. }
  6990. }, {
  6991. key: 'toggleOutlineTree',
  6992. value: function toggleOutlineTree() {
  6993. if (!this.outline) {
  6994. return;
  6995. }
  6996. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  6997. }
  6998. }, {
  6999. key: 'render',
  7000. value: function render(_ref2) {
  7001. var outline = _ref2.outline;
  7002. var outlineCount = 0;
  7003. if (this.outline) {
  7004. this.reset();
  7005. }
  7006. this.outline = outline || null;
  7007. if (!outline) {
  7008. this._dispatchEvent(outlineCount);
  7009. return;
  7010. }
  7011. var fragment = document.createDocumentFragment();
  7012. var queue = [{
  7013. parent: fragment,
  7014. items: this.outline
  7015. }];
  7016. var hasAnyNesting = false;
  7017. while (queue.length > 0) {
  7018. var levelData = queue.shift();
  7019. for (var i = 0, len = levelData.items.length; i < len; i++) {
  7020. var item = levelData.items[i];
  7021. var div = document.createElement('div');
  7022. div.className = 'outlineItem';
  7023. var element = document.createElement('a');
  7024. this._bindLink(element, item);
  7025. this._setStyles(element, item);
  7026. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  7027. div.appendChild(element);
  7028. if (item.items.length > 0) {
  7029. hasAnyNesting = true;
  7030. this._addToggleButton(div);
  7031. var itemsDiv = document.createElement('div');
  7032. itemsDiv.className = 'outlineItems';
  7033. div.appendChild(itemsDiv);
  7034. queue.push({
  7035. parent: itemsDiv,
  7036. items: item.items
  7037. });
  7038. }
  7039. levelData.parent.appendChild(div);
  7040. outlineCount++;
  7041. }
  7042. }
  7043. if (hasAnyNesting) {
  7044. this.container.classList.add('outlineWithDeepNesting');
  7045. }
  7046. this.container.appendChild(fragment);
  7047. this._dispatchEvent(outlineCount);
  7048. }
  7049. }]);
  7050. return PDFOutlineViewer;
  7051. }();
  7052. exports.PDFOutlineViewer = PDFOutlineViewer;
  7053. /***/
  7054. }),
  7055. /* 22 */
  7056. /***/ (function (module, exports, __webpack_require__) {
  7057. "use strict";
  7058. Object.defineProperty(exports, "__esModule", {
  7059. value: true
  7060. });
  7061. exports.PDFPageView = undefined;
  7062. 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; }; }();
  7063. var _ui_utils = __webpack_require__(0);
  7064. var _pdfjsLib = __webpack_require__(1);
  7065. var _dom_events = __webpack_require__(2);
  7066. var _pdf_rendering_queue = __webpack_require__(3);
  7067. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7068. var PDFPageView = function () {
  7069. function PDFPageView(options) {
  7070. _classCallCheck(this, PDFPageView);
  7071. var container = options.container;
  7072. var defaultViewport = options.defaultViewport;
  7073. this.id = options.id;
  7074. this.renderingId = 'page' + this.id;
  7075. this.pdfPage = null;
  7076. this.pageLabel = null;
  7077. this.rotation = 0;
  7078. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  7079. this.viewport = defaultViewport;
  7080. this.pdfPageRotate = defaultViewport.rotation;
  7081. this.hasRestrictedScaling = false;
  7082. this.enhanceTextSelection = options.enhanceTextSelection || false;
  7083. this.renderInteractiveForms = options.renderInteractiveForms || false;
  7084. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  7085. this.renderingQueue = options.renderingQueue;
  7086. this.textLayerFactory = options.textLayerFactory;
  7087. this.annotationLayerFactory = options.annotationLayerFactory;
  7088. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  7089. this.l10n = options.l10n || _ui_utils.NullL10n;
  7090. this.paintTask = null;
  7091. this.paintedViewportMap = new WeakMap();
  7092. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  7093. this.resume = null;
  7094. this.error = null;
  7095. this.onBeforeDraw = null;
  7096. this.onAfterDraw = null;
  7097. this.annotationLayer = null;
  7098. this.textLayer = null;
  7099. this.zoomLayer = null;
  7100. var div = document.createElement('div');
  7101. div.className = 'page';
  7102. div.style.width = Math.floor(this.viewport.width) + 'px';
  7103. div.style.height = Math.floor(this.viewport.height) + 'px';
  7104. div.setAttribute('data-page-number', this.id);
  7105. this.div = div;
  7106. container.appendChild(div);
  7107. }
  7108. _createClass(PDFPageView, [{
  7109. key: 'setPdfPage',
  7110. value: function setPdfPage(pdfPage) {
  7111. this.pdfPage = pdfPage;
  7112. this.pdfPageRotate = pdfPage.rotate;
  7113. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  7114. this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
  7115. this.stats = pdfPage.stats;
  7116. this.reset();
  7117. }
  7118. }, {
  7119. key: 'destroy',
  7120. value: function destroy() {
  7121. this.reset();
  7122. if (this.pdfPage) {
  7123. this.pdfPage.cleanup();
  7124. this.pdfPage = null;
  7125. }
  7126. }
  7127. }, {
  7128. key: '_resetZoomLayer',
  7129. value: function _resetZoomLayer() {
  7130. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7131. if (!this.zoomLayer) {
  7132. return;
  7133. }
  7134. var zoomLayerCanvas = this.zoomLayer.firstChild;
  7135. this.paintedViewportMap.delete(zoomLayerCanvas);
  7136. zoomLayerCanvas.width = 0;
  7137. zoomLayerCanvas.height = 0;
  7138. if (removeFromDOM) {
  7139. this.zoomLayer.remove();
  7140. }
  7141. this.zoomLayer = null;
  7142. }
  7143. }, {
  7144. key: 'reset',
  7145. value: function reset() {
  7146. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7147. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7148. this.cancelRendering();
  7149. var div = this.div;
  7150. div.style.width = Math.floor(this.viewport.width) + 'px';
  7151. div.style.height = Math.floor(this.viewport.height) + 'px';
  7152. var childNodes = div.childNodes;
  7153. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  7154. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  7155. for (var i = childNodes.length - 1; i >= 0; i--) {
  7156. var node = childNodes[i];
  7157. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  7158. continue;
  7159. }
  7160. div.removeChild(node);
  7161. }
  7162. div.removeAttribute('data-loaded');
  7163. if (currentAnnotationNode) {
  7164. this.annotationLayer.hide();
  7165. } else {
  7166. this.annotationLayer = null;
  7167. }
  7168. if (!currentZoomLayerNode) {
  7169. if (this.canvas) {
  7170. this.paintedViewportMap.delete(this.canvas);
  7171. this.canvas.width = 0;
  7172. this.canvas.height = 0;
  7173. delete this.canvas;
  7174. }
  7175. this._resetZoomLayer();
  7176. }
  7177. if (this.svg) {
  7178. this.paintedViewportMap.delete(this.svg);
  7179. delete this.svg;
  7180. }
  7181. this.loadingIconDiv = document.createElement('div');
  7182. this.loadingIconDiv.className = 'loadingIcon';
  7183. div.appendChild(this.loadingIconDiv);
  7184. }
  7185. }, {
  7186. key: 'update',
  7187. value: function update(scale, rotation) {
  7188. this.scale = scale || this.scale;
  7189. if (typeof rotation !== 'undefined') {
  7190. this.rotation = rotation;
  7191. }
  7192. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  7193. this.viewport = this.viewport.clone({
  7194. scale: this.scale * _ui_utils.CSS_UNITS,
  7195. rotation: totalRotation
  7196. });
  7197. if (this.svg) {
  7198. this.cssTransform(this.svg, true);
  7199. this.eventBus.dispatch('pagerendered', {
  7200. source: this,
  7201. pageNumber: this.id,
  7202. cssTransform: true
  7203. });
  7204. return;
  7205. }
  7206. var isScalingRestricted = false;
  7207. if (this.canvas && _pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  7208. var outputScale = this.outputScale;
  7209. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > _pdfjsLib.PDFJS.maxCanvasPixels) {
  7210. isScalingRestricted = true;
  7211. }
  7212. }
  7213. if (this.canvas) {
  7214. if (_pdfjsLib.PDFJS.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  7215. this.cssTransform(this.canvas, true);
  7216. this.eventBus.dispatch('pagerendered', {
  7217. source: this,
  7218. pageNumber: this.id,
  7219. cssTransform: true
  7220. });
  7221. return;
  7222. }
  7223. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  7224. this.zoomLayer = this.canvas.parentNode;
  7225. this.zoomLayer.style.position = 'absolute';
  7226. }
  7227. }
  7228. if (this.zoomLayer) {
  7229. this.cssTransform(this.zoomLayer.firstChild);
  7230. }
  7231. this.reset(true, true);
  7232. }
  7233. }, {
  7234. key: 'cancelRendering',
  7235. value: function cancelRendering() {
  7236. if (this.paintTask) {
  7237. this.paintTask.cancel();
  7238. this.paintTask = null;
  7239. }
  7240. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  7241. this.resume = null;
  7242. if (this.textLayer) {
  7243. this.textLayer.cancel();
  7244. this.textLayer = null;
  7245. }
  7246. }
  7247. }, {
  7248. key: 'cssTransform',
  7249. value: function cssTransform(target) {
  7250. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7251. var width = this.viewport.width;
  7252. var height = this.viewport.height;
  7253. var div = this.div;
  7254. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  7255. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  7256. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  7257. var absRotation = Math.abs(relativeRotation);
  7258. var scaleX = 1,
  7259. scaleY = 1;
  7260. if (absRotation === 90 || absRotation === 270) {
  7261. scaleX = height / width;
  7262. scaleY = width / height;
  7263. }
  7264. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  7265. _pdfjsLib.CustomStyle.setProp('transform', target, cssTransform);
  7266. if (this.textLayer) {
  7267. var textLayerViewport = this.textLayer.viewport;
  7268. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  7269. var textAbsRotation = Math.abs(textRelativeRotation);
  7270. var scale = width / textLayerViewport.width;
  7271. if (textAbsRotation === 90 || textAbsRotation === 270) {
  7272. scale = width / textLayerViewport.height;
  7273. }
  7274. var textLayerDiv = this.textLayer.textLayerDiv;
  7275. var transX = void 0,
  7276. transY = void 0;
  7277. switch (textAbsRotation) {
  7278. case 0:
  7279. transX = transY = 0;
  7280. break;
  7281. case 90:
  7282. transX = 0;
  7283. transY = '-' + textLayerDiv.style.height;
  7284. break;
  7285. case 180:
  7286. transX = '-' + textLayerDiv.style.width;
  7287. transY = '-' + textLayerDiv.style.height;
  7288. break;
  7289. case 270:
  7290. transX = '-' + textLayerDiv.style.width;
  7291. transY = 0;
  7292. break;
  7293. default:
  7294. console.error('Bad rotation value.');
  7295. break;
  7296. }
  7297. _pdfjsLib.CustomStyle.setProp('transform', textLayerDiv, 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')');
  7298. _pdfjsLib.CustomStyle.setProp('transformOrigin', textLayerDiv, '0% 0%');
  7299. }
  7300. if (redrawAnnotations && this.annotationLayer) {
  7301. this.annotationLayer.render(this.viewport, 'display');
  7302. }
  7303. }
  7304. }, {
  7305. key: 'getPagePoint',
  7306. value: function getPagePoint(x, y) {
  7307. return this.viewport.convertToPdfPoint(x, y);
  7308. }
  7309. }, {
  7310. key: 'draw',
  7311. value: function draw() {
  7312. var _this = this;
  7313. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  7314. console.error('Must be in new state before drawing');
  7315. this.reset();
  7316. }
  7317. if (!this.pdfPage) {
  7318. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  7319. return Promise.reject(new Error('Page is not loaded'));
  7320. }
  7321. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  7322. var pdfPage = this.pdfPage;
  7323. var div = this.div;
  7324. var canvasWrapper = document.createElement('div');
  7325. canvasWrapper.style.width = div.style.width;
  7326. canvasWrapper.style.height = div.style.height;
  7327. canvasWrapper.classList.add('canvasWrapper');
  7328. if (this.annotationLayer && this.annotationLayer.div) {
  7329. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  7330. } else {
  7331. div.appendChild(canvasWrapper);
  7332. }
  7333. var textLayer = null;
  7334. if (this.textLayerFactory) {
  7335. var textLayerDiv = document.createElement('div');
  7336. textLayerDiv.className = 'textLayer';
  7337. textLayerDiv.style.width = canvasWrapper.style.width;
  7338. textLayerDiv.style.height = canvasWrapper.style.height;
  7339. if (this.annotationLayer && this.annotationLayer.div) {
  7340. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  7341. } else {
  7342. div.appendChild(textLayerDiv);
  7343. }
  7344. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.enhanceTextSelection);
  7345. }
  7346. this.textLayer = textLayer;
  7347. var renderContinueCallback = null;
  7348. if (this.renderingQueue) {
  7349. renderContinueCallback = function renderContinueCallback(cont) {
  7350. if (!_this.renderingQueue.isHighestPriority(_this)) {
  7351. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  7352. _this.resume = function () {
  7353. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  7354. cont();
  7355. };
  7356. return;
  7357. }
  7358. cont();
  7359. };
  7360. }
  7361. var finishPaintTask = function finishPaintTask(error) {
  7362. if (paintTask === _this.paintTask) {
  7363. _this.paintTask = null;
  7364. }
  7365. if (error === 'cancelled' || error instanceof _pdfjsLib.RenderingCancelledException) {
  7366. _this.error = null;
  7367. return Promise.resolve(undefined);
  7368. }
  7369. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  7370. if (_this.loadingIconDiv) {
  7371. div.removeChild(_this.loadingIconDiv);
  7372. delete _this.loadingIconDiv;
  7373. }
  7374. _this._resetZoomLayer(true);
  7375. _this.error = error;
  7376. _this.stats = pdfPage.stats;
  7377. if (_this.onAfterDraw) {
  7378. _this.onAfterDraw();
  7379. }
  7380. _this.eventBus.dispatch('pagerendered', {
  7381. source: _this,
  7382. pageNumber: _this.id,
  7383. cssTransform: false
  7384. });
  7385. if (error) {
  7386. return Promise.reject(error);
  7387. }
  7388. return Promise.resolve(undefined);
  7389. };
  7390. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  7391. paintTask.onRenderContinue = renderContinueCallback;
  7392. this.paintTask = paintTask;
  7393. var resultPromise = paintTask.promise.then(function () {
  7394. return finishPaintTask(null).then(function () {
  7395. if (textLayer) {
  7396. var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true });
  7397. textLayer.setTextContentStream(readableStream);
  7398. textLayer.render();
  7399. }
  7400. });
  7401. }, function (reason) {
  7402. return finishPaintTask(reason);
  7403. });
  7404. if (this.annotationLayerFactory) {
  7405. if (!this.annotationLayer) {
  7406. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms, this.l10n);
  7407. }
  7408. this.annotationLayer.render(this.viewport, 'display');
  7409. }
  7410. div.setAttribute('data-loaded', true);
  7411. if (this.onBeforeDraw) {
  7412. this.onBeforeDraw();
  7413. }
  7414. return resultPromise;
  7415. }
  7416. }, {
  7417. key: 'paintOnCanvas',
  7418. value: function paintOnCanvas(canvasWrapper) {
  7419. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  7420. var result = {
  7421. promise: renderCapability.promise,
  7422. onRenderContinue: function onRenderContinue(cont) {
  7423. cont();
  7424. },
  7425. cancel: function cancel() {
  7426. renderTask.cancel();
  7427. }
  7428. };
  7429. var viewport = this.viewport;
  7430. var canvas = document.createElement('canvas');
  7431. canvas.id = this.renderingId;
  7432. canvas.setAttribute('hidden', 'hidden');
  7433. var isCanvasHidden = true;
  7434. var showCanvas = function showCanvas() {
  7435. if (isCanvasHidden) {
  7436. canvas.removeAttribute('hidden');
  7437. isCanvasHidden = false;
  7438. }
  7439. };
  7440. canvasWrapper.appendChild(canvas);
  7441. this.canvas = canvas;
  7442. canvas.mozOpaque = true;
  7443. var ctx = canvas.getContext('2d', { alpha: false });
  7444. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  7445. this.outputScale = outputScale;
  7446. if (_pdfjsLib.PDFJS.useOnlyCssZoom) {
  7447. var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });
  7448. outputScale.sx *= actualSizeViewport.width / viewport.width;
  7449. outputScale.sy *= actualSizeViewport.height / viewport.height;
  7450. outputScale.scaled = true;
  7451. }
  7452. if (_pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  7453. var pixelsInViewport = viewport.width * viewport.height;
  7454. var maxScale = Math.sqrt(_pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport);
  7455. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  7456. outputScale.sx = maxScale;
  7457. outputScale.sy = maxScale;
  7458. outputScale.scaled = true;
  7459. this.hasRestrictedScaling = true;
  7460. } else {
  7461. this.hasRestrictedScaling = false;
  7462. }
  7463. }
  7464. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  7465. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  7466. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  7467. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  7468. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  7469. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  7470. this.paintedViewportMap.set(canvas, viewport);
  7471. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  7472. var renderContext = {
  7473. canvasContext: ctx,
  7474. transform: transform,
  7475. viewport: this.viewport,
  7476. renderInteractiveForms: this.renderInteractiveForms
  7477. };
  7478. var renderTask = this.pdfPage.render(renderContext);
  7479. renderTask.onContinue = function (cont) {
  7480. showCanvas();
  7481. if (result.onRenderContinue) {
  7482. result.onRenderContinue(cont);
  7483. } else {
  7484. cont();
  7485. }
  7486. };
  7487. renderTask.promise.then(function () {
  7488. showCanvas();
  7489. renderCapability.resolve(undefined);
  7490. }, function (error) {
  7491. showCanvas();
  7492. renderCapability.reject(error);
  7493. });
  7494. return result;
  7495. }
  7496. }, {
  7497. key: 'paintOnSvg',
  7498. value: function paintOnSvg(wrapper) {
  7499. var _this2 = this;
  7500. var cancelled = false;
  7501. var ensureNotCancelled = function ensureNotCancelled() {
  7502. if (cancelled) {
  7503. if (_pdfjsLib.PDFJS.pdfjsNext) {
  7504. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  7505. } else {
  7506. throw 'cancelled';
  7507. }
  7508. }
  7509. };
  7510. var pdfPage = this.pdfPage;
  7511. var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });
  7512. var promise = pdfPage.getOperatorList().then(function (opList) {
  7513. ensureNotCancelled();
  7514. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  7515. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  7516. ensureNotCancelled();
  7517. _this2.svg = svg;
  7518. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  7519. svg.style.width = wrapper.style.width;
  7520. svg.style.height = wrapper.style.height;
  7521. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  7522. wrapper.appendChild(svg);
  7523. });
  7524. });
  7525. return {
  7526. promise: promise,
  7527. onRenderContinue: function onRenderContinue(cont) {
  7528. cont();
  7529. },
  7530. cancel: function cancel() {
  7531. cancelled = true;
  7532. }
  7533. };
  7534. }
  7535. }, {
  7536. key: 'setPageLabel',
  7537. value: function setPageLabel(label) {
  7538. this.pageLabel = typeof label === 'string' ? label : null;
  7539. if (this.pageLabel !== null) {
  7540. this.div.setAttribute('data-page-label', this.pageLabel);
  7541. } else {
  7542. this.div.removeAttribute('data-page-label');
  7543. }
  7544. }
  7545. }, {
  7546. key: 'width',
  7547. get: function get() {
  7548. return this.viewport.width;
  7549. }
  7550. }, {
  7551. key: 'height',
  7552. get: function get() {
  7553. return this.viewport.height;
  7554. }
  7555. }]);
  7556. return PDFPageView;
  7557. }();
  7558. exports.PDFPageView = PDFPageView;
  7559. /***/
  7560. }),
  7561. /* 23 */
  7562. /***/ (function (module, exports, __webpack_require__) {
  7563. "use strict";
  7564. Object.defineProperty(exports, "__esModule", {
  7565. value: true
  7566. });
  7567. exports.PDFPresentationMode = undefined;
  7568. 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; }; }();
  7569. var _ui_utils = __webpack_require__(0);
  7570. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7571. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  7572. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  7573. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  7574. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  7575. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  7576. var PAGE_SWITCH_THRESHOLD = 0.1;
  7577. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  7578. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  7579. var PDFPresentationMode = function () {
  7580. function PDFPresentationMode(_ref) {
  7581. var _this = this;
  7582. var container = _ref.container,
  7583. _ref$viewer = _ref.viewer,
  7584. viewer = _ref$viewer === undefined ? null : _ref$viewer,
  7585. pdfViewer = _ref.pdfViewer,
  7586. eventBus = _ref.eventBus,
  7587. _ref$contextMenuItems = _ref.contextMenuItems,
  7588. contextMenuItems = _ref$contextMenuItems === undefined ? null : _ref$contextMenuItems;
  7589. _classCallCheck(this, PDFPresentationMode);
  7590. this.container = container;
  7591. this.viewer = viewer || container.firstElementChild;
  7592. this.pdfViewer = pdfViewer;
  7593. this.eventBus = eventBus;
  7594. this.active = false;
  7595. this.args = null;
  7596. this.contextMenuOpen = false;
  7597. this.mouseScrollTimeStamp = 0;
  7598. this.mouseScrollDelta = 0;
  7599. this.touchSwipeState = null;
  7600. if (contextMenuItems) {
  7601. contextMenuItems.contextFirstPage.addEventListener('click', function () {
  7602. _this.contextMenuOpen = false;
  7603. _this.eventBus.dispatch('firstpage');
  7604. });
  7605. contextMenuItems.contextLastPage.addEventListener('click', function () {
  7606. _this.contextMenuOpen = false;
  7607. _this.eventBus.dispatch('lastpage');
  7608. });
  7609. contextMenuItems.contextPageRotateCw.addEventListener('click', function () {
  7610. _this.contextMenuOpen = false;
  7611. _this.eventBus.dispatch('rotatecw');
  7612. });
  7613. contextMenuItems.contextPageRotateCcw.addEventListener('click', function () {
  7614. _this.contextMenuOpen = false;
  7615. _this.eventBus.dispatch('rotateccw');
  7616. });
  7617. }
  7618. }
  7619. _createClass(PDFPresentationMode, [{
  7620. key: 'request',
  7621. value: function request() {
  7622. if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
  7623. return false;
  7624. }
  7625. this._addFullscreenChangeListeners();
  7626. this._setSwitchInProgress();
  7627. this._notifyStateChange();
  7628. if (this.container.requestFullscreen) {
  7629. this.container.requestFullscreen();
  7630. } else if (this.container.mozRequestFullScreen) {
  7631. this.container.mozRequestFullScreen();
  7632. } else if (this.container.webkitRequestFullscreen) {
  7633. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  7634. } else if (this.container.msRequestFullscreen) {
  7635. this.container.msRequestFullscreen();
  7636. } else {
  7637. return false;
  7638. }
  7639. this.args = {
  7640. page: this.pdfViewer.currentPageNumber,
  7641. previousScale: this.pdfViewer.currentScaleValue
  7642. };
  7643. return true;
  7644. }
  7645. }, {
  7646. key: '_mouseWheel',
  7647. value: function _mouseWheel(evt) {
  7648. if (!this.active) {
  7649. return;
  7650. }
  7651. evt.preventDefault();
  7652. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7653. var currentTime = new Date().getTime();
  7654. var storedTime = this.mouseScrollTimeStamp;
  7655. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7656. return;
  7657. }
  7658. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7659. this._resetMouseScrollState();
  7660. }
  7661. this.mouseScrollDelta += delta;
  7662. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7663. var totalDelta = this.mouseScrollDelta;
  7664. this._resetMouseScrollState();
  7665. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  7666. if (success) {
  7667. this.mouseScrollTimeStamp = currentTime;
  7668. }
  7669. }
  7670. }
  7671. }, {
  7672. key: '_goToPreviousPage',
  7673. value: function _goToPreviousPage() {
  7674. var page = this.pdfViewer.currentPageNumber;
  7675. if (page <= 1) {
  7676. return false;
  7677. }
  7678. this.pdfViewer.currentPageNumber = page - 1;
  7679. return true;
  7680. }
  7681. }, {
  7682. key: '_goToNextPage',
  7683. value: function _goToNextPage() {
  7684. var page = this.pdfViewer.currentPageNumber;
  7685. if (page >= this.pdfViewer.pagesCount) {
  7686. return false;
  7687. }
  7688. this.pdfViewer.currentPageNumber = page + 1;
  7689. return true;
  7690. }
  7691. }, {
  7692. key: '_notifyStateChange',
  7693. value: function _notifyStateChange() {
  7694. this.eventBus.dispatch('presentationmodechanged', {
  7695. source: this,
  7696. active: this.active,
  7697. switchInProgress: !!this.switchInProgress
  7698. });
  7699. }
  7700. }, {
  7701. key: '_setSwitchInProgress',
  7702. value: function _setSwitchInProgress() {
  7703. var _this2 = this;
  7704. if (this.switchInProgress) {
  7705. clearTimeout(this.switchInProgress);
  7706. }
  7707. this.switchInProgress = setTimeout(function () {
  7708. _this2._removeFullscreenChangeListeners();
  7709. delete _this2.switchInProgress;
  7710. _this2._notifyStateChange();
  7711. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  7712. }
  7713. }, {
  7714. key: '_resetSwitchInProgress',
  7715. value: function _resetSwitchInProgress() {
  7716. if (this.switchInProgress) {
  7717. clearTimeout(this.switchInProgress);
  7718. delete this.switchInProgress;
  7719. }
  7720. }
  7721. }, {
  7722. key: '_enter',
  7723. value: function _enter() {
  7724. var _this3 = this;
  7725. this.active = true;
  7726. this._resetSwitchInProgress();
  7727. this._notifyStateChange();
  7728. this.container.classList.add(ACTIVE_SELECTOR);
  7729. setTimeout(function () {
  7730. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  7731. _this3.pdfViewer.currentScaleValue = 'page-fit';
  7732. }, 0);
  7733. this._addWindowListeners();
  7734. this._showControls();
  7735. this.contextMenuOpen = false;
  7736. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  7737. window.getSelection().removeAllRanges();
  7738. }
  7739. }, {
  7740. key: '_exit',
  7741. value: function _exit() {
  7742. var _this4 = this;
  7743. var page = this.pdfViewer.currentPageNumber;
  7744. this.container.classList.remove(ACTIVE_SELECTOR);
  7745. setTimeout(function () {
  7746. _this4.active = false;
  7747. _this4._removeFullscreenChangeListeners();
  7748. _this4._notifyStateChange();
  7749. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  7750. _this4.pdfViewer.currentPageNumber = page;
  7751. _this4.args = null;
  7752. }, 0);
  7753. this._removeWindowListeners();
  7754. this._hideControls();
  7755. this._resetMouseScrollState();
  7756. this.container.removeAttribute('contextmenu');
  7757. this.contextMenuOpen = false;
  7758. }
  7759. }, {
  7760. key: '_mouseDown',
  7761. value: function _mouseDown(evt) {
  7762. if (this.contextMenuOpen) {
  7763. this.contextMenuOpen = false;
  7764. evt.preventDefault();
  7765. return;
  7766. }
  7767. if (evt.button === 0) {
  7768. var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
  7769. if (!isInternalLink) {
  7770. evt.preventDefault();
  7771. if (evt.shiftKey) {
  7772. this._goToPreviousPage();
  7773. } else {
  7774. this._goToNextPage();
  7775. }
  7776. }
  7777. }
  7778. }
  7779. }, {
  7780. key: '_contextMenu',
  7781. value: function _contextMenu() {
  7782. this.contextMenuOpen = true;
  7783. }
  7784. }, {
  7785. key: '_showControls',
  7786. value: function _showControls() {
  7787. var _this5 = this;
  7788. if (this.controlsTimeout) {
  7789. clearTimeout(this.controlsTimeout);
  7790. } else {
  7791. this.container.classList.add(CONTROLS_SELECTOR);
  7792. }
  7793. this.controlsTimeout = setTimeout(function () {
  7794. _this5.container.classList.remove(CONTROLS_SELECTOR);
  7795. delete _this5.controlsTimeout;
  7796. }, DELAY_BEFORE_HIDING_CONTROLS);
  7797. }
  7798. }, {
  7799. key: '_hideControls',
  7800. value: function _hideControls() {
  7801. if (!this.controlsTimeout) {
  7802. return;
  7803. }
  7804. clearTimeout(this.controlsTimeout);
  7805. this.container.classList.remove(CONTROLS_SELECTOR);
  7806. delete this.controlsTimeout;
  7807. }
  7808. }, {
  7809. key: '_resetMouseScrollState',
  7810. value: function _resetMouseScrollState() {
  7811. this.mouseScrollTimeStamp = 0;
  7812. this.mouseScrollDelta = 0;
  7813. }
  7814. }, {
  7815. key: '_touchSwipe',
  7816. value: function _touchSwipe(evt) {
  7817. if (!this.active) {
  7818. return;
  7819. }
  7820. if (evt.touches.length > 1) {
  7821. this.touchSwipeState = null;
  7822. return;
  7823. }
  7824. switch (evt.type) {
  7825. case 'touchstart':
  7826. this.touchSwipeState = {
  7827. startX: evt.touches[0].pageX,
  7828. startY: evt.touches[0].pageY,
  7829. endX: evt.touches[0].pageX,
  7830. endY: evt.touches[0].pageY
  7831. };
  7832. break;
  7833. case 'touchmove':
  7834. if (this.touchSwipeState === null) {
  7835. return;
  7836. }
  7837. this.touchSwipeState.endX = evt.touches[0].pageX;
  7838. this.touchSwipeState.endY = evt.touches[0].pageY;
  7839. evt.preventDefault();
  7840. break;
  7841. case 'touchend':
  7842. if (this.touchSwipeState === null) {
  7843. return;
  7844. }
  7845. var delta = 0;
  7846. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7847. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7848. var absAngle = Math.abs(Math.atan2(dy, dx));
  7849. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7850. delta = dx;
  7851. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7852. delta = dy;
  7853. }
  7854. if (delta > 0) {
  7855. this._goToPreviousPage();
  7856. } else if (delta < 0) {
  7857. this._goToNextPage();
  7858. }
  7859. break;
  7860. }
  7861. }
  7862. }, {
  7863. key: '_addWindowListeners',
  7864. value: function _addWindowListeners() {
  7865. this.showControlsBind = this._showControls.bind(this);
  7866. this.mouseDownBind = this._mouseDown.bind(this);
  7867. this.mouseWheelBind = this._mouseWheel.bind(this);
  7868. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  7869. this.contextMenuBind = this._contextMenu.bind(this);
  7870. this.touchSwipeBind = this._touchSwipe.bind(this);
  7871. window.addEventListener('mousemove', this.showControlsBind);
  7872. window.addEventListener('mousedown', this.mouseDownBind);
  7873. window.addEventListener('wheel', this.mouseWheelBind);
  7874. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  7875. window.addEventListener('contextmenu', this.contextMenuBind);
  7876. window.addEventListener('touchstart', this.touchSwipeBind);
  7877. window.addEventListener('touchmove', this.touchSwipeBind);
  7878. window.addEventListener('touchend', this.touchSwipeBind);
  7879. }
  7880. }, {
  7881. key: '_removeWindowListeners',
  7882. value: function _removeWindowListeners() {
  7883. window.removeEventListener('mousemove', this.showControlsBind);
  7884. window.removeEventListener('mousedown', this.mouseDownBind);
  7885. window.removeEventListener('wheel', this.mouseWheelBind);
  7886. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  7887. window.removeEventListener('contextmenu', this.contextMenuBind);
  7888. window.removeEventListener('touchstart', this.touchSwipeBind);
  7889. window.removeEventListener('touchmove', this.touchSwipeBind);
  7890. window.removeEventListener('touchend', this.touchSwipeBind);
  7891. delete this.showControlsBind;
  7892. delete this.mouseDownBind;
  7893. delete this.mouseWheelBind;
  7894. delete this.resetMouseScrollStateBind;
  7895. delete this.contextMenuBind;
  7896. delete this.touchSwipeBind;
  7897. }
  7898. }, {
  7899. key: '_fullscreenChange',
  7900. value: function _fullscreenChange() {
  7901. if (this.isFullscreen) {
  7902. this._enter();
  7903. } else {
  7904. this._exit();
  7905. }
  7906. }
  7907. }, {
  7908. key: '_addFullscreenChangeListeners',
  7909. value: function _addFullscreenChangeListeners() {
  7910. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  7911. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  7912. window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7913. window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7914. window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7915. }
  7916. }, {
  7917. key: '_removeFullscreenChangeListeners',
  7918. value: function _removeFullscreenChangeListeners() {
  7919. window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
  7920. window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7921. window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7922. window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7923. delete this.fullscreenChangeBind;
  7924. }
  7925. }, {
  7926. key: 'isFullscreen',
  7927. get: function get() {
  7928. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  7929. }
  7930. }]);
  7931. return PDFPresentationMode;
  7932. }();
  7933. exports.PDFPresentationMode = PDFPresentationMode;
  7934. /***/
  7935. }),
  7936. /* 24 */
  7937. /***/ (function (module, exports, __webpack_require__) {
  7938. "use strict";
  7939. Object.defineProperty(exports, "__esModule", {
  7940. value: true
  7941. });
  7942. exports.PDFSidebar = exports.SidebarView = undefined;
  7943. 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; }; }();
  7944. var _ui_utils = __webpack_require__(0);
  7945. var _pdf_rendering_queue = __webpack_require__(3);
  7946. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7947. var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
  7948. var SidebarView = {
  7949. NONE: 0,
  7950. THUMBS: 1,
  7951. OUTLINE: 2,
  7952. ATTACHMENTS: 3
  7953. };
  7954. var PDFSidebar = function () {
  7955. function PDFSidebar(options) {
  7956. var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
  7957. _classCallCheck(this, PDFSidebar);
  7958. this.isOpen = false;
  7959. this.active = SidebarView.THUMBS;
  7960. this.isInitialViewSet = false;
  7961. this.onToggled = null;
  7962. this.pdfViewer = options.pdfViewer;
  7963. this.pdfThumbnailViewer = options.pdfThumbnailViewer;
  7964. this.pdfOutlineViewer = options.pdfOutlineViewer;
  7965. this.mainContainer = options.mainContainer;
  7966. this.outerContainer = options.outerContainer;
  7967. this.eventBus = options.eventBus;
  7968. this.toggleButton = options.toggleButton;
  7969. this.thumbnailButton = options.thumbnailButton;
  7970. this.outlineButton = options.outlineButton;
  7971. this.attachmentsButton = options.attachmentsButton;
  7972. this.thumbnailView = options.thumbnailView;
  7973. this.outlineView = options.outlineView;
  7974. this.attachmentsView = options.attachmentsView;
  7975. this.disableNotification = options.disableNotification || false;
  7976. this.l10n = l10n;
  7977. this._addEventListeners();
  7978. }
  7979. _createClass(PDFSidebar, [{
  7980. key: 'reset',
  7981. value: function reset() {
  7982. this.isInitialViewSet = false;
  7983. this._hideUINotification(null);
  7984. this.switchView(SidebarView.THUMBS);
  7985. this.outlineButton.disabled = false;
  7986. this.attachmentsButton.disabled = false;
  7987. }
  7988. }, {
  7989. key: 'setInitialView',
  7990. value: function setInitialView(view) {
  7991. if (this.isInitialViewSet) {
  7992. return;
  7993. }
  7994. this.isInitialViewSet = true;
  7995. if (this.isOpen && view === SidebarView.NONE) {
  7996. this._dispatchEvent();
  7997. return;
  7998. }
  7999. var isViewPreserved = view === this.visibleView;
  8000. this.switchView(view, true);
  8001. if (isViewPreserved) {
  8002. this._dispatchEvent();
  8003. }
  8004. }
  8005. }, {
  8006. key: 'switchView',
  8007. value: function switchView(view) {
  8008. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8009. if (view === SidebarView.NONE) {
  8010. this.close();
  8011. return;
  8012. }
  8013. var isViewChanged = view !== this.active;
  8014. var shouldForceRendering = false;
  8015. switch (view) {
  8016. case SidebarView.THUMBS:
  8017. this.thumbnailButton.classList.add('toggled');
  8018. this.outlineButton.classList.remove('toggled');
  8019. this.attachmentsButton.classList.remove('toggled');
  8020. this.thumbnailView.classList.remove('hidden');
  8021. this.outlineView.classList.add('hidden');
  8022. this.attachmentsView.classList.add('hidden');
  8023. if (this.isOpen && isViewChanged) {
  8024. this._updateThumbnailViewer();
  8025. shouldForceRendering = true;
  8026. }
  8027. break;
  8028. case SidebarView.OUTLINE:
  8029. if (this.outlineButton.disabled) {
  8030. return;
  8031. }
  8032. this.thumbnailButton.classList.remove('toggled');
  8033. this.outlineButton.classList.add('toggled');
  8034. this.attachmentsButton.classList.remove('toggled');
  8035. this.thumbnailView.classList.add('hidden');
  8036. this.outlineView.classList.remove('hidden');
  8037. this.attachmentsView.classList.add('hidden');
  8038. break;
  8039. case SidebarView.ATTACHMENTS:
  8040. if (this.attachmentsButton.disabled) {
  8041. return;
  8042. }
  8043. this.thumbnailButton.classList.remove('toggled');
  8044. this.outlineButton.classList.remove('toggled');
  8045. this.attachmentsButton.classList.add('toggled');
  8046. this.thumbnailView.classList.add('hidden');
  8047. this.outlineView.classList.add('hidden');
  8048. this.attachmentsView.classList.remove('hidden');
  8049. break;
  8050. default:
  8051. console.error('PDFSidebar_switchView: "' + view + '" is an unsupported value.');
  8052. return;
  8053. }
  8054. this.active = view | 0;
  8055. if (forceOpen && !this.isOpen) {
  8056. this.open();
  8057. return;
  8058. }
  8059. if (shouldForceRendering) {
  8060. this._forceRendering();
  8061. }
  8062. if (isViewChanged) {
  8063. this._dispatchEvent();
  8064. }
  8065. this._hideUINotification(this.active);
  8066. }
  8067. }, {
  8068. key: 'open',
  8069. value: function open() {
  8070. if (this.isOpen) {
  8071. return;
  8072. }
  8073. this.isOpen = true;
  8074. this.toggleButton.classList.add('toggled');
  8075. this.outerContainer.classList.add('sidebarMoving');
  8076. this.outerContainer.classList.add('sidebarOpen');
  8077. if (this.active === SidebarView.THUMBS) {
  8078. this._updateThumbnailViewer();
  8079. }
  8080. this._forceRendering();
  8081. this._dispatchEvent();
  8082. this._hideUINotification(this.active);
  8083. }
  8084. }, {
  8085. key: 'close',
  8086. value: function close() {
  8087. if (!this.isOpen) {
  8088. return;
  8089. }
  8090. this.isOpen = false;
  8091. this.toggleButton.classList.remove('toggled');
  8092. this.outerContainer.classList.add('sidebarMoving');
  8093. this.outerContainer.classList.remove('sidebarOpen');
  8094. this._forceRendering();
  8095. this._dispatchEvent();
  8096. }
  8097. }, {
  8098. key: 'toggle',
  8099. value: function toggle() {
  8100. if (this.isOpen) {
  8101. this.close();
  8102. } else {
  8103. this.open();
  8104. }
  8105. }
  8106. }, {
  8107. key: '_dispatchEvent',
  8108. value: function _dispatchEvent() {
  8109. this.eventBus.dispatch('sidebarviewchanged', {
  8110. source: this,
  8111. view: this.visibleView
  8112. });
  8113. }
  8114. }, {
  8115. key: '_forceRendering',
  8116. value: function _forceRendering() {
  8117. if (this.onToggled) {
  8118. this.onToggled();
  8119. } else {
  8120. this.pdfViewer.forceRendering();
  8121. this.pdfThumbnailViewer.forceRendering();
  8122. }
  8123. }
  8124. }, {
  8125. key: '_updateThumbnailViewer',
  8126. value: function _updateThumbnailViewer() {
  8127. var pdfViewer = this.pdfViewer,
  8128. pdfThumbnailViewer = this.pdfThumbnailViewer;
  8129. var pagesCount = pdfViewer.pagesCount;
  8130. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  8131. var pageView = pdfViewer.getPageView(pageIndex);
  8132. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  8133. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  8134. thumbnailView.setImage(pageView);
  8135. }
  8136. }
  8137. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  8138. }
  8139. }, {
  8140. key: '_showUINotification',
  8141. value: function _showUINotification(view) {
  8142. var _this = this;
  8143. if (this.disableNotification) {
  8144. return;
  8145. }
  8146. this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
  8147. _this.toggleButton.title = msg;
  8148. });
  8149. if (!this.isOpen) {
  8150. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  8151. } else if (view === this.active) {
  8152. return;
  8153. }
  8154. switch (view) {
  8155. case SidebarView.OUTLINE:
  8156. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  8157. break;
  8158. case SidebarView.ATTACHMENTS:
  8159. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  8160. break;
  8161. }
  8162. }
  8163. }, {
  8164. key: '_hideUINotification',
  8165. value: function _hideUINotification(view) {
  8166. var _this2 = this;
  8167. if (this.disableNotification) {
  8168. return;
  8169. }
  8170. var removeNotification = function removeNotification(view) {
  8171. switch (view) {
  8172. case SidebarView.OUTLINE:
  8173. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  8174. break;
  8175. case SidebarView.ATTACHMENTS:
  8176. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  8177. break;
  8178. }
  8179. };
  8180. if (!this.isOpen && view !== null) {
  8181. return;
  8182. }
  8183. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  8184. if (view !== null) {
  8185. removeNotification(view);
  8186. return;
  8187. }
  8188. for (view in SidebarView) {
  8189. removeNotification(SidebarView[view]);
  8190. }
  8191. this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
  8192. _this2.toggleButton.title = msg;
  8193. });
  8194. }
  8195. }, {
  8196. key: '_addEventListeners',
  8197. value: function _addEventListeners() {
  8198. var _this3 = this;
  8199. this.mainContainer.addEventListener('transitionend', function (evt) {
  8200. if (evt.target === _this3.mainContainer) {
  8201. _this3.outerContainer.classList.remove('sidebarMoving');
  8202. }
  8203. });
  8204. this.thumbnailButton.addEventListener('click', function () {
  8205. _this3.switchView(SidebarView.THUMBS);
  8206. });
  8207. this.outlineButton.addEventListener('click', function () {
  8208. _this3.switchView(SidebarView.OUTLINE);
  8209. });
  8210. this.outlineButton.addEventListener('dblclick', function () {
  8211. _this3.pdfOutlineViewer.toggleOutlineTree();
  8212. });
  8213. this.attachmentsButton.addEventListener('click', function () {
  8214. _this3.switchView(SidebarView.ATTACHMENTS);
  8215. });
  8216. this.eventBus.on('outlineloaded', function (evt) {
  8217. var outlineCount = evt.outlineCount;
  8218. _this3.outlineButton.disabled = !outlineCount;
  8219. if (outlineCount) {
  8220. _this3._showUINotification(SidebarView.OUTLINE);
  8221. } else if (_this3.active === SidebarView.OUTLINE) {
  8222. _this3.switchView(SidebarView.THUMBS);
  8223. }
  8224. });
  8225. this.eventBus.on('attachmentsloaded', function (evt) {
  8226. var attachmentsCount = evt.attachmentsCount;
  8227. _this3.attachmentsButton.disabled = !attachmentsCount;
  8228. if (attachmentsCount) {
  8229. _this3._showUINotification(SidebarView.ATTACHMENTS);
  8230. } else if (_this3.active === SidebarView.ATTACHMENTS) {
  8231. _this3.switchView(SidebarView.THUMBS);
  8232. }
  8233. });
  8234. this.eventBus.on('presentationmodechanged', function (evt) {
  8235. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  8236. _this3._updateThumbnailViewer();
  8237. }
  8238. });
  8239. }
  8240. }, {
  8241. key: 'visibleView',
  8242. get: function get() {
  8243. return this.isOpen ? this.active : SidebarView.NONE;
  8244. }
  8245. }, {
  8246. key: 'isThumbnailViewVisible',
  8247. get: function get() {
  8248. return this.isOpen && this.active === SidebarView.THUMBS;
  8249. }
  8250. }, {
  8251. key: 'isOutlineViewVisible',
  8252. get: function get() {
  8253. return this.isOpen && this.active === SidebarView.OUTLINE;
  8254. }
  8255. }, {
  8256. key: 'isAttachmentsViewVisible',
  8257. get: function get() {
  8258. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  8259. }
  8260. }]);
  8261. return PDFSidebar;
  8262. }();
  8263. exports.SidebarView = SidebarView;
  8264. exports.PDFSidebar = PDFSidebar;
  8265. /***/
  8266. }),
  8267. /* 25 */
  8268. /***/ (function (module, exports, __webpack_require__) {
  8269. "use strict";
  8270. Object.defineProperty(exports, "__esModule", {
  8271. value: true
  8272. });
  8273. exports.PDFThumbnailView = undefined;
  8274. 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; }; }();
  8275. var _pdfjsLib = __webpack_require__(1);
  8276. var _ui_utils = __webpack_require__(0);
  8277. var _pdf_rendering_queue = __webpack_require__(3);
  8278. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8279. var MAX_NUM_SCALING_STEPS = 3;
  8280. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  8281. var THUMBNAIL_WIDTH = 98;
  8282. var TempImageFactory = function TempImageFactoryClosure() {
  8283. var tempCanvasCache = null;
  8284. return {
  8285. getCanvas: function getCanvas(width, height) {
  8286. var tempCanvas = tempCanvasCache;
  8287. if (!tempCanvas) {
  8288. tempCanvas = document.createElement('canvas');
  8289. tempCanvasCache = tempCanvas;
  8290. }
  8291. tempCanvas.width = width;
  8292. tempCanvas.height = height;
  8293. tempCanvas.mozOpaque = true;
  8294. var ctx = tempCanvas.getContext('2d', { alpha: false });
  8295. ctx.save();
  8296. ctx.fillStyle = 'rgb(255, 255, 255)';
  8297. ctx.fillRect(0, 0, width, height);
  8298. ctx.restore();
  8299. return tempCanvas;
  8300. },
  8301. destroyCanvas: function destroyCanvas() {
  8302. var tempCanvas = tempCanvasCache;
  8303. if (tempCanvas) {
  8304. tempCanvas.width = 0;
  8305. tempCanvas.height = 0;
  8306. }
  8307. tempCanvasCache = null;
  8308. }
  8309. };
  8310. }();
  8311. var PDFThumbnailView = function () {
  8312. function PDFThumbnailView(_ref) {
  8313. var container = _ref.container,
  8314. id = _ref.id,
  8315. defaultViewport = _ref.defaultViewport,
  8316. linkService = _ref.linkService,
  8317. renderingQueue = _ref.renderingQueue,
  8318. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  8319. disableCanvasToImageConversion = _ref$disableCanvasToI === undefined ? false : _ref$disableCanvasToI,
  8320. _ref$l10n = _ref.l10n,
  8321. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  8322. _classCallCheck(this, PDFThumbnailView);
  8323. this.id = id;
  8324. this.renderingId = 'thumbnail' + id;
  8325. this.pageLabel = null;
  8326. this.pdfPage = null;
  8327. this.rotation = 0;
  8328. this.viewport = defaultViewport;
  8329. this.pdfPageRotate = defaultViewport.rotation;
  8330. this.linkService = linkService;
  8331. this.renderingQueue = renderingQueue;
  8332. this.renderTask = null;
  8333. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8334. this.resume = null;
  8335. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  8336. this.pageWidth = this.viewport.width;
  8337. this.pageHeight = this.viewport.height;
  8338. this.pageRatio = this.pageWidth / this.pageHeight;
  8339. this.canvasWidth = THUMBNAIL_WIDTH;
  8340. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8341. this.scale = this.canvasWidth / this.pageWidth;
  8342. this.l10n = l10n;
  8343. var anchor = document.createElement('a');
  8344. anchor.href = linkService.getAnchorUrl('#page=' + id);
  8345. this.l10n.get('thumb_page_title', { page: id }, 'Page {{page}}').then(function (msg) {
  8346. anchor.title = msg;
  8347. });
  8348. anchor.onclick = function () {
  8349. linkService.page = id;
  8350. return false;
  8351. };
  8352. this.anchor = anchor;
  8353. var div = document.createElement('div');
  8354. div.className = 'thumbnail';
  8355. div.setAttribute('data-page-number', this.id);
  8356. this.div = div;
  8357. if (id === 1) {
  8358. div.classList.add('selected');
  8359. }
  8360. var ring = document.createElement('div');
  8361. ring.className = 'thumbnailSelectionRing';
  8362. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8363. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  8364. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  8365. this.ring = ring;
  8366. div.appendChild(ring);
  8367. anchor.appendChild(div);
  8368. container.appendChild(anchor);
  8369. }
  8370. _createClass(PDFThumbnailView, [{
  8371. key: 'setPdfPage',
  8372. value: function setPdfPage(pdfPage) {
  8373. this.pdfPage = pdfPage;
  8374. this.pdfPageRotate = pdfPage.rotate;
  8375. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8376. this.viewport = pdfPage.getViewport(1, totalRotation);
  8377. this.reset();
  8378. }
  8379. }, {
  8380. key: 'reset',
  8381. value: function reset() {
  8382. this.cancelRendering();
  8383. this.pageWidth = this.viewport.width;
  8384. this.pageHeight = this.viewport.height;
  8385. this.pageRatio = this.pageWidth / this.pageHeight;
  8386. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8387. this.scale = this.canvasWidth / this.pageWidth;
  8388. this.div.removeAttribute('data-loaded');
  8389. var ring = this.ring;
  8390. var childNodes = ring.childNodes;
  8391. for (var i = childNodes.length - 1; i >= 0; i--) {
  8392. ring.removeChild(childNodes[i]);
  8393. }
  8394. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8395. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  8396. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  8397. if (this.canvas) {
  8398. this.canvas.width = 0;
  8399. this.canvas.height = 0;
  8400. delete this.canvas;
  8401. }
  8402. if (this.image) {
  8403. this.image.removeAttribute('src');
  8404. delete this.image;
  8405. }
  8406. }
  8407. }, {
  8408. key: 'update',
  8409. value: function update(rotation) {
  8410. if (typeof rotation !== 'undefined') {
  8411. this.rotation = rotation;
  8412. }
  8413. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8414. this.viewport = this.viewport.clone({
  8415. scale: 1,
  8416. rotation: totalRotation
  8417. });
  8418. this.reset();
  8419. }
  8420. }, {
  8421. key: 'cancelRendering',
  8422. value: function cancelRendering() {
  8423. if (this.renderTask) {
  8424. this.renderTask.cancel();
  8425. this.renderTask = null;
  8426. }
  8427. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8428. this.resume = null;
  8429. }
  8430. }, {
  8431. key: '_getPageDrawContext',
  8432. value: function _getPageDrawContext() {
  8433. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8434. var canvas = document.createElement('canvas');
  8435. this.canvas = canvas;
  8436. canvas.mozOpaque = true;
  8437. var ctx = canvas.getContext('2d', { alpha: false });
  8438. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  8439. canvas.width = this.canvasWidth * outputScale.sx | 0;
  8440. canvas.height = this.canvasHeight * outputScale.sy | 0;
  8441. canvas.style.width = this.canvasWidth + 'px';
  8442. canvas.style.height = this.canvasHeight + 'px';
  8443. if (!noCtxScale && outputScale.scaled) {
  8444. ctx.scale(outputScale.sx, outputScale.sy);
  8445. }
  8446. return ctx;
  8447. }
  8448. }, {
  8449. key: '_convertCanvasToImage',
  8450. value: function _convertCanvasToImage() {
  8451. var _this = this;
  8452. if (!this.canvas) {
  8453. return;
  8454. }
  8455. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8456. return;
  8457. }
  8458. var id = this.renderingId;
  8459. var className = 'thumbnailImage';
  8460. if (this.disableCanvasToImageConversion) {
  8461. this.canvas.id = id;
  8462. this.canvas.className = className;
  8463. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
  8464. _this.canvas.setAttribute('aria-label', msg);
  8465. });
  8466. this.div.setAttribute('data-loaded', true);
  8467. this.ring.appendChild(this.canvas);
  8468. return;
  8469. }
  8470. var image = document.createElement('img');
  8471. image.id = id;
  8472. image.className = className;
  8473. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
  8474. image.setAttribute('aria-label', msg);
  8475. });
  8476. image.style.width = this.canvasWidth + 'px';
  8477. image.style.height = this.canvasHeight + 'px';
  8478. image.src = this.canvas.toDataURL();
  8479. this.image = image;
  8480. this.div.setAttribute('data-loaded', true);
  8481. this.ring.appendChild(image);
  8482. this.canvas.width = 0;
  8483. this.canvas.height = 0;
  8484. delete this.canvas;
  8485. }
  8486. }, {
  8487. key: 'draw',
  8488. value: function draw() {
  8489. var _this2 = this;
  8490. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8491. console.error('Must be in new state before drawing');
  8492. return Promise.resolve(undefined);
  8493. }
  8494. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8495. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  8496. var finishRenderTask = function finishRenderTask(error) {
  8497. if (renderTask === _this2.renderTask) {
  8498. _this2.renderTask = null;
  8499. }
  8500. if (error === 'cancelled' || error instanceof _pdfjsLib.RenderingCancelledException) {
  8501. renderCapability.resolve(undefined);
  8502. return;
  8503. }
  8504. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8505. _this2._convertCanvasToImage();
  8506. if (!error) {
  8507. renderCapability.resolve(undefined);
  8508. } else {
  8509. renderCapability.reject(error);
  8510. }
  8511. };
  8512. var ctx = this._getPageDrawContext();
  8513. var drawViewport = this.viewport.clone({ scale: this.scale });
  8514. var renderContinueCallback = function renderContinueCallback(cont) {
  8515. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  8516. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  8517. _this2.resume = function () {
  8518. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8519. cont();
  8520. };
  8521. return;
  8522. }
  8523. cont();
  8524. };
  8525. var renderContext = {
  8526. canvasContext: ctx,
  8527. viewport: drawViewport
  8528. };
  8529. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  8530. renderTask.onContinue = renderContinueCallback;
  8531. renderTask.promise.then(function () {
  8532. finishRenderTask(null);
  8533. }, function (error) {
  8534. finishRenderTask(error);
  8535. });
  8536. return renderCapability.promise;
  8537. }
  8538. }, {
  8539. key: 'setImage',
  8540. value: function setImage(pageView) {
  8541. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8542. return;
  8543. }
  8544. var img = pageView.canvas;
  8545. if (!img) {
  8546. return;
  8547. }
  8548. if (!this.pdfPage) {
  8549. this.setPdfPage(pageView.pdfPage);
  8550. }
  8551. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8552. var ctx = this._getPageDrawContext(true);
  8553. var canvas = ctx.canvas;
  8554. if (img.width <= 2 * canvas.width) {
  8555. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  8556. this._convertCanvasToImage();
  8557. return;
  8558. }
  8559. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  8560. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  8561. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  8562. var reducedImageCtx = reducedImage.getContext('2d');
  8563. while (reducedWidth > img.width || reducedHeight > img.height) {
  8564. reducedWidth >>= 1;
  8565. reducedHeight >>= 1;
  8566. }
  8567. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  8568. while (reducedWidth > 2 * canvas.width) {
  8569. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  8570. reducedWidth >>= 1;
  8571. reducedHeight >>= 1;
  8572. }
  8573. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  8574. this._convertCanvasToImage();
  8575. }
  8576. }, {
  8577. key: 'setPageLabel',
  8578. value: function setPageLabel(label) {
  8579. var _this3 = this;
  8580. this.pageLabel = typeof label === 'string' ? label : null;
  8581. this.l10n.get('thumb_page_title', { page: this.pageId }, 'Page {{page}}').then(function (msg) {
  8582. _this3.anchor.title = msg;
  8583. });
  8584. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8585. return;
  8586. }
  8587. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) {
  8588. if (_this3.image) {
  8589. _this3.image.setAttribute('aria-label', ariaLabel);
  8590. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  8591. _this3.canvas.setAttribute('aria-label', ariaLabel);
  8592. }
  8593. });
  8594. }
  8595. }, {
  8596. key: 'pageId',
  8597. get: function get() {
  8598. return this.pageLabel !== null ? this.pageLabel : this.id;
  8599. }
  8600. }], [{
  8601. key: 'cleanup',
  8602. value: function cleanup() {
  8603. TempImageFactory.destroyCanvas();
  8604. }
  8605. }]);
  8606. return PDFThumbnailView;
  8607. }();
  8608. exports.PDFThumbnailView = PDFThumbnailView;
  8609. /***/
  8610. }),
  8611. /* 26 */
  8612. /***/ (function (module, exports, __webpack_require__) {
  8613. "use strict";
  8614. Object.defineProperty(exports, "__esModule", {
  8615. value: true
  8616. });
  8617. exports.PDFThumbnailViewer = undefined;
  8618. 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; }; }();
  8619. var _ui_utils = __webpack_require__(0);
  8620. var _pdf_thumbnail_view = __webpack_require__(25);
  8621. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8622. var THUMBNAIL_SCROLL_MARGIN = -19;
  8623. var PDFThumbnailViewer = function () {
  8624. function PDFThumbnailViewer(_ref) {
  8625. var container = _ref.container,
  8626. linkService = _ref.linkService,
  8627. renderingQueue = _ref.renderingQueue,
  8628. _ref$l10n = _ref.l10n,
  8629. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  8630. _classCallCheck(this, PDFThumbnailViewer);
  8631. this.container = container;
  8632. this.linkService = linkService;
  8633. this.renderingQueue = renderingQueue;
  8634. this.l10n = l10n;
  8635. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  8636. this._resetView();
  8637. }
  8638. _createClass(PDFThumbnailViewer, [{
  8639. key: '_scrollUpdated',
  8640. value: function _scrollUpdated() {
  8641. this.renderingQueue.renderHighestPriority();
  8642. }
  8643. }, {
  8644. key: 'getThumbnail',
  8645. value: function getThumbnail(index) {
  8646. return this._thumbnails[index];
  8647. }
  8648. }, {
  8649. key: '_getVisibleThumbs',
  8650. value: function _getVisibleThumbs() {
  8651. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  8652. }
  8653. }, {
  8654. key: 'scrollThumbnailIntoView',
  8655. value: function scrollThumbnailIntoView(page) {
  8656. var selected = document.querySelector('.thumbnail.selected');
  8657. if (selected) {
  8658. selected.classList.remove('selected');
  8659. }
  8660. var thumbnail = document.querySelector('div.thumbnail[data-page-number="' + page + '"]');
  8661. if (thumbnail) {
  8662. thumbnail.classList.add('selected');
  8663. }
  8664. var visibleThumbs = this._getVisibleThumbs();
  8665. var numVisibleThumbs = visibleThumbs.views.length;
  8666. if (numVisibleThumbs > 0) {
  8667. var first = visibleThumbs.first.id;
  8668. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  8669. if (page <= first || page >= last) {
  8670. (0, _ui_utils.scrollIntoView)(thumbnail, { top: THUMBNAIL_SCROLL_MARGIN });
  8671. }
  8672. }
  8673. }
  8674. }, {
  8675. key: 'cleanup',
  8676. value: function cleanup() {
  8677. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  8678. }
  8679. }, {
  8680. key: '_resetView',
  8681. value: function _resetView() {
  8682. this._thumbnails = [];
  8683. this._pageLabels = null;
  8684. this._pagesRotation = 0;
  8685. this._pagesRequests = [];
  8686. this.container.textContent = '';
  8687. }
  8688. }, {
  8689. key: 'setDocument',
  8690. value: function setDocument(pdfDocument) {
  8691. var _this = this;
  8692. if (this.pdfDocument) {
  8693. this._cancelRendering();
  8694. this._resetView();
  8695. }
  8696. this.pdfDocument = pdfDocument;
  8697. if (!pdfDocument) {
  8698. return;
  8699. }
  8700. pdfDocument.getPage(1).then(function (firstPage) {
  8701. var pagesCount = pdfDocument.numPages;
  8702. var viewport = firstPage.getViewport(1.0);
  8703. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8704. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  8705. container: _this.container,
  8706. id: pageNum,
  8707. defaultViewport: viewport.clone(),
  8708. linkService: _this.linkService,
  8709. renderingQueue: _this.renderingQueue,
  8710. disableCanvasToImageConversion: false,
  8711. l10n: _this.l10n
  8712. });
  8713. _this._thumbnails.push(thumbnail);
  8714. }
  8715. }).catch(function (reason) {
  8716. console.error('Unable to initialize thumbnail viewer', reason);
  8717. });
  8718. }
  8719. }, {
  8720. key: '_cancelRendering',
  8721. value: function _cancelRendering() {
  8722. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8723. if (this._thumbnails[i]) {
  8724. this._thumbnails[i].cancelRendering();
  8725. }
  8726. }
  8727. }
  8728. }, {
  8729. key: 'setPageLabels',
  8730. value: function setPageLabels(labels) {
  8731. if (!this.pdfDocument) {
  8732. return;
  8733. }
  8734. if (!labels) {
  8735. this._pageLabels = null;
  8736. } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  8737. this._pageLabels = null;
  8738. console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
  8739. } else {
  8740. this._pageLabels = labels;
  8741. }
  8742. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8743. var label = this._pageLabels && this._pageLabels[i];
  8744. this._thumbnails[i].setPageLabel(label);
  8745. }
  8746. }
  8747. }, {
  8748. key: '_ensurePdfPageLoaded',
  8749. value: function _ensurePdfPageLoaded(thumbView) {
  8750. var _this2 = this;
  8751. if (thumbView.pdfPage) {
  8752. return Promise.resolve(thumbView.pdfPage);
  8753. }
  8754. var pageNumber = thumbView.id;
  8755. if (this._pagesRequests[pageNumber]) {
  8756. return this._pagesRequests[pageNumber];
  8757. }
  8758. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  8759. thumbView.setPdfPage(pdfPage);
  8760. _this2._pagesRequests[pageNumber] = null;
  8761. return pdfPage;
  8762. }).catch(function (reason) {
  8763. console.error('Unable to get page for thumb view', reason);
  8764. _this2._pagesRequests[pageNumber] = null;
  8765. });
  8766. this._pagesRequests[pageNumber] = promise;
  8767. return promise;
  8768. }
  8769. }, {
  8770. key: 'forceRendering',
  8771. value: function forceRendering() {
  8772. var _this3 = this;
  8773. var visibleThumbs = this._getVisibleThumbs();
  8774. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  8775. if (thumbView) {
  8776. this._ensurePdfPageLoaded(thumbView).then(function () {
  8777. _this3.renderingQueue.renderView(thumbView);
  8778. });
  8779. return true;
  8780. }
  8781. return false;
  8782. }
  8783. }, {
  8784. key: 'pagesRotation',
  8785. get: function get() {
  8786. return this._pagesRotation;
  8787. },
  8788. set: function set(rotation) {
  8789. if (!(typeof rotation === 'number' && rotation % 90 === 0)) {
  8790. throw new Error('Invalid thumbnails rotation angle.');
  8791. }
  8792. if (!this.pdfDocument) {
  8793. return;
  8794. }
  8795. this._pagesRotation = rotation;
  8796. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8797. this._thumbnails[i].update(rotation);
  8798. }
  8799. }
  8800. }]);
  8801. return PDFThumbnailViewer;
  8802. }();
  8803. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  8804. /***/
  8805. }),
  8806. /* 27 */
  8807. /***/ (function (module, exports, __webpack_require__) {
  8808. "use strict";
  8809. Object.defineProperty(exports, "__esModule", {
  8810. value: true
  8811. });
  8812. exports.PDFViewer = exports.PresentationModeState = undefined;
  8813. 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; }; }();
  8814. var _pdfjsLib = __webpack_require__(1);
  8815. var _ui_utils = __webpack_require__(0);
  8816. var _pdf_rendering_queue = __webpack_require__(3);
  8817. var _annotation_layer_builder = __webpack_require__(11);
  8818. var _dom_events = __webpack_require__(2);
  8819. var _pdf_page_view = __webpack_require__(22);
  8820. var _pdf_link_service = __webpack_require__(5);
  8821. var _text_layer_builder = __webpack_require__(30);
  8822. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8823. var PresentationModeState = {
  8824. UNKNOWN: 0,
  8825. NORMAL: 1,
  8826. CHANGING: 2,
  8827. FULLSCREEN: 3
  8828. };
  8829. var DEFAULT_CACHE_SIZE = 10;
  8830. function PDFPageViewBuffer(size) {
  8831. var data = [];
  8832. this.push = function cachePush(view) {
  8833. var i = data.indexOf(view);
  8834. if (i >= 0) {
  8835. data.splice(i, 1);
  8836. }
  8837. data.push(view);
  8838. if (data.length > size) {
  8839. data.shift().destroy();
  8840. }
  8841. };
  8842. this.resize = function (newSize) {
  8843. size = newSize;
  8844. while (data.length > size) {
  8845. data.shift().destroy();
  8846. }
  8847. };
  8848. }
  8849. function isSameScale(oldScale, newScale) {
  8850. if (newScale === oldScale) {
  8851. return true;
  8852. }
  8853. if (Math.abs(newScale - oldScale) < 1e-15) {
  8854. return true;
  8855. }
  8856. return false;
  8857. }
  8858. function isPortraitOrientation(size) {
  8859. return size.width <= size.height;
  8860. }
  8861. var PDFViewer = function () {
  8862. function PDFViewer(options) {
  8863. _classCallCheck(this, PDFViewer);
  8864. this.container = options.container;
  8865. this.viewer = options.viewer || options.container.firstElementChild;
  8866. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  8867. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  8868. this.downloadManager = options.downloadManager || null;
  8869. this.removePageBorders = options.removePageBorders || false;
  8870. this.enhanceTextSelection = options.enhanceTextSelection || false;
  8871. this.renderInteractiveForms = options.renderInteractiveForms || false;
  8872. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  8873. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  8874. this.l10n = options.l10n || _ui_utils.NullL10n;
  8875. this.defaultRenderingQueue = !options.renderingQueue;
  8876. if (this.defaultRenderingQueue) {
  8877. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  8878. this.renderingQueue.setViewer(this);
  8879. } else {
  8880. this.renderingQueue = options.renderingQueue;
  8881. }
  8882. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  8883. this.presentationModeState = PresentationModeState.UNKNOWN;
  8884. this._resetView();
  8885. if (this.removePageBorders) {
  8886. this.viewer.classList.add('removePageBorders');
  8887. }
  8888. }
  8889. _createClass(PDFViewer, [{
  8890. key: 'getPageView',
  8891. value: function getPageView(index) {
  8892. return this._pages[index];
  8893. }
  8894. }, {
  8895. key: '_setCurrentPageNumber',
  8896. value: function _setCurrentPageNumber(val) {
  8897. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8898. if (this._currentPageNumber === val) {
  8899. if (resetCurrentPageView) {
  8900. this._resetCurrentPageView();
  8901. }
  8902. return;
  8903. }
  8904. if (!(0 < val && val <= this.pagesCount)) {
  8905. console.error('PDFViewer._setCurrentPageNumber: "' + val + '" is out of bounds.');
  8906. return;
  8907. }
  8908. var arg = {
  8909. source: this,
  8910. pageNumber: val,
  8911. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  8912. };
  8913. this._currentPageNumber = val;
  8914. this.eventBus.dispatch('pagechanging', arg);
  8915. this.eventBus.dispatch('pagechange', arg);
  8916. if (resetCurrentPageView) {
  8917. this._resetCurrentPageView();
  8918. }
  8919. }
  8920. }, {
  8921. key: 'setDocument',
  8922. value: function setDocument(pdfDocument) {
  8923. var _this = this;
  8924. if (this.pdfDocument) {
  8925. this._cancelRendering();
  8926. this._resetView();
  8927. }
  8928. this.pdfDocument = pdfDocument;
  8929. if (!pdfDocument) {
  8930. return;
  8931. }
  8932. var pagesCount = pdfDocument.numPages;
  8933. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  8934. this.pagesPromise = pagesCapability.promise;
  8935. pagesCapability.promise.then(function () {
  8936. _this._pageViewsReady = true;
  8937. _this.eventBus.dispatch('pagesloaded', {
  8938. source: _this,
  8939. pagesCount: pagesCount
  8940. });
  8941. });
  8942. var isOnePageRenderedResolved = false;
  8943. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  8944. this.onePageRendered = onePageRenderedCapability.promise;
  8945. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  8946. pageView.onBeforeDraw = function () {
  8947. _this._buffer.push(pageView);
  8948. };
  8949. pageView.onAfterDraw = function () {
  8950. if (!isOnePageRenderedResolved) {
  8951. isOnePageRenderedResolved = true;
  8952. onePageRenderedCapability.resolve();
  8953. }
  8954. };
  8955. };
  8956. var firstPagePromise = pdfDocument.getPage(1);
  8957. this.firstPagePromise = firstPagePromise;
  8958. firstPagePromise.then(function (pdfPage) {
  8959. var scale = _this.currentScale;
  8960. var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
  8961. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8962. var textLayerFactory = null;
  8963. if (!_pdfjsLib.PDFJS.disableTextLayer) {
  8964. textLayerFactory = _this;
  8965. }
  8966. var pageView = new _pdf_page_view.PDFPageView({
  8967. container: _this.viewer,
  8968. eventBus: _this.eventBus,
  8969. id: pageNum,
  8970. scale: scale,
  8971. defaultViewport: viewport.clone(),
  8972. renderingQueue: _this.renderingQueue,
  8973. textLayerFactory: textLayerFactory,
  8974. annotationLayerFactory: _this,
  8975. enhanceTextSelection: _this.enhanceTextSelection,
  8976. renderInteractiveForms: _this.renderInteractiveForms,
  8977. renderer: _this.renderer,
  8978. l10n: _this.l10n
  8979. });
  8980. bindOnAfterAndBeforeDraw(pageView);
  8981. _this._pages.push(pageView);
  8982. }
  8983. onePageRenderedCapability.promise.then(function () {
  8984. if (_pdfjsLib.PDFJS.disableAutoFetch) {
  8985. pagesCapability.resolve();
  8986. return;
  8987. }
  8988. var getPagesLeft = pagesCount;
  8989. var _loop = function _loop(_pageNum) {
  8990. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  8991. var pageView = _this._pages[_pageNum - 1];
  8992. if (!pageView.pdfPage) {
  8993. pageView.setPdfPage(pdfPage);
  8994. }
  8995. _this.linkService.cachePageRef(_pageNum, pdfPage.ref);
  8996. if (--getPagesLeft === 0) {
  8997. pagesCapability.resolve();
  8998. }
  8999. }, function (reason) {
  9000. console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);
  9001. if (--getPagesLeft === 0) {
  9002. pagesCapability.resolve();
  9003. }
  9004. });
  9005. };
  9006. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  9007. _loop(_pageNum);
  9008. }
  9009. });
  9010. _this.eventBus.dispatch('pagesinit', { source: _this });
  9011. if (_this.defaultRenderingQueue) {
  9012. _this.update();
  9013. }
  9014. if (_this.findController) {
  9015. _this.findController.resolveFirstPage();
  9016. }
  9017. }).catch(function (reason) {
  9018. console.error('Unable to initialize viewer', reason);
  9019. });
  9020. }
  9021. }, {
  9022. key: 'setPageLabels',
  9023. value: function setPageLabels(labels) {
  9024. if (!this.pdfDocument) {
  9025. return;
  9026. }
  9027. if (!labels) {
  9028. this._pageLabels = null;
  9029. } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  9030. this._pageLabels = null;
  9031. console.error('PDFViewer.setPageLabels: Invalid page labels.');
  9032. } else {
  9033. this._pageLabels = labels;
  9034. }
  9035. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9036. var pageView = this._pages[i];
  9037. var label = this._pageLabels && this._pageLabels[i];
  9038. pageView.setPageLabel(label);
  9039. }
  9040. }
  9041. }, {
  9042. key: '_resetView',
  9043. value: function _resetView() {
  9044. this._pages = [];
  9045. this._currentPageNumber = 1;
  9046. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  9047. this._currentScaleValue = null;
  9048. this._pageLabels = null;
  9049. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  9050. this._location = null;
  9051. this._pagesRotation = 0;
  9052. this._pagesRequests = [];
  9053. this._pageViewsReady = false;
  9054. this.viewer.textContent = '';
  9055. }
  9056. }, {
  9057. key: '_scrollUpdate',
  9058. value: function _scrollUpdate() {
  9059. if (this.pagesCount === 0) {
  9060. return;
  9061. }
  9062. this.update();
  9063. }
  9064. }, {
  9065. key: '_setScaleDispatchEvent',
  9066. value: function _setScaleDispatchEvent(newScale, newValue) {
  9067. var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9068. var arg = {
  9069. source: this,
  9070. scale: newScale,
  9071. presetValue: preset ? newValue : undefined
  9072. };
  9073. this.eventBus.dispatch('scalechanging', arg);
  9074. this.eventBus.dispatch('scalechange', arg);
  9075. }
  9076. }, {
  9077. key: '_setScaleUpdatePages',
  9078. value: function _setScaleUpdatePages(newScale, newValue) {
  9079. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9080. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9081. this._currentScaleValue = newValue.toString();
  9082. if (isSameScale(this._currentScale, newScale)) {
  9083. if (preset) {
  9084. this._setScaleDispatchEvent(newScale, newValue, true);
  9085. }
  9086. return;
  9087. }
  9088. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9089. this._pages[i].update(newScale);
  9090. }
  9091. this._currentScale = newScale;
  9092. if (!noScroll) {
  9093. var page = this._currentPageNumber,
  9094. dest = void 0;
  9095. if (this._location && !_pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  9096. page = this._location.pageNumber;
  9097. dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];
  9098. }
  9099. this.scrollPageIntoView({
  9100. pageNumber: page,
  9101. destArray: dest,
  9102. allowNegativeOffset: true
  9103. });
  9104. }
  9105. this._setScaleDispatchEvent(newScale, newValue, preset);
  9106. if (this.defaultRenderingQueue) {
  9107. this.update();
  9108. }
  9109. }
  9110. }, {
  9111. key: '_setScale',
  9112. value: function _setScale(value) {
  9113. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9114. var scale = parseFloat(value);
  9115. if (scale > 0) {
  9116. this._setScaleUpdatePages(scale, value, noScroll, false);
  9117. } else {
  9118. var currentPage = this._pages[this._currentPageNumber - 1];
  9119. if (!currentPage) {
  9120. return;
  9121. }
  9122. var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9123. var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  9124. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  9125. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  9126. switch (value) {
  9127. case 'page-actual':
  9128. scale = 1;
  9129. break;
  9130. case 'page-width':
  9131. scale = pageWidthScale;
  9132. break;
  9133. case 'page-height':
  9134. scale = pageHeightScale;
  9135. break;
  9136. case 'page-fit':
  9137. scale = Math.min(pageWidthScale, pageHeightScale);
  9138. break;
  9139. case 'auto':
  9140. var isLandscape = currentPage.width > currentPage.height;
  9141. var horizontalScale = isLandscape ? Math.min(pageHeightScale, pageWidthScale) : pageWidthScale;
  9142. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  9143. break;
  9144. default:
  9145. console.error('PDFViewer._setScale: "' + value + '" is an unknown zoom value.');
  9146. return;
  9147. }
  9148. this._setScaleUpdatePages(scale, value, noScroll, true);
  9149. }
  9150. }
  9151. }, {
  9152. key: '_resetCurrentPageView',
  9153. value: function _resetCurrentPageView() {
  9154. if (this.isInPresentationMode) {
  9155. this._setScale(this._currentScaleValue, true);
  9156. }
  9157. var pageView = this._pages[this._currentPageNumber - 1];
  9158. (0, _ui_utils.scrollIntoView)(pageView.div);
  9159. }
  9160. }, {
  9161. key: 'scrollPageIntoView',
  9162. value: function scrollPageIntoView(params) {
  9163. if (!this.pdfDocument) {
  9164. return;
  9165. }
  9166. if (arguments.length > 1 || typeof params === 'number') {
  9167. console.warn('Call of scrollPageIntoView() with obsolete signature.');
  9168. var paramObj = {};
  9169. if (typeof params === 'number') {
  9170. paramObj.pageNumber = params;
  9171. }
  9172. if (arguments[1] instanceof Array) {
  9173. paramObj.destArray = arguments[1];
  9174. }
  9175. params = paramObj;
  9176. }
  9177. var pageNumber = params.pageNumber || 0;
  9178. var dest = params.destArray || null;
  9179. var allowNegativeOffset = params.allowNegativeOffset || false;
  9180. if (this.isInPresentationMode || !dest) {
  9181. this._setCurrentPageNumber(pageNumber, true);
  9182. return;
  9183. }
  9184. var pageView = this._pages[pageNumber - 1];
  9185. if (!pageView) {
  9186. console.error('PDFViewer.scrollPageIntoView: Invalid "pageNumber" parameter.');
  9187. return;
  9188. }
  9189. var x = 0,
  9190. y = 0;
  9191. var width = 0,
  9192. height = 0,
  9193. widthScale = void 0,
  9194. heightScale = void 0;
  9195. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  9196. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  9197. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  9198. var scale = 0;
  9199. switch (dest[1].name) {
  9200. case 'XYZ':
  9201. x = dest[2];
  9202. y = dest[3];
  9203. scale = dest[4];
  9204. x = x !== null ? x : 0;
  9205. y = y !== null ? y : pageHeight;
  9206. break;
  9207. case 'Fit':
  9208. case 'FitB':
  9209. scale = 'page-fit';
  9210. break;
  9211. case 'FitH':
  9212. case 'FitBH':
  9213. y = dest[2];
  9214. scale = 'page-width';
  9215. if (y === null && this._location) {
  9216. x = this._location.left;
  9217. y = this._location.top;
  9218. }
  9219. break;
  9220. case 'FitV':
  9221. case 'FitBV':
  9222. x = dest[2];
  9223. width = pageWidth;
  9224. height = pageHeight;
  9225. scale = 'page-height';
  9226. break;
  9227. case 'FitR':
  9228. x = dest[2];
  9229. y = dest[3];
  9230. width = dest[4] - x;
  9231. height = dest[5] - y;
  9232. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9233. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  9234. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  9235. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  9236. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  9237. break;
  9238. default:
  9239. console.error('PDFViewer.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');
  9240. return;
  9241. }
  9242. if (scale && scale !== this._currentScale) {
  9243. this.currentScaleValue = scale;
  9244. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  9245. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  9246. }
  9247. if (scale === 'page-fit' && !dest[4]) {
  9248. (0, _ui_utils.scrollIntoView)(pageView.div);
  9249. return;
  9250. }
  9251. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  9252. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  9253. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  9254. if (!allowNegativeOffset) {
  9255. left = Math.max(left, 0);
  9256. top = Math.max(top, 0);
  9257. }
  9258. (0, _ui_utils.scrollIntoView)(pageView.div, {
  9259. left: left,
  9260. top: top
  9261. });
  9262. }
  9263. }, {
  9264. key: '_updateLocation',
  9265. value: function _updateLocation(firstPage) {
  9266. var currentScale = this._currentScale;
  9267. var currentScaleValue = this._currentScaleValue;
  9268. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  9269. var pageNumber = firstPage.id;
  9270. var pdfOpenParams = '#page=' + pageNumber;
  9271. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  9272. var currentPageView = this._pages[pageNumber - 1];
  9273. var container = this.container;
  9274. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  9275. var intLeft = Math.round(topLeft[0]);
  9276. var intTop = Math.round(topLeft[1]);
  9277. pdfOpenParams += ',' + intLeft + ',' + intTop;
  9278. this._location = {
  9279. pageNumber: pageNumber,
  9280. scale: normalizedScaleValue,
  9281. top: intTop,
  9282. left: intLeft,
  9283. pdfOpenParams: pdfOpenParams
  9284. };
  9285. }
  9286. }, {
  9287. key: 'update',
  9288. value: function update() {
  9289. var visible = this._getVisiblePages();
  9290. var visiblePages = visible.views;
  9291. if (visiblePages.length === 0) {
  9292. return;
  9293. }
  9294. var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * visiblePages.length + 1);
  9295. this._buffer.resize(suggestedCacheSize);
  9296. this.renderingQueue.renderHighestPriority(visible);
  9297. var currentId = this._currentPageNumber;
  9298. var firstPage = visible.first;
  9299. var stillFullyVisible = false;
  9300. for (var i = 0, ii = visiblePages.length; i < ii; ++i) {
  9301. var page = visiblePages[i];
  9302. if (page.percent < 100) {
  9303. break;
  9304. }
  9305. if (page.id === currentId) {
  9306. stillFullyVisible = true;
  9307. break;
  9308. }
  9309. }
  9310. if (!stillFullyVisible) {
  9311. currentId = visiblePages[0].id;
  9312. }
  9313. if (!this.isInPresentationMode) {
  9314. this._setCurrentPageNumber(currentId);
  9315. }
  9316. this._updateLocation(firstPage);
  9317. this.eventBus.dispatch('updateviewarea', {
  9318. source: this,
  9319. location: this._location
  9320. });
  9321. }
  9322. }, {
  9323. key: 'containsElement',
  9324. value: function containsElement(element) {
  9325. return this.container.contains(element);
  9326. }
  9327. }, {
  9328. key: 'focus',
  9329. value: function focus() {
  9330. this.container.focus();
  9331. }
  9332. }, {
  9333. key: '_getVisiblePages',
  9334. value: function _getVisiblePages() {
  9335. if (!this.isInPresentationMode) {
  9336. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true);
  9337. }
  9338. var visible = [];
  9339. var currentPage = this._pages[this._currentPageNumber - 1];
  9340. visible.push({
  9341. id: currentPage.id,
  9342. view: currentPage
  9343. });
  9344. return {
  9345. first: currentPage,
  9346. last: currentPage,
  9347. views: visible
  9348. };
  9349. }
  9350. }, {
  9351. key: 'cleanup',
  9352. value: function cleanup() {
  9353. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9354. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9355. this._pages[i].reset();
  9356. }
  9357. }
  9358. }
  9359. }, {
  9360. key: '_cancelRendering',
  9361. value: function _cancelRendering() {
  9362. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9363. if (this._pages[i]) {
  9364. this._pages[i].cancelRendering();
  9365. }
  9366. }
  9367. }
  9368. }, {
  9369. key: '_ensurePdfPageLoaded',
  9370. value: function _ensurePdfPageLoaded(pageView) {
  9371. var _this2 = this;
  9372. if (pageView.pdfPage) {
  9373. return Promise.resolve(pageView.pdfPage);
  9374. }
  9375. var pageNumber = pageView.id;
  9376. if (this._pagesRequests[pageNumber]) {
  9377. return this._pagesRequests[pageNumber];
  9378. }
  9379. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  9380. if (!pageView.pdfPage) {
  9381. pageView.setPdfPage(pdfPage);
  9382. }
  9383. _this2._pagesRequests[pageNumber] = null;
  9384. return pdfPage;
  9385. }).catch(function (reason) {
  9386. console.error('Unable to get page for page view', reason);
  9387. _this2._pagesRequests[pageNumber] = null;
  9388. });
  9389. this._pagesRequests[pageNumber] = promise;
  9390. return promise;
  9391. }
  9392. }, {
  9393. key: 'forceRendering',
  9394. value: function forceRendering(currentlyVisiblePages) {
  9395. var _this3 = this;
  9396. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  9397. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
  9398. if (pageView) {
  9399. this._ensurePdfPageLoaded(pageView).then(function () {
  9400. _this3.renderingQueue.renderView(pageView);
  9401. });
  9402. return true;
  9403. }
  9404. return false;
  9405. }
  9406. }, {
  9407. key: 'getPageTextContent',
  9408. value: function getPageTextContent(pageIndex) {
  9409. return this.pdfDocument.getPage(pageIndex + 1).then(function (page) {
  9410. return page.getTextContent({ normalizeWhitespace: true });
  9411. });
  9412. }
  9413. }, {
  9414. key: 'createTextLayerBuilder',
  9415. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9416. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9417. return new _text_layer_builder.TextLayerBuilder({
  9418. textLayerDiv: textLayerDiv,
  9419. eventBus: this.eventBus,
  9420. pageIndex: pageIndex,
  9421. viewport: viewport,
  9422. findController: this.isInPresentationMode ? null : this.findController,
  9423. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  9424. });
  9425. }
  9426. }, {
  9427. key: 'createAnnotationLayerBuilder',
  9428. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9429. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9430. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  9431. return new _annotation_layer_builder.AnnotationLayerBuilder({
  9432. pageDiv: pageDiv,
  9433. pdfPage: pdfPage,
  9434. renderInteractiveForms: renderInteractiveForms,
  9435. linkService: this.linkService,
  9436. downloadManager: this.downloadManager,
  9437. l10n: l10n
  9438. });
  9439. }
  9440. }, {
  9441. key: 'setFindController',
  9442. value: function setFindController(findController) {
  9443. this.findController = findController;
  9444. }
  9445. }, {
  9446. key: 'getPagesOverview',
  9447. value: function getPagesOverview() {
  9448. var pagesOverview = this._pages.map(function (pageView) {
  9449. var viewport = pageView.pdfPage.getViewport(1);
  9450. return {
  9451. width: viewport.width,
  9452. height: viewport.height,
  9453. rotation: viewport.rotation
  9454. };
  9455. });
  9456. if (!this.enablePrintAutoRotate) {
  9457. return pagesOverview;
  9458. }
  9459. var isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);
  9460. return pagesOverview.map(function (size) {
  9461. if (isFirstPagePortrait === isPortraitOrientation(size)) {
  9462. return size;
  9463. }
  9464. return {
  9465. width: size.height,
  9466. height: size.width,
  9467. rotation: (size.rotation + 90) % 360
  9468. };
  9469. });
  9470. }
  9471. }, {
  9472. key: 'pagesCount',
  9473. get: function get() {
  9474. return this._pages.length;
  9475. }
  9476. }, {
  9477. key: 'pageViewsReady',
  9478. get: function get() {
  9479. return this._pageViewsReady;
  9480. }
  9481. }, {
  9482. key: 'currentPageNumber',
  9483. get: function get() {
  9484. return this._currentPageNumber;
  9485. },
  9486. set: function set(val) {
  9487. if ((val | 0) !== val) {
  9488. throw new Error('Invalid page number.');
  9489. }
  9490. if (!this.pdfDocument) {
  9491. return;
  9492. }
  9493. this._setCurrentPageNumber(val, true);
  9494. }
  9495. }, {
  9496. key: 'currentPageLabel',
  9497. get: function get() {
  9498. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  9499. },
  9500. set: function set(val) {
  9501. var pageNumber = val | 0;
  9502. if (this._pageLabels) {
  9503. var i = this._pageLabels.indexOf(val);
  9504. if (i >= 0) {
  9505. pageNumber = i + 1;
  9506. }
  9507. }
  9508. this.currentPageNumber = pageNumber;
  9509. }
  9510. }, {
  9511. key: 'currentScale',
  9512. get: function get() {
  9513. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  9514. },
  9515. set: function set(val) {
  9516. if (isNaN(val)) {
  9517. throw new Error('Invalid numeric scale');
  9518. }
  9519. if (!this.pdfDocument) {
  9520. return;
  9521. }
  9522. this._setScale(val, false);
  9523. }
  9524. }, {
  9525. key: 'currentScaleValue',
  9526. get: function get() {
  9527. return this._currentScaleValue;
  9528. },
  9529. set: function set(val) {
  9530. if (!this.pdfDocument) {
  9531. return;
  9532. }
  9533. this._setScale(val, false);
  9534. }
  9535. }, {
  9536. key: 'pagesRotation',
  9537. get: function get() {
  9538. return this._pagesRotation;
  9539. },
  9540. set: function set(rotation) {
  9541. if (!(typeof rotation === 'number' && rotation % 90 === 0)) {
  9542. throw new Error('Invalid pages rotation angle.');
  9543. }
  9544. if (!this.pdfDocument) {
  9545. return;
  9546. }
  9547. this._pagesRotation = rotation;
  9548. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9549. var pageView = this._pages[i];
  9550. pageView.update(pageView.scale, rotation);
  9551. }
  9552. this._setScale(this._currentScaleValue, true);
  9553. if (this.defaultRenderingQueue) {
  9554. this.update();
  9555. }
  9556. }
  9557. }, {
  9558. key: 'isInPresentationMode',
  9559. get: function get() {
  9560. return this.presentationModeState === PresentationModeState.FULLSCREEN;
  9561. }
  9562. }, {
  9563. key: 'isChangingPresentationMode',
  9564. get: function get() {
  9565. return this.presentationModeState === PresentationModeState.CHANGING;
  9566. }
  9567. }, {
  9568. key: 'isHorizontalScrollbarEnabled',
  9569. get: function get() {
  9570. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  9571. }
  9572. }, {
  9573. key: 'hasEqualPageSizes',
  9574. get: function get() {
  9575. var firstPageView = this._pages[0];
  9576. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  9577. var pageView = this._pages[i];
  9578. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  9579. return false;
  9580. }
  9581. }
  9582. return true;
  9583. }
  9584. }]);
  9585. return PDFViewer;
  9586. }();
  9587. exports.PresentationModeState = PresentationModeState;
  9588. exports.PDFViewer = PDFViewer;
  9589. /***/
  9590. }),
  9591. /* 28 */
  9592. /***/ (function (module, exports, __webpack_require__) {
  9593. "use strict";
  9594. Object.defineProperty(exports, "__esModule", {
  9595. value: true
  9596. });
  9597. exports.BasePreferences = undefined;
  9598. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  9599. 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; }; }();
  9600. var _ui_utils = __webpack_require__(0);
  9601. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9602. var defaultPreferences = null;
  9603. function getDefaultPreferences() {
  9604. if (!defaultPreferences) {
  9605. defaultPreferences = Promise.resolve({
  9606. "showPreviousViewOnLoad": true,
  9607. "defaultZoomValue": "",
  9608. "sidebarViewOnLoad": 0,
  9609. "enableHandToolOnLoad": false,
  9610. "cursorToolOnLoad": 0,
  9611. "enableWebGL": false,
  9612. "pdfBugEnabled": false,
  9613. "disableRange": false,
  9614. "disableStream": false,
  9615. "disableAutoFetch": false,
  9616. "disableFontFace": false,
  9617. "disableTextLayer": false,
  9618. "useOnlyCssZoom": false,
  9619. "externalLinkTarget": 0,
  9620. "enhanceTextSelection": false,
  9621. "renderer": "canvas",
  9622. "renderInteractiveForms": false,
  9623. "enablePrintAutoRotate": false,
  9624. "disablePageMode": false,
  9625. "disablePageLabels": false
  9626. });
  9627. }
  9628. return defaultPreferences;
  9629. }
  9630. var BasePreferences = function () {
  9631. function BasePreferences() {
  9632. var _this = this;
  9633. _classCallCheck(this, BasePreferences);
  9634. if (this.constructor === BasePreferences) {
  9635. throw new Error('Cannot initialize BasePreferences.');
  9636. }
  9637. this.prefs = null;
  9638. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  9639. Object.defineProperty(_this, 'defaults', {
  9640. value: Object.freeze(defaults),
  9641. writable: false,
  9642. enumerable: true,
  9643. configurable: false
  9644. });
  9645. _this.prefs = (0, _ui_utils.cloneObj)(defaults);
  9646. return _this._readFromStorage(defaults);
  9647. }).then(function (prefObj) {
  9648. if (prefObj) {
  9649. _this.prefs = prefObj;
  9650. }
  9651. });
  9652. }
  9653. _createClass(BasePreferences, [{
  9654. key: "_writeToStorage",
  9655. value: function _writeToStorage(prefObj) {
  9656. return Promise.reject(new Error('Not implemented: _writeToStorage'));
  9657. }
  9658. }, {
  9659. key: "_readFromStorage",
  9660. value: function _readFromStorage(prefObj) {
  9661. return Promise.reject(new Error('Not implemented: _readFromStorage'));
  9662. }
  9663. }, {
  9664. key: "reset",
  9665. value: function reset() {
  9666. var _this2 = this;
  9667. return this._initializedPromise.then(function () {
  9668. _this2.prefs = (0, _ui_utils.cloneObj)(_this2.defaults);
  9669. return _this2._writeToStorage(_this2.defaults);
  9670. });
  9671. }
  9672. }, {
  9673. key: "reload",
  9674. value: function reload() {
  9675. var _this3 = this;
  9676. return this._initializedPromise.then(function () {
  9677. return _this3._readFromStorage(_this3.defaults);
  9678. }).then(function (prefObj) {
  9679. if (prefObj) {
  9680. _this3.prefs = prefObj;
  9681. }
  9682. });
  9683. }
  9684. }, {
  9685. key: "set",
  9686. value: function set(name, value) {
  9687. var _this4 = this;
  9688. return this._initializedPromise.then(function () {
  9689. if (_this4.defaults[name] === undefined) {
  9690. throw new Error("Set preference: \"" + name + "\" is undefined.");
  9691. } else if (value === undefined) {
  9692. throw new Error('Set preference: no value is specified.');
  9693. }
  9694. var valueType = typeof value === "undefined" ? "undefined" : _typeof(value);
  9695. var defaultType = _typeof(_this4.defaults[name]);
  9696. if (valueType !== defaultType) {
  9697. if (valueType === 'number' && defaultType === 'string') {
  9698. value = value.toString();
  9699. } else {
  9700. throw new Error("Set preference: \"" + value + "\" is a " + valueType + ", " + ("expected a " + defaultType + "."));
  9701. }
  9702. } else {
  9703. if (valueType === 'number' && (value | 0) !== value) {
  9704. throw new Error("Set preference: \"" + value + "\" must be an integer.");
  9705. }
  9706. }
  9707. _this4.prefs[name] = value;
  9708. return _this4._writeToStorage(_this4.prefs);
  9709. });
  9710. }
  9711. }, {
  9712. key: "get",
  9713. value: function get(name) {
  9714. var _this5 = this;
  9715. return this._initializedPromise.then(function () {
  9716. var defaultValue = _this5.defaults[name];
  9717. if (defaultValue === undefined) {
  9718. throw new Error("Get preference: \"" + name + "\" is undefined.");
  9719. } else {
  9720. var prefValue = _this5.prefs[name];
  9721. if (prefValue !== undefined) {
  9722. return prefValue;
  9723. }
  9724. }
  9725. return defaultValue;
  9726. });
  9727. }
  9728. }]);
  9729. return BasePreferences;
  9730. }();
  9731. exports.BasePreferences = BasePreferences;
  9732. /***/
  9733. }),
  9734. /* 29 */
  9735. /***/ (function (module, exports, __webpack_require__) {
  9736. "use strict";
  9737. Object.defineProperty(exports, "__esModule", {
  9738. value: true
  9739. });
  9740. exports.SecondaryToolbar = undefined;
  9741. 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; }; }();
  9742. var _pdf_cursor_tools = __webpack_require__(6);
  9743. var _ui_utils = __webpack_require__(0);
  9744. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9745. var SecondaryToolbar = function () {
  9746. function SecondaryToolbar(options, mainContainer, eventBus) {
  9747. _classCallCheck(this, SecondaryToolbar);
  9748. this.toolbar = options.toolbar;
  9749. this.toggleButton = options.toggleButton;
  9750. this.toolbarButtonContainer = options.toolbarButtonContainer;
  9751. this.buttons = [{
  9752. element: options.presentationModeButton,
  9753. eventName: 'presentationmode',
  9754. close: true
  9755. }, {
  9756. element: options.openFileButton,
  9757. eventName: 'openfile',
  9758. close: true
  9759. }, {
  9760. element: options.printButton,
  9761. eventName: 'print',
  9762. close: true
  9763. }, {
  9764. element: options.downloadButton,
  9765. eventName: 'download',
  9766. close: true
  9767. }, {
  9768. element: options.viewBookmarkButton,
  9769. eventName: null,
  9770. close: true
  9771. }, {
  9772. element: options.firstPageButton,
  9773. eventName: 'firstpage',
  9774. close: true
  9775. }, {
  9776. element: options.lastPageButton,
  9777. eventName: 'lastpage',
  9778. close: true
  9779. }, {
  9780. element: options.pageRotateCwButton,
  9781. eventName: 'rotatecw',
  9782. close: false
  9783. }, {
  9784. element: options.pageRotateCcwButton,
  9785. eventName: 'rotateccw',
  9786. close: false
  9787. }, {
  9788. element: options.cursorSelectToolButton,
  9789. eventName: 'switchcursortool',
  9790. eventDetails: { tool: _pdf_cursor_tools.CursorTool.SELECT },
  9791. close: true
  9792. }, {
  9793. element: options.cursorHandToolButton,
  9794. eventName: 'switchcursortool',
  9795. eventDetails: { tool: _pdf_cursor_tools.CursorTool.HAND },
  9796. close: true
  9797. }, {
  9798. element: options.documentPropertiesButton,
  9799. eventName: 'documentproperties',
  9800. close: true
  9801. }];
  9802. this.items = {
  9803. firstPage: options.firstPageButton,
  9804. lastPage: options.lastPageButton,
  9805. pageRotateCw: options.pageRotateCwButton,
  9806. pageRotateCcw: options.pageRotateCcwButton
  9807. };
  9808. this.mainContainer = mainContainer;
  9809. this.eventBus = eventBus;
  9810. this.opened = false;
  9811. this.containerHeight = null;
  9812. this.previousContainerHeight = null;
  9813. this.reset();
  9814. this._bindClickListeners();
  9815. this._bindCursorToolsListener(options);
  9816. this.eventBus.on('resize', this._setMaxHeight.bind(this));
  9817. }
  9818. _createClass(SecondaryToolbar, [{
  9819. key: 'setPageNumber',
  9820. value: function setPageNumber(pageNumber) {
  9821. this.pageNumber = pageNumber;
  9822. this._updateUIState();
  9823. }
  9824. }, {
  9825. key: 'setPagesCount',
  9826. value: function setPagesCount(pagesCount) {
  9827. this.pagesCount = pagesCount;
  9828. this._updateUIState();
  9829. }
  9830. }, {
  9831. key: 'reset',
  9832. value: function reset() {
  9833. this.pageNumber = 0;
  9834. this.pagesCount = 0;
  9835. this._updateUIState();
  9836. }
  9837. }, {
  9838. key: '_updateUIState',
  9839. value: function _updateUIState() {
  9840. this.items.firstPage.disabled = this.pageNumber <= 1;
  9841. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  9842. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  9843. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  9844. }
  9845. }, {
  9846. key: '_bindClickListeners',
  9847. value: function _bindClickListeners() {
  9848. var _this = this;
  9849. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  9850. var _loop = function _loop(button) {
  9851. var _buttons$button = _this.buttons[button],
  9852. element = _buttons$button.element,
  9853. eventName = _buttons$button.eventName,
  9854. close = _buttons$button.close,
  9855. eventDetails = _buttons$button.eventDetails;
  9856. element.addEventListener('click', function (evt) {
  9857. if (eventName !== null) {
  9858. var details = { source: _this };
  9859. for (var property in eventDetails) {
  9860. details[property] = eventDetails[property];
  9861. }
  9862. _this.eventBus.dispatch(eventName, details);
  9863. }
  9864. if (close) {
  9865. _this.close();
  9866. }
  9867. });
  9868. };
  9869. for (var button in this.buttons) {
  9870. _loop(button);
  9871. }
  9872. }
  9873. }, {
  9874. key: '_bindCursorToolsListener',
  9875. value: function _bindCursorToolsListener(buttons) {
  9876. this.eventBus.on('cursortoolchanged', function (evt) {
  9877. buttons.cursorSelectToolButton.classList.remove('toggled');
  9878. buttons.cursorHandToolButton.classList.remove('toggled');
  9879. switch (evt.tool) {
  9880. case _pdf_cursor_tools.CursorTool.SELECT:
  9881. buttons.cursorSelectToolButton.classList.add('toggled');
  9882. break;
  9883. case _pdf_cursor_tools.CursorTool.HAND:
  9884. buttons.cursorHandToolButton.classList.add('toggled');
  9885. break;
  9886. }
  9887. });
  9888. }
  9889. }, {
  9890. key: 'open',
  9891. value: function open() {
  9892. if (this.opened) {
  9893. return;
  9894. }
  9895. this.opened = true;
  9896. this._setMaxHeight();
  9897. this.toggleButton.classList.add('toggled');
  9898. this.toolbar.classList.remove('hidden');
  9899. }
  9900. }, {
  9901. key: 'close',
  9902. value: function close() {
  9903. if (!this.opened) {
  9904. return;
  9905. }
  9906. this.opened = false;
  9907. this.toolbar.classList.add('hidden');
  9908. this.toggleButton.classList.remove('toggled');
  9909. }
  9910. }, {
  9911. key: 'toggle',
  9912. value: function toggle() {
  9913. if (this.opened) {
  9914. this.close();
  9915. } else {
  9916. this.open();
  9917. }
  9918. }
  9919. }, {
  9920. key: '_setMaxHeight',
  9921. value: function _setMaxHeight() {
  9922. if (!this.opened) {
  9923. return;
  9924. }
  9925. this.containerHeight = this.mainContainer.clientHeight;
  9926. if (this.containerHeight === this.previousContainerHeight) {
  9927. return;
  9928. }
  9929. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  9930. this.previousContainerHeight = this.containerHeight;
  9931. }
  9932. }, {
  9933. key: 'isOpen',
  9934. get: function get() {
  9935. return this.opened;
  9936. }
  9937. }]);
  9938. return SecondaryToolbar;
  9939. }();
  9940. exports.SecondaryToolbar = SecondaryToolbar;
  9941. /***/
  9942. }),
  9943. /* 30 */
  9944. /***/ (function (module, exports, __webpack_require__) {
  9945. "use strict";
  9946. Object.defineProperty(exports, "__esModule", {
  9947. value: true
  9948. });
  9949. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
  9950. 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; }; }();
  9951. var _dom_events = __webpack_require__(2);
  9952. var _pdfjsLib = __webpack_require__(1);
  9953. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9954. var EXPAND_DIVS_TIMEOUT = 300;
  9955. var TextLayerBuilder = function () {
  9956. function TextLayerBuilder(_ref) {
  9957. var textLayerDiv = _ref.textLayerDiv,
  9958. eventBus = _ref.eventBus,
  9959. pageIndex = _ref.pageIndex,
  9960. viewport = _ref.viewport,
  9961. _ref$findController = _ref.findController,
  9962. findController = _ref$findController === undefined ? null : _ref$findController,
  9963. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  9964. enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false : _ref$enhanceTextSelec;
  9965. _classCallCheck(this, TextLayerBuilder);
  9966. this.textLayerDiv = textLayerDiv;
  9967. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  9968. this.textContent = null;
  9969. this.textContentItemsStr = [];
  9970. this.textContentStream = null;
  9971. this.renderingDone = false;
  9972. this.pageIdx = pageIndex;
  9973. this.pageNumber = this.pageIdx + 1;
  9974. this.matches = [];
  9975. this.viewport = viewport;
  9976. this.textDivs = [];
  9977. this.findController = findController;
  9978. this.textLayerRenderTask = null;
  9979. this.enhanceTextSelection = enhanceTextSelection;
  9980. this._bindMouse();
  9981. }
  9982. _createClass(TextLayerBuilder, [{
  9983. key: '_finishRendering',
  9984. value: function _finishRendering() {
  9985. this.renderingDone = true;
  9986. if (!this.enhanceTextSelection) {
  9987. var endOfContent = document.createElement('div');
  9988. endOfContent.className = 'endOfContent';
  9989. this.textLayerDiv.appendChild(endOfContent);
  9990. }
  9991. this.eventBus.dispatch('textlayerrendered', {
  9992. source: this,
  9993. pageNumber: this.pageNumber,
  9994. numTextDivs: this.textDivs.length
  9995. });
  9996. }
  9997. }, {
  9998. key: 'render',
  9999. value: function render() {
  10000. var _this = this;
  10001. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10002. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  10003. return;
  10004. }
  10005. this.cancel();
  10006. this.textDivs = [];
  10007. var textLayerFrag = document.createDocumentFragment();
  10008. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  10009. textContent: this.textContent,
  10010. textContentStream: this.textContentStream,
  10011. container: textLayerFrag,
  10012. viewport: this.viewport,
  10013. textDivs: this.textDivs,
  10014. textContentItemsStr: this.textContentItemsStr,
  10015. timeout: timeout,
  10016. enhanceTextSelection: this.enhanceTextSelection
  10017. });
  10018. this.textLayerRenderTask.promise.then(function () {
  10019. _this.textLayerDiv.appendChild(textLayerFrag);
  10020. _this._finishRendering();
  10021. _this.updateMatches();
  10022. }, function (reason) { });
  10023. }
  10024. }, {
  10025. key: 'cancel',
  10026. value: function cancel() {
  10027. if (this.textLayerRenderTask) {
  10028. this.textLayerRenderTask.cancel();
  10029. this.textLayerRenderTask = null;
  10030. }
  10031. }
  10032. }, {
  10033. key: 'setTextContentStream',
  10034. value: function setTextContentStream(readableStream) {
  10035. this.cancel();
  10036. this.textContentStream = readableStream;
  10037. }
  10038. }, {
  10039. key: 'setTextContent',
  10040. value: function setTextContent(textContent) {
  10041. this.cancel();
  10042. this.textContent = textContent;
  10043. }
  10044. }, {
  10045. key: 'convertMatches',
  10046. value: function convertMatches(matches, matchesLength) {
  10047. var i = 0;
  10048. var iIndex = 0;
  10049. var textContentItemsStr = this.textContentItemsStr;
  10050. var end = textContentItemsStr.length - 1;
  10051. var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
  10052. var ret = [];
  10053. if (!matches) {
  10054. return ret;
  10055. }
  10056. for (var m = 0, len = matches.length; m < len; m++) {
  10057. var matchIdx = matches[m];
  10058. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  10059. iIndex += textContentItemsStr[i].length;
  10060. i++;
  10061. }
  10062. if (i === textContentItemsStr.length) {
  10063. console.error('Could not find a matching mapping');
  10064. }
  10065. var match = {
  10066. begin: {
  10067. divIdx: i,
  10068. offset: matchIdx - iIndex
  10069. }
  10070. };
  10071. if (matchesLength) {
  10072. matchIdx += matchesLength[m];
  10073. } else {
  10074. matchIdx += queryLen;
  10075. }
  10076. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  10077. iIndex += textContentItemsStr[i].length;
  10078. i++;
  10079. }
  10080. match.end = {
  10081. divIdx: i,
  10082. offset: matchIdx - iIndex
  10083. };
  10084. ret.push(match);
  10085. }
  10086. return ret;
  10087. }
  10088. }, {
  10089. key: 'renderMatches',
  10090. value: function renderMatches(matches) {
  10091. if (matches.length === 0) {
  10092. return;
  10093. }
  10094. var textContentItemsStr = this.textContentItemsStr;
  10095. var textDivs = this.textDivs;
  10096. var prevEnd = null;
  10097. var pageIdx = this.pageIdx;
  10098. var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx;
  10099. var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
  10100. var highlightAll = this.findController === null ? false : this.findController.state.highlightAll;
  10101. var infinity = {
  10102. divIdx: -1,
  10103. offset: undefined
  10104. };
  10105. function beginText(begin, className) {
  10106. var divIdx = begin.divIdx;
  10107. textDivs[divIdx].textContent = '';
  10108. appendTextToDiv(divIdx, 0, begin.offset, className);
  10109. }
  10110. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  10111. var div = textDivs[divIdx];
  10112. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  10113. var node = document.createTextNode(content);
  10114. if (className) {
  10115. var span = document.createElement('span');
  10116. span.className = className;
  10117. span.appendChild(node);
  10118. div.appendChild(span);
  10119. return;
  10120. }
  10121. div.appendChild(node);
  10122. }
  10123. var i0 = selectedMatchIdx,
  10124. i1 = i0 + 1;
  10125. if (highlightAll) {
  10126. i0 = 0;
  10127. i1 = matches.length;
  10128. } else if (!isSelectedPage) {
  10129. return;
  10130. }
  10131. for (var i = i0; i < i1; i++) {
  10132. var match = matches[i];
  10133. var begin = match.begin;
  10134. var end = match.end;
  10135. var isSelected = isSelectedPage && i === selectedMatchIdx;
  10136. var highlightSuffix = isSelected ? ' selected' : '';
  10137. if (this.findController) {
  10138. this.findController.updateMatchPosition(pageIdx, i, textDivs, begin.divIdx);
  10139. }
  10140. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  10141. if (prevEnd !== null) {
  10142. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10143. }
  10144. beginText(begin);
  10145. } else {
  10146. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  10147. }
  10148. if (begin.divIdx === end.divIdx) {
  10149. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  10150. } else {
  10151. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  10152. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  10153. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  10154. }
  10155. beginText(end, 'highlight end' + highlightSuffix);
  10156. }
  10157. prevEnd = end;
  10158. }
  10159. if (prevEnd) {
  10160. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10161. }
  10162. }
  10163. }, {
  10164. key: 'updateMatches',
  10165. value: function updateMatches() {
  10166. if (!this.renderingDone) {
  10167. return;
  10168. }
  10169. var matches = this.matches;
  10170. var textDivs = this.textDivs;
  10171. var textContentItemsStr = this.textContentItemsStr;
  10172. var clearedUntilDivIdx = -1;
  10173. for (var i = 0, len = matches.length; i < len; i++) {
  10174. var match = matches[i];
  10175. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  10176. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  10177. var div = textDivs[n];
  10178. div.textContent = textContentItemsStr[n];
  10179. div.className = '';
  10180. }
  10181. clearedUntilDivIdx = match.end.divIdx + 1;
  10182. }
  10183. if (this.findController === null || !this.findController.active) {
  10184. return;
  10185. }
  10186. var pageMatches = void 0,
  10187. pageMatchesLength = void 0;
  10188. if (this.findController !== null) {
  10189. pageMatches = this.findController.pageMatches[this.pageIdx] || null;
  10190. pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null;
  10191. }
  10192. this.matches = this.convertMatches(pageMatches, pageMatchesLength);
  10193. this.renderMatches(this.matches);
  10194. }
  10195. }, {
  10196. key: '_bindMouse',
  10197. value: function _bindMouse() {
  10198. var _this2 = this;
  10199. var div = this.textLayerDiv;
  10200. var expandDivsTimer = null;
  10201. div.addEventListener('mousedown', function (evt) {
  10202. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10203. _this2.textLayerRenderTask.expandTextDivs(true);
  10204. if (expandDivsTimer) {
  10205. clearTimeout(expandDivsTimer);
  10206. expandDivsTimer = null;
  10207. }
  10208. return;
  10209. }
  10210. var end = div.querySelector('.endOfContent');
  10211. if (!end) {
  10212. return;
  10213. }
  10214. var adjustTop = evt.target !== div;
  10215. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  10216. if (adjustTop) {
  10217. var divBounds = div.getBoundingClientRect();
  10218. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  10219. end.style.top = (r * 100).toFixed(2) + '%';
  10220. }
  10221. end.classList.add('active');
  10222. });
  10223. div.addEventListener('mouseup', function () {
  10224. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10225. expandDivsTimer = setTimeout(function () {
  10226. if (_this2.textLayerRenderTask) {
  10227. _this2.textLayerRenderTask.expandTextDivs(false);
  10228. }
  10229. expandDivsTimer = null;
  10230. }, EXPAND_DIVS_TIMEOUT);
  10231. return;
  10232. }
  10233. var end = div.querySelector('.endOfContent');
  10234. if (!end) {
  10235. return;
  10236. }
  10237. end.style.top = '';
  10238. end.classList.remove('active');
  10239. });
  10240. }
  10241. }]);
  10242. return TextLayerBuilder;
  10243. }();
  10244. var DefaultTextLayerFactory = function () {
  10245. function DefaultTextLayerFactory() {
  10246. _classCallCheck(this, DefaultTextLayerFactory);
  10247. }
  10248. _createClass(DefaultTextLayerFactory, [{
  10249. key: 'createTextLayerBuilder',
  10250. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10251. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10252. return new TextLayerBuilder({
  10253. textLayerDiv: textLayerDiv,
  10254. pageIndex: pageIndex,
  10255. viewport: viewport,
  10256. enhanceTextSelection: enhanceTextSelection
  10257. });
  10258. }
  10259. }]);
  10260. return DefaultTextLayerFactory;
  10261. }();
  10262. exports.TextLayerBuilder = TextLayerBuilder;
  10263. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  10264. /***/
  10265. }),
  10266. /* 31 */
  10267. /***/ (function (module, exports, __webpack_require__) {
  10268. "use strict";
  10269. Object.defineProperty(exports, "__esModule", {
  10270. value: true
  10271. });
  10272. exports.Toolbar = undefined;
  10273. 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; }; }();
  10274. var _ui_utils = __webpack_require__(0);
  10275. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10276. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  10277. var SCALE_SELECT_CONTAINER_PADDING = 8;
  10278. var SCALE_SELECT_PADDING = 22;
  10279. var Toolbar = function () {
  10280. function Toolbar(options, mainContainer, eventBus) {
  10281. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  10282. _classCallCheck(this, Toolbar);
  10283. this.toolbar = options.container;
  10284. this.mainContainer = mainContainer;
  10285. this.eventBus = eventBus;
  10286. this.l10n = l10n;
  10287. this.items = options;
  10288. this._wasLocalized = false;
  10289. this.reset();
  10290. this._bindListeners();
  10291. }
  10292. _createClass(Toolbar, [{
  10293. key: 'setPageNumber',
  10294. value: function setPageNumber(pageNumber, pageLabel) {
  10295. this.pageNumber = pageNumber;
  10296. this.pageLabel = pageLabel;
  10297. this._updateUIState(false);
  10298. }
  10299. }, {
  10300. key: 'setPagesCount',
  10301. value: function setPagesCount(pagesCount, hasPageLabels) {
  10302. this.pagesCount = pagesCount;
  10303. this.hasPageLabels = hasPageLabels;
  10304. this._updateUIState(true);
  10305. }
  10306. }, {
  10307. key: 'setPageScale',
  10308. value: function setPageScale(pageScaleValue, pageScale) {
  10309. this.pageScaleValue = pageScaleValue;
  10310. this.pageScale = pageScale;
  10311. this._updateUIState(false);
  10312. }
  10313. }, {
  10314. key: 'reset',
  10315. value: function reset() {
  10316. this.pageNumber = 0;
  10317. this.pageLabel = null;
  10318. this.hasPageLabels = false;
  10319. this.pagesCount = 0;
  10320. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10321. this.pageScale = _ui_utils.DEFAULT_SCALE;
  10322. this._updateUIState(true);
  10323. }
  10324. }, {
  10325. key: '_bindListeners',
  10326. value: function _bindListeners() {
  10327. var _this = this;
  10328. var eventBus = this.eventBus,
  10329. items = this.items;
  10330. var self = this;
  10331. items.previous.addEventListener('click', function () {
  10332. eventBus.dispatch('previouspage');
  10333. });
  10334. items.next.addEventListener('click', function () {
  10335. eventBus.dispatch('nextpage');
  10336. });
  10337. items.zoomIn.addEventListener('click', function () {
  10338. eventBus.dispatch('zoomin');
  10339. });
  10340. items.zoomOut.addEventListener('click', function () {
  10341. eventBus.dispatch('zoomout');
  10342. });
  10343. items.pageNumber.addEventListener('click', function () {
  10344. this.select();
  10345. });
  10346. items.pageNumber.addEventListener('change', function () {
  10347. eventBus.dispatch('pagenumberchanged', {
  10348. source: self,
  10349. value: this.value
  10350. });
  10351. });
  10352. items.scaleSelect.addEventListener('change', function () {
  10353. if (this.value === 'custom') {
  10354. return;
  10355. }
  10356. eventBus.dispatch('scalechanged', {
  10357. source: self,
  10358. value: this.value
  10359. });
  10360. });
  10361. items.presentationModeButton.addEventListener('click', function () {
  10362. eventBus.dispatch('presentationmode');
  10363. });
  10364. items.openFile.addEventListener('click', function () {
  10365. eventBus.dispatch('openfile');
  10366. });
  10367. items.print.addEventListener('click', function () {
  10368. eventBus.dispatch('print');
  10369. });
  10370. items.download.addEventListener('click', function () {
  10371. eventBus.dispatch('download');
  10372. });
  10373. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  10374. eventBus.on('localized', function () {
  10375. _this._localized();
  10376. });
  10377. }
  10378. }, {
  10379. key: '_localized',
  10380. value: function _localized() {
  10381. this._wasLocalized = true;
  10382. this._adjustScaleWidth();
  10383. this._updateUIState(true);
  10384. }
  10385. }, {
  10386. key: '_updateUIState',
  10387. value: function _updateUIState() {
  10388. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10389. if (!this._wasLocalized) {
  10390. return;
  10391. }
  10392. var pageNumber = this.pageNumber,
  10393. pagesCount = this.pagesCount,
  10394. items = this.items;
  10395. var scaleValue = (this.pageScaleValue || this.pageScale).toString();
  10396. var scale = this.pageScale;
  10397. if (resetNumPages) {
  10398. if (this.hasPageLabels) {
  10399. items.pageNumber.type = 'text';
  10400. } else {
  10401. items.pageNumber.type = 'number';
  10402. this.l10n.get('of_pages', { pagesCount: pagesCount }, 'of {{pagesCount}}').then(function (msg) {
  10403. items.numPages.textContent = msg;
  10404. });
  10405. }
  10406. items.pageNumber.max = pagesCount;
  10407. }
  10408. if (this.hasPageLabels) {
  10409. items.pageNumber.value = this.pageLabel;
  10410. this.l10n.get('page_of_pages', {
  10411. pageNumber: pageNumber,
  10412. pagesCount: pagesCount
  10413. }, '({{pageNumber}} of {{pagesCount}})').then(function (msg) {
  10414. items.numPages.textContent = msg;
  10415. });
  10416. } else {
  10417. items.pageNumber.value = pageNumber;
  10418. }
  10419. items.previous.disabled = pageNumber <= 1;
  10420. items.next.disabled = pageNumber >= pagesCount;
  10421. items.zoomOut.disabled = scale <= _ui_utils.MIN_SCALE;
  10422. items.zoomIn.disabled = scale >= _ui_utils.MAX_SCALE;
  10423. var customScale = Math.round(scale * 10000) / 100;
  10424. this.l10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%').then(function (msg) {
  10425. var options = items.scaleSelect.options;
  10426. var predefinedValueFound = false;
  10427. for (var i = 0, ii = options.length; i < ii; i++) {
  10428. var option = options[i];
  10429. if (option.value !== scaleValue) {
  10430. option.selected = false;
  10431. continue;
  10432. }
  10433. option.selected = true;
  10434. predefinedValueFound = true;
  10435. }
  10436. if (!predefinedValueFound) {
  10437. items.customScaleOption.textContent = msg;
  10438. items.customScaleOption.selected = true;
  10439. }
  10440. });
  10441. }
  10442. }, {
  10443. key: 'updateLoadingIndicatorState',
  10444. value: function updateLoadingIndicatorState() {
  10445. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10446. var pageNumberInput = this.items.pageNumber;
  10447. if (loading) {
  10448. pageNumberInput.classList.add(PAGE_NUMBER_LOADING_INDICATOR);
  10449. } else {
  10450. pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR);
  10451. }
  10452. }
  10453. }, {
  10454. key: '_adjustScaleWidth',
  10455. value: function _adjustScaleWidth() {
  10456. var container = this.items.scaleSelectContainer;
  10457. var select = this.items.scaleSelect;
  10458. _ui_utils.animationStarted.then(function () {
  10459. if (container.clientWidth === 0) {
  10460. container.setAttribute('style', 'display: inherit;');
  10461. }
  10462. if (container.clientWidth > 0) {
  10463. select.setAttribute('style', 'min-width: inherit;');
  10464. var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
  10465. select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
  10466. container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;');
  10467. }
  10468. });
  10469. }
  10470. }]);
  10471. return Toolbar;
  10472. }();
  10473. exports.Toolbar = Toolbar;
  10474. /***/
  10475. }),
  10476. /* 32 */
  10477. /***/ (function (module, exports, __webpack_require__) {
  10478. "use strict";
  10479. Object.defineProperty(exports, "__esModule", {
  10480. value: true
  10481. });
  10482. 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; }; }();
  10483. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10484. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  10485. var ViewHistory = function () {
  10486. function ViewHistory(fingerprint) {
  10487. var _this = this;
  10488. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  10489. _classCallCheck(this, ViewHistory);
  10490. this.fingerprint = fingerprint;
  10491. this.cacheSize = cacheSize;
  10492. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  10493. var database = JSON.parse(databaseStr || '{}');
  10494. if (!('files' in database)) {
  10495. database.files = [];
  10496. }
  10497. if (database.files.length >= _this.cacheSize) {
  10498. database.files.shift();
  10499. }
  10500. var index = void 0;
  10501. for (var i = 0, length = database.files.length; i < length; i++) {
  10502. var branch = database.files[i];
  10503. if (branch.fingerprint === _this.fingerprint) {
  10504. index = i;
  10505. break;
  10506. }
  10507. }
  10508. if (typeof index !== 'number') {
  10509. index = database.files.push({ fingerprint: _this.fingerprint }) - 1;
  10510. }
  10511. _this.file = database.files[index];
  10512. _this.database = database;
  10513. });
  10514. }
  10515. _createClass(ViewHistory, [{
  10516. key: '_writeToStorage',
  10517. value: function _writeToStorage() {
  10518. var _this2 = this;
  10519. return new Promise(function (resolve) {
  10520. var databaseStr = JSON.stringify(_this2.database);
  10521. localStorage.setItem('pdfjs.history', databaseStr);
  10522. resolve();
  10523. });
  10524. }
  10525. }, {
  10526. key: '_readFromStorage',
  10527. value: function _readFromStorage() {
  10528. return new Promise(function (resolve) {
  10529. var value = localStorage.getItem('pdfjs.history');
  10530. if (!value) {
  10531. var databaseStr = localStorage.getItem('database');
  10532. if (databaseStr) {
  10533. try {
  10534. var database = JSON.parse(databaseStr);
  10535. if (typeof database.files[0].fingerprint === 'string') {
  10536. localStorage.setItem('pdfjs.history', databaseStr);
  10537. localStorage.removeItem('database');
  10538. value = databaseStr;
  10539. }
  10540. } catch (ex) { }
  10541. }
  10542. }
  10543. resolve(value);
  10544. });
  10545. }
  10546. }, {
  10547. key: 'set',
  10548. value: function set(name, val) {
  10549. var _this3 = this;
  10550. return this._initializedPromise.then(function () {
  10551. _this3.file[name] = val;
  10552. return _this3._writeToStorage();
  10553. });
  10554. }
  10555. }, {
  10556. key: 'setMultiple',
  10557. value: function setMultiple(properties) {
  10558. var _this4 = this;
  10559. return this._initializedPromise.then(function () {
  10560. for (var name in properties) {
  10561. _this4.file[name] = properties[name];
  10562. }
  10563. return _this4._writeToStorage();
  10564. });
  10565. }
  10566. }, {
  10567. key: 'get',
  10568. value: function get(name, defaultValue) {
  10569. var _this5 = this;
  10570. return this._initializedPromise.then(function () {
  10571. var val = _this5.file[name];
  10572. return val !== undefined ? val : defaultValue;
  10573. });
  10574. }
  10575. }, {
  10576. key: 'getMultiple',
  10577. value: function getMultiple(properties) {
  10578. var _this6 = this;
  10579. return this._initializedPromise.then(function () {
  10580. var values = Object.create(null);
  10581. for (var name in properties) {
  10582. var val = _this6.file[name];
  10583. values[name] = val !== undefined ? val : properties[name];
  10584. }
  10585. return values;
  10586. });
  10587. }
  10588. }]);
  10589. return ViewHistory;
  10590. }();
  10591. exports.ViewHistory = ViewHistory;
  10592. /***/
  10593. }),
  10594. /* 33 */
  10595. /***/ (function (module, exports, __webpack_require__) {
  10596. "use strict";
  10597. var DEFAULT_URL = my_pdf_file;//'compressed.tracemonkey-pldi-09.pdf';
  10598. ;
  10599. var pdfjsWebApp = void 0;
  10600. {
  10601. pdfjsWebApp = __webpack_require__(4);
  10602. }
  10603. ;
  10604. {
  10605. __webpack_require__(8);
  10606. }
  10607. ;
  10608. {
  10609. __webpack_require__(9);
  10610. }
  10611. function getViewerConfiguration() {
  10612. return {
  10613. appContainer: document.body,
  10614. mainContainer: document.getElementById('viewerContainer'),
  10615. viewerContainer: document.getElementById('viewer'),
  10616. eventBus: null,
  10617. toolbar: {
  10618. container: document.getElementById('toolbarViewer'),
  10619. numPages: document.getElementById('numPages'),
  10620. pageNumber: document.getElementById('pageNumber'),
  10621. scaleSelectContainer: document.getElementById('scaleSelectContainer'),
  10622. scaleSelect: document.getElementById('scaleSelect'),
  10623. customScaleOption: document.getElementById('customScaleOption'),
  10624. previous: document.getElementById('previous'),
  10625. next: document.getElementById('next'),
  10626. zoomIn: document.getElementById('zoomIn'),
  10627. zoomOut: document.getElementById('zoomOut'),
  10628. viewFind: document.getElementById('viewFind'),
  10629. openFile: document.getElementById('openFile'),
  10630. print: document.getElementById('print'),
  10631. presentationModeButton: document.getElementById('presentationMode'),
  10632. download: document.getElementById('download'),
  10633. viewBookmark: document.getElementById('viewBookmark')
  10634. },
  10635. secondaryToolbar: {
  10636. toolbar: document.getElementById('secondaryToolbar'),
  10637. toggleButton: document.getElementById('secondaryToolbarToggle'),
  10638. toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
  10639. presentationModeButton: document.getElementById('secondaryPresentationMode'),
  10640. openFileButton: document.getElementById('secondaryOpenFile'),
  10641. printButton: document.getElementById('secondaryPrint'),
  10642. downloadButton: document.getElementById('secondaryDownload'),
  10643. viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
  10644. firstPageButton: document.getElementById('firstPage'),
  10645. lastPageButton: document.getElementById('lastPage'),
  10646. pageRotateCwButton: document.getElementById('pageRotateCw'),
  10647. pageRotateCcwButton: document.getElementById('pageRotateCcw'),
  10648. cursorSelectToolButton: document.getElementById('cursorSelectTool'),
  10649. cursorHandToolButton: document.getElementById('cursorHandTool'),
  10650. documentPropertiesButton: document.getElementById('pdfDocumentProperties')
  10651. },
  10652. fullscreen: {
  10653. contextFirstPage: document.getElementById('contextFirstPage'),
  10654. contextLastPage: document.getElementById('contextLastPage'),
  10655. contextPageRotateCw: document.getElementById('contextPageRotateCw'),
  10656. contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
  10657. },
  10658. sidebar: {
  10659. mainContainer: document.getElementById('mainContainer'),
  10660. outerContainer: document.getElementById('outerContainer'),
  10661. toggleButton: document.getElementById('sidebarToggle'),
  10662. thumbnailButton: document.getElementById('viewThumbnail'),
  10663. outlineButton: document.getElementById('viewOutline'),
  10664. attachmentsButton: document.getElementById('viewAttachments'),
  10665. thumbnailView: document.getElementById('thumbnailView'),
  10666. outlineView: document.getElementById('outlineView'),
  10667. attachmentsView: document.getElementById('attachmentsView')
  10668. },
  10669. findBar: {
  10670. bar: document.getElementById('findbar'),
  10671. toggleButton: document.getElementById('viewFind'),
  10672. findField: document.getElementById('findInput'),
  10673. highlightAllCheckbox: document.getElementById('findHighlightAll'),
  10674. caseSensitiveCheckbox: document.getElementById('findMatchCase'),
  10675. findMsg: document.getElementById('findMsg'),
  10676. findResultsCount: document.getElementById('findResultsCount'),
  10677. findStatusIcon: document.getElementById('findStatusIcon'),
  10678. findPreviousButton: document.getElementById('findPrevious'),
  10679. findNextButton: document.getElementById('findNext')
  10680. },
  10681. passwordOverlay: {
  10682. overlayName: 'passwordOverlay',
  10683. container: document.getElementById('passwordOverlay'),
  10684. label: document.getElementById('passwordText'),
  10685. input: document.getElementById('password'),
  10686. submitButton: document.getElementById('passwordSubmit'),
  10687. cancelButton: document.getElementById('passwordCancel')
  10688. },
  10689. pdfDocumentProperties: {
  10690. overlayName: 'documentPropertiesOverlay',
  10691. container: document.getElementById('documentPropertiesOverlay'),
  10692. closeButton: document.getElementById('documentPropertiesClose'),
  10693. fields: {
  10694. 'fileName': document.getElementById('fileNameField'),
  10695. 'fileSize': document.getElementById('fileSizeField'),
  10696. 'title': document.getElementById('titleField'),
  10697. 'author': document.getElementById('authorField'),
  10698. 'subject': document.getElementById('subjectField'),
  10699. 'keywords': document.getElementById('keywordsField'),
  10700. 'creationDate': document.getElementById('creationDateField'),
  10701. 'modificationDate': document.getElementById('modificationDateField'),
  10702. 'creator': document.getElementById('creatorField'),
  10703. 'producer': document.getElementById('producerField'),
  10704. 'version': document.getElementById('versionField'),
  10705. 'pageCount': document.getElementById('pageCountField')
  10706. }
  10707. },
  10708. errorWrapper: {
  10709. container: document.getElementById('errorWrapper'),
  10710. errorMessage: document.getElementById('errorMessage'),
  10711. closeButton: document.getElementById('errorClose'),
  10712. errorMoreInfo: document.getElementById('errorMoreInfo'),
  10713. moreInfoButton: document.getElementById('errorShowMore'),
  10714. lessInfoButton: document.getElementById('errorShowLess')
  10715. },
  10716. printContainer: document.getElementById('printContainer'),
  10717. openFileInputName: 'fileInput',
  10718. debuggerScriptPath: './debugger.js',
  10719. defaultUrl: DEFAULT_URL
  10720. };
  10721. }
  10722. function webViewerLoad() {
  10723. var config = getViewerConfiguration();
  10724. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  10725. pdfjsWebApp.PDFViewerApplication.run(config);
  10726. }
  10727. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  10728. webViewerLoad();
  10729. } else {
  10730. document.addEventListener('DOMContentLoaded', webViewerLoad, true);
  10731. }
  10732. /***/
  10733. })
  10734. /******/]);
  10735. //# sourceMappingURL=viewer.js.map
  10736. // open a file in the viewer
  10737. // The workerSrc property shall be specified.
  10738. //PDFJS.workerSrc = './Content/pdfViewer/pdf.worker.js';
  10739. /*
  10740. var file = fObj.Obj;
  10741. scale = 0.5||pdfSet.pdfScale;
  10742. PDFJS.disableWorker = true;
  10743. PDFJS.getDocument(file).then(function(pdfDoc){
  10744. for(var num = 1; num <= pdfDoc.numPages; num++){
  10745. pdfDoc.getPage(num).then(function(page){
  10746. var viewport = page.getViewport(scale); //options.scale
  10747. var canvas = document.createElement('canvas');
  10748. var ctx = canvas.getContext('2d');
  10749. var renderContext = {
  10750. canvasContext: ctx,
  10751. viewport: viewport
  10752. };
  10753. canvas.height = viewport.height;
  10754. canvas.width = viewport.width;
  10755. $("#"+divId + " #viewer").append(canvas);
  10756. page.render(renderContext);
  10757. });
  10758. }
  10759. });
  10760. */
  10761. return true;
  10762. }
  10763. /////////////////////////////////////////////////Docx//////////////////////////////////////////
  10764. function getDocxContent(fObj, divId, docxSet) {
  10765. $("#" + divId).html("");
  10766. var file = fObj.Obj;
  10767. var mammothOptions = {
  10768. styleMap: docxSet.styleMap,
  10769. includeEmbeddedStyleMap: docxSet.includeEmbeddedStyleMap,
  10770. includeDefaultStyleMap: docxSet.includeDefaultStyleMap,
  10771. convertImage: docxSet.convertImage,
  10772. ignoreEmptyParagraphs: docxSet.ignoreEmptyParagraphs,
  10773. idPrefix: docxSet.idPrefix,
  10774. isRtl: docxSet.isRtl
  10775. };
  10776. JSZipUtils.getBinaryContent(file, function (err, content) {
  10777. mammoth.convertToHtml({ arrayBuffer: content }, mammothOptions)
  10778. .then(displayResult)
  10779. .done();
  10780. });
  10781. function displayResult(result) {
  10782. var isRtl = mammothOptions.isRtl;
  10783. var rslt = result.value;
  10784. if (isRtl == "auto") {
  10785. var position = rslt.search(/[\u0590-\u05FF]/);
  10786. if (position >= 0) {
  10787. $('#' + divId).attr("dir", "rtl");
  10788. } else {
  10789. $('#' + divId).attr("dir", "ltr");
  10790. }
  10791. } else if (isRtl === true) {
  10792. $('#' + divId).attr("dir", "rtl");
  10793. } else if (isRtl === false) {
  10794. $('#' + divId).attr("dir", "ltr");
  10795. }
  10796. $('#' + divId).html(rslt);
  10797. if (result.messages != "") {
  10798. var messageHtml = result.messages.map(function (message) {
  10799. return message.type + ': ' + message.message + "\n";
  10800. }).join("");
  10801. console.log("Docx viewer Messages: \n" + messageHtml + "\n");
  10802. }
  10803. }
  10804. return true;
  10805. }
  10806. /////////////////////////////////////////////////doc//////////////////////////////////////////
  10807. function getDocContent(fObj, divId, docxSet) {
  10808. $("#" + divId).html("");
  10809. var file = fObj.Obj;
  10810. var ran5 = 10000 + Math.round(Math.floor() * 90000);
  10811. var subDiv = $('<div/>').attr({ class: 'doc_files', id: "doc_file_" + ran5, style: "color:#9d9999;font-size:30pt" });
  10812. $("#" + divId).append(subDiv);
  10813. $("#doc_file_" + ran5).html(".doc file is not supported, convert it to .docx file");
  10814. return
  10815. }
  10816. /////////////////////////////////////////////////pptx//////////////////////////////////////////
  10817. function getPptxContent(fObj, divId, pptxSet) {
  10818. $("#" + divId).html("");
  10819. //console.log(fObj,divId);
  10820. var file = fObj.Obj;
  10821. $("#" + divId).pptxToHtml({
  10822. pptxFileUrl: file,
  10823. slidesScale: pptxSet.slidesScale, //Change Slides scale by percent
  10824. slideMode: pptxSet.slideMode, /** true,false*/
  10825. keyBoardShortCut: pptxSet.keyBoardShortCut, /** true,false ,condition: slideMode: true XXXXX - need to remove - this is doublcated*/
  10826. mediaProcess: pptxSet.mediaProcess, /** true,false: if true then process video and audio files */
  10827. jsZipV2: pptxSet.jsZipV2,
  10828. slideModeConfig: {
  10829. first: pptxSet.slideModeConfig.first,
  10830. nav: pptxSet.slideModeConfig.nav, /** true,false : show or not nav buttons*/
  10831. navTxtColor: pptxSet.slideModeConfig.navTxtColor, /** color */
  10832. keyBoardShortCut: pptxSet.slideModeConfig.keyBoardShortCut, /** true,false ,condition: */
  10833. showSlideNum: pptxSet.slideModeConfig.showSlideNum, /** true,false */
  10834. showTotalSlideNum: pptxSet.slideModeConfig.showTotalSlideNum, /** true,false */
  10835. autoSlide: pptxSet.slideModeConfig.autoSlide, /** false or seconds , F8 to active ,keyBoardShortCut: true */
  10836. randomAutoSlide: pptxSet.slideModeConfig.randomAutoSlide, /** true,false ,autoSlide:true */
  10837. loop: pptxSet.slideModeConfig.loop, /** true,false */
  10838. background: pptxSet.slideModeConfig.background, /** false or color*/
  10839. transition: pptxSet.slideModeConfig.transition, /** transition type: "slid","fade","default","random" , to show transition efects :transitionTime > 0.5 */
  10840. transitionTime: pptxSet.slideModeConfig.transitionTime /** transition time between slides in seconds */
  10841. }
  10842. });
  10843. return true;
  10844. }
  10845. /////////////////////////////////////////////////ppt//////////////////////////////////////////
  10846. function getPptContent(fObj, divId, pptxSet) {
  10847. $("#" + divId).html("");
  10848. var file = fObj.Obj;
  10849. var ran5 = 10000 + Math.round(Math.floor() * 90000);
  10850. var subDiv = $('<div/>').attr({ class: 'ppt_files', id: "ppt_file_" + ran5, style: "color:#9d9999;font-size:30pt" });
  10851. $("#" + divId).append(subDiv);
  10852. $("#ppt_file_" + ran5).html(".ppt file is not supported, convert it to .pptx file");
  10853. return true;
  10854. }
  10855. /////////////////////////////////////////////////Sheet//////////////////////////////////////////
  10856. function getSheetContent(fObj, divId, sheetSet) {
  10857. if (jQuery.ui === undefined && sheetSet.jqueryui) {
  10858. console.log("You set jqueryui as true , but you not included jquery-ui.js and jquery-ui.css");
  10859. sheetSet.jqueryui = false;
  10860. }
  10861. if (jQuery.ui && sheetSet.jqueryui) {
  10862. $("." + divId + "_clas").tabs("destroy");
  10863. }
  10864. var file = fObj.Obj;
  10865. var $container, availableWidth, availableHeight;
  10866. var hot, hot_ary = [];
  10867. $container = $("#" + divId);
  10868. $container.addClass(divId + "_clas");
  10869. $container.addClass("wbSheets_clas");
  10870. if (sheetSet.search) {
  10871. $("<div></div>", {
  10872. id: "wbSheets_search_warpper"
  10873. }).appendTo('#' + divId);
  10874. $("<input/>", {
  10875. id: "wbSheets_search_field",
  10876. type: "text",
  10877. placeholder: "Search...",
  10878. style: "border-radius: 5px; width:20%;"
  10879. }).appendTo('#' + divId + " #wbSheets_search_warpper");
  10880. $("<hr>", {
  10881. }).appendTo('#' + divId);
  10882. }
  10883. //function process_wb(wb) {
  10884. //}
  10885. var url = file;
  10886. var req = new XMLHttpRequest();
  10887. req.open("GET", url, true);
  10888. req.responseType = "arraybuffer";
  10889. req.onload = function (e) {
  10890. var data = new Uint8Array(req.response);
  10891. var wb = XLSX.read(data, { type: "array" });
  10892. var sheetNames = wb.SheetNames;
  10893. /*
  10894. $container.append('<ul class="wbSheets_clas_ul">');
  10895. var li_container = "";
  10896. sheetNames.forEach(function (sheetName, idx) {
  10897. var subDivId = 'wbSheets_' + idx;
  10898. var slcted = "";
  10899. if (!sheetSet.jqueryui && idx == 0) {
  10900. slcted = "selected"
  10901. }
  10902. $("#" + divId + " ul").append('<li class = "' + slcted + '"><a href="#' + subDivId + '">' + sheetName + '</a></li>');
  10903. });
  10904. */
  10905. sheetNames.forEach(function (sheetName, idx) {
  10906. var subDivId = 'wbSheets_' + idx;
  10907. var json = XLSX.utils.sheet_to_json(wb.Sheets[sheetName], { header: 1 });
  10908. var dsply = "";
  10909. if (!sheetSet.jqueryui) {
  10910. if (idx == 0) {
  10911. dsply = "display:block;";
  10912. } else {
  10913. dsply = "display:none;";
  10914. }
  10915. }
  10916. var subDiv = $('<div/>').attr({
  10917. class: 'wbSheets',
  10918. id: subDivId,
  10919. style: dsply
  10920. });
  10921. //$container.append(subDiv);
  10922. //availableWidth = Math.max(subDiv.width(),600);
  10923. //availableHeight = Math.max(subDiv.height(), 500);
  10924. availableWidth = $container.width() - 20;
  10925. availableHeight = $container.height() - ((sheetSet.search) ? 90 : 50);
  10926. /* add header row for table */
  10927. if (!json) json = [];
  10928. json.forEach(function (r) {
  10929. //must "...,{header:1}"
  10930. if (json[0].length < r.length) json[0].length = r.length;
  10931. });
  10932. /*
  10933. MAIN LOOP TO ITERATE ALL SHEETS FROM XLSX
  10934. */
  10935. let thisSheet = '';
  10936. thisSheet += (`<table class="ui celled unstackable table">
  10937. <thead>
  10938. <tr>
  10939. <th colspan="100%">${sheetName}</th>
  10940. </tr>
  10941. </thead>
  10942. <tbody>`);
  10943. console.log(json);
  10944. //Get the max width of table
  10945. let maxWidthGrid = 0;
  10946. let trimOffLine = json.length;
  10947. let lineCounter = 0;
  10948. let previousLineIsZero = false;
  10949. json.forEach(function(line){
  10950. //Get the max width of the table
  10951. if (line.length > maxWidthGrid){
  10952. maxWidthGrid = line.length;
  10953. }
  10954. //Calculate early stop line
  10955. if (line.length == 0 && !previousLineIsZero){
  10956. trimOffLine = lineCounter;
  10957. previousLineIsZero = true;
  10958. }else if (previousLineIsZero && line.length > 0){
  10959. trimOffLine = lineCounter;
  10960. previousLineIsZero = false;
  10961. }
  10962. lineCounter++;
  10963. });
  10964. lineCounter = 0;
  10965. for (var x = 0; x < trimOffLine; x++){
  10966. let line = json[x];
  10967. thisSheet += (`<tr>`);
  10968. for (var i = 0; i < maxWidthGrid; i++){
  10969. let thisGridValue = line[i];
  10970. if (typeof(thisGridValue) != "undefined"){
  10971. thisSheet += (`<td>${thisGridValue}</td>`);
  10972. }else{
  10973. //Empty grid
  10974. thisSheet += (`<td></td>`);
  10975. }
  10976. }
  10977. thisSheet += (`</tr>`);
  10978. lineCounter++;
  10979. }
  10980. thisSheet += (`</tbody></table>`);
  10981. $($container).append(thisSheet);
  10982. /*
  10983. var container = document.getElementById(subDivId);
  10984. hot = new Handsontable(container, {
  10985. data: json,
  10986. activeHeaderClassName: sheetSet.activeHeaderClassName,
  10987. allowEmpty: sheetSet.allowEmpty,
  10988. autoColumnSize: sheetSet.autoColumnSize,
  10989. autoRowSize: sheetSet.autoRowSize,
  10990. columns: sheetSet.columns,
  10991. columnSorting: sheetSet.columnSorting,
  10992. contextMenu: sheetSet.contextMenu,
  10993. copyable: sheetSet.copyable,
  10994. fixedColumnsLeft: sheetSet.fixedColumnsLeft,
  10995. fixedRowsTop: sheetSet.fixedRowsTop,
  10996. language: sheetSet.language,
  10997. search: sheetSet.search,
  10998. selectionMode: sheetSet.selectionMode,
  10999. sortIndicator: sheetSet.sortIndicator,
  11000. readOnly: sheetSet.readOnly,
  11001. startRows: sheetSet.startRows,
  11002. startCols: sheetSet.startCols,
  11003. rowHeaders: sheetSet.rowHeaders,
  11004. colHeaders: sheetSet.colHeaders,
  11005. width: (!sheetSet.width) ? availableWidth : sheetSet.width,
  11006. height: (!sheetSet.height) ? availableHeight : sheetSet.height
  11007. });
  11008. hot_ary.push(hot);
  11009. */
  11010. });
  11011. /*
  11012. if (jQuery.ui && sheetSet.jqueryui) {
  11013. $("." + divId + "_clas").tabs();
  11014. } else {
  11015. $("." + divId + "_clas li").click(function (e) {
  11016. e.preventDefault();
  11017. $("." + divId + "_clas li").removeClass("selected");
  11018. $(this).addClass("selected");
  11019. var hrf = $($(this)[0].firstChild).attr("href").substr(1);
  11020. $("." + divId + "_clas .wbSheets").hide();
  11021. $("." + divId + "_clas #" + hrf).show();
  11022. });
  11023. }
  11024. if (sheetSet.search) {
  11025. var searchFiled = document.getElementById('wbSheets_search_field');
  11026. Handsontable.dom.addEvent(searchFiled, 'keyup', function (event) {
  11027. var srch_txt = this.value;
  11028. hot_ary.forEach(function (hot_val) {
  11029. var search = hot_val.getPlugin('search');
  11030. var queryResult = search.query(srch_txt);
  11031. hot_val.render();
  11032. })
  11033. });
  11034. }
  11035. //$("."+divId+"_clas").tabs("refresh");
  11036. */
  11037. /*
  11038. availableWidth = $container.width()-105;
  11039. availableHeight = $container.height()-70;
  11040. $("."+divId+"_clas .wbSheets .ht_master .wtHolder").css({
  11041. width: availableWidth,
  11042. height:availableHeight
  11043. });
  11044. $("."+divId+"_clas .wbSheets .ht_master .wtHolder").on("scroll",function(){
  11045. $("."+divId+"_clas .wbSheets .ht_master .wtHolder").css({
  11046. width: availableWidth,
  11047. height:availableHeight
  11048. });
  11049. })
  11050. */
  11051. };
  11052. req.send();
  11053. return true;
  11054. }
  11055. /////////////////////////////////////////////////Images//////////////////////////////////////////
  11056. function getImgContent(fObj, divId, imgSet) {
  11057. $("#" + divId).html("");
  11058. var file = fObj.Obj;
  11059. var img_div = $("#" + divId);
  11060. $("#" + divId).verySimpleImageViewer({
  11061. imageSource: file,
  11062. frame: imgSet.frame,
  11063. maxZoom: imgSet.maxZoom,
  11064. zoomFactor: imgSet.zoomFactor,
  11065. mouse: imgSet.mouse,
  11066. keyboard: imgSet.keyboard,
  11067. toolbar: imgSet.toolbar,
  11068. rotateToolbar: imgSet.rotateToolbar
  11069. });
  11070. return true;
  11071. }
  11072. /////////////////////////////////////////////////Unknown file//////////////////////////////////////////
  11073. function unknownMsg(divId) {
  11074. $("#" + divId).html("");
  11075. var ran5 = 10000 + Math.round(Math.floor() * 90000);
  11076. var subDiv = $('<div/>').attr({ class: 'unknown_files', id: "unknown_file_" + ran5, style: "color:#9d9999;font-size:30pt" });
  11077. $("#" + divId).append(subDiv);
  11078. $("#unknown_file_" + ran5).html("The file is not supported!");
  11079. return true;
  11080. }
  11081. }(jQuery));