viewer.js 342 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. /******/ (function(modules) { // webpackBootstrap
  16. /******/ // The module cache
  17. /******/ var installedModules = {};
  18. /******/
  19. /******/ // The require function
  20. /******/ function __webpack_require__(moduleId) {
  21. /******/
  22. /******/ // Check if module is in cache
  23. /******/ if(installedModules[moduleId]) {
  24. /******/ return installedModules[moduleId].exports;
  25. /******/ }
  26. /******/ // Create a new module (and put it into the cache)
  27. /******/ var module = installedModules[moduleId] = {
  28. /******/ i: moduleId,
  29. /******/ l: false,
  30. /******/ exports: {}
  31. /******/ };
  32. /******/
  33. /******/ // Execute the module function
  34. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  35. /******/
  36. /******/ // Flag the module as loaded
  37. /******/ module.l = true;
  38. /******/
  39. /******/ // Return the exports of the module
  40. /******/ return module.exports;
  41. /******/ }
  42. /******/
  43. /******/
  44. /******/ // expose the modules object (__webpack_modules__)
  45. /******/ __webpack_require__.m = modules;
  46. /******/
  47. /******/ // expose the module cache
  48. /******/ __webpack_require__.c = installedModules;
  49. /******/
  50. /******/ // identity function for calling harmony imports with the correct context
  51. /******/ __webpack_require__.i = function(value) { return value; };
  52. /******/
  53. /******/ // define getter function for harmony exports
  54. /******/ __webpack_require__.d = function(exports, name, getter) {
  55. /******/ if(!__webpack_require__.o(exports, name)) {
  56. /******/ Object.defineProperty(exports, name, {
  57. /******/ configurable: false,
  58. /******/ enumerable: true,
  59. /******/ get: getter
  60. /******/ });
  61. /******/ }
  62. /******/ };
  63. /******/
  64. /******/ // getDefaultExport function for compatibility with non-harmony modules
  65. /******/ __webpack_require__.n = function(module) {
  66. /******/ var getter = module && module.__esModule ?
  67. /******/ function getDefault() { return module['default']; } :
  68. /******/ function getModuleExports() { return module; };
  69. /******/ __webpack_require__.d(getter, 'a', getter);
  70. /******/ return getter;
  71. /******/ };
  72. /******/
  73. /******/ // Object.prototype.hasOwnProperty.call
  74. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  75. /******/
  76. /******/ // __webpack_public_path__
  77. /******/ __webpack_require__.p = "";
  78. /******/
  79. /******/ // Load entry module and return exports
  80. /******/ return __webpack_require__(__webpack_require__.s = 33);
  81. /******/ })
  82. /************************************************************************/
  83. /******/ ([
  84. /* 0 */
  85. /***/ (function(module, exports, __webpack_require__) {
  86. "use strict";
  87. Object.defineProperty(exports, "__esModule", {
  88. value: true
  89. });
  90. 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;
  91. 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; }; }();
  92. var _pdfjsLib = __webpack_require__(1);
  93. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  94. var CSS_UNITS = 96.0 / 72.0;
  95. var DEFAULT_SCALE_VALUE = 'auto';
  96. var DEFAULT_SCALE = 1.0;
  97. var MIN_SCALE = 0.25;
  98. var MAX_SCALE = 10.0;
  99. var UNKNOWN_SCALE = 0;
  100. var MAX_AUTO_SCALE = 1.25;
  101. var SCROLLBAR_PADDING = 40;
  102. var VERTICAL_PADDING = 5;
  103. var RendererType = {
  104. CANVAS: 'canvas',
  105. SVG: 'svg'
  106. };
  107. function formatL10nValue(text, args) {
  108. if (!args) {
  109. return text;
  110. }
  111. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  112. return name in args ? args[name] : '{{' + name + '}}';
  113. });
  114. }
  115. var NullL10n = {
  116. get: function get(property, args, fallback) {
  117. return Promise.resolve(formatL10nValue(fallback, args));
  118. },
  119. translate: function translate(element) {
  120. return Promise.resolve();
  121. }
  122. };
  123. _pdfjsLib.PDFJS.disableFullscreen = _pdfjsLib.PDFJS.disableFullscreen === undefined ? false : _pdfjsLib.PDFJS.disableFullscreen;
  124. _pdfjsLib.PDFJS.useOnlyCssZoom = _pdfjsLib.PDFJS.useOnlyCssZoom === undefined ? false : _pdfjsLib.PDFJS.useOnlyCssZoom;
  125. _pdfjsLib.PDFJS.maxCanvasPixels = _pdfjsLib.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjsLib.PDFJS.maxCanvasPixels;
  126. _pdfjsLib.PDFJS.disableHistory = _pdfjsLib.PDFJS.disableHistory === undefined ? false : _pdfjsLib.PDFJS.disableHistory;
  127. _pdfjsLib.PDFJS.disableTextLayer = _pdfjsLib.PDFJS.disableTextLayer === undefined ? false : _pdfjsLib.PDFJS.disableTextLayer;
  128. _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom = _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom === undefined ? false : _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom;
  129. {
  130. _pdfjsLib.PDFJS.locale = _pdfjsLib.PDFJS.locale === undefined && typeof navigator !== 'undefined' ? navigator.language : _pdfjsLib.PDFJS.locale;
  131. }
  132. function getOutputScale(ctx) {
  133. var devicePixelRatio = window.devicePixelRatio || 1;
  134. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  135. var pixelRatio = devicePixelRatio / backingStoreRatio;
  136. return {
  137. sx: pixelRatio,
  138. sy: pixelRatio,
  139. scaled: pixelRatio !== 1
  140. };
  141. }
  142. function scrollIntoView(element, spot) {
  143. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  144. var parent = element.offsetParent;
  145. if (!parent) {
  146. console.error('offsetParent is not set -- cannot scroll');
  147. return;
  148. }
  149. var offsetY = element.offsetTop + element.clientTop;
  150. var offsetX = element.offsetLeft + element.clientLeft;
  151. while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  152. if (parent.dataset._scaleY) {
  153. offsetY /= parent.dataset._scaleY;
  154. offsetX /= parent.dataset._scaleX;
  155. }
  156. offsetY += parent.offsetTop;
  157. offsetX += parent.offsetLeft;
  158. parent = parent.offsetParent;
  159. if (!parent) {
  160. return;
  161. }
  162. }
  163. if (spot) {
  164. if (spot.top !== undefined) {
  165. offsetY += spot.top;
  166. }
  167. if (spot.left !== undefined) {
  168. offsetX += spot.left;
  169. parent.scrollLeft = offsetX;
  170. }
  171. }
  172. parent.scrollTop = offsetY;
  173. }
  174. function watchScroll(viewAreaElement, callback) {
  175. var debounceScroll = function debounceScroll(evt) {
  176. if (rAF) {
  177. return;
  178. }
  179. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  180. rAF = null;
  181. var currentY = viewAreaElement.scrollTop;
  182. var lastY = state.lastY;
  183. if (currentY !== lastY) {
  184. state.down = currentY > lastY;
  185. }
  186. state.lastY = currentY;
  187. callback(state);
  188. });
  189. };
  190. var state = {
  191. down: true,
  192. lastY: viewAreaElement.scrollTop,
  193. _eventHandler: debounceScroll
  194. };
  195. var rAF = null;
  196. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  197. return state;
  198. }
  199. function parseQueryString(query) {
  200. var parts = query.split('&');
  201. var params = Object.create(null);
  202. for (var i = 0, ii = parts.length; i < ii; ++i) {
  203. var param = parts[i].split('=');
  204. var key = param[0].toLowerCase();
  205. var value = param.length > 1 ? param[1] : null;
  206. params[decodeURIComponent(key)] = decodeURIComponent(value);
  207. }
  208. return params;
  209. }
  210. function binarySearchFirstItem(items, condition) {
  211. var minIndex = 0;
  212. var maxIndex = items.length - 1;
  213. if (items.length === 0 || !condition(items[maxIndex])) {
  214. return items.length;
  215. }
  216. if (condition(items[minIndex])) {
  217. return minIndex;
  218. }
  219. while (minIndex < maxIndex) {
  220. var currentIndex = minIndex + maxIndex >> 1;
  221. var currentItem = items[currentIndex];
  222. if (condition(currentItem)) {
  223. maxIndex = currentIndex;
  224. } else {
  225. minIndex = currentIndex + 1;
  226. }
  227. }
  228. return minIndex;
  229. }
  230. function approximateFraction(x) {
  231. if (Math.floor(x) === x) {
  232. return [x, 1];
  233. }
  234. var xinv = 1 / x;
  235. var limit = 8;
  236. if (xinv > limit) {
  237. return [1, limit];
  238. } else if (Math.floor(xinv) === xinv) {
  239. return [1, xinv];
  240. }
  241. var x_ = x > 1 ? xinv : x;
  242. var a = 0,
  243. b = 1,
  244. c = 1,
  245. d = 1;
  246. while (true) {
  247. var p = a + c,
  248. q = b + d;
  249. if (q > limit) {
  250. break;
  251. }
  252. if (x_ <= p / q) {
  253. c = p;
  254. d = q;
  255. } else {
  256. a = p;
  257. b = q;
  258. }
  259. }
  260. var result = void 0;
  261. if (x_ - a / b < c / d - x_) {
  262. result = x_ === x ? [a, b] : [b, a];
  263. } else {
  264. result = x_ === x ? [c, d] : [d, c];
  265. }
  266. return result;
  267. }
  268. function roundToDivide(x, div) {
  269. var r = x % div;
  270. return r === 0 ? x : Math.round(x - r + div);
  271. }
  272. function getVisibleElements(scrollEl, views) {
  273. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  274. var top = scrollEl.scrollTop,
  275. bottom = top + scrollEl.clientHeight;
  276. var left = scrollEl.scrollLeft,
  277. right = left + scrollEl.clientWidth;
  278. function isElementBottomBelowViewTop(view) {
  279. var element = view.div;
  280. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  281. return elementBottom > top;
  282. }
  283. var visible = [],
  284. view = void 0,
  285. element = void 0;
  286. var currentHeight = void 0,
  287. viewHeight = void 0,
  288. hiddenHeight = void 0,
  289. percentHeight = void 0;
  290. var currentWidth = void 0,
  291. viewWidth = void 0;
  292. var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
  293. for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {
  294. view = views[i];
  295. element = view.div;
  296. currentHeight = element.offsetTop + element.clientTop;
  297. viewHeight = element.clientHeight;
  298. if (currentHeight > bottom) {
  299. break;
  300. }
  301. currentWidth = element.offsetLeft + element.clientLeft;
  302. viewWidth = element.clientWidth;
  303. if (currentWidth + viewWidth < left || currentWidth > right) {
  304. continue;
  305. }
  306. hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);
  307. percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;
  308. visible.push({
  309. id: view.id,
  310. x: currentWidth,
  311. y: currentHeight,
  312. view: view,
  313. percent: percentHeight
  314. });
  315. }
  316. var first = visible[0];
  317. var last = visible[visible.length - 1];
  318. if (sortByVisibility) {
  319. visible.sort(function (a, b) {
  320. var pc = a.percent - b.percent;
  321. if (Math.abs(pc) > 0.001) {
  322. return -pc;
  323. }
  324. return a.id - b.id;
  325. });
  326. }
  327. return {
  328. first: first,
  329. last: last,
  330. views: visible
  331. };
  332. }
  333. function noContextMenuHandler(evt) {
  334. evt.preventDefault();
  335. }
  336. function isDataSchema(url) {
  337. var i = 0,
  338. ii = url.length;
  339. while (i < ii && url[i].trim() === '') {
  340. i++;
  341. }
  342. return url.substr(i, 5).toLowerCase() === 'data:';
  343. }
  344. function getPDFFileNameFromURL(url) {
  345. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  346. if (isDataSchema(url)) {
  347. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  348. return defaultFilename;
  349. }
  350. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  351. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  352. var splitURI = reURI.exec(url);
  353. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  354. if (suggestedFilename) {
  355. suggestedFilename = suggestedFilename[0];
  356. if (suggestedFilename.indexOf('%') !== -1) {
  357. try {
  358. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  359. } catch (ex) {}
  360. }
  361. }
  362. return suggestedFilename || defaultFilename;
  363. }
  364. function normalizeWheelEventDelta(evt) {
  365. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  366. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  367. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  368. delta = -delta;
  369. }
  370. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  371. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  372. var MOUSE_PIXELS_PER_LINE = 30;
  373. var MOUSE_LINES_PER_PAGE = 30;
  374. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  375. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  376. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  377. delta /= MOUSE_LINES_PER_PAGE;
  378. }
  379. return delta;
  380. }
  381. function cloneObj(obj) {
  382. var result = Object.create(null);
  383. for (var i in obj) {
  384. if (Object.prototype.hasOwnProperty.call(obj, i)) {
  385. result[i] = obj[i];
  386. }
  387. }
  388. return result;
  389. }
  390. var animationStarted = new Promise(function (resolve) {
  391. window.requestAnimationFrame(resolve);
  392. });
  393. var mozL10n = void 0;
  394. var localized = Promise.resolve();
  395. var EventBus = function () {
  396. function EventBus() {
  397. _classCallCheck(this, EventBus);
  398. this._listeners = Object.create(null);
  399. }
  400. _createClass(EventBus, [{
  401. key: 'on',
  402. value: function on(eventName, listener) {
  403. var eventListeners = this._listeners[eventName];
  404. if (!eventListeners) {
  405. eventListeners = [];
  406. this._listeners[eventName] = eventListeners;
  407. }
  408. eventListeners.push(listener);
  409. }
  410. }, {
  411. key: 'off',
  412. value: function off(eventName, listener) {
  413. var eventListeners = this._listeners[eventName];
  414. var i = void 0;
  415. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  416. return;
  417. }
  418. eventListeners.splice(i, 1);
  419. }
  420. }, {
  421. key: 'dispatch',
  422. value: function dispatch(eventName) {
  423. var eventListeners = this._listeners[eventName];
  424. if (!eventListeners || eventListeners.length === 0) {
  425. return;
  426. }
  427. var args = Array.prototype.slice.call(arguments, 1);
  428. eventListeners.slice(0).forEach(function (listener) {
  429. listener.apply(null, args);
  430. });
  431. }
  432. }]);
  433. return EventBus;
  434. }();
  435. function clamp(v, min, max) {
  436. return Math.min(Math.max(v, min), max);
  437. }
  438. var ProgressBar = function () {
  439. function ProgressBar(id) {
  440. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  441. height = _ref.height,
  442. width = _ref.width,
  443. units = _ref.units;
  444. _classCallCheck(this, ProgressBar);
  445. this.visible = true;
  446. this.div = document.querySelector(id + ' .progress');
  447. this.bar = this.div.parentNode;
  448. this.height = height || 100;
  449. this.width = width || 100;
  450. this.units = units || '%';
  451. this.div.style.height = this.height + this.units;
  452. this.percent = 0;
  453. }
  454. _createClass(ProgressBar, [{
  455. key: '_updateBar',
  456. value: function _updateBar() {
  457. if (this._indeterminate) {
  458. this.div.classList.add('indeterminate');
  459. this.div.style.width = this.width + this.units;
  460. return;
  461. }
  462. this.div.classList.remove('indeterminate');
  463. var progressSize = this.width * this._percent / 100;
  464. this.div.style.width = progressSize + this.units;
  465. }
  466. }, {
  467. key: 'setWidth',
  468. value: function setWidth(viewer) {
  469. if (!viewer) {
  470. return;
  471. }
  472. var container = viewer.parentNode;
  473. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  474. if (scrollbarWidth > 0) {
  475. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  476. }
  477. }
  478. }, {
  479. key: 'hide',
  480. value: function hide() {
  481. if (!this.visible) {
  482. return;
  483. }
  484. this.visible = false;
  485. this.bar.classList.add('hidden');
  486. document.body.classList.remove('loadingInProgress');
  487. }
  488. }, {
  489. key: 'show',
  490. value: function show() {
  491. if (this.visible) {
  492. return;
  493. }
  494. this.visible = true;
  495. document.body.classList.add('loadingInProgress');
  496. this.bar.classList.remove('hidden');
  497. }
  498. }, {
  499. key: 'percent',
  500. get: function get() {
  501. return this._percent;
  502. },
  503. set: function set(val) {
  504. this._indeterminate = isNaN(val);
  505. this._percent = clamp(val, 0, 100);
  506. this._updateBar();
  507. }
  508. }]);
  509. return ProgressBar;
  510. }();
  511. exports.CSS_UNITS = CSS_UNITS;
  512. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  513. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  514. exports.MIN_SCALE = MIN_SCALE;
  515. exports.MAX_SCALE = MAX_SCALE;
  516. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  517. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  518. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  519. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  520. exports.cloneObj = cloneObj;
  521. exports.RendererType = RendererType;
  522. exports.mozL10n = mozL10n;
  523. exports.NullL10n = NullL10n;
  524. exports.EventBus = EventBus;
  525. exports.ProgressBar = ProgressBar;
  526. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  527. exports.noContextMenuHandler = noContextMenuHandler;
  528. exports.parseQueryString = parseQueryString;
  529. exports.getVisibleElements = getVisibleElements;
  530. exports.roundToDivide = roundToDivide;
  531. exports.approximateFraction = approximateFraction;
  532. exports.getOutputScale = getOutputScale;
  533. exports.scrollIntoView = scrollIntoView;
  534. exports.watchScroll = watchScroll;
  535. exports.binarySearchFirstItem = binarySearchFirstItem;
  536. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  537. exports.animationStarted = animationStarted;
  538. exports.localized = localized;
  539. /***/ }),
  540. /* 1 */
  541. /***/ (function(module, exports, __webpack_require__) {
  542. "use strict";
  543. var pdfjsLib;
  544. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  545. pdfjsLib = window['pdfjs-dist/build/pdf'];
  546. } else {
  547. pdfjsLib = require('../build/pdf.js');
  548. }
  549. module.exports = pdfjsLib;
  550. /***/ }),
  551. /* 2 */
  552. /***/ (function(module, exports, __webpack_require__) {
  553. "use strict";
  554. Object.defineProperty(exports, "__esModule", {
  555. value: true
  556. });
  557. exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
  558. var _ui_utils = __webpack_require__(0);
  559. function attachDOMEventsToEventBus(eventBus) {
  560. eventBus.on('documentload', function () {
  561. var event = document.createEvent('CustomEvent');
  562. event.initCustomEvent('documentload', true, true, {});
  563. window.dispatchEvent(event);
  564. });
  565. eventBus.on('pagerendered', function (evt) {
  566. var event = document.createEvent('CustomEvent');
  567. event.initCustomEvent('pagerendered', true, true, {
  568. pageNumber: evt.pageNumber,
  569. cssTransform: evt.cssTransform
  570. });
  571. evt.source.div.dispatchEvent(event);
  572. });
  573. eventBus.on('textlayerrendered', function (evt) {
  574. var event = document.createEvent('CustomEvent');
  575. event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber });
  576. evt.source.textLayerDiv.dispatchEvent(event);
  577. });
  578. eventBus.on('pagechange', function (evt) {
  579. var event = document.createEvent('UIEvents');
  580. event.initUIEvent('pagechange', true, true, window, 0);
  581. event.pageNumber = evt.pageNumber;
  582. evt.source.container.dispatchEvent(event);
  583. });
  584. eventBus.on('pagesinit', function (evt) {
  585. var event = document.createEvent('CustomEvent');
  586. event.initCustomEvent('pagesinit', true, true, null);
  587. evt.source.container.dispatchEvent(event);
  588. });
  589. eventBus.on('pagesloaded', function (evt) {
  590. var event = document.createEvent('CustomEvent');
  591. event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount });
  592. evt.source.container.dispatchEvent(event);
  593. });
  594. eventBus.on('scalechange', function (evt) {
  595. var event = document.createEvent('UIEvents');
  596. event.initUIEvent('scalechange', true, true, window, 0);
  597. event.scale = evt.scale;
  598. event.presetValue = evt.presetValue;
  599. evt.source.container.dispatchEvent(event);
  600. });
  601. eventBus.on('updateviewarea', function (evt) {
  602. var event = document.createEvent('UIEvents');
  603. event.initUIEvent('updateviewarea', true, true, window, 0);
  604. event.location = evt.location;
  605. evt.source.container.dispatchEvent(event);
  606. });
  607. eventBus.on('find', function (evt) {
  608. if (evt.source === window) {
  609. return;
  610. }
  611. var event = document.createEvent('CustomEvent');
  612. event.initCustomEvent('find' + evt.type, true, true, {
  613. query: evt.query,
  614. phraseSearch: evt.phraseSearch,
  615. caseSensitive: evt.caseSensitive,
  616. highlightAll: evt.highlightAll,
  617. findPrevious: evt.findPrevious
  618. });
  619. window.dispatchEvent(event);
  620. });
  621. eventBus.on('attachmentsloaded', function (evt) {
  622. var event = document.createEvent('CustomEvent');
  623. event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount });
  624. evt.source.container.dispatchEvent(event);
  625. });
  626. eventBus.on('sidebarviewchanged', function (evt) {
  627. var event = document.createEvent('CustomEvent');
  628. event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view });
  629. evt.source.outerContainer.dispatchEvent(event);
  630. });
  631. eventBus.on('pagemode', function (evt) {
  632. var event = document.createEvent('CustomEvent');
  633. event.initCustomEvent('pagemode', true, true, { mode: evt.mode });
  634. evt.source.pdfViewer.container.dispatchEvent(event);
  635. });
  636. eventBus.on('namedaction', function (evt) {
  637. var event = document.createEvent('CustomEvent');
  638. event.initCustomEvent('namedaction', true, true, { action: evt.action });
  639. evt.source.pdfViewer.container.dispatchEvent(event);
  640. });
  641. eventBus.on('presentationmodechanged', function (evt) {
  642. var event = document.createEvent('CustomEvent');
  643. event.initCustomEvent('presentationmodechanged', true, true, {
  644. active: evt.active,
  645. switchInProgress: evt.switchInProgress
  646. });
  647. window.dispatchEvent(event);
  648. });
  649. eventBus.on('outlineloaded', function (evt) {
  650. var event = document.createEvent('CustomEvent');
  651. event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });
  652. evt.source.container.dispatchEvent(event);
  653. });
  654. }
  655. var globalEventBus = null;
  656. function getGlobalEventBus() {
  657. if (globalEventBus) {
  658. return globalEventBus;
  659. }
  660. globalEventBus = new _ui_utils.EventBus();
  661. attachDOMEventsToEventBus(globalEventBus);
  662. return globalEventBus;
  663. }
  664. exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
  665. exports.getGlobalEventBus = getGlobalEventBus;
  666. /***/ }),
  667. /* 3 */
  668. /***/ (function(module, exports, __webpack_require__) {
  669. "use strict";
  670. Object.defineProperty(exports, "__esModule", {
  671. value: true
  672. });
  673. 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; }; }();
  674. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  675. var CLEANUP_TIMEOUT = 30000;
  676. var RenderingStates = {
  677. INITIAL: 0,
  678. RUNNING: 1,
  679. PAUSED: 2,
  680. FINISHED: 3
  681. };
  682. var PDFRenderingQueue = function () {
  683. function PDFRenderingQueue() {
  684. _classCallCheck(this, PDFRenderingQueue);
  685. this.pdfViewer = null;
  686. this.pdfThumbnailViewer = null;
  687. this.onIdle = null;
  688. this.highestPriorityPage = null;
  689. this.idleTimeout = null;
  690. this.printing = false;
  691. this.isThumbnailViewEnabled = false;
  692. }
  693. _createClass(PDFRenderingQueue, [{
  694. key: "setViewer",
  695. value: function setViewer(pdfViewer) {
  696. this.pdfViewer = pdfViewer;
  697. }
  698. }, {
  699. key: "setThumbnailViewer",
  700. value: function setThumbnailViewer(pdfThumbnailViewer) {
  701. this.pdfThumbnailViewer = pdfThumbnailViewer;
  702. }
  703. }, {
  704. key: "isHighestPriority",
  705. value: function isHighestPriority(view) {
  706. return this.highestPriorityPage === view.renderingId;
  707. }
  708. }, {
  709. key: "renderHighestPriority",
  710. value: function renderHighestPriority(currentlyVisiblePages) {
  711. if (this.idleTimeout) {
  712. clearTimeout(this.idleTimeout);
  713. this.idleTimeout = null;
  714. }
  715. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  716. return;
  717. }
  718. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  719. if (this.pdfThumbnailViewer.forceRendering()) {
  720. return;
  721. }
  722. }
  723. if (this.printing) {
  724. return;
  725. }
  726. if (this.onIdle) {
  727. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  728. }
  729. }
  730. }, {
  731. key: "getHighestPriority",
  732. value: function getHighestPriority(visible, views, scrolledDown) {
  733. var visibleViews = visible.views;
  734. var numVisible = visibleViews.length;
  735. if (numVisible === 0) {
  736. return false;
  737. }
  738. for (var i = 0; i < numVisible; ++i) {
  739. var view = visibleViews[i].view;
  740. if (!this.isViewFinished(view)) {
  741. return view;
  742. }
  743. }
  744. if (scrolledDown) {
  745. var nextPageIndex = visible.last.id;
  746. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  747. return views[nextPageIndex];
  748. }
  749. } else {
  750. var previousPageIndex = visible.first.id - 2;
  751. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  752. return views[previousPageIndex];
  753. }
  754. }
  755. return null;
  756. }
  757. }, {
  758. key: "isViewFinished",
  759. value: function isViewFinished(view) {
  760. return view.renderingState === RenderingStates.FINISHED;
  761. }
  762. }, {
  763. key: "renderView",
  764. value: function renderView(view) {
  765. var _this = this;
  766. switch (view.renderingState) {
  767. case RenderingStates.FINISHED:
  768. return false;
  769. case RenderingStates.PAUSED:
  770. this.highestPriorityPage = view.renderingId;
  771. view.resume();
  772. break;
  773. case RenderingStates.RUNNING:
  774. this.highestPriorityPage = view.renderingId;
  775. break;
  776. case RenderingStates.INITIAL:
  777. this.highestPriorityPage = view.renderingId;
  778. var continueRendering = function continueRendering() {
  779. _this.renderHighestPriority();
  780. };
  781. view.draw().then(continueRendering, continueRendering);
  782. break;
  783. }
  784. return true;
  785. }
  786. }]);
  787. return PDFRenderingQueue;
  788. }();
  789. exports.RenderingStates = RenderingStates;
  790. exports.PDFRenderingQueue = PDFRenderingQueue;
  791. /***/ }),
  792. /* 4 */
  793. /***/ (function(module, exports, __webpack_require__) {
  794. "use strict";
  795. Object.defineProperty(exports, "__esModule", {
  796. value: true
  797. });
  798. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = undefined;
  799. 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"); } }; }();
  800. var _ui_utils = __webpack_require__(0);
  801. var _pdfjsLib = __webpack_require__(1);
  802. var _pdf_cursor_tools = __webpack_require__(6);
  803. var _pdf_rendering_queue = __webpack_require__(3);
  804. var _pdf_sidebar = __webpack_require__(24);
  805. var _pdf_viewer = __webpack_require__(27);
  806. var _dom_events = __webpack_require__(2);
  807. var _overlay_manager = __webpack_require__(15);
  808. var _password_prompt = __webpack_require__(16);
  809. var _pdf_attachment_viewer = __webpack_require__(17);
  810. var _pdf_document_properties = __webpack_require__(18);
  811. var _pdf_find_bar = __webpack_require__(19);
  812. var _pdf_find_controller = __webpack_require__(7);
  813. var _pdf_history = __webpack_require__(20);
  814. var _pdf_link_service = __webpack_require__(5);
  815. var _pdf_outline_viewer = __webpack_require__(21);
  816. var _pdf_presentation_mode = __webpack_require__(23);
  817. var _pdf_thumbnail_viewer = __webpack_require__(26);
  818. var _secondary_toolbar = __webpack_require__(29);
  819. var _toolbar = __webpack_require__(31);
  820. var _view_history = __webpack_require__(32);
  821. var DEFAULT_SCALE_DELTA = 1.1;
  822. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  823. function configure(PDFJS) {
  824. PDFJS.imageResourcesPath = './images/';
  825. PDFJS.workerSrc = '../build/pdf.worker.js';
  826. PDFJS.cMapUrl = '../web/cmaps/';
  827. PDFJS.cMapPacked = true;
  828. }
  829. var DefaultExternalServices = {
  830. updateFindControlState: function updateFindControlState(data) {},
  831. initPassiveLoading: function initPassiveLoading(callbacks) {},
  832. fallback: function fallback(data, callback) {},
  833. reportTelemetry: function reportTelemetry(data) {},
  834. createDownloadManager: function createDownloadManager() {
  835. throw new Error('Not implemented: createDownloadManager');
  836. },
  837. createPreferences: function createPreferences() {
  838. throw new Error('Not implemented: createPreferences');
  839. },
  840. createL10n: function createL10n() {
  841. throw new Error('Not implemented: createL10n');
  842. },
  843. supportsIntegratedFind: false,
  844. supportsDocumentFonts: true,
  845. supportsDocumentColors: true,
  846. supportedMouseWheelZoomModifierKeys: {
  847. ctrlKey: true,
  848. metaKey: true
  849. }
  850. };
  851. var PDFViewerApplication = {
  852. initialBookmark: document.location.hash.substring(1),
  853. initialDestination: null,
  854. initialized: false,
  855. fellback: false,
  856. appConfig: null,
  857. pdfDocument: null,
  858. pdfLoadingTask: null,
  859. printService: null,
  860. pdfViewer: null,
  861. pdfThumbnailViewer: null,
  862. pdfRenderingQueue: null,
  863. pdfPresentationMode: null,
  864. pdfDocumentProperties: null,
  865. pdfLinkService: null,
  866. pdfHistory: null,
  867. pdfSidebar: null,
  868. pdfOutlineViewer: null,
  869. pdfAttachmentViewer: null,
  870. pdfCursorTools: null,
  871. store: null,
  872. downloadManager: null,
  873. overlayManager: null,
  874. preferences: null,
  875. toolbar: null,
  876. secondaryToolbar: null,
  877. eventBus: null,
  878. l10n: null,
  879. isInitialViewSet: false,
  880. downloadComplete: false,
  881. viewerPrefs: {
  882. sidebarViewOnLoad: _pdf_sidebar.SidebarView.NONE,
  883. pdfBugEnabled: false,
  884. showPreviousViewOnLoad: true,
  885. defaultZoomValue: '',
  886. disablePageMode: false,
  887. disablePageLabels: false,
  888. renderer: 'canvas',
  889. enhanceTextSelection: false,
  890. renderInteractiveForms: false,
  891. enablePrintAutoRotate: false
  892. },
  893. isViewerEmbedded: window.parent !== window,
  894. url: '',
  895. baseUrl: '',
  896. externalServices: DefaultExternalServices,
  897. _boundEvents: {},
  898. initialize: function initialize(appConfig) {
  899. var _this = this;
  900. this.preferences = this.externalServices.createPreferences();
  901. configure(_pdfjsLib.PDFJS);
  902. this.appConfig = appConfig;
  903. return this._readPreferences().then(function () {
  904. return _this._initializeL10n();
  905. }).then(function () {
  906. return _this._initializeViewerComponents();
  907. }).then(function () {
  908. _this.bindEvents();
  909. _this.bindWindowEvents();
  910. var appContainer = appConfig.appContainer || document.documentElement;
  911. _this.l10n.translate(appContainer).then(function () {
  912. _this.eventBus.dispatch('localized');
  913. });
  914. if (_this.isViewerEmbedded && !_pdfjsLib.PDFJS.isExternalLinkTargetSet()) {
  915. _pdfjsLib.PDFJS.externalLinkTarget = _pdfjsLib.PDFJS.LinkTarget.TOP;
  916. }
  917. _this.initialized = true;
  918. });
  919. },
  920. _readPreferences: function _readPreferences() {
  921. var preferences = this.preferences,
  922. viewerPrefs = this.viewerPrefs;
  923. return Promise.all([preferences.get('enableWebGL').then(function resolved(value) {
  924. _pdfjsLib.PDFJS.disableWebGL = !value;
  925. }), preferences.get('sidebarViewOnLoad').then(function resolved(value) {
  926. viewerPrefs['sidebarViewOnLoad'] = value;
  927. }), preferences.get('pdfBugEnabled').then(function resolved(value) {
  928. viewerPrefs['pdfBugEnabled'] = value;
  929. }), preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
  930. viewerPrefs['showPreviousViewOnLoad'] = value;
  931. }), preferences.get('defaultZoomValue').then(function resolved(value) {
  932. viewerPrefs['defaultZoomValue'] = value;
  933. }), preferences.get('enhanceTextSelection').then(function resolved(value) {
  934. viewerPrefs['enhanceTextSelection'] = value;
  935. }), preferences.get('disableTextLayer').then(function resolved(value) {
  936. if (_pdfjsLib.PDFJS.disableTextLayer === true) {
  937. return;
  938. }
  939. _pdfjsLib.PDFJS.disableTextLayer = value;
  940. }), preferences.get('disableRange').then(function resolved(value) {
  941. if (_pdfjsLib.PDFJS.disableRange === true) {
  942. return;
  943. }
  944. _pdfjsLib.PDFJS.disableRange = value;
  945. }), preferences.get('disableStream').then(function resolved(value) {
  946. if (_pdfjsLib.PDFJS.disableStream === true) {
  947. return;
  948. }
  949. _pdfjsLib.PDFJS.disableStream = value;
  950. }), preferences.get('disableAutoFetch').then(function resolved(value) {
  951. _pdfjsLib.PDFJS.disableAutoFetch = value;
  952. }), preferences.get('disableFontFace').then(function resolved(value) {
  953. if (_pdfjsLib.PDFJS.disableFontFace === true) {
  954. return;
  955. }
  956. _pdfjsLib.PDFJS.disableFontFace = value;
  957. }), preferences.get('useOnlyCssZoom').then(function resolved(value) {
  958. _pdfjsLib.PDFJS.useOnlyCssZoom = value;
  959. }), preferences.get('externalLinkTarget').then(function resolved(value) {
  960. if (_pdfjsLib.PDFJS.isExternalLinkTargetSet()) {
  961. return;
  962. }
  963. _pdfjsLib.PDFJS.externalLinkTarget = value;
  964. }), preferences.get('renderer').then(function resolved(value) {
  965. viewerPrefs['renderer'] = value;
  966. }), preferences.get('renderInteractiveForms').then(function resolved(value) {
  967. viewerPrefs['renderInteractiveForms'] = value;
  968. }), preferences.get('disablePageMode').then(function resolved(value) {
  969. viewerPrefs['disablePageMode'] = value;
  970. }), preferences.get('disablePageLabels').then(function resolved(value) {
  971. viewerPrefs['disablePageLabels'] = value;
  972. }), preferences.get('enablePrintAutoRotate').then(function resolved(value) {
  973. viewerPrefs['enablePrintAutoRotate'] = value;
  974. })]).catch(function (reason) {});
  975. },
  976. _initializeL10n: function _initializeL10n() {
  977. if (this.viewerPrefs['pdfBugEnabled']) {
  978. var hash = document.location.hash.substring(1);
  979. var hashParams = (0, _ui_utils.parseQueryString)(hash);
  980. if ('locale' in hashParams) {
  981. _pdfjsLib.PDFJS.locale = hashParams['locale'];
  982. }
  983. }
  984. this.l10n = this.externalServices.createL10n();
  985. return this.l10n.getDirection().then(function (dir) {
  986. document.getElementsByTagName('html')[0].dir = dir;
  987. });
  988. },
  989. _initializeViewerComponents: function _initializeViewerComponents() {
  990. var _this2 = this;
  991. var appConfig = this.appConfig;
  992. return new Promise(function (resolve, reject) {
  993. _this2.overlayManager = new _overlay_manager.OverlayManager();
  994. var eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)();
  995. _this2.eventBus = eventBus;
  996. var pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  997. pdfRenderingQueue.onIdle = _this2.cleanup.bind(_this2);
  998. _this2.pdfRenderingQueue = pdfRenderingQueue;
  999. var pdfLinkService = new _pdf_link_service.PDFLinkService({ eventBus: eventBus });
  1000. _this2.pdfLinkService = pdfLinkService;
  1001. var downloadManager = _this2.externalServices.createDownloadManager();
  1002. _this2.downloadManager = downloadManager;
  1003. var container = appConfig.mainContainer;
  1004. var viewer = appConfig.viewerContainer;
  1005. _this2.pdfViewer = new _pdf_viewer.PDFViewer({
  1006. container: container,
  1007. viewer: viewer,
  1008. eventBus: eventBus,
  1009. renderingQueue: pdfRenderingQueue,
  1010. linkService: pdfLinkService,
  1011. downloadManager: downloadManager,
  1012. renderer: _this2.viewerPrefs['renderer'],
  1013. l10n: _this2.l10n,
  1014. enhanceTextSelection: _this2.viewerPrefs['enhanceTextSelection'],
  1015. renderInteractiveForms: _this2.viewerPrefs['renderInteractiveForms'],
  1016. enablePrintAutoRotate: _this2.viewerPrefs['enablePrintAutoRotate']
  1017. });
  1018. pdfRenderingQueue.setViewer(_this2.pdfViewer);
  1019. pdfLinkService.setViewer(_this2.pdfViewer);
  1020. var thumbnailContainer = appConfig.sidebar.thumbnailView;
  1021. _this2.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  1022. container: thumbnailContainer,
  1023. renderingQueue: pdfRenderingQueue,
  1024. linkService: pdfLinkService,
  1025. l10n: _this2.l10n
  1026. });
  1027. pdfRenderingQueue.setThumbnailViewer(_this2.pdfThumbnailViewer);
  1028. _this2.pdfHistory = new _pdf_history.PDFHistory({
  1029. linkService: pdfLinkService,
  1030. eventBus: eventBus
  1031. });
  1032. pdfLinkService.setHistory(_this2.pdfHistory);
  1033. _this2.findController = new _pdf_find_controller.PDFFindController({ pdfViewer: _this2.pdfViewer });
  1034. _this2.findController.onUpdateResultsCount = function (matchCount) {
  1035. if (_this2.supportsIntegratedFind) {
  1036. return;
  1037. }
  1038. _this2.findBar.updateResultsCount(matchCount);
  1039. };
  1040. _this2.findController.onUpdateState = function (state, previous, matchCount) {
  1041. if (_this2.supportsIntegratedFind) {
  1042. _this2.externalServices.updateFindControlState({
  1043. result: state,
  1044. findPrevious: previous
  1045. });
  1046. } else {
  1047. _this2.findBar.updateUIState(state, previous, matchCount);
  1048. }
  1049. };
  1050. _this2.pdfViewer.setFindController(_this2.findController);
  1051. var findBarConfig = Object.create(appConfig.findBar);
  1052. findBarConfig.findController = _this2.findController;
  1053. findBarConfig.eventBus = eventBus;
  1054. _this2.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig, _this2.l10n);
  1055. _this2.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this2.overlayManager, _this2.l10n);
  1056. _this2.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  1057. container: container,
  1058. eventBus: eventBus,
  1059. preferences: _this2.preferences
  1060. });
  1061. _this2.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus, _this2.l10n);
  1062. _this2.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  1063. if (_this2.supportsFullscreen) {
  1064. _this2.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  1065. container: container,
  1066. viewer: viewer,
  1067. pdfViewer: _this2.pdfViewer,
  1068. eventBus: eventBus,
  1069. contextMenuItems: appConfig.fullscreen
  1070. });
  1071. }
  1072. _this2.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this2.overlayManager, _this2.l10n);
  1073. _this2.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  1074. container: appConfig.sidebar.outlineView,
  1075. eventBus: eventBus,
  1076. linkService: pdfLinkService
  1077. });
  1078. _this2.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  1079. container: appConfig.sidebar.attachmentsView,
  1080. eventBus: eventBus,
  1081. downloadManager: downloadManager
  1082. });
  1083. var sidebarConfig = Object.create(appConfig.sidebar);
  1084. sidebarConfig.pdfViewer = _this2.pdfViewer;
  1085. sidebarConfig.pdfThumbnailViewer = _this2.pdfThumbnailViewer;
  1086. sidebarConfig.pdfOutlineViewer = _this2.pdfOutlineViewer;
  1087. sidebarConfig.eventBus = eventBus;
  1088. _this2.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, _this2.l10n);
  1089. _this2.pdfSidebar.onToggled = _this2.forceRendering.bind(_this2);
  1090. resolve(undefined);
  1091. });
  1092. },
  1093. run: function run(config) {
  1094. this.initialize(config).then(webViewerInitialized);
  1095. },
  1096. zoomIn: function zoomIn(ticks) {
  1097. var newScale = this.pdfViewer.currentScale;
  1098. do {
  1099. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  1100. newScale = Math.ceil(newScale * 10) / 10;
  1101. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  1102. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  1103. this.pdfViewer.currentScaleValue = newScale;
  1104. },
  1105. zoomOut: function zoomOut(ticks) {
  1106. var newScale = this.pdfViewer.currentScale;
  1107. do {
  1108. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  1109. newScale = Math.floor(newScale * 10) / 10;
  1110. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  1111. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  1112. this.pdfViewer.currentScaleValue = newScale;
  1113. },
  1114. get pagesCount() {
  1115. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1116. },
  1117. get pageRotation() {
  1118. return this.pdfViewer.pagesRotation;
  1119. },
  1120. set page(val) {
  1121. this.pdfViewer.currentPageNumber = val;
  1122. },
  1123. get page() {
  1124. return this.pdfViewer.currentPageNumber;
  1125. },
  1126. get printing() {
  1127. return !!this.printService;
  1128. },
  1129. get supportsPrinting() {
  1130. return PDFPrintServiceFactory.instance.supportsPrinting;
  1131. },
  1132. get supportsFullscreen() {
  1133. var support = void 0;
  1134. var doc = document.documentElement;
  1135. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  1136. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  1137. support = false;
  1138. }
  1139. if (support && _pdfjsLib.PDFJS.disableFullscreen === true) {
  1140. support = false;
  1141. }
  1142. return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support);
  1143. },
  1144. get supportsIntegratedFind() {
  1145. return this.externalServices.supportsIntegratedFind;
  1146. },
  1147. get supportsDocumentFonts() {
  1148. return this.externalServices.supportsDocumentFonts;
  1149. },
  1150. get supportsDocumentColors() {
  1151. return this.externalServices.supportsDocumentColors;
  1152. },
  1153. get loadingBar() {
  1154. var bar = new _ui_utils.ProgressBar('#loadingBar');
  1155. return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar);
  1156. },
  1157. get supportedMouseWheelZoomModifierKeys() {
  1158. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  1159. },
  1160. initPassiveLoading: function initPassiveLoading() {
  1161. throw new Error('Not implemented: initPassiveLoading');
  1162. },
  1163. setTitleUsingUrl: function setTitleUsingUrl(url) {
  1164. this.url = url;
  1165. this.baseUrl = url.split('#')[0];
  1166. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  1167. if (!title) {
  1168. try {
  1169. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  1170. } catch (ex) {
  1171. title = url;
  1172. }
  1173. }
  1174. this.setTitle(title);
  1175. },
  1176. setTitle: function setTitle(title) {
  1177. if (this.isViewerEmbedded) {
  1178. return;
  1179. }
  1180. document.title = title;
  1181. },
  1182. close: function close() {
  1183. var errorWrapper = this.appConfig.errorWrapper.container;
  1184. errorWrapper.setAttribute('hidden', 'true');
  1185. if (!this.pdfLoadingTask) {
  1186. return Promise.resolve();
  1187. }
  1188. var promise = this.pdfLoadingTask.destroy();
  1189. this.pdfLoadingTask = null;
  1190. if (this.pdfDocument) {
  1191. this.pdfDocument = null;
  1192. this.pdfThumbnailViewer.setDocument(null);
  1193. this.pdfViewer.setDocument(null);
  1194. this.pdfLinkService.setDocument(null, null);
  1195. this.pdfDocumentProperties.setDocument(null, null);
  1196. }
  1197. this.store = null;
  1198. this.isInitialViewSet = false;
  1199. this.downloadComplete = false;
  1200. this.pdfSidebar.reset();
  1201. this.pdfOutlineViewer.reset();
  1202. this.pdfAttachmentViewer.reset();
  1203. this.findController.reset();
  1204. this.findBar.reset();
  1205. this.toolbar.reset();
  1206. this.secondaryToolbar.reset();
  1207. if (typeof PDFBug !== 'undefined') {
  1208. PDFBug.cleanup();
  1209. }
  1210. return promise;
  1211. },
  1212. open: function open(file, args) {
  1213. var _this3 = this;
  1214. if (arguments.length > 2 || typeof args === 'number') {
  1215. return Promise.reject(new Error('Call of open() with obsolete signature.'));
  1216. }
  1217. if (this.pdfLoadingTask) {
  1218. return this.close().then(function () {
  1219. _this3.preferences.reload();
  1220. return _this3.open(file, args);
  1221. });
  1222. }
  1223. var parameters = Object.create(null),
  1224. scale = void 0;
  1225. if (typeof file === 'string') {
  1226. this.setTitleUsingUrl(file);
  1227. parameters.url = file;
  1228. } else if (file && 'byteLength' in file) {
  1229. parameters.data = file;
  1230. } else if (file.url && file.originalUrl) {
  1231. this.setTitleUsingUrl(file.originalUrl);
  1232. parameters.url = file.url;
  1233. }
  1234. if (args) {
  1235. for (var prop in args) {
  1236. parameters[prop] = args[prop];
  1237. }
  1238. if (args.scale) {
  1239. scale = args.scale;
  1240. }
  1241. if (args.length) {
  1242. this.pdfDocumentProperties.setFileSize(args.length);
  1243. }
  1244. }
  1245. var loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  1246. this.pdfLoadingTask = loadingTask;
  1247. loadingTask.onPassword = function (updateCallback, reason) {
  1248. _this3.passwordPrompt.setUpdateCallback(updateCallback, reason);
  1249. _this3.passwordPrompt.open();
  1250. };
  1251. loadingTask.onProgress = function (_ref) {
  1252. var loaded = _ref.loaded,
  1253. total = _ref.total;
  1254. _this3.progress(loaded / total);
  1255. };
  1256. loadingTask.onUnsupportedFeature = this.fallback.bind(this);
  1257. return loadingTask.promise.then(function (pdfDocument) {
  1258. _this3.load(pdfDocument, scale);
  1259. }, function (exception) {
  1260. var message = exception && exception.message;
  1261. var loadingErrorMessage = void 0;
  1262. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  1263. loadingErrorMessage = _this3.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
  1264. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  1265. loadingErrorMessage = _this3.l10n.get('missing_file_error', null, 'Missing PDF file.');
  1266. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  1267. loadingErrorMessage = _this3.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
  1268. } else {
  1269. loadingErrorMessage = _this3.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
  1270. }
  1271. return loadingErrorMessage.then(function (msg) {
  1272. _this3.error(msg, { message: message });
  1273. throw new Error(msg);
  1274. });
  1275. });
  1276. },
  1277. download: function download() {
  1278. var _this4 = this;
  1279. function downloadByUrl() {
  1280. downloadManager.downloadUrl(url, filename);
  1281. }
  1282. var url = this.baseUrl;
  1283. var filename = (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  1284. var downloadManager = this.downloadManager;
  1285. downloadManager.onerror = function (err) {
  1286. _this4.error('PDF failed to download: ' + err);
  1287. };
  1288. if (!this.pdfDocument || !this.downloadComplete) {
  1289. downloadByUrl();
  1290. return;
  1291. }
  1292. this.pdfDocument.getData().then(function (data) {
  1293. var blob = (0, _pdfjsLib.createBlob)(data, 'application/pdf');
  1294. downloadManager.download(blob, url, filename);
  1295. }).catch(downloadByUrl);
  1296. },
  1297. fallback: function fallback(featureId) {},
  1298. error: function error(message, moreInfo) {
  1299. var moreInfoText = [this.l10n.get('error_version_info', {
  1300. version: _pdfjsLib.version || '?',
  1301. build: _pdfjsLib.build || '?'
  1302. }, 'PDF.js v{{version}} (build: {{build}})')];
  1303. if (moreInfo) {
  1304. moreInfoText.push(this.l10n.get('error_message', { message: moreInfo.message }, 'Message: {{message}}'));
  1305. if (moreInfo.stack) {
  1306. moreInfoText.push(this.l10n.get('error_stack', { stack: moreInfo.stack }, 'Stack: {{stack}}'));
  1307. } else {
  1308. if (moreInfo.filename) {
  1309. moreInfoText.push(this.l10n.get('error_file', { file: moreInfo.filename }, 'File: {{file}}'));
  1310. }
  1311. if (moreInfo.lineNumber) {
  1312. moreInfoText.push(this.l10n.get('error_line', { line: moreInfo.lineNumber }, 'Line: {{line}}'));
  1313. }
  1314. }
  1315. }
  1316. var errorWrapperConfig = this.appConfig.errorWrapper;
  1317. var errorWrapper = errorWrapperConfig.container;
  1318. errorWrapper.removeAttribute('hidden');
  1319. var errorMessage = errorWrapperConfig.errorMessage;
  1320. errorMessage.textContent = message;
  1321. var closeButton = errorWrapperConfig.closeButton;
  1322. closeButton.onclick = function () {
  1323. errorWrapper.setAttribute('hidden', 'true');
  1324. };
  1325. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1326. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1327. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1328. moreInfoButton.onclick = function () {
  1329. errorMoreInfo.removeAttribute('hidden');
  1330. moreInfoButton.setAttribute('hidden', 'true');
  1331. lessInfoButton.removeAttribute('hidden');
  1332. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
  1333. };
  1334. lessInfoButton.onclick = function () {
  1335. errorMoreInfo.setAttribute('hidden', 'true');
  1336. moreInfoButton.removeAttribute('hidden');
  1337. lessInfoButton.setAttribute('hidden', 'true');
  1338. };
  1339. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1340. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1341. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1342. moreInfoButton.removeAttribute('hidden');
  1343. lessInfoButton.setAttribute('hidden', 'true');
  1344. Promise.all(moreInfoText).then(function (parts) {
  1345. errorMoreInfo.value = parts.join('\n');
  1346. });
  1347. },
  1348. progress: function progress(level) {
  1349. var _this5 = this;
  1350. if (this.downloadComplete) {
  1351. return;
  1352. }
  1353. var percent = Math.round(level * 100);
  1354. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1355. this.loadingBar.percent = percent;
  1356. if (_pdfjsLib.PDFJS.disableAutoFetch && percent) {
  1357. if (this.disableAutoFetchLoadingBarTimeout) {
  1358. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1359. this.disableAutoFetchLoadingBarTimeout = null;
  1360. }
  1361. this.loadingBar.show();
  1362. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1363. _this5.loadingBar.hide();
  1364. _this5.disableAutoFetchLoadingBarTimeout = null;
  1365. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1366. }
  1367. }
  1368. },
  1369. load: function load(pdfDocument, scale) {
  1370. var _this6 = this;
  1371. scale = scale || _ui_utils.UNKNOWN_SCALE;
  1372. this.pdfDocument = pdfDocument;
  1373. pdfDocument.getDownloadInfo().then(function () {
  1374. _this6.downloadComplete = true;
  1375. _this6.loadingBar.hide();
  1376. firstPagePromise.then(function () {
  1377. _this6.eventBus.dispatch('documentload', { source: _this6 });
  1378. });
  1379. });
  1380. var pageModePromise = pdfDocument.getPageMode().catch(function () {});
  1381. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1382. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1383. var id = this.documentFingerprint = pdfDocument.fingerprint;
  1384. var store = this.store = new _view_history.ViewHistory(id);
  1385. var baseDocumentUrl = void 0;
  1386. baseDocumentUrl = null;
  1387. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1388. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1389. var pdfViewer = this.pdfViewer;
  1390. pdfViewer.setDocument(pdfDocument);
  1391. var firstPagePromise = pdfViewer.firstPagePromise;
  1392. var pagesPromise = pdfViewer.pagesPromise;
  1393. var onePageRendered = pdfViewer.onePageRendered;
  1394. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1395. pdfThumbnailViewer.setDocument(pdfDocument);
  1396. firstPagePromise.then(function (pdfPage) {
  1397. _this6.loadingBar.setWidth(_this6.appConfig.viewerContainer);
  1398. if (!_pdfjsLib.PDFJS.disableHistory && !_this6.isViewerEmbedded) {
  1399. if (!_this6.viewerPrefs['showPreviousViewOnLoad']) {
  1400. _this6.pdfHistory.clearHistoryState();
  1401. }
  1402. _this6.pdfHistory.initialize(_this6.documentFingerprint);
  1403. if (_this6.pdfHistory.initialDestination) {
  1404. _this6.initialDestination = _this6.pdfHistory.initialDestination;
  1405. } else if (_this6.pdfHistory.initialBookmark) {
  1406. _this6.initialBookmark = _this6.pdfHistory.initialBookmark;
  1407. }
  1408. }
  1409. var initialParams = {
  1410. destination: _this6.initialDestination,
  1411. bookmark: _this6.initialBookmark,
  1412. hash: null
  1413. };
  1414. var storePromise = store.getMultiple({
  1415. exists: false,
  1416. page: '1',
  1417. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1418. scrollLeft: '0',
  1419. scrollTop: '0',
  1420. sidebarView: _pdf_sidebar.SidebarView.NONE
  1421. }).catch(function () {});
  1422. Promise.all([storePromise, pageModePromise]).then(function (_ref2) {
  1423. var _ref3 = _slicedToArray(_ref2, 2),
  1424. _ref3$ = _ref3[0],
  1425. values = _ref3$ === undefined ? {} : _ref3$,
  1426. pageMode = _ref3[1];
  1427. var hash = _this6.viewerPrefs['defaultZoomValue'] ? 'zoom=' + _this6.viewerPrefs['defaultZoomValue'] : null;
  1428. var sidebarView = _this6.viewerPrefs['sidebarViewOnLoad'];
  1429. if (values.exists && _this6.viewerPrefs['showPreviousViewOnLoad']) {
  1430. hash = 'page=' + values.page + '&zoom=' + (_this6.viewerPrefs['defaultZoomValue'] || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop;
  1431. sidebarView = sidebarView || values.sidebarView | 0;
  1432. }
  1433. if (pageMode && !_this6.viewerPrefs['disablePageMode']) {
  1434. sidebarView = sidebarView || apiPageModeToSidebarView(pageMode);
  1435. }
  1436. return {
  1437. hash: hash,
  1438. sidebarView: sidebarView
  1439. };
  1440. }).then(function (_ref4) {
  1441. var hash = _ref4.hash,
  1442. sidebarView = _ref4.sidebarView;
  1443. _this6.setInitialView(hash, {
  1444. sidebarView: sidebarView,
  1445. scale: scale
  1446. });
  1447. initialParams.hash = hash;
  1448. if (!_this6.isViewerEmbedded) {
  1449. pdfViewer.focus();
  1450. }
  1451. return pagesPromise;
  1452. }).then(function () {
  1453. if (!initialParams.destination && !initialParams.bookmark && !initialParams.hash) {
  1454. return;
  1455. }
  1456. if (pdfViewer.hasEqualPageSizes) {
  1457. return;
  1458. }
  1459. _this6.initialDestination = initialParams.destination;
  1460. _this6.initialBookmark = initialParams.bookmark;
  1461. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1462. _this6.setInitialView(initialParams.hash);
  1463. }).then(function () {
  1464. pdfViewer.update();
  1465. });
  1466. });
  1467. pdfDocument.getPageLabels().then(function (labels) {
  1468. if (!labels || _this6.viewerPrefs['disablePageLabels']) {
  1469. return;
  1470. }
  1471. var i = 0,
  1472. numLabels = labels.length;
  1473. if (numLabels !== _this6.pagesCount) {
  1474. console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
  1475. return;
  1476. }
  1477. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1478. i++;
  1479. }
  1480. if (i === numLabels) {
  1481. return;
  1482. }
  1483. pdfViewer.setPageLabels(labels);
  1484. pdfThumbnailViewer.setPageLabels(labels);
  1485. _this6.toolbar.setPagesCount(pdfDocument.numPages, true);
  1486. _this6.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1487. });
  1488. pagesPromise.then(function () {
  1489. if (!_this6.supportsPrinting) {
  1490. return;
  1491. }
  1492. pdfDocument.getJavaScript().then(function (javaScript) {
  1493. if (javaScript.length) {
  1494. console.warn('Warning: JavaScript is not supported');
  1495. _this6.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1496. }
  1497. var regex = /\bprint\s*\(/;
  1498. for (var i = 0, ii = javaScript.length; i < ii; i++) {
  1499. var js = javaScript[i];
  1500. if (js && regex.test(js)) {
  1501. setTimeout(function () {
  1502. window.print();
  1503. });
  1504. return;
  1505. }
  1506. }
  1507. });
  1508. });
  1509. Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () {
  1510. pdfDocument.getOutline().then(function (outline) {
  1511. _this6.pdfOutlineViewer.render({ outline: outline });
  1512. });
  1513. pdfDocument.getAttachments().then(function (attachments) {
  1514. _this6.pdfAttachmentViewer.render({ attachments: attachments });
  1515. });
  1516. });
  1517. pdfDocument.getMetadata().then(function (_ref5) {
  1518. var info = _ref5.info,
  1519. metadata = _ref5.metadata;
  1520. _this6.documentInfo = info;
  1521. _this6.metadata = metadata;
  1522. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib.version || '-') + (!_pdfjsLib.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')');
  1523. var pdfTitle = void 0;
  1524. if (metadata && metadata.has('dc:title')) {
  1525. var title = metadata.get('dc:title');
  1526. if (title !== 'Untitled') {
  1527. pdfTitle = title;
  1528. }
  1529. }
  1530. if (!pdfTitle && info && info['Title']) {
  1531. pdfTitle = info['Title'];
  1532. }
  1533. if (pdfTitle) {
  1534. _this6.setTitle(pdfTitle + ' - ' + document.title);
  1535. }
  1536. if (info.IsAcroFormPresent) {
  1537. console.warn('Warning: AcroForm/XFA is not supported');
  1538. _this6.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1539. }
  1540. });
  1541. },
  1542. setInitialView: function setInitialView(storedHash) {
  1543. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1544. var _options$scale = options.scale,
  1545. scale = _options$scale === undefined ? 0 : _options$scale,
  1546. _options$sidebarView = options.sidebarView,
  1547. sidebarView = _options$sidebarView === undefined ? _pdf_sidebar.SidebarView.NONE : _options$sidebarView;
  1548. this.isInitialViewSet = true;
  1549. this.pdfSidebar.setInitialView(sidebarView);
  1550. if (this.initialDestination) {
  1551. this.pdfLinkService.navigateTo(this.initialDestination);
  1552. this.initialDestination = null;
  1553. } else if (this.initialBookmark) {
  1554. this.pdfLinkService.setHash(this.initialBookmark);
  1555. this.pdfHistory.push({ hash: this.initialBookmark }, true);
  1556. this.initialBookmark = null;
  1557. } else if (storedHash) {
  1558. this.pdfLinkService.setHash(storedHash);
  1559. } else if (scale) {
  1560. this.pdfViewer.currentScaleValue = scale;
  1561. this.page = 1;
  1562. }
  1563. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1564. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1565. if (!this.pdfViewer.currentScaleValue) {
  1566. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1567. }
  1568. },
  1569. cleanup: function cleanup() {
  1570. if (!this.pdfDocument) {
  1571. return;
  1572. }
  1573. this.pdfViewer.cleanup();
  1574. this.pdfThumbnailViewer.cleanup();
  1575. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1576. this.pdfDocument.cleanup();
  1577. }
  1578. },
  1579. forceRendering: function forceRendering() {
  1580. this.pdfRenderingQueue.printing = this.printing;
  1581. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1582. this.pdfRenderingQueue.renderHighestPriority();
  1583. },
  1584. beforePrint: function beforePrint() {
  1585. var _this7 = this;
  1586. if (this.printService) {
  1587. return;
  1588. }
  1589. if (!this.supportsPrinting) {
  1590. this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
  1591. _this7.error(printMessage);
  1592. });
  1593. return;
  1594. }
  1595. if (!this.pdfViewer.pageViewsReady) {
  1596. this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
  1597. window.alert(notReadyMessage);
  1598. });
  1599. return;
  1600. }
  1601. var pagesOverview = this.pdfViewer.getPagesOverview();
  1602. var printContainer = this.appConfig.printContainer;
  1603. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  1604. this.printService = printService;
  1605. this.forceRendering();
  1606. printService.layout();
  1607. },
  1608. afterPrint: function pdfViewSetupAfterPrint() {
  1609. if (this.printService) {
  1610. this.printService.destroy();
  1611. this.printService = null;
  1612. }
  1613. this.forceRendering();
  1614. },
  1615. rotatePages: function rotatePages(delta) {
  1616. if (!this.pdfDocument) {
  1617. return;
  1618. }
  1619. var pdfViewer = this.pdfViewer,
  1620. pdfThumbnailViewer = this.pdfThumbnailViewer;
  1621. var pageNumber = pdfViewer.currentPageNumber;
  1622. var newRotation = (pdfViewer.pagesRotation + 360 + delta) % 360;
  1623. pdfViewer.pagesRotation = newRotation;
  1624. pdfThumbnailViewer.pagesRotation = newRotation;
  1625. this.forceRendering();
  1626. pdfViewer.currentPageNumber = pageNumber;
  1627. },
  1628. requestPresentationMode: function requestPresentationMode() {
  1629. if (!this.pdfPresentationMode) {
  1630. return;
  1631. }
  1632. this.pdfPresentationMode.request();
  1633. },
  1634. bindEvents: function bindEvents() {
  1635. var eventBus = this.eventBus,
  1636. _boundEvents = this._boundEvents;
  1637. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1638. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1639. eventBus.on('resize', webViewerResize);
  1640. eventBus.on('hashchange', webViewerHashchange);
  1641. eventBus.on('beforeprint', _boundEvents.beforePrint);
  1642. eventBus.on('afterprint', _boundEvents.afterPrint);
  1643. eventBus.on('pagerendered', webViewerPageRendered);
  1644. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  1645. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  1646. eventBus.on('pagechanging', webViewerPageChanging);
  1647. eventBus.on('scalechanging', webViewerScaleChanging);
  1648. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  1649. eventBus.on('pagemode', webViewerPageMode);
  1650. eventBus.on('namedaction', webViewerNamedAction);
  1651. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  1652. eventBus.on('presentationmode', webViewerPresentationMode);
  1653. eventBus.on('openfile', webViewerOpenFile);
  1654. eventBus.on('print', webViewerPrint);
  1655. eventBus.on('download', webViewerDownload);
  1656. eventBus.on('firstpage', webViewerFirstPage);
  1657. eventBus.on('lastpage', webViewerLastPage);
  1658. eventBus.on('nextpage', webViewerNextPage);
  1659. eventBus.on('previouspage', webViewerPreviousPage);
  1660. eventBus.on('zoomin', webViewerZoomIn);
  1661. eventBus.on('zoomout', webViewerZoomOut);
  1662. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  1663. eventBus.on('scalechanged', webViewerScaleChanged);
  1664. eventBus.on('rotatecw', webViewerRotateCw);
  1665. eventBus.on('rotateccw', webViewerRotateCcw);
  1666. eventBus.on('documentproperties', webViewerDocumentProperties);
  1667. eventBus.on('find', webViewerFind);
  1668. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  1669. eventBus.on('fileinputchange', webViewerFileInputChange);
  1670. },
  1671. bindWindowEvents: function bindWindowEvents() {
  1672. var eventBus = this.eventBus,
  1673. _boundEvents = this._boundEvents;
  1674. _boundEvents.windowResize = function () {
  1675. eventBus.dispatch('resize');
  1676. };
  1677. _boundEvents.windowHashChange = function () {
  1678. eventBus.dispatch('hashchange', { hash: document.location.hash.substring(1) });
  1679. };
  1680. _boundEvents.windowBeforePrint = function () {
  1681. eventBus.dispatch('beforeprint');
  1682. };
  1683. _boundEvents.windowAfterPrint = function () {
  1684. eventBus.dispatch('afterprint');
  1685. };
  1686. window.addEventListener('wheel', webViewerWheel);
  1687. window.addEventListener('click', webViewerClick);
  1688. window.addEventListener('keydown', webViewerKeyDown);
  1689. window.addEventListener('resize', _boundEvents.windowResize);
  1690. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  1691. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1692. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  1693. _boundEvents.windowChange = function (evt) {
  1694. var files = evt.target.files;
  1695. if (!files || files.length === 0) {
  1696. return;
  1697. }
  1698. eventBus.dispatch('fileinputchange', { fileInput: evt.target });
  1699. };
  1700. window.addEventListener('change', _boundEvents.windowChange);
  1701. },
  1702. unbindEvents: function unbindEvents() {
  1703. var eventBus = this.eventBus,
  1704. _boundEvents = this._boundEvents;
  1705. eventBus.off('resize', webViewerResize);
  1706. eventBus.off('hashchange', webViewerHashchange);
  1707. eventBus.off('beforeprint', _boundEvents.beforePrint);
  1708. eventBus.off('afterprint', _boundEvents.afterPrint);
  1709. eventBus.off('pagerendered', webViewerPageRendered);
  1710. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  1711. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  1712. eventBus.off('pagechanging', webViewerPageChanging);
  1713. eventBus.off('scalechanging', webViewerScaleChanging);
  1714. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  1715. eventBus.off('pagemode', webViewerPageMode);
  1716. eventBus.off('namedaction', webViewerNamedAction);
  1717. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  1718. eventBus.off('presentationmode', webViewerPresentationMode);
  1719. eventBus.off('openfile', webViewerOpenFile);
  1720. eventBus.off('print', webViewerPrint);
  1721. eventBus.off('download', webViewerDownload);
  1722. eventBus.off('firstpage', webViewerFirstPage);
  1723. eventBus.off('lastpage', webViewerLastPage);
  1724. eventBus.off('nextpage', webViewerNextPage);
  1725. eventBus.off('previouspage', webViewerPreviousPage);
  1726. eventBus.off('zoomin', webViewerZoomIn);
  1727. eventBus.off('zoomout', webViewerZoomOut);
  1728. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  1729. eventBus.off('scalechanged', webViewerScaleChanged);
  1730. eventBus.off('rotatecw', webViewerRotateCw);
  1731. eventBus.off('rotateccw', webViewerRotateCcw);
  1732. eventBus.off('documentproperties', webViewerDocumentProperties);
  1733. eventBus.off('find', webViewerFind);
  1734. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  1735. eventBus.off('fileinputchange', webViewerFileInputChange);
  1736. _boundEvents.beforePrint = null;
  1737. _boundEvents.afterPrint = null;
  1738. },
  1739. unbindWindowEvents: function unbindWindowEvents() {
  1740. var _boundEvents = this._boundEvents;
  1741. window.removeEventListener('wheel', webViewerWheel);
  1742. window.removeEventListener('click', webViewerClick);
  1743. window.removeEventListener('keydown', webViewerKeyDown);
  1744. window.removeEventListener('resize', _boundEvents.windowResize);
  1745. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  1746. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1747. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  1748. window.removeEventListener('change', _boundEvents.windowChange);
  1749. _boundEvents.windowChange = null;
  1750. _boundEvents.windowResize = null;
  1751. _boundEvents.windowHashChange = null;
  1752. _boundEvents.windowBeforePrint = null;
  1753. _boundEvents.windowAfterPrint = null;
  1754. }
  1755. };
  1756. var validateFileURL = void 0;
  1757. {
  1758. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  1759. validateFileURL = function validateFileURL(file) {
  1760. if (file === undefined) {
  1761. return;
  1762. }
  1763. try {
  1764. var viewerOrigin = new URL(window.location.href).origin || 'null';
  1765. if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) {
  1766. return;
  1767. }
  1768. var fileOrigin = new URL(file, window.location.href).origin;
  1769. if (fileOrigin !== viewerOrigin) {
  1770. // throw new Error('file origin does not match viewer\'s');
  1771. }
  1772. } catch (ex) {
  1773. var message = ex && ex.message;
  1774. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
  1775. PDFViewerApplication.error(loadingErrorMessage, { message: message });
  1776. });
  1777. throw ex;
  1778. }
  1779. };
  1780. }
  1781. function loadAndEnablePDFBug(enabledTabs) {
  1782. return new Promise(function (resolve, reject) {
  1783. var appConfig = PDFViewerApplication.appConfig;
  1784. var script = document.createElement('script');
  1785. script.src = appConfig.debuggerScriptPath;
  1786. script.onload = function () {
  1787. PDFBug.enable(enabledTabs);
  1788. PDFBug.init({
  1789. PDFJS: _pdfjsLib.PDFJS,
  1790. OPS: _pdfjsLib.OPS
  1791. }, appConfig.mainContainer);
  1792. resolve();
  1793. };
  1794. script.onerror = function () {
  1795. reject(new Error('Cannot load debugger at ' + script.src));
  1796. };
  1797. (document.getElementsByTagName('head')[0] || document.body).appendChild(script);
  1798. });
  1799. }
  1800. function webViewerInitialized() {
  1801. var appConfig = PDFViewerApplication.appConfig;
  1802. var file = void 0;
  1803. var queryString = document.location.search.substring(1);
  1804. var params = (0, _ui_utils.parseQueryString)(queryString);
  1805. file = 'file' in params ? params.file : appConfig.defaultUrl;
  1806. validateFileURL(file);
  1807. var waitForBeforeOpening = [];
  1808. var fileInput = document.createElement('input');
  1809. fileInput.id = appConfig.openFileInputName;
  1810. fileInput.className = 'fileInput';
  1811. fileInput.setAttribute('type', 'file');
  1812. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1813. document.body.appendChild(fileInput);
  1814. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1815. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  1816. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
  1817. } else {
  1818. fileInput.value = null;
  1819. }
  1820. if (PDFViewerApplication.viewerPrefs['pdfBugEnabled']) {
  1821. var hash = document.location.hash.substring(1);
  1822. var hashParams = (0, _ui_utils.parseQueryString)(hash);
  1823. if ('disableworker' in hashParams) {
  1824. _pdfjsLib.PDFJS.disableWorker = hashParams['disableworker'] === 'true';
  1825. }
  1826. if ('disablerange' in hashParams) {
  1827. _pdfjsLib.PDFJS.disableRange = hashParams['disablerange'] === 'true';
  1828. }
  1829. if ('disablestream' in hashParams) {
  1830. _pdfjsLib.PDFJS.disableStream = hashParams['disablestream'] === 'true';
  1831. }
  1832. if ('disableautofetch' in hashParams) {
  1833. _pdfjsLib.PDFJS.disableAutoFetch = hashParams['disableautofetch'] === 'true';
  1834. }
  1835. if ('disablefontface' in hashParams) {
  1836. _pdfjsLib.PDFJS.disableFontFace = hashParams['disablefontface'] === 'true';
  1837. }
  1838. if ('disablehistory' in hashParams) {
  1839. _pdfjsLib.PDFJS.disableHistory = hashParams['disablehistory'] === 'true';
  1840. }
  1841. if ('webgl' in hashParams) {
  1842. _pdfjsLib.PDFJS.disableWebGL = hashParams['webgl'] !== 'true';
  1843. }
  1844. if ('useonlycsszoom' in hashParams) {
  1845. _pdfjsLib.PDFJS.useOnlyCssZoom = hashParams['useonlycsszoom'] === 'true';
  1846. }
  1847. if ('verbosity' in hashParams) {
  1848. _pdfjsLib.PDFJS.verbosity = hashParams['verbosity'] | 0;
  1849. }
  1850. if ('ignorecurrentpositiononzoom' in hashParams) {
  1851. _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true';
  1852. }
  1853. if ('textlayer' in hashParams) {
  1854. switch (hashParams['textlayer']) {
  1855. case 'off':
  1856. _pdfjsLib.PDFJS.disableTextLayer = true;
  1857. break;
  1858. case 'visible':
  1859. case 'shadow':
  1860. case 'hover':
  1861. var viewer = appConfig.viewerContainer;
  1862. viewer.classList.add('textLayer-' + hashParams['textlayer']);
  1863. break;
  1864. }
  1865. }
  1866. if ('pdfbug' in hashParams) {
  1867. _pdfjsLib.PDFJS.pdfBug = true;
  1868. var pdfBug = hashParams['pdfbug'];
  1869. var enabled = pdfBug.split(',');
  1870. waitForBeforeOpening.push(loadAndEnablePDFBug(enabled));
  1871. }
  1872. }
  1873. if (!PDFViewerApplication.supportsPrinting) {
  1874. appConfig.toolbar.print.classList.add('hidden');
  1875. appConfig.secondaryToolbar.printButton.classList.add('hidden');
  1876. }
  1877. if (!PDFViewerApplication.supportsFullscreen) {
  1878. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  1879. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
  1880. }
  1881. if (PDFViewerApplication.supportsIntegratedFind) {
  1882. appConfig.toolbar.viewFind.classList.add('hidden');
  1883. }
  1884. appConfig.sidebar.mainContainer.addEventListener('transitionend', function (evt) {
  1885. if (evt.target === this) {
  1886. PDFViewerApplication.eventBus.dispatch('resize');
  1887. }
  1888. }, true);
  1889. appConfig.sidebar.toggleButton.addEventListener('click', function () {
  1890. PDFViewerApplication.pdfSidebar.toggle();
  1891. });
  1892. Promise.all(waitForBeforeOpening).then(function () {
  1893. webViewerOpenFileViaURL(file);
  1894. }).catch(function (reason) {
  1895. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while opening.').then(function (msg) {
  1896. PDFViewerApplication.error(msg, reason);
  1897. });
  1898. });
  1899. }
  1900. var webViewerOpenFileViaURL = void 0;
  1901. {
  1902. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  1903. if (file && file.lastIndexOf('file:', 0) === 0) {
  1904. PDFViewerApplication.setTitleUsingUrl(file);
  1905. var xhr = new XMLHttpRequest();
  1906. xhr.onload = function () {
  1907. PDFViewerApplication.open(new Uint8Array(xhr.response));
  1908. };
  1909. try {
  1910. xhr.open('GET', file);
  1911. xhr.responseType = 'arraybuffer';
  1912. xhr.send();
  1913. } catch (ex) {
  1914. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
  1915. PDFViewerApplication.error(msg, ex);
  1916. });
  1917. }
  1918. return;
  1919. }
  1920. if (file) {
  1921. PDFViewerApplication.open(file);
  1922. }
  1923. };
  1924. }
  1925. function webViewerPageRendered(evt) {
  1926. var pageNumber = evt.pageNumber;
  1927. var pageIndex = pageNumber - 1;
  1928. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  1929. if (pageNumber === PDFViewerApplication.page) {
  1930. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  1931. }
  1932. if (!pageView) {
  1933. return;
  1934. }
  1935. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1936. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  1937. thumbnailView.setImage(pageView);
  1938. }
  1939. if (_pdfjsLib.PDFJS.pdfBug && Stats.enabled && pageView.stats) {
  1940. Stats.add(pageNumber, pageView.stats);
  1941. }
  1942. if (pageView.error) {
  1943. PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
  1944. PDFViewerApplication.error(msg, pageView.error);
  1945. });
  1946. }
  1947. }
  1948. function webViewerTextLayerRendered(evt) {}
  1949. function webViewerPageMode(evt) {
  1950. var mode = evt.mode,
  1951. view = void 0;
  1952. switch (mode) {
  1953. case 'thumbs':
  1954. view = _pdf_sidebar.SidebarView.THUMBS;
  1955. break;
  1956. case 'bookmarks':
  1957. case 'outline':
  1958. view = _pdf_sidebar.SidebarView.OUTLINE;
  1959. break;
  1960. case 'attachments':
  1961. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  1962. break;
  1963. case 'none':
  1964. view = _pdf_sidebar.SidebarView.NONE;
  1965. break;
  1966. default:
  1967. console.error('Invalid "pagemode" hash parameter: ' + mode);
  1968. return;
  1969. }
  1970. PDFViewerApplication.pdfSidebar.switchView(view, true);
  1971. }
  1972. function webViewerNamedAction(evt) {
  1973. var action = evt.action;
  1974. switch (action) {
  1975. case 'GoToPage':
  1976. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1977. break;
  1978. case 'Find':
  1979. if (!PDFViewerApplication.supportsIntegratedFind) {
  1980. PDFViewerApplication.findBar.toggle();
  1981. }
  1982. break;
  1983. }
  1984. }
  1985. function webViewerPresentationModeChanged(evt) {
  1986. var active = evt.active,
  1987. switchInProgress = evt.switchInProgress;
  1988. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _pdf_viewer.PresentationModeState.CHANGING : active ? _pdf_viewer.PresentationModeState.FULLSCREEN : _pdf_viewer.PresentationModeState.NORMAL;
  1989. }
  1990. function webViewerSidebarViewChanged(evt) {
  1991. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  1992. var store = PDFViewerApplication.store;
  1993. if (store && PDFViewerApplication.isInitialViewSet) {
  1994. store.set('sidebarView', evt.view).catch(function () {});
  1995. }
  1996. }
  1997. function webViewerUpdateViewarea(evt) {
  1998. var location = evt.location,
  1999. store = PDFViewerApplication.store;
  2000. if (store && PDFViewerApplication.isInitialViewSet) {
  2001. store.setMultiple({
  2002. 'exists': true,
  2003. 'page': location.pageNumber,
  2004. 'zoom': location.scale,
  2005. 'scrollLeft': location.left,
  2006. 'scrollTop': location.top
  2007. }).catch(function () {});
  2008. }
  2009. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2010. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2011. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2012. PDFViewerApplication.pdfHistory.updateCurrentBookmark(location.pdfOpenParams, location.pageNumber);
  2013. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2014. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2015. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2016. }
  2017. function webViewerResize() {
  2018. var pdfDocument = PDFViewerApplication.pdfDocument,
  2019. pdfViewer = PDFViewerApplication.pdfViewer;
  2020. if (!pdfDocument) {
  2021. return;
  2022. }
  2023. var currentScaleValue = pdfViewer.currentScaleValue;
  2024. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
  2025. pdfViewer.currentScaleValue = currentScaleValue;
  2026. }
  2027. pdfViewer.update();
  2028. }
  2029. function webViewerHashchange(evt) {
  2030. if (PDFViewerApplication.pdfHistory.isHashChangeUnlocked) {
  2031. var hash = evt.hash;
  2032. if (!hash) {
  2033. return;
  2034. }
  2035. if (!PDFViewerApplication.isInitialViewSet) {
  2036. PDFViewerApplication.initialBookmark = hash;
  2037. } else {
  2038. PDFViewerApplication.pdfLinkService.setHash(hash);
  2039. }
  2040. }
  2041. }
  2042. var webViewerFileInputChange = void 0;
  2043. {
  2044. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2045. var file = evt.fileInput.files[0];
  2046. if (!_pdfjsLib.PDFJS.disableCreateObjectURL && URL.createObjectURL) {
  2047. PDFViewerApplication.open(URL.createObjectURL(file));
  2048. } else {
  2049. var fileReader = new FileReader();
  2050. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  2051. var buffer = evt.target.result;
  2052. PDFViewerApplication.open(new Uint8Array(buffer));
  2053. };
  2054. fileReader.readAsArrayBuffer(file);
  2055. }
  2056. PDFViewerApplication.setTitleUsingUrl(file.name);
  2057. var appConfig = PDFViewerApplication.appConfig;
  2058. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  2059. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  2060. appConfig.toolbar.download.setAttribute('hidden', 'true');
  2061. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
  2062. };
  2063. }
  2064. function webViewerPresentationMode() {
  2065. PDFViewerApplication.requestPresentationMode();
  2066. }
  2067. function webViewerOpenFile() {
  2068. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  2069. document.getElementById(openFileInputName).click();
  2070. }
  2071. function webViewerPrint() {
  2072. window.print();
  2073. }
  2074. function webViewerDownload() {
  2075. PDFViewerApplication.download();
  2076. }
  2077. function webViewerFirstPage() {
  2078. if (PDFViewerApplication.pdfDocument) {
  2079. PDFViewerApplication.page = 1;
  2080. }
  2081. }
  2082. function webViewerLastPage() {
  2083. if (PDFViewerApplication.pdfDocument) {
  2084. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2085. }
  2086. }
  2087. function webViewerNextPage() {
  2088. PDFViewerApplication.page++;
  2089. }
  2090. function webViewerPreviousPage() {
  2091. PDFViewerApplication.page--;
  2092. }
  2093. function webViewerZoomIn() {
  2094. PDFViewerApplication.zoomIn();
  2095. }
  2096. function webViewerZoomOut() {
  2097. PDFViewerApplication.zoomOut();
  2098. }
  2099. function webViewerPageNumberChanged(evt) {
  2100. var pdfViewer = PDFViewerApplication.pdfViewer;
  2101. pdfViewer.currentPageLabel = evt.value;
  2102. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  2103. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2104. }
  2105. }
  2106. function webViewerScaleChanged(evt) {
  2107. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  2108. }
  2109. function webViewerRotateCw() {
  2110. PDFViewerApplication.rotatePages(90);
  2111. }
  2112. function webViewerRotateCcw() {
  2113. PDFViewerApplication.rotatePages(-90);
  2114. }
  2115. function webViewerDocumentProperties() {
  2116. PDFViewerApplication.pdfDocumentProperties.open();
  2117. }
  2118. function webViewerFind(evt) {
  2119. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  2120. query: evt.query,
  2121. phraseSearch: evt.phraseSearch,
  2122. caseSensitive: evt.caseSensitive,
  2123. highlightAll: evt.highlightAll,
  2124. findPrevious: evt.findPrevious
  2125. });
  2126. }
  2127. function webViewerFindFromUrlHash(evt) {
  2128. PDFViewerApplication.findController.executeCommand('find', {
  2129. query: evt.query,
  2130. phraseSearch: evt.phraseSearch,
  2131. caseSensitive: false,
  2132. highlightAll: true,
  2133. findPrevious: false
  2134. });
  2135. }
  2136. function webViewerScaleChanging(evt) {
  2137. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  2138. PDFViewerApplication.pdfViewer.update();
  2139. }
  2140. function webViewerPageChanging(evt) {
  2141. var page = evt.pageNumber;
  2142. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  2143. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  2144. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2145. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  2146. }
  2147. if (_pdfjsLib.PDFJS.pdfBug && Stats.enabled) {
  2148. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  2149. if (pageView.stats) {
  2150. Stats.add(page, pageView.stats);
  2151. }
  2152. }
  2153. }
  2154. var zoomDisabled = false,
  2155. zoomDisabledTimeout = void 0;
  2156. function webViewerWheel(evt) {
  2157. var pdfViewer = PDFViewerApplication.pdfViewer;
  2158. if (pdfViewer.isInPresentationMode) {
  2159. return;
  2160. }
  2161. if (evt.ctrlKey || evt.metaKey) {
  2162. var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  2163. if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
  2164. return;
  2165. }
  2166. evt.preventDefault();
  2167. if (zoomDisabled) {
  2168. return;
  2169. }
  2170. var previousScale = pdfViewer.currentScale;
  2171. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  2172. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  2173. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  2174. if (ticks < 0) {
  2175. PDFViewerApplication.zoomOut(-ticks);
  2176. } else {
  2177. PDFViewerApplication.zoomIn(ticks);
  2178. }
  2179. var currentScale = pdfViewer.currentScale;
  2180. if (previousScale !== currentScale) {
  2181. var scaleCorrectionFactor = currentScale / previousScale - 1;
  2182. var rect = pdfViewer.container.getBoundingClientRect();
  2183. var dx = evt.clientX - rect.left;
  2184. var dy = evt.clientY - rect.top;
  2185. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  2186. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  2187. }
  2188. } else {
  2189. zoomDisabled = true;
  2190. clearTimeout(zoomDisabledTimeout);
  2191. zoomDisabledTimeout = setTimeout(function () {
  2192. zoomDisabled = false;
  2193. }, 1000);
  2194. }
  2195. }
  2196. function webViewerClick(evt) {
  2197. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  2198. return;
  2199. }
  2200. var appConfig = PDFViewerApplication.appConfig;
  2201. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  2202. PDFViewerApplication.secondaryToolbar.close();
  2203. }
  2204. }
  2205. function webViewerKeyDown(evt) {
  2206. if (PDFViewerApplication.overlayManager.active) {
  2207. return;
  2208. }
  2209. var handled = false,
  2210. ensureViewerFocused = false;
  2211. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2212. var pdfViewer = PDFViewerApplication.pdfViewer;
  2213. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2214. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2215. switch (evt.keyCode) {
  2216. case 70:
  2217. if (!PDFViewerApplication.supportsIntegratedFind) {
  2218. PDFViewerApplication.findBar.open();
  2219. handled = true;
  2220. }
  2221. break;
  2222. case 71:
  2223. if (!PDFViewerApplication.supportsIntegratedFind) {
  2224. var findState = PDFViewerApplication.findController.state;
  2225. if (findState) {
  2226. PDFViewerApplication.findController.executeCommand('findagain', {
  2227. query: findState.query,
  2228. phraseSearch: findState.phraseSearch,
  2229. caseSensitive: findState.caseSensitive,
  2230. highlightAll: findState.highlightAll,
  2231. findPrevious: cmd === 5 || cmd === 12
  2232. });
  2233. }
  2234. handled = true;
  2235. }
  2236. break;
  2237. case 61:
  2238. case 107:
  2239. case 187:
  2240. case 171:
  2241. if (!isViewerInPresentationMode) {
  2242. PDFViewerApplication.zoomIn();
  2243. }
  2244. handled = true;
  2245. break;
  2246. case 173:
  2247. case 109:
  2248. case 189:
  2249. if (!isViewerInPresentationMode) {
  2250. PDFViewerApplication.zoomOut();
  2251. }
  2252. handled = true;
  2253. break;
  2254. case 48:
  2255. case 96:
  2256. if (!isViewerInPresentationMode) {
  2257. setTimeout(function () {
  2258. pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2259. });
  2260. handled = false;
  2261. }
  2262. break;
  2263. case 38:
  2264. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2265. PDFViewerApplication.page = 1;
  2266. handled = true;
  2267. ensureViewerFocused = true;
  2268. }
  2269. break;
  2270. case 40:
  2271. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2272. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2273. handled = true;
  2274. ensureViewerFocused = true;
  2275. }
  2276. break;
  2277. }
  2278. }
  2279. if (cmd === 1 || cmd === 8) {
  2280. switch (evt.keyCode) {
  2281. case 83:
  2282. PDFViewerApplication.download();
  2283. handled = true;
  2284. break;
  2285. }
  2286. }
  2287. if (cmd === 3 || cmd === 10) {
  2288. switch (evt.keyCode) {
  2289. case 80:
  2290. PDFViewerApplication.requestPresentationMode();
  2291. handled = true;
  2292. break;
  2293. case 71:
  2294. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2295. handled = true;
  2296. break;
  2297. }
  2298. }
  2299. if (handled) {
  2300. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2301. pdfViewer.focus();
  2302. }
  2303. evt.preventDefault();
  2304. return;
  2305. }
  2306. var curElement = document.activeElement || document.querySelector(':focus');
  2307. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2308. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
  2309. if (evt.keyCode !== 27) {
  2310. return;
  2311. }
  2312. }
  2313. if (cmd === 0) {
  2314. switch (evt.keyCode) {
  2315. case 38:
  2316. case 33:
  2317. case 8:
  2318. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2319. break;
  2320. }
  2321. case 37:
  2322. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2323. break;
  2324. }
  2325. case 75:
  2326. case 80:
  2327. if (PDFViewerApplication.page > 1) {
  2328. PDFViewerApplication.page--;
  2329. }
  2330. handled = true;
  2331. break;
  2332. case 27:
  2333. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2334. PDFViewerApplication.secondaryToolbar.close();
  2335. handled = true;
  2336. }
  2337. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2338. PDFViewerApplication.findBar.close();
  2339. handled = true;
  2340. }
  2341. break;
  2342. case 40:
  2343. case 34:
  2344. case 32:
  2345. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2346. break;
  2347. }
  2348. case 39:
  2349. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2350. break;
  2351. }
  2352. case 74:
  2353. case 78:
  2354. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2355. PDFViewerApplication.page++;
  2356. }
  2357. handled = true;
  2358. break;
  2359. case 36:
  2360. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2361. PDFViewerApplication.page = 1;
  2362. handled = true;
  2363. ensureViewerFocused = true;
  2364. }
  2365. break;
  2366. case 35:
  2367. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2368. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2369. handled = true;
  2370. ensureViewerFocused = true;
  2371. }
  2372. break;
  2373. case 83:
  2374. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2375. break;
  2376. case 72:
  2377. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2378. break;
  2379. case 82:
  2380. PDFViewerApplication.rotatePages(90);
  2381. break;
  2382. }
  2383. }
  2384. if (cmd === 4) {
  2385. switch (evt.keyCode) {
  2386. case 32:
  2387. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2388. break;
  2389. }
  2390. if (PDFViewerApplication.page > 1) {
  2391. PDFViewerApplication.page--;
  2392. }
  2393. handled = true;
  2394. break;
  2395. case 82:
  2396. PDFViewerApplication.rotatePages(-90);
  2397. break;
  2398. }
  2399. }
  2400. if (!handled && !isViewerInPresentationMode) {
  2401. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
  2402. ensureViewerFocused = true;
  2403. }
  2404. }
  2405. if (cmd === 2) {
  2406. switch (evt.keyCode) {
  2407. case 37:
  2408. if (isViewerInPresentationMode) {
  2409. PDFViewerApplication.pdfHistory.back();
  2410. handled = true;
  2411. }
  2412. break;
  2413. case 39:
  2414. if (isViewerInPresentationMode) {
  2415. PDFViewerApplication.pdfHistory.forward();
  2416. handled = true;
  2417. }
  2418. break;
  2419. }
  2420. }
  2421. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2422. pdfViewer.focus();
  2423. }
  2424. if (handled) {
  2425. evt.preventDefault();
  2426. }
  2427. }
  2428. function apiPageModeToSidebarView(mode) {
  2429. switch (mode) {
  2430. case 'UseNone':
  2431. return _pdf_sidebar.SidebarView.NONE;
  2432. case 'UseThumbs':
  2433. return _pdf_sidebar.SidebarView.THUMBS;
  2434. case 'UseOutlines':
  2435. return _pdf_sidebar.SidebarView.OUTLINE;
  2436. case 'UseAttachments':
  2437. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2438. case 'UseOC':
  2439. }
  2440. return _pdf_sidebar.SidebarView.NONE;
  2441. }
  2442. var PDFPrintServiceFactory = {
  2443. instance: {
  2444. supportsPrinting: false,
  2445. createPrintService: function createPrintService() {
  2446. throw new Error('Not implemented: createPrintService');
  2447. }
  2448. }
  2449. };
  2450. exports.PDFViewerApplication = PDFViewerApplication;
  2451. exports.DefaultExternalServices = DefaultExternalServices;
  2452. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2453. /***/ }),
  2454. /* 5 */
  2455. /***/ (function(module, exports, __webpack_require__) {
  2456. "use strict";
  2457. Object.defineProperty(exports, "__esModule", {
  2458. value: true
  2459. });
  2460. exports.SimpleLinkService = exports.PDFLinkService = undefined;
  2461. 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; };
  2462. 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; }; }();
  2463. var _dom_events = __webpack_require__(2);
  2464. var _ui_utils = __webpack_require__(0);
  2465. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2466. var PDFLinkService = function () {
  2467. function PDFLinkService() {
  2468. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  2469. eventBus = _ref.eventBus;
  2470. _classCallCheck(this, PDFLinkService);
  2471. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  2472. this.baseUrl = null;
  2473. this.pdfDocument = null;
  2474. this.pdfViewer = null;
  2475. this.pdfHistory = null;
  2476. this._pagesRefCache = null;
  2477. }
  2478. _createClass(PDFLinkService, [{
  2479. key: 'setDocument',
  2480. value: function setDocument(pdfDocument, baseUrl) {
  2481. this.baseUrl = baseUrl;
  2482. this.pdfDocument = pdfDocument;
  2483. this._pagesRefCache = Object.create(null);
  2484. }
  2485. }, {
  2486. key: 'setViewer',
  2487. value: function setViewer(pdfViewer) {
  2488. this.pdfViewer = pdfViewer;
  2489. }
  2490. }, {
  2491. key: 'setHistory',
  2492. value: function setHistory(pdfHistory) {
  2493. this.pdfHistory = pdfHistory;
  2494. }
  2495. }, {
  2496. key: 'navigateTo',
  2497. value: function navigateTo(dest) {
  2498. var _this = this;
  2499. var goToDestination = function goToDestination(_ref2) {
  2500. var namedDest = _ref2.namedDest,
  2501. explicitDest = _ref2.explicitDest;
  2502. var destRef = explicitDest[0],
  2503. pageNumber = void 0;
  2504. if (destRef instanceof Object) {
  2505. pageNumber = _this._cachedPageNumber(destRef);
  2506. if (pageNumber === null) {
  2507. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  2508. _this.cachePageRef(pageIndex + 1, destRef);
  2509. goToDestination({
  2510. namedDest: namedDest,
  2511. explicitDest: explicitDest
  2512. });
  2513. }).catch(function () {
  2514. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'));
  2515. });
  2516. return;
  2517. }
  2518. } else if ((destRef | 0) === destRef) {
  2519. pageNumber = destRef + 1;
  2520. } else {
  2521. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));
  2522. return;
  2523. }
  2524. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  2525. console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));
  2526. return;
  2527. }
  2528. _this.pdfViewer.scrollPageIntoView({
  2529. pageNumber: pageNumber,
  2530. destArray: explicitDest
  2531. });
  2532. if (_this.pdfHistory) {
  2533. _this.pdfHistory.push({
  2534. dest: explicitDest,
  2535. hash: namedDest,
  2536. page: pageNumber
  2537. });
  2538. }
  2539. };
  2540. new Promise(function (resolve, reject) {
  2541. if (typeof dest === 'string') {
  2542. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  2543. resolve({
  2544. namedDest: dest,
  2545. explicitDest: destArray
  2546. });
  2547. });
  2548. return;
  2549. }
  2550. resolve({
  2551. namedDest: '',
  2552. explicitDest: dest
  2553. });
  2554. }).then(function (data) {
  2555. if (!(data.explicitDest instanceof Array)) {
  2556. console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));
  2557. return;
  2558. }
  2559. goToDestination(data);
  2560. });
  2561. }
  2562. }, {
  2563. key: 'getDestinationHash',
  2564. value: function getDestinationHash(dest) {
  2565. if (typeof dest === 'string') {
  2566. return this.getAnchorUrl('#' + escape(dest));
  2567. }
  2568. if (dest instanceof Array) {
  2569. var str = JSON.stringify(dest);
  2570. return this.getAnchorUrl('#' + escape(str));
  2571. }
  2572. return this.getAnchorUrl('');
  2573. }
  2574. }, {
  2575. key: 'getAnchorUrl',
  2576. value: function getAnchorUrl(anchor) {
  2577. return (this.baseUrl || '') + anchor;
  2578. }
  2579. }, {
  2580. key: 'setHash',
  2581. value: function setHash(hash) {
  2582. var pageNumber = void 0,
  2583. dest = void 0;
  2584. if (hash.indexOf('=') >= 0) {
  2585. var params = (0, _ui_utils.parseQueryString)(hash);
  2586. if ('search' in params) {
  2587. this.eventBus.dispatch('findfromurlhash', {
  2588. source: this,
  2589. query: params['search'].replace(/"/g, ''),
  2590. phraseSearch: params['phrase'] === 'true'
  2591. });
  2592. }
  2593. if ('nameddest' in params) {
  2594. if (this.pdfHistory) {
  2595. this.pdfHistory.updateNextHashParam(params.nameddest);
  2596. }
  2597. this.navigateTo(params.nameddest);
  2598. return;
  2599. }
  2600. if ('page' in params) {
  2601. pageNumber = params.page | 0 || 1;
  2602. }
  2603. if ('zoom' in params) {
  2604. var zoomArgs = params.zoom.split(',');
  2605. var zoomArg = zoomArgs[0];
  2606. var zoomArgNumber = parseFloat(zoomArg);
  2607. if (zoomArg.indexOf('Fit') === -1) {
  2608. dest = [null, { name: 'XYZ' }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  2609. } else {
  2610. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  2611. dest = [null, { name: zoomArg }];
  2612. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  2613. dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  2614. } else if (zoomArg === 'FitR') {
  2615. if (zoomArgs.length !== 5) {
  2616. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  2617. } else {
  2618. dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  2619. }
  2620. } else {
  2621. console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.');
  2622. }
  2623. }
  2624. }
  2625. if (dest) {
  2626. this.pdfViewer.scrollPageIntoView({
  2627. pageNumber: pageNumber || this.page,
  2628. destArray: dest,
  2629. allowNegativeOffset: true
  2630. });
  2631. } else if (pageNumber) {
  2632. this.page = pageNumber;
  2633. }
  2634. if ('pagemode' in params) {
  2635. this.eventBus.dispatch('pagemode', {
  2636. source: this,
  2637. mode: params.pagemode
  2638. });
  2639. }
  2640. } else {
  2641. if (/^\d+$/.test(hash) && hash <= this.pagesCount) {
  2642. console.warn('PDFLinkService_setHash: specifying a page number ' + 'directly after the hash symbol (#) is deprecated, ' + ('please use the "#page=' + hash + '" form instead.'));
  2643. this.page = hash | 0;
  2644. }
  2645. dest = unescape(hash);
  2646. try {
  2647. dest = JSON.parse(dest);
  2648. if (!(dest instanceof Array)) {
  2649. dest = dest.toString();
  2650. }
  2651. } catch (ex) {}
  2652. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  2653. if (this.pdfHistory) {
  2654. this.pdfHistory.updateNextHashParam(dest);
  2655. }
  2656. this.navigateTo(dest);
  2657. return;
  2658. }
  2659. console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.');
  2660. }
  2661. }
  2662. }, {
  2663. key: 'executeNamedAction',
  2664. value: function executeNamedAction(action) {
  2665. switch (action) {
  2666. case 'GoBack':
  2667. if (this.pdfHistory) {
  2668. this.pdfHistory.back();
  2669. }
  2670. break;
  2671. case 'GoForward':
  2672. if (this.pdfHistory) {
  2673. this.pdfHistory.forward();
  2674. }
  2675. break;
  2676. case 'NextPage':
  2677. if (this.page < this.pagesCount) {
  2678. this.page++;
  2679. }
  2680. break;
  2681. case 'PrevPage':
  2682. if (this.page > 1) {
  2683. this.page--;
  2684. }
  2685. break;
  2686. case 'LastPage':
  2687. this.page = this.pagesCount;
  2688. break;
  2689. case 'FirstPage':
  2690. this.page = 1;
  2691. break;
  2692. default:
  2693. break;
  2694. }
  2695. this.eventBus.dispatch('namedaction', {
  2696. source: this,
  2697. action: action
  2698. });
  2699. }
  2700. }, {
  2701. key: 'onFileAttachmentAnnotation',
  2702. value: function onFileAttachmentAnnotation(_ref3) {
  2703. var id = _ref3.id,
  2704. filename = _ref3.filename,
  2705. content = _ref3.content;
  2706. this.eventBus.dispatch('fileattachmentannotation', {
  2707. source: this,
  2708. id: id,
  2709. filename: filename,
  2710. content: content
  2711. });
  2712. }
  2713. }, {
  2714. key: 'cachePageRef',
  2715. value: function cachePageRef(pageNum, pageRef) {
  2716. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  2717. this._pagesRefCache[refStr] = pageNum;
  2718. }
  2719. }, {
  2720. key: '_cachedPageNumber',
  2721. value: function _cachedPageNumber(pageRef) {
  2722. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  2723. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  2724. }
  2725. }, {
  2726. key: 'pagesCount',
  2727. get: function get() {
  2728. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  2729. }
  2730. }, {
  2731. key: 'page',
  2732. get: function get() {
  2733. return this.pdfViewer.currentPageNumber;
  2734. },
  2735. set: function set(value) {
  2736. this.pdfViewer.currentPageNumber = value;
  2737. }
  2738. }]);
  2739. return PDFLinkService;
  2740. }();
  2741. function isValidExplicitDestination(dest) {
  2742. if (!(dest instanceof Array)) {
  2743. return false;
  2744. }
  2745. var destLength = dest.length,
  2746. allowNull = true;
  2747. if (destLength < 2) {
  2748. return false;
  2749. }
  2750. var page = dest[0];
  2751. 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)) {
  2752. return false;
  2753. }
  2754. var zoom = dest[1];
  2755. if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
  2756. return false;
  2757. }
  2758. switch (zoom.name) {
  2759. case 'XYZ':
  2760. if (destLength !== 5) {
  2761. return false;
  2762. }
  2763. break;
  2764. case 'Fit':
  2765. case 'FitB':
  2766. return destLength === 2;
  2767. case 'FitH':
  2768. case 'FitBH':
  2769. case 'FitV':
  2770. case 'FitBV':
  2771. if (destLength !== 3) {
  2772. return false;
  2773. }
  2774. break;
  2775. case 'FitR':
  2776. if (destLength !== 6) {
  2777. return false;
  2778. }
  2779. allowNull = false;
  2780. break;
  2781. default:
  2782. return false;
  2783. }
  2784. for (var i = 2; i < destLength; i++) {
  2785. var param = dest[i];
  2786. if (!(typeof param === 'number' || allowNull && param === null)) {
  2787. return false;
  2788. }
  2789. }
  2790. return true;
  2791. }
  2792. var SimpleLinkService = function () {
  2793. function SimpleLinkService() {
  2794. _classCallCheck(this, SimpleLinkService);
  2795. }
  2796. _createClass(SimpleLinkService, [{
  2797. key: 'navigateTo',
  2798. value: function navigateTo(dest) {}
  2799. }, {
  2800. key: 'getDestinationHash',
  2801. value: function getDestinationHash(dest) {
  2802. return '#';
  2803. }
  2804. }, {
  2805. key: 'getAnchorUrl',
  2806. value: function getAnchorUrl(hash) {
  2807. return '#';
  2808. }
  2809. }, {
  2810. key: 'setHash',
  2811. value: function setHash(hash) {}
  2812. }, {
  2813. key: 'executeNamedAction',
  2814. value: function executeNamedAction(action) {}
  2815. }, {
  2816. key: 'onFileAttachmentAnnotation',
  2817. value: function onFileAttachmentAnnotation(_ref4) {
  2818. var id = _ref4.id,
  2819. filename = _ref4.filename,
  2820. content = _ref4.content;
  2821. }
  2822. }, {
  2823. key: 'cachePageRef',
  2824. value: function cachePageRef(pageNum, pageRef) {}
  2825. }, {
  2826. key: 'page',
  2827. get: function get() {
  2828. return 0;
  2829. },
  2830. set: function set(value) {}
  2831. }]);
  2832. return SimpleLinkService;
  2833. }();
  2834. exports.PDFLinkService = PDFLinkService;
  2835. exports.SimpleLinkService = SimpleLinkService;
  2836. /***/ }),
  2837. /* 6 */
  2838. /***/ (function(module, exports, __webpack_require__) {
  2839. "use strict";
  2840. Object.defineProperty(exports, "__esModule", {
  2841. value: true
  2842. });
  2843. exports.PDFCursorTools = exports.CursorTool = undefined;
  2844. 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"); } }; }();
  2845. 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; }; }();
  2846. var _grab_to_pan = __webpack_require__(14);
  2847. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2848. var CursorTool = {
  2849. SELECT: 0,
  2850. HAND: 1,
  2851. ZOOM: 2
  2852. };
  2853. var PDFCursorTools = function () {
  2854. function PDFCursorTools(_ref) {
  2855. var _this = this;
  2856. var container = _ref.container,
  2857. eventBus = _ref.eventBus,
  2858. preferences = _ref.preferences;
  2859. _classCallCheck(this, PDFCursorTools);
  2860. this.container = container;
  2861. this.eventBus = eventBus;
  2862. this.active = CursorTool.SELECT;
  2863. this.activeBeforePresentationMode = null;
  2864. this.handTool = new _grab_to_pan.GrabToPan({ element: this.container });
  2865. this._addEventListeners();
  2866. Promise.all([preferences.get('cursorToolOnLoad'), preferences.get('enableHandToolOnLoad')]).then(function (_ref2) {
  2867. var _ref3 = _slicedToArray(_ref2, 2),
  2868. cursorToolPref = _ref3[0],
  2869. handToolPref = _ref3[1];
  2870. if (handToolPref === true) {
  2871. preferences.set('enableHandToolOnLoad', false);
  2872. if (cursorToolPref === CursorTool.SELECT) {
  2873. cursorToolPref = CursorTool.HAND;
  2874. preferences.set('cursorToolOnLoad', cursorToolPref).catch(function () {});
  2875. }
  2876. }
  2877. _this.switchTool(cursorToolPref);
  2878. }).catch(function () {});
  2879. }
  2880. _createClass(PDFCursorTools, [{
  2881. key: 'switchTool',
  2882. value: function switchTool(tool) {
  2883. var _this2 = this;
  2884. if (this.activeBeforePresentationMode !== null) {
  2885. return;
  2886. }
  2887. if (tool === this.active) {
  2888. return;
  2889. }
  2890. var disableActiveTool = function disableActiveTool() {
  2891. switch (_this2.active) {
  2892. case CursorTool.SELECT:
  2893. break;
  2894. case CursorTool.HAND:
  2895. _this2.handTool.deactivate();
  2896. break;
  2897. case CursorTool.ZOOM:
  2898. }
  2899. };
  2900. switch (tool) {
  2901. case CursorTool.SELECT:
  2902. disableActiveTool();
  2903. break;
  2904. case CursorTool.HAND:
  2905. disableActiveTool();
  2906. this.handTool.activate();
  2907. break;
  2908. case CursorTool.ZOOM:
  2909. default:
  2910. console.error('switchTool: "' + tool + '" is an unsupported value.');
  2911. return;
  2912. }
  2913. this.active = tool;
  2914. this._dispatchEvent();
  2915. }
  2916. }, {
  2917. key: '_dispatchEvent',
  2918. value: function _dispatchEvent() {
  2919. this.eventBus.dispatch('cursortoolchanged', {
  2920. source: this,
  2921. tool: this.active
  2922. });
  2923. }
  2924. }, {
  2925. key: '_addEventListeners',
  2926. value: function _addEventListeners() {
  2927. var _this3 = this;
  2928. this.eventBus.on('switchcursortool', function (evt) {
  2929. _this3.switchTool(evt.tool);
  2930. });
  2931. this.eventBus.on('presentationmodechanged', function (evt) {
  2932. if (evt.switchInProgress) {
  2933. return;
  2934. }
  2935. var previouslyActive = void 0;
  2936. if (evt.active) {
  2937. previouslyActive = _this3.active;
  2938. _this3.switchTool(CursorTool.SELECT);
  2939. _this3.activeBeforePresentationMode = previouslyActive;
  2940. } else {
  2941. previouslyActive = _this3.activeBeforePresentationMode;
  2942. _this3.activeBeforePresentationMode = null;
  2943. _this3.switchTool(previouslyActive);
  2944. }
  2945. });
  2946. }
  2947. }, {
  2948. key: 'activeTool',
  2949. get: function get() {
  2950. return this.active;
  2951. }
  2952. }]);
  2953. return PDFCursorTools;
  2954. }();
  2955. exports.CursorTool = CursorTool;
  2956. exports.PDFCursorTools = PDFCursorTools;
  2957. /***/ }),
  2958. /* 7 */
  2959. /***/ (function(module, exports, __webpack_require__) {
  2960. "use strict";
  2961. Object.defineProperty(exports, "__esModule", {
  2962. value: true
  2963. });
  2964. exports.PDFFindController = exports.FindState = undefined;
  2965. 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; }; }();
  2966. var _pdfjsLib = __webpack_require__(1);
  2967. var _ui_utils = __webpack_require__(0);
  2968. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2969. var FindState = {
  2970. FOUND: 0,
  2971. NOT_FOUND: 1,
  2972. WRAPPED: 2,
  2973. PENDING: 3
  2974. };
  2975. var FIND_SCROLL_OFFSET_TOP = -50;
  2976. var FIND_SCROLL_OFFSET_LEFT = -400;
  2977. var FIND_TIMEOUT = 250;
  2978. var CHARACTERS_TO_NORMALIZE = {
  2979. '\u2018': '\'',
  2980. '\u2019': '\'',
  2981. '\u201A': '\'',
  2982. '\u201B': '\'',
  2983. '\u201C': '"',
  2984. '\u201D': '"',
  2985. '\u201E': '"',
  2986. '\u201F': '"',
  2987. '\xBC': '1/4',
  2988. '\xBD': '1/2',
  2989. '\xBE': '3/4'
  2990. };
  2991. var PDFFindController = function () {
  2992. function PDFFindController(_ref) {
  2993. var pdfViewer = _ref.pdfViewer;
  2994. _classCallCheck(this, PDFFindController);
  2995. this.pdfViewer = pdfViewer;
  2996. this.onUpdateResultsCount = null;
  2997. this.onUpdateState = null;
  2998. this.reset();
  2999. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  3000. this.normalizationRegex = new RegExp('[' + replace + ']', 'g');
  3001. }
  3002. _createClass(PDFFindController, [{
  3003. key: 'reset',
  3004. value: function reset() {
  3005. var _this = this;
  3006. this.startedTextExtraction = false;
  3007. this.extractTextPromises = [];
  3008. this.pendingFindMatches = Object.create(null);
  3009. this.active = false;
  3010. this.pageContents = [];
  3011. this.pageMatches = [];
  3012. this.pageMatchesLength = null;
  3013. this.matchCount = 0;
  3014. this.selected = {
  3015. pageIdx: -1,
  3016. matchIdx: -1
  3017. };
  3018. this.offset = {
  3019. pageIdx: null,
  3020. matchIdx: null
  3021. };
  3022. this.pagesToSearch = null;
  3023. this.resumePageIdx = null;
  3024. this.state = null;
  3025. this.dirtyMatch = false;
  3026. this.findTimeout = null;
  3027. this._firstPagePromise = new Promise(function (resolve) {
  3028. _this.resolveFirstPage = resolve;
  3029. });
  3030. }
  3031. }, {
  3032. key: 'normalize',
  3033. value: function normalize(text) {
  3034. return text.replace(this.normalizationRegex, function (ch) {
  3035. return CHARACTERS_TO_NORMALIZE[ch];
  3036. });
  3037. }
  3038. }, {
  3039. key: '_prepareMatches',
  3040. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  3041. function isSubTerm(matchesWithLength, currentIndex) {
  3042. var currentElem = matchesWithLength[currentIndex];
  3043. var nextElem = matchesWithLength[currentIndex + 1];
  3044. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  3045. currentElem.skipped = true;
  3046. return true;
  3047. }
  3048. for (var i = currentIndex - 1; i >= 0; i--) {
  3049. var prevElem = matchesWithLength[i];
  3050. if (prevElem.skipped) {
  3051. continue;
  3052. }
  3053. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  3054. break;
  3055. }
  3056. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  3057. currentElem.skipped = true;
  3058. return true;
  3059. }
  3060. }
  3061. return false;
  3062. }
  3063. matchesWithLength.sort(function (a, b) {
  3064. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  3065. });
  3066. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  3067. if (isSubTerm(matchesWithLength, i)) {
  3068. continue;
  3069. }
  3070. matches.push(matchesWithLength[i].match);
  3071. matchesLength.push(matchesWithLength[i].matchLength);
  3072. }
  3073. }
  3074. }, {
  3075. key: 'calcFindPhraseMatch',
  3076. value: function calcFindPhraseMatch(query, pageIndex, pageContent) {
  3077. var matches = [];
  3078. var queryLen = query.length;
  3079. var matchIdx = -queryLen;
  3080. while (true) {
  3081. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  3082. if (matchIdx === -1) {
  3083. break;
  3084. }
  3085. matches.push(matchIdx);
  3086. }
  3087. this.pageMatches[pageIndex] = matches;
  3088. }
  3089. }, {
  3090. key: 'calcFindWordMatch',
  3091. value: function calcFindWordMatch(query, pageIndex, pageContent) {
  3092. var matchesWithLength = [];
  3093. var queryArray = query.match(/\S+/g);
  3094. for (var i = 0, len = queryArray.length; i < len; i++) {
  3095. var subquery = queryArray[i];
  3096. var subqueryLen = subquery.length;
  3097. var matchIdx = -subqueryLen;
  3098. while (true) {
  3099. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  3100. if (matchIdx === -1) {
  3101. break;
  3102. }
  3103. matchesWithLength.push({
  3104. match: matchIdx,
  3105. matchLength: subqueryLen,
  3106. skipped: false
  3107. });
  3108. }
  3109. }
  3110. if (!this.pageMatchesLength) {
  3111. this.pageMatchesLength = [];
  3112. }
  3113. this.pageMatchesLength[pageIndex] = [];
  3114. this.pageMatches[pageIndex] = [];
  3115. this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex]);
  3116. }
  3117. }, {
  3118. key: 'calcFindMatch',
  3119. value: function calcFindMatch(pageIndex) {
  3120. var pageContent = this.normalize(this.pageContents[pageIndex]);
  3121. var query = this.normalize(this.state.query);
  3122. var caseSensitive = this.state.caseSensitive;
  3123. var phraseSearch = this.state.phraseSearch;
  3124. var queryLen = query.length;
  3125. if (queryLen === 0) {
  3126. return;
  3127. }
  3128. if (!caseSensitive) {
  3129. pageContent = pageContent.toLowerCase();
  3130. query = query.toLowerCase();
  3131. }
  3132. if (phraseSearch) {
  3133. this.calcFindPhraseMatch(query, pageIndex, pageContent);
  3134. } else {
  3135. this.calcFindWordMatch(query, pageIndex, pageContent);
  3136. }
  3137. this.updatePage(pageIndex);
  3138. if (this.resumePageIdx === pageIndex) {
  3139. this.resumePageIdx = null;
  3140. this.nextPageMatch();
  3141. }
  3142. if (this.pageMatches[pageIndex].length > 0) {
  3143. this.matchCount += this.pageMatches[pageIndex].length;
  3144. this.updateUIResultsCount();
  3145. }
  3146. }
  3147. }, {
  3148. key: 'extractText',
  3149. value: function extractText() {
  3150. var _this2 = this;
  3151. if (this.startedTextExtraction) {
  3152. return;
  3153. }
  3154. this.startedTextExtraction = true;
  3155. this.pageContents.length = 0;
  3156. var promise = Promise.resolve();
  3157. var _loop = function _loop(i, ii) {
  3158. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  3159. _this2.extractTextPromises[i] = extractTextCapability.promise;
  3160. promise = promise.then(function () {
  3161. return _this2.pdfViewer.getPageTextContent(i).then(function (textContent) {
  3162. var textItems = textContent.items;
  3163. var strBuf = [];
  3164. for (var j = 0, jj = textItems.length; j < jj; j++) {
  3165. strBuf.push(textItems[j].str);
  3166. }
  3167. _this2.pageContents[i] = strBuf.join('');
  3168. extractTextCapability.resolve(i);
  3169. }, function (reason) {
  3170. console.error('Unable to get page ' + (i + 1) + ' text content', reason);
  3171. _this2.pageContents[i] = '';
  3172. extractTextCapability.resolve(i);
  3173. });
  3174. });
  3175. };
  3176. for (var i = 0, ii = this.pdfViewer.pagesCount; i < ii; i++) {
  3177. _loop(i, ii);
  3178. }
  3179. }
  3180. }, {
  3181. key: 'executeCommand',
  3182. value: function executeCommand(cmd, state) {
  3183. var _this3 = this;
  3184. if (this.state === null || cmd !== 'findagain') {
  3185. this.dirtyMatch = true;
  3186. }
  3187. this.state = state;
  3188. this.updateUIState(FindState.PENDING);
  3189. this._firstPagePromise.then(function () {
  3190. _this3.extractText();
  3191. clearTimeout(_this3.findTimeout);
  3192. if (cmd === 'find') {
  3193. _this3.findTimeout = setTimeout(_this3.nextMatch.bind(_this3), FIND_TIMEOUT);
  3194. } else {
  3195. _this3.nextMatch();
  3196. }
  3197. });
  3198. }
  3199. }, {
  3200. key: 'updatePage',
  3201. value: function updatePage(index) {
  3202. if (this.selected.pageIdx === index) {
  3203. this.pdfViewer.currentPageNumber = index + 1;
  3204. }
  3205. var page = this.pdfViewer.getPageView(index);
  3206. if (page.textLayer) {
  3207. page.textLayer.updateMatches();
  3208. }
  3209. }
  3210. }, {
  3211. key: 'nextMatch',
  3212. value: function nextMatch() {
  3213. var _this4 = this;
  3214. var previous = this.state.findPrevious;
  3215. var currentPageIndex = this.pdfViewer.currentPageNumber - 1;
  3216. var numPages = this.pdfViewer.pagesCount;
  3217. this.active = true;
  3218. if (this.dirtyMatch) {
  3219. this.dirtyMatch = false;
  3220. this.selected.pageIdx = this.selected.matchIdx = -1;
  3221. this.offset.pageIdx = currentPageIndex;
  3222. this.offset.matchIdx = null;
  3223. this.hadMatch = false;
  3224. this.resumePageIdx = null;
  3225. this.pageMatches = [];
  3226. this.matchCount = 0;
  3227. this.pageMatchesLength = null;
  3228. for (var i = 0; i < numPages; i++) {
  3229. this.updatePage(i);
  3230. if (!(i in this.pendingFindMatches)) {
  3231. this.pendingFindMatches[i] = true;
  3232. this.extractTextPromises[i].then(function (pageIdx) {
  3233. delete _this4.pendingFindMatches[pageIdx];
  3234. _this4.calcFindMatch(pageIdx);
  3235. });
  3236. }
  3237. }
  3238. }
  3239. if (this.state.query === '') {
  3240. this.updateUIState(FindState.FOUND);
  3241. return;
  3242. }
  3243. if (this.resumePageIdx) {
  3244. return;
  3245. }
  3246. var offset = this.offset;
  3247. this.pagesToSearch = numPages;
  3248. if (offset.matchIdx !== null) {
  3249. var numPageMatches = this.pageMatches[offset.pageIdx].length;
  3250. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  3251. this.hadMatch = true;
  3252. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  3253. this.updateMatch(true);
  3254. return;
  3255. }
  3256. this.advanceOffsetPage(previous);
  3257. }
  3258. this.nextPageMatch();
  3259. }
  3260. }, {
  3261. key: 'matchesReady',
  3262. value: function matchesReady(matches) {
  3263. var offset = this.offset;
  3264. var numMatches = matches.length;
  3265. var previous = this.state.findPrevious;
  3266. if (numMatches) {
  3267. this.hadMatch = true;
  3268. offset.matchIdx = previous ? numMatches - 1 : 0;
  3269. this.updateMatch(true);
  3270. return true;
  3271. }
  3272. this.advanceOffsetPage(previous);
  3273. if (offset.wrapped) {
  3274. offset.matchIdx = null;
  3275. if (this.pagesToSearch < 0) {
  3276. this.updateMatch(false);
  3277. return true;
  3278. }
  3279. }
  3280. return false;
  3281. }
  3282. }, {
  3283. key: 'updateMatchPosition',
  3284. value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
  3285. if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
  3286. var spot = {
  3287. top: FIND_SCROLL_OFFSET_TOP,
  3288. left: FIND_SCROLL_OFFSET_LEFT
  3289. };
  3290. (0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
  3291. }
  3292. }
  3293. }, {
  3294. key: 'nextPageMatch',
  3295. value: function nextPageMatch() {
  3296. if (this.resumePageIdx !== null) {
  3297. console.error('There can only be one pending page.');
  3298. }
  3299. var matches = null;
  3300. do {
  3301. var pageIdx = this.offset.pageIdx;
  3302. matches = this.pageMatches[pageIdx];
  3303. if (!matches) {
  3304. this.resumePageIdx = pageIdx;
  3305. break;
  3306. }
  3307. } while (!this.matchesReady(matches));
  3308. }
  3309. }, {
  3310. key: 'advanceOffsetPage',
  3311. value: function advanceOffsetPage(previous) {
  3312. var offset = this.offset;
  3313. var numPages = this.extractTextPromises.length;
  3314. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  3315. offset.matchIdx = null;
  3316. this.pagesToSearch--;
  3317. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  3318. offset.pageIdx = previous ? numPages - 1 : 0;
  3319. offset.wrapped = true;
  3320. }
  3321. }
  3322. }, {
  3323. key: 'updateMatch',
  3324. value: function updateMatch() {
  3325. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3326. var state = FindState.NOT_FOUND;
  3327. var wrapped = this.offset.wrapped;
  3328. this.offset.wrapped = false;
  3329. if (found) {
  3330. var previousPage = this.selected.pageIdx;
  3331. this.selected.pageIdx = this.offset.pageIdx;
  3332. this.selected.matchIdx = this.offset.matchIdx;
  3333. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  3334. if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
  3335. this.updatePage(previousPage);
  3336. }
  3337. }
  3338. this.updateUIState(state, this.state.findPrevious);
  3339. if (this.selected.pageIdx !== -1) {
  3340. this.updatePage(this.selected.pageIdx);
  3341. }
  3342. }
  3343. }, {
  3344. key: 'updateUIResultsCount',
  3345. value: function updateUIResultsCount() {
  3346. if (this.onUpdateResultsCount) {
  3347. this.onUpdateResultsCount(this.matchCount);
  3348. }
  3349. }
  3350. }, {
  3351. key: 'updateUIState',
  3352. value: function updateUIState(state, previous) {
  3353. if (this.onUpdateState) {
  3354. this.onUpdateState(state, previous, this.matchCount);
  3355. }
  3356. }
  3357. }]);
  3358. return PDFFindController;
  3359. }();
  3360. exports.FindState = FindState;
  3361. exports.PDFFindController = PDFFindController;
  3362. /***/ }),
  3363. /* 8 */
  3364. /***/ (function(module, exports, __webpack_require__) {
  3365. "use strict";
  3366. Object.defineProperty(exports, "__esModule", {
  3367. value: true
  3368. });
  3369. exports.GenericCom = undefined;
  3370. 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; }; }();
  3371. var _app = __webpack_require__(4);
  3372. var _preferences = __webpack_require__(28);
  3373. var _download_manager = __webpack_require__(12);
  3374. var _genericl10n = __webpack_require__(13);
  3375. var _pdfjsLib = __webpack_require__(1);
  3376. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3377. 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; }
  3378. 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; }
  3379. ;
  3380. var GenericCom = {};
  3381. var GenericPreferences = function (_BasePreferences) {
  3382. _inherits(GenericPreferences, _BasePreferences);
  3383. function GenericPreferences() {
  3384. _classCallCheck(this, GenericPreferences);
  3385. return _possibleConstructorReturn(this, (GenericPreferences.__proto__ || Object.getPrototypeOf(GenericPreferences)).apply(this, arguments));
  3386. }
  3387. _createClass(GenericPreferences, [{
  3388. key: '_writeToStorage',
  3389. value: function _writeToStorage(prefObj) {
  3390. return new Promise(function (resolve) {
  3391. localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
  3392. resolve();
  3393. });
  3394. }
  3395. }, {
  3396. key: '_readFromStorage',
  3397. value: function _readFromStorage(prefObj) {
  3398. return new Promise(function (resolve) {
  3399. var readPrefs = JSON.parse(localStorage.getItem('pdfjs.preferences'));
  3400. resolve(readPrefs);
  3401. });
  3402. }
  3403. }]);
  3404. return GenericPreferences;
  3405. }(_preferences.BasePreferences);
  3406. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  3407. GenericExternalServices.createDownloadManager = function () {
  3408. return new _download_manager.DownloadManager();
  3409. };
  3410. GenericExternalServices.createPreferences = function () {
  3411. return new GenericPreferences();
  3412. };
  3413. GenericExternalServices.createL10n = function () {
  3414. return new _genericl10n.GenericL10n(_pdfjsLib.PDFJS.locale);
  3415. };
  3416. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  3417. exports.GenericCom = GenericCom;
  3418. /***/ }),
  3419. /* 9 */
  3420. /***/ (function(module, exports, __webpack_require__) {
  3421. "use strict";
  3422. Object.defineProperty(exports, "__esModule", {
  3423. value: true
  3424. });
  3425. exports.PDFPrintService = undefined;
  3426. var _ui_utils = __webpack_require__(0);
  3427. var _app = __webpack_require__(4);
  3428. var _pdfjsLib = __webpack_require__(1);
  3429. var activeService = null;
  3430. var overlayManager = null;
  3431. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  3432. var scratchCanvas = activeService.scratchCanvas;
  3433. var PRINT_RESOLUTION = 150;
  3434. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  3435. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  3436. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  3437. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  3438. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  3439. var ctx = scratchCanvas.getContext('2d');
  3440. ctx.save();
  3441. ctx.fillStyle = 'rgb(255, 255, 255)';
  3442. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  3443. ctx.restore();
  3444. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  3445. var renderContext = {
  3446. canvasContext: ctx,
  3447. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  3448. viewport: pdfPage.getViewport(1, size.rotation),
  3449. intent: 'print'
  3450. };
  3451. return pdfPage.render(renderContext).promise;
  3452. }).then(function () {
  3453. return {
  3454. width: width,
  3455. height: height
  3456. };
  3457. });
  3458. }
  3459. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  3460. this.pdfDocument = pdfDocument;
  3461. this.pagesOverview = pagesOverview;
  3462. this.printContainer = printContainer;
  3463. this.l10n = l10n || _ui_utils.NullL10n;
  3464. this.currentPage = -1;
  3465. this.scratchCanvas = document.createElement('canvas');
  3466. }
  3467. PDFPrintService.prototype = {
  3468. layout: function layout() {
  3469. this.throwIfInactive();
  3470. var body = document.querySelector('body');
  3471. body.setAttribute('data-pdfjsprinting', true);
  3472. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  3473. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  3474. }, this);
  3475. if (!hasEqualPageSizes) {
  3476. console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!');
  3477. }
  3478. this.pageStyleSheet = document.createElement('style');
  3479. var pageSize = this.pagesOverview[0];
  3480. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  3481. body.appendChild(this.pageStyleSheet);
  3482. },
  3483. destroy: function destroy() {
  3484. if (activeService !== this) {
  3485. return;
  3486. }
  3487. this.printContainer.textContent = '';
  3488. if (this.pageStyleSheet && this.pageStyleSheet.parentNode) {
  3489. this.pageStyleSheet.parentNode.removeChild(this.pageStyleSheet);
  3490. this.pageStyleSheet = null;
  3491. }
  3492. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  3493. this.scratchCanvas = null;
  3494. activeService = null;
  3495. ensureOverlay().then(function () {
  3496. if (overlayManager.active !== 'printServiceOverlay') {
  3497. return;
  3498. }
  3499. overlayManager.close('printServiceOverlay');
  3500. });
  3501. },
  3502. renderPages: function renderPages() {
  3503. var _this = this;
  3504. var pageCount = this.pagesOverview.length;
  3505. var renderNextPage = function renderNextPage(resolve, reject) {
  3506. _this.throwIfInactive();
  3507. if (++_this.currentPage >= pageCount) {
  3508. renderProgress(pageCount, pageCount, _this.l10n);
  3509. resolve();
  3510. return;
  3511. }
  3512. var index = _this.currentPage;
  3513. renderProgress(index, pageCount, _this.l10n);
  3514. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
  3515. renderNextPage(resolve, reject);
  3516. }, reject);
  3517. };
  3518. return new Promise(renderNextPage);
  3519. },
  3520. useRenderedPage: function useRenderedPage(printItem) {
  3521. this.throwIfInactive();
  3522. var img = document.createElement('img');
  3523. img.style.width = printItem.width;
  3524. img.style.height = printItem.height;
  3525. var scratchCanvas = this.scratchCanvas;
  3526. if ('toBlob' in scratchCanvas && !_pdfjsLib.PDFJS.disableCreateObjectURL) {
  3527. scratchCanvas.toBlob(function (blob) {
  3528. img.src = URL.createObjectURL(blob);
  3529. });
  3530. } else {
  3531. img.src = scratchCanvas.toDataURL();
  3532. }
  3533. var wrapper = document.createElement('div');
  3534. wrapper.appendChild(img);
  3535. this.printContainer.appendChild(wrapper);
  3536. return new Promise(function (resolve, reject) {
  3537. img.onload = resolve;
  3538. img.onerror = reject;
  3539. });
  3540. },
  3541. performPrint: function performPrint() {
  3542. var _this2 = this;
  3543. this.throwIfInactive();
  3544. return new Promise(function (resolve) {
  3545. setTimeout(function () {
  3546. if (!_this2.active) {
  3547. resolve();
  3548. return;
  3549. }
  3550. print.call(window);
  3551. setTimeout(resolve, 20);
  3552. }, 0);
  3553. });
  3554. },
  3555. get active() {
  3556. return this === activeService;
  3557. },
  3558. throwIfInactive: function throwIfInactive() {
  3559. if (!this.active) {
  3560. throw new Error('This print request was cancelled or completed.');
  3561. }
  3562. }
  3563. };
  3564. var print = window.print;
  3565. window.print = function print() {
  3566. if (activeService) {
  3567. console.warn('Ignored window.print() because of a pending print job.');
  3568. return;
  3569. }
  3570. ensureOverlay().then(function () {
  3571. if (activeService) {
  3572. overlayManager.open('printServiceOverlay');
  3573. }
  3574. });
  3575. try {
  3576. dispatchEvent('beforeprint');
  3577. } finally {
  3578. if (!activeService) {
  3579. console.error('Expected print service to be initialized.');
  3580. ensureOverlay().then(function () {
  3581. if (overlayManager.active === 'printServiceOverlay') {
  3582. overlayManager.close('printServiceOverlay');
  3583. }
  3584. });
  3585. return;
  3586. }
  3587. var activeServiceOnEntry = activeService;
  3588. activeService.renderPages().then(function () {
  3589. return activeServiceOnEntry.performPrint();
  3590. }).catch(function () {}).then(function () {
  3591. if (activeServiceOnEntry.active) {
  3592. abort();
  3593. }
  3594. });
  3595. }
  3596. };
  3597. function dispatchEvent(eventType) {
  3598. var event = document.createEvent('CustomEvent');
  3599. event.initCustomEvent(eventType, false, false, 'custom');
  3600. window.dispatchEvent(event);
  3601. }
  3602. function abort() {
  3603. if (activeService) {
  3604. activeService.destroy();
  3605. dispatchEvent('afterprint');
  3606. }
  3607. }
  3608. function renderProgress(index, total, l10n) {
  3609. var progressContainer = document.getElementById('printServiceOverlay');
  3610. var progress = Math.round(100 * index / total);
  3611. var progressBar = progressContainer.querySelector('progress');
  3612. var progressPerc = progressContainer.querySelector('.relative-progress');
  3613. progressBar.value = progress;
  3614. l10n.get('print_progress_percent', { progress: progress }, progress + '%').then(function (msg) {
  3615. progressPerc.textContent = msg;
  3616. });
  3617. }
  3618. var hasAttachEvent = !!document.attachEvent;
  3619. window.addEventListener('keydown', function (event) {
  3620. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  3621. window.print();
  3622. if (hasAttachEvent) {
  3623. return;
  3624. }
  3625. event.preventDefault();
  3626. if (event.stopImmediatePropagation) {
  3627. event.stopImmediatePropagation();
  3628. } else {
  3629. event.stopPropagation();
  3630. }
  3631. return;
  3632. }
  3633. }, true);
  3634. if (hasAttachEvent) {
  3635. document.attachEvent('onkeydown', function (event) {
  3636. event = event || window.event;
  3637. if (event.keyCode === 80 && event.ctrlKey) {
  3638. event.keyCode = 0;
  3639. return false;
  3640. }
  3641. });
  3642. }
  3643. if ('onbeforeprint' in window) {
  3644. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  3645. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  3646. event.stopImmediatePropagation();
  3647. }
  3648. };
  3649. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  3650. window.addEventListener('afterprint', stopPropagationIfNeeded);
  3651. }
  3652. var overlayPromise;
  3653. function ensureOverlay() {
  3654. if (!overlayPromise) {
  3655. overlayManager = _app.PDFViewerApplication.overlayManager;
  3656. if (!overlayManager) {
  3657. throw new Error('The overlay manager has not yet been initialized.');
  3658. }
  3659. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
  3660. document.getElementById('printCancel').onclick = abort;
  3661. }
  3662. return overlayPromise;
  3663. }
  3664. _app.PDFPrintServiceFactory.instance = {
  3665. supportsPrinting: true,
  3666. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  3667. if (activeService) {
  3668. throw new Error('The print service is created and active.');
  3669. }
  3670. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  3671. return activeService;
  3672. }
  3673. };
  3674. exports.PDFPrintService = PDFPrintService;
  3675. /***/ }),
  3676. /* 10 */
  3677. /***/ (function(module, exports, __webpack_require__) {
  3678. "use strict";
  3679. document.webL10n = function (window, document, undefined) {
  3680. var gL10nData = {};
  3681. var gTextData = '';
  3682. var gTextProp = 'textContent';
  3683. var gLanguage = '';
  3684. var gMacros = {};
  3685. var gReadyState = 'loading';
  3686. var gAsyncResourceLoading = true;
  3687. function getL10nResourceLinks() {
  3688. return document.querySelectorAll('link[type="application/l10n"]');
  3689. }
  3690. function getL10nDictionary() {
  3691. var script = document.querySelector('script[type="application/l10n"]');
  3692. return script ? JSON.parse(script.innerHTML) : null;
  3693. }
  3694. function getTranslatableChildren(element) {
  3695. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  3696. }
  3697. function getL10nAttributes(element) {
  3698. if (!element) return {};
  3699. var l10nId = element.getAttribute('data-l10n-id');
  3700. var l10nArgs = element.getAttribute('data-l10n-args');
  3701. var args = {};
  3702. if (l10nArgs) {
  3703. try {
  3704. args = JSON.parse(l10nArgs);
  3705. } catch (e) {
  3706. console.warn('could not parse arguments for #' + l10nId);
  3707. }
  3708. }
  3709. return {
  3710. id: l10nId,
  3711. args: args
  3712. };
  3713. }
  3714. function fireL10nReadyEvent(lang) {
  3715. var evtObject = document.createEvent('Event');
  3716. evtObject.initEvent('localized', true, false);
  3717. evtObject.language = lang;
  3718. document.dispatchEvent(evtObject);
  3719. }
  3720. function xhrLoadText(url, onSuccess, onFailure) {
  3721. onSuccess = onSuccess || function _onSuccess(data) {};
  3722. onFailure = onFailure || function _onFailure() {};
  3723. var xhr = new XMLHttpRequest();
  3724. xhr.open('GET', url, gAsyncResourceLoading);
  3725. if (xhr.overrideMimeType) {
  3726. xhr.overrideMimeType('text/plain; charset=utf-8');
  3727. }
  3728. xhr.onreadystatechange = function () {
  3729. if (xhr.readyState == 4) {
  3730. if (xhr.status == 200 || xhr.status === 0) {
  3731. onSuccess(xhr.responseText);
  3732. } else {
  3733. onFailure();
  3734. }
  3735. }
  3736. };
  3737. xhr.onerror = onFailure;
  3738. xhr.ontimeout = onFailure;
  3739. try {
  3740. xhr.send(null);
  3741. } catch (e) {
  3742. onFailure();
  3743. }
  3744. }
  3745. function parseResource(href, lang, successCallback, failureCallback) {
  3746. var baseURL = href.replace(/[^\/]*$/, '') || './';
  3747. function evalString(text) {
  3748. if (text.lastIndexOf('\\') < 0) return text;
  3749. 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, "'");
  3750. }
  3751. function parseProperties(text, parsedPropertiesCallback) {
  3752. var dictionary = {};
  3753. var reBlank = /^\s*|\s*$/;
  3754. var reComment = /^\s*#|^\s*$/;
  3755. var reSection = /^\s*\[(.*)\]\s*$/;
  3756. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  3757. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  3758. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  3759. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  3760. var currentLang = '*';
  3761. var genericLang = lang.split('-', 1)[0];
  3762. var skipLang = false;
  3763. var match = '';
  3764. function nextEntry() {
  3765. while (true) {
  3766. if (!entries.length) {
  3767. parsedRawLinesCallback();
  3768. return;
  3769. }
  3770. var line = entries.shift();
  3771. if (reComment.test(line)) continue;
  3772. if (extendedSyntax) {
  3773. match = reSection.exec(line);
  3774. if (match) {
  3775. currentLang = match[1].toLowerCase();
  3776. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  3777. continue;
  3778. } else if (skipLang) {
  3779. continue;
  3780. }
  3781. match = reImport.exec(line);
  3782. if (match) {
  3783. loadImport(baseURL + match[1], nextEntry);
  3784. return;
  3785. }
  3786. }
  3787. var tmp = line.match(reSplit);
  3788. if (tmp && tmp.length == 3) {
  3789. dictionary[tmp[1]] = evalString(tmp[2]);
  3790. }
  3791. }
  3792. }
  3793. nextEntry();
  3794. }
  3795. function loadImport(url, callback) {
  3796. xhrLoadText(url, function (content) {
  3797. parseRawLines(content, false, callback);
  3798. }, function () {
  3799. console.warn(url + ' not found.');
  3800. callback();
  3801. });
  3802. }
  3803. parseRawLines(text, true, function () {
  3804. parsedPropertiesCallback(dictionary);
  3805. });
  3806. }
  3807. xhrLoadText(href, function (response) {
  3808. gTextData += response;
  3809. parseProperties(response, function (data) {
  3810. for (var key in data) {
  3811. var id,
  3812. prop,
  3813. index = key.lastIndexOf('.');
  3814. if (index > 0) {
  3815. id = key.substring(0, index);
  3816. prop = key.substr(index + 1);
  3817. } else {
  3818. id = key;
  3819. prop = gTextProp;
  3820. }
  3821. if (!gL10nData[id]) {
  3822. gL10nData[id] = {};
  3823. }
  3824. gL10nData[id][prop] = data[key];
  3825. }
  3826. if (successCallback) {
  3827. successCallback();
  3828. }
  3829. });
  3830. }, failureCallback);
  3831. }
  3832. function loadLocale(lang, callback) {
  3833. if (lang) {
  3834. lang = lang.toLowerCase();
  3835. }
  3836. callback = callback || function _callback() {};
  3837. clear();
  3838. gLanguage = lang;
  3839. var langLinks = getL10nResourceLinks();
  3840. var langCount = langLinks.length;
  3841. if (langCount === 0) {
  3842. var dict = getL10nDictionary();
  3843. if (dict && dict.locales && dict.default_locale) {
  3844. console.log('using the embedded JSON directory, early way out');
  3845. gL10nData = dict.locales[lang];
  3846. if (!gL10nData) {
  3847. var defaultLocale = dict.default_locale.toLowerCase();
  3848. for (var anyCaseLang in dict.locales) {
  3849. anyCaseLang = anyCaseLang.toLowerCase();
  3850. if (anyCaseLang === lang) {
  3851. gL10nData = dict.locales[lang];
  3852. break;
  3853. } else if (anyCaseLang === defaultLocale) {
  3854. gL10nData = dict.locales[defaultLocale];
  3855. }
  3856. }
  3857. }
  3858. callback();
  3859. } else {
  3860. console.log('no resource to load, early way out');
  3861. }
  3862. fireL10nReadyEvent(lang);
  3863. gReadyState = 'complete';
  3864. return;
  3865. }
  3866. var onResourceLoaded = null;
  3867. var gResourceCount = 0;
  3868. onResourceLoaded = function onResourceLoaded() {
  3869. gResourceCount++;
  3870. if (gResourceCount >= langCount) {
  3871. callback();
  3872. fireL10nReadyEvent(lang);
  3873. gReadyState = 'complete';
  3874. }
  3875. };
  3876. function L10nResourceLink(link) {
  3877. var href = link.href;
  3878. this.load = function (lang, callback) {
  3879. parseResource(href, lang, callback, function () {
  3880. console.warn(href + ' not found.');
  3881. console.warn('"' + lang + '" resource not found');
  3882. gLanguage = '';
  3883. callback();
  3884. });
  3885. };
  3886. }
  3887. for (var i = 0; i < langCount; i++) {
  3888. var resource = new L10nResourceLink(langLinks[i]);
  3889. resource.load(lang, onResourceLoaded);
  3890. }
  3891. }
  3892. function clear() {
  3893. gL10nData = {};
  3894. gTextData = '';
  3895. gLanguage = '';
  3896. }
  3897. function getPluralRules(lang) {
  3898. var locales2rules = {
  3899. 'af': 3,
  3900. 'ak': 4,
  3901. 'am': 4,
  3902. 'ar': 1,
  3903. 'asa': 3,
  3904. 'az': 0,
  3905. 'be': 11,
  3906. 'bem': 3,
  3907. 'bez': 3,
  3908. 'bg': 3,
  3909. 'bh': 4,
  3910. 'bm': 0,
  3911. 'bn': 3,
  3912. 'bo': 0,
  3913. 'br': 20,
  3914. 'brx': 3,
  3915. 'bs': 11,
  3916. 'ca': 3,
  3917. 'cgg': 3,
  3918. 'chr': 3,
  3919. 'cs': 12,
  3920. 'cy': 17,
  3921. 'da': 3,
  3922. 'de': 3,
  3923. 'dv': 3,
  3924. 'dz': 0,
  3925. 'ee': 3,
  3926. 'el': 3,
  3927. 'en': 3,
  3928. 'eo': 3,
  3929. 'es': 3,
  3930. 'et': 3,
  3931. 'eu': 3,
  3932. 'fa': 0,
  3933. 'ff': 5,
  3934. 'fi': 3,
  3935. 'fil': 4,
  3936. 'fo': 3,
  3937. 'fr': 5,
  3938. 'fur': 3,
  3939. 'fy': 3,
  3940. 'ga': 8,
  3941. 'gd': 24,
  3942. 'gl': 3,
  3943. 'gsw': 3,
  3944. 'gu': 3,
  3945. 'guw': 4,
  3946. 'gv': 23,
  3947. 'ha': 3,
  3948. 'haw': 3,
  3949. 'he': 2,
  3950. 'hi': 4,
  3951. 'hr': 11,
  3952. 'hu': 0,
  3953. 'id': 0,
  3954. 'ig': 0,
  3955. 'ii': 0,
  3956. 'is': 3,
  3957. 'it': 3,
  3958. 'iu': 7,
  3959. 'ja': 0,
  3960. 'jmc': 3,
  3961. 'jv': 0,
  3962. 'ka': 0,
  3963. 'kab': 5,
  3964. 'kaj': 3,
  3965. 'kcg': 3,
  3966. 'kde': 0,
  3967. 'kea': 0,
  3968. 'kk': 3,
  3969. 'kl': 3,
  3970. 'km': 0,
  3971. 'kn': 0,
  3972. 'ko': 0,
  3973. 'ksb': 3,
  3974. 'ksh': 21,
  3975. 'ku': 3,
  3976. 'kw': 7,
  3977. 'lag': 18,
  3978. 'lb': 3,
  3979. 'lg': 3,
  3980. 'ln': 4,
  3981. 'lo': 0,
  3982. 'lt': 10,
  3983. 'lv': 6,
  3984. 'mas': 3,
  3985. 'mg': 4,
  3986. 'mk': 16,
  3987. 'ml': 3,
  3988. 'mn': 3,
  3989. 'mo': 9,
  3990. 'mr': 3,
  3991. 'ms': 0,
  3992. 'mt': 15,
  3993. 'my': 0,
  3994. 'nah': 3,
  3995. 'naq': 7,
  3996. 'nb': 3,
  3997. 'nd': 3,
  3998. 'ne': 3,
  3999. 'nl': 3,
  4000. 'nn': 3,
  4001. 'no': 3,
  4002. 'nr': 3,
  4003. 'nso': 4,
  4004. 'ny': 3,
  4005. 'nyn': 3,
  4006. 'om': 3,
  4007. 'or': 3,
  4008. 'pa': 3,
  4009. 'pap': 3,
  4010. 'pl': 13,
  4011. 'ps': 3,
  4012. 'pt': 3,
  4013. 'rm': 3,
  4014. 'ro': 9,
  4015. 'rof': 3,
  4016. 'ru': 11,
  4017. 'rwk': 3,
  4018. 'sah': 0,
  4019. 'saq': 3,
  4020. 'se': 7,
  4021. 'seh': 3,
  4022. 'ses': 0,
  4023. 'sg': 0,
  4024. 'sh': 11,
  4025. 'shi': 19,
  4026. 'sk': 12,
  4027. 'sl': 14,
  4028. 'sma': 7,
  4029. 'smi': 7,
  4030. 'smj': 7,
  4031. 'smn': 7,
  4032. 'sms': 7,
  4033. 'sn': 3,
  4034. 'so': 3,
  4035. 'sq': 3,
  4036. 'sr': 11,
  4037. 'ss': 3,
  4038. 'ssy': 3,
  4039. 'st': 3,
  4040. 'sv': 3,
  4041. 'sw': 3,
  4042. 'syr': 3,
  4043. 'ta': 3,
  4044. 'te': 3,
  4045. 'teo': 3,
  4046. 'th': 0,
  4047. 'ti': 4,
  4048. 'tig': 3,
  4049. 'tk': 3,
  4050. 'tl': 4,
  4051. 'tn': 3,
  4052. 'to': 0,
  4053. 'tr': 0,
  4054. 'ts': 3,
  4055. 'tzm': 22,
  4056. 'uk': 11,
  4057. 'ur': 3,
  4058. 've': 3,
  4059. 'vi': 0,
  4060. 'vun': 3,
  4061. 'wa': 4,
  4062. 'wae': 3,
  4063. 'wo': 0,
  4064. 'xh': 3,
  4065. 'xog': 3,
  4066. 'yo': 0,
  4067. 'zh': 0,
  4068. 'zu': 3
  4069. };
  4070. function isIn(n, list) {
  4071. return list.indexOf(n) !== -1;
  4072. }
  4073. function isBetween(n, start, end) {
  4074. return start <= n && n <= end;
  4075. }
  4076. var pluralRules = {
  4077. '0': function _(n) {
  4078. return 'other';
  4079. },
  4080. '1': function _(n) {
  4081. if (isBetween(n % 100, 3, 10)) return 'few';
  4082. if (n === 0) return 'zero';
  4083. if (isBetween(n % 100, 11, 99)) return 'many';
  4084. if (n == 2) return 'two';
  4085. if (n == 1) return 'one';
  4086. return 'other';
  4087. },
  4088. '2': function _(n) {
  4089. if (n !== 0 && n % 10 === 0) return 'many';
  4090. if (n == 2) return 'two';
  4091. if (n == 1) return 'one';
  4092. return 'other';
  4093. },
  4094. '3': function _(n) {
  4095. if (n == 1) return 'one';
  4096. return 'other';
  4097. },
  4098. '4': function _(n) {
  4099. if (isBetween(n, 0, 1)) return 'one';
  4100. return 'other';
  4101. },
  4102. '5': function _(n) {
  4103. if (isBetween(n, 0, 2) && n != 2) return 'one';
  4104. return 'other';
  4105. },
  4106. '6': function _(n) {
  4107. if (n === 0) return 'zero';
  4108. if (n % 10 == 1 && n % 100 != 11) return 'one';
  4109. return 'other';
  4110. },
  4111. '7': function _(n) {
  4112. if (n == 2) return 'two';
  4113. if (n == 1) return 'one';
  4114. return 'other';
  4115. },
  4116. '8': function _(n) {
  4117. if (isBetween(n, 3, 6)) return 'few';
  4118. if (isBetween(n, 7, 10)) return 'many';
  4119. if (n == 2) return 'two';
  4120. if (n == 1) return 'one';
  4121. return 'other';
  4122. },
  4123. '9': function _(n) {
  4124. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  4125. if (n == 1) return 'one';
  4126. return 'other';
  4127. },
  4128. '10': function _(n) {
  4129. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  4130. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  4131. return 'other';
  4132. },
  4133. '11': function _(n) {
  4134. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  4135. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  4136. if (n % 10 == 1 && n % 100 != 11) return 'one';
  4137. return 'other';
  4138. },
  4139. '12': function _(n) {
  4140. if (isBetween(n, 2, 4)) return 'few';
  4141. if (n == 1) return 'one';
  4142. return 'other';
  4143. },
  4144. '13': function _(n) {
  4145. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  4146. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  4147. if (n == 1) return 'one';
  4148. return 'other';
  4149. },
  4150. '14': function _(n) {
  4151. if (isBetween(n % 100, 3, 4)) return 'few';
  4152. if (n % 100 == 2) return 'two';
  4153. if (n % 100 == 1) return 'one';
  4154. return 'other';
  4155. },
  4156. '15': function _(n) {
  4157. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  4158. if (isBetween(n % 100, 11, 19)) return 'many';
  4159. if (n == 1) return 'one';
  4160. return 'other';
  4161. },
  4162. '16': function _(n) {
  4163. if (n % 10 == 1 && n != 11) return 'one';
  4164. return 'other';
  4165. },
  4166. '17': function _(n) {
  4167. if (n == 3) return 'few';
  4168. if (n === 0) return 'zero';
  4169. if (n == 6) return 'many';
  4170. if (n == 2) return 'two';
  4171. if (n == 1) return 'one';
  4172. return 'other';
  4173. },
  4174. '18': function _(n) {
  4175. if (n === 0) return 'zero';
  4176. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  4177. return 'other';
  4178. },
  4179. '19': function _(n) {
  4180. if (isBetween(n, 2, 10)) return 'few';
  4181. if (isBetween(n, 0, 1)) return 'one';
  4182. return 'other';
  4183. },
  4184. '20': function _(n) {
  4185. 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';
  4186. if (n % 1000000 === 0 && n !== 0) return 'many';
  4187. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  4188. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  4189. return 'other';
  4190. },
  4191. '21': function _(n) {
  4192. if (n === 0) return 'zero';
  4193. if (n == 1) return 'one';
  4194. return 'other';
  4195. },
  4196. '22': function _(n) {
  4197. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  4198. return 'other';
  4199. },
  4200. '23': function _(n) {
  4201. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  4202. return 'other';
  4203. },
  4204. '24': function _(n) {
  4205. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  4206. if (isIn(n, [2, 12])) return 'two';
  4207. if (isIn(n, [1, 11])) return 'one';
  4208. return 'other';
  4209. }
  4210. };
  4211. var index = locales2rules[lang.replace(/-.*$/, '')];
  4212. if (!(index in pluralRules)) {
  4213. console.warn('plural form unknown for [' + lang + ']');
  4214. return function () {
  4215. return 'other';
  4216. };
  4217. }
  4218. return pluralRules[index];
  4219. }
  4220. gMacros.plural = function (str, param, key, prop) {
  4221. var n = parseFloat(param);
  4222. if (isNaN(n)) return str;
  4223. if (prop != gTextProp) return str;
  4224. if (!gMacros._pluralRules) {
  4225. gMacros._pluralRules = getPluralRules(gLanguage);
  4226. }
  4227. var index = '[' + gMacros._pluralRules(n) + ']';
  4228. if (n === 0 && key + '[zero]' in gL10nData) {
  4229. str = gL10nData[key + '[zero]'][prop];
  4230. } else if (n == 1 && key + '[one]' in gL10nData) {
  4231. str = gL10nData[key + '[one]'][prop];
  4232. } else if (n == 2 && key + '[two]' in gL10nData) {
  4233. str = gL10nData[key + '[two]'][prop];
  4234. } else if (key + index in gL10nData) {
  4235. str = gL10nData[key + index][prop];
  4236. } else if (key + '[other]' in gL10nData) {
  4237. str = gL10nData[key + '[other]'][prop];
  4238. }
  4239. return str;
  4240. };
  4241. function getL10nData(key, args, fallback) {
  4242. var data = gL10nData[key];
  4243. if (!data) {
  4244. console.warn('#' + key + ' is undefined.');
  4245. if (!fallback) {
  4246. return null;
  4247. }
  4248. data = fallback;
  4249. }
  4250. var rv = {};
  4251. for (var prop in data) {
  4252. var str = data[prop];
  4253. str = substIndexes(str, args, key, prop);
  4254. str = substArguments(str, args, key);
  4255. rv[prop] = str;
  4256. }
  4257. return rv;
  4258. }
  4259. function substIndexes(str, args, key, prop) {
  4260. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  4261. var reMatch = reIndex.exec(str);
  4262. if (!reMatch || !reMatch.length) return str;
  4263. var macroName = reMatch[1];
  4264. var paramName = reMatch[2];
  4265. var param;
  4266. if (args && paramName in args) {
  4267. param = args[paramName];
  4268. } else if (paramName in gL10nData) {
  4269. param = gL10nData[paramName];
  4270. }
  4271. if (macroName in gMacros) {
  4272. var macro = gMacros[macroName];
  4273. str = macro(str, param, key, prop);
  4274. }
  4275. return str;
  4276. }
  4277. function substArguments(str, args, key) {
  4278. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  4279. return str.replace(reArgs, function (matched_text, arg) {
  4280. if (args && arg in args) {
  4281. return args[arg];
  4282. }
  4283. if (arg in gL10nData) {
  4284. return gL10nData[arg];
  4285. }
  4286. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  4287. return matched_text;
  4288. });
  4289. }
  4290. function translateElement(element) {
  4291. var l10n = getL10nAttributes(element);
  4292. if (!l10n.id) return;
  4293. var data = getL10nData(l10n.id, l10n.args);
  4294. if (!data) {
  4295. console.warn('#' + l10n.id + ' is undefined.');
  4296. return;
  4297. }
  4298. if (data[gTextProp]) {
  4299. if (getChildElementCount(element) === 0) {
  4300. element[gTextProp] = data[gTextProp];
  4301. } else {
  4302. var children = element.childNodes;
  4303. var found = false;
  4304. for (var i = 0, l = children.length; i < l; i++) {
  4305. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  4306. if (found) {
  4307. children[i].nodeValue = '';
  4308. } else {
  4309. children[i].nodeValue = data[gTextProp];
  4310. found = true;
  4311. }
  4312. }
  4313. }
  4314. if (!found) {
  4315. var textNode = document.createTextNode(data[gTextProp]);
  4316. element.insertBefore(textNode, element.firstChild);
  4317. }
  4318. }
  4319. delete data[gTextProp];
  4320. }
  4321. for (var k in data) {
  4322. element[k] = data[k];
  4323. }
  4324. }
  4325. function getChildElementCount(element) {
  4326. if (element.children) {
  4327. return element.children.length;
  4328. }
  4329. if (typeof element.childElementCount !== 'undefined') {
  4330. return element.childElementCount;
  4331. }
  4332. var count = 0;
  4333. for (var i = 0; i < element.childNodes.length; i++) {
  4334. count += element.nodeType === 1 ? 1 : 0;
  4335. }
  4336. return count;
  4337. }
  4338. function translateFragment(element) {
  4339. element = element || document.documentElement;
  4340. var children = getTranslatableChildren(element);
  4341. var elementCount = children.length;
  4342. for (var i = 0; i < elementCount; i++) {
  4343. translateElement(children[i]);
  4344. }
  4345. translateElement(element);
  4346. }
  4347. return {
  4348. get: function get(key, args, fallbackString) {
  4349. var index = key.lastIndexOf('.');
  4350. var prop = gTextProp;
  4351. if (index > 0) {
  4352. prop = key.substr(index + 1);
  4353. key = key.substring(0, index);
  4354. }
  4355. var fallback;
  4356. if (fallbackString) {
  4357. fallback = {};
  4358. fallback[prop] = fallbackString;
  4359. }
  4360. var data = getL10nData(key, args, fallback);
  4361. if (data && prop in data) {
  4362. return data[prop];
  4363. }
  4364. return '{{' + key + '}}';
  4365. },
  4366. getData: function getData() {
  4367. return gL10nData;
  4368. },
  4369. getText: function getText() {
  4370. return gTextData;
  4371. },
  4372. getLanguage: function getLanguage() {
  4373. return gLanguage;
  4374. },
  4375. setLanguage: function setLanguage(lang, callback) {
  4376. loadLocale(lang, function () {
  4377. if (callback) callback();
  4378. });
  4379. },
  4380. getDirection: function getDirection() {
  4381. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  4382. var shortCode = gLanguage.split('-', 1)[0];
  4383. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  4384. },
  4385. translate: translateFragment,
  4386. getReadyState: function getReadyState() {
  4387. return gReadyState;
  4388. },
  4389. ready: function ready(callback) {
  4390. if (!callback) {
  4391. return;
  4392. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  4393. window.setTimeout(function () {
  4394. callback();
  4395. });
  4396. } else if (document.addEventListener) {
  4397. document.addEventListener('localized', function once() {
  4398. document.removeEventListener('localized', once);
  4399. callback();
  4400. });
  4401. }
  4402. }
  4403. };
  4404. }(window, document);
  4405. /***/ }),
  4406. /* 11 */
  4407. /***/ (function(module, exports, __webpack_require__) {
  4408. "use strict";
  4409. Object.defineProperty(exports, "__esModule", {
  4410. value: true
  4411. });
  4412. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
  4413. 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; }; }();
  4414. var _pdfjsLib = __webpack_require__(1);
  4415. var _ui_utils = __webpack_require__(0);
  4416. var _pdf_link_service = __webpack_require__(5);
  4417. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4418. var AnnotationLayerBuilder = function () {
  4419. function AnnotationLayerBuilder(_ref) {
  4420. var pageDiv = _ref.pageDiv,
  4421. pdfPage = _ref.pdfPage,
  4422. linkService = _ref.linkService,
  4423. downloadManager = _ref.downloadManager,
  4424. _ref$renderInteractiv = _ref.renderInteractiveForms,
  4425. renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv,
  4426. _ref$l10n = _ref.l10n,
  4427. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  4428. _classCallCheck(this, AnnotationLayerBuilder);
  4429. this.pageDiv = pageDiv;
  4430. this.pdfPage = pdfPage;
  4431. this.linkService = linkService;
  4432. this.downloadManager = downloadManager;
  4433. this.renderInteractiveForms = renderInteractiveForms;
  4434. this.l10n = l10n;
  4435. this.div = null;
  4436. }
  4437. _createClass(AnnotationLayerBuilder, [{
  4438. key: 'render',
  4439. value: function render(viewport) {
  4440. var _this = this;
  4441. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  4442. this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
  4443. var parameters = {
  4444. viewport: viewport.clone({ dontFlip: true }),
  4445. div: _this.div,
  4446. annotations: annotations,
  4447. page: _this.pdfPage,
  4448. renderInteractiveForms: _this.renderInteractiveForms,
  4449. linkService: _this.linkService,
  4450. downloadManager: _this.downloadManager
  4451. };
  4452. if (_this.div) {
  4453. _pdfjsLib.AnnotationLayer.update(parameters);
  4454. } else {
  4455. if (annotations.length === 0) {
  4456. return;
  4457. }
  4458. _this.div = document.createElement('div');
  4459. _this.div.className = 'annotationLayer';
  4460. _this.pageDiv.appendChild(_this.div);
  4461. parameters.div = _this.div;
  4462. _pdfjsLib.AnnotationLayer.render(parameters);
  4463. _this.l10n.translate(_this.div);
  4464. }
  4465. });
  4466. }
  4467. }, {
  4468. key: 'hide',
  4469. value: function hide() {
  4470. if (!this.div) {
  4471. return;
  4472. }
  4473. this.div.setAttribute('hidden', 'true');
  4474. }
  4475. }]);
  4476. return AnnotationLayerBuilder;
  4477. }();
  4478. var DefaultAnnotationLayerFactory = function () {
  4479. function DefaultAnnotationLayerFactory() {
  4480. _classCallCheck(this, DefaultAnnotationLayerFactory);
  4481. }
  4482. _createClass(DefaultAnnotationLayerFactory, [{
  4483. key: 'createAnnotationLayerBuilder',
  4484. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  4485. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4486. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  4487. return new AnnotationLayerBuilder({
  4488. pageDiv: pageDiv,
  4489. pdfPage: pdfPage,
  4490. renderInteractiveForms: renderInteractiveForms,
  4491. linkService: new _pdf_link_service.SimpleLinkService(),
  4492. l10n: l10n
  4493. });
  4494. }
  4495. }]);
  4496. return DefaultAnnotationLayerFactory;
  4497. }();
  4498. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  4499. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  4500. /***/ }),
  4501. /* 12 */
  4502. /***/ (function(module, exports, __webpack_require__) {
  4503. "use strict";
  4504. Object.defineProperty(exports, "__esModule", {
  4505. value: true
  4506. });
  4507. exports.DownloadManager = undefined;
  4508. 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; }; }();
  4509. var _pdfjsLib = __webpack_require__(1);
  4510. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4511. ;
  4512. function _download(blobUrl, filename) {
  4513. var a = document.createElement('a');
  4514. if (a.click) {
  4515. a.href = blobUrl;
  4516. a.target = '_parent';
  4517. if ('download' in a) {
  4518. a.download = filename;
  4519. }
  4520. (document.body || document.documentElement).appendChild(a);
  4521. a.click();
  4522. a.parentNode.removeChild(a);
  4523. } else {
  4524. if (window.top === window && blobUrl.split('#')[0] === window.location.href.split('#')[0]) {
  4525. var padCharacter = blobUrl.indexOf('?') === -1 ? '?' : '&';
  4526. blobUrl = blobUrl.replace(/#|$/, padCharacter + '$&');
  4527. }
  4528. window.open(blobUrl, '_parent');
  4529. }
  4530. }
  4531. var DownloadManager = function () {
  4532. function DownloadManager() {
  4533. _classCallCheck(this, DownloadManager);
  4534. }
  4535. _createClass(DownloadManager, [{
  4536. key: 'downloadUrl',
  4537. value: function downloadUrl(url, filename) {
  4538. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  4539. return;
  4540. }
  4541. _download(url + '#pdfjs.action=download', filename);
  4542. }
  4543. }, {
  4544. key: 'downloadData',
  4545. value: function downloadData(data, filename, contentType) {
  4546. if (navigator.msSaveBlob) {
  4547. return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
  4548. }
  4549. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _pdfjsLib.PDFJS.disableCreateObjectURL);
  4550. _download(blobUrl, filename);
  4551. }
  4552. }, {
  4553. key: 'download',
  4554. value: function download(blob, url, filename) {
  4555. if (navigator.msSaveBlob) {
  4556. if (!navigator.msSaveBlob(blob, filename)) {
  4557. this.downloadUrl(url, filename);
  4558. }
  4559. return;
  4560. }
  4561. if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
  4562. this.downloadUrl(url, filename);
  4563. return;
  4564. }
  4565. var blobUrl = URL.createObjectURL(blob);
  4566. _download(blobUrl, filename);
  4567. }
  4568. }]);
  4569. return DownloadManager;
  4570. }();
  4571. exports.DownloadManager = DownloadManager;
  4572. /***/ }),
  4573. /* 13 */
  4574. /***/ (function(module, exports, __webpack_require__) {
  4575. "use strict";
  4576. Object.defineProperty(exports, "__esModule", {
  4577. value: true
  4578. });
  4579. exports.GenericL10n = undefined;
  4580. 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; }; }();
  4581. __webpack_require__(10);
  4582. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4583. var webL10n = document.webL10n;
  4584. var GenericL10n = function () {
  4585. function GenericL10n(lang) {
  4586. _classCallCheck(this, GenericL10n);
  4587. this._lang = lang;
  4588. this._ready = new Promise(function (resolve, reject) {
  4589. webL10n.setLanguage(lang, function () {
  4590. resolve(webL10n);
  4591. });
  4592. });
  4593. }
  4594. _createClass(GenericL10n, [{
  4595. key: 'getDirection',
  4596. value: function getDirection() {
  4597. return this._ready.then(function (l10n) {
  4598. return l10n.getDirection();
  4599. });
  4600. }
  4601. }, {
  4602. key: 'get',
  4603. value: function get(property, args, fallback) {
  4604. return this._ready.then(function (l10n) {
  4605. return l10n.get(property, args, fallback);
  4606. });
  4607. }
  4608. }, {
  4609. key: 'translate',
  4610. value: function translate(element) {
  4611. return this._ready.then(function (l10n) {
  4612. return l10n.translate(element);
  4613. });
  4614. }
  4615. }]);
  4616. return GenericL10n;
  4617. }();
  4618. exports.GenericL10n = GenericL10n;
  4619. /***/ }),
  4620. /* 14 */
  4621. /***/ (function(module, exports, __webpack_require__) {
  4622. "use strict";
  4623. Object.defineProperty(exports, "__esModule", {
  4624. value: true
  4625. });
  4626. function GrabToPan(options) {
  4627. this.element = options.element;
  4628. this.document = options.element.ownerDocument;
  4629. if (typeof options.ignoreTarget === 'function') {
  4630. this.ignoreTarget = options.ignoreTarget;
  4631. }
  4632. this.onActiveChanged = options.onActiveChanged;
  4633. this.activate = this.activate.bind(this);
  4634. this.deactivate = this.deactivate.bind(this);
  4635. this.toggle = this.toggle.bind(this);
  4636. this._onmousedown = this._onmousedown.bind(this);
  4637. this._onmousemove = this._onmousemove.bind(this);
  4638. this._endPan = this._endPan.bind(this);
  4639. var overlay = this.overlay = document.createElement('div');
  4640. overlay.className = 'grab-to-pan-grabbing';
  4641. }
  4642. GrabToPan.prototype = {
  4643. CSS_CLASS_GRAB: 'grab-to-pan-grab',
  4644. activate: function GrabToPan_activate() {
  4645. if (!this.active) {
  4646. this.active = true;
  4647. this.element.addEventListener('mousedown', this._onmousedown, true);
  4648. this.element.classList.add(this.CSS_CLASS_GRAB);
  4649. if (this.onActiveChanged) {
  4650. this.onActiveChanged(true);
  4651. }
  4652. }
  4653. },
  4654. deactivate: function GrabToPan_deactivate() {
  4655. if (this.active) {
  4656. this.active = false;
  4657. this.element.removeEventListener('mousedown', this._onmousedown, true);
  4658. this._endPan();
  4659. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4660. if (this.onActiveChanged) {
  4661. this.onActiveChanged(false);
  4662. }
  4663. }
  4664. },
  4665. toggle: function GrabToPan_toggle() {
  4666. if (this.active) {
  4667. this.deactivate();
  4668. } else {
  4669. this.activate();
  4670. }
  4671. },
  4672. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4673. return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option');
  4674. },
  4675. _onmousedown: function GrabToPan__onmousedown(event) {
  4676. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4677. return;
  4678. }
  4679. if (event.originalTarget) {
  4680. try {
  4681. event.originalTarget.tagName;
  4682. } catch (e) {
  4683. return;
  4684. }
  4685. }
  4686. this.scrollLeftStart = this.element.scrollLeft;
  4687. this.scrollTopStart = this.element.scrollTop;
  4688. this.clientXStart = event.clientX;
  4689. this.clientYStart = event.clientY;
  4690. this.document.addEventListener('mousemove', this._onmousemove, true);
  4691. this.document.addEventListener('mouseup', this._endPan, true);
  4692. this.element.addEventListener('scroll', this._endPan, true);
  4693. event.preventDefault();
  4694. event.stopPropagation();
  4695. var focusedElement = document.activeElement;
  4696. if (focusedElement && !focusedElement.contains(event.target)) {
  4697. focusedElement.blur();
  4698. }
  4699. },
  4700. _onmousemove: function GrabToPan__onmousemove(event) {
  4701. this.element.removeEventListener('scroll', this._endPan, true);
  4702. if (isLeftMouseReleased(event)) {
  4703. this._endPan();
  4704. return;
  4705. }
  4706. var xDiff = event.clientX - this.clientXStart;
  4707. var yDiff = event.clientY - this.clientYStart;
  4708. var scrollTop = this.scrollTopStart - yDiff;
  4709. var scrollLeft = this.scrollLeftStart - xDiff;
  4710. if (this.element.scrollTo) {
  4711. this.element.scrollTo({
  4712. top: scrollTop,
  4713. left: scrollLeft,
  4714. behavior: 'instant'
  4715. });
  4716. } else {
  4717. this.element.scrollTop = scrollTop;
  4718. this.element.scrollLeft = scrollLeft;
  4719. }
  4720. if (!this.overlay.parentNode) {
  4721. document.body.appendChild(this.overlay);
  4722. }
  4723. },
  4724. _endPan: function GrabToPan__endPan() {
  4725. this.element.removeEventListener('scroll', this._endPan, true);
  4726. this.document.removeEventListener('mousemove', this._onmousemove, true);
  4727. this.document.removeEventListener('mouseup', this._endPan, true);
  4728. this.overlay.remove();
  4729. }
  4730. };
  4731. var matchesSelector;
  4732. ['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function (prefix) {
  4733. var name = prefix + 'atches';
  4734. if (name in document.documentElement) {
  4735. matchesSelector = name;
  4736. }
  4737. name += 'Selector';
  4738. if (name in document.documentElement) {
  4739. matchesSelector = name;
  4740. }
  4741. return matchesSelector;
  4742. });
  4743. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  4744. var chrome = window.chrome;
  4745. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4746. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  4747. function isLeftMouseReleased(event) {
  4748. if ('buttons' in event && isNotIEorIsIE10plus) {
  4749. return !(event.buttons & 1);
  4750. }
  4751. if (isChrome15OrOpera15plus || isSafari6plus) {
  4752. return event.which === 0;
  4753. }
  4754. }
  4755. exports.GrabToPan = GrabToPan;
  4756. /***/ }),
  4757. /* 15 */
  4758. /***/ (function(module, exports, __webpack_require__) {
  4759. "use strict";
  4760. Object.defineProperty(exports, "__esModule", {
  4761. value: true
  4762. });
  4763. 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; }; }();
  4764. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4765. var OverlayManager = function () {
  4766. function OverlayManager() {
  4767. _classCallCheck(this, OverlayManager);
  4768. this._overlays = {};
  4769. this._active = null;
  4770. this._keyDownBound = this._keyDown.bind(this);
  4771. }
  4772. _createClass(OverlayManager, [{
  4773. key: 'register',
  4774. value: function register(name, element) {
  4775. var _this = this;
  4776. var callerCloseMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4777. var canForceClose = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  4778. return new Promise(function (resolve) {
  4779. var container = void 0;
  4780. if (!name || !element || !(container = element.parentNode)) {
  4781. throw new Error('Not enough parameters.');
  4782. } else if (_this._overlays[name]) {
  4783. throw new Error('The overlay is already registered.');
  4784. }
  4785. _this._overlays[name] = {
  4786. element: element,
  4787. container: container,
  4788. callerCloseMethod: callerCloseMethod,
  4789. canForceClose: canForceClose
  4790. };
  4791. resolve();
  4792. });
  4793. }
  4794. }, {
  4795. key: 'unregister',
  4796. value: function unregister(name) {
  4797. var _this2 = this;
  4798. return new Promise(function (resolve) {
  4799. if (!_this2._overlays[name]) {
  4800. throw new Error('The overlay does not exist.');
  4801. } else if (_this2._active === name) {
  4802. throw new Error('The overlay cannot be removed while it is active.');
  4803. }
  4804. delete _this2._overlays[name];
  4805. resolve();
  4806. });
  4807. }
  4808. }, {
  4809. key: 'open',
  4810. value: function open(name) {
  4811. var _this3 = this;
  4812. return new Promise(function (resolve) {
  4813. if (!_this3._overlays[name]) {
  4814. throw new Error('The overlay does not exist.');
  4815. } else if (_this3._active) {
  4816. if (_this3._overlays[name].canForceClose) {
  4817. _this3._closeThroughCaller();
  4818. } else if (_this3._active === name) {
  4819. throw new Error('The overlay is already active.');
  4820. } else {
  4821. throw new Error('Another overlay is currently active.');
  4822. }
  4823. }
  4824. _this3._active = name;
  4825. _this3._overlays[_this3._active].element.classList.remove('hidden');
  4826. _this3._overlays[_this3._active].container.classList.remove('hidden');
  4827. window.addEventListener('keydown', _this3._keyDownBound);
  4828. resolve();
  4829. });
  4830. }
  4831. }, {
  4832. key: 'close',
  4833. value: function close(name) {
  4834. var _this4 = this;
  4835. return new Promise(function (resolve) {
  4836. if (!_this4._overlays[name]) {
  4837. throw new Error('The overlay does not exist.');
  4838. } else if (!_this4._active) {
  4839. throw new Error('The overlay is currently not active.');
  4840. } else if (_this4._active !== name) {
  4841. throw new Error('Another overlay is currently active.');
  4842. }
  4843. _this4._overlays[_this4._active].container.classList.add('hidden');
  4844. _this4._overlays[_this4._active].element.classList.add('hidden');
  4845. _this4._active = null;
  4846. window.removeEventListener('keydown', _this4._keyDownBound);
  4847. resolve();
  4848. });
  4849. }
  4850. }, {
  4851. key: '_keyDown',
  4852. value: function _keyDown(evt) {
  4853. if (this._active && evt.keyCode === 27) {
  4854. this._closeThroughCaller();
  4855. evt.preventDefault();
  4856. }
  4857. }
  4858. }, {
  4859. key: '_closeThroughCaller',
  4860. value: function _closeThroughCaller() {
  4861. if (this._overlays[this._active].callerCloseMethod) {
  4862. this._overlays[this._active].callerCloseMethod();
  4863. }
  4864. if (this._active) {
  4865. this.close(this._active);
  4866. }
  4867. }
  4868. }, {
  4869. key: 'active',
  4870. get: function get() {
  4871. return this._active;
  4872. }
  4873. }]);
  4874. return OverlayManager;
  4875. }();
  4876. exports.OverlayManager = OverlayManager;
  4877. /***/ }),
  4878. /* 16 */
  4879. /***/ (function(module, exports, __webpack_require__) {
  4880. "use strict";
  4881. Object.defineProperty(exports, "__esModule", {
  4882. value: true
  4883. });
  4884. exports.PasswordPrompt = undefined;
  4885. 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; }; }();
  4886. var _ui_utils = __webpack_require__(0);
  4887. var _pdfjsLib = __webpack_require__(1);
  4888. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4889. var PasswordPrompt = function () {
  4890. function PasswordPrompt(options, overlayManager) {
  4891. var _this = this;
  4892. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  4893. _classCallCheck(this, PasswordPrompt);
  4894. this.overlayName = options.overlayName;
  4895. this.container = options.container;
  4896. this.label = options.label;
  4897. this.input = options.input;
  4898. this.submitButton = options.submitButton;
  4899. this.cancelButton = options.cancelButton;
  4900. this.overlayManager = overlayManager;
  4901. this.l10n = l10n;
  4902. this.updateCallback = null;
  4903. this.reason = null;
  4904. this.submitButton.addEventListener('click', this.verify.bind(this));
  4905. this.cancelButton.addEventListener('click', this.close.bind(this));
  4906. this.input.addEventListener('keydown', function (e) {
  4907. if (e.keyCode === 13) {
  4908. _this.verify();
  4909. }
  4910. });
  4911. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  4912. }
  4913. _createClass(PasswordPrompt, [{
  4914. key: 'open',
  4915. value: function open() {
  4916. var _this2 = this;
  4917. this.overlayManager.open(this.overlayName).then(function () {
  4918. _this2.input.focus();
  4919. var promptString = void 0;
  4920. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  4921. promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
  4922. } else {
  4923. promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
  4924. }
  4925. promptString.then(function (msg) {
  4926. _this2.label.textContent = msg;
  4927. });
  4928. });
  4929. }
  4930. }, {
  4931. key: 'close',
  4932. value: function close() {
  4933. var _this3 = this;
  4934. this.overlayManager.close(this.overlayName).then(function () {
  4935. _this3.input.value = '';
  4936. });
  4937. }
  4938. }, {
  4939. key: 'verify',
  4940. value: function verify() {
  4941. var password = this.input.value;
  4942. if (password && password.length > 0) {
  4943. this.close();
  4944. return this.updateCallback(password);
  4945. }
  4946. }
  4947. }, {
  4948. key: 'setUpdateCallback',
  4949. value: function setUpdateCallback(updateCallback, reason) {
  4950. this.updateCallback = updateCallback;
  4951. this.reason = reason;
  4952. }
  4953. }]);
  4954. return PasswordPrompt;
  4955. }();
  4956. exports.PasswordPrompt = PasswordPrompt;
  4957. /***/ }),
  4958. /* 17 */
  4959. /***/ (function(module, exports, __webpack_require__) {
  4960. "use strict";
  4961. Object.defineProperty(exports, "__esModule", {
  4962. value: true
  4963. });
  4964. exports.PDFAttachmentViewer = undefined;
  4965. 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; }; }();
  4966. var _pdfjsLib = __webpack_require__(1);
  4967. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4968. var PDFAttachmentViewer = function () {
  4969. function PDFAttachmentViewer(_ref) {
  4970. var container = _ref.container,
  4971. eventBus = _ref.eventBus,
  4972. downloadManager = _ref.downloadManager;
  4973. _classCallCheck(this, PDFAttachmentViewer);
  4974. this.attachments = null;
  4975. this.container = container;
  4976. this.eventBus = eventBus;
  4977. this.downloadManager = downloadManager;
  4978. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4979. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
  4980. }
  4981. _createClass(PDFAttachmentViewer, [{
  4982. key: 'reset',
  4983. value: function reset() {
  4984. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4985. this.attachments = null;
  4986. this.container.textContent = '';
  4987. if (!keepRenderedCapability) {
  4988. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4989. }
  4990. }
  4991. }, {
  4992. key: '_dispatchEvent',
  4993. value: function _dispatchEvent(attachmentsCount) {
  4994. this.eventBus.dispatch('attachmentsloaded', {
  4995. source: this,
  4996. attachmentsCount: attachmentsCount
  4997. });
  4998. this._renderedCapability.resolve();
  4999. }
  5000. }, {
  5001. key: '_bindPdfLink',
  5002. value: function _bindPdfLink(button, content, filename) {
  5003. if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
  5004. throw new Error('bindPdfLink: ' + 'Unsupported "PDFJS.disableCreateObjectURL" value.');
  5005. }
  5006. var blobUrl = void 0;
  5007. button.onclick = function () {
  5008. if (!blobUrl) {
  5009. blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf');
  5010. }
  5011. var viewerUrl = void 0;
  5012. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
  5013. window.open(viewerUrl);
  5014. return false;
  5015. };
  5016. }
  5017. }, {
  5018. key: '_bindLink',
  5019. value: function _bindLink(button, content, filename) {
  5020. var _this = this;
  5021. button.onclick = function () {
  5022. _this.downloadManager.downloadData(content, filename, '');
  5023. return false;
  5024. };
  5025. }
  5026. }, {
  5027. key: 'render',
  5028. value: function render(_ref2) {
  5029. var attachments = _ref2.attachments,
  5030. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  5031. keepRenderedCapability = _ref2$keepRenderedCap === undefined ? false : _ref2$keepRenderedCap;
  5032. var attachmentsCount = 0;
  5033. if (this.attachments) {
  5034. this.reset(keepRenderedCapability === true);
  5035. }
  5036. this.attachments = attachments || null;
  5037. if (!attachments) {
  5038. this._dispatchEvent(attachmentsCount);
  5039. return;
  5040. }
  5041. var names = Object.keys(attachments).sort(function (a, b) {
  5042. return a.toLowerCase().localeCompare(b.toLowerCase());
  5043. });
  5044. attachmentsCount = names.length;
  5045. for (var i = 0; i < attachmentsCount; i++) {
  5046. var item = attachments[names[i]];
  5047. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  5048. var div = document.createElement('div');
  5049. div.className = 'attachmentsItem';
  5050. var button = document.createElement('button');
  5051. button.textContent = filename;
  5052. if (/\.pdf$/i.test(filename) && !_pdfjsLib.PDFJS.disableCreateObjectURL) {
  5053. this._bindPdfLink(button, item.content, filename);
  5054. } else {
  5055. this._bindLink(button, item.content, filename);
  5056. }
  5057. div.appendChild(button);
  5058. this.container.appendChild(div);
  5059. }
  5060. this._dispatchEvent(attachmentsCount);
  5061. }
  5062. }, {
  5063. key: '_appendAttachment',
  5064. value: function _appendAttachment(_ref3) {
  5065. var _this2 = this;
  5066. var id = _ref3.id,
  5067. filename = _ref3.filename,
  5068. content = _ref3.content;
  5069. this._renderedCapability.promise.then(function () {
  5070. var attachments = _this2.attachments;
  5071. if (!attachments) {
  5072. attachments = Object.create(null);
  5073. } else {
  5074. for (var name in attachments) {
  5075. if (id === name) {
  5076. return;
  5077. }
  5078. }
  5079. }
  5080. attachments[id] = {
  5081. filename: filename,
  5082. content: content
  5083. };
  5084. _this2.render({
  5085. attachments: attachments,
  5086. keepRenderedCapability: true
  5087. });
  5088. });
  5089. }
  5090. }]);
  5091. return PDFAttachmentViewer;
  5092. }();
  5093. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5094. /***/ }),
  5095. /* 18 */
  5096. /***/ (function(module, exports, __webpack_require__) {
  5097. "use strict";
  5098. Object.defineProperty(exports, "__esModule", {
  5099. value: true
  5100. });
  5101. exports.PDFDocumentProperties = undefined;
  5102. 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"); } }; }();
  5103. 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; }; }();
  5104. var _ui_utils = __webpack_require__(0);
  5105. var _pdfjsLib = __webpack_require__(1);
  5106. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5107. var DEFAULT_FIELD_CONTENT = '-';
  5108. var PDFDocumentProperties = function () {
  5109. function PDFDocumentProperties(_ref, overlayManager) {
  5110. var overlayName = _ref.overlayName,
  5111. fields = _ref.fields,
  5112. container = _ref.container,
  5113. closeButton = _ref.closeButton;
  5114. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5115. _classCallCheck(this, PDFDocumentProperties);
  5116. this.overlayName = overlayName;
  5117. this.fields = fields;
  5118. this.container = container;
  5119. this.overlayManager = overlayManager;
  5120. this.l10n = l10n;
  5121. this._reset();
  5122. if (closeButton) {
  5123. closeButton.addEventListener('click', this.close.bind(this));
  5124. }
  5125. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5126. }
  5127. _createClass(PDFDocumentProperties, [{
  5128. key: 'open',
  5129. value: function open() {
  5130. var _this = this;
  5131. var freezeFieldData = function freezeFieldData(data) {
  5132. Object.defineProperty(_this, 'fieldData', {
  5133. value: Object.freeze(data),
  5134. writable: false,
  5135. enumerable: true,
  5136. configurable: true
  5137. });
  5138. };
  5139. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  5140. if (_this.fieldData) {
  5141. _this._updateUI();
  5142. return;
  5143. }
  5144. _this.pdfDocument.getMetadata().then(function (_ref2) {
  5145. var info = _ref2.info,
  5146. metadata = _ref2.metadata;
  5147. return Promise.all([info, metadata, _this._parseFileSize(_this.maybeFileSize), _this._parseDate(info.CreationDate), _this._parseDate(info.ModDate)]);
  5148. }).then(function (_ref3) {
  5149. var _ref4 = _slicedToArray(_ref3, 5),
  5150. info = _ref4[0],
  5151. metadata = _ref4[1],
  5152. fileSize = _ref4[2],
  5153. creationDate = _ref4[3],
  5154. modificationDate = _ref4[4];
  5155. freezeFieldData({
  5156. 'fileName': (0, _ui_utils.getPDFFileNameFromURL)(_this.url),
  5157. 'fileSize': fileSize,
  5158. 'title': info.Title,
  5159. 'author': info.Author,
  5160. 'subject': info.Subject,
  5161. 'keywords': info.Keywords,
  5162. 'creationDate': creationDate,
  5163. 'modificationDate': modificationDate,
  5164. 'creator': info.Creator,
  5165. 'producer': info.Producer,
  5166. 'version': info.PDFFormatVersion,
  5167. 'pageCount': _this.pdfDocument.numPages
  5168. });
  5169. _this._updateUI();
  5170. return _this.pdfDocument.getDownloadInfo();
  5171. }).then(function (_ref5) {
  5172. var length = _ref5.length;
  5173. return _this._parseFileSize(length);
  5174. }).then(function (fileSize) {
  5175. var data = (0, _ui_utils.cloneObj)(_this.fieldData);
  5176. data['fileSize'] = fileSize;
  5177. freezeFieldData(data);
  5178. _this._updateUI();
  5179. });
  5180. });
  5181. }
  5182. }, {
  5183. key: 'close',
  5184. value: function close() {
  5185. this.overlayManager.close(this.overlayName);
  5186. }
  5187. }, {
  5188. key: 'setDocument',
  5189. value: function setDocument(pdfDocument, url) {
  5190. if (this.pdfDocument) {
  5191. this._reset();
  5192. this._updateUI(true);
  5193. }
  5194. if (!pdfDocument) {
  5195. return;
  5196. }
  5197. this.pdfDocument = pdfDocument;
  5198. this.url = url;
  5199. this._dataAvailableCapability.resolve();
  5200. }
  5201. }, {
  5202. key: 'setFileSize',
  5203. value: function setFileSize(fileSize) {
  5204. if (typeof fileSize === 'number' && fileSize > 0) {
  5205. this.maybeFileSize = fileSize;
  5206. }
  5207. }
  5208. }, {
  5209. key: '_reset',
  5210. value: function _reset() {
  5211. this.pdfDocument = null;
  5212. this.url = null;
  5213. this.maybeFileSize = 0;
  5214. delete this.fieldData;
  5215. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5216. }
  5217. }, {
  5218. key: '_updateUI',
  5219. value: function _updateUI() {
  5220. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5221. if (reset || !this.fieldData) {
  5222. for (var id in this.fields) {
  5223. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5224. }
  5225. return;
  5226. }
  5227. if (this.overlayManager.active !== this.overlayName) {
  5228. return;
  5229. }
  5230. for (var _id in this.fields) {
  5231. var content = this.fieldData[_id];
  5232. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5233. }
  5234. }
  5235. }, {
  5236. key: '_parseFileSize',
  5237. value: function _parseFileSize() {
  5238. var fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  5239. var kb = fileSize / 1024;
  5240. if (!kb) {
  5241. return Promise.resolve(undefined);
  5242. } else if (kb < 1024) {
  5243. return this.l10n.get('document_properties_kb', {
  5244. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5245. size_b: fileSize.toLocaleString()
  5246. }, '{{size_kb}} KB ({{size_b}} bytes)');
  5247. }
  5248. return this.l10n.get('document_properties_mb', {
  5249. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5250. size_b: fileSize.toLocaleString()
  5251. }, '{{size_mb}} MB ({{size_b}} bytes)');
  5252. }
  5253. }, {
  5254. key: '_parseDate',
  5255. value: function _parseDate(inputDate) {
  5256. if (!inputDate) {
  5257. return;
  5258. }
  5259. var dateToParse = inputDate;
  5260. if (dateToParse.substring(0, 2) === 'D:') {
  5261. dateToParse = dateToParse.substring(2);
  5262. }
  5263. var year = parseInt(dateToParse.substring(0, 4), 10);
  5264. var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
  5265. var day = parseInt(dateToParse.substring(6, 8), 10);
  5266. var hours = parseInt(dateToParse.substring(8, 10), 10);
  5267. var minutes = parseInt(dateToParse.substring(10, 12), 10);
  5268. var seconds = parseInt(dateToParse.substring(12, 14), 10);
  5269. var utRel = dateToParse.substring(14, 15);
  5270. var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
  5271. var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
  5272. if (utRel === '-') {
  5273. hours += offsetHours;
  5274. minutes += offsetMinutes;
  5275. } else if (utRel === '+') {
  5276. hours -= offsetHours;
  5277. minutes -= offsetMinutes;
  5278. }
  5279. var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
  5280. var dateString = date.toLocaleDateString();
  5281. var timeString = date.toLocaleTimeString();
  5282. return this.l10n.get('document_properties_date_string', {
  5283. date: dateString,
  5284. time: timeString
  5285. }, '{{date}}, {{time}}');
  5286. }
  5287. }]);
  5288. return PDFDocumentProperties;
  5289. }();
  5290. exports.PDFDocumentProperties = PDFDocumentProperties;
  5291. /***/ }),
  5292. /* 19 */
  5293. /***/ (function(module, exports, __webpack_require__) {
  5294. "use strict";
  5295. Object.defineProperty(exports, "__esModule", {
  5296. value: true
  5297. });
  5298. exports.PDFFindBar = undefined;
  5299. 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; }; }();
  5300. var _pdf_find_controller = __webpack_require__(7);
  5301. var _ui_utils = __webpack_require__(0);
  5302. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5303. var PDFFindBar = function () {
  5304. function PDFFindBar(options) {
  5305. var _this = this;
  5306. var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
  5307. _classCallCheck(this, PDFFindBar);
  5308. this.opened = false;
  5309. this.bar = options.bar || null;
  5310. this.toggleButton = options.toggleButton || null;
  5311. this.findField = options.findField || null;
  5312. this.highlightAll = options.highlightAllCheckbox || null;
  5313. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5314. this.findMsg = options.findMsg || null;
  5315. this.findResultsCount = options.findResultsCount || null;
  5316. this.findStatusIcon = options.findStatusIcon || null;
  5317. this.findPreviousButton = options.findPreviousButton || null;
  5318. this.findNextButton = options.findNextButton || null;
  5319. this.findController = options.findController || null;
  5320. this.eventBus = options.eventBus;
  5321. this.l10n = l10n;
  5322. if (this.findController === null) {
  5323. throw new Error('PDFFindBar cannot be used without a ' + 'PDFFindController instance.');
  5324. }
  5325. this.toggleButton.addEventListener('click', function () {
  5326. _this.toggle();
  5327. });
  5328. this.findField.addEventListener('input', function () {
  5329. _this.dispatchEvent('');
  5330. });
  5331. this.bar.addEventListener('keydown', function (e) {
  5332. switch (e.keyCode) {
  5333. case 13:
  5334. if (e.target === _this.findField) {
  5335. _this.dispatchEvent('again', e.shiftKey);
  5336. }
  5337. break;
  5338. case 27:
  5339. _this.close();
  5340. break;
  5341. }
  5342. });
  5343. this.findPreviousButton.addEventListener('click', function () {
  5344. _this.dispatchEvent('again', true);
  5345. });
  5346. this.findNextButton.addEventListener('click', function () {
  5347. _this.dispatchEvent('again', false);
  5348. });
  5349. this.highlightAll.addEventListener('click', function () {
  5350. _this.dispatchEvent('highlightallchange');
  5351. });
  5352. this.caseSensitive.addEventListener('click', function () {
  5353. _this.dispatchEvent('casesensitivitychange');
  5354. });
  5355. this.eventBus.on('resize', this._adjustWidth.bind(this));
  5356. }
  5357. _createClass(PDFFindBar, [{
  5358. key: 'reset',
  5359. value: function reset() {
  5360. this.updateUIState();
  5361. }
  5362. }, {
  5363. key: 'dispatchEvent',
  5364. value: function dispatchEvent(type, findPrev) {
  5365. this.eventBus.dispatch('find', {
  5366. source: this,
  5367. type: type,
  5368. query: this.findField.value,
  5369. caseSensitive: this.caseSensitive.checked,
  5370. phraseSearch: true,
  5371. highlightAll: this.highlightAll.checked,
  5372. findPrevious: findPrev
  5373. });
  5374. }
  5375. }, {
  5376. key: 'updateUIState',
  5377. value: function updateUIState(state, previous, matchCount) {
  5378. var _this2 = this;
  5379. var notFound = false;
  5380. var findMsg = '';
  5381. var status = '';
  5382. switch (state) {
  5383. case _pdf_find_controller.FindState.FOUND:
  5384. break;
  5385. case _pdf_find_controller.FindState.PENDING:
  5386. status = 'pending';
  5387. break;
  5388. case _pdf_find_controller.FindState.NOT_FOUND:
  5389. findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
  5390. notFound = true;
  5391. break;
  5392. case _pdf_find_controller.FindState.WRAPPED:
  5393. if (previous) {
  5394. findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
  5395. } else {
  5396. findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
  5397. }
  5398. break;
  5399. }
  5400. if (notFound) {
  5401. this.findField.classList.add('notFound');
  5402. } else {
  5403. this.findField.classList.remove('notFound');
  5404. }
  5405. this.findField.setAttribute('data-status', status);
  5406. Promise.resolve(findMsg).then(function (msg) {
  5407. _this2.findMsg.textContent = msg;
  5408. _this2._adjustWidth();
  5409. });
  5410. this.updateResultsCount(matchCount);
  5411. }
  5412. }, {
  5413. key: 'updateResultsCount',
  5414. value: function updateResultsCount(matchCount) {
  5415. if (!this.findResultsCount) {
  5416. return;
  5417. }
  5418. if (!matchCount) {
  5419. this.findResultsCount.classList.add('hidden');
  5420. this.findResultsCount.textContent = '';
  5421. } else {
  5422. this.findResultsCount.textContent = matchCount.toLocaleString();
  5423. this.findResultsCount.classList.remove('hidden');
  5424. }
  5425. this._adjustWidth();
  5426. }
  5427. }, {
  5428. key: 'open',
  5429. value: function open() {
  5430. if (!this.opened) {
  5431. this.opened = true;
  5432. this.toggleButton.classList.add('toggled');
  5433. this.bar.classList.remove('hidden');
  5434. }
  5435. this.findField.select();
  5436. this.findField.focus();
  5437. this._adjustWidth();
  5438. }
  5439. }, {
  5440. key: 'close',
  5441. value: function close() {
  5442. if (!this.opened) {
  5443. return;
  5444. }
  5445. this.opened = false;
  5446. this.toggleButton.classList.remove('toggled');
  5447. this.bar.classList.add('hidden');
  5448. this.findController.active = false;
  5449. }
  5450. }, {
  5451. key: 'toggle',
  5452. value: function toggle() {
  5453. if (this.opened) {
  5454. this.close();
  5455. } else {
  5456. this.open();
  5457. }
  5458. }
  5459. }, {
  5460. key: '_adjustWidth',
  5461. value: function _adjustWidth() {
  5462. if (!this.opened) {
  5463. return;
  5464. }
  5465. this.bar.classList.remove('wrapContainers');
  5466. var findbarHeight = this.bar.clientHeight;
  5467. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5468. if (findbarHeight > inputContainerHeight) {
  5469. this.bar.classList.add('wrapContainers');
  5470. }
  5471. }
  5472. }]);
  5473. return PDFFindBar;
  5474. }();
  5475. exports.PDFFindBar = PDFFindBar;
  5476. /***/ }),
  5477. /* 20 */
  5478. /***/ (function(module, exports, __webpack_require__) {
  5479. "use strict";
  5480. Object.defineProperty(exports, "__esModule", {
  5481. value: true
  5482. });
  5483. exports.PDFHistory = undefined;
  5484. var _dom_events = __webpack_require__(2);
  5485. function PDFHistory(options) {
  5486. this.linkService = options.linkService;
  5487. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  5488. this.initialized = false;
  5489. this.initialDestination = null;
  5490. this.initialBookmark = null;
  5491. }
  5492. PDFHistory.prototype = {
  5493. initialize: function pdfHistoryInitialize(fingerprint) {
  5494. this.initialized = true;
  5495. this.reInitialized = false;
  5496. this.allowHashChange = true;
  5497. this.historyUnlocked = true;
  5498. this.isViewerInPresentationMode = false;
  5499. this.previousHash = window.location.hash.substring(1);
  5500. this.currentBookmark = '';
  5501. this.currentPage = 0;
  5502. this.updatePreviousBookmark = false;
  5503. this.previousBookmark = '';
  5504. this.previousPage = 0;
  5505. this.nextHashParam = '';
  5506. this.fingerprint = fingerprint;
  5507. this.currentUid = this.uid = 0;
  5508. this.current = {};
  5509. var state = window.history.state;
  5510. if (this._isStateObjectDefined(state)) {
  5511. if (state.target.dest) {
  5512. this.initialDestination = state.target.dest;
  5513. } else {
  5514. this.initialBookmark = state.target.hash;
  5515. }
  5516. this.currentUid = state.uid;
  5517. this.uid = state.uid + 1;
  5518. this.current = state.target;
  5519. } else {
  5520. if (state && state.fingerprint && this.fingerprint !== state.fingerprint) {
  5521. this.reInitialized = true;
  5522. }
  5523. this._pushOrReplaceState({ fingerprint: this.fingerprint }, true);
  5524. }
  5525. var self = this;
  5526. window.addEventListener('popstate', function pdfHistoryPopstate(evt) {
  5527. if (!self.historyUnlocked) {
  5528. return;
  5529. }
  5530. if (evt.state) {
  5531. self._goTo(evt.state);
  5532. return;
  5533. }
  5534. if (self.uid === 0) {
  5535. var previousParams = self.previousHash && self.currentBookmark && self.previousHash !== self.currentBookmark ? {
  5536. hash: self.currentBookmark,
  5537. page: self.currentPage
  5538. } : { page: 1 };
  5539. replacePreviousHistoryState(previousParams, function () {
  5540. updateHistoryWithCurrentHash();
  5541. });
  5542. } else {
  5543. updateHistoryWithCurrentHash();
  5544. }
  5545. });
  5546. function updateHistoryWithCurrentHash() {
  5547. self.previousHash = window.location.hash.slice(1);
  5548. self._pushToHistory({ hash: self.previousHash }, false, true);
  5549. self._updatePreviousBookmark();
  5550. }
  5551. function replacePreviousHistoryState(params, callback) {
  5552. self.historyUnlocked = false;
  5553. self.allowHashChange = false;
  5554. window.addEventListener('popstate', rewriteHistoryAfterBack);
  5555. history.back();
  5556. function rewriteHistoryAfterBack() {
  5557. window.removeEventListener('popstate', rewriteHistoryAfterBack);
  5558. window.addEventListener('popstate', rewriteHistoryAfterForward);
  5559. self._pushToHistory(params, false, true);
  5560. history.forward();
  5561. }
  5562. function rewriteHistoryAfterForward() {
  5563. window.removeEventListener('popstate', rewriteHistoryAfterForward);
  5564. self.allowHashChange = true;
  5565. self.historyUnlocked = true;
  5566. callback();
  5567. }
  5568. }
  5569. function pdfHistoryBeforeUnload() {
  5570. var previousParams = self._getPreviousParams(null, true);
  5571. if (previousParams) {
  5572. var replacePrevious = !self.current.dest && self.current.hash !== self.previousHash;
  5573. self._pushToHistory(previousParams, false, replacePrevious);
  5574. self._updatePreviousBookmark();
  5575. }
  5576. window.removeEventListener('beforeunload', pdfHistoryBeforeUnload);
  5577. }
  5578. window.addEventListener('beforeunload', pdfHistoryBeforeUnload);
  5579. window.addEventListener('pageshow', function pdfHistoryPageShow(evt) {
  5580. window.addEventListener('beforeunload', pdfHistoryBeforeUnload);
  5581. });
  5582. self.eventBus.on('presentationmodechanged', function (e) {
  5583. self.isViewerInPresentationMode = e.active;
  5584. });
  5585. },
  5586. clearHistoryState: function pdfHistory_clearHistoryState() {
  5587. this._pushOrReplaceState(null, true);
  5588. },
  5589. _isStateObjectDefined: function pdfHistory_isStateObjectDefined(state) {
  5590. return state && state.uid >= 0 && state.fingerprint && this.fingerprint === state.fingerprint && state.target && state.target.hash ? true : false;
  5591. },
  5592. _pushOrReplaceState: function pdfHistory_pushOrReplaceState(stateObj, replace) {
  5593. if (replace) {
  5594. window.history.replaceState(stateObj, '', document.URL);
  5595. } else {
  5596. window.history.pushState(stateObj, '', document.URL);
  5597. }
  5598. },
  5599. get isHashChangeUnlocked() {
  5600. if (!this.initialized) {
  5601. return true;
  5602. }
  5603. return this.allowHashChange;
  5604. },
  5605. _updatePreviousBookmark: function pdfHistory_updatePreviousBookmark() {
  5606. if (this.updatePreviousBookmark && this.currentBookmark && this.currentPage) {
  5607. this.previousBookmark = this.currentBookmark;
  5608. this.previousPage = this.currentPage;
  5609. this.updatePreviousBookmark = false;
  5610. }
  5611. },
  5612. updateCurrentBookmark: function pdfHistoryUpdateCurrentBookmark(bookmark, pageNum) {
  5613. if (this.initialized) {
  5614. this.currentBookmark = bookmark.substring(1);
  5615. this.currentPage = pageNum | 0;
  5616. this._updatePreviousBookmark();
  5617. }
  5618. },
  5619. updateNextHashParam: function pdfHistoryUpdateNextHashParam(param) {
  5620. if (this.initialized) {
  5621. this.nextHashParam = param;
  5622. }
  5623. },
  5624. push: function pdfHistoryPush(params, isInitialBookmark) {
  5625. if (!(this.initialized && this.historyUnlocked)) {
  5626. return;
  5627. }
  5628. if (params.dest && !params.hash) {
  5629. params.hash = this.current.hash && this.current.dest && this.current.dest === params.dest ? this.current.hash : this.linkService.getDestinationHash(params.dest).split('#')[1];
  5630. }
  5631. if (params.page) {
  5632. params.page |= 0;
  5633. }
  5634. if (isInitialBookmark) {
  5635. var target = window.history.state.target;
  5636. if (!target) {
  5637. this._pushToHistory(params, false);
  5638. this.previousHash = window.location.hash.substring(1);
  5639. }
  5640. this.updatePreviousBookmark = this.nextHashParam ? false : true;
  5641. if (target) {
  5642. this._updatePreviousBookmark();
  5643. }
  5644. return;
  5645. }
  5646. if (this.nextHashParam) {
  5647. if (this.nextHashParam === params.hash) {
  5648. this.nextHashParam = null;
  5649. this.updatePreviousBookmark = true;
  5650. return;
  5651. }
  5652. this.nextHashParam = null;
  5653. }
  5654. if (params.hash) {
  5655. if (this.current.hash) {
  5656. if (this.current.hash !== params.hash) {
  5657. this._pushToHistory(params, true);
  5658. } else {
  5659. if (!this.current.page && params.page) {
  5660. this._pushToHistory(params, false, true);
  5661. }
  5662. this.updatePreviousBookmark = true;
  5663. }
  5664. } else {
  5665. this._pushToHistory(params, true);
  5666. }
  5667. } else if (this.current.page && params.page && this.current.page !== params.page) {
  5668. this._pushToHistory(params, true);
  5669. }
  5670. },
  5671. _getPreviousParams: function pdfHistory_getPreviousParams(onlyCheckPage, beforeUnload) {
  5672. if (!(this.currentBookmark && this.currentPage)) {
  5673. return null;
  5674. } else if (this.updatePreviousBookmark) {
  5675. this.updatePreviousBookmark = false;
  5676. }
  5677. if (this.uid > 0 && !(this.previousBookmark && this.previousPage)) {
  5678. return null;
  5679. }
  5680. if (!this.current.dest && !onlyCheckPage || beforeUnload) {
  5681. if (this.previousBookmark === this.currentBookmark) {
  5682. return null;
  5683. }
  5684. } else if (this.current.page || onlyCheckPage) {
  5685. if (this.previousPage === this.currentPage) {
  5686. return null;
  5687. }
  5688. } else {
  5689. return null;
  5690. }
  5691. var params = {
  5692. hash: this.currentBookmark,
  5693. page: this.currentPage
  5694. };
  5695. if (this.isViewerInPresentationMode) {
  5696. params.hash = null;
  5697. }
  5698. return params;
  5699. },
  5700. _stateObj: function pdfHistory_stateObj(params) {
  5701. return {
  5702. fingerprint: this.fingerprint,
  5703. uid: this.uid,
  5704. target: params
  5705. };
  5706. },
  5707. _pushToHistory: function pdfHistory_pushToHistory(params, addPrevious, overwrite) {
  5708. if (!this.initialized) {
  5709. return;
  5710. }
  5711. if (!params.hash && params.page) {
  5712. params.hash = 'page=' + params.page;
  5713. }
  5714. if (addPrevious && !overwrite) {
  5715. var previousParams = this._getPreviousParams();
  5716. if (previousParams) {
  5717. var replacePrevious = !this.current.dest && this.current.hash !== this.previousHash;
  5718. this._pushToHistory(previousParams, false, replacePrevious);
  5719. }
  5720. }
  5721. this._pushOrReplaceState(this._stateObj(params), overwrite || this.uid === 0);
  5722. this.currentUid = this.uid++;
  5723. this.current = params;
  5724. this.updatePreviousBookmark = true;
  5725. },
  5726. _goTo: function pdfHistory_goTo(state) {
  5727. if (!(this.initialized && this.historyUnlocked && this._isStateObjectDefined(state))) {
  5728. return;
  5729. }
  5730. if (!this.reInitialized && state.uid < this.currentUid) {
  5731. var previousParams = this._getPreviousParams(true);
  5732. if (previousParams) {
  5733. this._pushToHistory(this.current, false);
  5734. this._pushToHistory(previousParams, false);
  5735. this.currentUid = state.uid;
  5736. window.history.back();
  5737. return;
  5738. }
  5739. }
  5740. this.historyUnlocked = false;
  5741. if (state.target.dest) {
  5742. this.linkService.navigateTo(state.target.dest);
  5743. } else {
  5744. this.linkService.setHash(state.target.hash);
  5745. }
  5746. this.currentUid = state.uid;
  5747. if (state.uid > this.uid) {
  5748. this.uid = state.uid;
  5749. }
  5750. this.current = state.target;
  5751. this.updatePreviousBookmark = true;
  5752. var currentHash = window.location.hash.substring(1);
  5753. if (this.previousHash !== currentHash) {
  5754. this.allowHashChange = false;
  5755. }
  5756. this.previousHash = currentHash;
  5757. this.historyUnlocked = true;
  5758. },
  5759. back: function pdfHistoryBack() {
  5760. this.go(-1);
  5761. },
  5762. forward: function pdfHistoryForward() {
  5763. this.go(1);
  5764. },
  5765. go: function pdfHistoryGo(direction) {
  5766. if (this.initialized && this.historyUnlocked) {
  5767. var state = window.history.state;
  5768. if (direction === -1 && state && state.uid > 0) {
  5769. window.history.back();
  5770. } else if (direction === 1 && state && state.uid < this.uid - 1) {
  5771. window.history.forward();
  5772. }
  5773. }
  5774. }
  5775. };
  5776. exports.PDFHistory = PDFHistory;
  5777. /***/ }),
  5778. /* 21 */
  5779. /***/ (function(module, exports, __webpack_require__) {
  5780. "use strict";
  5781. Object.defineProperty(exports, "__esModule", {
  5782. value: true
  5783. });
  5784. exports.PDFOutlineViewer = undefined;
  5785. 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; }; }();
  5786. var _pdfjsLib = __webpack_require__(1);
  5787. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5788. var DEFAULT_TITLE = '\u2013';
  5789. var PDFOutlineViewer = function () {
  5790. function PDFOutlineViewer(_ref) {
  5791. var container = _ref.container,
  5792. linkService = _ref.linkService,
  5793. eventBus = _ref.eventBus;
  5794. _classCallCheck(this, PDFOutlineViewer);
  5795. this.outline = null;
  5796. this.lastToggleIsShow = true;
  5797. this.container = container;
  5798. this.linkService = linkService;
  5799. this.eventBus = eventBus;
  5800. }
  5801. _createClass(PDFOutlineViewer, [{
  5802. key: 'reset',
  5803. value: function reset() {
  5804. this.outline = null;
  5805. this.lastToggleIsShow = true;
  5806. this.container.textContent = '';
  5807. this.container.classList.remove('outlineWithDeepNesting');
  5808. }
  5809. }, {
  5810. key: '_dispatchEvent',
  5811. value: function _dispatchEvent(outlineCount) {
  5812. this.eventBus.dispatch('outlineloaded', {
  5813. source: this,
  5814. outlineCount: outlineCount
  5815. });
  5816. }
  5817. }, {
  5818. key: '_bindLink',
  5819. value: function _bindLink(element, item) {
  5820. var _this = this;
  5821. if (item.url) {
  5822. (0, _pdfjsLib.addLinkAttributes)(element, {
  5823. url: item.url,
  5824. target: item.newWindow ? _pdfjsLib.PDFJS.LinkTarget.BLANK : undefined
  5825. });
  5826. return;
  5827. }
  5828. var destination = item.dest;
  5829. element.href = this.linkService.getDestinationHash(destination);
  5830. element.onclick = function () {
  5831. if (destination) {
  5832. _this.linkService.navigateTo(destination);
  5833. }
  5834. return false;
  5835. };
  5836. }
  5837. }, {
  5838. key: '_setStyles',
  5839. value: function _setStyles(element, item) {
  5840. var styleStr = '';
  5841. if (item.bold) {
  5842. styleStr += 'font-weight: bold;';
  5843. }
  5844. if (item.italic) {
  5845. styleStr += 'font-style: italic;';
  5846. }
  5847. if (styleStr) {
  5848. element.setAttribute('style', styleStr);
  5849. }
  5850. }
  5851. }, {
  5852. key: '_addToggleButton',
  5853. value: function _addToggleButton(div) {
  5854. var _this2 = this;
  5855. var toggler = document.createElement('div');
  5856. toggler.className = 'outlineItemToggler';
  5857. toggler.onclick = function (evt) {
  5858. evt.stopPropagation();
  5859. toggler.classList.toggle('outlineItemsHidden');
  5860. if (evt.shiftKey) {
  5861. var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
  5862. _this2._toggleOutlineItem(div, shouldShowAll);
  5863. }
  5864. };
  5865. div.insertBefore(toggler, div.firstChild);
  5866. }
  5867. }, {
  5868. key: '_toggleOutlineItem',
  5869. value: function _toggleOutlineItem(root, show) {
  5870. this.lastToggleIsShow = show;
  5871. var togglers = root.querySelectorAll('.outlineItemToggler');
  5872. for (var i = 0, ii = togglers.length; i < ii; ++i) {
  5873. togglers[i].classList[show ? 'remove' : 'add']('outlineItemsHidden');
  5874. }
  5875. }
  5876. }, {
  5877. key: 'toggleOutlineTree',
  5878. value: function toggleOutlineTree() {
  5879. if (!this.outline) {
  5880. return;
  5881. }
  5882. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  5883. }
  5884. }, {
  5885. key: 'render',
  5886. value: function render(_ref2) {
  5887. var outline = _ref2.outline;
  5888. var outlineCount = 0;
  5889. if (this.outline) {
  5890. this.reset();
  5891. }
  5892. this.outline = outline || null;
  5893. if (!outline) {
  5894. this._dispatchEvent(outlineCount);
  5895. return;
  5896. }
  5897. var fragment = document.createDocumentFragment();
  5898. var queue = [{
  5899. parent: fragment,
  5900. items: this.outline
  5901. }];
  5902. var hasAnyNesting = false;
  5903. while (queue.length > 0) {
  5904. var levelData = queue.shift();
  5905. for (var i = 0, len = levelData.items.length; i < len; i++) {
  5906. var item = levelData.items[i];
  5907. var div = document.createElement('div');
  5908. div.className = 'outlineItem';
  5909. var element = document.createElement('a');
  5910. this._bindLink(element, item);
  5911. this._setStyles(element, item);
  5912. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  5913. div.appendChild(element);
  5914. if (item.items.length > 0) {
  5915. hasAnyNesting = true;
  5916. this._addToggleButton(div);
  5917. var itemsDiv = document.createElement('div');
  5918. itemsDiv.className = 'outlineItems';
  5919. div.appendChild(itemsDiv);
  5920. queue.push({
  5921. parent: itemsDiv,
  5922. items: item.items
  5923. });
  5924. }
  5925. levelData.parent.appendChild(div);
  5926. outlineCount++;
  5927. }
  5928. }
  5929. if (hasAnyNesting) {
  5930. this.container.classList.add('outlineWithDeepNesting');
  5931. }
  5932. this.container.appendChild(fragment);
  5933. this._dispatchEvent(outlineCount);
  5934. }
  5935. }]);
  5936. return PDFOutlineViewer;
  5937. }();
  5938. exports.PDFOutlineViewer = PDFOutlineViewer;
  5939. /***/ }),
  5940. /* 22 */
  5941. /***/ (function(module, exports, __webpack_require__) {
  5942. "use strict";
  5943. Object.defineProperty(exports, "__esModule", {
  5944. value: true
  5945. });
  5946. exports.PDFPageView = undefined;
  5947. 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; }; }();
  5948. var _ui_utils = __webpack_require__(0);
  5949. var _pdfjsLib = __webpack_require__(1);
  5950. var _dom_events = __webpack_require__(2);
  5951. var _pdf_rendering_queue = __webpack_require__(3);
  5952. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5953. var PDFPageView = function () {
  5954. function PDFPageView(options) {
  5955. _classCallCheck(this, PDFPageView);
  5956. var container = options.container;
  5957. var defaultViewport = options.defaultViewport;
  5958. this.id = options.id;
  5959. this.renderingId = 'page' + this.id;
  5960. this.pdfPage = null;
  5961. this.pageLabel = null;
  5962. this.rotation = 0;
  5963. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  5964. this.viewport = defaultViewport;
  5965. this.pdfPageRotate = defaultViewport.rotation;
  5966. this.hasRestrictedScaling = false;
  5967. this.enhanceTextSelection = options.enhanceTextSelection || false;
  5968. this.renderInteractiveForms = options.renderInteractiveForms || false;
  5969. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  5970. this.renderingQueue = options.renderingQueue;
  5971. this.textLayerFactory = options.textLayerFactory;
  5972. this.annotationLayerFactory = options.annotationLayerFactory;
  5973. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  5974. this.l10n = options.l10n || _ui_utils.NullL10n;
  5975. this.paintTask = null;
  5976. this.paintedViewportMap = new WeakMap();
  5977. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  5978. this.resume = null;
  5979. this.error = null;
  5980. this.onBeforeDraw = null;
  5981. this.onAfterDraw = null;
  5982. this.annotationLayer = null;
  5983. this.textLayer = null;
  5984. this.zoomLayer = null;
  5985. var div = document.createElement('div');
  5986. div.className = 'page';
  5987. div.style.width = Math.floor(this.viewport.width) + 'px';
  5988. div.style.height = Math.floor(this.viewport.height) + 'px';
  5989. div.setAttribute('data-page-number', this.id);
  5990. this.div = div;
  5991. container.appendChild(div);
  5992. }
  5993. _createClass(PDFPageView, [{
  5994. key: 'setPdfPage',
  5995. value: function setPdfPage(pdfPage) {
  5996. this.pdfPage = pdfPage;
  5997. this.pdfPageRotate = pdfPage.rotate;
  5998. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  5999. this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
  6000. this.stats = pdfPage.stats;
  6001. this.reset();
  6002. }
  6003. }, {
  6004. key: 'destroy',
  6005. value: function destroy() {
  6006. this.reset();
  6007. if (this.pdfPage) {
  6008. this.pdfPage.cleanup();
  6009. this.pdfPage = null;
  6010. }
  6011. }
  6012. }, {
  6013. key: '_resetZoomLayer',
  6014. value: function _resetZoomLayer() {
  6015. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6016. if (!this.zoomLayer) {
  6017. return;
  6018. }
  6019. var zoomLayerCanvas = this.zoomLayer.firstChild;
  6020. this.paintedViewportMap.delete(zoomLayerCanvas);
  6021. zoomLayerCanvas.width = 0;
  6022. zoomLayerCanvas.height = 0;
  6023. if (removeFromDOM) {
  6024. this.zoomLayer.remove();
  6025. }
  6026. this.zoomLayer = null;
  6027. }
  6028. }, {
  6029. key: 'reset',
  6030. value: function reset() {
  6031. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6032. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6033. this.cancelRendering();
  6034. var div = this.div;
  6035. div.style.width = Math.floor(this.viewport.width) + 'px';
  6036. div.style.height = Math.floor(this.viewport.height) + 'px';
  6037. var childNodes = div.childNodes;
  6038. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  6039. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  6040. for (var i = childNodes.length - 1; i >= 0; i--) {
  6041. var node = childNodes[i];
  6042. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  6043. continue;
  6044. }
  6045. div.removeChild(node);
  6046. }
  6047. div.removeAttribute('data-loaded');
  6048. if (currentAnnotationNode) {
  6049. this.annotationLayer.hide();
  6050. } else {
  6051. this.annotationLayer = null;
  6052. }
  6053. if (!currentZoomLayerNode) {
  6054. if (this.canvas) {
  6055. this.paintedViewportMap.delete(this.canvas);
  6056. this.canvas.width = 0;
  6057. this.canvas.height = 0;
  6058. delete this.canvas;
  6059. }
  6060. this._resetZoomLayer();
  6061. }
  6062. if (this.svg) {
  6063. this.paintedViewportMap.delete(this.svg);
  6064. delete this.svg;
  6065. }
  6066. this.loadingIconDiv = document.createElement('div');
  6067. this.loadingIconDiv.className = 'loadingIcon';
  6068. div.appendChild(this.loadingIconDiv);
  6069. }
  6070. }, {
  6071. key: 'update',
  6072. value: function update(scale, rotation) {
  6073. this.scale = scale || this.scale;
  6074. if (typeof rotation !== 'undefined') {
  6075. this.rotation = rotation;
  6076. }
  6077. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  6078. this.viewport = this.viewport.clone({
  6079. scale: this.scale * _ui_utils.CSS_UNITS,
  6080. rotation: totalRotation
  6081. });
  6082. if (this.svg) {
  6083. this.cssTransform(this.svg, true);
  6084. this.eventBus.dispatch('pagerendered', {
  6085. source: this,
  6086. pageNumber: this.id,
  6087. cssTransform: true
  6088. });
  6089. return;
  6090. }
  6091. var isScalingRestricted = false;
  6092. if (this.canvas && _pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  6093. var outputScale = this.outputScale;
  6094. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > _pdfjsLib.PDFJS.maxCanvasPixels) {
  6095. isScalingRestricted = true;
  6096. }
  6097. }
  6098. if (this.canvas) {
  6099. if (_pdfjsLib.PDFJS.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  6100. this.cssTransform(this.canvas, true);
  6101. this.eventBus.dispatch('pagerendered', {
  6102. source: this,
  6103. pageNumber: this.id,
  6104. cssTransform: true
  6105. });
  6106. return;
  6107. }
  6108. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  6109. this.zoomLayer = this.canvas.parentNode;
  6110. this.zoomLayer.style.position = 'absolute';
  6111. }
  6112. }
  6113. if (this.zoomLayer) {
  6114. this.cssTransform(this.zoomLayer.firstChild);
  6115. }
  6116. this.reset(true, true);
  6117. }
  6118. }, {
  6119. key: 'cancelRendering',
  6120. value: function cancelRendering() {
  6121. if (this.paintTask) {
  6122. this.paintTask.cancel();
  6123. this.paintTask = null;
  6124. }
  6125. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  6126. this.resume = null;
  6127. if (this.textLayer) {
  6128. this.textLayer.cancel();
  6129. this.textLayer = null;
  6130. }
  6131. }
  6132. }, {
  6133. key: 'cssTransform',
  6134. value: function cssTransform(target) {
  6135. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6136. var width = this.viewport.width;
  6137. var height = this.viewport.height;
  6138. var div = this.div;
  6139. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  6140. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  6141. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  6142. var absRotation = Math.abs(relativeRotation);
  6143. var scaleX = 1,
  6144. scaleY = 1;
  6145. if (absRotation === 90 || absRotation === 270) {
  6146. scaleX = height / width;
  6147. scaleY = width / height;
  6148. }
  6149. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  6150. _pdfjsLib.CustomStyle.setProp('transform', target, cssTransform);
  6151. if (this.textLayer) {
  6152. var textLayerViewport = this.textLayer.viewport;
  6153. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  6154. var textAbsRotation = Math.abs(textRelativeRotation);
  6155. var scale = width / textLayerViewport.width;
  6156. if (textAbsRotation === 90 || textAbsRotation === 270) {
  6157. scale = width / textLayerViewport.height;
  6158. }
  6159. var textLayerDiv = this.textLayer.textLayerDiv;
  6160. var transX = void 0,
  6161. transY = void 0;
  6162. switch (textAbsRotation) {
  6163. case 0:
  6164. transX = transY = 0;
  6165. break;
  6166. case 90:
  6167. transX = 0;
  6168. transY = '-' + textLayerDiv.style.height;
  6169. break;
  6170. case 180:
  6171. transX = '-' + textLayerDiv.style.width;
  6172. transY = '-' + textLayerDiv.style.height;
  6173. break;
  6174. case 270:
  6175. transX = '-' + textLayerDiv.style.width;
  6176. transY = 0;
  6177. break;
  6178. default:
  6179. console.error('Bad rotation value.');
  6180. break;
  6181. }
  6182. _pdfjsLib.CustomStyle.setProp('transform', textLayerDiv, 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')');
  6183. _pdfjsLib.CustomStyle.setProp('transformOrigin', textLayerDiv, '0% 0%');
  6184. }
  6185. if (redrawAnnotations && this.annotationLayer) {
  6186. this.annotationLayer.render(this.viewport, 'display');
  6187. }
  6188. }
  6189. }, {
  6190. key: 'getPagePoint',
  6191. value: function getPagePoint(x, y) {
  6192. return this.viewport.convertToPdfPoint(x, y);
  6193. }
  6194. }, {
  6195. key: 'draw',
  6196. value: function draw() {
  6197. var _this = this;
  6198. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  6199. console.error('Must be in new state before drawing');
  6200. this.reset();
  6201. }
  6202. if (!this.pdfPage) {
  6203. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  6204. return Promise.reject(new Error('Page is not loaded'));
  6205. }
  6206. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  6207. var pdfPage = this.pdfPage;
  6208. var div = this.div;
  6209. var canvasWrapper = document.createElement('div');
  6210. canvasWrapper.style.width = div.style.width;
  6211. canvasWrapper.style.height = div.style.height;
  6212. canvasWrapper.classList.add('canvasWrapper');
  6213. if (this.annotationLayer && this.annotationLayer.div) {
  6214. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  6215. } else {
  6216. div.appendChild(canvasWrapper);
  6217. }
  6218. var textLayer = null;
  6219. if (this.textLayerFactory) {
  6220. var textLayerDiv = document.createElement('div');
  6221. textLayerDiv.className = 'textLayer';
  6222. textLayerDiv.style.width = canvasWrapper.style.width;
  6223. textLayerDiv.style.height = canvasWrapper.style.height;
  6224. if (this.annotationLayer && this.annotationLayer.div) {
  6225. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  6226. } else {
  6227. div.appendChild(textLayerDiv);
  6228. }
  6229. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.enhanceTextSelection);
  6230. }
  6231. this.textLayer = textLayer;
  6232. var renderContinueCallback = null;
  6233. if (this.renderingQueue) {
  6234. renderContinueCallback = function renderContinueCallback(cont) {
  6235. if (!_this.renderingQueue.isHighestPriority(_this)) {
  6236. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  6237. _this.resume = function () {
  6238. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  6239. cont();
  6240. };
  6241. return;
  6242. }
  6243. cont();
  6244. };
  6245. }
  6246. var finishPaintTask = function finishPaintTask(error) {
  6247. if (paintTask === _this.paintTask) {
  6248. _this.paintTask = null;
  6249. }
  6250. if (error === 'cancelled' || error instanceof _pdfjsLib.RenderingCancelledException) {
  6251. _this.error = null;
  6252. return Promise.resolve(undefined);
  6253. }
  6254. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  6255. if (_this.loadingIconDiv) {
  6256. div.removeChild(_this.loadingIconDiv);
  6257. delete _this.loadingIconDiv;
  6258. }
  6259. _this._resetZoomLayer(true);
  6260. _this.error = error;
  6261. _this.stats = pdfPage.stats;
  6262. if (_this.onAfterDraw) {
  6263. _this.onAfterDraw();
  6264. }
  6265. _this.eventBus.dispatch('pagerendered', {
  6266. source: _this,
  6267. pageNumber: _this.id,
  6268. cssTransform: false
  6269. });
  6270. if (error) {
  6271. return Promise.reject(error);
  6272. }
  6273. return Promise.resolve(undefined);
  6274. };
  6275. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  6276. paintTask.onRenderContinue = renderContinueCallback;
  6277. this.paintTask = paintTask;
  6278. var resultPromise = paintTask.promise.then(function () {
  6279. return finishPaintTask(null).then(function () {
  6280. if (textLayer) {
  6281. var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true });
  6282. textLayer.setTextContentStream(readableStream);
  6283. textLayer.render();
  6284. }
  6285. });
  6286. }, function (reason) {
  6287. return finishPaintTask(reason);
  6288. });
  6289. if (this.annotationLayerFactory) {
  6290. if (!this.annotationLayer) {
  6291. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms, this.l10n);
  6292. }
  6293. this.annotationLayer.render(this.viewport, 'display');
  6294. }
  6295. div.setAttribute('data-loaded', true);
  6296. if (this.onBeforeDraw) {
  6297. this.onBeforeDraw();
  6298. }
  6299. return resultPromise;
  6300. }
  6301. }, {
  6302. key: 'paintOnCanvas',
  6303. value: function paintOnCanvas(canvasWrapper) {
  6304. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  6305. var result = {
  6306. promise: renderCapability.promise,
  6307. onRenderContinue: function onRenderContinue(cont) {
  6308. cont();
  6309. },
  6310. cancel: function cancel() {
  6311. renderTask.cancel();
  6312. }
  6313. };
  6314. var viewport = this.viewport;
  6315. var canvas = document.createElement('canvas');
  6316. canvas.id = this.renderingId;
  6317. canvas.setAttribute('hidden', 'hidden');
  6318. var isCanvasHidden = true;
  6319. var showCanvas = function showCanvas() {
  6320. if (isCanvasHidden) {
  6321. canvas.removeAttribute('hidden');
  6322. isCanvasHidden = false;
  6323. }
  6324. };
  6325. canvasWrapper.appendChild(canvas);
  6326. this.canvas = canvas;
  6327. canvas.mozOpaque = true;
  6328. var ctx = canvas.getContext('2d', { alpha: false });
  6329. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  6330. this.outputScale = outputScale;
  6331. if (_pdfjsLib.PDFJS.useOnlyCssZoom) {
  6332. var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });
  6333. outputScale.sx *= actualSizeViewport.width / viewport.width;
  6334. outputScale.sy *= actualSizeViewport.height / viewport.height;
  6335. outputScale.scaled = true;
  6336. }
  6337. if (_pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  6338. var pixelsInViewport = viewport.width * viewport.height;
  6339. var maxScale = Math.sqrt(_pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport);
  6340. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  6341. outputScale.sx = maxScale;
  6342. outputScale.sy = maxScale;
  6343. outputScale.scaled = true;
  6344. this.hasRestrictedScaling = true;
  6345. } else {
  6346. this.hasRestrictedScaling = false;
  6347. }
  6348. }
  6349. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  6350. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  6351. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  6352. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  6353. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  6354. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  6355. this.paintedViewportMap.set(canvas, viewport);
  6356. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  6357. var renderContext = {
  6358. canvasContext: ctx,
  6359. transform: transform,
  6360. viewport: this.viewport,
  6361. renderInteractiveForms: this.renderInteractiveForms
  6362. };
  6363. var renderTask = this.pdfPage.render(renderContext);
  6364. renderTask.onContinue = function (cont) {
  6365. showCanvas();
  6366. if (result.onRenderContinue) {
  6367. result.onRenderContinue(cont);
  6368. } else {
  6369. cont();
  6370. }
  6371. };
  6372. renderTask.promise.then(function () {
  6373. showCanvas();
  6374. renderCapability.resolve(undefined);
  6375. }, function (error) {
  6376. showCanvas();
  6377. renderCapability.reject(error);
  6378. });
  6379. return result;
  6380. }
  6381. }, {
  6382. key: 'paintOnSvg',
  6383. value: function paintOnSvg(wrapper) {
  6384. var _this2 = this;
  6385. var cancelled = false;
  6386. var ensureNotCancelled = function ensureNotCancelled() {
  6387. if (cancelled) {
  6388. if (_pdfjsLib.PDFJS.pdfjsNext) {
  6389. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  6390. } else {
  6391. throw 'cancelled';
  6392. }
  6393. }
  6394. };
  6395. var pdfPage = this.pdfPage;
  6396. var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });
  6397. var promise = pdfPage.getOperatorList().then(function (opList) {
  6398. ensureNotCancelled();
  6399. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  6400. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  6401. ensureNotCancelled();
  6402. _this2.svg = svg;
  6403. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  6404. svg.style.width = wrapper.style.width;
  6405. svg.style.height = wrapper.style.height;
  6406. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  6407. wrapper.appendChild(svg);
  6408. });
  6409. });
  6410. return {
  6411. promise: promise,
  6412. onRenderContinue: function onRenderContinue(cont) {
  6413. cont();
  6414. },
  6415. cancel: function cancel() {
  6416. cancelled = true;
  6417. }
  6418. };
  6419. }
  6420. }, {
  6421. key: 'setPageLabel',
  6422. value: function setPageLabel(label) {
  6423. this.pageLabel = typeof label === 'string' ? label : null;
  6424. if (this.pageLabel !== null) {
  6425. this.div.setAttribute('data-page-label', this.pageLabel);
  6426. } else {
  6427. this.div.removeAttribute('data-page-label');
  6428. }
  6429. }
  6430. }, {
  6431. key: 'width',
  6432. get: function get() {
  6433. return this.viewport.width;
  6434. }
  6435. }, {
  6436. key: 'height',
  6437. get: function get() {
  6438. return this.viewport.height;
  6439. }
  6440. }]);
  6441. return PDFPageView;
  6442. }();
  6443. exports.PDFPageView = PDFPageView;
  6444. /***/ }),
  6445. /* 23 */
  6446. /***/ (function(module, exports, __webpack_require__) {
  6447. "use strict";
  6448. Object.defineProperty(exports, "__esModule", {
  6449. value: true
  6450. });
  6451. exports.PDFPresentationMode = undefined;
  6452. 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; }; }();
  6453. var _ui_utils = __webpack_require__(0);
  6454. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6455. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  6456. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  6457. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  6458. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  6459. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  6460. var PAGE_SWITCH_THRESHOLD = 0.1;
  6461. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  6462. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  6463. var PDFPresentationMode = function () {
  6464. function PDFPresentationMode(_ref) {
  6465. var _this = this;
  6466. var container = _ref.container,
  6467. _ref$viewer = _ref.viewer,
  6468. viewer = _ref$viewer === undefined ? null : _ref$viewer,
  6469. pdfViewer = _ref.pdfViewer,
  6470. eventBus = _ref.eventBus,
  6471. _ref$contextMenuItems = _ref.contextMenuItems,
  6472. contextMenuItems = _ref$contextMenuItems === undefined ? null : _ref$contextMenuItems;
  6473. _classCallCheck(this, PDFPresentationMode);
  6474. this.container = container;
  6475. this.viewer = viewer || container.firstElementChild;
  6476. this.pdfViewer = pdfViewer;
  6477. this.eventBus = eventBus;
  6478. this.active = false;
  6479. this.args = null;
  6480. this.contextMenuOpen = false;
  6481. this.mouseScrollTimeStamp = 0;
  6482. this.mouseScrollDelta = 0;
  6483. this.touchSwipeState = null;
  6484. if (contextMenuItems) {
  6485. contextMenuItems.contextFirstPage.addEventListener('click', function () {
  6486. _this.contextMenuOpen = false;
  6487. _this.eventBus.dispatch('firstpage');
  6488. });
  6489. contextMenuItems.contextLastPage.addEventListener('click', function () {
  6490. _this.contextMenuOpen = false;
  6491. _this.eventBus.dispatch('lastpage');
  6492. });
  6493. contextMenuItems.contextPageRotateCw.addEventListener('click', function () {
  6494. _this.contextMenuOpen = false;
  6495. _this.eventBus.dispatch('rotatecw');
  6496. });
  6497. contextMenuItems.contextPageRotateCcw.addEventListener('click', function () {
  6498. _this.contextMenuOpen = false;
  6499. _this.eventBus.dispatch('rotateccw');
  6500. });
  6501. }
  6502. }
  6503. _createClass(PDFPresentationMode, [{
  6504. key: 'request',
  6505. value: function request() {
  6506. if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
  6507. return false;
  6508. }
  6509. this._addFullscreenChangeListeners();
  6510. this._setSwitchInProgress();
  6511. this._notifyStateChange();
  6512. if (this.container.requestFullscreen) {
  6513. this.container.requestFullscreen();
  6514. } else if (this.container.mozRequestFullScreen) {
  6515. this.container.mozRequestFullScreen();
  6516. } else if (this.container.webkitRequestFullscreen) {
  6517. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  6518. } else if (this.container.msRequestFullscreen) {
  6519. this.container.msRequestFullscreen();
  6520. } else {
  6521. return false;
  6522. }
  6523. this.args = {
  6524. page: this.pdfViewer.currentPageNumber,
  6525. previousScale: this.pdfViewer.currentScaleValue
  6526. };
  6527. return true;
  6528. }
  6529. }, {
  6530. key: '_mouseWheel',
  6531. value: function _mouseWheel(evt) {
  6532. if (!this.active) {
  6533. return;
  6534. }
  6535. evt.preventDefault();
  6536. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  6537. var currentTime = new Date().getTime();
  6538. var storedTime = this.mouseScrollTimeStamp;
  6539. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  6540. return;
  6541. }
  6542. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  6543. this._resetMouseScrollState();
  6544. }
  6545. this.mouseScrollDelta += delta;
  6546. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  6547. var totalDelta = this.mouseScrollDelta;
  6548. this._resetMouseScrollState();
  6549. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  6550. if (success) {
  6551. this.mouseScrollTimeStamp = currentTime;
  6552. }
  6553. }
  6554. }
  6555. }, {
  6556. key: '_goToPreviousPage',
  6557. value: function _goToPreviousPage() {
  6558. var page = this.pdfViewer.currentPageNumber;
  6559. if (page <= 1) {
  6560. return false;
  6561. }
  6562. this.pdfViewer.currentPageNumber = page - 1;
  6563. return true;
  6564. }
  6565. }, {
  6566. key: '_goToNextPage',
  6567. value: function _goToNextPage() {
  6568. var page = this.pdfViewer.currentPageNumber;
  6569. if (page >= this.pdfViewer.pagesCount) {
  6570. return false;
  6571. }
  6572. this.pdfViewer.currentPageNumber = page + 1;
  6573. return true;
  6574. }
  6575. }, {
  6576. key: '_notifyStateChange',
  6577. value: function _notifyStateChange() {
  6578. this.eventBus.dispatch('presentationmodechanged', {
  6579. source: this,
  6580. active: this.active,
  6581. switchInProgress: !!this.switchInProgress
  6582. });
  6583. }
  6584. }, {
  6585. key: '_setSwitchInProgress',
  6586. value: function _setSwitchInProgress() {
  6587. var _this2 = this;
  6588. if (this.switchInProgress) {
  6589. clearTimeout(this.switchInProgress);
  6590. }
  6591. this.switchInProgress = setTimeout(function () {
  6592. _this2._removeFullscreenChangeListeners();
  6593. delete _this2.switchInProgress;
  6594. _this2._notifyStateChange();
  6595. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  6596. }
  6597. }, {
  6598. key: '_resetSwitchInProgress',
  6599. value: function _resetSwitchInProgress() {
  6600. if (this.switchInProgress) {
  6601. clearTimeout(this.switchInProgress);
  6602. delete this.switchInProgress;
  6603. }
  6604. }
  6605. }, {
  6606. key: '_enter',
  6607. value: function _enter() {
  6608. var _this3 = this;
  6609. this.active = true;
  6610. this._resetSwitchInProgress();
  6611. this._notifyStateChange();
  6612. this.container.classList.add(ACTIVE_SELECTOR);
  6613. setTimeout(function () {
  6614. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  6615. _this3.pdfViewer.currentScaleValue = 'page-fit';
  6616. }, 0);
  6617. this._addWindowListeners();
  6618. this._showControls();
  6619. this.contextMenuOpen = false;
  6620. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  6621. window.getSelection().removeAllRanges();
  6622. }
  6623. }, {
  6624. key: '_exit',
  6625. value: function _exit() {
  6626. var _this4 = this;
  6627. var page = this.pdfViewer.currentPageNumber;
  6628. this.container.classList.remove(ACTIVE_SELECTOR);
  6629. setTimeout(function () {
  6630. _this4.active = false;
  6631. _this4._removeFullscreenChangeListeners();
  6632. _this4._notifyStateChange();
  6633. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  6634. _this4.pdfViewer.currentPageNumber = page;
  6635. _this4.args = null;
  6636. }, 0);
  6637. this._removeWindowListeners();
  6638. this._hideControls();
  6639. this._resetMouseScrollState();
  6640. this.container.removeAttribute('contextmenu');
  6641. this.contextMenuOpen = false;
  6642. }
  6643. }, {
  6644. key: '_mouseDown',
  6645. value: function _mouseDown(evt) {
  6646. if (this.contextMenuOpen) {
  6647. this.contextMenuOpen = false;
  6648. evt.preventDefault();
  6649. return;
  6650. }
  6651. if (evt.button === 0) {
  6652. var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
  6653. if (!isInternalLink) {
  6654. evt.preventDefault();
  6655. if (evt.shiftKey) {
  6656. this._goToPreviousPage();
  6657. } else {
  6658. this._goToNextPage();
  6659. }
  6660. }
  6661. }
  6662. }
  6663. }, {
  6664. key: '_contextMenu',
  6665. value: function _contextMenu() {
  6666. this.contextMenuOpen = true;
  6667. }
  6668. }, {
  6669. key: '_showControls',
  6670. value: function _showControls() {
  6671. var _this5 = this;
  6672. if (this.controlsTimeout) {
  6673. clearTimeout(this.controlsTimeout);
  6674. } else {
  6675. this.container.classList.add(CONTROLS_SELECTOR);
  6676. }
  6677. this.controlsTimeout = setTimeout(function () {
  6678. _this5.container.classList.remove(CONTROLS_SELECTOR);
  6679. delete _this5.controlsTimeout;
  6680. }, DELAY_BEFORE_HIDING_CONTROLS);
  6681. }
  6682. }, {
  6683. key: '_hideControls',
  6684. value: function _hideControls() {
  6685. if (!this.controlsTimeout) {
  6686. return;
  6687. }
  6688. clearTimeout(this.controlsTimeout);
  6689. this.container.classList.remove(CONTROLS_SELECTOR);
  6690. delete this.controlsTimeout;
  6691. }
  6692. }, {
  6693. key: '_resetMouseScrollState',
  6694. value: function _resetMouseScrollState() {
  6695. this.mouseScrollTimeStamp = 0;
  6696. this.mouseScrollDelta = 0;
  6697. }
  6698. }, {
  6699. key: '_touchSwipe',
  6700. value: function _touchSwipe(evt) {
  6701. if (!this.active) {
  6702. return;
  6703. }
  6704. if (evt.touches.length > 1) {
  6705. this.touchSwipeState = null;
  6706. return;
  6707. }
  6708. switch (evt.type) {
  6709. case 'touchstart':
  6710. this.touchSwipeState = {
  6711. startX: evt.touches[0].pageX,
  6712. startY: evt.touches[0].pageY,
  6713. endX: evt.touches[0].pageX,
  6714. endY: evt.touches[0].pageY
  6715. };
  6716. break;
  6717. case 'touchmove':
  6718. if (this.touchSwipeState === null) {
  6719. return;
  6720. }
  6721. this.touchSwipeState.endX = evt.touches[0].pageX;
  6722. this.touchSwipeState.endY = evt.touches[0].pageY;
  6723. evt.preventDefault();
  6724. break;
  6725. case 'touchend':
  6726. if (this.touchSwipeState === null) {
  6727. return;
  6728. }
  6729. var delta = 0;
  6730. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  6731. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  6732. var absAngle = Math.abs(Math.atan2(dy, dx));
  6733. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  6734. delta = dx;
  6735. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  6736. delta = dy;
  6737. }
  6738. if (delta > 0) {
  6739. this._goToPreviousPage();
  6740. } else if (delta < 0) {
  6741. this._goToNextPage();
  6742. }
  6743. break;
  6744. }
  6745. }
  6746. }, {
  6747. key: '_addWindowListeners',
  6748. value: function _addWindowListeners() {
  6749. this.showControlsBind = this._showControls.bind(this);
  6750. this.mouseDownBind = this._mouseDown.bind(this);
  6751. this.mouseWheelBind = this._mouseWheel.bind(this);
  6752. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  6753. this.contextMenuBind = this._contextMenu.bind(this);
  6754. this.touchSwipeBind = this._touchSwipe.bind(this);
  6755. window.addEventListener('mousemove', this.showControlsBind);
  6756. window.addEventListener('mousedown', this.mouseDownBind);
  6757. window.addEventListener('wheel', this.mouseWheelBind);
  6758. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  6759. window.addEventListener('contextmenu', this.contextMenuBind);
  6760. window.addEventListener('touchstart', this.touchSwipeBind);
  6761. window.addEventListener('touchmove', this.touchSwipeBind);
  6762. window.addEventListener('touchend', this.touchSwipeBind);
  6763. }
  6764. }, {
  6765. key: '_removeWindowListeners',
  6766. value: function _removeWindowListeners() {
  6767. window.removeEventListener('mousemove', this.showControlsBind);
  6768. window.removeEventListener('mousedown', this.mouseDownBind);
  6769. window.removeEventListener('wheel', this.mouseWheelBind);
  6770. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  6771. window.removeEventListener('contextmenu', this.contextMenuBind);
  6772. window.removeEventListener('touchstart', this.touchSwipeBind);
  6773. window.removeEventListener('touchmove', this.touchSwipeBind);
  6774. window.removeEventListener('touchend', this.touchSwipeBind);
  6775. delete this.showControlsBind;
  6776. delete this.mouseDownBind;
  6777. delete this.mouseWheelBind;
  6778. delete this.resetMouseScrollStateBind;
  6779. delete this.contextMenuBind;
  6780. delete this.touchSwipeBind;
  6781. }
  6782. }, {
  6783. key: '_fullscreenChange',
  6784. value: function _fullscreenChange() {
  6785. if (this.isFullscreen) {
  6786. this._enter();
  6787. } else {
  6788. this._exit();
  6789. }
  6790. }
  6791. }, {
  6792. key: '_addFullscreenChangeListeners',
  6793. value: function _addFullscreenChangeListeners() {
  6794. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  6795. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  6796. window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  6797. window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  6798. window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  6799. }
  6800. }, {
  6801. key: '_removeFullscreenChangeListeners',
  6802. value: function _removeFullscreenChangeListeners() {
  6803. window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
  6804. window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  6805. window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  6806. window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  6807. delete this.fullscreenChangeBind;
  6808. }
  6809. }, {
  6810. key: 'isFullscreen',
  6811. get: function get() {
  6812. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  6813. }
  6814. }]);
  6815. return PDFPresentationMode;
  6816. }();
  6817. exports.PDFPresentationMode = PDFPresentationMode;
  6818. /***/ }),
  6819. /* 24 */
  6820. /***/ (function(module, exports, __webpack_require__) {
  6821. "use strict";
  6822. Object.defineProperty(exports, "__esModule", {
  6823. value: true
  6824. });
  6825. exports.PDFSidebar = exports.SidebarView = undefined;
  6826. 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; }; }();
  6827. var _ui_utils = __webpack_require__(0);
  6828. var _pdf_rendering_queue = __webpack_require__(3);
  6829. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6830. var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
  6831. var SidebarView = {
  6832. NONE: 0,
  6833. THUMBS: 1,
  6834. OUTLINE: 2,
  6835. ATTACHMENTS: 3
  6836. };
  6837. var PDFSidebar = function () {
  6838. function PDFSidebar(options) {
  6839. var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
  6840. _classCallCheck(this, PDFSidebar);
  6841. this.isOpen = false;
  6842. this.active = SidebarView.THUMBS;
  6843. this.isInitialViewSet = false;
  6844. this.onToggled = null;
  6845. this.pdfViewer = options.pdfViewer;
  6846. this.pdfThumbnailViewer = options.pdfThumbnailViewer;
  6847. this.pdfOutlineViewer = options.pdfOutlineViewer;
  6848. this.mainContainer = options.mainContainer;
  6849. this.outerContainer = options.outerContainer;
  6850. this.eventBus = options.eventBus;
  6851. this.toggleButton = options.toggleButton;
  6852. this.thumbnailButton = options.thumbnailButton;
  6853. this.outlineButton = options.outlineButton;
  6854. this.attachmentsButton = options.attachmentsButton;
  6855. this.thumbnailView = options.thumbnailView;
  6856. this.outlineView = options.outlineView;
  6857. this.attachmentsView = options.attachmentsView;
  6858. this.disableNotification = options.disableNotification || false;
  6859. this.l10n = l10n;
  6860. this._addEventListeners();
  6861. }
  6862. _createClass(PDFSidebar, [{
  6863. key: 'reset',
  6864. value: function reset() {
  6865. this.isInitialViewSet = false;
  6866. this._hideUINotification(null);
  6867. this.switchView(SidebarView.THUMBS);
  6868. this.outlineButton.disabled = false;
  6869. this.attachmentsButton.disabled = false;
  6870. }
  6871. }, {
  6872. key: 'setInitialView',
  6873. value: function setInitialView(view) {
  6874. if (this.isInitialViewSet) {
  6875. return;
  6876. }
  6877. this.isInitialViewSet = true;
  6878. if (this.isOpen && view === SidebarView.NONE) {
  6879. this._dispatchEvent();
  6880. return;
  6881. }
  6882. var isViewPreserved = view === this.visibleView;
  6883. this.switchView(view, true);
  6884. if (isViewPreserved) {
  6885. this._dispatchEvent();
  6886. }
  6887. }
  6888. }, {
  6889. key: 'switchView',
  6890. value: function switchView(view) {
  6891. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6892. if (view === SidebarView.NONE) {
  6893. this.close();
  6894. return;
  6895. }
  6896. var isViewChanged = view !== this.active;
  6897. var shouldForceRendering = false;
  6898. switch (view) {
  6899. case SidebarView.THUMBS:
  6900. this.thumbnailButton.classList.add('toggled');
  6901. this.outlineButton.classList.remove('toggled');
  6902. this.attachmentsButton.classList.remove('toggled');
  6903. this.thumbnailView.classList.remove('hidden');
  6904. this.outlineView.classList.add('hidden');
  6905. this.attachmentsView.classList.add('hidden');
  6906. if (this.isOpen && isViewChanged) {
  6907. this._updateThumbnailViewer();
  6908. shouldForceRendering = true;
  6909. }
  6910. break;
  6911. case SidebarView.OUTLINE:
  6912. if (this.outlineButton.disabled) {
  6913. return;
  6914. }
  6915. this.thumbnailButton.classList.remove('toggled');
  6916. this.outlineButton.classList.add('toggled');
  6917. this.attachmentsButton.classList.remove('toggled');
  6918. this.thumbnailView.classList.add('hidden');
  6919. this.outlineView.classList.remove('hidden');
  6920. this.attachmentsView.classList.add('hidden');
  6921. break;
  6922. case SidebarView.ATTACHMENTS:
  6923. if (this.attachmentsButton.disabled) {
  6924. return;
  6925. }
  6926. this.thumbnailButton.classList.remove('toggled');
  6927. this.outlineButton.classList.remove('toggled');
  6928. this.attachmentsButton.classList.add('toggled');
  6929. this.thumbnailView.classList.add('hidden');
  6930. this.outlineView.classList.add('hidden');
  6931. this.attachmentsView.classList.remove('hidden');
  6932. break;
  6933. default:
  6934. console.error('PDFSidebar_switchView: "' + view + '" is an unsupported value.');
  6935. return;
  6936. }
  6937. this.active = view | 0;
  6938. if (forceOpen && !this.isOpen) {
  6939. this.open();
  6940. return;
  6941. }
  6942. if (shouldForceRendering) {
  6943. this._forceRendering();
  6944. }
  6945. if (isViewChanged) {
  6946. this._dispatchEvent();
  6947. }
  6948. this._hideUINotification(this.active);
  6949. }
  6950. }, {
  6951. key: 'open',
  6952. value: function open() {
  6953. if (this.isOpen) {
  6954. return;
  6955. }
  6956. this.isOpen = true;
  6957. this.toggleButton.classList.add('toggled');
  6958. this.outerContainer.classList.add('sidebarMoving');
  6959. this.outerContainer.classList.add('sidebarOpen');
  6960. if (this.active === SidebarView.THUMBS) {
  6961. this._updateThumbnailViewer();
  6962. }
  6963. this._forceRendering();
  6964. this._dispatchEvent();
  6965. this._hideUINotification(this.active);
  6966. }
  6967. }, {
  6968. key: 'close',
  6969. value: function close() {
  6970. if (!this.isOpen) {
  6971. return;
  6972. }
  6973. this.isOpen = false;
  6974. this.toggleButton.classList.remove('toggled');
  6975. this.outerContainer.classList.add('sidebarMoving');
  6976. this.outerContainer.classList.remove('sidebarOpen');
  6977. this._forceRendering();
  6978. this._dispatchEvent();
  6979. }
  6980. }, {
  6981. key: 'toggle',
  6982. value: function toggle() {
  6983. if (this.isOpen) {
  6984. this.close();
  6985. } else {
  6986. this.open();
  6987. }
  6988. }
  6989. }, {
  6990. key: '_dispatchEvent',
  6991. value: function _dispatchEvent() {
  6992. this.eventBus.dispatch('sidebarviewchanged', {
  6993. source: this,
  6994. view: this.visibleView
  6995. });
  6996. }
  6997. }, {
  6998. key: '_forceRendering',
  6999. value: function _forceRendering() {
  7000. if (this.onToggled) {
  7001. this.onToggled();
  7002. } else {
  7003. this.pdfViewer.forceRendering();
  7004. this.pdfThumbnailViewer.forceRendering();
  7005. }
  7006. }
  7007. }, {
  7008. key: '_updateThumbnailViewer',
  7009. value: function _updateThumbnailViewer() {
  7010. var pdfViewer = this.pdfViewer,
  7011. pdfThumbnailViewer = this.pdfThumbnailViewer;
  7012. var pagesCount = pdfViewer.pagesCount;
  7013. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  7014. var pageView = pdfViewer.getPageView(pageIndex);
  7015. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  7016. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  7017. thumbnailView.setImage(pageView);
  7018. }
  7019. }
  7020. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  7021. }
  7022. }, {
  7023. key: '_showUINotification',
  7024. value: function _showUINotification(view) {
  7025. var _this = this;
  7026. if (this.disableNotification) {
  7027. return;
  7028. }
  7029. this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
  7030. _this.toggleButton.title = msg;
  7031. });
  7032. if (!this.isOpen) {
  7033. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  7034. } else if (view === this.active) {
  7035. return;
  7036. }
  7037. switch (view) {
  7038. case SidebarView.OUTLINE:
  7039. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  7040. break;
  7041. case SidebarView.ATTACHMENTS:
  7042. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  7043. break;
  7044. }
  7045. }
  7046. }, {
  7047. key: '_hideUINotification',
  7048. value: function _hideUINotification(view) {
  7049. var _this2 = this;
  7050. if (this.disableNotification) {
  7051. return;
  7052. }
  7053. var removeNotification = function removeNotification(view) {
  7054. switch (view) {
  7055. case SidebarView.OUTLINE:
  7056. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  7057. break;
  7058. case SidebarView.ATTACHMENTS:
  7059. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  7060. break;
  7061. }
  7062. };
  7063. if (!this.isOpen && view !== null) {
  7064. return;
  7065. }
  7066. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  7067. if (view !== null) {
  7068. removeNotification(view);
  7069. return;
  7070. }
  7071. for (view in SidebarView) {
  7072. removeNotification(SidebarView[view]);
  7073. }
  7074. this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
  7075. _this2.toggleButton.title = msg;
  7076. });
  7077. }
  7078. }, {
  7079. key: '_addEventListeners',
  7080. value: function _addEventListeners() {
  7081. var _this3 = this;
  7082. this.mainContainer.addEventListener('transitionend', function (evt) {
  7083. if (evt.target === _this3.mainContainer) {
  7084. _this3.outerContainer.classList.remove('sidebarMoving');
  7085. }
  7086. });
  7087. this.thumbnailButton.addEventListener('click', function () {
  7088. _this3.switchView(SidebarView.THUMBS);
  7089. });
  7090. this.outlineButton.addEventListener('click', function () {
  7091. _this3.switchView(SidebarView.OUTLINE);
  7092. });
  7093. this.outlineButton.addEventListener('dblclick', function () {
  7094. _this3.pdfOutlineViewer.toggleOutlineTree();
  7095. });
  7096. this.attachmentsButton.addEventListener('click', function () {
  7097. _this3.switchView(SidebarView.ATTACHMENTS);
  7098. });
  7099. this.eventBus.on('outlineloaded', function (evt) {
  7100. var outlineCount = evt.outlineCount;
  7101. _this3.outlineButton.disabled = !outlineCount;
  7102. if (outlineCount) {
  7103. _this3._showUINotification(SidebarView.OUTLINE);
  7104. } else if (_this3.active === SidebarView.OUTLINE) {
  7105. _this3.switchView(SidebarView.THUMBS);
  7106. }
  7107. });
  7108. this.eventBus.on('attachmentsloaded', function (evt) {
  7109. var attachmentsCount = evt.attachmentsCount;
  7110. _this3.attachmentsButton.disabled = !attachmentsCount;
  7111. if (attachmentsCount) {
  7112. _this3._showUINotification(SidebarView.ATTACHMENTS);
  7113. } else if (_this3.active === SidebarView.ATTACHMENTS) {
  7114. _this3.switchView(SidebarView.THUMBS);
  7115. }
  7116. });
  7117. this.eventBus.on('presentationmodechanged', function (evt) {
  7118. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  7119. _this3._updateThumbnailViewer();
  7120. }
  7121. });
  7122. }
  7123. }, {
  7124. key: 'visibleView',
  7125. get: function get() {
  7126. return this.isOpen ? this.active : SidebarView.NONE;
  7127. }
  7128. }, {
  7129. key: 'isThumbnailViewVisible',
  7130. get: function get() {
  7131. return this.isOpen && this.active === SidebarView.THUMBS;
  7132. }
  7133. }, {
  7134. key: 'isOutlineViewVisible',
  7135. get: function get() {
  7136. return this.isOpen && this.active === SidebarView.OUTLINE;
  7137. }
  7138. }, {
  7139. key: 'isAttachmentsViewVisible',
  7140. get: function get() {
  7141. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  7142. }
  7143. }]);
  7144. return PDFSidebar;
  7145. }();
  7146. exports.SidebarView = SidebarView;
  7147. exports.PDFSidebar = PDFSidebar;
  7148. /***/ }),
  7149. /* 25 */
  7150. /***/ (function(module, exports, __webpack_require__) {
  7151. "use strict";
  7152. Object.defineProperty(exports, "__esModule", {
  7153. value: true
  7154. });
  7155. exports.PDFThumbnailView = undefined;
  7156. 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; }; }();
  7157. var _pdfjsLib = __webpack_require__(1);
  7158. var _ui_utils = __webpack_require__(0);
  7159. var _pdf_rendering_queue = __webpack_require__(3);
  7160. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7161. var MAX_NUM_SCALING_STEPS = 3;
  7162. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  7163. var THUMBNAIL_WIDTH = 98;
  7164. var TempImageFactory = function TempImageFactoryClosure() {
  7165. var tempCanvasCache = null;
  7166. return {
  7167. getCanvas: function getCanvas(width, height) {
  7168. var tempCanvas = tempCanvasCache;
  7169. if (!tempCanvas) {
  7170. tempCanvas = document.createElement('canvas');
  7171. tempCanvasCache = tempCanvas;
  7172. }
  7173. tempCanvas.width = width;
  7174. tempCanvas.height = height;
  7175. tempCanvas.mozOpaque = true;
  7176. var ctx = tempCanvas.getContext('2d', { alpha: false });
  7177. ctx.save();
  7178. ctx.fillStyle = 'rgb(255, 255, 255)';
  7179. ctx.fillRect(0, 0, width, height);
  7180. ctx.restore();
  7181. return tempCanvas;
  7182. },
  7183. destroyCanvas: function destroyCanvas() {
  7184. var tempCanvas = tempCanvasCache;
  7185. if (tempCanvas) {
  7186. tempCanvas.width = 0;
  7187. tempCanvas.height = 0;
  7188. }
  7189. tempCanvasCache = null;
  7190. }
  7191. };
  7192. }();
  7193. var PDFThumbnailView = function () {
  7194. function PDFThumbnailView(_ref) {
  7195. var container = _ref.container,
  7196. id = _ref.id,
  7197. defaultViewport = _ref.defaultViewport,
  7198. linkService = _ref.linkService,
  7199. renderingQueue = _ref.renderingQueue,
  7200. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  7201. disableCanvasToImageConversion = _ref$disableCanvasToI === undefined ? false : _ref$disableCanvasToI,
  7202. _ref$l10n = _ref.l10n,
  7203. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  7204. _classCallCheck(this, PDFThumbnailView);
  7205. this.id = id;
  7206. this.renderingId = 'thumbnail' + id;
  7207. this.pageLabel = null;
  7208. this.pdfPage = null;
  7209. this.rotation = 0;
  7210. this.viewport = defaultViewport;
  7211. this.pdfPageRotate = defaultViewport.rotation;
  7212. this.linkService = linkService;
  7213. this.renderingQueue = renderingQueue;
  7214. this.renderTask = null;
  7215. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  7216. this.resume = null;
  7217. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  7218. this.pageWidth = this.viewport.width;
  7219. this.pageHeight = this.viewport.height;
  7220. this.pageRatio = this.pageWidth / this.pageHeight;
  7221. this.canvasWidth = THUMBNAIL_WIDTH;
  7222. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  7223. this.scale = this.canvasWidth / this.pageWidth;
  7224. this.l10n = l10n;
  7225. var anchor = document.createElement('a');
  7226. anchor.href = linkService.getAnchorUrl('#page=' + id);
  7227. this.l10n.get('thumb_page_title', { page: id }, 'Page {{page}}').then(function (msg) {
  7228. anchor.title = msg;
  7229. });
  7230. anchor.onclick = function () {
  7231. linkService.page = id;
  7232. return false;
  7233. };
  7234. this.anchor = anchor;
  7235. var div = document.createElement('div');
  7236. div.className = 'thumbnail';
  7237. div.setAttribute('data-page-number', this.id);
  7238. this.div = div;
  7239. if (id === 1) {
  7240. div.classList.add('selected');
  7241. }
  7242. var ring = document.createElement('div');
  7243. ring.className = 'thumbnailSelectionRing';
  7244. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  7245. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  7246. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  7247. this.ring = ring;
  7248. div.appendChild(ring);
  7249. anchor.appendChild(div);
  7250. container.appendChild(anchor);
  7251. }
  7252. _createClass(PDFThumbnailView, [{
  7253. key: 'setPdfPage',
  7254. value: function setPdfPage(pdfPage) {
  7255. this.pdfPage = pdfPage;
  7256. this.pdfPageRotate = pdfPage.rotate;
  7257. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  7258. this.viewport = pdfPage.getViewport(1, totalRotation);
  7259. this.reset();
  7260. }
  7261. }, {
  7262. key: 'reset',
  7263. value: function reset() {
  7264. this.cancelRendering();
  7265. this.pageWidth = this.viewport.width;
  7266. this.pageHeight = this.viewport.height;
  7267. this.pageRatio = this.pageWidth / this.pageHeight;
  7268. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  7269. this.scale = this.canvasWidth / this.pageWidth;
  7270. this.div.removeAttribute('data-loaded');
  7271. var ring = this.ring;
  7272. var childNodes = ring.childNodes;
  7273. for (var i = childNodes.length - 1; i >= 0; i--) {
  7274. ring.removeChild(childNodes[i]);
  7275. }
  7276. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  7277. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  7278. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  7279. if (this.canvas) {
  7280. this.canvas.width = 0;
  7281. this.canvas.height = 0;
  7282. delete this.canvas;
  7283. }
  7284. if (this.image) {
  7285. this.image.removeAttribute('src');
  7286. delete this.image;
  7287. }
  7288. }
  7289. }, {
  7290. key: 'update',
  7291. value: function update(rotation) {
  7292. if (typeof rotation !== 'undefined') {
  7293. this.rotation = rotation;
  7294. }
  7295. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  7296. this.viewport = this.viewport.clone({
  7297. scale: 1,
  7298. rotation: totalRotation
  7299. });
  7300. this.reset();
  7301. }
  7302. }, {
  7303. key: 'cancelRendering',
  7304. value: function cancelRendering() {
  7305. if (this.renderTask) {
  7306. this.renderTask.cancel();
  7307. this.renderTask = null;
  7308. }
  7309. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  7310. this.resume = null;
  7311. }
  7312. }, {
  7313. key: '_getPageDrawContext',
  7314. value: function _getPageDrawContext() {
  7315. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7316. var canvas = document.createElement('canvas');
  7317. this.canvas = canvas;
  7318. canvas.mozOpaque = true;
  7319. var ctx = canvas.getContext('2d', { alpha: false });
  7320. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  7321. canvas.width = this.canvasWidth * outputScale.sx | 0;
  7322. canvas.height = this.canvasHeight * outputScale.sy | 0;
  7323. canvas.style.width = this.canvasWidth + 'px';
  7324. canvas.style.height = this.canvasHeight + 'px';
  7325. if (!noCtxScale && outputScale.scaled) {
  7326. ctx.scale(outputScale.sx, outputScale.sy);
  7327. }
  7328. return ctx;
  7329. }
  7330. }, {
  7331. key: '_convertCanvasToImage',
  7332. value: function _convertCanvasToImage() {
  7333. var _this = this;
  7334. if (!this.canvas) {
  7335. return;
  7336. }
  7337. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  7338. return;
  7339. }
  7340. var id = this.renderingId;
  7341. var className = 'thumbnailImage';
  7342. if (this.disableCanvasToImageConversion) {
  7343. this.canvas.id = id;
  7344. this.canvas.className = className;
  7345. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
  7346. _this.canvas.setAttribute('aria-label', msg);
  7347. });
  7348. this.div.setAttribute('data-loaded', true);
  7349. this.ring.appendChild(this.canvas);
  7350. return;
  7351. }
  7352. var image = document.createElement('img');
  7353. image.id = id;
  7354. image.className = className;
  7355. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
  7356. image.setAttribute('aria-label', msg);
  7357. });
  7358. image.style.width = this.canvasWidth + 'px';
  7359. image.style.height = this.canvasHeight + 'px';
  7360. image.src = this.canvas.toDataURL();
  7361. this.image = image;
  7362. this.div.setAttribute('data-loaded', true);
  7363. this.ring.appendChild(image);
  7364. this.canvas.width = 0;
  7365. this.canvas.height = 0;
  7366. delete this.canvas;
  7367. }
  7368. }, {
  7369. key: 'draw',
  7370. value: function draw() {
  7371. var _this2 = this;
  7372. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  7373. console.error('Must be in new state before drawing');
  7374. return Promise.resolve(undefined);
  7375. }
  7376. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  7377. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  7378. var finishRenderTask = function finishRenderTask(error) {
  7379. if (renderTask === _this2.renderTask) {
  7380. _this2.renderTask = null;
  7381. }
  7382. if (error === 'cancelled' || error instanceof _pdfjsLib.RenderingCancelledException) {
  7383. renderCapability.resolve(undefined);
  7384. return;
  7385. }
  7386. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  7387. _this2._convertCanvasToImage();
  7388. if (!error) {
  7389. renderCapability.resolve(undefined);
  7390. } else {
  7391. renderCapability.reject(error);
  7392. }
  7393. };
  7394. var ctx = this._getPageDrawContext();
  7395. var drawViewport = this.viewport.clone({ scale: this.scale });
  7396. var renderContinueCallback = function renderContinueCallback(cont) {
  7397. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  7398. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  7399. _this2.resume = function () {
  7400. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  7401. cont();
  7402. };
  7403. return;
  7404. }
  7405. cont();
  7406. };
  7407. var renderContext = {
  7408. canvasContext: ctx,
  7409. viewport: drawViewport
  7410. };
  7411. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  7412. renderTask.onContinue = renderContinueCallback;
  7413. renderTask.promise.then(function () {
  7414. finishRenderTask(null);
  7415. }, function (error) {
  7416. finishRenderTask(error);
  7417. });
  7418. return renderCapability.promise;
  7419. }
  7420. }, {
  7421. key: 'setImage',
  7422. value: function setImage(pageView) {
  7423. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  7424. return;
  7425. }
  7426. var img = pageView.canvas;
  7427. if (!img) {
  7428. return;
  7429. }
  7430. if (!this.pdfPage) {
  7431. this.setPdfPage(pageView.pdfPage);
  7432. }
  7433. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  7434. var ctx = this._getPageDrawContext(true);
  7435. var canvas = ctx.canvas;
  7436. if (img.width <= 2 * canvas.width) {
  7437. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  7438. this._convertCanvasToImage();
  7439. return;
  7440. }
  7441. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  7442. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  7443. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  7444. var reducedImageCtx = reducedImage.getContext('2d');
  7445. while (reducedWidth > img.width || reducedHeight > img.height) {
  7446. reducedWidth >>= 1;
  7447. reducedHeight >>= 1;
  7448. }
  7449. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  7450. while (reducedWidth > 2 * canvas.width) {
  7451. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  7452. reducedWidth >>= 1;
  7453. reducedHeight >>= 1;
  7454. }
  7455. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  7456. this._convertCanvasToImage();
  7457. }
  7458. }, {
  7459. key: 'setPageLabel',
  7460. value: function setPageLabel(label) {
  7461. var _this3 = this;
  7462. this.pageLabel = typeof label === 'string' ? label : null;
  7463. this.l10n.get('thumb_page_title', { page: this.pageId }, 'Page {{page}}').then(function (msg) {
  7464. _this3.anchor.title = msg;
  7465. });
  7466. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  7467. return;
  7468. }
  7469. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) {
  7470. if (_this3.image) {
  7471. _this3.image.setAttribute('aria-label', ariaLabel);
  7472. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  7473. _this3.canvas.setAttribute('aria-label', ariaLabel);
  7474. }
  7475. });
  7476. }
  7477. }, {
  7478. key: 'pageId',
  7479. get: function get() {
  7480. return this.pageLabel !== null ? this.pageLabel : this.id;
  7481. }
  7482. }], [{
  7483. key: 'cleanup',
  7484. value: function cleanup() {
  7485. TempImageFactory.destroyCanvas();
  7486. }
  7487. }]);
  7488. return PDFThumbnailView;
  7489. }();
  7490. exports.PDFThumbnailView = PDFThumbnailView;
  7491. /***/ }),
  7492. /* 26 */
  7493. /***/ (function(module, exports, __webpack_require__) {
  7494. "use strict";
  7495. Object.defineProperty(exports, "__esModule", {
  7496. value: true
  7497. });
  7498. exports.PDFThumbnailViewer = undefined;
  7499. 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; }; }();
  7500. var _ui_utils = __webpack_require__(0);
  7501. var _pdf_thumbnail_view = __webpack_require__(25);
  7502. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7503. var THUMBNAIL_SCROLL_MARGIN = -19;
  7504. var PDFThumbnailViewer = function () {
  7505. function PDFThumbnailViewer(_ref) {
  7506. var container = _ref.container,
  7507. linkService = _ref.linkService,
  7508. renderingQueue = _ref.renderingQueue,
  7509. _ref$l10n = _ref.l10n,
  7510. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  7511. _classCallCheck(this, PDFThumbnailViewer);
  7512. this.container = container;
  7513. this.linkService = linkService;
  7514. this.renderingQueue = renderingQueue;
  7515. this.l10n = l10n;
  7516. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  7517. this._resetView();
  7518. }
  7519. _createClass(PDFThumbnailViewer, [{
  7520. key: '_scrollUpdated',
  7521. value: function _scrollUpdated() {
  7522. this.renderingQueue.renderHighestPriority();
  7523. }
  7524. }, {
  7525. key: 'getThumbnail',
  7526. value: function getThumbnail(index) {
  7527. return this._thumbnails[index];
  7528. }
  7529. }, {
  7530. key: '_getVisibleThumbs',
  7531. value: function _getVisibleThumbs() {
  7532. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  7533. }
  7534. }, {
  7535. key: 'scrollThumbnailIntoView',
  7536. value: function scrollThumbnailIntoView(page) {
  7537. var selected = document.querySelector('.thumbnail.selected');
  7538. if (selected) {
  7539. selected.classList.remove('selected');
  7540. }
  7541. var thumbnail = document.querySelector('div.thumbnail[data-page-number="' + page + '"]');
  7542. if (thumbnail) {
  7543. thumbnail.classList.add('selected');
  7544. }
  7545. var visibleThumbs = this._getVisibleThumbs();
  7546. var numVisibleThumbs = visibleThumbs.views.length;
  7547. if (numVisibleThumbs > 0) {
  7548. var first = visibleThumbs.first.id;
  7549. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  7550. if (page <= first || page >= last) {
  7551. (0, _ui_utils.scrollIntoView)(thumbnail, { top: THUMBNAIL_SCROLL_MARGIN });
  7552. }
  7553. }
  7554. }
  7555. }, {
  7556. key: 'cleanup',
  7557. value: function cleanup() {
  7558. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  7559. }
  7560. }, {
  7561. key: '_resetView',
  7562. value: function _resetView() {
  7563. this._thumbnails = [];
  7564. this._pageLabels = null;
  7565. this._pagesRotation = 0;
  7566. this._pagesRequests = [];
  7567. this.container.textContent = '';
  7568. }
  7569. }, {
  7570. key: 'setDocument',
  7571. value: function setDocument(pdfDocument) {
  7572. var _this = this;
  7573. if (this.pdfDocument) {
  7574. this._cancelRendering();
  7575. this._resetView();
  7576. }
  7577. this.pdfDocument = pdfDocument;
  7578. if (!pdfDocument) {
  7579. return;
  7580. }
  7581. pdfDocument.getPage(1).then(function (firstPage) {
  7582. var pagesCount = pdfDocument.numPages;
  7583. var viewport = firstPage.getViewport(1.0);
  7584. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  7585. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  7586. container: _this.container,
  7587. id: pageNum,
  7588. defaultViewport: viewport.clone(),
  7589. linkService: _this.linkService,
  7590. renderingQueue: _this.renderingQueue,
  7591. disableCanvasToImageConversion: false,
  7592. l10n: _this.l10n
  7593. });
  7594. _this._thumbnails.push(thumbnail);
  7595. }
  7596. }).catch(function (reason) {
  7597. console.error('Unable to initialize thumbnail viewer', reason);
  7598. });
  7599. }
  7600. }, {
  7601. key: '_cancelRendering',
  7602. value: function _cancelRendering() {
  7603. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7604. if (this._thumbnails[i]) {
  7605. this._thumbnails[i].cancelRendering();
  7606. }
  7607. }
  7608. }
  7609. }, {
  7610. key: 'setPageLabels',
  7611. value: function setPageLabels(labels) {
  7612. if (!this.pdfDocument) {
  7613. return;
  7614. }
  7615. if (!labels) {
  7616. this._pageLabels = null;
  7617. } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  7618. this._pageLabels = null;
  7619. console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
  7620. } else {
  7621. this._pageLabels = labels;
  7622. }
  7623. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7624. var label = this._pageLabels && this._pageLabels[i];
  7625. this._thumbnails[i].setPageLabel(label);
  7626. }
  7627. }
  7628. }, {
  7629. key: '_ensurePdfPageLoaded',
  7630. value: function _ensurePdfPageLoaded(thumbView) {
  7631. var _this2 = this;
  7632. if (thumbView.pdfPage) {
  7633. return Promise.resolve(thumbView.pdfPage);
  7634. }
  7635. var pageNumber = thumbView.id;
  7636. if (this._pagesRequests[pageNumber]) {
  7637. return this._pagesRequests[pageNumber];
  7638. }
  7639. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  7640. thumbView.setPdfPage(pdfPage);
  7641. _this2._pagesRequests[pageNumber] = null;
  7642. return pdfPage;
  7643. }).catch(function (reason) {
  7644. console.error('Unable to get page for thumb view', reason);
  7645. _this2._pagesRequests[pageNumber] = null;
  7646. });
  7647. this._pagesRequests[pageNumber] = promise;
  7648. return promise;
  7649. }
  7650. }, {
  7651. key: 'forceRendering',
  7652. value: function forceRendering() {
  7653. var _this3 = this;
  7654. var visibleThumbs = this._getVisibleThumbs();
  7655. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  7656. if (thumbView) {
  7657. this._ensurePdfPageLoaded(thumbView).then(function () {
  7658. _this3.renderingQueue.renderView(thumbView);
  7659. });
  7660. return true;
  7661. }
  7662. return false;
  7663. }
  7664. }, {
  7665. key: 'pagesRotation',
  7666. get: function get() {
  7667. return this._pagesRotation;
  7668. },
  7669. set: function set(rotation) {
  7670. if (!(typeof rotation === 'number' && rotation % 90 === 0)) {
  7671. throw new Error('Invalid thumbnails rotation angle.');
  7672. }
  7673. if (!this.pdfDocument) {
  7674. return;
  7675. }
  7676. this._pagesRotation = rotation;
  7677. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7678. this._thumbnails[i].update(rotation);
  7679. }
  7680. }
  7681. }]);
  7682. return PDFThumbnailViewer;
  7683. }();
  7684. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  7685. /***/ }),
  7686. /* 27 */
  7687. /***/ (function(module, exports, __webpack_require__) {
  7688. "use strict";
  7689. Object.defineProperty(exports, "__esModule", {
  7690. value: true
  7691. });
  7692. exports.PDFViewer = exports.PresentationModeState = undefined;
  7693. 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; }; }();
  7694. var _pdfjsLib = __webpack_require__(1);
  7695. var _ui_utils = __webpack_require__(0);
  7696. var _pdf_rendering_queue = __webpack_require__(3);
  7697. var _annotation_layer_builder = __webpack_require__(11);
  7698. var _dom_events = __webpack_require__(2);
  7699. var _pdf_page_view = __webpack_require__(22);
  7700. var _pdf_link_service = __webpack_require__(5);
  7701. var _text_layer_builder = __webpack_require__(30);
  7702. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7703. var PresentationModeState = {
  7704. UNKNOWN: 0,
  7705. NORMAL: 1,
  7706. CHANGING: 2,
  7707. FULLSCREEN: 3
  7708. };
  7709. var DEFAULT_CACHE_SIZE = 10;
  7710. function PDFPageViewBuffer(size) {
  7711. var data = [];
  7712. this.push = function cachePush(view) {
  7713. var i = data.indexOf(view);
  7714. if (i >= 0) {
  7715. data.splice(i, 1);
  7716. }
  7717. data.push(view);
  7718. if (data.length > size) {
  7719. data.shift().destroy();
  7720. }
  7721. };
  7722. this.resize = function (newSize) {
  7723. size = newSize;
  7724. while (data.length > size) {
  7725. data.shift().destroy();
  7726. }
  7727. };
  7728. }
  7729. function isSameScale(oldScale, newScale) {
  7730. if (newScale === oldScale) {
  7731. return true;
  7732. }
  7733. if (Math.abs(newScale - oldScale) < 1e-15) {
  7734. return true;
  7735. }
  7736. return false;
  7737. }
  7738. function isPortraitOrientation(size) {
  7739. return size.width <= size.height;
  7740. }
  7741. var PDFViewer = function () {
  7742. function PDFViewer(options) {
  7743. _classCallCheck(this, PDFViewer);
  7744. this.container = options.container;
  7745. this.viewer = options.viewer || options.container.firstElementChild;
  7746. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  7747. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  7748. this.downloadManager = options.downloadManager || null;
  7749. this.removePageBorders = options.removePageBorders || false;
  7750. this.enhanceTextSelection = options.enhanceTextSelection || false;
  7751. this.renderInteractiveForms = options.renderInteractiveForms || false;
  7752. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  7753. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  7754. this.l10n = options.l10n || _ui_utils.NullL10n;
  7755. this.defaultRenderingQueue = !options.renderingQueue;
  7756. if (this.defaultRenderingQueue) {
  7757. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  7758. this.renderingQueue.setViewer(this);
  7759. } else {
  7760. this.renderingQueue = options.renderingQueue;
  7761. }
  7762. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  7763. this.presentationModeState = PresentationModeState.UNKNOWN;
  7764. this._resetView();
  7765. if (this.removePageBorders) {
  7766. this.viewer.classList.add('removePageBorders');
  7767. }
  7768. }
  7769. _createClass(PDFViewer, [{
  7770. key: 'getPageView',
  7771. value: function getPageView(index) {
  7772. return this._pages[index];
  7773. }
  7774. }, {
  7775. key: '_setCurrentPageNumber',
  7776. value: function _setCurrentPageNumber(val) {
  7777. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7778. if (this._currentPageNumber === val) {
  7779. if (resetCurrentPageView) {
  7780. this._resetCurrentPageView();
  7781. }
  7782. return;
  7783. }
  7784. if (!(0 < val && val <= this.pagesCount)) {
  7785. console.error('PDFViewer._setCurrentPageNumber: "' + val + '" is out of bounds.');
  7786. return;
  7787. }
  7788. var arg = {
  7789. source: this,
  7790. pageNumber: val,
  7791. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  7792. };
  7793. this._currentPageNumber = val;
  7794. this.eventBus.dispatch('pagechanging', arg);
  7795. this.eventBus.dispatch('pagechange', arg);
  7796. if (resetCurrentPageView) {
  7797. this._resetCurrentPageView();
  7798. }
  7799. }
  7800. }, {
  7801. key: 'setDocument',
  7802. value: function setDocument(pdfDocument) {
  7803. var _this = this;
  7804. if (this.pdfDocument) {
  7805. this._cancelRendering();
  7806. this._resetView();
  7807. }
  7808. this.pdfDocument = pdfDocument;
  7809. if (!pdfDocument) {
  7810. return;
  7811. }
  7812. var pagesCount = pdfDocument.numPages;
  7813. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  7814. this.pagesPromise = pagesCapability.promise;
  7815. pagesCapability.promise.then(function () {
  7816. _this._pageViewsReady = true;
  7817. _this.eventBus.dispatch('pagesloaded', {
  7818. source: _this,
  7819. pagesCount: pagesCount
  7820. });
  7821. });
  7822. var isOnePageRenderedResolved = false;
  7823. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  7824. this.onePageRendered = onePageRenderedCapability.promise;
  7825. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  7826. pageView.onBeforeDraw = function () {
  7827. _this._buffer.push(pageView);
  7828. };
  7829. pageView.onAfterDraw = function () {
  7830. if (!isOnePageRenderedResolved) {
  7831. isOnePageRenderedResolved = true;
  7832. onePageRenderedCapability.resolve();
  7833. }
  7834. };
  7835. };
  7836. var firstPagePromise = pdfDocument.getPage(1);
  7837. this.firstPagePromise = firstPagePromise;
  7838. firstPagePromise.then(function (pdfPage) {
  7839. var scale = _this.currentScale;
  7840. var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
  7841. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  7842. var textLayerFactory = null;
  7843. if (!_pdfjsLib.PDFJS.disableTextLayer) {
  7844. textLayerFactory = _this;
  7845. }
  7846. var pageView = new _pdf_page_view.PDFPageView({
  7847. container: _this.viewer,
  7848. eventBus: _this.eventBus,
  7849. id: pageNum,
  7850. scale: scale,
  7851. defaultViewport: viewport.clone(),
  7852. renderingQueue: _this.renderingQueue,
  7853. textLayerFactory: textLayerFactory,
  7854. annotationLayerFactory: _this,
  7855. enhanceTextSelection: _this.enhanceTextSelection,
  7856. renderInteractiveForms: _this.renderInteractiveForms,
  7857. renderer: _this.renderer,
  7858. l10n: _this.l10n
  7859. });
  7860. bindOnAfterAndBeforeDraw(pageView);
  7861. _this._pages.push(pageView);
  7862. }
  7863. onePageRenderedCapability.promise.then(function () {
  7864. if (_pdfjsLib.PDFJS.disableAutoFetch) {
  7865. pagesCapability.resolve();
  7866. return;
  7867. }
  7868. var getPagesLeft = pagesCount;
  7869. var _loop = function _loop(_pageNum) {
  7870. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  7871. var pageView = _this._pages[_pageNum - 1];
  7872. if (!pageView.pdfPage) {
  7873. pageView.setPdfPage(pdfPage);
  7874. }
  7875. _this.linkService.cachePageRef(_pageNum, pdfPage.ref);
  7876. if (--getPagesLeft === 0) {
  7877. pagesCapability.resolve();
  7878. }
  7879. }, function (reason) {
  7880. console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);
  7881. if (--getPagesLeft === 0) {
  7882. pagesCapability.resolve();
  7883. }
  7884. });
  7885. };
  7886. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  7887. _loop(_pageNum);
  7888. }
  7889. });
  7890. _this.eventBus.dispatch('pagesinit', { source: _this });
  7891. if (_this.defaultRenderingQueue) {
  7892. _this.update();
  7893. }
  7894. if (_this.findController) {
  7895. _this.findController.resolveFirstPage();
  7896. }
  7897. }).catch(function (reason) {
  7898. console.error('Unable to initialize viewer', reason);
  7899. });
  7900. }
  7901. }, {
  7902. key: 'setPageLabels',
  7903. value: function setPageLabels(labels) {
  7904. if (!this.pdfDocument) {
  7905. return;
  7906. }
  7907. if (!labels) {
  7908. this._pageLabels = null;
  7909. } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  7910. this._pageLabels = null;
  7911. console.error('PDFViewer.setPageLabels: Invalid page labels.');
  7912. } else {
  7913. this._pageLabels = labels;
  7914. }
  7915. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  7916. var pageView = this._pages[i];
  7917. var label = this._pageLabels && this._pageLabels[i];
  7918. pageView.setPageLabel(label);
  7919. }
  7920. }
  7921. }, {
  7922. key: '_resetView',
  7923. value: function _resetView() {
  7924. this._pages = [];
  7925. this._currentPageNumber = 1;
  7926. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  7927. this._currentScaleValue = null;
  7928. this._pageLabels = null;
  7929. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  7930. this._location = null;
  7931. this._pagesRotation = 0;
  7932. this._pagesRequests = [];
  7933. this._pageViewsReady = false;
  7934. this.viewer.textContent = '';
  7935. }
  7936. }, {
  7937. key: '_scrollUpdate',
  7938. value: function _scrollUpdate() {
  7939. if (this.pagesCount === 0) {
  7940. return;
  7941. }
  7942. this.update();
  7943. }
  7944. }, {
  7945. key: '_setScaleDispatchEvent',
  7946. value: function _setScaleDispatchEvent(newScale, newValue) {
  7947. var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7948. var arg = {
  7949. source: this,
  7950. scale: newScale,
  7951. presetValue: preset ? newValue : undefined
  7952. };
  7953. this.eventBus.dispatch('scalechanging', arg);
  7954. this.eventBus.dispatch('scalechange', arg);
  7955. }
  7956. }, {
  7957. key: '_setScaleUpdatePages',
  7958. value: function _setScaleUpdatePages(newScale, newValue) {
  7959. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7960. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  7961. this._currentScaleValue = newValue.toString();
  7962. if (isSameScale(this._currentScale, newScale)) {
  7963. if (preset) {
  7964. this._setScaleDispatchEvent(newScale, newValue, true);
  7965. }
  7966. return;
  7967. }
  7968. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  7969. this._pages[i].update(newScale);
  7970. }
  7971. this._currentScale = newScale;
  7972. if (!noScroll) {
  7973. var page = this._currentPageNumber,
  7974. dest = void 0;
  7975. if (this._location && !_pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  7976. page = this._location.pageNumber;
  7977. dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];
  7978. }
  7979. this.scrollPageIntoView({
  7980. pageNumber: page,
  7981. destArray: dest,
  7982. allowNegativeOffset: true
  7983. });
  7984. }
  7985. this._setScaleDispatchEvent(newScale, newValue, preset);
  7986. if (this.defaultRenderingQueue) {
  7987. this.update();
  7988. }
  7989. }
  7990. }, {
  7991. key: '_setScale',
  7992. value: function _setScale(value) {
  7993. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7994. var scale = parseFloat(value);
  7995. if (scale > 0) {
  7996. this._setScaleUpdatePages(scale, value, noScroll, false);
  7997. } else {
  7998. var currentPage = this._pages[this._currentPageNumber - 1];
  7999. if (!currentPage) {
  8000. return;
  8001. }
  8002. var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8003. var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  8004. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  8005. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  8006. switch (value) {
  8007. case 'page-actual':
  8008. scale = 1;
  8009. break;
  8010. case 'page-width':
  8011. scale = pageWidthScale;
  8012. break;
  8013. case 'page-height':
  8014. scale = pageHeightScale;
  8015. break;
  8016. case 'page-fit':
  8017. scale = Math.min(pageWidthScale, pageHeightScale);
  8018. break;
  8019. case 'auto':
  8020. var isLandscape = currentPage.width > currentPage.height;
  8021. var horizontalScale = isLandscape ? Math.min(pageHeightScale, pageWidthScale) : pageWidthScale;
  8022. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  8023. break;
  8024. default:
  8025. console.error('PDFViewer._setScale: "' + value + '" is an unknown zoom value.');
  8026. return;
  8027. }
  8028. this._setScaleUpdatePages(scale, value, noScroll, true);
  8029. }
  8030. }
  8031. }, {
  8032. key: '_resetCurrentPageView',
  8033. value: function _resetCurrentPageView() {
  8034. if (this.isInPresentationMode) {
  8035. this._setScale(this._currentScaleValue, true);
  8036. }
  8037. var pageView = this._pages[this._currentPageNumber - 1];
  8038. (0, _ui_utils.scrollIntoView)(pageView.div);
  8039. }
  8040. }, {
  8041. key: 'scrollPageIntoView',
  8042. value: function scrollPageIntoView(params) {
  8043. if (!this.pdfDocument) {
  8044. return;
  8045. }
  8046. if (arguments.length > 1 || typeof params === 'number') {
  8047. console.warn('Call of scrollPageIntoView() with obsolete signature.');
  8048. var paramObj = {};
  8049. if (typeof params === 'number') {
  8050. paramObj.pageNumber = params;
  8051. }
  8052. if (arguments[1] instanceof Array) {
  8053. paramObj.destArray = arguments[1];
  8054. }
  8055. params = paramObj;
  8056. }
  8057. var pageNumber = params.pageNumber || 0;
  8058. var dest = params.destArray || null;
  8059. var allowNegativeOffset = params.allowNegativeOffset || false;
  8060. if (this.isInPresentationMode || !dest) {
  8061. this._setCurrentPageNumber(pageNumber, true);
  8062. return;
  8063. }
  8064. var pageView = this._pages[pageNumber - 1];
  8065. if (!pageView) {
  8066. console.error('PDFViewer.scrollPageIntoView: Invalid "pageNumber" parameter.');
  8067. return;
  8068. }
  8069. var x = 0,
  8070. y = 0;
  8071. var width = 0,
  8072. height = 0,
  8073. widthScale = void 0,
  8074. heightScale = void 0;
  8075. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  8076. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  8077. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  8078. var scale = 0;
  8079. switch (dest[1].name) {
  8080. case 'XYZ':
  8081. x = dest[2];
  8082. y = dest[3];
  8083. scale = dest[4];
  8084. x = x !== null ? x : 0;
  8085. y = y !== null ? y : pageHeight;
  8086. break;
  8087. case 'Fit':
  8088. case 'FitB':
  8089. scale = 'page-fit';
  8090. break;
  8091. case 'FitH':
  8092. case 'FitBH':
  8093. y = dest[2];
  8094. scale = 'page-width';
  8095. if (y === null && this._location) {
  8096. x = this._location.left;
  8097. y = this._location.top;
  8098. }
  8099. break;
  8100. case 'FitV':
  8101. case 'FitBV':
  8102. x = dest[2];
  8103. width = pageWidth;
  8104. height = pageHeight;
  8105. scale = 'page-height';
  8106. break;
  8107. case 'FitR':
  8108. x = dest[2];
  8109. y = dest[3];
  8110. width = dest[4] - x;
  8111. height = dest[5] - y;
  8112. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8113. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  8114. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  8115. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  8116. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  8117. break;
  8118. default:
  8119. console.error('PDFViewer.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');
  8120. return;
  8121. }
  8122. if (scale && scale !== this._currentScale) {
  8123. this.currentScaleValue = scale;
  8124. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  8125. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  8126. }
  8127. if (scale === 'page-fit' && !dest[4]) {
  8128. (0, _ui_utils.scrollIntoView)(pageView.div);
  8129. return;
  8130. }
  8131. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  8132. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  8133. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  8134. if (!allowNegativeOffset) {
  8135. left = Math.max(left, 0);
  8136. top = Math.max(top, 0);
  8137. }
  8138. (0, _ui_utils.scrollIntoView)(pageView.div, {
  8139. left: left,
  8140. top: top
  8141. });
  8142. }
  8143. }, {
  8144. key: '_updateLocation',
  8145. value: function _updateLocation(firstPage) {
  8146. var currentScale = this._currentScale;
  8147. var currentScaleValue = this._currentScaleValue;
  8148. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  8149. var pageNumber = firstPage.id;
  8150. var pdfOpenParams = '#page=' + pageNumber;
  8151. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  8152. var currentPageView = this._pages[pageNumber - 1];
  8153. var container = this.container;
  8154. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  8155. var intLeft = Math.round(topLeft[0]);
  8156. var intTop = Math.round(topLeft[1]);
  8157. pdfOpenParams += ',' + intLeft + ',' + intTop;
  8158. this._location = {
  8159. pageNumber: pageNumber,
  8160. scale: normalizedScaleValue,
  8161. top: intTop,
  8162. left: intLeft,
  8163. pdfOpenParams: pdfOpenParams
  8164. };
  8165. }
  8166. }, {
  8167. key: 'update',
  8168. value: function update() {
  8169. var visible = this._getVisiblePages();
  8170. var visiblePages = visible.views;
  8171. if (visiblePages.length === 0) {
  8172. return;
  8173. }
  8174. var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * visiblePages.length + 1);
  8175. this._buffer.resize(suggestedCacheSize);
  8176. this.renderingQueue.renderHighestPriority(visible);
  8177. var currentId = this._currentPageNumber;
  8178. var firstPage = visible.first;
  8179. var stillFullyVisible = false;
  8180. for (var i = 0, ii = visiblePages.length; i < ii; ++i) {
  8181. var page = visiblePages[i];
  8182. if (page.percent < 100) {
  8183. break;
  8184. }
  8185. if (page.id === currentId) {
  8186. stillFullyVisible = true;
  8187. break;
  8188. }
  8189. }
  8190. if (!stillFullyVisible) {
  8191. currentId = visiblePages[0].id;
  8192. }
  8193. if (!this.isInPresentationMode) {
  8194. this._setCurrentPageNumber(currentId);
  8195. }
  8196. this._updateLocation(firstPage);
  8197. this.eventBus.dispatch('updateviewarea', {
  8198. source: this,
  8199. location: this._location
  8200. });
  8201. }
  8202. }, {
  8203. key: 'containsElement',
  8204. value: function containsElement(element) {
  8205. return this.container.contains(element);
  8206. }
  8207. }, {
  8208. key: 'focus',
  8209. value: function focus() {
  8210. this.container.focus();
  8211. }
  8212. }, {
  8213. key: '_getVisiblePages',
  8214. value: function _getVisiblePages() {
  8215. if (!this.isInPresentationMode) {
  8216. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true);
  8217. }
  8218. var visible = [];
  8219. var currentPage = this._pages[this._currentPageNumber - 1];
  8220. visible.push({
  8221. id: currentPage.id,
  8222. view: currentPage
  8223. });
  8224. return {
  8225. first: currentPage,
  8226. last: currentPage,
  8227. views: visible
  8228. };
  8229. }
  8230. }, {
  8231. key: 'cleanup',
  8232. value: function cleanup() {
  8233. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8234. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8235. this._pages[i].reset();
  8236. }
  8237. }
  8238. }
  8239. }, {
  8240. key: '_cancelRendering',
  8241. value: function _cancelRendering() {
  8242. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8243. if (this._pages[i]) {
  8244. this._pages[i].cancelRendering();
  8245. }
  8246. }
  8247. }
  8248. }, {
  8249. key: '_ensurePdfPageLoaded',
  8250. value: function _ensurePdfPageLoaded(pageView) {
  8251. var _this2 = this;
  8252. if (pageView.pdfPage) {
  8253. return Promise.resolve(pageView.pdfPage);
  8254. }
  8255. var pageNumber = pageView.id;
  8256. if (this._pagesRequests[pageNumber]) {
  8257. return this._pagesRequests[pageNumber];
  8258. }
  8259. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  8260. if (!pageView.pdfPage) {
  8261. pageView.setPdfPage(pdfPage);
  8262. }
  8263. _this2._pagesRequests[pageNumber] = null;
  8264. return pdfPage;
  8265. }).catch(function (reason) {
  8266. console.error('Unable to get page for page view', reason);
  8267. _this2._pagesRequests[pageNumber] = null;
  8268. });
  8269. this._pagesRequests[pageNumber] = promise;
  8270. return promise;
  8271. }
  8272. }, {
  8273. key: 'forceRendering',
  8274. value: function forceRendering(currentlyVisiblePages) {
  8275. var _this3 = this;
  8276. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  8277. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
  8278. if (pageView) {
  8279. this._ensurePdfPageLoaded(pageView).then(function () {
  8280. _this3.renderingQueue.renderView(pageView);
  8281. });
  8282. return true;
  8283. }
  8284. return false;
  8285. }
  8286. }, {
  8287. key: 'getPageTextContent',
  8288. value: function getPageTextContent(pageIndex) {
  8289. return this.pdfDocument.getPage(pageIndex + 1).then(function (page) {
  8290. return page.getTextContent({ normalizeWhitespace: true });
  8291. });
  8292. }
  8293. }, {
  8294. key: 'createTextLayerBuilder',
  8295. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  8296. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8297. return new _text_layer_builder.TextLayerBuilder({
  8298. textLayerDiv: textLayerDiv,
  8299. eventBus: this.eventBus,
  8300. pageIndex: pageIndex,
  8301. viewport: viewport,
  8302. findController: this.isInPresentationMode ? null : this.findController,
  8303. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  8304. });
  8305. }
  8306. }, {
  8307. key: 'createAnnotationLayerBuilder',
  8308. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  8309. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8310. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  8311. return new _annotation_layer_builder.AnnotationLayerBuilder({
  8312. pageDiv: pageDiv,
  8313. pdfPage: pdfPage,
  8314. renderInteractiveForms: renderInteractiveForms,
  8315. linkService: this.linkService,
  8316. downloadManager: this.downloadManager,
  8317. l10n: l10n
  8318. });
  8319. }
  8320. }, {
  8321. key: 'setFindController',
  8322. value: function setFindController(findController) {
  8323. this.findController = findController;
  8324. }
  8325. }, {
  8326. key: 'getPagesOverview',
  8327. value: function getPagesOverview() {
  8328. var pagesOverview = this._pages.map(function (pageView) {
  8329. var viewport = pageView.pdfPage.getViewport(1);
  8330. return {
  8331. width: viewport.width,
  8332. height: viewport.height,
  8333. rotation: viewport.rotation
  8334. };
  8335. });
  8336. if (!this.enablePrintAutoRotate) {
  8337. return pagesOverview;
  8338. }
  8339. var isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);
  8340. return pagesOverview.map(function (size) {
  8341. if (isFirstPagePortrait === isPortraitOrientation(size)) {
  8342. return size;
  8343. }
  8344. return {
  8345. width: size.height,
  8346. height: size.width,
  8347. rotation: (size.rotation + 90) % 360
  8348. };
  8349. });
  8350. }
  8351. }, {
  8352. key: 'pagesCount',
  8353. get: function get() {
  8354. return this._pages.length;
  8355. }
  8356. }, {
  8357. key: 'pageViewsReady',
  8358. get: function get() {
  8359. return this._pageViewsReady;
  8360. }
  8361. }, {
  8362. key: 'currentPageNumber',
  8363. get: function get() {
  8364. return this._currentPageNumber;
  8365. },
  8366. set: function set(val) {
  8367. if ((val | 0) !== val) {
  8368. throw new Error('Invalid page number.');
  8369. }
  8370. if (!this.pdfDocument) {
  8371. return;
  8372. }
  8373. this._setCurrentPageNumber(val, true);
  8374. }
  8375. }, {
  8376. key: 'currentPageLabel',
  8377. get: function get() {
  8378. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  8379. },
  8380. set: function set(val) {
  8381. var pageNumber = val | 0;
  8382. if (this._pageLabels) {
  8383. var i = this._pageLabels.indexOf(val);
  8384. if (i >= 0) {
  8385. pageNumber = i + 1;
  8386. }
  8387. }
  8388. this.currentPageNumber = pageNumber;
  8389. }
  8390. }, {
  8391. key: 'currentScale',
  8392. get: function get() {
  8393. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  8394. },
  8395. set: function set(val) {
  8396. if (isNaN(val)) {
  8397. throw new Error('Invalid numeric scale');
  8398. }
  8399. if (!this.pdfDocument) {
  8400. return;
  8401. }
  8402. this._setScale(val, false);
  8403. }
  8404. }, {
  8405. key: 'currentScaleValue',
  8406. get: function get() {
  8407. return this._currentScaleValue;
  8408. },
  8409. set: function set(val) {
  8410. if (!this.pdfDocument) {
  8411. return;
  8412. }
  8413. this._setScale(val, false);
  8414. }
  8415. }, {
  8416. key: 'pagesRotation',
  8417. get: function get() {
  8418. return this._pagesRotation;
  8419. },
  8420. set: function set(rotation) {
  8421. if (!(typeof rotation === 'number' && rotation % 90 === 0)) {
  8422. throw new Error('Invalid pages rotation angle.');
  8423. }
  8424. if (!this.pdfDocument) {
  8425. return;
  8426. }
  8427. this._pagesRotation = rotation;
  8428. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8429. var pageView = this._pages[i];
  8430. pageView.update(pageView.scale, rotation);
  8431. }
  8432. this._setScale(this._currentScaleValue, true);
  8433. if (this.defaultRenderingQueue) {
  8434. this.update();
  8435. }
  8436. }
  8437. }, {
  8438. key: 'isInPresentationMode',
  8439. get: function get() {
  8440. return this.presentationModeState === PresentationModeState.FULLSCREEN;
  8441. }
  8442. }, {
  8443. key: 'isChangingPresentationMode',
  8444. get: function get() {
  8445. return this.presentationModeState === PresentationModeState.CHANGING;
  8446. }
  8447. }, {
  8448. key: 'isHorizontalScrollbarEnabled',
  8449. get: function get() {
  8450. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  8451. }
  8452. }, {
  8453. key: 'hasEqualPageSizes',
  8454. get: function get() {
  8455. var firstPageView = this._pages[0];
  8456. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  8457. var pageView = this._pages[i];
  8458. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  8459. return false;
  8460. }
  8461. }
  8462. return true;
  8463. }
  8464. }]);
  8465. return PDFViewer;
  8466. }();
  8467. exports.PresentationModeState = PresentationModeState;
  8468. exports.PDFViewer = PDFViewer;
  8469. /***/ }),
  8470. /* 28 */
  8471. /***/ (function(module, exports, __webpack_require__) {
  8472. "use strict";
  8473. Object.defineProperty(exports, "__esModule", {
  8474. value: true
  8475. });
  8476. exports.BasePreferences = undefined;
  8477. 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; };
  8478. 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; }; }();
  8479. var _ui_utils = __webpack_require__(0);
  8480. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8481. var defaultPreferences = null;
  8482. function getDefaultPreferences() {
  8483. if (!defaultPreferences) {
  8484. defaultPreferences = Promise.resolve({
  8485. "showPreviousViewOnLoad": true,
  8486. "defaultZoomValue": "",
  8487. "sidebarViewOnLoad": 0,
  8488. "enableHandToolOnLoad": false,
  8489. "cursorToolOnLoad": 0,
  8490. "enableWebGL": false,
  8491. "pdfBugEnabled": false,
  8492. "disableRange": false,
  8493. "disableStream": false,
  8494. "disableAutoFetch": false,
  8495. "disableFontFace": false,
  8496. "disableTextLayer": false,
  8497. "useOnlyCssZoom": false,
  8498. "externalLinkTarget": 0,
  8499. "enhanceTextSelection": false,
  8500. "renderer": "canvas",
  8501. "renderInteractiveForms": false,
  8502. "enablePrintAutoRotate": false,
  8503. "disablePageMode": false,
  8504. "disablePageLabels": false
  8505. });
  8506. }
  8507. return defaultPreferences;
  8508. }
  8509. var BasePreferences = function () {
  8510. function BasePreferences() {
  8511. var _this = this;
  8512. _classCallCheck(this, BasePreferences);
  8513. if (this.constructor === BasePreferences) {
  8514. throw new Error('Cannot initialize BasePreferences.');
  8515. }
  8516. this.prefs = null;
  8517. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  8518. Object.defineProperty(_this, 'defaults', {
  8519. value: Object.freeze(defaults),
  8520. writable: false,
  8521. enumerable: true,
  8522. configurable: false
  8523. });
  8524. _this.prefs = (0, _ui_utils.cloneObj)(defaults);
  8525. return _this._readFromStorage(defaults);
  8526. }).then(function (prefObj) {
  8527. if (prefObj) {
  8528. _this.prefs = prefObj;
  8529. }
  8530. });
  8531. }
  8532. _createClass(BasePreferences, [{
  8533. key: "_writeToStorage",
  8534. value: function _writeToStorage(prefObj) {
  8535. return Promise.reject(new Error('Not implemented: _writeToStorage'));
  8536. }
  8537. }, {
  8538. key: "_readFromStorage",
  8539. value: function _readFromStorage(prefObj) {
  8540. return Promise.reject(new Error('Not implemented: _readFromStorage'));
  8541. }
  8542. }, {
  8543. key: "reset",
  8544. value: function reset() {
  8545. var _this2 = this;
  8546. return this._initializedPromise.then(function () {
  8547. _this2.prefs = (0, _ui_utils.cloneObj)(_this2.defaults);
  8548. return _this2._writeToStorage(_this2.defaults);
  8549. });
  8550. }
  8551. }, {
  8552. key: "reload",
  8553. value: function reload() {
  8554. var _this3 = this;
  8555. return this._initializedPromise.then(function () {
  8556. return _this3._readFromStorage(_this3.defaults);
  8557. }).then(function (prefObj) {
  8558. if (prefObj) {
  8559. _this3.prefs = prefObj;
  8560. }
  8561. });
  8562. }
  8563. }, {
  8564. key: "set",
  8565. value: function set(name, value) {
  8566. var _this4 = this;
  8567. return this._initializedPromise.then(function () {
  8568. if (_this4.defaults[name] === undefined) {
  8569. throw new Error("Set preference: \"" + name + "\" is undefined.");
  8570. } else if (value === undefined) {
  8571. throw new Error('Set preference: no value is specified.');
  8572. }
  8573. var valueType = typeof value === "undefined" ? "undefined" : _typeof(value);
  8574. var defaultType = _typeof(_this4.defaults[name]);
  8575. if (valueType !== defaultType) {
  8576. if (valueType === 'number' && defaultType === 'string') {
  8577. value = value.toString();
  8578. } else {
  8579. throw new Error("Set preference: \"" + value + "\" is a " + valueType + ", " + ("expected a " + defaultType + "."));
  8580. }
  8581. } else {
  8582. if (valueType === 'number' && (value | 0) !== value) {
  8583. throw new Error("Set preference: \"" + value + "\" must be an integer.");
  8584. }
  8585. }
  8586. _this4.prefs[name] = value;
  8587. return _this4._writeToStorage(_this4.prefs);
  8588. });
  8589. }
  8590. }, {
  8591. key: "get",
  8592. value: function get(name) {
  8593. var _this5 = this;
  8594. return this._initializedPromise.then(function () {
  8595. var defaultValue = _this5.defaults[name];
  8596. if (defaultValue === undefined) {
  8597. throw new Error("Get preference: \"" + name + "\" is undefined.");
  8598. } else {
  8599. var prefValue = _this5.prefs[name];
  8600. if (prefValue !== undefined) {
  8601. return prefValue;
  8602. }
  8603. }
  8604. return defaultValue;
  8605. });
  8606. }
  8607. }]);
  8608. return BasePreferences;
  8609. }();
  8610. exports.BasePreferences = BasePreferences;
  8611. /***/ }),
  8612. /* 29 */
  8613. /***/ (function(module, exports, __webpack_require__) {
  8614. "use strict";
  8615. Object.defineProperty(exports, "__esModule", {
  8616. value: true
  8617. });
  8618. exports.SecondaryToolbar = undefined;
  8619. 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; }; }();
  8620. var _pdf_cursor_tools = __webpack_require__(6);
  8621. var _ui_utils = __webpack_require__(0);
  8622. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8623. var SecondaryToolbar = function () {
  8624. function SecondaryToolbar(options, mainContainer, eventBus) {
  8625. _classCallCheck(this, SecondaryToolbar);
  8626. this.toolbar = options.toolbar;
  8627. this.toggleButton = options.toggleButton;
  8628. this.toolbarButtonContainer = options.toolbarButtonContainer;
  8629. this.buttons = [{
  8630. element: options.presentationModeButton,
  8631. eventName: 'presentationmode',
  8632. close: true
  8633. }, {
  8634. element: options.openFileButton,
  8635. eventName: 'openfile',
  8636. close: true
  8637. }, {
  8638. element: options.printButton,
  8639. eventName: 'print',
  8640. close: true
  8641. }, {
  8642. element: options.downloadButton,
  8643. eventName: 'download',
  8644. close: true
  8645. }, {
  8646. element: options.viewBookmarkButton,
  8647. eventName: null,
  8648. close: true
  8649. }, {
  8650. element: options.firstPageButton,
  8651. eventName: 'firstpage',
  8652. close: true
  8653. }, {
  8654. element: options.lastPageButton,
  8655. eventName: 'lastpage',
  8656. close: true
  8657. }, {
  8658. element: options.pageRotateCwButton,
  8659. eventName: 'rotatecw',
  8660. close: false
  8661. }, {
  8662. element: options.pageRotateCcwButton,
  8663. eventName: 'rotateccw',
  8664. close: false
  8665. }, {
  8666. element: options.cursorSelectToolButton,
  8667. eventName: 'switchcursortool',
  8668. eventDetails: { tool: _pdf_cursor_tools.CursorTool.SELECT },
  8669. close: true
  8670. }, {
  8671. element: options.cursorHandToolButton,
  8672. eventName: 'switchcursortool',
  8673. eventDetails: { tool: _pdf_cursor_tools.CursorTool.HAND },
  8674. close: true
  8675. }, {
  8676. element: options.documentPropertiesButton,
  8677. eventName: 'documentproperties',
  8678. close: true
  8679. }];
  8680. this.items = {
  8681. firstPage: options.firstPageButton,
  8682. lastPage: options.lastPageButton,
  8683. pageRotateCw: options.pageRotateCwButton,
  8684. pageRotateCcw: options.pageRotateCcwButton
  8685. };
  8686. this.mainContainer = mainContainer;
  8687. this.eventBus = eventBus;
  8688. this.opened = false;
  8689. this.containerHeight = null;
  8690. this.previousContainerHeight = null;
  8691. this.reset();
  8692. this._bindClickListeners();
  8693. this._bindCursorToolsListener(options);
  8694. this.eventBus.on('resize', this._setMaxHeight.bind(this));
  8695. }
  8696. _createClass(SecondaryToolbar, [{
  8697. key: 'setPageNumber',
  8698. value: function setPageNumber(pageNumber) {
  8699. this.pageNumber = pageNumber;
  8700. this._updateUIState();
  8701. }
  8702. }, {
  8703. key: 'setPagesCount',
  8704. value: function setPagesCount(pagesCount) {
  8705. this.pagesCount = pagesCount;
  8706. this._updateUIState();
  8707. }
  8708. }, {
  8709. key: 'reset',
  8710. value: function reset() {
  8711. this.pageNumber = 0;
  8712. this.pagesCount = 0;
  8713. this._updateUIState();
  8714. }
  8715. }, {
  8716. key: '_updateUIState',
  8717. value: function _updateUIState() {
  8718. this.items.firstPage.disabled = this.pageNumber <= 1;
  8719. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  8720. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  8721. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  8722. }
  8723. }, {
  8724. key: '_bindClickListeners',
  8725. value: function _bindClickListeners() {
  8726. var _this = this;
  8727. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  8728. var _loop = function _loop(button) {
  8729. var _buttons$button = _this.buttons[button],
  8730. element = _buttons$button.element,
  8731. eventName = _buttons$button.eventName,
  8732. close = _buttons$button.close,
  8733. eventDetails = _buttons$button.eventDetails;
  8734. element.addEventListener('click', function (evt) {
  8735. if (eventName !== null) {
  8736. var details = { source: _this };
  8737. for (var property in eventDetails) {
  8738. details[property] = eventDetails[property];
  8739. }
  8740. _this.eventBus.dispatch(eventName, details);
  8741. }
  8742. if (close) {
  8743. _this.close();
  8744. }
  8745. });
  8746. };
  8747. for (var button in this.buttons) {
  8748. _loop(button);
  8749. }
  8750. }
  8751. }, {
  8752. key: '_bindCursorToolsListener',
  8753. value: function _bindCursorToolsListener(buttons) {
  8754. this.eventBus.on('cursortoolchanged', function (evt) {
  8755. buttons.cursorSelectToolButton.classList.remove('toggled');
  8756. buttons.cursorHandToolButton.classList.remove('toggled');
  8757. switch (evt.tool) {
  8758. case _pdf_cursor_tools.CursorTool.SELECT:
  8759. buttons.cursorSelectToolButton.classList.add('toggled');
  8760. break;
  8761. case _pdf_cursor_tools.CursorTool.HAND:
  8762. buttons.cursorHandToolButton.classList.add('toggled');
  8763. break;
  8764. }
  8765. });
  8766. }
  8767. }, {
  8768. key: 'open',
  8769. value: function open() {
  8770. if (this.opened) {
  8771. return;
  8772. }
  8773. this.opened = true;
  8774. this._setMaxHeight();
  8775. this.toggleButton.classList.add('toggled');
  8776. this.toolbar.classList.remove('hidden');
  8777. }
  8778. }, {
  8779. key: 'close',
  8780. value: function close() {
  8781. if (!this.opened) {
  8782. return;
  8783. }
  8784. this.opened = false;
  8785. this.toolbar.classList.add('hidden');
  8786. this.toggleButton.classList.remove('toggled');
  8787. }
  8788. }, {
  8789. key: 'toggle',
  8790. value: function toggle() {
  8791. if (this.opened) {
  8792. this.close();
  8793. } else {
  8794. this.open();
  8795. }
  8796. }
  8797. }, {
  8798. key: '_setMaxHeight',
  8799. value: function _setMaxHeight() {
  8800. if (!this.opened) {
  8801. return;
  8802. }
  8803. this.containerHeight = this.mainContainer.clientHeight;
  8804. if (this.containerHeight === this.previousContainerHeight) {
  8805. return;
  8806. }
  8807. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  8808. this.previousContainerHeight = this.containerHeight;
  8809. }
  8810. }, {
  8811. key: 'isOpen',
  8812. get: function get() {
  8813. return this.opened;
  8814. }
  8815. }]);
  8816. return SecondaryToolbar;
  8817. }();
  8818. exports.SecondaryToolbar = SecondaryToolbar;
  8819. /***/ }),
  8820. /* 30 */
  8821. /***/ (function(module, exports, __webpack_require__) {
  8822. "use strict";
  8823. Object.defineProperty(exports, "__esModule", {
  8824. value: true
  8825. });
  8826. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
  8827. 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; }; }();
  8828. var _dom_events = __webpack_require__(2);
  8829. var _pdfjsLib = __webpack_require__(1);
  8830. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8831. var EXPAND_DIVS_TIMEOUT = 300;
  8832. var TextLayerBuilder = function () {
  8833. function TextLayerBuilder(_ref) {
  8834. var textLayerDiv = _ref.textLayerDiv,
  8835. eventBus = _ref.eventBus,
  8836. pageIndex = _ref.pageIndex,
  8837. viewport = _ref.viewport,
  8838. _ref$findController = _ref.findController,
  8839. findController = _ref$findController === undefined ? null : _ref$findController,
  8840. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  8841. enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false : _ref$enhanceTextSelec;
  8842. _classCallCheck(this, TextLayerBuilder);
  8843. this.textLayerDiv = textLayerDiv;
  8844. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  8845. this.textContent = null;
  8846. this.textContentItemsStr = [];
  8847. this.textContentStream = null;
  8848. this.renderingDone = false;
  8849. this.pageIdx = pageIndex;
  8850. this.pageNumber = this.pageIdx + 1;
  8851. this.matches = [];
  8852. this.viewport = viewport;
  8853. this.textDivs = [];
  8854. this.findController = findController;
  8855. this.textLayerRenderTask = null;
  8856. this.enhanceTextSelection = enhanceTextSelection;
  8857. this._bindMouse();
  8858. }
  8859. _createClass(TextLayerBuilder, [{
  8860. key: '_finishRendering',
  8861. value: function _finishRendering() {
  8862. this.renderingDone = true;
  8863. if (!this.enhanceTextSelection) {
  8864. var endOfContent = document.createElement('div');
  8865. endOfContent.className = 'endOfContent';
  8866. this.textLayerDiv.appendChild(endOfContent);
  8867. }
  8868. this.eventBus.dispatch('textlayerrendered', {
  8869. source: this,
  8870. pageNumber: this.pageNumber,
  8871. numTextDivs: this.textDivs.length
  8872. });
  8873. }
  8874. }, {
  8875. key: 'render',
  8876. value: function render() {
  8877. var _this = this;
  8878. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  8879. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  8880. return;
  8881. }
  8882. this.cancel();
  8883. this.textDivs = [];
  8884. var textLayerFrag = document.createDocumentFragment();
  8885. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  8886. textContent: this.textContent,
  8887. textContentStream: this.textContentStream,
  8888. container: textLayerFrag,
  8889. viewport: this.viewport,
  8890. textDivs: this.textDivs,
  8891. textContentItemsStr: this.textContentItemsStr,
  8892. timeout: timeout,
  8893. enhanceTextSelection: this.enhanceTextSelection
  8894. });
  8895. this.textLayerRenderTask.promise.then(function () {
  8896. _this.textLayerDiv.appendChild(textLayerFrag);
  8897. _this._finishRendering();
  8898. _this.updateMatches();
  8899. }, function (reason) {});
  8900. }
  8901. }, {
  8902. key: 'cancel',
  8903. value: function cancel() {
  8904. if (this.textLayerRenderTask) {
  8905. this.textLayerRenderTask.cancel();
  8906. this.textLayerRenderTask = null;
  8907. }
  8908. }
  8909. }, {
  8910. key: 'setTextContentStream',
  8911. value: function setTextContentStream(readableStream) {
  8912. this.cancel();
  8913. this.textContentStream = readableStream;
  8914. }
  8915. }, {
  8916. key: 'setTextContent',
  8917. value: function setTextContent(textContent) {
  8918. this.cancel();
  8919. this.textContent = textContent;
  8920. }
  8921. }, {
  8922. key: 'convertMatches',
  8923. value: function convertMatches(matches, matchesLength) {
  8924. var i = 0;
  8925. var iIndex = 0;
  8926. var textContentItemsStr = this.textContentItemsStr;
  8927. var end = textContentItemsStr.length - 1;
  8928. var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
  8929. var ret = [];
  8930. if (!matches) {
  8931. return ret;
  8932. }
  8933. for (var m = 0, len = matches.length; m < len; m++) {
  8934. var matchIdx = matches[m];
  8935. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  8936. iIndex += textContentItemsStr[i].length;
  8937. i++;
  8938. }
  8939. if (i === textContentItemsStr.length) {
  8940. console.error('Could not find a matching mapping');
  8941. }
  8942. var match = {
  8943. begin: {
  8944. divIdx: i,
  8945. offset: matchIdx - iIndex
  8946. }
  8947. };
  8948. if (matchesLength) {
  8949. matchIdx += matchesLength[m];
  8950. } else {
  8951. matchIdx += queryLen;
  8952. }
  8953. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  8954. iIndex += textContentItemsStr[i].length;
  8955. i++;
  8956. }
  8957. match.end = {
  8958. divIdx: i,
  8959. offset: matchIdx - iIndex
  8960. };
  8961. ret.push(match);
  8962. }
  8963. return ret;
  8964. }
  8965. }, {
  8966. key: 'renderMatches',
  8967. value: function renderMatches(matches) {
  8968. if (matches.length === 0) {
  8969. return;
  8970. }
  8971. var textContentItemsStr = this.textContentItemsStr;
  8972. var textDivs = this.textDivs;
  8973. var prevEnd = null;
  8974. var pageIdx = this.pageIdx;
  8975. var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx;
  8976. var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
  8977. var highlightAll = this.findController === null ? false : this.findController.state.highlightAll;
  8978. var infinity = {
  8979. divIdx: -1,
  8980. offset: undefined
  8981. };
  8982. function beginText(begin, className) {
  8983. var divIdx = begin.divIdx;
  8984. textDivs[divIdx].textContent = '';
  8985. appendTextToDiv(divIdx, 0, begin.offset, className);
  8986. }
  8987. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  8988. var div = textDivs[divIdx];
  8989. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  8990. var node = document.createTextNode(content);
  8991. if (className) {
  8992. var span = document.createElement('span');
  8993. span.className = className;
  8994. span.appendChild(node);
  8995. div.appendChild(span);
  8996. return;
  8997. }
  8998. div.appendChild(node);
  8999. }
  9000. var i0 = selectedMatchIdx,
  9001. i1 = i0 + 1;
  9002. if (highlightAll) {
  9003. i0 = 0;
  9004. i1 = matches.length;
  9005. } else if (!isSelectedPage) {
  9006. return;
  9007. }
  9008. for (var i = i0; i < i1; i++) {
  9009. var match = matches[i];
  9010. var begin = match.begin;
  9011. var end = match.end;
  9012. var isSelected = isSelectedPage && i === selectedMatchIdx;
  9013. var highlightSuffix = isSelected ? ' selected' : '';
  9014. if (this.findController) {
  9015. this.findController.updateMatchPosition(pageIdx, i, textDivs, begin.divIdx);
  9016. }
  9017. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  9018. if (prevEnd !== null) {
  9019. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  9020. }
  9021. beginText(begin);
  9022. } else {
  9023. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  9024. }
  9025. if (begin.divIdx === end.divIdx) {
  9026. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  9027. } else {
  9028. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  9029. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  9030. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  9031. }
  9032. beginText(end, 'highlight end' + highlightSuffix);
  9033. }
  9034. prevEnd = end;
  9035. }
  9036. if (prevEnd) {
  9037. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  9038. }
  9039. }
  9040. }, {
  9041. key: 'updateMatches',
  9042. value: function updateMatches() {
  9043. if (!this.renderingDone) {
  9044. return;
  9045. }
  9046. var matches = this.matches;
  9047. var textDivs = this.textDivs;
  9048. var textContentItemsStr = this.textContentItemsStr;
  9049. var clearedUntilDivIdx = -1;
  9050. for (var i = 0, len = matches.length; i < len; i++) {
  9051. var match = matches[i];
  9052. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  9053. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  9054. var div = textDivs[n];
  9055. div.textContent = textContentItemsStr[n];
  9056. div.className = '';
  9057. }
  9058. clearedUntilDivIdx = match.end.divIdx + 1;
  9059. }
  9060. if (this.findController === null || !this.findController.active) {
  9061. return;
  9062. }
  9063. var pageMatches = void 0,
  9064. pageMatchesLength = void 0;
  9065. if (this.findController !== null) {
  9066. pageMatches = this.findController.pageMatches[this.pageIdx] || null;
  9067. pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null;
  9068. }
  9069. this.matches = this.convertMatches(pageMatches, pageMatchesLength);
  9070. this.renderMatches(this.matches);
  9071. }
  9072. }, {
  9073. key: '_bindMouse',
  9074. value: function _bindMouse() {
  9075. var _this2 = this;
  9076. var div = this.textLayerDiv;
  9077. var expandDivsTimer = null;
  9078. div.addEventListener('mousedown', function (evt) {
  9079. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  9080. _this2.textLayerRenderTask.expandTextDivs(true);
  9081. if (expandDivsTimer) {
  9082. clearTimeout(expandDivsTimer);
  9083. expandDivsTimer = null;
  9084. }
  9085. return;
  9086. }
  9087. var end = div.querySelector('.endOfContent');
  9088. if (!end) {
  9089. return;
  9090. }
  9091. var adjustTop = evt.target !== div;
  9092. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  9093. if (adjustTop) {
  9094. var divBounds = div.getBoundingClientRect();
  9095. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  9096. end.style.top = (r * 100).toFixed(2) + '%';
  9097. }
  9098. end.classList.add('active');
  9099. });
  9100. div.addEventListener('mouseup', function () {
  9101. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  9102. expandDivsTimer = setTimeout(function () {
  9103. if (_this2.textLayerRenderTask) {
  9104. _this2.textLayerRenderTask.expandTextDivs(false);
  9105. }
  9106. expandDivsTimer = null;
  9107. }, EXPAND_DIVS_TIMEOUT);
  9108. return;
  9109. }
  9110. var end = div.querySelector('.endOfContent');
  9111. if (!end) {
  9112. return;
  9113. }
  9114. end.style.top = '';
  9115. end.classList.remove('active');
  9116. });
  9117. }
  9118. }]);
  9119. return TextLayerBuilder;
  9120. }();
  9121. var DefaultTextLayerFactory = function () {
  9122. function DefaultTextLayerFactory() {
  9123. _classCallCheck(this, DefaultTextLayerFactory);
  9124. }
  9125. _createClass(DefaultTextLayerFactory, [{
  9126. key: 'createTextLayerBuilder',
  9127. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9128. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9129. return new TextLayerBuilder({
  9130. textLayerDiv: textLayerDiv,
  9131. pageIndex: pageIndex,
  9132. viewport: viewport,
  9133. enhanceTextSelection: enhanceTextSelection
  9134. });
  9135. }
  9136. }]);
  9137. return DefaultTextLayerFactory;
  9138. }();
  9139. exports.TextLayerBuilder = TextLayerBuilder;
  9140. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  9141. /***/ }),
  9142. /* 31 */
  9143. /***/ (function(module, exports, __webpack_require__) {
  9144. "use strict";
  9145. Object.defineProperty(exports, "__esModule", {
  9146. value: true
  9147. });
  9148. exports.Toolbar = undefined;
  9149. 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; }; }();
  9150. var _ui_utils = __webpack_require__(0);
  9151. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9152. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  9153. var SCALE_SELECT_CONTAINER_PADDING = 8;
  9154. var SCALE_SELECT_PADDING = 22;
  9155. var Toolbar = function () {
  9156. function Toolbar(options, mainContainer, eventBus) {
  9157. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  9158. _classCallCheck(this, Toolbar);
  9159. this.toolbar = options.container;
  9160. this.mainContainer = mainContainer;
  9161. this.eventBus = eventBus;
  9162. this.l10n = l10n;
  9163. this.items = options;
  9164. this._wasLocalized = false;
  9165. this.reset();
  9166. this._bindListeners();
  9167. }
  9168. _createClass(Toolbar, [{
  9169. key: 'setPageNumber',
  9170. value: function setPageNumber(pageNumber, pageLabel) {
  9171. this.pageNumber = pageNumber;
  9172. this.pageLabel = pageLabel;
  9173. this._updateUIState(false);
  9174. }
  9175. }, {
  9176. key: 'setPagesCount',
  9177. value: function setPagesCount(pagesCount, hasPageLabels) {
  9178. this.pagesCount = pagesCount;
  9179. this.hasPageLabels = hasPageLabels;
  9180. this._updateUIState(true);
  9181. }
  9182. }, {
  9183. key: 'setPageScale',
  9184. value: function setPageScale(pageScaleValue, pageScale) {
  9185. this.pageScaleValue = pageScaleValue;
  9186. this.pageScale = pageScale;
  9187. this._updateUIState(false);
  9188. }
  9189. }, {
  9190. key: 'reset',
  9191. value: function reset() {
  9192. this.pageNumber = 0;
  9193. this.pageLabel = null;
  9194. this.hasPageLabels = false;
  9195. this.pagesCount = 0;
  9196. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  9197. this.pageScale = _ui_utils.DEFAULT_SCALE;
  9198. this._updateUIState(true);
  9199. }
  9200. }, {
  9201. key: '_bindListeners',
  9202. value: function _bindListeners() {
  9203. var _this = this;
  9204. var eventBus = this.eventBus,
  9205. items = this.items;
  9206. var self = this;
  9207. items.previous.addEventListener('click', function () {
  9208. eventBus.dispatch('previouspage');
  9209. });
  9210. items.next.addEventListener('click', function () {
  9211. eventBus.dispatch('nextpage');
  9212. });
  9213. items.zoomIn.addEventListener('click', function () {
  9214. eventBus.dispatch('zoomin');
  9215. });
  9216. items.zoomOut.addEventListener('click', function () {
  9217. eventBus.dispatch('zoomout');
  9218. });
  9219. items.pageNumber.addEventListener('click', function () {
  9220. this.select();
  9221. });
  9222. items.pageNumber.addEventListener('change', function () {
  9223. eventBus.dispatch('pagenumberchanged', {
  9224. source: self,
  9225. value: this.value
  9226. });
  9227. });
  9228. items.scaleSelect.addEventListener('change', function () {
  9229. if (this.value === 'custom') {
  9230. return;
  9231. }
  9232. eventBus.dispatch('scalechanged', {
  9233. source: self,
  9234. value: this.value
  9235. });
  9236. });
  9237. items.presentationModeButton.addEventListener('click', function () {
  9238. eventBus.dispatch('presentationmode');
  9239. });
  9240. items.openFile.addEventListener('click', function () {
  9241. eventBus.dispatch('openfile');
  9242. });
  9243. items.print.addEventListener('click', function () {
  9244. eventBus.dispatch('print');
  9245. });
  9246. items.download.addEventListener('click', function () {
  9247. eventBus.dispatch('download');
  9248. });
  9249. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  9250. eventBus.on('localized', function () {
  9251. _this._localized();
  9252. });
  9253. }
  9254. }, {
  9255. key: '_localized',
  9256. value: function _localized() {
  9257. this._wasLocalized = true;
  9258. this._adjustScaleWidth();
  9259. this._updateUIState(true);
  9260. }
  9261. }, {
  9262. key: '_updateUIState',
  9263. value: function _updateUIState() {
  9264. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9265. if (!this._wasLocalized) {
  9266. return;
  9267. }
  9268. var pageNumber = this.pageNumber,
  9269. pagesCount = this.pagesCount,
  9270. items = this.items;
  9271. var scaleValue = (this.pageScaleValue || this.pageScale).toString();
  9272. var scale = this.pageScale;
  9273. if (resetNumPages) {
  9274. if (this.hasPageLabels) {
  9275. items.pageNumber.type = 'text';
  9276. } else {
  9277. items.pageNumber.type = 'number';
  9278. this.l10n.get('of_pages', { pagesCount: pagesCount }, 'of {{pagesCount}}').then(function (msg) {
  9279. items.numPages.textContent = msg;
  9280. });
  9281. }
  9282. items.pageNumber.max = pagesCount;
  9283. }
  9284. if (this.hasPageLabels) {
  9285. items.pageNumber.value = this.pageLabel;
  9286. this.l10n.get('page_of_pages', {
  9287. pageNumber: pageNumber,
  9288. pagesCount: pagesCount
  9289. }, '({{pageNumber}} of {{pagesCount}})').then(function (msg) {
  9290. items.numPages.textContent = msg;
  9291. });
  9292. } else {
  9293. items.pageNumber.value = pageNumber;
  9294. }
  9295. items.previous.disabled = pageNumber <= 1;
  9296. items.next.disabled = pageNumber >= pagesCount;
  9297. items.zoomOut.disabled = scale <= _ui_utils.MIN_SCALE;
  9298. items.zoomIn.disabled = scale >= _ui_utils.MAX_SCALE;
  9299. var customScale = Math.round(scale * 10000) / 100;
  9300. this.l10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%').then(function (msg) {
  9301. var options = items.scaleSelect.options;
  9302. var predefinedValueFound = false;
  9303. for (var i = 0, ii = options.length; i < ii; i++) {
  9304. var option = options[i];
  9305. if (option.value !== scaleValue) {
  9306. option.selected = false;
  9307. continue;
  9308. }
  9309. option.selected = true;
  9310. predefinedValueFound = true;
  9311. }
  9312. if (!predefinedValueFound) {
  9313. items.customScaleOption.textContent = msg;
  9314. items.customScaleOption.selected = true;
  9315. }
  9316. });
  9317. }
  9318. }, {
  9319. key: 'updateLoadingIndicatorState',
  9320. value: function updateLoadingIndicatorState() {
  9321. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9322. var pageNumberInput = this.items.pageNumber;
  9323. if (loading) {
  9324. pageNumberInput.classList.add(PAGE_NUMBER_LOADING_INDICATOR);
  9325. } else {
  9326. pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR);
  9327. }
  9328. }
  9329. }, {
  9330. key: '_adjustScaleWidth',
  9331. value: function _adjustScaleWidth() {
  9332. var container = this.items.scaleSelectContainer;
  9333. var select = this.items.scaleSelect;
  9334. _ui_utils.animationStarted.then(function () {
  9335. if (container.clientWidth === 0) {
  9336. container.setAttribute('style', 'display: inherit;');
  9337. }
  9338. if (container.clientWidth > 0) {
  9339. select.setAttribute('style', 'min-width: inherit;');
  9340. var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
  9341. select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
  9342. container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;');
  9343. }
  9344. });
  9345. }
  9346. }]);
  9347. return Toolbar;
  9348. }();
  9349. exports.Toolbar = Toolbar;
  9350. /***/ }),
  9351. /* 32 */
  9352. /***/ (function(module, exports, __webpack_require__) {
  9353. "use strict";
  9354. Object.defineProperty(exports, "__esModule", {
  9355. value: true
  9356. });
  9357. 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; }; }();
  9358. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9359. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  9360. var ViewHistory = function () {
  9361. function ViewHistory(fingerprint) {
  9362. var _this = this;
  9363. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  9364. _classCallCheck(this, ViewHistory);
  9365. this.fingerprint = fingerprint;
  9366. this.cacheSize = cacheSize;
  9367. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  9368. var database = JSON.parse(databaseStr || '{}');
  9369. if (!('files' in database)) {
  9370. database.files = [];
  9371. }
  9372. if (database.files.length >= _this.cacheSize) {
  9373. database.files.shift();
  9374. }
  9375. var index = void 0;
  9376. for (var i = 0, length = database.files.length; i < length; i++) {
  9377. var branch = database.files[i];
  9378. if (branch.fingerprint === _this.fingerprint) {
  9379. index = i;
  9380. break;
  9381. }
  9382. }
  9383. if (typeof index !== 'number') {
  9384. index = database.files.push({ fingerprint: _this.fingerprint }) - 1;
  9385. }
  9386. _this.file = database.files[index];
  9387. _this.database = database;
  9388. });
  9389. }
  9390. _createClass(ViewHistory, [{
  9391. key: '_writeToStorage',
  9392. value: function _writeToStorage() {
  9393. var _this2 = this;
  9394. return new Promise(function (resolve) {
  9395. var databaseStr = JSON.stringify(_this2.database);
  9396. localStorage.setItem('pdfjs.history', databaseStr);
  9397. resolve();
  9398. });
  9399. }
  9400. }, {
  9401. key: '_readFromStorage',
  9402. value: function _readFromStorage() {
  9403. return new Promise(function (resolve) {
  9404. var value = localStorage.getItem('pdfjs.history');
  9405. if (!value) {
  9406. var databaseStr = localStorage.getItem('database');
  9407. if (databaseStr) {
  9408. try {
  9409. var database = JSON.parse(databaseStr);
  9410. if (typeof database.files[0].fingerprint === 'string') {
  9411. localStorage.setItem('pdfjs.history', databaseStr);
  9412. localStorage.removeItem('database');
  9413. value = databaseStr;
  9414. }
  9415. } catch (ex) {}
  9416. }
  9417. }
  9418. resolve(value);
  9419. });
  9420. }
  9421. }, {
  9422. key: 'set',
  9423. value: function set(name, val) {
  9424. var _this3 = this;
  9425. return this._initializedPromise.then(function () {
  9426. _this3.file[name] = val;
  9427. return _this3._writeToStorage();
  9428. });
  9429. }
  9430. }, {
  9431. key: 'setMultiple',
  9432. value: function setMultiple(properties) {
  9433. var _this4 = this;
  9434. return this._initializedPromise.then(function () {
  9435. for (var name in properties) {
  9436. _this4.file[name] = properties[name];
  9437. }
  9438. return _this4._writeToStorage();
  9439. });
  9440. }
  9441. }, {
  9442. key: 'get',
  9443. value: function get(name, defaultValue) {
  9444. var _this5 = this;
  9445. return this._initializedPromise.then(function () {
  9446. var val = _this5.file[name];
  9447. return val !== undefined ? val : defaultValue;
  9448. });
  9449. }
  9450. }, {
  9451. key: 'getMultiple',
  9452. value: function getMultiple(properties) {
  9453. var _this6 = this;
  9454. return this._initializedPromise.then(function () {
  9455. var values = Object.create(null);
  9456. for (var name in properties) {
  9457. var val = _this6.file[name];
  9458. values[name] = val !== undefined ? val : properties[name];
  9459. }
  9460. return values;
  9461. });
  9462. }
  9463. }]);
  9464. return ViewHistory;
  9465. }();
  9466. exports.ViewHistory = ViewHistory;
  9467. /***/ }),
  9468. /* 33 */
  9469. /***/ (function(module, exports, __webpack_require__) {
  9470. "use strict";
  9471. var DEFAULT_URL = 'demo.pdf';
  9472. // var DEFAULT_URL = '';
  9473. ;
  9474. var pdfjsWebApp = void 0;
  9475. {
  9476. pdfjsWebApp = __webpack_require__(4);
  9477. }
  9478. ;
  9479. {
  9480. __webpack_require__(8);
  9481. }
  9482. ;
  9483. {
  9484. __webpack_require__(9);
  9485. }
  9486. function getViewerConfiguration() {
  9487. return {
  9488. appContainer: document.body,
  9489. mainContainer: document.getElementById('viewerContainer'),
  9490. viewerContainer: document.getElementById('viewer'),
  9491. eventBus: null,
  9492. toolbar: {
  9493. container: document.getElementById('toolbarViewer'),
  9494. numPages: document.getElementById('numPages'),
  9495. pageNumber: document.getElementById('pageNumber'),
  9496. scaleSelectContainer: document.getElementById('scaleSelectContainer'),
  9497. scaleSelect: document.getElementById('scaleSelect'),
  9498. customScaleOption: document.getElementById('customScaleOption'),
  9499. previous: document.getElementById('previous'),
  9500. next: document.getElementById('next'),
  9501. zoomIn: document.getElementById('zoomIn'),
  9502. zoomOut: document.getElementById('zoomOut'),
  9503. viewFind: document.getElementById('viewFind'),
  9504. openFile: document.getElementById('openFile'),
  9505. print: document.getElementById('print'),
  9506. presentationModeButton: document.getElementById('presentationMode'),
  9507. download: document.getElementById('download'),
  9508. viewBookmark: document.getElementById('viewBookmark')
  9509. },
  9510. secondaryToolbar: {
  9511. toolbar: document.getElementById('secondaryToolbar'),
  9512. toggleButton: document.getElementById('secondaryToolbarToggle'),
  9513. toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
  9514. presentationModeButton: document.getElementById('secondaryPresentationMode'),
  9515. openFileButton: document.getElementById('secondaryOpenFile'),
  9516. printButton: document.getElementById('secondaryPrint'),
  9517. downloadButton: document.getElementById('secondaryDownload'),
  9518. viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
  9519. firstPageButton: document.getElementById('firstPage'),
  9520. lastPageButton: document.getElementById('lastPage'),
  9521. pageRotateCwButton: document.getElementById('pageRotateCw'),
  9522. pageRotateCcwButton: document.getElementById('pageRotateCcw'),
  9523. cursorSelectToolButton: document.getElementById('cursorSelectTool'),
  9524. cursorHandToolButton: document.getElementById('cursorHandTool'),
  9525. documentPropertiesButton: document.getElementById('documentProperties')
  9526. },
  9527. fullscreen: {
  9528. contextFirstPage: document.getElementById('contextFirstPage'),
  9529. contextLastPage: document.getElementById('contextLastPage'),
  9530. contextPageRotateCw: document.getElementById('contextPageRotateCw'),
  9531. contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
  9532. },
  9533. sidebar: {
  9534. mainContainer: document.getElementById('mainContainer'),
  9535. outerContainer: document.getElementById('outerContainer'),
  9536. toggleButton: document.getElementById('sidebarToggle'),
  9537. thumbnailButton: document.getElementById('viewThumbnail'),
  9538. outlineButton: document.getElementById('viewOutline'),
  9539. attachmentsButton: document.getElementById('viewAttachments'),
  9540. thumbnailView: document.getElementById('thumbnailView'),
  9541. outlineView: document.getElementById('outlineView'),
  9542. attachmentsView: document.getElementById('attachmentsView')
  9543. },
  9544. findBar: {
  9545. bar: document.getElementById('findbar'),
  9546. toggleButton: document.getElementById('viewFind'),
  9547. findField: document.getElementById('findInput'),
  9548. highlightAllCheckbox: document.getElementById('findHighlightAll'),
  9549. caseSensitiveCheckbox: document.getElementById('findMatchCase'),
  9550. findMsg: document.getElementById('findMsg'),
  9551. findResultsCount: document.getElementById('findResultsCount'),
  9552. findStatusIcon: document.getElementById('findStatusIcon'),
  9553. findPreviousButton: document.getElementById('findPrevious'),
  9554. findNextButton: document.getElementById('findNext')
  9555. },
  9556. passwordOverlay: {
  9557. overlayName: 'passwordOverlay',
  9558. container: document.getElementById('passwordOverlay'),
  9559. label: document.getElementById('passwordText'),
  9560. input: document.getElementById('password'),
  9561. submitButton: document.getElementById('passwordSubmit'),
  9562. cancelButton: document.getElementById('passwordCancel')
  9563. },
  9564. documentProperties: {
  9565. overlayName: 'documentPropertiesOverlay',
  9566. container: document.getElementById('documentPropertiesOverlay'),
  9567. closeButton: document.getElementById('documentPropertiesClose'),
  9568. fields: {
  9569. 'fileName': document.getElementById('fileNameField'),
  9570. 'fileSize': document.getElementById('fileSizeField'),
  9571. 'title': document.getElementById('titleField'),
  9572. 'author': document.getElementById('authorField'),
  9573. 'subject': document.getElementById('subjectField'),
  9574. 'keywords': document.getElementById('keywordsField'),
  9575. 'creationDate': document.getElementById('creationDateField'),
  9576. 'modificationDate': document.getElementById('modificationDateField'),
  9577. 'creator': document.getElementById('creatorField'),
  9578. 'producer': document.getElementById('producerField'),
  9579. 'version': document.getElementById('versionField'),
  9580. 'pageCount': document.getElementById('pageCountField')
  9581. }
  9582. },
  9583. errorWrapper: {
  9584. container: document.getElementById('errorWrapper'),
  9585. errorMessage: document.getElementById('errorMessage'),
  9586. closeButton: document.getElementById('errorClose'),
  9587. errorMoreInfo: document.getElementById('errorMoreInfo'),
  9588. moreInfoButton: document.getElementById('errorShowMore'),
  9589. lessInfoButton: document.getElementById('errorShowLess')
  9590. },
  9591. printContainer: document.getElementById('printContainer'),
  9592. openFileInputName: 'fileInput',
  9593. debuggerScriptPath: './debugger.js',
  9594. defaultUrl: DEFAULT_URL
  9595. };
  9596. }
  9597. function webViewerLoad() {
  9598. var config = getViewerConfiguration();
  9599. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  9600. pdfjsWebApp.PDFViewerApplication.run(config);
  9601. }
  9602. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  9603. webViewerLoad();
  9604. } else {
  9605. document.addEventListener('DOMContentLoaded', webViewerLoad, true);
  9606. }
  9607. /***/ })
  9608. /******/ ]);
  9609. //# sourceMappingURL=viewer.js.map