handsontable.full.js 1.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619
  1. /*!
  2. (The MIT License)
  3. Copyright (c) 2012-2014 Marcin Warpechowski
  4. Copyright (c) 2015 Handsoncode sp. z o.o. <hello@handsoncode.net>
  5. Permission is hereby granted, free of charge, to any person obtaining
  6. a copy of this software and associated documentation files (the
  7. 'Software'), to deal in the Software without restriction, including
  8. without limitation the rights to use, copy, modify, merge, publish,
  9. distribute, sublicense, and/or sell copies of the Software, and to
  10. permit persons to whom the Software is furnished to do so, subject to
  11. the following conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  17. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  18. CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  19. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  20. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Handsontable = f()}})(function(){var define,module,exports;return (function init(modules, cache, entry) {
  23. (function outer (modules, cache, entry) {
  24. // Save the require from previous bundle to this closure if any
  25. var previousRequire = typeof require == "function" && require;
  26. var globalNS = JSON.parse('{"zeroclipboard":"ZeroClipboard","moment":"moment","pikaday":"Pikaday"}') || {};
  27. function newRequire(name, jumped){
  28. if(!cache[name]) {
  29. if(!modules[name]) {
  30. // if we cannot find the the module within our internal map or
  31. // cache jump to the current global require ie. the last bundle
  32. // that was added to the page.
  33. var currentRequire = typeof require == "function" && require;
  34. if (!jumped && currentRequire) return currentRequire(name, true);
  35. // If there are other bundles on this page the require from the
  36. // previous one is saved to 'previousRequire'. Repeat this as
  37. // many times as there are bundles until the module is found or
  38. // we exhaust the require chain.
  39. if (previousRequire) return previousRequire(name, true);
  40. // Try find module from global scope
  41. if (globalNS[name] && typeof window[globalNS[name]] !== 'undefined') {
  42. return window[globalNS[name]];
  43. }
  44. var err = new Error('Cannot find module \'' + name + '\'');
  45. err.code = 'MODULE_NOT_FOUND';
  46. throw err;
  47. }
  48. var m = cache[name] = {exports:{}};
  49. modules[name][0].call(m.exports, function(x){
  50. var id = modules[name][1][x];
  51. return newRequire(id ? id : x);
  52. },m,m.exports,outer,modules,cache,entry);
  53. }
  54. return cache[name].exports;
  55. }
  56. for(var i=0;i<entry.length;i++) newRequire(entry[i]);
  57. // Override the current require with this new one
  58. return newRequire;
  59. })(modules, cache, entry);
  60. return function() {
  61. return Handsontable;
  62. };
  63. })
  64. ({1:[function(require,module,exports){
  65. "use strict";
  66. if (window.jQuery) {
  67. (function(window, $, Handsontable) {
  68. $.fn.handsontable = function(action) {
  69. var i,
  70. ilen,
  71. args,
  72. output,
  73. userSettings,
  74. $this = this.first(),
  75. instance = $this.data('handsontable');
  76. if (typeof action !== 'string') {
  77. userSettings = action || {};
  78. if (instance) {
  79. instance.updateSettings(userSettings);
  80. } else {
  81. instance = new Handsontable.Core($this[0], userSettings);
  82. $this.data('handsontable', instance);
  83. instance.init();
  84. }
  85. return $this;
  86. } else {
  87. args = [];
  88. if (arguments.length > 1) {
  89. for (i = 1, ilen = arguments.length; i < ilen; i++) {
  90. args.push(arguments[i]);
  91. }
  92. }
  93. if (instance) {
  94. if (typeof instance[action] !== 'undefined') {
  95. output = instance[action].apply(instance, args);
  96. if (action === 'destroy') {
  97. $this.removeData();
  98. }
  99. } else {
  100. throw new Error('Handsontable do not provide action: ' + action);
  101. }
  102. }
  103. return output;
  104. }
  105. };
  106. })(window, jQuery, Handsontable);
  107. }
  108. //#
  109. },{}],2:[function(require,module,exports){
  110. "use strict";
  111. Object.defineProperties(exports, {
  112. WalkontableBorder: {get: function() {
  113. return WalkontableBorder;
  114. }},
  115. __esModule: {value: true}
  116. });
  117. var $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  118. $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_event__,
  119. $___46__46__47__46__46__47__46__46__47_eventManager__,
  120. $__cell_47_coords__,
  121. $__overlay_47__95_base_46_js__;
  122. var $__0 = ($___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}),
  123. getComputedStyle = $__0.getComputedStyle,
  124. getTrimmingContainer = $__0.getTrimmingContainer,
  125. innerWidth = $__0.innerWidth,
  126. innerHeight = $__0.innerHeight,
  127. offset = $__0.offset,
  128. outerHeight = $__0.outerHeight,
  129. outerWidth = $__0.outerWidth;
  130. var stopImmediatePropagation = ($___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_event__ && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_event__}).stopImmediatePropagation;
  131. var EventManager = ($___46__46__47__46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47__46__46__47_eventManager__}).EventManager;
  132. var WalkontableCellCoords = ($__cell_47_coords__ = require("cell/coords"), $__cell_47_coords__ && $__cell_47_coords__.__esModule && $__cell_47_coords__ || {default: $__cell_47_coords__}).WalkontableCellCoords;
  133. var WalkontableOverlay = ($__overlay_47__95_base_46_js__ = require("overlay/_base.js"), $__overlay_47__95_base_46_js__ && $__overlay_47__95_base_46_js__.__esModule && $__overlay_47__95_base_46_js__ || {default: $__overlay_47__95_base_46_js__}).WalkontableOverlay;
  134. var WalkontableBorder = function WalkontableBorder(wotInstance, settings) {
  135. if (!settings) {
  136. return;
  137. }
  138. this.eventManager = new EventManager(wotInstance);
  139. this.instance = wotInstance;
  140. this.wot = wotInstance;
  141. this.settings = settings;
  142. this.mouseDown = false;
  143. this.main = null;
  144. this.top = null;
  145. this.left = null;
  146. this.bottom = null;
  147. this.right = null;
  148. this.topStyle = null;
  149. this.leftStyle = null;
  150. this.bottomStyle = null;
  151. this.rightStyle = null;
  152. this.cornerDefaultStyle = {
  153. width: '5px',
  154. height: '5px',
  155. borderWidth: '2px',
  156. borderStyle: 'solid',
  157. borderColor: '#FFF'
  158. };
  159. this.corner = null;
  160. this.cornerStyle = null;
  161. this.createBorders(settings);
  162. this.registerListeners();
  163. };
  164. ($traceurRuntime.createClass)(WalkontableBorder, {
  165. registerListeners: function() {
  166. var $__5 = this;
  167. this.eventManager.addEventListener(document.body, 'mousedown', (function() {
  168. return $__5.onMouseDown();
  169. }));
  170. this.eventManager.addEventListener(document.body, 'mouseup', (function() {
  171. return $__5.onMouseUp();
  172. }));
  173. var $__7 = this,
  174. $__8 = function(c, len) {
  175. $__7.eventManager.addEventListener($__7.main.childNodes[c], 'mouseenter', (function(event) {
  176. return $__5.onMouseEnter(event, $__5.main.childNodes[c]);
  177. }));
  178. };
  179. for (var c = 0,
  180. len = this.main.childNodes.length; c < len; c++) {
  181. $__8(c, len);
  182. }
  183. },
  184. onMouseDown: function() {
  185. this.mouseDown = true;
  186. },
  187. onMouseUp: function() {
  188. this.mouseDown = false;
  189. },
  190. onMouseEnter: function(event, parentElement) {
  191. if (!this.mouseDown || !this.wot.getSetting('hideBorderOnMouseDownOver')) {
  192. return;
  193. }
  194. event.preventDefault();
  195. stopImmediatePropagation(event);
  196. var _this = this;
  197. var bounds = parentElement.getBoundingClientRect();
  198. parentElement.style.display = 'none';
  199. function isOutside(event) {
  200. if (event.clientY < Math.floor(bounds.top)) {
  201. return true;
  202. }
  203. if (event.clientY > Math.ceil(bounds.top + bounds.height)) {
  204. return true;
  205. }
  206. if (event.clientX < Math.floor(bounds.left)) {
  207. return true;
  208. }
  209. if (event.clientX > Math.ceil(bounds.left + bounds.width)) {
  210. return true;
  211. }
  212. }
  213. function handler(event) {
  214. if (isOutside(event)) {
  215. _this.eventManager.removeEventListener(document.body, 'mousemove', handler);
  216. parentElement.style.display = 'block';
  217. }
  218. }
  219. this.eventManager.addEventListener(document.body, 'mousemove', handler);
  220. },
  221. createBorders: function(settings) {
  222. this.main = document.createElement('div');
  223. var borderDivs = ['top', 'left', 'bottom', 'right', 'corner'];
  224. var style = this.main.style;
  225. style.position = 'absolute';
  226. style.top = 0;
  227. style.left = 0;
  228. for (var i = 0; i < 5; i++) {
  229. var position = borderDivs[i];
  230. var div = document.createElement('div');
  231. div.className = 'wtBorder ' + (this.settings.className || '');
  232. if (this.settings[position] && this.settings[position].hide) {
  233. div.className += ' hidden';
  234. }
  235. style = div.style;
  236. style.backgroundColor = (this.settings[position] && this.settings[position].color) ? this.settings[position].color : settings.border.color;
  237. style.height = (this.settings[position] && this.settings[position].width) ? this.settings[position].width + 'px' : settings.border.width + 'px';
  238. style.width = (this.settings[position] && this.settings[position].width) ? this.settings[position].width + 'px' : settings.border.width + 'px';
  239. this.main.appendChild(div);
  240. }
  241. this.top = this.main.childNodes[0];
  242. this.left = this.main.childNodes[1];
  243. this.bottom = this.main.childNodes[2];
  244. this.right = this.main.childNodes[3];
  245. this.topStyle = this.top.style;
  246. this.leftStyle = this.left.style;
  247. this.bottomStyle = this.bottom.style;
  248. this.rightStyle = this.right.style;
  249. this.corner = this.main.childNodes[4];
  250. this.corner.className += ' corner';
  251. this.cornerStyle = this.corner.style;
  252. this.cornerStyle.width = this.cornerDefaultStyle.width;
  253. this.cornerStyle.height = this.cornerDefaultStyle.height;
  254. this.cornerStyle.border = [this.cornerDefaultStyle.borderWidth, this.cornerDefaultStyle.borderStyle, this.cornerDefaultStyle.borderColor].join(' ');
  255. if (Handsontable.mobileBrowser) {
  256. this.createMultipleSelectorHandles();
  257. }
  258. this.disappear();
  259. if (!this.wot.wtTable.bordersHolder) {
  260. this.wot.wtTable.bordersHolder = document.createElement('div');
  261. this.wot.wtTable.bordersHolder.className = 'htBorders';
  262. this.wot.wtTable.spreader.appendChild(this.wot.wtTable.bordersHolder);
  263. }
  264. this.wot.wtTable.bordersHolder.insertBefore(this.main, this.wot.wtTable.bordersHolder.firstChild);
  265. },
  266. createMultipleSelectorHandles: function() {
  267. this.selectionHandles = {
  268. topLeft: document.createElement('DIV'),
  269. topLeftHitArea: document.createElement('DIV'),
  270. bottomRight: document.createElement('DIV'),
  271. bottomRightHitArea: document.createElement('DIV')
  272. };
  273. var width = 10;
  274. var hitAreaWidth = 40;
  275. this.selectionHandles.topLeft.className = 'topLeftSelectionHandle';
  276. this.selectionHandles.topLeftHitArea.className = 'topLeftSelectionHandle-HitArea';
  277. this.selectionHandles.bottomRight.className = 'bottomRightSelectionHandle';
  278. this.selectionHandles.bottomRightHitArea.className = 'bottomRightSelectionHandle-HitArea';
  279. this.selectionHandles.styles = {
  280. topLeft: this.selectionHandles.topLeft.style,
  281. topLeftHitArea: this.selectionHandles.topLeftHitArea.style,
  282. bottomRight: this.selectionHandles.bottomRight.style,
  283. bottomRightHitArea: this.selectionHandles.bottomRightHitArea.style
  284. };
  285. var hitAreaStyle = {
  286. position: 'absolute',
  287. height: hitAreaWidth + 'px',
  288. width: hitAreaWidth + 'px',
  289. 'border-radius': parseInt(hitAreaWidth / 1.5, 10) + 'px'
  290. };
  291. for (var prop in hitAreaStyle) {
  292. if (hitAreaStyle.hasOwnProperty(prop)) {
  293. this.selectionHandles.styles.bottomRightHitArea[prop] = hitAreaStyle[prop];
  294. this.selectionHandles.styles.topLeftHitArea[prop] = hitAreaStyle[prop];
  295. }
  296. }
  297. var handleStyle = {
  298. position: 'absolute',
  299. height: width + 'px',
  300. width: width + 'px',
  301. 'border-radius': parseInt(width / 1.5, 10) + 'px',
  302. background: '#F5F5FF',
  303. border: '1px solid #4285c8'
  304. };
  305. for (var prop$__9 in handleStyle) {
  306. if (handleStyle.hasOwnProperty(prop$__9)) {
  307. this.selectionHandles.styles.bottomRight[prop$__9] = handleStyle[prop$__9];
  308. this.selectionHandles.styles.topLeft[prop$__9] = handleStyle[prop$__9];
  309. }
  310. }
  311. this.main.appendChild(this.selectionHandles.topLeft);
  312. this.main.appendChild(this.selectionHandles.bottomRight);
  313. this.main.appendChild(this.selectionHandles.topLeftHitArea);
  314. this.main.appendChild(this.selectionHandles.bottomRightHitArea);
  315. },
  316. isPartRange: function(row, col) {
  317. if (this.wot.selections.area.cellRange) {
  318. if (row != this.wot.selections.area.cellRange.to.row || col != this.wot.selections.area.cellRange.to.col) {
  319. return true;
  320. }
  321. }
  322. return false;
  323. },
  324. updateMultipleSelectionHandlesPosition: function(row, col, top, left, width, height) {
  325. var handleWidth = parseInt(this.selectionHandles.styles.topLeft.width, 10);
  326. var hitAreaWidth = parseInt(this.selectionHandles.styles.topLeftHitArea.width, 10);
  327. this.selectionHandles.styles.topLeft.top = parseInt(top - handleWidth, 10) + 'px';
  328. this.selectionHandles.styles.topLeft.left = parseInt(left - handleWidth, 10) + 'px';
  329. this.selectionHandles.styles.topLeftHitArea.top = parseInt(top - (hitAreaWidth / 4) * 3, 10) + 'px';
  330. this.selectionHandles.styles.topLeftHitArea.left = parseInt(left - (hitAreaWidth / 4) * 3, 10) + 'px';
  331. this.selectionHandles.styles.bottomRight.top = parseInt(top + height, 10) + 'px';
  332. this.selectionHandles.styles.bottomRight.left = parseInt(left + width, 10) + 'px';
  333. this.selectionHandles.styles.bottomRightHitArea.top = parseInt(top + height - hitAreaWidth / 4, 10) + 'px';
  334. this.selectionHandles.styles.bottomRightHitArea.left = parseInt(left + width - hitAreaWidth / 4, 10) + 'px';
  335. if (this.settings.border.multipleSelectionHandlesVisible && this.settings.border.multipleSelectionHandlesVisible()) {
  336. this.selectionHandles.styles.topLeft.display = 'block';
  337. this.selectionHandles.styles.topLeftHitArea.display = 'block';
  338. if (this.isPartRange(row, col)) {
  339. this.selectionHandles.styles.bottomRight.display = 'none';
  340. this.selectionHandles.styles.bottomRightHitArea.display = 'none';
  341. } else {
  342. this.selectionHandles.styles.bottomRight.display = 'block';
  343. this.selectionHandles.styles.bottomRightHitArea.display = 'block';
  344. }
  345. } else {
  346. this.selectionHandles.styles.topLeft.display = 'none';
  347. this.selectionHandles.styles.bottomRight.display = 'none';
  348. this.selectionHandles.styles.topLeftHitArea.display = 'none';
  349. this.selectionHandles.styles.bottomRightHitArea.display = 'none';
  350. }
  351. if (row == this.wot.wtSettings.getSetting('fixedRowsTop') || col == this.wot.wtSettings.getSetting('fixedColumnsLeft')) {
  352. this.selectionHandles.styles.topLeft.zIndex = '9999';
  353. this.selectionHandles.styles.topLeftHitArea.zIndex = '9999';
  354. } else {
  355. this.selectionHandles.styles.topLeft.zIndex = '';
  356. this.selectionHandles.styles.topLeftHitArea.zIndex = '';
  357. }
  358. },
  359. appear: function(corners) {
  360. if (this.disabled) {
  361. return;
  362. }
  363. var isMultiple,
  364. fromTD,
  365. toTD,
  366. fromOffset,
  367. toOffset,
  368. containerOffset,
  369. top,
  370. minTop,
  371. left,
  372. minLeft,
  373. height,
  374. width,
  375. fromRow,
  376. fromColumn,
  377. toRow,
  378. toColumn,
  379. trimmingContainer,
  380. cornerOverlappingContainer,
  381. ilen;
  382. if (WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_TOP) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_TOP_LEFT_CORNER)) {
  383. ilen = this.wot.getSetting('fixedRowsTop');
  384. } else if (WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM_LEFT_CORNER)) {
  385. ilen = this.wot.getSetting('fixedRowsBottom');
  386. } else {
  387. ilen = this.wot.wtTable.getRenderedRowsCount();
  388. }
  389. for (var i = 0; i < ilen; i++) {
  390. var s = this.wot.wtTable.rowFilter.renderedToSource(i);
  391. if (s >= corners[0] && s <= corners[2]) {
  392. fromRow = s;
  393. break;
  394. }
  395. }
  396. for (var i$__10 = ilen - 1; i$__10 >= 0; i$__10--) {
  397. var s$__11 = this.wot.wtTable.rowFilter.renderedToSource(i$__10);
  398. if (s$__11 >= corners[0] && s$__11 <= corners[2]) {
  399. toRow = s$__11;
  400. break;
  401. }
  402. }
  403. ilen = this.wot.wtTable.getRenderedColumnsCount();
  404. for (var i$__12 = 0; i$__12 < ilen; i$__12++) {
  405. var s$__13 = this.wot.wtTable.columnFilter.renderedToSource(i$__12);
  406. if (s$__13 >= corners[1] && s$__13 <= corners[3]) {
  407. fromColumn = s$__13;
  408. break;
  409. }
  410. }
  411. for (var i$__14 = ilen - 1; i$__14 >= 0; i$__14--) {
  412. var s$__15 = this.wot.wtTable.columnFilter.renderedToSource(i$__14);
  413. if (s$__15 >= corners[1] && s$__15 <= corners[3]) {
  414. toColumn = s$__15;
  415. break;
  416. }
  417. }
  418. if (fromRow === void 0 || fromColumn === void 0) {
  419. this.disappear();
  420. return;
  421. }
  422. isMultiple = (fromRow !== toRow || fromColumn !== toColumn);
  423. fromTD = this.wot.wtTable.getCell(new WalkontableCellCoords(fromRow, fromColumn));
  424. toTD = isMultiple ? this.wot.wtTable.getCell(new WalkontableCellCoords(toRow, toColumn)) : fromTD;
  425. fromOffset = offset(fromTD);
  426. toOffset = isMultiple ? offset(toTD) : fromOffset;
  427. containerOffset = offset(this.wot.wtTable.TABLE);
  428. minTop = fromOffset.top;
  429. height = toOffset.top + outerHeight(toTD) - minTop;
  430. minLeft = fromOffset.left;
  431. width = toOffset.left + outerWidth(toTD) - minLeft;
  432. top = minTop - containerOffset.top - 1;
  433. left = minLeft - containerOffset.left - 1;
  434. var style = getComputedStyle(fromTD);
  435. if (parseInt(style.borderTopWidth, 10) > 0) {
  436. top += 1;
  437. height = height > 0 ? height - 1 : 0;
  438. }
  439. if (parseInt(style.borderLeftWidth, 10) > 0) {
  440. left += 1;
  441. width = width > 0 ? width - 1 : 0;
  442. }
  443. this.topStyle.top = top + 'px';
  444. this.topStyle.left = left + 'px';
  445. this.topStyle.width = width + 'px';
  446. this.topStyle.display = 'block';
  447. this.leftStyle.top = top + 'px';
  448. this.leftStyle.left = left + 'px';
  449. this.leftStyle.height = height + 'px';
  450. this.leftStyle.display = 'block';
  451. var delta = Math.floor(this.settings.border.width / 2);
  452. this.bottomStyle.top = top + height - delta + 'px';
  453. this.bottomStyle.left = left + 'px';
  454. this.bottomStyle.width = width + 'px';
  455. this.bottomStyle.display = 'block';
  456. this.rightStyle.top = top + 'px';
  457. this.rightStyle.left = left + width - delta + 'px';
  458. this.rightStyle.height = height + 1 + 'px';
  459. this.rightStyle.display = 'block';
  460. if (Handsontable.mobileBrowser || (!this.hasSetting(this.settings.border.cornerVisible) || this.isPartRange(toRow, toColumn))) {
  461. this.cornerStyle.display = 'none';
  462. } else {
  463. this.cornerStyle.top = top + height - 4 + 'px';
  464. this.cornerStyle.left = left + width - 4 + 'px';
  465. this.cornerStyle.borderRightWidth = this.cornerDefaultStyle.borderWidth;
  466. this.cornerStyle.width = this.cornerDefaultStyle.width;
  467. this.cornerStyle.display = 'block';
  468. trimmingContainer = getTrimmingContainer(this.wot.wtTable.TABLE);
  469. if (toColumn === this.wot.getSetting('totalColumns') - 1) {
  470. cornerOverlappingContainer = toTD.offsetLeft + outerWidth(toTD) >= innerWidth(trimmingContainer);
  471. if (cornerOverlappingContainer) {
  472. this.cornerStyle.left = Math.floor(left + width - 3 - parseInt(this.cornerDefaultStyle.width) / 2) + 'px';
  473. this.cornerStyle.borderRightWidth = 0;
  474. }
  475. }
  476. if (toRow === this.wot.getSetting('totalRows') - 1) {
  477. cornerOverlappingContainer = toTD.offsetTop + outerHeight(toTD) >= innerHeight(trimmingContainer);
  478. if (cornerOverlappingContainer) {
  479. this.cornerStyle.top = Math.floor(top + height - 3 - parseInt(this.cornerDefaultStyle.height) / 2) + 'px';
  480. this.cornerStyle.borderBottomWidth = 0;
  481. }
  482. }
  483. }
  484. if (Handsontable.mobileBrowser) {
  485. this.updateMultipleSelectionHandlesPosition(fromRow, fromColumn, top, left, width, height);
  486. }
  487. },
  488. disappear: function() {
  489. this.topStyle.display = 'none';
  490. this.leftStyle.display = 'none';
  491. this.bottomStyle.display = 'none';
  492. this.rightStyle.display = 'none';
  493. this.cornerStyle.display = 'none';
  494. if (Handsontable.mobileBrowser) {
  495. this.selectionHandles.styles.topLeft.display = 'none';
  496. this.selectionHandles.styles.bottomRight.display = 'none';
  497. }
  498. },
  499. hasSetting: function(setting) {
  500. if (typeof setting === 'function') {
  501. return setting();
  502. }
  503. return !!setting;
  504. }
  505. }, {});
  506. ;
  507. window.WalkontableBorder = WalkontableBorder;
  508. //#
  509. },{"cell/coords":5,"eventManager":41,"helpers/dom/element":45,"helpers/dom/event":46,"overlay/_base.js":11}],3:[function(require,module,exports){
  510. "use strict";
  511. Object.defineProperties(exports, {
  512. WalkontableViewportColumnsCalculator: {get: function() {
  513. return WalkontableViewportColumnsCalculator;
  514. }},
  515. __esModule: {value: true}
  516. });
  517. var privatePool = new WeakMap();
  518. var WalkontableViewportColumnsCalculator = function WalkontableViewportColumnsCalculator(viewportWidth, scrollOffset, totalColumns, columnWidthFn, overrideFn, onlyFullyVisible, stretchH) {
  519. privatePool.set(this, {
  520. viewportWidth: viewportWidth,
  521. scrollOffset: scrollOffset,
  522. totalColumns: totalColumns,
  523. columnWidthFn: columnWidthFn,
  524. overrideFn: overrideFn,
  525. onlyFullyVisible: onlyFullyVisible
  526. });
  527. this.count = 0;
  528. this.startColumn = null;
  529. this.endColumn = null;
  530. this.startPosition = null;
  531. this.stretchAllRatio = 0;
  532. this.stretchLastWidth = 0;
  533. this.stretch = stretchH;
  534. this.totalTargetWidth = 0;
  535. this.needVerifyLastColumnWidth = true;
  536. this.stretchAllColumnsWidth = [];
  537. this.calculate();
  538. };
  539. var $WalkontableViewportColumnsCalculator = WalkontableViewportColumnsCalculator;
  540. ($traceurRuntime.createClass)(WalkontableViewportColumnsCalculator, {
  541. calculate: function() {
  542. var sum = 0;
  543. var needReverse = true;
  544. var startPositions = [];
  545. var columnWidth;
  546. var priv = privatePool.get(this);
  547. var onlyFullyVisible = priv.onlyFullyVisible;
  548. var overrideFn = priv.overrideFn;
  549. var scrollOffset = priv.scrollOffset;
  550. var totalColumns = priv.totalColumns;
  551. var viewportWidth = priv.viewportWidth;
  552. for (var i = 0; i < totalColumns; i++) {
  553. columnWidth = this._getColumnWidth(i);
  554. if (sum <= scrollOffset && !onlyFullyVisible) {
  555. this.startColumn = i;
  556. }
  557. if (sum >= scrollOffset && sum + columnWidth <= scrollOffset + viewportWidth) {
  558. if (this.startColumn == null) {
  559. this.startColumn = i;
  560. }
  561. this.endColumn = i;
  562. }
  563. startPositions.push(sum);
  564. sum += columnWidth;
  565. if (!onlyFullyVisible) {
  566. this.endColumn = i;
  567. }
  568. if (sum >= scrollOffset + viewportWidth) {
  569. needReverse = false;
  570. break;
  571. }
  572. }
  573. if (this.endColumn === totalColumns - 1 && needReverse) {
  574. this.startColumn = this.endColumn;
  575. while (this.startColumn > 0) {
  576. var viewportSum = startPositions[this.endColumn] + columnWidth - startPositions[this.startColumn - 1];
  577. if (viewportSum <= viewportWidth || !onlyFullyVisible) {
  578. this.startColumn--;
  579. }
  580. if (viewportSum > viewportWidth) {
  581. break;
  582. }
  583. }
  584. }
  585. if (this.startColumn !== null && overrideFn) {
  586. overrideFn(this);
  587. }
  588. this.startPosition = startPositions[this.startColumn];
  589. if (this.startPosition == void 0) {
  590. this.startPosition = null;
  591. }
  592. if (this.startColumn !== null) {
  593. this.count = this.endColumn - this.startColumn + 1;
  594. }
  595. },
  596. refreshStretching: function(totalWidth) {
  597. if (this.stretch === 'none') {
  598. return;
  599. }
  600. var sumAll = 0;
  601. var columnWidth;
  602. var remainingSize;
  603. var priv = privatePool.get(this);
  604. var totalColumns = priv.totalColumns;
  605. for (var i = 0; i < totalColumns; i++) {
  606. columnWidth = this._getColumnWidth(i);
  607. sumAll += columnWidth;
  608. }
  609. this.totalTargetWidth = totalWidth;
  610. remainingSize = sumAll - totalWidth;
  611. if (this.stretch === 'all' && remainingSize < 0) {
  612. this.stretchAllRatio = totalWidth / sumAll;
  613. this.stretchAllColumnsWidth = [];
  614. this.needVerifyLastColumnWidth = true;
  615. } else if (this.stretch === 'last' && totalWidth !== Infinity) {
  616. this.stretchLastWidth = -remainingSize + this._getColumnWidth(totalColumns - 1);
  617. }
  618. },
  619. getStretchedColumnWidth: function(column, baseWidth) {
  620. var result = null;
  621. if (this.stretch === 'all' && this.stretchAllRatio !== 0) {
  622. result = this._getStretchedAllColumnWidth(column, baseWidth);
  623. } else if (this.stretch === 'last' && this.stretchLastWidth !== 0) {
  624. result = this._getStretchedLastColumnWidth(column);
  625. }
  626. return result;
  627. },
  628. _getStretchedAllColumnWidth: function(column, baseWidth) {
  629. var sumRatioWidth = 0;
  630. var priv = privatePool.get(this);
  631. var totalColumns = priv.totalColumns;
  632. if (!this.stretchAllColumnsWidth[column]) {
  633. this.stretchAllColumnsWidth[column] = Math.round(baseWidth * this.stretchAllRatio);
  634. }
  635. if (this.stretchAllColumnsWidth.length === totalColumns && this.needVerifyLastColumnWidth) {
  636. this.needVerifyLastColumnWidth = false;
  637. for (var i = 0; i < this.stretchAllColumnsWidth.length; i++) {
  638. sumRatioWidth += this.stretchAllColumnsWidth[i];
  639. }
  640. if (sumRatioWidth !== this.totalTargetWidth) {
  641. this.stretchAllColumnsWidth[this.stretchAllColumnsWidth.length - 1] += this.totalTargetWidth - sumRatioWidth;
  642. }
  643. }
  644. return this.stretchAllColumnsWidth[column];
  645. },
  646. _getStretchedLastColumnWidth: function(column) {
  647. var priv = privatePool.get(this);
  648. var totalColumns = priv.totalColumns;
  649. if (column === totalColumns - 1) {
  650. return this.stretchLastWidth;
  651. }
  652. return null;
  653. },
  654. _getColumnWidth: function(column) {
  655. var width = privatePool.get(this).columnWidthFn(column);
  656. if (width === undefined) {
  657. width = $WalkontableViewportColumnsCalculator.DEFAULT_WIDTH;
  658. }
  659. return width;
  660. }
  661. }, {get DEFAULT_WIDTH() {
  662. return 50;
  663. }});
  664. ;
  665. window.WalkontableViewportColumnsCalculator = WalkontableViewportColumnsCalculator;
  666. //#
  667. },{}],4:[function(require,module,exports){
  668. "use strict";
  669. Object.defineProperties(exports, {
  670. WalkontableViewportRowsCalculator: {get: function() {
  671. return WalkontableViewportRowsCalculator;
  672. }},
  673. __esModule: {value: true}
  674. });
  675. var privatePool = new WeakMap();
  676. var WalkontableViewportRowsCalculator = function WalkontableViewportRowsCalculator(viewportHeight, scrollOffset, totalRows, rowHeightFn, overrideFn, onlyFullyVisible, horizontalScrollbarHeight) {
  677. privatePool.set(this, {
  678. viewportHeight: viewportHeight,
  679. scrollOffset: scrollOffset,
  680. totalRows: totalRows,
  681. rowHeightFn: rowHeightFn,
  682. overrideFn: overrideFn,
  683. onlyFullyVisible: onlyFullyVisible,
  684. horizontalScrollbarHeight: horizontalScrollbarHeight
  685. });
  686. this.count = 0;
  687. this.startRow = null;
  688. this.endRow = null;
  689. this.startPosition = null;
  690. this.calculate();
  691. };
  692. var $WalkontableViewportRowsCalculator = WalkontableViewportRowsCalculator;
  693. ($traceurRuntime.createClass)(WalkontableViewportRowsCalculator, {calculate: function() {
  694. var sum = 0;
  695. var needReverse = true;
  696. var startPositions = [];
  697. var priv = privatePool.get(this);
  698. var onlyFullyVisible = priv.onlyFullyVisible;
  699. var overrideFn = priv.overrideFn;
  700. var rowHeightFn = priv.rowHeightFn;
  701. var scrollOffset = priv.scrollOffset;
  702. var totalRows = priv.totalRows;
  703. var viewportHeight = priv.viewportHeight;
  704. var horizontalScrollbarHeight = priv.horizontalScrollbarHeight || 0;
  705. for (var i = 0; i < totalRows; i++) {
  706. var rowHeight = rowHeightFn(i);
  707. if (rowHeight === undefined) {
  708. rowHeight = $WalkontableViewportRowsCalculator.DEFAULT_HEIGHT;
  709. }
  710. if (sum <= scrollOffset && !onlyFullyVisible) {
  711. this.startRow = i;
  712. }
  713. if (sum >= scrollOffset && sum + rowHeight <= scrollOffset + viewportHeight - horizontalScrollbarHeight) {
  714. if (this.startRow === null) {
  715. this.startRow = i;
  716. }
  717. this.endRow = i;
  718. }
  719. startPositions.push(sum);
  720. sum += rowHeight;
  721. if (!onlyFullyVisible) {
  722. this.endRow = i;
  723. }
  724. if (sum >= scrollOffset + viewportHeight - horizontalScrollbarHeight) {
  725. needReverse = false;
  726. break;
  727. }
  728. }
  729. if (this.endRow === totalRows - 1 && needReverse) {
  730. this.startRow = this.endRow;
  731. while (this.startRow > 0) {
  732. var viewportSum = startPositions[this.endRow] + rowHeight - startPositions[this.startRow - 1];
  733. if (viewportSum <= viewportHeight - horizontalScrollbarHeight || !onlyFullyVisible) {
  734. this.startRow--;
  735. }
  736. if (viewportSum >= viewportHeight - horizontalScrollbarHeight) {
  737. break;
  738. }
  739. }
  740. }
  741. if (this.startRow !== null && overrideFn) {
  742. overrideFn(this);
  743. }
  744. this.startPosition = startPositions[this.startRow];
  745. if (this.startPosition == void 0) {
  746. this.startPosition = null;
  747. }
  748. if (this.startRow !== null) {
  749. this.count = this.endRow - this.startRow + 1;
  750. }
  751. }}, {get DEFAULT_HEIGHT() {
  752. return 23;
  753. }});
  754. ;
  755. window.WalkontableViewportRowsCalculator = WalkontableViewportRowsCalculator;
  756. //#
  757. },{}],5:[function(require,module,exports){
  758. "use strict";
  759. Object.defineProperties(exports, {
  760. WalkontableCellCoords: {get: function() {
  761. return WalkontableCellCoords;
  762. }},
  763. __esModule: {value: true}
  764. });
  765. var WalkontableCellCoords = function WalkontableCellCoords(row, col) {
  766. if (typeof row !== 'undefined' && typeof col !== 'undefined') {
  767. this.row = row;
  768. this.col = col;
  769. } else {
  770. this.row = null;
  771. this.col = null;
  772. }
  773. };
  774. ($traceurRuntime.createClass)(WalkontableCellCoords, {
  775. isValid: function(wotInstance) {
  776. if (this.row < 0 || this.col < 0) {
  777. return false;
  778. }
  779. if (this.row >= wotInstance.getSetting('totalRows') || this.col >= wotInstance.getSetting('totalColumns')) {
  780. return false;
  781. }
  782. return true;
  783. },
  784. isEqual: function(cellCoords) {
  785. if (cellCoords === this) {
  786. return true;
  787. }
  788. return this.row === cellCoords.row && this.col === cellCoords.col;
  789. },
  790. isSouthEastOf: function(testedCoords) {
  791. return this.row >= testedCoords.row && this.col >= testedCoords.col;
  792. },
  793. isNorthWestOf: function(testedCoords) {
  794. return this.row <= testedCoords.row && this.col <= testedCoords.col;
  795. },
  796. isSouthWestOf: function(testedCoords) {
  797. return this.row >= testedCoords.row && this.col <= testedCoords.col;
  798. },
  799. isNorthEastOf: function(testedCoords) {
  800. return this.row <= testedCoords.row && this.col >= testedCoords.col;
  801. }
  802. }, {});
  803. ;
  804. window.WalkontableCellCoords = WalkontableCellCoords;
  805. //#
  806. },{}],6:[function(require,module,exports){
  807. "use strict";
  808. Object.defineProperties(exports, {
  809. WalkontableCellRange: {get: function() {
  810. return WalkontableCellRange;
  811. }},
  812. __esModule: {value: true}
  813. });
  814. var $___46__46__47_cell_47_coords__;
  815. var WalkontableCellCoords = ($___46__46__47_cell_47_coords__ = require("cell/coords"), $___46__46__47_cell_47_coords__ && $___46__46__47_cell_47_coords__.__esModule && $___46__46__47_cell_47_coords__ || {default: $___46__46__47_cell_47_coords__}).WalkontableCellCoords;
  816. var WalkontableCellRange = function WalkontableCellRange(highlight, from, to) {
  817. this.highlight = highlight;
  818. this.from = from;
  819. this.to = to;
  820. };
  821. var $WalkontableCellRange = WalkontableCellRange;
  822. ($traceurRuntime.createClass)(WalkontableCellRange, {
  823. isValid: function(wotInstance) {
  824. return this.from.isValid(wotInstance) && this.to.isValid(wotInstance);
  825. },
  826. isSingle: function() {
  827. return this.from.row === this.to.row && this.from.col === this.to.col;
  828. },
  829. getHeight: function() {
  830. return Math.max(this.from.row, this.to.row) - Math.min(this.from.row, this.to.row) + 1;
  831. },
  832. getWidth: function() {
  833. return Math.max(this.from.col, this.to.col) - Math.min(this.from.col, this.to.col) + 1;
  834. },
  835. includes: function(cellCoords) {
  836. var topLeft = this.getTopLeftCorner();
  837. var bottomRight = this.getBottomRightCorner();
  838. if (cellCoords.row < 0) {
  839. cellCoords.row = 0;
  840. }
  841. if (cellCoords.col < 0) {
  842. cellCoords.col = 0;
  843. }
  844. return topLeft.row <= cellCoords.row && bottomRight.row >= cellCoords.row && topLeft.col <= cellCoords.col && bottomRight.col >= cellCoords.col;
  845. },
  846. includesRange: function(testedRange) {
  847. return this.includes(testedRange.getTopLeftCorner()) && this.includes(testedRange.getBottomRightCorner());
  848. },
  849. isEqual: function(testedRange) {
  850. return (Math.min(this.from.row, this.to.row) == Math.min(testedRange.from.row, testedRange.to.row)) && (Math.max(this.from.row, this.to.row) == Math.max(testedRange.from.row, testedRange.to.row)) && (Math.min(this.from.col, this.to.col) == Math.min(testedRange.from.col, testedRange.to.col)) && (Math.max(this.from.col, this.to.col) == Math.max(testedRange.from.col, testedRange.to.col));
  851. },
  852. overlaps: function(testedRange) {
  853. return testedRange.isSouthEastOf(this.getTopLeftCorner()) && testedRange.isNorthWestOf(this.getBottomRightCorner());
  854. },
  855. isSouthEastOf: function(testedCoords) {
  856. return this.getTopLeftCorner().isSouthEastOf(testedCoords) || this.getBottomRightCorner().isSouthEastOf(testedCoords);
  857. },
  858. isNorthWestOf: function(testedCoords) {
  859. return this.getTopLeftCorner().isNorthWestOf(testedCoords) || this.getBottomRightCorner().isNorthWestOf(testedCoords);
  860. },
  861. expand: function(cellCoords) {
  862. var topLeft = this.getTopLeftCorner();
  863. var bottomRight = this.getBottomRightCorner();
  864. if (cellCoords.row < topLeft.row || cellCoords.col < topLeft.col || cellCoords.row > bottomRight.row || cellCoords.col > bottomRight.col) {
  865. this.from = new WalkontableCellCoords(Math.min(topLeft.row, cellCoords.row), Math.min(topLeft.col, cellCoords.col));
  866. this.to = new WalkontableCellCoords(Math.max(bottomRight.row, cellCoords.row), Math.max(bottomRight.col, cellCoords.col));
  867. return true;
  868. }
  869. return false;
  870. },
  871. expandByRange: function(expandingRange) {
  872. if (this.includesRange(expandingRange) || !this.overlaps(expandingRange)) {
  873. return false;
  874. }
  875. var topLeft = this.getTopLeftCorner();
  876. var bottomRight = this.getBottomRightCorner();
  877. var topRight = this.getTopRightCorner();
  878. var bottomLeft = this.getBottomLeftCorner();
  879. var expandingTopLeft = expandingRange.getTopLeftCorner();
  880. var expandingBottomRight = expandingRange.getBottomRightCorner();
  881. var resultTopRow = Math.min(topLeft.row, expandingTopLeft.row);
  882. var resultTopCol = Math.min(topLeft.col, expandingTopLeft.col);
  883. var resultBottomRow = Math.max(bottomRight.row, expandingBottomRight.row);
  884. var resultBottomCol = Math.max(bottomRight.col, expandingBottomRight.col);
  885. var finalFrom = new WalkontableCellCoords(resultTopRow, resultTopCol),
  886. finalTo = new WalkontableCellCoords(resultBottomRow, resultBottomCol);
  887. var isCorner = new $WalkontableCellRange(finalFrom, finalFrom, finalTo).isCorner(this.from, expandingRange),
  888. onlyMerge = expandingRange.isEqual(new $WalkontableCellRange(finalFrom, finalFrom, finalTo));
  889. if (isCorner && !onlyMerge) {
  890. if (this.from.col > finalFrom.col) {
  891. finalFrom.col = resultBottomCol;
  892. finalTo.col = resultTopCol;
  893. }
  894. if (this.from.row > finalFrom.row) {
  895. finalFrom.row = resultBottomRow;
  896. finalTo.row = resultTopRow;
  897. }
  898. }
  899. this.from = finalFrom;
  900. this.to = finalTo;
  901. return true;
  902. },
  903. getDirection: function() {
  904. if (this.from.isNorthWestOf(this.to)) {
  905. return 'NW-SE';
  906. } else if (this.from.isNorthEastOf(this.to)) {
  907. return 'NE-SW';
  908. } else if (this.from.isSouthEastOf(this.to)) {
  909. return 'SE-NW';
  910. } else if (this.from.isSouthWestOf(this.to)) {
  911. return 'SW-NE';
  912. }
  913. },
  914. setDirection: function(direction) {
  915. switch (direction) {
  916. case 'NW-SE':
  917. this.from = this.getTopLeftCorner();
  918. this.to = this.getBottomRightCorner();
  919. break;
  920. case 'NE-SW':
  921. this.from = this.getTopRightCorner();
  922. this.to = this.getBottomLeftCorner();
  923. break;
  924. case 'SE-NW':
  925. this.from = this.getBottomRightCorner();
  926. this.to = this.getTopLeftCorner();
  927. break;
  928. case 'SW-NE':
  929. this.from = this.getBottomLeftCorner();
  930. this.to = this.getTopRightCorner();
  931. break;
  932. }
  933. },
  934. getTopLeftCorner: function() {
  935. return new WalkontableCellCoords(Math.min(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  936. },
  937. getBottomRightCorner: function() {
  938. return new WalkontableCellCoords(Math.max(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  939. },
  940. getTopRightCorner: function() {
  941. return new WalkontableCellCoords(Math.min(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  942. },
  943. getBottomLeftCorner: function() {
  944. return new WalkontableCellCoords(Math.max(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  945. },
  946. isCorner: function(coords, expandedRange) {
  947. if (expandedRange) {
  948. if (expandedRange.includes(coords)) {
  949. if (this.getTopLeftCorner().isEqual(new WalkontableCellCoords(expandedRange.from.row, expandedRange.from.col)) || this.getTopRightCorner().isEqual(new WalkontableCellCoords(expandedRange.from.row, expandedRange.to.col)) || this.getBottomLeftCorner().isEqual(new WalkontableCellCoords(expandedRange.to.row, expandedRange.from.col)) || this.getBottomRightCorner().isEqual(new WalkontableCellCoords(expandedRange.to.row, expandedRange.to.col))) {
  950. return true;
  951. }
  952. }
  953. }
  954. return coords.isEqual(this.getTopLeftCorner()) || coords.isEqual(this.getTopRightCorner()) || coords.isEqual(this.getBottomLeftCorner()) || coords.isEqual(this.getBottomRightCorner());
  955. },
  956. getOppositeCorner: function(coords, expandedRange) {
  957. if (!(coords instanceof WalkontableCellCoords)) {
  958. return false;
  959. }
  960. if (expandedRange) {
  961. if (expandedRange.includes(coords)) {
  962. if (this.getTopLeftCorner().isEqual(new WalkontableCellCoords(expandedRange.from.row, expandedRange.from.col))) {
  963. return this.getBottomRightCorner();
  964. }
  965. if (this.getTopRightCorner().isEqual(new WalkontableCellCoords(expandedRange.from.row, expandedRange.to.col))) {
  966. return this.getBottomLeftCorner();
  967. }
  968. if (this.getBottomLeftCorner().isEqual(new WalkontableCellCoords(expandedRange.to.row, expandedRange.from.col))) {
  969. return this.getTopRightCorner();
  970. }
  971. if (this.getBottomRightCorner().isEqual(new WalkontableCellCoords(expandedRange.to.row, expandedRange.to.col))) {
  972. return this.getTopLeftCorner();
  973. }
  974. }
  975. }
  976. if (coords.isEqual(this.getBottomRightCorner())) {
  977. return this.getTopLeftCorner();
  978. } else if (coords.isEqual(this.getTopLeftCorner())) {
  979. return this.getBottomRightCorner();
  980. } else if (coords.isEqual(this.getTopRightCorner())) {
  981. return this.getBottomLeftCorner();
  982. } else if (coords.isEqual(this.getBottomLeftCorner())) {
  983. return this.getTopRightCorner();
  984. }
  985. },
  986. getBordersSharedWith: function(range) {
  987. if (!this.includesRange(range)) {
  988. return [];
  989. }
  990. var thisBorders = {
  991. top: Math.min(this.from.row, this.to.row),
  992. bottom: Math.max(this.from.row, this.to.row),
  993. left: Math.min(this.from.col, this.to.col),
  994. right: Math.max(this.from.col, this.to.col)
  995. };
  996. var rangeBorders = {
  997. top: Math.min(range.from.row, range.to.row),
  998. bottom: Math.max(range.from.row, range.to.row),
  999. left: Math.min(range.from.col, range.to.col),
  1000. right: Math.max(range.from.col, range.to.col)
  1001. };
  1002. var result = [];
  1003. if (thisBorders.top == rangeBorders.top) {
  1004. result.push('top');
  1005. }
  1006. if (thisBorders.right == rangeBorders.right) {
  1007. result.push('right');
  1008. }
  1009. if (thisBorders.bottom == rangeBorders.bottom) {
  1010. result.push('bottom');
  1011. }
  1012. if (thisBorders.left == rangeBorders.left) {
  1013. result.push('left');
  1014. }
  1015. return result;
  1016. },
  1017. getInner: function() {
  1018. var topLeft = this.getTopLeftCorner();
  1019. var bottomRight = this.getBottomRightCorner();
  1020. var out = [];
  1021. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  1022. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  1023. if (!(this.from.row === r && this.from.col === c) && !(this.to.row === r && this.to.col === c)) {
  1024. out.push(new WalkontableCellCoords(r, c));
  1025. }
  1026. }
  1027. }
  1028. return out;
  1029. },
  1030. getAll: function() {
  1031. var topLeft = this.getTopLeftCorner();
  1032. var bottomRight = this.getBottomRightCorner();
  1033. var out = [];
  1034. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  1035. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  1036. if (topLeft.row === r && topLeft.col === c) {
  1037. out.push(topLeft);
  1038. } else if (bottomRight.row === r && bottomRight.col === c) {
  1039. out.push(bottomRight);
  1040. } else {
  1041. out.push(new WalkontableCellCoords(r, c));
  1042. }
  1043. }
  1044. }
  1045. return out;
  1046. },
  1047. forAll: function(callback) {
  1048. var topLeft = this.getTopLeftCorner();
  1049. var bottomRight = this.getBottomRightCorner();
  1050. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  1051. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  1052. var breakIteration = callback(r, c);
  1053. if (breakIteration === false) {
  1054. return;
  1055. }
  1056. }
  1057. }
  1058. }
  1059. }, {});
  1060. ;
  1061. window.WalkontableCellRange = WalkontableCellRange;
  1062. //#
  1063. },{"cell/coords":5}],7:[function(require,module,exports){
  1064. "use strict";
  1065. Object.defineProperties(exports, {
  1066. Walkontable: {get: function() {
  1067. return Walkontable;
  1068. }},
  1069. __esModule: {value: true}
  1070. });
  1071. var $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  1072. $___46__46__47__46__46__47__46__46__47_helpers_47_object__,
  1073. $___46__46__47__46__46__47__46__46__47_helpers_47_string__,
  1074. $__event__,
  1075. $__overlays__,
  1076. $__scroll__,
  1077. $__settings__,
  1078. $__table__,
  1079. $__viewport__,
  1080. $__overlay_47__95_base_46_js__,
  1081. $__overlay_47_top_46_js__,
  1082. $__overlay_47_left_46_js__,
  1083. $__overlay_47_debug_46_js__,
  1084. $__overlay_47_topLeftCorner_46_js__;
  1085. var $__0 = ($___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}),
  1086. addClass = $__0.addClass,
  1087. fastInnerText = $__0.fastInnerText,
  1088. isVisible = $__0.isVisible,
  1089. removeClass = $__0.removeClass;
  1090. var objectEach = ($___46__46__47__46__46__47__46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47__46__46__47__46__46__47_helpers_47_object__ && $___46__46__47__46__46__47__46__46__47_helpers_47_object__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_object__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_object__}).objectEach;
  1091. var $__2 = ($___46__46__47__46__46__47__46__46__47_helpers_47_string__ = require("helpers/string"), $___46__46__47__46__46__47__46__46__47_helpers_47_string__ && $___46__46__47__46__46__47__46__46__47_helpers_47_string__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_string__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_string__}),
  1092. toUpperCaseFirst = $__2.toUpperCaseFirst,
  1093. randomString = $__2.randomString;
  1094. var WalkontableEvent = ($__event__ = require("event"), $__event__ && $__event__.__esModule && $__event__ || {default: $__event__}).WalkontableEvent;
  1095. var WalkontableOverlays = ($__overlays__ = require("overlays"), $__overlays__ && $__overlays__.__esModule && $__overlays__ || {default: $__overlays__}).WalkontableOverlays;
  1096. var WalkontableScroll = ($__scroll__ = require("scroll"), $__scroll__ && $__scroll__.__esModule && $__scroll__ || {default: $__scroll__}).WalkontableScroll;
  1097. var WalkontableSettings = ($__settings__ = require("settings"), $__settings__ && $__settings__.__esModule && $__settings__ || {default: $__settings__}).WalkontableSettings;
  1098. var WalkontableTable = ($__table__ = require("table"), $__table__ && $__table__.__esModule && $__table__ || {default: $__table__}).WalkontableTable;
  1099. var WalkontableViewport = ($__viewport__ = require("viewport"), $__viewport__ && $__viewport__.__esModule && $__viewport__ || {default: $__viewport__}).WalkontableViewport;
  1100. var WalkontableOverlay = ($__overlay_47__95_base_46_js__ = require("overlay/_base.js"), $__overlay_47__95_base_46_js__ && $__overlay_47__95_base_46_js__.__esModule && $__overlay_47__95_base_46_js__ || {default: $__overlay_47__95_base_46_js__}).WalkontableOverlay;
  1101. var WalkontableTopOverlay = ($__overlay_47_top_46_js__ = require("overlay/top.js"), $__overlay_47_top_46_js__ && $__overlay_47_top_46_js__.__esModule && $__overlay_47_top_46_js__ || {default: $__overlay_47_top_46_js__}).WalkontableTopOverlay;
  1102. var WalkontableLeftOverlay = ($__overlay_47_left_46_js__ = require("overlay/left.js"), $__overlay_47_left_46_js__ && $__overlay_47_left_46_js__.__esModule && $__overlay_47_left_46_js__ || {default: $__overlay_47_left_46_js__}).WalkontableLeftOverlay;
  1103. var WalkontableDebugOverlay = ($__overlay_47_debug_46_js__ = require("overlay/debug.js"), $__overlay_47_debug_46_js__ && $__overlay_47_debug_46_js__.__esModule && $__overlay_47_debug_46_js__ || {default: $__overlay_47_debug_46_js__}).WalkontableDebugOverlay;
  1104. var WalkontableTopLeftCornerOverlay = ($__overlay_47_topLeftCorner_46_js__ = require("overlay/topLeftCorner.js"), $__overlay_47_topLeftCorner_46_js__ && $__overlay_47_topLeftCorner_46_js__.__esModule && $__overlay_47_topLeftCorner_46_js__ || {default: $__overlay_47_topLeftCorner_46_js__}).WalkontableTopLeftCornerOverlay;
  1105. var Walkontable = function Walkontable(settings) {
  1106. var originalHeaders = [];
  1107. this.guid = 'wt_' + randomString();
  1108. if (settings.cloneSource) {
  1109. this.cloneSource = settings.cloneSource;
  1110. this.cloneOverlay = settings.cloneOverlay;
  1111. this.wtSettings = settings.cloneSource.wtSettings;
  1112. this.wtTable = new WalkontableTable(this, settings.table, settings.wtRootElement);
  1113. this.wtScroll = new WalkontableScroll(this);
  1114. this.wtViewport = settings.cloneSource.wtViewport;
  1115. this.wtEvent = new WalkontableEvent(this);
  1116. this.selections = this.cloneSource.selections;
  1117. } else {
  1118. this.wtSettings = new WalkontableSettings(this, settings);
  1119. this.wtTable = new WalkontableTable(this, settings.table);
  1120. this.wtScroll = new WalkontableScroll(this);
  1121. this.wtViewport = new WalkontableViewport(this);
  1122. this.wtEvent = new WalkontableEvent(this);
  1123. this.selections = this.getSetting('selections');
  1124. this.wtOverlays = new WalkontableOverlays(this);
  1125. this.exportSettingsAsClassNames();
  1126. }
  1127. if (this.wtTable.THEAD.childNodes.length && this.wtTable.THEAD.childNodes[0].childNodes.length) {
  1128. for (var c = 0,
  1129. clen = this.wtTable.THEAD.childNodes[0].childNodes.length; c < clen; c++) {
  1130. originalHeaders.push(this.wtTable.THEAD.childNodes[0].childNodes[c].innerHTML);
  1131. }
  1132. if (!this.getSetting('columnHeaders').length) {
  1133. this.update('columnHeaders', [function(column, TH) {
  1134. fastInnerText(TH, originalHeaders[column]);
  1135. }]);
  1136. }
  1137. }
  1138. this.drawn = false;
  1139. this.drawInterrupted = false;
  1140. };
  1141. ($traceurRuntime.createClass)(Walkontable, {
  1142. draw: function() {
  1143. var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
  1144. this.drawInterrupted = false;
  1145. if (!fastDraw && !isVisible(this.wtTable.TABLE)) {
  1146. this.drawInterrupted = true;
  1147. } else {
  1148. this.wtTable.draw(fastDraw);
  1149. }
  1150. return this;
  1151. },
  1152. getCell: function(coords) {
  1153. var topmost = arguments[1] !== (void 0) ? arguments[1] : false;
  1154. if (!topmost) {
  1155. return this.wtTable.getCell(coords);
  1156. }
  1157. var totalRows = this.wtSettings.getSetting('totalRows');
  1158. var fixedRowsTop = this.wtSettings.getSetting('fixedRowsTop');
  1159. var fixedRowsBottom = this.wtSettings.getSetting('fixedRowsBottom');
  1160. var fixedColumns = this.wtSettings.getSetting('fixedColumnsLeft');
  1161. if (coords.row < fixedRowsTop && coords.col < fixedColumns) {
  1162. return this.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell(coords);
  1163. } else if (coords.row < fixedRowsTop) {
  1164. return this.wtOverlays.topOverlay.clone.wtTable.getCell(coords);
  1165. } else if (coords.col < fixedColumns && coords.row >= totalRows - fixedRowsBottom) {
  1166. if (this.wtOverlays.bottomLeftCornerOverlay.clone) {
  1167. return this.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell(coords);
  1168. }
  1169. } else if (coords.col < fixedColumns) {
  1170. return this.wtOverlays.leftOverlay.clone.wtTable.getCell(coords);
  1171. } else if (coords.row > totalRows - fixedRowsBottom) {
  1172. if (this.wtOverlays.bottomOverlay.clone) {
  1173. return this.wtOverlays.bottomOverlay.clone.wtTable.getCell(coords);
  1174. }
  1175. }
  1176. return this.wtTable.getCell(coords);
  1177. },
  1178. update: function(settings, value) {
  1179. return this.wtSettings.update(settings, value);
  1180. },
  1181. scrollVertical: function(row) {
  1182. this.wtOverlays.topOverlay.scrollTo(row);
  1183. this.getSetting('onScrollVertically');
  1184. return this;
  1185. },
  1186. scrollHorizontal: function(column) {
  1187. this.wtOverlays.leftOverlay.scrollTo(column);
  1188. this.getSetting('onScrollHorizontally');
  1189. return this;
  1190. },
  1191. scrollViewport: function(coords) {
  1192. this.wtScroll.scrollViewport(coords);
  1193. return this;
  1194. },
  1195. getViewport: function() {
  1196. return [this.wtTable.getFirstVisibleRow(), this.wtTable.getFirstVisibleColumn(), this.wtTable.getLastVisibleRow(), this.wtTable.getLastVisibleColumn()];
  1197. },
  1198. getOverlayName: function() {
  1199. return this.cloneOverlay ? this.cloneOverlay.type : 'master';
  1200. },
  1201. exportSettingsAsClassNames: function() {
  1202. var $__14 = this;
  1203. var toExport = {
  1204. rowHeaders: ['array'],
  1205. columnHeaders: ['array']
  1206. };
  1207. var allClassNames = [];
  1208. var newClassNames = [];
  1209. objectEach(toExport, (function(optionType, key) {
  1210. if (optionType.indexOf('array') > -1 && $__14.getSetting(key).length) {
  1211. newClassNames.push('ht' + toUpperCaseFirst(key));
  1212. }
  1213. allClassNames.push('ht' + toUpperCaseFirst(key));
  1214. }));
  1215. removeClass(this.wtTable.wtRootElement.parentNode, allClassNames);
  1216. addClass(this.wtTable.wtRootElement.parentNode, newClassNames);
  1217. },
  1218. getSetting: function(key, param1, param2, param3, param4) {
  1219. return this.wtSettings.getSetting(key, param1, param2, param3, param4);
  1220. },
  1221. hasSetting: function(key) {
  1222. return this.wtSettings.has(key);
  1223. },
  1224. destroy: function() {
  1225. this.wtOverlays.destroy();
  1226. this.wtEvent.destroy();
  1227. }
  1228. }, {});
  1229. ;
  1230. window.Walkontable = Walkontable;
  1231. //#
  1232. },{"event":8,"helpers/dom/element":45,"helpers/object":50,"helpers/string":52,"overlay/_base.js":11,"overlay/debug.js":12,"overlay/left.js":13,"overlay/top.js":14,"overlay/topLeftCorner.js":15,"overlays":16,"scroll":17,"settings":19,"table":20,"viewport":22}],8:[function(require,module,exports){
  1233. "use strict";
  1234. Object.defineProperties(exports, {
  1235. WalkontableEvent: {get: function() {
  1236. return WalkontableEvent;
  1237. }},
  1238. __esModule: {value: true}
  1239. });
  1240. var $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  1241. $___46__46__47__46__46__47__46__46__47_eventManager__;
  1242. var $__0 = ($___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}),
  1243. closest = $__0.closest,
  1244. hasClass = $__0.hasClass,
  1245. isChildOf = $__0.isChildOf;
  1246. var eventManagerObject = ($___46__46__47__46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47__46__46__47_eventManager__}).eventManager;
  1247. function WalkontableEvent(instance) {
  1248. var that = this;
  1249. var eventManager = eventManagerObject(instance);
  1250. this.instance = instance;
  1251. var dblClickOrigin = [null, null];
  1252. this.dblClickTimeout = [null, null];
  1253. var onMouseDown = function(event) {
  1254. var cell = that.parentCell(event.realTarget);
  1255. if (hasClass(event.realTarget, 'corner')) {
  1256. that.instance.getSetting('onCellCornerMouseDown', event, event.realTarget);
  1257. } else if (cell.TD) {
  1258. if (that.instance.hasSetting('onCellMouseDown')) {
  1259. that.instance.getSetting('onCellMouseDown', event, cell.coords, cell.TD, that.instance);
  1260. }
  1261. }
  1262. if (event.button !== 2) {
  1263. if (cell.TD) {
  1264. dblClickOrigin[0] = cell.TD;
  1265. clearTimeout(that.dblClickTimeout[0]);
  1266. that.dblClickTimeout[0] = setTimeout(function() {
  1267. dblClickOrigin[0] = null;
  1268. }, 1000);
  1269. }
  1270. }
  1271. };
  1272. var onTouchMove = function(event) {
  1273. that.instance.touchMoving = true;
  1274. };
  1275. var longTouchTimeout;
  1276. var onTouchStart = function(event) {
  1277. var container = this;
  1278. eventManager.addEventListener(this, 'touchmove', onTouchMove);
  1279. that.checkIfTouchMove = setTimeout(function() {
  1280. if (that.instance.touchMoving === true) {
  1281. that.instance.touchMoving = void 0;
  1282. eventManager.removeEventListener('touchmove', onTouchMove, false);
  1283. return;
  1284. } else {
  1285. onMouseDown(event);
  1286. }
  1287. }, 30);
  1288. };
  1289. var lastMouseOver;
  1290. var onMouseOver = function(event) {
  1291. var table,
  1292. td;
  1293. if (that.instance.hasSetting('onCellMouseOver')) {
  1294. table = that.instance.wtTable.TABLE;
  1295. td = closest(event.realTarget, ['TD', 'TH'], table);
  1296. if (td && td !== lastMouseOver && isChildOf(td, table)) {
  1297. lastMouseOver = td;
  1298. that.instance.getSetting('onCellMouseOver', event, that.instance.wtTable.getCoords(td), td, that.instance);
  1299. }
  1300. }
  1301. };
  1302. var onMouseUp = function(event) {
  1303. if (event.button !== 2) {
  1304. var cell = that.parentCell(event.realTarget);
  1305. if (cell.TD === dblClickOrigin[0] && cell.TD === dblClickOrigin[1]) {
  1306. if (hasClass(event.realTarget, 'corner')) {
  1307. that.instance.getSetting('onCellCornerDblClick', event, cell.coords, cell.TD, that.instance);
  1308. } else {
  1309. that.instance.getSetting('onCellDblClick', event, cell.coords, cell.TD, that.instance);
  1310. }
  1311. dblClickOrigin[0] = null;
  1312. dblClickOrigin[1] = null;
  1313. } else if (cell.TD === dblClickOrigin[0]) {
  1314. dblClickOrigin[1] = cell.TD;
  1315. clearTimeout(that.dblClickTimeout[1]);
  1316. that.dblClickTimeout[1] = setTimeout(function() {
  1317. dblClickOrigin[1] = null;
  1318. }, 500);
  1319. }
  1320. }
  1321. };
  1322. var onTouchEnd = function(event) {
  1323. clearTimeout(longTouchTimeout);
  1324. event.preventDefault();
  1325. onMouseUp(event);
  1326. };
  1327. eventManager.addEventListener(this.instance.wtTable.holder, 'mousedown', onMouseDown);
  1328. eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseover', onMouseOver);
  1329. eventManager.addEventListener(this.instance.wtTable.holder, 'mouseup', onMouseUp);
  1330. if (this.instance.wtTable.holder.parentNode.parentNode && Handsontable.mobileBrowser && !that.instance.wtTable.isWorkingOnClone()) {
  1331. var classSelector = '.' + this.instance.wtTable.holder.parentNode.className.split(' ').join('.');
  1332. eventManager.addEventListener(this.instance.wtTable.holder, 'touchstart', function(event) {
  1333. that.instance.touchApplied = true;
  1334. if (isChildOf(event.target, classSelector)) {
  1335. onTouchStart.call(event.target, event);
  1336. }
  1337. });
  1338. eventManager.addEventListener(this.instance.wtTable.holder, 'touchend', function(event) {
  1339. that.instance.touchApplied = false;
  1340. if (isChildOf(event.target, classSelector)) {
  1341. onTouchEnd.call(event.target, event);
  1342. }
  1343. });
  1344. if (!that.instance.momentumScrolling) {
  1345. that.instance.momentumScrolling = {};
  1346. }
  1347. eventManager.addEventListener(this.instance.wtTable.holder, 'scroll', function(event) {
  1348. clearTimeout(that.instance.momentumScrolling._timeout);
  1349. if (!that.instance.momentumScrolling.ongoing) {
  1350. that.instance.getSetting('onBeforeTouchScroll');
  1351. }
  1352. that.instance.momentumScrolling.ongoing = true;
  1353. that.instance.momentumScrolling._timeout = setTimeout(function() {
  1354. if (!that.instance.touchApplied) {
  1355. that.instance.momentumScrolling.ongoing = false;
  1356. that.instance.getSetting('onAfterMomentumScroll');
  1357. }
  1358. }, 200);
  1359. });
  1360. }
  1361. eventManager.addEventListener(window, 'resize', function() {
  1362. if (that.instance.getSetting('stretchH') !== 'none') {
  1363. that.instance.draw();
  1364. }
  1365. });
  1366. this.destroy = function() {
  1367. clearTimeout(this.dblClickTimeout[0]);
  1368. clearTimeout(this.dblClickTimeout[1]);
  1369. eventManager.destroy();
  1370. };
  1371. }
  1372. WalkontableEvent.prototype.parentCell = function(elem) {
  1373. var cell = {};
  1374. var TABLE = this.instance.wtTable.TABLE;
  1375. var TD = closest(elem, ['TD', 'TH'], TABLE);
  1376. if (TD && isChildOf(TD, TABLE)) {
  1377. cell.coords = this.instance.wtTable.getCoords(TD);
  1378. cell.TD = TD;
  1379. } else if (hasClass(elem, 'wtBorder') && hasClass(elem, 'current')) {
  1380. cell.coords = this.instance.selections.current.cellRange.highlight;
  1381. cell.TD = this.instance.wtTable.getCell(cell.coords);
  1382. } else if (hasClass(elem, 'wtBorder') && hasClass(elem, 'area')) {
  1383. if (this.instance.selections.area.cellRange) {
  1384. cell.coords = this.instance.selections.area.cellRange.to;
  1385. cell.TD = this.instance.wtTable.getCell(cell.coords);
  1386. }
  1387. }
  1388. return cell;
  1389. };
  1390. ;
  1391. window.WalkontableEvent = WalkontableEvent;
  1392. //#
  1393. },{"eventManager":41,"helpers/dom/element":45}],9:[function(require,module,exports){
  1394. "use strict";
  1395. Object.defineProperties(exports, {
  1396. WalkontableColumnFilter: {get: function() {
  1397. return WalkontableColumnFilter;
  1398. }},
  1399. __esModule: {value: true}
  1400. });
  1401. var WalkontableColumnFilter = function WalkontableColumnFilter(offset, total, countTH) {
  1402. this.offset = offset;
  1403. this.total = total;
  1404. this.countTH = countTH;
  1405. };
  1406. ($traceurRuntime.createClass)(WalkontableColumnFilter, {
  1407. offsetted: function(index) {
  1408. return index + this.offset;
  1409. },
  1410. unOffsetted: function(index) {
  1411. return index - this.offset;
  1412. },
  1413. renderedToSource: function(index) {
  1414. return this.offsetted(index);
  1415. },
  1416. sourceToRendered: function(index) {
  1417. return this.unOffsetted(index);
  1418. },
  1419. offsettedTH: function(index) {
  1420. return index - this.countTH;
  1421. },
  1422. unOffsettedTH: function(index) {
  1423. return index + this.countTH;
  1424. },
  1425. visibleRowHeadedColumnToSourceColumn: function(index) {
  1426. return this.renderedToSource(this.offsettedTH(index));
  1427. },
  1428. sourceColumnToVisibleRowHeadedColumn: function(index) {
  1429. return this.unOffsettedTH(this.sourceToRendered(index));
  1430. }
  1431. }, {});
  1432. ;
  1433. window.WalkontableColumnFilter = WalkontableColumnFilter;
  1434. //#
  1435. },{}],10:[function(require,module,exports){
  1436. "use strict";
  1437. Object.defineProperties(exports, {
  1438. WalkontableRowFilter: {get: function() {
  1439. return WalkontableRowFilter;
  1440. }},
  1441. __esModule: {value: true}
  1442. });
  1443. var WalkontableRowFilter = function WalkontableRowFilter(offset, total, countTH) {
  1444. this.offset = offset;
  1445. this.total = total;
  1446. this.countTH = countTH;
  1447. };
  1448. ($traceurRuntime.createClass)(WalkontableRowFilter, {
  1449. offsetted: function(index) {
  1450. return index + this.offset;
  1451. },
  1452. unOffsetted: function(index) {
  1453. return index - this.offset;
  1454. },
  1455. renderedToSource: function(index) {
  1456. return this.offsetted(index);
  1457. },
  1458. sourceToRendered: function(index) {
  1459. return this.unOffsetted(index);
  1460. },
  1461. offsettedTH: function(index) {
  1462. return index - this.countTH;
  1463. },
  1464. unOffsettedTH: function(index) {
  1465. return index + this.countTH;
  1466. },
  1467. visibleColHeadedRowToSourceRow: function(index) {
  1468. return this.renderedToSource(this.offsettedTH(index));
  1469. },
  1470. sourceRowToVisibleColHeadedRow: function(index) {
  1471. return this.unOffsettedTH(this.sourceToRendered(index));
  1472. }
  1473. }, {});
  1474. ;
  1475. window.WalkontableRowFilter = WalkontableRowFilter;
  1476. //#
  1477. },{}],11:[function(require,module,exports){
  1478. "use strict";
  1479. Object.defineProperties(exports, {
  1480. WalkontableOverlay: {get: function() {
  1481. return WalkontableOverlay;
  1482. }},
  1483. __esModule: {value: true}
  1484. });
  1485. var $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  1486. $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_object__,
  1487. $___46__46__47__46__46__47__46__46__47__46__46__47_eventManager__;
  1488. var $__0 = ($___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}),
  1489. getScrollableElement = $__0.getScrollableElement,
  1490. getTrimmingContainer = $__0.getTrimmingContainer;
  1491. var defineGetter = ($___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_object__ && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_object__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_object__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_object__}).defineGetter;
  1492. var eventManagerObject = ($___46__46__47__46__46__47__46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47__46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47__46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_eventManager__}).eventManager;
  1493. var registeredOverlays = {};
  1494. var WalkontableOverlay = function WalkontableOverlay(wotInstance) {
  1495. defineGetter(this, 'wot', wotInstance, {writable: false});
  1496. this.instance = this.wot;
  1497. this.type = '';
  1498. this.TABLE = this.wot.wtTable.TABLE;
  1499. this.hider = this.wot.wtTable.hider;
  1500. this.spreader = this.wot.wtTable.spreader;
  1501. this.holder = this.wot.wtTable.holder;
  1502. this.wtRootElement = this.wot.wtTable.wtRootElement;
  1503. this.trimmingContainer = getTrimmingContainer(this.hider.parentNode.parentNode);
  1504. this.mainTableScrollableElement = getScrollableElement(this.wot.wtTable.TABLE);
  1505. this.needFullRender = this.shouldBeRendered();
  1506. this.areElementSizesAdjusted = false;
  1507. };
  1508. var $WalkontableOverlay = WalkontableOverlay;
  1509. ($traceurRuntime.createClass)(WalkontableOverlay, {
  1510. shouldBeRendered: function() {
  1511. return true;
  1512. },
  1513. makeClone: function(direction) {
  1514. if ($WalkontableOverlay.CLONE_TYPES.indexOf(direction) === -1) {
  1515. throw new Error('Clone type "' + direction + '" is not supported.');
  1516. }
  1517. var clone = document.createElement('DIV');
  1518. var clonedTable = document.createElement('TABLE');
  1519. clone.className = 'ht_clone_' + direction + ' handsontable';
  1520. clone.style.position = 'absolute';
  1521. clone.style.top = 0;
  1522. clone.style.left = 0;
  1523. clone.style.overflow = 'hidden';
  1524. clonedTable.className = this.wot.wtTable.TABLE.className;
  1525. clone.appendChild(clonedTable);
  1526. this.type = direction;
  1527. this.wot.wtTable.wtRootElement.parentNode.appendChild(clone);
  1528. return new Walkontable({
  1529. cloneSource: this.wot,
  1530. cloneOverlay: this,
  1531. table: clonedTable
  1532. });
  1533. },
  1534. refresh: function() {
  1535. var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
  1536. var nextCycleRenderFlag = this.shouldBeRendered();
  1537. if (this.clone && (this.needFullRender || nextCycleRenderFlag)) {
  1538. this.clone.draw(fastDraw);
  1539. }
  1540. this.needFullRender = nextCycleRenderFlag;
  1541. },
  1542. destroy: function() {
  1543. eventManagerObject(this.clone).destroy();
  1544. }
  1545. }, {
  1546. get CLONE_TOP() {
  1547. return 'top';
  1548. },
  1549. get CLONE_BOTTOM() {
  1550. return 'bottom';
  1551. },
  1552. get CLONE_LEFT() {
  1553. return 'left';
  1554. },
  1555. get CLONE_TOP_LEFT_CORNER() {
  1556. return 'top_left_corner';
  1557. },
  1558. get CLONE_BOTTOM_LEFT_CORNER() {
  1559. return 'bottom_left_corner';
  1560. },
  1561. get CLONE_DEBUG() {
  1562. return 'debug';
  1563. },
  1564. get CLONE_TYPES() {
  1565. return [$WalkontableOverlay.CLONE_TOP, $WalkontableOverlay.CLONE_BOTTOM, $WalkontableOverlay.CLONE_LEFT, $WalkontableOverlay.CLONE_TOP_LEFT_CORNER, $WalkontableOverlay.CLONE_BOTTOM_LEFT_CORNER, $WalkontableOverlay.CLONE_DEBUG];
  1566. },
  1567. registerOverlay: function(type, overlayClass) {
  1568. if ($WalkontableOverlay.CLONE_TYPES.indexOf(type) === -1) {
  1569. throw new Error(("Unsupported overlay (" + type + ")."));
  1570. }
  1571. registeredOverlays[type] = overlayClass;
  1572. },
  1573. createOverlay: function(type, wot) {
  1574. return new registeredOverlays[type](wot);
  1575. },
  1576. isOverlayTypeOf: function(overlay, type) {
  1577. if (!overlay || !registeredOverlays[type]) {
  1578. return false;
  1579. }
  1580. return overlay instanceof registeredOverlays[type];
  1581. }
  1582. });
  1583. ;
  1584. window.WalkontableOverlay = WalkontableOverlay;
  1585. //#
  1586. },{"eventManager":41,"helpers/dom/element":45,"helpers/object":50}],12:[function(require,module,exports){
  1587. "use strict";
  1588. Object.defineProperties(exports, {
  1589. WalkontableDebugOverlay: {get: function() {
  1590. return WalkontableDebugOverlay;
  1591. }},
  1592. __esModule: {value: true}
  1593. });
  1594. var $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  1595. $___95_base__;
  1596. var addClass = ($___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}).addClass;
  1597. var WalkontableOverlay = ($___95_base__ = require("_base"), $___95_base__ && $___95_base__.__esModule && $___95_base__ || {default: $___95_base__}).WalkontableOverlay;
  1598. var WalkontableDebugOverlay = function WalkontableDebugOverlay(wotInstance) {
  1599. $traceurRuntime.superConstructor($WalkontableDebugOverlay).call(this, wotInstance);
  1600. this.clone = this.makeClone(WalkontableOverlay.CLONE_DEBUG);
  1601. this.clone.wtTable.holder.style.opacity = 0.4;
  1602. this.clone.wtTable.holder.style.textShadow = '0 0 2px #ff0000';
  1603. addClass(this.clone.wtTable.holder.parentNode, 'wtDebugVisible');
  1604. };
  1605. var $WalkontableDebugOverlay = WalkontableDebugOverlay;
  1606. ($traceurRuntime.createClass)(WalkontableDebugOverlay, {}, {}, WalkontableOverlay);
  1607. ;
  1608. window.WalkontableDebugOverlay = WalkontableDebugOverlay;
  1609. WalkontableOverlay.registerOverlay(WalkontableOverlay.CLONE_DEBUG, WalkontableDebugOverlay);
  1610. //#
  1611. },{"_base":11,"helpers/dom/element":45}],13:[function(require,module,exports){
  1612. "use strict";
  1613. Object.defineProperties(exports, {
  1614. WalkontableLeftOverlay: {get: function() {
  1615. return WalkontableLeftOverlay;
  1616. }},
  1617. __esModule: {value: true}
  1618. });
  1619. var $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  1620. $___95_base__;
  1621. var $__0 = ($___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}),
  1622. addClass = $__0.addClass,
  1623. getScrollbarWidth = $__0.getScrollbarWidth,
  1624. getScrollLeft = $__0.getScrollLeft,
  1625. getWindowScrollTop = $__0.getWindowScrollTop,
  1626. hasClass = $__0.hasClass,
  1627. outerWidth = $__0.outerWidth,
  1628. removeClass = $__0.removeClass,
  1629. setOverlayPosition = $__0.setOverlayPosition;
  1630. var WalkontableOverlay = ($___95_base__ = require("_base"), $___95_base__ && $___95_base__.__esModule && $___95_base__ || {default: $___95_base__}).WalkontableOverlay;
  1631. var WalkontableLeftOverlay = function WalkontableLeftOverlay(wotInstance) {
  1632. $traceurRuntime.superConstructor($WalkontableLeftOverlay).call(this, wotInstance);
  1633. this.clone = this.makeClone(WalkontableOverlay.CLONE_LEFT);
  1634. };
  1635. var $WalkontableLeftOverlay = WalkontableLeftOverlay;
  1636. ($traceurRuntime.createClass)(WalkontableLeftOverlay, {
  1637. shouldBeRendered: function() {
  1638. return this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length ? true : false;
  1639. },
  1640. resetFixedPosition: function() {
  1641. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  1642. return;
  1643. }
  1644. var overlayRoot = this.clone.wtTable.holder.parentNode;
  1645. var headerPosition = 0;
  1646. if (this.trimmingContainer === window) {
  1647. var box = this.wot.wtTable.hider.getBoundingClientRect();
  1648. var left = Math.ceil(box.left);
  1649. var right = Math.ceil(box.right);
  1650. var finalLeft;
  1651. var finalTop;
  1652. finalTop = this.wot.wtTable.hider.style.top;
  1653. finalTop = finalTop === '' ? 0 : finalTop;
  1654. if (left < 0 && (right - overlayRoot.offsetWidth) > 0) {
  1655. finalLeft = -left;
  1656. } else {
  1657. finalLeft = 0;
  1658. }
  1659. headerPosition = finalLeft;
  1660. finalLeft = finalLeft + 'px';
  1661. setOverlayPosition(overlayRoot, finalLeft, finalTop);
  1662. } else {
  1663. headerPosition = this.getScrollPosition();
  1664. }
  1665. this.adjustHeaderBordersPosition(headerPosition);
  1666. this.adjustElementsSize();
  1667. },
  1668. setScrollPosition: function(pos) {
  1669. if (this.mainTableScrollableElement === window) {
  1670. window.scrollTo(pos, getWindowScrollTop());
  1671. } else {
  1672. this.mainTableScrollableElement.scrollLeft = pos;
  1673. }
  1674. },
  1675. onScroll: function() {
  1676. this.wot.getSetting('onScrollVertically');
  1677. },
  1678. sumCellSizes: function(from, to) {
  1679. var sum = 0;
  1680. var defaultColumnWidth = this.wot.wtSettings.defaultColumnWidth;
  1681. while (from < to) {
  1682. sum += this.wot.wtTable.getStretchedColumnWidth(from) || defaultColumnWidth;
  1683. from++;
  1684. }
  1685. return sum;
  1686. },
  1687. adjustElementsSize: function() {
  1688. var force = arguments[0] !== (void 0) ? arguments[0] : false;
  1689. if (this.needFullRender || force) {
  1690. this.adjustRootElementSize();
  1691. this.adjustRootChildrenSize();
  1692. if (!force) {
  1693. this.areElementSizesAdjusted = true;
  1694. }
  1695. }
  1696. },
  1697. adjustRootElementSize: function() {
  1698. var masterHolder = this.wot.wtTable.holder;
  1699. var scrollbarHeight = masterHolder.clientHeight === masterHolder.offsetHeight ? 0 : getScrollbarWidth();
  1700. var overlayRoot = this.clone.wtTable.holder.parentNode;
  1701. var overlayRootStyle = overlayRoot.style;
  1702. var tableWidth;
  1703. if (this.trimmingContainer !== window) {
  1704. overlayRootStyle.height = this.wot.wtViewport.getWorkspaceHeight() - scrollbarHeight + 'px';
  1705. }
  1706. this.clone.wtTable.holder.style.height = overlayRootStyle.height;
  1707. tableWidth = outerWidth(this.clone.wtTable.TABLE);
  1708. overlayRootStyle.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  1709. },
  1710. adjustRootChildrenSize: function() {
  1711. var scrollbarWidth = getScrollbarWidth();
  1712. this.clone.wtTable.hider.style.height = this.hider.style.height;
  1713. this.clone.wtTable.holder.style.height = this.clone.wtTable.holder.parentNode.style.height;
  1714. if (scrollbarWidth === 0) {
  1715. scrollbarWidth = 30;
  1716. }
  1717. this.clone.wtTable.holder.style.width = parseInt(this.clone.wtTable.holder.parentNode.style.width, 10) + scrollbarWidth + 'px';
  1718. },
  1719. applyToDOM: function() {
  1720. var total = this.wot.getSetting('totalColumns');
  1721. if (!this.areElementSizesAdjusted) {
  1722. this.adjustElementsSize();
  1723. }
  1724. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  1725. this.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  1726. } else if (total === 0) {
  1727. this.spreader.style.left = '0';
  1728. } else {
  1729. throw new Error('Incorrect value of the columnsRenderCalculator');
  1730. }
  1731. this.spreader.style.right = '';
  1732. if (this.needFullRender) {
  1733. this.syncOverlayOffset();
  1734. }
  1735. },
  1736. syncOverlayOffset: function() {
  1737. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  1738. this.clone.wtTable.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  1739. } else {
  1740. this.clone.wtTable.spreader.style.top = '';
  1741. }
  1742. },
  1743. scrollTo: function(sourceCol, beyondRendered) {
  1744. var newX = this.getTableParentOffset();
  1745. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  1746. var mainHolder = sourceInstance.wtTable.holder;
  1747. var scrollbarCompensation = 0;
  1748. if (beyondRendered && mainHolder.offsetWidth !== mainHolder.clientWidth) {
  1749. scrollbarCompensation = getScrollbarWidth();
  1750. }
  1751. if (beyondRendered) {
  1752. newX += this.sumCellSizes(0, sourceCol + 1);
  1753. newX -= this.wot.wtViewport.getViewportWidth();
  1754. } else {
  1755. newX += this.sumCellSizes(this.wot.getSetting('fixedColumnsLeft'), sourceCol);
  1756. }
  1757. newX += scrollbarCompensation;
  1758. this.setScrollPosition(newX);
  1759. },
  1760. getTableParentOffset: function() {
  1761. if (this.trimmingContainer === window) {
  1762. return this.wot.wtTable.holderOffset.left;
  1763. } else {
  1764. return 0;
  1765. }
  1766. },
  1767. getScrollPosition: function() {
  1768. return getScrollLeft(this.mainTableScrollableElement);
  1769. },
  1770. adjustHeaderBordersPosition: function(position) {
  1771. var masterParent = this.wot.wtTable.holder.parentNode;
  1772. var rowHeaders = this.wot.getSetting('rowHeaders');
  1773. var fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
  1774. if (fixedColumnsLeft && !rowHeaders.length) {
  1775. addClass(masterParent, 'innerBorderLeft');
  1776. } else if (!fixedColumnsLeft && rowHeaders.length) {
  1777. var previousState = hasClass(masterParent, 'innerBorderLeft');
  1778. if (position) {
  1779. addClass(masterParent, 'innerBorderLeft');
  1780. } else {
  1781. removeClass(masterParent, 'innerBorderLeft');
  1782. }
  1783. if (!previousState && position || previousState && !position) {
  1784. this.wot.wtOverlays.adjustElementsSize();
  1785. }
  1786. }
  1787. }
  1788. }, {}, WalkontableOverlay);
  1789. ;
  1790. window.WalkontableLeftOverlay = WalkontableLeftOverlay;
  1791. WalkontableOverlay.registerOverlay(WalkontableOverlay.CLONE_LEFT, WalkontableLeftOverlay);
  1792. //#
  1793. },{"_base":11,"helpers/dom/element":45}],14:[function(require,module,exports){
  1794. "use strict";
  1795. Object.defineProperties(exports, {
  1796. WalkontableTopOverlay: {get: function() {
  1797. return WalkontableTopOverlay;
  1798. }},
  1799. __esModule: {value: true}
  1800. });
  1801. var $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  1802. $___95_base__;
  1803. var $__0 = ($___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}),
  1804. addClass = $__0.addClass,
  1805. getScrollbarWidth = $__0.getScrollbarWidth,
  1806. getScrollTop = $__0.getScrollTop,
  1807. getWindowScrollLeft = $__0.getWindowScrollLeft,
  1808. hasClass = $__0.hasClass,
  1809. outerHeight = $__0.outerHeight,
  1810. removeClass = $__0.removeClass,
  1811. setOverlayPosition = $__0.setOverlayPosition;
  1812. var WalkontableOverlay = ($___95_base__ = require("_base"), $___95_base__ && $___95_base__.__esModule && $___95_base__ || {default: $___95_base__}).WalkontableOverlay;
  1813. var WalkontableTopOverlay = function WalkontableTopOverlay(wotInstance) {
  1814. $traceurRuntime.superConstructor($WalkontableTopOverlay).call(this, wotInstance);
  1815. this.clone = this.makeClone(WalkontableOverlay.CLONE_TOP);
  1816. };
  1817. var $WalkontableTopOverlay = WalkontableTopOverlay;
  1818. ($traceurRuntime.createClass)(WalkontableTopOverlay, {
  1819. shouldBeRendered: function() {
  1820. return this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length ? true : false;
  1821. },
  1822. resetFixedPosition: function() {
  1823. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  1824. return;
  1825. }
  1826. var overlayRoot = this.clone.wtTable.holder.parentNode;
  1827. var headerPosition = 0;
  1828. if (this.wot.wtOverlays.leftOverlay.trimmingContainer === window) {
  1829. var box = this.wot.wtTable.hider.getBoundingClientRect();
  1830. var top = Math.ceil(box.top);
  1831. var bottom = Math.ceil(box.bottom);
  1832. var finalLeft;
  1833. var finalTop;
  1834. finalLeft = this.wot.wtTable.hider.style.left;
  1835. finalLeft = finalLeft === '' ? 0 : finalLeft;
  1836. if (top < 0 && (bottom - overlayRoot.offsetHeight) > 0) {
  1837. finalTop = -top;
  1838. } else {
  1839. finalTop = 0;
  1840. }
  1841. headerPosition = finalTop;
  1842. finalTop = finalTop + 'px';
  1843. setOverlayPosition(overlayRoot, finalLeft, finalTop);
  1844. } else {
  1845. headerPosition = this.getScrollPosition();
  1846. }
  1847. this.adjustHeaderBordersPosition(headerPosition);
  1848. this.adjustElementsSize();
  1849. },
  1850. setScrollPosition: function(pos) {
  1851. if (this.mainTableScrollableElement === window) {
  1852. window.scrollTo(getWindowScrollLeft(), pos);
  1853. } else {
  1854. this.mainTableScrollableElement.scrollTop = pos;
  1855. }
  1856. },
  1857. onScroll: function() {
  1858. this.wot.getSetting('onScrollHorizontally');
  1859. },
  1860. sumCellSizes: function(from, to) {
  1861. var sum = 0;
  1862. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  1863. while (from < to) {
  1864. var height = this.wot.wtTable.getRowHeight(from);
  1865. sum += height === void 0 ? defaultRowHeight : height;
  1866. from++;
  1867. }
  1868. return sum;
  1869. },
  1870. adjustElementsSize: function() {
  1871. var force = arguments[0] !== (void 0) ? arguments[0] : false;
  1872. if (this.needFullRender || force) {
  1873. this.adjustRootElementSize();
  1874. this.adjustRootChildrenSize();
  1875. if (!force) {
  1876. this.areElementSizesAdjusted = true;
  1877. }
  1878. }
  1879. },
  1880. adjustRootElementSize: function() {
  1881. var masterHolder = this.wot.wtTable.holder;
  1882. var scrollbarWidth = masterHolder.clientWidth === masterHolder.offsetWidth ? 0 : getScrollbarWidth();
  1883. var overlayRoot = this.clone.wtTable.holder.parentNode;
  1884. var overlayRootStyle = overlayRoot.style;
  1885. var tableHeight;
  1886. if (this.trimmingContainer !== window) {
  1887. overlayRootStyle.width = this.wot.wtViewport.getWorkspaceWidth() - scrollbarWidth + 'px';
  1888. }
  1889. this.clone.wtTable.holder.style.width = overlayRootStyle.width;
  1890. tableHeight = outerHeight(this.clone.wtTable.TABLE);
  1891. overlayRootStyle.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  1892. },
  1893. adjustRootChildrenSize: function() {
  1894. var scrollbarWidth = getScrollbarWidth();
  1895. this.clone.wtTable.hider.style.width = this.hider.style.width;
  1896. this.clone.wtTable.holder.style.width = this.clone.wtTable.holder.parentNode.style.width;
  1897. if (scrollbarWidth === 0) {
  1898. scrollbarWidth = 30;
  1899. }
  1900. this.clone.wtTable.holder.style.height = parseInt(this.clone.wtTable.holder.parentNode.style.height, 10) + scrollbarWidth + 'px';
  1901. },
  1902. applyToDOM: function() {
  1903. var total = this.wot.getSetting('totalRows');
  1904. if (!this.areElementSizesAdjusted) {
  1905. this.adjustElementsSize();
  1906. }
  1907. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  1908. this.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  1909. } else if (total === 0) {
  1910. this.spreader.style.top = '0';
  1911. } else {
  1912. throw new Error('Incorrect value of the rowsRenderCalculator');
  1913. }
  1914. this.spreader.style.bottom = '';
  1915. if (this.needFullRender) {
  1916. this.syncOverlayOffset();
  1917. }
  1918. },
  1919. syncOverlayOffset: function() {
  1920. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  1921. this.clone.wtTable.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  1922. } else {
  1923. this.clone.wtTable.spreader.style.left = '';
  1924. }
  1925. },
  1926. scrollTo: function(sourceRow, bottomEdge) {
  1927. var newY = this.getTableParentOffset();
  1928. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  1929. var mainHolder = sourceInstance.wtTable.holder;
  1930. var scrollbarCompensation = 0;
  1931. if (bottomEdge && mainHolder.offsetHeight !== mainHolder.clientHeight) {
  1932. scrollbarCompensation = getScrollbarWidth();
  1933. }
  1934. if (bottomEdge) {
  1935. var fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  1936. var fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  1937. var totalRows = this.wot.getSetting('totalRows');
  1938. newY += this.sumCellSizes(0, sourceRow + 1);
  1939. newY -= this.wot.wtViewport.getViewportHeight() - this.sumCellSizes(totalRows - fixedRowsBottom, totalRows);
  1940. newY += 1;
  1941. } else {
  1942. newY += this.sumCellSizes(this.wot.getSetting('fixedRowsTop'), sourceRow);
  1943. }
  1944. newY += scrollbarCompensation;
  1945. this.setScrollPosition(newY);
  1946. },
  1947. getTableParentOffset: function() {
  1948. if (this.mainTableScrollableElement === window) {
  1949. return this.wot.wtTable.holderOffset.top;
  1950. } else {
  1951. return 0;
  1952. }
  1953. },
  1954. getScrollPosition: function() {
  1955. return getScrollTop(this.mainTableScrollableElement);
  1956. },
  1957. adjustHeaderBordersPosition: function(position) {
  1958. if (this.wot.getSetting('fixedRowsTop') === 0 && this.wot.getSetting('columnHeaders').length > 0) {
  1959. var masterParent = this.wot.wtTable.holder.parentNode;
  1960. var previousState = hasClass(masterParent, 'innerBorderTop');
  1961. if (position) {
  1962. addClass(masterParent, 'innerBorderTop');
  1963. } else {
  1964. removeClass(masterParent, 'innerBorderTop');
  1965. }
  1966. if (!previousState && position || previousState && !position) {
  1967. this.wot.wtOverlays.adjustElementsSize();
  1968. }
  1969. }
  1970. if (this.wot.getSetting('rowHeaders').length === 0) {
  1971. var secondHeaderCell = this.clone.wtTable.THEAD.querySelectorAll('th:nth-of-type(2)');
  1972. if (secondHeaderCell) {
  1973. for (var i = 0; i < secondHeaderCell.length; i++) {
  1974. secondHeaderCell[i].style['border-left-width'] = 0;
  1975. }
  1976. }
  1977. }
  1978. }
  1979. }, {}, WalkontableOverlay);
  1980. ;
  1981. window.WalkontableTopOverlay = WalkontableTopOverlay;
  1982. WalkontableOverlay.registerOverlay(WalkontableOverlay.CLONE_TOP, WalkontableTopOverlay);
  1983. //#
  1984. },{"_base":11,"helpers/dom/element":45}],15:[function(require,module,exports){
  1985. "use strict";
  1986. Object.defineProperties(exports, {
  1987. WalkontableTopLeftCornerOverlay: {get: function() {
  1988. return WalkontableTopLeftCornerOverlay;
  1989. }},
  1990. __esModule: {value: true}
  1991. });
  1992. var $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  1993. $___95_base__;
  1994. var $__0 = ($___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}),
  1995. outerHeight = $__0.outerHeight,
  1996. outerWidth = $__0.outerWidth,
  1997. setOverlayPosition = $__0.setOverlayPosition;
  1998. var WalkontableOverlay = ($___95_base__ = require("_base"), $___95_base__ && $___95_base__.__esModule && $___95_base__ || {default: $___95_base__}).WalkontableOverlay;
  1999. var WalkontableTopLeftCornerOverlay = function WalkontableTopLeftCornerOverlay(wotInstance) {
  2000. $traceurRuntime.superConstructor($WalkontableTopLeftCornerOverlay).call(this, wotInstance);
  2001. this.clone = this.makeClone(WalkontableOverlay.CLONE_TOP_LEFT_CORNER);
  2002. };
  2003. var $WalkontableTopLeftCornerOverlay = WalkontableTopLeftCornerOverlay;
  2004. ($traceurRuntime.createClass)(WalkontableTopLeftCornerOverlay, {
  2005. shouldBeRendered: function() {
  2006. return (this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length) && (this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length) ? true : false;
  2007. },
  2008. resetFixedPosition: function() {
  2009. if (!this.wot.wtTable.holder.parentNode) {
  2010. return;
  2011. }
  2012. var overlayRoot = this.clone.wtTable.holder.parentNode;
  2013. var tableHeight = outerHeight(this.clone.wtTable.TABLE);
  2014. var tableWidth = outerWidth(this.clone.wtTable.TABLE);
  2015. if (this.trimmingContainer === window) {
  2016. var box = this.wot.wtTable.hider.getBoundingClientRect();
  2017. var top = Math.ceil(box.top);
  2018. var left = Math.ceil(box.left);
  2019. var bottom = Math.ceil(box.bottom);
  2020. var right = Math.ceil(box.right);
  2021. var finalLeft;
  2022. var finalTop;
  2023. if (left < 0 && (right - overlayRoot.offsetWidth) > 0) {
  2024. finalLeft = -left + 'px';
  2025. } else {
  2026. finalLeft = '0';
  2027. }
  2028. if (top < 0 && (bottom - overlayRoot.offsetHeight) > 0) {
  2029. finalTop = -top + 'px';
  2030. } else {
  2031. finalTop = '0';
  2032. }
  2033. setOverlayPosition(overlayRoot, finalLeft, finalTop);
  2034. }
  2035. overlayRoot.style.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  2036. overlayRoot.style.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  2037. }
  2038. }, {}, WalkontableOverlay);
  2039. ;
  2040. window.WalkontableTopLeftCornerOverlay = WalkontableTopLeftCornerOverlay;
  2041. WalkontableOverlay.registerOverlay(WalkontableOverlay.CLONE_TOP_LEFT_CORNER, WalkontableTopLeftCornerOverlay);
  2042. //#
  2043. },{"_base":11,"helpers/dom/element":45}],16:[function(require,module,exports){
  2044. "use strict";
  2045. Object.defineProperties(exports, {
  2046. WalkontableOverlays: {get: function() {
  2047. return WalkontableOverlays;
  2048. }},
  2049. __esModule: {value: true}
  2050. });
  2051. var $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  2052. $___46__46__47__46__46__47__46__46__47_helpers_47_unicode__,
  2053. $___46__46__47__46__46__47__46__46__47_eventManager__;
  2054. var $__0 = ($___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}),
  2055. getScrollableElement = $__0.getScrollableElement,
  2056. getScrollbarWidth = $__0.getScrollbarWidth,
  2057. getScrollLeft = $__0.getScrollLeft,
  2058. getScrollTop = $__0.getScrollTop;
  2059. var isKey = ($___46__46__47__46__46__47__46__46__47_helpers_47_unicode__ = require("helpers/unicode"), $___46__46__47__46__46__47__46__46__47_helpers_47_unicode__ && $___46__46__47__46__46__47__46__46__47_helpers_47_unicode__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_unicode__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_unicode__}).isKey;
  2060. var EventManager = ($___46__46__47__46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47__46__46__47_eventManager__}).EventManager;
  2061. var WalkontableOverlays = function WalkontableOverlays(wotInstance) {
  2062. this.wot = wotInstance;
  2063. this.instance = this.wot;
  2064. this.eventManager = new EventManager(this.wot);
  2065. this.wot.update('scrollbarWidth', getScrollbarWidth());
  2066. this.wot.update('scrollbarHeight', getScrollbarWidth());
  2067. this.mainTableScrollableElement = getScrollableElement(this.wot.wtTable.TABLE);
  2068. this.topOverlay = WalkontableOverlay.createOverlay(WalkontableOverlay.CLONE_TOP, this.wot);
  2069. if (typeof WalkontableBottomOverlay === 'undefined') {
  2070. this.bottomOverlay = {needFullRender: false};
  2071. } else {
  2072. this.bottomOverlay = WalkontableOverlay.createOverlay(WalkontableOverlay.CLONE_BOTTOM, this.wot);
  2073. }
  2074. this.leftOverlay = WalkontableOverlay.createOverlay(WalkontableOverlay.CLONE_LEFT, this.wot);
  2075. if (this.topOverlay.needFullRender && this.leftOverlay.needFullRender) {
  2076. this.topLeftCornerOverlay = WalkontableOverlay.createOverlay(WalkontableOverlay.CLONE_TOP_LEFT_CORNER, this.wot);
  2077. }
  2078. if (this.bottomOverlay.needFullRender && this.leftOverlay.needFullRender && typeof WalkontableBottomLeftCornerOverlay !== 'undefined') {
  2079. this.bottomLeftCornerOverlay = WalkontableOverlay.createOverlay(WalkontableOverlay.CLONE_BOTTOM_LEFT_CORNER, this.wot);
  2080. } else {
  2081. this.bottomLeftCornerOverlay = {needFullRender: false};
  2082. }
  2083. if (this.wot.getSetting('debug')) {
  2084. this.debug = WalkontableOverlay.createOverlay(WalkontableOverlay.CLONE_DEBUG, this.wot);
  2085. }
  2086. this.destroyed = false;
  2087. this.keyPressed = false;
  2088. this.spreaderLastSize = {
  2089. width: null,
  2090. height: null
  2091. };
  2092. this.overlayScrollPositions = {
  2093. master: {
  2094. top: 0,
  2095. left: 0
  2096. },
  2097. top: {
  2098. top: null,
  2099. left: 0
  2100. },
  2101. bottom: {
  2102. top: null,
  2103. left: 0
  2104. },
  2105. left: {
  2106. top: 0,
  2107. left: null
  2108. }
  2109. };
  2110. this.verticalScrolling = false;
  2111. this.horizontalScrolling = false;
  2112. this.delegatedScrollCallback = false;
  2113. this.registerListeners();
  2114. };
  2115. ($traceurRuntime.createClass)(WalkontableOverlays, {
  2116. refreshAll: function() {
  2117. if (!this.wot.drawn) {
  2118. return;
  2119. }
  2120. if (!this.wot.wtTable.holder.parentNode) {
  2121. this.destroy();
  2122. return;
  2123. }
  2124. this.wot.draw(true);
  2125. if (this.verticalScrolling) {
  2126. this.leftOverlay.onScroll();
  2127. }
  2128. if (this.horizontalScrolling) {
  2129. this.topOverlay.onScroll();
  2130. }
  2131. this.verticalScrolling = false;
  2132. this.horizontalScrolling = false;
  2133. },
  2134. registerListeners: function() {
  2135. var $__3 = this;
  2136. this.eventManager.addEventListener(document.documentElement, 'keydown', (function(event) {
  2137. return $__3.onKeyDown(event);
  2138. }));
  2139. this.eventManager.addEventListener(document.documentElement, 'keyup', (function() {
  2140. return $__3.onKeyUp();
  2141. }));
  2142. this.eventManager.addEventListener(document, 'visibilitychange', (function() {
  2143. return $__3.onKeyUp();
  2144. }));
  2145. this.eventManager.addEventListener(this.mainTableScrollableElement, 'scroll', (function(event) {
  2146. return $__3.onTableScroll(event);
  2147. }));
  2148. if (this.topOverlay.needFullRender) {
  2149. this.eventManager.addEventListener(this.topOverlay.clone.wtTable.holder, 'scroll', (function(event) {
  2150. return $__3.onTableScroll(event);
  2151. }));
  2152. this.eventManager.addEventListener(this.topOverlay.clone.wtTable.holder, 'wheel', (function(event) {
  2153. return $__3.onTableScroll(event);
  2154. }));
  2155. }
  2156. if (this.bottomOverlay.needFullRender) {
  2157. this.eventManager.addEventListener(this.bottomOverlay.clone.wtTable.holder, 'scroll', (function(event) {
  2158. return $__3.onTableScroll(event);
  2159. }));
  2160. this.eventManager.addEventListener(this.bottomOverlay.clone.wtTable.holder, 'wheel', (function(event) {
  2161. return $__3.onTableScroll(event);
  2162. }));
  2163. }
  2164. if (this.leftOverlay.needFullRender) {
  2165. this.eventManager.addEventListener(this.leftOverlay.clone.wtTable.holder, 'scroll', (function(event) {
  2166. return $__3.onTableScroll(event);
  2167. }));
  2168. this.eventManager.addEventListener(this.leftOverlay.clone.wtTable.holder, 'wheel', (function(event) {
  2169. return $__3.onTableScroll(event);
  2170. }));
  2171. }
  2172. if (this.topOverlay.trimmingContainer !== window && this.leftOverlay.trimmingContainer !== window) {
  2173. this.eventManager.addEventListener(window, 'wheel', (function(event) {
  2174. var overlay;
  2175. var deltaY = event.wheelDeltaY || event.deltaY;
  2176. var deltaX = event.wheelDeltaX || event.deltaX;
  2177. if ($__3.topOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  2178. overlay = 'top';
  2179. } else if ($__3.bottomOverlay.clone && $__3.bottomOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  2180. overlay = 'bottom';
  2181. } else if ($__3.leftOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  2182. overlay = 'left';
  2183. }
  2184. if (overlay == 'top' && deltaY !== 0) {
  2185. event.preventDefault();
  2186. } else if (overlay == 'left' && deltaX !== 0) {
  2187. event.preventDefault();
  2188. } else if (overlay == 'bottom' && deltaY !== 0) {
  2189. event.preventDefault();
  2190. }
  2191. }));
  2192. }
  2193. },
  2194. onTableScroll: function(event) {
  2195. if (Handsontable.mobileBrowser) {
  2196. return;
  2197. }
  2198. if (this.keyPressed && this.mainTableScrollableElement !== window && !event.target.contains(this.mainTableScrollableElement)) {
  2199. return;
  2200. }
  2201. if (event.type === 'scroll') {
  2202. this.syncScrollPositions(event);
  2203. } else {
  2204. this.translateMouseWheelToScroll(event);
  2205. }
  2206. },
  2207. onKeyDown: function(event) {
  2208. this.keyPressed = isKey(event.keyCode, 'ARROW_UP|ARROW_RIGHT|ARROW_DOWN|ARROW_LEFT');
  2209. },
  2210. onKeyUp: function() {
  2211. this.keyPressed = false;
  2212. },
  2213. translateMouseWheelToScroll: function(event) {
  2214. var topOverlay = this.topOverlay.clone.wtTable.holder;
  2215. var bottomOverlay = this.bottomOverlay.clone ? this.bottomOverlay.clone.wtTable.holder : null;
  2216. var leftOverlay = this.leftOverlay.clone.wtTable.holder;
  2217. var eventMockup = {type: 'wheel'};
  2218. var tempElem = event.target;
  2219. var deltaY = event.wheelDeltaY || (-1) * event.deltaY;
  2220. var deltaX = event.wheelDeltaX || (-1) * event.deltaX;
  2221. var parentHolder;
  2222. while (tempElem != document && tempElem != null) {
  2223. if (tempElem.className.indexOf('wtHolder') > -1) {
  2224. parentHolder = tempElem;
  2225. break;
  2226. }
  2227. tempElem = tempElem.parentNode;
  2228. }
  2229. eventMockup.target = parentHolder;
  2230. if (parentHolder == topOverlay) {
  2231. this.syncScrollPositions(eventMockup, (-0.2) * deltaY);
  2232. } else if (parentHolder == bottomOverlay) {
  2233. this.syncScrollPositions(eventMockup, (-0.2) * deltaY);
  2234. } else if (parentHolder == leftOverlay) {
  2235. this.syncScrollPositions(eventMockup, (-0.2) * deltaX);
  2236. }
  2237. return false;
  2238. },
  2239. syncScrollPositions: function(event) {
  2240. var fakeScrollValue = arguments[1] !== (void 0) ? arguments[1] : null;
  2241. if (this.destroyed) {
  2242. return;
  2243. }
  2244. if (arguments.length === 0) {
  2245. this.syncScrollWithMaster();
  2246. return;
  2247. }
  2248. var master = this.mainTableScrollableElement;
  2249. var target = event.target;
  2250. var tempScrollValue = 0;
  2251. var scrollValueChanged = false;
  2252. var topOverlay;
  2253. var leftOverlay;
  2254. var bottomOverlay;
  2255. var delegatedScroll = false;
  2256. if (this.topOverlay.needFullRender) {
  2257. topOverlay = this.topOverlay.clone.wtTable.holder;
  2258. }
  2259. if (this.bottomOverlay.needFullRender) {
  2260. bottomOverlay = this.bottomOverlay.clone.wtTable.holder;
  2261. }
  2262. if (this.leftOverlay.needFullRender) {
  2263. leftOverlay = this.leftOverlay.clone.wtTable.holder;
  2264. }
  2265. if (target === document) {
  2266. target = window;
  2267. }
  2268. if (target === master) {
  2269. tempScrollValue = getScrollLeft(target);
  2270. if (this.overlayScrollPositions.master.left !== tempScrollValue) {
  2271. this.horizontalScrolling = true;
  2272. this.overlayScrollPositions.master.left = tempScrollValue;
  2273. scrollValueChanged = true;
  2274. if (topOverlay) {
  2275. topOverlay.scrollLeft = tempScrollValue;
  2276. delegatedScroll = (this.mainTableScrollableElement !== window);
  2277. }
  2278. if (bottomOverlay) {
  2279. bottomOverlay.scrollLeft = tempScrollValue;
  2280. delegatedScroll = (this.mainTableScrollableElement !== window);
  2281. }
  2282. }
  2283. tempScrollValue = getScrollTop(target);
  2284. if (this.overlayScrollPositions.master.top !== tempScrollValue) {
  2285. this.verticalScrolling = true;
  2286. this.overlayScrollPositions.master.top = tempScrollValue;
  2287. scrollValueChanged = true;
  2288. if (leftOverlay) {
  2289. leftOverlay.scrollTop = tempScrollValue;
  2290. delegatedScroll = (this.mainTableScrollableElement !== window);
  2291. }
  2292. }
  2293. } else if (target === bottomOverlay) {
  2294. tempScrollValue = getScrollLeft(target);
  2295. if (this.overlayScrollPositions.bottom.left !== tempScrollValue) {
  2296. this.horizontalScrolling = true;
  2297. this.overlayScrollPositions.bottom.left = tempScrollValue;
  2298. scrollValueChanged = true;
  2299. master.scrollLeft = tempScrollValue;
  2300. }
  2301. if (fakeScrollValue !== null) {
  2302. scrollValueChanged = true;
  2303. master.scrollTop += fakeScrollValue;
  2304. }
  2305. } else if (target === topOverlay) {
  2306. tempScrollValue = getScrollLeft(target);
  2307. if (this.overlayScrollPositions.top.left !== tempScrollValue) {
  2308. this.horizontalScrolling = true;
  2309. this.overlayScrollPositions.top.left = tempScrollValue;
  2310. scrollValueChanged = true;
  2311. master.scrollLeft = tempScrollValue;
  2312. }
  2313. if (fakeScrollValue !== null) {
  2314. scrollValueChanged = true;
  2315. master.scrollTop += fakeScrollValue;
  2316. }
  2317. } else if (target === leftOverlay) {
  2318. tempScrollValue = getScrollTop(target);
  2319. if (this.overlayScrollPositions.left.top !== tempScrollValue) {
  2320. this.verticalScrolling = true;
  2321. this.overlayScrollPositions.left.top = tempScrollValue;
  2322. scrollValueChanged = true;
  2323. master.scrollTop = tempScrollValue;
  2324. }
  2325. if (fakeScrollValue !== null) {
  2326. scrollValueChanged = true;
  2327. master.scrollLeft += fakeScrollValue;
  2328. }
  2329. }
  2330. if (!this.keyPressed && scrollValueChanged && event.type === 'scroll') {
  2331. if (this.delegatedScrollCallback) {
  2332. this.delegatedScrollCallback = false;
  2333. } else {
  2334. this.refreshAll();
  2335. }
  2336. if (delegatedScroll) {
  2337. this.delegatedScrollCallback = true;
  2338. }
  2339. }
  2340. },
  2341. syncScrollWithMaster: function() {
  2342. var master = this.topOverlay.mainTableScrollableElement;
  2343. if (this.topOverlay.needFullRender) {
  2344. this.topOverlay.clone.wtTable.holder.scrollLeft = master.scrollLeft;
  2345. }
  2346. if (this.leftOverlay.needFullRender) {
  2347. this.leftOverlay.clone.wtTable.holder.scrollTop = master.scrollTop;
  2348. }
  2349. },
  2350. destroy: function() {
  2351. this.eventManager.destroy();
  2352. this.topOverlay.destroy();
  2353. if (this.bottomOverlay.clone) {
  2354. this.bottomOverlay.destroy();
  2355. }
  2356. this.leftOverlay.destroy();
  2357. if (this.topLeftCornerOverlay) {
  2358. this.topLeftCornerOverlay.destroy();
  2359. }
  2360. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) {
  2361. this.bottomLeftCornerOverlay.destroy();
  2362. }
  2363. if (this.debug) {
  2364. this.debug.destroy();
  2365. }
  2366. this.destroyed = true;
  2367. },
  2368. refresh: function() {
  2369. var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
  2370. if (this.topOverlay.areElementSizesAdjusted && this.leftOverlay.areElementSizesAdjusted) {
  2371. var container = this.wot.wtTable.wtRootElement.parentNode || this.wot.wtTable.wtRootElement;
  2372. var width = container.clientWidth;
  2373. var height = container.clientHeight;
  2374. if (width !== this.spreaderLastSize.width || height !== this.spreaderLastSize.height) {
  2375. this.spreaderLastSize.width = width;
  2376. this.spreaderLastSize.height = height;
  2377. this.adjustElementsSize();
  2378. }
  2379. }
  2380. if (this.bottomOverlay.clone) {
  2381. this.bottomOverlay.refresh(fastDraw);
  2382. }
  2383. this.leftOverlay.refresh(fastDraw);
  2384. this.topOverlay.refresh(fastDraw);
  2385. if (this.topLeftCornerOverlay) {
  2386. this.topLeftCornerOverlay.refresh(fastDraw);
  2387. }
  2388. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) {
  2389. this.bottomLeftCornerOverlay.refresh(fastDraw);
  2390. }
  2391. if (this.debug) {
  2392. this.debug.refresh(fastDraw);
  2393. }
  2394. },
  2395. adjustElementsSize: function() {
  2396. var force = arguments[0] !== (void 0) ? arguments[0] : false;
  2397. var totalColumns = this.wot.getSetting('totalColumns');
  2398. var totalRows = this.wot.getSetting('totalRows');
  2399. var headerRowSize = this.wot.wtViewport.getRowHeaderWidth();
  2400. var headerColumnSize = this.wot.wtViewport.getColumnHeaderHeight();
  2401. var hiderStyle = this.wot.wtTable.hider.style;
  2402. hiderStyle.width = (headerRowSize + this.leftOverlay.sumCellSizes(0, totalColumns)) + 'px';
  2403. hiderStyle.height = (headerColumnSize + this.topOverlay.sumCellSizes(0, totalRows) + 1) + 'px';
  2404. this.topOverlay.adjustElementsSize(force);
  2405. this.leftOverlay.adjustElementsSize(force);
  2406. if (this.bottomOverlay.clone) {
  2407. this.bottomOverlay.adjustElementsSize(force);
  2408. }
  2409. },
  2410. applyToDOM: function() {
  2411. if (!this.topOverlay.areElementSizesAdjusted || !this.leftOverlay.areElementSizesAdjusted) {
  2412. this.adjustElementsSize();
  2413. }
  2414. this.topOverlay.applyToDOM();
  2415. if (this.bottomOverlay.clone) {
  2416. this.bottomOverlay.applyToDOM();
  2417. }
  2418. this.leftOverlay.applyToDOM();
  2419. }
  2420. }, {});
  2421. ;
  2422. window.WalkontableOverlays = WalkontableOverlays;
  2423. //#
  2424. },{"eventManager":41,"helpers/dom/element":45,"helpers/unicode":53}],17:[function(require,module,exports){
  2425. "use strict";
  2426. Object.defineProperties(exports, {
  2427. WalkontableScroll: {get: function() {
  2428. return WalkontableScroll;
  2429. }},
  2430. __esModule: {value: true}
  2431. });
  2432. var WalkontableScroll = function WalkontableScroll(wotInstance) {
  2433. this.wot = wotInstance;
  2434. this.instance = wotInstance;
  2435. };
  2436. ($traceurRuntime.createClass)(WalkontableScroll, {scrollViewport: function(coords) {
  2437. if (!this.wot.drawn) {
  2438. return;
  2439. }
  2440. var totalRows = this.wot.getSetting('totalRows');
  2441. var totalColumns = this.wot.getSetting('totalColumns');
  2442. var fixedRowsTop = this.instance.getSetting('fixedRowsTop');
  2443. var fixedRowsBottom = this.instance.getSetting('fixedRowsBottom');
  2444. var fixedColumnsLeft = this.instance.getSetting('fixedColumnsLeft');
  2445. if (coords.row < 0 || coords.row > totalRows - 1) {
  2446. throw new Error('row ' + coords.row + ' does not exist');
  2447. }
  2448. if (coords.col < 0 || coords.col > totalColumns - 1) {
  2449. throw new Error('column ' + coords.col + ' does not exist');
  2450. }
  2451. if (coords.row > this.instance.wtTable.getLastVisibleRow() && coords.row < totalRows - fixedRowsBottom) {
  2452. this.wot.wtOverlays.topOverlay.scrollTo(coords.row, true);
  2453. } else if (coords.row >= fixedRowsTop && coords.row < this.instance.wtTable.getFirstVisibleRow()) {
  2454. this.wot.wtOverlays.topOverlay.scrollTo(coords.row);
  2455. }
  2456. if (coords.col > this.instance.wtTable.getLastVisibleColumn()) {
  2457. this.wot.wtOverlays.leftOverlay.scrollTo(coords.col, true);
  2458. } else if (coords.col >= fixedColumnsLeft && coords.col < this.instance.wtTable.getFirstVisibleColumn()) {
  2459. this.wot.wtOverlays.leftOverlay.scrollTo(coords.col);
  2460. }
  2461. }}, {});
  2462. ;
  2463. window.WalkontableScroll = WalkontableScroll;
  2464. //#
  2465. },{}],18:[function(require,module,exports){
  2466. "use strict";
  2467. Object.defineProperties(exports, {
  2468. WalkontableSelection: {get: function() {
  2469. return WalkontableSelection;
  2470. }},
  2471. __esModule: {value: true}
  2472. });
  2473. var $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  2474. $__border__,
  2475. $__cell_47_coords__,
  2476. $__cell_47_range__;
  2477. var addClass = ($___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}).addClass;
  2478. var WalkontableBorder = ($__border__ = require("border"), $__border__ && $__border__.__esModule && $__border__ || {default: $__border__}).WalkontableBorder;
  2479. var WalkontableCellCoords = ($__cell_47_coords__ = require("cell/coords"), $__cell_47_coords__ && $__cell_47_coords__.__esModule && $__cell_47_coords__ || {default: $__cell_47_coords__}).WalkontableCellCoords;
  2480. var WalkontableCellRange = ($__cell_47_range__ = require("cell/range"), $__cell_47_range__ && $__cell_47_range__.__esModule && $__cell_47_range__ || {default: $__cell_47_range__}).WalkontableCellRange;
  2481. var WalkontableSelection = function WalkontableSelection(settings, cellRange) {
  2482. this.settings = settings;
  2483. this.cellRange = cellRange || null;
  2484. this.instanceBorders = {};
  2485. };
  2486. ($traceurRuntime.createClass)(WalkontableSelection, {
  2487. getBorder: function(wotInstance) {
  2488. if (this.instanceBorders[wotInstance.guid]) {
  2489. return this.instanceBorders[wotInstance.guid];
  2490. }
  2491. this.instanceBorders[wotInstance.guid] = new WalkontableBorder(wotInstance, this.settings);
  2492. },
  2493. isEmpty: function() {
  2494. return this.cellRange === null;
  2495. },
  2496. add: function(coords) {
  2497. if (this.isEmpty()) {
  2498. this.cellRange = new WalkontableCellRange(coords, coords, coords);
  2499. } else {
  2500. this.cellRange.expand(coords);
  2501. }
  2502. },
  2503. replace: function(oldCoords, newCoords) {
  2504. if (!this.isEmpty()) {
  2505. if (this.cellRange.from.isEqual(oldCoords)) {
  2506. this.cellRange.from = newCoords;
  2507. return true;
  2508. }
  2509. if (this.cellRange.to.isEqual(oldCoords)) {
  2510. this.cellRange.to = newCoords;
  2511. return true;
  2512. }
  2513. }
  2514. return false;
  2515. },
  2516. clear: function() {
  2517. this.cellRange = null;
  2518. },
  2519. getCorners: function() {
  2520. var topLeft = this.cellRange.getTopLeftCorner();
  2521. var bottomRight = this.cellRange.getBottomRightCorner();
  2522. return [topLeft.row, topLeft.col, bottomRight.row, bottomRight.col];
  2523. },
  2524. addClassAtCoords: function(wotInstance, sourceRow, sourceColumn, className) {
  2525. var TD = wotInstance.wtTable.getCell(new WalkontableCellCoords(sourceRow, sourceColumn));
  2526. if (typeof TD === 'object') {
  2527. addClass(TD, className);
  2528. }
  2529. },
  2530. draw: function(wotInstance) {
  2531. if (this.isEmpty()) {
  2532. if (this.settings.border) {
  2533. var border = this.getBorder(wotInstance);
  2534. if (border) {
  2535. border.disappear();
  2536. }
  2537. }
  2538. return;
  2539. }
  2540. var renderedRows = wotInstance.wtTable.getRenderedRowsCount();
  2541. var renderedColumns = wotInstance.wtTable.getRenderedColumnsCount();
  2542. var corners = this.getCorners();
  2543. var sourceRow,
  2544. sourceCol,
  2545. TH;
  2546. for (var column = 0; column < renderedColumns; column++) {
  2547. sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
  2548. if (sourceCol >= corners[1] && sourceCol <= corners[3]) {
  2549. TH = wotInstance.wtTable.getColumnHeader(sourceCol);
  2550. if (TH && this.settings.highlightColumnClassName) {
  2551. addClass(TH, this.settings.highlightColumnClassName);
  2552. }
  2553. }
  2554. }
  2555. for (var row = 0; row < renderedRows; row++) {
  2556. sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row);
  2557. if (sourceRow >= corners[0] && sourceRow <= corners[2]) {
  2558. TH = wotInstance.wtTable.getRowHeader(sourceRow);
  2559. if (TH && this.settings.highlightRowClassName) {
  2560. addClass(TH, this.settings.highlightRowClassName);
  2561. }
  2562. }
  2563. for (var column$__5 = 0; column$__5 < renderedColumns; column$__5++) {
  2564. sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column$__5);
  2565. if (sourceRow >= corners[0] && sourceRow <= corners[2] && sourceCol >= corners[1] && sourceCol <= corners[3]) {
  2566. if (this.settings.className) {
  2567. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.className);
  2568. }
  2569. } else if (sourceRow >= corners[0] && sourceRow <= corners[2]) {
  2570. if (this.settings.highlightRowClassName) {
  2571. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightRowClassName);
  2572. }
  2573. } else if (sourceCol >= corners[1] && sourceCol <= corners[3]) {
  2574. if (this.settings.highlightColumnClassName) {
  2575. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightColumnClassName);
  2576. }
  2577. }
  2578. }
  2579. }
  2580. wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className);
  2581. if (this.settings.border) {
  2582. var border$__6 = this.getBorder(wotInstance);
  2583. if (border$__6) {
  2584. border$__6.appear(corners);
  2585. }
  2586. }
  2587. }
  2588. }, {});
  2589. ;
  2590. window.WalkontableSelection = WalkontableSelection;
  2591. //#
  2592. },{"border":2,"cell/coords":5,"cell/range":6,"helpers/dom/element":45}],19:[function(require,module,exports){
  2593. "use strict";
  2594. Object.defineProperties(exports, {
  2595. WalkontableSettings: {get: function() {
  2596. return WalkontableSettings;
  2597. }},
  2598. __esModule: {value: true}
  2599. });
  2600. var $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__;
  2601. var fastInnerText = ($___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}).fastInnerText;
  2602. var WalkontableSettings = function WalkontableSettings(wotInstance, settings) {
  2603. var $__1 = this;
  2604. this.wot = wotInstance;
  2605. this.instance = wotInstance;
  2606. this.defaults = {
  2607. table: void 0,
  2608. debug: false,
  2609. externalRowCalculator: false,
  2610. stretchH: 'none',
  2611. currentRowClassName: null,
  2612. currentColumnClassName: null,
  2613. data: void 0,
  2614. fixedColumnsLeft: 0,
  2615. fixedRowsTop: 0,
  2616. fixedRowsBottom: 0,
  2617. minSpareRows: 0,
  2618. rowHeaders: function() {
  2619. return [];
  2620. },
  2621. columnHeaders: function() {
  2622. return [];
  2623. },
  2624. totalRows: void 0,
  2625. totalColumns: void 0,
  2626. cellRenderer: (function(row, column, TD) {
  2627. var cellData = $__1.getSetting('data', row, column);
  2628. fastInnerText(TD, cellData === void 0 || cellData === null ? '' : cellData);
  2629. }),
  2630. columnWidth: function(col) {
  2631. return;
  2632. },
  2633. rowHeight: function(row) {
  2634. return;
  2635. },
  2636. defaultRowHeight: 23,
  2637. defaultColumnWidth: 50,
  2638. selections: null,
  2639. hideBorderOnMouseDownOver: false,
  2640. viewportRowCalculatorOverride: null,
  2641. viewportColumnCalculatorOverride: null,
  2642. onCellMouseDown: null,
  2643. onCellMouseOver: null,
  2644. onCellDblClick: null,
  2645. onCellCornerMouseDown: null,
  2646. onCellCornerDblClick: null,
  2647. beforeDraw: null,
  2648. onDraw: null,
  2649. onBeforeDrawBorders: null,
  2650. onScrollVertically: null,
  2651. onScrollHorizontally: null,
  2652. onBeforeTouchScroll: null,
  2653. onAfterMomentumScroll: null,
  2654. scrollbarWidth: 10,
  2655. scrollbarHeight: 10,
  2656. renderAllRows: false,
  2657. groups: false
  2658. };
  2659. this.settings = {};
  2660. for (var i in this.defaults) {
  2661. if (this.defaults.hasOwnProperty(i)) {
  2662. if (settings[i] !== void 0) {
  2663. this.settings[i] = settings[i];
  2664. } else if (this.defaults[i] === void 0) {
  2665. throw new Error('A required setting "' + i + '" was not provided');
  2666. } else {
  2667. this.settings[i] = this.defaults[i];
  2668. }
  2669. }
  2670. }
  2671. };
  2672. ($traceurRuntime.createClass)(WalkontableSettings, {
  2673. update: function(settings, value) {
  2674. if (value === void 0) {
  2675. for (var i in settings) {
  2676. if (settings.hasOwnProperty(i)) {
  2677. this.settings[i] = settings[i];
  2678. }
  2679. }
  2680. } else {
  2681. this.settings[settings] = value;
  2682. }
  2683. return this.wot;
  2684. },
  2685. getSetting: function(key, param1, param2, param3, param4) {
  2686. if (typeof this.settings[key] === 'function') {
  2687. return this.settings[key](param1, param2, param3, param4);
  2688. } else if (param1 !== void 0 && Array.isArray(this.settings[key])) {
  2689. return this.settings[key][param1];
  2690. } else {
  2691. return this.settings[key];
  2692. }
  2693. },
  2694. has: function(key) {
  2695. return !!this.settings[key];
  2696. }
  2697. }, {});
  2698. ;
  2699. window.WalkontableSettings = WalkontableSettings;
  2700. //#
  2701. },{"helpers/dom/element":45}],20:[function(require,module,exports){
  2702. "use strict";
  2703. Object.defineProperties(exports, {
  2704. WalkontableTable: {get: function() {
  2705. return WalkontableTable;
  2706. }},
  2707. __esModule: {value: true}
  2708. });
  2709. var $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  2710. $__cell_47_coords__,
  2711. $__cell_47_range__,
  2712. $__filter_47_column__,
  2713. $__filter_47_row__,
  2714. $__tableRenderer__;
  2715. var $__0 = ($___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}),
  2716. getStyle = $__0.getStyle,
  2717. getTrimmingContainer = $__0.getTrimmingContainer,
  2718. hasClass = $__0.hasClass,
  2719. index = $__0.index,
  2720. offset = $__0.offset,
  2721. removeClass = $__0.removeClass,
  2722. removeTextNodes = $__0.removeTextNodes,
  2723. overlayContainsElement = $__0.overlayContainsElement;
  2724. var WalkontableCellCoords = ($__cell_47_coords__ = require("cell/coords"), $__cell_47_coords__ && $__cell_47_coords__.__esModule && $__cell_47_coords__ || {default: $__cell_47_coords__}).WalkontableCellCoords;
  2725. var WalkontableCellRange = ($__cell_47_range__ = require("cell/range"), $__cell_47_range__ && $__cell_47_range__.__esModule && $__cell_47_range__ || {default: $__cell_47_range__}).WalkontableCellRange;
  2726. var WalkontableColumnFilter = ($__filter_47_column__ = require("filter/column"), $__filter_47_column__ && $__filter_47_column__.__esModule && $__filter_47_column__ || {default: $__filter_47_column__}).WalkontableColumnFilter;
  2727. var WalkontableRowFilter = ($__filter_47_row__ = require("filter/row"), $__filter_47_row__ && $__filter_47_row__.__esModule && $__filter_47_row__ || {default: $__filter_47_row__}).WalkontableRowFilter;
  2728. var WalkontableTableRenderer = ($__tableRenderer__ = require("tableRenderer"), $__tableRenderer__ && $__tableRenderer__.__esModule && $__tableRenderer__ || {default: $__tableRenderer__}).WalkontableTableRenderer;
  2729. var WalkontableTable = function WalkontableTable(wotInstance, table) {
  2730. this.wot = wotInstance;
  2731. this.instance = this.wot;
  2732. this.TABLE = table;
  2733. this.TBODY = null;
  2734. this.THEAD = null;
  2735. this.COLGROUP = null;
  2736. this.tableOffset = 0;
  2737. this.holderOffset = 0;
  2738. removeTextNodes(this.TABLE);
  2739. this.spreader = this.createSpreader(this.TABLE);
  2740. this.hider = this.createHider(this.spreader);
  2741. this.holder = this.createHolder(this.hider);
  2742. this.wtRootElement = this.holder.parentNode;
  2743. this.alignOverlaysWithTrimmingContainer();
  2744. this.fixTableDomTree();
  2745. this.colgroupChildrenLength = this.COLGROUP.childNodes.length;
  2746. this.theadChildrenLength = this.THEAD.firstChild ? this.THEAD.firstChild.childNodes.length : 0;
  2747. this.tbodyChildrenLength = this.TBODY.childNodes.length;
  2748. this.rowFilter = null;
  2749. this.columnFilter = null;
  2750. };
  2751. ($traceurRuntime.createClass)(WalkontableTable, {
  2752. fixTableDomTree: function() {
  2753. this.TBODY = this.TABLE.querySelector('tbody');
  2754. if (!this.TBODY) {
  2755. this.TBODY = document.createElement('tbody');
  2756. this.TABLE.appendChild(this.TBODY);
  2757. }
  2758. this.THEAD = this.TABLE.querySelector('thead');
  2759. if (!this.THEAD) {
  2760. this.THEAD = document.createElement('thead');
  2761. this.TABLE.insertBefore(this.THEAD, this.TBODY);
  2762. }
  2763. this.COLGROUP = this.TABLE.querySelector('colgroup');
  2764. if (!this.COLGROUP) {
  2765. this.COLGROUP = document.createElement('colgroup');
  2766. this.TABLE.insertBefore(this.COLGROUP, this.THEAD);
  2767. }
  2768. if (this.wot.getSetting('columnHeaders').length && !this.THEAD.childNodes.length) {
  2769. this.THEAD.appendChild(document.createElement('TR'));
  2770. }
  2771. },
  2772. createSpreader: function(table) {
  2773. var parent = table.parentNode;
  2774. var spreader;
  2775. if (!parent || parent.nodeType !== 1 || !hasClass(parent, 'wtHolder')) {
  2776. spreader = document.createElement('div');
  2777. spreader.className = 'wtSpreader';
  2778. if (parent) {
  2779. parent.insertBefore(spreader, table);
  2780. }
  2781. spreader.appendChild(table);
  2782. }
  2783. spreader.style.position = 'relative';
  2784. return spreader;
  2785. },
  2786. createHider: function(spreader) {
  2787. var parent = spreader.parentNode;
  2788. var hider;
  2789. if (!parent || parent.nodeType !== 1 || !hasClass(parent, 'wtHolder')) {
  2790. hider = document.createElement('div');
  2791. hider.className = 'wtHider';
  2792. if (parent) {
  2793. parent.insertBefore(hider, spreader);
  2794. }
  2795. hider.appendChild(spreader);
  2796. }
  2797. return hider;
  2798. },
  2799. createHolder: function(hider) {
  2800. var parent = hider.parentNode;
  2801. var holder;
  2802. if (!parent || parent.nodeType !== 1 || !hasClass(parent, 'wtHolder')) {
  2803. holder = document.createElement('div');
  2804. holder.style.position = 'relative';
  2805. holder.className = 'wtHolder';
  2806. if (parent) {
  2807. parent.insertBefore(holder, hider);
  2808. }
  2809. if (!this.isWorkingOnClone()) {
  2810. holder.parentNode.className += 'ht_master handsontable';
  2811. }
  2812. holder.appendChild(hider);
  2813. }
  2814. return holder;
  2815. },
  2816. alignOverlaysWithTrimmingContainer: function() {
  2817. var trimmingElement = getTrimmingContainer(this.wtRootElement);
  2818. if (!this.isWorkingOnClone()) {
  2819. this.holder.parentNode.style.position = 'relative';
  2820. if (trimmingElement === window) {
  2821. this.holder.style.overflow = 'visible';
  2822. this.wtRootElement.style.overflow = 'visible';
  2823. } else {
  2824. this.holder.style.width = getStyle(trimmingElement, 'width');
  2825. this.holder.style.height = getStyle(trimmingElement, 'height');
  2826. this.holder.style.overflow = '';
  2827. }
  2828. }
  2829. },
  2830. isWorkingOnClone: function() {
  2831. return !!this.wot.cloneSource;
  2832. },
  2833. draw: function(fastDraw) {
  2834. var totalRows = this.instance.getSetting('totalRows');
  2835. if (!this.isWorkingOnClone()) {
  2836. this.holderOffset = offset(this.holder);
  2837. fastDraw = this.wot.wtViewport.createRenderCalculators(fastDraw);
  2838. }
  2839. if (fastDraw) {
  2840. if (!this.isWorkingOnClone()) {
  2841. this.wot.wtViewport.createVisibleCalculators();
  2842. }
  2843. if (this.wot.wtOverlays) {
  2844. this.wot.wtOverlays.refresh(true);
  2845. }
  2846. } else {
  2847. if (this.isWorkingOnClone()) {
  2848. this.tableOffset = this.wot.cloneSource.wtTable.tableOffset;
  2849. } else {
  2850. this.tableOffset = offset(this.TABLE);
  2851. }
  2852. var startRow;
  2853. if (WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_DEBUG) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_TOP) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_TOP_LEFT_CORNER)) {
  2854. startRow = 0;
  2855. } else if (WalkontableOverlay.isOverlayTypeOf(this.instance.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM) || WalkontableOverlay.isOverlayTypeOf(this.instance.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM_LEFT_CORNER)) {
  2856. startRow = totalRows - this.wot.getSetting('fixedRowsBottom');
  2857. } else {
  2858. startRow = this.wot.wtViewport.rowsRenderCalculator.startRow;
  2859. }
  2860. var startColumn;
  2861. if (WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_DEBUG) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_LEFT) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_TOP_LEFT_CORNER) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM_LEFT_CORNER)) {
  2862. startColumn = 0;
  2863. } else {
  2864. startColumn = this.wot.wtViewport.columnsRenderCalculator.startColumn;
  2865. }
  2866. this.rowFilter = new WalkontableRowFilter(startRow, totalRows, this.wot.getSetting('columnHeaders').length);
  2867. this.columnFilter = new WalkontableColumnFilter(startColumn, this.wot.getSetting('totalColumns'), this.wot.getSetting('rowHeaders').length);
  2868. this._doDraw();
  2869. this.alignOverlaysWithTrimmingContainer();
  2870. }
  2871. this.refreshSelections(fastDraw);
  2872. if (!this.isWorkingOnClone()) {
  2873. this.wot.wtOverlays.topOverlay.resetFixedPosition();
  2874. if (this.wot.wtOverlays.bottomOverlay.clone) {
  2875. this.wot.wtOverlays.bottomOverlay.resetFixedPosition();
  2876. }
  2877. this.wot.wtOverlays.leftOverlay.resetFixedPosition();
  2878. if (this.wot.wtOverlays.topLeftCornerOverlay) {
  2879. this.wot.wtOverlays.topLeftCornerOverlay.resetFixedPosition();
  2880. }
  2881. if (this.instance.wtOverlays.bottomLeftCornerOverlay && this.instance.wtOverlays.bottomLeftCornerOverlay.clone) {
  2882. this.wot.wtOverlays.bottomLeftCornerOverlay.resetFixedPosition();
  2883. }
  2884. }
  2885. this.wot.drawn = true;
  2886. return this;
  2887. },
  2888. _doDraw: function() {
  2889. var wtRenderer = new WalkontableTableRenderer(this);
  2890. wtRenderer.render();
  2891. },
  2892. removeClassFromCells: function(className) {
  2893. var nodes = this.TABLE.querySelectorAll('.' + className);
  2894. for (var i = 0,
  2895. len = nodes.length; i < len; i++) {
  2896. removeClass(nodes[i], className);
  2897. }
  2898. },
  2899. refreshSelections: function(fastDraw) {
  2900. if (!this.wot.selections) {
  2901. return;
  2902. }
  2903. var len = this.wot.selections.length;
  2904. if (fastDraw) {
  2905. for (var i = 0; i < len; i++) {
  2906. if (this.wot.selections[i].settings.className) {
  2907. this.removeClassFromCells(this.wot.selections[i].settings.className);
  2908. }
  2909. if (this.wot.selections[i].settings.highlightRowClassName) {
  2910. this.removeClassFromCells(this.wot.selections[i].settings.highlightRowClassName);
  2911. }
  2912. if (this.wot.selections[i].settings.highlightColumnClassName) {
  2913. this.removeClassFromCells(this.wot.selections[i].settings.highlightColumnClassName);
  2914. }
  2915. }
  2916. }
  2917. for (var i$__7 = 0; i$__7 < len; i$__7++) {
  2918. this.wot.selections[i$__7].draw(this.wot, fastDraw);
  2919. }
  2920. },
  2921. getCell: function(coords) {
  2922. if (this.isRowBeforeRenderedRows(coords.row)) {
  2923. return -1;
  2924. } else if (this.isRowAfterRenderedRows(coords.row)) {
  2925. return -2;
  2926. }
  2927. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(coords.row)];
  2928. if (TR) {
  2929. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(coords.col)];
  2930. }
  2931. },
  2932. getColumnHeader: function(col) {
  2933. var level = arguments[1] !== (void 0) ? arguments[1] : 0;
  2934. var TR = this.THEAD.childNodes[level];
  2935. if (TR) {
  2936. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(col)];
  2937. }
  2938. },
  2939. getRowHeader: function(row) {
  2940. if (this.columnFilter.sourceColumnToVisibleRowHeadedColumn(0) === 0) {
  2941. return null;
  2942. }
  2943. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  2944. if (TR) {
  2945. return TR.childNodes[0];
  2946. }
  2947. },
  2948. getCoords: function(TD) {
  2949. var TR = TD.parentNode;
  2950. var row = index(TR);
  2951. if (TR.parentNode === this.THEAD) {
  2952. row = this.rowFilter.visibleColHeadedRowToSourceRow(row);
  2953. } else {
  2954. row = this.rowFilter.renderedToSource(row);
  2955. }
  2956. var col = this.columnFilter.visibleRowHeadedColumnToSourceColumn(TD.cellIndex);
  2957. return new WalkontableCellCoords(row, col);
  2958. },
  2959. getTrForRow: function(row) {
  2960. return this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  2961. },
  2962. getFirstRenderedRow: function() {
  2963. return this.wot.wtViewport.rowsRenderCalculator.startRow;
  2964. },
  2965. getFirstVisibleRow: function() {
  2966. return this.wot.wtViewport.rowsVisibleCalculator.startRow;
  2967. },
  2968. getFirstRenderedColumn: function() {
  2969. return this.wot.wtViewport.columnsRenderCalculator.startColumn;
  2970. },
  2971. getFirstVisibleColumn: function() {
  2972. return this.wot.wtViewport.columnsVisibleCalculator.startColumn;
  2973. },
  2974. getLastRenderedRow: function() {
  2975. return this.wot.wtViewport.rowsRenderCalculator.endRow;
  2976. },
  2977. getLastVisibleRow: function() {
  2978. return this.wot.wtViewport.rowsVisibleCalculator.endRow;
  2979. },
  2980. getLastRenderedColumn: function() {
  2981. return this.wot.wtViewport.columnsRenderCalculator.endColumn;
  2982. },
  2983. getLastVisibleColumn: function() {
  2984. return this.wot.wtViewport.columnsVisibleCalculator.endColumn;
  2985. },
  2986. isRowBeforeRenderedRows: function(row) {
  2987. return (this.rowFilter.sourceToRendered(row) < 0 && row >= 0);
  2988. },
  2989. isRowAfterViewport: function(row) {
  2990. return (this.rowFilter.sourceToRendered(row) > this.getLastVisibleRow());
  2991. },
  2992. isRowAfterRenderedRows: function(row) {
  2993. return (this.rowFilter.sourceToRendered(row) > this.getLastRenderedRow());
  2994. },
  2995. isColumnBeforeViewport: function(column) {
  2996. return this.columnFilter.sourceToRendered(column) < 0 && column >= 0;
  2997. },
  2998. isColumnAfterViewport: function(column) {
  2999. return (this.columnFilter.sourceToRendered(column) > this.getLastVisibleColumn());
  3000. },
  3001. isLastRowFullyVisible: function() {
  3002. return this.getLastVisibleRow() === this.getLastRenderedRow();
  3003. },
  3004. isLastColumnFullyVisible: function() {
  3005. return this.getLastVisibleColumn() === this.getLastRenderedColumn();
  3006. },
  3007. getRenderedColumnsCount: function() {
  3008. if (WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_DEBUG)) {
  3009. return this.wot.getSetting('totalColumns');
  3010. } else if (WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_LEFT) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_TOP_LEFT_CORNER) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM_LEFT_CORNER)) {
  3011. return this.wot.getSetting('fixedColumnsLeft');
  3012. } else {
  3013. return this.wot.wtViewport.columnsRenderCalculator.count;
  3014. }
  3015. },
  3016. getRenderedRowsCount: function() {
  3017. if (WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_DEBUG)) {
  3018. return this.wot.getSetting('totalRows');
  3019. } else if (WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_TOP) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_TOP_LEFT_CORNER)) {
  3020. return this.wot.getSetting('fixedRowsTop');
  3021. } else if (WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM_LEFT_CORNER)) {
  3022. return this.instance.getSetting('fixedRowsBottom');
  3023. }
  3024. return this.wot.wtViewport.rowsRenderCalculator.count;
  3025. },
  3026. getVisibleRowsCount: function() {
  3027. return this.wot.wtViewport.rowsVisibleCalculator.count;
  3028. },
  3029. allRowsInViewport: function() {
  3030. return this.wot.getSetting('totalRows') == this.getVisibleRowsCount();
  3031. },
  3032. getRowHeight: function(sourceRow) {
  3033. var height = this.wot.wtSettings.settings.rowHeight(sourceRow);
  3034. var oversizedHeight = this.wot.wtViewport.oversizedRows[sourceRow];
  3035. if (oversizedHeight !== void 0) {
  3036. height = height === void 0 ? oversizedHeight : Math.max(height, oversizedHeight);
  3037. }
  3038. return height;
  3039. },
  3040. getColumnHeaderHeight: function(level) {
  3041. var height = this.wot.wtSettings.settings.defaultRowHeight;
  3042. var oversizedHeight = this.wot.wtViewport.oversizedColumnHeaders[level];
  3043. if (oversizedHeight !== void 0) {
  3044. height = height ? Math.max(height, oversizedHeight) : oversizedHeight;
  3045. }
  3046. return height;
  3047. },
  3048. getVisibleColumnsCount: function() {
  3049. return this.wot.wtViewport.columnsVisibleCalculator.count;
  3050. },
  3051. allColumnsInViewport: function() {
  3052. return this.wot.getSetting('totalColumns') == this.getVisibleColumnsCount();
  3053. },
  3054. getColumnWidth: function(sourceColumn) {
  3055. var width = this.wot.wtSettings.settings.columnWidth;
  3056. if (typeof width === 'function') {
  3057. width = width(sourceColumn);
  3058. } else if (typeof width === 'object') {
  3059. width = width[sourceColumn];
  3060. }
  3061. return width || this.wot.wtSettings.settings.defaultColumnWidth;
  3062. },
  3063. getStretchedColumnWidth: function(sourceColumn) {
  3064. var columnWidth = this.getColumnWidth(sourceColumn);
  3065. var width = [void 0, null].indexOf(columnWidth) === -1 ? columnWidth : this.instance.wtSettings.settings.defaultColumnWidth;
  3066. var calculator = this.wot.wtViewport.columnsRenderCalculator;
  3067. if (calculator) {
  3068. var stretchedWidth = calculator.getStretchedColumnWidth(sourceColumn, width);
  3069. if (stretchedWidth) {
  3070. width = stretchedWidth;
  3071. }
  3072. }
  3073. return width;
  3074. }
  3075. }, {});
  3076. ;
  3077. window.WalkontableTable = WalkontableTable;
  3078. //#
  3079. },{"cell/coords":5,"cell/range":6,"filter/column":9,"filter/row":10,"helpers/dom/element":45,"tableRenderer":21}],21:[function(require,module,exports){
  3080. "use strict";
  3081. Object.defineProperties(exports, {
  3082. WalkontableTableRenderer: {get: function() {
  3083. return WalkontableTableRenderer;
  3084. }},
  3085. __esModule: {value: true}
  3086. });
  3087. var $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__;
  3088. var $__0 = ($___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}),
  3089. addClass = $__0.addClass,
  3090. empty = $__0.empty,
  3091. getScrollbarWidth = $__0.getScrollbarWidth,
  3092. hasClass = $__0.hasClass,
  3093. innerHeight = $__0.innerHeight;
  3094. var WalkontableTableRenderer = function WalkontableTableRenderer(wtTable) {
  3095. this.wtTable = wtTable;
  3096. this.wot = wtTable.instance;
  3097. this.instance = wtTable.instance;
  3098. this.rowFilter = wtTable.rowFilter;
  3099. this.columnFilter = wtTable.columnFilter;
  3100. this.TABLE = wtTable.TABLE;
  3101. this.THEAD = wtTable.THEAD;
  3102. this.TBODY = wtTable.TBODY;
  3103. this.COLGROUP = wtTable.COLGROUP;
  3104. this.rowHeaders = [];
  3105. this.rowHeaderCount = 0;
  3106. this.columnHeaders = [];
  3107. this.columnHeaderCount = 0;
  3108. this.fixedRowsTop = 0;
  3109. this.fixedRowsBottom = 0;
  3110. };
  3111. ($traceurRuntime.createClass)(WalkontableTableRenderer, {
  3112. render: function() {
  3113. if (!this.wtTable.isWorkingOnClone()) {
  3114. this.wot.getSetting('beforeDraw', true);
  3115. }
  3116. this.rowHeaders = this.wot.getSetting('rowHeaders');
  3117. this.rowHeaderCount = this.rowHeaders.length;
  3118. this.fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  3119. this.fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  3120. this.columnHeaders = this.wot.getSetting('columnHeaders');
  3121. this.columnHeaderCount = this.columnHeaders.length;
  3122. var columnsToRender = this.wtTable.getRenderedColumnsCount();
  3123. var rowsToRender = this.wtTable.getRenderedRowsCount();
  3124. var totalColumns = this.wot.getSetting('totalColumns');
  3125. var totalRows = this.wot.getSetting('totalRows');
  3126. var workspaceWidth;
  3127. var adjusted = false;
  3128. if (WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM) || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM_LEFT_CORNER)) {
  3129. this.columnHeaders = [];
  3130. this.columnHeaderCount = 0;
  3131. }
  3132. if (totalColumns > 0) {
  3133. this.adjustAvailableNodes();
  3134. adjusted = true;
  3135. this.renderColumnHeaders();
  3136. this.renderRows(totalRows, rowsToRender, columnsToRender);
  3137. if (!this.wtTable.isWorkingOnClone()) {
  3138. workspaceWidth = this.wot.wtViewport.getWorkspaceWidth();
  3139. this.wot.wtViewport.containerWidth = null;
  3140. }
  3141. this.adjustColumnHeaderHeights();
  3142. this.adjustColumnWidths(columnsToRender);
  3143. this.markOversizedColumns();
  3144. }
  3145. if (!adjusted) {
  3146. this.adjustAvailableNodes();
  3147. }
  3148. this.removeRedundantRows(rowsToRender);
  3149. if (!this.wtTable.isWorkingOnClone()) {
  3150. this.markOversizedRows();
  3151. this.wot.wtViewport.createVisibleCalculators();
  3152. this.wot.wtOverlays.refresh(false);
  3153. this.wot.wtOverlays.applyToDOM();
  3154. if (workspaceWidth !== this.wot.wtViewport.getWorkspaceWidth()) {
  3155. this.wot.wtViewport.containerWidth = null;
  3156. var firstRendered = this.wtTable.getFirstRenderedColumn();
  3157. var lastRendered = this.wtTable.getLastRenderedColumn();
  3158. for (var i = firstRendered; i < lastRendered; i++) {
  3159. var width = this.wtTable.getStretchedColumnWidth(i);
  3160. var renderedIndex = this.columnFilter.sourceToRendered(i);
  3161. this.COLGROUP.childNodes[renderedIndex + this.rowHeaderCount].style.width = width + 'px';
  3162. }
  3163. }
  3164. this.wot.getSetting('onDraw', true);
  3165. } else if (WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM)) {
  3166. var masterOverlay = this.wot.cloneOverlay.instance;
  3167. this.wot.cloneOverlay.markOversizedFixedBottomRows();
  3168. masterOverlay.wtOverlays.adjustElementsSize();
  3169. }
  3170. },
  3171. removeRedundantRows: function(renderedRowsCount) {
  3172. while (this.wtTable.tbodyChildrenLength > renderedRowsCount) {
  3173. this.TBODY.removeChild(this.TBODY.lastChild);
  3174. this.wtTable.tbodyChildrenLength--;
  3175. }
  3176. },
  3177. renderRows: function(totalRows, rowsToRender, columnsToRender) {
  3178. var lastTD,
  3179. TR;
  3180. var visibleRowIndex = 0;
  3181. var sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  3182. var isWorkingOnClone = this.wtTable.isWorkingOnClone();
  3183. while (sourceRowIndex < totalRows && sourceRowIndex >= 0) {
  3184. if (visibleRowIndex > 1000) {
  3185. console.error('Security brake: Too much TRs. Please define height for your table, which will enforce scrollbars.');
  3186. }
  3187. if (rowsToRender !== void 0 && visibleRowIndex === rowsToRender) {
  3188. break;
  3189. }
  3190. TR = this.getOrCreateTrForRow(visibleRowIndex, TR);
  3191. this.renderRowHeaders(sourceRowIndex, TR);
  3192. this.adjustColumns(TR, columnsToRender + this.rowHeaderCount);
  3193. lastTD = this.renderCells(sourceRowIndex, TR, columnsToRender);
  3194. if (!isWorkingOnClone || WalkontableOverlay.isOverlayTypeOf(this.wot.cloneOverlay, WalkontableOverlay.CLONE_BOTTOM)) {
  3195. this.resetOversizedRow(sourceRowIndex);
  3196. }
  3197. if (TR.firstChild) {
  3198. var height = this.wot.wtTable.getRowHeight(sourceRowIndex);
  3199. if (height) {
  3200. height--;
  3201. TR.firstChild.style.height = height + 'px';
  3202. } else {
  3203. TR.firstChild.style.height = '';
  3204. }
  3205. }
  3206. visibleRowIndex++;
  3207. sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  3208. }
  3209. },
  3210. resetOversizedRow: function(sourceRow) {
  3211. if (this.wot.getSetting('externalRowCalculator')) {
  3212. return;
  3213. }
  3214. if (this.wot.wtViewport.oversizedRows && this.wot.wtViewport.oversizedRows[sourceRow]) {
  3215. this.wot.wtViewport.oversizedRows[sourceRow] = void 0;
  3216. }
  3217. },
  3218. markOversizedRows: function() {
  3219. if (this.wot.getSetting('externalRowCalculator')) {
  3220. return;
  3221. }
  3222. var rowCount = this.instance.wtTable.TBODY.childNodes.length;
  3223. var expectedTableHeight = rowCount * this.instance.wtSettings.settings.defaultRowHeight;
  3224. var actualTableHeight = innerHeight(this.instance.wtTable.TBODY) - 1;
  3225. var previousRowHeight;
  3226. var rowInnerHeight;
  3227. var sourceRowIndex;
  3228. var currentTr;
  3229. var rowHeader;
  3230. var totalRows = this.instance.getSetting('totalRows');
  3231. if (expectedTableHeight === actualTableHeight && !this.instance.getSetting('fixedRowsBottom')) {
  3232. return;
  3233. }
  3234. while (rowCount) {
  3235. rowCount--;
  3236. sourceRowIndex = this.instance.wtTable.rowFilter.renderedToSource(rowCount);
  3237. previousRowHeight = this.instance.wtTable.getRowHeight(sourceRowIndex);
  3238. currentTr = this.instance.wtTable.getTrForRow(sourceRowIndex);
  3239. rowHeader = currentTr.querySelector('th');
  3240. if (rowHeader) {
  3241. rowInnerHeight = innerHeight(rowHeader);
  3242. } else {
  3243. rowInnerHeight = innerHeight(currentTr) - 1;
  3244. }
  3245. if ((!previousRowHeight && this.instance.wtSettings.settings.defaultRowHeight < rowInnerHeight || previousRowHeight < rowInnerHeight)) {
  3246. this.instance.wtViewport.oversizedRows[sourceRowIndex] = ++rowInnerHeight;
  3247. }
  3248. }
  3249. },
  3250. markOversizedColumns: function() {
  3251. var overlayName = this.wot.getOverlayName();
  3252. if (!this.columnHeaderCount || this.wot.wtViewport.isMarkedOversizedColumn[overlayName] || this.wtTable.isWorkingOnClone()) {
  3253. return;
  3254. }
  3255. var columnCount = this.wtTable.getRenderedColumnsCount();
  3256. for (var i = 0; i < this.columnHeaderCount; i++) {
  3257. for (var renderedColumnIndex = (-1) * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
  3258. this.markIfOversizedColumnHeader(renderedColumnIndex);
  3259. }
  3260. }
  3261. this.wot.wtViewport.isMarkedOversizedColumn[overlayName] = true;
  3262. },
  3263. adjustColumnHeaderHeights: function() {
  3264. var columnHeaders = this.wot.getSetting('columnHeaders');
  3265. var childs = this.wot.wtTable.THEAD.childNodes;
  3266. var oversizedCols = this.wot.wtViewport.oversizedColumnHeaders;
  3267. for (var i = 0,
  3268. len = columnHeaders.length; i < len; i++) {
  3269. if (oversizedCols[i]) {
  3270. if (childs[i].childNodes.length === 0) {
  3271. return;
  3272. }
  3273. childs[i].childNodes[0].style.height = oversizedCols[i] + 'px';
  3274. }
  3275. }
  3276. },
  3277. markIfOversizedColumnHeader: function(col) {
  3278. var sourceColIndex = this.wot.wtTable.columnFilter.renderedToSource(col);
  3279. var level = this.columnHeaderCount;
  3280. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  3281. var previousColHeaderHeight;
  3282. var currentHeader;
  3283. var currentHeaderHeight;
  3284. while (level) {
  3285. level--;
  3286. previousColHeaderHeight = this.wot.wtTable.getColumnHeaderHeight(level);
  3287. currentHeader = this.wot.wtTable.getColumnHeader(sourceColIndex, level);
  3288. if (!currentHeader) {
  3289. continue;
  3290. }
  3291. currentHeaderHeight = innerHeight(currentHeader);
  3292. if (!previousColHeaderHeight && defaultRowHeight < currentHeaderHeight || previousColHeaderHeight < currentHeaderHeight) {
  3293. this.wot.wtViewport.oversizedColumnHeaders[level] = currentHeaderHeight;
  3294. }
  3295. }
  3296. },
  3297. renderCells: function(sourceRowIndex, TR, columnsToRender) {
  3298. var TD;
  3299. var sourceColIndex;
  3300. for (var visibleColIndex = 0; visibleColIndex < columnsToRender; visibleColIndex++) {
  3301. sourceColIndex = this.columnFilter.renderedToSource(visibleColIndex);
  3302. if (visibleColIndex === 0) {
  3303. TD = TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(sourceColIndex)];
  3304. } else {
  3305. TD = TD.nextSibling;
  3306. }
  3307. if (TD.nodeName == 'TH') {
  3308. TD = replaceThWithTd(TD, TR);
  3309. }
  3310. if (!hasClass(TD, 'hide')) {
  3311. TD.className = '';
  3312. }
  3313. TD.removeAttribute('style');
  3314. this.wot.wtSettings.settings.cellRenderer(sourceRowIndex, sourceColIndex, TD);
  3315. }
  3316. return TD;
  3317. },
  3318. adjustColumnWidths: function(columnsToRender) {
  3319. var scrollbarCompensation = 0;
  3320. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  3321. var mainHolder = sourceInstance.wtTable.holder;
  3322. if (mainHolder.offsetHeight < mainHolder.scrollHeight) {
  3323. scrollbarCompensation = getScrollbarWidth();
  3324. }
  3325. this.wot.wtViewport.columnsRenderCalculator.refreshStretching(this.wot.wtViewport.getViewportWidth() - scrollbarCompensation);
  3326. for (var renderedColIndex = 0; renderedColIndex < columnsToRender; renderedColIndex++) {
  3327. var width = this.wtTable.getStretchedColumnWidth(this.columnFilter.renderedToSource(renderedColIndex));
  3328. this.COLGROUP.childNodes[renderedColIndex + this.rowHeaderCount].style.width = width + 'px';
  3329. }
  3330. },
  3331. appendToTbody: function(TR) {
  3332. this.TBODY.appendChild(TR);
  3333. this.wtTable.tbodyChildrenLength++;
  3334. },
  3335. getOrCreateTrForRow: function(rowIndex, currentTr) {
  3336. var TR;
  3337. if (rowIndex >= this.wtTable.tbodyChildrenLength) {
  3338. TR = this.createRow();
  3339. this.appendToTbody(TR);
  3340. } else if (rowIndex === 0) {
  3341. TR = this.TBODY.firstChild;
  3342. } else {
  3343. TR = currentTr.nextSibling;
  3344. }
  3345. if (TR.className) {
  3346. TR.removeAttribute('class');
  3347. }
  3348. return TR;
  3349. },
  3350. createRow: function() {
  3351. var TR = document.createElement('TR');
  3352. for (var visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  3353. TR.appendChild(document.createElement('TH'));
  3354. }
  3355. return TR;
  3356. },
  3357. renderRowHeader: function(row, col, TH) {
  3358. TH.className = '';
  3359. TH.removeAttribute('style');
  3360. this.rowHeaders[col](row, TH, col);
  3361. },
  3362. renderRowHeaders: function(row, TR) {
  3363. for (var TH = TR.firstChild,
  3364. visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  3365. if (!TH) {
  3366. TH = document.createElement('TH');
  3367. TR.appendChild(TH);
  3368. } else if (TH.nodeName == 'TD') {
  3369. TH = replaceTdWithTh(TH, TR);
  3370. }
  3371. this.renderRowHeader(row, visibleColIndex, TH);
  3372. TH = TH.nextSibling;
  3373. }
  3374. },
  3375. adjustAvailableNodes: function() {
  3376. this.adjustColGroups();
  3377. this.adjustThead();
  3378. },
  3379. renderColumnHeaders: function() {
  3380. var overlayName = this.wot.getOverlayName();
  3381. if (!this.columnHeaderCount) {
  3382. return;
  3383. }
  3384. var columnCount = this.wtTable.getRenderedColumnsCount();
  3385. for (var i = 0; i < this.columnHeaderCount; i++) {
  3386. var TR = this.getTrForColumnHeaders(i);
  3387. for (var renderedColumnIndex = (-1) * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
  3388. var sourceCol = this.columnFilter.renderedToSource(renderedColumnIndex);
  3389. this.renderColumnHeader(i, sourceCol, TR.childNodes[renderedColumnIndex + this.rowHeaderCount]);
  3390. }
  3391. }
  3392. },
  3393. adjustColGroups: function() {
  3394. var columnCount = this.wtTable.getRenderedColumnsCount();
  3395. while (this.wtTable.colgroupChildrenLength < columnCount + this.rowHeaderCount) {
  3396. this.COLGROUP.appendChild(document.createElement('COL'));
  3397. this.wtTable.colgroupChildrenLength++;
  3398. }
  3399. while (this.wtTable.colgroupChildrenLength > columnCount + this.rowHeaderCount) {
  3400. this.COLGROUP.removeChild(this.COLGROUP.lastChild);
  3401. this.wtTable.colgroupChildrenLength--;
  3402. }
  3403. if (this.rowHeaderCount) {
  3404. addClass(this.COLGROUP.childNodes[0], 'rowHeader');
  3405. }
  3406. },
  3407. adjustThead: function() {
  3408. var columnCount = this.wtTable.getRenderedColumnsCount();
  3409. var TR = this.THEAD.firstChild;
  3410. if (this.columnHeaders.length) {
  3411. for (var i = 0,
  3412. len = this.columnHeaders.length; i < len; i++) {
  3413. TR = this.THEAD.childNodes[i];
  3414. if (!TR) {
  3415. TR = document.createElement('TR');
  3416. this.THEAD.appendChild(TR);
  3417. }
  3418. this.theadChildrenLength = TR.childNodes.length;
  3419. while (this.theadChildrenLength < columnCount + this.rowHeaderCount) {
  3420. TR.appendChild(document.createElement('TH'));
  3421. this.theadChildrenLength++;
  3422. }
  3423. while (this.theadChildrenLength > columnCount + this.rowHeaderCount) {
  3424. TR.removeChild(TR.lastChild);
  3425. this.theadChildrenLength--;
  3426. }
  3427. }
  3428. var theadChildrenLength = this.THEAD.childNodes.length;
  3429. if (theadChildrenLength > this.columnHeaders.length) {
  3430. for (var i$__2 = this.columnHeaders.length; i$__2 < theadChildrenLength; i$__2++) {
  3431. this.THEAD.removeChild(this.THEAD.lastChild);
  3432. }
  3433. }
  3434. } else if (TR) {
  3435. empty(TR);
  3436. }
  3437. },
  3438. getTrForColumnHeaders: function(index) {
  3439. return this.THEAD.childNodes[index];
  3440. },
  3441. renderColumnHeader: function(row, col, TH) {
  3442. TH.className = '';
  3443. TH.removeAttribute('style');
  3444. return this.columnHeaders[row](col, TH, row);
  3445. },
  3446. adjustColumns: function(TR, desiredCount) {
  3447. var count = TR.childNodes.length;
  3448. while (count < desiredCount) {
  3449. var TD = document.createElement('TD');
  3450. TR.appendChild(TD);
  3451. count++;
  3452. }
  3453. while (count > desiredCount) {
  3454. TR.removeChild(TR.lastChild);
  3455. count--;
  3456. }
  3457. },
  3458. removeRedundantColumns: function(columnsToRender) {
  3459. while (this.wtTable.tbodyChildrenLength > columnsToRender) {
  3460. this.TBODY.removeChild(this.TBODY.lastChild);
  3461. this.wtTable.tbodyChildrenLength--;
  3462. }
  3463. }
  3464. }, {});
  3465. function replaceTdWithTh(TD, TR) {
  3466. var TH = document.createElement('TH');
  3467. TR.insertBefore(TH, TD);
  3468. TR.removeChild(TD);
  3469. return TH;
  3470. }
  3471. function replaceThWithTd(TH, TR) {
  3472. var TD = document.createElement('TD');
  3473. TR.insertBefore(TD, TH);
  3474. TR.removeChild(TH);
  3475. return TD;
  3476. }
  3477. ;
  3478. window.WalkontableTableRenderer = WalkontableTableRenderer;
  3479. //#
  3480. },{"helpers/dom/element":45}],22:[function(require,module,exports){
  3481. "use strict";
  3482. Object.defineProperties(exports, {
  3483. WalkontableViewport: {get: function() {
  3484. return WalkontableViewport;
  3485. }},
  3486. __esModule: {value: true}
  3487. });
  3488. var $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__,
  3489. $___46__46__47__46__46__47__46__46__47_eventManager__,
  3490. $__calculator_47_viewportColumns__,
  3491. $__calculator_47_viewportRows__;
  3492. var $__0 = ($___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_47_dom_47_element__}),
  3493. getScrollbarWidth = $__0.getScrollbarWidth,
  3494. getScrollTop = $__0.getScrollTop,
  3495. getStyle = $__0.getStyle,
  3496. offset = $__0.offset,
  3497. outerHeight = $__0.outerHeight,
  3498. outerWidth = $__0.outerWidth;
  3499. var EventManager = ($___46__46__47__46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47__46__46__47_eventManager__}).EventManager;
  3500. var WalkontableViewportColumnsCalculator = ($__calculator_47_viewportColumns__ = require("calculator/viewportColumns"), $__calculator_47_viewportColumns__ && $__calculator_47_viewportColumns__.__esModule && $__calculator_47_viewportColumns__ || {default: $__calculator_47_viewportColumns__}).WalkontableViewportColumnsCalculator;
  3501. var WalkontableViewportRowsCalculator = ($__calculator_47_viewportRows__ = require("calculator/viewportRows"), $__calculator_47_viewportRows__ && $__calculator_47_viewportRows__.__esModule && $__calculator_47_viewportRows__ || {default: $__calculator_47_viewportRows__}).WalkontableViewportRowsCalculator;
  3502. var WalkontableViewport = function WalkontableViewport(wotInstance) {
  3503. var $__4 = this;
  3504. this.wot = wotInstance;
  3505. this.instance = this.wot;
  3506. this.oversizedRows = [];
  3507. this.oversizedColumnHeaders = [];
  3508. this.isMarkedOversizedColumn = {};
  3509. this.clientHeight = 0;
  3510. this.containerWidth = NaN;
  3511. this.rowHeaderWidth = NaN;
  3512. this.rowsVisibleCalculator = null;
  3513. this.columnsVisibleCalculator = null;
  3514. this.eventManager = new EventManager(this.wot);
  3515. this.eventManager.addEventListener(window, 'resize', (function() {
  3516. $__4.clientHeight = $__4.getWorkspaceHeight();
  3517. }));
  3518. };
  3519. ($traceurRuntime.createClass)(WalkontableViewport, {
  3520. getWorkspaceHeight: function() {
  3521. var trimmingContainer = this.instance.wtOverlays.topOverlay.trimmingContainer;
  3522. var elemHeight;
  3523. var height = 0;
  3524. if (trimmingContainer === window) {
  3525. height = document.documentElement.clientHeight;
  3526. } else {
  3527. elemHeight = outerHeight(trimmingContainer);
  3528. height = (elemHeight > 0 && trimmingContainer.clientHeight > 0) ? trimmingContainer.clientHeight : Infinity;
  3529. }
  3530. return height;
  3531. },
  3532. getWorkspaceWidth: function() {
  3533. var width;
  3534. var totalColumns = this.instance.getSetting('totalColumns');
  3535. var trimmingContainer = this.instance.wtOverlays.leftOverlay.trimmingContainer;
  3536. var overflow;
  3537. var stretchSetting = this.instance.getSetting('stretchH');
  3538. var docOffsetWidth = document.documentElement.offsetWidth;
  3539. if (Handsontable.freezeOverlays) {
  3540. width = Math.min(docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  3541. } else {
  3542. width = Math.min(this.getContainerFillWidth(), docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  3543. }
  3544. if (trimmingContainer === window && totalColumns > 0 && this.sumColumnWidths(0, totalColumns - 1) > width) {
  3545. return document.documentElement.clientWidth;
  3546. }
  3547. if (trimmingContainer !== window) {
  3548. overflow = getStyle(this.instance.wtOverlays.leftOverlay.trimmingContainer, 'overflow');
  3549. if (overflow == 'scroll' || overflow == 'hidden' || overflow == 'auto') {
  3550. return Math.max(width, trimmingContainer.clientWidth);
  3551. }
  3552. }
  3553. if (stretchSetting === 'none' || !stretchSetting) {
  3554. return Math.max(width, outerWidth(this.instance.wtTable.TABLE));
  3555. } else {
  3556. return width;
  3557. }
  3558. },
  3559. hasVerticalScroll: function() {
  3560. return this.getWorkspaceActualHeight() > this.getWorkspaceHeight();
  3561. },
  3562. hasHorizontalScroll: function() {
  3563. return this.getWorkspaceActualWidth() > this.getWorkspaceWidth();
  3564. },
  3565. sumColumnWidths: function(from, length) {
  3566. var sum = 0;
  3567. while (from < length) {
  3568. sum += this.wot.wtTable.getColumnWidth(from);
  3569. from++;
  3570. }
  3571. return sum;
  3572. },
  3573. getContainerFillWidth: function() {
  3574. if (this.containerWidth) {
  3575. return this.containerWidth;
  3576. }
  3577. var mainContainer = this.instance.wtTable.holder;
  3578. var fillWidth;
  3579. var dummyElement;
  3580. dummyElement = document.createElement('div');
  3581. dummyElement.style.width = '100%';
  3582. dummyElement.style.height = '1px';
  3583. mainContainer.appendChild(dummyElement);
  3584. fillWidth = dummyElement.offsetWidth;
  3585. this.containerWidth = fillWidth;
  3586. mainContainer.removeChild(dummyElement);
  3587. return fillWidth;
  3588. },
  3589. getWorkspaceOffset: function() {
  3590. return offset(this.wot.wtTable.TABLE);
  3591. },
  3592. getWorkspaceActualHeight: function() {
  3593. return outerHeight(this.wot.wtTable.TABLE);
  3594. },
  3595. getWorkspaceActualWidth: function() {
  3596. return outerWidth(this.wot.wtTable.TABLE) || outerWidth(this.wot.wtTable.TBODY) || outerWidth(this.wot.wtTable.THEAD);
  3597. },
  3598. getColumnHeaderHeight: function() {
  3599. if (isNaN(this.columnHeaderHeight)) {
  3600. this.columnHeaderHeight = outerHeight(this.wot.wtTable.THEAD);
  3601. }
  3602. return this.columnHeaderHeight;
  3603. },
  3604. getViewportHeight: function() {
  3605. var containerHeight = this.getWorkspaceHeight();
  3606. var columnHeaderHeight;
  3607. if (containerHeight === Infinity) {
  3608. return containerHeight;
  3609. }
  3610. columnHeaderHeight = this.getColumnHeaderHeight();
  3611. if (columnHeaderHeight > 0) {
  3612. containerHeight -= columnHeaderHeight;
  3613. }
  3614. return containerHeight;
  3615. },
  3616. getRowHeaderWidth: function() {
  3617. if (this.wot.cloneSource) {
  3618. return this.wot.cloneSource.wtViewport.getRowHeaderWidth();
  3619. }
  3620. if (isNaN(this.rowHeaderWidth)) {
  3621. var rowHeaders = this.instance.getSetting('rowHeaders');
  3622. if (rowHeaders.length) {
  3623. var TH = this.instance.wtTable.TABLE.querySelector('TH');
  3624. this.rowHeaderWidth = 0;
  3625. for (var i = 0,
  3626. len = rowHeaders.length; i < len; i++) {
  3627. if (TH) {
  3628. this.rowHeaderWidth += outerWidth(TH);
  3629. TH = TH.nextSibling;
  3630. } else {
  3631. this.rowHeaderWidth += 50;
  3632. }
  3633. }
  3634. } else {
  3635. this.rowHeaderWidth = 0;
  3636. }
  3637. }
  3638. return this.rowHeaderWidth;
  3639. },
  3640. getViewportWidth: function() {
  3641. var containerWidth = this.getWorkspaceWidth();
  3642. var rowHeaderWidth;
  3643. if (containerWidth === Infinity) {
  3644. return containerWidth;
  3645. }
  3646. rowHeaderWidth = this.getRowHeaderWidth();
  3647. if (rowHeaderWidth > 0) {
  3648. return containerWidth - rowHeaderWidth;
  3649. }
  3650. return containerWidth;
  3651. },
  3652. createRowsCalculator: function() {
  3653. var visible = arguments[0] !== (void 0) ? arguments[0] : false;
  3654. var $__4 = this;
  3655. var height;
  3656. var pos;
  3657. var fixedRowsTop;
  3658. var scrollbarHeight;
  3659. var fixedRowsBottom;
  3660. var fixedRowsHeight;
  3661. var totalRows;
  3662. this.rowHeaderWidth = NaN;
  3663. if (this.wot.wtSettings.settings.renderAllRows) {
  3664. height = Infinity;
  3665. } else {
  3666. height = this.getViewportHeight();
  3667. }
  3668. pos = getScrollTop(this.wot.wtOverlays.mainTableScrollableElement) - this.wot.wtOverlays.topOverlay.getTableParentOffset();
  3669. if (pos < 0) {
  3670. pos = 0;
  3671. }
  3672. fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  3673. fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  3674. totalRows = this.wot.getSetting('totalRows');
  3675. if (fixedRowsTop) {
  3676. fixedRowsHeight = this.wot.wtOverlays.topOverlay.sumCellSizes(0, fixedRowsTop);
  3677. pos += fixedRowsHeight;
  3678. height -= fixedRowsHeight;
  3679. }
  3680. if (fixedRowsBottom && this.wot.wtOverlays.bottomOverlay.clone) {
  3681. fixedRowsHeight = this.wot.wtOverlays.bottomOverlay.sumCellSizes(totalRows - fixedRowsBottom, totalRows);
  3682. height -= fixedRowsHeight;
  3683. }
  3684. if (this.wot.wtTable.holder.clientHeight === this.wot.wtTable.holder.offsetHeight) {
  3685. scrollbarHeight = 0;
  3686. } else {
  3687. scrollbarHeight = getScrollbarWidth();
  3688. }
  3689. return new WalkontableViewportRowsCalculator(height, pos, this.wot.getSetting('totalRows'), (function(sourceRow) {
  3690. return $__4.wot.wtTable.getRowHeight(sourceRow);
  3691. }), visible ? null : this.wot.wtSettings.settings.viewportRowCalculatorOverride, visible, scrollbarHeight);
  3692. },
  3693. createColumnsCalculator: function() {
  3694. var visible = arguments[0] !== (void 0) ? arguments[0] : false;
  3695. var $__4 = this;
  3696. var width = this.getViewportWidth();
  3697. var pos;
  3698. var fixedColumnsLeft;
  3699. this.columnHeaderHeight = NaN;
  3700. pos = this.wot.wtOverlays.leftOverlay.getScrollPosition() - this.wot.wtOverlays.leftOverlay.getTableParentOffset();
  3701. if (pos < 0) {
  3702. pos = 0;
  3703. }
  3704. fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
  3705. if (fixedColumnsLeft) {
  3706. var fixedColumnsWidth = this.wot.wtOverlays.leftOverlay.sumCellSizes(0, fixedColumnsLeft);
  3707. pos += fixedColumnsWidth;
  3708. width -= fixedColumnsWidth;
  3709. }
  3710. if (this.wot.wtTable.holder.clientWidth !== this.wot.wtTable.holder.offsetWidth) {
  3711. width -= getScrollbarWidth();
  3712. }
  3713. return new WalkontableViewportColumnsCalculator(width, pos, this.wot.getSetting('totalColumns'), (function(sourceCol) {
  3714. return $__4.wot.wtTable.getColumnWidth(sourceCol);
  3715. }), visible ? null : this.wot.wtSettings.settings.viewportColumnCalculatorOverride, visible, this.wot.getSetting('stretchH'));
  3716. },
  3717. createRenderCalculators: function() {
  3718. var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
  3719. if (fastDraw) {
  3720. var proposedRowsVisibleCalculator = this.createRowsCalculator(true);
  3721. var proposedColumnsVisibleCalculator = this.createColumnsCalculator(true);
  3722. if (!(this.areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) && this.areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator))) {
  3723. fastDraw = false;
  3724. }
  3725. }
  3726. if (!fastDraw) {
  3727. this.rowsRenderCalculator = this.createRowsCalculator();
  3728. this.columnsRenderCalculator = this.createColumnsCalculator();
  3729. }
  3730. this.rowsVisibleCalculator = null;
  3731. this.columnsVisibleCalculator = null;
  3732. return fastDraw;
  3733. },
  3734. createVisibleCalculators: function() {
  3735. this.rowsVisibleCalculator = this.createRowsCalculator(true);
  3736. this.columnsVisibleCalculator = this.createColumnsCalculator(true);
  3737. },
  3738. areAllProposedVisibleRowsAlreadyRendered: function(proposedRowsVisibleCalculator) {
  3739. if (this.rowsVisibleCalculator) {
  3740. if (proposedRowsVisibleCalculator.startRow < this.rowsRenderCalculator.startRow || (proposedRowsVisibleCalculator.startRow === this.rowsRenderCalculator.startRow && proposedRowsVisibleCalculator.startRow > 0)) {
  3741. return false;
  3742. } else if (proposedRowsVisibleCalculator.endRow > this.rowsRenderCalculator.endRow || (proposedRowsVisibleCalculator.endRow === this.rowsRenderCalculator.endRow && proposedRowsVisibleCalculator.endRow < this.wot.getSetting('totalRows') - 1)) {
  3743. return false;
  3744. } else {
  3745. return true;
  3746. }
  3747. }
  3748. return false;
  3749. },
  3750. areAllProposedVisibleColumnsAlreadyRendered: function(proposedColumnsVisibleCalculator) {
  3751. if (this.columnsVisibleCalculator) {
  3752. if (proposedColumnsVisibleCalculator.startColumn < this.columnsRenderCalculator.startColumn || (proposedColumnsVisibleCalculator.startColumn === this.columnsRenderCalculator.startColumn && proposedColumnsVisibleCalculator.startColumn > 0)) {
  3753. return false;
  3754. } else if (proposedColumnsVisibleCalculator.endColumn > this.columnsRenderCalculator.endColumn || (proposedColumnsVisibleCalculator.endColumn === this.columnsRenderCalculator.endColumn && proposedColumnsVisibleCalculator.endColumn < this.wot.getSetting('totalColumns') - 1)) {
  3755. return false;
  3756. } else {
  3757. return true;
  3758. }
  3759. }
  3760. return false;
  3761. }
  3762. }, {});
  3763. ;
  3764. window.WalkontableViewport = WalkontableViewport;
  3765. //#
  3766. },{"calculator/viewportColumns":3,"calculator/viewportRows":4,"eventManager":41,"helpers/dom/element":45}],23:[function(require,module,exports){
  3767. "use strict";
  3768. var $__shims_47_classes__,
  3769. $__es6collections__,
  3770. $__pluginHooks__,
  3771. $__core__,
  3772. $__renderers_47__95_cellDecorator__,
  3773. $__cellTypes__,
  3774. $___46__46__47_plugins_47_jqueryHandsontable__,
  3775. $__helpers_47_array__,
  3776. $__helpers_47_browser__,
  3777. $__helpers_47_data__,
  3778. $__helpers_47_function__,
  3779. $__helpers_47_mixed__,
  3780. $__helpers_47_number__,
  3781. $__helpers_47_object__,
  3782. $__helpers_47_setting__,
  3783. $__helpers_47_string__,
  3784. $__helpers_47_unicode__,
  3785. $__helpers_47_dom_47_element__,
  3786. $__helpers_47_dom_47_event__;
  3787. window.Handsontable = function Handsontable(rootElement, userSettings) {
  3788. var instance = new Handsontable.Core(rootElement, userSettings || {});
  3789. instance.init();
  3790. return instance;
  3791. };
  3792. ($__shims_47_classes__ = require("shims/classes"), $__shims_47_classes__ && $__shims_47_classes__.__esModule && $__shims_47_classes__ || {default: $__shims_47_classes__});
  3793. ($__es6collections__ = require("es6collections"), $__es6collections__ && $__es6collections__.__esModule && $__es6collections__ || {default: $__es6collections__});
  3794. var Hooks = ($__pluginHooks__ = require("pluginHooks"), $__pluginHooks__ && $__pluginHooks__.__esModule && $__pluginHooks__ || {default: $__pluginHooks__}).Hooks;
  3795. if (!Handsontable.hooks) {
  3796. Handsontable.hooks = new Hooks();
  3797. }
  3798. ($__core__ = require("core"), $__core__ && $__core__.__esModule && $__core__ || {default: $__core__});
  3799. ($__renderers_47__95_cellDecorator__ = require("renderers/_cellDecorator"), $__renderers_47__95_cellDecorator__ && $__renderers_47__95_cellDecorator__.__esModule && $__renderers_47__95_cellDecorator__ || {default: $__renderers_47__95_cellDecorator__});
  3800. ($__cellTypes__ = require("cellTypes"), $__cellTypes__ && $__cellTypes__.__esModule && $__cellTypes__ || {default: $__cellTypes__});
  3801. ($___46__46__47_plugins_47_jqueryHandsontable__ = require("plugins/jqueryHandsontable"), $___46__46__47_plugins_47_jqueryHandsontable__ && $___46__46__47_plugins_47_jqueryHandsontable__.__esModule && $___46__46__47_plugins_47_jqueryHandsontable__ || {default: $___46__46__47_plugins_47_jqueryHandsontable__});
  3802. var arrayHelpers = ($__helpers_47_array__ = require("helpers/array"), $__helpers_47_array__ && $__helpers_47_array__.__esModule && $__helpers_47_array__ || {default: $__helpers_47_array__});
  3803. var browserHelpers = ($__helpers_47_browser__ = require("helpers/browser"), $__helpers_47_browser__ && $__helpers_47_browser__.__esModule && $__helpers_47_browser__ || {default: $__helpers_47_browser__});
  3804. var dataHelpers = ($__helpers_47_data__ = require("helpers/data"), $__helpers_47_data__ && $__helpers_47_data__.__esModule && $__helpers_47_data__ || {default: $__helpers_47_data__});
  3805. var functionHelpers = ($__helpers_47_function__ = require("helpers/function"), $__helpers_47_function__ && $__helpers_47_function__.__esModule && $__helpers_47_function__ || {default: $__helpers_47_function__});
  3806. var mixedHelpers = ($__helpers_47_mixed__ = require("helpers/mixed"), $__helpers_47_mixed__ && $__helpers_47_mixed__.__esModule && $__helpers_47_mixed__ || {default: $__helpers_47_mixed__});
  3807. var numberHelpers = ($__helpers_47_number__ = require("helpers/number"), $__helpers_47_number__ && $__helpers_47_number__.__esModule && $__helpers_47_number__ || {default: $__helpers_47_number__});
  3808. var objectHelpers = ($__helpers_47_object__ = require("helpers/object"), $__helpers_47_object__ && $__helpers_47_object__.__esModule && $__helpers_47_object__ || {default: $__helpers_47_object__});
  3809. var settingHelpers = ($__helpers_47_setting__ = require("helpers/setting"), $__helpers_47_setting__ && $__helpers_47_setting__.__esModule && $__helpers_47_setting__ || {default: $__helpers_47_setting__});
  3810. var stringHelpers = ($__helpers_47_string__ = require("helpers/string"), $__helpers_47_string__ && $__helpers_47_string__.__esModule && $__helpers_47_string__ || {default: $__helpers_47_string__});
  3811. var unicodeHelpers = ($__helpers_47_unicode__ = require("helpers/unicode"), $__helpers_47_unicode__ && $__helpers_47_unicode__.__esModule && $__helpers_47_unicode__ || {default: $__helpers_47_unicode__});
  3812. var domHelpers = ($__helpers_47_dom_47_element__ = require("helpers/dom/element"), $__helpers_47_dom_47_element__ && $__helpers_47_dom_47_element__.__esModule && $__helpers_47_dom_47_element__ || {default: $__helpers_47_dom_47_element__});
  3813. var domEventHelpers = ($__helpers_47_dom_47_event__ = require("helpers/dom/event"), $__helpers_47_dom_47_event__ && $__helpers_47_dom_47_event__.__esModule && $__helpers_47_dom_47_event__ || {default: $__helpers_47_dom_47_event__});
  3814. var HELPERS = [arrayHelpers, browserHelpers, dataHelpers, functionHelpers, mixedHelpers, numberHelpers, objectHelpers, settingHelpers, stringHelpers, unicodeHelpers];
  3815. var DOM = [domHelpers, domEventHelpers];
  3816. Handsontable.buildDate = 'Fri Dec 04 2015 11:56:12 GMT+0100 (CET)';
  3817. Handsontable.packageName = 'handsontable';
  3818. Handsontable.version = '0.20.2';
  3819. var baseVersion = '@@baseVersion';
  3820. if (!/^@@/.test(baseVersion)) {
  3821. Handsontable.baseVersion = baseVersion;
  3822. }
  3823. Handsontable.plugins = {};
  3824. Handsontable.helper = {};
  3825. Handsontable.dom = {};
  3826. Handsontable.Dom = Handsontable.dom;
  3827. arrayHelpers.arrayEach(HELPERS, (function(helper) {
  3828. arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), (function(key) {
  3829. if (key.charAt(0) !== '_') {
  3830. Handsontable.helper[key] = helper[key];
  3831. }
  3832. }));
  3833. }));
  3834. arrayHelpers.arrayEach(DOM, (function(helper) {
  3835. arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), (function(key) {
  3836. if (key.charAt(0) !== '_') {
  3837. Handsontable.dom[key] = helper[key];
  3838. }
  3839. }));
  3840. }));
  3841. //#
  3842. },{"cellTypes":24,"core":25,"es6collections":"es6collections","helpers/array":42,"helpers/browser":43,"helpers/data":44,"helpers/dom/element":45,"helpers/dom/event":46,"helpers/function":47,"helpers/mixed":48,"helpers/number":49,"helpers/object":50,"helpers/setting":51,"helpers/string":52,"helpers/unicode":53,"pluginHooks":56,"plugins/jqueryHandsontable":1,"renderers/_cellDecorator":89,"shims/classes":96}],24:[function(require,module,exports){
  3843. "use strict";
  3844. var $__helpers_47_browser__,
  3845. $__editors__,
  3846. $__renderers__,
  3847. $__editors_47_autocompleteEditor__,
  3848. $__editors_47_checkboxEditor__,
  3849. $__editors_47_dateEditor__,
  3850. $__editors_47_dropdownEditor__,
  3851. $__editors_47_handsontableEditor__,
  3852. $__editors_47_mobileTextEditor__,
  3853. $__editors_47_numericEditor__,
  3854. $__editors_47_passwordEditor__,
  3855. $__editors_47_selectEditor__,
  3856. $__editors_47_textEditor__,
  3857. $__renderers_47_autocompleteRenderer__,
  3858. $__renderers_47_checkboxRenderer__,
  3859. $__renderers_47_htmlRenderer__,
  3860. $__renderers_47_numericRenderer__,
  3861. $__renderers_47_passwordRenderer__,
  3862. $__renderers_47_textRenderer__,
  3863. $__validators_47_autocompleteValidator__,
  3864. $__validators_47_dateValidator__,
  3865. $__validators_47_numericValidator__;
  3866. var isMobileBrowser = ($__helpers_47_browser__ = require("helpers/browser"), $__helpers_47_browser__ && $__helpers_47_browser__.__esModule && $__helpers_47_browser__ || {default: $__helpers_47_browser__}).isMobileBrowser;
  3867. var getEditorConstructor = ($__editors__ = require("editors"), $__editors__ && $__editors__.__esModule && $__editors__ || {default: $__editors__}).getEditorConstructor;
  3868. var getRenderer = ($__renderers__ = require("renderers"), $__renderers__ && $__renderers__.__esModule && $__renderers__ || {default: $__renderers__}).getRenderer;
  3869. var AutocompleteEditor = ($__editors_47_autocompleteEditor__ = require("editors/autocompleteEditor"), $__editors_47_autocompleteEditor__ && $__editors_47_autocompleteEditor__.__esModule && $__editors_47_autocompleteEditor__ || {default: $__editors_47_autocompleteEditor__}).AutocompleteEditor;
  3870. var CheckboxEditor = ($__editors_47_checkboxEditor__ = require("editors/checkboxEditor"), $__editors_47_checkboxEditor__ && $__editors_47_checkboxEditor__.__esModule && $__editors_47_checkboxEditor__ || {default: $__editors_47_checkboxEditor__}).CheckboxEditor;
  3871. var DateEditor = ($__editors_47_dateEditor__ = require("editors/dateEditor"), $__editors_47_dateEditor__ && $__editors_47_dateEditor__.__esModule && $__editors_47_dateEditor__ || {default: $__editors_47_dateEditor__}).DateEditor;
  3872. var DropdownEditor = ($__editors_47_dropdownEditor__ = require("editors/dropdownEditor"), $__editors_47_dropdownEditor__ && $__editors_47_dropdownEditor__.__esModule && $__editors_47_dropdownEditor__ || {default: $__editors_47_dropdownEditor__}).DropdownEditor;
  3873. var HandsontableEditor = ($__editors_47_handsontableEditor__ = require("editors/handsontableEditor"), $__editors_47_handsontableEditor__ && $__editors_47_handsontableEditor__.__esModule && $__editors_47_handsontableEditor__ || {default: $__editors_47_handsontableEditor__}).HandsontableEditor;
  3874. var MobileTextEditor = ($__editors_47_mobileTextEditor__ = require("editors/mobileTextEditor"), $__editors_47_mobileTextEditor__ && $__editors_47_mobileTextEditor__.__esModule && $__editors_47_mobileTextEditor__ || {default: $__editors_47_mobileTextEditor__}).MobileTextEditor;
  3875. var NumericEditor = ($__editors_47_numericEditor__ = require("editors/numericEditor"), $__editors_47_numericEditor__ && $__editors_47_numericEditor__.__esModule && $__editors_47_numericEditor__ || {default: $__editors_47_numericEditor__}).NumericEditor;
  3876. var PasswordEditor = ($__editors_47_passwordEditor__ = require("editors/passwordEditor"), $__editors_47_passwordEditor__ && $__editors_47_passwordEditor__.__esModule && $__editors_47_passwordEditor__ || {default: $__editors_47_passwordEditor__}).PasswordEditor;
  3877. var SelectEditor = ($__editors_47_selectEditor__ = require("editors/selectEditor"), $__editors_47_selectEditor__ && $__editors_47_selectEditor__.__esModule && $__editors_47_selectEditor__ || {default: $__editors_47_selectEditor__}).SelectEditor;
  3878. var TextEditor = ($__editors_47_textEditor__ = require("editors/textEditor"), $__editors_47_textEditor__ && $__editors_47_textEditor__.__esModule && $__editors_47_textEditor__ || {default: $__editors_47_textEditor__}).TextEditor;
  3879. var AutocompleteRenderer = ($__renderers_47_autocompleteRenderer__ = require("renderers/autocompleteRenderer"), $__renderers_47_autocompleteRenderer__ && $__renderers_47_autocompleteRenderer__.__esModule && $__renderers_47_autocompleteRenderer__ || {default: $__renderers_47_autocompleteRenderer__}).AutocompleteRenderer;
  3880. var CheckboxRenderer = ($__renderers_47_checkboxRenderer__ = require("renderers/checkboxRenderer"), $__renderers_47_checkboxRenderer__ && $__renderers_47_checkboxRenderer__.__esModule && $__renderers_47_checkboxRenderer__ || {default: $__renderers_47_checkboxRenderer__}).CheckboxRenderer;
  3881. var HtmlRenderer = ($__renderers_47_htmlRenderer__ = require("renderers/htmlRenderer"), $__renderers_47_htmlRenderer__ && $__renderers_47_htmlRenderer__.__esModule && $__renderers_47_htmlRenderer__ || {default: $__renderers_47_htmlRenderer__}).HtmlRenderer;
  3882. var NumericRenderer = ($__renderers_47_numericRenderer__ = require("renderers/numericRenderer"), $__renderers_47_numericRenderer__ && $__renderers_47_numericRenderer__.__esModule && $__renderers_47_numericRenderer__ || {default: $__renderers_47_numericRenderer__}).NumericRenderer;
  3883. var PasswordRenderer = ($__renderers_47_passwordRenderer__ = require("renderers/passwordRenderer"), $__renderers_47_passwordRenderer__ && $__renderers_47_passwordRenderer__.__esModule && $__renderers_47_passwordRenderer__ || {default: $__renderers_47_passwordRenderer__}).PasswordRenderer;
  3884. var TextRenderer = ($__renderers_47_textRenderer__ = require("renderers/textRenderer"), $__renderers_47_textRenderer__ && $__renderers_47_textRenderer__.__esModule && $__renderers_47_textRenderer__ || {default: $__renderers_47_textRenderer__}).TextRenderer;
  3885. var AutocompleteValidator = ($__validators_47_autocompleteValidator__ = require("validators/autocompleteValidator"), $__validators_47_autocompleteValidator__ && $__validators_47_autocompleteValidator__.__esModule && $__validators_47_autocompleteValidator__ || {default: $__validators_47_autocompleteValidator__}).AutocompleteValidator;
  3886. var DateValidator = ($__validators_47_dateValidator__ = require("validators/dateValidator"), $__validators_47_dateValidator__ && $__validators_47_dateValidator__.__esModule && $__validators_47_dateValidator__ || {default: $__validators_47_dateValidator__}).DateValidator;
  3887. var NumericValidator = ($__validators_47_numericValidator__ = require("validators/numericValidator"), $__validators_47_numericValidator__ && $__validators_47_numericValidator__.__esModule && $__validators_47_numericValidator__ || {default: $__validators_47_numericValidator__}).NumericValidator;
  3888. Handsontable.mobileBrowser = isMobileBrowser();
  3889. Handsontable.AutocompleteCell = {
  3890. editor: getEditorConstructor('autocomplete'),
  3891. renderer: getRenderer('autocomplete'),
  3892. validator: Handsontable.AutocompleteValidator
  3893. };
  3894. Handsontable.CheckboxCell = {
  3895. editor: getEditorConstructor('checkbox'),
  3896. renderer: getRenderer('checkbox')
  3897. };
  3898. Handsontable.TextCell = {
  3899. editor: Handsontable.mobileBrowser ? getEditorConstructor('mobile') : getEditorConstructor('text'),
  3900. renderer: getRenderer('text')
  3901. };
  3902. Handsontable.NumericCell = {
  3903. editor: getEditorConstructor('numeric'),
  3904. renderer: getRenderer('numeric'),
  3905. validator: Handsontable.NumericValidator,
  3906. dataType: 'number'
  3907. };
  3908. Handsontable.DateCell = {
  3909. editor: getEditorConstructor('date'),
  3910. validator: Handsontable.DateValidator,
  3911. renderer: getRenderer('autocomplete')
  3912. };
  3913. Handsontable.HandsontableCell = {
  3914. editor: getEditorConstructor('handsontable'),
  3915. renderer: getRenderer('autocomplete')
  3916. };
  3917. Handsontable.PasswordCell = {
  3918. editor: getEditorConstructor('password'),
  3919. renderer: getRenderer('password'),
  3920. copyable: false
  3921. };
  3922. Handsontable.DropdownCell = {
  3923. editor: getEditorConstructor('dropdown'),
  3924. renderer: getRenderer('autocomplete'),
  3925. validator: Handsontable.AutocompleteValidator
  3926. };
  3927. Handsontable.cellTypes = {
  3928. text: Handsontable.TextCell,
  3929. date: Handsontable.DateCell,
  3930. numeric: Handsontable.NumericCell,
  3931. checkbox: Handsontable.CheckboxCell,
  3932. autocomplete: Handsontable.AutocompleteCell,
  3933. handsontable: Handsontable.HandsontableCell,
  3934. password: Handsontable.PasswordCell,
  3935. dropdown: Handsontable.DropdownCell
  3936. };
  3937. Handsontable.cellLookup = {validator: {
  3938. numeric: Handsontable.NumericValidator,
  3939. autocomplete: Handsontable.AutocompleteValidator
  3940. }};
  3941. //#
  3942. },{"editors":29,"editors/autocompleteEditor":31,"editors/checkboxEditor":32,"editors/dateEditor":33,"editors/dropdownEditor":34,"editors/handsontableEditor":35,"editors/mobileTextEditor":36,"editors/numericEditor":37,"editors/passwordEditor":38,"editors/selectEditor":39,"editors/textEditor":40,"helpers/browser":43,"renderers":88,"renderers/autocompleteRenderer":90,"renderers/checkboxRenderer":91,"renderers/htmlRenderer":92,"renderers/numericRenderer":93,"renderers/passwordRenderer":94,"renderers/textRenderer":95,"validators/autocompleteValidator":100,"validators/dateValidator":101,"validators/numericValidator":102}],25:[function(require,module,exports){
  3943. "use strict";
  3944. var $__numeral__,
  3945. $__helpers_47_dom_47_element__,
  3946. $__helpers_47_setting__,
  3947. $__dataMap__,
  3948. $__editorManager__,
  3949. $__eventManager__,
  3950. $__helpers_47_object__,
  3951. $__helpers_47_array__,
  3952. $__plugins__,
  3953. $__renderers__,
  3954. $__helpers_47_string__,
  3955. $__helpers_47_number__,
  3956. $__tableView__,
  3957. $__dataSource__,
  3958. $__helpers_47_data__,
  3959. $__3rdparty_47_walkontable_47_src_47_cell_47_coords__,
  3960. $__3rdparty_47_walkontable_47_src_47_cell_47_range__,
  3961. $__3rdparty_47_walkontable_47_src_47_selection__,
  3962. $__3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__;
  3963. var numeral = ($__numeral__ = require("numeral"), $__numeral__ && $__numeral__.__esModule && $__numeral__ || {default: $__numeral__}).default;
  3964. var $__1 = ($__helpers_47_dom_47_element__ = require("helpers/dom/element"), $__helpers_47_dom_47_element__ && $__helpers_47_dom_47_element__.__esModule && $__helpers_47_dom_47_element__ || {default: $__helpers_47_dom_47_element__}),
  3965. addClass = $__1.addClass,
  3966. empty = $__1.empty,
  3967. isChildOfWebComponentTable = $__1.isChildOfWebComponentTable,
  3968. removeClass = $__1.removeClass;
  3969. var columnFactory = ($__helpers_47_setting__ = require("helpers/setting"), $__helpers_47_setting__ && $__helpers_47_setting__.__esModule && $__helpers_47_setting__ || {default: $__helpers_47_setting__}).columnFactory;
  3970. var DataMap = ($__dataMap__ = require("dataMap"), $__dataMap__ && $__dataMap__.__esModule && $__dataMap__ || {default: $__dataMap__}).DataMap;
  3971. var EditorManager = ($__editorManager__ = require("editorManager"), $__editorManager__ && $__editorManager__.__esModule && $__editorManager__ || {default: $__editorManager__}).EditorManager;
  3972. var eventManagerObject = ($__eventManager__ = require("eventManager"), $__eventManager__ && $__eventManager__.__esModule && $__eventManager__ || {default: $__eventManager__}).eventManager;
  3973. var $__6 = ($__helpers_47_object__ = require("helpers/object"), $__helpers_47_object__ && $__helpers_47_object__.__esModule && $__helpers_47_object__ || {default: $__helpers_47_object__}),
  3974. extend = $__6.extend,
  3975. duckSchema = $__6.duckSchema,
  3976. isObjectEquals = $__6.isObjectEquals,
  3977. deepClone = $__6.deepClone;
  3978. var arrayFlatten = ($__helpers_47_array__ = require("helpers/array"), $__helpers_47_array__ && $__helpers_47_array__.__esModule && $__helpers_47_array__ || {default: $__helpers_47_array__}).arrayFlatten;
  3979. var getPlugin = ($__plugins__ = require("plugins"), $__plugins__ && $__plugins__.__esModule && $__plugins__ || {default: $__plugins__}).getPlugin;
  3980. var getRenderer = ($__renderers__ = require("renderers"), $__renderers__ && $__renderers__.__esModule && $__renderers__ || {default: $__renderers__}).getRenderer;
  3981. var randomString = ($__helpers_47_string__ = require("helpers/string"), $__helpers_47_string__ && $__helpers_47_string__.__esModule && $__helpers_47_string__ || {default: $__helpers_47_string__}).randomString;
  3982. var rangeEach = ($__helpers_47_number__ = require("helpers/number"), $__helpers_47_number__ && $__helpers_47_number__.__esModule && $__helpers_47_number__ || {default: $__helpers_47_number__}).rangeEach;
  3983. var TableView = ($__tableView__ = require("tableView"), $__tableView__ && $__tableView__.__esModule && $__tableView__ || {default: $__tableView__}).TableView;
  3984. var DataSource = ($__dataSource__ = require("dataSource"), $__dataSource__ && $__dataSource__.__esModule && $__dataSource__ || {default: $__dataSource__}).DataSource;
  3985. var $__14 = ($__helpers_47_data__ = require("helpers/data"), $__helpers_47_data__ && $__helpers_47_data__.__esModule && $__helpers_47_data__ || {default: $__helpers_47_data__}),
  3986. translateRowsToColumns = $__14.translateRowsToColumns,
  3987. cellMethodLookupFactory = $__14.cellMethodLookupFactory,
  3988. spreadsheetColumnLabel = $__14.spreadsheetColumnLabel;
  3989. var WalkontableCellCoords = ($__3rdparty_47_walkontable_47_src_47_cell_47_coords__ = require("3rdparty/walkontable/src/cell/coords"), $__3rdparty_47_walkontable_47_src_47_cell_47_coords__ && $__3rdparty_47_walkontable_47_src_47_cell_47_coords__.__esModule && $__3rdparty_47_walkontable_47_src_47_cell_47_coords__ || {default: $__3rdparty_47_walkontable_47_src_47_cell_47_coords__}).WalkontableCellCoords;
  3990. var WalkontableCellRange = ($__3rdparty_47_walkontable_47_src_47_cell_47_range__ = require("3rdparty/walkontable/src/cell/range"), $__3rdparty_47_walkontable_47_src_47_cell_47_range__ && $__3rdparty_47_walkontable_47_src_47_cell_47_range__.__esModule && $__3rdparty_47_walkontable_47_src_47_cell_47_range__ || {default: $__3rdparty_47_walkontable_47_src_47_cell_47_range__}).WalkontableCellRange;
  3991. var WalkontableSelection = ($__3rdparty_47_walkontable_47_src_47_selection__ = require("3rdparty/walkontable/src/selection"), $__3rdparty_47_walkontable_47_src_47_selection__ && $__3rdparty_47_walkontable_47_src_47_selection__.__esModule && $__3rdparty_47_walkontable_47_src_47_selection__ || {default: $__3rdparty_47_walkontable_47_src_47_selection__}).WalkontableSelection;
  3992. var WalkontableViewportColumnsCalculator = ($__3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__ = require("3rdparty/walkontable/src/calculator/viewportColumns"), $__3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__ && $__3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__.__esModule && $__3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__ || {default: $__3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__}).WalkontableViewportColumnsCalculator;
  3993. Handsontable.activeGuid = null;
  3994. Handsontable.Core = function Core(rootElement, userSettings) {
  3995. var priv,
  3996. datamap,
  3997. dataSource,
  3998. grid,
  3999. selection,
  4000. editorManager,
  4001. instance = this,
  4002. GridSettings = function() {},
  4003. eventManager = eventManagerObject(instance);
  4004. extend(GridSettings.prototype, DefaultSettings.prototype);
  4005. extend(GridSettings.prototype, userSettings);
  4006. extend(GridSettings.prototype, expandType(userSettings));
  4007. this.rootElement = rootElement;
  4008. this.isHotTableEnv = isChildOfWebComponentTable(this.rootElement);
  4009. Handsontable.eventManager.isHotTableEnv = this.isHotTableEnv;
  4010. this.container = document.createElement('DIV');
  4011. this.renderCall = false;
  4012. rootElement.insertBefore(this.container, rootElement.firstChild);
  4013. this.guid = 'ht_' + randomString();
  4014. if (!this.rootElement.id || this.rootElement.id.substring(0, 3) === 'ht_') {
  4015. this.rootElement.id = this.guid;
  4016. }
  4017. priv = {
  4018. cellSettings: [],
  4019. columnSettings: [],
  4020. columnsSettingConflicts: ['data', 'width'],
  4021. settings: new GridSettings(),
  4022. selRange: null,
  4023. isPopulated: null,
  4024. scrollable: null,
  4025. firstRun: true
  4026. };
  4027. grid = {
  4028. alter: function(action, index, amount, source, keepEmptyRows) {
  4029. var delta;
  4030. amount = amount || 1;
  4031. switch (action) {
  4032. case 'insert_row':
  4033. if (instance.getSettings().maxRows === instance.countSourceRows()) {
  4034. return;
  4035. }
  4036. delta = datamap.createRow(index, amount);
  4037. if (delta) {
  4038. if (selection.isSelected() && priv.selRange.from.row >= index) {
  4039. priv.selRange.from.row = priv.selRange.from.row + delta;
  4040. selection.transformEnd(delta, 0);
  4041. } else {
  4042. selection.refreshBorders();
  4043. }
  4044. }
  4045. break;
  4046. case 'insert_col':
  4047. delta = datamap.createCol(index, amount);
  4048. if (delta) {
  4049. if (Array.isArray(instance.getSettings().colHeaders)) {
  4050. var spliceArray = [index, 0];
  4051. spliceArray.length += delta;
  4052. Array.prototype.splice.apply(instance.getSettings().colHeaders, spliceArray);
  4053. }
  4054. if (selection.isSelected() && priv.selRange.from.col >= index) {
  4055. priv.selRange.from.col = priv.selRange.from.col + delta;
  4056. selection.transformEnd(0, delta);
  4057. } else {
  4058. selection.refreshBorders();
  4059. }
  4060. }
  4061. break;
  4062. case 'remove_row':
  4063. datamap.removeRow(index, amount);
  4064. priv.cellSettings.splice(index, amount);
  4065. var totalRows = instance.countRows();
  4066. var fixedRowsTop = instance.getSettings().fixedRowsTop;
  4067. if (fixedRowsTop >= index + 1) {
  4068. instance.getSettings().fixedRowsTop -= Math.min(amount, fixedRowsTop - index);
  4069. }
  4070. var fixedRowsBottom = instance.getSettings().fixedRowsBottom;
  4071. if (fixedRowsBottom && totalRows - fixedRowsBottom <= index + 1) {
  4072. instance.getSettings().fixedRowsBottom -= Math.min(amount, fixedRowsBottom - index);
  4073. }
  4074. grid.adjustRowsAndCols();
  4075. selection.refreshBorders();
  4076. break;
  4077. case 'remove_col':
  4078. datamap.removeCol(index, amount);
  4079. for (var row = 0,
  4080. len = datamap.getAll().length; row < len; row++) {
  4081. if (row in priv.cellSettings) {
  4082. priv.cellSettings[row].splice(index, amount);
  4083. }
  4084. }
  4085. var fixedColumnsLeft = instance.getSettings().fixedColumnsLeft;
  4086. if (fixedColumnsLeft >= index + 1) {
  4087. instance.getSettings().fixedColumnsLeft -= Math.min(amount, fixedColumnsLeft - index);
  4088. }
  4089. if (Array.isArray(instance.getSettings().colHeaders)) {
  4090. if (typeof index == 'undefined') {
  4091. index = -1;
  4092. }
  4093. instance.getSettings().colHeaders.splice(index, amount);
  4094. }
  4095. grid.adjustRowsAndCols();
  4096. selection.refreshBorders();
  4097. break;
  4098. default:
  4099. throw new Error('There is no such action "' + action + '"');
  4100. break;
  4101. }
  4102. if (!keepEmptyRows) {
  4103. grid.adjustRowsAndCols();
  4104. }
  4105. },
  4106. adjustRowsAndCols: function() {
  4107. if (priv.settings.minRows) {
  4108. var rows = instance.countRows();
  4109. if (rows < priv.settings.minRows) {
  4110. for (var r = 0,
  4111. minRows = priv.settings.minRows; r < minRows - rows; r++) {
  4112. datamap.createRow(instance.countRows(), 1, true);
  4113. }
  4114. }
  4115. }
  4116. if (priv.settings.minSpareRows) {
  4117. var emptyRows = instance.countEmptyRows(true);
  4118. if (emptyRows < priv.settings.minSpareRows) {
  4119. for (; emptyRows < priv.settings.minSpareRows && instance.countRows() < priv.settings.maxRows; emptyRows++) {
  4120. datamap.createRow(instance.countRows(), 1, true);
  4121. }
  4122. }
  4123. }
  4124. {
  4125. var emptyCols;
  4126. if (priv.settings.minCols || priv.settings.minSpareCols) {
  4127. emptyCols = instance.countEmptyCols(true);
  4128. }
  4129. if (priv.settings.minCols && !priv.settings.columns && instance.countCols() < priv.settings.minCols) {
  4130. for (; instance.countCols() < priv.settings.minCols; emptyCols++) {
  4131. datamap.createCol(instance.countCols(), 1, true);
  4132. }
  4133. }
  4134. if (priv.settings.minSpareCols && !priv.settings.columns && instance.dataType === 'array' && emptyCols < priv.settings.minSpareCols) {
  4135. for (; emptyCols < priv.settings.minSpareCols && instance.countCols() < priv.settings.maxCols; emptyCols++) {
  4136. datamap.createCol(instance.countCols(), 1, true);
  4137. }
  4138. }
  4139. }
  4140. var rowCount = instance.countRows();
  4141. var colCount = instance.countCols();
  4142. if (rowCount === 0 || colCount === 0) {
  4143. selection.deselect();
  4144. }
  4145. if (selection.isSelected()) {
  4146. var selectionChanged = false;
  4147. var fromRow = priv.selRange.from.row;
  4148. var fromCol = priv.selRange.from.col;
  4149. var toRow = priv.selRange.to.row;
  4150. var toCol = priv.selRange.to.col;
  4151. if (fromRow > rowCount - 1) {
  4152. fromRow = rowCount - 1;
  4153. selectionChanged = true;
  4154. if (toRow > fromRow) {
  4155. toRow = fromRow;
  4156. }
  4157. } else if (toRow > rowCount - 1) {
  4158. toRow = rowCount - 1;
  4159. selectionChanged = true;
  4160. if (fromRow > toRow) {
  4161. fromRow = toRow;
  4162. }
  4163. }
  4164. if (fromCol > colCount - 1) {
  4165. fromCol = colCount - 1;
  4166. selectionChanged = true;
  4167. if (toCol > fromCol) {
  4168. toCol = fromCol;
  4169. }
  4170. } else if (toCol > colCount - 1) {
  4171. toCol = colCount - 1;
  4172. selectionChanged = true;
  4173. if (fromCol > toCol) {
  4174. fromCol = toCol;
  4175. }
  4176. }
  4177. if (selectionChanged) {
  4178. instance.selectCell(fromRow, fromCol, toRow, toCol);
  4179. }
  4180. }
  4181. if (instance.view) {
  4182. instance.view.wt.wtOverlays.adjustElementsSize();
  4183. }
  4184. },
  4185. populateFromArray: function(start, input, end, source, method, direction, deltas) {
  4186. var r,
  4187. rlen,
  4188. c,
  4189. clen,
  4190. setData = [],
  4191. current = {};
  4192. rlen = input.length;
  4193. if (rlen === 0) {
  4194. return false;
  4195. }
  4196. var repeatCol,
  4197. repeatRow,
  4198. cmax,
  4199. rmax,
  4200. baseEnd = {
  4201. row: end === null ? null : end.row,
  4202. col: end === null ? null : end.col
  4203. };
  4204. switch (method) {
  4205. case 'shift_down':
  4206. repeatCol = end ? end.col - start.col + 1 : 0;
  4207. repeatRow = end ? end.row - start.row + 1 : 0;
  4208. input = translateRowsToColumns(input);
  4209. for (c = 0, clen = input.length, cmax = Math.max(clen, repeatCol); c < cmax; c++) {
  4210. if (c < clen) {
  4211. for (r = 0, rlen = input[c].length; r < repeatRow - rlen; r++) {
  4212. input[c].push(input[c][r % rlen]);
  4213. }
  4214. input[c].unshift(start.col + c, start.row, 0);
  4215. instance.spliceCol.apply(instance, input[c]);
  4216. } else {
  4217. input[c % clen][0] = start.col + c;
  4218. instance.spliceCol.apply(instance, input[c % clen]);
  4219. }
  4220. }
  4221. break;
  4222. case 'shift_right':
  4223. repeatCol = end ? end.col - start.col + 1 : 0;
  4224. repeatRow = end ? end.row - start.row + 1 : 0;
  4225. for (r = 0, rlen = input.length, rmax = Math.max(rlen, repeatRow); r < rmax; r++) {
  4226. if (r < rlen) {
  4227. for (c = 0, clen = input[r].length; c < repeatCol - clen; c++) {
  4228. input[r].push(input[r][c % clen]);
  4229. }
  4230. input[r].unshift(start.row + r, start.col, 0);
  4231. instance.spliceRow.apply(instance, input[r]);
  4232. } else {
  4233. input[r % rlen][0] = start.row + r;
  4234. instance.spliceRow.apply(instance, input[r % rlen]);
  4235. }
  4236. }
  4237. break;
  4238. case 'overwrite':
  4239. default:
  4240. current.row = start.row;
  4241. current.col = start.col;
  4242. var selected = {
  4243. row: (end && start) ? (end.row - start.row + 1) : 1,
  4244. col: (end && start) ? (end.col - start.col + 1) : 1
  4245. };
  4246. var skippedRow = 0;
  4247. var skippedColumn = 0;
  4248. var pushData = true;
  4249. var cellMeta;
  4250. var getInputValue = function getInputValue(row) {
  4251. var col = arguments[1] !== (void 0) ? arguments[1] : null;
  4252. var rowValue = input[row % input.length];
  4253. if (col !== null) {
  4254. return rowValue[col % rowValue.length];
  4255. }
  4256. return rowValue;
  4257. };
  4258. var rowInputLength = input.length;
  4259. var rowSelectionLength = end ? end.row - start.row + 1 : 0;
  4260. if (end) {
  4261. rlen = rowSelectionLength;
  4262. } else {
  4263. rlen = Math.max(rowInputLength, rowSelectionLength);
  4264. }
  4265. for (r = 0; r < rlen; r++) {
  4266. if ((end && current.row > end.row && rowSelectionLength > rowInputLength) || (!priv.settings.allowInsertRow && current.row > instance.countRows() - 1) || (current.row >= priv.settings.maxRows)) {
  4267. break;
  4268. }
  4269. var logicalRow = r - skippedRow;
  4270. var colInputLength = getInputValue(logicalRow).length;
  4271. var colSelectionLength = end ? end.col - start.col + 1 : 0;
  4272. if (end) {
  4273. clen = colSelectionLength;
  4274. } else {
  4275. clen = Math.max(colInputLength, colSelectionLength);
  4276. }
  4277. current.col = start.col;
  4278. cellMeta = instance.getCellMeta(current.row, current.col);
  4279. if ((source === 'paste' || source === 'autofill') && cellMeta.skipRowOnPaste) {
  4280. skippedRow++;
  4281. current.row++;
  4282. rlen++;
  4283. continue;
  4284. }
  4285. skippedColumn = 0;
  4286. for (c = 0; c < clen; c++) {
  4287. if ((end && current.col > end.col && colSelectionLength > colInputLength) || (!priv.settings.allowInsertColumn && current.col > instance.countCols() - 1) || (current.col >= priv.settings.maxCols)) {
  4288. break;
  4289. }
  4290. cellMeta = instance.getCellMeta(current.row, current.col);
  4291. if ((source === 'paste' || source === 'autofill') && cellMeta.skipColumnOnPaste) {
  4292. skippedColumn++;
  4293. current.col++;
  4294. clen++;
  4295. continue;
  4296. }
  4297. if (cellMeta.readOnly) {
  4298. current.col++;
  4299. continue;
  4300. }
  4301. var logicalColumn = c - skippedColumn;
  4302. var value = getInputValue(logicalRow, logicalColumn);
  4303. var orgValue = instance.getDataAtCell(current.row, current.col);
  4304. var index = {
  4305. row: logicalRow,
  4306. col: logicalColumn
  4307. };
  4308. if (source === 'autofill') {
  4309. var result = instance.runHooks('beforeAutofillInsidePopulate', index, direction, input, deltas, {}, selected);
  4310. if (result) {
  4311. value = typeof(result.value) === 'undefined' ? value : result.value;
  4312. }
  4313. }
  4314. if (value !== null && typeof value === 'object') {
  4315. if (orgValue === null || typeof orgValue !== 'object') {
  4316. pushData = false;
  4317. } else {
  4318. var orgValueSchema = duckSchema(orgValue[0] || orgValue);
  4319. var valueSchema = duckSchema(value[0] || value);
  4320. if (isObjectEquals(orgValueSchema, valueSchema)) {
  4321. value = deepClone(value);
  4322. } else {
  4323. pushData = false;
  4324. }
  4325. }
  4326. } else if (orgValue !== null && typeof orgValue === 'object') {
  4327. pushData = false;
  4328. }
  4329. if (pushData) {
  4330. setData.push([current.row, current.col, value]);
  4331. }
  4332. pushData = true;
  4333. current.col++;
  4334. }
  4335. current.row++;
  4336. }
  4337. instance.setDataAtCell(setData, null, null, source || 'populateFromArray');
  4338. break;
  4339. }
  4340. }
  4341. };
  4342. this.selection = selection = {
  4343. inProgress: false,
  4344. selectedHeader: {
  4345. cols: false,
  4346. rows: false
  4347. },
  4348. setSelectedHeaders: function(rows, cols) {
  4349. instance.selection.selectedHeader.rows = rows;
  4350. instance.selection.selectedHeader.cols = cols;
  4351. },
  4352. begin: function() {
  4353. instance.selection.inProgress = true;
  4354. },
  4355. finish: function() {
  4356. var sel = instance.getSelected();
  4357. Handsontable.hooks.run(instance, 'afterSelectionEnd', sel[0], sel[1], sel[2], sel[3]);
  4358. Handsontable.hooks.run(instance, 'afterSelectionEndByProp', sel[0], instance.colToProp(sel[1]), sel[2], instance.colToProp(sel[3]));
  4359. instance.selection.inProgress = false;
  4360. },
  4361. isInProgress: function() {
  4362. return instance.selection.inProgress;
  4363. },
  4364. setRangeStart: function(coords, keepEditorOpened) {
  4365. Handsontable.hooks.run(instance, 'beforeSetRangeStart', coords);
  4366. priv.selRange = new WalkontableCellRange(coords, coords, coords);
  4367. selection.setRangeEnd(coords, null, keepEditorOpened);
  4368. },
  4369. setRangeEnd: function(coords, scrollToCell, keepEditorOpened) {
  4370. if (priv.selRange === null) {
  4371. return;
  4372. }
  4373. var disableVisualSelection,
  4374. isHeaderSelected = false,
  4375. areCoordsPositive = true;
  4376. var firstVisibleRow = instance.view.wt.wtTable.getFirstVisibleRow();
  4377. var firstVisibleColumn = instance.view.wt.wtTable.getFirstVisibleColumn();
  4378. var newRangeCoords = {
  4379. row: null,
  4380. col: null
  4381. };
  4382. Handsontable.hooks.run(instance, 'beforeSetRangeEnd', coords);
  4383. instance.selection.begin();
  4384. newRangeCoords.row = coords.row < 0 ? firstVisibleRow : coords.row;
  4385. newRangeCoords.col = coords.col < 0 ? firstVisibleColumn : coords.col;
  4386. priv.selRange.to = new WalkontableCellCoords(newRangeCoords.row, newRangeCoords.col);
  4387. if (!priv.settings.multiSelect) {
  4388. priv.selRange.from = coords;
  4389. }
  4390. instance.view.wt.selections.current.clear();
  4391. disableVisualSelection = instance.getCellMeta(priv.selRange.highlight.row, priv.selRange.highlight.col).disableVisualSelection;
  4392. if (typeof disableVisualSelection === 'string') {
  4393. disableVisualSelection = [disableVisualSelection];
  4394. }
  4395. if (disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('current') === -1) {
  4396. instance.view.wt.selections.current.add(priv.selRange.highlight);
  4397. }
  4398. instance.view.wt.selections.area.clear();
  4399. if ((disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('area') === -1) && selection.isMultiple()) {
  4400. instance.view.wt.selections.area.add(priv.selRange.from);
  4401. instance.view.wt.selections.area.add(priv.selRange.to);
  4402. }
  4403. if (priv.settings.currentRowClassName || priv.settings.currentColClassName) {
  4404. instance.view.wt.selections.highlight.clear();
  4405. instance.view.wt.selections.highlight.add(priv.selRange.from);
  4406. instance.view.wt.selections.highlight.add(priv.selRange.to);
  4407. }
  4408. Handsontable.hooks.run(instance, 'afterSelection', priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col);
  4409. Handsontable.hooks.run(instance, 'afterSelectionByProp', priv.selRange.from.row, datamap.colToProp(priv.selRange.from.col), priv.selRange.to.row, datamap.colToProp(priv.selRange.to.col));
  4410. if ((priv.selRange.from.row === 0 && priv.selRange.to.row === instance.countRows() - 1 && instance.countRows() > 1) || (priv.selRange.from.col === 0 && priv.selRange.to.col === instance.countCols() - 1 && instance.countCols() > 1)) {
  4411. isHeaderSelected = true;
  4412. }
  4413. if (coords.row < 0 || coords.col < 0) {
  4414. areCoordsPositive = false;
  4415. }
  4416. if (scrollToCell !== false && !isHeaderSelected && areCoordsPositive) {
  4417. if (priv.selRange.from && !selection.isMultiple()) {
  4418. instance.view.scrollViewport(priv.selRange.from);
  4419. } else {
  4420. instance.view.scrollViewport(coords);
  4421. }
  4422. }
  4423. selection.refreshBorders(null, keepEditorOpened);
  4424. },
  4425. refreshBorders: function(revertOriginal, keepEditor) {
  4426. if (!keepEditor) {
  4427. editorManager.destroyEditor(revertOriginal);
  4428. }
  4429. instance.view.render();
  4430. if (selection.isSelected() && !keepEditor) {
  4431. editorManager.prepareEditor();
  4432. }
  4433. },
  4434. isMultiple: function() {
  4435. var isMultiple = !(priv.selRange.to.col === priv.selRange.from.col && priv.selRange.to.row === priv.selRange.from.row),
  4436. modifier = Handsontable.hooks.run(instance, 'afterIsMultipleSelection', isMultiple);
  4437. if (isMultiple) {
  4438. return modifier;
  4439. }
  4440. },
  4441. transformStart: function(rowDelta, colDelta, force, keepEditorOpened) {
  4442. var delta = new WalkontableCellCoords(rowDelta, colDelta),
  4443. rowTransformDir = 0,
  4444. colTransformDir = 0,
  4445. totalRows,
  4446. totalCols,
  4447. coords,
  4448. fixedRowsBottom;
  4449. instance.runHooks('modifyTransformStart', delta);
  4450. totalRows = instance.countRows();
  4451. totalCols = instance.countCols();
  4452. fixedRowsBottom = instance.getSettings().fixedRowsBottom;
  4453. if (priv.selRange.highlight.row + rowDelta > totalRows - 1) {
  4454. if (force && priv.settings.minSpareRows > 0 && !(fixedRowsBottom && priv.selRange.highlight.row >= totalRows - fixedRowsBottom - 1)) {
  4455. instance.alter('insert_row', totalRows);
  4456. totalRows = instance.countRows();
  4457. } else if (priv.settings.autoWrapCol) {
  4458. delta.row = 1 - totalRows;
  4459. delta.col = priv.selRange.highlight.col + delta.col == totalCols - 1 ? 1 - totalCols : 1;
  4460. }
  4461. } else if (priv.settings.autoWrapCol && priv.selRange.highlight.row + delta.row < 0 && priv.selRange.highlight.col + delta.col >= 0) {
  4462. delta.row = totalRows - 1;
  4463. delta.col = priv.selRange.highlight.col + delta.col == 0 ? totalCols - 1 : -1;
  4464. }
  4465. if (priv.selRange.highlight.col + delta.col > totalCols - 1) {
  4466. if (force && priv.settings.minSpareCols > 0) {
  4467. instance.alter('insert_col', totalCols);
  4468. totalCols = instance.countCols();
  4469. } else if (priv.settings.autoWrapRow) {
  4470. delta.row = priv.selRange.highlight.row + delta.row == totalRows - 1 ? 1 - totalRows : 1;
  4471. delta.col = 1 - totalCols;
  4472. }
  4473. } else if (priv.settings.autoWrapRow && priv.selRange.highlight.col + delta.col < 0 && priv.selRange.highlight.row + delta.row >= 0) {
  4474. delta.row = priv.selRange.highlight.row + delta.row == 0 ? totalRows - 1 : -1;
  4475. delta.col = totalCols - 1;
  4476. }
  4477. coords = new WalkontableCellCoords(priv.selRange.highlight.row + delta.row, priv.selRange.highlight.col + delta.col);
  4478. if (coords.row < 0) {
  4479. rowTransformDir = -1;
  4480. coords.row = 0;
  4481. } else if (coords.row > 0 && coords.row >= totalRows) {
  4482. rowTransformDir = 1;
  4483. coords.row = totalRows - 1;
  4484. }
  4485. if (coords.col < 0) {
  4486. colTransformDir = -1;
  4487. coords.col = 0;
  4488. } else if (coords.col > 0 && coords.col >= totalCols) {
  4489. colTransformDir = 1;
  4490. coords.col = totalCols - 1;
  4491. }
  4492. instance.runHooks('afterModifyTransformStart', coords, rowTransformDir, colTransformDir);
  4493. selection.setRangeStart(coords, keepEditorOpened);
  4494. },
  4495. transformEnd: function(rowDelta, colDelta) {
  4496. var delta = new WalkontableCellCoords(rowDelta, colDelta),
  4497. rowTransformDir = 0,
  4498. colTransformDir = 0,
  4499. totalRows,
  4500. totalCols,
  4501. coords;
  4502. instance.runHooks('modifyTransformEnd', delta);
  4503. totalRows = instance.countRows();
  4504. totalCols = instance.countCols();
  4505. coords = new WalkontableCellCoords(priv.selRange.to.row + delta.row, priv.selRange.to.col + delta.col);
  4506. if (coords.row < 0) {
  4507. rowTransformDir = -1;
  4508. coords.row = 0;
  4509. } else if (coords.row > 0 && coords.row >= totalRows) {
  4510. rowTransformDir = 1;
  4511. coords.row = totalRows - 1;
  4512. }
  4513. if (coords.col < 0) {
  4514. colTransformDir = -1;
  4515. coords.col = 0;
  4516. } else if (coords.col > 0 && coords.col >= totalCols) {
  4517. colTransformDir = 1;
  4518. coords.col = totalCols - 1;
  4519. }
  4520. instance.runHooks('afterModifyTransformEnd', coords, rowTransformDir, colTransformDir);
  4521. selection.setRangeEnd(coords, true);
  4522. },
  4523. isSelected: function() {
  4524. return (priv.selRange !== null);
  4525. },
  4526. inInSelection: function(coords) {
  4527. if (!selection.isSelected()) {
  4528. return false;
  4529. }
  4530. return priv.selRange.includes(coords);
  4531. },
  4532. deselect: function() {
  4533. if (!selection.isSelected()) {
  4534. return;
  4535. }
  4536. instance.selection.inProgress = false;
  4537. priv.selRange = null;
  4538. instance.view.wt.selections.current.clear();
  4539. instance.view.wt.selections.area.clear();
  4540. if (priv.settings.currentRowClassName || priv.settings.currentColClassName) {
  4541. instance.view.wt.selections.highlight.clear();
  4542. }
  4543. editorManager.destroyEditor();
  4544. selection.refreshBorders();
  4545. Handsontable.hooks.run(instance, 'afterDeselect');
  4546. },
  4547. selectAll: function() {
  4548. if (!priv.settings.multiSelect) {
  4549. return;
  4550. }
  4551. selection.setRangeStart(new WalkontableCellCoords(0, 0));
  4552. selection.setRangeEnd(new WalkontableCellCoords(instance.countRows() - 1, instance.countCols() - 1), false);
  4553. },
  4554. empty: function() {
  4555. if (!selection.isSelected()) {
  4556. return;
  4557. }
  4558. var topLeft = priv.selRange.getTopLeftCorner();
  4559. var bottomRight = priv.selRange.getBottomRightCorner();
  4560. var r,
  4561. c,
  4562. changes = [];
  4563. for (r = topLeft.row; r <= bottomRight.row; r++) {
  4564. for (c = topLeft.col; c <= bottomRight.col; c++) {
  4565. if (!instance.getCellMeta(r, c).readOnly) {
  4566. changes.push([r, c, '']);
  4567. }
  4568. }
  4569. }
  4570. instance.setDataAtCell(changes);
  4571. }
  4572. };
  4573. this.init = function() {
  4574. dataSource = new DataSource(instance, priv.settings.data);
  4575. Handsontable.hooks.run(instance, 'beforeInit');
  4576. if (Handsontable.mobileBrowser) {
  4577. addClass(instance.rootElement, 'mobile');
  4578. }
  4579. this.updateSettings(priv.settings, true);
  4580. this.view = new TableView(this);
  4581. editorManager = new EditorManager(instance, priv, selection, datamap);
  4582. this.forceFullRender = true;
  4583. Handsontable.hooks.run(instance, 'init');
  4584. this.view.render();
  4585. if (typeof priv.firstRun === 'object') {
  4586. Handsontable.hooks.run(instance, 'afterChange', priv.firstRun[0], priv.firstRun[1]);
  4587. priv.firstRun = false;
  4588. }
  4589. Handsontable.hooks.run(instance, 'afterInit');
  4590. };
  4591. function ValidatorsQueue() {
  4592. var resolved = false;
  4593. return {
  4594. validatorsInQueue: 0,
  4595. valid: true,
  4596. addValidatorToQueue: function() {
  4597. this.validatorsInQueue++;
  4598. resolved = false;
  4599. },
  4600. removeValidatorFormQueue: function() {
  4601. this.validatorsInQueue = this.validatorsInQueue - 1 < 0 ? 0 : this.validatorsInQueue - 1;
  4602. this.checkIfQueueIsEmpty();
  4603. },
  4604. onQueueEmpty: function(valid) {},
  4605. checkIfQueueIsEmpty: function() {
  4606. if (this.validatorsInQueue == 0 && resolved == false) {
  4607. resolved = true;
  4608. this.onQueueEmpty(this.valid);
  4609. }
  4610. }
  4611. };
  4612. }
  4613. function validateChanges(changes, source, callback) {
  4614. var waitingForValidator = new ValidatorsQueue();
  4615. waitingForValidator.onQueueEmpty = resolve;
  4616. for (var i = changes.length - 1; i >= 0; i--) {
  4617. if (changes[i] === null) {
  4618. changes.splice(i, 1);
  4619. } else {
  4620. var row = changes[i][0];
  4621. var col = datamap.propToCol(changes[i][1]);
  4622. var logicalCol = instance.runHooks('modifyCol', col);
  4623. var cellProperties = instance.getCellMeta(row, logicalCol);
  4624. if (cellProperties.type === 'numeric' && typeof changes[i][3] === 'string') {
  4625. if (changes[i][3].length > 0 && (/^-?[\d\s]*(\.|\,)?\d*$/.test(changes[i][3]) || cellProperties.format)) {
  4626. var len = changes[i][3].length;
  4627. if (typeof cellProperties.language == 'undefined') {
  4628. numeral.language('en');
  4629. } else if (changes[i][3].indexOf('.') === len - 3 && changes[i][3].indexOf(',') === -1) {
  4630. numeral.language('en');
  4631. } else {
  4632. numeral.language(cellProperties.language);
  4633. }
  4634. if (numeral.validate(changes[i][3])) {
  4635. changes[i][3] = numeral().unformat(changes[i][3]);
  4636. }
  4637. }
  4638. }
  4639. if (instance.getCellValidator(cellProperties)) {
  4640. waitingForValidator.addValidatorToQueue();
  4641. instance.validateCell(changes[i][3], cellProperties, (function(i, cellProperties) {
  4642. return function(result) {
  4643. if (typeof result !== 'boolean') {
  4644. throw new Error('Validation error: result is not boolean');
  4645. }
  4646. if (result === false && cellProperties.allowInvalid === false) {
  4647. changes.splice(i, 1);
  4648. cellProperties.valid = true;
  4649. --i;
  4650. }
  4651. waitingForValidator.removeValidatorFormQueue();
  4652. };
  4653. })(i, cellProperties), source);
  4654. }
  4655. }
  4656. }
  4657. waitingForValidator.checkIfQueueIsEmpty();
  4658. function resolve() {
  4659. var beforeChangeResult;
  4660. if (changes.length) {
  4661. beforeChangeResult = Handsontable.hooks.run(instance, 'beforeChange', changes, source);
  4662. if (typeof beforeChangeResult === 'function') {
  4663. console.warn('Your beforeChange callback returns a function. It\'s not supported since Handsontable 0.12.1 (and the returned function will not be executed).');
  4664. } else if (beforeChangeResult === false) {
  4665. changes.splice(0, changes.length);
  4666. }
  4667. }
  4668. callback();
  4669. }
  4670. }
  4671. function applyChanges(changes, source) {
  4672. var i = changes.length - 1;
  4673. if (i < 0) {
  4674. return;
  4675. }
  4676. for (; 0 <= i; i--) {
  4677. if (changes[i] === null) {
  4678. changes.splice(i, 1);
  4679. continue;
  4680. }
  4681. if (changes[i][2] == null && changes[i][3] == null) {
  4682. continue;
  4683. }
  4684. if (priv.settings.allowInsertRow) {
  4685. while (changes[i][0] > instance.countRows() - 1) {
  4686. datamap.createRow();
  4687. }
  4688. }
  4689. if (instance.dataType === 'array' && priv.settings.allowInsertColumn) {
  4690. while (datamap.propToCol(changes[i][1]) > instance.countCols() - 1) {
  4691. datamap.createCol();
  4692. }
  4693. }
  4694. datamap.set(changes[i][0], changes[i][1], changes[i][3]);
  4695. }
  4696. instance.forceFullRender = true;
  4697. grid.adjustRowsAndCols();
  4698. Handsontable.hooks.run(instance, 'beforeChangeRender', changes, source);
  4699. selection.refreshBorders(null, true);
  4700. instance.view.wt.wtOverlays.adjustElementsSize();
  4701. Handsontable.hooks.run(instance, 'afterChange', changes, source || 'edit');
  4702. }
  4703. this.validateCell = function(value, cellProperties, callback, source) {
  4704. var validator = instance.getCellValidator(cellProperties);
  4705. function done(valid) {
  4706. var col = cellProperties.physicalCol,
  4707. row = cellProperties.physicalRow,
  4708. td = instance.getCell(row, col, true);
  4709. if (td) {
  4710. instance.view.wt.wtSettings.settings.cellRenderer(row, col, td);
  4711. }
  4712. callback(valid);
  4713. }
  4714. if (Object.prototype.toString.call(validator) === '[object RegExp]') {
  4715. validator = (function(validator) {
  4716. return function(value, callback) {
  4717. callback(validator.test(value));
  4718. };
  4719. })(validator);
  4720. }
  4721. if (typeof validator == 'function') {
  4722. value = Handsontable.hooks.run(instance, 'beforeValidate', value, cellProperties.row, cellProperties.prop, source);
  4723. instance._registerTimeout(setTimeout(function() {
  4724. validator.call(cellProperties, value, function(valid) {
  4725. valid = Handsontable.hooks.run(instance, 'afterValidate', valid, value, cellProperties.row, cellProperties.prop, source);
  4726. cellProperties.valid = valid;
  4727. done(valid);
  4728. Handsontable.hooks.run(instance, 'postAfterValidate', valid, value, cellProperties.row, cellProperties.prop, source);
  4729. });
  4730. }, 0));
  4731. } else {
  4732. cellProperties.valid = true;
  4733. done(cellProperties.valid);
  4734. }
  4735. };
  4736. function setDataInputToArray(row, propOrCol, value) {
  4737. if (typeof row === 'object') {
  4738. return row;
  4739. } else {
  4740. return [[row, propOrCol, value]];
  4741. }
  4742. }
  4743. this.setDataAtCell = function(row, col, value, source) {
  4744. var input = setDataInputToArray(row, col, value),
  4745. i,
  4746. ilen,
  4747. changes = [],
  4748. prop;
  4749. for (i = 0, ilen = input.length; i < ilen; i++) {
  4750. if (typeof input[i] !== 'object') {
  4751. throw new Error('Method `setDataAtCell` accepts row number or changes array of arrays as its first parameter');
  4752. }
  4753. if (typeof input[i][1] !== 'number') {
  4754. throw new Error('Method `setDataAtCell` accepts row and column number as its parameters. If you want to use object property name, use method `setDataAtRowProp`');
  4755. }
  4756. prop = datamap.colToProp(input[i][1]);
  4757. changes.push([input[i][0], prop, datamap.get(input[i][0], prop), input[i][2]]);
  4758. }
  4759. if (!source && typeof row === 'object') {
  4760. source = col;
  4761. }
  4762. validateChanges(changes, source, function() {
  4763. applyChanges(changes, source);
  4764. });
  4765. };
  4766. this.setDataAtRowProp = function(row, prop, value, source) {
  4767. var input = setDataInputToArray(row, prop, value),
  4768. i,
  4769. ilen,
  4770. changes = [];
  4771. for (i = 0, ilen = input.length; i < ilen; i++) {
  4772. changes.push([input[i][0], input[i][1], datamap.get(input[i][0], input[i][1]), input[i][2]]);
  4773. }
  4774. if (!source && typeof row === 'object') {
  4775. source = prop;
  4776. }
  4777. validateChanges(changes, source, function() {
  4778. applyChanges(changes, source);
  4779. });
  4780. };
  4781. this.listen = function() {
  4782. Handsontable.activeGuid = instance.guid;
  4783. };
  4784. this.unlisten = function() {
  4785. Handsontable.activeGuid = null;
  4786. };
  4787. this.isListening = function() {
  4788. return Handsontable.activeGuid === instance.guid;
  4789. };
  4790. this.destroyEditor = function(revertOriginal) {
  4791. selection.refreshBorders(revertOriginal);
  4792. };
  4793. this.populateFromArray = function(row, col, input, endRow, endCol, source, method, direction, deltas) {
  4794. var c;
  4795. if (!(typeof input === 'object' && typeof input[0] === 'object')) {
  4796. throw new Error('populateFromArray parameter `input` must be an array of arrays');
  4797. }
  4798. c = typeof endRow === 'number' ? new WalkontableCellCoords(endRow, endCol) : null;
  4799. return grid.populateFromArray(new WalkontableCellCoords(row, col), input, c, source, method, direction, deltas);
  4800. };
  4801. this.spliceCol = function(col, index, amount) {
  4802. return datamap.spliceCol.apply(datamap, arguments);
  4803. };
  4804. this.spliceRow = function(row, index, amount) {
  4805. return datamap.spliceRow.apply(datamap, arguments);
  4806. };
  4807. this.getSelected = function() {
  4808. if (selection.isSelected()) {
  4809. return [priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col];
  4810. }
  4811. };
  4812. this.getSelectedRange = function() {
  4813. if (selection.isSelected()) {
  4814. return priv.selRange;
  4815. }
  4816. };
  4817. this.render = function() {
  4818. if (instance.view) {
  4819. instance.renderCall = true;
  4820. instance.forceFullRender = true;
  4821. selection.refreshBorders(null, true);
  4822. }
  4823. };
  4824. this.loadData = function(data) {
  4825. if (typeof data === 'object' && data !== null) {
  4826. if (!(data.push && data.splice)) {
  4827. data = [data];
  4828. }
  4829. } else if (data === null) {
  4830. data = [];
  4831. var row;
  4832. for (var r = 0,
  4833. rlen = priv.settings.startRows; r < rlen; r++) {
  4834. row = [];
  4835. for (var c = 0,
  4836. clen = priv.settings.startCols; c < clen; c++) {
  4837. row.push(null);
  4838. }
  4839. data.push(row);
  4840. }
  4841. } else {
  4842. throw new Error('loadData only accepts array of objects or array of arrays (' + typeof data + ' given)');
  4843. }
  4844. priv.isPopulated = false;
  4845. GridSettings.prototype.data = data;
  4846. if (Array.isArray(priv.settings.dataSchema) || Array.isArray(data[0])) {
  4847. instance.dataType = 'array';
  4848. } else if (typeof priv.settings.dataSchema === 'function') {
  4849. instance.dataType = 'function';
  4850. } else {
  4851. instance.dataType = 'object';
  4852. }
  4853. datamap = new DataMap(instance, priv, GridSettings);
  4854. dataSource.data = data;
  4855. dataSource.dataType = instance.dataType;
  4856. dataSource.colToProp = datamap.colToProp.bind(datamap);
  4857. dataSource.propToCol = datamap.propToCol.bind(datamap);
  4858. clearCellSettingCache();
  4859. grid.adjustRowsAndCols();
  4860. Handsontable.hooks.run(instance, 'afterLoadData', priv.firstRun);
  4861. if (priv.firstRun) {
  4862. priv.firstRun = [null, 'loadData'];
  4863. } else {
  4864. Handsontable.hooks.run(instance, 'afterChange', null, 'loadData');
  4865. instance.render();
  4866. }
  4867. priv.isPopulated = true;
  4868. function clearCellSettingCache() {
  4869. priv.cellSettings.length = 0;
  4870. }
  4871. };
  4872. this.getData = function(r, c, r2, c2) {
  4873. if (typeof r === 'undefined') {
  4874. return datamap.getAll();
  4875. } else {
  4876. return datamap.getRange(new WalkontableCellCoords(r, c), new WalkontableCellCoords(r2, c2), datamap.DESTINATION_RENDERER);
  4877. }
  4878. };
  4879. this.getCopyableText = function(startRow, startCol, endRow, endCol) {
  4880. return datamap.getCopyableText(new WalkontableCellCoords(startRow, startCol), new WalkontableCellCoords(endRow, endCol));
  4881. };
  4882. this.getCopyableData = function(row, column) {
  4883. return datamap.getCopyable(row, datamap.colToProp(column));
  4884. };
  4885. this.getSchema = function() {
  4886. return datamap.getSchema();
  4887. };
  4888. this.updateSettings = function(settings, init) {
  4889. var i,
  4890. clen;
  4891. if (typeof settings.rows !== 'undefined') {
  4892. throw new Error('"rows" setting is no longer supported. do you mean startRows, minRows or maxRows?');
  4893. }
  4894. if (typeof settings.cols !== 'undefined') {
  4895. throw new Error('"cols" setting is no longer supported. do you mean startCols, minCols or maxCols?');
  4896. }
  4897. for (i in settings) {
  4898. if (i === 'data') {
  4899. continue;
  4900. } else {
  4901. if (Handsontable.hooks.getRegistered().indexOf(i) > -1) {
  4902. if (typeof settings[i] === 'function' || Array.isArray(settings[i])) {
  4903. instance.addHook(i, settings[i]);
  4904. }
  4905. } else {
  4906. if (!init && settings.hasOwnProperty(i)) {
  4907. GridSettings.prototype[i] = settings[i];
  4908. }
  4909. }
  4910. }
  4911. }
  4912. if (settings.data === void 0 && priv.settings.data === void 0) {
  4913. instance.loadData(null);
  4914. } else if (settings.data !== void 0) {
  4915. instance.loadData(settings.data);
  4916. } else if (settings.columns !== void 0) {
  4917. datamap.createMap();
  4918. }
  4919. clen = instance.countCols();
  4920. priv.cellSettings.length = 0;
  4921. if (clen > 0) {
  4922. var proto,
  4923. column;
  4924. for (i = 0; i < clen; i++) {
  4925. priv.columnSettings[i] = columnFactory(GridSettings, priv.columnsSettingConflicts);
  4926. proto = priv.columnSettings[i].prototype;
  4927. if (GridSettings.prototype.columns) {
  4928. column = GridSettings.prototype.columns[i];
  4929. extend(proto, column);
  4930. extend(proto, expandType(column));
  4931. }
  4932. }
  4933. }
  4934. if (typeof settings.cell !== 'undefined') {
  4935. for (i in settings.cell) {
  4936. if (settings.cell.hasOwnProperty(i)) {
  4937. var cell = settings.cell[i];
  4938. instance.setCellMetaObject(cell.row, cell.col, cell);
  4939. }
  4940. }
  4941. }
  4942. Handsontable.hooks.run(instance, 'afterCellMetaReset');
  4943. if (typeof settings.className !== 'undefined') {
  4944. if (GridSettings.prototype.className) {
  4945. removeClass(instance.rootElement, GridSettings.prototype.className);
  4946. }
  4947. if (settings.className) {
  4948. addClass(instance.rootElement, settings.className);
  4949. }
  4950. }
  4951. if (typeof settings.height != 'undefined') {
  4952. var height = settings.height;
  4953. if (typeof height == 'function') {
  4954. height = height();
  4955. }
  4956. instance.rootElement.style.height = height + 'px';
  4957. }
  4958. if (typeof settings.width != 'undefined') {
  4959. var width = settings.width;
  4960. if (typeof width == 'function') {
  4961. width = width();
  4962. }
  4963. instance.rootElement.style.width = width + 'px';
  4964. }
  4965. if (height) {
  4966. instance.rootElement.style.overflow = 'hidden';
  4967. }
  4968. if (!init) {
  4969. Handsontable.hooks.run(instance, 'afterUpdateSettings');
  4970. }
  4971. grid.adjustRowsAndCols();
  4972. if (instance.view && !priv.firstRun) {
  4973. instance.forceFullRender = true;
  4974. selection.refreshBorders(null, true);
  4975. }
  4976. };
  4977. this.getValue = function() {
  4978. var sel = instance.getSelected();
  4979. if (GridSettings.prototype.getValue) {
  4980. if (typeof GridSettings.prototype.getValue === 'function') {
  4981. return GridSettings.prototype.getValue.call(instance);
  4982. } else if (sel) {
  4983. return instance.getData()[sel[0]][GridSettings.prototype.getValue];
  4984. }
  4985. } else if (sel) {
  4986. return instance.getDataAtCell(sel[0], sel[1]);
  4987. }
  4988. };
  4989. function expandType(obj) {
  4990. if (!obj.hasOwnProperty('type')) {
  4991. return;
  4992. }
  4993. var type,
  4994. expandedType = {};
  4995. if (typeof obj.type === 'object') {
  4996. type = obj.type;
  4997. } else if (typeof obj.type === 'string') {
  4998. type = Handsontable.cellTypes[obj.type];
  4999. if (type === void 0) {
  5000. throw new Error('You declared cell type "' + obj.type + '" as a string that is not mapped to a known object. Cell type must be an object or a string mapped to an object in Handsontable.cellTypes');
  5001. }
  5002. }
  5003. for (var i in type) {
  5004. if (type.hasOwnProperty(i) && !obj.hasOwnProperty(i)) {
  5005. expandedType[i] = type[i];
  5006. }
  5007. }
  5008. return expandedType;
  5009. }
  5010. this.getSettings = function() {
  5011. return priv.settings;
  5012. };
  5013. this.clear = function() {
  5014. selection.selectAll();
  5015. selection.empty();
  5016. };
  5017. this.alter = function(action, index, amount, source, keepEmptyRows) {
  5018. grid.alter(action, index, amount, source, keepEmptyRows);
  5019. };
  5020. this.getCell = function(row, col, topmost) {
  5021. return instance.view.getCellAtCoords(new WalkontableCellCoords(row, col), topmost);
  5022. };
  5023. this.getCoords = function(elem) {
  5024. return this.view.wt.wtTable.getCoords.call(this.view.wt.wtTable, elem);
  5025. };
  5026. this.colToProp = function(col) {
  5027. return datamap.colToProp(col);
  5028. };
  5029. this.propToCol = function(prop) {
  5030. return datamap.propToCol(prop);
  5031. };
  5032. this.getDataAtCell = function(row, col) {
  5033. return datamap.get(row, datamap.colToProp(col));
  5034. };
  5035. this.getDataAtRowProp = function(row, prop) {
  5036. return datamap.get(row, prop);
  5037. };
  5038. this.getDataAtCol = function(col) {
  5039. var out = [];
  5040. return out.concat.apply(out, datamap.getRange(new WalkontableCellCoords(0, col), new WalkontableCellCoords(priv.settings.data.length - 1, col), datamap.DESTINATION_RENDERER));
  5041. };
  5042. this.getDataAtProp = function(prop) {
  5043. var out = [],
  5044. range;
  5045. range = datamap.getRange(new WalkontableCellCoords(0, datamap.propToCol(prop)), new WalkontableCellCoords(priv.settings.data.length - 1, datamap.propToCol(prop)), datamap.DESTINATION_RENDERER);
  5046. return out.concat.apply(out, range);
  5047. };
  5048. this.getSourceData = function(r, c, r2, c2) {
  5049. var data;
  5050. if (r === void 0) {
  5051. data = dataSource.getData();
  5052. } else {
  5053. data = dataSource.getByRange(new WalkontableCellCoords(r, c), new WalkontableCellCoords(r2, c2));
  5054. }
  5055. return data;
  5056. };
  5057. this.getSourceDataAtCol = function(column) {
  5058. return dataSource.getAtColumn(column);
  5059. };
  5060. this.getSourceDataAtRow = function(row) {
  5061. return dataSource.getAtRow(row);
  5062. };
  5063. this.getSourceDataAtCell = function(row, column) {
  5064. return dataSource.getAtCell(row, column);
  5065. };
  5066. this.getDataAtRow = function(row) {
  5067. var data = datamap.getRange(new WalkontableCellCoords(row, 0), new WalkontableCellCoords(row, this.countCols() - 1), datamap.DESTINATION_RENDERER);
  5068. return data[0];
  5069. };
  5070. this.getDataType = function(rowFrom, columnFrom, rowTo, columnTo) {
  5071. var $__19 = this;
  5072. var previousType = null;
  5073. var currentType = null;
  5074. if (rowFrom === void 0) {
  5075. rowFrom = 0;
  5076. rowTo = this.countRows();
  5077. columnFrom = 0;
  5078. columnTo = this.countCols();
  5079. }
  5080. if (rowTo === void 0) {
  5081. rowTo = rowFrom;
  5082. }
  5083. if (columnTo === void 0) {
  5084. columnTo = columnFrom;
  5085. }
  5086. var type = 'mixed';
  5087. rangeEach(Math.min(rowFrom, rowTo), Math.max(rowFrom, rowTo), (function(row) {
  5088. var isTypeEqual = true;
  5089. rangeEach(Math.min(columnFrom, columnTo), Math.max(columnFrom, columnTo), (function(column) {
  5090. var cellType = $__19.getCellMeta(row, column);
  5091. currentType = cellType.type;
  5092. if (previousType) {
  5093. isTypeEqual = previousType === currentType;
  5094. } else {
  5095. previousType = currentType;
  5096. }
  5097. return isTypeEqual;
  5098. }));
  5099. type = isTypeEqual ? currentType : 'mixed';
  5100. return isTypeEqual;
  5101. }));
  5102. return type;
  5103. };
  5104. this.removeCellMeta = function(row, col, key) {
  5105. var cellMeta = instance.getCellMeta(row, col);
  5106. if (cellMeta[key] != undefined) {
  5107. delete priv.cellSettings[row][col][key];
  5108. }
  5109. };
  5110. this.setCellMetaObject = function(row, col, prop) {
  5111. if (typeof prop === 'object') {
  5112. for (var key in prop) {
  5113. if (prop.hasOwnProperty(key)) {
  5114. var value = prop[key];
  5115. this.setCellMeta(row, col, key, value);
  5116. }
  5117. }
  5118. }
  5119. };
  5120. this.setCellMeta = function(row, col, key, val) {
  5121. if (!priv.cellSettings[row]) {
  5122. priv.cellSettings[row] = [];
  5123. }
  5124. if (!priv.cellSettings[row][col]) {
  5125. priv.cellSettings[row][col] = new priv.columnSettings[col]();
  5126. }
  5127. priv.cellSettings[row][col][key] = val;
  5128. Handsontable.hooks.run(instance, 'afterSetCellMeta', row, col, key, val);
  5129. };
  5130. this.getCellsMeta = function() {
  5131. return arrayFlatten(priv.cellSettings);
  5132. };
  5133. this.getCellMeta = function(row, col) {
  5134. var prop = datamap.colToProp(col),
  5135. cellProperties;
  5136. var physicalRow = row;
  5137. var physicalCol = col;
  5138. row = translateRowIndex(row);
  5139. col = translateColIndex(col);
  5140. if (!priv.columnSettings[col]) {
  5141. priv.columnSettings[col] = columnFactory(GridSettings, priv.columnsSettingConflicts);
  5142. }
  5143. if (!priv.cellSettings[row]) {
  5144. priv.cellSettings[row] = [];
  5145. }
  5146. if (!priv.cellSettings[row][col]) {
  5147. priv.cellSettings[row][col] = new priv.columnSettings[col]();
  5148. }
  5149. cellProperties = priv.cellSettings[row][col];
  5150. cellProperties.row = row;
  5151. cellProperties.col = col;
  5152. cellProperties.physicalRow = physicalRow;
  5153. cellProperties.physicalCol = physicalCol;
  5154. cellProperties.prop = prop;
  5155. cellProperties.instance = instance;
  5156. Handsontable.hooks.run(instance, 'beforeGetCellMeta', row, col, cellProperties);
  5157. extend(cellProperties, expandType(cellProperties));
  5158. if (cellProperties.cells) {
  5159. var settings = cellProperties.cells.call(cellProperties, row, col, prop);
  5160. if (settings) {
  5161. extend(cellProperties, settings);
  5162. extend(cellProperties, expandType(settings));
  5163. }
  5164. }
  5165. Handsontable.hooks.run(instance, 'afterGetCellMeta', row, col, cellProperties);
  5166. return cellProperties;
  5167. };
  5168. this.isColumnModificationAllowed = function() {
  5169. return !(instance.dataType === 'object' || instance.getSettings().columns);
  5170. };
  5171. function translateRowIndex(row) {
  5172. return Handsontable.hooks.run(instance, 'modifyRow', row);
  5173. }
  5174. function translateColIndex(col) {
  5175. return Handsontable.hooks.run(instance, 'modifyCol', col);
  5176. }
  5177. var rendererLookup = cellMethodLookupFactory('renderer');
  5178. this.getCellRenderer = function(row, col) {
  5179. var renderer = rendererLookup.call(this, row, col);
  5180. return getRenderer(renderer);
  5181. };
  5182. this.getCellEditor = cellMethodLookupFactory('editor');
  5183. this.getCellValidator = cellMethodLookupFactory('validator');
  5184. this.validateCells = function(callback) {
  5185. var waitingForValidator = new ValidatorsQueue();
  5186. waitingForValidator.onQueueEmpty = callback;
  5187. var i = instance.countRows() - 1;
  5188. while (i >= 0) {
  5189. var j = instance.countCols() - 1;
  5190. while (j >= 0) {
  5191. waitingForValidator.addValidatorToQueue();
  5192. instance.validateCell(instance.getDataAtCell(i, j), instance.getCellMeta(i, j), function(result) {
  5193. if (typeof result !== 'boolean') {
  5194. throw new Error('Validation error: result is not boolean');
  5195. }
  5196. if (result === false) {
  5197. waitingForValidator.valid = false;
  5198. }
  5199. waitingForValidator.removeValidatorFormQueue();
  5200. }, 'validateCells');
  5201. j--;
  5202. }
  5203. i--;
  5204. }
  5205. waitingForValidator.checkIfQueueIsEmpty();
  5206. };
  5207. this.getRowHeader = function(row) {
  5208. var rowHeader = priv.settings.rowHeaders;
  5209. if (row !== void 0) {
  5210. row = Handsontable.hooks.run(instance, 'modifyRowHeader', row);
  5211. }
  5212. if (row === void 0) {
  5213. rowHeader = [];
  5214. rangeEach(instance.countRows() - 1, (function(i) {
  5215. rowHeader.push(instance.getRowHeader(i));
  5216. }));
  5217. } else if (Array.isArray(rowHeader) && rowHeader[row] !== void 0) {
  5218. rowHeader = rowHeader[row];
  5219. } else if (typeof rowHeader === 'function') {
  5220. rowHeader = rowHeader(row);
  5221. } else if (rowHeader && typeof rowHeader !== 'string' && typeof rowHeader !== 'number') {
  5222. rowHeader = row + 1;
  5223. }
  5224. return rowHeader;
  5225. };
  5226. this.hasRowHeaders = function() {
  5227. return !!priv.settings.rowHeaders;
  5228. };
  5229. this.hasColHeaders = function() {
  5230. if (priv.settings.colHeaders !== void 0 && priv.settings.colHeaders !== null) {
  5231. return !!priv.settings.colHeaders;
  5232. }
  5233. for (var i = 0,
  5234. ilen = instance.countCols(); i < ilen; i++) {
  5235. if (instance.getColHeader(i)) {
  5236. return true;
  5237. }
  5238. }
  5239. return false;
  5240. };
  5241. this.getColHeader = function(col) {
  5242. col = Handsontable.hooks.run(instance, 'modifyColHeader', col);
  5243. if (col === void 0) {
  5244. var out = [];
  5245. for (var i = 0,
  5246. ilen = instance.countCols(); i < ilen; i++) {
  5247. out.push(instance.getColHeader(i));
  5248. }
  5249. return out;
  5250. } else {
  5251. var baseCol = col;
  5252. col = Handsontable.hooks.run(instance, 'modifyCol', col);
  5253. if (priv.settings.columns && priv.settings.columns[col] && priv.settings.columns[col].title) {
  5254. return priv.settings.columns[col].title;
  5255. } else if (Array.isArray(priv.settings.colHeaders) && priv.settings.colHeaders[col] !== void 0) {
  5256. return priv.settings.colHeaders[col];
  5257. } else if (typeof priv.settings.colHeaders === 'function') {
  5258. return priv.settings.colHeaders(col);
  5259. } else if (priv.settings.colHeaders && typeof priv.settings.colHeaders !== 'string' && typeof priv.settings.colHeaders !== 'number') {
  5260. return spreadsheetColumnLabel(baseCol);
  5261. } else {
  5262. return priv.settings.colHeaders;
  5263. }
  5264. }
  5265. };
  5266. this._getColWidthFromSettings = function(col) {
  5267. var cellProperties = instance.getCellMeta(0, col);
  5268. var width = cellProperties.width;
  5269. if (width === void 0 || width === priv.settings.width) {
  5270. width = cellProperties.colWidths;
  5271. }
  5272. if (width !== void 0 && width !== null) {
  5273. switch (typeof width) {
  5274. case 'object':
  5275. width = width[col];
  5276. break;
  5277. case 'function':
  5278. width = width(col);
  5279. break;
  5280. }
  5281. if (typeof width === 'string') {
  5282. width = parseInt(width, 10);
  5283. }
  5284. }
  5285. return width;
  5286. };
  5287. this.getColWidth = function(col) {
  5288. var width = instance._getColWidthFromSettings(col);
  5289. width = Handsontable.hooks.run(instance, 'modifyColWidth', width, col);
  5290. if (width === void 0) {
  5291. width = WalkontableViewportColumnsCalculator.DEFAULT_WIDTH;
  5292. }
  5293. return width;
  5294. };
  5295. this._getRowHeightFromSettings = function(row) {
  5296. var height = priv.settings.rowHeights;
  5297. if (height !== void 0 && height !== null) {
  5298. switch (typeof height) {
  5299. case 'object':
  5300. height = height[row];
  5301. break;
  5302. case 'function':
  5303. height = height(row);
  5304. break;
  5305. }
  5306. if (typeof height === 'string') {
  5307. height = parseInt(height, 10);
  5308. }
  5309. }
  5310. return height;
  5311. };
  5312. this.getRowHeight = function(row) {
  5313. var height = instance._getRowHeightFromSettings(row);
  5314. height = Handsontable.hooks.run(instance, 'modifyRowHeight', height, row);
  5315. return height;
  5316. };
  5317. this.countSourceRows = function() {
  5318. return instance.getSourceData() ? instance.getSourceData().length : 0;
  5319. };
  5320. this.countRows = function() {
  5321. return datamap.getLength();
  5322. };
  5323. this.countCols = function() {
  5324. if (instance.dataType === 'object' || instance.dataType === 'function') {
  5325. if (priv.settings.columns && priv.settings.columns.length) {
  5326. return priv.settings.columns.length;
  5327. } else {
  5328. return datamap.colToPropCache.length;
  5329. }
  5330. } else if (instance.dataType === 'array') {
  5331. if (priv.settings.columns && priv.settings.columns.length) {
  5332. return priv.settings.columns.length;
  5333. } else if (priv.settings.data && priv.settings.data[0] && priv.settings.data[0].length) {
  5334. return priv.settings.data[0].length;
  5335. } else {
  5336. return 0;
  5337. }
  5338. }
  5339. };
  5340. this.getColspanOffset = function(col, level) {
  5341. var colspanSum = 0;
  5342. if (instance.colspanArray) {
  5343. for (var i = 0; i < col; i++) {
  5344. colspanSum += instance.colspanArray[level][i] - 1 || 0;
  5345. }
  5346. return colspanSum;
  5347. }
  5348. var colspanSum = 0;
  5349. var TRindex = instance.view.wt.wtTable.THEAD.childNodes.length - level - 1;
  5350. var TR = instance.view.wt.wtTable.THEAD.querySelector('tr:nth-child(' + parseInt(TRindex + 1, 10) + ')');
  5351. var rowHeadersCount = instance.view.wt.wtSettings.settings.rowHeaders().length;
  5352. for (var i = rowHeadersCount; i < rowHeadersCount + col; i++) {
  5353. if (TR.childNodes[i].hasAttribute('colspan')) {
  5354. colspanSum += parseInt(TR.childNodes[i].getAttribute('colspan'), 10) - 1;
  5355. }
  5356. }
  5357. return colspanSum;
  5358. };
  5359. this.getHeaderColspan = function(col, level) {
  5360. var TRindex = instance.view.wt.wtTable.THEAD.childNodes.length - level - 1;
  5361. var rowHeadersCount = instance.view.wt.wtSettings.settings.rowHeaders().length;
  5362. var TR = instance.view.wt.wtTable.THEAD.querySelector('tr:nth-child(' + parseInt(TRindex + 1, 10) + ')');
  5363. var offsettedColIndex = rowHeadersCount + col - instance.view.wt.wtViewport.columnsRenderCalculator.startColumn;
  5364. if (TR.childNodes[offsettedColIndex].hasAttribute('colspan')) {
  5365. return parseInt(TR.childNodes[offsettedColIndex].getAttribute('colspan'), 10);
  5366. }
  5367. return 0;
  5368. };
  5369. this.rowOffset = function() {
  5370. return instance.view.wt.wtTable.getFirstRenderedRow();
  5371. };
  5372. this.colOffset = function() {
  5373. return instance.view.wt.wtTable.getFirstRenderedColumn();
  5374. };
  5375. this.countRenderedRows = function() {
  5376. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedRowsCount() : -1;
  5377. };
  5378. this.countVisibleRows = function() {
  5379. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleRowsCount() : -1;
  5380. };
  5381. this.countRenderedCols = function() {
  5382. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedColumnsCount() : -1;
  5383. };
  5384. this.countVisibleCols = function() {
  5385. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleColumnsCount() : -1;
  5386. };
  5387. this.countEmptyRows = function(ending) {
  5388. var i = instance.countRows() - 1,
  5389. empty = 0,
  5390. row;
  5391. while (i >= 0) {
  5392. row = Handsontable.hooks.run(this, 'modifyRow', i);
  5393. if (instance.isEmptyRow(row)) {
  5394. empty++;
  5395. } else if (ending) {
  5396. break;
  5397. }
  5398. i--;
  5399. }
  5400. return empty;
  5401. };
  5402. this.countEmptyCols = function(ending) {
  5403. if (instance.countRows() < 1) {
  5404. return 0;
  5405. }
  5406. var i = instance.countCols() - 1,
  5407. empty = 0;
  5408. while (i >= 0) {
  5409. if (instance.isEmptyCol(i)) {
  5410. empty++;
  5411. } else if (ending) {
  5412. break;
  5413. }
  5414. i--;
  5415. }
  5416. return empty;
  5417. };
  5418. this.isEmptyRow = function(row) {
  5419. return priv.settings.isEmptyRow.call(instance, row);
  5420. };
  5421. this.isEmptyCol = function(col) {
  5422. return priv.settings.isEmptyCol.call(instance, col);
  5423. };
  5424. this.selectCell = function(row, col, endRow, endCol, scrollToCell, changeListener) {
  5425. var coords;
  5426. changeListener = typeof changeListener === 'undefined' || changeListener === true;
  5427. if (typeof row !== 'number' || row < 0 || row >= instance.countRows()) {
  5428. return false;
  5429. }
  5430. if (typeof col !== 'number' || col < 0 || col >= instance.countCols()) {
  5431. return false;
  5432. }
  5433. if (typeof endRow !== 'undefined') {
  5434. if (typeof endRow !== 'number' || endRow < 0 || endRow >= instance.countRows()) {
  5435. return false;
  5436. }
  5437. if (typeof endCol !== 'number' || endCol < 0 || endCol >= instance.countCols()) {
  5438. return false;
  5439. }
  5440. }
  5441. coords = new WalkontableCellCoords(row, col);
  5442. priv.selRange = new WalkontableCellRange(coords, coords, coords);
  5443. if (changeListener) {
  5444. instance.listen();
  5445. }
  5446. if (typeof endRow === 'undefined') {
  5447. selection.setRangeEnd(priv.selRange.from, scrollToCell);
  5448. } else {
  5449. selection.setRangeEnd(new WalkontableCellCoords(endRow, endCol), scrollToCell);
  5450. }
  5451. instance.selection.finish();
  5452. return true;
  5453. };
  5454. this.selectCellByProp = function(row, prop, endRow, endProp, scrollToCell) {
  5455. arguments[1] = datamap.propToCol(arguments[1]);
  5456. if (typeof arguments[3] !== 'undefined') {
  5457. arguments[3] = datamap.propToCol(arguments[3]);
  5458. }
  5459. return instance.selectCell.apply(instance, arguments);
  5460. };
  5461. this.deselectCell = function() {
  5462. selection.deselect();
  5463. };
  5464. this.destroy = function() {
  5465. instance._clearTimeouts();
  5466. if (instance.view) {
  5467. instance.view.destroy();
  5468. }
  5469. if (dataSource) {
  5470. dataSource.destroy();
  5471. }
  5472. dataSource = null;
  5473. empty(instance.rootElement);
  5474. eventManager.destroy();
  5475. Handsontable.hooks.run(instance, 'afterDestroy');
  5476. Handsontable.hooks.destroy(instance);
  5477. for (var i in instance) {
  5478. if (instance.hasOwnProperty(i)) {
  5479. if (typeof instance[i] === 'function') {
  5480. instance[i] = postMortem;
  5481. } else if (i !== 'guid') {
  5482. instance[i] = null;
  5483. }
  5484. }
  5485. }
  5486. priv = null;
  5487. datamap = null;
  5488. grid = null;
  5489. selection = null;
  5490. editorManager = null;
  5491. instance = null;
  5492. GridSettings = null;
  5493. };
  5494. function postMortem() {
  5495. throw new Error('This method cannot be called because this Handsontable instance has been destroyed');
  5496. }
  5497. this.getActiveEditor = function() {
  5498. return editorManager.getActiveEditor();
  5499. };
  5500. this.getPlugin = function(pluginName) {
  5501. return getPlugin(this, pluginName);
  5502. };
  5503. this.getInstance = function() {
  5504. return instance;
  5505. };
  5506. this.addHook = function(key, callback) {
  5507. Handsontable.hooks.add(key, callback, instance);
  5508. };
  5509. this.hasHook = function(key) {
  5510. return Handsontable.hooks.has(key, instance);
  5511. };
  5512. this.addHookOnce = function(key, callback) {
  5513. Handsontable.hooks.once(key, callback, instance);
  5514. };
  5515. this.removeHook = function(key, callback) {
  5516. Handsontable.hooks.remove(key, callback, instance);
  5517. };
  5518. this.runHooks = function(key, p1, p2, p3, p4, p5, p6) {
  5519. return Handsontable.hooks.run(instance, key, p1, p2, p3, p4, p5, p6);
  5520. };
  5521. this.timeouts = [];
  5522. this._registerTimeout = function(handle) {
  5523. this.timeouts.push(handle);
  5524. };
  5525. this._clearTimeouts = function() {
  5526. for (var i = 0,
  5527. ilen = this.timeouts.length; i < ilen; i++) {
  5528. clearTimeout(this.timeouts[i]);
  5529. }
  5530. };
  5531. this.version = Handsontable.version;
  5532. Handsontable.hooks.run(instance, 'construct');
  5533. };
  5534. var DefaultSettings = function() {};
  5535. DefaultSettings.prototype = {
  5536. data: void 0,
  5537. dataSchema: void 0,
  5538. width: void 0,
  5539. height: void 0,
  5540. startRows: 5,
  5541. startCols: 5,
  5542. rowHeaders: null,
  5543. colHeaders: null,
  5544. colWidths: void 0,
  5545. rowHeights: void 0,
  5546. columns: void 0,
  5547. cells: void 0,
  5548. cell: [],
  5549. comments: false,
  5550. customBorders: false,
  5551. minRows: 0,
  5552. minCols: 0,
  5553. maxRows: Infinity,
  5554. maxCols: Infinity,
  5555. minSpareRows: 0,
  5556. minSpareCols: 0,
  5557. allowInsertRow: true,
  5558. allowInsertColumn: true,
  5559. allowRemoveRow: true,
  5560. allowRemoveColumn: true,
  5561. multiSelect: true,
  5562. fillHandle: true,
  5563. fixedRowsTop: 0,
  5564. fixedRowsBottom: 0,
  5565. fixedColumnsLeft: 0,
  5566. outsideClickDeselects: true,
  5567. enterBeginsEditing: true,
  5568. enterMoves: {
  5569. row: 1,
  5570. col: 0
  5571. },
  5572. tabMoves: {
  5573. row: 0,
  5574. col: 1
  5575. },
  5576. autoWrapRow: false,
  5577. autoWrapCol: false,
  5578. copyRowsLimit: 1000,
  5579. copyColsLimit: 1000,
  5580. pasteMode: 'overwrite',
  5581. persistentState: false,
  5582. currentRowClassName: void 0,
  5583. currentColClassName: void 0,
  5584. className: void 0,
  5585. tableClassName: void 0,
  5586. stretchH: 'none',
  5587. isEmptyRow: function(row) {
  5588. var col,
  5589. colLen,
  5590. value,
  5591. meta;
  5592. for (col = 0, colLen = this.countCols(); col < colLen; col++) {
  5593. value = this.getDataAtCell(row, col);
  5594. if (value !== '' && value !== null && typeof value !== 'undefined') {
  5595. if (typeof value === 'object') {
  5596. meta = this.getCellMeta(row, col);
  5597. return isObjectEquals(this.getSchema()[meta.prop], value);
  5598. }
  5599. return false;
  5600. }
  5601. }
  5602. return true;
  5603. },
  5604. isEmptyCol: function(col) {
  5605. var row,
  5606. rowLen,
  5607. value;
  5608. for (row = 0, rowLen = this.countRows(); row < rowLen; row++) {
  5609. value = this.getDataAtCell(row, col);
  5610. if (value !== '' && value !== null && typeof value !== 'undefined') {
  5611. return false;
  5612. }
  5613. }
  5614. return true;
  5615. },
  5616. observeDOMVisibility: true,
  5617. allowInvalid: true,
  5618. invalidCellClassName: 'htInvalid',
  5619. placeholder: false,
  5620. placeholderCellClassName: 'htPlaceholder',
  5621. readOnlyCellClassName: 'htDimmed',
  5622. renderer: void 0,
  5623. commentedCellClassName: 'htCommentCell',
  5624. fragmentSelection: false,
  5625. readOnly: false,
  5626. skipColumnOnPaste: false,
  5627. search: false,
  5628. type: 'text',
  5629. copyable: true,
  5630. editor: void 0,
  5631. autoComplete: void 0,
  5632. visibleRows: 10,
  5633. trimDropdown: true,
  5634. debug: false,
  5635. wordWrap: true,
  5636. noWordWrapClassName: 'htNoWrap',
  5637. contextMenu: void 0,
  5638. contextMenuCopyPaste: void 0,
  5639. copyPaste: void 0,
  5640. undo: void 0,
  5641. columnSorting: void 0,
  5642. manualColumnMove: void 0,
  5643. manualColumnResize: void 0,
  5644. manualRowMove: void 0,
  5645. manualRowResize: void 0,
  5646. mergeCells: false,
  5647. viewportRowRenderingOffset: 'auto',
  5648. viewportColumnRenderingOffset: 'auto',
  5649. validator: void 0,
  5650. disableVisualSelection: false,
  5651. sortIndicator: false,
  5652. manualColumnFreeze: void 0,
  5653. trimWhitespace: true,
  5654. settings: void 0,
  5655. source: void 0,
  5656. title: void 0,
  5657. checkedTemplate: void 0,
  5658. uncheckedTemplate: void 0,
  5659. label: void 0,
  5660. format: void 0,
  5661. language: void 0,
  5662. selectOptions: void 0,
  5663. autoColumnSize: void 0,
  5664. autoRowSize: void 0,
  5665. dateFormat: void 0,
  5666. correctFormat: false,
  5667. defaultDate: void 0,
  5668. strict: void 0,
  5669. renderAllRows: void 0
  5670. };
  5671. Handsontable.DefaultSettings = DefaultSettings;
  5672. //#
  5673. },{"3rdparty/walkontable/src/calculator/viewportColumns":3,"3rdparty/walkontable/src/cell/coords":5,"3rdparty/walkontable/src/cell/range":6,"3rdparty/walkontable/src/selection":18,"dataMap":26,"dataSource":27,"editorManager":28,"eventManager":41,"helpers/array":42,"helpers/data":44,"helpers/dom/element":45,"helpers/number":49,"helpers/object":50,"helpers/setting":51,"helpers/string":52,"numeral":"numeral","plugins":57,"renderers":88,"tableView":97}],26:[function(require,module,exports){
  5674. "use strict";
  5675. Object.defineProperties(exports, {
  5676. DataMap: {get: function() {
  5677. return DataMap;
  5678. }},
  5679. __esModule: {value: true}
  5680. });
  5681. var $__SheetClip__,
  5682. $__helpers_47_data__,
  5683. $__helpers_47_setting__,
  5684. $__helpers_47_object__,
  5685. $__helpers_47_array__,
  5686. $__helpers_47_number__,
  5687. $__multiMap__;
  5688. var SheetClip = ($__SheetClip__ = require("SheetClip"), $__SheetClip__ && $__SheetClip__.__esModule && $__SheetClip__ || {default: $__SheetClip__}).default;
  5689. var cellMethodLookupFactory = ($__helpers_47_data__ = require("helpers/data"), $__helpers_47_data__ && $__helpers_47_data__.__esModule && $__helpers_47_data__ || {default: $__helpers_47_data__}).cellMethodLookupFactory;
  5690. var columnFactory = ($__helpers_47_setting__ = require("helpers/setting"), $__helpers_47_setting__ && $__helpers_47_setting__.__esModule && $__helpers_47_setting__ || {default: $__helpers_47_setting__}).columnFactory;
  5691. var $__3 = ($__helpers_47_object__ = require("helpers/object"), $__helpers_47_object__ && $__helpers_47_object__.__esModule && $__helpers_47_object__ || {default: $__helpers_47_object__}),
  5692. duckSchema = $__3.duckSchema,
  5693. deepExtend = $__3.deepExtend;
  5694. var $__4 = ($__helpers_47_array__ = require("helpers/array"), $__helpers_47_array__ && $__helpers_47_array__.__esModule && $__helpers_47_array__ || {default: $__helpers_47_array__}),
  5695. extendArray = $__4.extendArray,
  5696. to2dArray = $__4.to2dArray;
  5697. var rangeEach = ($__helpers_47_number__ = require("helpers/number"), $__helpers_47_number__ && $__helpers_47_number__.__esModule && $__helpers_47_number__ || {default: $__helpers_47_number__}).rangeEach;
  5698. var MultiMap = ($__multiMap__ = require("multiMap"), $__multiMap__ && $__multiMap__.__esModule && $__multiMap__ || {default: $__multiMap__}).MultiMap;
  5699. function DataMap(instance, priv, GridSettings) {
  5700. this.instance = instance;
  5701. this.priv = priv;
  5702. this.GridSettings = GridSettings;
  5703. this.dataSource = this.instance.getSettings().data;
  5704. if (this.dataSource[0]) {
  5705. this.duckSchema = this.recursiveDuckSchema(this.dataSource[0]);
  5706. } else {
  5707. this.duckSchema = {};
  5708. }
  5709. this.createMap();
  5710. }
  5711. DataMap.prototype.DESTINATION_RENDERER = 1;
  5712. DataMap.prototype.DESTINATION_CLIPBOARD_GENERATOR = 2;
  5713. DataMap.prototype.recursiveDuckSchema = function(object) {
  5714. return duckSchema(object);
  5715. };
  5716. DataMap.prototype.recursiveDuckColumns = function(schema, lastCol, parent) {
  5717. var prop,
  5718. i;
  5719. if (typeof lastCol === 'undefined') {
  5720. lastCol = 0;
  5721. parent = '';
  5722. }
  5723. if (typeof schema === 'object' && !Array.isArray(schema)) {
  5724. for (i in schema) {
  5725. if (schema.hasOwnProperty(i)) {
  5726. if (schema[i] === null) {
  5727. prop = parent + i;
  5728. this.colToPropCache.push(prop);
  5729. this.propToColCache.set(prop, lastCol);
  5730. lastCol++;
  5731. } else {
  5732. lastCol = this.recursiveDuckColumns(schema[i], lastCol, i + '.');
  5733. }
  5734. }
  5735. }
  5736. }
  5737. return lastCol;
  5738. };
  5739. DataMap.prototype.createMap = function() {
  5740. var i,
  5741. ilen,
  5742. schema = this.getSchema();
  5743. if (typeof schema === 'undefined') {
  5744. throw new Error('trying to create `columns` definition but you didnt\' provide `schema` nor `data`');
  5745. }
  5746. this.colToPropCache = [];
  5747. this.propToColCache = new MultiMap();
  5748. var columns = this.instance.getSettings().columns;
  5749. if (columns) {
  5750. for (i = 0, ilen = columns.length; i < ilen; i++) {
  5751. if (typeof columns[i].data != 'undefined') {
  5752. this.colToPropCache[i] = columns[i].data;
  5753. this.propToColCache.set(columns[i].data, i);
  5754. }
  5755. }
  5756. } else {
  5757. this.recursiveDuckColumns(schema);
  5758. }
  5759. };
  5760. DataMap.prototype.colToProp = function(col) {
  5761. col = Handsontable.hooks.run(this.instance, 'modifyCol', col);
  5762. if (this.colToPropCache && typeof this.colToPropCache[col] !== 'undefined') {
  5763. return this.colToPropCache[col];
  5764. }
  5765. return col;
  5766. };
  5767. DataMap.prototype.propToCol = function(prop) {
  5768. var col;
  5769. if (typeof this.propToColCache.get(prop) === 'undefined') {
  5770. col = prop;
  5771. } else {
  5772. col = this.propToColCache.get(prop);
  5773. }
  5774. col = Handsontable.hooks.run(this.instance, 'modifyCol', col);
  5775. return col;
  5776. };
  5777. DataMap.prototype.getSchema = function() {
  5778. var schema = this.instance.getSettings().dataSchema;
  5779. if (schema) {
  5780. if (typeof schema === 'function') {
  5781. return schema();
  5782. }
  5783. return schema;
  5784. }
  5785. return this.duckSchema;
  5786. };
  5787. DataMap.prototype.createRow = function(index, amount, createdAutomatically) {
  5788. var row,
  5789. colCount = this.instance.countCols(),
  5790. numberOfCreatedRows = 0,
  5791. currentIndex;
  5792. if (!amount) {
  5793. amount = 1;
  5794. }
  5795. if (typeof index !== 'number' || index >= this.instance.countSourceRows()) {
  5796. index = this.instance.countSourceRows();
  5797. }
  5798. currentIndex = index;
  5799. var maxRows = this.instance.getSettings().maxRows;
  5800. while (numberOfCreatedRows < amount && this.instance.countSourceRows() < maxRows) {
  5801. if (this.instance.dataType === 'array') {
  5802. row = [];
  5803. for (var c = 0; c < colCount; c++) {
  5804. row.push(null);
  5805. }
  5806. } else if (this.instance.dataType === 'function') {
  5807. row = this.instance.getSettings().dataSchema(index);
  5808. } else {
  5809. row = {};
  5810. deepExtend(row, this.getSchema());
  5811. }
  5812. if (index === this.instance.countSourceRows()) {
  5813. this.dataSource.push(row);
  5814. } else {
  5815. this.dataSource.splice(index, 0, row);
  5816. }
  5817. numberOfCreatedRows++;
  5818. currentIndex++;
  5819. }
  5820. Handsontable.hooks.run(this.instance, 'afterCreateRow', index, numberOfCreatedRows, createdAutomatically);
  5821. this.instance.forceFullRender = true;
  5822. return numberOfCreatedRows;
  5823. };
  5824. DataMap.prototype.createCol = function(index, amount, createdAutomatically) {
  5825. if (!this.instance.isColumnModificationAllowed()) {
  5826. throw new Error('Cannot create new column. When data source in an object, ' + 'you can only have as much columns as defined in first data row, data schema or in the \'columns\' setting.' + 'If you want to be able to add new columns, you have to use array datasource.');
  5827. }
  5828. var rlen = this.instance.countSourceRows(),
  5829. data = this.dataSource,
  5830. constructor,
  5831. numberOfCreatedCols = 0,
  5832. currentIndex;
  5833. if (!amount) {
  5834. amount = 1;
  5835. }
  5836. currentIndex = index;
  5837. var maxCols = this.instance.getSettings().maxCols;
  5838. while (numberOfCreatedCols < amount && this.instance.countCols() < maxCols) {
  5839. constructor = columnFactory(this.GridSettings, this.priv.columnsSettingConflicts);
  5840. if (typeof index !== 'number' || index >= this.instance.countCols()) {
  5841. for (var r = 0; r < rlen; r++) {
  5842. if (typeof data[r] === 'undefined') {
  5843. data[r] = [];
  5844. }
  5845. data[r].push(null);
  5846. }
  5847. this.priv.columnSettings.push(constructor);
  5848. } else {
  5849. for (var r = 0; r < rlen; r++) {
  5850. data[r].splice(currentIndex, 0, null);
  5851. }
  5852. this.priv.columnSettings.splice(currentIndex, 0, constructor);
  5853. }
  5854. numberOfCreatedCols++;
  5855. currentIndex++;
  5856. }
  5857. Handsontable.hooks.run(this.instance, 'afterCreateCol', index, numberOfCreatedCols, createdAutomatically);
  5858. this.instance.forceFullRender = true;
  5859. return numberOfCreatedCols;
  5860. };
  5861. DataMap.prototype.removeRow = function(index, amount) {
  5862. if (!amount) {
  5863. amount = 1;
  5864. }
  5865. if (typeof index !== 'number') {
  5866. index = -amount;
  5867. }
  5868. index = (this.instance.countSourceRows() + index) % this.instance.countSourceRows();
  5869. var logicRows = this.physicalRowsToLogical(index, amount);
  5870. var actionWasNotCancelled = Handsontable.hooks.run(this.instance, 'beforeRemoveRow', index, amount, logicRows);
  5871. if (actionWasNotCancelled === false) {
  5872. return;
  5873. }
  5874. var data = this.dataSource;
  5875. var newData = data.filter(function(row, index) {
  5876. return logicRows.indexOf(index) == -1;
  5877. });
  5878. data.length = 0;
  5879. Array.prototype.push.apply(data, newData);
  5880. Handsontable.hooks.run(this.instance, 'afterRemoveRow', index, amount, logicRows);
  5881. this.instance.forceFullRender = true;
  5882. };
  5883. DataMap.prototype.removeCol = function(index, amount) {
  5884. if (this.instance.dataType === 'object' || this.instance.getSettings().columns) {
  5885. throw new Error('cannot remove column with object data source or columns option specified');
  5886. }
  5887. if (!amount) {
  5888. amount = 1;
  5889. }
  5890. if (typeof index !== 'number') {
  5891. index = -amount;
  5892. }
  5893. index = (this.instance.countCols() + index) % this.instance.countCols();
  5894. var actionWasNotCancelled = Handsontable.hooks.run(this.instance, 'beforeRemoveCol', index, amount);
  5895. if (actionWasNotCancelled === false) {
  5896. return;
  5897. }
  5898. var data = this.dataSource;
  5899. for (var r = 0,
  5900. rlen = this.instance.countSourceRows(); r < rlen; r++) {
  5901. data[r].splice(index, amount);
  5902. }
  5903. this.priv.columnSettings.splice(index, amount);
  5904. Handsontable.hooks.run(this.instance, 'afterRemoveCol', index, amount);
  5905. this.instance.forceFullRender = true;
  5906. };
  5907. DataMap.prototype.spliceCol = function(col, index, amount) {
  5908. var elements = 4 <= arguments.length ? [].slice.call(arguments, 3) : [];
  5909. var colData = this.instance.getDataAtCol(col);
  5910. var removed = colData.slice(index, index + amount);
  5911. var after = colData.slice(index + amount);
  5912. extendArray(elements, after);
  5913. var i = 0;
  5914. while (i < amount) {
  5915. elements.push(null);
  5916. i++;
  5917. }
  5918. to2dArray(elements);
  5919. this.instance.populateFromArray(index, col, elements, null, null, 'spliceCol');
  5920. return removed;
  5921. };
  5922. DataMap.prototype.spliceRow = function(row, index, amount) {
  5923. var elements = 4 <= arguments.length ? [].slice.call(arguments, 3) : [];
  5924. var rowData = this.instance.getSourceDataAtRow(row);
  5925. var removed = rowData.slice(index, index + amount);
  5926. var after = rowData.slice(index + amount);
  5927. extendArray(elements, after);
  5928. var i = 0;
  5929. while (i < amount) {
  5930. elements.push(null);
  5931. i++;
  5932. }
  5933. this.instance.populateFromArray(row, index, [elements], null, null, 'spliceRow');
  5934. return removed;
  5935. };
  5936. DataMap.prototype.get = function(row, prop) {
  5937. row = Handsontable.hooks.run(this.instance, 'modifyRow', row);
  5938. if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  5939. var sliced = prop.split('.');
  5940. var out = this.dataSource[row];
  5941. if (!out) {
  5942. return null;
  5943. }
  5944. for (var i = 0,
  5945. ilen = sliced.length; i < ilen; i++) {
  5946. out = out[sliced[i]];
  5947. if (typeof out === 'undefined') {
  5948. return null;
  5949. }
  5950. }
  5951. return out;
  5952. } else if (typeof prop === 'function') {
  5953. return prop(this.dataSource.slice(row, row + 1)[0]);
  5954. }
  5955. if (this.dataSource[row] && this.dataSource[row].hasOwnProperty && this.dataSource[row].hasOwnProperty(prop)) {
  5956. return this.dataSource[row][prop];
  5957. }
  5958. return null;
  5959. };
  5960. var copyableLookup = cellMethodLookupFactory('copyable', false);
  5961. DataMap.prototype.getCopyable = function(row, prop) {
  5962. if (copyableLookup.call(this.instance, row, this.propToCol(prop))) {
  5963. return this.get(row, prop);
  5964. }
  5965. return '';
  5966. };
  5967. DataMap.prototype.set = function(row, prop, value, source) {
  5968. row = Handsontable.hooks.run(this.instance, 'modifyRow', row, source || 'datamapGet');
  5969. if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  5970. var sliced = prop.split('.');
  5971. var out = this.dataSource[row];
  5972. for (var i = 0,
  5973. ilen = sliced.length - 1; i < ilen; i++) {
  5974. if (typeof out[sliced[i]] === 'undefined') {
  5975. out[sliced[i]] = {};
  5976. }
  5977. out = out[sliced[i]];
  5978. }
  5979. out[sliced[i]] = value;
  5980. } else if (typeof prop === 'function') {
  5981. prop(this.dataSource.slice(row, row + 1)[0], value);
  5982. } else {
  5983. this.dataSource[row][prop] = value;
  5984. }
  5985. };
  5986. DataMap.prototype.physicalRowsToLogical = function(index, amount) {
  5987. var totalRows = this.instance.countSourceRows();
  5988. var physicRow = (totalRows + index) % totalRows;
  5989. var logicRows = [];
  5990. var rowsToRemove = amount;
  5991. var row;
  5992. while (physicRow < totalRows && rowsToRemove) {
  5993. row = Handsontable.hooks.run(this.instance, 'modifyRow', physicRow);
  5994. logicRows.push(row);
  5995. rowsToRemove--;
  5996. physicRow++;
  5997. }
  5998. return logicRows;
  5999. };
  6000. DataMap.prototype.clear = function() {
  6001. for (var r = 0; r < this.instance.countSourceRows(); r++) {
  6002. for (var c = 0; c < this.instance.countCols(); c++) {
  6003. this.set(r, this.colToProp(c), '');
  6004. }
  6005. }
  6006. };
  6007. DataMap.prototype.getLength = function() {
  6008. var $__7 = this;
  6009. var length = this.instance.countSourceRows();
  6010. if (Handsontable.hooks.has('modifyRow', this.instance)) {
  6011. rangeEach(this.instance.countSourceRows() - 1, (function(row) {
  6012. row = Handsontable.hooks.run($__7.instance, 'modifyRow', row);
  6013. if (row === null) {
  6014. length--;
  6015. }
  6016. }));
  6017. }
  6018. return length;
  6019. };
  6020. DataMap.prototype.getAll = function() {
  6021. var start = {
  6022. row: 0,
  6023. col: 0
  6024. };
  6025. var end = {
  6026. row: Math.max(this.instance.countSourceRows() - 1, 0),
  6027. col: Math.max(this.instance.countCols() - 1, 0)
  6028. };
  6029. if (start.row - end.row === 0 && !this.instance.countSourceRows()) {
  6030. return [];
  6031. }
  6032. return this.getRange(start, end, DataMap.prototype.DESTINATION_RENDERER);
  6033. };
  6034. DataMap.prototype.getRange = function(start, end, destination) {
  6035. var r,
  6036. rlen,
  6037. c,
  6038. clen,
  6039. output = [],
  6040. row,
  6041. rowExists;
  6042. var getFn = destination === this.DESTINATION_CLIPBOARD_GENERATOR ? this.getCopyable : this.get;
  6043. rlen = Math.max(start.row, end.row);
  6044. clen = Math.max(start.col, end.col);
  6045. for (r = Math.min(start.row, end.row); r <= rlen; r++) {
  6046. row = [];
  6047. var physicalRow = Handsontable.hooks.run(this.instance, 'modifyRow', r);
  6048. for (c = Math.min(start.col, end.col); c <= clen; c++) {
  6049. var rowValue;
  6050. if (physicalRow === null) {
  6051. break;
  6052. }
  6053. row.push(getFn.call(this, r, this.colToProp(c)));
  6054. }
  6055. if (physicalRow !== null) {
  6056. output.push(row);
  6057. }
  6058. }
  6059. return output;
  6060. };
  6061. DataMap.prototype.getText = function(start, end) {
  6062. return SheetClip.stringify(this.getRange(start, end, this.DESTINATION_RENDERER));
  6063. };
  6064. DataMap.prototype.getCopyableText = function(start, end) {
  6065. return SheetClip.stringify(this.getRange(start, end, this.DESTINATION_CLIPBOARD_GENERATOR));
  6066. };
  6067. ;
  6068. Handsontable.DataMap = DataMap;
  6069. //#
  6070. },{"SheetClip":"SheetClip","helpers/array":42,"helpers/data":44,"helpers/number":49,"helpers/object":50,"helpers/setting":51,"multiMap":55}],27:[function(require,module,exports){
  6071. "use strict";
  6072. Object.defineProperties(exports, {
  6073. DataSource: {get: function() {
  6074. return DataSource;
  6075. }},
  6076. __esModule: {value: true}
  6077. });
  6078. var $__helpers_47_data__,
  6079. $__helpers_47_setting__,
  6080. $__helpers_47_object__,
  6081. $__helpers_47_array__,
  6082. $__helpers_47_number__;
  6083. var cellMethodLookupFactory = ($__helpers_47_data__ = require("helpers/data"), $__helpers_47_data__ && $__helpers_47_data__.__esModule && $__helpers_47_data__ || {default: $__helpers_47_data__}).cellMethodLookupFactory;
  6084. var columnFactory = ($__helpers_47_setting__ = require("helpers/setting"), $__helpers_47_setting__ && $__helpers_47_setting__.__esModule && $__helpers_47_setting__ || {default: $__helpers_47_setting__}).columnFactory;
  6085. var $__2 = ($__helpers_47_object__ = require("helpers/object"), $__helpers_47_object__ && $__helpers_47_object__.__esModule && $__helpers_47_object__ || {default: $__helpers_47_object__}),
  6086. duckSchema = $__2.duckSchema,
  6087. deepExtend = $__2.deepExtend,
  6088. getProperty = $__2.getProperty;
  6089. var $__3 = ($__helpers_47_array__ = require("helpers/array"), $__helpers_47_array__ && $__helpers_47_array__.__esModule && $__helpers_47_array__ || {default: $__helpers_47_array__}),
  6090. extendArray = $__3.extendArray,
  6091. arrayEach = $__3.arrayEach;
  6092. var rangeEach = ($__helpers_47_number__ = require("helpers/number"), $__helpers_47_number__ && $__helpers_47_number__.__esModule && $__helpers_47_number__ || {default: $__helpers_47_number__}).rangeEach;
  6093. var DataSource = function DataSource(hotInstance, dataSource) {
  6094. this.hot = hotInstance;
  6095. this.data = dataSource;
  6096. this.dataType = 'array';
  6097. this.colToProp = (function() {});
  6098. this.propToCol = (function() {});
  6099. };
  6100. ($traceurRuntime.createClass)(DataSource, {
  6101. getData: function() {
  6102. return this.data;
  6103. },
  6104. getAtColumn: function(column) {
  6105. var $__5 = this;
  6106. var result = [];
  6107. arrayEach(this.data, (function(row) {
  6108. var property = $__5.colToProp(column);
  6109. if (typeof property === 'string') {
  6110. row = getProperty(row, property);
  6111. } else {
  6112. row = row[property];
  6113. }
  6114. result.push(row);
  6115. }));
  6116. return result;
  6117. },
  6118. getAtRow: function(row) {
  6119. return this.data[row];
  6120. },
  6121. getAtCell: function(row, column) {
  6122. return this.data[row][this.colToProp(column)];
  6123. },
  6124. getByRange: function(start, end) {
  6125. var $__5 = this;
  6126. var startRow = Math.min(start.row, end.row);
  6127. var startCol = Math.min(start.col, end.col);
  6128. var endRow = Math.max(start.row, end.row);
  6129. var endCol = Math.max(start.col, end.col);
  6130. var result = [];
  6131. rangeEach(startRow, endRow, (function(currentRow) {
  6132. var row = $__5.getAtRow(currentRow);
  6133. var newRow;
  6134. if ($__5.dataType === 'array') {
  6135. newRow = row.slice(startCol, endCol);
  6136. } else if ($__5.dataType === 'object') {
  6137. newRow = {};
  6138. rangeEach(startCol, endCol, (function(column) {
  6139. var prop = $__5.colToProp(column);
  6140. newRow[prop] = row[prop];
  6141. }));
  6142. }
  6143. result.push(newRow);
  6144. }));
  6145. return result;
  6146. },
  6147. destroy: function() {
  6148. this.data = null;
  6149. this.hot = null;
  6150. }
  6151. }, {});
  6152. ;
  6153. //#
  6154. },{"helpers/array":42,"helpers/data":44,"helpers/number":49,"helpers/object":50,"helpers/setting":51}],28:[function(require,module,exports){
  6155. "use strict";
  6156. Object.defineProperties(exports, {
  6157. EditorManager: {get: function() {
  6158. return EditorManager;
  6159. }},
  6160. __esModule: {value: true}
  6161. });
  6162. var $__3rdparty_47_walkontable_47_src_47_cell_47_coords__,
  6163. $__helpers_47_unicode__,
  6164. $__helpers_47_dom_47_event__,
  6165. $__editors__,
  6166. $__eventManager__;
  6167. var WalkontableCellCoords = ($__3rdparty_47_walkontable_47_src_47_cell_47_coords__ = require("3rdparty/walkontable/src/cell/coords"), $__3rdparty_47_walkontable_47_src_47_cell_47_coords__ && $__3rdparty_47_walkontable_47_src_47_cell_47_coords__.__esModule && $__3rdparty_47_walkontable_47_src_47_cell_47_coords__ || {default: $__3rdparty_47_walkontable_47_src_47_cell_47_coords__}).WalkontableCellCoords;
  6168. var $__1 = ($__helpers_47_unicode__ = require("helpers/unicode"), $__helpers_47_unicode__ && $__helpers_47_unicode__.__esModule && $__helpers_47_unicode__ || {default: $__helpers_47_unicode__}),
  6169. KEY_CODES = $__1.KEY_CODES,
  6170. isMetaKey = $__1.isMetaKey,
  6171. isCtrlKey = $__1.isCtrlKey;
  6172. var $__2 = ($__helpers_47_dom_47_event__ = require("helpers/dom/event"), $__helpers_47_dom_47_event__ && $__helpers_47_dom_47_event__.__esModule && $__helpers_47_dom_47_event__ || {default: $__helpers_47_dom_47_event__}),
  6173. stopPropagation = $__2.stopPropagation,
  6174. stopImmediatePropagation = $__2.stopImmediatePropagation,
  6175. isImmediatePropagationStopped = $__2.isImmediatePropagationStopped;
  6176. var getEditor = ($__editors__ = require("editors"), $__editors__ && $__editors__.__esModule && $__editors__ || {default: $__editors__}).getEditor;
  6177. var eventManagerObject = ($__eventManager__ = require("eventManager"), $__eventManager__ && $__eventManager__.__esModule && $__eventManager__ || {default: $__eventManager__}).eventManager;
  6178. ;
  6179. Handsontable.EditorManager = EditorManager;
  6180. function EditorManager(instance, priv, selection) {
  6181. var _this = this,
  6182. destroyed = false,
  6183. eventManager,
  6184. activeEditor;
  6185. eventManager = eventManagerObject(instance);
  6186. function moveSelectionAfterEnter(shiftKey) {
  6187. var enterMoves = typeof priv.settings.enterMoves === 'function' ? priv.settings.enterMoves(event) : priv.settings.enterMoves;
  6188. if (shiftKey) {
  6189. selection.transformStart(-enterMoves.row, -enterMoves.col);
  6190. } else {
  6191. selection.transformStart(enterMoves.row, enterMoves.col, true);
  6192. }
  6193. }
  6194. function moveSelectionUp(shiftKey) {
  6195. if (shiftKey) {
  6196. selection.transformEnd(-1, 0);
  6197. } else {
  6198. selection.transformStart(-1, 0);
  6199. }
  6200. }
  6201. function moveSelectionDown(shiftKey) {
  6202. if (shiftKey) {
  6203. selection.transformEnd(1, 0);
  6204. } else {
  6205. selection.transformStart(1, 0);
  6206. }
  6207. }
  6208. function moveSelectionRight(shiftKey) {
  6209. if (shiftKey) {
  6210. selection.transformEnd(0, 1);
  6211. } else {
  6212. selection.transformStart(0, 1);
  6213. }
  6214. }
  6215. function moveSelectionLeft(shiftKey) {
  6216. if (shiftKey) {
  6217. selection.transformEnd(0, -1);
  6218. } else {
  6219. selection.transformStart(0, -1);
  6220. }
  6221. }
  6222. function onKeyDown(event) {
  6223. var ctrlDown,
  6224. rangeModifier;
  6225. if (!instance.isListening()) {
  6226. return;
  6227. }
  6228. Handsontable.hooks.run(instance, 'beforeKeyDown', event);
  6229. if (destroyed) {
  6230. return;
  6231. }
  6232. if (isImmediatePropagationStopped(event)) {
  6233. return;
  6234. }
  6235. priv.lastKeyCode = event.keyCode;
  6236. if (!selection.isSelected()) {
  6237. return;
  6238. }
  6239. ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  6240. if (activeEditor && !activeEditor.isWaiting()) {
  6241. if (!isMetaKey(event.keyCode) && !isCtrlKey(event.keyCode) && !ctrlDown && !_this.isEditorOpened()) {
  6242. _this.openEditor('', event);
  6243. return;
  6244. }
  6245. }
  6246. rangeModifier = event.shiftKey ? selection.setRangeEnd : selection.setRangeStart;
  6247. switch (event.keyCode) {
  6248. case KEY_CODES.A:
  6249. if (!_this.isEditorOpened() && ctrlDown) {
  6250. selection.selectAll();
  6251. event.preventDefault();
  6252. stopPropagation(event);
  6253. }
  6254. break;
  6255. case KEY_CODES.ARROW_UP:
  6256. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  6257. _this.closeEditorAndSaveChanges(ctrlDown);
  6258. }
  6259. moveSelectionUp(event.shiftKey);
  6260. event.preventDefault();
  6261. stopPropagation(event);
  6262. break;
  6263. case KEY_CODES.ARROW_DOWN:
  6264. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  6265. _this.closeEditorAndSaveChanges(ctrlDown);
  6266. }
  6267. moveSelectionDown(event.shiftKey);
  6268. event.preventDefault();
  6269. stopPropagation(event);
  6270. break;
  6271. case KEY_CODES.ARROW_RIGHT:
  6272. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  6273. _this.closeEditorAndSaveChanges(ctrlDown);
  6274. }
  6275. moveSelectionRight(event.shiftKey);
  6276. event.preventDefault();
  6277. stopPropagation(event);
  6278. break;
  6279. case KEY_CODES.ARROW_LEFT:
  6280. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  6281. _this.closeEditorAndSaveChanges(ctrlDown);
  6282. }
  6283. moveSelectionLeft(event.shiftKey);
  6284. event.preventDefault();
  6285. stopPropagation(event);
  6286. break;
  6287. case KEY_CODES.TAB:
  6288. var tabMoves = typeof priv.settings.tabMoves === 'function' ? priv.settings.tabMoves(event) : priv.settings.tabMoves;
  6289. if (event.shiftKey) {
  6290. selection.transformStart(-tabMoves.row, -tabMoves.col);
  6291. } else {
  6292. selection.transformStart(tabMoves.row, tabMoves.col, true);
  6293. }
  6294. event.preventDefault();
  6295. stopPropagation(event);
  6296. break;
  6297. case KEY_CODES.BACKSPACE:
  6298. case KEY_CODES.DELETE:
  6299. selection.empty(event);
  6300. _this.prepareEditor();
  6301. event.preventDefault();
  6302. break;
  6303. case KEY_CODES.F2:
  6304. _this.openEditor(null, event);
  6305. if (activeEditor) {
  6306. activeEditor.enableFullEditMode();
  6307. }
  6308. event.preventDefault();
  6309. break;
  6310. case KEY_CODES.ENTER:
  6311. if (_this.isEditorOpened()) {
  6312. if (activeEditor && activeEditor.state !== Handsontable.EditorState.WAITING) {
  6313. _this.closeEditorAndSaveChanges(ctrlDown);
  6314. }
  6315. moveSelectionAfterEnter(event.shiftKey);
  6316. } else {
  6317. if (instance.getSettings().enterBeginsEditing) {
  6318. _this.openEditor(null, event);
  6319. if (activeEditor) {
  6320. activeEditor.enableFullEditMode();
  6321. }
  6322. } else {
  6323. moveSelectionAfterEnter(event.shiftKey);
  6324. }
  6325. }
  6326. event.preventDefault();
  6327. stopImmediatePropagation(event);
  6328. break;
  6329. case KEY_CODES.ESCAPE:
  6330. if (_this.isEditorOpened()) {
  6331. _this.closeEditorAndRestoreOriginalValue(ctrlDown);
  6332. }
  6333. event.preventDefault();
  6334. break;
  6335. case KEY_CODES.HOME:
  6336. if (event.ctrlKey || event.metaKey) {
  6337. rangeModifier(new WalkontableCellCoords(0, priv.selRange.from.col));
  6338. } else {
  6339. rangeModifier(new WalkontableCellCoords(priv.selRange.from.row, 0));
  6340. }
  6341. event.preventDefault();
  6342. stopPropagation(event);
  6343. break;
  6344. case KEY_CODES.END:
  6345. if (event.ctrlKey || event.metaKey) {
  6346. rangeModifier(new WalkontableCellCoords(instance.countRows() - 1, priv.selRange.from.col));
  6347. } else {
  6348. rangeModifier(new WalkontableCellCoords(priv.selRange.from.row, instance.countCols() - 1));
  6349. }
  6350. event.preventDefault();
  6351. stopPropagation(event);
  6352. break;
  6353. case KEY_CODES.PAGE_UP:
  6354. selection.transformStart(-instance.countVisibleRows(), 0);
  6355. event.preventDefault();
  6356. stopPropagation(event);
  6357. break;
  6358. case KEY_CODES.PAGE_DOWN:
  6359. selection.transformStart(instance.countVisibleRows(), 0);
  6360. event.preventDefault();
  6361. stopPropagation(event);
  6362. break;
  6363. }
  6364. }
  6365. function init() {
  6366. instance.addHook('afterDocumentKeyDown', onKeyDown);
  6367. eventManager.addEventListener(document.documentElement, 'keydown', function(event) {
  6368. instance.runHooks('afterDocumentKeyDown', event);
  6369. });
  6370. function onDblClick(event, coords, elem) {
  6371. if (elem.nodeName == 'TD') {
  6372. _this.openEditor();
  6373. if (activeEditor) {
  6374. activeEditor.enableFullEditMode();
  6375. }
  6376. }
  6377. }
  6378. instance.view.wt.update('onCellDblClick', onDblClick);
  6379. instance.addHook('afterDestroy', function() {
  6380. destroyed = true;
  6381. });
  6382. }
  6383. this.destroyEditor = function(revertOriginal) {
  6384. this.closeEditor(revertOriginal);
  6385. };
  6386. this.getActiveEditor = function() {
  6387. return activeEditor;
  6388. };
  6389. this.prepareEditor = function() {
  6390. var row,
  6391. col,
  6392. prop,
  6393. td,
  6394. originalValue,
  6395. cellProperties,
  6396. editorClass;
  6397. if (activeEditor && activeEditor.isWaiting()) {
  6398. this.closeEditor(false, false, function(dataSaved) {
  6399. if (dataSaved) {
  6400. _this.prepareEditor();
  6401. }
  6402. });
  6403. return;
  6404. }
  6405. row = priv.selRange.highlight.row;
  6406. col = priv.selRange.highlight.col;
  6407. prop = instance.colToProp(col);
  6408. td = instance.getCell(row, col);
  6409. originalValue = instance.getDataAtCell(row, col);
  6410. cellProperties = instance.getCellMeta(row, col);
  6411. editorClass = instance.getCellEditor(cellProperties);
  6412. if (editorClass) {
  6413. activeEditor = Handsontable.editors.getEditor(editorClass, instance);
  6414. activeEditor.prepare(row, col, prop, td, originalValue, cellProperties);
  6415. } else {
  6416. activeEditor = void 0;
  6417. }
  6418. };
  6419. this.isEditorOpened = function() {
  6420. return activeEditor && activeEditor.isOpened();
  6421. };
  6422. this.openEditor = function(initialValue, event) {
  6423. if (activeEditor && !activeEditor.cellProperties.readOnly) {
  6424. activeEditor.beginEditing(initialValue, event);
  6425. } else if (activeEditor && activeEditor.cellProperties.readOnly) {
  6426. if (event && event.keyCode === KEY_CODES.ENTER) {
  6427. moveSelectionAfterEnter();
  6428. }
  6429. }
  6430. };
  6431. this.closeEditor = function(restoreOriginalValue, ctrlDown, callback) {
  6432. if (activeEditor) {
  6433. activeEditor.finishEditing(restoreOriginalValue, ctrlDown, callback);
  6434. } else {
  6435. if (callback) {
  6436. callback(false);
  6437. }
  6438. }
  6439. };
  6440. this.closeEditorAndSaveChanges = function(ctrlDown) {
  6441. return this.closeEditor(false, ctrlDown);
  6442. };
  6443. this.closeEditorAndRestoreOriginalValue = function(ctrlDown) {
  6444. return this.closeEditor(true, ctrlDown);
  6445. };
  6446. init();
  6447. }
  6448. //#
  6449. },{"3rdparty/walkontable/src/cell/coords":5,"editors":29,"eventManager":41,"helpers/dom/event":46,"helpers/unicode":53}],29:[function(require,module,exports){
  6450. "use strict";
  6451. Object.defineProperties(exports, {
  6452. registerEditor: {get: function() {
  6453. return registerEditor;
  6454. }},
  6455. getEditor: {get: function() {
  6456. return getEditor;
  6457. }},
  6458. hasEditor: {get: function() {
  6459. return hasEditor;
  6460. }},
  6461. getEditorConstructor: {get: function() {
  6462. return getEditorConstructor;
  6463. }},
  6464. __esModule: {value: true}
  6465. });
  6466. var $__helpers_47_string__;
  6467. var toUpperCaseFirst = ($__helpers_47_string__ = require("helpers/string"), $__helpers_47_string__ && $__helpers_47_string__.__esModule && $__helpers_47_string__ || {default: $__helpers_47_string__}).toUpperCaseFirst;
  6468. ;
  6469. var registeredEditorNames = {},
  6470. registeredEditorClasses = new WeakMap();
  6471. Handsontable.editors = Handsontable.editors || {};
  6472. Handsontable.editors.registerEditor = registerEditor;
  6473. Handsontable.editors.getEditor = getEditor;
  6474. function RegisteredEditor(editorClass) {
  6475. var Clazz,
  6476. instances;
  6477. instances = {};
  6478. Clazz = editorClass;
  6479. this.getConstructor = function() {
  6480. return editorClass;
  6481. };
  6482. this.getInstance = function(hotInstance) {
  6483. if (!(hotInstance.guid in instances)) {
  6484. instances[hotInstance.guid] = new Clazz(hotInstance);
  6485. }
  6486. return instances[hotInstance.guid];
  6487. };
  6488. }
  6489. function registerEditor(editorName, editorClass) {
  6490. var editor = new RegisteredEditor(editorClass);
  6491. if (typeof editorName === 'string') {
  6492. registeredEditorNames[editorName] = editor;
  6493. Handsontable.editors[toUpperCaseFirst(editorName) + 'Editor'] = editorClass;
  6494. }
  6495. registeredEditorClasses.set(editorClass, editor);
  6496. }
  6497. function getEditor(editorName, hotInstance) {
  6498. var editor;
  6499. if (typeof editorName == 'function') {
  6500. if (!(registeredEditorClasses.get(editorName))) {
  6501. registerEditor(null, editorName);
  6502. }
  6503. editor = registeredEditorClasses.get(editorName);
  6504. } else if (typeof editorName == 'string') {
  6505. editor = registeredEditorNames[editorName];
  6506. } else {
  6507. throw Error('Only strings and functions can be passed as "editor" parameter ');
  6508. }
  6509. if (!editor) {
  6510. throw Error('No editor registered under name "' + editorName + '"');
  6511. }
  6512. return editor.getInstance(hotInstance);
  6513. }
  6514. function getEditorConstructor(editorName) {
  6515. var editor;
  6516. if (typeof editorName == 'string') {
  6517. editor = registeredEditorNames[editorName];
  6518. } else {
  6519. throw Error('Only strings and functions can be passed as "editor" parameter ');
  6520. }
  6521. if (!editor) {
  6522. throw Error('No editor registered under name "' + editorName + '"');
  6523. }
  6524. return editor.getConstructor();
  6525. }
  6526. function hasEditor(editorName) {
  6527. return registeredEditorNames[editorName] ? true : false;
  6528. }
  6529. //#
  6530. },{"helpers/string":52}],30:[function(require,module,exports){
  6531. "use strict";
  6532. Object.defineProperties(exports, {
  6533. BaseEditor: {get: function() {
  6534. return BaseEditor;
  6535. }},
  6536. __esModule: {value: true}
  6537. });
  6538. var $___46__46__47_helpers_47_mixed__,
  6539. $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__;
  6540. var stringify = ($___46__46__47_helpers_47_mixed__ = require("helpers/mixed"), $___46__46__47_helpers_47_mixed__ && $___46__46__47_helpers_47_mixed__.__esModule && $___46__46__47_helpers_47_mixed__ || {default: $___46__46__47_helpers_47_mixed__}).stringify;
  6541. var WalkontableCellCoords = ($___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ = require("3rdparty/walkontable/src/cell/coords"), $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ && $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__.__esModule && $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ || {default: $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__}).WalkontableCellCoords;
  6542. ;
  6543. Handsontable.editors = Handsontable.editors || {};
  6544. Handsontable.editors.BaseEditor = BaseEditor;
  6545. Handsontable.EditorState = {
  6546. VIRGIN: 'STATE_VIRGIN',
  6547. EDITING: 'STATE_EDITING',
  6548. WAITING: 'STATE_WAITING',
  6549. FINISHED: 'STATE_FINISHED'
  6550. };
  6551. function BaseEditor(instance) {
  6552. this.instance = instance;
  6553. this.state = Handsontable.EditorState.VIRGIN;
  6554. this._opened = false;
  6555. this._fullEditMode = false;
  6556. this._closeCallback = null;
  6557. this.init();
  6558. }
  6559. BaseEditor.prototype._fireCallbacks = function(result) {
  6560. if (this._closeCallback) {
  6561. this._closeCallback(result);
  6562. this._closeCallback = null;
  6563. }
  6564. };
  6565. BaseEditor.prototype.init = function() {};
  6566. BaseEditor.prototype.getValue = function() {
  6567. throw Error('Editor getValue() method unimplemented');
  6568. };
  6569. BaseEditor.prototype.setValue = function(newValue) {
  6570. throw Error('Editor setValue() method unimplemented');
  6571. };
  6572. BaseEditor.prototype.open = function() {
  6573. throw Error('Editor open() method unimplemented');
  6574. };
  6575. BaseEditor.prototype.close = function() {
  6576. throw Error('Editor close() method unimplemented');
  6577. };
  6578. BaseEditor.prototype.prepare = function(row, col, prop, td, originalValue, cellProperties) {
  6579. this.TD = td;
  6580. this.row = row;
  6581. this.col = col;
  6582. this.prop = prop;
  6583. this.originalValue = originalValue;
  6584. this.cellProperties = cellProperties;
  6585. if (this.instance.view.isMouseDown() && document.activeElement && document.activeElement !== document.body) {
  6586. document.activeElement.blur();
  6587. } else if (!document.activeElement) {
  6588. document.body.focus();
  6589. }
  6590. this.state = Handsontable.EditorState.VIRGIN;
  6591. };
  6592. BaseEditor.prototype.extend = function() {
  6593. var baseClass = this.constructor;
  6594. function Editor() {
  6595. baseClass.apply(this, arguments);
  6596. }
  6597. function inherit(Child, Parent) {
  6598. function Bridge() {}
  6599. Bridge.prototype = Parent.prototype;
  6600. Child.prototype = new Bridge();
  6601. Child.prototype.constructor = Child;
  6602. return Child;
  6603. }
  6604. return inherit(Editor, baseClass);
  6605. };
  6606. BaseEditor.prototype.saveValue = function(val, ctrlDown) {
  6607. var sel,
  6608. tmp;
  6609. if (ctrlDown) {
  6610. sel = this.instance.getSelected();
  6611. if (sel[0] > sel[2]) {
  6612. tmp = sel[0];
  6613. sel[0] = sel[2];
  6614. sel[2] = tmp;
  6615. }
  6616. if (sel[1] > sel[3]) {
  6617. tmp = sel[1];
  6618. sel[1] = sel[3];
  6619. sel[3] = tmp;
  6620. }
  6621. this.instance.populateFromArray(sel[0], sel[1], val, sel[2], sel[3], 'edit');
  6622. } else {
  6623. this.instance.populateFromArray(this.row, this.col, val, null, null, 'edit');
  6624. }
  6625. };
  6626. BaseEditor.prototype.beginEditing = function(initialValue, event) {
  6627. if (this.state != Handsontable.EditorState.VIRGIN) {
  6628. return;
  6629. }
  6630. this.instance.view.scrollViewport(new WalkontableCellCoords(this.row, this.col));
  6631. this.instance.view.render();
  6632. this.state = Handsontable.EditorState.EDITING;
  6633. initialValue = typeof initialValue == 'string' ? initialValue : this.originalValue;
  6634. this.setValue(stringify(initialValue));
  6635. this.open(event);
  6636. this._opened = true;
  6637. this.focus();
  6638. this.instance.view.render();
  6639. };
  6640. BaseEditor.prototype.finishEditing = function(restoreOriginalValue, ctrlDown, callback) {
  6641. var _this = this,
  6642. val;
  6643. if (callback) {
  6644. var previousCloseCallback = this._closeCallback;
  6645. this._closeCallback = function(result) {
  6646. if (previousCloseCallback) {
  6647. previousCloseCallback(result);
  6648. }
  6649. callback(result);
  6650. };
  6651. }
  6652. if (this.isWaiting()) {
  6653. return;
  6654. }
  6655. if (this.state == Handsontable.EditorState.VIRGIN) {
  6656. this.instance._registerTimeout(setTimeout(function() {
  6657. _this._fireCallbacks(true);
  6658. }, 0));
  6659. return;
  6660. }
  6661. if (this.state == Handsontable.EditorState.EDITING) {
  6662. if (restoreOriginalValue) {
  6663. this.cancelChanges();
  6664. this.instance.view.render();
  6665. return;
  6666. }
  6667. if (this.instance.getSettings().trimWhitespace) {
  6668. val = [[typeof this.getValue() === 'string' ? String.prototype.trim.call(this.getValue() || '') : this.getValue()]];
  6669. } else {
  6670. val = [[this.getValue()]];
  6671. }
  6672. this.state = Handsontable.EditorState.WAITING;
  6673. this.saveValue(val, ctrlDown);
  6674. if (this.instance.getCellValidator(this.cellProperties)) {
  6675. this.instance.addHookOnce('postAfterValidate', function(result) {
  6676. _this.state = Handsontable.EditorState.FINISHED;
  6677. _this.discardEditor(result);
  6678. });
  6679. } else {
  6680. this.state = Handsontable.EditorState.FINISHED;
  6681. this.discardEditor(true);
  6682. }
  6683. }
  6684. };
  6685. BaseEditor.prototype.cancelChanges = function() {
  6686. this.state = Handsontable.EditorState.FINISHED;
  6687. this.discardEditor();
  6688. };
  6689. BaseEditor.prototype.discardEditor = function(result) {
  6690. if (this.state !== Handsontable.EditorState.FINISHED) {
  6691. return;
  6692. }
  6693. if (result === false && this.cellProperties.allowInvalid !== true) {
  6694. this.instance.selectCell(this.row, this.col);
  6695. this.focus();
  6696. this.state = Handsontable.EditorState.EDITING;
  6697. this._fireCallbacks(false);
  6698. } else {
  6699. this.close();
  6700. this._opened = false;
  6701. this._fullEditMode = false;
  6702. this.state = Handsontable.EditorState.VIRGIN;
  6703. this._fireCallbacks(true);
  6704. }
  6705. };
  6706. BaseEditor.prototype.enableFullEditMode = function() {
  6707. this._fullEditMode = true;
  6708. };
  6709. BaseEditor.prototype.isInFullEditMode = function() {
  6710. return this._fullEditMode;
  6711. };
  6712. BaseEditor.prototype.isOpened = function() {
  6713. return this._opened;
  6714. };
  6715. BaseEditor.prototype.isWaiting = function() {
  6716. return this.state === Handsontable.EditorState.WAITING;
  6717. };
  6718. BaseEditor.prototype.checkEditorSection = function() {
  6719. var totalRows = this.instance.countRows();
  6720. var section = '';
  6721. if (this.row < this.instance.getSettings().fixedRowsTop) {
  6722. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  6723. section = 'top-left-corner';
  6724. } else {
  6725. section = 'top';
  6726. }
  6727. } else if (this.instance.getSettings().fixedRowsBottom && this.row >= totalRows - this.instance.getSettings().fixedRowsBottom) {
  6728. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  6729. section = 'bottom-left-corner';
  6730. } else {
  6731. section = 'bottom';
  6732. }
  6733. } else {
  6734. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  6735. section = 'left';
  6736. }
  6737. }
  6738. return section;
  6739. };
  6740. //#
  6741. },{"3rdparty/walkontable/src/cell/coords":5,"helpers/mixed":48}],31:[function(require,module,exports){
  6742. "use strict";
  6743. Object.defineProperties(exports, {
  6744. AutocompleteEditor: {get: function() {
  6745. return AutocompleteEditor;
  6746. }},
  6747. __esModule: {value: true}
  6748. });
  6749. var $___46__46__47_helpers_47_unicode__,
  6750. $___46__46__47_helpers_47_mixed__,
  6751. $___46__46__47_helpers_47_array__,
  6752. $___46__46__47_helpers_47_dom_47_element__,
  6753. $___46__46__47_editors__,
  6754. $__handsontableEditor__;
  6755. var $__0 = ($___46__46__47_helpers_47_unicode__ = require("helpers/unicode"), $___46__46__47_helpers_47_unicode__ && $___46__46__47_helpers_47_unicode__.__esModule && $___46__46__47_helpers_47_unicode__ || {default: $___46__46__47_helpers_47_unicode__}),
  6756. KEY_CODES = $__0.KEY_CODES,
  6757. isPrintableChar = $__0.isPrintableChar;
  6758. var stringify = ($___46__46__47_helpers_47_mixed__ = require("helpers/mixed"), $___46__46__47_helpers_47_mixed__ && $___46__46__47_helpers_47_mixed__.__esModule && $___46__46__47_helpers_47_mixed__ || {default: $___46__46__47_helpers_47_mixed__}).stringify;
  6759. var pivot = ($___46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47_helpers_47_array__ && $___46__46__47_helpers_47_array__.__esModule && $___46__46__47_helpers_47_array__ || {default: $___46__46__47_helpers_47_array__}).pivot;
  6760. var $__3 = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}),
  6761. addClass = $__3.addClass,
  6762. getCaretPosition = $__3.getCaretPosition,
  6763. getScrollbarWidth = $__3.getScrollbarWidth,
  6764. getSelectionEndPosition = $__3.getSelectionEndPosition,
  6765. outerWidth = $__3.outerWidth,
  6766. setCaretPosition = $__3.setCaretPosition;
  6767. var $__4 = ($___46__46__47_editors__ = require("editors"), $___46__46__47_editors__ && $___46__46__47_editors__.__esModule && $___46__46__47_editors__ || {default: $___46__46__47_editors__}),
  6768. getEditorConstructor = $__4.getEditorConstructor,
  6769. registerEditor = $__4.registerEditor;
  6770. var HandsontableEditor = ($__handsontableEditor__ = require("handsontableEditor"), $__handsontableEditor__ && $__handsontableEditor__.__esModule && $__handsontableEditor__ || {default: $__handsontableEditor__}).HandsontableEditor;
  6771. var AutocompleteEditor = HandsontableEditor.prototype.extend();
  6772. AutocompleteEditor.prototype.init = function() {
  6773. HandsontableEditor.prototype.init.apply(this, arguments);
  6774. this.query = null;
  6775. this.choices = [];
  6776. };
  6777. AutocompleteEditor.prototype.createElements = function() {
  6778. HandsontableEditor.prototype.createElements.apply(this, arguments);
  6779. addClass(this.htContainer, 'autocompleteEditor');
  6780. addClass(this.htContainer, window.navigator.platform.indexOf('Mac') === -1 ? '' : 'htMacScroll');
  6781. };
  6782. var skipOne = false;
  6783. function onBeforeKeyDown(event) {
  6784. skipOne = false;
  6785. var editor = this.getActiveEditor();
  6786. if (isPrintableChar(event.keyCode) || event.keyCode === KEY_CODES.BACKSPACE || event.keyCode === KEY_CODES.DELETE || event.keyCode === KEY_CODES.INSERT) {
  6787. var timeOffset = 0;
  6788. if (event.keyCode === KEY_CODES.C && (event.ctrlKey || event.metaKey)) {
  6789. return;
  6790. }
  6791. if (!editor.isOpened()) {
  6792. timeOffset += 10;
  6793. }
  6794. if (editor.htEditor) {
  6795. editor.instance._registerTimeout(setTimeout(function() {
  6796. editor.queryChoices(editor.TEXTAREA.value);
  6797. skipOne = true;
  6798. }, timeOffset));
  6799. }
  6800. }
  6801. }
  6802. AutocompleteEditor.prototype.prepare = function() {
  6803. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  6804. HandsontableEditor.prototype.prepare.apply(this, arguments);
  6805. };
  6806. AutocompleteEditor.prototype.open = function() {
  6807. this.TEXTAREA_PARENT.style.overflow = 'auto';
  6808. HandsontableEditor.prototype.open.apply(this, arguments);
  6809. this.TEXTAREA_PARENT.style.overflow = '';
  6810. var choicesListHot = this.htEditor.getInstance();
  6811. var that = this;
  6812. var trimDropdown = this.cellProperties.trimDropdown === void 0 ? true : this.cellProperties.trimDropdown;
  6813. this.TEXTAREA.style.visibility = 'visible';
  6814. this.focus();
  6815. choicesListHot.updateSettings({
  6816. colWidths: trimDropdown ? [outerWidth(this.TEXTAREA) - 2] : void 0,
  6817. width: trimDropdown ? outerWidth(this.TEXTAREA) + getScrollbarWidth() + 2 : void 0,
  6818. afterRenderer: function(TD, row, col, prop, value) {
  6819. var caseSensitive = this.getCellMeta(row, col).filteringCaseSensitive === true,
  6820. indexOfMatch,
  6821. match,
  6822. value = stringify(value);
  6823. if (value) {
  6824. indexOfMatch = caseSensitive ? value.indexOf(this.query) : value.toLowerCase().indexOf(that.query.toLowerCase());
  6825. if (indexOfMatch != -1) {
  6826. match = value.substr(indexOfMatch, that.query.length);
  6827. TD.innerHTML = value.replace(match, '<strong>' + match + '</strong>');
  6828. }
  6829. }
  6830. },
  6831. autoColumnSize: true,
  6832. modifyColWidth: function(width, col) {
  6833. var autoWidths = this.getPlugin('autoColumnSize').widths;
  6834. if (autoWidths[col]) {
  6835. width = autoWidths[col];
  6836. }
  6837. return trimDropdown ? width : width + 15;
  6838. }
  6839. });
  6840. this.htEditor.view.wt.wtTable.holder.parentNode.style['padding-right'] = getScrollbarWidth() + 2 + 'px';
  6841. if (skipOne) {
  6842. skipOne = false;
  6843. }
  6844. that.instance._registerTimeout(setTimeout(function() {
  6845. that.queryChoices(that.TEXTAREA.value);
  6846. }, 0));
  6847. };
  6848. AutocompleteEditor.prototype.close = function() {
  6849. HandsontableEditor.prototype.close.apply(this, arguments);
  6850. };
  6851. AutocompleteEditor.prototype.queryChoices = function(query) {
  6852. this.query = query;
  6853. if (typeof this.cellProperties.source == 'function') {
  6854. var that = this;
  6855. this.cellProperties.source(query, function(choices) {
  6856. that.updateChoicesList(choices);
  6857. });
  6858. } else if (Array.isArray(this.cellProperties.source)) {
  6859. var choices;
  6860. if (!query || this.cellProperties.filter === false) {
  6861. choices = this.cellProperties.source;
  6862. } else {
  6863. var filteringCaseSensitive = this.cellProperties.filteringCaseSensitive === true;
  6864. var lowerCaseQuery = query.toLowerCase();
  6865. choices = this.cellProperties.source.filter(function(choice) {
  6866. if (filteringCaseSensitive) {
  6867. return choice.indexOf(query) != -1;
  6868. } else {
  6869. return choice.toLowerCase().indexOf(lowerCaseQuery) != -1;
  6870. }
  6871. });
  6872. }
  6873. this.updateChoicesList(choices);
  6874. } else {
  6875. this.updateChoicesList([]);
  6876. }
  6877. };
  6878. AutocompleteEditor.prototype.updateChoicesList = function(choices) {
  6879. var pos = getCaretPosition(this.TEXTAREA),
  6880. endPos = getSelectionEndPosition(this.TEXTAREA);
  6881. var orderByRelevance = AutocompleteEditor.sortByRelevance(this.getValue(), choices, this.cellProperties.filteringCaseSensitive);
  6882. var highlightIndex;
  6883. if (this.cellProperties.filter == false) {
  6884. highlightIndex = orderByRelevance[0];
  6885. } else {
  6886. var sorted = [];
  6887. for (var i = 0,
  6888. choicesCount = orderByRelevance.length; i < choicesCount; i++) {
  6889. sorted.push(choices[orderByRelevance[i]]);
  6890. }
  6891. highlightIndex = 0;
  6892. choices = sorted;
  6893. }
  6894. this.choices = choices;
  6895. this.htEditor.loadData(pivot([choices]));
  6896. this.updateDropdownHeight();
  6897. if (this.cellProperties.strict === true) {
  6898. this.highlightBestMatchingChoice(highlightIndex);
  6899. }
  6900. this.instance.listen();
  6901. this.TEXTAREA.focus();
  6902. setCaretPosition(this.TEXTAREA, pos, (pos == endPos ? void 0 : endPos));
  6903. };
  6904. AutocompleteEditor.prototype.updateDropdownHeight = function() {
  6905. var currentDropdownWidth = this.htEditor.getColWidth(0) + getScrollbarWidth() + 2;
  6906. var trimDropdown = this.cellProperties.trimDropdown === void 0 ? true : this.cellProperties.trimDropdown;
  6907. this.htEditor.updateSettings({
  6908. height: this.getDropdownHeight(),
  6909. width: trimDropdown ? void 0 : currentDropdownWidth
  6910. });
  6911. this.htEditor.view.wt.wtTable.alignOverlaysWithTrimmingContainer();
  6912. };
  6913. AutocompleteEditor.prototype.finishEditing = function(restoreOriginalValue) {
  6914. if (!restoreOriginalValue) {
  6915. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  6916. }
  6917. HandsontableEditor.prototype.finishEditing.apply(this, arguments);
  6918. };
  6919. AutocompleteEditor.prototype.highlightBestMatchingChoice = function(index) {
  6920. if (typeof index === 'number') {
  6921. this.htEditor.selectCell(index, 0);
  6922. } else {
  6923. this.htEditor.deselectCell();
  6924. }
  6925. };
  6926. AutocompleteEditor.sortByRelevance = function(value, choices, caseSensitive) {
  6927. var choicesRelevance = [],
  6928. currentItem,
  6929. valueLength = value.length,
  6930. valueIndex,
  6931. charsLeft,
  6932. result = [],
  6933. i,
  6934. choicesCount;
  6935. if (valueLength === 0) {
  6936. for (i = 0, choicesCount = choices.length; i < choicesCount; i++) {
  6937. result.push(i);
  6938. }
  6939. return result;
  6940. }
  6941. for (i = 0, choicesCount = choices.length; i < choicesCount; i++) {
  6942. currentItem = stringify(choices[i]);
  6943. if (caseSensitive) {
  6944. valueIndex = currentItem.indexOf(value);
  6945. } else {
  6946. valueIndex = currentItem.toLowerCase().indexOf(value.toLowerCase());
  6947. }
  6948. if (valueIndex == -1) {
  6949. continue;
  6950. }
  6951. charsLeft = currentItem.length - valueIndex - valueLength;
  6952. choicesRelevance.push({
  6953. baseIndex: i,
  6954. index: valueIndex,
  6955. charsLeft: charsLeft,
  6956. value: currentItem
  6957. });
  6958. }
  6959. choicesRelevance.sort(function(a, b) {
  6960. if (b.index === -1) {
  6961. return -1;
  6962. }
  6963. if (a.index === -1) {
  6964. return 1;
  6965. }
  6966. if (a.index < b.index) {
  6967. return -1;
  6968. } else if (b.index < a.index) {
  6969. return 1;
  6970. } else if (a.index === b.index) {
  6971. if (a.charsLeft < b.charsLeft) {
  6972. return -1;
  6973. } else if (a.charsLeft > b.charsLeft) {
  6974. return 1;
  6975. } else {
  6976. return 0;
  6977. }
  6978. }
  6979. });
  6980. for (i = 0, choicesCount = choicesRelevance.length; i < choicesCount; i++) {
  6981. result.push(choicesRelevance[i].baseIndex);
  6982. }
  6983. return result;
  6984. };
  6985. AutocompleteEditor.prototype.getDropdownHeight = function() {
  6986. var firstRowHeight = this.htEditor.getInstance().getRowHeight(0) || 23;
  6987. var _visibleRows = this.cellProperties.visibleRows;
  6988. return this.choices.length >= _visibleRows ? _visibleRows * firstRowHeight : this.choices.length * firstRowHeight + 8;
  6989. };
  6990. AutocompleteEditor.prototype.allowKeyEventPropagation = function(keyCode) {
  6991. var selected = {row: this.htEditor.getSelectedRange() ? this.htEditor.getSelectedRange().from.row : -1};
  6992. var allowed = false;
  6993. if (keyCode === KEY_CODES.ARROW_DOWN && selected.row < this.htEditor.countRows() - 1) {
  6994. allowed = true;
  6995. }
  6996. if (keyCode === KEY_CODES.ARROW_UP && selected.row > -1) {
  6997. allowed = true;
  6998. }
  6999. return allowed;
  7000. };
  7001. ;
  7002. registerEditor('autocomplete', AutocompleteEditor);
  7003. //#
  7004. },{"editors":29,"handsontableEditor":35,"helpers/array":42,"helpers/dom/element":45,"helpers/mixed":48,"helpers/unicode":53}],32:[function(require,module,exports){
  7005. "use strict";
  7006. Object.defineProperties(exports, {
  7007. CheckboxEditor: {get: function() {
  7008. return CheckboxEditor;
  7009. }},
  7010. __esModule: {value: true}
  7011. });
  7012. var $___46__46__47_editors__,
  7013. $___95_baseEditor__,
  7014. $___46__46__47_helpers_47_dom_47_element__;
  7015. var registerEditor = ($___46__46__47_editors__ = require("editors"), $___46__46__47_editors__ && $___46__46__47_editors__.__esModule && $___46__46__47_editors__ || {default: $___46__46__47_editors__}).registerEditor;
  7016. var BaseEditor = ($___95_baseEditor__ = require("_baseEditor"), $___95_baseEditor__ && $___95_baseEditor__.__esModule && $___95_baseEditor__ || {default: $___95_baseEditor__}).BaseEditor;
  7017. var hasClass = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}).hasClass;
  7018. var CheckboxEditor = function CheckboxEditor() {
  7019. $traceurRuntime.superConstructor($CheckboxEditor).apply(this, arguments);
  7020. };
  7021. var $CheckboxEditor = CheckboxEditor;
  7022. ($traceurRuntime.createClass)(CheckboxEditor, {
  7023. beginEditing: function() {
  7024. var checkbox = this.TD.querySelector('input[type="checkbox"]');
  7025. if (!hasClass(checkbox, 'htBadValue')) {
  7026. checkbox.click();
  7027. }
  7028. },
  7029. finishEditing: function() {},
  7030. init: function() {},
  7031. open: function() {},
  7032. close: function() {},
  7033. getValue: function() {},
  7034. setValue: function() {},
  7035. focus: function() {}
  7036. }, {}, BaseEditor);
  7037. ;
  7038. registerEditor('checkbox', CheckboxEditor);
  7039. //#
  7040. },{"_baseEditor":30,"editors":29,"helpers/dom/element":45}],33:[function(require,module,exports){
  7041. "use strict";
  7042. Object.defineProperties(exports, {
  7043. DateEditor: {get: function() {
  7044. return DateEditor;
  7045. }},
  7046. __esModule: {value: true}
  7047. });
  7048. var $___46__46__47_helpers_47_dom_47_element__,
  7049. $___46__46__47_helpers_47_object__,
  7050. $___46__46__47_eventManager__,
  7051. $___46__46__47_editors__,
  7052. $___46__46__47_helpers_47_unicode__,
  7053. $___46__46__47_helpers_47_dom_47_event__,
  7054. $__textEditor__,
  7055. $__moment__,
  7056. $__pikaday__;
  7057. var $__0 = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}),
  7058. addClass = $__0.addClass,
  7059. outerHeight = $__0.outerHeight;
  7060. var deepExtend = ($___46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47_helpers_47_object__ && $___46__46__47_helpers_47_object__.__esModule && $___46__46__47_helpers_47_object__ || {default: $___46__46__47_helpers_47_object__}).deepExtend;
  7061. var EventManager = ($___46__46__47_eventManager__ = require("eventManager"), $___46__46__47_eventManager__ && $___46__46__47_eventManager__.__esModule && $___46__46__47_eventManager__ || {default: $___46__46__47_eventManager__}).EventManager;
  7062. var $__3 = ($___46__46__47_editors__ = require("editors"), $___46__46__47_editors__ && $___46__46__47_editors__.__esModule && $___46__46__47_editors__ || {default: $___46__46__47_editors__}),
  7063. getEditor = $__3.getEditor,
  7064. registerEditor = $__3.registerEditor;
  7065. var isMetaKey = ($___46__46__47_helpers_47_unicode__ = require("helpers/unicode"), $___46__46__47_helpers_47_unicode__ && $___46__46__47_helpers_47_unicode__.__esModule && $___46__46__47_helpers_47_unicode__ || {default: $___46__46__47_helpers_47_unicode__}).isMetaKey;
  7066. var stopPropagation = ($___46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47_helpers_47_dom_47_event__ && $___46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47_helpers_47_dom_47_event__}).stopPropagation;
  7067. var TextEditor = ($__textEditor__ = require("textEditor"), $__textEditor__ && $__textEditor__.__esModule && $__textEditor__ || {default: $__textEditor__}).TextEditor;
  7068. var moment = ($__moment__ = require("moment"), $__moment__ && $__moment__.__esModule && $__moment__ || {default: $__moment__}).default;
  7069. var Pikaday = ($__pikaday__ = require("pikaday"), $__pikaday__ && $__pikaday__.__esModule && $__pikaday__ || {default: $__pikaday__}).default;
  7070. Handsontable.editors = Handsontable.editors || {};
  7071. Handsontable.editors.DateEditor = DateEditor;
  7072. var DateEditor = function DateEditor(hotInstance) {
  7073. this.$datePicker = null;
  7074. this.datePicker = null;
  7075. this.datePickerStyle = null;
  7076. this.defaultDateFormat = 'DD/MM/YYYY';
  7077. this.isCellEdited = false;
  7078. this.parentDestroyed = false;
  7079. $traceurRuntime.superConstructor($DateEditor).call(this, hotInstance);
  7080. };
  7081. var $DateEditor = DateEditor;
  7082. ($traceurRuntime.createClass)(DateEditor, {
  7083. init: function() {
  7084. var $__9 = this;
  7085. if (typeof moment !== 'function') {
  7086. throw new Error('You need to include moment.js to your project.');
  7087. }
  7088. if (typeof Pikaday !== 'function') {
  7089. throw new Error('You need to include Pikaday to your project.');
  7090. }
  7091. $traceurRuntime.superGet(this, $DateEditor.prototype, "init").call(this);
  7092. this.instance.addHook('afterDestroy', (function() {
  7093. $__9.parentDestroyed = true;
  7094. $__9.destroyElements();
  7095. }));
  7096. },
  7097. createElements: function() {
  7098. $traceurRuntime.superGet(this, $DateEditor.prototype, "createElements").call(this);
  7099. this.datePicker = document.createElement('DIV');
  7100. this.datePickerStyle = this.datePicker.style;
  7101. this.datePickerStyle.position = 'absolute';
  7102. this.datePickerStyle.top = 0;
  7103. this.datePickerStyle.left = 0;
  7104. this.datePickerStyle.zIndex = 9999;
  7105. addClass(this.datePicker, 'htDatepickerHolder');
  7106. document.body.appendChild(this.datePicker);
  7107. this.$datePicker = new Pikaday(this.getDatePickerConfig());
  7108. var eventManager = new EventManager(this);
  7109. eventManager.addEventListener(this.datePicker, 'mousedown', (function(event) {
  7110. return stopPropagation(event);
  7111. }));
  7112. this.hideDatepicker();
  7113. },
  7114. destroyElements: function() {
  7115. this.$datePicker.destroy();
  7116. },
  7117. prepare: function(row, col, prop, td, originalValue, cellProperties) {
  7118. this._opened = false;
  7119. $traceurRuntime.superGet(this, $DateEditor.prototype, "prepare").call(this, row, col, prop, td, originalValue, cellProperties);
  7120. },
  7121. open: function() {
  7122. var event = arguments[0] !== (void 0) ? arguments[0] : null;
  7123. $traceurRuntime.superGet(this, $DateEditor.prototype, "open").call(this);
  7124. this.showDatepicker(event);
  7125. },
  7126. close: function() {
  7127. var $__9 = this;
  7128. this._opened = false;
  7129. this.instance._registerTimeout(setTimeout((function() {
  7130. $__9.instance.selection.refreshBorders();
  7131. }), 0));
  7132. $traceurRuntime.superGet(this, $DateEditor.prototype, "close").call(this);
  7133. },
  7134. finishEditing: function() {
  7135. var isCancelled = arguments[0] !== (void 0) ? arguments[0] : false;
  7136. var ctrlDown = arguments[1] !== (void 0) ? arguments[1] : false;
  7137. if (isCancelled) {
  7138. var value = this.originalValue;
  7139. if (value !== void 0) {
  7140. this.setValue(value);
  7141. }
  7142. }
  7143. this.hideDatepicker();
  7144. $traceurRuntime.superGet(this, $DateEditor.prototype, "finishEditing").call(this, isCancelled, ctrlDown);
  7145. },
  7146. showDatepicker: function(event) {
  7147. this.$datePicker.config(this.getDatePickerConfig());
  7148. var offset = this.TD.getBoundingClientRect();
  7149. var dateFormat = this.cellProperties.dateFormat || this.defaultDateFormat;
  7150. var datePickerConfig = this.$datePicker.config();
  7151. var dateStr;
  7152. var isMouseDown = this.instance.view.isMouseDown();
  7153. var isMeta = event ? isMetaKey(event.keyCode) : false;
  7154. this.datePickerStyle.top = (window.pageYOffset + offset.top + outerHeight(this.TD)) + 'px';
  7155. this.datePickerStyle.left = (window.pageXOffset + offset.left) + 'px';
  7156. this.$datePicker._onInputFocus = function() {};
  7157. datePickerConfig.format = dateFormat;
  7158. if (this.originalValue) {
  7159. dateStr = this.originalValue;
  7160. if (moment(dateStr, dateFormat, true).isValid()) {
  7161. this.$datePicker.setMoment(moment(dateStr, dateFormat), true);
  7162. }
  7163. if (!isMeta && !isMouseDown) {
  7164. this.setValue('');
  7165. }
  7166. } else {
  7167. if (this.cellProperties.defaultDate) {
  7168. dateStr = this.cellProperties.defaultDate;
  7169. datePickerConfig.defaultDate = dateStr;
  7170. if (moment(dateStr, dateFormat, true).isValid()) {
  7171. this.$datePicker.setMoment(moment(dateStr, dateFormat), true);
  7172. }
  7173. if (!isMeta && !isMouseDown) {
  7174. this.setValue('');
  7175. }
  7176. } else {
  7177. this.$datePicker.gotoToday();
  7178. }
  7179. }
  7180. this.datePickerStyle.display = 'block';
  7181. this.$datePicker.show();
  7182. },
  7183. hideDatepicker: function() {
  7184. this.datePickerStyle.display = 'none';
  7185. this.$datePicker.hide();
  7186. },
  7187. getDatePickerConfig: function() {
  7188. var $__9 = this;
  7189. var htInput = this.TEXTAREA;
  7190. var options = {};
  7191. if (this.cellProperties && this.cellProperties.datePickerConfig) {
  7192. deepExtend(options, this.cellProperties.datePickerConfig);
  7193. }
  7194. var origOnSelect = options.onSelect;
  7195. var origOnClose = options.onClose;
  7196. options.field = htInput;
  7197. options.trigger = htInput;
  7198. options.container = this.datePicker;
  7199. options.bound = false;
  7200. options.format = options.format || this.defaultDateFormat;
  7201. options.reposition = options.reposition || false;
  7202. options.onSelect = (function(dateStr) {
  7203. if (!isNaN(dateStr.getTime())) {
  7204. dateStr = moment(dateStr).format($__9.cellProperties.dateFormat || $__9.defaultDateFormat);
  7205. }
  7206. $__9.setValue(dateStr);
  7207. $__9.hideDatepicker();
  7208. if (origOnSelect) {
  7209. origOnSelect();
  7210. }
  7211. });
  7212. options.onClose = (function() {
  7213. if (!$__9.parentDestroyed) {
  7214. $__9.finishEditing(false);
  7215. }
  7216. if (origOnClose) {
  7217. origOnClose();
  7218. }
  7219. });
  7220. return options;
  7221. }
  7222. }, {}, TextEditor);
  7223. ;
  7224. registerEditor('date', DateEditor);
  7225. //#
  7226. },{"editors":29,"eventManager":41,"helpers/dom/element":45,"helpers/dom/event":46,"helpers/object":50,"helpers/unicode":53,"moment":"moment","pikaday":"pikaday","textEditor":40}],34:[function(require,module,exports){
  7227. "use strict";
  7228. Object.defineProperties(exports, {
  7229. DropdownEditor: {get: function() {
  7230. return DropdownEditor;
  7231. }},
  7232. __esModule: {value: true}
  7233. });
  7234. var $___46__46__47_editors__,
  7235. $__autocompleteEditor__;
  7236. var $__0 = ($___46__46__47_editors__ = require("editors"), $___46__46__47_editors__ && $___46__46__47_editors__.__esModule && $___46__46__47_editors__ || {default: $___46__46__47_editors__}),
  7237. getEditor = $__0.getEditor,
  7238. registerEditor = $__0.registerEditor;
  7239. var AutocompleteEditor = ($__autocompleteEditor__ = require("autocompleteEditor"), $__autocompleteEditor__ && $__autocompleteEditor__.__esModule && $__autocompleteEditor__ || {default: $__autocompleteEditor__}).AutocompleteEditor;
  7240. var DropdownEditor = function DropdownEditor() {
  7241. $traceurRuntime.superConstructor($DropdownEditor).apply(this, arguments);
  7242. };
  7243. var $DropdownEditor = DropdownEditor;
  7244. ($traceurRuntime.createClass)(DropdownEditor, {prepare: function(row, col, prop, td, originalValue, cellProperties) {
  7245. $traceurRuntime.superGet(this, $DropdownEditor.prototype, "prepare").call(this, row, col, prop, td, originalValue, cellProperties);
  7246. this.cellProperties.filter = false;
  7247. this.cellProperties.strict = true;
  7248. }}, {}, AutocompleteEditor);
  7249. Handsontable.hooks.add('beforeValidate', function(value, row, col, source) {
  7250. var cellMeta = this.getCellMeta(row, col);
  7251. if (cellMeta.editor === Handsontable.editors.DropdownEditor) {
  7252. if (cellMeta.strict === void 0) {
  7253. cellMeta.filter = false;
  7254. cellMeta.strict = true;
  7255. }
  7256. }
  7257. });
  7258. ;
  7259. registerEditor('dropdown', DropdownEditor);
  7260. //#
  7261. },{"autocompleteEditor":31,"editors":29}],35:[function(require,module,exports){
  7262. "use strict";
  7263. Object.defineProperties(exports, {
  7264. HandsontableEditor: {get: function() {
  7265. return HandsontableEditor;
  7266. }},
  7267. __esModule: {value: true}
  7268. });
  7269. var $___46__46__47_helpers_47_unicode__,
  7270. $___46__46__47_helpers_47_object__,
  7271. $___46__46__47_helpers_47_dom_47_element__,
  7272. $___46__46__47_helpers_47_dom_47_event__,
  7273. $___46__46__47_editors__,
  7274. $__textEditor__;
  7275. var KEY_CODES = ($___46__46__47_helpers_47_unicode__ = require("helpers/unicode"), $___46__46__47_helpers_47_unicode__ && $___46__46__47_helpers_47_unicode__.__esModule && $___46__46__47_helpers_47_unicode__ || {default: $___46__46__47_helpers_47_unicode__}).KEY_CODES;
  7276. var extend = ($___46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47_helpers_47_object__ && $___46__46__47_helpers_47_object__.__esModule && $___46__46__47_helpers_47_object__ || {default: $___46__46__47_helpers_47_object__}).extend;
  7277. var setCaretPosition = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}).setCaretPosition;
  7278. var $__3 = ($___46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47_helpers_47_dom_47_event__ && $___46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47_helpers_47_dom_47_event__}),
  7279. stopImmediatePropagation = $__3.stopImmediatePropagation,
  7280. isImmediatePropagationStopped = $__3.isImmediatePropagationStopped;
  7281. var $__4 = ($___46__46__47_editors__ = require("editors"), $___46__46__47_editors__ && $___46__46__47_editors__.__esModule && $___46__46__47_editors__ || {default: $___46__46__47_editors__}),
  7282. getEditor = $__4.getEditor,
  7283. registerEditor = $__4.registerEditor;
  7284. var TextEditor = ($__textEditor__ = require("textEditor"), $__textEditor__ && $__textEditor__.__esModule && $__textEditor__ || {default: $__textEditor__}).TextEditor;
  7285. var HandsontableEditor = TextEditor.prototype.extend();
  7286. HandsontableEditor.prototype.createElements = function() {
  7287. TextEditor.prototype.createElements.apply(this, arguments);
  7288. var DIV = document.createElement('DIV');
  7289. DIV.className = 'handsontableEditor';
  7290. this.TEXTAREA_PARENT.appendChild(DIV);
  7291. this.htContainer = DIV;
  7292. this.assignHooks();
  7293. };
  7294. HandsontableEditor.prototype.prepare = function(td, row, col, prop, value, cellProperties) {
  7295. TextEditor.prototype.prepare.apply(this, arguments);
  7296. var parent = this;
  7297. var options = {
  7298. startRows: 0,
  7299. startCols: 0,
  7300. minRows: 0,
  7301. minCols: 0,
  7302. className: 'listbox',
  7303. copyPaste: false,
  7304. autoColumnSize: false,
  7305. autoRowSize: false,
  7306. readOnly: true,
  7307. fillHandle: false,
  7308. afterOnCellMouseDown: function() {
  7309. var value = this.getValue();
  7310. if (value !== void 0) {
  7311. parent.setValue(value);
  7312. }
  7313. parent.instance.destroyEditor();
  7314. }
  7315. };
  7316. if (this.cellProperties.handsontable) {
  7317. extend(options, cellProperties.handsontable);
  7318. }
  7319. this.htOptions = options;
  7320. };
  7321. var onBeforeKeyDown = function(event) {
  7322. if (isImmediatePropagationStopped(event)) {
  7323. return;
  7324. }
  7325. var editor = this.getActiveEditor();
  7326. var innerHOT = editor.htEditor.getInstance();
  7327. var rowToSelect;
  7328. if (event.keyCode == KEY_CODES.ARROW_DOWN) {
  7329. if (innerHOT.getSelected()) {
  7330. var selectedRow = innerHOT.getSelected()[0];
  7331. var lastRow = innerHOT.countRows() - 1;
  7332. rowToSelect = Math.min(lastRow, selectedRow + 1);
  7333. } else {
  7334. rowToSelect = 0;
  7335. }
  7336. } else if (event.keyCode == KEY_CODES.ARROW_UP) {
  7337. if (innerHOT.getSelected()) {
  7338. var selectedRow = innerHOT.getSelected()[0];
  7339. rowToSelect = selectedRow - 1;
  7340. }
  7341. }
  7342. if (rowToSelect !== void 0) {
  7343. if (rowToSelect < 0) {
  7344. innerHOT.deselectCell();
  7345. } else {
  7346. innerHOT.selectCell(rowToSelect, 0);
  7347. }
  7348. if (innerHOT.getData().length) {
  7349. event.preventDefault();
  7350. stopImmediatePropagation(event);
  7351. editor.instance.listen();
  7352. editor.TEXTAREA.focus();
  7353. }
  7354. }
  7355. };
  7356. HandsontableEditor.prototype.open = function() {
  7357. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  7358. TextEditor.prototype.open.apply(this, arguments);
  7359. if (this.htEditor) {
  7360. this.htEditor.destroy();
  7361. }
  7362. this.htEditor = new Handsontable(this.htContainer, this.htOptions);
  7363. if (this.cellProperties.strict) {
  7364. this.htEditor.selectCell(0, 0);
  7365. this.TEXTAREA.style.visibility = 'hidden';
  7366. } else {
  7367. this.htEditor.deselectCell();
  7368. this.TEXTAREA.style.visibility = 'visible';
  7369. }
  7370. setCaretPosition(this.TEXTAREA, 0, this.TEXTAREA.value.length);
  7371. };
  7372. HandsontableEditor.prototype.close = function() {
  7373. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  7374. this.instance.listen();
  7375. TextEditor.prototype.close.apply(this, arguments);
  7376. };
  7377. HandsontableEditor.prototype.focus = function() {
  7378. this.instance.listen();
  7379. TextEditor.prototype.focus.apply(this, arguments);
  7380. };
  7381. HandsontableEditor.prototype.beginEditing = function(initialValue) {
  7382. var onBeginEditing = this.instance.getSettings().onBeginEditing;
  7383. if (onBeginEditing && onBeginEditing() === false) {
  7384. return;
  7385. }
  7386. TextEditor.prototype.beginEditing.apply(this, arguments);
  7387. };
  7388. HandsontableEditor.prototype.finishEditing = function(isCancelled, ctrlDown) {
  7389. if (this.htEditor && this.htEditor.isListening()) {
  7390. this.instance.listen();
  7391. }
  7392. if (this.htEditor && this.htEditor.getSelected()) {
  7393. var value = this.htEditor.getInstance().getValue();
  7394. if (value !== void 0) {
  7395. this.setValue(value);
  7396. }
  7397. }
  7398. return TextEditor.prototype.finishEditing.apply(this, arguments);
  7399. };
  7400. HandsontableEditor.prototype.assignHooks = function() {
  7401. var _this = this;
  7402. this.instance.addHook('afterDestroy', function() {
  7403. if (_this.htEditor) {
  7404. _this.htEditor.destroy();
  7405. }
  7406. });
  7407. };
  7408. ;
  7409. registerEditor('handsontable', HandsontableEditor);
  7410. //#
  7411. },{"editors":29,"helpers/dom/element":45,"helpers/dom/event":46,"helpers/object":50,"helpers/unicode":53,"textEditor":40}],36:[function(require,module,exports){
  7412. "use strict";
  7413. Object.defineProperties(exports, {
  7414. MobileTextEditor: {get: function() {
  7415. return MobileTextEditor;
  7416. }},
  7417. __esModule: {value: true}
  7418. });
  7419. var $___46__46__47_helpers_47_unicode__,
  7420. $___46__46__47_helpers_47_dom_47_event__,
  7421. $___46__46__47_helpers_47_dom_47_element__,
  7422. $___46__46__47_editors__,
  7423. $___95_baseEditor__,
  7424. $___46__46__47_eventManager__;
  7425. var KEY_CODES = ($___46__46__47_helpers_47_unicode__ = require("helpers/unicode"), $___46__46__47_helpers_47_unicode__ && $___46__46__47_helpers_47_unicode__.__esModule && $___46__46__47_helpers_47_unicode__ || {default: $___46__46__47_helpers_47_unicode__}).KEY_CODES;
  7426. var $__1 = ($___46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47_helpers_47_dom_47_event__ && $___46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47_helpers_47_dom_47_event__}),
  7427. stopImmediatePropagation = $__1.stopImmediatePropagation,
  7428. isImmediatePropagationStopped = $__1.isImmediatePropagationStopped;
  7429. var $__2 = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}),
  7430. addClass = $__2.addClass,
  7431. getScrollLeft = $__2.getScrollLeft,
  7432. getScrollTop = $__2.getScrollTop,
  7433. hasClass = $__2.hasClass,
  7434. isChildOf = $__2.isChildOf,
  7435. offset = $__2.offset,
  7436. outerHeight = $__2.outerHeight,
  7437. outerWidth = $__2.outerWidth,
  7438. removeClass = $__2.removeClass,
  7439. setCaretPosition = $__2.setCaretPosition;
  7440. var $__3 = ($___46__46__47_editors__ = require("editors"), $___46__46__47_editors__ && $___46__46__47_editors__.__esModule && $___46__46__47_editors__ || {default: $___46__46__47_editors__}),
  7441. getEditor = $__3.getEditor,
  7442. registerEditor = $__3.registerEditor;
  7443. var BaseEditor = ($___95_baseEditor__ = require("_baseEditor"), $___95_baseEditor__ && $___95_baseEditor__.__esModule && $___95_baseEditor__ || {default: $___95_baseEditor__}).BaseEditor;
  7444. var eventManagerObject = ($___46__46__47_eventManager__ = require("eventManager"), $___46__46__47_eventManager__ && $___46__46__47_eventManager__.__esModule && $___46__46__47_eventManager__ || {default: $___46__46__47_eventManager__}).eventManager;
  7445. var MobileTextEditor = BaseEditor.prototype.extend(),
  7446. domDimensionsCache = {};
  7447. var createControls = function() {
  7448. this.controls = {};
  7449. this.controls.leftButton = document.createElement('DIV');
  7450. this.controls.leftButton.className = 'leftButton';
  7451. this.controls.rightButton = document.createElement('DIV');
  7452. this.controls.rightButton.className = 'rightButton';
  7453. this.controls.upButton = document.createElement('DIV');
  7454. this.controls.upButton.className = 'upButton';
  7455. this.controls.downButton = document.createElement('DIV');
  7456. this.controls.downButton.className = 'downButton';
  7457. for (var button in this.controls) {
  7458. if (this.controls.hasOwnProperty(button)) {
  7459. this.positionControls.appendChild(this.controls[button]);
  7460. }
  7461. }
  7462. };
  7463. MobileTextEditor.prototype.valueChanged = function() {
  7464. return this.initValue != this.getValue();
  7465. };
  7466. MobileTextEditor.prototype.init = function() {
  7467. var that = this;
  7468. this.eventManager = eventManagerObject(this.instance);
  7469. this.createElements();
  7470. this.bindEvents();
  7471. this.instance.addHook('afterDestroy', function() {
  7472. that.destroy();
  7473. });
  7474. };
  7475. MobileTextEditor.prototype.getValue = function() {
  7476. return this.TEXTAREA.value;
  7477. };
  7478. MobileTextEditor.prototype.setValue = function(newValue) {
  7479. this.initValue = newValue;
  7480. this.TEXTAREA.value = newValue;
  7481. };
  7482. MobileTextEditor.prototype.createElements = function() {
  7483. this.editorContainer = document.createElement('DIV');
  7484. this.editorContainer.className = 'htMobileEditorContainer';
  7485. this.cellPointer = document.createElement('DIV');
  7486. this.cellPointer.className = 'cellPointer';
  7487. this.moveHandle = document.createElement('DIV');
  7488. this.moveHandle.className = 'moveHandle';
  7489. this.inputPane = document.createElement('DIV');
  7490. this.inputPane.className = 'inputs';
  7491. this.positionControls = document.createElement('DIV');
  7492. this.positionControls.className = 'positionControls';
  7493. this.TEXTAREA = document.createElement('TEXTAREA');
  7494. addClass(this.TEXTAREA, 'handsontableInput');
  7495. this.inputPane.appendChild(this.TEXTAREA);
  7496. this.editorContainer.appendChild(this.cellPointer);
  7497. this.editorContainer.appendChild(this.moveHandle);
  7498. this.editorContainer.appendChild(this.inputPane);
  7499. this.editorContainer.appendChild(this.positionControls);
  7500. createControls.call(this);
  7501. document.body.appendChild(this.editorContainer);
  7502. };
  7503. MobileTextEditor.prototype.onBeforeKeyDown = function(event) {
  7504. var instance = this;
  7505. var that = instance.getActiveEditor();
  7506. if (event.target !== that.TEXTAREA || isImmediatePropagationStopped(event)) {
  7507. return;
  7508. }
  7509. switch (event.keyCode) {
  7510. case KEY_CODES.ENTER:
  7511. that.close();
  7512. event.preventDefault();
  7513. break;
  7514. case KEY_CODES.BACKSPACE:
  7515. stopImmediatePropagation(event);
  7516. break;
  7517. }
  7518. };
  7519. MobileTextEditor.prototype.open = function() {
  7520. this.instance.addHook('beforeKeyDown', this.onBeforeKeyDown);
  7521. addClass(this.editorContainer, 'active');
  7522. removeClass(this.cellPointer, 'hidden');
  7523. this.updateEditorPosition();
  7524. };
  7525. MobileTextEditor.prototype.focus = function() {
  7526. this.TEXTAREA.focus();
  7527. setCaretPosition(this.TEXTAREA, this.TEXTAREA.value.length);
  7528. };
  7529. MobileTextEditor.prototype.close = function() {
  7530. this.TEXTAREA.blur();
  7531. this.instance.removeHook('beforeKeyDown', this.onBeforeKeyDown);
  7532. removeClass(this.editorContainer, 'active');
  7533. };
  7534. MobileTextEditor.prototype.scrollToView = function() {
  7535. var coords = this.instance.getSelectedRange().highlight;
  7536. this.instance.view.scrollViewport(coords);
  7537. };
  7538. MobileTextEditor.prototype.hideCellPointer = function() {
  7539. if (!hasClass(this.cellPointer, 'hidden')) {
  7540. addClass(this.cellPointer, 'hidden');
  7541. }
  7542. };
  7543. MobileTextEditor.prototype.updateEditorPosition = function(x, y) {
  7544. if (x && y) {
  7545. x = parseInt(x, 10);
  7546. y = parseInt(y, 10);
  7547. this.editorContainer.style.top = y + 'px';
  7548. this.editorContainer.style.left = x + 'px';
  7549. } else {
  7550. var selection = this.instance.getSelected(),
  7551. selectedCell = this.instance.getCell(selection[0], selection[1]);
  7552. if (!domDimensionsCache.cellPointer) {
  7553. domDimensionsCache.cellPointer = {
  7554. height: outerHeight(this.cellPointer),
  7555. width: outerWidth(this.cellPointer)
  7556. };
  7557. }
  7558. if (!domDimensionsCache.editorContainer) {
  7559. domDimensionsCache.editorContainer = {width: outerWidth(this.editorContainer)};
  7560. }
  7561. if (selectedCell !== undefined) {
  7562. var scrollLeft = this.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer == window ? 0 : getScrollLeft(this.instance.view.wt.wtOverlays.leftOverlay.holder);
  7563. var scrollTop = this.instance.view.wt.wtOverlays.topOverlay.trimmingContainer == window ? 0 : getScrollTop(this.instance.view.wt.wtOverlays.topOverlay.holder);
  7564. var selectedCellOffset = offset(selectedCell),
  7565. selectedCellWidth = outerWidth(selectedCell),
  7566. currentScrollPosition = {
  7567. x: scrollLeft,
  7568. y: scrollTop
  7569. };
  7570. this.editorContainer.style.top = parseInt(selectedCellOffset.top + outerHeight(selectedCell) - currentScrollPosition.y + domDimensionsCache.cellPointer.height, 10) + 'px';
  7571. this.editorContainer.style.left = parseInt((window.innerWidth / 2) - (domDimensionsCache.editorContainer.width / 2), 10) + 'px';
  7572. if (selectedCellOffset.left + selectedCellWidth / 2 > parseInt(this.editorContainer.style.left, 10) + domDimensionsCache.editorContainer.width) {
  7573. this.editorContainer.style.left = window.innerWidth - domDimensionsCache.editorContainer.width + 'px';
  7574. } else if (selectedCellOffset.left + selectedCellWidth / 2 < parseInt(this.editorContainer.style.left, 10) + 20) {
  7575. this.editorContainer.style.left = 0 + 'px';
  7576. }
  7577. this.cellPointer.style.left = parseInt(selectedCellOffset.left - (domDimensionsCache.cellPointer.width / 2) - offset(this.editorContainer).left + (selectedCellWidth / 2) - currentScrollPosition.x, 10) + 'px';
  7578. }
  7579. }
  7580. };
  7581. MobileTextEditor.prototype.updateEditorData = function() {
  7582. var selected = this.instance.getSelected(),
  7583. selectedValue = this.instance.getDataAtCell(selected[0], selected[1]);
  7584. this.row = selected[0];
  7585. this.col = selected[1];
  7586. this.setValue(selectedValue);
  7587. this.updateEditorPosition();
  7588. };
  7589. MobileTextEditor.prototype.prepareAndSave = function() {
  7590. var val;
  7591. if (!this.valueChanged()) {
  7592. return true;
  7593. }
  7594. if (this.instance.getSettings().trimWhitespace) {
  7595. val = [[String.prototype.trim.call(this.getValue())]];
  7596. } else {
  7597. val = [[this.getValue()]];
  7598. }
  7599. this.saveValue(val);
  7600. };
  7601. MobileTextEditor.prototype.bindEvents = function() {
  7602. var that = this;
  7603. this.eventManager.addEventListener(this.controls.leftButton, 'touchend', function(event) {
  7604. that.prepareAndSave();
  7605. that.instance.selection.transformStart(0, -1, null, true);
  7606. that.updateEditorData();
  7607. event.preventDefault();
  7608. });
  7609. this.eventManager.addEventListener(this.controls.rightButton, 'touchend', function(event) {
  7610. that.prepareAndSave();
  7611. that.instance.selection.transformStart(0, 1, null, true);
  7612. that.updateEditorData();
  7613. event.preventDefault();
  7614. });
  7615. this.eventManager.addEventListener(this.controls.upButton, 'touchend', function(event) {
  7616. that.prepareAndSave();
  7617. that.instance.selection.transformStart(-1, 0, null, true);
  7618. that.updateEditorData();
  7619. event.preventDefault();
  7620. });
  7621. this.eventManager.addEventListener(this.controls.downButton, 'touchend', function(event) {
  7622. that.prepareAndSave();
  7623. that.instance.selection.transformStart(1, 0, null, true);
  7624. that.updateEditorData();
  7625. event.preventDefault();
  7626. });
  7627. this.eventManager.addEventListener(this.moveHandle, 'touchstart', function(event) {
  7628. if (event.touches.length == 1) {
  7629. var touch = event.touches[0],
  7630. onTouchPosition = {
  7631. x: that.editorContainer.offsetLeft,
  7632. y: that.editorContainer.offsetTop
  7633. },
  7634. onTouchOffset = {
  7635. x: touch.pageX - onTouchPosition.x,
  7636. y: touch.pageY - onTouchPosition.y
  7637. };
  7638. that.eventManager.addEventListener(this, 'touchmove', function(event) {
  7639. var touch = event.touches[0];
  7640. that.updateEditorPosition(touch.pageX - onTouchOffset.x, touch.pageY - onTouchOffset.y);
  7641. that.hideCellPointer();
  7642. event.preventDefault();
  7643. });
  7644. }
  7645. });
  7646. this.eventManager.addEventListener(document.body, 'touchend', function(event) {
  7647. if (!isChildOf(event.target, that.editorContainer) && !isChildOf(event.target, that.instance.rootElement)) {
  7648. that.close();
  7649. }
  7650. });
  7651. this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.leftOverlay.holder, 'scroll', function(event) {
  7652. if (that.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer != window) {
  7653. that.hideCellPointer();
  7654. }
  7655. });
  7656. this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.topOverlay.holder, 'scroll', function(event) {
  7657. if (that.instance.view.wt.wtOverlays.topOverlay.trimmingContainer != window) {
  7658. that.hideCellPointer();
  7659. }
  7660. });
  7661. };
  7662. MobileTextEditor.prototype.destroy = function() {
  7663. this.eventManager.clear();
  7664. this.editorContainer.parentNode.removeChild(this.editorContainer);
  7665. };
  7666. ;
  7667. registerEditor('mobile', MobileTextEditor);
  7668. //#
  7669. },{"_baseEditor":30,"editors":29,"eventManager":41,"helpers/dom/element":45,"helpers/dom/event":46,"helpers/unicode":53}],37:[function(require,module,exports){
  7670. "use strict";
  7671. Object.defineProperties(exports, {
  7672. NumericEditor: {get: function() {
  7673. return NumericEditor;
  7674. }},
  7675. __esModule: {value: true}
  7676. });
  7677. var $__numeral__,
  7678. $___46__46__47_editors__,
  7679. $__textEditor__;
  7680. var numeral = ($__numeral__ = require("numeral"), $__numeral__ && $__numeral__.__esModule && $__numeral__ || {default: $__numeral__}).default;
  7681. var $__1 = ($___46__46__47_editors__ = require("editors"), $___46__46__47_editors__ && $___46__46__47_editors__.__esModule && $___46__46__47_editors__ || {default: $___46__46__47_editors__}),
  7682. getEditor = $__1.getEditor,
  7683. registerEditor = $__1.registerEditor;
  7684. var TextEditor = ($__textEditor__ = require("textEditor"), $__textEditor__ && $__textEditor__.__esModule && $__textEditor__ || {default: $__textEditor__}).TextEditor;
  7685. var NumericEditor = function NumericEditor() {
  7686. $traceurRuntime.superConstructor($NumericEditor).apply(this, arguments);
  7687. };
  7688. var $NumericEditor = NumericEditor;
  7689. ($traceurRuntime.createClass)(NumericEditor, {beginEditing: function(initialValue) {
  7690. if (typeof initialValue === 'undefined' && this.originalValue) {
  7691. if (typeof this.cellProperties.language !== 'undefined') {
  7692. numeral.language(this.cellProperties.language);
  7693. }
  7694. var decimalDelimiter = numeral.languageData().delimiters.decimal;
  7695. initialValue = ('' + this.originalValue).replace('.', decimalDelimiter);
  7696. }
  7697. $traceurRuntime.superGet(this, $NumericEditor.prototype, "beginEditing").call(this, initialValue);
  7698. }}, {}, TextEditor);
  7699. ;
  7700. registerEditor('numeric', NumericEditor);
  7701. //#
  7702. },{"editors":29,"numeral":"numeral","textEditor":40}],38:[function(require,module,exports){
  7703. "use strict";
  7704. Object.defineProperties(exports, {
  7705. PasswordEditor: {get: function() {
  7706. return PasswordEditor;
  7707. }},
  7708. __esModule: {value: true}
  7709. });
  7710. var $___46__46__47_helpers_47_dom_47_element__,
  7711. $___46__46__47_editors__,
  7712. $__textEditor__;
  7713. var empty = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}).empty;
  7714. var $__1 = ($___46__46__47_editors__ = require("editors"), $___46__46__47_editors__ && $___46__46__47_editors__.__esModule && $___46__46__47_editors__ || {default: $___46__46__47_editors__}),
  7715. getEditor = $__1.getEditor,
  7716. registerEditor = $__1.registerEditor;
  7717. var TextEditor = ($__textEditor__ = require("textEditor"), $__textEditor__ && $__textEditor__.__esModule && $__textEditor__ || {default: $__textEditor__}).TextEditor;
  7718. var PasswordEditor = function PasswordEditor() {
  7719. $traceurRuntime.superConstructor($PasswordEditor).apply(this, arguments);
  7720. };
  7721. var $PasswordEditor = PasswordEditor;
  7722. ($traceurRuntime.createClass)(PasswordEditor, {createElements: function() {
  7723. $traceurRuntime.superGet(this, $PasswordEditor.prototype, "createElements").call(this);
  7724. this.TEXTAREA = document.createElement('input');
  7725. this.TEXTAREA.setAttribute('type', 'password');
  7726. this.TEXTAREA.className = 'handsontableInput';
  7727. this.textareaStyle = this.TEXTAREA.style;
  7728. this.textareaStyle.width = 0;
  7729. this.textareaStyle.height = 0;
  7730. empty(this.TEXTAREA_PARENT);
  7731. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  7732. }}, {}, TextEditor);
  7733. ;
  7734. registerEditor('password', PasswordEditor);
  7735. //#
  7736. },{"editors":29,"helpers/dom/element":45,"textEditor":40}],39:[function(require,module,exports){
  7737. "use strict";
  7738. Object.defineProperties(exports, {
  7739. SelectEditor: {get: function() {
  7740. return SelectEditor;
  7741. }},
  7742. __esModule: {value: true}
  7743. });
  7744. var $___46__46__47_helpers_47_dom_47_element__,
  7745. $___46__46__47_helpers_47_dom_47_event__,
  7746. $___46__46__47_helpers_47_unicode__,
  7747. $___46__46__47_editors__,
  7748. $___95_baseEditor__;
  7749. var $__0 = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}),
  7750. addClass = $__0.addClass,
  7751. empty = $__0.empty,
  7752. fastInnerHTML = $__0.fastInnerHTML,
  7753. getComputedStyle = $__0.getComputedStyle,
  7754. getCssTransform = $__0.getCssTransform,
  7755. getScrollableElement = $__0.getScrollableElement,
  7756. offset = $__0.offset,
  7757. outerHeight = $__0.outerHeight,
  7758. outerWidth = $__0.outerWidth,
  7759. resetCssTransform = $__0.resetCssTransform;
  7760. var stopImmediatePropagation = ($___46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47_helpers_47_dom_47_event__ && $___46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47_helpers_47_dom_47_event__}).stopImmediatePropagation;
  7761. var KEY_CODES = ($___46__46__47_helpers_47_unicode__ = require("helpers/unicode"), $___46__46__47_helpers_47_unicode__ && $___46__46__47_helpers_47_unicode__.__esModule && $___46__46__47_helpers_47_unicode__ || {default: $___46__46__47_helpers_47_unicode__}).KEY_CODES;
  7762. var $__3 = ($___46__46__47_editors__ = require("editors"), $___46__46__47_editors__ && $___46__46__47_editors__.__esModule && $___46__46__47_editors__ || {default: $___46__46__47_editors__}),
  7763. getEditor = $__3.getEditor,
  7764. registerEditor = $__3.registerEditor;
  7765. var BaseEditor = ($___95_baseEditor__ = require("_baseEditor"), $___95_baseEditor__ && $___95_baseEditor__.__esModule && $___95_baseEditor__ || {default: $___95_baseEditor__}).BaseEditor;
  7766. var SelectEditor = BaseEditor.prototype.extend();
  7767. SelectEditor.prototype.init = function() {
  7768. this.select = document.createElement('SELECT');
  7769. addClass(this.select, 'htSelectEditor');
  7770. this.select.style.display = 'none';
  7771. this.instance.rootElement.appendChild(this.select);
  7772. this.registerHooks();
  7773. };
  7774. SelectEditor.prototype.registerHooks = function() {
  7775. var $__5 = this;
  7776. this.instance.addHook('afterScrollHorizontally', (function() {
  7777. return $__5.refreshDimensions();
  7778. }));
  7779. this.instance.addHook('afterScrollVertically', (function() {
  7780. return $__5.refreshDimensions();
  7781. }));
  7782. this.instance.addHook('afterColumnResize', (function() {
  7783. return $__5.refreshDimensions();
  7784. }));
  7785. this.instance.addHook('afterRowResize', (function() {
  7786. return $__5.refreshDimensions();
  7787. }));
  7788. };
  7789. SelectEditor.prototype.prepare = function() {
  7790. BaseEditor.prototype.prepare.apply(this, arguments);
  7791. var selectOptions = this.cellProperties.selectOptions;
  7792. var options;
  7793. if (typeof selectOptions == 'function') {
  7794. options = this.prepareOptions(selectOptions(this.row, this.col, this.prop));
  7795. } else {
  7796. options = this.prepareOptions(selectOptions);
  7797. }
  7798. empty(this.select);
  7799. for (var option in options) {
  7800. if (options.hasOwnProperty(option)) {
  7801. var optionElement = document.createElement('OPTION');
  7802. optionElement.value = option;
  7803. fastInnerHTML(optionElement, options[option]);
  7804. this.select.appendChild(optionElement);
  7805. }
  7806. }
  7807. };
  7808. SelectEditor.prototype.prepareOptions = function(optionsToPrepare) {
  7809. var preparedOptions = {};
  7810. if (Array.isArray(optionsToPrepare)) {
  7811. for (var i = 0,
  7812. len = optionsToPrepare.length; i < len; i++) {
  7813. preparedOptions[optionsToPrepare[i]] = optionsToPrepare[i];
  7814. }
  7815. } else if (typeof optionsToPrepare == 'object') {
  7816. preparedOptions = optionsToPrepare;
  7817. }
  7818. return preparedOptions;
  7819. };
  7820. SelectEditor.prototype.getValue = function() {
  7821. return this.select.value;
  7822. };
  7823. SelectEditor.prototype.setValue = function(value) {
  7824. this.select.value = value;
  7825. };
  7826. var onBeforeKeyDown = function(event) {
  7827. var instance = this;
  7828. var editor = instance.getActiveEditor();
  7829. switch (event.keyCode) {
  7830. case KEY_CODES.ARROW_UP:
  7831. var previousOptionIndex = editor.select.selectedIndex - 1;
  7832. if (previousOptionIndex >= 0) {
  7833. editor.select[previousOptionIndex].selected = true;
  7834. }
  7835. stopImmediatePropagation(event);
  7836. event.preventDefault();
  7837. break;
  7838. case KEY_CODES.ARROW_DOWN:
  7839. var nextOptionIndex = editor.select.selectedIndex + 1;
  7840. if (nextOptionIndex <= editor.select.length - 1) {
  7841. editor.select[nextOptionIndex].selected = true;
  7842. }
  7843. stopImmediatePropagation(event);
  7844. event.preventDefault();
  7845. break;
  7846. }
  7847. };
  7848. SelectEditor.prototype.open = function() {
  7849. this._opened = true;
  7850. this.refreshDimensions();
  7851. this.select.style.display = '';
  7852. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  7853. };
  7854. SelectEditor.prototype.close = function() {
  7855. this._opened = false;
  7856. this.select.style.display = 'none';
  7857. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  7858. };
  7859. SelectEditor.prototype.focus = function() {
  7860. this.select.focus();
  7861. };
  7862. SelectEditor.prototype.refreshDimensions = function() {
  7863. if (this.state !== Handsontable.EditorState.EDITING) {
  7864. return;
  7865. }
  7866. this.TD = this.getEditedCell();
  7867. if (!this.TD) {
  7868. this.close();
  7869. return;
  7870. }
  7871. var width = outerWidth(this.TD) + 1,
  7872. height = outerHeight(this.TD) + 1,
  7873. currentOffset = offset(this.TD),
  7874. containerOffset = offset(this.instance.rootElement),
  7875. scrollableContainer = getScrollableElement(this.TD),
  7876. editTop = currentOffset.top - containerOffset.top - 1 - (scrollableContainer.scrollTop || 0),
  7877. editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0),
  7878. editorSection = this.checkEditorSection(),
  7879. cssTransformOffset;
  7880. var settings = this.instance.getSettings();
  7881. var rowHeadersCount = settings.rowHeaders ? 1 : 0;
  7882. var colHeadersCount = settings.colHeaders ? 1 : 0;
  7883. switch (editorSection) {
  7884. case 'top':
  7885. cssTransformOffset = getCssTransform(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  7886. break;
  7887. case 'left':
  7888. cssTransformOffset = getCssTransform(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  7889. break;
  7890. case 'top-left-corner':
  7891. cssTransformOffset = getCssTransform(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  7892. break;
  7893. case 'bottom-left-corner':
  7894. cssTransformOffset = getCssTransform(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  7895. break;
  7896. case 'bottom':
  7897. cssTransformOffset = getCssTransform(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode);
  7898. break;
  7899. }
  7900. if (this.instance.getSelected()[0] === 0) {
  7901. editTop += 1;
  7902. }
  7903. if (this.instance.getSelected()[1] === 0) {
  7904. editLeft += 1;
  7905. }
  7906. var selectStyle = this.select.style;
  7907. if (cssTransformOffset && cssTransformOffset != -1) {
  7908. selectStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  7909. } else {
  7910. resetCssTransform(this.select);
  7911. }
  7912. var cellComputedStyle = getComputedStyle(this.TD);
  7913. if (parseInt(cellComputedStyle.borderTopWidth, 10) > 0) {
  7914. height -= 1;
  7915. }
  7916. if (parseInt(cellComputedStyle.borderLeftWidth, 10) > 0) {
  7917. width -= 1;
  7918. }
  7919. selectStyle.height = height + 'px';
  7920. selectStyle.minWidth = width + 'px';
  7921. selectStyle.top = editTop + 'px';
  7922. selectStyle.left = editLeft + 'px';
  7923. selectStyle.margin = '0px';
  7924. };
  7925. SelectEditor.prototype.getEditedCell = function() {
  7926. var editorSection = this.checkEditorSection(),
  7927. editedCell;
  7928. switch (editorSection) {
  7929. case 'top':
  7930. editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
  7931. row: this.row,
  7932. col: this.col
  7933. });
  7934. this.select.style.zIndex = 101;
  7935. break;
  7936. case 'corner':
  7937. editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
  7938. row: this.row,
  7939. col: this.col
  7940. });
  7941. this.select.style.zIndex = 103;
  7942. break;
  7943. case 'left':
  7944. editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
  7945. row: this.row,
  7946. col: this.col
  7947. });
  7948. this.select.style.zIndex = 102;
  7949. break;
  7950. default:
  7951. editedCell = this.instance.getCell(this.row, this.col);
  7952. this.select.style.zIndex = '';
  7953. break;
  7954. }
  7955. return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
  7956. };
  7957. ;
  7958. registerEditor('select', SelectEditor);
  7959. //#
  7960. },{"_baseEditor":30,"editors":29,"helpers/dom/element":45,"helpers/dom/event":46,"helpers/unicode":53}],40:[function(require,module,exports){
  7961. "use strict";
  7962. Object.defineProperties(exports, {
  7963. TextEditor: {get: function() {
  7964. return TextEditor;
  7965. }},
  7966. __esModule: {value: true}
  7967. });
  7968. var $___46__46__47_helpers_47_dom_47_element__,
  7969. $__autoResize__,
  7970. $___95_baseEditor__,
  7971. $___46__46__47_eventManager__,
  7972. $___46__46__47_editors__,
  7973. $___46__46__47_helpers_47_unicode__,
  7974. $___46__46__47_helpers_47_dom_47_event__;
  7975. var $__0 = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}),
  7976. addClass = $__0.addClass,
  7977. getCaretPosition = $__0.getCaretPosition,
  7978. getComputedStyle = $__0.getComputedStyle,
  7979. getCssTransform = $__0.getCssTransform,
  7980. getScrollableElement = $__0.getScrollableElement,
  7981. innerWidth = $__0.innerWidth,
  7982. offset = $__0.offset,
  7983. resetCssTransform = $__0.resetCssTransform,
  7984. setCaretPosition = $__0.setCaretPosition;
  7985. var autoResize = ($__autoResize__ = require("autoResize"), $__autoResize__ && $__autoResize__.__esModule && $__autoResize__ || {default: $__autoResize__}).default;
  7986. var BaseEditor = ($___95_baseEditor__ = require("_baseEditor"), $___95_baseEditor__ && $___95_baseEditor__.__esModule && $___95_baseEditor__ || {default: $___95_baseEditor__}).BaseEditor;
  7987. var eventManagerObject = ($___46__46__47_eventManager__ = require("eventManager"), $___46__46__47_eventManager__ && $___46__46__47_eventManager__.__esModule && $___46__46__47_eventManager__ || {default: $___46__46__47_eventManager__}).eventManager;
  7988. var $__4 = ($___46__46__47_editors__ = require("editors"), $___46__46__47_editors__ && $___46__46__47_editors__.__esModule && $___46__46__47_editors__ || {default: $___46__46__47_editors__}),
  7989. getEditor = $__4.getEditor,
  7990. registerEditor = $__4.registerEditor;
  7991. var KEY_CODES = ($___46__46__47_helpers_47_unicode__ = require("helpers/unicode"), $___46__46__47_helpers_47_unicode__ && $___46__46__47_helpers_47_unicode__.__esModule && $___46__46__47_helpers_47_unicode__ || {default: $___46__46__47_helpers_47_unicode__}).KEY_CODES;
  7992. var $__6 = ($___46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47_helpers_47_dom_47_event__ && $___46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47_helpers_47_dom_47_event__}),
  7993. stopPropagation = $__6.stopPropagation,
  7994. stopImmediatePropagation = $__6.stopImmediatePropagation,
  7995. isImmediatePropagationStopped = $__6.isImmediatePropagationStopped;
  7996. var TextEditor = BaseEditor.prototype.extend();
  7997. TextEditor.prototype.init = function() {
  7998. var that = this;
  7999. this.createElements();
  8000. this.eventManager = eventManagerObject(this);
  8001. this.bindEvents();
  8002. this.autoResize = autoResize();
  8003. this.instance.addHook('afterDestroy', function() {
  8004. that.destroy();
  8005. });
  8006. };
  8007. TextEditor.prototype.getValue = function() {
  8008. return this.TEXTAREA.value;
  8009. };
  8010. TextEditor.prototype.setValue = function(newValue) {
  8011. this.TEXTAREA.value = newValue;
  8012. };
  8013. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  8014. var instance = this,
  8015. that = instance.getActiveEditor(),
  8016. ctrlDown;
  8017. ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  8018. if (event.target !== that.TEXTAREA || isImmediatePropagationStopped(event)) {
  8019. return;
  8020. }
  8021. if (event.keyCode === 17 || event.keyCode === 224 || event.keyCode === 91 || event.keyCode === 93) {
  8022. stopImmediatePropagation(event);
  8023. return;
  8024. }
  8025. switch (event.keyCode) {
  8026. case KEY_CODES.ARROW_RIGHT:
  8027. if (that.isInFullEditMode()) {
  8028. if ((!that.isWaiting() && !that.allowKeyEventPropagation) || (!that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode))) {
  8029. stopImmediatePropagation(event);
  8030. }
  8031. }
  8032. break;
  8033. case KEY_CODES.ARROW_LEFT:
  8034. if (that.isInFullEditMode()) {
  8035. if ((!that.isWaiting() && !that.allowKeyEventPropagation) || (!that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode))) {
  8036. stopImmediatePropagation(event);
  8037. }
  8038. }
  8039. break;
  8040. case KEY_CODES.ARROW_UP:
  8041. case KEY_CODES.ARROW_DOWN:
  8042. if (that.isInFullEditMode()) {
  8043. if ((!that.isWaiting() && !that.allowKeyEventPropagation) || (!that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode))) {
  8044. stopImmediatePropagation(event);
  8045. }
  8046. }
  8047. break;
  8048. case KEY_CODES.ENTER:
  8049. var selected = that.instance.getSelected();
  8050. var isMultipleSelection = !(selected[0] === selected[2] && selected[1] === selected[3]);
  8051. if ((ctrlDown && !isMultipleSelection) || event.altKey) {
  8052. if (that.isOpened()) {
  8053. var caretPosition = getCaretPosition(that.TEXTAREA),
  8054. value = that.getValue();
  8055. var newValue = value.slice(0, caretPosition) + '\n' + value.slice(caretPosition);
  8056. that.setValue(newValue);
  8057. setCaretPosition(that.TEXTAREA, caretPosition + 1);
  8058. } else {
  8059. that.beginEditing(that.originalValue + '\n');
  8060. }
  8061. stopImmediatePropagation(event);
  8062. }
  8063. event.preventDefault();
  8064. break;
  8065. case KEY_CODES.A:
  8066. case KEY_CODES.X:
  8067. case KEY_CODES.C:
  8068. case KEY_CODES.V:
  8069. if (ctrlDown) {
  8070. stopImmediatePropagation(event);
  8071. }
  8072. break;
  8073. case KEY_CODES.BACKSPACE:
  8074. case KEY_CODES.DELETE:
  8075. case KEY_CODES.HOME:
  8076. case KEY_CODES.END:
  8077. stopImmediatePropagation(event);
  8078. break;
  8079. }
  8080. if ([KEY_CODES.ARROW_UP, KEY_CODES.ARROW_RIGHT, KEY_CODES.ARROW_DOWN, KEY_CODES.ARROW_LEFT].indexOf(event.keyCode) === -1) {
  8081. that.autoResize.resize(String.fromCharCode(event.keyCode));
  8082. }
  8083. };
  8084. TextEditor.prototype.open = function() {
  8085. this.refreshDimensions();
  8086. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  8087. };
  8088. TextEditor.prototype.close = function(tdOutside) {
  8089. this.textareaParentStyle.display = 'none';
  8090. this.autoResize.unObserve();
  8091. if (document.activeElement === this.TEXTAREA) {
  8092. this.instance.listen();
  8093. }
  8094. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  8095. };
  8096. TextEditor.prototype.focus = function() {
  8097. this.TEXTAREA.focus();
  8098. setCaretPosition(this.TEXTAREA, this.TEXTAREA.value.length);
  8099. };
  8100. TextEditor.prototype.createElements = function() {
  8101. this.TEXTAREA = document.createElement('TEXTAREA');
  8102. addClass(this.TEXTAREA, 'handsontableInput');
  8103. this.textareaStyle = this.TEXTAREA.style;
  8104. this.textareaStyle.width = 0;
  8105. this.textareaStyle.height = 0;
  8106. this.TEXTAREA_PARENT = document.createElement('DIV');
  8107. addClass(this.TEXTAREA_PARENT, 'handsontableInputHolder');
  8108. this.textareaParentStyle = this.TEXTAREA_PARENT.style;
  8109. this.textareaParentStyle.top = 0;
  8110. this.textareaParentStyle.left = 0;
  8111. this.textareaParentStyle.display = 'none';
  8112. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  8113. this.instance.rootElement.appendChild(this.TEXTAREA_PARENT);
  8114. var that = this;
  8115. this.instance._registerTimeout(setTimeout(function() {
  8116. that.refreshDimensions();
  8117. }, 0));
  8118. };
  8119. TextEditor.prototype.getEditedCell = function() {
  8120. var editorSection = this.checkEditorSection(),
  8121. editedCell;
  8122. switch (editorSection) {
  8123. case 'top':
  8124. editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
  8125. row: this.row,
  8126. col: this.col
  8127. });
  8128. this.textareaParentStyle.zIndex = 101;
  8129. break;
  8130. case 'top-left-corner':
  8131. editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
  8132. row: this.row,
  8133. col: this.col
  8134. });
  8135. this.textareaParentStyle.zIndex = 103;
  8136. break;
  8137. case 'bottom-left-corner':
  8138. editedCell = this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell({
  8139. row: this.row,
  8140. col: this.col
  8141. });
  8142. this.textareaParentStyle.zIndex = 103;
  8143. break;
  8144. case 'left':
  8145. editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
  8146. row: this.row,
  8147. col: this.col
  8148. });
  8149. this.textareaParentStyle.zIndex = 102;
  8150. break;
  8151. case 'bottom':
  8152. editedCell = this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.getCell({
  8153. row: this.row,
  8154. col: this.col
  8155. });
  8156. this.textareaParentStyle.zIndex = 102;
  8157. break;
  8158. default:
  8159. editedCell = this.instance.getCell(this.row, this.col);
  8160. this.textareaParentStyle.zIndex = '';
  8161. break;
  8162. }
  8163. return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
  8164. };
  8165. TextEditor.prototype.refreshDimensions = function() {
  8166. if (this.state !== Handsontable.EditorState.EDITING) {
  8167. return;
  8168. }
  8169. this.TD = this.getEditedCell();
  8170. if (!this.TD) {
  8171. this.close(true);
  8172. return;
  8173. }
  8174. var currentOffset = offset(this.TD),
  8175. containerOffset = offset(this.instance.rootElement),
  8176. scrollableContainer = getScrollableElement(this.TD),
  8177. totalRowsCount = this.instance.countRows(),
  8178. editTop = currentOffset.top - containerOffset.top - 1 - (scrollableContainer.scrollTop || 0),
  8179. editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0),
  8180. settings = this.instance.getSettings(),
  8181. rowHeadersCount = settings.rowHeaders ? 1 : 0,
  8182. colHeadersCount = settings.colHeaders ? 1 : 0,
  8183. editorSection = this.checkEditorSection(),
  8184. backgroundColor = this.TD.style.backgroundColor,
  8185. cssTransformOffset;
  8186. switch (editorSection) {
  8187. case 'top':
  8188. cssTransformOffset = getCssTransform(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  8189. break;
  8190. case 'left':
  8191. cssTransformOffset = getCssTransform(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  8192. break;
  8193. case 'top-left-corner':
  8194. cssTransformOffset = getCssTransform(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  8195. break;
  8196. case 'bottom-left-corner':
  8197. cssTransformOffset = getCssTransform(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  8198. break;
  8199. case 'bottom':
  8200. cssTransformOffset = getCssTransform(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode);
  8201. break;
  8202. }
  8203. if (colHeadersCount && this.instance.getSelected()[0] === 0 || (settings.fixedRowsBottom && this.instance.getSelected()[0] === totalRowsCount - settings.fixedRowsBottom)) {
  8204. editTop += 1;
  8205. }
  8206. if (this.instance.getSelected()[1] === 0) {
  8207. editLeft += 1;
  8208. }
  8209. if (cssTransformOffset && cssTransformOffset != -1) {
  8210. this.textareaParentStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  8211. } else {
  8212. resetCssTransform(this.textareaParentStyle);
  8213. }
  8214. this.textareaParentStyle.top = editTop + 'px';
  8215. this.textareaParentStyle.left = editLeft + 'px';
  8216. var cellTopOffset = this.TD.offsetTop - this.instance.view.wt.wtOverlays.topOverlay.getScrollPosition(),
  8217. cellLeftOffset = this.TD.offsetLeft - this.instance.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  8218. var width = innerWidth(this.TD) - 8;
  8219. var maxWidth = this.instance.view.maximumVisibleElementWidth(cellLeftOffset) - 9;
  8220. var height = this.TD.scrollHeight + 1;
  8221. var maxHeight = Math.max(this.instance.view.maximumVisibleElementHeight(cellTopOffset) - 2, 23);
  8222. var cellComputedStyle = getComputedStyle(this.TD);
  8223. this.TEXTAREA.style.fontSize = cellComputedStyle.fontSize;
  8224. this.TEXTAREA.style.fontFamily = cellComputedStyle.fontFamily;
  8225. this.TEXTAREA.style.backgroundColor = '';
  8226. this.TEXTAREA.style.backgroundColor = backgroundColor ? backgroundColor : getComputedStyle(this.TEXTAREA).backgroundColor;
  8227. this.autoResize.init(this.TEXTAREA, {
  8228. minHeight: Math.min(height, maxHeight),
  8229. maxHeight: maxHeight,
  8230. minWidth: Math.min(width, maxWidth),
  8231. maxWidth: maxWidth
  8232. }, true);
  8233. this.textareaParentStyle.display = 'block';
  8234. };
  8235. TextEditor.prototype.bindEvents = function() {
  8236. var editor = this;
  8237. this.eventManager.addEventListener(this.TEXTAREA, 'cut', function(event) {
  8238. stopPropagation(event);
  8239. });
  8240. this.eventManager.addEventListener(this.TEXTAREA, 'paste', function(event) {
  8241. stopPropagation(event);
  8242. });
  8243. this.instance.addHook('afterScrollHorizontally', function() {
  8244. editor.refreshDimensions();
  8245. });
  8246. this.instance.addHook('afterScrollVertically', function() {
  8247. editor.refreshDimensions();
  8248. });
  8249. this.instance.addHook('afterColumnResize', function() {
  8250. editor.refreshDimensions();
  8251. editor.focus();
  8252. });
  8253. this.instance.addHook('afterRowResize', function() {
  8254. editor.refreshDimensions();
  8255. editor.focus();
  8256. });
  8257. this.instance.addHook('afterDestroy', function() {
  8258. editor.eventManager.destroy();
  8259. });
  8260. };
  8261. TextEditor.prototype.destroy = function() {
  8262. this.eventManager.destroy();
  8263. };
  8264. ;
  8265. registerEditor('text', TextEditor);
  8266. //#
  8267. },{"_baseEditor":30,"autoResize":"autoResize","editors":29,"eventManager":41,"helpers/dom/element":45,"helpers/dom/event":46,"helpers/unicode":53}],41:[function(require,module,exports){
  8268. "use strict";
  8269. Object.defineProperties(exports, {
  8270. EventManager: {get: function() {
  8271. return EventManager;
  8272. }},
  8273. eventManager: {get: function() {
  8274. return eventManager;
  8275. }},
  8276. __esModule: {value: true}
  8277. });
  8278. var $__helpers_47_dom_47_element__,
  8279. $__helpers_47_browser__;
  8280. var $__0 = ($__helpers_47_dom_47_element__ = require("helpers/dom/element"), $__helpers_47_dom_47_element__ && $__helpers_47_dom_47_element__.__esModule && $__helpers_47_dom_47_element__ || {default: $__helpers_47_dom_47_element__}),
  8281. polymerWrap = $__0.polymerWrap,
  8282. closest = $__0.closest;
  8283. var isWebComponentSupportedNatively = ($__helpers_47_browser__ = require("helpers/browser"), $__helpers_47_browser__ && $__helpers_47_browser__.__esModule && $__helpers_47_browser__ || {default: $__helpers_47_browser__}).isWebComponentSupportedNatively;
  8284. var EventManager = function EventManager() {
  8285. var context = arguments[0] !== (void 0) ? arguments[0] : null;
  8286. this.context = context || this;
  8287. if (!this.context.eventListeners) {
  8288. this.context.eventListeners = [];
  8289. }
  8290. };
  8291. ($traceurRuntime.createClass)(EventManager, {
  8292. addEventListener: function(element, eventName, callback) {
  8293. var $__2 = this;
  8294. var context = this.context;
  8295. function callbackProxy(event) {
  8296. if (event.target == void 0 && event.srcElement != void 0) {
  8297. if (event.definePoperty) {
  8298. event.definePoperty('target', {value: event.srcElement});
  8299. } else {
  8300. event.target = event.srcElement;
  8301. }
  8302. }
  8303. if (event.preventDefault == void 0) {
  8304. if (event.definePoperty) {
  8305. event.definePoperty('preventDefault', {value: function() {
  8306. this.returnValue = false;
  8307. }});
  8308. } else {
  8309. event.preventDefault = function() {
  8310. this.returnValue = false;
  8311. };
  8312. }
  8313. }
  8314. event = extendEvent(context, event);
  8315. callback.call(this, event);
  8316. }
  8317. this.context.eventListeners.push({
  8318. element: element,
  8319. event: eventName,
  8320. callback: callback,
  8321. callbackProxy: callbackProxy
  8322. });
  8323. if (window.addEventListener) {
  8324. element.addEventListener(eventName, callbackProxy, false);
  8325. } else {
  8326. element.attachEvent('on' + eventName, callbackProxy);
  8327. }
  8328. Handsontable.countEventManagerListeners++;
  8329. return (function() {
  8330. $__2.removeEventListener(element, eventName, callback);
  8331. });
  8332. },
  8333. removeEventListener: function(element, eventName, callback) {
  8334. var len = this.context.eventListeners.length;
  8335. var tmpEvent;
  8336. while (len--) {
  8337. tmpEvent = this.context.eventListeners[len];
  8338. if (tmpEvent.event == eventName && tmpEvent.element == element) {
  8339. if (callback && callback != tmpEvent.callback) {
  8340. continue;
  8341. }
  8342. this.context.eventListeners.splice(len, 1);
  8343. if (tmpEvent.element.removeEventListener) {
  8344. tmpEvent.element.removeEventListener(tmpEvent.event, tmpEvent.callbackProxy, false);
  8345. } else {
  8346. tmpEvent.element.detachEvent('on' + tmpEvent.event, tmpEvent.callbackProxy);
  8347. }
  8348. Handsontable.countEventManagerListeners--;
  8349. }
  8350. }
  8351. },
  8352. clearEvents: function() {
  8353. if (!this.context) {
  8354. return;
  8355. }
  8356. var len = this.context.eventListeners.length;
  8357. while (len--) {
  8358. var event = this.context.eventListeners[len];
  8359. if (event) {
  8360. this.removeEventListener(event.element, event.event, event.callback);
  8361. }
  8362. }
  8363. },
  8364. clear: function() {
  8365. this.clearEvents();
  8366. },
  8367. destroy: function() {
  8368. this.clearEvents();
  8369. this.context = null;
  8370. },
  8371. fireEvent: function(element, eventName) {
  8372. var options = {
  8373. bubbles: true,
  8374. cancelable: (eventName !== 'mousemove'),
  8375. view: window,
  8376. detail: 0,
  8377. screenX: 0,
  8378. screenY: 0,
  8379. clientX: 1,
  8380. clientY: 1,
  8381. ctrlKey: false,
  8382. altKey: false,
  8383. shiftKey: false,
  8384. metaKey: false,
  8385. button: 0,
  8386. relatedTarget: undefined
  8387. };
  8388. var event;
  8389. if (document.createEvent) {
  8390. event = document.createEvent('MouseEvents');
  8391. event.initMouseEvent(eventName, options.bubbles, options.cancelable, options.view, options.detail, options.screenX, options.screenY, options.clientX, options.clientY, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, options.relatedTarget || document.body.parentNode);
  8392. } else {
  8393. event = document.createEventObject();
  8394. }
  8395. if (element.dispatchEvent) {
  8396. element.dispatchEvent(event);
  8397. } else {
  8398. element.fireEvent('on' + eventName, event);
  8399. }
  8400. }
  8401. }, {});
  8402. function extendEvent(context, event) {
  8403. var componentName = 'HOT-TABLE';
  8404. var isHotTableSpotted;
  8405. var fromElement;
  8406. var realTarget;
  8407. var target;
  8408. var len;
  8409. event.isTargetWebComponent = false;
  8410. event.realTarget = event.target;
  8411. if (!Handsontable.eventManager.isHotTableEnv) {
  8412. return event;
  8413. }
  8414. event = polymerWrap(event);
  8415. len = event.path ? event.path.length : 0;
  8416. while (len--) {
  8417. if (event.path[len].nodeName === componentName) {
  8418. isHotTableSpotted = true;
  8419. } else if (isHotTableSpotted && event.path[len].shadowRoot) {
  8420. target = event.path[len];
  8421. break;
  8422. }
  8423. if (len === 0 && !target) {
  8424. target = event.path[len];
  8425. }
  8426. }
  8427. if (!target) {
  8428. target = event.target;
  8429. }
  8430. event.isTargetWebComponent = true;
  8431. if (isWebComponentSupportedNatively()) {
  8432. event.realTarget = event.srcElement || event.toElement;
  8433. } else if (context instanceof Handsontable.Core || context instanceof Walkontable) {
  8434. if (context instanceof Handsontable.Core) {
  8435. fromElement = context.view ? context.view.wt.wtTable.TABLE : null;
  8436. } else if (context instanceof Walkontable) {
  8437. fromElement = context.wtTable.TABLE.parentNode.parentNode;
  8438. }
  8439. realTarget = closest(event.target, [componentName], fromElement);
  8440. if (realTarget) {
  8441. event.realTarget = fromElement.querySelector(componentName) || event.target;
  8442. } else {
  8443. event.realTarget = event.target;
  8444. }
  8445. }
  8446. Object.defineProperty(event, 'target', {
  8447. get: function() {
  8448. return polymerWrap(target);
  8449. },
  8450. enumerable: true,
  8451. configurable: true
  8452. });
  8453. return event;
  8454. }
  8455. ;
  8456. window.Handsontable = window.Handsontable || {};
  8457. Handsontable.countEventManagerListeners = 0;
  8458. Handsontable.eventManager = eventManager;
  8459. function eventManager(context) {
  8460. return new EventManager(context);
  8461. }
  8462. //#
  8463. },{"helpers/browser":43,"helpers/dom/element":45}],42:[function(require,module,exports){
  8464. "use strict";
  8465. Object.defineProperties(exports, {
  8466. to2dArray: {get: function() {
  8467. return to2dArray;
  8468. }},
  8469. extendArray: {get: function() {
  8470. return extendArray;
  8471. }},
  8472. pivot: {get: function() {
  8473. return pivot;
  8474. }},
  8475. arrayReduce: {get: function() {
  8476. return arrayReduce;
  8477. }},
  8478. arrayFilter: {get: function() {
  8479. return arrayFilter;
  8480. }},
  8481. arrayMap: {get: function() {
  8482. return arrayMap;
  8483. }},
  8484. arrayEach: {get: function() {
  8485. return arrayEach;
  8486. }},
  8487. arraySum: {get: function() {
  8488. return arraySum;
  8489. }},
  8490. arrayMax: {get: function() {
  8491. return arrayMax;
  8492. }},
  8493. arrayMin: {get: function() {
  8494. return arrayMin;
  8495. }},
  8496. arrayAvg: {get: function() {
  8497. return arrayAvg;
  8498. }},
  8499. arrayFlatten: {get: function() {
  8500. return arrayFlatten;
  8501. }},
  8502. arrayUnique: {get: function() {
  8503. return arrayUnique;
  8504. }},
  8505. __esModule: {value: true}
  8506. });
  8507. function to2dArray(arr) {
  8508. var i = 0,
  8509. ilen = arr.length;
  8510. while (i < ilen) {
  8511. arr[i] = [arr[i]];
  8512. i++;
  8513. }
  8514. }
  8515. function extendArray(arr, extension) {
  8516. var i = 0,
  8517. ilen = extension.length;
  8518. while (i < ilen) {
  8519. arr.push(extension[i]);
  8520. i++;
  8521. }
  8522. }
  8523. function pivot(arr) {
  8524. var pivotedArr = [];
  8525. if (!arr || arr.length === 0 || !arr[0] || arr[0].length === 0) {
  8526. return pivotedArr;
  8527. }
  8528. var rowCount = arr.length;
  8529. var colCount = arr[0].length;
  8530. for (var i = 0; i < rowCount; i++) {
  8531. for (var j = 0; j < colCount; j++) {
  8532. if (!pivotedArr[j]) {
  8533. pivotedArr[j] = [];
  8534. }
  8535. pivotedArr[j][i] = arr[i][j];
  8536. }
  8537. }
  8538. return pivotedArr;
  8539. }
  8540. function arrayReduce(array, iteratee, accumulator, initFromArray) {
  8541. var index = -1,
  8542. length = array.length;
  8543. if (initFromArray && length) {
  8544. accumulator = array[++index];
  8545. }
  8546. while (++index < length) {
  8547. accumulator = iteratee(accumulator, array[index], index, array);
  8548. }
  8549. return accumulator;
  8550. }
  8551. function arrayFilter(array, predicate) {
  8552. var index = -1,
  8553. length = array.length,
  8554. resIndex = -1,
  8555. result = [];
  8556. while (++index < length) {
  8557. var value = array[index];
  8558. if (predicate(value, index, array)) {
  8559. result[++resIndex] = value;
  8560. }
  8561. }
  8562. return result;
  8563. }
  8564. function arrayMap(array, iteratee) {
  8565. var index = -1,
  8566. length = array.length,
  8567. resIndex = -1,
  8568. result = [];
  8569. while (++index < length) {
  8570. var value = array[index];
  8571. result[++resIndex] = iteratee(value, index, array);
  8572. }
  8573. return result;
  8574. }
  8575. function arrayEach(array, iteratee) {
  8576. var index = -1,
  8577. length = array.length;
  8578. while (++index < length) {
  8579. if (iteratee(array[index], index, array) === false) {
  8580. break;
  8581. }
  8582. }
  8583. return array;
  8584. }
  8585. function arraySum(array) {
  8586. return arrayReduce(array, (function(a, b) {
  8587. return (a + b);
  8588. }), 0);
  8589. }
  8590. function arrayMax(array) {
  8591. return arrayReduce(array, (function(a, b) {
  8592. return (a > b ? a : b);
  8593. }), Array.isArray(array) ? array[0] : void 0);
  8594. }
  8595. function arrayMin(array) {
  8596. return arrayReduce(array, (function(a, b) {
  8597. return (a < b ? a : b);
  8598. }), Array.isArray(array) ? array[0] : void 0);
  8599. }
  8600. function arrayAvg(array) {
  8601. if (!array.length) {
  8602. return 0;
  8603. }
  8604. return arraySum(array) / array.length;
  8605. }
  8606. function arrayFlatten(array) {
  8607. return arrayReduce(array, (function(initial, value) {
  8608. return initial.concat(Array.isArray(value) ? arrayFlatten(value) : value);
  8609. }), []);
  8610. }
  8611. function arrayUnique(array) {
  8612. var unique = [];
  8613. arrayEach(array, (function(value) {
  8614. if (unique.indexOf(value) === -1) {
  8615. unique.push(value);
  8616. }
  8617. }));
  8618. return unique;
  8619. }
  8620. //#
  8621. },{}],43:[function(require,module,exports){
  8622. "use strict";
  8623. Object.defineProperties(exports, {
  8624. isIE8: {get: function() {
  8625. return isIE8;
  8626. }},
  8627. isIE9: {get: function() {
  8628. return isIE9;
  8629. }},
  8630. isSafari: {get: function() {
  8631. return isSafari;
  8632. }},
  8633. isChrome: {get: function() {
  8634. return isChrome;
  8635. }},
  8636. isMobileBrowser: {get: function() {
  8637. return isMobileBrowser;
  8638. }},
  8639. isTouchSupported: {get: function() {
  8640. return isTouchSupported;
  8641. }},
  8642. isWebComponentSupportedNatively: {get: function() {
  8643. return isWebComponentSupportedNatively;
  8644. }},
  8645. hasCaptionProblem: {get: function() {
  8646. return hasCaptionProblem;
  8647. }},
  8648. __esModule: {value: true}
  8649. });
  8650. var _isIE8 = !(document.createTextNode('test').textContent);
  8651. function isIE8() {
  8652. return _isIE8;
  8653. }
  8654. var _isIE9 = !!(document.documentMode);
  8655. function isIE9() {
  8656. return _isIE9;
  8657. }
  8658. var _isSafari = (/Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor));
  8659. function isSafari() {
  8660. return _isSafari;
  8661. }
  8662. var _isChrome = (/Chrome/.test(navigator.userAgent) && /Google/.test(navigator.vendor));
  8663. function isChrome() {
  8664. return _isChrome;
  8665. }
  8666. function isMobileBrowser(userAgent) {
  8667. if (!userAgent) {
  8668. userAgent = navigator.userAgent;
  8669. }
  8670. return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent));
  8671. }
  8672. function isTouchSupported() {
  8673. return ('ontouchstart' in window);
  8674. }
  8675. function isWebComponentSupportedNatively() {
  8676. var test = document.createElement('div');
  8677. return test.createShadowRoot && test.createShadowRoot.toString().match(/\[native code\]/) ? true : false;
  8678. }
  8679. var _hasCaptionProblem;
  8680. function detectCaptionProblem() {
  8681. var TABLE = document.createElement('TABLE');
  8682. TABLE.style.borderSpacing = 0;
  8683. TABLE.style.borderWidth = 0;
  8684. TABLE.style.padding = 0;
  8685. var TBODY = document.createElement('TBODY');
  8686. TABLE.appendChild(TBODY);
  8687. TBODY.appendChild(document.createElement('TR'));
  8688. TBODY.firstChild.appendChild(document.createElement('TD'));
  8689. TBODY.firstChild.firstChild.innerHTML = '<tr><td>t<br>t</td></tr>';
  8690. var CAPTION = document.createElement('CAPTION');
  8691. CAPTION.innerHTML = 'c<br>c<br>c<br>c';
  8692. CAPTION.style.padding = 0;
  8693. CAPTION.style.margin = 0;
  8694. TABLE.insertBefore(CAPTION, TBODY);
  8695. document.body.appendChild(TABLE);
  8696. _hasCaptionProblem = (TABLE.offsetHeight < 2 * TABLE.lastChild.offsetHeight);
  8697. document.body.removeChild(TABLE);
  8698. }
  8699. function hasCaptionProblem() {
  8700. if (_hasCaptionProblem === void 0) {
  8701. detectCaptionProblem();
  8702. }
  8703. return _hasCaptionProblem;
  8704. }
  8705. //#
  8706. },{}],44:[function(require,module,exports){
  8707. "use strict";
  8708. Object.defineProperties(exports, {
  8709. spreadsheetColumnLabel: {get: function() {
  8710. return spreadsheetColumnLabel;
  8711. }},
  8712. createSpreadsheetData: {get: function() {
  8713. return createSpreadsheetData;
  8714. }},
  8715. createSpreadsheetObjectData: {get: function() {
  8716. return createSpreadsheetObjectData;
  8717. }},
  8718. createEmptySpreadsheetData: {get: function() {
  8719. return createEmptySpreadsheetData;
  8720. }},
  8721. translateRowsToColumns: {get: function() {
  8722. return translateRowsToColumns;
  8723. }},
  8724. cellMethodLookupFactory: {get: function() {
  8725. return cellMethodLookupFactory;
  8726. }},
  8727. __esModule: {value: true}
  8728. });
  8729. var $__object__;
  8730. var getPrototypeOf = ($__object__ = require("object"), $__object__ && $__object__.__esModule && $__object__ || {default: $__object__}).getPrototypeOf;
  8731. function spreadsheetColumnLabel(index) {
  8732. var dividend = index + 1;
  8733. var columnLabel = '';
  8734. var modulo;
  8735. while (dividend > 0) {
  8736. modulo = (dividend - 1) % 26;
  8737. columnLabel = String.fromCharCode(65 + modulo) + columnLabel;
  8738. dividend = parseInt((dividend - modulo) / 26, 10);
  8739. }
  8740. return columnLabel;
  8741. }
  8742. function createSpreadsheetData(rowCount, colCount) {
  8743. rowCount = typeof rowCount === 'number' ? rowCount : 100;
  8744. colCount = typeof colCount === 'number' ? colCount : 4;
  8745. var rows = [],
  8746. i,
  8747. j;
  8748. for (i = 0; i < rowCount; i++) {
  8749. var row = [];
  8750. for (j = 0; j < colCount; j++) {
  8751. row.push(spreadsheetColumnLabel(j) + (i + 1));
  8752. }
  8753. rows.push(row);
  8754. }
  8755. return rows;
  8756. }
  8757. function createSpreadsheetObjectData(rowCount, colCount) {
  8758. rowCount = typeof rowCount === 'number' ? rowCount : 100;
  8759. colCount = typeof colCount === 'number' ? colCount : 4;
  8760. var rows = [],
  8761. i,
  8762. j;
  8763. for (i = 0; i < rowCount; i++) {
  8764. var row = {};
  8765. for (j = 0; j < colCount; j++) {
  8766. row['prop' + j] = spreadsheetColumnLabel(j) + (i + 1);
  8767. }
  8768. rows.push(row);
  8769. }
  8770. return rows;
  8771. }
  8772. function createEmptySpreadsheetData(rows, columns) {
  8773. var data = [];
  8774. var row;
  8775. for (var i = 0; i < rows; i++) {
  8776. row = [];
  8777. for (var j = 0; j < columns; j++) {
  8778. row.push('');
  8779. }
  8780. data.push(row);
  8781. }
  8782. return data;
  8783. }
  8784. function translateRowsToColumns(input) {
  8785. var i,
  8786. ilen,
  8787. j,
  8788. jlen,
  8789. output = [],
  8790. olen = 0;
  8791. for (i = 0, ilen = input.length; i < ilen; i++) {
  8792. for (j = 0, jlen = input[i].length; j < jlen; j++) {
  8793. if (j == olen) {
  8794. output.push([]);
  8795. olen++;
  8796. }
  8797. output[j].push(input[i][j]);
  8798. }
  8799. }
  8800. return output;
  8801. }
  8802. function cellMethodLookupFactory(methodName, allowUndefined) {
  8803. allowUndefined = typeof allowUndefined == 'undefined' ? true : allowUndefined;
  8804. return function cellMethodLookup(row, col) {
  8805. return (function getMethodFromProperties(properties) {
  8806. if (!properties) {
  8807. return;
  8808. } else if (properties.hasOwnProperty(methodName) && properties[methodName] !== void 0) {
  8809. return properties[methodName];
  8810. } else if (properties.hasOwnProperty('type') && properties.type) {
  8811. var type;
  8812. if (typeof properties.type != 'string') {
  8813. throw new Error('Cell type must be a string ');
  8814. }
  8815. type = translateTypeNameToObject(properties.type);
  8816. if (type.hasOwnProperty(methodName)) {
  8817. return type[methodName];
  8818. } else if (allowUndefined) {
  8819. return;
  8820. }
  8821. }
  8822. return getMethodFromProperties(getPrototypeOf(properties));
  8823. })(typeof row == 'number' ? this.getCellMeta(row, col) : row);
  8824. };
  8825. function translateTypeNameToObject(typeName) {
  8826. var type = Handsontable.cellTypes[typeName];
  8827. if (typeof type == 'undefined') {
  8828. throw new Error('You declared cell type "' + typeName + '" as a string that is not mapped to a known object. ' + 'Cell type must be an object or a string mapped to an object in Handsontable.cellTypes');
  8829. }
  8830. return type;
  8831. }
  8832. }
  8833. //#
  8834. },{"object":50}],45:[function(require,module,exports){
  8835. "use strict";
  8836. Object.defineProperties(exports, {
  8837. closest: {get: function() {
  8838. return closest;
  8839. }},
  8840. isChildOf: {get: function() {
  8841. return isChildOf;
  8842. }},
  8843. isChildOfWebComponentTable: {get: function() {
  8844. return isChildOfWebComponentTable;
  8845. }},
  8846. polymerWrap: {get: function() {
  8847. return polymerWrap;
  8848. }},
  8849. polymerUnwrap: {get: function() {
  8850. return polymerUnwrap;
  8851. }},
  8852. index: {get: function() {
  8853. return index;
  8854. }},
  8855. overlayContainsElement: {get: function() {
  8856. return overlayContainsElement;
  8857. }},
  8858. hasClass: {get: function() {
  8859. return hasClass;
  8860. }},
  8861. addClass: {get: function() {
  8862. return addClass;
  8863. }},
  8864. removeClass: {get: function() {
  8865. return removeClass;
  8866. }},
  8867. removeTextNodes: {get: function() {
  8868. return removeTextNodes;
  8869. }},
  8870. empty: {get: function() {
  8871. return empty;
  8872. }},
  8873. HTML_CHARACTERS: {get: function() {
  8874. return HTML_CHARACTERS;
  8875. }},
  8876. fastInnerHTML: {get: function() {
  8877. return fastInnerHTML;
  8878. }},
  8879. fastInnerText: {get: function() {
  8880. return fastInnerText;
  8881. }},
  8882. isVisible: {get: function() {
  8883. return isVisible;
  8884. }},
  8885. offset: {get: function() {
  8886. return offset;
  8887. }},
  8888. getWindowScrollTop: {get: function() {
  8889. return getWindowScrollTop;
  8890. }},
  8891. getWindowScrollLeft: {get: function() {
  8892. return getWindowScrollLeft;
  8893. }},
  8894. getScrollTop: {get: function() {
  8895. return getScrollTop;
  8896. }},
  8897. getScrollLeft: {get: function() {
  8898. return getScrollLeft;
  8899. }},
  8900. getScrollableElement: {get: function() {
  8901. return getScrollableElement;
  8902. }},
  8903. getTrimmingContainer: {get: function() {
  8904. return getTrimmingContainer;
  8905. }},
  8906. getStyle: {get: function() {
  8907. return getStyle;
  8908. }},
  8909. getComputedStyle: {get: function() {
  8910. return getComputedStyle;
  8911. }},
  8912. outerWidth: {get: function() {
  8913. return outerWidth;
  8914. }},
  8915. outerHeight: {get: function() {
  8916. return outerHeight;
  8917. }},
  8918. innerHeight: {get: function() {
  8919. return innerHeight;
  8920. }},
  8921. innerWidth: {get: function() {
  8922. return innerWidth;
  8923. }},
  8924. addEvent: {get: function() {
  8925. return addEvent;
  8926. }},
  8927. removeEvent: {get: function() {
  8928. return removeEvent;
  8929. }},
  8930. getCaretPosition: {get: function() {
  8931. return getCaretPosition;
  8932. }},
  8933. getSelectionEndPosition: {get: function() {
  8934. return getSelectionEndPosition;
  8935. }},
  8936. getSelectionText: {get: function() {
  8937. return getSelectionText;
  8938. }},
  8939. setCaretPosition: {get: function() {
  8940. return setCaretPosition;
  8941. }},
  8942. getScrollbarWidth: {get: function() {
  8943. return getScrollbarWidth;
  8944. }},
  8945. setOverlayPosition: {get: function() {
  8946. return setOverlayPosition;
  8947. }},
  8948. getCssTransform: {get: function() {
  8949. return getCssTransform;
  8950. }},
  8951. resetCssTransform: {get: function() {
  8952. return resetCssTransform;
  8953. }},
  8954. isInput: {get: function() {
  8955. return isInput;
  8956. }},
  8957. isOutsideInput: {get: function() {
  8958. return isOutsideInput;
  8959. }},
  8960. requestAnimationFrame: {get: function() {
  8961. return requestAnimationFrame;
  8962. }},
  8963. cancelAnimationFrame: {get: function() {
  8964. return cancelAnimationFrame;
  8965. }},
  8966. __esModule: {value: true}
  8967. });
  8968. var $___46__46__47_browser__;
  8969. var $__0 = ($___46__46__47_browser__ = require("../browser"), $___46__46__47_browser__ && $___46__46__47_browser__.__esModule && $___46__46__47_browser__ || {default: $___46__46__47_browser__}),
  8970. isIE8 = $__0.isIE8,
  8971. isIE9 = $__0.isIE9,
  8972. isSafari = $__0.isSafari,
  8973. hasCaptionProblem = $__0.hasCaptionProblem;
  8974. function closest(element, nodes, until) {
  8975. while (element != null && element !== until) {
  8976. if (element.nodeType === Node.ELEMENT_NODE && (nodes.indexOf(element.nodeName) > -1 || nodes.indexOf(element) > -1)) {
  8977. return element;
  8978. }
  8979. if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  8980. element = element.host;
  8981. } else {
  8982. element = element.parentNode;
  8983. }
  8984. }
  8985. return null;
  8986. }
  8987. function isChildOf(child, parent) {
  8988. var node = child.parentNode;
  8989. var queriedParents = [];
  8990. if (typeof parent === 'string') {
  8991. queriedParents = Array.prototype.slice.call(document.querySelectorAll(parent), 0);
  8992. } else {
  8993. queriedParents.push(parent);
  8994. }
  8995. while (node != null) {
  8996. if (queriedParents.indexOf(node) > -1) {
  8997. return true;
  8998. }
  8999. node = node.parentNode;
  9000. }
  9001. return false;
  9002. }
  9003. function isChildOfWebComponentTable(element) {
  9004. var hotTableName = 'hot-table',
  9005. result = false,
  9006. parentNode;
  9007. parentNode = polymerWrap(element);
  9008. function isHotTable(element) {
  9009. return element.nodeType === Node.ELEMENT_NODE && element.nodeName === hotTableName.toUpperCase();
  9010. }
  9011. while (parentNode != null) {
  9012. if (isHotTable(parentNode)) {
  9013. result = true;
  9014. break;
  9015. } else if (parentNode.host && parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  9016. result = isHotTable(parentNode.host);
  9017. if (result) {
  9018. break;
  9019. }
  9020. parentNode = parentNode.host;
  9021. }
  9022. parentNode = parentNode.parentNode;
  9023. }
  9024. return result;
  9025. }
  9026. function polymerWrap(element) {
  9027. return typeof Polymer !== 'undefined' && typeof wrap === 'function' ? wrap(element) : element;
  9028. }
  9029. function polymerUnwrap(element) {
  9030. return typeof Polymer !== 'undefined' && typeof unwrap === 'function' ? unwrap(element) : element;
  9031. }
  9032. function index(element) {
  9033. var i = 0;
  9034. if (element.previousSibling) {
  9035. while (element = element.previousSibling) {
  9036. ++i;
  9037. }
  9038. }
  9039. return i;
  9040. }
  9041. function overlayContainsElement(overlayType, element) {
  9042. var overlayElement = document.querySelector('.ht_clone_' + overlayType);
  9043. return overlayElement ? overlayElement.contains(element) : null;
  9044. }
  9045. var classListSupport = document.documentElement.classList ? true : false;
  9046. var _hasClass,
  9047. _addClass,
  9048. _removeClass;
  9049. function filterEmptyClassNames(classNames) {
  9050. var len = 0,
  9051. result = [];
  9052. if (!classNames || !classNames.length) {
  9053. return result;
  9054. }
  9055. while (classNames[len]) {
  9056. result.push(classNames[len]);
  9057. len++;
  9058. }
  9059. return result;
  9060. }
  9061. if (classListSupport) {
  9062. var isSupportMultipleClassesArg = (function() {
  9063. var element = document.createElement('div');
  9064. element.classList.add('test', 'test2');
  9065. return element.classList.contains('test2');
  9066. }());
  9067. _hasClass = function _hasClass(element, className) {
  9068. if (className === '') {
  9069. return false;
  9070. }
  9071. return element.classList.contains(className);
  9072. };
  9073. _addClass = function _addClass(element, className) {
  9074. var len = 0;
  9075. if (typeof className === 'string') {
  9076. className = className.split(' ');
  9077. }
  9078. className = filterEmptyClassNames(className);
  9079. if (isSupportMultipleClassesArg) {
  9080. element.classList.add.apply(element.classList, className);
  9081. } else {
  9082. while (className && className[len]) {
  9083. element.classList.add(className[len]);
  9084. len++;
  9085. }
  9086. }
  9087. };
  9088. _removeClass = function _removeClass(element, className) {
  9089. var len = 0;
  9090. if (typeof className === 'string') {
  9091. className = className.split(' ');
  9092. }
  9093. className = filterEmptyClassNames(className);
  9094. if (isSupportMultipleClassesArg) {
  9095. element.classList.remove.apply(element.classList, className);
  9096. } else {
  9097. while (className && className[len]) {
  9098. element.classList.remove(className[len]);
  9099. len++;
  9100. }
  9101. }
  9102. };
  9103. } else {
  9104. var createClassNameRegExp = function createClassNameRegExp(className) {
  9105. return new RegExp('(\\s|^)' + className + '(\\s|$)');
  9106. };
  9107. _hasClass = function _hasClass(element, className) {
  9108. return element.className.match(createClassNameRegExp(className)) ? true : false;
  9109. };
  9110. _addClass = function _addClass(element, className) {
  9111. var len = 0,
  9112. _className = element.className;
  9113. if (typeof className === 'string') {
  9114. className = className.split(' ');
  9115. }
  9116. if (_className === '') {
  9117. _className = className.join(' ');
  9118. } else {
  9119. while (className && className[len]) {
  9120. if (!createClassNameRegExp(className[len]).test(_className)) {
  9121. _className += ' ' + className[len];
  9122. }
  9123. len++;
  9124. }
  9125. }
  9126. element.className = _className;
  9127. };
  9128. _removeClass = function _removeClass(element, className) {
  9129. var len = 0,
  9130. _className = element.className;
  9131. if (typeof className === 'string') {
  9132. className = className.split(' ');
  9133. }
  9134. while (className && className[len]) {
  9135. _className = _className.replace(createClassNameRegExp(className[len]), ' ').trim();
  9136. len++;
  9137. }
  9138. if (element.className !== _className) {
  9139. element.className = _className;
  9140. }
  9141. };
  9142. }
  9143. function hasClass(element, className) {
  9144. return _hasClass(element, className);
  9145. }
  9146. function addClass(element, className) {
  9147. return _addClass(element, className);
  9148. }
  9149. function removeClass(element, className) {
  9150. return _removeClass(element, className);
  9151. }
  9152. function removeTextNodes(element, parent) {
  9153. if (element.nodeType === 3) {
  9154. parent.removeChild(element);
  9155. } else if (['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR'].indexOf(element.nodeName) > -1) {
  9156. var childs = element.childNodes;
  9157. for (var i = childs.length - 1; i >= 0; i--) {
  9158. removeTextNodes(childs[i], element);
  9159. }
  9160. }
  9161. }
  9162. function empty(element) {
  9163. var child;
  9164. while (child = element.lastChild) {
  9165. element.removeChild(child);
  9166. }
  9167. }
  9168. var HTML_CHARACTERS = /(<(.*)>|&(.*);)/;
  9169. function fastInnerHTML(element, content) {
  9170. if (HTML_CHARACTERS.test(content)) {
  9171. element.innerHTML = content;
  9172. } else {
  9173. fastInnerText(element, content);
  9174. }
  9175. }
  9176. var textContextSupport = document.createTextNode('test').textContent ? true : false;
  9177. function fastInnerText(element, content) {
  9178. var child = element.firstChild;
  9179. if (child && child.nodeType === 3 && child.nextSibling === null) {
  9180. if (textContextSupport) {
  9181. child.textContent = content;
  9182. } else {
  9183. child.data = content;
  9184. }
  9185. } else {
  9186. empty(element);
  9187. element.appendChild(document.createTextNode(content));
  9188. }
  9189. }
  9190. function isVisible(elem) {
  9191. var next = elem;
  9192. while (polymerUnwrap(next) !== document.documentElement) {
  9193. if (next === null) {
  9194. return false;
  9195. } else if (next.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  9196. if (next.host) {
  9197. if (next.host.impl) {
  9198. return isVisible(next.host.impl);
  9199. } else if (next.host) {
  9200. return isVisible(next.host);
  9201. } else {
  9202. throw new Error('Lost in Web Components world');
  9203. }
  9204. } else {
  9205. return false;
  9206. }
  9207. } else if (next.style.display === 'none') {
  9208. return false;
  9209. }
  9210. next = next.parentNode;
  9211. }
  9212. return true;
  9213. }
  9214. function offset(elem) {
  9215. var offsetLeft,
  9216. offsetTop,
  9217. lastElem,
  9218. docElem,
  9219. box;
  9220. docElem = document.documentElement;
  9221. if (hasCaptionProblem() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') {
  9222. box = elem.getBoundingClientRect();
  9223. return {
  9224. top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
  9225. left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)
  9226. };
  9227. }
  9228. offsetLeft = elem.offsetLeft;
  9229. offsetTop = elem.offsetTop;
  9230. lastElem = elem;
  9231. while (elem = elem.offsetParent) {
  9232. if (elem === document.body) {
  9233. break;
  9234. }
  9235. offsetLeft += elem.offsetLeft;
  9236. offsetTop += elem.offsetTop;
  9237. lastElem = elem;
  9238. }
  9239. if (lastElem && lastElem.style.position === 'fixed') {
  9240. offsetLeft += window.pageXOffset || docElem.scrollLeft;
  9241. offsetTop += window.pageYOffset || docElem.scrollTop;
  9242. }
  9243. return {
  9244. left: offsetLeft,
  9245. top: offsetTop
  9246. };
  9247. }
  9248. function getWindowScrollTop() {
  9249. var res = window.scrollY;
  9250. if (res === void 0) {
  9251. res = document.documentElement.scrollTop;
  9252. }
  9253. return res;
  9254. }
  9255. function getWindowScrollLeft() {
  9256. var res = window.scrollX;
  9257. if (res === void 0) {
  9258. res = document.documentElement.scrollLeft;
  9259. }
  9260. return res;
  9261. }
  9262. function getScrollTop(element) {
  9263. if (element === window) {
  9264. return getWindowScrollTop();
  9265. } else {
  9266. return element.scrollTop;
  9267. }
  9268. }
  9269. function getScrollLeft(element) {
  9270. if (element === window) {
  9271. return getWindowScrollLeft();
  9272. } else {
  9273. return element.scrollLeft;
  9274. }
  9275. }
  9276. function getScrollableElement(element) {
  9277. var el = element.parentNode,
  9278. props = ['auto', 'scroll'],
  9279. overflow,
  9280. overflowX,
  9281. overflowY,
  9282. computedStyle = '',
  9283. computedOverflow = '',
  9284. computedOverflowY = '',
  9285. computedOverflowX = '';
  9286. while (el && el.style && document.body !== el) {
  9287. overflow = el.style.overflow;
  9288. overflowX = el.style.overflowX;
  9289. overflowY = el.style.overflowY;
  9290. if (overflow == 'scroll' || overflowX == 'scroll' || overflowY == 'scroll') {
  9291. return el;
  9292. } else if (window.getComputedStyle) {
  9293. computedStyle = window.getComputedStyle(el);
  9294. computedOverflow = computedStyle.getPropertyValue('overflow');
  9295. computedOverflowY = computedStyle.getPropertyValue('overflow-y');
  9296. computedOverflowX = computedStyle.getPropertyValue('overflow-x');
  9297. if (computedOverflow === 'scroll' || computedOverflowX === 'scroll' || computedOverflowY === 'scroll') {
  9298. return el;
  9299. }
  9300. }
  9301. if (el.clientHeight <= el.scrollHeight && (props.indexOf(overflowY) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowY) !== -1)) {
  9302. return el;
  9303. }
  9304. if (el.clientWidth <= el.scrollWidth && (props.indexOf(overflowX) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowX) !== -1)) {
  9305. return el;
  9306. }
  9307. el = el.parentNode;
  9308. }
  9309. return window;
  9310. }
  9311. function getTrimmingContainer(base) {
  9312. var el = base.parentNode;
  9313. while (el && el.style && document.body !== el) {
  9314. if (el.style.overflow !== 'visible' && el.style.overflow !== '') {
  9315. return el;
  9316. } else if (window.getComputedStyle) {
  9317. var computedStyle = window.getComputedStyle(el);
  9318. if (computedStyle.getPropertyValue('overflow') !== 'visible' && computedStyle.getPropertyValue('overflow') !== '') {
  9319. return el;
  9320. }
  9321. }
  9322. el = el.parentNode;
  9323. }
  9324. return window;
  9325. }
  9326. function getStyle(element, prop) {
  9327. if (!element) {
  9328. return;
  9329. } else if (element === window) {
  9330. if (prop === 'width') {
  9331. return window.innerWidth + 'px';
  9332. } else if (prop === 'height') {
  9333. return window.innerHeight + 'px';
  9334. }
  9335. return;
  9336. }
  9337. var styleProp = element.style[prop],
  9338. computedStyle;
  9339. if (styleProp !== '' && styleProp !== void 0) {
  9340. return styleProp;
  9341. } else {
  9342. computedStyle = getComputedStyle(element);
  9343. if (computedStyle[prop] !== '' && computedStyle[prop] !== void 0) {
  9344. return computedStyle[prop];
  9345. }
  9346. return void 0;
  9347. }
  9348. }
  9349. function getComputedStyle(element) {
  9350. return element.currentStyle || document.defaultView.getComputedStyle(element);
  9351. }
  9352. function outerWidth(element) {
  9353. return element.offsetWidth;
  9354. }
  9355. function outerHeight(elem) {
  9356. if (hasCaptionProblem() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') {
  9357. return elem.offsetHeight + elem.firstChild.offsetHeight;
  9358. } else {
  9359. return elem.offsetHeight;
  9360. }
  9361. }
  9362. function innerHeight(element) {
  9363. return element.clientHeight || element.innerHeight;
  9364. }
  9365. function innerWidth(element) {
  9366. return element.clientWidth || element.innerWidth;
  9367. }
  9368. function addEvent(element, event, callback) {
  9369. if (window.addEventListener) {
  9370. element.addEventListener(event, callback, false);
  9371. } else {
  9372. element.attachEvent('on' + event, callback);
  9373. }
  9374. }
  9375. function removeEvent(element, event, callback) {
  9376. if (window.removeEventListener) {
  9377. element.removeEventListener(event, callback, false);
  9378. } else {
  9379. element.detachEvent('on' + event, callback);
  9380. }
  9381. }
  9382. function getCaretPosition(el) {
  9383. if (el.selectionStart) {
  9384. return el.selectionStart;
  9385. } else if (document.selection) {
  9386. el.focus();
  9387. var r = document.selection.createRange();
  9388. if (r == null) {
  9389. return 0;
  9390. }
  9391. var re = el.createTextRange();
  9392. var rc = re.duplicate();
  9393. re.moveToBookmark(r.getBookmark());
  9394. rc.setEndPoint('EndToStart', re);
  9395. return rc.text.length;
  9396. }
  9397. return 0;
  9398. }
  9399. function getSelectionEndPosition(el) {
  9400. if (el.selectionEnd) {
  9401. return el.selectionEnd;
  9402. } else if (document.selection) {
  9403. var r = document.selection.createRange();
  9404. if (r == null) {
  9405. return 0;
  9406. }
  9407. var re = el.createTextRange();
  9408. return re.text.indexOf(r.text) + r.text.length;
  9409. }
  9410. }
  9411. function getSelectionText() {
  9412. var text = '';
  9413. if (window.getSelection) {
  9414. text = window.getSelection().toString();
  9415. } else if (document.selection && document.selection.type !== 'Control') {
  9416. text = document.selection.createRange().text;
  9417. }
  9418. return text;
  9419. }
  9420. function setCaretPosition(element, pos, endPos) {
  9421. if (endPos === void 0) {
  9422. endPos = pos;
  9423. }
  9424. if (element.setSelectionRange) {
  9425. element.focus();
  9426. try {
  9427. element.setSelectionRange(pos, endPos);
  9428. } catch (err) {
  9429. var elementParent = element.parentNode;
  9430. var parentDisplayValue = elementParent.style.display;
  9431. elementParent.style.display = 'block';
  9432. element.setSelectionRange(pos, endPos);
  9433. elementParent.style.display = parentDisplayValue;
  9434. }
  9435. } else if (element.createTextRange) {
  9436. var range = element.createTextRange();
  9437. range.collapse(true);
  9438. range.moveEnd('character', endPos);
  9439. range.moveStart('character', pos);
  9440. range.select();
  9441. }
  9442. }
  9443. var cachedScrollbarWidth;
  9444. function walkontableCalculateScrollbarWidth() {
  9445. var inner = document.createElement('p');
  9446. inner.style.width = '100%';
  9447. inner.style.height = '200px';
  9448. var outer = document.createElement('div');
  9449. outer.style.position = 'absolute';
  9450. outer.style.top = '0px';
  9451. outer.style.left = '0px';
  9452. outer.style.visibility = 'hidden';
  9453. outer.style.width = '200px';
  9454. outer.style.height = '150px';
  9455. outer.style.overflow = 'hidden';
  9456. outer.appendChild(inner);
  9457. (document.body || document.documentElement).appendChild(outer);
  9458. var w1 = inner.offsetWidth;
  9459. outer.style.overflow = 'scroll';
  9460. var w2 = inner.offsetWidth;
  9461. if (w1 == w2) {
  9462. w2 = outer.clientWidth;
  9463. }
  9464. (document.body || document.documentElement).removeChild(outer);
  9465. return (w1 - w2);
  9466. }
  9467. function getScrollbarWidth() {
  9468. if (cachedScrollbarWidth === void 0) {
  9469. cachedScrollbarWidth = walkontableCalculateScrollbarWidth();
  9470. }
  9471. return cachedScrollbarWidth;
  9472. }
  9473. function setOverlayPosition(overlayElem, left, top) {
  9474. if (isIE8() || isIE9()) {
  9475. overlayElem.style.top = top;
  9476. overlayElem.style.left = left;
  9477. } else if (isSafari()) {
  9478. overlayElem.style['-webkit-transform'] = 'translate3d(' + left + ',' + top + ',0)';
  9479. } else {
  9480. overlayElem.style.transform = 'translate3d(' + left + ',' + top + ',0)';
  9481. }
  9482. }
  9483. function getCssTransform(element) {
  9484. var transform;
  9485. if (element.style.transform && (transform = element.style.transform) !== '') {
  9486. return ['transform', transform];
  9487. } else if (element.style['-webkit-transform'] && (transform = element.style['-webkit-transform']) !== '') {
  9488. return ['-webkit-transform', transform];
  9489. }
  9490. return -1;
  9491. }
  9492. function resetCssTransform(element) {
  9493. if (element.transform && element.transform !== '') {
  9494. element.transform = '';
  9495. } else if (element['-webkit-transform'] && element['-webkit-transform'] !== '') {
  9496. element['-webkit-transform'] = '';
  9497. }
  9498. }
  9499. function isInput(element) {
  9500. var inputs = ['INPUT', 'SELECT', 'TEXTAREA'];
  9501. return inputs.indexOf(element.nodeName) > -1 || element.contentEditable === 'true';
  9502. }
  9503. function isOutsideInput(element) {
  9504. return isInput(element) && element.className.indexOf('handsontableInput') == -1 && element.className.indexOf('copyPaste') == -1;
  9505. }
  9506. var lastTime = 0;
  9507. var vendors = ['ms', 'moz', 'webkit', 'o'];
  9508. var _requestAnimationFrame = window.requestAnimationFrame;
  9509. var _cancelAnimationFrame = window.cancelAnimationFrame;
  9510. for (var x = 0; x < vendors.length && !_requestAnimationFrame; ++x) {
  9511. _requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
  9512. _cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
  9513. }
  9514. if (!_requestAnimationFrame) {
  9515. _requestAnimationFrame = function(callback) {
  9516. var currTime = new Date().getTime();
  9517. var timeToCall = Math.max(0, 16 - (currTime - lastTime));
  9518. var id = window.setTimeout(function() {
  9519. callback(currTime + timeToCall);
  9520. }, timeToCall);
  9521. lastTime = currTime + timeToCall;
  9522. return id;
  9523. };
  9524. }
  9525. if (!_cancelAnimationFrame) {
  9526. _cancelAnimationFrame = function(id) {
  9527. clearTimeout(id);
  9528. };
  9529. }
  9530. function requestAnimationFrame(callback) {
  9531. return _requestAnimationFrame.call(window, callback);
  9532. }
  9533. function cancelAnimationFrame(id) {
  9534. _cancelAnimationFrame.call(window, id);
  9535. }
  9536. //#
  9537. },{"../browser":43}],46:[function(require,module,exports){
  9538. "use strict";
  9539. Object.defineProperties(exports, {
  9540. stopImmediatePropagation: {get: function() {
  9541. return stopImmediatePropagation;
  9542. }},
  9543. isImmediatePropagationStopped: {get: function() {
  9544. return isImmediatePropagationStopped;
  9545. }},
  9546. stopPropagation: {get: function() {
  9547. return stopPropagation;
  9548. }},
  9549. pageX: {get: function() {
  9550. return pageX;
  9551. }},
  9552. pageY: {get: function() {
  9553. return pageY;
  9554. }},
  9555. __esModule: {value: true}
  9556. });
  9557. function stopImmediatePropagation(event) {
  9558. event.isImmediatePropagationEnabled = false;
  9559. event.cancelBubble = true;
  9560. }
  9561. function isImmediatePropagationStopped(event) {
  9562. return event.isImmediatePropagationEnabled === false;
  9563. }
  9564. function stopPropagation(event) {
  9565. if (typeof event.stopPropagation === 'function') {
  9566. event.stopPropagation();
  9567. } else {
  9568. event.cancelBubble = true;
  9569. }
  9570. }
  9571. function pageX(event) {
  9572. if (event.pageX) {
  9573. return event.pageX;
  9574. }
  9575. var scrollLeft = getWindowScrollLeft();
  9576. var cursorX = event.clientX + scrollLeft;
  9577. return cursorX;
  9578. }
  9579. function pageY(event) {
  9580. if (event.pageY) {
  9581. return event.pageY;
  9582. }
  9583. var scrollTop = getWindowScrollTop();
  9584. var cursorY = event.clientY + scrollTop;
  9585. return cursorY;
  9586. }
  9587. //#
  9588. },{}],47:[function(require,module,exports){
  9589. "use strict";
  9590. Object.defineProperties(exports, {
  9591. proxy: {get: function() {
  9592. return proxy;
  9593. }},
  9594. throttle: {get: function() {
  9595. return throttle;
  9596. }},
  9597. throttleAfterHits: {get: function() {
  9598. return throttleAfterHits;
  9599. }},
  9600. __esModule: {value: true}
  9601. });
  9602. function proxy(fun, context) {
  9603. return function() {
  9604. return fun.apply(context, arguments);
  9605. };
  9606. }
  9607. function throttle(func) {
  9608. var wait = arguments[1] !== (void 0) ? arguments[1] : 200;
  9609. var lastCalled = 0;
  9610. var result = {lastCallThrottled: true};
  9611. var lastTimer = null;
  9612. function _throttle() {
  9613. var $__0 = this;
  9614. var args = arguments;
  9615. var stamp = Date.now();
  9616. var needCall = false;
  9617. result.lastCallThrottled = true;
  9618. if (!lastCalled) {
  9619. lastCalled = stamp;
  9620. needCall = true;
  9621. }
  9622. var remaining = wait - (stamp - lastCalled);
  9623. if (needCall) {
  9624. result.lastCallThrottled = false;
  9625. func.apply(this, args);
  9626. } else {
  9627. if (lastTimer) {
  9628. clearTimeout(lastTimer);
  9629. }
  9630. lastTimer = setTimeout((function() {
  9631. result.lastCallThrottled = false;
  9632. func.apply($__0, args);
  9633. lastCalled = 0;
  9634. lastTimer = void 0;
  9635. }), remaining);
  9636. }
  9637. return result;
  9638. }
  9639. return _throttle;
  9640. }
  9641. function throttleAfterHits(func) {
  9642. var wait = arguments[1] !== (void 0) ? arguments[1] : 200;
  9643. var hits = arguments[2] !== (void 0) ? arguments[2] : 10;
  9644. var funcThrottle = throttle(func, wait);
  9645. var remainHits = hits;
  9646. function _clearHits() {
  9647. remainHits = hits;
  9648. }
  9649. function _throttleAfterHits() {
  9650. if (remainHits) {
  9651. remainHits--;
  9652. return func.apply(this, arguments);
  9653. }
  9654. return funcThrottle.apply(this, arguments);
  9655. }
  9656. _throttleAfterHits.clearHits = _clearHits;
  9657. return _throttleAfterHits;
  9658. }
  9659. //#
  9660. },{}],48:[function(require,module,exports){
  9661. "use strict";
  9662. Object.defineProperties(exports, {
  9663. stringify: {get: function() {
  9664. return stringify;
  9665. }},
  9666. __esModule: {value: true}
  9667. });
  9668. function stringify(value) {
  9669. switch (typeof value) {
  9670. case 'string':
  9671. case 'number':
  9672. return value + '';
  9673. case 'object':
  9674. if (value === null) {
  9675. return '';
  9676. } else {
  9677. return value.toString();
  9678. }
  9679. break;
  9680. case 'undefined':
  9681. return '';
  9682. default:
  9683. return value.toString();
  9684. }
  9685. }
  9686. //#
  9687. },{}],49:[function(require,module,exports){
  9688. "use strict";
  9689. Object.defineProperties(exports, {
  9690. isNumeric: {get: function() {
  9691. return isNumeric;
  9692. }},
  9693. rangeEach: {get: function() {
  9694. return rangeEach;
  9695. }},
  9696. rangeEachReverse: {get: function() {
  9697. return rangeEachReverse;
  9698. }},
  9699. valueAccordingPercent: {get: function() {
  9700. return valueAccordingPercent;
  9701. }},
  9702. __esModule: {value: true}
  9703. });
  9704. function isNumeric(n) {
  9705. var t = typeof n;
  9706. return t == 'number' ? !isNaN(n) && isFinite(n) : t == 'string' ? !n.length ? false : n.length == 1 ? /\d/.test(n) : /^\s*[+-]?\s*(?:(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?)|(?:0x[a-f\d]+))\s*$/i.test(n) : t == 'object' ? !!n && typeof n.valueOf() == 'number' && !(n instanceof Date) : false;
  9707. }
  9708. function rangeEach(rangeFrom, rangeTo, iteratee) {
  9709. var index = -1;
  9710. if (typeof rangeTo === 'function') {
  9711. iteratee = rangeTo;
  9712. rangeTo = rangeFrom;
  9713. } else {
  9714. index = rangeFrom - 1;
  9715. }
  9716. while (++index <= rangeTo) {
  9717. if (iteratee(index) === false) {
  9718. break;
  9719. }
  9720. }
  9721. }
  9722. function rangeEachReverse(rangeFrom, rangeTo, iteratee) {
  9723. var index = rangeFrom + 1;
  9724. if (typeof rangeTo === 'function') {
  9725. iteratee = rangeTo;
  9726. rangeTo = 0;
  9727. }
  9728. while (--index >= rangeTo) {
  9729. if (iteratee(index) === false) {
  9730. break;
  9731. }
  9732. }
  9733. }
  9734. function valueAccordingPercent(value, percent) {
  9735. percent = parseInt(percent.toString().replace('%', ''), 10);
  9736. percent = parseInt(value * percent / 100);
  9737. return percent;
  9738. }
  9739. //#
  9740. },{}],50:[function(require,module,exports){
  9741. "use strict";
  9742. Object.defineProperties(exports, {
  9743. duckSchema: {get: function() {
  9744. return duckSchema;
  9745. }},
  9746. inherit: {get: function() {
  9747. return inherit;
  9748. }},
  9749. extend: {get: function() {
  9750. return extend;
  9751. }},
  9752. deepExtend: {get: function() {
  9753. return deepExtend;
  9754. }},
  9755. deepClone: {get: function() {
  9756. return deepClone;
  9757. }},
  9758. clone: {get: function() {
  9759. return clone;
  9760. }},
  9761. mixin: {get: function() {
  9762. return mixin;
  9763. }},
  9764. isObjectEquals: {get: function() {
  9765. return isObjectEquals;
  9766. }},
  9767. isObject: {get: function() {
  9768. return isObject;
  9769. }},
  9770. getPrototypeOf: {get: function() {
  9771. return getPrototypeOf;
  9772. }},
  9773. defineGetter: {get: function() {
  9774. return defineGetter;
  9775. }},
  9776. objectEach: {get: function() {
  9777. return objectEach;
  9778. }},
  9779. getProperty: {get: function() {
  9780. return getProperty;
  9781. }},
  9782. __esModule: {value: true}
  9783. });
  9784. var $__array__;
  9785. var arrayEach = ($__array__ = require("array"), $__array__ && $__array__.__esModule && $__array__ || {default: $__array__}).arrayEach;
  9786. function duckSchema(object) {
  9787. var schema;
  9788. if (Array.isArray(object)) {
  9789. schema = [];
  9790. } else {
  9791. schema = {};
  9792. objectEach(object, function(value, key) {
  9793. if (value && typeof value === 'object' && !Array.isArray(value)) {
  9794. schema[key] = duckSchema(value);
  9795. } else if (Array.isArray(value)) {
  9796. if (value.length && typeof value[0] === 'object' && !Array.isArray(value[0])) {
  9797. schema[key] = [duckSchema(value[0])];
  9798. } else {
  9799. schema[key] = [];
  9800. }
  9801. } else {
  9802. schema[key] = null;
  9803. }
  9804. });
  9805. }
  9806. return schema;
  9807. }
  9808. function inherit(Child, Parent) {
  9809. Parent.prototype.constructor = Parent;
  9810. Child.prototype = new Parent();
  9811. Child.prototype.constructor = Child;
  9812. return Child;
  9813. }
  9814. function extend(target, extension) {
  9815. objectEach(extension, function(value, key) {
  9816. target[key] = value;
  9817. });
  9818. return target;
  9819. }
  9820. function deepExtend(target, extension) {
  9821. objectEach(extension, function(value, key) {
  9822. if (extension[key] && typeof extension[key] === 'object') {
  9823. if (!target[key]) {
  9824. if (Array.isArray(extension[key])) {
  9825. target[key] = [];
  9826. } else {
  9827. target[key] = {};
  9828. }
  9829. }
  9830. deepExtend(target[key], extension[key]);
  9831. } else {
  9832. target[key] = extension[key];
  9833. }
  9834. });
  9835. }
  9836. function deepClone(obj) {
  9837. if (typeof obj === 'object') {
  9838. return JSON.parse(JSON.stringify(obj));
  9839. }
  9840. return obj;
  9841. }
  9842. function clone(object) {
  9843. var result = {};
  9844. objectEach(object, (function(value, key) {
  9845. result[key] = value;
  9846. }));
  9847. return result;
  9848. }
  9849. function mixin(Base) {
  9850. for (var mixins = [],
  9851. $__1 = 1; $__1 < arguments.length; $__1++)
  9852. mixins[$__1 - 1] = arguments[$__1];
  9853. if (!Base.MIXINS) {
  9854. Base.MIXINS = [];
  9855. }
  9856. arrayEach(mixins, (function(mixin) {
  9857. Base.MIXINS.push(mixin.MIXIN_NAME);
  9858. objectEach(mixin, (function(value, key) {
  9859. if (Base.prototype[key] !== void 0) {
  9860. throw new Error(("Mixin conflict. Property '" + key + "' already exist and cannot be overwritten."));
  9861. }
  9862. if (typeof value === 'function') {
  9863. Base.prototype[key] = value;
  9864. } else {
  9865. var getter = function _getter(propertyName, initialValue) {
  9866. propertyName = '_' + propertyName;
  9867. var initValue = (function(value) {
  9868. if (Array.isArray(value) || isObject(value)) {
  9869. value = deepClone(value);
  9870. }
  9871. return value;
  9872. });
  9873. return function() {
  9874. if (this[propertyName] === void 0) {
  9875. this[propertyName] = initValue(initialValue);
  9876. }
  9877. return this[propertyName];
  9878. };
  9879. };
  9880. var setter = function _setter(propertyName) {
  9881. propertyName = '_' + propertyName;
  9882. return function(value) {
  9883. this[propertyName] = value;
  9884. };
  9885. };
  9886. Object.defineProperty(Base.prototype, key, {
  9887. get: getter(key, value),
  9888. set: setter(key),
  9889. configurable: true
  9890. });
  9891. }
  9892. }));
  9893. }));
  9894. return Base;
  9895. }
  9896. function isObjectEquals(object1, object2) {
  9897. return JSON.stringify(object1) === JSON.stringify(object2);
  9898. }
  9899. function isObject(obj) {
  9900. return Object.prototype.toString.call(obj) == '[object Object]';
  9901. }
  9902. function getPrototypeOf(obj) {
  9903. var prototype;
  9904. if (typeof obj.__proto__ == 'object') {
  9905. prototype = obj.__proto__;
  9906. } else {
  9907. var oldConstructor,
  9908. constructor = obj.constructor;
  9909. if (typeof obj.constructor == 'function') {
  9910. oldConstructor = constructor;
  9911. if (delete obj.constructor) {
  9912. constructor = obj.constructor;
  9913. obj.constructor = oldConstructor;
  9914. }
  9915. }
  9916. prototype = constructor ? constructor.prototype : null;
  9917. }
  9918. return prototype;
  9919. }
  9920. function defineGetter(object, property, value, options) {
  9921. options.value = value;
  9922. options.writable = options.writable !== false;
  9923. options.enumerable = options.enumerable !== false;
  9924. options.configurable = options.configurable !== false;
  9925. Object.defineProperty(object, property, options);
  9926. }
  9927. function objectEach(object, iteratee) {
  9928. for (var key in object) {
  9929. if (!object.hasOwnProperty || (object.hasOwnProperty && object.hasOwnProperty(key))) {
  9930. if (iteratee(object[key], key, object) === false) {
  9931. break;
  9932. }
  9933. }
  9934. }
  9935. return object;
  9936. }
  9937. function getProperty(object, name) {
  9938. var names = name.split('.');
  9939. var result = object;
  9940. objectEach(names, (function(name) {
  9941. result = result[name];
  9942. if (result === void 0) {
  9943. result = void 0;
  9944. return false;
  9945. }
  9946. }));
  9947. return result;
  9948. }
  9949. //#
  9950. },{"array":42}],51:[function(require,module,exports){
  9951. "use strict";
  9952. Object.defineProperties(exports, {
  9953. columnFactory: {get: function() {
  9954. return columnFactory;
  9955. }},
  9956. __esModule: {value: true}
  9957. });
  9958. var $__object__;
  9959. var inherit = ($__object__ = require("object"), $__object__ && $__object__.__esModule && $__object__ || {default: $__object__}).inherit;
  9960. function columnFactory(GridSettings, conflictList) {
  9961. function ColumnSettings() {}
  9962. ;
  9963. inherit(ColumnSettings, GridSettings);
  9964. for (var i = 0,
  9965. len = conflictList.length; i < len; i++) {
  9966. ColumnSettings.prototype[conflictList[i]] = void 0;
  9967. }
  9968. return ColumnSettings;
  9969. }
  9970. //#
  9971. },{"object":50}],52:[function(require,module,exports){
  9972. "use strict";
  9973. Object.defineProperties(exports, {
  9974. toUpperCaseFirst: {get: function() {
  9975. return toUpperCaseFirst;
  9976. }},
  9977. startsWith: {get: function() {
  9978. return startsWith;
  9979. }},
  9980. endsWith: {get: function() {
  9981. return endsWith;
  9982. }},
  9983. equalsIgnoreCase: {get: function() {
  9984. return equalsIgnoreCase;
  9985. }},
  9986. randomString: {get: function() {
  9987. return randomString;
  9988. }},
  9989. isPercentValue: {get: function() {
  9990. return isPercentValue;
  9991. }},
  9992. substitute: {get: function() {
  9993. return substitute;
  9994. }},
  9995. padStart: {get: function() {
  9996. return padStart;
  9997. }},
  9998. __esModule: {value: true}
  9999. });
  10000. var $__mixed__,
  10001. $__number__;
  10002. var stringify = ($__mixed__ = require("mixed"), $__mixed__ && $__mixed__.__esModule && $__mixed__ || {default: $__mixed__}).stringify;
  10003. var rangeEach = ($__number__ = require("number"), $__number__ && $__number__.__esModule && $__number__ || {default: $__number__}).rangeEach;
  10004. function toUpperCaseFirst(string) {
  10005. return string[0].toUpperCase() + string.substr(1);
  10006. }
  10007. function startsWith(string, needle) {
  10008. var result = true;
  10009. rangeEach(needle.length - 1, (function(index) {
  10010. if (string.charAt(index) !== needle.charAt(index)) {
  10011. result = false;
  10012. return false;
  10013. }
  10014. }));
  10015. return result;
  10016. }
  10017. function endsWith(string, needle) {
  10018. var result = true;
  10019. var needleLength = needle.length - 1;
  10020. var stringLength = string.length - 1;
  10021. rangeEach(needleLength, (function(index) {
  10022. var stringIndex = stringLength - index;
  10023. var needleIndex = needleLength - index;
  10024. if (string.charAt(stringIndex) !== needle.charAt(needleIndex)) {
  10025. result = false;
  10026. return false;
  10027. }
  10028. }));
  10029. return result;
  10030. }
  10031. function equalsIgnoreCase() {
  10032. for (var strings = [],
  10033. $__2 = 0; $__2 < arguments.length; $__2++)
  10034. strings[$__2] = arguments[$__2];
  10035. var unique = [];
  10036. var length = strings.length;
  10037. while (length--) {
  10038. var string = stringify(strings[length]).toLowerCase();
  10039. if (unique.indexOf(string) === -1) {
  10040. unique.push(string);
  10041. }
  10042. }
  10043. return unique.length === 1;
  10044. }
  10045. function randomString() {
  10046. function s4() {
  10047. return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
  10048. }
  10049. return s4() + s4() + s4() + s4();
  10050. }
  10051. function isPercentValue(value) {
  10052. return /^([0-9][0-9]?\%$)|(^100\%$)/.test(value);
  10053. }
  10054. function substitute(template) {
  10055. var variables = arguments[1] !== (void 0) ? arguments[1] : {};
  10056. return (template + '').replace(/(?:\\)?\[([^\[\]]+)]/g, function(match, name) {
  10057. if (match.charAt(0) === '\\') {
  10058. return match.substr(1, match.length - 1);
  10059. }
  10060. return variables[name] === void 0 ? '' : variables[name];
  10061. });
  10062. }
  10063. function padStart(string, maxLength) {
  10064. var fillString = arguments[2] !== (void 0) ? arguments[2] : ' ';
  10065. string = string + '';
  10066. if (string.length >= maxLength) {
  10067. return string;
  10068. }
  10069. fillString = String(fillString);
  10070. var fillStringLength = fillString.length;
  10071. if (!fillStringLength) {
  10072. fillString = ' ';
  10073. }
  10074. var fillLen = maxLength - string.length;
  10075. var timesToRepeat = Math.ceil(fillLen / fillString.length);
  10076. var truncatedString = '';
  10077. rangeEach(timesToRepeat, (function(index) {
  10078. truncatedString += fillString;
  10079. }));
  10080. truncatedString = truncatedString.slice(0, fillLen);
  10081. return truncatedString + string;
  10082. }
  10083. ;
  10084. //#
  10085. },{"mixed":48,"number":49}],53:[function(require,module,exports){
  10086. "use strict";
  10087. Object.defineProperties(exports, {
  10088. KEY_CODES: {get: function() {
  10089. return KEY_CODES;
  10090. }},
  10091. isPrintableChar: {get: function() {
  10092. return isPrintableChar;
  10093. }},
  10094. isMetaKey: {get: function() {
  10095. return isMetaKey;
  10096. }},
  10097. isCtrlKey: {get: function() {
  10098. return isCtrlKey;
  10099. }},
  10100. isKey: {get: function() {
  10101. return isKey;
  10102. }},
  10103. __esModule: {value: true}
  10104. });
  10105. var $__array__;
  10106. var arrayEach = ($__array__ = require("array"), $__array__ && $__array__.__esModule && $__array__ || {default: $__array__}).arrayEach;
  10107. var KEY_CODES = {
  10108. MOUSE_LEFT: 1,
  10109. MOUSE_RIGHT: 3,
  10110. MOUSE_MIDDLE: 2,
  10111. BACKSPACE: 8,
  10112. COMMA: 188,
  10113. INSERT: 45,
  10114. DELETE: 46,
  10115. END: 35,
  10116. ENTER: 13,
  10117. ESCAPE: 27,
  10118. CONTROL_LEFT: 91,
  10119. COMMAND_LEFT: 17,
  10120. COMMAND_RIGHT: 93,
  10121. ALT: 18,
  10122. HOME: 36,
  10123. PAGE_DOWN: 34,
  10124. PAGE_UP: 33,
  10125. PERIOD: 190,
  10126. SPACE: 32,
  10127. SHIFT: 16,
  10128. CAPS_LOCK: 20,
  10129. TAB: 9,
  10130. ARROW_RIGHT: 39,
  10131. ARROW_LEFT: 37,
  10132. ARROW_UP: 38,
  10133. ARROW_DOWN: 40,
  10134. F1: 112,
  10135. F2: 113,
  10136. F3: 114,
  10137. F4: 115,
  10138. F5: 116,
  10139. F6: 117,
  10140. F7: 118,
  10141. F8: 119,
  10142. F9: 120,
  10143. F10: 121,
  10144. F11: 122,
  10145. F12: 123,
  10146. A: 65,
  10147. X: 88,
  10148. C: 67,
  10149. V: 86
  10150. };
  10151. function isPrintableChar(keyCode) {
  10152. return ((keyCode == 32) || (keyCode >= 48 && keyCode <= 57) || (keyCode >= 96 && keyCode <= 111) || (keyCode >= 186 && keyCode <= 192) || (keyCode >= 219 && keyCode <= 222) || keyCode >= 226 || (keyCode >= 65 && keyCode <= 90));
  10153. }
  10154. function isMetaKey(keyCode) {
  10155. var metaKeys = [KEY_CODES.ARROW_DOWN, KEY_CODES.ARROW_UP, KEY_CODES.ARROW_LEFT, KEY_CODES.ARROW_RIGHT, KEY_CODES.HOME, KEY_CODES.END, KEY_CODES.DELETE, KEY_CODES.BACKSPACE, KEY_CODES.F1, KEY_CODES.F2, KEY_CODES.F3, KEY_CODES.F4, KEY_CODES.F5, KEY_CODES.F6, KEY_CODES.F7, KEY_CODES.F8, KEY_CODES.F9, KEY_CODES.F10, KEY_CODES.F11, KEY_CODES.F12, KEY_CODES.TAB, KEY_CODES.PAGE_DOWN, KEY_CODES.PAGE_UP, KEY_CODES.ENTER, KEY_CODES.ESCAPE, KEY_CODES.SHIFT, KEY_CODES.CAPS_LOCK, KEY_CODES.ALT];
  10156. return metaKeys.indexOf(keyCode) !== -1;
  10157. }
  10158. function isCtrlKey(keyCode) {
  10159. return [KEY_CODES.CONTROL_LEFT, 224, KEY_CODES.COMMAND_LEFT, KEY_CODES.COMMAND_RIGHT].indexOf(keyCode) !== -1;
  10160. }
  10161. function isKey(keyCode, baseCode) {
  10162. var keys = baseCode.split('|');
  10163. var result = false;
  10164. arrayEach(keys, function(key) {
  10165. if (keyCode === KEY_CODES[key]) {
  10166. result = true;
  10167. return false;
  10168. }
  10169. });
  10170. return result;
  10171. }
  10172. //#
  10173. },{"array":42}],54:[function(require,module,exports){
  10174. "use strict";
  10175. Object.defineProperties(exports, {
  10176. localHooks: {get: function() {
  10177. return localHooks;
  10178. }},
  10179. __esModule: {value: true}
  10180. });
  10181. var $___46__46__47_helpers_47_array__,
  10182. $___46__46__47_helpers_47_object__;
  10183. var arrayEach = ($___46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47_helpers_47_array__ && $___46__46__47_helpers_47_array__.__esModule && $___46__46__47_helpers_47_array__ || {default: $___46__46__47_helpers_47_array__}).arrayEach;
  10184. var defineGetter = ($___46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47_helpers_47_object__ && $___46__46__47_helpers_47_object__.__esModule && $___46__46__47_helpers_47_object__ || {default: $___46__46__47_helpers_47_object__}).defineGetter;
  10185. var MIXIN_NAME = 'localHooks';
  10186. var localHooks = {
  10187. _localHooks: Object.create(null),
  10188. addLocalHook: function(key, callback) {
  10189. if (!this._localHooks[key]) {
  10190. this._localHooks[key] = [];
  10191. }
  10192. this._localHooks[key].push(callback);
  10193. },
  10194. runLocalHooks: function(key) {
  10195. for (var params = [],
  10196. $__3 = 1; $__3 < arguments.length; $__3++)
  10197. params[$__3 - 1] = arguments[$__3];
  10198. var $__2 = this;
  10199. if (this._localHooks[key]) {
  10200. arrayEach(this._localHooks[key], (function(callback) {
  10201. return callback.apply($__2, params);
  10202. }));
  10203. }
  10204. },
  10205. clearLocalHooks: function() {
  10206. this._localHooks = {};
  10207. }
  10208. };
  10209. defineGetter(localHooks, 'MIXIN_NAME', MIXIN_NAME, {
  10210. writable: false,
  10211. enumerable: false
  10212. });
  10213. ;
  10214. Handsontable.utils = Handsontable.utils || {};
  10215. Handsontable.utils.localHooks = localHooks;
  10216. //#
  10217. },{"helpers/array":42,"helpers/object":50}],55:[function(require,module,exports){
  10218. "use strict";
  10219. Object.defineProperties(exports, {
  10220. MultiMap: {get: function() {
  10221. return MultiMap;
  10222. }},
  10223. __esModule: {value: true}
  10224. });
  10225. ;
  10226. window.MultiMap = MultiMap;
  10227. function MultiMap() {
  10228. var map = {
  10229. arrayMap: [],
  10230. weakMap: new WeakMap()
  10231. };
  10232. return {
  10233. get: function(key) {
  10234. if (canBeAnArrayMapKey(key)) {
  10235. return map.arrayMap[key];
  10236. } else if (canBeAWeakMapKey(key)) {
  10237. return map.weakMap.get(key);
  10238. }
  10239. },
  10240. set: function(key, value) {
  10241. if (canBeAnArrayMapKey(key)) {
  10242. map.arrayMap[key] = value;
  10243. } else if (canBeAWeakMapKey(key)) {
  10244. map.weakMap.set(key, value);
  10245. } else {
  10246. throw new Error('Invalid key type');
  10247. }
  10248. },
  10249. delete: function(key) {
  10250. if (canBeAnArrayMapKey(key)) {
  10251. delete map.arrayMap[key];
  10252. } else if (canBeAWeakMapKey(key)) {
  10253. map.weakMap.delete(key);
  10254. }
  10255. }
  10256. };
  10257. function canBeAnArrayMapKey(obj) {
  10258. return obj !== null && !isNaNSymbol(obj) && (typeof obj == 'string' || typeof obj == 'number');
  10259. }
  10260. function canBeAWeakMapKey(obj) {
  10261. return obj !== null && (typeof obj == 'object' || typeof obj == 'function');
  10262. }
  10263. function isNaNSymbol(obj) {
  10264. return obj !== obj;
  10265. }
  10266. }
  10267. //#
  10268. },{}],56:[function(require,module,exports){
  10269. "use strict";
  10270. Object.defineProperties(exports, {
  10271. Hooks: {get: function() {
  10272. return Hooks;
  10273. }},
  10274. __esModule: {value: true}
  10275. });
  10276. var $__helpers_47_array__,
  10277. $__helpers_47_object__;
  10278. var REGISTERED_HOOKS = ['afterCellMetaReset', 'afterChange', 'afterChangesObserved', 'afterContextMenuDefaultOptions', 'afterContextMenuHide', 'afterContextMenuShow', 'afterCopyLimit', 'afterCreateCol', 'afterCreateRow', 'afterDeselect', 'afterDestroy', 'afterDocumentKeyDown', 'afterGetCellMeta', 'afterGetColHeader', 'afterGetRowHeader', 'afterInit', 'afterLoadData', 'afterMomentumScroll', 'afterOnCellCornerMouseDown', 'afterOnCellMouseDown', 'afterOnCellMouseOver', 'afterRemoveCol', 'afterRemoveRow', 'afterRender', 'afterRenderer', 'afterScrollHorizontally', 'afterScrollVertically', 'afterSelection', 'afterSelectionByProp', 'afterSelectionEnd', 'afterSelectionEndByProp', 'afterSetCellMeta', 'afterUpdateSettings', 'afterValidate', 'beforeAutofill', 'beforeCellAlignment', 'beforeChange', 'beforeChangeRender', 'beforeDrawBorders', 'beforeGetCellMeta', 'beforeInit', 'beforeInitWalkontable', 'beforeKeyDown', 'beforeOnCellMouseDown', 'beforeRemoveCol', 'beforeRemoveRow', 'beforeRender', 'beforeSetRangeEnd', 'beforeTouchScroll', 'beforeValidate', 'construct', 'init', 'modifyCol', 'modifyColHeader', 'modifyColWidth', 'modifyRow', 'modifyRowHeader', 'modifyRowHeight', 'persistentStateLoad', 'persistentStateReset', 'persistentStateSave', 'beforeColumnSort', 'afterColumnSort', 'afterAutofillApplyValues', 'modifyCopyableRange', 'beforeColumnMove', 'afterColumnMove', 'beforeRowMove', 'afterRowMove', 'beforeColumnResize', 'afterColumnResize', 'beforeRowResize', 'afterRowResize'];
  10279. var arrayEach = ($__helpers_47_array__ = require("helpers/array"), $__helpers_47_array__ && $__helpers_47_array__.__esModule && $__helpers_47_array__ || {default: $__helpers_47_array__}).arrayEach;
  10280. var objectEach = ($__helpers_47_object__ = require("helpers/object"), $__helpers_47_object__ && $__helpers_47_object__.__esModule && $__helpers_47_object__ || {default: $__helpers_47_object__}).objectEach;
  10281. var Hooks = function Hooks() {
  10282. this.globalBucket = this.createEmptyBucket();
  10283. };
  10284. ($traceurRuntime.createClass)(Hooks, {
  10285. createEmptyBucket: function() {
  10286. var bucket = Object.create(null);
  10287. arrayEach(REGISTERED_HOOKS, (function(hook) {
  10288. return (bucket[hook] = []);
  10289. }));
  10290. return bucket;
  10291. },
  10292. getBucket: function() {
  10293. var context = arguments[0] !== (void 0) ? arguments[0] : null;
  10294. if (context) {
  10295. if (!context.pluginHookBucket) {
  10296. context.pluginHookBucket = this.createEmptyBucket();
  10297. }
  10298. return context.pluginHookBucket;
  10299. }
  10300. return this.globalBucket;
  10301. },
  10302. add: function(key, callback) {
  10303. var context = arguments[2] !== (void 0) ? arguments[2] : null;
  10304. var $__2 = this;
  10305. if (Array.isArray(callback)) {
  10306. arrayEach(callback, (function(c) {
  10307. return ($__2.add(key, c, context));
  10308. }));
  10309. } else {
  10310. var bucket = this.getBucket(context);
  10311. if (typeof bucket[key] === 'undefined') {
  10312. this.register(key);
  10313. bucket[key] = [];
  10314. }
  10315. callback.skip = false;
  10316. if (bucket[key].indexOf(callback) === -1) {
  10317. bucket[key].push(callback);
  10318. }
  10319. }
  10320. return this;
  10321. },
  10322. once: function(key, callback) {
  10323. var context = arguments[2] !== (void 0) ? arguments[2] : null;
  10324. var $__2 = this;
  10325. if (Array.isArray(callback)) {
  10326. arrayEach(callback, (function(c) {
  10327. return ($__2.once(key, c, context));
  10328. }));
  10329. } else {
  10330. callback.runOnce = true;
  10331. this.add(key, callback, context);
  10332. }
  10333. },
  10334. remove: function(key, callback) {
  10335. var context = arguments[2] !== (void 0) ? arguments[2] : null;
  10336. var bucket = this.getBucket(context);
  10337. if (typeof bucket[key] !== 'undefined') {
  10338. if (bucket[key].indexOf(callback) >= 0) {
  10339. callback.skip = true;
  10340. return true;
  10341. }
  10342. }
  10343. return false;
  10344. },
  10345. has: function(key) {
  10346. var context = arguments[1] !== (void 0) ? arguments[1] : null;
  10347. var bucket = this.getBucket(context);
  10348. return bucket[key] !== void 0 && bucket[key].length ? true : false;
  10349. },
  10350. run: function(context, key, p1, p2, p3, p4, p5, p6) {
  10351. {
  10352. var globalHandlers = this.globalBucket[key];
  10353. var index = -1;
  10354. var length = globalHandlers ? globalHandlers.length : 0;
  10355. if (length) {
  10356. while (++index < length) {
  10357. if (!globalHandlers[index] || globalHandlers[index].skip) {
  10358. continue;
  10359. }
  10360. var res = globalHandlers[index].call(context, p1, p2, p3, p4, p5, p6);
  10361. if (res !== void 0) {
  10362. p1 = res;
  10363. }
  10364. if (globalHandlers[index] && globalHandlers[index].runOnce) {
  10365. this.remove(key, globalHandlers[index]);
  10366. }
  10367. }
  10368. }
  10369. }
  10370. {
  10371. var localHandlers = this.getBucket(context)[key];
  10372. var index$__4 = -1;
  10373. var length$__5 = localHandlers ? localHandlers.length : 0;
  10374. if (length$__5) {
  10375. while (++index$__4 < length$__5) {
  10376. if (!localHandlers[index$__4] || localHandlers[index$__4].skip) {
  10377. continue;
  10378. }
  10379. var res$__6 = localHandlers[index$__4].call(context, p1, p2, p3, p4, p5, p6);
  10380. if (res$__6 !== void 0) {
  10381. p1 = res$__6;
  10382. }
  10383. if (localHandlers[index$__4] && localHandlers[index$__4].runOnce) {
  10384. this.remove(key, localHandlers[index$__4], context);
  10385. }
  10386. }
  10387. }
  10388. }
  10389. return p1;
  10390. },
  10391. destroy: function() {
  10392. var context = arguments[0] !== (void 0) ? arguments[0] : null;
  10393. objectEach(this.getBucket(context), (function(value, key, bucket) {
  10394. return (bucket[key].length = 0);
  10395. }));
  10396. },
  10397. register: function(key) {
  10398. if (!this.isRegistered(key)) {
  10399. REGISTERED_HOOKS.push(key);
  10400. }
  10401. },
  10402. deregister: function(key) {
  10403. if (this.isRegistered(key)) {
  10404. REGISTERED_HOOKS.splice(REGISTERED_HOOKS.indexOf(key), 1);
  10405. }
  10406. },
  10407. isRegistered: function(key) {
  10408. return REGISTERED_HOOKS.indexOf(key) >= 0;
  10409. },
  10410. getRegistered: function() {
  10411. return REGISTERED_HOOKS;
  10412. }
  10413. }, {});
  10414. ;
  10415. Handsontable.utils = Handsontable.utils || {};
  10416. Handsontable.utils.Hooks = Hooks;
  10417. //#
  10418. },{"helpers/array":42,"helpers/object":50}],57:[function(require,module,exports){
  10419. "use strict";
  10420. Object.defineProperties(exports, {
  10421. registerPlugin: {get: function() {
  10422. return registerPlugin;
  10423. }},
  10424. getPlugin: {get: function() {
  10425. return getPlugin;
  10426. }},
  10427. getRegistredPluginNames: {get: function() {
  10428. return getRegistredPluginNames;
  10429. }},
  10430. getPluginName: {get: function() {
  10431. return getPluginName;
  10432. }},
  10433. __esModule: {value: true}
  10434. });
  10435. var $__helpers_47_object__,
  10436. $__helpers_47_string__;
  10437. var objectEach = ($__helpers_47_object__ = require("helpers/object"), $__helpers_47_object__ && $__helpers_47_object__.__esModule && $__helpers_47_object__ || {default: $__helpers_47_object__}).objectEach;
  10438. var toUpperCaseFirst = ($__helpers_47_string__ = require("helpers/string"), $__helpers_47_string__ && $__helpers_47_string__.__esModule && $__helpers_47_string__ || {default: $__helpers_47_string__}).toUpperCaseFirst;
  10439. var registeredPlugins = new WeakMap();
  10440. Handsontable.plugins = Handsontable.plugins || {};
  10441. function registerPlugin(pluginName, PluginClass) {
  10442. pluginName = toUpperCaseFirst(pluginName);
  10443. Handsontable.plugins[pluginName] = PluginClass;
  10444. Handsontable.hooks.add('construct', function() {
  10445. var holder;
  10446. if (!registeredPlugins.has(this)) {
  10447. registeredPlugins.set(this, {});
  10448. }
  10449. holder = registeredPlugins.get(this);
  10450. if (!holder[pluginName]) {
  10451. holder[pluginName] = new PluginClass(this);
  10452. }
  10453. });
  10454. Handsontable.hooks.add('afterDestroy', function() {
  10455. if (registeredPlugins.has(this)) {
  10456. var pluginsHolder = registeredPlugins.get(this);
  10457. objectEach(pluginsHolder, (function(plugin) {
  10458. return plugin.destroy();
  10459. }));
  10460. registeredPlugins.delete(this);
  10461. }
  10462. });
  10463. }
  10464. function getPlugin(instance, pluginName) {
  10465. if (typeof pluginName != 'string') {
  10466. throw Error('Only strings can be passed as "plugin" parameter');
  10467. }
  10468. var _pluginName = toUpperCaseFirst(pluginName);
  10469. if (!registeredPlugins.has(instance) || !registeredPlugins.get(instance)[_pluginName]) {
  10470. return void 0;
  10471. }
  10472. return registeredPlugins.get(instance)[_pluginName];
  10473. }
  10474. function getRegistredPluginNames(hotInstance) {
  10475. return registeredPlugins.has(hotInstance) ? Object.keys(registeredPlugins.get(hotInstance)) : [];
  10476. }
  10477. function getPluginName(hotInstance, plugin) {
  10478. var pluginName = null;
  10479. if (registeredPlugins.has(hotInstance)) {
  10480. objectEach(registeredPlugins.get(hotInstance), (function(pluginInstance, name) {
  10481. if (pluginInstance === plugin) {
  10482. pluginName = name;
  10483. }
  10484. }));
  10485. }
  10486. return pluginName;
  10487. }
  10488. ;
  10489. Handsontable.plugins.utils = Handsontable.plugins.utils || {};
  10490. Handsontable.plugins.registerPlugin = registerPlugin;
  10491. //#
  10492. },{"helpers/object":50,"helpers/string":52}],58:[function(require,module,exports){
  10493. "use strict";
  10494. Object.defineProperties(exports, {
  10495. default: {get: function() {
  10496. return $__default;
  10497. }},
  10498. __esModule: {value: true}
  10499. });
  10500. var $___46__46__47_helpers_47_object__,
  10501. $___46__46__47_helpers_47_array__,
  10502. $___46__46__47_plugins__;
  10503. var $__0 = ($___46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47_helpers_47_object__ && $___46__46__47_helpers_47_object__.__esModule && $___46__46__47_helpers_47_object__ || {default: $___46__46__47_helpers_47_object__}),
  10504. defineGetter = $__0.defineGetter,
  10505. objectEach = $__0.objectEach;
  10506. var arrayEach = ($___46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47_helpers_47_array__ && $___46__46__47_helpers_47_array__.__esModule && $___46__46__47_helpers_47_array__ || {default: $___46__46__47_helpers_47_array__}).arrayEach;
  10507. var $__2 = ($___46__46__47_plugins__ = require("plugins"), $___46__46__47_plugins__ && $___46__46__47_plugins__.__esModule && $___46__46__47_plugins__ || {default: $___46__46__47_plugins__}),
  10508. getRegistredPluginNames = $__2.getRegistredPluginNames,
  10509. getPluginName = $__2.getPluginName;
  10510. var privatePool = new WeakMap();
  10511. var initializedPlugins = null;
  10512. var BasePlugin = function BasePlugin(hotInstance) {
  10513. var $__3 = this;
  10514. defineGetter(this, 'hot', hotInstance, {writable: false});
  10515. privatePool.set(this, {hooks: {}});
  10516. initializedPlugins = null;
  10517. this.pluginName = null;
  10518. this.pluginsInitializedCallbacks = [];
  10519. this.isPluginsReady = false;
  10520. this.enabled = false;
  10521. this.initialized = false;
  10522. this.hot.addHook('afterPluginsInitialized', (function() {
  10523. return $__3.onAfterPluginsInitialized();
  10524. }));
  10525. this.hot.addHook('afterUpdateSettings', (function() {
  10526. return $__3.onUpdateSettings();
  10527. }));
  10528. this.hot.addHook('beforeInit', (function() {
  10529. return $__3.init();
  10530. }));
  10531. };
  10532. ($traceurRuntime.createClass)(BasePlugin, {
  10533. init: function() {
  10534. this.pluginName = getPluginName(this.hot, this);
  10535. if (this.isEnabled && this.isEnabled()) {
  10536. this.enablePlugin();
  10537. }
  10538. if (!initializedPlugins) {
  10539. initializedPlugins = getRegistredPluginNames(this.hot);
  10540. }
  10541. if (initializedPlugins.indexOf(this.pluginName) >= 0) {
  10542. initializedPlugins.splice(initializedPlugins.indexOf(this.pluginName), 1);
  10543. }
  10544. if (!initializedPlugins.length) {
  10545. this.hot.runHooks('afterPluginsInitialized');
  10546. }
  10547. this.initialized = true;
  10548. },
  10549. enablePlugin: function() {
  10550. this.enabled = true;
  10551. },
  10552. disablePlugin: function() {
  10553. if (this.eventManager) {
  10554. this.eventManager.clear();
  10555. }
  10556. this.clearHooks();
  10557. this.enabled = false;
  10558. },
  10559. addHook: function(name, callback) {
  10560. var hooks = privatePool.get(this).hooks[name] = (privatePool.get(this).hooks[name] || []);
  10561. this.hot.addHook(name, callback);
  10562. hooks.push(callback);
  10563. privatePool.get(this).hooks[name] = hooks;
  10564. },
  10565. removeHooks: function(name) {
  10566. var $__3 = this;
  10567. arrayEach(privatePool.get(this).hooks[name] || [], (function(callback) {
  10568. $__3.hot.removeHook(name, callback);
  10569. }));
  10570. },
  10571. clearHooks: function() {
  10572. var $__3 = this;
  10573. var hooks = privatePool.get(this).hooks;
  10574. objectEach(hooks, (function(callbacks, name) {
  10575. return $__3.removeHooks(name);
  10576. }));
  10577. hooks.length = 0;
  10578. },
  10579. callOnPluginsReady: function(callback) {
  10580. if (this.isPluginsReady) {
  10581. callback();
  10582. } else {
  10583. this.pluginsInitializedCallbacks.push(callback);
  10584. }
  10585. },
  10586. onAfterPluginsInitialized: function() {
  10587. arrayEach(this.pluginsInitializedCallbacks, (function(callback) {
  10588. return callback();
  10589. }));
  10590. this.pluginsInitializedCallbacks.length = 0;
  10591. this.isPluginsReady = true;
  10592. },
  10593. onUpdateSettings: function() {
  10594. if (this.isEnabled) {
  10595. if (this.enabled && !this.isEnabled()) {
  10596. this.disablePlugin();
  10597. }
  10598. if (!this.enabled && this.isEnabled()) {
  10599. this.enablePlugin();
  10600. }
  10601. if (this.enabled && this.isEnabled()) {
  10602. this.updatePlugin();
  10603. }
  10604. }
  10605. },
  10606. updatePlugin: function() {},
  10607. destroy: function() {
  10608. var $__3 = this;
  10609. if (this.eventManager) {
  10610. this.eventManager.destroy();
  10611. }
  10612. this.clearHooks();
  10613. objectEach(this, (function(value, property) {
  10614. if (property !== 'hot') {
  10615. $__3[property] = null;
  10616. }
  10617. }));
  10618. delete this.hot;
  10619. }
  10620. }, {});
  10621. var $__default = BasePlugin;
  10622. Handsontable.plugins.BasePlugin = BasePlugin;
  10623. //#
  10624. },{"helpers/array":42,"helpers/object":50,"plugins":57}],59:[function(require,module,exports){
  10625. "use strict";
  10626. Object.defineProperties(exports, {
  10627. AutoColumnSize: {get: function() {
  10628. return AutoColumnSize;
  10629. }},
  10630. __esModule: {value: true}
  10631. });
  10632. var $___46__46__47__95_base__,
  10633. $___46__46__47__46__46__47_helpers_47_array__,
  10634. $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  10635. $___46__46__47__46__46__47_utils_47_ghostTable__,
  10636. $___46__46__47__46__46__47_helpers_47_object__,
  10637. $___46__46__47__46__46__47_helpers_47_number__,
  10638. $___46__46__47__46__46__47_plugins__,
  10639. $___46__46__47__46__46__47_utils_47_samplesGenerator__,
  10640. $___46__46__47__46__46__47_helpers_47_string__,
  10641. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__;
  10642. var BasePlugin = ($___46__46__47__95_base__ = require("_base"), $___46__46__47__95_base__ && $___46__46__47__95_base__.__esModule && $___46__46__47__95_base__ || {default: $___46__46__47__95_base__}).default;
  10643. var $__1 = ($___46__46__47__46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47__46__46__47_helpers_47_array__ && $___46__46__47__46__46__47_helpers_47_array__.__esModule && $___46__46__47__46__46__47_helpers_47_array__ || {default: $___46__46__47__46__46__47_helpers_47_array__}),
  10644. arrayEach = $__1.arrayEach,
  10645. arrayFilter = $__1.arrayFilter;
  10646. var $__2 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  10647. cancelAnimationFrame = $__2.cancelAnimationFrame,
  10648. requestAnimationFrame = $__2.requestAnimationFrame,
  10649. isVisible = $__2.isVisible;
  10650. var GhostTable = ($___46__46__47__46__46__47_utils_47_ghostTable__ = require("utils/ghostTable"), $___46__46__47__46__46__47_utils_47_ghostTable__ && $___46__46__47__46__46__47_utils_47_ghostTable__.__esModule && $___46__46__47__46__46__47_utils_47_ghostTable__ || {default: $___46__46__47__46__46__47_utils_47_ghostTable__}).GhostTable;
  10651. var $__4 = ($___46__46__47__46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47__46__46__47_helpers_47_object__ && $___46__46__47__46__46__47_helpers_47_object__.__esModule && $___46__46__47__46__46__47_helpers_47_object__ || {default: $___46__46__47__46__46__47_helpers_47_object__}),
  10652. isObject = $__4.isObject,
  10653. objectEach = $__4.objectEach;
  10654. var $__5 = ($___46__46__47__46__46__47_helpers_47_number__ = require("helpers/number"), $___46__46__47__46__46__47_helpers_47_number__ && $___46__46__47__46__46__47_helpers_47_number__.__esModule && $___46__46__47__46__46__47_helpers_47_number__ || {default: $___46__46__47__46__46__47_helpers_47_number__}),
  10655. valueAccordingPercent = $__5.valueAccordingPercent,
  10656. rangeEach = $__5.rangeEach;
  10657. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  10658. var SamplesGenerator = ($___46__46__47__46__46__47_utils_47_samplesGenerator__ = require("utils/samplesGenerator"), $___46__46__47__46__46__47_utils_47_samplesGenerator__ && $___46__46__47__46__46__47_utils_47_samplesGenerator__.__esModule && $___46__46__47__46__46__47_utils_47_samplesGenerator__ || {default: $___46__46__47__46__46__47_utils_47_samplesGenerator__}).SamplesGenerator;
  10659. var isPercentValue = ($___46__46__47__46__46__47_helpers_47_string__ = require("helpers/string"), $___46__46__47__46__46__47_helpers_47_string__ && $___46__46__47__46__46__47_helpers_47_string__.__esModule && $___46__46__47__46__46__47_helpers_47_string__ || {default: $___46__46__47__46__46__47_helpers_47_string__}).isPercentValue;
  10660. var WalkontableViewportColumnsCalculator = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__ = require("3rdparty/walkontable/src/calculator/viewportColumns"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_calculator_47_viewportColumns__}).WalkontableViewportColumnsCalculator;
  10661. var AutoColumnSize = function AutoColumnSize(hotInstance) {
  10662. var $__10 = this;
  10663. $traceurRuntime.superConstructor($AutoColumnSize).call(this, hotInstance);
  10664. this.widths = [];
  10665. this.ghostTable = new GhostTable(this.hot);
  10666. this.samplesGenerator = new SamplesGenerator((function(row, col) {
  10667. return $__10.hot.getDataAtCell(row, col);
  10668. }));
  10669. this.firstCalculation = true;
  10670. this.inProgress = false;
  10671. this.addHook('beforeColumnResize', (function(col, size, isDblClick) {
  10672. return $__10.onBeforeColumnResize(col, size, isDblClick);
  10673. }));
  10674. };
  10675. var $AutoColumnSize = AutoColumnSize;
  10676. ($traceurRuntime.createClass)(AutoColumnSize, {
  10677. isEnabled: function() {
  10678. return this.hot.getSettings().autoColumnSize !== false && !this.hot.getSettings().colWidths;
  10679. },
  10680. enablePlugin: function() {
  10681. var $__10 = this;
  10682. if (this.enabled) {
  10683. return;
  10684. }
  10685. this.addHook('afterLoadData', (function() {
  10686. return $__10.onAfterLoadData();
  10687. }));
  10688. this.addHook('beforeChange', (function(changes) {
  10689. return $__10.onBeforeChange(changes);
  10690. }));
  10691. this.addHook('beforeRender', (function(force) {
  10692. return $__10.onBeforeRender(force);
  10693. }));
  10694. this.addHook('modifyColWidth', (function(width, col) {
  10695. return $__10.getColumnWidth(col, width);
  10696. }));
  10697. $traceurRuntime.superGet(this, $AutoColumnSize.prototype, "enablePlugin").call(this);
  10698. },
  10699. disablePlugin: function() {
  10700. $traceurRuntime.superGet(this, $AutoColumnSize.prototype, "disablePlugin").call(this);
  10701. },
  10702. calculateColumnsWidth: function() {
  10703. var colRange = arguments[0] !== (void 0) ? arguments[0] : {
  10704. from: 0,
  10705. to: this.hot.countCols() - 1
  10706. };
  10707. var rowRange = arguments[1] !== (void 0) ? arguments[1] : {
  10708. from: 0,
  10709. to: this.hot.countRows() - 1
  10710. };
  10711. var force = arguments[2] !== (void 0) ? arguments[2] : false;
  10712. var $__10 = this;
  10713. if (typeof colRange === 'number') {
  10714. colRange = {
  10715. from: colRange,
  10716. to: colRange
  10717. };
  10718. }
  10719. if (typeof rowRange === 'number') {
  10720. rowRange = {
  10721. from: rowRange,
  10722. to: rowRange
  10723. };
  10724. }
  10725. rangeEach(colRange.from, colRange.to, (function(col) {
  10726. if (force || ($__10.widths[col] === void 0 && !$__10.hot._getColWidthFromSettings(col))) {
  10727. var samples = $__10.samplesGenerator.generateColumnSamples(col, rowRange);
  10728. samples.forEach((function(sample, col) {
  10729. return $__10.ghostTable.addColumn(col, sample);
  10730. }));
  10731. }
  10732. }));
  10733. if (this.ghostTable.columns.length) {
  10734. this.ghostTable.getWidths((function(col, width) {
  10735. return $__10.widths[col] = width;
  10736. }));
  10737. this.ghostTable.clean();
  10738. }
  10739. },
  10740. calculateAllColumnsWidth: function() {
  10741. var rowRange = arguments[0] !== (void 0) ? arguments[0] : {
  10742. from: 0,
  10743. to: this.hot.countRows() - 1
  10744. };
  10745. var $__10 = this;
  10746. var current = 0;
  10747. var length = this.hot.countCols() - 1;
  10748. var timer = null;
  10749. this.inProgress = true;
  10750. var loop = (function() {
  10751. if (!$__10.hot) {
  10752. cancelAnimationFrame(timer);
  10753. $__10.inProgress = false;
  10754. return;
  10755. }
  10756. $__10.calculateColumnsWidth({
  10757. from: current,
  10758. to: Math.min(current + $AutoColumnSize.CALCULATION_STEP, length)
  10759. }, rowRange);
  10760. current = current + $AutoColumnSize.CALCULATION_STEP + 1;
  10761. if (current < length) {
  10762. timer = requestAnimationFrame(loop);
  10763. } else {
  10764. cancelAnimationFrame(timer);
  10765. $__10.inProgress = false;
  10766. $__10.hot.view.wt.wtOverlays.adjustElementsSize(true);
  10767. if ($__10.hot.view.wt.wtOverlays.leftOverlay.needFullRender) {
  10768. $__10.hot.view.wt.wtOverlays.leftOverlay.clone.draw();
  10769. }
  10770. }
  10771. });
  10772. if (this.firstCalculation && this.getSyncCalculationLimit()) {
  10773. this.calculateColumnsWidth({
  10774. from: 0,
  10775. to: this.getSyncCalculationLimit()
  10776. }, rowRange);
  10777. this.firstCalculation = false;
  10778. current = this.getSyncCalculationLimit() + 1;
  10779. }
  10780. if (current < length) {
  10781. loop();
  10782. } else {
  10783. this.inProgress = false;
  10784. }
  10785. },
  10786. recalculateAllColumnsWidth: function() {
  10787. if (this.hot.view && isVisible(this.hot.view.wt.wtTable.TABLE)) {
  10788. this.clearCache();
  10789. this.calculateAllColumnsWidth();
  10790. }
  10791. },
  10792. getSyncCalculationLimit: function() {
  10793. var limit = $AutoColumnSize.SYNC_CALCULATION_LIMIT;
  10794. var colsLimit = this.hot.countCols() - 1;
  10795. if (isObject(this.hot.getSettings().autoColumnSize)) {
  10796. limit = this.hot.getSettings().autoColumnSize.syncLimit;
  10797. if (isPercentValue(limit)) {
  10798. limit = valueAccordingPercent(colsLimit, limit);
  10799. } else {
  10800. limit = limit >> 0;
  10801. }
  10802. }
  10803. return Math.min(limit, colsLimit);
  10804. },
  10805. getColumnWidth: function(col) {
  10806. var defaultWidth = arguments[1];
  10807. var keepMinimum = arguments[2] !== (void 0) ? arguments[2] : true;
  10808. var width = defaultWidth;
  10809. if (width === void 0) {
  10810. width = this.widths[col];
  10811. if (keepMinimum && typeof width === 'number') {
  10812. width = Math.max(width, WalkontableViewportColumnsCalculator.DEFAULT_WIDTH);
  10813. }
  10814. }
  10815. return width;
  10816. },
  10817. getFirstVisibleColumn: function() {
  10818. var wot = this.hot.view.wt;
  10819. if (wot.wtViewport.columnsVisibleCalculator) {
  10820. return wot.wtTable.getFirstVisibleColumn();
  10821. }
  10822. if (wot.wtViewport.columnsRenderCalculator) {
  10823. return wot.wtTable.getFirstRenderedColumn();
  10824. }
  10825. return -1;
  10826. },
  10827. getLastVisibleColumn: function() {
  10828. var wot = this.hot.view.wt;
  10829. if (wot.wtViewport.columnsVisibleCalculator) {
  10830. return wot.wtTable.getLastVisibleColumn();
  10831. }
  10832. if (wot.wtViewport.columnsRenderCalculator) {
  10833. return wot.wtTable.getLastRenderedColumn();
  10834. }
  10835. return -1;
  10836. },
  10837. clearCache: function() {
  10838. this.widths.length = 0;
  10839. },
  10840. isNeedRecalculate: function() {
  10841. return arrayFilter(this.widths, (function(item) {
  10842. return (item === void 0);
  10843. })).length ? true : false;
  10844. },
  10845. onBeforeRender: function() {
  10846. var force = this.hot.renderCall;
  10847. this.calculateColumnsWidth({
  10848. from: this.getFirstVisibleColumn(),
  10849. to: this.getLastVisibleColumn()
  10850. }, void 0, force);
  10851. if (this.isNeedRecalculate() && !this.inProgress) {
  10852. this.calculateAllColumnsWidth();
  10853. }
  10854. },
  10855. onAfterLoadData: function() {
  10856. var $__10 = this;
  10857. if (this.hot.view) {
  10858. this.recalculateAllColumnsWidth();
  10859. } else {
  10860. setTimeout((function() {
  10861. if ($__10.hot) {
  10862. $__10.recalculateAllColumnsWidth();
  10863. }
  10864. }), 0);
  10865. }
  10866. },
  10867. onBeforeChange: function(changes) {
  10868. var $__10 = this;
  10869. arrayEach(changes, (function(data) {
  10870. return $__10.widths[data[1]] = void 0;
  10871. }));
  10872. },
  10873. onBeforeColumnResize: function(col, size, isDblClick) {
  10874. if (isDblClick) {
  10875. this.calculateColumnsWidth(col, void 0, true);
  10876. size = this.getColumnWidth(col, void 0, false);
  10877. }
  10878. return size;
  10879. },
  10880. destroy: function() {
  10881. this.ghostTable.clean();
  10882. $traceurRuntime.superGet(this, $AutoColumnSize.prototype, "destroy").call(this);
  10883. }
  10884. }, {
  10885. get CALCULATION_STEP() {
  10886. return 50;
  10887. },
  10888. get SYNC_CALCULATION_LIMIT() {
  10889. return 50;
  10890. }
  10891. }, BasePlugin);
  10892. ;
  10893. registerPlugin('autoColumnSize', AutoColumnSize);
  10894. //#
  10895. },{"3rdparty/walkontable/src/calculator/viewportColumns":3,"_base":58,"helpers/array":42,"helpers/dom/element":45,"helpers/number":49,"helpers/object":50,"helpers/string":52,"plugins":57,"utils/ghostTable":98,"utils/samplesGenerator":99}],60:[function(require,module,exports){
  10896. "use strict";
  10897. Object.defineProperties(exports, {
  10898. AutoRowSize: {get: function() {
  10899. return AutoRowSize;
  10900. }},
  10901. __esModule: {value: true}
  10902. });
  10903. var $___46__46__47__95_base__,
  10904. $___46__46__47__46__46__47_helpers_47_array__,
  10905. $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  10906. $___46__46__47__46__46__47_utils_47_ghostTable__,
  10907. $___46__46__47__46__46__47_helpers_47_object__,
  10908. $___46__46__47__46__46__47_helpers_47_number__,
  10909. $___46__46__47__46__46__47_plugins__,
  10910. $___46__46__47__46__46__47_utils_47_samplesGenerator__,
  10911. $___46__46__47__46__46__47_helpers_47_string__;
  10912. var BasePlugin = ($___46__46__47__95_base__ = require("_base"), $___46__46__47__95_base__ && $___46__46__47__95_base__.__esModule && $___46__46__47__95_base__ || {default: $___46__46__47__95_base__}).default;
  10913. var $__1 = ($___46__46__47__46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47__46__46__47_helpers_47_array__ && $___46__46__47__46__46__47_helpers_47_array__.__esModule && $___46__46__47__46__46__47_helpers_47_array__ || {default: $___46__46__47__46__46__47_helpers_47_array__}),
  10914. arrayEach = $__1.arrayEach,
  10915. arrayFilter = $__1.arrayFilter;
  10916. var $__2 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  10917. cancelAnimationFrame = $__2.cancelAnimationFrame,
  10918. requestAnimationFrame = $__2.requestAnimationFrame,
  10919. isVisible = $__2.isVisible;
  10920. var GhostTable = ($___46__46__47__46__46__47_utils_47_ghostTable__ = require("utils/ghostTable"), $___46__46__47__46__46__47_utils_47_ghostTable__ && $___46__46__47__46__46__47_utils_47_ghostTable__.__esModule && $___46__46__47__46__46__47_utils_47_ghostTable__ || {default: $___46__46__47__46__46__47_utils_47_ghostTable__}).GhostTable;
  10921. var $__4 = ($___46__46__47__46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47__46__46__47_helpers_47_object__ && $___46__46__47__46__46__47_helpers_47_object__.__esModule && $___46__46__47__46__46__47_helpers_47_object__ || {default: $___46__46__47__46__46__47_helpers_47_object__}),
  10922. isObject = $__4.isObject,
  10923. objectEach = $__4.objectEach;
  10924. var $__5 = ($___46__46__47__46__46__47_helpers_47_number__ = require("helpers/number"), $___46__46__47__46__46__47_helpers_47_number__ && $___46__46__47__46__46__47_helpers_47_number__.__esModule && $___46__46__47__46__46__47_helpers_47_number__ || {default: $___46__46__47__46__46__47_helpers_47_number__}),
  10925. valueAccordingPercent = $__5.valueAccordingPercent,
  10926. rangeEach = $__5.rangeEach;
  10927. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  10928. var SamplesGenerator = ($___46__46__47__46__46__47_utils_47_samplesGenerator__ = require("utils/samplesGenerator"), $___46__46__47__46__46__47_utils_47_samplesGenerator__ && $___46__46__47__46__46__47_utils_47_samplesGenerator__.__esModule && $___46__46__47__46__46__47_utils_47_samplesGenerator__ || {default: $___46__46__47__46__46__47_utils_47_samplesGenerator__}).SamplesGenerator;
  10929. var isPercentValue = ($___46__46__47__46__46__47_helpers_47_string__ = require("helpers/string"), $___46__46__47__46__46__47_helpers_47_string__ && $___46__46__47__46__46__47_helpers_47_string__.__esModule && $___46__46__47__46__46__47_helpers_47_string__ || {default: $___46__46__47__46__46__47_helpers_47_string__}).isPercentValue;
  10930. var AutoRowSize = function AutoRowSize(hotInstance) {
  10931. var $__9 = this;
  10932. $traceurRuntime.superConstructor($AutoRowSize).call(this, hotInstance);
  10933. this.heights = [];
  10934. this.ghostTable = new GhostTable(this.hot);
  10935. this.samplesGenerator = new SamplesGenerator((function(row, col) {
  10936. return $__9.hot.getDataAtCell(row, col);
  10937. }));
  10938. this.firstCalculation = true;
  10939. this.inProgress = false;
  10940. this.addHook('beforeRowResize', (function(row, size, isDblClick) {
  10941. return $__9.onBeforeRowResize(row, size, isDblClick);
  10942. }));
  10943. };
  10944. var $AutoRowSize = AutoRowSize;
  10945. ($traceurRuntime.createClass)(AutoRowSize, {
  10946. isEnabled: function() {
  10947. return this.hot.getSettings().autoRowSize === true || isObject(this.hot.getSettings().autoRowSize);
  10948. },
  10949. enablePlugin: function() {
  10950. var $__9 = this;
  10951. if (this.enabled) {
  10952. return;
  10953. }
  10954. this.addHook('afterLoadData', (function() {
  10955. return $__9.onAfterLoadData();
  10956. }));
  10957. this.addHook('beforeChange', (function(changes) {
  10958. return $__9.onBeforeChange(changes);
  10959. }));
  10960. this.addHook('beforeColumnMove', (function() {
  10961. return $__9.recalculateAllRowsHeight();
  10962. }));
  10963. this.addHook('beforeColumnResize', (function() {
  10964. return $__9.recalculateAllRowsHeight();
  10965. }));
  10966. this.addHook('beforeColumnSort', (function() {
  10967. return $__9.clearCache();
  10968. }));
  10969. this.addHook('beforeRender', (function(force) {
  10970. return $__9.onBeforeRender(force);
  10971. }));
  10972. this.addHook('beforeRowMove', (function(rowStart, rowEnd) {
  10973. return $__9.onBeforeRowMove(rowStart, rowEnd);
  10974. }));
  10975. this.addHook('modifyRowHeight', (function(height, row) {
  10976. return $__9.getRowHeight(row, height);
  10977. }));
  10978. $traceurRuntime.superGet(this, $AutoRowSize.prototype, "enablePlugin").call(this);
  10979. },
  10980. disablePlugin: function() {
  10981. $traceurRuntime.superGet(this, $AutoRowSize.prototype, "disablePlugin").call(this);
  10982. },
  10983. calculateRowsHeight: function() {
  10984. var rowRange = arguments[0] !== (void 0) ? arguments[0] : {
  10985. from: 0,
  10986. to: this.hot.countRows() - 1
  10987. };
  10988. var colRange = arguments[1] !== (void 0) ? arguments[1] : {
  10989. from: 0,
  10990. to: this.hot.countCols() - 1
  10991. };
  10992. var force = arguments[2] !== (void 0) ? arguments[2] : false;
  10993. var $__9 = this;
  10994. if (typeof rowRange === 'number') {
  10995. rowRange = {
  10996. from: rowRange,
  10997. to: rowRange
  10998. };
  10999. }
  11000. if (typeof colRange === 'number') {
  11001. colRange = {
  11002. from: colRange,
  11003. to: colRange
  11004. };
  11005. }
  11006. rangeEach(rowRange.from, rowRange.to, (function(row) {
  11007. if (force || $__9.heights[row] === void 0) {
  11008. var samples = $__9.samplesGenerator.generateRowSamples(row, colRange);
  11009. samples.forEach((function(sample, row) {
  11010. return $__9.ghostTable.addRow(row, sample);
  11011. }));
  11012. }
  11013. }));
  11014. if (this.ghostTable.rows.length) {
  11015. this.ghostTable.getHeights((function(row, height) {
  11016. return $__9.heights[row] = height;
  11017. }));
  11018. this.ghostTable.clean();
  11019. }
  11020. },
  11021. calculateAllRowsHeight: function() {
  11022. var colRange = arguments[0] !== (void 0) ? arguments[0] : {
  11023. from: 0,
  11024. to: this.hot.countCols() - 1
  11025. };
  11026. var $__9 = this;
  11027. var current = 0;
  11028. var length = this.hot.countRows() - 1;
  11029. var timer = null;
  11030. this.inProgress = true;
  11031. var loop = (function() {
  11032. if (!$__9.hot) {
  11033. cancelAnimationFrame(timer);
  11034. $__9.inProgress = false;
  11035. return;
  11036. }
  11037. $__9.calculateRowsHeight({
  11038. from: current,
  11039. to: Math.min(current + $AutoRowSize.CALCULATION_STEP, length)
  11040. }, colRange);
  11041. current = current + $AutoRowSize.CALCULATION_STEP + 1;
  11042. if (current < length) {
  11043. timer = requestAnimationFrame(loop);
  11044. } else {
  11045. cancelAnimationFrame(timer);
  11046. $__9.inProgress = false;
  11047. $__9.hot.view.wt.wtOverlays.adjustElementsSize(true);
  11048. if ($__9.hot.view.wt.wtOverlays.leftOverlay.needFullRender) {
  11049. $__9.hot.view.wt.wtOverlays.leftOverlay.clone.draw();
  11050. }
  11051. }
  11052. });
  11053. if (this.firstCalculation && this.getSyncCalculationLimit()) {
  11054. this.calculateRowsHeight({
  11055. from: 0,
  11056. to: this.getSyncCalculationLimit()
  11057. }, colRange);
  11058. this.firstCalculation = false;
  11059. current = this.getSyncCalculationLimit() + 1;
  11060. }
  11061. if (current < length) {
  11062. loop();
  11063. } else {
  11064. this.inProgress = false;
  11065. }
  11066. },
  11067. recalculateAllRowsHeight: function() {
  11068. if (isVisible(this.hot.view.wt.wtTable.TABLE)) {
  11069. this.clearCache();
  11070. this.calculateAllRowsHeight();
  11071. }
  11072. },
  11073. getSyncCalculationLimit: function() {
  11074. var limit = $AutoRowSize.SYNC_CALCULATION_LIMIT;
  11075. var rowsLimit = this.hot.countRows() - 1;
  11076. if (isObject(this.hot.getSettings().autoRowSize)) {
  11077. limit = this.hot.getSettings().autoRowSize.syncLimit;
  11078. if (isPercentValue(limit)) {
  11079. limit = valueAccordingPercent(rowsLimit, limit);
  11080. } else {
  11081. limit = limit >> 0;
  11082. }
  11083. }
  11084. return Math.min(limit, rowsLimit);
  11085. },
  11086. getRowHeight: function(row) {
  11087. var defaultHeight = arguments[1];
  11088. var height = defaultHeight;
  11089. if (this.heights[row] !== void 0 && this.heights[row] > (defaultHeight || 0)) {
  11090. height = this.heights[row];
  11091. }
  11092. return height;
  11093. },
  11094. getFirstVisibleRow: function() {
  11095. var wot = this.hot.view.wt;
  11096. if (wot.wtViewport.rowsVisibleCalculator) {
  11097. return wot.wtTable.getFirstVisibleRow();
  11098. }
  11099. if (wot.wtViewport.rowsRenderCalculator) {
  11100. return wot.wtTable.getFirstRenderedRow();
  11101. }
  11102. return -1;
  11103. },
  11104. getLastVisibleRow: function() {
  11105. var wot = this.hot.view.wt;
  11106. if (wot.wtViewport.rowsVisibleCalculator) {
  11107. return wot.wtTable.getLastVisibleRow();
  11108. }
  11109. if (wot.wtViewport.rowsRenderCalculator) {
  11110. return wot.wtTable.getLastRenderedRow();
  11111. }
  11112. return -1;
  11113. },
  11114. clearCache: function() {
  11115. this.heights.length = 0;
  11116. },
  11117. clearCacheByRange: function(range) {
  11118. var $__9 = this;
  11119. if (typeof range === 'number') {
  11120. range = {
  11121. from: range,
  11122. to: range
  11123. };
  11124. }
  11125. rangeEach(Math.min(range.from, range.to), Math.max(range.from, range.to), (function(row) {
  11126. return $__9.heights[row] = void 0;
  11127. }));
  11128. },
  11129. isNeedRecalculate: function() {
  11130. return arrayFilter(this.heights, (function(item) {
  11131. return (item === void 0);
  11132. })).length ? true : false;
  11133. },
  11134. onBeforeRender: function() {
  11135. var force = this.hot.renderCall;
  11136. this.calculateRowsHeight({
  11137. from: this.getFirstVisibleRow(),
  11138. to: this.getLastVisibleRow()
  11139. }, void 0, force);
  11140. if (this.isNeedRecalculate() && !this.inProgress) {
  11141. this.calculateAllRowsHeight();
  11142. }
  11143. },
  11144. onBeforeRowMove: function(from, to) {
  11145. this.clearCacheByRange({
  11146. from: from,
  11147. to: to
  11148. });
  11149. this.calculateAllRowsHeight();
  11150. },
  11151. onBeforeRowResize: function(row, size, isDblClick) {
  11152. if (isDblClick) {
  11153. this.calculateRowsHeight(row, void 0, true);
  11154. size = this.getRowHeight(row);
  11155. }
  11156. return size;
  11157. },
  11158. onAfterLoadData: function() {
  11159. var $__9 = this;
  11160. if (this.hot.view) {
  11161. this.recalculateAllRowsHeight();
  11162. } else {
  11163. setTimeout((function() {
  11164. if ($__9.hot) {
  11165. $__9.recalculateAllRowsHeight();
  11166. }
  11167. }), 0);
  11168. }
  11169. },
  11170. onBeforeChange: function(changes) {
  11171. var range = null;
  11172. if (changes.length === 1) {
  11173. range = changes[0][0];
  11174. } else if (changes.length > 1) {
  11175. range = {
  11176. from: changes[0][0],
  11177. to: changes[changes.length - 1][0]
  11178. };
  11179. }
  11180. if (range !== null) {
  11181. this.clearCacheByRange(range);
  11182. }
  11183. },
  11184. destroy: function() {
  11185. this.ghostTable.clean();
  11186. $traceurRuntime.superGet(this, $AutoRowSize.prototype, "destroy").call(this);
  11187. }
  11188. }, {
  11189. get CALCULATION_STEP() {
  11190. return 50;
  11191. },
  11192. get SYNC_CALCULATION_LIMIT() {
  11193. return 500;
  11194. }
  11195. }, BasePlugin);
  11196. ;
  11197. registerPlugin('autoRowSize', AutoRowSize);
  11198. //#
  11199. },{"_base":58,"helpers/array":42,"helpers/dom/element":45,"helpers/number":49,"helpers/object":50,"helpers/string":52,"plugins":57,"utils/ghostTable":98,"utils/samplesGenerator":99}],61:[function(require,module,exports){
  11200. "use strict";
  11201. Object.defineProperties(exports, {
  11202. Autofill: {get: function() {
  11203. return Autofill;
  11204. }},
  11205. __esModule: {value: true}
  11206. });
  11207. var $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  11208. $___46__46__47__46__46__47_eventManager__,
  11209. $___46__46__47__46__46__47_plugins__,
  11210. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__;
  11211. var $__0 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  11212. offset = $__0.offset,
  11213. outerHeight = $__0.outerHeight,
  11214. outerWidth = $__0.outerWidth;
  11215. var eventManagerObject = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).eventManager;
  11216. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  11217. var WalkontableCellCoords = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ = require("3rdparty/walkontable/src/cell/coords"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__}).WalkontableCellCoords;
  11218. ;
  11219. function getDeltas(start, end, data, direction) {
  11220. var rlength = data.length,
  11221. clength = data ? data[0].length : 0,
  11222. deltas = [],
  11223. arr = [],
  11224. diffRow,
  11225. diffCol,
  11226. startValue,
  11227. endValue,
  11228. delta;
  11229. diffRow = end.row - start.row;
  11230. diffCol = end.col - start.col;
  11231. if (['down', 'up'].indexOf(direction) !== -1) {
  11232. for (var col = 0; col <= diffCol; col++) {
  11233. startValue = parseInt(data[0][col], 10);
  11234. endValue = parseInt(data[rlength - 1][col], 10);
  11235. delta = (direction === 'down' ? (endValue - startValue) : (startValue - endValue)) / (rlength - 1) || 0;
  11236. arr.push(delta);
  11237. }
  11238. deltas.push(arr);
  11239. }
  11240. if (['right', 'left'].indexOf(direction) !== -1) {
  11241. for (var row = 0; row <= diffRow; row++) {
  11242. startValue = parseInt(data[row][0], 10);
  11243. endValue = parseInt(data[row][clength - 1], 10);
  11244. delta = (direction === 'right' ? (endValue - startValue) : (startValue - endValue)) / (clength - 1) || 0;
  11245. arr = [];
  11246. arr.push(delta);
  11247. deltas.push(arr);
  11248. }
  11249. }
  11250. return deltas;
  11251. }
  11252. function Autofill(instance) {
  11253. var _this = this,
  11254. mouseDownOnCellCorner = false,
  11255. wtOnCellCornerMouseDown,
  11256. wtOnCellMouseOver,
  11257. eventManager;
  11258. this.instance = instance;
  11259. this.addingStarted = false;
  11260. eventManager = eventManagerObject(instance);
  11261. function mouseUpCallback(event) {
  11262. if (!instance.autofill) {
  11263. return true;
  11264. }
  11265. if (instance.autofill.handle && instance.autofill.handle.isDragged) {
  11266. if (instance.autofill.handle.isDragged > 1) {
  11267. instance.autofill.apply();
  11268. }
  11269. instance.autofill.handle.isDragged = 0;
  11270. mouseDownOnCellCorner = false;
  11271. }
  11272. }
  11273. function mouseMoveCallback(event) {
  11274. var tableBottom,
  11275. tableRight;
  11276. if (!_this.instance.autofill) {
  11277. return false;
  11278. }
  11279. tableBottom = offset(_this.instance.table).top - (window.pageYOffset || document.documentElement.scrollTop) + outerHeight(_this.instance.table);
  11280. tableRight = offset(_this.instance.table).left - (window.pageXOffset || document.documentElement.scrollLeft) + outerWidth(_this.instance.table);
  11281. if (_this.addingStarted === false && _this.instance.autofill.handle.isDragged > 0 && event.clientY > tableBottom && event.clientX <= tableRight) {
  11282. _this.instance.mouseDragOutside = true;
  11283. _this.addingStarted = true;
  11284. } else {
  11285. _this.instance.mouseDragOutside = false;
  11286. }
  11287. if (_this.instance.mouseDragOutside) {
  11288. setTimeout(function() {
  11289. _this.addingStarted = false;
  11290. _this.instance.alter('insert_row');
  11291. }, 200);
  11292. }
  11293. }
  11294. eventManager.addEventListener(document, 'mouseup', mouseUpCallback);
  11295. eventManager.addEventListener(document, 'mousemove', mouseMoveCallback);
  11296. wtOnCellCornerMouseDown = this.instance.view.wt.wtSettings.settings.onCellCornerMouseDown;
  11297. this.instance.view.wt.wtSettings.settings.onCellCornerMouseDown = function(event) {
  11298. instance.autofill.handle.isDragged = 1;
  11299. mouseDownOnCellCorner = true;
  11300. wtOnCellCornerMouseDown(event);
  11301. };
  11302. wtOnCellMouseOver = this.instance.view.wt.wtSettings.settings.onCellMouseOver;
  11303. this.instance.view.wt.wtSettings.settings.onCellMouseOver = function(event, coords, TD, wt) {
  11304. if (instance.autofill && mouseDownOnCellCorner && !instance.view.isMouseDown() && instance.autofill.handle && instance.autofill.handle.isDragged) {
  11305. instance.autofill.handle.isDragged++;
  11306. instance.autofill.showBorder(coords);
  11307. instance.autofill.checkIfNewRowNeeded();
  11308. }
  11309. wtOnCellMouseOver(event, coords, TD, wt);
  11310. };
  11311. this.instance.view.wt.wtSettings.settings.onCellCornerDblClick = function() {
  11312. instance.autofill.selectAdjacent();
  11313. };
  11314. }
  11315. Autofill.prototype.init = function() {
  11316. this.handle = {};
  11317. };
  11318. Autofill.prototype.disable = function() {
  11319. this.handle.disabled = true;
  11320. };
  11321. Autofill.prototype.selectAdjacent = function() {
  11322. var select,
  11323. data,
  11324. r,
  11325. maxR,
  11326. c;
  11327. if (this.instance.selection.isMultiple()) {
  11328. select = this.instance.view.wt.selections.area.getCorners();
  11329. } else {
  11330. select = this.instance.view.wt.selections.current.getCorners();
  11331. }
  11332. data = this.instance.getData();
  11333. rows: for (r = select[2] + 1; r < this.instance.countRows(); r++) {
  11334. for (c = select[1]; c <= select[3]; c++) {
  11335. if (data[r][c]) {
  11336. break rows;
  11337. }
  11338. }
  11339. if (!!data[r][select[1] - 1] || !!data[r][select[3] + 1]) {
  11340. maxR = r;
  11341. }
  11342. }
  11343. if (maxR) {
  11344. this.instance.view.wt.selections.fill.clear();
  11345. this.instance.view.wt.selections.fill.add(new WalkontableCellCoords(select[0], select[1]));
  11346. this.instance.view.wt.selections.fill.add(new WalkontableCellCoords(maxR, select[3]));
  11347. this.apply();
  11348. }
  11349. };
  11350. Autofill.prototype.apply = function() {
  11351. var drag,
  11352. select,
  11353. start,
  11354. end,
  11355. _data,
  11356. direction,
  11357. deltas,
  11358. selRange;
  11359. this.handle.isDragged = 0;
  11360. if (this.instance.view.wt.selections.fill.isEmpty()) {
  11361. return;
  11362. }
  11363. drag = this.instance.view.wt.selections.fill.getCorners();
  11364. this.instance.view.wt.selections.fill.clear();
  11365. if (this.instance.selection.isMultiple()) {
  11366. select = this.instance.view.wt.selections.area.getCorners();
  11367. } else {
  11368. select = this.instance.view.wt.selections.current.getCorners();
  11369. }
  11370. Handsontable.hooks.run(this.instance, 'afterAutofillApplyValues', select, drag);
  11371. if (drag[0] === select[0] && drag[1] < select[1]) {
  11372. direction = 'left';
  11373. start = new WalkontableCellCoords(drag[0], drag[1]);
  11374. end = new WalkontableCellCoords(drag[2], select[1] - 1);
  11375. } else if (drag[0] === select[0] && drag[3] > select[3]) {
  11376. direction = 'right';
  11377. start = new WalkontableCellCoords(drag[0], select[3] + 1);
  11378. end = new WalkontableCellCoords(drag[2], drag[3]);
  11379. } else if (drag[0] < select[0] && drag[1] === select[1]) {
  11380. direction = 'up';
  11381. start = new WalkontableCellCoords(drag[0], drag[1]);
  11382. end = new WalkontableCellCoords(select[0] - 1, drag[3]);
  11383. } else if (drag[2] > select[2] && drag[1] === select[1]) {
  11384. direction = 'down';
  11385. start = new WalkontableCellCoords(select[2] + 1, drag[1]);
  11386. end = new WalkontableCellCoords(drag[2], drag[3]);
  11387. }
  11388. if (start && start.row > -1 && start.col > -1) {
  11389. selRange = {
  11390. from: this.instance.getSelectedRange().from,
  11391. to: this.instance.getSelectedRange().to
  11392. };
  11393. _data = this.instance.getData(selRange.from.row, selRange.from.col, selRange.to.row, selRange.to.col);
  11394. deltas = getDeltas(start, end, _data, direction);
  11395. Handsontable.hooks.run(this.instance, 'beforeAutofill', start, end, _data);
  11396. this.instance.populateFromArray(start.row, start.col, _data, end.row, end.col, 'autofill', null, direction, deltas);
  11397. this.instance.selection.setRangeStart(new WalkontableCellCoords(drag[0], drag[1]));
  11398. this.instance.selection.setRangeEnd(new WalkontableCellCoords(drag[2], drag[3]));
  11399. } else {
  11400. this.instance.selection.refreshBorders();
  11401. }
  11402. };
  11403. Autofill.prototype.showBorder = function(coords) {
  11404. var topLeft = this.instance.getSelectedRange().getTopLeftCorner(),
  11405. bottomRight = this.instance.getSelectedRange().getBottomRightCorner();
  11406. if (this.instance.getSettings().fillHandle !== 'horizontal' && (bottomRight.row < coords.row || topLeft.row > coords.row)) {
  11407. coords = new WalkontableCellCoords(coords.row, bottomRight.col);
  11408. } else if (this.instance.getSettings().fillHandle !== 'vertical') {
  11409. coords = new WalkontableCellCoords(bottomRight.row, coords.col);
  11410. } else {
  11411. return;
  11412. }
  11413. this.instance.view.wt.selections.fill.clear();
  11414. this.instance.view.wt.selections.fill.add(this.instance.getSelectedRange().from);
  11415. this.instance.view.wt.selections.fill.add(this.instance.getSelectedRange().to);
  11416. this.instance.view.wt.selections.fill.add(coords);
  11417. this.instance.view.render();
  11418. };
  11419. Autofill.prototype.checkIfNewRowNeeded = function() {
  11420. var fillCorners,
  11421. selection,
  11422. tableRows = this.instance.countRows(),
  11423. that = this;
  11424. if (this.instance.view.wt.selections.fill.cellRange && this.addingStarted === false) {
  11425. selection = this.instance.getSelected();
  11426. fillCorners = this.instance.view.wt.selections.fill.getCorners();
  11427. if (selection[2] < tableRows - 1 && fillCorners[2] === tableRows - 1) {
  11428. this.addingStarted = true;
  11429. this.instance._registerTimeout(setTimeout(function() {
  11430. that.instance.alter('insert_row');
  11431. that.addingStarted = false;
  11432. }, 200));
  11433. }
  11434. }
  11435. };
  11436. Handsontable.hooks.add('afterInit', function() {
  11437. var autofill = new Autofill(this);
  11438. if (typeof this.getSettings().fillHandle !== 'undefined') {
  11439. if (autofill.handle && this.getSettings().fillHandle === false) {
  11440. autofill.disable();
  11441. } else if (!autofill.handle && this.getSettings().fillHandle !== false) {
  11442. this.autofill = autofill;
  11443. this.autofill.init();
  11444. }
  11445. }
  11446. });
  11447. Handsontable.Autofill = Autofill;
  11448. //#
  11449. },{"3rdparty/walkontable/src/cell/coords":5,"eventManager":41,"helpers/dom/element":45,"plugins":57}],62:[function(require,module,exports){
  11450. "use strict";
  11451. Object.defineProperties(exports, {
  11452. ColumnSorting: {get: function() {
  11453. return ColumnSorting;
  11454. }},
  11455. __esModule: {value: true}
  11456. });
  11457. var $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  11458. $___46__46__47__46__46__47_helpers_47_array__,
  11459. $___46__46__47__46__46__47_eventManager__,
  11460. $___46__46__47__95_base__,
  11461. $___46__46__47__46__46__47_plugins__;
  11462. var $__0 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  11463. addClass = $__0.addClass,
  11464. closest = $__0.closest,
  11465. hasClass = $__0.hasClass,
  11466. index = $__0.index,
  11467. removeClass = $__0.removeClass;
  11468. var $__1 = ($___46__46__47__46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47__46__46__47_helpers_47_array__ && $___46__46__47__46__46__47_helpers_47_array__.__esModule && $___46__46__47__46__46__47_helpers_47_array__ || {default: $___46__46__47__46__46__47_helpers_47_array__}),
  11469. arrayEach = $__1.arrayEach,
  11470. arrayMap = $__1.arrayMap,
  11471. arrayReduce = $__1.arrayReduce;
  11472. var eventManagerObject = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).eventManager;
  11473. var BasePlugin = ($___46__46__47__95_base__ = require("_base"), $___46__46__47__95_base__ && $___46__46__47__95_base__.__esModule && $___46__46__47__95_base__ || {default: $___46__46__47__95_base__}).default;
  11474. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  11475. Handsontable.hooks.register('beforeColumnSort');
  11476. Handsontable.hooks.register('afterColumnSort');
  11477. var ColumnSorting = function ColumnSorting(hotInstance) {
  11478. $traceurRuntime.superConstructor($ColumnSorting).call(this, hotInstance);
  11479. this.sortIndicators = [];
  11480. };
  11481. var $ColumnSorting = ColumnSorting;
  11482. ($traceurRuntime.createClass)(ColumnSorting, {
  11483. isEnabled: function() {
  11484. return !!(this.hot.getSettings().columnSorting);
  11485. },
  11486. enablePlugin: function() {
  11487. var $__5 = this;
  11488. if (this.enabled) {
  11489. return;
  11490. }
  11491. var _this = this;
  11492. this.hot.sortIndex = [];
  11493. this.hot.sort = function() {
  11494. var args = Array.prototype.slice.call(arguments);
  11495. return _this.sortByColumn.apply(_this, args);
  11496. };
  11497. if (typeof this.hot.getSettings().observeChanges === 'undefined') {
  11498. this.enableObserveChangesPlugin();
  11499. }
  11500. this.bindColumnSortingAfterClick();
  11501. this.addHook('afterTrimRow', (function(row) {
  11502. return $__5.sort();
  11503. }));
  11504. this.addHook('afterUntrimRow', (function(row) {
  11505. return $__5.sort();
  11506. }));
  11507. this.addHook('modifyRow', (function(row) {
  11508. return $__5.translateRow(row);
  11509. }));
  11510. this.addHook('afterUpdateSettings', (function() {
  11511. return $__5.onAfterUpdateSettings();
  11512. }));
  11513. this.addHook('afterGetColHeader', (function(col, TH) {
  11514. return $__5.getColHeader(col, TH);
  11515. }));
  11516. this.addHook('afterCreateRow', function() {
  11517. _this.afterCreateRow.apply(_this, arguments);
  11518. });
  11519. this.addHook('afterRemoveRow', function() {
  11520. _this.afterRemoveRow.apply(_this, arguments);
  11521. });
  11522. this.addHook('afterInit', (function() {
  11523. return $__5.sortBySettings();
  11524. }));
  11525. this.addHook('afterLoadData', (function() {
  11526. $__5.hot.sortIndex = [];
  11527. if ($__5.hot.view) {
  11528. $__5.sortBySettings();
  11529. }
  11530. }));
  11531. if (this.hot.view) {
  11532. this.sortBySettings();
  11533. }
  11534. $traceurRuntime.superGet(this, $ColumnSorting.prototype, "enablePlugin").call(this);
  11535. },
  11536. disablePlugin: function() {
  11537. this.hot.sort = void 0;
  11538. $traceurRuntime.superGet(this, $ColumnSorting.prototype, "disablePlugin").call(this);
  11539. },
  11540. onAfterUpdateSettings: function() {
  11541. this.sortBySettings();
  11542. },
  11543. sortBySettings: function() {
  11544. var sortingSettings = this.hot.getSettings().columnSorting;
  11545. var loadedSortingState = this.loadSortingState();
  11546. var sortingColumn;
  11547. var sortingOrder;
  11548. if (typeof loadedSortingState === 'undefined') {
  11549. sortingColumn = sortingSettings.column;
  11550. sortingOrder = sortingSettings.sortOrder;
  11551. } else {
  11552. sortingColumn = loadedSortingState.sortColumn;
  11553. sortingOrder = loadedSortingState.sortOrder;
  11554. }
  11555. this.sortByColumn(sortingColumn, sortingOrder);
  11556. },
  11557. setSortingColumn: function(col, order) {
  11558. if (typeof col == 'undefined') {
  11559. this.hot.sortColumn = void 0;
  11560. this.hot.sortOrder = void 0;
  11561. return;
  11562. } else if (this.hot.sortColumn === col && typeof order == 'undefined') {
  11563. if (this.hot.sortOrder === false) {
  11564. this.hot.sortOrder = void 0;
  11565. } else {
  11566. this.hot.sortOrder = !this.hot.sortOrder;
  11567. }
  11568. } else {
  11569. this.hot.sortOrder = typeof order === 'undefined' ? true : order;
  11570. }
  11571. this.hot.sortColumn = col;
  11572. },
  11573. sortByColumn: function(col, order) {
  11574. this.setSortingColumn(col, order);
  11575. if (typeof this.hot.sortColumn == 'undefined') {
  11576. return;
  11577. }
  11578. Handsontable.hooks.run(this.hot, 'beforeColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  11579. this.sort();
  11580. this.hot.render();
  11581. this.saveSortingState();
  11582. Handsontable.hooks.run(this.hot, 'afterColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  11583. },
  11584. saveSortingState: function() {
  11585. var sortingState = {};
  11586. if (typeof this.hot.sortColumn != 'undefined') {
  11587. sortingState.sortColumn = this.hot.sortColumn;
  11588. }
  11589. if (typeof this.hot.sortOrder != 'undefined') {
  11590. sortingState.sortOrder = this.hot.sortOrder;
  11591. }
  11592. if (sortingState.hasOwnProperty('sortColumn') || sortingState.hasOwnProperty('sortOrder')) {
  11593. Handsontable.hooks.run(this.hot, 'persistentStateSave', 'columnSorting', sortingState);
  11594. }
  11595. },
  11596. loadSortingState: function() {
  11597. var storedState = {};
  11598. Handsontable.hooks.run(this.hot, 'persistentStateLoad', 'columnSorting', storedState);
  11599. return storedState.value;
  11600. },
  11601. bindColumnSortingAfterClick: function() {
  11602. if (this.bindedSortEvent) {
  11603. return;
  11604. }
  11605. var eventManager = eventManagerObject(this.hot),
  11606. _this = this;
  11607. this.bindedSortEvent = true;
  11608. eventManager.addEventListener(this.hot.rootElement, 'click', function(e) {
  11609. if (hasClass(e.target, 'columnSorting')) {
  11610. var col = getColumn(e.target);
  11611. if (col === this.lastSortedColumn) {
  11612. switch (_this.hot.sortOrder) {
  11613. case void 0:
  11614. _this.sortOrderClass = 'ascending';
  11615. break;
  11616. case true:
  11617. _this.sortOrderClass = 'descending';
  11618. break;
  11619. case false:
  11620. _this.sortOrderClass = void 0;
  11621. }
  11622. } else {
  11623. _this.sortOrderClass = 'ascending';
  11624. }
  11625. this.lastSortedColumn = col;
  11626. _this.sortByColumn(col);
  11627. }
  11628. });
  11629. function countRowHeaders() {
  11630. var tr = _this.hot.view.TBODY.querySelector('tr');
  11631. var length = 1;
  11632. if (tr) {
  11633. length = tr.querySelectorAll('th').length;
  11634. }
  11635. return length;
  11636. }
  11637. function getColumn(target) {
  11638. var TH = closest(target, 'TH');
  11639. return _this.hot.view.wt.wtTable.getFirstRenderedColumn() + index(TH) - countRowHeaders();
  11640. }
  11641. },
  11642. enableObserveChangesPlugin: function() {
  11643. var _this = this;
  11644. this.hot._registerTimeout(setTimeout(function() {
  11645. _this.hot.updateSettings({observeChanges: true});
  11646. }, 0));
  11647. },
  11648. defaultSort: function(sortOrder) {
  11649. return function(a, b) {
  11650. if (typeof a[1] == 'string') {
  11651. a[1] = a[1].toLowerCase();
  11652. }
  11653. if (typeof b[1] == 'string') {
  11654. b[1] = b[1].toLowerCase();
  11655. }
  11656. if (a[1] === b[1]) {
  11657. return 0;
  11658. }
  11659. if (a[1] === null || a[1] === '') {
  11660. return 1;
  11661. }
  11662. if (b[1] === null || b[1] === '') {
  11663. return -1;
  11664. }
  11665. if (isNaN(a[1]) && !isNaN(b[1])) {
  11666. return sortOrder ? 1 : -1;
  11667. } else if (!isNaN(a[1]) && isNaN(b[1])) {
  11668. return sortOrder ? -1 : 1;
  11669. }
  11670. if (a[1] < b[1]) {
  11671. return sortOrder ? -1 : 1;
  11672. }
  11673. if (a[1] > b[1]) {
  11674. return sortOrder ? 1 : -1;
  11675. }
  11676. return 0;
  11677. };
  11678. },
  11679. dateSort: function(sortOrder) {
  11680. return function(a, b) {
  11681. if (a[1] === b[1]) {
  11682. return 0;
  11683. }
  11684. if (a[1] === null || a[1] === '') {
  11685. return 1;
  11686. }
  11687. if (b[1] === null || b[1] === '') {
  11688. return -1;
  11689. }
  11690. var aDate = new Date(a[1]);
  11691. var bDate = new Date(b[1]);
  11692. if (aDate < bDate) {
  11693. return sortOrder ? -1 : 1;
  11694. }
  11695. if (aDate > bDate) {
  11696. return sortOrder ? 1 : -1;
  11697. }
  11698. return 0;
  11699. };
  11700. },
  11701. sort: function() {
  11702. if (typeof this.hot.sortOrder == 'undefined') {
  11703. this.hot.sortIndex.length = 0;
  11704. return;
  11705. }
  11706. var colMeta,
  11707. sortFunction;
  11708. this.hot.sortingEnabled = false;
  11709. this.hot.sortIndex.length = 0;
  11710. var colOffset = this.hot.colOffset();
  11711. for (var i = 0,
  11712. ilen = this.hot.countRows() - this.hot.getSettings().minSpareRows; i < ilen; i++) {
  11713. this.hot.sortIndex.push([i, this.hot.getDataAtCell(i, this.hot.sortColumn + colOffset)]);
  11714. }
  11715. colMeta = this.hot.getCellMeta(0, this.hot.sortColumn);
  11716. this.sortIndicators[this.hot.sortColumn] = colMeta.sortIndicator;
  11717. switch (colMeta.type) {
  11718. case 'date':
  11719. sortFunction = this.dateSort;
  11720. break;
  11721. default:
  11722. sortFunction = this.defaultSort;
  11723. }
  11724. this.hot.sortIndex.sort(sortFunction(this.hot.sortOrder));
  11725. for (var i = this.hot.sortIndex.length; i < this.hot.countRows(); i++) {
  11726. this.hot.sortIndex.push([i, this.hot.getDataAtCell(i, this.hot.sortColumn + colOffset)]);
  11727. }
  11728. this.hot.sortingEnabled = true;
  11729. },
  11730. translateRow: function(row) {
  11731. if (this.hot.sortingEnabled && (typeof this.hot.sortOrder !== 'undefined') && this.hot.sortIndex && this.hot.sortIndex.length && this.hot.sortIndex[row]) {
  11732. return this.hot.sortIndex[row][0];
  11733. }
  11734. return row;
  11735. },
  11736. untranslateRow: function(row) {
  11737. if (this.hot.sortingEnabled && this.hot.sortIndex && this.hot.sortIndex.length) {
  11738. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  11739. if (this.hot.sortIndex[i][0] == row) {
  11740. return i;
  11741. }
  11742. }
  11743. }
  11744. },
  11745. getColHeader: function(col, TH) {
  11746. var headerLink = TH.querySelector('.colHeader');
  11747. var colspan = TH.getAttribute('colspan');
  11748. var TRs = TH.parentNode.parentNode.childNodes;
  11749. var headerLevel = Array.prototype.indexOf.call(TRs, TH.parentNode);
  11750. headerLevel = headerLevel - TRs.length;
  11751. if (!headerLink) {
  11752. return;
  11753. }
  11754. if (this.hot.getSettings().columnSorting && col >= 0 && headerLevel === -1) {
  11755. addClass(headerLink, 'columnSorting');
  11756. }
  11757. removeClass(headerLink, 'descending');
  11758. removeClass(headerLink, 'ascending');
  11759. if (this.sortIndicators[col]) {
  11760. if (col === this.hot.sortColumn) {
  11761. if (this.sortOrderClass === 'ascending') {
  11762. addClass(headerLink, 'ascending');
  11763. } else if (this.sortOrderClass === 'descending') {
  11764. addClass(headerLink, 'descending');
  11765. }
  11766. }
  11767. }
  11768. },
  11769. isSorted: function() {
  11770. return typeof this.hot.sortColumn != 'undefined';
  11771. },
  11772. afterCreateRow: function(index, amount) {
  11773. if (!this.isSorted()) {
  11774. return;
  11775. }
  11776. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  11777. if (this.hot.sortIndex[i][0] >= index) {
  11778. this.hot.sortIndex[i][0] += amount;
  11779. }
  11780. }
  11781. for (var i = 0; i < amount; i++) {
  11782. this.hot.sortIndex.splice(index + i, 0, [index + i, this.hot.getSourceData()[index + i][this.hot.sortColumn + this.hot.colOffset()]]);
  11783. }
  11784. this.saveSortingState();
  11785. },
  11786. afterRemoveRow: function(index, amount) {
  11787. if (!this.isSorted()) {
  11788. return;
  11789. }
  11790. var removedRows = this.hot.sortIndex.splice(index, amount);
  11791. removedRows = arrayMap(removedRows, (function(row) {
  11792. return row[0];
  11793. }));
  11794. function countRowShift(logicalRow) {
  11795. return arrayReduce(removedRows, (function(count, removedLogicalRow) {
  11796. if (logicalRow > removedLogicalRow) {
  11797. count++;
  11798. }
  11799. return count;
  11800. }), 0);
  11801. }
  11802. this.hot.sortIndex = arrayMap(this.hot.sortIndex, (function(logicalRow, physicalRow) {
  11803. var rowShift = countRowShift(logicalRow[0]);
  11804. if (rowShift) {
  11805. logicalRow[0] -= rowShift;
  11806. }
  11807. return logicalRow;
  11808. }));
  11809. this.saveSortingState();
  11810. }
  11811. }, {}, BasePlugin);
  11812. ;
  11813. registerPlugin('columnSorting', ColumnSorting);
  11814. //#
  11815. },{"_base":58,"eventManager":41,"helpers/array":42,"helpers/dom/element":45,"plugins":57}],63:[function(require,module,exports){
  11816. "use strict";
  11817. Object.defineProperties(exports, {
  11818. CommentEditor: {get: function() {
  11819. return CommentEditor;
  11820. }},
  11821. __esModule: {value: true}
  11822. });
  11823. var $___46__46__47__46__46__47_helpers_47_dom_47_element__;
  11824. var addClass = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}).addClass;
  11825. var CommentEditor = function CommentEditor() {
  11826. this.editor = this.createEditor();
  11827. this.editorStyle = this.editor.style;
  11828. this.editorStyle.position = 'absolute';
  11829. this.editorStyle.zIndex = 100;
  11830. this.hide();
  11831. };
  11832. var $CommentEditor = CommentEditor;
  11833. ($traceurRuntime.createClass)(CommentEditor, {
  11834. setPosition: function(x, y) {
  11835. this.editorStyle.left = x + 'px';
  11836. this.editorStyle.top = y + 'px';
  11837. },
  11838. show: function() {
  11839. this.editorStyle.display = 'block';
  11840. },
  11841. hide: function() {
  11842. this.editorStyle.display = 'none';
  11843. },
  11844. isVisible: function() {
  11845. return this.editorStyle.display === 'block';
  11846. },
  11847. setValue: function() {
  11848. var value = arguments[0] !== (void 0) ? arguments[0] : '';
  11849. value = value || '';
  11850. this.getInputElement().value = value;
  11851. },
  11852. getValue: function() {
  11853. return this.getInputElement().value;
  11854. },
  11855. isFocused: function() {
  11856. return document.activeElement === this.getInputElement();
  11857. },
  11858. focus: function() {
  11859. this.getInputElement().focus();
  11860. },
  11861. createEditor: function() {
  11862. var container = document.querySelector('.' + $CommentEditor.CLASS_EDITOR_CONTAINER);
  11863. var editor;
  11864. var textArea;
  11865. if (!container) {
  11866. container = document.createElement('div');
  11867. addClass(container, $CommentEditor.CLASS_EDITOR_CONTAINER);
  11868. document.body.appendChild(container);
  11869. }
  11870. editor = document.createElement('div');
  11871. addClass(editor, $CommentEditor.CLASS_EDITOR);
  11872. textArea = document.createElement('textarea');
  11873. addClass(textArea, $CommentEditor.CLASS_INPUT);
  11874. editor.appendChild(textArea);
  11875. container.appendChild(editor);
  11876. return editor;
  11877. },
  11878. getInputElement: function() {
  11879. return this.editor.querySelector('.' + $CommentEditor.CLASS_INPUT);
  11880. },
  11881. destroy: function() {
  11882. this.editor.parentNode.removeChild(this.editor);
  11883. this.editor = null;
  11884. this.editorStyle = null;
  11885. }
  11886. }, {
  11887. get CLASS_EDITOR_CONTAINER() {
  11888. return 'htCommentsContainer';
  11889. },
  11890. get CLASS_EDITOR() {
  11891. return 'htComments';
  11892. },
  11893. get CLASS_INPUT() {
  11894. return 'htCommentTextArea';
  11895. },
  11896. get CLASS_CELL() {
  11897. return 'htCommentCell';
  11898. }
  11899. });
  11900. ;
  11901. //#
  11902. },{"helpers/dom/element":45}],64:[function(require,module,exports){
  11903. "use strict";
  11904. Object.defineProperties(exports, {
  11905. Comments: {get: function() {
  11906. return Comments;
  11907. }},
  11908. __esModule: {value: true}
  11909. });
  11910. var $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  11911. $___46__46__47__46__46__47_eventManager__,
  11912. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__,
  11913. $___46__46__47__46__46__47_plugins__,
  11914. $___46__46__47__95_base__,
  11915. $__commentEditor__;
  11916. var $__0 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  11917. addClass = $__0.addClass,
  11918. closest = $__0.closest,
  11919. getWindowScrollLeft = $__0.getWindowScrollLeft,
  11920. getWindowScrollTop = $__0.getWindowScrollTop,
  11921. hasClass = $__0.hasClass,
  11922. offset = $__0.offset;
  11923. var EventManager = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).EventManager;
  11924. var WalkontableCellCoords = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ = require("3rdparty/walkontable/src/cell/coords"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__}).WalkontableCellCoords;
  11925. var $__3 = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}),
  11926. registerPlugin = $__3.registerPlugin,
  11927. getPlugin = $__3.getPlugin;
  11928. var BasePlugin = ($___46__46__47__95_base__ = require("_base"), $___46__46__47__95_base__ && $___46__46__47__95_base__.__esModule && $___46__46__47__95_base__ || {default: $___46__46__47__95_base__}).default;
  11929. var CommentEditor = ($__commentEditor__ = require("commentEditor"), $__commentEditor__ && $__commentEditor__.__esModule && $__commentEditor__ || {default: $__commentEditor__}).CommentEditor;
  11930. var Comments = function Comments(hotInstance) {
  11931. $traceurRuntime.superConstructor($Comments).call(this, hotInstance);
  11932. this.editor = null;
  11933. this.eventManager = null;
  11934. this.range = {};
  11935. this.mouseDown = false;
  11936. this.contextMenuEvent = false;
  11937. this.timer = null;
  11938. };
  11939. var $Comments = Comments;
  11940. ($traceurRuntime.createClass)(Comments, {
  11941. isEnabled: function() {
  11942. return this.hot.getSettings().comments;
  11943. },
  11944. enablePlugin: function() {
  11945. var $__6 = this;
  11946. if (this.enabled) {
  11947. return;
  11948. }
  11949. if (!this.editor) {
  11950. this.editor = new CommentEditor();
  11951. }
  11952. if (!this.eventManager) {
  11953. this.eventManager = new EventManager(this);
  11954. }
  11955. this.addHook('afterContextMenuDefaultOptions', (function(options) {
  11956. return $__6.addToContextMenu(options);
  11957. }));
  11958. this.addHook('afterRenderer', (function(TD, row, col, prop, value, cellProperties) {
  11959. return $__6.onAfterRenderer(TD, cellProperties);
  11960. }));
  11961. this.addHook('afterScrollHorizontally', (function() {
  11962. return $__6.refreshEditorPosition();
  11963. }));
  11964. this.addHook('afterScrollVertically', (function() {
  11965. return $__6.refreshEditorPosition();
  11966. }));
  11967. this.addHook('afterColumnResize', (function() {
  11968. return $__6.refreshEditorPosition();
  11969. }));
  11970. this.addHook('afterRowResize', (function() {
  11971. return $__6.refreshEditorPosition();
  11972. }));
  11973. this.registerListeners();
  11974. $traceurRuntime.superGet(this, $Comments.prototype, "enablePlugin").call(this);
  11975. },
  11976. disablePlugin: function() {
  11977. $traceurRuntime.superGet(this, $Comments.prototype, "disablePlugin").call(this);
  11978. },
  11979. registerListeners: function() {
  11980. var $__6 = this;
  11981. this.eventManager.addEventListener(document, 'mouseover', (function(event) {
  11982. return $__6.onMouseOver(event);
  11983. }));
  11984. this.eventManager.addEventListener(document, 'mousedown', (function(event) {
  11985. return $__6.onMouseDown(event);
  11986. }));
  11987. this.eventManager.addEventListener(document, 'mousemove', (function(event) {
  11988. return $__6.onMouseMove(event);
  11989. }));
  11990. this.eventManager.addEventListener(document, 'mouseup', (function(event) {
  11991. return $__6.onMouseUp(event);
  11992. }));
  11993. this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', (function(event) {
  11994. return $__6.onEditorBlur(event);
  11995. }));
  11996. },
  11997. setRange: function(range) {
  11998. this.range = range;
  11999. },
  12000. clearRange: function() {
  12001. this.range = {};
  12002. },
  12003. targetIsCellWithComment: function(event) {
  12004. return hasClass(event.target, 'htCommentCell') && closest(event.target, [this.hot.rootElement]) ? true : false;
  12005. },
  12006. targetIsCommentTextArea: function(event) {
  12007. return this.editor.getInputElement() === event.target;
  12008. },
  12009. saveComment: function() {
  12010. if (!this.range.from) {
  12011. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  12012. }
  12013. var comment = this.editor.getValue();
  12014. var row = this.range.from.row;
  12015. var col = this.range.from.col;
  12016. this.hot.setCellMeta(row, col, 'comment', comment);
  12017. this.hot.render();
  12018. },
  12019. saveCommentAtCell: function(row, col) {
  12020. this.setRange({from: new WalkontableCellCoords(row, col)});
  12021. this.saveComment();
  12022. },
  12023. removeComment: function() {
  12024. if (!this.range.from) {
  12025. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  12026. }
  12027. this.hot.removeCellMeta(this.range.from.row, this.range.from.col, 'comment');
  12028. this.hot.render();
  12029. this.hide();
  12030. },
  12031. removeCommentAtCell: function(row, col) {
  12032. this.setRange({from: new WalkontableCellCoords(row, col)});
  12033. this.removeComment();
  12034. },
  12035. show: function() {
  12036. if (!this.range.from) {
  12037. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  12038. }
  12039. var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
  12040. this.refreshEditorPosition(true);
  12041. this.editor.setValue(meta.comment || '');
  12042. this.editor.show();
  12043. return true;
  12044. },
  12045. showAtCell: function(row, col) {
  12046. this.setRange({from: new WalkontableCellCoords(row, col)});
  12047. return this.show();
  12048. },
  12049. hide: function() {
  12050. this.editor.hide();
  12051. },
  12052. refreshEditorPosition: function() {
  12053. var force = arguments[0] !== (void 0) ? arguments[0] : false;
  12054. if (!force && (!this.range.from || !this.editor.isVisible())) {
  12055. return;
  12056. }
  12057. var TD = this.hot.view.wt.wtTable.getCell(this.range.from);
  12058. var cellOffset = offset(TD);
  12059. var lastColWidth = this.hot.getColWidth(this.range.from.col);
  12060. var cellTopOffset = cellOffset.top;
  12061. var cellLeftOffset = cellOffset.left;
  12062. var verticalCompensation = 0;
  12063. var horizontalCompensation = 0;
  12064. if (this.hot.view.wt.wtViewport.hasVerticalScroll()) {
  12065. cellTopOffset = cellTopOffset - this.hot.view.wt.wtOverlays.topOverlay.getScrollPosition();
  12066. verticalCompensation = 20;
  12067. }
  12068. if (this.hot.view.wt.wtViewport.hasHorizontalScroll()) {
  12069. cellLeftOffset = cellLeftOffset - this.hot.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  12070. horizontalCompensation = 20;
  12071. }
  12072. var x = cellLeftOffset + lastColWidth;
  12073. var y = cellTopOffset;
  12074. var rect = this.hot.view.wt.wtTable.holder.getBoundingClientRect();
  12075. var holderPos = {
  12076. left: rect.left + getWindowScrollLeft() + horizontalCompensation,
  12077. right: rect.right + getWindowScrollLeft() - 15,
  12078. top: rect.top + getWindowScrollTop() + verticalCompensation,
  12079. bottom: rect.bottom + getWindowScrollTop()
  12080. };
  12081. if (x <= holderPos.left || x > holderPos.right || y <= holderPos.top || y > holderPos.bottom) {
  12082. this.hide();
  12083. } else {
  12084. this.editor.setPosition(x, y);
  12085. }
  12086. },
  12087. onMouseDown: function(event) {
  12088. this.mouseDown = true;
  12089. if (!this.hot.view || !this.hot.view.wt) {
  12090. return;
  12091. }
  12092. if (!this.contextMenuEvent && !this.targetIsCommentTextArea(event) && !this.targetIsCellWithComment(event)) {
  12093. this.hide();
  12094. }
  12095. this.contextMenuEvent = false;
  12096. },
  12097. onMouseOver: function(event) {
  12098. if (this.mouseDown || this.editor.isFocused()) {
  12099. return;
  12100. }
  12101. if (this.targetIsCellWithComment(event)) {
  12102. var coordinates = this.hot.view.wt.wtTable.getCoords(event.target);
  12103. var range = {from: new WalkontableCellCoords(coordinates.row, coordinates.col)};
  12104. this.setRange(range);
  12105. this.show();
  12106. } else if (!this.targetIsCommentTextArea(event) && !this.editor.isFocused()) {
  12107. this.hide();
  12108. }
  12109. },
  12110. onMouseMove: function(event) {
  12111. var $__6 = this;
  12112. if (this.targetIsCommentTextArea(event)) {
  12113. this.mouseDown = true;
  12114. clearTimeout(this.timer);
  12115. this.timer = setTimeout((function() {
  12116. $__6.mouseDown = false;
  12117. }), 200);
  12118. }
  12119. },
  12120. onMouseUp: function(event) {
  12121. this.mouseDown = false;
  12122. },
  12123. onAfterRenderer: function(TD, cellProperties) {
  12124. if (cellProperties.comment) {
  12125. addClass(TD, cellProperties.commentedCellClassName);
  12126. }
  12127. },
  12128. onEditorBlur: function(event) {
  12129. this.saveComment();
  12130. },
  12131. checkSelectionCommentsConsistency: function() {
  12132. var selected = this.hot.getSelectedRange();
  12133. if (!selected) {
  12134. return false;
  12135. }
  12136. var hasComment = false;
  12137. var cell = selected.from;
  12138. if (this.hot.getCellMeta(cell.row, cell.col).comment) {
  12139. hasComment = true;
  12140. }
  12141. return hasComment;
  12142. },
  12143. onContextMenuAddComment: function() {
  12144. var $__6 = this;
  12145. var coords = this.hot.getSelectedRange();
  12146. this.contextMenuEvent = true;
  12147. this.setRange({from: coords.from});
  12148. this.show();
  12149. setTimeout((function() {
  12150. if ($__6.hot) {
  12151. $__6.hot.deselectCell();
  12152. $__6.editor.focus();
  12153. }
  12154. }), 10);
  12155. },
  12156. onContextMenuRemoveComment: function(key, selection) {
  12157. this.contextMenuEvent = true;
  12158. this.removeCommentAtCell(selection.start.row, selection.start.col);
  12159. },
  12160. addToContextMenu: function(defaultOptions) {
  12161. var $__6 = this;
  12162. defaultOptions.items.push(Handsontable.plugins.ContextMenu.SEPARATOR, {
  12163. key: 'commentsAddEdit',
  12164. name: (function() {
  12165. return $__6.checkSelectionCommentsConsistency() ? 'Edit Comment' : 'Add Comment';
  12166. }),
  12167. callback: (function() {
  12168. return $__6.onContextMenuAddComment();
  12169. }),
  12170. disabled: function() {
  12171. return this.getSelected() ? false : true;
  12172. }
  12173. }, {
  12174. key: 'commentsRemove',
  12175. name: function() {
  12176. return 'Delete Comment';
  12177. },
  12178. callback: (function(key, selection) {
  12179. return $__6.onContextMenuRemoveComment(key, selection);
  12180. }),
  12181. disabled: (function() {
  12182. return !$__6.checkSelectionCommentsConsistency();
  12183. })
  12184. });
  12185. },
  12186. destroy: function() {
  12187. if (this.editor) {
  12188. this.editor.destroy();
  12189. }
  12190. $traceurRuntime.superGet(this, $Comments.prototype, "destroy").call(this);
  12191. }
  12192. }, {}, BasePlugin);
  12193. ;
  12194. registerPlugin('comments', Comments);
  12195. //#
  12196. },{"3rdparty/walkontable/src/cell/coords":5,"_base":58,"commentEditor":63,"eventManager":41,"helpers/dom/element":45,"plugins":57}],65:[function(require,module,exports){
  12197. "use strict";
  12198. Object.defineProperties(exports, {
  12199. CommandExecutor: {get: function() {
  12200. return CommandExecutor;
  12201. }},
  12202. __esModule: {value: true}
  12203. });
  12204. var $___46__46__47__46__46__47_helpers_47_array__;
  12205. var arrayEach = ($___46__46__47__46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47__46__46__47_helpers_47_array__ && $___46__46__47__46__46__47_helpers_47_array__.__esModule && $___46__46__47__46__46__47_helpers_47_array__ || {default: $___46__46__47__46__46__47_helpers_47_array__}).arrayEach;
  12206. var CommandExecutor = function CommandExecutor(hotInstance) {
  12207. this.hot = hotInstance;
  12208. this.commands = {};
  12209. this.commonCallback = null;
  12210. };
  12211. ($traceurRuntime.createClass)(CommandExecutor, {
  12212. registerCommand: function(name, commandDescriptor) {
  12213. this.commands[name] = commandDescriptor;
  12214. },
  12215. setCommonCallback: function(callback) {
  12216. this.commonCallback = callback;
  12217. },
  12218. execute: function(commandName) {
  12219. for (var params = [],
  12220. $__3 = 1; $__3 < arguments.length; $__3++)
  12221. params[$__3 - 1] = arguments[$__3];
  12222. var $__1 = this;
  12223. var commandSplit = commandName.split(':');
  12224. commandName = commandSplit[0];
  12225. var subCommandName = commandSplit.length === 2 ? commandSplit[1] : null;
  12226. var command = this.commands[commandName];
  12227. if (!command) {
  12228. throw new Error(("Menu command '" + commandName + "' not exists."));
  12229. }
  12230. if (subCommandName && command.submenu) {
  12231. command = findSubCommand(subCommandName, command.submenu.items);
  12232. }
  12233. if (command.disabled === true) {
  12234. return;
  12235. }
  12236. if (typeof command.disabled == 'function' && command.disabled.call(this.hot) === true) {
  12237. return;
  12238. }
  12239. if (command.hasOwnProperty('submenu')) {
  12240. return;
  12241. }
  12242. var callbacks = [];
  12243. if (typeof command.callback === 'function') {
  12244. callbacks.push(command.callback);
  12245. }
  12246. if (typeof this.commonCallback === 'function') {
  12247. callbacks.push(this.commonCallback);
  12248. }
  12249. params.unshift(commandSplit.join(':'));
  12250. arrayEach(callbacks, (function(callback) {
  12251. return callback.apply($__1.hot, params);
  12252. }));
  12253. }
  12254. }, {});
  12255. function findSubCommand(subCommandName, subCommands) {
  12256. var command;
  12257. arrayEach(subCommands, (function(cmd) {
  12258. var cmds = cmd.key ? cmd.key.split(':') : null;
  12259. if (Array.isArray(cmds) && cmds[1] === subCommandName) {
  12260. command = cmd;
  12261. return false;
  12262. }
  12263. }));
  12264. return command;
  12265. }
  12266. ;
  12267. //#
  12268. },{"helpers/array":42}],66:[function(require,module,exports){
  12269. "use strict";
  12270. Object.defineProperties(exports, {
  12271. ContextMenu: {get: function() {
  12272. return ContextMenu;
  12273. }},
  12274. __esModule: {value: true}
  12275. });
  12276. var $___46__46__47__95_base__,
  12277. $___46__46__47__46__46__47_helpers_47_array__,
  12278. $__commandExecutor__,
  12279. $___46__46__47__46__46__47_eventManager__,
  12280. $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  12281. $__itemsFactory__,
  12282. $__menu__,
  12283. $___46__46__47__46__46__47_helpers_47_object__,
  12284. $___46__46__47__46__46__47_plugins__,
  12285. $___46__46__47__46__46__47_helpers_47_dom_47_event__,
  12286. $__predefinedItems__;
  12287. var BasePlugin = ($___46__46__47__95_base__ = require("_base"), $___46__46__47__95_base__ && $___46__46__47__95_base__.__esModule && $___46__46__47__95_base__ || {default: $___46__46__47__95_base__}).default;
  12288. var arrayEach = ($___46__46__47__46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47__46__46__47_helpers_47_array__ && $___46__46__47__46__46__47_helpers_47_array__.__esModule && $___46__46__47__46__46__47_helpers_47_array__ || {default: $___46__46__47__46__46__47_helpers_47_array__}).arrayEach;
  12289. var CommandExecutor = ($__commandExecutor__ = require("commandExecutor"), $__commandExecutor__ && $__commandExecutor__.__esModule && $__commandExecutor__ || {default: $__commandExecutor__}).CommandExecutor;
  12290. var EventManager = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).EventManager;
  12291. var hasClass = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}).hasClass;
  12292. var ItemsFactory = ($__itemsFactory__ = require("itemsFactory"), $__itemsFactory__ && $__itemsFactory__.__esModule && $__itemsFactory__ || {default: $__itemsFactory__}).ItemsFactory;
  12293. var Menu = ($__menu__ = require("menu"), $__menu__ && $__menu__.__esModule && $__menu__ || {default: $__menu__}).Menu;
  12294. var $__7 = ($___46__46__47__46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47__46__46__47_helpers_47_object__ && $___46__46__47__46__46__47_helpers_47_object__.__esModule && $___46__46__47__46__46__47_helpers_47_object__ || {default: $___46__46__47__46__46__47_helpers_47_object__}),
  12295. objectEach = $__7.objectEach,
  12296. mixin = $__7.mixin;
  12297. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  12298. var stopPropagation = ($___46__46__47__46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47__46__46__47_helpers_47_dom_47_event__ && $___46__46__47__46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_event__}).stopPropagation;
  12299. var $__10 = ($__predefinedItems__ = require("predefinedItems"), $__predefinedItems__ && $__predefinedItems__.__esModule && $__predefinedItems__ || {default: $__predefinedItems__}),
  12300. ROW_ABOVE = $__10.ROW_ABOVE,
  12301. ROW_BELOW = $__10.ROW_BELOW,
  12302. COLUMN_LEFT = $__10.COLUMN_LEFT,
  12303. COLUMN_RIGHT = $__10.COLUMN_RIGHT,
  12304. REMOVE_ROW = $__10.REMOVE_ROW,
  12305. REMOVE_COLUMN = $__10.REMOVE_COLUMN,
  12306. UNDO = $__10.UNDO,
  12307. REDO = $__10.REDO,
  12308. READ_ONLY = $__10.READ_ONLY,
  12309. ALIGNMENT = $__10.ALIGNMENT,
  12310. SEPARATOR = $__10.SEPARATOR,
  12311. predefinedItems = $__10.predefinedItems;
  12312. var ContextMenu = function ContextMenu(hotInstance) {
  12313. $traceurRuntime.superConstructor($ContextMenu).call(this, hotInstance);
  12314. this.eventManager = new EventManager(this);
  12315. this.commandExecutor = new CommandExecutor(this.hot);
  12316. this.itemsFactory = null;
  12317. this.menu = null;
  12318. };
  12319. var $ContextMenu = ContextMenu;
  12320. ($traceurRuntime.createClass)(ContextMenu, {
  12321. isEnabled: function() {
  12322. return this.hot.getSettings().contextMenu;
  12323. },
  12324. enablePlugin: function() {
  12325. var $__11 = this;
  12326. if (this.enabled) {
  12327. return;
  12328. }
  12329. this.itemsFactory = new ItemsFactory(this.hot, $ContextMenu.DEFAULT_ITEMS);
  12330. var settings = this.hot.getSettings().contextMenu;
  12331. var predefinedItems = {items: this.itemsFactory.getVisibleItems(settings)};
  12332. this.registerEvents();
  12333. if (typeof settings.callback === 'function') {
  12334. this.commandExecutor.setCommonCallback(settings.callback);
  12335. }
  12336. $traceurRuntime.superGet(this, $ContextMenu.prototype, "enablePlugin").call(this);
  12337. this.callOnPluginsReady((function() {
  12338. $__11.hot.runHooks('afterContextMenuDefaultOptions', predefinedItems);
  12339. $__11.itemsFactory.setPredefinedItems(predefinedItems.items);
  12340. var menuItems = $__11.itemsFactory.getVisibleItems(settings);
  12341. $__11.menu = new Menu($__11.hot, {
  12342. className: 'htContextMenu',
  12343. keepInViewport: true
  12344. });
  12345. $__11.menu.setMenuItems(menuItems);
  12346. $__11.menu.addLocalHook('afterOpen', (function() {
  12347. return $__11.onMenuAfterOpen();
  12348. }));
  12349. $__11.menu.addLocalHook('afterClose', (function() {
  12350. return $__11.onMenuAfterClose();
  12351. }));
  12352. $__11.menu.addLocalHook('executeCommand', (function() {
  12353. for (var params = [],
  12354. $__13 = 0; $__13 < arguments.length; $__13++)
  12355. params[$__13] = arguments[$__13];
  12356. return $__11.executeCommand.apply($__11, params);
  12357. }));
  12358. arrayEach(menuItems, (function(command) {
  12359. return $__11.commandExecutor.registerCommand(command.key, command);
  12360. }));
  12361. }));
  12362. },
  12363. disablePlugin: function() {
  12364. this.close();
  12365. if (this.menu) {
  12366. this.menu.destroy();
  12367. this.menu = null;
  12368. }
  12369. $traceurRuntime.superGet(this, $ContextMenu.prototype, "disablePlugin").call(this);
  12370. },
  12371. registerEvents: function() {
  12372. var $__11 = this;
  12373. this.eventManager.addEventListener(this.hot.rootElement, 'contextmenu', (function(event) {
  12374. return $__11.onContextMenu(event);
  12375. }));
  12376. },
  12377. open: function(event) {
  12378. if (!this.menu) {
  12379. return;
  12380. }
  12381. this.menu.open();
  12382. this.menu.setPosition(event);
  12383. this.menu.hotMenu.isHotTableEnv = this.hot.isHotTableEnv;
  12384. Handsontable.eventManager.isHotTableEnv = this.hot.isHotTableEnv;
  12385. },
  12386. close: function() {
  12387. if (!this.menu) {
  12388. return;
  12389. }
  12390. this.menu.close();
  12391. },
  12392. executeCommand: function() {
  12393. for (var params = [],
  12394. $__13 = 0; $__13 < arguments.length; $__13++)
  12395. params[$__13] = arguments[$__13];
  12396. this.commandExecutor.execute.apply(this.commandExecutor, params);
  12397. },
  12398. onContextMenu: function(event) {
  12399. var settings = this.hot.getSettings();
  12400. var showRowHeaders = settings.rowHeaders;
  12401. var showColHeaders = settings.colHeaders;
  12402. function isValidElement(element) {
  12403. return element.nodeName === 'TD' || element.parentNode.nodeName === 'TD';
  12404. }
  12405. var element = event.realTarget;
  12406. this.close();
  12407. event.preventDefault();
  12408. stopPropagation(event);
  12409. if (!(showRowHeaders || showColHeaders)) {
  12410. if (!isValidElement(element) && !(hasClass(element, 'current') && hasClass(element, 'wtBorder'))) {
  12411. return;
  12412. }
  12413. } else if (showRowHeaders && showColHeaders) {
  12414. var containsCornerHeader = element.parentNode.querySelectorAll('.cornerHeader').length > 0;
  12415. if (containsCornerHeader) {
  12416. return;
  12417. }
  12418. }
  12419. this.open(event);
  12420. },
  12421. onMenuAfterOpen: function() {
  12422. this.hot.runHooks('afterContextMenuShow', this);
  12423. },
  12424. onMenuAfterClose: function() {
  12425. this.hot.listen();
  12426. this.hot.runHooks('afterContextMenuHide', this);
  12427. },
  12428. destroy: function() {
  12429. this.close();
  12430. if (this.menu) {
  12431. this.menu.destroy();
  12432. }
  12433. $traceurRuntime.superGet(this, $ContextMenu.prototype, "destroy").call(this);
  12434. }
  12435. }, {get DEFAULT_ITEMS() {
  12436. return [ROW_ABOVE, ROW_BELOW, SEPARATOR, COLUMN_LEFT, COLUMN_RIGHT, SEPARATOR, REMOVE_ROW, REMOVE_COLUMN, SEPARATOR, UNDO, REDO, SEPARATOR, READ_ONLY, SEPARATOR, ALIGNMENT];
  12437. }}, BasePlugin);
  12438. ContextMenu.SEPARATOR = {name: SEPARATOR};
  12439. Handsontable.hooks.register('afterContextMenuDefaultOptions');
  12440. Handsontable.hooks.register('afterContextMenuShow');
  12441. Handsontable.hooks.register('afterContextMenuHide');
  12442. Handsontable.hooks.register('afterContextMenuExecute');
  12443. ;
  12444. registerPlugin('contextMenu', ContextMenu);
  12445. //#
  12446. },{"_base":58,"commandExecutor":65,"eventManager":41,"helpers/array":42,"helpers/dom/element":45,"helpers/dom/event":46,"helpers/object":50,"itemsFactory":68,"menu":69,"plugins":57,"predefinedItems":70}],67:[function(require,module,exports){
  12447. "use strict";
  12448. Object.defineProperties(exports, {
  12449. Cursor: {get: function() {
  12450. return Cursor;
  12451. }},
  12452. __esModule: {value: true}
  12453. });
  12454. var $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  12455. $___46__46__47__46__46__47_helpers_47_dom_47_event__;
  12456. var $__0 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  12457. getWindowScrollLeft = $__0.getWindowScrollLeft,
  12458. getWindowScrollTop = $__0.getWindowScrollTop;
  12459. var $__1 = ($___46__46__47__46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47__46__46__47_helpers_47_dom_47_event__ && $___46__46__47__46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_event__}),
  12460. pageX = $__1.pageX,
  12461. pageY = $__1.pageY;
  12462. var Cursor = function Cursor(object) {
  12463. var windowScrollTop = getWindowScrollTop();
  12464. var windowScrollLeft = getWindowScrollLeft();
  12465. var top,
  12466. topRelative;
  12467. var left,
  12468. leftRelative;
  12469. var scrollTop,
  12470. scrollLeft;
  12471. var cellHeight,
  12472. cellWidth;
  12473. this.type = this.getSourceType(object);
  12474. if (this.type === 'literal') {
  12475. top = parseInt(object.top, 10);
  12476. left = parseInt(object.left, 10);
  12477. cellHeight = object.height;
  12478. cellWidth = object.width;
  12479. } else if (this.type === 'event') {
  12480. top = parseInt(pageY(object), 10);
  12481. left = parseInt(pageX(object), 10);
  12482. cellHeight = object.target.clientHeight;
  12483. cellWidth = object.target.clientWidth;
  12484. }
  12485. topRelative = top - windowScrollTop;
  12486. leftRelative = left - windowScrollLeft;
  12487. scrollTop = windowScrollTop;
  12488. scrollLeft = windowScrollLeft;
  12489. this.top = top;
  12490. this.topRelative = topRelative;
  12491. this.left = left;
  12492. this.leftRelative = leftRelative;
  12493. this.scrollTop = scrollTop;
  12494. this.scrollLeft = scrollLeft;
  12495. this.cellHeight = cellHeight;
  12496. this.cellWidth = cellWidth;
  12497. };
  12498. ($traceurRuntime.createClass)(Cursor, {
  12499. getSourceType: function(object) {
  12500. var type = 'literal';
  12501. if (object instanceof Event) {
  12502. type = 'event';
  12503. }
  12504. return type;
  12505. },
  12506. fitsAbove: function(element) {
  12507. return this.topRelative >= element.offsetHeight;
  12508. },
  12509. fitsBelow: function(element) {
  12510. var viewportHeight = arguments[1] !== (void 0) ? arguments[1] : window.innerHeight;
  12511. return this.topRelative + element.offsetHeight <= viewportHeight;
  12512. },
  12513. fitsOnRight: function(element) {
  12514. var viewportWidth = arguments[1] !== (void 0) ? arguments[1] : window.innerWidth;
  12515. return this.leftRelative + this.cellWidth + element.offsetWidth <= viewportWidth;
  12516. },
  12517. fitsOnLeft: function(element) {
  12518. return this.leftRelative >= element.offsetWidth;
  12519. }
  12520. }, {});
  12521. ;
  12522. Handsontable.plugins.utils = Handsontable.plugins.utils || {};
  12523. Handsontable.plugins.utils.Cursor = Cursor;
  12524. //#
  12525. },{"helpers/dom/element":45,"helpers/dom/event":46}],68:[function(require,module,exports){
  12526. "use strict";
  12527. Object.defineProperties(exports, {
  12528. ItemsFactory: {get: function() {
  12529. return ItemsFactory;
  12530. }},
  12531. __esModule: {value: true}
  12532. });
  12533. var $___46__46__47__46__46__47_helpers_47_object__,
  12534. $___46__46__47__46__46__47_helpers_47_array__,
  12535. $__predefinedItems__;
  12536. var $__0 = ($___46__46__47__46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47__46__46__47_helpers_47_object__ && $___46__46__47__46__46__47_helpers_47_object__.__esModule && $___46__46__47__46__46__47_helpers_47_object__ || {default: $___46__46__47__46__46__47_helpers_47_object__}),
  12537. objectEach = $__0.objectEach,
  12538. isObject = $__0.isObject,
  12539. extend = $__0.extend;
  12540. var arrayEach = ($___46__46__47__46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47__46__46__47_helpers_47_array__ && $___46__46__47__46__46__47_helpers_47_array__.__esModule && $___46__46__47__46__46__47_helpers_47_array__ || {default: $___46__46__47__46__46__47_helpers_47_array__}).arrayEach;
  12541. var $__2 = ($__predefinedItems__ = require("predefinedItems"), $__predefinedItems__ && $__predefinedItems__.__esModule && $__predefinedItems__ || {default: $__predefinedItems__}),
  12542. SEPARATOR = $__2.SEPARATOR,
  12543. ITEMS = $__2.ITEMS,
  12544. predefinedItems = $__2.predefinedItems;
  12545. var ItemsFactory = function ItemsFactory(hotInstance) {
  12546. var orderPattern = arguments[1] !== (void 0) ? arguments[1] : null;
  12547. this.hot = hotInstance;
  12548. this.predefinedItems = predefinedItems();
  12549. this.defaultOrderPattern = orderPattern;
  12550. };
  12551. ($traceurRuntime.createClass)(ItemsFactory, {
  12552. setPredefinedItems: function(predefinedItems) {
  12553. var $__3 = this;
  12554. var items = {};
  12555. this.defaultOrderPattern.length = 0;
  12556. objectEach(predefinedItems, (function(value, key) {
  12557. var menuItemKey = '';
  12558. if (value.name === SEPARATOR) {
  12559. items[SEPARATOR] = value;
  12560. menuItemKey = SEPARATOR;
  12561. } else if (isNaN(parseInt(key, 10))) {
  12562. value.key = value.key === void 0 ? key : value.key;
  12563. items[key] = value;
  12564. menuItemKey = value.key;
  12565. } else {
  12566. items[value.key] = value;
  12567. menuItemKey = value.key;
  12568. }
  12569. $__3.defaultOrderPattern.push(menuItemKey);
  12570. }));
  12571. this.predefinedItems = items;
  12572. },
  12573. getVisibleItems: function() {
  12574. var pattern = arguments[0] !== (void 0) ? arguments[0] : null;
  12575. var $__3 = this;
  12576. var visibleItems = {};
  12577. objectEach(this.predefinedItems, (function(value, key) {
  12578. if (!value.hidden || value.hidden && !value.hidden.apply($__3.hot)) {
  12579. visibleItems[key] = value;
  12580. }
  12581. }));
  12582. return getItems(pattern, this.defaultOrderPattern, visibleItems);
  12583. },
  12584. getItems: function() {
  12585. var pattern = arguments[0] !== (void 0) ? arguments[0] : null;
  12586. return getItems(pattern, this.defaultOrderPattern, this.predefinedItems);
  12587. }
  12588. }, {});
  12589. function getItems() {
  12590. var pattern = arguments[0] !== (void 0) ? arguments[0] : null;
  12591. var defaultPattern = arguments[1] !== (void 0) ? arguments[1] : [];
  12592. var items = arguments[2] !== (void 0) ? arguments[2] : {};
  12593. var result = [];
  12594. if (pattern && pattern.items) {
  12595. pattern = pattern.items;
  12596. } else if (!Array.isArray(pattern)) {
  12597. pattern = defaultPattern;
  12598. }
  12599. if (isObject(pattern)) {
  12600. objectEach(pattern, (function(value, key) {
  12601. var item = items[typeof value === 'string' ? value : key];
  12602. if (!item) {
  12603. item = value;
  12604. }
  12605. if (isObject(value)) {
  12606. extend(item, value);
  12607. } else if (typeof item === 'string') {
  12608. item = {name: item};
  12609. }
  12610. if (item.key === void 0) {
  12611. item.key = key;
  12612. }
  12613. result.push(item);
  12614. }));
  12615. } else {
  12616. arrayEach(pattern, (function(name, key) {
  12617. var item = items[name];
  12618. if (!item && ITEMS.indexOf(name) >= 0) {
  12619. return;
  12620. }
  12621. if (!item) {
  12622. item = {
  12623. name: name,
  12624. key: key + ''
  12625. };
  12626. }
  12627. if (isObject(name)) {
  12628. extend(item, name);
  12629. }
  12630. if (item.key === void 0) {
  12631. item.key = key;
  12632. }
  12633. result.push(item);
  12634. }));
  12635. }
  12636. if (result[0].name === SEPARATOR) {
  12637. result.shift();
  12638. }
  12639. return result;
  12640. }
  12641. ;
  12642. //#
  12643. },{"helpers/array":42,"helpers/object":50,"predefinedItems":70}],69:[function(require,module,exports){
  12644. "use strict";
  12645. Object.defineProperties(exports, {
  12646. Menu: {get: function() {
  12647. return Menu;
  12648. }},
  12649. __esModule: {value: true}
  12650. });
  12651. var $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  12652. $___46__46__47__46__46__47_helpers_47_array__,
  12653. $__cursor__,
  12654. $___46__46__47__46__46__47_eventManager__,
  12655. $___46__46__47__46__46__47_helpers_47_object__,
  12656. $__utils__,
  12657. $___46__46__47__46__46__47_helpers_47_unicode__,
  12658. $___46__46__47__46__46__47_mixins_47_localHooks__,
  12659. $__predefinedItems__,
  12660. $___46__46__47__46__46__47_helpers_47_dom_47_event__;
  12661. var $__0 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  12662. addClass = $__0.addClass,
  12663. empty = $__0.empty,
  12664. fastInnerHTML = $__0.fastInnerHTML,
  12665. getComputedStyle = $__0.getComputedStyle,
  12666. getScrollbarWidth = $__0.getScrollbarWidth,
  12667. getWindowScrollLeft = $__0.getWindowScrollLeft,
  12668. getWindowScrollTop = $__0.getWindowScrollTop,
  12669. hasClass = $__0.hasClass,
  12670. isChildOf = $__0.isChildOf,
  12671. removeClass = $__0.removeClass;
  12672. var arrayEach = ($___46__46__47__46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47__46__46__47_helpers_47_array__ && $___46__46__47__46__46__47_helpers_47_array__.__esModule && $___46__46__47__46__46__47_helpers_47_array__ || {default: $___46__46__47__46__46__47_helpers_47_array__}).arrayEach;
  12673. var Cursor = ($__cursor__ = require("cursor"), $__cursor__ && $__cursor__.__esModule && $__cursor__ || {default: $__cursor__}).Cursor;
  12674. var EventManager = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).EventManager;
  12675. var $__4 = ($___46__46__47__46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47__46__46__47_helpers_47_object__ && $___46__46__47__46__46__47_helpers_47_object__.__esModule && $___46__46__47__46__46__47_helpers_47_object__ || {default: $___46__46__47__46__46__47_helpers_47_object__}),
  12676. extend = $__4.extend,
  12677. isObject = $__4.isObject,
  12678. objectEach = $__4.objectEach,
  12679. mixin = $__4.mixin;
  12680. var $__5 = ($__utils__ = require("utils"), $__utils__ && $__utils__.__esModule && $__utils__ || {default: $__utils__}),
  12681. isSeparator = $__5.isSeparator,
  12682. isDisabled = $__5.isDisabled,
  12683. isSelectionDisabled = $__5.isSelectionDisabled,
  12684. hasSubMenu = $__5.hasSubMenu,
  12685. normalizeSelection = $__5.normalizeSelection;
  12686. var KEY_CODES = ($___46__46__47__46__46__47_helpers_47_unicode__ = require("helpers/unicode"), $___46__46__47__46__46__47_helpers_47_unicode__ && $___46__46__47__46__46__47_helpers_47_unicode__.__esModule && $___46__46__47__46__46__47_helpers_47_unicode__ || {default: $___46__46__47__46__46__47_helpers_47_unicode__}).KEY_CODES;
  12687. var localHooks = ($___46__46__47__46__46__47_mixins_47_localHooks__ = require("mixins/localHooks"), $___46__46__47__46__46__47_mixins_47_localHooks__ && $___46__46__47__46__46__47_mixins_47_localHooks__.__esModule && $___46__46__47__46__46__47_mixins_47_localHooks__ || {default: $___46__46__47__46__46__47_mixins_47_localHooks__}).localHooks;
  12688. var $__8 = ($__predefinedItems__ = require("predefinedItems"), $__predefinedItems__ && $__predefinedItems__.__esModule && $__predefinedItems__ || {default: $__predefinedItems__}),
  12689. SEPARATOR = $__8.SEPARATOR,
  12690. predefinedItems = $__8.predefinedItems;
  12691. var $__9 = ($___46__46__47__46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47__46__46__47_helpers_47_dom_47_event__ && $___46__46__47__46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_event__}),
  12692. stopPropagation = $__9.stopPropagation,
  12693. stopImmediatePropagation = $__9.stopImmediatePropagation,
  12694. pageX = $__9.pageX,
  12695. pageY = $__9.pageY;
  12696. var Menu = function Menu(hotInstance) {
  12697. var options = arguments[1] !== (void 0) ? arguments[1] : {
  12698. parent: null,
  12699. name: null,
  12700. className: '',
  12701. keepInViewport: true
  12702. };
  12703. this.hot = hotInstance;
  12704. this.options = options;
  12705. this.eventManager = new EventManager(this);
  12706. this.container = this.createContainer(this.options.name);
  12707. this.hotMenu = null;
  12708. this.hotSubMenus = {};
  12709. this.parentMenu = this.options.parent || null;
  12710. this.menuItems = null;
  12711. this.origOutsideClickDeselects = null;
  12712. this._afterScrollCallback = null;
  12713. this.registerEvents();
  12714. };
  12715. var $Menu = Menu;
  12716. ($traceurRuntime.createClass)(Menu, {
  12717. registerEvents: function() {
  12718. var $__10 = this;
  12719. this.eventManager.addEventListener(document.documentElement, 'mousedown', (function(event) {
  12720. return $__10.onDocumentMouseDown(event);
  12721. }));
  12722. },
  12723. setMenuItems: function(menuItems) {
  12724. this.menuItems = menuItems;
  12725. },
  12726. isSubMenu: function() {
  12727. return this.parentMenu !== null;
  12728. },
  12729. open: function() {
  12730. var $__10 = this;
  12731. this.container.removeAttribute('style');
  12732. this.container.style.display = 'block';
  12733. var settings = {
  12734. data: this.menuItems,
  12735. colHeaders: false,
  12736. colWidths: [200],
  12737. autoRowSize: false,
  12738. readOnly: true,
  12739. copyPaste: false,
  12740. columns: [{
  12741. data: 'name',
  12742. renderer: (function(hot, TD, row, col, prop, value) {
  12743. return $__10.menuItemRenderer(hot, TD, row, col, prop, value);
  12744. })
  12745. }],
  12746. renderAllRows: true,
  12747. fragmentSelection: 'cell',
  12748. beforeKeyDown: (function(event) {
  12749. return $__10.onBeforeKeyDown(event);
  12750. }),
  12751. afterOnCellMouseOver: (function(event, coords, TD) {
  12752. return $__10.openSubMenu(coords.row);
  12753. })
  12754. };
  12755. this.origOutsideClickDeselects = this.hot.getSettings().outsideClickDeselects;
  12756. this.hot.getSettings().outsideClickDeselects = false;
  12757. this.hotMenu = new Handsontable.Core(this.container, settings);
  12758. this.hotMenu.addHook('afterInit', (function() {
  12759. return $__10.onAfterInit();
  12760. }));
  12761. this.hotMenu.init();
  12762. this.hotMenu.listen();
  12763. this.blockMainTableCallbacks();
  12764. this.runLocalHooks('afterOpen');
  12765. },
  12766. close: function() {
  12767. var closeParent = arguments[0] !== (void 0) ? arguments[0] : false;
  12768. if (!this.isOpened()) {
  12769. return;
  12770. }
  12771. if (closeParent && this.parentMenu) {
  12772. this.parentMenu.close();
  12773. } else {
  12774. this.closeAllSubMenus();
  12775. this.container.style.display = 'none';
  12776. this.releaseMainTableCallbacks();
  12777. this.hotMenu.destroy();
  12778. this.hotMenu = null;
  12779. this.hot.getSettings().outsideClickDeselects = this.origOutsideClickDeselects;
  12780. this.runLocalHooks('afterClose');
  12781. }
  12782. },
  12783. openSubMenu: function(row) {
  12784. var cell = this.hotMenu.getCell(row, 0);
  12785. this.closeAllSubMenus();
  12786. if (!cell || !hasSubMenu(cell)) {
  12787. return false;
  12788. }
  12789. var dataItem = this.hotMenu.getSourceDataAtRow(row);
  12790. var subMenu = new $Menu(this.hot, {
  12791. parent: this,
  12792. name: dataItem.name,
  12793. className: this.options.className
  12794. });
  12795. subMenu.setMenuItems(dataItem.submenu.items);
  12796. subMenu.open();
  12797. subMenu.setPosition(cell.getBoundingClientRect());
  12798. this.hotSubMenus[dataItem.key] = subMenu;
  12799. return subMenu;
  12800. },
  12801. closeSubMenu: function(row) {
  12802. var dataItem = this.hotMenu.getSourceDataAtRow(row);
  12803. var menus = this.hotSubMenus[dataItem.key];
  12804. if (menus) {
  12805. menus.destroy();
  12806. delete this.hotSubMenus[dataItem.key];
  12807. }
  12808. },
  12809. closeAllSubMenus: function() {
  12810. var $__10 = this;
  12811. arrayEach(this.hotMenu.getData(), (function(value, row) {
  12812. return $__10.closeSubMenu(row);
  12813. }));
  12814. },
  12815. isAllSubMenusClosed: function() {
  12816. return Object.keys(this.hotSubMenus).length === 0;
  12817. },
  12818. destroy: function() {
  12819. this.clearLocalHooks();
  12820. this.close();
  12821. this.parentMenu = null;
  12822. this.eventManager.destroy();
  12823. },
  12824. isOpened: function() {
  12825. return this.hotMenu !== null;
  12826. },
  12827. executeCommand: function(event) {
  12828. if (!this.isOpened() || !this.hotMenu.getSelected()) {
  12829. return;
  12830. }
  12831. var selectedItem = this.hotMenu.getSourceDataAtRow(this.hotMenu.getSelected()[0]);
  12832. this.runLocalHooks('select', selectedItem, event);
  12833. if (selectedItem.isCommand === false) {
  12834. return;
  12835. }
  12836. var selRange = this.hot.getSelectedRange();
  12837. var normalizedSelection = selRange ? normalizeSelection(selRange) : {};
  12838. this.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event);
  12839. if (this.isSubMenu()) {
  12840. this.parentMenu.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event);
  12841. }
  12842. this.close(true);
  12843. },
  12844. setPosition: function(coords) {
  12845. var cursor = new Cursor(coords);
  12846. if (this.options.keepInViewport) {
  12847. if (cursor.fitsBelow(this.container)) {
  12848. this.setPositionBelowCursor(cursor);
  12849. } else if (cursor.fitsAbove(this.container)) {
  12850. this.setPositionAboveCursor(cursor);
  12851. } else {
  12852. this.setPositionBelowCursor(cursor);
  12853. }
  12854. if (cursor.fitsOnRight(this.container)) {
  12855. this.setPositionOnRightOfCursor(cursor);
  12856. } else {
  12857. this.setPositionOnLeftOfCursor(cursor);
  12858. }
  12859. } else {
  12860. this.setPositionBelowCursor(cursor);
  12861. this.setPositionOnRightOfCursor(cursor);
  12862. }
  12863. },
  12864. setPositionAboveCursor: function(cursor) {
  12865. var top = cursor.top - this.container.offsetHeight;
  12866. if (this.isSubMenu()) {
  12867. top = window.scrollY + cursor.top + cursor.cellHeight - this.container.offsetHeight + 3;
  12868. }
  12869. this.container.style.top = top + 'px';
  12870. },
  12871. setPositionBelowCursor: function(cursor) {
  12872. var top = cursor.top - 1;
  12873. if (this.isSubMenu()) {
  12874. top = cursor.top + window.scrollY - 1;
  12875. }
  12876. this.container.style.top = top + 'px';
  12877. },
  12878. setPositionOnRightOfCursor: function(cursor) {
  12879. var left;
  12880. if (this.isSubMenu()) {
  12881. left = window.scrollX + 1 + cursor.left + cursor.cellWidth;
  12882. } else {
  12883. left = 1 + cursor.left;
  12884. }
  12885. this.container.style.left = left + 'px';
  12886. },
  12887. setPositionOnLeftOfCursor: function(cursor) {
  12888. this.container.style.left = (cursor.left - this.container.offsetWidth + getScrollbarWidth() + 4) + 'px';
  12889. },
  12890. selectFirstCell: function() {
  12891. var cell = this.hotMenu.getCell(0, 0);
  12892. if (isSeparator(cell) || isDisabled(cell) || isSelectionDisabled(cell)) {
  12893. this.selectNextCell(0, 0);
  12894. } else {
  12895. this.hotMenu.selectCell(0, 0);
  12896. }
  12897. },
  12898. selectLastCell: function() {
  12899. var lastRow = this.hotMenu.countRows() - 1;
  12900. var cell = this.hotMenu.getCell(lastRow, 0);
  12901. if (isSeparator(cell) || isDisabled(cell) || isSelectionDisabled(cell)) {
  12902. this.selectPrevCell(lastRow, 0);
  12903. } else {
  12904. this.hotMenu.selectCell(lastRow, 0);
  12905. }
  12906. },
  12907. selectNextCell: function(row, col) {
  12908. var nextRow = row + 1;
  12909. var cell = nextRow < this.hotMenu.countRows() ? this.hotMenu.getCell(nextRow, col) : null;
  12910. if (!cell) {
  12911. return;
  12912. }
  12913. if (isSeparator(cell) || isDisabled(cell) || isSelectionDisabled(cell)) {
  12914. this.selectNextCell(nextRow, col);
  12915. } else {
  12916. this.hotMenu.selectCell(nextRow, col);
  12917. }
  12918. },
  12919. selectPrevCell: function(row, col) {
  12920. var prevRow = row - 1;
  12921. var cell = prevRow >= 0 ? this.hotMenu.getCell(prevRow, col) : null;
  12922. if (!cell) {
  12923. return;
  12924. }
  12925. if (isSeparator(cell) || isDisabled(cell) || isSelectionDisabled(cell)) {
  12926. this.selectPrevCell(prevRow, col);
  12927. } else {
  12928. this.hotMenu.selectCell(prevRow, col);
  12929. }
  12930. },
  12931. menuItemRenderer: function(hot, TD, row, col, prop, value) {
  12932. var $__10 = this;
  12933. var item = hot.getSourceDataAtRow(row);
  12934. var wrapper = document.createElement('div');
  12935. var isSubMenu = (function(item) {
  12936. return item.hasOwnProperty('submenu');
  12937. });
  12938. var itemIsSeparator = (function(item) {
  12939. return new RegExp(SEPARATOR, 'i').test(item.name);
  12940. });
  12941. var itemIsDisabled = (function(item) {
  12942. return item.disabled === true || (typeof item.disabled == 'function' && item.disabled.call($__10.hot) === true);
  12943. });
  12944. var itemIsHidden = (function(item) {
  12945. return typeof item.hidden == 'function' && item.hidden.call($__10.hot) === true;
  12946. });
  12947. var itemIsSelectionDisabled = (function(item) {
  12948. return item.disableSelection;
  12949. });
  12950. var isHidden = itemIsHidden(item);
  12951. if (typeof value === 'function') {
  12952. value = value.call(this.hot);
  12953. }
  12954. empty(TD);
  12955. addClass(wrapper, 'htItemWrapper');
  12956. TD.appendChild(wrapper);
  12957. if (itemIsSeparator(item)) {
  12958. addClass(TD, 'htSeparator');
  12959. } else if (!isHidden && typeof item.renderer === 'function') {
  12960. addClass(TD, 'htCustomMenuRenderer');
  12961. TD.appendChild(item.renderer(hot, wrapper, row, col, prop, value));
  12962. } else {
  12963. fastInnerHTML(wrapper, value);
  12964. }
  12965. if (isHidden) {
  12966. if (TD.parentNode) {
  12967. addClass(TD.parentNode, 'htHidden');
  12968. }
  12969. } else if (itemIsDisabled(item)) {
  12970. addClass(TD, 'htDisabled');
  12971. this.eventManager.addEventListener(wrapper, 'mouseenter', (function() {
  12972. return hot.deselectCell();
  12973. }));
  12974. } else if (itemIsSelectionDisabled(item)) {
  12975. addClass(TD, 'htSelectionDisabled');
  12976. this.eventManager.addEventListener(wrapper, 'mouseenter', (function() {
  12977. return hot.deselectCell();
  12978. }));
  12979. } else if (isSubMenu(item)) {
  12980. addClass(TD, 'htSubmenu');
  12981. if (itemIsSelectionDisabled(item)) {
  12982. this.eventManager.addEventListener(wrapper, 'mouseenter', (function() {
  12983. return hot.deselectCell();
  12984. }));
  12985. } else {
  12986. this.eventManager.addEventListener(wrapper, 'mouseenter', (function() {
  12987. return hot.selectCell(row, col, void 0, void 0, void 0, false);
  12988. }));
  12989. }
  12990. } else {
  12991. removeClass(TD, 'htSubmenu');
  12992. removeClass(TD, 'htDisabled');
  12993. if (itemIsSelectionDisabled(item)) {
  12994. this.eventManager.addEventListener(wrapper, 'mouseenter', (function() {
  12995. return hot.deselectCell();
  12996. }));
  12997. } else {
  12998. this.eventManager.addEventListener(wrapper, 'mouseenter', (function() {
  12999. return hot.selectCell(row, col, void 0, void 0, void 0, false);
  13000. }));
  13001. }
  13002. }
  13003. },
  13004. createContainer: function() {
  13005. var name = arguments[0] !== (void 0) ? arguments[0] : null;
  13006. if (name) {
  13007. name = name.replace(/ /g, '_');
  13008. name = this.options.className + 'Sub_' + name;
  13009. }
  13010. var container;
  13011. if (name) {
  13012. container = document.querySelector('.' + this.options.className + '.' + name);
  13013. } else {
  13014. container = document.querySelector('.' + this.options.className);
  13015. }
  13016. if (!container) {
  13017. container = document.createElement('div');
  13018. addClass(container, 'htMenu ' + this.options.className);
  13019. if (name) {
  13020. addClass(container, name);
  13021. }
  13022. document.getElementsByTagName('body')[0].appendChild(container);
  13023. }
  13024. return container;
  13025. },
  13026. blockMainTableCallbacks: function() {
  13027. this._afterScrollCallback = function() {};
  13028. this.hot.addHook('afterScrollVertically', this._afterScrollCallback);
  13029. this.hot.addHook('afterScrollHorizontally', this._afterScrollCallback);
  13030. },
  13031. releaseMainTableCallbacks: function() {
  13032. if (this._afterScrollCallback) {
  13033. this.hot.removeHook('afterScrollVertically', this._afterScrollCallback);
  13034. this.hot.removeHook('afterScrollHorizontally', this._afterScrollCallback);
  13035. this._afterScrollCallback = null;
  13036. }
  13037. },
  13038. onBeforeKeyDown: function(event) {
  13039. var selection = this.hotMenu.getSelected();
  13040. var stopEvent = false;
  13041. switch (event.keyCode) {
  13042. case KEY_CODES.ESCAPE:
  13043. this.close();
  13044. stopEvent = true;
  13045. break;
  13046. case KEY_CODES.ENTER:
  13047. if (selection) {
  13048. if (this.hotMenu.getSourceDataAtRow(selection[0]).submenu) {
  13049. stopEvent = true;
  13050. } else {
  13051. this.executeCommand(event);
  13052. this.close(true);
  13053. }
  13054. }
  13055. break;
  13056. case KEY_CODES.ARROW_DOWN:
  13057. if (selection) {
  13058. this.selectNextCell(selection[0], selection[1]);
  13059. } else {
  13060. this.selectFirstCell();
  13061. }
  13062. stopEvent = true;
  13063. break;
  13064. case KEY_CODES.ARROW_UP:
  13065. if (selection) {
  13066. this.selectPrevCell(selection[0], selection[1]);
  13067. } else {
  13068. this.selectLastCell();
  13069. }
  13070. stopEvent = true;
  13071. break;
  13072. case KEY_CODES.ARROW_RIGHT:
  13073. if (selection) {
  13074. var menu = this.openSubMenu(selection[0]);
  13075. if (menu) {
  13076. menu.selectFirstCell();
  13077. }
  13078. }
  13079. stopEvent = true;
  13080. break;
  13081. case KEY_CODES.ARROW_LEFT:
  13082. if (selection && this.isSubMenu()) {
  13083. this.close();
  13084. if (this.parentMenu) {
  13085. this.parentMenu.hotMenu.listen();
  13086. }
  13087. stopEvent = true;
  13088. }
  13089. break;
  13090. }
  13091. if (stopEvent) {
  13092. event.preventDefault();
  13093. stopImmediatePropagation(event);
  13094. }
  13095. },
  13096. onAfterInit: function() {
  13097. var data = this.hotMenu.getSettings().data;
  13098. var hiderStyle = this.hotMenu.view.wt.wtTable.hider.style;
  13099. var holderStyle = this.hotMenu.view.wt.wtTable.holder.style;
  13100. var currentHiderWidth = parseInt(hiderStyle.width, 10);
  13101. var realHeight = 0;
  13102. arrayEach(data, (function(value) {
  13103. return realHeight += value.name === SEPARATOR ? 1 : 26;
  13104. }));
  13105. holderStyle.width = currentHiderWidth + 22 + 'px';
  13106. holderStyle.height = realHeight + 4 + 'px';
  13107. },
  13108. onDocumentMouseDown: function(event) {
  13109. if (!this.isOpened()) {
  13110. return;
  13111. }
  13112. if (this.container && isChildOf(event.target, this.container)) {
  13113. this.executeCommand(event);
  13114. }
  13115. if ((this.isAllSubMenusClosed() || this.isSubMenu()) && (!isChildOf(event.target, '.htMenu') && isChildOf(event.target, document))) {
  13116. this.close(true);
  13117. }
  13118. }
  13119. }, {});
  13120. mixin(Menu, localHooks);
  13121. ;
  13122. //#
  13123. },{"cursor":67,"eventManager":41,"helpers/array":42,"helpers/dom/element":45,"helpers/dom/event":46,"helpers/object":50,"helpers/unicode":53,"mixins/localHooks":54,"predefinedItems":70,"utils":71}],70:[function(require,module,exports){
  13124. "use strict";
  13125. var $__4;
  13126. Object.defineProperties(exports, {
  13127. ROW_ABOVE: {get: function() {
  13128. return ROW_ABOVE;
  13129. }},
  13130. ROW_BELOW: {get: function() {
  13131. return ROW_BELOW;
  13132. }},
  13133. COLUMN_LEFT: {get: function() {
  13134. return COLUMN_LEFT;
  13135. }},
  13136. COLUMN_RIGHT: {get: function() {
  13137. return COLUMN_RIGHT;
  13138. }},
  13139. CLEAR_COLUMN: {get: function() {
  13140. return CLEAR_COLUMN;
  13141. }},
  13142. REMOVE_ROW: {get: function() {
  13143. return REMOVE_ROW;
  13144. }},
  13145. REMOVE_COLUMN: {get: function() {
  13146. return REMOVE_COLUMN;
  13147. }},
  13148. UNDO: {get: function() {
  13149. return UNDO;
  13150. }},
  13151. REDO: {get: function() {
  13152. return REDO;
  13153. }},
  13154. READ_ONLY: {get: function() {
  13155. return READ_ONLY;
  13156. }},
  13157. ALIGNMENT: {get: function() {
  13158. return ALIGNMENT;
  13159. }},
  13160. SEPARATOR: {get: function() {
  13161. return SEPARATOR;
  13162. }},
  13163. ITEMS: {get: function() {
  13164. return ITEMS;
  13165. }},
  13166. predefinedItems: {get: function() {
  13167. return predefinedItems;
  13168. }},
  13169. addItem: {get: function() {
  13170. return addItem;
  13171. }},
  13172. __esModule: {value: true}
  13173. });
  13174. var $___46__46__47__46__46__47_helpers_47_object__,
  13175. $___46__46__47__46__46__47_helpers_47_number__,
  13176. $__utils__;
  13177. var $__0 = ($___46__46__47__46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47__46__46__47_helpers_47_object__ && $___46__46__47__46__46__47_helpers_47_object__.__esModule && $___46__46__47__46__46__47_helpers_47_object__ || {default: $___46__46__47__46__46__47_helpers_47_object__}),
  13178. objectEach = $__0.objectEach,
  13179. clone = $__0.clone;
  13180. var rangeEach = ($___46__46__47__46__46__47_helpers_47_number__ = require("helpers/number"), $___46__46__47__46__46__47_helpers_47_number__ && $___46__46__47__46__46__47_helpers_47_number__.__esModule && $___46__46__47__46__46__47_helpers_47_number__ || {default: $___46__46__47__46__46__47_helpers_47_number__}).rangeEach;
  13181. var $__2 = ($__utils__ = require("utils"), $__utils__ && $__utils__.__esModule && $__utils__ || {default: $__utils__}),
  13182. align = $__2.align,
  13183. getAlignmentClasses = $__2.getAlignmentClasses,
  13184. getValidSelection = $__2.getValidSelection,
  13185. checkSelectionConsistency = $__2.checkSelectionConsistency,
  13186. markLabelAsSelected = $__2.markLabelAsSelected;
  13187. var ROW_ABOVE = 'row_above';
  13188. var ROW_BELOW = 'row_below';
  13189. var COLUMN_LEFT = 'col_left';
  13190. var COLUMN_RIGHT = 'col_right';
  13191. var CLEAR_COLUMN = 'clear_column';
  13192. var REMOVE_ROW = 'remove_row';
  13193. var REMOVE_COLUMN = 'remove_col';
  13194. var UNDO = 'undo';
  13195. var REDO = 'redo';
  13196. var READ_ONLY = 'make_read_only';
  13197. var ALIGNMENT = 'alignment';
  13198. var SEPARATOR = '---------';
  13199. var ITEMS = [ROW_ABOVE, ROW_BELOW, COLUMN_LEFT, COLUMN_RIGHT, CLEAR_COLUMN, REMOVE_ROW, REMOVE_COLUMN, UNDO, REDO, READ_ONLY, ALIGNMENT, SEPARATOR];
  13200. function predefinedItems() {
  13201. var items = {};
  13202. objectEach(_predefinedItems, (function(value, key) {
  13203. return items[key] = clone(value);
  13204. }));
  13205. return items;
  13206. }
  13207. function addItem(key, item) {
  13208. if (ITEMS.indexOf(key) === -1) {
  13209. _predefinedItems[key] = item;
  13210. }
  13211. }
  13212. var _predefinedItems = ($__4 = {}, Object.defineProperty($__4, SEPARATOR, {
  13213. value: {name: SEPARATOR},
  13214. configurable: true,
  13215. enumerable: true,
  13216. writable: true
  13217. }), Object.defineProperty($__4, ROW_ABOVE, {
  13218. value: {
  13219. key: ROW_ABOVE,
  13220. name: 'Insert row above',
  13221. callback: function(key, selection) {
  13222. this.alter('insert_row', selection.start.row);
  13223. },
  13224. disabled: function() {
  13225. var selected = getValidSelection(this);
  13226. if (!selected) {
  13227. return true;
  13228. }
  13229. var rowCount = this.countRows();
  13230. var entireColumnSelection = [0, selected[1], rowCount - 1, selected[1]];
  13231. return (entireColumnSelection.join(',') === selected.join(',')) && rowCount > 1;
  13232. },
  13233. hidden: function() {
  13234. return !this.getSettings().allowInsertRow;
  13235. }
  13236. },
  13237. configurable: true,
  13238. enumerable: true,
  13239. writable: true
  13240. }), Object.defineProperty($__4, ROW_BELOW, {
  13241. value: {
  13242. key: ROW_BELOW,
  13243. name: 'Insert row below',
  13244. callback: function(key, selection) {
  13245. this.alter('insert_row', selection.end.row + 1);
  13246. },
  13247. disabled: function() {
  13248. var selected = getValidSelection(this);
  13249. if (!selected) {
  13250. return true;
  13251. }
  13252. var rowCount = this.countRows();
  13253. var entireColumnSelection = [0, selected[1], rowCount - 1, selected[1]];
  13254. return (entireColumnSelection.join(',') === selected.join(',')) && rowCount > 1;
  13255. },
  13256. hidden: function() {
  13257. return !this.getSettings().allowInsertRow;
  13258. }
  13259. },
  13260. configurable: true,
  13261. enumerable: true,
  13262. writable: true
  13263. }), Object.defineProperty($__4, COLUMN_LEFT, {
  13264. value: {
  13265. key: COLUMN_LEFT,
  13266. name: 'Insert column on the left',
  13267. callback: function(key, selection) {
  13268. this.alter('insert_col', selection.start.col);
  13269. },
  13270. disabled: function() {
  13271. var selected = getValidSelection(this);
  13272. if (!selected) {
  13273. return true;
  13274. }
  13275. if (!this.isColumnModificationAllowed()) {
  13276. return true;
  13277. }
  13278. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  13279. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  13280. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
  13281. },
  13282. hidden: function() {
  13283. return !this.getSettings().allowInsertColumn;
  13284. }
  13285. },
  13286. configurable: true,
  13287. enumerable: true,
  13288. writable: true
  13289. }), Object.defineProperty($__4, COLUMN_RIGHT, {
  13290. value: {
  13291. key: COLUMN_RIGHT,
  13292. name: 'Insert column on the right',
  13293. callback: function(key, selection) {
  13294. this.alter('insert_col', selection.end.col + 1);
  13295. },
  13296. disabled: function() {
  13297. var selected = getValidSelection(this);
  13298. if (!selected) {
  13299. return true;
  13300. }
  13301. if (!this.isColumnModificationAllowed()) {
  13302. return true;
  13303. }
  13304. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  13305. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  13306. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
  13307. },
  13308. hidden: function() {
  13309. return !this.getSettings().allowInsertColumn;
  13310. }
  13311. },
  13312. configurable: true,
  13313. enumerable: true,
  13314. writable: true
  13315. }), Object.defineProperty($__4, CLEAR_COLUMN, {
  13316. value: {
  13317. key: CLEAR_COLUMN,
  13318. name: 'Clear column',
  13319. callback: function(key, selection) {
  13320. var column = selection.start.col;
  13321. if (this.countRows()) {
  13322. this.populateFromArray(0, column, [[null]], Math.max(selection.start.row, selection.end.row), column);
  13323. }
  13324. },
  13325. disabled: function() {
  13326. var selected = getValidSelection(this);
  13327. if (!selected) {
  13328. return true;
  13329. }
  13330. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  13331. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  13332. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
  13333. }
  13334. },
  13335. configurable: true,
  13336. enumerable: true,
  13337. writable: true
  13338. }), Object.defineProperty($__4, REMOVE_ROW, {
  13339. value: {
  13340. key: REMOVE_ROW,
  13341. name: 'Remove row',
  13342. callback: function(key, selection) {
  13343. var amount = selection.end.row - selection.start.row + 1;
  13344. this.alter('remove_row', selection.start.row, amount);
  13345. },
  13346. disabled: function() {
  13347. var selected = getValidSelection(this);
  13348. if (!selected) {
  13349. return true;
  13350. }
  13351. var entireColumnSelection = [0, selected[1], this.countRows() - 1, selected[1]];
  13352. return entireColumnSelection.join(',') === selected.join(',');
  13353. },
  13354. hidden: function() {
  13355. return !this.getSettings().allowRemoveRow;
  13356. }
  13357. },
  13358. configurable: true,
  13359. enumerable: true,
  13360. writable: true
  13361. }), Object.defineProperty($__4, REMOVE_COLUMN, {
  13362. value: {
  13363. key: REMOVE_COLUMN,
  13364. name: 'Remove column',
  13365. callback: function(key, selection) {
  13366. var amount = selection.end.col - selection.start.col + 1;
  13367. this.alter('remove_col', selection.start.col, amount);
  13368. },
  13369. disabled: function() {
  13370. var selected = getValidSelection(this);
  13371. if (!selected) {
  13372. return true;
  13373. }
  13374. if (!this.isColumnModificationAllowed()) {
  13375. return true;
  13376. }
  13377. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  13378. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  13379. return (selected[1] < 0 || rowSelected);
  13380. },
  13381. hidden: function() {
  13382. return !this.getSettings().allowRemoveColumn;
  13383. }
  13384. },
  13385. configurable: true,
  13386. enumerable: true,
  13387. writable: true
  13388. }), Object.defineProperty($__4, UNDO, {
  13389. value: {
  13390. key: UNDO,
  13391. name: 'Undo',
  13392. callback: function() {
  13393. this.undo();
  13394. },
  13395. disabled: function() {
  13396. return this.undoRedo && !this.undoRedo.isUndoAvailable();
  13397. }
  13398. },
  13399. configurable: true,
  13400. enumerable: true,
  13401. writable: true
  13402. }), Object.defineProperty($__4, REDO, {
  13403. value: {
  13404. key: REDO,
  13405. name: 'Redo',
  13406. callback: function() {
  13407. this.redo();
  13408. },
  13409. disabled: function() {
  13410. return this.undoRedo && !this.undoRedo.isRedoAvailable();
  13411. }
  13412. },
  13413. configurable: true,
  13414. enumerable: true,
  13415. writable: true
  13416. }), Object.defineProperty($__4, READ_ONLY, {
  13417. value: {
  13418. key: READ_ONLY,
  13419. name: function() {
  13420. var $__3 = this;
  13421. var label = 'Read only';
  13422. var atLeastOneReadOnly = checkSelectionConsistency(this.getSelectedRange(), (function(row, col) {
  13423. return $__3.getCellMeta(row, col).readOnly;
  13424. }));
  13425. if (atLeastOneReadOnly) {
  13426. label = markLabelAsSelected(label);
  13427. }
  13428. return label;
  13429. },
  13430. callback: function() {
  13431. var $__3 = this;
  13432. var range = this.getSelectedRange();
  13433. var atLeastOneReadOnly = checkSelectionConsistency(range, (function(row, col) {
  13434. return $__3.getCellMeta(row, col).readOnly;
  13435. }));
  13436. range.forAll((function(row, col) {
  13437. $__3.getCellMeta(row, col).readOnly = atLeastOneReadOnly ? false : true;
  13438. }));
  13439. this.render();
  13440. },
  13441. disabled: function() {
  13442. return this.getSelectedRange() ? false : true;
  13443. }
  13444. },
  13445. configurable: true,
  13446. enumerable: true,
  13447. writable: true
  13448. }), Object.defineProperty($__4, ALIGNMENT, {
  13449. value: {
  13450. key: ALIGNMENT,
  13451. name: 'Alignment',
  13452. disabled: function() {
  13453. return this.getSelectedRange() ? false : true;
  13454. },
  13455. submenu: {items: [{
  13456. key: (ALIGNMENT + ":left"),
  13457. name: function() {
  13458. var $__3 = this;
  13459. var label = 'Left';
  13460. var hasClass = checkSelectionConsistency(this.getSelectedRange(), (function(row, col) {
  13461. var className = $__3.getCellMeta(row, col).className;
  13462. if (className && className.indexOf('htLeft') !== -1) {
  13463. return true;
  13464. }
  13465. }));
  13466. if (hasClass) {
  13467. label = markLabelAsSelected(label);
  13468. }
  13469. return label;
  13470. },
  13471. callback: function() {
  13472. var $__3 = this;
  13473. var range = this.getSelectedRange();
  13474. var stateBefore = getAlignmentClasses(range, (function(row, col) {
  13475. return $__3.getCellMeta(row, col).className;
  13476. }));
  13477. var type = 'horizontal';
  13478. var alignment = 'htLeft';
  13479. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  13480. align(range, type, alignment, (function(row, col) {
  13481. return $__3.getCellMeta(row, col);
  13482. }));
  13483. this.render();
  13484. },
  13485. disabled: false
  13486. }, {
  13487. key: (ALIGNMENT + ":center"),
  13488. name: function() {
  13489. var $__3 = this;
  13490. var label = 'Center';
  13491. var hasClass = checkSelectionConsistency(this.getSelectedRange(), (function(row, col) {
  13492. var className = $__3.getCellMeta(row, col).className;
  13493. if (className && className.indexOf('htCenter') !== -1) {
  13494. return true;
  13495. }
  13496. }));
  13497. if (hasClass) {
  13498. label = markLabelAsSelected(label);
  13499. }
  13500. return label;
  13501. },
  13502. callback: function() {
  13503. var $__3 = this;
  13504. var range = this.getSelectedRange();
  13505. var stateBefore = getAlignmentClasses(range, (function(row, col) {
  13506. return $__3.getCellMeta(row, col).className;
  13507. }));
  13508. var type = 'horizontal';
  13509. var alignment = 'htCenter';
  13510. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  13511. align(range, type, alignment, (function(row, col) {
  13512. return $__3.getCellMeta(row, col);
  13513. }));
  13514. this.render();
  13515. },
  13516. disabled: false
  13517. }, {
  13518. key: (ALIGNMENT + ":right"),
  13519. name: function() {
  13520. var $__3 = this;
  13521. var label = 'Right';
  13522. var hasClass = checkSelectionConsistency(this.getSelectedRange(), (function(row, col) {
  13523. var className = $__3.getCellMeta(row, col).className;
  13524. if (className && className.indexOf('htRight') !== -1) {
  13525. return true;
  13526. }
  13527. }));
  13528. if (hasClass) {
  13529. label = markLabelAsSelected(label);
  13530. }
  13531. return label;
  13532. },
  13533. callback: function() {
  13534. var $__3 = this;
  13535. var range = this.getSelectedRange();
  13536. var stateBefore = getAlignmentClasses(range, (function(row, col) {
  13537. return $__3.getCellMeta(row, col).className;
  13538. }));
  13539. var type = 'horizontal';
  13540. var alignment = 'htRight';
  13541. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  13542. align(range, type, alignment, (function(row, col) {
  13543. return $__3.getCellMeta(row, col);
  13544. }));
  13545. this.render();
  13546. },
  13547. disabled: false
  13548. }, {
  13549. key: (ALIGNMENT + ":justify"),
  13550. name: function() {
  13551. var $__3 = this;
  13552. var label = 'Justify';
  13553. var hasClass = checkSelectionConsistency(this.getSelectedRange(), (function(row, col) {
  13554. var className = $__3.getCellMeta(row, col).className;
  13555. if (className && className.indexOf('htJustify') !== -1) {
  13556. return true;
  13557. }
  13558. }));
  13559. if (hasClass) {
  13560. label = markLabelAsSelected(label);
  13561. }
  13562. return label;
  13563. },
  13564. callback: function() {
  13565. var $__3 = this;
  13566. var range = this.getSelectedRange();
  13567. var stateBefore = getAlignmentClasses(range, (function(row, col) {
  13568. return $__3.getCellMeta(row, col).className;
  13569. }));
  13570. var type = 'horizontal';
  13571. var alignment = 'htJustify';
  13572. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  13573. align(range, type, alignment, (function(row, col) {
  13574. return $__3.getCellMeta(row, col);
  13575. }));
  13576. this.render();
  13577. },
  13578. disabled: false
  13579. }, {name: SEPARATOR}, {
  13580. key: (ALIGNMENT + ":top"),
  13581. name: function() {
  13582. var $__3 = this;
  13583. var label = 'Top';
  13584. var hasClass = checkSelectionConsistency(this.getSelectedRange(), (function(row, col) {
  13585. var className = $__3.getCellMeta(row, col).className;
  13586. if (className && className.indexOf('htTop') !== -1) {
  13587. return true;
  13588. }
  13589. }));
  13590. if (hasClass) {
  13591. label = markLabelAsSelected(label);
  13592. }
  13593. return label;
  13594. },
  13595. callback: function() {
  13596. var $__3 = this;
  13597. var range = this.getSelectedRange();
  13598. var stateBefore = getAlignmentClasses(range, (function(row, col) {
  13599. return $__3.getCellMeta(row, col).className;
  13600. }));
  13601. var type = 'vertical';
  13602. var alignment = 'htTop';
  13603. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  13604. align(range, type, alignment, (function(row, col) {
  13605. return $__3.getCellMeta(row, col);
  13606. }));
  13607. this.render();
  13608. },
  13609. disabled: false
  13610. }, {
  13611. key: (ALIGNMENT + ":middle"),
  13612. name: function() {
  13613. var $__3 = this;
  13614. var label = 'Middle';
  13615. var hasClass = checkSelectionConsistency(this.getSelectedRange(), (function(row, col) {
  13616. var className = $__3.getCellMeta(row, col).className;
  13617. if (className && className.indexOf('htMiddle') !== -1) {
  13618. return true;
  13619. }
  13620. }));
  13621. if (hasClass) {
  13622. label = markLabelAsSelected(label);
  13623. }
  13624. return label;
  13625. },
  13626. callback: function() {
  13627. var $__3 = this;
  13628. var range = this.getSelectedRange();
  13629. var stateBefore = getAlignmentClasses(range, (function(row, col) {
  13630. return $__3.getCellMeta(row, col).className;
  13631. }));
  13632. var type = 'vertical';
  13633. var alignment = 'htMiddle';
  13634. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  13635. align(range, type, alignment, (function(row, col) {
  13636. return $__3.getCellMeta(row, col);
  13637. }));
  13638. this.render();
  13639. },
  13640. disabled: false
  13641. }, {
  13642. key: (ALIGNMENT + ":bottom"),
  13643. name: function() {
  13644. var $__3 = this;
  13645. var label = 'Bottom';
  13646. var hasClass = checkSelectionConsistency(this.getSelectedRange(), (function(row, col) {
  13647. var className = $__3.getCellMeta(row, col).className;
  13648. if (className && className.indexOf('htBottom') !== -1) {
  13649. return true;
  13650. }
  13651. }));
  13652. if (hasClass) {
  13653. label = markLabelAsSelected(label);
  13654. }
  13655. return label;
  13656. },
  13657. callback: function() {
  13658. var $__3 = this;
  13659. var range = this.getSelectedRange();
  13660. var stateBefore = getAlignmentClasses(range, (function(row, col) {
  13661. return $__3.getCellMeta(row, col).className;
  13662. }));
  13663. var type = 'vertical';
  13664. var alignment = 'htBottom';
  13665. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  13666. align(range, type, alignment, (function(row, col) {
  13667. return $__3.getCellMeta(row, col);
  13668. }));
  13669. this.render();
  13670. },
  13671. disabled: false
  13672. }]}
  13673. },
  13674. configurable: true,
  13675. enumerable: true,
  13676. writable: true
  13677. }), $__4);
  13678. //#
  13679. },{"helpers/number":49,"helpers/object":50,"utils":71}],71:[function(require,module,exports){
  13680. "use strict";
  13681. Object.defineProperties(exports, {
  13682. normalizeSelection: {get: function() {
  13683. return normalizeSelection;
  13684. }},
  13685. isSeparator: {get: function() {
  13686. return isSeparator;
  13687. }},
  13688. hasSubMenu: {get: function() {
  13689. return hasSubMenu;
  13690. }},
  13691. isDisabled: {get: function() {
  13692. return isDisabled;
  13693. }},
  13694. isSelectionDisabled: {get: function() {
  13695. return isSelectionDisabled;
  13696. }},
  13697. getValidSelection: {get: function() {
  13698. return getValidSelection;
  13699. }},
  13700. prepareVerticalAlignClass: {get: function() {
  13701. return prepareVerticalAlignClass;
  13702. }},
  13703. prepareHorizontalAlignClass: {get: function() {
  13704. return prepareHorizontalAlignClass;
  13705. }},
  13706. getAlignmentClasses: {get: function() {
  13707. return getAlignmentClasses;
  13708. }},
  13709. align: {get: function() {
  13710. return align;
  13711. }},
  13712. checkSelectionConsistency: {get: function() {
  13713. return checkSelectionConsistency;
  13714. }},
  13715. markLabelAsSelected: {get: function() {
  13716. return markLabelAsSelected;
  13717. }},
  13718. __esModule: {value: true}
  13719. });
  13720. var $___46__46__47__46__46__47_helpers_47_dom_47_element__;
  13721. var hasClass = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}).hasClass;
  13722. function normalizeSelection(selRange) {
  13723. return {
  13724. start: selRange.getTopLeftCorner(),
  13725. end: selRange.getBottomRightCorner()
  13726. };
  13727. }
  13728. function isSeparator(cell) {
  13729. return hasClass(cell, 'htSeparator');
  13730. }
  13731. function hasSubMenu(cell) {
  13732. return hasClass(cell, 'htSubmenu');
  13733. }
  13734. function isDisabled(cell) {
  13735. return hasClass(cell, 'htDisabled');
  13736. }
  13737. function isSelectionDisabled(cell) {
  13738. return hasClass(cell, 'htSelectionDisabled');
  13739. }
  13740. function getValidSelection(hot) {
  13741. var selected = hot.getSelected();
  13742. if (!selected) {
  13743. return null;
  13744. }
  13745. if (selected[0] < 0) {
  13746. return null;
  13747. }
  13748. if (hot.countRows() >= hot.getSettings().maxRows) {
  13749. return null;
  13750. }
  13751. return selected;
  13752. }
  13753. function prepareVerticalAlignClass(className, alignment) {
  13754. if (className.indexOf(alignment) != -1) {
  13755. return className;
  13756. }
  13757. className = className.replace('htTop', '').replace('htMiddle', '').replace('htBottom', '').replace(' ', '');
  13758. className += ' ' + alignment;
  13759. return className;
  13760. }
  13761. function prepareHorizontalAlignClass(className, alignment) {
  13762. if (className.indexOf(alignment) != -1) {
  13763. return className;
  13764. }
  13765. className = className.replace('htLeft', '').replace('htCenter', '').replace('htRight', '').replace('htJustify', '').replace(' ', '');
  13766. className += ' ' + alignment;
  13767. return className;
  13768. }
  13769. function getAlignmentClasses(range, callback) {
  13770. var classes = {};
  13771. for (var row = range.from.row; row <= range.to.row; row++) {
  13772. for (var col = range.from.col; col <= range.to.col; col++) {
  13773. if (!classes[row]) {
  13774. classes[row] = [];
  13775. }
  13776. classes[row][col] = callback(row, col);
  13777. }
  13778. }
  13779. return classes;
  13780. }
  13781. function align(range, type, alignment, cellDescriptor) {
  13782. if (range.from.row == range.to.row && range.from.col == range.to.col) {
  13783. applyAlignClassName(range.from.row, range.from.col, type, alignment, cellDescriptor);
  13784. } else {
  13785. for (var row = range.from.row; row <= range.to.row; row++) {
  13786. for (var col = range.from.col; col <= range.to.col; col++) {
  13787. applyAlignClassName(row, col, type, alignment, cellDescriptor);
  13788. }
  13789. }
  13790. }
  13791. }
  13792. function applyAlignClassName(row, col, type, alignment, cellDescriptor) {
  13793. var cellMeta = cellDescriptor(row, col);
  13794. var className = alignment;
  13795. if (cellMeta.className) {
  13796. if (type === 'vertical') {
  13797. className = prepareVerticalAlignClass(cellMeta.className, alignment);
  13798. } else {
  13799. className = prepareHorizontalAlignClass(cellMeta.className, alignment);
  13800. }
  13801. }
  13802. cellMeta.className = className;
  13803. }
  13804. function checkSelectionConsistency(range, comparator) {
  13805. var result = false;
  13806. if (range) {
  13807. range.forAll(function(row, col) {
  13808. if (comparator(row, col)) {
  13809. result = true;
  13810. return false;
  13811. }
  13812. });
  13813. }
  13814. return result;
  13815. }
  13816. function markLabelAsSelected(label) {
  13817. return '<span class="selected">' + String.fromCharCode(10003) + '</span>' + label;
  13818. }
  13819. //#
  13820. },{"helpers/dom/element":45}],72:[function(require,module,exports){
  13821. "use strict";
  13822. Object.defineProperties(exports, {
  13823. ContextMenuCopyPaste: {get: function() {
  13824. return ContextMenuCopyPaste;
  13825. }},
  13826. __esModule: {value: true}
  13827. });
  13828. var $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  13829. $___46__46__47__46__46__47_helpers_47_array__,
  13830. $___46__46__47__46__46__47_eventManager__,
  13831. $___46__46__47__46__46__47_plugins__,
  13832. $___46__46__47__95_base__,
  13833. $__zeroclipboard__;
  13834. var removeClass = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}).removeClass;
  13835. var arrayEach = ($___46__46__47__46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47__46__46__47_helpers_47_array__ && $___46__46__47__46__46__47_helpers_47_array__.__esModule && $___46__46__47__46__46__47_helpers_47_array__ || {default: $___46__46__47__46__46__47_helpers_47_array__}).arrayEach;
  13836. var EventManager = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).EventManager;
  13837. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  13838. var BasePlugin = ($___46__46__47__95_base__ = require("_base"), $___46__46__47__95_base__ && $___46__46__47__95_base__.__esModule && $___46__46__47__95_base__ || {default: $___46__46__47__95_base__}).default;
  13839. var ZeroClipboard = ($__zeroclipboard__ = require("zeroclipboard"), $__zeroclipboard__ && $__zeroclipboard__.__esModule && $__zeroclipboard__ || {default: $__zeroclipboard__}).default;
  13840. var ContextMenuCopyPaste = function ContextMenuCopyPaste(hotInstance) {
  13841. $traceurRuntime.superConstructor($ContextMenuCopyPaste).call(this, hotInstance);
  13842. this.eventManager = new EventManager(this);
  13843. this.swfPath = null;
  13844. this.outsideClickDeselectsCache = null;
  13845. };
  13846. var $ContextMenuCopyPaste = ContextMenuCopyPaste;
  13847. ($traceurRuntime.createClass)(ContextMenuCopyPaste, {
  13848. isEnabled: function() {
  13849. return this.hot.getSettings().contextMenuCopyPaste;
  13850. },
  13851. enablePlugin: function() {
  13852. var $__6 = this;
  13853. if (this.enabled) {
  13854. return;
  13855. }
  13856. if (typeof this.hot.getSettings().contextMenuCopyPaste === 'object') {
  13857. this.swfPath = this.hot.getSettings().contextMenuCopyPaste.swfPath;
  13858. }
  13859. if (typeof ZeroClipboard === 'undefined') {
  13860. console.error('To be able to use the Copy/Paste feature from the context menu, you need to manually include ZeroClipboard.js file to your website.');
  13861. }
  13862. try {
  13863. new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
  13864. } catch (exception) {
  13865. if (typeof navigator.mimeTypes['application/x-shockwave-flash'] == 'undefined') {
  13866. console.error('To be able to use the Copy/Paste feature from the context menu, your browser needs to have Flash Plugin installed.');
  13867. }
  13868. }
  13869. if (this.swfPath) {
  13870. ZeroClipboard.config({swfPath: this.swfPath});
  13871. }
  13872. this.hot.addHook('afterContextMenuShow', (function() {
  13873. return $__6.onAfterContextMenuShow();
  13874. }));
  13875. this.hot.addHook('afterContextMenuDefaultOptions', (function(options) {
  13876. return $__6.onAfterContextMenuDefaultOptions(options);
  13877. }));
  13878. this.registerEvents();
  13879. $traceurRuntime.superGet(this, $ContextMenuCopyPaste.prototype, "enablePlugin").call(this);
  13880. },
  13881. disablePlugin: function() {
  13882. $traceurRuntime.superGet(this, $ContextMenuCopyPaste.prototype, "disablePlugin").call(this);
  13883. },
  13884. registerEvents: function() {
  13885. var $__6 = this;
  13886. this.eventManager.addEventListener(document, 'mouseenter', (function() {
  13887. return $__6.removeCurrentClass();
  13888. }));
  13889. this.eventManager.addEventListener(document, 'mouseleave', (function() {
  13890. return $__6.removeZeroClipboardClass();
  13891. }));
  13892. },
  13893. getCopyValue: function() {
  13894. this.hot.copyPaste.setCopyableText();
  13895. return this.hot.copyPaste.copyPasteInstance.elTextarea.value;
  13896. },
  13897. onAfterContextMenuDefaultOptions: function(defaultOptions) {
  13898. defaultOptions.items.unshift({
  13899. key: 'copy',
  13900. name: 'Copy'
  13901. }, {
  13902. key: 'paste',
  13903. name: 'Paste',
  13904. callback: function() {
  13905. this.copyPaste.triggerPaste();
  13906. }
  13907. }, Handsontable.plugins.ContextMenu.SEPARATOR);
  13908. },
  13909. onAfterContextMenuShow: function() {
  13910. var $__6 = this;
  13911. var contextMenu = this.hot.getPlugin('contextMenu');
  13912. var data = contextMenu.menu.hotMenu.getSourceData();
  13913. arrayEach(data, (function(item, index) {
  13914. if (item.key === 'copy') {
  13915. var zeroClipboardInstance = new ZeroClipboard(contextMenu.menu.hotMenu.getCell(index, 0));
  13916. zeroClipboardInstance.off();
  13917. zeroClipboardInstance.on('copy', (function(event) {
  13918. var clipboard = event.clipboardData;
  13919. clipboard.setData('text/plain', $__6.getCopyValue());
  13920. $__6.hot.getSettings().outsideClickDeselects = $__6.outsideClickDeselectsCache;
  13921. }));
  13922. return false;
  13923. }
  13924. }));
  13925. },
  13926. removeCurrentClass: function() {
  13927. var contextMenu = this.hot.getPlugin('contextMenu');
  13928. if (contextMenu.menu.isOpened()) {
  13929. var element = contextMenu.menu.hotMenu.rootElement.querySelector('td.current');
  13930. if (element) {
  13931. removeClass(element, 'current');
  13932. }
  13933. }
  13934. this.outsideClickDeselectsCache = this.hot.getSettings().outsideClickDeselects;
  13935. this.hot.getSettings().outsideClickDeselects = false;
  13936. },
  13937. removeZeroClipboardClass: function() {
  13938. var contextMenu = this.hot.getPlugin('contextMenu');
  13939. if (contextMenu.menu.isOpened()) {
  13940. var element = contextMenu.menu.hotMenu.rootElement.querySelector('td.zeroclipboard-is-hover');
  13941. if (element) {
  13942. removeClass(element, 'zeroclipboard-is-hover');
  13943. }
  13944. }
  13945. this.hot.getSettings().outsideClickDeselects = this.outsideClickDeselectsCache;
  13946. }
  13947. }, {}, BasePlugin);
  13948. ;
  13949. registerPlugin('contextMenuCopyPaste', ContextMenuCopyPaste);
  13950. //#
  13951. },{"_base":58,"eventManager":41,"helpers/array":42,"helpers/dom/element":45,"plugins":57,"zeroclipboard":"zeroclipboard"}],73:[function(require,module,exports){
  13952. "use strict";
  13953. Object.defineProperties(exports, {
  13954. CopyPastePlugin: {get: function() {
  13955. return CopyPastePlugin;
  13956. }},
  13957. __esModule: {value: true}
  13958. });
  13959. var $__copyPaste__,
  13960. $__SheetClip__,
  13961. $___46__46__47__46__46__47_helpers_47_unicode__,
  13962. $___46__46__47__46__46__47_helpers_47_array__,
  13963. $___46__46__47__46__46__47_helpers_47_number__,
  13964. $___46__46__47__46__46__47_helpers_47_dom_47_event__,
  13965. $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  13966. $___46__46__47__46__46__47_helpers_47_function__,
  13967. $___46__46__47__46__46__47_plugins__,
  13968. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__,
  13969. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__;
  13970. var copyPaste = ($__copyPaste__ = require("copyPaste"), $__copyPaste__ && $__copyPaste__.__esModule && $__copyPaste__ || {default: $__copyPaste__}).default;
  13971. var SheetClip = ($__SheetClip__ = require("SheetClip"), $__SheetClip__ && $__SheetClip__.__esModule && $__SheetClip__ || {default: $__SheetClip__}).default;
  13972. var $__2 = ($___46__46__47__46__46__47_helpers_47_unicode__ = require("helpers/unicode"), $___46__46__47__46__46__47_helpers_47_unicode__ && $___46__46__47__46__46__47_helpers_47_unicode__.__esModule && $___46__46__47__46__46__47_helpers_47_unicode__ || {default: $___46__46__47__46__46__47_helpers_47_unicode__}),
  13973. KEY_CODES = $__2.KEY_CODES,
  13974. isCtrlKey = $__2.isCtrlKey;
  13975. var arrayEach = ($___46__46__47__46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47__46__46__47_helpers_47_array__ && $___46__46__47__46__46__47_helpers_47_array__.__esModule && $___46__46__47__46__46__47_helpers_47_array__ || {default: $___46__46__47__46__46__47_helpers_47_array__}).arrayEach;
  13976. var rangeEach = ($___46__46__47__46__46__47_helpers_47_number__ = require("helpers/number"), $___46__46__47__46__46__47_helpers_47_number__ && $___46__46__47__46__46__47_helpers_47_number__.__esModule && $___46__46__47__46__46__47_helpers_47_number__ || {default: $___46__46__47__46__46__47_helpers_47_number__}).rangeEach;
  13977. var $__5 = ($___46__46__47__46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47__46__46__47_helpers_47_dom_47_event__ && $___46__46__47__46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_event__}),
  13978. stopImmediatePropagation = $__5.stopImmediatePropagation,
  13979. isImmediatePropagationStopped = $__5.isImmediatePropagationStopped;
  13980. var getSelectionText = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}).getSelectionText;
  13981. var proxy = ($___46__46__47__46__46__47_helpers_47_function__ = require("helpers/function"), $___46__46__47__46__46__47_helpers_47_function__ && $___46__46__47__46__46__47_helpers_47_function__.__esModule && $___46__46__47__46__46__47_helpers_47_function__ || {default: $___46__46__47__46__46__47_helpers_47_function__}).proxy;
  13982. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  13983. var WalkontableCellCoords = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ = require("3rdparty/walkontable/src/cell/coords"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__}).WalkontableCellCoords;
  13984. var WalkontableCellRange = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__ = require("3rdparty/walkontable/src/cell/range"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__}).WalkontableCellRange;
  13985. function CopyPastePlugin(instance) {
  13986. var _this = this;
  13987. this.copyPasteInstance = copyPaste();
  13988. this.copyPasteInstance.onCut(onCut);
  13989. this.copyPasteInstance.onPaste(onPaste);
  13990. this.onPaste = onPaste;
  13991. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  13992. function onCut() {
  13993. if (!instance.isListening()) {
  13994. return;
  13995. }
  13996. instance.selection.empty();
  13997. }
  13998. function onPaste(str) {
  13999. var input,
  14000. inputArray,
  14001. selected,
  14002. coordsFrom,
  14003. coordsTo,
  14004. cellRange,
  14005. topLeftCorner,
  14006. bottomRightCorner,
  14007. areaStart,
  14008. areaEnd;
  14009. if (!instance.isListening() || !instance.selection.isSelected()) {
  14010. return;
  14011. }
  14012. input = str;
  14013. inputArray = SheetClip.parse(input);
  14014. selected = instance.getSelected();
  14015. coordsFrom = new WalkontableCellCoords(selected[0], selected[1]);
  14016. coordsTo = new WalkontableCellCoords(selected[2], selected[3]);
  14017. cellRange = new WalkontableCellRange(coordsFrom, coordsFrom, coordsTo);
  14018. topLeftCorner = cellRange.getTopLeftCorner();
  14019. bottomRightCorner = cellRange.getBottomRightCorner();
  14020. areaStart = topLeftCorner;
  14021. areaEnd = new WalkontableCellCoords(Math.max(bottomRightCorner.row, inputArray.length - 1 + topLeftCorner.row), Math.max(bottomRightCorner.col, inputArray[0].length - 1 + topLeftCorner.col));
  14022. var isSelRowAreaCoverInputValue = coordsTo.row - coordsFrom.row >= inputArray.length - 1;
  14023. var isSelColAreaCoverInputValue = coordsTo.col - coordsFrom.col >= inputArray[0].length - 1;
  14024. instance.addHookOnce('afterChange', (function(changes, source) {
  14025. var changesLength = changes ? changes.length : 0;
  14026. if (changesLength) {
  14027. var offset = {
  14028. row: 0,
  14029. col: 0
  14030. };
  14031. var highestColumnIndex = -1;
  14032. arrayEach(changes, (function(change, index) {
  14033. var nextChange = changesLength > index + 1 ? changes[index + 1] : null;
  14034. if (nextChange) {
  14035. if (!isSelRowAreaCoverInputValue) {
  14036. offset.row = offset.row + Math.max(nextChange[0] - change[0] - 1, 0);
  14037. }
  14038. if (!isSelColAreaCoverInputValue && change[1] > highestColumnIndex) {
  14039. highestColumnIndex = change[1];
  14040. offset.col = offset.col + Math.max(nextChange[1] - change[1] - 1, 0);
  14041. }
  14042. }
  14043. }));
  14044. instance.selectCell(areaStart.row, areaStart.col, areaEnd.row + offset.row, areaEnd.col + offset.col);
  14045. }
  14046. }));
  14047. instance.populateFromArray(areaStart.row, areaStart.col, inputArray, areaEnd.row, areaEnd.col, 'paste', instance.getSettings().pasteMode);
  14048. }
  14049. function onBeforeKeyDown(event) {
  14050. if (!instance.getSelected()) {
  14051. return;
  14052. }
  14053. if (instance.getActiveEditor() && instance.getActiveEditor().isOpened()) {
  14054. return;
  14055. }
  14056. if (isImmediatePropagationStopped(event)) {
  14057. return;
  14058. }
  14059. if (isCtrlKey(event.keyCode)) {
  14060. if (instance.getSettings().fragmentSelection && getSelectionText()) {
  14061. return;
  14062. }
  14063. _this.setCopyableText();
  14064. stopImmediatePropagation(event);
  14065. return;
  14066. }
  14067. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  14068. if (event.keyCode == KEY_CODES.A && ctrlDown) {
  14069. instance._registerTimeout(setTimeout(proxy(_this.setCopyableText, _this), 0));
  14070. }
  14071. }
  14072. this.destroy = function() {
  14073. if (this.copyPasteInstance) {
  14074. this.copyPasteInstance.removeCallback(onCut);
  14075. this.copyPasteInstance.removeCallback(onPaste);
  14076. this.copyPasteInstance.destroy();
  14077. this.copyPasteInstance = null;
  14078. }
  14079. instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  14080. };
  14081. instance.addHook('afterDestroy', proxy(this.destroy, this));
  14082. this.triggerPaste = proxy(this.copyPasteInstance.triggerPaste, this.copyPasteInstance);
  14083. this.triggerCut = proxy(this.copyPasteInstance.triggerCut, this.copyPasteInstance);
  14084. this.setCopyableText = function() {
  14085. var settings = instance.getSettings();
  14086. var copyRowsLimit = settings.copyRowsLimit;
  14087. var copyColsLimit = settings.copyColsLimit;
  14088. var selRange = instance.getSelectedRange();
  14089. var topLeft = selRange.getTopLeftCorner();
  14090. var bottomRight = selRange.getBottomRightCorner();
  14091. var startRow = topLeft.row;
  14092. var startCol = topLeft.col;
  14093. var endRow = bottomRight.row;
  14094. var endCol = bottomRight.col;
  14095. var finalEndRow = Math.min(endRow, startRow + copyRowsLimit - 1);
  14096. var finalEndCol = Math.min(endCol, startCol + copyColsLimit - 1);
  14097. var copyableRanges = [];
  14098. copyableRanges.push({
  14099. startRow: startRow,
  14100. startCol: startCol,
  14101. endRow: finalEndRow,
  14102. endCol: finalEndCol
  14103. });
  14104. copyableRanges = Handsontable.hooks.run(instance, 'modifyCopyableRange', copyableRanges);
  14105. var copyableData = this.getRangedCopyableData(copyableRanges);
  14106. instance.copyPaste.copyPasteInstance.copyable(copyableData);
  14107. if (endRow !== finalEndRow || endCol !== finalEndCol) {
  14108. Handsontable.hooks.run(instance, 'afterCopyLimit', endRow - startRow + 1, endCol - startCol + 1, copyRowsLimit, copyColsLimit);
  14109. }
  14110. };
  14111. this.getRangedCopyableData = function(ranges) {
  14112. var dataSet = [];
  14113. var copyableRows = [];
  14114. var copyableColumns = [];
  14115. arrayEach(ranges, (function(range) {
  14116. rangeEach(range.startRow, range.endRow, (function(row) {
  14117. if (copyableRows.indexOf(row) === -1) {
  14118. copyableRows.push(row);
  14119. }
  14120. }));
  14121. rangeEach(range.startCol, range.endCol, (function(column) {
  14122. if (copyableColumns.indexOf(column) === -1) {
  14123. copyableColumns.push(column);
  14124. }
  14125. }));
  14126. }));
  14127. arrayEach(copyableRows, (function(row) {
  14128. var rowSet = [];
  14129. arrayEach(copyableColumns, (function(column) {
  14130. rowSet.push(instance.getCopyableData(row, column));
  14131. }));
  14132. dataSet.push(rowSet);
  14133. }));
  14134. return SheetClip.stringify(dataSet);
  14135. };
  14136. }
  14137. function init() {
  14138. var instance = this,
  14139. pluginEnabled = instance.getSettings().copyPaste !== false;
  14140. if (pluginEnabled && !instance.copyPaste) {
  14141. instance.copyPaste = new CopyPastePlugin(instance);
  14142. } else if (!pluginEnabled && instance.copyPaste) {
  14143. instance.copyPaste.destroy();
  14144. instance.copyPaste = null;
  14145. }
  14146. }
  14147. Handsontable.hooks.add('afterInit', init);
  14148. Handsontable.hooks.add('afterUpdateSettings', init);
  14149. Handsontable.hooks.register('afterCopyLimit');
  14150. Handsontable.hooks.register('modifyCopyableRange');
  14151. ;
  14152. //#
  14153. },{"3rdparty/walkontable/src/cell/coords":5,"3rdparty/walkontable/src/cell/range":6,"SheetClip":"SheetClip","copyPaste":"copyPaste","helpers/array":42,"helpers/dom/element":45,"helpers/dom/event":46,"helpers/function":47,"helpers/number":49,"helpers/unicode":53,"plugins":57}],74:[function(require,module,exports){
  14154. "use strict";
  14155. var $___46__46__47__46__46__47_plugins__,
  14156. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__,
  14157. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection__;
  14158. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  14159. var WalkontableCellRange = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__ = require("3rdparty/walkontable/src/cell/range"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__}).WalkontableCellRange;
  14160. var WalkontableSelection = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection__ = require("3rdparty/walkontable/src/selection"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection__}).WalkontableSelection;
  14161. function CustomBorders() {}
  14162. var instance;
  14163. var checkEnable = function(customBorders) {
  14164. if (typeof customBorders === 'boolean') {
  14165. if (customBorders === true) {
  14166. return true;
  14167. }
  14168. }
  14169. if (typeof customBorders === 'object') {
  14170. if (customBorders.length > 0) {
  14171. return true;
  14172. }
  14173. }
  14174. return false;
  14175. };
  14176. var init = function() {
  14177. if (checkEnable(this.getSettings().customBorders)) {
  14178. if (!this.customBorders) {
  14179. instance = this;
  14180. this.customBorders = new CustomBorders();
  14181. }
  14182. }
  14183. };
  14184. var getSettingIndex = function(className) {
  14185. for (var i = 0; i < instance.view.wt.selections.length; i++) {
  14186. if (instance.view.wt.selections[i].settings.className == className) {
  14187. return i;
  14188. }
  14189. }
  14190. return -1;
  14191. };
  14192. var insertBorderIntoSettings = function(border) {
  14193. var coordinates = {
  14194. row: border.row,
  14195. col: border.col
  14196. };
  14197. var selection = new WalkontableSelection(border, new WalkontableCellRange(coordinates, coordinates, coordinates));
  14198. var index = getSettingIndex(border.className);
  14199. if (index >= 0) {
  14200. instance.view.wt.selections[index] = selection;
  14201. } else {
  14202. instance.view.wt.selections.push(selection);
  14203. }
  14204. };
  14205. var prepareBorderFromCustomAdded = function(row, col, borderObj) {
  14206. var border = createEmptyBorders(row, col);
  14207. border = extendDefaultBorder(border, borderObj);
  14208. this.setCellMeta(row, col, 'borders', border);
  14209. insertBorderIntoSettings(border);
  14210. };
  14211. var prepareBorderFromCustomAddedRange = function(rowObj) {
  14212. var range = rowObj.range;
  14213. for (var row = range.from.row; row <= range.to.row; row++) {
  14214. for (var col = range.from.col; col <= range.to.col; col++) {
  14215. var border = createEmptyBorders(row, col);
  14216. var add = 0;
  14217. if (row == range.from.row) {
  14218. add++;
  14219. if (rowObj.hasOwnProperty('top')) {
  14220. border.top = rowObj.top;
  14221. }
  14222. }
  14223. if (row == range.to.row) {
  14224. add++;
  14225. if (rowObj.hasOwnProperty('bottom')) {
  14226. border.bottom = rowObj.bottom;
  14227. }
  14228. }
  14229. if (col == range.from.col) {
  14230. add++;
  14231. if (rowObj.hasOwnProperty('left')) {
  14232. border.left = rowObj.left;
  14233. }
  14234. }
  14235. if (col == range.to.col) {
  14236. add++;
  14237. if (rowObj.hasOwnProperty('right')) {
  14238. border.right = rowObj.right;
  14239. }
  14240. }
  14241. if (add > 0) {
  14242. this.setCellMeta(row, col, 'borders', border);
  14243. insertBorderIntoSettings(border);
  14244. }
  14245. }
  14246. }
  14247. };
  14248. var createClassName = function(row, col) {
  14249. return 'border_row' + row + 'col' + col;
  14250. };
  14251. var createDefaultCustomBorder = function() {
  14252. return {
  14253. width: 1,
  14254. color: '#000'
  14255. };
  14256. };
  14257. var createSingleEmptyBorder = function() {
  14258. return {hide: true};
  14259. };
  14260. var createDefaultHtBorder = function() {
  14261. return {
  14262. width: 1,
  14263. color: '#000',
  14264. cornerVisible: false
  14265. };
  14266. };
  14267. var createEmptyBorders = function(row, col) {
  14268. return {
  14269. className: createClassName(row, col),
  14270. border: createDefaultHtBorder(),
  14271. row: row,
  14272. col: col,
  14273. top: createSingleEmptyBorder(),
  14274. right: createSingleEmptyBorder(),
  14275. bottom: createSingleEmptyBorder(),
  14276. left: createSingleEmptyBorder()
  14277. };
  14278. };
  14279. var extendDefaultBorder = function(defaultBorder, customBorder) {
  14280. if (customBorder.hasOwnProperty('border')) {
  14281. defaultBorder.border = customBorder.border;
  14282. }
  14283. if (customBorder.hasOwnProperty('top')) {
  14284. defaultBorder.top = customBorder.top;
  14285. }
  14286. if (customBorder.hasOwnProperty('right')) {
  14287. defaultBorder.right = customBorder.right;
  14288. }
  14289. if (customBorder.hasOwnProperty('bottom')) {
  14290. defaultBorder.bottom = customBorder.bottom;
  14291. }
  14292. if (customBorder.hasOwnProperty('left')) {
  14293. defaultBorder.left = customBorder.left;
  14294. }
  14295. return defaultBorder;
  14296. };
  14297. var removeBordersFromDom = function(borderClassName) {
  14298. var borders = document.querySelectorAll('.' + borderClassName);
  14299. for (var i = 0; i < borders.length; i++) {
  14300. if (borders[i]) {
  14301. if (borders[i].nodeName != 'TD') {
  14302. var parent = borders[i].parentNode;
  14303. if (parent.parentNode) {
  14304. parent.parentNode.removeChild(parent);
  14305. }
  14306. }
  14307. }
  14308. }
  14309. };
  14310. var removeAllBorders = function(row, col) {
  14311. var borderClassName = createClassName(row, col);
  14312. removeBordersFromDom(borderClassName);
  14313. this.removeCellMeta(row, col, 'borders');
  14314. };
  14315. var setBorder = function(row, col, place, remove) {
  14316. var bordersMeta = this.getCellMeta(row, col).borders;
  14317. if (!bordersMeta || bordersMeta.border == undefined) {
  14318. bordersMeta = createEmptyBorders(row, col);
  14319. }
  14320. if (remove) {
  14321. bordersMeta[place] = createSingleEmptyBorder();
  14322. } else {
  14323. bordersMeta[place] = createDefaultCustomBorder();
  14324. }
  14325. this.setCellMeta(row, col, 'borders', bordersMeta);
  14326. var borderClassName = createClassName(row, col);
  14327. removeBordersFromDom(borderClassName);
  14328. insertBorderIntoSettings(bordersMeta);
  14329. this.render();
  14330. };
  14331. var prepareBorder = function(range, place, remove) {
  14332. if (range.from.row == range.to.row && range.from.col == range.to.col) {
  14333. if (place == 'noBorders') {
  14334. removeAllBorders.call(this, range.from.row, range.from.col);
  14335. } else {
  14336. setBorder.call(this, range.from.row, range.from.col, place, remove);
  14337. }
  14338. } else {
  14339. switch (place) {
  14340. case 'noBorders':
  14341. for (var column = range.from.col; column <= range.to.col; column++) {
  14342. for (var row = range.from.row; row <= range.to.row; row++) {
  14343. removeAllBorders.call(this, row, column);
  14344. }
  14345. }
  14346. break;
  14347. case 'top':
  14348. for (var topCol = range.from.col; topCol <= range.to.col; topCol++) {
  14349. setBorder.call(this, range.from.row, topCol, place, remove);
  14350. }
  14351. break;
  14352. case 'right':
  14353. for (var rowRight = range.from.row; rowRight <= range.to.row; rowRight++) {
  14354. setBorder.call(this, rowRight, range.to.col, place);
  14355. }
  14356. break;
  14357. case 'bottom':
  14358. for (var bottomCol = range.from.col; bottomCol <= range.to.col; bottomCol++) {
  14359. setBorder.call(this, range.to.row, bottomCol, place);
  14360. }
  14361. break;
  14362. case 'left':
  14363. for (var rowLeft = range.from.row; rowLeft <= range.to.row; rowLeft++) {
  14364. setBorder.call(this, rowLeft, range.from.col, place);
  14365. }
  14366. break;
  14367. }
  14368. }
  14369. };
  14370. var checkSelectionBorders = function(hot, direction) {
  14371. var atLeastOneHasBorder = false;
  14372. hot.getSelectedRange().forAll(function(r, c) {
  14373. var metaBorders = hot.getCellMeta(r, c).borders;
  14374. if (metaBorders) {
  14375. if (direction) {
  14376. if (!metaBorders[direction].hasOwnProperty('hide')) {
  14377. atLeastOneHasBorder = true;
  14378. return false;
  14379. }
  14380. } else {
  14381. atLeastOneHasBorder = true;
  14382. return false;
  14383. }
  14384. }
  14385. });
  14386. return atLeastOneHasBorder;
  14387. };
  14388. var markSelected = function(label) {
  14389. return '<span class="selected">' + String.fromCharCode(10003) + '</span>' + label;
  14390. };
  14391. var addBordersOptionsToContextMenu = function(defaultOptions) {
  14392. if (!this.getSettings().customBorders) {
  14393. return;
  14394. }
  14395. defaultOptions.items.push(Handsontable.plugins.ContextMenu.SEPARATOR);
  14396. defaultOptions.items.push({
  14397. key: 'borders',
  14398. name: 'Borders',
  14399. submenu: {items: [{
  14400. key: 'borders:top',
  14401. name: function() {
  14402. var label = 'Top';
  14403. var hasBorder = checkSelectionBorders(this, 'top');
  14404. if (hasBorder) {
  14405. label = markSelected(label);
  14406. }
  14407. return label;
  14408. },
  14409. callback: function() {
  14410. var hasBorder = checkSelectionBorders(this, 'top');
  14411. prepareBorder.call(this, this.getSelectedRange(), 'top', hasBorder);
  14412. },
  14413. disabled: false
  14414. }, {
  14415. key: 'borders:right',
  14416. name: function() {
  14417. var label = 'Right';
  14418. var hasBorder = checkSelectionBorders(this, 'right');
  14419. if (hasBorder) {
  14420. label = markSelected(label);
  14421. }
  14422. return label;
  14423. },
  14424. callback: function() {
  14425. var hasBorder = checkSelectionBorders(this, 'right');
  14426. prepareBorder.call(this, this.getSelectedRange(), 'right', hasBorder);
  14427. },
  14428. disabled: false
  14429. }, {
  14430. key: 'borders:bottom',
  14431. name: function() {
  14432. var label = 'Bottom';
  14433. var hasBorder = checkSelectionBorders(this, 'bottom');
  14434. if (hasBorder) {
  14435. label = markSelected(label);
  14436. }
  14437. return label;
  14438. },
  14439. callback: function() {
  14440. var hasBorder = checkSelectionBorders(this, 'bottom');
  14441. prepareBorder.call(this, this.getSelectedRange(), 'bottom', hasBorder);
  14442. },
  14443. disabled: false
  14444. }, {
  14445. key: 'borders:left',
  14446. name: function() {
  14447. var label = 'Left';
  14448. var hasBorder = checkSelectionBorders(this, 'left');
  14449. if (hasBorder) {
  14450. label = markSelected(label);
  14451. }
  14452. return label;
  14453. },
  14454. callback: function() {
  14455. var hasBorder = checkSelectionBorders(this, 'left');
  14456. prepareBorder.call(this, this.getSelectedRange(), 'left', hasBorder);
  14457. },
  14458. disabled: false
  14459. }, {
  14460. key: 'borders:no_borders',
  14461. name: 'Remove border(s)',
  14462. callback: function() {
  14463. prepareBorder.call(this, this.getSelectedRange(), 'noBorders');
  14464. },
  14465. disabled: function() {
  14466. return !checkSelectionBorders(this);
  14467. }
  14468. }]}
  14469. });
  14470. };
  14471. Handsontable.hooks.add('beforeInit', init);
  14472. Handsontable.hooks.add('afterContextMenuDefaultOptions', addBordersOptionsToContextMenu);
  14473. Handsontable.hooks.add('afterInit', function() {
  14474. var customBorders = this.getSettings().customBorders;
  14475. if (customBorders) {
  14476. for (var i = 0; i < customBorders.length; i++) {
  14477. if (customBorders[i].range) {
  14478. prepareBorderFromCustomAddedRange.call(this, customBorders[i]);
  14479. } else {
  14480. prepareBorderFromCustomAdded.call(this, customBorders[i].row, customBorders[i].col, customBorders[i]);
  14481. }
  14482. }
  14483. this.render();
  14484. this.view.wt.draw(true);
  14485. }
  14486. });
  14487. Handsontable.CustomBorders = CustomBorders;
  14488. //#
  14489. },{"3rdparty/walkontable/src/cell/range":6,"3rdparty/walkontable/src/selection":18,"plugins":57}],75:[function(require,module,exports){
  14490. "use strict";
  14491. Object.defineProperties(exports, {
  14492. DragToScroll: {get: function() {
  14493. return DragToScroll;
  14494. }},
  14495. __esModule: {value: true}
  14496. });
  14497. var $___46__46__47__46__46__47_eventManager__,
  14498. $___46__46__47__46__46__47_plugins__;
  14499. var eventManagerObject = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).eventManager;
  14500. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  14501. ;
  14502. Handsontable.plugins.DragToScroll = DragToScroll;
  14503. function DragToScroll() {
  14504. this.boundaries = null;
  14505. this.callback = null;
  14506. }
  14507. DragToScroll.prototype.setBoundaries = function(boundaries) {
  14508. this.boundaries = boundaries;
  14509. };
  14510. DragToScroll.prototype.setCallback = function(callback) {
  14511. this.callback = callback;
  14512. };
  14513. DragToScroll.prototype.check = function(x, y) {
  14514. var diffX = 0;
  14515. var diffY = 0;
  14516. if (y < this.boundaries.top) {
  14517. diffY = y - this.boundaries.top;
  14518. } else if (y > this.boundaries.bottom) {
  14519. diffY = y - this.boundaries.bottom;
  14520. }
  14521. if (x < this.boundaries.left) {
  14522. diffX = x - this.boundaries.left;
  14523. } else if (x > this.boundaries.right) {
  14524. diffX = x - this.boundaries.right;
  14525. }
  14526. this.callback(diffX, diffY);
  14527. };
  14528. var dragToScroll;
  14529. var instance;
  14530. var setupListening = function(instance) {
  14531. instance.dragToScrollListening = false;
  14532. var scrollHandler = instance.view.wt.wtTable.holder;
  14533. dragToScroll = new DragToScroll();
  14534. if (scrollHandler === window) {
  14535. return;
  14536. } else {
  14537. dragToScroll.setBoundaries(scrollHandler.getBoundingClientRect());
  14538. }
  14539. dragToScroll.setCallback(function(scrollX, scrollY) {
  14540. if (scrollX < 0) {
  14541. scrollHandler.scrollLeft -= 50;
  14542. } else if (scrollX > 0) {
  14543. scrollHandler.scrollLeft += 50;
  14544. }
  14545. if (scrollY < 0) {
  14546. scrollHandler.scrollTop -= 20;
  14547. } else if (scrollY > 0) {
  14548. scrollHandler.scrollTop += 20;
  14549. }
  14550. });
  14551. instance.dragToScrollListening = true;
  14552. };
  14553. Handsontable.hooks.add('afterInit', function() {
  14554. var instance = this;
  14555. var eventManager = eventManagerObject(this);
  14556. eventManager.addEventListener(document, 'mouseup', function() {
  14557. instance.dragToScrollListening = false;
  14558. });
  14559. eventManager.addEventListener(document, 'mousemove', function(event) {
  14560. if (instance.dragToScrollListening) {
  14561. dragToScroll.check(event.clientX, event.clientY);
  14562. }
  14563. });
  14564. });
  14565. Handsontable.hooks.add('afterDestroy', function() {
  14566. eventManagerObject(this).clear();
  14567. });
  14568. Handsontable.hooks.add('afterOnCellMouseDown', function() {
  14569. setupListening(this);
  14570. });
  14571. Handsontable.hooks.add('afterOnCellCornerMouseDown', function() {
  14572. setupListening(this);
  14573. });
  14574. Handsontable.plugins.DragToScroll = DragToScroll;
  14575. //#
  14576. },{"eventManager":41,"plugins":57}],76:[function(require,module,exports){
  14577. "use strict";
  14578. Object.defineProperties(exports, {
  14579. ManualColumnFreeze: {get: function() {
  14580. return ManualColumnFreeze;
  14581. }},
  14582. __esModule: {value: true}
  14583. });
  14584. var $___46__46__47__95_base__,
  14585. $___46__46__47__46__46__47_plugins__;
  14586. var BasePlugin = ($___46__46__47__95_base__ = require("_base"), $___46__46__47__95_base__ && $___46__46__47__95_base__.__esModule && $___46__46__47__95_base__ || {default: $___46__46__47__95_base__}).default;
  14587. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  14588. var ManualColumnFreeze = function ManualColumnFreeze(hotInstance) {
  14589. $traceurRuntime.superConstructor($ManualColumnFreeze).call(this, hotInstance);
  14590. };
  14591. var $ManualColumnFreeze = ManualColumnFreeze;
  14592. ($traceurRuntime.createClass)(ManualColumnFreeze, {
  14593. isEnabled: function() {
  14594. return !!this.hot.getSettings().manualColumnFreeze;
  14595. },
  14596. enablePlugin: function() {
  14597. var $__2 = this;
  14598. if (this.enabled) {
  14599. return;
  14600. }
  14601. this.addHook('modifyCol', (function(col) {
  14602. return $__2.onModifyCol(col);
  14603. }));
  14604. this.addHook('afterContextMenuDefaultOptions', (function(defaultOptions) {
  14605. return $__2.addContextMenuEntry(defaultOptions);
  14606. }));
  14607. $traceurRuntime.superGet(this, $ManualColumnFreeze.prototype, "enablePlugin").call(this);
  14608. },
  14609. disablePlugin: function() {
  14610. $traceurRuntime.superGet(this, $ManualColumnFreeze.prototype, "disablePlugin").call(this);
  14611. },
  14612. init: function() {
  14613. $traceurRuntime.superGet(this, $ManualColumnFreeze.prototype, "init").call(this);
  14614. if (typeof this.hot.manualColumnPositionsPluginUsages === 'undefined') {
  14615. this.hot.manualColumnPositionsPluginUsages = ['manualColumnFreeze'];
  14616. } else {
  14617. this.hot.manualColumnPositionsPluginUsages.push('manualColumnFreeze');
  14618. }
  14619. this.fixedColumnsCount = this.hot.getSettings().fixedColumnsLeft;
  14620. },
  14621. onModifyCol: function(column) {
  14622. if (this.hot.manualColumnPositionsPluginUsages.length > 1) {
  14623. return column;
  14624. }
  14625. return this.getModifiedColumnIndex(column);
  14626. },
  14627. getModifiedColumnIndex: function(column) {
  14628. return this.hot.manualColumnPositions[column];
  14629. },
  14630. addContextMenuEntry: function(defaultOptions) {
  14631. var _this = this;
  14632. defaultOptions.items.push(Handsontable.plugins.ContextMenu.SEPARATOR, {
  14633. key: 'freeze_column',
  14634. name: function() {
  14635. var selectedColumn = _this.hot.getSelected()[1];
  14636. if (selectedColumn > _this.fixedColumnsCount - 1) {
  14637. return 'Freeze this column';
  14638. } else {
  14639. return 'Unfreeze this column';
  14640. }
  14641. },
  14642. disabled: function() {
  14643. var selection = _this.hot.getSelected();
  14644. return selection[1] !== selection[3];
  14645. },
  14646. callback: function() {
  14647. var selectedColumn = _this.hot.getSelected()[1];
  14648. if (selectedColumn > _this.fixedColumnsCount - 1) {
  14649. _this.freezeColumn(selectedColumn);
  14650. } else {
  14651. _this.unfreezeColumn(selectedColumn);
  14652. }
  14653. }
  14654. });
  14655. },
  14656. freezeColumn: function(column) {
  14657. if (column <= this.fixedColumnsCount - 1) {
  14658. return;
  14659. }
  14660. var modifiedColumn = this.getModifiedColumnIndex(column) || column;
  14661. this.checkPositionData(modifiedColumn);
  14662. this.modifyColumnOrder(modifiedColumn, column, null, 'freeze');
  14663. this.addFixedColumn();
  14664. this.hot.view.wt.wtOverlays.leftOverlay.refresh();
  14665. this.hot.view.wt.wtOverlays.adjustElementsSize();
  14666. },
  14667. unfreezeColumn: function(column) {
  14668. if (column > this.fixedColumnsCount - 1) {
  14669. return;
  14670. }
  14671. var returnCol = this.getBestColumnReturnPosition(column);
  14672. var modifiedColumn = this.getModifiedColumnIndex(column) || column;
  14673. this.checkPositionData(modifiedColumn);
  14674. this.modifyColumnOrder(modifiedColumn, column, returnCol, 'unfreeze');
  14675. this.removeFixedColumn();
  14676. this.hot.view.wt.wtOverlays.leftOverlay.refresh();
  14677. this.hot.view.wt.wtOverlays.adjustElementsSize();
  14678. },
  14679. addFixedColumn: function() {
  14680. this.hot.updateSettings({fixedColumnsLeft: this.fixedColumnsCount + 1});
  14681. this.fixedColumnsCount++;
  14682. },
  14683. removeFixedColumn: function() {
  14684. this.hot.updateSettings({fixedColumnsLeft: this.fixedColumnsCount - 1});
  14685. this.fixedColumnsCount--;
  14686. },
  14687. checkPositionData: function(column) {
  14688. if (!this.hot.manualColumnPositions || this.hot.manualColumnPositions.length === 0) {
  14689. if (!this.hot.manualColumnPositions) {
  14690. this.hot.manualColumnPositions = [];
  14691. }
  14692. }
  14693. if (column) {
  14694. if (!this.hot.manualColumnPositions[column]) {
  14695. this.createPositionData(column + 1);
  14696. }
  14697. } else {
  14698. this.createPositionData(this.hot.countCols());
  14699. }
  14700. },
  14701. createPositionData: function(length) {
  14702. if (this.hot.manualColumnPositions.length < length) {
  14703. for (var i = this.hot.manualColumnPositions.length; i < length; i++) {
  14704. this.hot.manualColumnPositions[i] = i;
  14705. }
  14706. }
  14707. },
  14708. modifyColumnOrder: function(column, actualColumn, returnColumn, action) {
  14709. if (returnColumn == null) {
  14710. returnColumn = column;
  14711. }
  14712. if (action === 'freeze') {
  14713. this.hot.manualColumnPositions.splice(this.fixedColumnsCount, 0, this.hot.manualColumnPositions.splice(actualColumn, 1)[0]);
  14714. } else if (action === 'unfreeze') {
  14715. this.hot.manualColumnPositions.splice(returnColumn, 0, this.hot.manualColumnPositions.splice(actualColumn, 1)[0]);
  14716. }
  14717. },
  14718. getBestColumnReturnPosition: function(column) {
  14719. var i = this.fixedColumnsCount;
  14720. var j = this.getModifiedColumnIndex(i);
  14721. var initialCol = this.getModifiedColumnIndex(column);
  14722. while (j < initialCol) {
  14723. i++;
  14724. j = this.getModifiedColumnIndex(i);
  14725. }
  14726. return i - 1;
  14727. }
  14728. }, {}, BasePlugin);
  14729. ;
  14730. registerPlugin('manualColumnFreeze', ManualColumnFreeze);
  14731. //#
  14732. },{"_base":58,"plugins":57}],77:[function(require,module,exports){
  14733. "use strict";
  14734. Object.defineProperties(exports, {
  14735. ManualColumnMove: {get: function() {
  14736. return ManualColumnMove;
  14737. }},
  14738. __esModule: {value: true}
  14739. });
  14740. var $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  14741. $___46__46__47__46__46__47_eventManager__,
  14742. $___46__46__47__46__46__47_helpers_47_dom_47_event__,
  14743. $___46__46__47__46__46__47_plugins__;
  14744. var $__0 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  14745. addClass = $__0.addClass,
  14746. hasClass = $__0.hasClass,
  14747. removeClass = $__0.removeClass;
  14748. var eventManagerObject = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).eventManager;
  14749. var $__2 = ($___46__46__47__46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47__46__46__47_helpers_47_dom_47_event__ && $___46__46__47__46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_event__}),
  14750. pageX = $__2.pageX,
  14751. pageY = $__2.pageY;
  14752. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  14753. ;
  14754. function ManualColumnMove() {
  14755. var startCol,
  14756. endCol,
  14757. startX,
  14758. startOffset,
  14759. currentCol,
  14760. instance,
  14761. currentTH,
  14762. handle = document.createElement('DIV'),
  14763. guide = document.createElement('DIV'),
  14764. eventManager = eventManagerObject(this);
  14765. handle.className = 'manualColumnMover';
  14766. guide.className = 'manualColumnMoverGuide';
  14767. var saveManualColumnPositions = function() {
  14768. var instance = this;
  14769. Handsontable.hooks.run(instance, 'persistentStateSave', 'manualColumnPositions', instance.manualColumnPositions);
  14770. };
  14771. var loadManualColumnPositions = function() {
  14772. var instance = this;
  14773. var storedState = {};
  14774. Handsontable.hooks.run(instance, 'persistentStateLoad', 'manualColumnPositions', storedState);
  14775. return storedState.value;
  14776. };
  14777. function setupHandlePosition(TH) {
  14778. instance = this;
  14779. currentTH = TH;
  14780. var col = this.view.wt.wtTable.getCoords(TH).col;
  14781. if (col >= 0) {
  14782. currentCol = col;
  14783. var box = currentTH.getBoundingClientRect();
  14784. startOffset = box.left;
  14785. handle.style.top = box.top + 'px';
  14786. handle.style.left = startOffset + 'px';
  14787. instance.rootElement.appendChild(handle);
  14788. }
  14789. }
  14790. function refreshHandlePosition(TH, delta) {
  14791. var box = TH.getBoundingClientRect();
  14792. var handleWidth = 6;
  14793. if (delta > 0) {
  14794. handle.style.left = (box.left + box.width - handleWidth) + 'px';
  14795. } else {
  14796. handle.style.left = box.left + 'px';
  14797. }
  14798. }
  14799. function setupGuidePosition() {
  14800. var instance = this;
  14801. addClass(handle, 'active');
  14802. addClass(guide, 'active');
  14803. var box = currentTH.getBoundingClientRect();
  14804. guide.style.width = box.width + 'px';
  14805. guide.style.height = instance.view.maximumVisibleElementHeight(0) + 'px';
  14806. guide.style.top = handle.style.top;
  14807. guide.style.left = startOffset + 'px';
  14808. instance.rootElement.appendChild(guide);
  14809. }
  14810. function refreshGuidePosition(diff) {
  14811. guide.style.left = startOffset + diff + 'px';
  14812. }
  14813. function hideHandleAndGuide() {
  14814. removeClass(handle, 'active');
  14815. removeClass(guide, 'active');
  14816. }
  14817. var checkColumnHeader = function(element) {
  14818. if (element.tagName != 'BODY') {
  14819. if (element.parentNode.tagName == 'THEAD') {
  14820. return true;
  14821. } else {
  14822. element = element.parentNode;
  14823. return checkColumnHeader(element);
  14824. }
  14825. }
  14826. return false;
  14827. };
  14828. var getTHFromTargetElement = function(element) {
  14829. if (element.tagName != 'TABLE') {
  14830. if (element.tagName == 'TH') {
  14831. return element;
  14832. } else {
  14833. return getTHFromTargetElement(element.parentNode);
  14834. }
  14835. }
  14836. return null;
  14837. };
  14838. var bindEvents = function() {
  14839. var instance = this;
  14840. var pressed;
  14841. eventManager.addEventListener(instance.rootElement, 'mouseover', function(e) {
  14842. if (checkColumnHeader(e.target)) {
  14843. var th = getTHFromTargetElement(e.target);
  14844. if (th) {
  14845. if (pressed) {
  14846. var col = instance.view.wt.wtTable.getCoords(th).col;
  14847. if (col >= 0) {
  14848. endCol = col;
  14849. refreshHandlePosition(e.target, endCol - startCol);
  14850. }
  14851. } else {
  14852. setupHandlePosition.call(instance, th);
  14853. }
  14854. }
  14855. }
  14856. });
  14857. eventManager.addEventListener(instance.rootElement, 'mousedown', function(e) {
  14858. if (hasClass(e.target, 'manualColumnMover')) {
  14859. startX = pageX(e);
  14860. setupGuidePosition.call(instance);
  14861. pressed = instance;
  14862. startCol = currentCol;
  14863. endCol = currentCol;
  14864. }
  14865. });
  14866. eventManager.addEventListener(window, 'mousemove', function(e) {
  14867. if (pressed) {
  14868. refreshGuidePosition(pageX(e) - startX);
  14869. }
  14870. });
  14871. eventManager.addEventListener(window, 'mouseup', function(e) {
  14872. if (pressed) {
  14873. hideHandleAndGuide();
  14874. pressed = false;
  14875. createPositionData(instance.manualColumnPositions, instance.countCols());
  14876. instance.manualColumnPositions.splice(endCol, 0, instance.manualColumnPositions.splice(startCol, 1)[0]);
  14877. Handsontable.hooks.run(instance, 'beforeColumnMove', startCol, endCol);
  14878. instance.forceFullRender = true;
  14879. instance.view.render();
  14880. saveManualColumnPositions.call(instance);
  14881. Handsontable.hooks.run(instance, 'afterColumnMove', startCol, endCol);
  14882. setupHandlePosition.call(instance, currentTH);
  14883. }
  14884. });
  14885. instance.addHook('afterDestroy', unbindEvents);
  14886. };
  14887. var unbindEvents = function() {
  14888. eventManager.clear();
  14889. };
  14890. var createPositionData = function(positionArr, len) {
  14891. if (positionArr.length < len) {
  14892. for (var i = positionArr.length; i < len; i++) {
  14893. positionArr[i] = i;
  14894. }
  14895. }
  14896. };
  14897. this.beforeInit = function() {
  14898. this.manualColumnPositions = [];
  14899. };
  14900. this.init = function(source) {
  14901. var instance = this;
  14902. var manualColMoveEnabled = !!(this.getSettings().manualColumnMove);
  14903. if (manualColMoveEnabled) {
  14904. var initialManualColumnPositions = this.getSettings().manualColumnMove;
  14905. var loadedManualColumnPositions = loadManualColumnPositions.call(instance);
  14906. if (typeof loadedManualColumnPositions != 'undefined') {
  14907. this.manualColumnPositions = loadedManualColumnPositions;
  14908. } else if (Array.isArray(initialManualColumnPositions)) {
  14909. this.manualColumnPositions = initialManualColumnPositions;
  14910. } else {
  14911. this.manualColumnPositions = [];
  14912. }
  14913. if (source === 'afterInit' || source === 'afterUpdateSettings' && eventManager.context.eventListeners.length === 0) {
  14914. if (typeof instance.manualColumnPositionsPluginUsages === 'undefined') {
  14915. instance.manualColumnPositionsPluginUsages = ['manualColumnMove'];
  14916. } else {
  14917. instance.manualColumnPositionsPluginUsages.push('manualColumnMove');
  14918. }
  14919. bindEvents.call(this);
  14920. if (this.manualColumnPositions.length > 0) {
  14921. this.forceFullRender = true;
  14922. this.render();
  14923. }
  14924. }
  14925. } else {
  14926. var pluginUsagesIndex = instance.manualColumnPositionsPluginUsages ? instance.manualColumnPositionsPluginUsages.indexOf('manualColumnMove') : -1;
  14927. if (pluginUsagesIndex > -1) {
  14928. unbindEvents.call(this);
  14929. this.manualColumnPositions = [];
  14930. instance.manualColumnPositionsPluginUsages[pluginUsagesIndex] = void 0;
  14931. }
  14932. }
  14933. };
  14934. this.modifyCol = function(col) {
  14935. if (this.getSettings().manualColumnMove) {
  14936. if (typeof this.manualColumnPositions[col] === 'undefined') {
  14937. createPositionData(this.manualColumnPositions, col + 1);
  14938. }
  14939. return this.manualColumnPositions[col];
  14940. }
  14941. return col;
  14942. };
  14943. this.afterRemoveCol = function(index, amount) {
  14944. if (!this.getSettings().manualColumnMove) {
  14945. return;
  14946. }
  14947. var rmindx,
  14948. colpos = this.manualColumnPositions;
  14949. rmindx = colpos.splice(index, amount);
  14950. colpos = colpos.map(function(colpos) {
  14951. var i,
  14952. newpos = colpos;
  14953. for (i = 0; i < rmindx.length; i++) {
  14954. if (colpos > rmindx[i]) {
  14955. newpos--;
  14956. }
  14957. }
  14958. return newpos;
  14959. });
  14960. this.manualColumnPositions = colpos;
  14961. };
  14962. this.afterCreateCol = function(index, amount) {
  14963. if (!this.getSettings().manualColumnMove) {
  14964. return;
  14965. }
  14966. var colpos = this.manualColumnPositions;
  14967. if (!colpos.length) {
  14968. return;
  14969. }
  14970. var addindx = [];
  14971. for (var i = 0; i < amount; i++) {
  14972. addindx.push(index + i);
  14973. }
  14974. if (index >= colpos.length) {
  14975. colpos.concat(addindx);
  14976. } else {
  14977. colpos = colpos.map(function(colpos) {
  14978. return (colpos >= index) ? (colpos + amount) : colpos;
  14979. });
  14980. colpos.splice.apply(colpos, [index, 0].concat(addindx));
  14981. }
  14982. this.manualColumnPositions = colpos;
  14983. };
  14984. }
  14985. var htManualColumnMove = new ManualColumnMove();
  14986. Handsontable.hooks.add('beforeInit', htManualColumnMove.beforeInit);
  14987. Handsontable.hooks.add('afterInit', function() {
  14988. htManualColumnMove.init.call(this, 'afterInit');
  14989. });
  14990. Handsontable.hooks.add('afterUpdateSettings', function() {
  14991. htManualColumnMove.init.call(this, 'afterUpdateSettings');
  14992. });
  14993. Handsontable.hooks.add('modifyCol', htManualColumnMove.modifyCol);
  14994. Handsontable.hooks.add('afterRemoveCol', htManualColumnMove.afterRemoveCol);
  14995. Handsontable.hooks.add('afterCreateCol', htManualColumnMove.afterCreateCol);
  14996. Handsontable.hooks.register('beforeColumnMove');
  14997. Handsontable.hooks.register('afterColumnMove');
  14998. //#
  14999. },{"eventManager":41,"helpers/dom/element":45,"helpers/dom/event":46,"plugins":57}],78:[function(require,module,exports){
  15000. "use strict";
  15001. Object.defineProperties(exports, {
  15002. ManualColumnResize: {get: function() {
  15003. return ManualColumnResize;
  15004. }},
  15005. __esModule: {value: true}
  15006. });
  15007. var $___46__46__47__95_base_46_js__,
  15008. $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  15009. $___46__46__47__46__46__47_eventManager__,
  15010. $___46__46__47__46__46__47_helpers_47_dom_47_event__,
  15011. $___46__46__47__46__46__47_plugins__;
  15012. var BasePlugin = ($___46__46__47__95_base_46_js__ = require("_base.js"), $___46__46__47__95_base_46_js__ && $___46__46__47__95_base_46_js__.__esModule && $___46__46__47__95_base_46_js__ || {default: $___46__46__47__95_base_46_js__}).default;
  15013. var $__1 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  15014. addClass = $__1.addClass,
  15015. hasClass = $__1.hasClass,
  15016. removeClass = $__1.removeClass;
  15017. var eventManagerObject = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).eventManager;
  15018. var $__3 = ($___46__46__47__46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47__46__46__47_helpers_47_dom_47_event__ && $___46__46__47__46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_event__}),
  15019. pageX = $__3.pageX,
  15020. pageY = $__3.pageY;
  15021. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  15022. var ManualColumnResize = function ManualColumnResize(hotInstance) {
  15023. $traceurRuntime.superConstructor($ManualColumnResize).call(this, hotInstance);
  15024. this.currentTH = null;
  15025. this.currentCol = null;
  15026. this.currentWidth = null;
  15027. this.newSize = null;
  15028. this.startY = null;
  15029. this.startWidth = null;
  15030. this.startOffset = null;
  15031. this.handle = document.createElement('DIV');
  15032. this.guide = document.createElement('DIV');
  15033. this.eventManager = eventManagerObject(this);
  15034. this.pressed = null;
  15035. this.dblclick = 0;
  15036. this.autoresizeTimeout = null;
  15037. this.manualColumnWidths = [];
  15038. addClass(this.handle, 'manualColumnResizer');
  15039. addClass(this.guide, 'manualColumnResizerGuide');
  15040. };
  15041. var $ManualColumnResize = ManualColumnResize;
  15042. ($traceurRuntime.createClass)(ManualColumnResize, {
  15043. isEnabled: function() {
  15044. return this.hot.getSettings().manualColumnResize;
  15045. },
  15046. enablePlugin: function() {
  15047. var $__5 = this;
  15048. if (this.enabled) {
  15049. return;
  15050. }
  15051. this.manualColumnWidths = [];
  15052. var initialColumnWidth = this.hot.getSettings().manualColumnResize;
  15053. var loadedManualColumnWidths = this.loadManualColumnWidths();
  15054. this.addHook('modifyColWidth', (function(width, col) {
  15055. return $__5.onModifyColWidth(width, col);
  15056. }));
  15057. if (typeof loadedManualColumnWidths != 'undefined') {
  15058. this.manualColumnWidths = loadedManualColumnWidths;
  15059. } else if (Array.isArray(initialColumnWidth)) {
  15060. this.manualColumnWidths = initialColumnWidth;
  15061. } else {
  15062. this.manualColumnWidths = [];
  15063. }
  15064. Handsontable.hooks.register('beforeColumnResize');
  15065. Handsontable.hooks.register('afterColumnResize');
  15066. this.bindEvents();
  15067. $traceurRuntime.superGet(this, $ManualColumnResize.prototype, "enablePlugin").call(this);
  15068. },
  15069. updatePlugin: function() {
  15070. var initialColumnWidth = this.hot.getSettings().manualColumnResize;
  15071. if (Array.isArray(initialColumnWidth)) {
  15072. this.manualColumnWidths = initialColumnWidth;
  15073. } else {
  15074. this.manualColumnWidths = [];
  15075. }
  15076. },
  15077. disablePlugin: function() {
  15078. $traceurRuntime.superGet(this, $ManualColumnResize.prototype, "disablePlugin").call(this);
  15079. },
  15080. saveManualColumnWidths: function() {
  15081. this.hot.runHooks('persistentStateSave', 'manualColumnWidths', this.manualColumnWidths);
  15082. },
  15083. loadManualColumnWidths: function() {
  15084. var storedState = {};
  15085. this.hot.runHooks('persistentStateLoad', 'manualColumnWidths', storedState);
  15086. return storedState.value;
  15087. },
  15088. setupHandlePosition: function(TH) {
  15089. this.currentTH = TH;
  15090. var col = this.hot.view.wt.wtTable.getCoords(TH).col;
  15091. if (col >= 0) {
  15092. var box = this.currentTH.getBoundingClientRect();
  15093. this.currentCol = col;
  15094. this.startOffset = box.left - 6;
  15095. this.startWidth = parseInt(box.width, 10);
  15096. this.handle.style.top = box.top + 'px';
  15097. this.handle.style.left = this.startOffset + this.startWidth + 'px';
  15098. this.hot.rootElement.appendChild(this.handle);
  15099. }
  15100. },
  15101. refreshHandlePosition: function() {
  15102. this.handle.style.left = this.startOffset + this.currentWidth + 'px';
  15103. },
  15104. setupGuidePosition: function() {
  15105. addClass(this.handle, 'active');
  15106. addClass(this.guide, 'active');
  15107. this.guide.style.top = this.handle.style.top;
  15108. this.guide.style.left = this.handle.style.left;
  15109. this.guide.style.height = this.hot.view.maximumVisibleElementHeight(0) + 'px';
  15110. this.hot.rootElement.appendChild(this.guide);
  15111. },
  15112. refreshGuidePosition: function() {
  15113. this.guide.style.left = this.handle.style.left;
  15114. },
  15115. hideHandleAndGuide: function() {
  15116. removeClass(this.handle, 'active');
  15117. removeClass(this.guide, 'active');
  15118. },
  15119. checkIfColumnHeader: function(element) {
  15120. if (element.tagName != 'BODY') {
  15121. if (element.parentNode.tagName == 'THEAD') {
  15122. return true;
  15123. } else {
  15124. element = element.parentNode;
  15125. return this.checkIfColumnHeader(element);
  15126. }
  15127. }
  15128. return false;
  15129. },
  15130. getTHFromTargetElement: function(element) {
  15131. if (element.tagName != 'TABLE') {
  15132. if (element.tagName == 'TH') {
  15133. return element;
  15134. } else {
  15135. return this.getTHFromTargetElement(element.parentNode);
  15136. }
  15137. }
  15138. return null;
  15139. },
  15140. onMouseOver: function(event) {
  15141. if (this.checkIfColumnHeader(event.target)) {
  15142. var th = this.getTHFromTargetElement(event.target);
  15143. if (!th) {
  15144. return;
  15145. }
  15146. var colspan = th.getAttribute('colspan');
  15147. if (th && (colspan === null || colspan === 1)) {
  15148. if (!this.pressed) {
  15149. this.setupHandlePosition(th);
  15150. }
  15151. }
  15152. }
  15153. },
  15154. afterMouseDownTimeout: function() {
  15155. if (this.dblclick >= 2) {
  15156. var hookNewSize = this.hot.runHooks('beforeColumnResize', this.currentCol, this.newSize, true);
  15157. if (hookNewSize !== void 0) {
  15158. this.newSize = hookNewSize;
  15159. }
  15160. this.setManualSize(this.currentCol, this.newSize);
  15161. this.hot.forceFullRender = true;
  15162. this.hot.view.render();
  15163. this.hot.view.wt.wtOverlays.adjustElementsSize(true);
  15164. this.hot.runHooks('afterColumnResize', this.currentCol, this.newSize, true);
  15165. }
  15166. this.dblclick = 0;
  15167. this.autoresizeTimeout = null;
  15168. },
  15169. onMouseDown: function(event) {
  15170. var $__5 = this;
  15171. if (hasClass(event.target, 'manualColumnResizer')) {
  15172. this.setupGuidePosition();
  15173. this.pressed = this.hot;
  15174. if (this.autoresizeTimeout === null) {
  15175. this.autoresizeTimeout = setTimeout((function() {
  15176. return $__5.afterMouseDownTimeout();
  15177. }), 500);
  15178. this.hot._registerTimeout(this.autoresizeTimeout);
  15179. }
  15180. this.dblclick++;
  15181. this.startX = pageX(event);
  15182. this.newSize = this.startWidth;
  15183. }
  15184. },
  15185. onMouseMove: function(event) {
  15186. if (this.pressed) {
  15187. this.currentWidth = this.startWidth + (pageX(event) - this.startX);
  15188. this.newSize = this.setManualSize(this.currentCol, this.currentWidth);
  15189. this.refreshHandlePosition();
  15190. this.refreshGuidePosition();
  15191. }
  15192. },
  15193. onMouseUp: function(event) {
  15194. if (this.pressed) {
  15195. this.hideHandleAndGuide();
  15196. this.pressed = false;
  15197. if (this.newSize != this.startWidth) {
  15198. this.hot.runHooks('beforeColumnResize', this.currentCol, this.newSize);
  15199. this.hot.forceFullRender = true;
  15200. this.hot.view.render();
  15201. this.hot.view.wt.wtOverlays.adjustElementsSize(true);
  15202. this.saveManualColumnWidths();
  15203. this.hot.runHooks('afterColumnResize', this.currentCol, this.newSize);
  15204. }
  15205. this.setupHandlePosition(this.currentTH);
  15206. }
  15207. },
  15208. bindEvents: function() {
  15209. var $__5 = this;
  15210. this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', (function(e) {
  15211. return $__5.onMouseOver(e);
  15212. }));
  15213. this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', (function(e) {
  15214. return $__5.onMouseDown(e);
  15215. }));
  15216. this.eventManager.addEventListener(window, 'mousemove', (function(e) {
  15217. return $__5.onMouseMove(e);
  15218. }));
  15219. this.eventManager.addEventListener(window, 'mouseup', (function(e) {
  15220. return $__5.onMouseUp(e);
  15221. }));
  15222. },
  15223. setManualSize: function(column, width) {
  15224. width = Math.max(width, 20);
  15225. column = this.hot.runHooks('modifyCol', column);
  15226. this.manualColumnWidths[column] = width;
  15227. return width;
  15228. },
  15229. onModifyColWidth: function(width, column) {
  15230. if (this.enabled) {
  15231. column = this.hot.runHooks('modifyCol', column);
  15232. if (this.hot.getSettings().manualColumnResize && this.manualColumnWidths[column]) {
  15233. return this.manualColumnWidths[column];
  15234. }
  15235. }
  15236. return width;
  15237. }
  15238. }, {}, BasePlugin);
  15239. ;
  15240. registerPlugin('manualColumnResize', ManualColumnResize);
  15241. //#
  15242. },{"_base.js":58,"eventManager":41,"helpers/dom/element":45,"helpers/dom/event":46,"plugins":57}],79:[function(require,module,exports){
  15243. "use strict";
  15244. Object.defineProperties(exports, {
  15245. ManualRowMove: {get: function() {
  15246. return ManualRowMove;
  15247. }},
  15248. __esModule: {value: true}
  15249. });
  15250. var $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  15251. $___46__46__47__46__46__47_eventManager__,
  15252. $___46__46__47__46__46__47_helpers_47_dom_47_event__,
  15253. $___46__46__47__46__46__47_plugins__;
  15254. var $__0 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  15255. addClass = $__0.addClass,
  15256. hasClass = $__0.hasClass,
  15257. removeClass = $__0.removeClass;
  15258. var eventManagerObject = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).eventManager;
  15259. var $__2 = ($___46__46__47__46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47__46__46__47_helpers_47_dom_47_event__ && $___46__46__47__46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_event__}),
  15260. pageX = $__2.pageX,
  15261. pageY = $__2.pageY;
  15262. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  15263. ;
  15264. function ManualRowMove() {
  15265. var startRow,
  15266. endRow,
  15267. startY,
  15268. startOffset,
  15269. currentRow,
  15270. currentTH,
  15271. handle = document.createElement('DIV'),
  15272. guide = document.createElement('DIV'),
  15273. eventManager = eventManagerObject(this);
  15274. handle.className = 'manualRowMover';
  15275. guide.className = 'manualRowMoverGuide';
  15276. var saveManualRowPositions = function() {
  15277. var instance = this;
  15278. Handsontable.hooks.run(instance, 'persistentStateSave', 'manualRowPositions', instance.manualRowPositions);
  15279. };
  15280. var loadManualRowPositions = function() {
  15281. var instance = this,
  15282. storedState = {};
  15283. Handsontable.hooks.run(instance, 'persistentStateLoad', 'manualRowPositions', storedState);
  15284. return storedState.value;
  15285. };
  15286. function setupHandlePosition(TH) {
  15287. var instance = this;
  15288. currentTH = TH;
  15289. var row = this.view.wt.wtTable.getCoords(TH).row;
  15290. if (row >= 0) {
  15291. currentRow = row;
  15292. var box = currentTH.getBoundingClientRect();
  15293. startOffset = box.top;
  15294. handle.style.top = startOffset + 'px';
  15295. handle.style.left = box.left + 'px';
  15296. instance.rootElement.appendChild(handle);
  15297. }
  15298. }
  15299. function refreshHandlePosition(TH, delta) {
  15300. var box = TH.getBoundingClientRect();
  15301. var handleHeight = 6;
  15302. if (delta > 0) {
  15303. handle.style.top = (box.top + box.height - handleHeight) + 'px';
  15304. } else {
  15305. handle.style.top = box.top + 'px';
  15306. }
  15307. }
  15308. function setupGuidePosition() {
  15309. var instance = this;
  15310. addClass(handle, 'active');
  15311. addClass(guide, 'active');
  15312. var box = currentTH.getBoundingClientRect();
  15313. guide.style.width = instance.view.maximumVisibleElementWidth(0) + 'px';
  15314. guide.style.height = box.height + 'px';
  15315. guide.style.top = startOffset + 'px';
  15316. guide.style.left = handle.style.left;
  15317. instance.rootElement.appendChild(guide);
  15318. }
  15319. function refreshGuidePosition(diff) {
  15320. guide.style.top = startOffset + diff + 'px';
  15321. }
  15322. function hideHandleAndGuide() {
  15323. removeClass(handle, 'active');
  15324. removeClass(guide, 'active');
  15325. }
  15326. var checkRowHeader = function(element) {
  15327. if (element.tagName != 'BODY') {
  15328. if (element.parentNode.tagName == 'TBODY') {
  15329. return true;
  15330. } else {
  15331. element = element.parentNode;
  15332. return checkRowHeader(element);
  15333. }
  15334. }
  15335. return false;
  15336. };
  15337. var getTHFromTargetElement = function(element) {
  15338. if (element.tagName != 'TABLE') {
  15339. if (element.tagName == 'TH') {
  15340. return element;
  15341. } else {
  15342. return getTHFromTargetElement(element.parentNode);
  15343. }
  15344. }
  15345. return null;
  15346. };
  15347. var bindEvents = function() {
  15348. var instance = this;
  15349. var pressed;
  15350. eventManager.addEventListener(instance.rootElement, 'mouseover', function(e) {
  15351. if (checkRowHeader(e.target)) {
  15352. var th = getTHFromTargetElement(e.target);
  15353. if (th) {
  15354. if (pressed) {
  15355. endRow = instance.view.wt.wtTable.getCoords(th).row;
  15356. refreshHandlePosition(th, endRow - startRow);
  15357. } else {
  15358. setupHandlePosition.call(instance, th);
  15359. }
  15360. }
  15361. }
  15362. });
  15363. eventManager.addEventListener(instance.rootElement, 'mousedown', function(e) {
  15364. if (hasClass(e.target, 'manualRowMover')) {
  15365. startY = pageY(e);
  15366. setupGuidePosition.call(instance);
  15367. pressed = instance;
  15368. startRow = currentRow;
  15369. endRow = currentRow;
  15370. }
  15371. });
  15372. eventManager.addEventListener(window, 'mousemove', function(e) {
  15373. if (pressed) {
  15374. refreshGuidePosition(pageY(e) - startY);
  15375. }
  15376. });
  15377. eventManager.addEventListener(window, 'mouseup', function(e) {
  15378. if (pressed) {
  15379. hideHandleAndGuide();
  15380. pressed = false;
  15381. createPositionData(instance.manualRowPositions, instance.countRows());
  15382. instance.manualRowPositions.splice(endRow, 0, instance.manualRowPositions.splice(startRow, 1)[0]);
  15383. Handsontable.hooks.run(instance, 'beforeRowMove', startRow, endRow);
  15384. instance.forceFullRender = true;
  15385. instance.view.render();
  15386. saveManualRowPositions.call(instance);
  15387. Handsontable.hooks.run(instance, 'afterRowMove', startRow, endRow);
  15388. setupHandlePosition.call(instance, currentTH);
  15389. }
  15390. });
  15391. instance.addHook('afterDestroy', unbindEvents);
  15392. };
  15393. var unbindEvents = function() {
  15394. eventManager.clear();
  15395. };
  15396. var createPositionData = function(positionArr, len) {
  15397. if (positionArr.length < len) {
  15398. for (var i = positionArr.length; i < len; i++) {
  15399. positionArr[i] = i;
  15400. }
  15401. }
  15402. };
  15403. this.beforeInit = function() {
  15404. this.manualRowPositions = [];
  15405. };
  15406. this.init = function(source) {
  15407. var instance = this;
  15408. var manualRowMoveEnabled = !!(instance.getSettings().manualRowMove);
  15409. if (manualRowMoveEnabled) {
  15410. var initialManualRowPositions = instance.getSettings().manualRowMove;
  15411. var loadedManualRowPostions = loadManualRowPositions.call(instance);
  15412. if (typeof instance.manualRowPositionsPluginUsages === 'undefined') {
  15413. instance.manualRowPositionsPluginUsages = ['manualColumnMove'];
  15414. } else {
  15415. instance.manualRowPositionsPluginUsages.push('manualColumnMove');
  15416. }
  15417. if (typeof loadedManualRowPostions != 'undefined') {
  15418. this.manualRowPositions = loadedManualRowPostions;
  15419. } else if (Array.isArray(initialManualRowPositions)) {
  15420. this.manualRowPositions = initialManualRowPositions;
  15421. } else {
  15422. this.manualRowPositions = [];
  15423. }
  15424. if (source === 'afterInit' || source === 'afterUpdateSettings' && eventManager.context.eventListeners.length === 0) {
  15425. bindEvents.call(this);
  15426. if (this.manualRowPositions.length > 0) {
  15427. instance.forceFullRender = true;
  15428. instance.render();
  15429. }
  15430. }
  15431. } else {
  15432. var pluginUsagesIndex = instance.manualRowPositionsPluginUsages ? instance.manualRowPositionsPluginUsages.indexOf('manualColumnMove') : -1;
  15433. if (pluginUsagesIndex > -1) {
  15434. unbindEvents.call(this);
  15435. instance.manualRowPositions = [];
  15436. instance.manualRowPositionsPluginUsages[pluginUsagesIndex] = void 0;
  15437. }
  15438. }
  15439. };
  15440. this.modifyRow = function(row) {
  15441. var instance = this;
  15442. if (instance.getSettings().manualRowMove) {
  15443. if (typeof instance.manualRowPositions[row] === 'undefined') {
  15444. createPositionData(this.manualRowPositions, row + 1);
  15445. }
  15446. return instance.manualRowPositions[row];
  15447. }
  15448. return row;
  15449. };
  15450. }
  15451. var htManualRowMove = new ManualRowMove();
  15452. Handsontable.hooks.add('beforeInit', htManualRowMove.beforeInit);
  15453. Handsontable.hooks.add('afterInit', function() {
  15454. htManualRowMove.init.call(this, 'afterInit');
  15455. });
  15456. Handsontable.hooks.add('afterUpdateSettings', function() {
  15457. htManualRowMove.init.call(this, 'afterUpdateSettings');
  15458. });
  15459. Handsontable.hooks.add('modifyRow', htManualRowMove.modifyRow);
  15460. Handsontable.hooks.register('beforeRowMove');
  15461. Handsontable.hooks.register('afterRowMove');
  15462. //#
  15463. },{"eventManager":41,"helpers/dom/element":45,"helpers/dom/event":46,"plugins":57}],80:[function(require,module,exports){
  15464. "use strict";
  15465. Object.defineProperties(exports, {
  15466. ManualRowResize: {get: function() {
  15467. return ManualRowResize;
  15468. }},
  15469. __esModule: {value: true}
  15470. });
  15471. var $___46__46__47__95_base_46_js__,
  15472. $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  15473. $___46__46__47__46__46__47_eventManager__,
  15474. $___46__46__47__46__46__47_helpers_47_dom_47_event__,
  15475. $___46__46__47__46__46__47_plugins__;
  15476. var BasePlugin = ($___46__46__47__95_base_46_js__ = require("_base.js"), $___46__46__47__95_base_46_js__ && $___46__46__47__95_base_46_js__.__esModule && $___46__46__47__95_base_46_js__ || {default: $___46__46__47__95_base_46_js__}).default;
  15477. var $__1 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  15478. addClass = $__1.addClass,
  15479. hasClass = $__1.hasClass,
  15480. removeClass = $__1.removeClass;
  15481. var eventManagerObject = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).eventManager;
  15482. var $__3 = ($___46__46__47__46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47__46__46__47_helpers_47_dom_47_event__ && $___46__46__47__46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_event__}),
  15483. pageX = $__3.pageX,
  15484. pageY = $__3.pageY;
  15485. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  15486. var ManualRowResize = function ManualRowResize(hotInstance) {
  15487. $traceurRuntime.superConstructor($ManualRowResize).call(this, hotInstance);
  15488. this.currentTH = null;
  15489. this.currentRow = null;
  15490. this.currentHeight = null;
  15491. this.newSize = null;
  15492. this.startY = null;
  15493. this.startHeight = null;
  15494. this.startOffset = null;
  15495. this.handle = document.createElement('DIV');
  15496. this.guide = document.createElement('DIV');
  15497. this.eventManager = eventManagerObject(this);
  15498. this.pressed = null;
  15499. this.dblclick = 0;
  15500. this.autoresizeTimeout = null;
  15501. this.manualRowHeights = [];
  15502. addClass(this.handle, 'manualRowResizer');
  15503. addClass(this.guide, 'manualRowResizerGuide');
  15504. };
  15505. var $ManualRowResize = ManualRowResize;
  15506. ($traceurRuntime.createClass)(ManualRowResize, {
  15507. isEnabled: function() {
  15508. return this.hot.getSettings().manualRowResize;
  15509. },
  15510. enablePlugin: function() {
  15511. var $__5 = this;
  15512. if (this.enabled) {
  15513. return;
  15514. }
  15515. this.manualRowHeights = [];
  15516. var initialRowHeights = this.hot.getSettings().manualRowResize;
  15517. var loadedManualRowHeights = this.loadManualRowHeights();
  15518. if (typeof loadedManualRowHeights != 'undefined') {
  15519. this.manualRowHeights = loadedManualRowHeights;
  15520. } else if (Array.isArray(initialRowHeights)) {
  15521. this.manualRowHeights = initialRowHeights;
  15522. } else {
  15523. this.manualRowHeights = [];
  15524. }
  15525. this.addHook('modifyRowHeight', (function(height, row) {
  15526. return $__5.onModifyRowHeight(height, row);
  15527. }));
  15528. Handsontable.hooks.register('beforeRowResize');
  15529. Handsontable.hooks.register('afterRowResize');
  15530. this.bindEvents();
  15531. $traceurRuntime.superGet(this, $ManualRowResize.prototype, "enablePlugin").call(this);
  15532. },
  15533. updatePlugin: function() {
  15534. var initialRowHeights = this.hot.getSettings().manualRowResize;
  15535. if (Array.isArray(initialRowHeights)) {
  15536. this.manualRowHeights = initialRowHeights;
  15537. } else {
  15538. this.manualRowHeights = [];
  15539. }
  15540. },
  15541. disablePlugin: function() {
  15542. $traceurRuntime.superGet(this, $ManualRowResize.prototype, "disablePlugin").call(this);
  15543. },
  15544. saveManualRowHeights: function() {
  15545. this.hot.runHooks('persistentStateSave', 'manualRowHeights', this.manualRowHeights);
  15546. },
  15547. loadManualRowHeights: function() {
  15548. var storedState = {};
  15549. this.hot.runHooks('persistentStateLoad', 'manualRowHeights', storedState);
  15550. return storedState.value;
  15551. },
  15552. setupHandlePosition: function(TH) {
  15553. this.currentTH = TH;
  15554. var row = this.hot.view.wt.wtTable.getCoords(TH).row;
  15555. if (row >= 0) {
  15556. var box = this.currentTH.getBoundingClientRect();
  15557. this.currentRow = row;
  15558. this.startOffset = box.top - 6;
  15559. this.startHeight = parseInt(box.height, 10);
  15560. this.handle.style.left = box.left + 'px';
  15561. this.handle.style.top = this.startOffset + this.startHeight + 'px';
  15562. this.hot.rootElement.appendChild(this.handle);
  15563. }
  15564. },
  15565. refreshHandlePosition: function() {
  15566. this.handle.style.top = this.startOffset + this.currentHeight + 'px';
  15567. },
  15568. setupGuidePosition: function() {
  15569. addClass(this.handle, 'active');
  15570. addClass(this.guide, 'active');
  15571. this.guide.style.top = this.handle.style.top;
  15572. this.guide.style.left = this.handle.style.left;
  15573. this.guide.style.width = this.hot.view.maximumVisibleElementWidth(0) + 'px';
  15574. this.hot.rootElement.appendChild(this.guide);
  15575. },
  15576. refreshGuidePosition: function() {
  15577. this.guide.style.top = this.handle.style.top;
  15578. },
  15579. hideHandleAndGuide: function() {
  15580. removeClass(this.handle, 'active');
  15581. removeClass(this.guide, 'active');
  15582. },
  15583. checkIfRowHeader: function(element) {
  15584. if (element.tagName != 'BODY') {
  15585. if (element.parentNode.tagName == 'TBODY') {
  15586. return true;
  15587. } else {
  15588. element = element.parentNode;
  15589. return this.checkIfRowHeader(element);
  15590. }
  15591. }
  15592. return false;
  15593. },
  15594. getTHFromTargetElement: function(element) {
  15595. if (element.tagName != 'TABLE') {
  15596. if (element.tagName == 'TH') {
  15597. return element;
  15598. } else {
  15599. return this.getTHFromTargetElement(element.parentNode);
  15600. }
  15601. }
  15602. return null;
  15603. },
  15604. onMouseOver: function(event) {
  15605. if (this.checkIfRowHeader(event.target)) {
  15606. var th = this.getTHFromTargetElement(event.target);
  15607. if (th) {
  15608. if (!this.pressed) {
  15609. this.setupHandlePosition(th);
  15610. }
  15611. }
  15612. }
  15613. },
  15614. afterMouseDownTimeout: function() {
  15615. if (this.dblclick >= 2) {
  15616. var hookNewSize = this.hot.runHooks('beforeRowResize', this.currentRow, this.newSize, true);
  15617. if (hookNewSize !== void 0) {
  15618. this.newSize = hookNewSize;
  15619. }
  15620. this.setManualSize(this.currentRow, this.newSize);
  15621. this.hot.forceFullRender = true;
  15622. this.hot.view.render();
  15623. this.hot.view.wt.wtOverlays.adjustElementsSize(true);
  15624. this.hot.runHooks('afterRowResize', this.currentRow, this.newSize, true);
  15625. }
  15626. this.dblclick = 0;
  15627. this.autoresizeTimeout = null;
  15628. },
  15629. onMouseDown: function(event) {
  15630. var $__5 = this;
  15631. if (hasClass(event.target, 'manualRowResizer')) {
  15632. this.setupGuidePosition();
  15633. this.pressed = this.hot;
  15634. if (this.autoresizeTimeout == null) {
  15635. this.autoresizeTimeout = setTimeout((function() {
  15636. return $__5.afterMouseDownTimeout();
  15637. }), 500);
  15638. this.hot._registerTimeout(this.autoresizeTimeout);
  15639. }
  15640. this.dblclick++;
  15641. this.startY = pageY(event);
  15642. this.newSize = this.startHeight;
  15643. }
  15644. },
  15645. onMouseMove: function(event) {
  15646. if (this.pressed) {
  15647. this.currentHeight = this.startHeight + (pageY(event) - this.startY);
  15648. this.newSize = this.setManualSize(this.currentRow, this.currentHeight);
  15649. this.refreshHandlePosition();
  15650. this.refreshGuidePosition();
  15651. }
  15652. },
  15653. onMouseUp: function(event) {
  15654. if (this.pressed) {
  15655. this.hideHandleAndGuide();
  15656. this.pressed = false;
  15657. if (this.newSize != this.startHeight) {
  15658. this.hot.runHooks('beforeRowResize', this.currentRow, this.newSize);
  15659. this.hot.forceFullRender = true;
  15660. this.hot.view.render();
  15661. this.hot.view.wt.wtOverlays.adjustElementsSize(true);
  15662. this.saveManualRowHeights();
  15663. this.hot.runHooks('afterRowResize', this.currentRow, this.newSize);
  15664. }
  15665. this.setupHandlePosition(this.currentTH);
  15666. }
  15667. },
  15668. bindEvents: function() {
  15669. var $__5 = this;
  15670. this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', (function(e) {
  15671. return $__5.onMouseOver(e);
  15672. }));
  15673. this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', (function(e) {
  15674. return $__5.onMouseDown(e);
  15675. }));
  15676. this.eventManager.addEventListener(window, 'mousemove', (function(e) {
  15677. return $__5.onMouseMove(e);
  15678. }));
  15679. this.eventManager.addEventListener(window, 'mouseup', (function(e) {
  15680. return $__5.onMouseUp(e);
  15681. }));
  15682. },
  15683. setManualSize: function(row, height) {
  15684. row = this.hot.runHooks('modifyRow', row);
  15685. this.manualRowHeights[row] = height;
  15686. return height;
  15687. },
  15688. onModifyRowHeight: function(height, row) {
  15689. if (this.enabled) {
  15690. var autoRowSizePlugin = this.hot.getPlugin('autoRowSize');
  15691. var autoRowHeightResult = autoRowSizePlugin ? autoRowSizePlugin.heights[row] : null;
  15692. row = this.hot.runHooks('modifyRow', row);
  15693. var manualRowHeight = this.manualRowHeights[row];
  15694. if (manualRowHeight !== void 0 && (manualRowHeight === autoRowHeightResult || manualRowHeight > (height || 0))) {
  15695. return manualRowHeight;
  15696. }
  15697. }
  15698. return height;
  15699. }
  15700. }, {}, BasePlugin);
  15701. ;
  15702. registerPlugin('manualRowResize', ManualRowResize);
  15703. //#
  15704. },{"_base.js":58,"eventManager":41,"helpers/dom/element":45,"helpers/dom/event":46,"plugins":57}],81:[function(require,module,exports){
  15705. "use strict";
  15706. Object.defineProperties(exports, {
  15707. MergeCells: {get: function() {
  15708. return MergeCells;
  15709. }},
  15710. __esModule: {value: true}
  15711. });
  15712. var $___46__46__47__46__46__47_plugins__,
  15713. $___46__46__47__46__46__47_helpers_47_dom_47_event__,
  15714. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__,
  15715. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__,
  15716. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table__;
  15717. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  15718. var stopImmediatePropagation = ($___46__46__47__46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47__46__46__47_helpers_47_dom_47_event__ && $___46__46__47__46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_event__}).stopImmediatePropagation;
  15719. var WalkontableCellCoords = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ = require("3rdparty/walkontable/src/cell/coords"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__}).WalkontableCellCoords;
  15720. var WalkontableCellRange = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__ = require("3rdparty/walkontable/src/cell/range"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range__}).WalkontableCellRange;
  15721. var WalkontableTable = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table__ = require("3rdparty/walkontable/src/table"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table__}).WalkontableTable;
  15722. ;
  15723. function CellInfoCollection() {
  15724. var collection = [];
  15725. collection.getInfo = function(row, col) {
  15726. for (var i = 0,
  15727. ilen = this.length; i < ilen; i++) {
  15728. if (this[i].row <= row && this[i].row + this[i].rowspan - 1 >= row && this[i].col <= col && this[i].col + this[i].colspan - 1 >= col) {
  15729. return this[i];
  15730. }
  15731. }
  15732. };
  15733. collection.setInfo = function(info) {
  15734. for (var i = 0,
  15735. ilen = this.length; i < ilen; i++) {
  15736. if (this[i].row === info.row && this[i].col === info.col) {
  15737. this[i] = info;
  15738. return;
  15739. }
  15740. }
  15741. this.push(info);
  15742. };
  15743. collection.removeInfo = function(row, col) {
  15744. for (var i = 0,
  15745. ilen = this.length; i < ilen; i++) {
  15746. if (this[i].row === row && this[i].col === col) {
  15747. this.splice(i, 1);
  15748. break;
  15749. }
  15750. }
  15751. };
  15752. return collection;
  15753. }
  15754. function MergeCells(mergeCellsSetting) {
  15755. this.mergedCellInfoCollection = new CellInfoCollection();
  15756. if (Array.isArray(mergeCellsSetting)) {
  15757. for (var i = 0,
  15758. ilen = mergeCellsSetting.length; i < ilen; i++) {
  15759. this.mergedCellInfoCollection.setInfo(mergeCellsSetting[i]);
  15760. }
  15761. }
  15762. }
  15763. MergeCells.prototype.canMergeRange = function(cellRange) {
  15764. return !cellRange.isSingle();
  15765. };
  15766. MergeCells.prototype.mergeRange = function(cellRange) {
  15767. if (!this.canMergeRange(cellRange)) {
  15768. return;
  15769. }
  15770. var topLeft = cellRange.getTopLeftCorner();
  15771. var bottomRight = cellRange.getBottomRightCorner();
  15772. var mergeParent = {};
  15773. mergeParent.row = topLeft.row;
  15774. mergeParent.col = topLeft.col;
  15775. mergeParent.rowspan = bottomRight.row - topLeft.row + 1;
  15776. mergeParent.colspan = bottomRight.col - topLeft.col + 1;
  15777. this.mergedCellInfoCollection.setInfo(mergeParent);
  15778. };
  15779. MergeCells.prototype.mergeOrUnmergeSelection = function(cellRange) {
  15780. var info = this.mergedCellInfoCollection.getInfo(cellRange.from.row, cellRange.from.col);
  15781. if (info) {
  15782. this.unmergeSelection(cellRange.from);
  15783. } else {
  15784. this.mergeSelection(cellRange);
  15785. }
  15786. };
  15787. MergeCells.prototype.mergeSelection = function(cellRange) {
  15788. this.mergeRange(cellRange);
  15789. };
  15790. MergeCells.prototype.unmergeSelection = function(cellRange) {
  15791. var info = this.mergedCellInfoCollection.getInfo(cellRange.row, cellRange.col);
  15792. this.mergedCellInfoCollection.removeInfo(info.row, info.col);
  15793. };
  15794. MergeCells.prototype.applySpanProperties = function(TD, row, col) {
  15795. var info = this.mergedCellInfoCollection.getInfo(row, col);
  15796. if (info) {
  15797. if (info.row === row && info.col === col) {
  15798. TD.setAttribute('rowspan', info.rowspan);
  15799. TD.setAttribute('colspan', info.colspan);
  15800. } else {
  15801. TD.removeAttribute('rowspan');
  15802. TD.removeAttribute('colspan');
  15803. TD.style.display = 'none';
  15804. }
  15805. } else {
  15806. TD.removeAttribute('rowspan');
  15807. TD.removeAttribute('colspan');
  15808. }
  15809. };
  15810. MergeCells.prototype.modifyTransform = function(hook, currentSelectedRange, delta) {
  15811. var sameRowspan = function(merged, coords) {
  15812. if (coords.row >= merged.row && coords.row <= (merged.row + merged.rowspan - 1)) {
  15813. return true;
  15814. }
  15815. return false;
  15816. },
  15817. sameColspan = function(merged, coords) {
  15818. if (coords.col >= merged.col && coords.col <= (merged.col + merged.colspan - 1)) {
  15819. return true;
  15820. }
  15821. return false;
  15822. },
  15823. getNextPosition = function(newDelta) {
  15824. return new WalkontableCellCoords(currentSelectedRange.to.row + newDelta.row, currentSelectedRange.to.col + newDelta.col);
  15825. };
  15826. var newDelta = {
  15827. row: delta.row,
  15828. col: delta.col
  15829. };
  15830. if (hook == 'modifyTransformStart') {
  15831. if (!this.lastDesiredCoords) {
  15832. this.lastDesiredCoords = new WalkontableCellCoords(null, null);
  15833. }
  15834. var currentPosition = new WalkontableCellCoords(currentSelectedRange.highlight.row, currentSelectedRange.highlight.col),
  15835. mergedParent = this.mergedCellInfoCollection.getInfo(currentPosition.row, currentPosition.col),
  15836. currentRangeContainsMerge;
  15837. for (var i = 0,
  15838. mergesLength = this.mergedCellInfoCollection.length; i < mergesLength; i++) {
  15839. var range = this.mergedCellInfoCollection[i];
  15840. range = new WalkontableCellCoords(range.row + range.rowspan - 1, range.col + range.colspan - 1);
  15841. if (currentSelectedRange.includes(range)) {
  15842. currentRangeContainsMerge = true;
  15843. break;
  15844. }
  15845. }
  15846. if (mergedParent) {
  15847. var mergeTopLeft = new WalkontableCellCoords(mergedParent.row, mergedParent.col),
  15848. mergeBottomRight = new WalkontableCellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1),
  15849. mergeRange = new WalkontableCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
  15850. if (!mergeRange.includes(this.lastDesiredCoords)) {
  15851. this.lastDesiredCoords = new WalkontableCellCoords(null, null);
  15852. }
  15853. newDelta.row = this.lastDesiredCoords.row ? this.lastDesiredCoords.row - currentPosition.row : newDelta.row;
  15854. newDelta.col = this.lastDesiredCoords.col ? this.lastDesiredCoords.col - currentPosition.col : newDelta.col;
  15855. if (delta.row > 0) {
  15856. newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
  15857. } else if (delta.row < 0) {
  15858. newDelta.row = currentPosition.row - mergedParent.row + delta.row;
  15859. }
  15860. if (delta.col > 0) {
  15861. newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
  15862. } else if (delta.col < 0) {
  15863. newDelta.col = currentPosition.col - mergedParent.col + delta.col;
  15864. }
  15865. }
  15866. var nextPosition = new WalkontableCellCoords(currentSelectedRange.highlight.row + newDelta.row, currentSelectedRange.highlight.col + newDelta.col),
  15867. nextParentIsMerged = this.mergedCellInfoCollection.getInfo(nextPosition.row, nextPosition.col);
  15868. if (nextParentIsMerged) {
  15869. this.lastDesiredCoords = nextPosition;
  15870. newDelta = {
  15871. row: nextParentIsMerged.row - currentPosition.row,
  15872. col: nextParentIsMerged.col - currentPosition.col
  15873. };
  15874. }
  15875. } else if (hook == 'modifyTransformEnd') {
  15876. for (var i = 0,
  15877. mergesLength = this.mergedCellInfoCollection.length; i < mergesLength; i++) {
  15878. var currentMerge = this.mergedCellInfoCollection[i],
  15879. mergeTopLeft = new WalkontableCellCoords(currentMerge.row, currentMerge.col),
  15880. mergeBottomRight = new WalkontableCellCoords(currentMerge.row + currentMerge.rowspan - 1, currentMerge.col + currentMerge.colspan - 1),
  15881. mergedRange = new WalkontableCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight),
  15882. sharedBorders = currentSelectedRange.getBordersSharedWith(mergedRange);
  15883. if (mergedRange.isEqual(currentSelectedRange)) {
  15884. currentSelectedRange.setDirection('NW-SE');
  15885. } else if (sharedBorders.length > 0) {
  15886. var mergeHighlighted = (currentSelectedRange.highlight.isEqual(mergedRange.from));
  15887. if (sharedBorders.indexOf('top') > -1) {
  15888. if (currentSelectedRange.to.isSouthEastOf(mergedRange.from) && mergeHighlighted) {
  15889. currentSelectedRange.setDirection('NW-SE');
  15890. } else if (currentSelectedRange.to.isSouthWestOf(mergedRange.from) && mergeHighlighted) {
  15891. currentSelectedRange.setDirection('NE-SW');
  15892. }
  15893. } else if (sharedBorders.indexOf('bottom') > -1) {
  15894. if (currentSelectedRange.to.isNorthEastOf(mergedRange.from) && mergeHighlighted) {
  15895. currentSelectedRange.setDirection('SW-NE');
  15896. } else if (currentSelectedRange.to.isNorthWestOf(mergedRange.from) && mergeHighlighted) {
  15897. currentSelectedRange.setDirection('SE-NW');
  15898. }
  15899. }
  15900. }
  15901. var nextPosition = getNextPosition(newDelta),
  15902. withinRowspan = sameRowspan(currentMerge, nextPosition),
  15903. withinColspan = sameColspan(currentMerge, nextPosition);
  15904. if (currentSelectedRange.includesRange(mergedRange) && (mergedRange.includes(nextPosition) || withinRowspan || withinColspan)) {
  15905. if (withinRowspan) {
  15906. if (newDelta.row < 0) {
  15907. newDelta.row -= currentMerge.rowspan - 1;
  15908. } else if (newDelta.row > 0) {
  15909. newDelta.row += currentMerge.rowspan - 1;
  15910. }
  15911. }
  15912. if (withinColspan) {
  15913. if (newDelta.col < 0) {
  15914. newDelta.col -= currentMerge.colspan - 1;
  15915. } else if (newDelta.col > 0) {
  15916. newDelta.col += currentMerge.colspan - 1;
  15917. }
  15918. }
  15919. }
  15920. }
  15921. }
  15922. if (newDelta.row !== 0) {
  15923. delta.row = newDelta.row;
  15924. }
  15925. if (newDelta.col !== 0) {
  15926. delta.col = newDelta.col;
  15927. }
  15928. };
  15929. MergeCells.prototype.shiftCollection = function(direction, index, count) {
  15930. var shiftVector = [0, 0];
  15931. switch (direction) {
  15932. case 'right':
  15933. shiftVector[0] += 1;
  15934. break;
  15935. case 'left':
  15936. shiftVector[0] -= 1;
  15937. break;
  15938. case 'down':
  15939. shiftVector[1] += 1;
  15940. break;
  15941. case 'up':
  15942. shiftVector[1] -= 1;
  15943. break;
  15944. }
  15945. for (var i = 0; i < this.mergedCellInfoCollection.length; i++) {
  15946. var currentMerge = this.mergedCellInfoCollection[i];
  15947. if (direction === 'right' || direction === 'left') {
  15948. if (index <= currentMerge.col) {
  15949. currentMerge.col += shiftVector[0];
  15950. }
  15951. } else {
  15952. if (index <= currentMerge.row) {
  15953. currentMerge.row += shiftVector[1];
  15954. }
  15955. }
  15956. }
  15957. };
  15958. var beforeInit = function() {
  15959. var instance = this;
  15960. var mergeCellsSetting = instance.getSettings().mergeCells;
  15961. if (mergeCellsSetting) {
  15962. if (!instance.mergeCells) {
  15963. instance.mergeCells = new MergeCells(mergeCellsSetting);
  15964. }
  15965. }
  15966. };
  15967. var afterInit = function() {
  15968. var instance = this;
  15969. if (instance.mergeCells) {
  15970. instance.view.wt.wtTable.getCell = function(coords) {
  15971. if (instance.getSettings().mergeCells) {
  15972. var mergeParent = instance.mergeCells.mergedCellInfoCollection.getInfo(coords.row, coords.col);
  15973. if (mergeParent) {
  15974. coords = mergeParent;
  15975. }
  15976. }
  15977. return WalkontableTable.prototype.getCell.call(this, coords);
  15978. };
  15979. }
  15980. };
  15981. var afterUpdateSettings = function() {
  15982. var instance = this;
  15983. var mergeCellsSetting = instance.getSettings().mergeCells;
  15984. if (mergeCellsSetting) {
  15985. if (instance.mergeCells) {
  15986. instance.mergeCells.mergedCellInfoCollection = new CellInfoCollection();
  15987. if (Array.isArray(mergeCellsSetting)) {
  15988. for (var i = 0,
  15989. ilen = mergeCellsSetting.length; i < ilen; i++) {
  15990. instance.mergeCells.mergedCellInfoCollection.setInfo(mergeCellsSetting[i]);
  15991. }
  15992. }
  15993. } else {
  15994. instance.mergeCells = new MergeCells(mergeCellsSetting);
  15995. }
  15996. } else {
  15997. if (instance.mergeCells) {
  15998. instance.mergeCells.mergedCellInfoCollection = new CellInfoCollection();
  15999. }
  16000. }
  16001. };
  16002. var onBeforeKeyDown = function(event) {
  16003. if (!this.mergeCells) {
  16004. return;
  16005. }
  16006. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  16007. if (ctrlDown) {
  16008. if (event.keyCode === 77) {
  16009. this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange());
  16010. this.render();
  16011. stopImmediatePropagation(event);
  16012. }
  16013. }
  16014. };
  16015. var addMergeActionsToContextMenu = function(defaultOptions) {
  16016. if (!this.getSettings().mergeCells) {
  16017. return;
  16018. }
  16019. defaultOptions.items.push(Handsontable.plugins.ContextMenu.SEPARATOR);
  16020. defaultOptions.items.push({
  16021. key: 'mergeCells',
  16022. name: function() {
  16023. var sel = this.getSelected();
  16024. var info = this.mergeCells.mergedCellInfoCollection.getInfo(sel[0], sel[1]);
  16025. if (info) {
  16026. return 'Unmerge cells';
  16027. } else {
  16028. return 'Merge cells';
  16029. }
  16030. },
  16031. callback: function() {
  16032. this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange());
  16033. this.render();
  16034. },
  16035. disabled: function() {
  16036. return false;
  16037. }
  16038. });
  16039. };
  16040. var afterRenderer = function(TD, row, col, prop, value, cellProperties) {
  16041. if (this.mergeCells) {
  16042. this.mergeCells.applySpanProperties(TD, row, col);
  16043. }
  16044. };
  16045. var modifyTransformFactory = function(hook) {
  16046. return function(delta) {
  16047. var mergeCellsSetting = this.getSettings().mergeCells;
  16048. if (mergeCellsSetting) {
  16049. var currentSelectedRange = this.getSelectedRange();
  16050. this.mergeCells.modifyTransform(hook, currentSelectedRange, delta);
  16051. if (hook === 'modifyTransformEnd') {
  16052. var totalRows = this.countRows();
  16053. var totalCols = this.countCols();
  16054. if (currentSelectedRange.from.row < 0) {
  16055. currentSelectedRange.from.row = 0;
  16056. } else if (currentSelectedRange.from.row > 0 && currentSelectedRange.from.row >= totalRows) {
  16057. currentSelectedRange.from.row = currentSelectedRange.from - 1;
  16058. }
  16059. if (currentSelectedRange.from.col < 0) {
  16060. currentSelectedRange.from.col = 0;
  16061. } else if (currentSelectedRange.from.col > 0 && currentSelectedRange.from.col >= totalCols) {
  16062. currentSelectedRange.from.col = totalCols - 1;
  16063. }
  16064. }
  16065. }
  16066. };
  16067. };
  16068. var beforeSetRangeEnd = function(coords) {
  16069. this.lastDesiredCoords = null;
  16070. var mergeCellsSetting = this.getSettings().mergeCells;
  16071. if (mergeCellsSetting) {
  16072. var selRange = this.getSelectedRange();
  16073. selRange.highlight = new WalkontableCellCoords(selRange.highlight.row, selRange.highlight.col);
  16074. selRange.to = coords;
  16075. var rangeExpanded = false;
  16076. do {
  16077. rangeExpanded = false;
  16078. for (var i = 0,
  16079. ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) {
  16080. var cellInfo = this.mergeCells.mergedCellInfoCollection[i];
  16081. var mergedCellTopLeft = new WalkontableCellCoords(cellInfo.row, cellInfo.col);
  16082. var mergedCellBottomRight = new WalkontableCellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1);
  16083. var mergedCellRange = new WalkontableCellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
  16084. if (selRange.expandByRange(mergedCellRange)) {
  16085. coords.row = selRange.to.row;
  16086. coords.col = selRange.to.col;
  16087. rangeExpanded = true;
  16088. }
  16089. }
  16090. } while (rangeExpanded);
  16091. }
  16092. };
  16093. var beforeDrawAreaBorders = function(corners, className) {
  16094. if (className && className == 'area') {
  16095. var mergeCellsSetting = this.getSettings().mergeCells;
  16096. if (mergeCellsSetting) {
  16097. var selRange = this.getSelectedRange();
  16098. var startRange = new WalkontableCellRange(selRange.from, selRange.from, selRange.from);
  16099. var stopRange = new WalkontableCellRange(selRange.to, selRange.to, selRange.to);
  16100. for (var i = 0,
  16101. ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) {
  16102. var cellInfo = this.mergeCells.mergedCellInfoCollection[i];
  16103. var mergedCellTopLeft = new WalkontableCellCoords(cellInfo.row, cellInfo.col);
  16104. var mergedCellBottomRight = new WalkontableCellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1);
  16105. var mergedCellRange = new WalkontableCellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
  16106. if (startRange.expandByRange(mergedCellRange)) {
  16107. corners[0] = startRange.from.row;
  16108. corners[1] = startRange.from.col;
  16109. }
  16110. if (stopRange.expandByRange(mergedCellRange)) {
  16111. corners[2] = stopRange.from.row;
  16112. corners[3] = stopRange.from.col;
  16113. }
  16114. }
  16115. }
  16116. }
  16117. };
  16118. var afterGetCellMeta = function(row, col, cellProperties) {
  16119. var mergeCellsSetting = this.getSettings().mergeCells;
  16120. if (mergeCellsSetting) {
  16121. var mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(row, col);
  16122. if (mergeParent && (mergeParent.row != row || mergeParent.col != col)) {
  16123. cellProperties.copyable = false;
  16124. }
  16125. }
  16126. };
  16127. var afterViewportRowCalculatorOverride = function(calc) {
  16128. var mergeCellsSetting = this.getSettings().mergeCells;
  16129. if (mergeCellsSetting) {
  16130. var colCount = this.countCols();
  16131. var mergeParent;
  16132. for (var c = 0; c < colCount; c++) {
  16133. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.startRow, c);
  16134. if (mergeParent) {
  16135. if (mergeParent.row < calc.startRow) {
  16136. calc.startRow = mergeParent.row;
  16137. return afterViewportRowCalculatorOverride.call(this, calc);
  16138. }
  16139. }
  16140. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.endRow, c);
  16141. if (mergeParent) {
  16142. var mergeEnd = mergeParent.row + mergeParent.rowspan - 1;
  16143. if (mergeEnd > calc.endRow) {
  16144. calc.endRow = mergeEnd;
  16145. return afterViewportRowCalculatorOverride.call(this, calc);
  16146. }
  16147. }
  16148. }
  16149. }
  16150. };
  16151. var afterViewportColumnCalculatorOverride = function(calc) {
  16152. var mergeCellsSetting = this.getSettings().mergeCells;
  16153. if (mergeCellsSetting) {
  16154. var rowCount = this.countRows();
  16155. var mergeParent;
  16156. for (var r = 0; r < rowCount; r++) {
  16157. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.startColumn);
  16158. if (mergeParent) {
  16159. if (mergeParent.col < calc.startColumn) {
  16160. calc.startColumn = mergeParent.col;
  16161. return afterViewportColumnCalculatorOverride.call(this, calc);
  16162. }
  16163. }
  16164. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.endColumn);
  16165. if (mergeParent) {
  16166. var mergeEnd = mergeParent.col + mergeParent.colspan - 1;
  16167. if (mergeEnd > calc.endColumn) {
  16168. calc.endColumn = mergeEnd;
  16169. return afterViewportColumnCalculatorOverride.call(this, calc);
  16170. }
  16171. }
  16172. }
  16173. }
  16174. };
  16175. var isMultipleSelection = function(isMultiple) {
  16176. if (isMultiple && this.mergeCells) {
  16177. var mergedCells = this.mergeCells.mergedCellInfoCollection,
  16178. selectionRange = this.getSelectedRange();
  16179. for (var group in mergedCells) {
  16180. if (selectionRange.highlight.row == mergedCells[group].row && selectionRange.highlight.col == mergedCells[group].col && selectionRange.to.row == mergedCells[group].row + mergedCells[group].rowspan - 1 && selectionRange.to.col == mergedCells[group].col + mergedCells[group].colspan - 1) {
  16181. return false;
  16182. }
  16183. }
  16184. }
  16185. return isMultiple;
  16186. };
  16187. function afterAutofillApplyValues(select, drag) {
  16188. var mergeCellsSetting = this.getSettings().mergeCells;
  16189. if (!mergeCellsSetting || this.selection.isMultiple()) {
  16190. return;
  16191. }
  16192. var info = this.mergeCells.mergedCellInfoCollection.getInfo(select[0], select[1]);
  16193. if (info) {
  16194. select[0] = info.row;
  16195. select[1] = info.col;
  16196. select[2] = info.row + info.rowspan - 1;
  16197. select[3] = info.col + info.colspan - 1;
  16198. }
  16199. }
  16200. function onAfterCreateCol(col, count) {
  16201. if (this.mergeCells) {
  16202. this.mergeCells.shiftCollection('right', col, count);
  16203. }
  16204. }
  16205. function onAfterRemoveCol(col, count) {
  16206. if (this.mergeCells) {
  16207. this.mergeCells.shiftCollection('left', col, count);
  16208. }
  16209. }
  16210. function onAfterCreateRow(row, count) {
  16211. if (this.mergeCells) {
  16212. this.mergeCells.shiftCollection('down', row, count);
  16213. }
  16214. }
  16215. function onAfterRemoveRow(row, count) {
  16216. if (this.mergeCells) {
  16217. this.mergeCells.shiftCollection('up', row, count);
  16218. }
  16219. }
  16220. Handsontable.hooks.add('beforeInit', beforeInit);
  16221. Handsontable.hooks.add('afterInit', afterInit);
  16222. Handsontable.hooks.add('afterUpdateSettings', afterUpdateSettings);
  16223. Handsontable.hooks.add('beforeKeyDown', onBeforeKeyDown);
  16224. Handsontable.hooks.add('modifyTransformStart', modifyTransformFactory('modifyTransformStart'));
  16225. Handsontable.hooks.add('modifyTransformEnd', modifyTransformFactory('modifyTransformEnd'));
  16226. Handsontable.hooks.add('beforeSetRangeEnd', beforeSetRangeEnd);
  16227. Handsontable.hooks.add('beforeDrawBorders', beforeDrawAreaBorders);
  16228. Handsontable.hooks.add('afterIsMultipleSelection', isMultipleSelection);
  16229. Handsontable.hooks.add('afterRenderer', afterRenderer);
  16230. Handsontable.hooks.add('afterContextMenuDefaultOptions', addMergeActionsToContextMenu);
  16231. Handsontable.hooks.add('afterGetCellMeta', afterGetCellMeta);
  16232. Handsontable.hooks.add('afterViewportRowCalculatorOverride', afterViewportRowCalculatorOverride);
  16233. Handsontable.hooks.add('afterViewportColumnCalculatorOverride', afterViewportColumnCalculatorOverride);
  16234. Handsontable.hooks.add('afterAutofillApplyValues', afterAutofillApplyValues);
  16235. Handsontable.hooks.add('afterCreateCol', onAfterCreateCol);
  16236. Handsontable.hooks.add('afterRemoveCol', onAfterRemoveCol);
  16237. Handsontable.hooks.add('afterCreateRow', onAfterCreateRow);
  16238. Handsontable.hooks.add('afterRemoveRow', onAfterRemoveRow);
  16239. Handsontable.MergeCells = MergeCells;
  16240. //#
  16241. },{"3rdparty/walkontable/src/cell/coords":5,"3rdparty/walkontable/src/cell/range":6,"3rdparty/walkontable/src/table":20,"helpers/dom/event":46,"plugins":57}],82:[function(require,module,exports){
  16242. "use strict";
  16243. Object.defineProperties(exports, {
  16244. MultipleSelectionHandles: {get: function() {
  16245. return MultipleSelectionHandles;
  16246. }},
  16247. __esModule: {value: true}
  16248. });
  16249. var $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  16250. $___46__46__47__95_base__,
  16251. $___46__46__47__46__46__47_eventManager__,
  16252. $___46__46__47__46__46__47_plugins__;
  16253. var $__0 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  16254. getWindowScrollTop = $__0.getWindowScrollTop,
  16255. hasClass = $__0.hasClass,
  16256. getWindowScrollLeft = $__0.getWindowScrollLeft;
  16257. var BasePlugin = ($___46__46__47__95_base__ = require("_base"), $___46__46__47__95_base__ && $___46__46__47__95_base__.__esModule && $___46__46__47__95_base__ || {default: $___46__46__47__95_base__}).default;
  16258. var EventManager = ($___46__46__47__46__46__47_eventManager__ = require("eventManager"), $___46__46__47__46__46__47_eventManager__ && $___46__46__47__46__46__47_eventManager__.__esModule && $___46__46__47__46__46__47_eventManager__ || {default: $___46__46__47__46__46__47_eventManager__}).EventManager;
  16259. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  16260. var MultipleSelectionHandles = function MultipleSelectionHandles(hotInstance) {
  16261. $traceurRuntime.superConstructor($MultipleSelectionHandles).call(this, hotInstance);
  16262. this.dragged = [];
  16263. this.eventManager = null;
  16264. this.lastSetCell = null;
  16265. };
  16266. var $MultipleSelectionHandles = MultipleSelectionHandles;
  16267. ($traceurRuntime.createClass)(MultipleSelectionHandles, {
  16268. isEnabled: function() {
  16269. return Handsontable.mobileBrowser;
  16270. },
  16271. enablePlugin: function() {
  16272. if (this.enabled) {
  16273. return;
  16274. }
  16275. if (!this.eventManager) {
  16276. this.eventManager = new EventManager(this);
  16277. }
  16278. this.registerListeners();
  16279. $traceurRuntime.superGet(this, $MultipleSelectionHandles.prototype, "enablePlugin").call(this);
  16280. },
  16281. registerListeners: function() {
  16282. var _this = this;
  16283. function removeFromDragged(query) {
  16284. if (_this.dragged.length === 1) {
  16285. _this.dragged.splice(0, _this.dragged.length);
  16286. return true;
  16287. }
  16288. var entryPosition = _this.dragged.indexOf(query);
  16289. if (entryPosition == -1) {
  16290. return false;
  16291. } else if (entryPosition === 0) {
  16292. _this.dragged = _this.dragged.slice(0, 1);
  16293. } else if (entryPosition == 1) {
  16294. _this.dragged = _this.dragged.slice(-1);
  16295. }
  16296. }
  16297. this.eventManager.addEventListener(this.hot.rootElement, 'touchstart', function(event) {
  16298. var selectedRange;
  16299. if (hasClass(event.target, 'topLeftSelectionHandle-HitArea')) {
  16300. selectedRange = _this.hot.getSelectedRange();
  16301. _this.dragged.push('topLeft');
  16302. _this.touchStartRange = {
  16303. width: selectedRange.getWidth(),
  16304. height: selectedRange.getHeight(),
  16305. direction: selectedRange.getDirection()
  16306. };
  16307. event.preventDefault();
  16308. return false;
  16309. } else if (hasClass(event.target, 'bottomRightSelectionHandle-HitArea')) {
  16310. selectedRange = _this.hot.getSelectedRange();
  16311. _this.dragged.push('bottomRight');
  16312. _this.touchStartRange = {
  16313. width: selectedRange.getWidth(),
  16314. height: selectedRange.getHeight(),
  16315. direction: selectedRange.getDirection()
  16316. };
  16317. event.preventDefault();
  16318. return false;
  16319. }
  16320. });
  16321. this.eventManager.addEventListener(this.hot.rootElement, 'touchend', function(event) {
  16322. if (hasClass(event.target, 'topLeftSelectionHandle-HitArea')) {
  16323. removeFromDragged.call(_this, 'topLeft');
  16324. _this.touchStartRange = void 0;
  16325. event.preventDefault();
  16326. return false;
  16327. } else if (hasClass(event.target, 'bottomRightSelectionHandle-HitArea')) {
  16328. removeFromDragged.call(_this, 'bottomRight');
  16329. _this.touchStartRange = void 0;
  16330. event.preventDefault();
  16331. return false;
  16332. }
  16333. });
  16334. this.eventManager.addEventListener(this.hot.rootElement, 'touchmove', function(event) {
  16335. var scrollTop = getWindowScrollTop(),
  16336. scrollLeft = getWindowScrollLeft(),
  16337. endTarget,
  16338. targetCoords,
  16339. selectedRange,
  16340. rangeWidth,
  16341. rangeHeight,
  16342. rangeDirection,
  16343. newRangeCoords;
  16344. if (_this.dragged.length === 0) {
  16345. return;
  16346. }
  16347. endTarget = document.elementFromPoint(event.touches[0].screenX - scrollLeft, event.touches[0].screenY - scrollTop);
  16348. if (!endTarget || endTarget === _this.lastSetCell) {
  16349. return;
  16350. }
  16351. if (endTarget.nodeName == 'TD' || endTarget.nodeName == 'TH') {
  16352. targetCoords = _this.hot.getCoords(endTarget);
  16353. if (targetCoords.col == -1) {
  16354. targetCoords.col = 0;
  16355. }
  16356. selectedRange = _this.hot.getSelectedRange();
  16357. rangeWidth = selectedRange.getWidth();
  16358. rangeHeight = selectedRange.getHeight();
  16359. rangeDirection = selectedRange.getDirection();
  16360. if (rangeWidth == 1 && rangeHeight == 1) {
  16361. _this.hot.selection.setRangeEnd(targetCoords);
  16362. }
  16363. newRangeCoords = _this.getCurrentRangeCoords(selectedRange, targetCoords, _this.touchStartRange.direction, rangeDirection, _this.dragged[0]);
  16364. if (newRangeCoords.start !== null) {
  16365. _this.hot.selection.setRangeStart(newRangeCoords.start);
  16366. }
  16367. _this.hot.selection.setRangeEnd(newRangeCoords.end);
  16368. _this.lastSetCell = endTarget;
  16369. }
  16370. event.preventDefault();
  16371. });
  16372. },
  16373. getCurrentRangeCoords: function(selectedRange, currentTouch, touchStartDirection, currentDirection, draggedHandle) {
  16374. var topLeftCorner = selectedRange.getTopLeftCorner(),
  16375. bottomRightCorner = selectedRange.getBottomRightCorner(),
  16376. bottomLeftCorner = selectedRange.getBottomLeftCorner(),
  16377. topRightCorner = selectedRange.getTopRightCorner();
  16378. var newCoords = {
  16379. start: null,
  16380. end: null
  16381. };
  16382. switch (touchStartDirection) {
  16383. case 'NE-SW':
  16384. switch (currentDirection) {
  16385. case 'NE-SW':
  16386. case 'NW-SE':
  16387. if (draggedHandle == 'topLeft') {
  16388. newCoords = {
  16389. start: new WalkontableCellCoords(currentTouch.row, selectedRange.highlight.col),
  16390. end: new WalkontableCellCoords(bottomLeftCorner.row, currentTouch.col)
  16391. };
  16392. } else {
  16393. newCoords = {
  16394. start: new WalkontableCellCoords(selectedRange.highlight.row, currentTouch.col),
  16395. end: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col)
  16396. };
  16397. }
  16398. break;
  16399. case 'SE-NW':
  16400. if (draggedHandle == 'bottomRight') {
  16401. newCoords = {
  16402. start: new WalkontableCellCoords(bottomRightCorner.row, currentTouch.col),
  16403. end: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col)
  16404. };
  16405. }
  16406. break;
  16407. }
  16408. break;
  16409. case 'NW-SE':
  16410. switch (currentDirection) {
  16411. case 'NE-SW':
  16412. if (draggedHandle == 'topLeft') {
  16413. newCoords = {
  16414. start: currentTouch,
  16415. end: bottomLeftCorner
  16416. };
  16417. } else {
  16418. newCoords.end = currentTouch;
  16419. }
  16420. break;
  16421. case 'NW-SE':
  16422. if (draggedHandle == 'topLeft') {
  16423. newCoords = {
  16424. start: currentTouch,
  16425. end: bottomRightCorner
  16426. };
  16427. } else {
  16428. newCoords.end = currentTouch;
  16429. }
  16430. break;
  16431. case 'SE-NW':
  16432. if (draggedHandle == 'topLeft') {
  16433. newCoords = {
  16434. start: currentTouch,
  16435. end: topLeftCorner
  16436. };
  16437. } else {
  16438. newCoords.end = currentTouch;
  16439. }
  16440. break;
  16441. case 'SW-NE':
  16442. if (draggedHandle == 'topLeft') {
  16443. newCoords = {
  16444. start: currentTouch,
  16445. end: topRightCorner
  16446. };
  16447. } else {
  16448. newCoords.end = currentTouch;
  16449. }
  16450. break;
  16451. }
  16452. break;
  16453. case 'SW-NE':
  16454. switch (currentDirection) {
  16455. case 'NW-SE':
  16456. if (draggedHandle == 'bottomRight') {
  16457. newCoords = {
  16458. start: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col),
  16459. end: new WalkontableCellCoords(bottomLeftCorner.row, currentTouch.col)
  16460. };
  16461. } else {
  16462. newCoords = {
  16463. start: new WalkontableCellCoords(topLeftCorner.row, currentTouch.col),
  16464. end: new WalkontableCellCoords(currentTouch.row, bottomRightCorner.col)
  16465. };
  16466. }
  16467. break;
  16468. case 'SW-NE':
  16469. if (draggedHandle == 'topLeft') {
  16470. newCoords = {
  16471. start: new WalkontableCellCoords(selectedRange.highlight.row, currentTouch.col),
  16472. end: new WalkontableCellCoords(currentTouch.row, bottomRightCorner.col)
  16473. };
  16474. } else {
  16475. newCoords = {
  16476. start: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col),
  16477. end: new WalkontableCellCoords(topLeftCorner.row, currentTouch.col)
  16478. };
  16479. }
  16480. break;
  16481. case 'SE-NW':
  16482. if (draggedHandle == 'bottomRight') {
  16483. newCoords = {
  16484. start: new WalkontableCellCoords(currentTouch.row, topRightCorner.col),
  16485. end: new WalkontableCellCoords(topLeftCorner.row, currentTouch.col)
  16486. };
  16487. } else if (draggedHandle == 'topLeft') {
  16488. newCoords = {
  16489. start: bottomLeftCorner,
  16490. end: currentTouch
  16491. };
  16492. }
  16493. break;
  16494. }
  16495. break;
  16496. case 'SE-NW':
  16497. switch (currentDirection) {
  16498. case 'NW-SE':
  16499. case 'NE-SW':
  16500. case 'SW-NE':
  16501. if (draggedHandle == 'topLeft') {
  16502. newCoords.end = currentTouch;
  16503. }
  16504. break;
  16505. case 'SE-NW':
  16506. if (draggedHandle == 'topLeft') {
  16507. newCoords.end = currentTouch;
  16508. } else {
  16509. newCoords = {
  16510. start: currentTouch,
  16511. end: topLeftCorner
  16512. };
  16513. }
  16514. break;
  16515. }
  16516. break;
  16517. }
  16518. return newCoords;
  16519. },
  16520. isDragged: function() {
  16521. return this.dragged.length > 0;
  16522. }
  16523. }, {}, BasePlugin);
  16524. ;
  16525. registerPlugin('multipleSelectionHandles', MultipleSelectionHandles);
  16526. //#
  16527. },{"_base":58,"eventManager":41,"helpers/dom/element":45,"plugins":57}],83:[function(require,module,exports){
  16528. "use strict";
  16529. Object.defineProperties(exports, {
  16530. ObserveChanges: {get: function() {
  16531. return ObserveChanges;
  16532. }},
  16533. __esModule: {value: true}
  16534. });
  16535. var $___46__46__47__46__46__47_plugins__,
  16536. $__jsonpatch__;
  16537. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  16538. var jsonpatch = ($__jsonpatch__ = require("jsonpatch"), $__jsonpatch__ && $__jsonpatch__.__esModule && $__jsonpatch__ || {default: $__jsonpatch__}).default;
  16539. ;
  16540. function ObserveChanges() {}
  16541. Handsontable.hooks.add('afterLoadData', init);
  16542. Handsontable.hooks.add('afterUpdateSettings', init);
  16543. Handsontable.hooks.register('afterChangesObserved');
  16544. function init() {
  16545. var instance = this;
  16546. var pluginEnabled = instance.getSettings().observeChanges;
  16547. if (pluginEnabled) {
  16548. if (instance.observer) {
  16549. destroy.call(instance);
  16550. }
  16551. createObserver.call(instance);
  16552. bindEvents.call(instance);
  16553. } else if (!pluginEnabled) {
  16554. destroy.call(instance);
  16555. }
  16556. }
  16557. function createObserver() {
  16558. var instance = this;
  16559. instance.observeChangesActive = true;
  16560. instance.pauseObservingChanges = function() {
  16561. instance.observeChangesActive = false;
  16562. };
  16563. instance.resumeObservingChanges = function() {
  16564. instance.observeChangesActive = true;
  16565. };
  16566. instance.observedData = instance.getSourceData();
  16567. instance.observer = jsonpatch.observe(instance.observedData, function(patches) {
  16568. if (instance.observeChangesActive) {
  16569. runHookForOperation.call(instance, patches);
  16570. instance.render();
  16571. }
  16572. instance.runHooks('afterChangesObserved');
  16573. });
  16574. }
  16575. function runHookForOperation(rawPatches) {
  16576. var instance = this;
  16577. var patches = cleanPatches(rawPatches);
  16578. for (var i = 0,
  16579. len = patches.length; i < len; i++) {
  16580. var patch = patches[i];
  16581. var parsedPath = parsePath(patch.path);
  16582. switch (patch.op) {
  16583. case 'add':
  16584. if (isNaN(parsedPath.col)) {
  16585. instance.runHooks('afterCreateRow', parsedPath.row);
  16586. } else {
  16587. instance.runHooks('afterCreateCol', parsedPath.col);
  16588. }
  16589. break;
  16590. case 'remove':
  16591. if (isNaN(parsedPath.col)) {
  16592. instance.runHooks('afterRemoveRow', parsedPath.row, 1);
  16593. } else {
  16594. instance.runHooks('afterRemoveCol', parsedPath.col, 1);
  16595. }
  16596. break;
  16597. case 'replace':
  16598. instance.runHooks('afterChange', [parsedPath.row, parsedPath.col, null, patch.value], 'external');
  16599. break;
  16600. }
  16601. }
  16602. function cleanPatches(rawPatches) {
  16603. var patches;
  16604. patches = removeLengthRelatedPatches(rawPatches);
  16605. patches = removeMultipleAddOrRemoveColPatches(patches);
  16606. return patches;
  16607. }
  16608. function removeMultipleAddOrRemoveColPatches(rawPatches) {
  16609. var newOrRemovedColumns = [];
  16610. return rawPatches.filter(function(patch) {
  16611. var parsedPath = parsePath(patch.path);
  16612. if (['add', 'remove'].indexOf(patch.op) != -1 && !isNaN(parsedPath.col)) {
  16613. if (newOrRemovedColumns.indexOf(parsedPath.col) != -1) {
  16614. return false;
  16615. } else {
  16616. newOrRemovedColumns.push(parsedPath.col);
  16617. }
  16618. }
  16619. return true;
  16620. });
  16621. }
  16622. function removeLengthRelatedPatches(rawPatches) {
  16623. return rawPatches.filter(function(patch) {
  16624. return !/[/]length/ig.test(patch.path);
  16625. });
  16626. }
  16627. function parsePath(path) {
  16628. var match = path.match(/^\/(\d+)\/?(.*)?$/);
  16629. return {
  16630. row: parseInt(match[1], 10),
  16631. col: /^\d*$/.test(match[2]) ? parseInt(match[2], 10) : match[2]
  16632. };
  16633. }
  16634. }
  16635. function destroy() {
  16636. var instance = this;
  16637. if (instance.observer) {
  16638. destroyObserver.call(instance);
  16639. unbindEvents.call(instance);
  16640. }
  16641. }
  16642. function destroyObserver() {
  16643. var instance = this;
  16644. jsonpatch.unobserve(instance.observedData, instance.observer);
  16645. delete instance.observedData;
  16646. delete instance.observeChangesActive;
  16647. delete instance.pauseObservingChanges;
  16648. delete instance.resumeObservingChanges;
  16649. }
  16650. function bindEvents() {
  16651. var instance = this;
  16652. instance.addHook('afterDestroy', destroy);
  16653. instance.addHook('afterCreateRow', afterTableAlter);
  16654. instance.addHook('afterRemoveRow', afterTableAlter);
  16655. instance.addHook('afterCreateCol', afterTableAlter);
  16656. instance.addHook('afterRemoveCol', afterTableAlter);
  16657. instance.addHook('afterChange', function(changes, source) {
  16658. if (source != 'loadData') {
  16659. afterTableAlter.call(this);
  16660. }
  16661. });
  16662. }
  16663. function unbindEvents() {
  16664. var instance = this;
  16665. instance.removeHook('afterDestroy', destroy);
  16666. instance.removeHook('afterCreateRow', afterTableAlter);
  16667. instance.removeHook('afterRemoveRow', afterTableAlter);
  16668. instance.removeHook('afterCreateCol', afterTableAlter);
  16669. instance.removeHook('afterRemoveCol', afterTableAlter);
  16670. instance.removeHook('afterChange', afterTableAlter);
  16671. }
  16672. function afterTableAlter() {
  16673. var instance = this;
  16674. instance.pauseObservingChanges();
  16675. instance.addHookOnce('afterChangesObserved', function() {
  16676. instance.resumeObservingChanges();
  16677. });
  16678. }
  16679. //#
  16680. },{"jsonpatch":"jsonpatch","plugins":57}],84:[function(require,module,exports){
  16681. "use strict";
  16682. Object.defineProperties(exports, {
  16683. HandsontablePersistentState: {get: function() {
  16684. return HandsontablePersistentState;
  16685. }},
  16686. __esModule: {value: true}
  16687. });
  16688. var $___46__46__47__46__46__47_plugins__;
  16689. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  16690. ;
  16691. function Storage(prefix) {
  16692. var savedKeys;
  16693. var saveSavedKeys = function() {
  16694. window.localStorage[prefix + '__' + 'persistentStateKeys'] = JSON.stringify(savedKeys);
  16695. };
  16696. var loadSavedKeys = function() {
  16697. var keysJSON = window.localStorage[prefix + '__' + 'persistentStateKeys'];
  16698. var keys = typeof keysJSON == 'string' ? JSON.parse(keysJSON) : void 0;
  16699. savedKeys = keys ? keys : [];
  16700. };
  16701. var clearSavedKeys = function() {
  16702. savedKeys = [];
  16703. saveSavedKeys();
  16704. };
  16705. loadSavedKeys();
  16706. this.saveValue = function(key, value) {
  16707. window.localStorage[prefix + '_' + key] = JSON.stringify(value);
  16708. if (savedKeys.indexOf(key) == -1) {
  16709. savedKeys.push(key);
  16710. saveSavedKeys();
  16711. }
  16712. };
  16713. this.loadValue = function(key, defaultValue) {
  16714. key = typeof key === 'undefined' ? defaultValue : key;
  16715. var value = window.localStorage[prefix + '_' + key];
  16716. return typeof value == 'undefined' ? void 0 : JSON.parse(value);
  16717. };
  16718. this.reset = function(key) {
  16719. window.localStorage.removeItem(prefix + '_' + key);
  16720. };
  16721. this.resetAll = function() {
  16722. for (var index = 0; index < savedKeys.length; index++) {
  16723. window.localStorage.removeItem(prefix + '_' + savedKeys[index]);
  16724. }
  16725. clearSavedKeys();
  16726. };
  16727. }
  16728. function HandsontablePersistentState() {
  16729. var plugin = this;
  16730. this.init = function() {
  16731. var instance = this,
  16732. pluginSettings = instance.getSettings().persistentState;
  16733. plugin.enabled = !!(pluginSettings);
  16734. if (!plugin.enabled) {
  16735. removeHooks.call(instance);
  16736. return;
  16737. }
  16738. if (!instance.storage) {
  16739. instance.storage = new Storage(instance.rootElement.id);
  16740. }
  16741. instance.resetState = plugin.resetValue;
  16742. addHooks.call(instance);
  16743. };
  16744. this.saveValue = function(key, value) {
  16745. var instance = this;
  16746. instance.storage.saveValue(key, value);
  16747. };
  16748. this.loadValue = function(key, saveTo) {
  16749. var instance = this;
  16750. saveTo.value = instance.storage.loadValue(key);
  16751. };
  16752. this.resetValue = function(key) {
  16753. var instance = this;
  16754. if (typeof key === 'undefined') {
  16755. instance.storage.resetAll();
  16756. } else {
  16757. instance.storage.reset(key);
  16758. }
  16759. };
  16760. var hooks = {
  16761. persistentStateSave: plugin.saveValue,
  16762. persistentStateLoad: plugin.loadValue,
  16763. persistentStateReset: plugin.resetValue
  16764. };
  16765. for (var hookName in hooks) {
  16766. if (hooks.hasOwnProperty(hookName)) {
  16767. Handsontable.hooks.register(hookName);
  16768. }
  16769. }
  16770. function addHooks() {
  16771. var instance = this;
  16772. for (var hookName in hooks) {
  16773. if (hooks.hasOwnProperty(hookName)) {
  16774. instance.addHook(hookName, hooks[hookName]);
  16775. }
  16776. }
  16777. }
  16778. function removeHooks() {
  16779. var instance = this;
  16780. for (var hookName in hooks) {
  16781. if (hooks.hasOwnProperty(hookName)) {
  16782. instance.removeHook(hookName, hooks[hookName]);
  16783. }
  16784. }
  16785. }
  16786. }
  16787. var htPersistentState = new HandsontablePersistentState();
  16788. Handsontable.hooks.add('beforeInit', htPersistentState.init);
  16789. Handsontable.hooks.add('afterUpdateSettings', htPersistentState.init);
  16790. //#
  16791. },{"plugins":57}],85:[function(require,module,exports){
  16792. "use strict";
  16793. var $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  16794. $___46__46__47__46__46__47_renderers__;
  16795. var $__0 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  16796. addClass = $__0.addClass,
  16797. removeClass = $__0.removeClass;
  16798. var $__1 = ($___46__46__47__46__46__47_renderers__ = require("renderers"), $___46__46__47__46__46__47_renderers__ && $___46__46__47__46__46__47_renderers__.__esModule && $___46__46__47__46__46__47_renderers__ || {default: $___46__46__47__46__46__47_renderers__}),
  16799. registerRenderer = $__1.registerRenderer,
  16800. getRenderer = $__1.getRenderer;
  16801. Handsontable.Search = function Search(instance) {
  16802. this.query = function(queryStr, callback, queryMethod) {
  16803. var rowCount = instance.countRows();
  16804. var colCount = instance.countCols();
  16805. var queryResult = [];
  16806. if (!callback) {
  16807. callback = Handsontable.Search.global.getDefaultCallback();
  16808. }
  16809. if (!queryMethod) {
  16810. queryMethod = Handsontable.Search.global.getDefaultQueryMethod();
  16811. }
  16812. for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) {
  16813. for (var colIndex = 0; colIndex < colCount; colIndex++) {
  16814. var cellData = instance.getDataAtCell(rowIndex, colIndex);
  16815. var cellProperties = instance.getCellMeta(rowIndex, colIndex);
  16816. var cellCallback = cellProperties.search.callback || callback;
  16817. var cellQueryMethod = cellProperties.search.queryMethod || queryMethod;
  16818. var testResult = cellQueryMethod(queryStr, cellData);
  16819. if (testResult) {
  16820. var singleResult = {
  16821. row: rowIndex,
  16822. col: colIndex,
  16823. data: cellData
  16824. };
  16825. queryResult.push(singleResult);
  16826. }
  16827. if (cellCallback) {
  16828. cellCallback(instance, rowIndex, colIndex, cellData, testResult);
  16829. }
  16830. }
  16831. }
  16832. return queryResult;
  16833. };
  16834. };
  16835. Handsontable.Search.DEFAULT_CALLBACK = function(instance, row, col, data, testResult) {
  16836. instance.getCellMeta(row, col).isSearchResult = testResult;
  16837. };
  16838. Handsontable.Search.DEFAULT_QUERY_METHOD = function(query, value) {
  16839. if (typeof query == 'undefined' || query == null || !query.toLowerCase || query.length === 0) {
  16840. return false;
  16841. }
  16842. if (typeof value == 'undefined' || value == null) {
  16843. return false;
  16844. }
  16845. return value.toString().toLowerCase().indexOf(query.toLowerCase()) != -1;
  16846. };
  16847. Handsontable.Search.DEFAULT_SEARCH_RESULT_CLASS = 'htSearchResult';
  16848. Handsontable.Search.global = (function() {
  16849. var defaultCallback = Handsontable.Search.DEFAULT_CALLBACK;
  16850. var defaultQueryMethod = Handsontable.Search.DEFAULT_QUERY_METHOD;
  16851. var defaultSearchResultClass = Handsontable.Search.DEFAULT_SEARCH_RESULT_CLASS;
  16852. return {
  16853. getDefaultCallback: function() {
  16854. return defaultCallback;
  16855. },
  16856. setDefaultCallback: function(newDefaultCallback) {
  16857. defaultCallback = newDefaultCallback;
  16858. },
  16859. getDefaultQueryMethod: function() {
  16860. return defaultQueryMethod;
  16861. },
  16862. setDefaultQueryMethod: function(newDefaultQueryMethod) {
  16863. defaultQueryMethod = newDefaultQueryMethod;
  16864. },
  16865. getDefaultSearchResultClass: function() {
  16866. return defaultSearchResultClass;
  16867. },
  16868. setDefaultSearchResultClass: function(newSearchResultClass) {
  16869. defaultSearchResultClass = newSearchResultClass;
  16870. }
  16871. };
  16872. })();
  16873. Handsontable.SearchCellDecorator = function(instance, TD, row, col, prop, value, cellProperties) {
  16874. var searchResultClass = (cellProperties.search !== null && typeof cellProperties.search == 'object' && cellProperties.search.searchResultClass) || Handsontable.Search.global.getDefaultSearchResultClass();
  16875. if (cellProperties.isSearchResult) {
  16876. addClass(TD, searchResultClass);
  16877. } else {
  16878. removeClass(TD, searchResultClass);
  16879. }
  16880. };
  16881. var originalBaseRenderer = getRenderer('base');
  16882. registerRenderer('base', function(instance, TD, row, col, prop, value, cellProperties) {
  16883. originalBaseRenderer.apply(this, arguments);
  16884. Handsontable.SearchCellDecorator.apply(this, arguments);
  16885. });
  16886. function init() {
  16887. var instance = this;
  16888. var pluginEnabled = !!instance.getSettings().search;
  16889. if (pluginEnabled) {
  16890. instance.search = new Handsontable.Search(instance);
  16891. } else {
  16892. delete instance.search;
  16893. }
  16894. }
  16895. Handsontable.hooks.add('afterInit', init);
  16896. Handsontable.hooks.add('afterUpdateSettings', init);
  16897. //#
  16898. },{"helpers/dom/element":45,"renderers":88}],86:[function(require,module,exports){
  16899. "use strict";
  16900. Object.defineProperties(exports, {
  16901. TouchScroll: {get: function() {
  16902. return TouchScroll;
  16903. }},
  16904. __esModule: {value: true}
  16905. });
  16906. var $___46__46__47__46__46__47_helpers_47_dom_47_element__,
  16907. $___46__46__47__95_base__,
  16908. $___46__46__47__46__46__47_plugins__;
  16909. var $__0 = ($___46__46__47__46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47__46__46__47_helpers_47_dom_47_element__ && $___46__46__47__46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_element__}),
  16910. addClass = $__0.addClass,
  16911. removeClass = $__0.removeClass;
  16912. var BasePlugin = ($___46__46__47__95_base__ = require("_base"), $___46__46__47__95_base__ && $___46__46__47__95_base__.__esModule && $___46__46__47__95_base__ || {default: $___46__46__47__95_base__}).default;
  16913. var registerPlugin = ($___46__46__47__46__46__47_plugins__ = require("plugins"), $___46__46__47__46__46__47_plugins__ && $___46__46__47__46__46__47_plugins__.__esModule && $___46__46__47__46__46__47_plugins__ || {default: $___46__46__47__46__46__47_plugins__}).registerPlugin;
  16914. var TouchScroll = function TouchScroll(hotInstance) {
  16915. var $__3 = this;
  16916. $traceurRuntime.superConstructor($TouchScroll).call(this, hotInstance);
  16917. this.hot.addHook('afterInit', (function() {
  16918. return $__3.afterInit();
  16919. }));
  16920. this.hot.addHook('afterUpdateSettings', (function() {
  16921. return $__3.onAfterUpdateSettings();
  16922. }));
  16923. this.scrollbars = [];
  16924. this.clones = [];
  16925. };
  16926. var $TouchScroll = TouchScroll;
  16927. ($traceurRuntime.createClass)(TouchScroll, {
  16928. afterInit: function() {
  16929. this.registerEvents();
  16930. this.onAfterUpdateSettings();
  16931. },
  16932. onAfterUpdateSettings: function() {
  16933. var _this = this;
  16934. this.hot.addHookOnce('afterRender', function() {
  16935. var wtOverlays = _this.hot.view.wt.wtOverlays;
  16936. _this.scrollbars = [];
  16937. _this.scrollbars.push(wtOverlays.topOverlay);
  16938. if (wtOverlays.bottomOverlay.clone) {
  16939. _this.scrollbars.push(wtOverlays.bottomOverlay);
  16940. }
  16941. _this.scrollbars.push(wtOverlays.leftOverlay);
  16942. if (wtOverlays.topLeftCornerOverlay) {
  16943. _this.scrollbars.push(wtOverlays.topLeftCornerOverlay);
  16944. }
  16945. if (wtOverlays.bottomLeftCornerOverlay && wtOverlays.bottomLeftCornerOverlay.clone) {
  16946. _this.scrollbars.push(wtOverlays.bottomLeftCornerOverlay);
  16947. }
  16948. _this.clones = [];
  16949. if (wtOverlays.topOverlay.needFullRender) {
  16950. _this.clones.push(wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  16951. }
  16952. if (wtOverlays.bottomOverlay.needFullRender) {
  16953. _this.clones.push(wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode);
  16954. }
  16955. if (wtOverlays.leftOverlay.needFullRender) {
  16956. _this.clones.push(wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  16957. }
  16958. if (wtOverlays.topLeftCornerOverlay) {
  16959. _this.clones.push(wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  16960. }
  16961. if (wtOverlays.bottomLeftCornerOverlay && wtOverlays.bottomLeftCornerOverlay.clone) {
  16962. _this.clones.push(wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  16963. }
  16964. });
  16965. },
  16966. registerEvents: function() {
  16967. var $__3 = this;
  16968. this.hot.addHook('beforeTouchScroll', (function() {
  16969. return $__3.onBeforeTouchScroll();
  16970. }));
  16971. this.hot.addHook('afterMomentumScroll', (function() {
  16972. return $__3.onAfterMomentumScroll();
  16973. }));
  16974. },
  16975. onBeforeTouchScroll: function() {
  16976. Handsontable.freezeOverlays = true;
  16977. for (var i = 0,
  16978. cloneCount = this.clones.length; i < cloneCount; i++) {
  16979. addClass(this.clones[i], 'hide-tween');
  16980. }
  16981. },
  16982. onAfterMomentumScroll: function() {
  16983. Handsontable.freezeOverlays = false;
  16984. var _that = this;
  16985. for (var i = 0,
  16986. cloneCount = this.clones.length; i < cloneCount; i++) {
  16987. removeClass(this.clones[i], 'hide-tween');
  16988. }
  16989. for (var i$__5 = 0,
  16990. cloneCount$__6 = this.clones.length; i$__5 < cloneCount$__6; i$__5++) {
  16991. addClass(this.clones[i$__5], 'show-tween');
  16992. }
  16993. setTimeout(function() {
  16994. for (var i = 0,
  16995. cloneCount = _that.clones.length; i < cloneCount; i++) {
  16996. removeClass(_that.clones[i], 'show-tween');
  16997. }
  16998. }, 400);
  16999. for (var i$__7 = 0,
  17000. cloneCount$__8 = this.scrollbars.length; i$__7 < cloneCount$__8; i$__7++) {
  17001. this.scrollbars[i$__7].refresh();
  17002. this.scrollbars[i$__7].resetFixedPosition();
  17003. }
  17004. this.hot.view.wt.wtOverlays.syncScrollWithMaster();
  17005. }
  17006. }, {}, BasePlugin);
  17007. ;
  17008. registerPlugin('touchScroll', TouchScroll);
  17009. //#
  17010. },{"_base":58,"helpers/dom/element":45,"plugins":57}],87:[function(require,module,exports){
  17011. "use strict";
  17012. var $___46__46__47__46__46__47_helpers_47_object__,
  17013. $___46__46__47__46__46__47_helpers_47_dom_47_event__;
  17014. var $__0 = ($___46__46__47__46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47__46__46__47_helpers_47_object__ && $___46__46__47__46__46__47_helpers_47_object__.__esModule && $___46__46__47__46__46__47_helpers_47_object__ || {default: $___46__46__47__46__46__47_helpers_47_object__}),
  17015. inherit = $__0.inherit,
  17016. deepClone = $__0.deepClone;
  17017. var stopImmediatePropagation = ($___46__46__47__46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47__46__46__47_helpers_47_dom_47_event__ && $___46__46__47__46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47__46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47__46__46__47_helpers_47_dom_47_event__}).stopImmediatePropagation;
  17018. Handsontable.UndoRedo = function(instance) {
  17019. var plugin = this;
  17020. this.instance = instance;
  17021. this.doneActions = [];
  17022. this.undoneActions = [];
  17023. this.ignoreNewActions = false;
  17024. instance.addHook('afterChange', function(changes, origin) {
  17025. if (changes) {
  17026. var action = new Handsontable.UndoRedo.ChangeAction(changes);
  17027. plugin.done(action);
  17028. }
  17029. });
  17030. instance.addHook('afterCreateRow', function(index, amount, createdAutomatically) {
  17031. if (createdAutomatically) {
  17032. return;
  17033. }
  17034. var action = new Handsontable.UndoRedo.CreateRowAction(index, amount);
  17035. plugin.done(action);
  17036. });
  17037. instance.addHook('beforeRemoveRow', function(index, amount) {
  17038. var originalData = plugin.instance.getSourceData();
  17039. index = (originalData.length + index) % originalData.length;
  17040. var removedData = originalData.slice(index, index + amount);
  17041. var action = new Handsontable.UndoRedo.RemoveRowAction(index, removedData);
  17042. plugin.done(action);
  17043. });
  17044. instance.addHook('afterCreateCol', function(index, amount, createdAutomatically) {
  17045. if (createdAutomatically) {
  17046. return;
  17047. }
  17048. var action = new Handsontable.UndoRedo.CreateColumnAction(index, amount);
  17049. plugin.done(action);
  17050. });
  17051. instance.addHook('beforeRemoveCol', function(index, amount) {
  17052. var originalData = plugin.instance.getSourceData();
  17053. index = (plugin.instance.countCols() + index) % plugin.instance.countCols();
  17054. var removedData = [];
  17055. for (var i = 0,
  17056. len = originalData.length; i < len; i++) {
  17057. removedData[i] = originalData[i].slice(index, index + amount);
  17058. }
  17059. var headers;
  17060. if (Array.isArray(instance.getSettings().colHeaders)) {
  17061. headers = instance.getSettings().colHeaders.slice(index, index + removedData.length);
  17062. }
  17063. var action = new Handsontable.UndoRedo.RemoveColumnAction(index, removedData, headers);
  17064. plugin.done(action);
  17065. });
  17066. instance.addHook('beforeCellAlignment', function(stateBefore, range, type, alignment) {
  17067. var action = new Handsontable.UndoRedo.CellAlignmentAction(stateBefore, range, type, alignment);
  17068. plugin.done(action);
  17069. });
  17070. };
  17071. Handsontable.UndoRedo.prototype.done = function(action) {
  17072. if (!this.ignoreNewActions) {
  17073. this.doneActions.push(action);
  17074. this.undoneActions.length = 0;
  17075. }
  17076. };
  17077. Handsontable.UndoRedo.prototype.undo = function() {
  17078. if (this.isUndoAvailable()) {
  17079. var action = this.doneActions.pop();
  17080. this.ignoreNewActions = true;
  17081. var that = this;
  17082. action.undo(this.instance, function() {
  17083. that.ignoreNewActions = false;
  17084. that.undoneActions.push(action);
  17085. });
  17086. }
  17087. };
  17088. Handsontable.UndoRedo.prototype.redo = function() {
  17089. if (this.isRedoAvailable()) {
  17090. var action = this.undoneActions.pop();
  17091. this.ignoreNewActions = true;
  17092. var that = this;
  17093. action.redo(this.instance, function() {
  17094. that.ignoreNewActions = false;
  17095. that.doneActions.push(action);
  17096. });
  17097. }
  17098. };
  17099. Handsontable.UndoRedo.prototype.isUndoAvailable = function() {
  17100. return this.doneActions.length > 0;
  17101. };
  17102. Handsontable.UndoRedo.prototype.isRedoAvailable = function() {
  17103. return this.undoneActions.length > 0;
  17104. };
  17105. Handsontable.UndoRedo.prototype.clear = function() {
  17106. this.doneActions.length = 0;
  17107. this.undoneActions.length = 0;
  17108. };
  17109. Handsontable.UndoRedo.Action = function() {};
  17110. Handsontable.UndoRedo.Action.prototype.undo = function() {};
  17111. Handsontable.UndoRedo.Action.prototype.redo = function() {};
  17112. Handsontable.UndoRedo.ChangeAction = function(changes) {
  17113. this.changes = changes;
  17114. };
  17115. inherit(Handsontable.UndoRedo.ChangeAction, Handsontable.UndoRedo.Action);
  17116. Handsontable.UndoRedo.ChangeAction.prototype.undo = function(instance, undoneCallback) {
  17117. var data = deepClone(this.changes),
  17118. emptyRowsAtTheEnd = instance.countEmptyRows(true),
  17119. emptyColsAtTheEnd = instance.countEmptyCols(true);
  17120. for (var i = 0,
  17121. len = data.length; i < len; i++) {
  17122. data[i].splice(3, 1);
  17123. }
  17124. instance.addHookOnce('afterChange', undoneCallback);
  17125. instance.setDataAtRowProp(data, null, null, 'undo');
  17126. for (var i = 0,
  17127. len = data.length; i < len; i++) {
  17128. if (instance.getSettings().minSpareRows && data[i][0] + 1 + instance.getSettings().minSpareRows === instance.countRows() && emptyRowsAtTheEnd == instance.getSettings().minSpareRows) {
  17129. instance.alter('remove_row', parseInt(data[i][0] + 1, 10), instance.getSettings().minSpareRows);
  17130. instance.undoRedo.doneActions.pop();
  17131. }
  17132. if (instance.getSettings().minSpareCols && data[i][1] + 1 + instance.getSettings().minSpareCols === instance.countCols() && emptyColsAtTheEnd == instance.getSettings().minSpareCols) {
  17133. instance.alter('remove_col', parseInt(data[i][1] + 1, 10), instance.getSettings().minSpareCols);
  17134. instance.undoRedo.doneActions.pop();
  17135. }
  17136. }
  17137. };
  17138. Handsontable.UndoRedo.ChangeAction.prototype.redo = function(instance, onFinishCallback) {
  17139. var data = deepClone(this.changes);
  17140. for (var i = 0,
  17141. len = data.length; i < len; i++) {
  17142. data[i].splice(2, 1);
  17143. }
  17144. instance.addHookOnce('afterChange', onFinishCallback);
  17145. instance.setDataAtRowProp(data, null, null, 'redo');
  17146. };
  17147. Handsontable.UndoRedo.CreateRowAction = function(index, amount) {
  17148. this.index = index;
  17149. this.amount = amount;
  17150. };
  17151. inherit(Handsontable.UndoRedo.CreateRowAction, Handsontable.UndoRedo.Action);
  17152. Handsontable.UndoRedo.CreateRowAction.prototype.undo = function(instance, undoneCallback) {
  17153. var rowCount = instance.countRows(),
  17154. minSpareRows = instance.getSettings().minSpareRows;
  17155. if (this.index >= rowCount && this.index - minSpareRows < rowCount) {
  17156. this.index -= minSpareRows;
  17157. }
  17158. instance.addHookOnce('afterRemoveRow', undoneCallback);
  17159. instance.alter('remove_row', this.index, this.amount);
  17160. };
  17161. Handsontable.UndoRedo.CreateRowAction.prototype.redo = function(instance, redoneCallback) {
  17162. instance.addHookOnce('afterCreateRow', redoneCallback);
  17163. instance.alter('insert_row', this.index + 1, this.amount);
  17164. };
  17165. Handsontable.UndoRedo.RemoveRowAction = function(index, data) {
  17166. this.index = index;
  17167. this.data = data;
  17168. };
  17169. inherit(Handsontable.UndoRedo.RemoveRowAction, Handsontable.UndoRedo.Action);
  17170. Handsontable.UndoRedo.RemoveRowAction.prototype.undo = function(instance, undoneCallback) {
  17171. var spliceArgs = [this.index, 0];
  17172. Array.prototype.push.apply(spliceArgs, this.data);
  17173. Array.prototype.splice.apply(instance.getSourceData(), spliceArgs);
  17174. instance.addHookOnce('afterRender', undoneCallback);
  17175. instance.render();
  17176. };
  17177. Handsontable.UndoRedo.RemoveRowAction.prototype.redo = function(instance, redoneCallback) {
  17178. instance.addHookOnce('afterRemoveRow', redoneCallback);
  17179. instance.alter('remove_row', this.index, this.data.length);
  17180. };
  17181. Handsontable.UndoRedo.CreateColumnAction = function(index, amount) {
  17182. this.index = index;
  17183. this.amount = amount;
  17184. };
  17185. inherit(Handsontable.UndoRedo.CreateColumnAction, Handsontable.UndoRedo.Action);
  17186. Handsontable.UndoRedo.CreateColumnAction.prototype.undo = function(instance, undoneCallback) {
  17187. instance.addHookOnce('afterRemoveCol', undoneCallback);
  17188. instance.alter('remove_col', this.index, this.amount);
  17189. };
  17190. Handsontable.UndoRedo.CreateColumnAction.prototype.redo = function(instance, redoneCallback) {
  17191. instance.addHookOnce('afterCreateCol', redoneCallback);
  17192. instance.alter('insert_col', this.index + 1, this.amount);
  17193. };
  17194. Handsontable.UndoRedo.CellAlignmentAction = function(stateBefore, range, type, alignment) {
  17195. this.stateBefore = stateBefore;
  17196. this.range = range;
  17197. this.type = type;
  17198. this.alignment = alignment;
  17199. };
  17200. Handsontable.UndoRedo.CellAlignmentAction.prototype.undo = function(instance, undoneCallback) {
  17201. if (!instance.getPlugin('contextMenu').isEnabled()) {
  17202. return;
  17203. }
  17204. for (var row = this.range.from.row; row <= this.range.to.row; row++) {
  17205. for (var col = this.range.from.col; col <= this.range.to.col; col++) {
  17206. instance.setCellMeta(row, col, 'className', this.stateBefore[row][col] || ' htLeft');
  17207. }
  17208. }
  17209. instance.addHookOnce('afterRender', undoneCallback);
  17210. instance.render();
  17211. };
  17212. Handsontable.UndoRedo.CellAlignmentAction.prototype.redo = function(instance, undoneCallback) {
  17213. if (!instance.getPlugin('contextMenu').isEnabled()) {
  17214. return;
  17215. }
  17216. instance.selectCell(this.range.from.row, this.range.from.col, this.range.to.row, this.range.to.col);
  17217. instance.getPlugin('contextMenu').executeCommand('alignment:' + this.alignment.replace('ht', '').toLowerCase());
  17218. instance.addHookOnce('afterRender', undoneCallback);
  17219. instance.render();
  17220. };
  17221. Handsontable.UndoRedo.RemoveColumnAction = function(index, data, headers) {
  17222. this.index = index;
  17223. this.data = data;
  17224. this.amount = this.data[0].length;
  17225. this.headers = headers;
  17226. };
  17227. inherit(Handsontable.UndoRedo.RemoveColumnAction, Handsontable.UndoRedo.Action);
  17228. Handsontable.UndoRedo.RemoveColumnAction.prototype.undo = function(instance, undoneCallback) {
  17229. var row,
  17230. spliceArgs;
  17231. for (var i = 0,
  17232. len = instance.getSourceData().length; i < len; i++) {
  17233. row = instance.getSourceDataAtRow(i);
  17234. spliceArgs = [this.index, 0];
  17235. Array.prototype.push.apply(spliceArgs, this.data[i]);
  17236. Array.prototype.splice.apply(row, spliceArgs);
  17237. }
  17238. if (typeof this.headers != 'undefined') {
  17239. spliceArgs = [this.index, 0];
  17240. Array.prototype.push.apply(spliceArgs, this.headers);
  17241. Array.prototype.splice.apply(instance.getSettings().colHeaders, spliceArgs);
  17242. }
  17243. instance.addHookOnce('afterRender', undoneCallback);
  17244. instance.render();
  17245. };
  17246. Handsontable.UndoRedo.RemoveColumnAction.prototype.redo = function(instance, redoneCallback) {
  17247. instance.addHookOnce('afterRemoveCol', redoneCallback);
  17248. instance.alter('remove_col', this.index, this.amount);
  17249. };
  17250. function init() {
  17251. var instance = this;
  17252. var pluginEnabled = typeof instance.getSettings().undo == 'undefined' || instance.getSettings().undo;
  17253. if (pluginEnabled) {
  17254. if (!instance.undoRedo) {
  17255. instance.undoRedo = new Handsontable.UndoRedo(instance);
  17256. exposeUndoRedoMethods(instance);
  17257. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  17258. instance.addHook('afterChange', onAfterChange);
  17259. }
  17260. } else {
  17261. if (instance.undoRedo) {
  17262. delete instance.undoRedo;
  17263. removeExposedUndoRedoMethods(instance);
  17264. instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  17265. instance.removeHook('afterChange', onAfterChange);
  17266. }
  17267. }
  17268. }
  17269. function onBeforeKeyDown(event) {
  17270. var instance = this;
  17271. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  17272. if (ctrlDown) {
  17273. if (event.keyCode === 89 || (event.shiftKey && event.keyCode === 90)) {
  17274. instance.undoRedo.redo();
  17275. stopImmediatePropagation(event);
  17276. } else if (event.keyCode === 90) {
  17277. instance.undoRedo.undo();
  17278. stopImmediatePropagation(event);
  17279. }
  17280. }
  17281. }
  17282. function onAfterChange(changes, source) {
  17283. var instance = this;
  17284. if (source == 'loadData') {
  17285. return instance.undoRedo.clear();
  17286. }
  17287. }
  17288. function exposeUndoRedoMethods(instance) {
  17289. instance.undo = function() {
  17290. return instance.undoRedo.undo();
  17291. };
  17292. instance.redo = function() {
  17293. return instance.undoRedo.redo();
  17294. };
  17295. instance.isUndoAvailable = function() {
  17296. return instance.undoRedo.isUndoAvailable();
  17297. };
  17298. instance.isRedoAvailable = function() {
  17299. return instance.undoRedo.isRedoAvailable();
  17300. };
  17301. instance.clearUndo = function() {
  17302. return instance.undoRedo.clear();
  17303. };
  17304. }
  17305. function removeExposedUndoRedoMethods(instance) {
  17306. delete instance.undo;
  17307. delete instance.redo;
  17308. delete instance.isUndoAvailable;
  17309. delete instance.isRedoAvailable;
  17310. delete instance.clearUndo;
  17311. }
  17312. Handsontable.hooks.add('afterInit', init);
  17313. Handsontable.hooks.add('afterUpdateSettings', init);
  17314. //#
  17315. },{"helpers/dom/event":46,"helpers/object":50}],88:[function(require,module,exports){
  17316. "use strict";
  17317. Object.defineProperties(exports, {
  17318. registerRenderer: {get: function() {
  17319. return registerRenderer;
  17320. }},
  17321. getRenderer: {get: function() {
  17322. return getRenderer;
  17323. }},
  17324. hasRenderer: {get: function() {
  17325. return hasRenderer;
  17326. }},
  17327. __esModule: {value: true}
  17328. });
  17329. var $__helpers_47_string__;
  17330. var toUpperCaseFirst = ($__helpers_47_string__ = require("helpers/string"), $__helpers_47_string__ && $__helpers_47_string__.__esModule && $__helpers_47_string__ || {default: $__helpers_47_string__}).toUpperCaseFirst;
  17331. var registeredRenderers = {};
  17332. Handsontable.renderers = Handsontable.renderers || {};
  17333. Handsontable.renderers.registerRenderer = registerRenderer;
  17334. Handsontable.renderers.getRenderer = getRenderer;
  17335. function registerRenderer(rendererName, rendererFunction) {
  17336. var registerName;
  17337. registeredRenderers[rendererName] = rendererFunction;
  17338. registerName = toUpperCaseFirst(rendererName) + 'Renderer';
  17339. Handsontable.renderers[registerName] = rendererFunction;
  17340. Handsontable[registerName] = rendererFunction;
  17341. }
  17342. function getRenderer(rendererName) {
  17343. if (typeof rendererName == 'function') {
  17344. return rendererName;
  17345. }
  17346. if (typeof rendererName != 'string') {
  17347. throw Error('Only strings and functions can be passed as "renderer" parameter');
  17348. }
  17349. if (!(rendererName in registeredRenderers)) {
  17350. throw Error('No editor registered under name "' + rendererName + '"');
  17351. }
  17352. return registeredRenderers[rendererName];
  17353. }
  17354. function hasRenderer(rendererName) {
  17355. return rendererName in registeredRenderers;
  17356. }
  17357. ;
  17358. //#
  17359. },{"helpers/string":52}],89:[function(require,module,exports){
  17360. "use strict";
  17361. Object.defineProperties(exports, {
  17362. cellDecorator: {get: function() {
  17363. return cellDecorator;
  17364. }},
  17365. __esModule: {value: true}
  17366. });
  17367. var $___46__46__47_helpers_47_dom_47_element__,
  17368. $___46__46__47_renderers__;
  17369. var $__0 = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}),
  17370. addClass = $__0.addClass,
  17371. removeClass = $__0.removeClass;
  17372. var registerRenderer = ($___46__46__47_renderers__ = require("renderers"), $___46__46__47_renderers__ && $___46__46__47_renderers__.__esModule && $___46__46__47_renderers__ || {default: $___46__46__47_renderers__}).registerRenderer;
  17373. ;
  17374. registerRenderer('base', cellDecorator);
  17375. Handsontable.renderers.cellDecorator = cellDecorator;
  17376. function cellDecorator(instance, TD, row, col, prop, value, cellProperties) {
  17377. if (cellProperties.className) {
  17378. if (TD.className) {
  17379. TD.className = TD.className + ' ' + cellProperties.className;
  17380. } else {
  17381. TD.className = cellProperties.className;
  17382. }
  17383. }
  17384. if (cellProperties.readOnly) {
  17385. addClass(TD, cellProperties.readOnlyCellClassName);
  17386. }
  17387. if (cellProperties.valid === false && cellProperties.invalidCellClassName) {
  17388. addClass(TD, cellProperties.invalidCellClassName);
  17389. } else {
  17390. removeClass(TD, cellProperties.invalidCellClassName);
  17391. }
  17392. if (cellProperties.wordWrap === false && cellProperties.noWordWrapClassName) {
  17393. addClass(TD, cellProperties.noWordWrapClassName);
  17394. }
  17395. if (!value && cellProperties.placeholder) {
  17396. addClass(TD, cellProperties.placeholderCellClassName);
  17397. }
  17398. }
  17399. //#
  17400. },{"helpers/dom/element":45,"renderers":88}],90:[function(require,module,exports){
  17401. "use strict";
  17402. Object.defineProperties(exports, {
  17403. autocompleteRenderer: {get: function() {
  17404. return autocompleteRenderer;
  17405. }},
  17406. __esModule: {value: true}
  17407. });
  17408. var $___46__46__47_helpers_47_dom_47_element__,
  17409. $___46__46__47_eventManager__,
  17410. $___46__46__47_renderers__,
  17411. $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__;
  17412. var $__0 = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}),
  17413. addClass = $__0.addClass,
  17414. hasClass = $__0.hasClass,
  17415. empty = $__0.empty;
  17416. var eventManagerObject = ($___46__46__47_eventManager__ = require("eventManager"), $___46__46__47_eventManager__ && $___46__46__47_eventManager__.__esModule && $___46__46__47_eventManager__ || {default: $___46__46__47_eventManager__}).eventManager;
  17417. var $__2 = ($___46__46__47_renderers__ = require("renderers"), $___46__46__47_renderers__ && $___46__46__47_renderers__.__esModule && $___46__46__47_renderers__ || {default: $___46__46__47_renderers__}),
  17418. getRenderer = $__2.getRenderer,
  17419. registerRenderer = $__2.registerRenderer;
  17420. var WalkontableCellCoords = ($___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ = require("3rdparty/walkontable/src/cell/coords"), $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ && $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__.__esModule && $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__ || {default: $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords__}).WalkontableCellCoords;
  17421. var clonableWRAPPER = document.createElement('DIV');
  17422. clonableWRAPPER.className = 'htAutocompleteWrapper';
  17423. var clonableARROW = document.createElement('DIV');
  17424. clonableARROW.className = 'htAutocompleteArrow';
  17425. clonableARROW.appendChild(document.createTextNode(String.fromCharCode(9660)));
  17426. var wrapTdContentWithWrapper = function(TD, WRAPPER) {
  17427. WRAPPER.innerHTML = TD.innerHTML;
  17428. empty(TD);
  17429. TD.appendChild(WRAPPER);
  17430. };
  17431. function autocompleteRenderer(instance, TD, row, col, prop, value, cellProperties) {
  17432. var WRAPPER = clonableWRAPPER.cloneNode(true);
  17433. var ARROW = clonableARROW.cloneNode(true);
  17434. getRenderer('text')(instance, TD, row, col, prop, value, cellProperties);
  17435. TD.appendChild(ARROW);
  17436. addClass(TD, 'htAutocomplete');
  17437. if (!TD.firstChild) {
  17438. TD.appendChild(document.createTextNode(String.fromCharCode(160)));
  17439. }
  17440. if (!instance.acArrowListener) {
  17441. var eventManager = eventManagerObject(instance);
  17442. instance.acArrowListener = function(event) {
  17443. if (hasClass(event.target, 'htAutocompleteArrow')) {
  17444. instance.view.wt.getSetting('onCellDblClick', null, new WalkontableCellCoords(row, col), TD);
  17445. }
  17446. };
  17447. eventManager.addEventListener(instance.rootElement, 'mousedown', instance.acArrowListener);
  17448. instance.addHookOnce('afterDestroy', function() {
  17449. eventManager.destroy();
  17450. });
  17451. }
  17452. }
  17453. ;
  17454. registerRenderer('autocomplete', autocompleteRenderer);
  17455. //#
  17456. },{"3rdparty/walkontable/src/cell/coords":5,"eventManager":41,"helpers/dom/element":45,"renderers":88}],91:[function(require,module,exports){
  17457. "use strict";
  17458. Object.defineProperties(exports, {
  17459. checkboxRenderer: {get: function() {
  17460. return checkboxRenderer;
  17461. }},
  17462. __esModule: {value: true}
  17463. });
  17464. var $___46__46__47_helpers_47_dom_47_element__,
  17465. $___46__46__47_helpers_47_string__,
  17466. $___46__46__47_eventManager__,
  17467. $___46__46__47_renderers__,
  17468. $___46__46__47_helpers_47_unicode__,
  17469. $___46__46__47_helpers_47_dom_47_event__;
  17470. var $__0 = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}),
  17471. empty = $__0.empty,
  17472. addClass = $__0.addClass,
  17473. hasClass = $__0.hasClass;
  17474. var equalsIgnoreCase = ($___46__46__47_helpers_47_string__ = require("helpers/string"), $___46__46__47_helpers_47_string__ && $___46__46__47_helpers_47_string__.__esModule && $___46__46__47_helpers_47_string__ || {default: $___46__46__47_helpers_47_string__}).equalsIgnoreCase;
  17475. var EventManager = ($___46__46__47_eventManager__ = require("eventManager"), $___46__46__47_eventManager__ && $___46__46__47_eventManager__.__esModule && $___46__46__47_eventManager__ || {default: $___46__46__47_eventManager__}).EventManager;
  17476. var $__3 = ($___46__46__47_renderers__ = require("renderers"), $___46__46__47_renderers__ && $___46__46__47_renderers__.__esModule && $___46__46__47_renderers__ || {default: $___46__46__47_renderers__}),
  17477. getRenderer = $__3.getRenderer,
  17478. registerRenderer = $__3.registerRenderer;
  17479. var KEY_CODES = ($___46__46__47_helpers_47_unicode__ = require("helpers/unicode"), $___46__46__47_helpers_47_unicode__ && $___46__46__47_helpers_47_unicode__.__esModule && $___46__46__47_helpers_47_unicode__ || {default: $___46__46__47_helpers_47_unicode__}).KEY_CODES;
  17480. var $__5 = ($___46__46__47_helpers_47_dom_47_event__ = require("helpers/dom/event"), $___46__46__47_helpers_47_dom_47_event__ && $___46__46__47_helpers_47_dom_47_event__.__esModule && $___46__46__47_helpers_47_dom_47_event__ || {default: $___46__46__47_helpers_47_dom_47_event__}),
  17481. stopPropagation = $__5.stopPropagation,
  17482. stopImmediatePropagation = $__5.stopImmediatePropagation,
  17483. isImmediatePropagationStopped = $__5.isImmediatePropagationStopped;
  17484. var isListeningKeyDownEvent = new WeakMap();
  17485. var BAD_VALUE_CLASS = 'htBadValue';
  17486. function checkboxRenderer(instance, TD, row, col, prop, value, cellProperties) {
  17487. var eventManager = new EventManager(instance);
  17488. var input = createInput();
  17489. var labelOptions = cellProperties.label;
  17490. var badValue = false;
  17491. if (typeof cellProperties.checkedTemplate === 'undefined') {
  17492. cellProperties.checkedTemplate = true;
  17493. }
  17494. if (typeof cellProperties.uncheckedTemplate === 'undefined') {
  17495. cellProperties.uncheckedTemplate = false;
  17496. }
  17497. empty(TD);
  17498. if (value === cellProperties.checkedTemplate || equalsIgnoreCase(value, cellProperties.checkedTemplate)) {
  17499. input.checked = true;
  17500. } else if (value === cellProperties.uncheckedTemplate || equalsIgnoreCase(value, cellProperties.uncheckedTemplate)) {
  17501. input.checked = false;
  17502. } else if (value === null) {
  17503. addClass(input, 'noValue');
  17504. } else {
  17505. input.style.display = 'none';
  17506. addClass(input, BAD_VALUE_CLASS);
  17507. badValue = true;
  17508. }
  17509. if (!badValue && labelOptions) {
  17510. var labelText = '';
  17511. if (labelOptions.value) {
  17512. labelText = typeof labelOptions.value === 'function' ? labelOptions.value.call(this, row, col, prop, value) : labelOptions.value;
  17513. } else if (labelOptions.property) {
  17514. labelText = instance.getDataAtRowProp(row, labelOptions.property);
  17515. }
  17516. var label = createLabel(labelText);
  17517. if (labelOptions.position === 'before') {
  17518. label.appendChild(input);
  17519. } else {
  17520. label.insertBefore(input, label.firstChild);
  17521. }
  17522. input = label;
  17523. }
  17524. TD.appendChild(input);
  17525. if (badValue) {
  17526. TD.appendChild(document.createTextNode('#bad-value#'));
  17527. }
  17528. if (cellProperties.readOnly) {
  17529. eventManager.addEventListener(input, 'click', preventDefault);
  17530. } else {
  17531. eventManager.addEventListener(input, 'mousedown', stopPropagation);
  17532. eventManager.addEventListener(input, 'mouseup', stopPropagation);
  17533. eventManager.addEventListener(input, 'change', (function(event) {
  17534. instance.setDataAtRowProp(row, prop, event.target.checked ? cellProperties.checkedTemplate : cellProperties.uncheckedTemplate);
  17535. }));
  17536. }
  17537. if (!isListeningKeyDownEvent.has(instance)) {
  17538. isListeningKeyDownEvent.set(instance, true);
  17539. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  17540. }
  17541. function onBeforeKeyDown(event) {
  17542. var allowedKeys = [KEY_CODES.SPACE, KEY_CODES.ENTER, KEY_CODES.DELETE, KEY_CODES.BACKSPACE];
  17543. if (allowedKeys.indexOf(event.keyCode) !== -1 && !isImmediatePropagationStopped(event)) {
  17544. eachSelectedCheckboxCell(function() {
  17545. stopImmediatePropagation(event);
  17546. event.preventDefault();
  17547. });
  17548. }
  17549. if (event.keyCode == KEY_CODES.SPACE || event.keyCode == KEY_CODES.ENTER) {
  17550. toggleSelected();
  17551. }
  17552. if (event.keyCode == KEY_CODES.DELETE || event.keyCode == KEY_CODES.BACKSPACE) {
  17553. toggleSelected(false);
  17554. }
  17555. }
  17556. function toggleSelected() {
  17557. var checked = arguments[0] !== (void 0) ? arguments[0] : null;
  17558. eachSelectedCheckboxCell(function(checkboxes) {
  17559. for (var i = 0,
  17560. len = checkboxes.length; i < len; i++) {
  17561. if (hasClass(checkboxes[i], BAD_VALUE_CLASS) && checked === null) {
  17562. return;
  17563. }
  17564. toggleCheckbox(checkboxes[i], checked);
  17565. }
  17566. });
  17567. }
  17568. function toggleCheckbox(checkbox) {
  17569. var checked = arguments[1] !== (void 0) ? arguments[1] : null;
  17570. if (checked === null) {
  17571. checkbox.checked = !checkbox.checked;
  17572. } else {
  17573. checkbox.checked = checked;
  17574. }
  17575. eventManager.fireEvent(checkbox, 'change');
  17576. }
  17577. function eachSelectedCheckboxCell(callback) {
  17578. var selRange = instance.getSelectedRange();
  17579. var topLeft = selRange.getTopLeftCorner();
  17580. var bottomRight = selRange.getBottomRightCorner();
  17581. for (var row = topLeft.row; row <= bottomRight.row; row++) {
  17582. for (var col = topLeft.col; col <= bottomRight.col; col++) {
  17583. var cell = instance.getCell(row, col);
  17584. var cellProperties$__6 = instance.getCellMeta(row, col);
  17585. var checkboxes = cell.querySelectorAll('input[type=checkbox]');
  17586. if (checkboxes.length > 0 && !cellProperties$__6.readOnly) {
  17587. callback(checkboxes);
  17588. }
  17589. }
  17590. }
  17591. }
  17592. }
  17593. ;
  17594. registerRenderer('checkbox', checkboxRenderer);
  17595. function createInput() {
  17596. var input = document.createElement('input');
  17597. input.className = 'htCheckboxRendererInput';
  17598. input.type = 'checkbox';
  17599. input.setAttribute('autocomplete', 'off');
  17600. return input.cloneNode(false);
  17601. }
  17602. function createLabel(text) {
  17603. var label = document.createElement('label');
  17604. label.className = 'htCheckboxRendererLabel';
  17605. label.appendChild(document.createTextNode(text));
  17606. return label.cloneNode(true);
  17607. }
  17608. function preventDefault(event) {
  17609. event.preventDefault();
  17610. }
  17611. //#
  17612. },{"eventManager":41,"helpers/dom/element":45,"helpers/dom/event":46,"helpers/string":52,"helpers/unicode":53,"renderers":88}],92:[function(require,module,exports){
  17613. "use strict";
  17614. Object.defineProperties(exports, {
  17615. htmlRenderer: {get: function() {
  17616. return htmlRenderer;
  17617. }},
  17618. __esModule: {value: true}
  17619. });
  17620. var $___46__46__47_helpers_47_dom_47_element__,
  17621. $___46__46__47_renderers__;
  17622. var fastInnerHTML = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}).fastInnerHTML;
  17623. var $__1 = ($___46__46__47_renderers__ = require("renderers"), $___46__46__47_renderers__ && $___46__46__47_renderers__.__esModule && $___46__46__47_renderers__ || {default: $___46__46__47_renderers__}),
  17624. getRenderer = $__1.getRenderer,
  17625. registerRenderer = $__1.registerRenderer;
  17626. function htmlRenderer(instance, TD, row, col, prop, value, cellProperties) {
  17627. getRenderer('base').apply(this, arguments);
  17628. fastInnerHTML(TD, value);
  17629. }
  17630. ;
  17631. registerRenderer('html', htmlRenderer);
  17632. //#
  17633. },{"helpers/dom/element":45,"renderers":88}],93:[function(require,module,exports){
  17634. "use strict";
  17635. Object.defineProperties(exports, {
  17636. numericRenderer: {get: function() {
  17637. return numericRenderer;
  17638. }},
  17639. __esModule: {value: true}
  17640. });
  17641. var $__numeral__,
  17642. $___46__46__47_helpers_47_dom_47_element__,
  17643. $___46__46__47_renderers__,
  17644. $___46__46__47_helpers_47_number__;
  17645. var numeral = ($__numeral__ = require("numeral"), $__numeral__ && $__numeral__.__esModule && $__numeral__ || {default: $__numeral__}).default;
  17646. var addClass = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}).addClass;
  17647. var $__2 = ($___46__46__47_renderers__ = require("renderers"), $___46__46__47_renderers__ && $___46__46__47_renderers__.__esModule && $___46__46__47_renderers__ || {default: $___46__46__47_renderers__}),
  17648. getRenderer = $__2.getRenderer,
  17649. registerRenderer = $__2.registerRenderer;
  17650. var isNumeric = ($___46__46__47_helpers_47_number__ = require("helpers/number"), $___46__46__47_helpers_47_number__ && $___46__46__47_helpers_47_number__.__esModule && $___46__46__47_helpers_47_number__ || {default: $___46__46__47_helpers_47_number__}).isNumeric;
  17651. function numericRenderer(instance, TD, row, col, prop, value, cellProperties) {
  17652. if (isNumeric(value)) {
  17653. if (typeof cellProperties.language !== 'undefined') {
  17654. numeral.language(cellProperties.language);
  17655. }
  17656. value = numeral(value).format(cellProperties.format || '0');
  17657. addClass(TD, 'htNumeric');
  17658. }
  17659. getRenderer('text')(instance, TD, row, col, prop, value, cellProperties);
  17660. }
  17661. ;
  17662. registerRenderer('numeric', numericRenderer);
  17663. //#
  17664. },{"helpers/dom/element":45,"helpers/number":49,"numeral":"numeral","renderers":88}],94:[function(require,module,exports){
  17665. "use strict";
  17666. Object.defineProperties(exports, {
  17667. passwordRenderer: {get: function() {
  17668. return passwordRenderer;
  17669. }},
  17670. __esModule: {value: true}
  17671. });
  17672. var $___46__46__47_helpers_47_dom_47_element__,
  17673. $___46__46__47_renderers__;
  17674. var fastInnerHTML = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}).fastInnerHTML;
  17675. var $__1 = ($___46__46__47_renderers__ = require("renderers"), $___46__46__47_renderers__ && $___46__46__47_renderers__.__esModule && $___46__46__47_renderers__ || {default: $___46__46__47_renderers__}),
  17676. getRenderer = $__1.getRenderer,
  17677. registerRenderer = $__1.registerRenderer;
  17678. function passwordRenderer(instance, TD, row, col, prop, value, cellProperties) {
  17679. getRenderer('text').apply(this, arguments);
  17680. value = TD.innerHTML;
  17681. var hash;
  17682. var hashLength = cellProperties.hashLength || value.length;
  17683. var hashSymbol = cellProperties.hashSymbol || '*';
  17684. for (hash = ''; hash.split(hashSymbol).length - 1 < hashLength; hash += hashSymbol) {}
  17685. fastInnerHTML(TD, hash);
  17686. }
  17687. ;
  17688. registerRenderer('password', passwordRenderer);
  17689. //#
  17690. },{"helpers/dom/element":45,"renderers":88}],95:[function(require,module,exports){
  17691. "use strict";
  17692. Object.defineProperties(exports, {
  17693. textRenderer: {get: function() {
  17694. return textRenderer;
  17695. }},
  17696. __esModule: {value: true}
  17697. });
  17698. var $___46__46__47_helpers_47_dom_47_element__,
  17699. $___46__46__47_helpers_47_mixed__,
  17700. $___46__46__47_renderers__;
  17701. var $__0 = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}),
  17702. empty = $__0.empty,
  17703. fastInnerText = $__0.fastInnerText;
  17704. var stringify = ($___46__46__47_helpers_47_mixed__ = require("helpers/mixed"), $___46__46__47_helpers_47_mixed__ && $___46__46__47_helpers_47_mixed__.__esModule && $___46__46__47_helpers_47_mixed__ || {default: $___46__46__47_helpers_47_mixed__}).stringify;
  17705. var $__2 = ($___46__46__47_renderers__ = require("renderers"), $___46__46__47_renderers__ && $___46__46__47_renderers__.__esModule && $___46__46__47_renderers__ || {default: $___46__46__47_renderers__}),
  17706. getRenderer = $__2.getRenderer,
  17707. registerRenderer = $__2.registerRenderer;
  17708. function textRenderer(instance, TD, row, col, prop, value, cellProperties) {
  17709. getRenderer('base').apply(this, arguments);
  17710. if (!value && cellProperties.placeholder) {
  17711. value = cellProperties.placeholder;
  17712. }
  17713. var escaped = stringify(value);
  17714. if (!instance.getSettings().trimWhitespace) {
  17715. escaped = escaped.replace(/ /g, String.fromCharCode(160));
  17716. }
  17717. if (cellProperties.rendererTemplate) {
  17718. empty(TD);
  17719. var TEMPLATE = document.createElement('TEMPLATE');
  17720. TEMPLATE.setAttribute('bind', '{{}}');
  17721. TEMPLATE.innerHTML = cellProperties.rendererTemplate;
  17722. HTMLTemplateElement.decorate(TEMPLATE);
  17723. TEMPLATE.model = instance.getSourceDataAtRow(row);
  17724. TD.appendChild(TEMPLATE);
  17725. } else {
  17726. fastInnerText(TD, escaped);
  17727. }
  17728. }
  17729. ;
  17730. registerRenderer('text', textRenderer);
  17731. //#
  17732. },{"helpers/dom/element":45,"helpers/mixed":48,"renderers":88}],96:[function(require,module,exports){
  17733. "use strict";
  17734. (function(global) {
  17735. 'use strict';
  17736. if (global.$traceurRuntime) {
  17737. return;
  17738. }
  17739. var $Object = Object;
  17740. var $TypeError = TypeError;
  17741. var $create = $Object.create;
  17742. var $defineProperties = $Object.defineProperties;
  17743. var $defineProperty = $Object.defineProperty;
  17744. var $freeze = $Object.freeze;
  17745. var $getOwnPropertyDescriptor = $Object.getOwnPropertyDescriptor;
  17746. var $getOwnPropertyNames = $Object.getOwnPropertyNames;
  17747. var $keys = $Object.keys;
  17748. var $hasOwnProperty = $Object.prototype.hasOwnProperty;
  17749. var $preventExtensions = Object.preventExtensions;
  17750. var $seal = Object.seal;
  17751. var $isExtensible = Object.isExtensible;
  17752. function nonEnum(value) {
  17753. return {
  17754. configurable: true,
  17755. enumerable: false,
  17756. value: value,
  17757. writable: true
  17758. };
  17759. }
  17760. var method = nonEnum;
  17761. var counter = 0;
  17762. function newUniqueString() {
  17763. return '__$' + Math.floor(Math.random() * 1e9) + '$' + ++counter + '$__';
  17764. }
  17765. var symbolInternalProperty = newUniqueString();
  17766. var symbolDescriptionProperty = newUniqueString();
  17767. var symbolDataProperty = newUniqueString();
  17768. var symbolValues = $create(null);
  17769. var privateNames = $create(null);
  17770. function isPrivateName(s) {
  17771. return privateNames[s];
  17772. }
  17773. function createPrivateName() {
  17774. var s = newUniqueString();
  17775. privateNames[s] = true;
  17776. return s;
  17777. }
  17778. function isShimSymbol(symbol) {
  17779. return typeof symbol === 'object' && symbol instanceof SymbolValue;
  17780. }
  17781. function typeOf(v) {
  17782. if (isShimSymbol(v))
  17783. return 'symbol';
  17784. return typeof v;
  17785. }
  17786. function Symbol(description) {
  17787. var value = new SymbolValue(description);
  17788. if (!(this instanceof Symbol))
  17789. return value;
  17790. throw new TypeError('Symbol cannot be new\'ed');
  17791. }
  17792. $defineProperty(Symbol.prototype, 'constructor', nonEnum(Symbol));
  17793. $defineProperty(Symbol.prototype, 'toString', method(function() {
  17794. var symbolValue = this[symbolDataProperty];
  17795. if (!getOption('symbols'))
  17796. return symbolValue[symbolInternalProperty];
  17797. if (!symbolValue)
  17798. throw TypeError('Conversion from symbol to string');
  17799. var desc = symbolValue[symbolDescriptionProperty];
  17800. if (desc === undefined)
  17801. desc = '';
  17802. return 'Symbol(' + desc + ')';
  17803. }));
  17804. $defineProperty(Symbol.prototype, 'valueOf', method(function() {
  17805. var symbolValue = this[symbolDataProperty];
  17806. if (!symbolValue)
  17807. throw TypeError('Conversion from symbol to string');
  17808. if (!getOption('symbols'))
  17809. return symbolValue[symbolInternalProperty];
  17810. return symbolValue;
  17811. }));
  17812. function SymbolValue(description) {
  17813. var key = newUniqueString();
  17814. $defineProperty(this, symbolDataProperty, {value: this});
  17815. $defineProperty(this, symbolInternalProperty, {value: key});
  17816. $defineProperty(this, symbolDescriptionProperty, {value: description});
  17817. freeze(this);
  17818. symbolValues[key] = this;
  17819. }
  17820. $defineProperty(SymbolValue.prototype, 'constructor', nonEnum(Symbol));
  17821. $defineProperty(SymbolValue.prototype, 'toString', {
  17822. value: Symbol.prototype.toString,
  17823. enumerable: false
  17824. });
  17825. $defineProperty(SymbolValue.prototype, 'valueOf', {
  17826. value: Symbol.prototype.valueOf,
  17827. enumerable: false
  17828. });
  17829. var hashProperty = createPrivateName();
  17830. var hashPropertyDescriptor = {value: undefined};
  17831. var hashObjectProperties = {
  17832. hash: {value: undefined},
  17833. self: {value: undefined}
  17834. };
  17835. var hashCounter = 0;
  17836. function getOwnHashObject(object) {
  17837. var hashObject = object[hashProperty];
  17838. if (hashObject && hashObject.self === object)
  17839. return hashObject;
  17840. if ($isExtensible(object)) {
  17841. hashObjectProperties.hash.value = hashCounter++;
  17842. hashObjectProperties.self.value = object;
  17843. hashPropertyDescriptor.value = $create(null, hashObjectProperties);
  17844. $defineProperty(object, hashProperty, hashPropertyDescriptor);
  17845. return hashPropertyDescriptor.value;
  17846. }
  17847. return undefined;
  17848. }
  17849. function freeze(object) {
  17850. getOwnHashObject(object);
  17851. return $freeze.apply(this, arguments);
  17852. }
  17853. function preventExtensions(object) {
  17854. getOwnHashObject(object);
  17855. return $preventExtensions.apply(this, arguments);
  17856. }
  17857. function seal(object) {
  17858. getOwnHashObject(object);
  17859. return $seal.apply(this, arguments);
  17860. }
  17861. freeze(SymbolValue.prototype);
  17862. function isSymbolString(s) {
  17863. return symbolValues[s] || privateNames[s];
  17864. }
  17865. function toProperty(name) {
  17866. if (isShimSymbol(name))
  17867. return name[symbolInternalProperty];
  17868. return name;
  17869. }
  17870. function removeSymbolKeys(array) {
  17871. var rv = [];
  17872. for (var i = 0; i < array.length; i++) {
  17873. if (!isSymbolString(array[i])) {
  17874. rv.push(array[i]);
  17875. }
  17876. }
  17877. return rv;
  17878. }
  17879. function getOwnPropertyNames(object) {
  17880. return removeSymbolKeys($getOwnPropertyNames(object));
  17881. }
  17882. function keys(object) {
  17883. return removeSymbolKeys($keys(object));
  17884. }
  17885. function getOwnPropertySymbols(object) {
  17886. var rv = [];
  17887. var names = $getOwnPropertyNames(object);
  17888. for (var i = 0; i < names.length; i++) {
  17889. var symbol = symbolValues[names[i]];
  17890. if (symbol) {
  17891. rv.push(symbol);
  17892. }
  17893. }
  17894. return rv;
  17895. }
  17896. function getOwnPropertyDescriptor(object, name) {
  17897. return $getOwnPropertyDescriptor(object, toProperty(name));
  17898. }
  17899. function hasOwnProperty(name) {
  17900. return $hasOwnProperty.call(this, toProperty(name));
  17901. }
  17902. function getOption(name) {
  17903. return global.traceur && global.traceur.options[name];
  17904. }
  17905. function defineProperty(object, name, descriptor) {
  17906. if (isShimSymbol(name)) {
  17907. name = name[symbolInternalProperty];
  17908. }
  17909. $defineProperty(object, name, descriptor);
  17910. return object;
  17911. }
  17912. function polyfillObject(Object) {
  17913. $defineProperty(Object, 'defineProperty', {value: defineProperty});
  17914. $defineProperty(Object, 'getOwnPropertyNames', {value: getOwnPropertyNames});
  17915. $defineProperty(Object, 'getOwnPropertyDescriptor', {value: getOwnPropertyDescriptor});
  17916. $defineProperty(Object.prototype, 'hasOwnProperty', {value: hasOwnProperty});
  17917. $defineProperty(Object, 'freeze', {value: freeze});
  17918. $defineProperty(Object, 'preventExtensions', {value: preventExtensions});
  17919. $defineProperty(Object, 'seal', {value: seal});
  17920. $defineProperty(Object, 'keys', {value: keys});
  17921. }
  17922. function exportStar(object) {
  17923. for (var i = 1; i < arguments.length; i++) {
  17924. var names = $getOwnPropertyNames(arguments[i]);
  17925. for (var j = 0; j < names.length; j++) {
  17926. var name = names[j];
  17927. if (isSymbolString(name))
  17928. continue;
  17929. (function(mod, name) {
  17930. $defineProperty(object, name, {
  17931. get: function() {
  17932. return mod[name];
  17933. },
  17934. enumerable: true
  17935. });
  17936. })(arguments[i], names[j]);
  17937. }
  17938. }
  17939. return object;
  17940. }
  17941. function isObject(x) {
  17942. return x != null && (typeof x === 'object' || typeof x === 'function');
  17943. }
  17944. function toObject(x) {
  17945. if (x == null)
  17946. throw $TypeError();
  17947. return $Object(x);
  17948. }
  17949. function checkObjectCoercible(argument) {
  17950. if (argument == null) {
  17951. throw new TypeError('Value cannot be converted to an Object');
  17952. }
  17953. return argument;
  17954. }
  17955. function polyfillSymbol(global, Symbol) {
  17956. if (!global.Symbol) {
  17957. global.Symbol = Symbol;
  17958. Object.getOwnPropertySymbols = getOwnPropertySymbols;
  17959. }
  17960. if (!global.Symbol.iterator) {
  17961. global.Symbol.iterator = Symbol('Symbol.iterator');
  17962. }
  17963. }
  17964. function setupGlobals(global) {
  17965. polyfillSymbol(global, Symbol);
  17966. global.Reflect = global.Reflect || {};
  17967. global.Reflect.global = global.Reflect.global || global;
  17968. polyfillObject(global.Object);
  17969. }
  17970. setupGlobals(global);
  17971. global.$traceurRuntime = {
  17972. checkObjectCoercible: checkObjectCoercible,
  17973. createPrivateName: createPrivateName,
  17974. defineProperties: $defineProperties,
  17975. defineProperty: $defineProperty,
  17976. exportStar: exportStar,
  17977. getOwnHashObject: getOwnHashObject,
  17978. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  17979. getOwnPropertyNames: $getOwnPropertyNames,
  17980. isObject: isObject,
  17981. isPrivateName: isPrivateName,
  17982. isSymbolString: isSymbolString,
  17983. keys: $keys,
  17984. setupGlobals: setupGlobals,
  17985. toObject: toObject,
  17986. toProperty: toProperty,
  17987. typeof: typeOf
  17988. };
  17989. })(window);
  17990. (function() {
  17991. 'use strict';
  17992. var $toProperty = $traceurRuntime.toProperty;
  17993. function spread() {
  17994. var rv = [],
  17995. j = 0,
  17996. iterResult;
  17997. for (var i = 0; i < arguments.length; i++) {
  17998. var valueToSpread = $traceurRuntime.checkObjectCoercible(arguments[i]);
  17999. if (typeof valueToSpread[$toProperty(Symbol.iterator)] !== 'function') {
  18000. throw new TypeError('Cannot spread non-iterable object.');
  18001. }
  18002. var iter = valueToSpread[$toProperty(Symbol.iterator)]();
  18003. while (!(iterResult = iter.next()).done) {
  18004. rv[j++] = iterResult.value;
  18005. }
  18006. }
  18007. return rv;
  18008. }
  18009. $traceurRuntime.spread = spread;
  18010. })();
  18011. (function() {
  18012. 'use strict';
  18013. var $Object = Object;
  18014. var $TypeError = TypeError;
  18015. var $create = $Object.create;
  18016. var $defineProperties = $traceurRuntime.defineProperties;
  18017. var $defineProperty = $traceurRuntime.defineProperty;
  18018. var $getOwnPropertyDescriptor = $traceurRuntime.getOwnPropertyDescriptor;
  18019. var $getPrototypeOf = Object.getPrototypeOf;
  18020. var $toProperty = $traceurRuntime.toProperty;
  18021. var $__0 = Object,
  18022. getOwnPropertyNames = $__0.getOwnPropertyNames,
  18023. getOwnPropertySymbols = $__0.getOwnPropertySymbols;
  18024. function superDescriptor(homeObject, name) {
  18025. var proto = $getPrototypeOf(homeObject);
  18026. do {
  18027. var result = $getOwnPropertyDescriptor(proto, name);
  18028. if (result)
  18029. return result;
  18030. proto = $getPrototypeOf(proto);
  18031. } while (proto);
  18032. return undefined;
  18033. }
  18034. function superConstructor(ctor) {
  18035. return ctor.__proto__;
  18036. }
  18037. function superCall(self, homeObject, name, args) {
  18038. return superGet(self, homeObject, name).apply(self, args);
  18039. }
  18040. function superGet(self, homeObject, name) {
  18041. var descriptor = superDescriptor(homeObject, name);
  18042. if (descriptor) {
  18043. if (!descriptor.get)
  18044. return descriptor.value;
  18045. return descriptor.get.call(self);
  18046. }
  18047. return undefined;
  18048. }
  18049. function superSet(self, homeObject, name, value) {
  18050. var descriptor = superDescriptor(homeObject, name);
  18051. if (descriptor && descriptor.set) {
  18052. descriptor.set.call(self, value);
  18053. return value;
  18054. }
  18055. throw $TypeError(("super has no setter '" + name + "'."));
  18056. }
  18057. function getDescriptors(object) {
  18058. var descriptors = {};
  18059. var names = getOwnPropertyNames(object);
  18060. for (var i = 0; i < names.length; i++) {
  18061. var name = names[i];
  18062. descriptors[name] = $getOwnPropertyDescriptor(object, name);
  18063. }
  18064. var symbols = getOwnPropertySymbols(object);
  18065. for (var i = 0; i < symbols.length; i++) {
  18066. var symbol = symbols[i];
  18067. descriptors[$toProperty(symbol)] = $getOwnPropertyDescriptor(object, $toProperty(symbol));
  18068. }
  18069. return descriptors;
  18070. }
  18071. function createClass(ctor, object, staticObject, superClass) {
  18072. $defineProperty(object, 'constructor', {
  18073. value: ctor,
  18074. configurable: true,
  18075. enumerable: false,
  18076. writable: true
  18077. });
  18078. if (arguments.length > 3) {
  18079. if (typeof superClass === 'function')
  18080. ctor.__proto__ = superClass;
  18081. ctor.prototype = $create(getProtoParent(superClass), getDescriptors(object));
  18082. } else {
  18083. ctor.prototype = object;
  18084. }
  18085. $defineProperty(ctor, 'prototype', {
  18086. configurable: false,
  18087. writable: false
  18088. });
  18089. return $defineProperties(ctor, getDescriptors(staticObject));
  18090. }
  18091. function getProtoParent(superClass) {
  18092. if (typeof superClass === 'function') {
  18093. var prototype = superClass.prototype;
  18094. if ($Object(prototype) === prototype || prototype === null)
  18095. return superClass.prototype;
  18096. throw new $TypeError('super prototype must be an Object or null');
  18097. }
  18098. if (superClass === null)
  18099. return null;
  18100. throw new $TypeError(("Super expression must either be null or a function, not " + typeof superClass + "."));
  18101. }
  18102. function defaultSuperCall(self, homeObject, args) {
  18103. if ($getPrototypeOf(homeObject) !== null)
  18104. superCall(self, homeObject, 'constructor', args);
  18105. }
  18106. $traceurRuntime.createClass = createClass;
  18107. $traceurRuntime.defaultSuperCall = defaultSuperCall;
  18108. $traceurRuntime.superCall = superCall;
  18109. $traceurRuntime.superConstructor = superConstructor;
  18110. $traceurRuntime.superGet = superGet;
  18111. $traceurRuntime.superSet = superSet;
  18112. })();
  18113. //#
  18114. },{}],97:[function(require,module,exports){
  18115. "use strict";
  18116. Object.defineProperties(exports, {
  18117. TableView: {get: function() {
  18118. return TableView;
  18119. }},
  18120. __esModule: {value: true}
  18121. });
  18122. var $__helpers_47_dom_47_element__,
  18123. $__eventManager__,
  18124. $__helpers_47_dom_47_event__,
  18125. $__3rdparty_47_walkontable_47_src_47_cell_47_coords__,
  18126. $__3rdparty_47_walkontable_47_src_47_selection__,
  18127. $__3rdparty_47_walkontable_47_src_47_core__;
  18128. var $__0 = ($__helpers_47_dom_47_element__ = require("helpers/dom/element"), $__helpers_47_dom_47_element__ && $__helpers_47_dom_47_element__.__esModule && $__helpers_47_dom_47_element__ || {default: $__helpers_47_dom_47_element__}),
  18129. addClass = $__0.addClass,
  18130. empty = $__0.empty,
  18131. fastInnerHTML = $__0.fastInnerHTML,
  18132. fastInnerText = $__0.fastInnerText,
  18133. getScrollbarWidth = $__0.getScrollbarWidth,
  18134. hasClass = $__0.hasClass,
  18135. isChildOf = $__0.isChildOf,
  18136. isInput = $__0.isInput,
  18137. isOutsideInput = $__0.isOutsideInput;
  18138. var eventManagerObject = ($__eventManager__ = require("eventManager"), $__eventManager__ && $__eventManager__.__esModule && $__eventManager__ || {default: $__eventManager__}).eventManager;
  18139. var $__2 = ($__helpers_47_dom_47_event__ = require("helpers/dom/event"), $__helpers_47_dom_47_event__ && $__helpers_47_dom_47_event__.__esModule && $__helpers_47_dom_47_event__ || {default: $__helpers_47_dom_47_event__}),
  18140. stopPropagation = $__2.stopPropagation,
  18141. isImmediatePropagationStopped = $__2.isImmediatePropagationStopped;
  18142. var WalkontableCellCoords = ($__3rdparty_47_walkontable_47_src_47_cell_47_coords__ = require("3rdparty/walkontable/src/cell/coords"), $__3rdparty_47_walkontable_47_src_47_cell_47_coords__ && $__3rdparty_47_walkontable_47_src_47_cell_47_coords__.__esModule && $__3rdparty_47_walkontable_47_src_47_cell_47_coords__ || {default: $__3rdparty_47_walkontable_47_src_47_cell_47_coords__}).WalkontableCellCoords;
  18143. var WalkontableSelection = ($__3rdparty_47_walkontable_47_src_47_selection__ = require("3rdparty/walkontable/src/selection"), $__3rdparty_47_walkontable_47_src_47_selection__ && $__3rdparty_47_walkontable_47_src_47_selection__.__esModule && $__3rdparty_47_walkontable_47_src_47_selection__ || {default: $__3rdparty_47_walkontable_47_src_47_selection__}).WalkontableSelection;
  18144. var Walkontable = ($__3rdparty_47_walkontable_47_src_47_core__ = require("3rdparty/walkontable/src/core"), $__3rdparty_47_walkontable_47_src_47_core__ && $__3rdparty_47_walkontable_47_src_47_core__.__esModule && $__3rdparty_47_walkontable_47_src_47_core__ || {default: $__3rdparty_47_walkontable_47_src_47_core__}).Walkontable;
  18145. Handsontable.TableView = TableView;
  18146. function TableView(instance) {
  18147. var that = this;
  18148. this.eventManager = eventManagerObject(instance);
  18149. this.instance = instance;
  18150. this.settings = instance.getSettings();
  18151. this.selectionMouseDown = false;
  18152. var originalStyle = instance.rootElement.getAttribute('style');
  18153. if (originalStyle) {
  18154. instance.rootElement.setAttribute('data-originalstyle', originalStyle);
  18155. }
  18156. addClass(instance.rootElement, 'handsontable');
  18157. var table = document.createElement('TABLE');
  18158. addClass(table, 'htCore');
  18159. if (instance.getSettings().tableClassName) {
  18160. addClass(table, instance.getSettings().tableClassName);
  18161. }
  18162. this.THEAD = document.createElement('THEAD');
  18163. table.appendChild(this.THEAD);
  18164. this.TBODY = document.createElement('TBODY');
  18165. table.appendChild(this.TBODY);
  18166. instance.table = table;
  18167. instance.container.insertBefore(table, instance.container.firstChild);
  18168. this.eventManager.addEventListener(instance.rootElement, 'mousedown', function(event) {
  18169. this.selectionMouseDown = true;
  18170. if (!that.isTextSelectionAllowed(event.target)) {
  18171. clearTextSelection();
  18172. event.preventDefault();
  18173. window.focus();
  18174. }
  18175. });
  18176. this.eventManager.addEventListener(instance.rootElement, 'mouseup', function(event) {
  18177. this.selectionMouseDown = false;
  18178. });
  18179. this.eventManager.addEventListener(instance.rootElement, 'mousemove', function(event) {
  18180. if (this.selectionMouseDown && !that.isTextSelectionAllowed(event.target)) {
  18181. clearTextSelection();
  18182. event.preventDefault();
  18183. }
  18184. });
  18185. this.eventManager.addEventListener(document.documentElement, 'keyup', function(event) {
  18186. if (instance.selection.isInProgress() && !event.shiftKey) {
  18187. instance.selection.finish();
  18188. }
  18189. });
  18190. var isMouseDown;
  18191. this.isMouseDown = function() {
  18192. return isMouseDown;
  18193. };
  18194. this.eventManager.addEventListener(document.documentElement, 'mouseup', function(event) {
  18195. if (instance.selection.isInProgress() && event.which === 1) {
  18196. instance.selection.finish();
  18197. }
  18198. isMouseDown = false;
  18199. if (isOutsideInput(document.activeElement)) {
  18200. instance.unlisten();
  18201. }
  18202. });
  18203. this.eventManager.addEventListener(document.documentElement, 'mousedown', function(event) {
  18204. var next = event.target;
  18205. var eventX = event.x || event.clientX;
  18206. var eventY = event.y || event.clientY;
  18207. if (isMouseDown || !instance.rootElement) {
  18208. return;
  18209. }
  18210. if (next === instance.view.wt.wtTable.holder) {
  18211. var scrollbarWidth = getScrollbarWidth();
  18212. if (document.elementFromPoint(eventX + scrollbarWidth, eventY) !== instance.view.wt.wtTable.holder || document.elementFromPoint(eventX, eventY + scrollbarWidth) !== instance.view.wt.wtTable.holder) {
  18213. return;
  18214. }
  18215. } else {
  18216. while (next !== document.documentElement) {
  18217. if (next === null) {
  18218. if (event.isTargetWebComponent) {
  18219. break;
  18220. }
  18221. return;
  18222. }
  18223. if (next === instance.rootElement) {
  18224. return;
  18225. }
  18226. next = next.parentNode;
  18227. }
  18228. }
  18229. if (that.settings.outsideClickDeselects) {
  18230. instance.deselectCell();
  18231. } else {
  18232. instance.destroyEditor();
  18233. }
  18234. });
  18235. this.eventManager.addEventListener(table, 'selectstart', function(event) {
  18236. if (that.settings.fragmentSelection || isInput(event.target)) {
  18237. return;
  18238. }
  18239. event.preventDefault();
  18240. });
  18241. var clearTextSelection = function() {
  18242. if (window.getSelection) {
  18243. if (window.getSelection().empty) {
  18244. window.getSelection().empty();
  18245. } else if (window.getSelection().removeAllRanges) {
  18246. window.getSelection().removeAllRanges();
  18247. }
  18248. } else if (document.selection) {
  18249. document.selection.empty();
  18250. }
  18251. };
  18252. var selections = [new WalkontableSelection({
  18253. className: 'current',
  18254. border: {
  18255. width: 2,
  18256. color: '#5292F7',
  18257. cornerVisible: function() {
  18258. return that.settings.fillHandle && !that.isCellEdited() && !instance.selection.isMultiple();
  18259. },
  18260. multipleSelectionHandlesVisible: function() {
  18261. return !that.isCellEdited() && !instance.selection.isMultiple();
  18262. }
  18263. }
  18264. }), new WalkontableSelection({
  18265. className: 'area',
  18266. border: {
  18267. width: 1,
  18268. color: '#89AFF9',
  18269. cornerVisible: function() {
  18270. return that.settings.fillHandle && !that.isCellEdited() && instance.selection.isMultiple();
  18271. },
  18272. multipleSelectionHandlesVisible: function() {
  18273. return !that.isCellEdited() && instance.selection.isMultiple();
  18274. }
  18275. }
  18276. }), new WalkontableSelection({
  18277. className: 'highlight',
  18278. highlightRowClassName: that.settings.currentRowClassName,
  18279. highlightColumnClassName: that.settings.currentColClassName
  18280. }), new WalkontableSelection({
  18281. className: 'fill',
  18282. border: {
  18283. width: 1,
  18284. color: 'red'
  18285. }
  18286. })];
  18287. selections.current = selections[0];
  18288. selections.area = selections[1];
  18289. selections.highlight = selections[2];
  18290. selections.fill = selections[3];
  18291. var walkontableConfig = {
  18292. debug: function() {
  18293. return that.settings.debug;
  18294. },
  18295. externalRowCalculator: this.instance.getPlugin('autoRowSize') && this.instance.getPlugin('autoRowSize').isEnabled(),
  18296. table: table,
  18297. stretchH: this.settings.stretchH,
  18298. data: instance.getDataAtCell,
  18299. totalRows: (function() {
  18300. return instance.countRows();
  18301. }),
  18302. totalColumns: (function() {
  18303. return instance.countCols();
  18304. }),
  18305. fixedColumnsLeft: function() {
  18306. return that.settings.fixedColumnsLeft;
  18307. },
  18308. fixedRowsTop: function() {
  18309. return that.settings.fixedRowsTop;
  18310. },
  18311. fixedRowsBottom: function() {
  18312. return that.settings.fixedRowsBottom;
  18313. },
  18314. minSpareRows: function() {
  18315. return that.settings.minSpareRows;
  18316. },
  18317. renderAllRows: that.settings.renderAllRows,
  18318. rowHeaders: function() {
  18319. var headerRenderers = [];
  18320. if (instance.hasRowHeaders()) {
  18321. headerRenderers.push(function(row, TH) {
  18322. that.appendRowHeader(row, TH);
  18323. });
  18324. }
  18325. Handsontable.hooks.run(instance, 'afterGetRowHeaderRenderers', headerRenderers);
  18326. return headerRenderers;
  18327. },
  18328. columnHeaders: function() {
  18329. var headerRenderers = [];
  18330. if (instance.hasColHeaders()) {
  18331. headerRenderers.push(function(column, TH) {
  18332. that.appendColHeader(column, TH);
  18333. });
  18334. }
  18335. Handsontable.hooks.run(instance, 'afterGetColumnHeaderRenderers', headerRenderers);
  18336. return headerRenderers;
  18337. },
  18338. columnWidth: instance.getColWidth,
  18339. rowHeight: instance.getRowHeight,
  18340. cellRenderer: function(row, col, TD) {
  18341. var prop = that.instance.colToProp(col),
  18342. cellProperties = that.instance.getCellMeta(row, col),
  18343. renderer = that.instance.getCellRenderer(cellProperties);
  18344. var value = that.instance.getDataAtRowProp(row, prop);
  18345. renderer(that.instance, TD, row, col, prop, value, cellProperties);
  18346. Handsontable.hooks.run(that.instance, 'afterRenderer', TD, row, col, prop, value, cellProperties);
  18347. },
  18348. selections: selections,
  18349. hideBorderOnMouseDownOver: function() {
  18350. return that.settings.fragmentSelection;
  18351. },
  18352. onCellMouseDown: function(event, coords, TD, wt) {
  18353. var colspanOffset;
  18354. var TR = TD.parentNode;
  18355. var THEAD = TR.parentNode;
  18356. var headerLevel;
  18357. var headerColspan;
  18358. instance.listen();
  18359. that.activeWt = wt;
  18360. isMouseDown = true;
  18361. Handsontable.hooks.run(instance, 'beforeOnCellMouseDown', event, coords, TD);
  18362. instance.selection.setSelectedHeaders(false, false);
  18363. if (!isImmediatePropagationStopped(event)) {
  18364. if (event.button === 2 && instance.selection.inInSelection(coords)) {
  18365. var nothing = 1;
  18366. } else if (event.shiftKey) {
  18367. if (coords.row >= 0 && coords.col >= 0) {
  18368. instance.selection.setRangeEnd(coords);
  18369. }
  18370. } else {
  18371. if ((coords.row < 0 || coords.col < 0) && (coords.row >= 0 || coords.col >= 0)) {
  18372. if (coords.row < 0) {
  18373. headerLevel = THEAD.childNodes.length - Array.prototype.indexOf.call(THEAD.childNodes, TR) - 1;
  18374. headerColspan = instance.getHeaderColspan(coords.col, headerLevel);
  18375. instance.selection.setSelectedHeaders(false, true);
  18376. instance.selectCell(0, coords.col, instance.countRows() - 1, coords.col + Math.max(0, headerColspan - 1));
  18377. }
  18378. if (coords.col < 0) {
  18379. instance.selection.setSelectedHeaders(true, false);
  18380. instance.selectCell(coords.row, 0, coords.row, instance.countCols() - 1);
  18381. }
  18382. } else {
  18383. coords.row = coords.row < 0 ? 0 : coords.row;
  18384. coords.col = coords.col < 0 ? 0 : coords.col;
  18385. instance.selection.setRangeStart(coords);
  18386. }
  18387. }
  18388. Handsontable.hooks.run(instance, 'afterOnCellMouseDown', event, coords, TD);
  18389. that.activeWt = that.wt;
  18390. }
  18391. },
  18392. onCellMouseOver: function(event, coords, TD, wt) {
  18393. that.activeWt = wt;
  18394. if (coords.row >= 0 && coords.col >= 0) {
  18395. if (isMouseDown) {
  18396. instance.selection.setRangeEnd(coords);
  18397. }
  18398. } else {
  18399. if (isMouseDown) {
  18400. if (coords.row < 0) {
  18401. if (instance.selection.selectedHeader.cols) {
  18402. instance.selection.setRangeEnd(new WalkontableCellCoords(instance.countRows() - 1, coords.col));
  18403. instance.selection.setSelectedHeaders(false, true);
  18404. } else {
  18405. instance.selection.setRangeEnd(new WalkontableCellCoords(coords.row, coords.col));
  18406. }
  18407. }
  18408. if (coords.col < 0) {
  18409. if (instance.selection.selectedHeader.rows) {
  18410. instance.selection.setRangeEnd(new WalkontableCellCoords(coords.row, instance.countCols() - 1));
  18411. instance.selection.setSelectedHeaders(true, false);
  18412. } else {
  18413. instance.selection.setRangeEnd(new WalkontableCellCoords(coords.row, coords.col));
  18414. }
  18415. }
  18416. }
  18417. }
  18418. Handsontable.hooks.run(instance, 'afterOnCellMouseOver', event, coords, TD);
  18419. that.activeWt = that.wt;
  18420. },
  18421. onCellCornerMouseDown: function(event) {
  18422. event.preventDefault();
  18423. Handsontable.hooks.run(instance, 'afterOnCellCornerMouseDown', event);
  18424. },
  18425. beforeDraw: function(force) {
  18426. that.beforeRender(force);
  18427. },
  18428. onDraw: function(force) {
  18429. that.onDraw(force);
  18430. },
  18431. onScrollVertically: function() {
  18432. instance.runHooks('afterScrollVertically');
  18433. },
  18434. onScrollHorizontally: function() {
  18435. instance.runHooks('afterScrollHorizontally');
  18436. },
  18437. onBeforeDrawBorders: function(corners, borderClassName) {
  18438. instance.runHooks('beforeDrawBorders', corners, borderClassName);
  18439. },
  18440. onBeforeTouchScroll: function() {
  18441. instance.runHooks('beforeTouchScroll');
  18442. },
  18443. onAfterMomentumScroll: function() {
  18444. instance.runHooks('afterMomentumScroll');
  18445. },
  18446. viewportRowCalculatorOverride: function(calc) {
  18447. var rows = instance.countRows();
  18448. var viewportOffset = that.settings.viewportRowRenderingOffset;
  18449. if (viewportOffset === 'auto' && that.settings.fixedRowsTop) {
  18450. viewportOffset = 10;
  18451. }
  18452. if (typeof viewportOffset === 'number') {
  18453. calc.startRow = Math.max(calc.startRow - viewportOffset, 0);
  18454. calc.endRow = Math.min(calc.endRow + viewportOffset, rows - 1);
  18455. }
  18456. if (viewportOffset === 'auto') {
  18457. var center = calc.startRow + calc.endRow - calc.startRow;
  18458. var offset = Math.ceil(center / rows * 12);
  18459. calc.startRow = Math.max(calc.startRow - offset, 0);
  18460. calc.endRow = Math.min(calc.endRow + offset, rows - 1);
  18461. }
  18462. instance.runHooks('afterViewportRowCalculatorOverride', calc);
  18463. },
  18464. viewportColumnCalculatorOverride: function(calc) {
  18465. var cols = instance.countCols();
  18466. var viewportOffset = that.settings.viewportColumnRenderingOffset;
  18467. if (viewportOffset === 'auto' && that.settings.fixedColumnsLeft) {
  18468. viewportOffset = 10;
  18469. }
  18470. if (typeof viewportOffset === 'number') {
  18471. calc.startColumn = Math.max(calc.startColumn - viewportOffset, 0);
  18472. calc.endColumn = Math.min(calc.endColumn + viewportOffset, cols - 1);
  18473. }
  18474. if (viewportOffset === 'auto') {
  18475. var center = calc.startColumn + calc.endColumn - calc.startColumn;
  18476. var offset = Math.ceil(center / cols * 12);
  18477. calc.startRow = Math.max(calc.startColumn - offset, 0);
  18478. calc.endColumn = Math.min(calc.endColumn + offset, cols - 1);
  18479. }
  18480. instance.runHooks('afterViewportColumnCalculatorOverride', calc);
  18481. }
  18482. };
  18483. Handsontable.hooks.run(instance, 'beforeInitWalkontable', walkontableConfig);
  18484. this.wt = new Walkontable(walkontableConfig);
  18485. this.activeWt = this.wt;
  18486. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'mousedown', function(event) {
  18487. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  18488. stopPropagation(event);
  18489. }
  18490. });
  18491. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'contextmenu', function(event) {
  18492. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  18493. stopPropagation(event);
  18494. }
  18495. });
  18496. this.eventManager.addEventListener(document.documentElement, 'click', function() {
  18497. if (that.settings.observeDOMVisibility) {
  18498. if (that.wt.drawInterrupted) {
  18499. that.instance.forceFullRender = true;
  18500. that.render();
  18501. }
  18502. }
  18503. });
  18504. }
  18505. TableView.prototype.isTextSelectionAllowed = function(el) {
  18506. if (isInput(el)) {
  18507. return true;
  18508. }
  18509. var isChildOfTableBody = isChildOf(el, this.instance.view.wt.wtTable.spreader);
  18510. if (this.settings.fragmentSelection === true && isChildOfTableBody) {
  18511. return true;
  18512. }
  18513. if (this.settings.fragmentSelection === 'cell' && this.isSelectedOnlyCell() && isChildOfTableBody) {
  18514. return true;
  18515. }
  18516. return false;
  18517. };
  18518. TableView.prototype.isSelectedOnlyCell = function() {
  18519. var $__6 = this.instance.getSelected() || [],
  18520. row = $__6[0],
  18521. col = $__6[1],
  18522. rowEnd = $__6[2],
  18523. colEnd = $__6[3];
  18524. return row !== void 0 && row === rowEnd && col === colEnd;
  18525. };
  18526. TableView.prototype.isCellEdited = function() {
  18527. var activeEditor = this.instance.getActiveEditor();
  18528. return activeEditor && activeEditor.isOpened();
  18529. };
  18530. TableView.prototype.beforeRender = function(force) {
  18531. if (force) {
  18532. Handsontable.hooks.run(this.instance, 'beforeRender', this.instance.forceFullRender);
  18533. }
  18534. };
  18535. TableView.prototype.onDraw = function(force) {
  18536. if (force) {
  18537. Handsontable.hooks.run(this.instance, 'afterRender', this.instance.forceFullRender);
  18538. }
  18539. };
  18540. TableView.prototype.render = function() {
  18541. this.wt.draw(!this.instance.forceFullRender);
  18542. this.instance.forceFullRender = false;
  18543. this.instance.renderCall = false;
  18544. };
  18545. TableView.prototype.getCellAtCoords = function(coords, topmost) {
  18546. var td = this.wt.getCell(coords, topmost);
  18547. if (td < 0) {
  18548. return null;
  18549. } else {
  18550. return td;
  18551. }
  18552. };
  18553. TableView.prototype.scrollViewport = function(coords) {
  18554. this.wt.scrollViewport(coords);
  18555. };
  18556. TableView.prototype.appendRowHeader = function(row, TH) {
  18557. if (TH.firstChild) {
  18558. var container = TH.firstChild;
  18559. if (!hasClass(container, 'relative')) {
  18560. empty(TH);
  18561. this.appendRowHeader(row, TH);
  18562. return;
  18563. }
  18564. this.updateCellHeader(container.querySelector('.rowHeader'), row, this.instance.getRowHeader);
  18565. } else {
  18566. var div = document.createElement('div');
  18567. var span = document.createElement('span');
  18568. div.className = 'relative';
  18569. span.className = 'rowHeader';
  18570. this.updateCellHeader(span, row, this.instance.getRowHeader);
  18571. div.appendChild(span);
  18572. TH.appendChild(div);
  18573. }
  18574. Handsontable.hooks.run(this.instance, 'afterGetRowHeader', row, TH);
  18575. };
  18576. TableView.prototype.appendColHeader = function(col, TH) {
  18577. if (TH.firstChild) {
  18578. var container = TH.firstChild;
  18579. if (hasClass(container, 'relative')) {
  18580. this.updateCellHeader(container.querySelector('.colHeader'), col, this.instance.getColHeader);
  18581. } else {
  18582. empty(TH);
  18583. this.appendColHeader(col, TH);
  18584. }
  18585. } else {
  18586. var div = document.createElement('div');
  18587. var span = document.createElement('span');
  18588. div.className = 'relative';
  18589. span.className = 'colHeader';
  18590. this.updateCellHeader(span, col, this.instance.getColHeader);
  18591. div.appendChild(span);
  18592. TH.appendChild(div);
  18593. }
  18594. Handsontable.hooks.run(this.instance, 'afterGetColHeader', col, TH);
  18595. };
  18596. TableView.prototype.updateCellHeader = function(element, index, content) {
  18597. if (index > -1) {
  18598. fastInnerHTML(element, content(index));
  18599. } else {
  18600. fastInnerText(element, String.fromCharCode(160));
  18601. addClass(element, 'cornerHeader');
  18602. }
  18603. };
  18604. TableView.prototype.maximumVisibleElementWidth = function(leftOffset) {
  18605. var workspaceWidth = this.wt.wtViewport.getWorkspaceWidth();
  18606. var maxWidth = workspaceWidth - leftOffset;
  18607. return maxWidth > 0 ? maxWidth : 0;
  18608. };
  18609. TableView.prototype.maximumVisibleElementHeight = function(topOffset) {
  18610. var workspaceHeight = this.wt.wtViewport.getWorkspaceHeight();
  18611. var maxHeight = workspaceHeight - topOffset;
  18612. return maxHeight > 0 ? maxHeight : 0;
  18613. };
  18614. TableView.prototype.mainViewIsActive = function() {
  18615. return this.wt === this.activeWt;
  18616. };
  18617. TableView.prototype.destroy = function() {
  18618. this.wt.destroy();
  18619. this.eventManager.destroy();
  18620. };
  18621. ;
  18622. //#
  18623. },{"3rdparty/walkontable/src/cell/coords":5,"3rdparty/walkontable/src/core":7,"3rdparty/walkontable/src/selection":18,"eventManager":41,"helpers/dom/element":45,"helpers/dom/event":46}],98:[function(require,module,exports){
  18624. "use strict";
  18625. Object.defineProperties(exports, {
  18626. GhostTable: {get: function() {
  18627. return GhostTable;
  18628. }},
  18629. __esModule: {value: true}
  18630. });
  18631. var $___46__46__47_helpers_47_dom_47_element__,
  18632. $___46__46__47_helpers_47_array__,
  18633. $___46__46__47_helpers_47_object__,
  18634. $___46__46__47_helpers_47_number__,
  18635. $___46__46__47_helpers_47_mixed__;
  18636. var $__0 = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}),
  18637. addClass = $__0.addClass,
  18638. outerHeight = $__0.outerHeight,
  18639. outerWidth = $__0.outerWidth;
  18640. var arrayEach = ($___46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47_helpers_47_array__ && $___46__46__47_helpers_47_array__.__esModule && $___46__46__47_helpers_47_array__ || {default: $___46__46__47_helpers_47_array__}).arrayEach;
  18641. var objectEach = ($___46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47_helpers_47_object__ && $___46__46__47_helpers_47_object__.__esModule && $___46__46__47_helpers_47_object__ || {default: $___46__46__47_helpers_47_object__}).objectEach;
  18642. var rangeEach = ($___46__46__47_helpers_47_number__ = require("helpers/number"), $___46__46__47_helpers_47_number__ && $___46__46__47_helpers_47_number__.__esModule && $___46__46__47_helpers_47_number__ || {default: $___46__46__47_helpers_47_number__}).rangeEach;
  18643. var stringify = ($___46__46__47_helpers_47_mixed__ = require("helpers/mixed"), $___46__46__47_helpers_47_mixed__ && $___46__46__47_helpers_47_mixed__.__esModule && $___46__46__47_helpers_47_mixed__ || {default: $___46__46__47_helpers_47_mixed__}).stringify;
  18644. var GhostTable = function GhostTable(hotInstance) {
  18645. this.hot = hotInstance;
  18646. this.container = null;
  18647. this.injected = false;
  18648. this.rows = [];
  18649. this.columns = [];
  18650. this.samples = null;
  18651. };
  18652. ($traceurRuntime.createClass)(GhostTable, {
  18653. addRow: function(row, samples) {
  18654. if (this.columns.length) {
  18655. throw new Error('Doesn\'t support multi-dimensional table');
  18656. }
  18657. if (!this.rows.length) {
  18658. this.container = this.createContainer(this.hot.rootElement.className);
  18659. }
  18660. var rowObject = {row: row};
  18661. this.rows.push(rowObject);
  18662. this.samples = samples;
  18663. this.table = this.createTable(this.hot.table.className);
  18664. this.table.colGroup.appendChild(this.createColGroupsCol());
  18665. this.table.tr.appendChild(this.createRow(row));
  18666. this.container.container.appendChild(this.table.fragment);
  18667. rowObject.table = this.table.table;
  18668. },
  18669. addColumn: function(column, samples) {
  18670. if (this.rows.length) {
  18671. throw new Error('Doesn\'t support multi-dimensional table');
  18672. }
  18673. if (!this.columns.length) {
  18674. this.container = this.createContainer(this.hot.rootElement.className);
  18675. }
  18676. var columnObject = {col: column};
  18677. this.columns.push(columnObject);
  18678. this.samples = samples;
  18679. this.table = this.createTable(this.hot.table.className);
  18680. if (this.hot.getColHeader(column) !== null) {
  18681. this.hot.view.appendColHeader(column, this.table.th);
  18682. }
  18683. this.table.tBody.appendChild(this.createCol(column));
  18684. this.container.container.appendChild(this.table.fragment);
  18685. columnObject.table = this.table.table;
  18686. },
  18687. getHeights: function(callback) {
  18688. if (!this.injected) {
  18689. this.injectTable();
  18690. }
  18691. arrayEach(this.rows, (function(row) {
  18692. callback(row.row, outerHeight(row.table) - 1);
  18693. }));
  18694. },
  18695. getWidths: function(callback) {
  18696. if (!this.injected) {
  18697. this.injectTable();
  18698. }
  18699. arrayEach(this.columns, (function(column) {
  18700. callback(column.col, outerWidth(column.table));
  18701. }));
  18702. },
  18703. createColGroupsCol: function() {
  18704. var $__5 = this;
  18705. var d = document;
  18706. var fragment = d.createDocumentFragment();
  18707. fragment.appendChild(this.createColElement(-1));
  18708. this.samples.forEach((function(sample) {
  18709. arrayEach(sample.strings, (function(string) {
  18710. fragment.appendChild($__5.createColElement(string.col));
  18711. }));
  18712. }));
  18713. return fragment;
  18714. },
  18715. createRow: function(row) {
  18716. var $__5 = this;
  18717. var d = document;
  18718. var fragment = d.createDocumentFragment();
  18719. var th = d.createElement('th');
  18720. if (this.hot.getRowHeader(row) !== null) {
  18721. this.hot.view.appendRowHeader(row, th);
  18722. }
  18723. fragment.appendChild(th);
  18724. this.samples.forEach((function(sample) {
  18725. arrayEach(sample.strings, (function(string) {
  18726. var column = string.col;
  18727. var cellProperties = $__5.hot.getCellMeta(row, column);
  18728. cellProperties.col = column;
  18729. cellProperties.row = row;
  18730. var renderer = $__5.hot.getCellRenderer(cellProperties);
  18731. var td = d.createElement('td');
  18732. renderer($__5.hot, td, row, column, $__5.hot.colToProp(column), string.value, cellProperties);
  18733. fragment.appendChild(td);
  18734. }));
  18735. }));
  18736. return fragment;
  18737. },
  18738. createCol: function(column) {
  18739. var $__5 = this;
  18740. var d = document;
  18741. var fragment = d.createDocumentFragment();
  18742. this.samples.forEach((function(sample) {
  18743. arrayEach(sample.strings, (function(string) {
  18744. var row = string.row;
  18745. var cellProperties = $__5.hot.getCellMeta(row, column);
  18746. cellProperties.col = column;
  18747. cellProperties.row = row;
  18748. var renderer = $__5.hot.getCellRenderer(cellProperties);
  18749. var td = d.createElement('td');
  18750. var tr = d.createElement('tr');
  18751. renderer($__5.hot, td, row, column, $__5.hot.colToProp(row), string.value, cellProperties);
  18752. tr.appendChild(td);
  18753. fragment.appendChild(tr);
  18754. }));
  18755. }));
  18756. return fragment;
  18757. },
  18758. clean: function() {
  18759. this.rows.length = 0;
  18760. this.columns.length = 0;
  18761. if (this.samples) {
  18762. this.samples.clear();
  18763. }
  18764. this.samples = null;
  18765. this.removeTable();
  18766. },
  18767. injectTable: function() {
  18768. var parent = arguments[0] !== (void 0) ? arguments[0] : null;
  18769. if (!this.injected) {
  18770. (parent || this.hot.rootElement).appendChild(this.container.fragment);
  18771. this.injected = true;
  18772. }
  18773. },
  18774. removeTable: function() {
  18775. if (this.injected && this.container.container.parentNode) {
  18776. this.container.container.parentNode.removeChild(this.container.container);
  18777. this.container = null;
  18778. this.injected = false;
  18779. }
  18780. },
  18781. createColElement: function(column) {
  18782. var d = document;
  18783. var col = d.createElement('col');
  18784. col.style.width = this.hot.view.wt.wtTable.getStretchedColumnWidth(column) + 'px';
  18785. return col;
  18786. },
  18787. createTable: function() {
  18788. var className = arguments[0] !== (void 0) ? arguments[0] : '';
  18789. var d = document;
  18790. var fragment = d.createDocumentFragment();
  18791. var table = d.createElement('table');
  18792. var tHead = d.createElement('thead');
  18793. var tBody = d.createElement('tbody');
  18794. var colGroup = d.createElement('colgroup');
  18795. var tr = d.createElement('tr');
  18796. var th = d.createElement('th');
  18797. if (this.isVertical()) {
  18798. table.appendChild(colGroup);
  18799. }
  18800. if (this.isHorizontal()) {
  18801. tr.appendChild(th);
  18802. tHead.appendChild(tr);
  18803. table.style.tableLayout = 'auto';
  18804. table.style.width = 'auto';
  18805. }
  18806. table.appendChild(tHead);
  18807. if (this.isVertical()) {
  18808. tBody.appendChild(tr);
  18809. }
  18810. table.appendChild(tBody);
  18811. addClass(table, className);
  18812. fragment.appendChild(table);
  18813. return {
  18814. fragment: fragment,
  18815. table: table,
  18816. tHead: tHead,
  18817. tBody: tBody,
  18818. colGroup: colGroup,
  18819. tr: tr,
  18820. th: th
  18821. };
  18822. },
  18823. createContainer: function() {
  18824. var className = arguments[0] !== (void 0) ? arguments[0] : '';
  18825. var d = document;
  18826. var fragment = d.createDocumentFragment();
  18827. var container = d.createElement('div');
  18828. className = 'htGhostTable htAutoSize ' + className.trim();
  18829. addClass(container, className);
  18830. fragment.appendChild(container);
  18831. return {
  18832. fragment: fragment,
  18833. container: container
  18834. };
  18835. },
  18836. isVertical: function() {
  18837. return this.rows.length && !this.columns.length ? true : false;
  18838. },
  18839. isHorizontal: function() {
  18840. return this.columns.length && !this.rows.length ? true : false;
  18841. }
  18842. }, {});
  18843. ;
  18844. Handsontable.utils = Handsontable.utils || {};
  18845. Handsontable.utils.GhostTable = GhostTable;
  18846. //#
  18847. },{"helpers/array":42,"helpers/dom/element":45,"helpers/mixed":48,"helpers/number":49,"helpers/object":50}],99:[function(require,module,exports){
  18848. "use strict";
  18849. var $__7;
  18850. Object.defineProperties(exports, {
  18851. SamplesGenerator: {get: function() {
  18852. return SamplesGenerator;
  18853. }},
  18854. __esModule: {value: true}
  18855. });
  18856. var $___46__46__47_helpers_47_dom_47_element__,
  18857. $___46__46__47_helpers_47_array__,
  18858. $___46__46__47_helpers_47_object__,
  18859. $___46__46__47_helpers_47_number__,
  18860. $___46__46__47_helpers_47_mixed__;
  18861. var $__0 = ($___46__46__47_helpers_47_dom_47_element__ = require("helpers/dom/element"), $___46__46__47_helpers_47_dom_47_element__ && $___46__46__47_helpers_47_dom_47_element__.__esModule && $___46__46__47_helpers_47_dom_47_element__ || {default: $___46__46__47_helpers_47_dom_47_element__}),
  18862. addClass = $__0.addClass,
  18863. outerHeight = $__0.outerHeight,
  18864. outerWidth = $__0.outerWidth;
  18865. var arrayEach = ($___46__46__47_helpers_47_array__ = require("helpers/array"), $___46__46__47_helpers_47_array__ && $___46__46__47_helpers_47_array__.__esModule && $___46__46__47_helpers_47_array__ || {default: $___46__46__47_helpers_47_array__}).arrayEach;
  18866. var objectEach = ($___46__46__47_helpers_47_object__ = require("helpers/object"), $___46__46__47_helpers_47_object__ && $___46__46__47_helpers_47_object__.__esModule && $___46__46__47_helpers_47_object__ || {default: $___46__46__47_helpers_47_object__}).objectEach;
  18867. var rangeEach = ($___46__46__47_helpers_47_number__ = require("helpers/number"), $___46__46__47_helpers_47_number__ && $___46__46__47_helpers_47_number__.__esModule && $___46__46__47_helpers_47_number__ || {default: $___46__46__47_helpers_47_number__}).rangeEach;
  18868. var stringify = ($___46__46__47_helpers_47_mixed__ = require("helpers/mixed"), $___46__46__47_helpers_47_mixed__ && $___46__46__47_helpers_47_mixed__.__esModule && $___46__46__47_helpers_47_mixed__ || {default: $___46__46__47_helpers_47_mixed__}).stringify;
  18869. var SamplesGenerator = function SamplesGenerator(dataFactory) {
  18870. this.samples = null;
  18871. this.dataFactory = dataFactory;
  18872. };
  18873. var $SamplesGenerator = SamplesGenerator;
  18874. ($traceurRuntime.createClass)(SamplesGenerator, ($__7 = {}, Object.defineProperty($__7, "generateRowSamples", {
  18875. value: function(rowRange, colRange) {
  18876. return this.generateSamples('row', colRange, rowRange);
  18877. },
  18878. configurable: true,
  18879. enumerable: true,
  18880. writable: true
  18881. }), Object.defineProperty($__7, "generateColumnSamples", {
  18882. value: function(colRange, rowRange) {
  18883. return this.generateSamples('col', rowRange, colRange);
  18884. },
  18885. configurable: true,
  18886. enumerable: true,
  18887. writable: true
  18888. }), Object.defineProperty($__7, "generateSamples", {
  18889. value: function(type, range, specifierRange) {
  18890. var $__5 = this;
  18891. var samples = new Map();
  18892. if (typeof specifierRange === 'number') {
  18893. specifierRange = {
  18894. from: specifierRange,
  18895. to: specifierRange
  18896. };
  18897. }
  18898. rangeEach(specifierRange.from, specifierRange.to, (function(index) {
  18899. var sample = $__5.generateSample(type, range, index);
  18900. samples.set(index, sample);
  18901. }));
  18902. return samples;
  18903. },
  18904. configurable: true,
  18905. enumerable: true,
  18906. writable: true
  18907. }), Object.defineProperty($__7, "generateSample", {
  18908. value: function(type, range, specifierValue) {
  18909. var $__5 = this;
  18910. var samples = new Map();
  18911. rangeEach(range.from, range.to, (function(index) {
  18912. var $__7;
  18913. var value;
  18914. if (type === 'row') {
  18915. value = $__5.dataFactory(specifierValue, index);
  18916. } else if (type === 'col') {
  18917. value = $__5.dataFactory(index, specifierValue);
  18918. } else {
  18919. throw new Error('Unsupported sample type');
  18920. }
  18921. if (!Array.isArray(value)) {
  18922. value = stringify(value);
  18923. }
  18924. var len = value.length;
  18925. if (!samples.has(len)) {
  18926. samples.set(len, {
  18927. needed: $SamplesGenerator.SAMPLE_COUNT,
  18928. strings: []
  18929. });
  18930. }
  18931. var sample = samples.get(len);
  18932. if (sample.needed) {
  18933. var computedKey = type === 'row' ? 'col' : 'row';
  18934. sample.strings.push(($__7 = {}, Object.defineProperty($__7, "value", {
  18935. value: value,
  18936. configurable: true,
  18937. enumerable: true,
  18938. writable: true
  18939. }), Object.defineProperty($__7, computedKey, {
  18940. value: index,
  18941. configurable: true,
  18942. enumerable: true,
  18943. writable: true
  18944. }), $__7));
  18945. sample.needed--;
  18946. }
  18947. }));
  18948. return samples;
  18949. },
  18950. configurable: true,
  18951. enumerable: true,
  18952. writable: true
  18953. }), $__7), {get SAMPLE_COUNT() {
  18954. return 3;
  18955. }});
  18956. ;
  18957. Handsontable.utils = Handsontable.utils || {};
  18958. Handsontable.utils.SamplesGenerator = SamplesGenerator;
  18959. //#
  18960. },{"helpers/array":42,"helpers/dom/element":45,"helpers/mixed":48,"helpers/number":49,"helpers/object":50}],100:[function(require,module,exports){
  18961. "use strict";
  18962. var $___46__46__47_helpers_47_mixed__;
  18963. var stringify = ($___46__46__47_helpers_47_mixed__ = require("helpers/mixed"), $___46__46__47_helpers_47_mixed__ && $___46__46__47_helpers_47_mixed__.__esModule && $___46__46__47_helpers_47_mixed__ || {default: $___46__46__47_helpers_47_mixed__}).stringify;
  18964. Handsontable.AutocompleteValidator = function(value, callback) {
  18965. if (this.strict && this.source) {
  18966. if (typeof this.source === 'function') {
  18967. this.source(value, process(value, callback));
  18968. } else {
  18969. process(value, callback)(this.source);
  18970. }
  18971. } else {
  18972. callback(true);
  18973. }
  18974. };
  18975. function process(value, callback) {
  18976. var originalVal = value;
  18977. var lowercaseVal = typeof originalVal === 'string' ? originalVal.toLowerCase() : null;
  18978. return function(source) {
  18979. var found = false;
  18980. for (var s = 0,
  18981. slen = source.length; s < slen; s++) {
  18982. if (originalVal === source[s]) {
  18983. found = true;
  18984. break;
  18985. } else if (lowercaseVal === stringify(source[s]).toLowerCase()) {
  18986. found = true;
  18987. break;
  18988. }
  18989. }
  18990. callback(found);
  18991. };
  18992. }
  18993. //#
  18994. },{"helpers/mixed":48}],101:[function(require,module,exports){
  18995. "use strict";
  18996. var $__moment__,
  18997. $___46__46__47_editors__;
  18998. var moment = ($__moment__ = require("moment"), $__moment__ && $__moment__.__esModule && $__moment__ || {default: $__moment__}).default;
  18999. var getEditor = ($___46__46__47_editors__ = require("editors"), $___46__46__47_editors__ && $___46__46__47_editors__.__esModule && $___46__46__47_editors__ || {default: $___46__46__47_editors__}).getEditor;
  19000. Handsontable.DateValidator = function(value, callback) {
  19001. var valid = true;
  19002. var dateEditor = getEditor('date', this.instance);
  19003. if (value === null) {
  19004. value = '';
  19005. }
  19006. var isValidDate = moment(new Date(value)).isValid();
  19007. var isValidFormat = moment(value, this.dateFormat || dateEditor.defaultDateFormat, true).isValid();
  19008. if (!isValidDate) {
  19009. valid = false;
  19010. }
  19011. if (!isValidDate && isValidFormat) {
  19012. valid = true;
  19013. }
  19014. if (isValidDate && !isValidFormat) {
  19015. if (this.correctFormat === true) {
  19016. var correctedValue = correctFormat(value, this.dateFormat);
  19017. this.instance.setDataAtCell(this.row, this.col, correctedValue, 'dateValidator');
  19018. valid = true;
  19019. } else {
  19020. valid = false;
  19021. }
  19022. }
  19023. callback(valid);
  19024. };
  19025. var correctFormat = function correctFormat(value, dateFormat) {
  19026. var date = moment(new Date(value));
  19027. var year = date.format('YYYY');
  19028. var yearNow = moment().format('YYYY');
  19029. if (year.substr(0, 2) !== yearNow.substr(0, 2)) {
  19030. if (!value.match(new RegExp(year))) {
  19031. date.year(year.replace(year.substr(0, 2), yearNow.substr(0, 2)));
  19032. }
  19033. } else if (year.length > 4) {
  19034. date.year((date.year() + '').substr(0, 4));
  19035. }
  19036. return date.format(dateFormat);
  19037. };
  19038. //#
  19039. },{"editors":29,"moment":"moment"}],102:[function(require,module,exports){
  19040. "use strict";
  19041. Handsontable.NumericValidator = function(value, callback) {
  19042. if (value === null) {
  19043. value = '';
  19044. }
  19045. callback(/^-?\d*(\.|\,)?\d*$/.test(value));
  19046. };
  19047. //#
  19048. },{}],"SheetClip":[function(require,module,exports){
  19049. "use strict";
  19050. (function(global) {
  19051. "use strict";
  19052. function countQuotes(str) {
  19053. return str.split('"').length - 1;
  19054. }
  19055. var SheetClip = {
  19056. parse: function(str) {
  19057. var r,
  19058. rLen,
  19059. rows,
  19060. arr = [],
  19061. a = 0,
  19062. c,
  19063. cLen,
  19064. multiline,
  19065. last;
  19066. rows = str.split('\n');
  19067. if (rows.length > 1 && rows[rows.length - 1] === '') {
  19068. rows.pop();
  19069. }
  19070. for (r = 0, rLen = rows.length; r < rLen; r += 1) {
  19071. rows[r] = rows[r].split('\t');
  19072. for (c = 0, cLen = rows[r].length; c < cLen; c += 1) {
  19073. if (!arr[a]) {
  19074. arr[a] = [];
  19075. }
  19076. if (multiline && c === 0) {
  19077. last = arr[a].length - 1;
  19078. arr[a][last] = arr[a][last] + '\n' + rows[r][0];
  19079. if (multiline && (countQuotes(rows[r][0]) & 1)) {
  19080. multiline = false;
  19081. arr[a][last] = arr[a][last].substring(0, arr[a][last].length - 1).replace(/""/g, '"');
  19082. }
  19083. } else {
  19084. if (c === cLen - 1 && rows[r][c].indexOf('"') === 0 && (countQuotes(rows[r][c]) & 1)) {
  19085. arr[a].push(rows[r][c].substring(1).replace(/""/g, '"'));
  19086. multiline = true;
  19087. } else {
  19088. arr[a].push(rows[r][c].replace(/""/g, '"'));
  19089. multiline = false;
  19090. }
  19091. }
  19092. }
  19093. if (!multiline) {
  19094. a += 1;
  19095. }
  19096. }
  19097. return arr;
  19098. },
  19099. stringify: function(arr) {
  19100. var r,
  19101. rLen,
  19102. c,
  19103. cLen,
  19104. str = '',
  19105. val;
  19106. for (r = 0, rLen = arr.length; r < rLen; r += 1) {
  19107. cLen = arr[r].length;
  19108. for (c = 0; c < cLen; c += 1) {
  19109. if (c > 0) {
  19110. str += '\t';
  19111. }
  19112. val = arr[r][c];
  19113. if (typeof val === 'string') {
  19114. if (val.indexOf('\n') > -1) {
  19115. str += '"' + val.replace(/"/g, '""') + '"';
  19116. } else {
  19117. str += val;
  19118. }
  19119. } else if (val === null || val === void 0) {
  19120. str += '';
  19121. } else {
  19122. str += val;
  19123. }
  19124. }
  19125. str += '\n';
  19126. }
  19127. return str;
  19128. }
  19129. };
  19130. if (typeof exports !== 'undefined') {
  19131. exports.parse = SheetClip.parse;
  19132. exports.stringify = SheetClip.stringify;
  19133. } else {
  19134. global.SheetClip = SheetClip;
  19135. }
  19136. }(window));
  19137. //#
  19138. },{}],"autoResize":[function(require,module,exports){
  19139. "use strict";
  19140. function autoResize() {
  19141. var defaults = {
  19142. minHeight: 200,
  19143. maxHeight: 300,
  19144. minWidth: 100,
  19145. maxWidth: 300
  19146. },
  19147. el,
  19148. body = document.body,
  19149. text = document.createTextNode(''),
  19150. span = document.createElement('SPAN'),
  19151. observe = function(element, event, handler) {
  19152. if (window.attachEvent) {
  19153. element.attachEvent('on' + event, handler);
  19154. } else {
  19155. element.addEventListener(event, handler, false);
  19156. }
  19157. },
  19158. unObserve = function(element, event, handler) {
  19159. if (window.removeEventListener) {
  19160. element.removeEventListener(event, handler, false);
  19161. } else {
  19162. element.detachEvent('on' + event, handler);
  19163. }
  19164. },
  19165. resize = function(newChar) {
  19166. var width,
  19167. scrollHeight;
  19168. if (!newChar) {
  19169. newChar = "";
  19170. } else if (!/^[a-zA-Z \.,\\\/\|0-9]$/.test(newChar)) {
  19171. newChar = ".";
  19172. }
  19173. if (text.textContent !== void 0) {
  19174. text.textContent = el.value + newChar;
  19175. } else {
  19176. text.data = el.value + newChar;
  19177. }
  19178. span.style.fontSize = Handsontable.Dom.getComputedStyle(el).fontSize;
  19179. span.style.fontFamily = Handsontable.Dom.getComputedStyle(el).fontFamily;
  19180. span.style.whiteSpace = "pre";
  19181. body.appendChild(span);
  19182. width = span.clientWidth + 2;
  19183. body.removeChild(span);
  19184. el.style.height = defaults.minHeight + 'px';
  19185. if (defaults.minWidth > width) {
  19186. el.style.width = defaults.minWidth + 'px';
  19187. } else if (width > defaults.maxWidth) {
  19188. el.style.width = defaults.maxWidth + 'px';
  19189. } else {
  19190. el.style.width = width + 'px';
  19191. }
  19192. scrollHeight = el.scrollHeight ? el.scrollHeight - 1 : 0;
  19193. if (defaults.minHeight > scrollHeight) {
  19194. el.style.height = defaults.minHeight + 'px';
  19195. } else if (defaults.maxHeight < scrollHeight) {
  19196. el.style.height = defaults.maxHeight + 'px';
  19197. el.style.overflowY = 'visible';
  19198. } else {
  19199. el.style.height = scrollHeight + 'px';
  19200. }
  19201. },
  19202. delayedResize = function() {
  19203. window.setTimeout(resize, 0);
  19204. },
  19205. extendDefaults = function(config) {
  19206. if (config && config.minHeight) {
  19207. if (config.minHeight == 'inherit') {
  19208. defaults.minHeight = el.clientHeight;
  19209. } else {
  19210. var minHeight = parseInt(config.minHeight);
  19211. if (!isNaN(minHeight)) {
  19212. defaults.minHeight = minHeight;
  19213. }
  19214. }
  19215. }
  19216. if (config && config.maxHeight) {
  19217. if (config.maxHeight == 'inherit') {
  19218. defaults.maxHeight = el.clientHeight;
  19219. } else {
  19220. var maxHeight = parseInt(config.maxHeight);
  19221. if (!isNaN(maxHeight)) {
  19222. defaults.maxHeight = maxHeight;
  19223. }
  19224. }
  19225. }
  19226. if (config && config.minWidth) {
  19227. if (config.minWidth == 'inherit') {
  19228. defaults.minWidth = el.clientWidth;
  19229. } else {
  19230. var minWidth = parseInt(config.minWidth);
  19231. if (!isNaN(minWidth)) {
  19232. defaults.minWidth = minWidth;
  19233. }
  19234. }
  19235. }
  19236. if (config && config.maxWidth) {
  19237. if (config.maxWidth == 'inherit') {
  19238. defaults.maxWidth = el.clientWidth;
  19239. } else {
  19240. var maxWidth = parseInt(config.maxWidth);
  19241. if (!isNaN(maxWidth)) {
  19242. defaults.maxWidth = maxWidth;
  19243. }
  19244. }
  19245. }
  19246. if (!span.firstChild) {
  19247. span.className = "autoResize";
  19248. span.style.display = 'inline-block';
  19249. span.appendChild(text);
  19250. }
  19251. },
  19252. init = function(el_, config, doObserve) {
  19253. el = el_;
  19254. extendDefaults(config);
  19255. if (el.nodeName == 'TEXTAREA') {
  19256. el.style.resize = 'none';
  19257. el.style.overflowY = '';
  19258. el.style.height = defaults.minHeight + 'px';
  19259. el.style.minWidth = defaults.minWidth + 'px';
  19260. el.style.maxWidth = defaults.maxWidth + 'px';
  19261. el.style.overflowY = 'hidden';
  19262. }
  19263. if (doObserve) {
  19264. observe(el, 'change', resize);
  19265. observe(el, 'cut', delayedResize);
  19266. observe(el, 'paste', delayedResize);
  19267. observe(el, 'drop', delayedResize);
  19268. observe(el, 'keydown', delayedResize);
  19269. }
  19270. resize();
  19271. };
  19272. return {
  19273. init: function(el_, config, doObserve) {
  19274. init(el_, config, doObserve);
  19275. },
  19276. unObserve: function() {
  19277. unObserve(el, 'change', resize);
  19278. unObserve(el, 'cut', delayedResize);
  19279. unObserve(el, 'paste', delayedResize);
  19280. unObserve(el, 'drop', delayedResize);
  19281. unObserve(el, 'keydown', delayedResize);
  19282. },
  19283. resize: resize
  19284. };
  19285. }
  19286. if (typeof exports !== 'undefined') {
  19287. module.exports = autoResize;
  19288. }
  19289. //#
  19290. },{}],"copyPaste":[function(require,module,exports){
  19291. "use strict";
  19292. var instance;
  19293. function copyPaste() {
  19294. if (!instance) {
  19295. instance = new CopyPasteClass();
  19296. } else if (instance.hasBeenDestroyed()) {
  19297. instance.init();
  19298. }
  19299. instance.refCounter++;
  19300. return instance;
  19301. }
  19302. if (typeof exports !== 'undefined') {
  19303. module.exports = copyPaste;
  19304. }
  19305. function CopyPasteClass() {
  19306. this.refCounter = 0;
  19307. this.init();
  19308. }
  19309. CopyPasteClass.prototype.init = function() {
  19310. var style,
  19311. parent;
  19312. this.copyCallbacks = [];
  19313. this.cutCallbacks = [];
  19314. this.pasteCallbacks = [];
  19315. parent = document.body;
  19316. if (document.getElementById('CopyPasteDiv')) {
  19317. this.elDiv = document.getElementById('CopyPasteDiv');
  19318. this.elTextarea = this.elDiv.firstChild;
  19319. } else {
  19320. this.elDiv = document.createElement('div');
  19321. this.elDiv.id = 'CopyPasteDiv';
  19322. style = this.elDiv.style;
  19323. style.position = 'fixed';
  19324. style.top = '-10000px';
  19325. style.left = '-10000px';
  19326. parent.appendChild(this.elDiv);
  19327. this.elTextarea = document.createElement('textarea');
  19328. this.elTextarea.className = 'copyPaste';
  19329. this.elTextarea.onpaste = function(event) {
  19330. var clipboardContents,
  19331. temp;
  19332. if ('WebkitAppearance' in document.documentElement.style) {
  19333. clipboardContents = event.clipboardData.getData("Text");
  19334. if (navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1) {
  19335. temp = clipboardContents.split('\n');
  19336. if (temp[temp.length - 1] === '') {
  19337. temp.pop();
  19338. }
  19339. clipboardContents = temp.join('\n');
  19340. }
  19341. this.value = clipboardContents;
  19342. return false;
  19343. }
  19344. };
  19345. style = this.elTextarea.style;
  19346. style.width = '10000px';
  19347. style.height = '10000px';
  19348. style.overflow = 'hidden';
  19349. this.elDiv.appendChild(this.elTextarea);
  19350. if (typeof style.opacity !== 'undefined') {
  19351. style.opacity = 0;
  19352. }
  19353. }
  19354. this.onKeyDownRef = this.onKeyDown.bind(this);
  19355. document.documentElement.addEventListener('keydown', this.onKeyDownRef, false);
  19356. };
  19357. CopyPasteClass.prototype.onKeyDown = function(event) {
  19358. var _this = this,
  19359. isCtrlDown = false;
  19360. function isActiveElementEditable() {
  19361. var element = document.activeElement;
  19362. if (element.shadowRoot && element.shadowRoot.activeElement) {
  19363. element = element.shadowRoot.activeElement;
  19364. }
  19365. return ['INPUT', 'SELECT', 'TEXTAREA'].indexOf(element.nodeName) > -1 || element.contentEditable === 'true';
  19366. }
  19367. if (event.metaKey) {
  19368. isCtrlDown = true;
  19369. } else if (event.ctrlKey && navigator.userAgent.indexOf('Mac') === -1) {
  19370. isCtrlDown = true;
  19371. }
  19372. if (isCtrlDown) {
  19373. if (document.activeElement !== this.elTextarea && (this.getSelectionText() !== '' || isActiveElementEditable())) {
  19374. return;
  19375. }
  19376. this.selectNodeText(this.elTextarea);
  19377. setTimeout(function() {
  19378. if (document.activeElement !== _this.elTextarea) {
  19379. _this.selectNodeText(_this.elTextarea);
  19380. }
  19381. }, 0);
  19382. }
  19383. if (isCtrlDown && (event.keyCode === 67 || event.keyCode === 86 || event.keyCode === 88)) {
  19384. if (event.keyCode === 88) {
  19385. setTimeout(function() {
  19386. _this.triggerCut(event);
  19387. }, 0);
  19388. } else if (event.keyCode === 86) {
  19389. setTimeout(function() {
  19390. _this.triggerPaste(event);
  19391. }, 0);
  19392. }
  19393. }
  19394. };
  19395. CopyPasteClass.prototype.selectNodeText = function(element) {
  19396. if (element) {
  19397. element.select();
  19398. }
  19399. };
  19400. CopyPasteClass.prototype.getSelectionText = function() {
  19401. var text = '';
  19402. if (window.getSelection) {
  19403. text = window.getSelection().toString();
  19404. } else if (document.selection && document.selection.type !== 'Control') {
  19405. text = document.selection.createRange().text;
  19406. }
  19407. return text;
  19408. };
  19409. CopyPasteClass.prototype.copyable = function(string) {
  19410. if (typeof string !== 'string' && string.toString === void 0) {
  19411. throw new Error('copyable requires string parameter');
  19412. }
  19413. this.elTextarea.value = string;
  19414. this.selectNodeText(this.elTextarea);
  19415. };
  19416. CopyPasteClass.prototype.onCut = function(callback) {
  19417. this.cutCallbacks.push(callback);
  19418. };
  19419. CopyPasteClass.prototype.onPaste = function(callback) {
  19420. this.pasteCallbacks.push(callback);
  19421. };
  19422. CopyPasteClass.prototype.removeCallback = function(callback) {
  19423. var i,
  19424. len;
  19425. for (i = 0, len = this.copyCallbacks.length; i < len; i++) {
  19426. if (this.copyCallbacks[i] === callback) {
  19427. this.copyCallbacks.splice(i, 1);
  19428. return true;
  19429. }
  19430. }
  19431. for (i = 0, len = this.cutCallbacks.length; i < len; i++) {
  19432. if (this.cutCallbacks[i] === callback) {
  19433. this.cutCallbacks.splice(i, 1);
  19434. return true;
  19435. }
  19436. }
  19437. for (i = 0, len = this.pasteCallbacks.length; i < len; i++) {
  19438. if (this.pasteCallbacks[i] === callback) {
  19439. this.pasteCallbacks.splice(i, 1);
  19440. return true;
  19441. }
  19442. }
  19443. return false;
  19444. };
  19445. CopyPasteClass.prototype.triggerCut = function(event) {
  19446. var _this = this;
  19447. if (_this.cutCallbacks) {
  19448. setTimeout(function() {
  19449. for (var i = 0,
  19450. len = _this.cutCallbacks.length; i < len; i++) {
  19451. _this.cutCallbacks[i](event);
  19452. }
  19453. }, 50);
  19454. }
  19455. };
  19456. CopyPasteClass.prototype.triggerPaste = function(event, string) {
  19457. var _this = this;
  19458. if (_this.pasteCallbacks) {
  19459. setTimeout(function() {
  19460. var val = string || _this.elTextarea.value;
  19461. for (var i = 0,
  19462. len = _this.pasteCallbacks.length; i < len; i++) {
  19463. _this.pasteCallbacks[i](val, event);
  19464. }
  19465. }, 50);
  19466. }
  19467. };
  19468. CopyPasteClass.prototype.destroy = function() {
  19469. if (!this.hasBeenDestroyed() && --this.refCounter === 0) {
  19470. if (this.elDiv && this.elDiv.parentNode) {
  19471. this.elDiv.parentNode.removeChild(this.elDiv);
  19472. this.elDiv = null;
  19473. this.elTextarea = null;
  19474. }
  19475. document.documentElement.removeEventListener('keydown', this.onKeyDownRef);
  19476. this.onKeyDownRef = null;
  19477. }
  19478. };
  19479. CopyPasteClass.prototype.hasBeenDestroyed = function() {
  19480. return !this.refCounter;
  19481. };
  19482. //#
  19483. },{}],"es6collections":[function(require,module,exports){
  19484. "use strict";
  19485. (function(exports) {
  19486. 'use strict';
  19487. var i;
  19488. var defineProperty = Object.defineProperty,
  19489. is = function(a, b) {
  19490. return isNaN(a) ? isNaN(b) : a === b;
  19491. };
  19492. if (typeof WeakMap == 'undefined') {
  19493. exports.WeakMap = createCollection({
  19494. 'delete': sharedDelete,
  19495. clear: sharedClear,
  19496. get: sharedGet,
  19497. has: mapHas,
  19498. set: sharedSet
  19499. }, true);
  19500. }
  19501. if (typeof Map == 'undefined') {
  19502. exports.Map = createCollection({
  19503. 'delete': sharedDelete,
  19504. has: mapHas,
  19505. get: sharedGet,
  19506. set: sharedSet,
  19507. keys: sharedKeys,
  19508. values: sharedValues,
  19509. entries: mapEntries,
  19510. forEach: sharedForEach,
  19511. clear: sharedClear
  19512. });
  19513. }
  19514. if (typeof Set == 'undefined') {
  19515. exports.Set = createCollection({
  19516. has: setHas,
  19517. add: sharedAdd,
  19518. 'delete': sharedDelete,
  19519. clear: sharedClear,
  19520. keys: sharedValues,
  19521. values: sharedValues,
  19522. entries: setEntries,
  19523. forEach: sharedForEach
  19524. });
  19525. }
  19526. if (typeof WeakSet == 'undefined') {
  19527. exports.WeakSet = createCollection({
  19528. 'delete': sharedDelete,
  19529. add: sharedAdd,
  19530. clear: sharedClear,
  19531. has: setHas
  19532. }, true);
  19533. }
  19534. function createCollection(proto, objectOnly) {
  19535. function Collection(a) {
  19536. if (!this || this.constructor !== Collection)
  19537. return new Collection(a);
  19538. this._keys = [];
  19539. this._values = [];
  19540. this._itp = [];
  19541. this.objectOnly = objectOnly;
  19542. if (a)
  19543. init.call(this, a);
  19544. }
  19545. if (!objectOnly) {
  19546. defineProperty(proto, 'size', {get: sharedSize});
  19547. }
  19548. proto.constructor = Collection;
  19549. Collection.prototype = proto;
  19550. return Collection;
  19551. }
  19552. function init(a) {
  19553. var i;
  19554. if (this.add)
  19555. a.forEach(this.add, this);
  19556. else
  19557. a.forEach(function(a) {
  19558. this.set(a[0], a[1]);
  19559. }, this);
  19560. }
  19561. function sharedDelete(key) {
  19562. if (this.has(key)) {
  19563. this._keys.splice(i, 1);
  19564. this._values.splice(i, 1);
  19565. this._itp.forEach(function(p) {
  19566. if (i < p[0])
  19567. p[0]--;
  19568. });
  19569. }
  19570. return -1 < i;
  19571. }
  19572. ;
  19573. function sharedGet(key) {
  19574. return this.has(key) ? this._values[i] : undefined;
  19575. }
  19576. function has(list, key) {
  19577. if (this.objectOnly && key !== Object(key))
  19578. throw new TypeError("Invalid value used as weak collection key");
  19579. if (key != key || key === 0)
  19580. for (i = list.length; i-- && !is(list[i], key); ) {}
  19581. else
  19582. i = list.indexOf(key);
  19583. return -1 < i;
  19584. }
  19585. function setHas(value) {
  19586. return has.call(this, this._values, value);
  19587. }
  19588. function mapHas(value) {
  19589. return has.call(this, this._keys, value);
  19590. }
  19591. function sharedSet(key, value) {
  19592. this.has(key) ? this._values[i] = value : this._values[this._keys.push(key) - 1] = value;
  19593. return this;
  19594. }
  19595. function sharedAdd(value) {
  19596. if (!this.has(value))
  19597. this._values.push(value);
  19598. return this;
  19599. }
  19600. function sharedClear() {
  19601. this._values.length = 0;
  19602. }
  19603. function sharedKeys() {
  19604. return sharedIterator(this._itp, this._keys);
  19605. }
  19606. function sharedValues() {
  19607. return sharedIterator(this._itp, this._values);
  19608. }
  19609. function mapEntries() {
  19610. return sharedIterator(this._itp, this._keys, this._values);
  19611. }
  19612. function setEntries() {
  19613. return sharedIterator(this._itp, this._values, this._values);
  19614. }
  19615. function sharedIterator(itp, array, array2) {
  19616. var p = [0],
  19617. done = false;
  19618. itp.push(p);
  19619. return {next: function() {
  19620. var v,
  19621. k = p[0];
  19622. if (!done && k < array.length) {
  19623. v = array2 ? [array[k], array2[k]] : array[k];
  19624. p[0]++;
  19625. } else {
  19626. done = true;
  19627. itp.splice(itp.indexOf(p), 1);
  19628. }
  19629. return {
  19630. done: done,
  19631. value: v
  19632. };
  19633. }};
  19634. }
  19635. function sharedSize() {
  19636. return this._values.length;
  19637. }
  19638. function sharedForEach(callback, context) {
  19639. var it = this.entries();
  19640. for (; ; ) {
  19641. var r = it.next();
  19642. if (r.done)
  19643. break;
  19644. callback.call(context, r.value[1], r.value[0], this);
  19645. }
  19646. }
  19647. })(typeof exports != 'undefined' && typeof global != 'undefined' ? global : window);
  19648. //#
  19649. },{}],"jsonpatch":[function(require,module,exports){
  19650. "use strict";
  19651. var jsonpatch;
  19652. (function(jsonpatch) {
  19653. var objOps = {
  19654. add: function(obj, key) {
  19655. obj[key] = this.value;
  19656. return true;
  19657. },
  19658. remove: function(obj, key) {
  19659. delete obj[key];
  19660. return true;
  19661. },
  19662. replace: function(obj, key) {
  19663. obj[key] = this.value;
  19664. return true;
  19665. },
  19666. move: function(obj, key, tree) {
  19667. var temp = {
  19668. op: "_get",
  19669. path: this.from
  19670. };
  19671. apply(tree, [temp]);
  19672. apply(tree, [{
  19673. op: "remove",
  19674. path: this.from
  19675. }]);
  19676. apply(tree, [{
  19677. op: "add",
  19678. path: this.path,
  19679. value: temp.value
  19680. }]);
  19681. return true;
  19682. },
  19683. copy: function(obj, key, tree) {
  19684. var temp = {
  19685. op: "_get",
  19686. path: this.from
  19687. };
  19688. apply(tree, [temp]);
  19689. apply(tree, [{
  19690. op: "add",
  19691. path: this.path,
  19692. value: temp.value
  19693. }]);
  19694. return true;
  19695. },
  19696. test: function(obj, key) {
  19697. return (JSON.stringify(obj[key]) === JSON.stringify(this.value));
  19698. },
  19699. _get: function(obj, key) {
  19700. this.value = obj[key];
  19701. }
  19702. };
  19703. var arrOps = {
  19704. add: function(arr, i) {
  19705. arr.splice(i, 0, this.value);
  19706. return true;
  19707. },
  19708. remove: function(arr, i) {
  19709. arr.splice(i, 1);
  19710. return true;
  19711. },
  19712. replace: function(arr, i) {
  19713. arr[i] = this.value;
  19714. return true;
  19715. },
  19716. move: objOps.move,
  19717. copy: objOps.copy,
  19718. test: objOps.test,
  19719. _get: objOps._get
  19720. };
  19721. var observeOps = {
  19722. add: function(patches, path) {
  19723. var patch = {
  19724. op: "add",
  19725. path: path + escapePathComponent(this.name),
  19726. value: this.object[this.name]
  19727. };
  19728. patches.push(patch);
  19729. },
  19730. 'delete': function(patches, path) {
  19731. var patch = {
  19732. op: "remove",
  19733. path: path + escapePathComponent(this.name)
  19734. };
  19735. patches.push(patch);
  19736. },
  19737. update: function(patches, path) {
  19738. var patch = {
  19739. op: "replace",
  19740. path: path + escapePathComponent(this.name),
  19741. value: this.object[this.name]
  19742. };
  19743. patches.push(patch);
  19744. }
  19745. };
  19746. function escapePathComponent(str) {
  19747. if (str.indexOf('/') === -1 && str.indexOf('~') === -1) {
  19748. return str;
  19749. }
  19750. return str.replace(/~/g, '~0').replace(/\//g, '~1');
  19751. }
  19752. function _getPathRecursive(root, obj) {
  19753. var found;
  19754. for (var key in root) {
  19755. if (root.hasOwnProperty(key)) {
  19756. if (root[key] === obj) {
  19757. return escapePathComponent(key) + '/';
  19758. } else if (typeof root[key] === 'object') {
  19759. found = _getPathRecursive(root[key], obj);
  19760. if (found != '') {
  19761. return escapePathComponent(key) + '/' + found;
  19762. }
  19763. }
  19764. }
  19765. }
  19766. return '';
  19767. }
  19768. function getPath(root, obj) {
  19769. if (root === obj) {
  19770. return '/';
  19771. }
  19772. var path = _getPathRecursive(root, obj);
  19773. if (path === '') {
  19774. throw new Error("Object not found in root");
  19775. }
  19776. return '/' + path;
  19777. }
  19778. var beforeDict = [];
  19779. jsonpatch.intervals;
  19780. var Mirror = (function() {
  19781. function Mirror(obj) {
  19782. this.observers = [];
  19783. this.obj = obj;
  19784. }
  19785. return Mirror;
  19786. })();
  19787. var ObserverInfo = (function() {
  19788. function ObserverInfo(callback, observer) {
  19789. this.callback = callback;
  19790. this.observer = observer;
  19791. }
  19792. return ObserverInfo;
  19793. })();
  19794. function getMirror(obj) {
  19795. for (var i = 0,
  19796. ilen = beforeDict.length; i < ilen; i++) {
  19797. if (beforeDict[i].obj === obj) {
  19798. return beforeDict[i];
  19799. }
  19800. }
  19801. }
  19802. function removeMirror(obj) {
  19803. for (var i = 0,
  19804. ilen = beforeDict.length; i < ilen; i++) {
  19805. if (beforeDict[i] === obj) {
  19806. beforeDict.splice(i, 1);
  19807. }
  19808. }
  19809. }
  19810. function getObserverFromMirror(mirror, callback) {
  19811. for (var j = 0,
  19812. jlen = mirror.observers.length; j < jlen; j++) {
  19813. if (mirror.observers[j].callback === callback) {
  19814. return mirror.observers[j].observer;
  19815. }
  19816. }
  19817. }
  19818. function removeObserverFromMirror(mirror, observer) {
  19819. for (var j = 0,
  19820. jlen = mirror.observers.length; j < jlen; j++) {
  19821. if (mirror.observers[j].observer === observer) {
  19822. mirror.observers.splice(j, 1);
  19823. if (!mirror.observers.length) {
  19824. removeMirror(mirror);
  19825. }
  19826. return;
  19827. }
  19828. }
  19829. }
  19830. function unobserve(root, observer) {
  19831. generate(observer);
  19832. if (Object.observe) {
  19833. _unobserve(observer, root);
  19834. } else {
  19835. clearTimeout(observer.next);
  19836. }
  19837. var mirror = getMirror(root);
  19838. removeObserverFromMirror(mirror, observer);
  19839. }
  19840. jsonpatch.unobserve = unobserve;
  19841. function observe(obj, callback) {
  19842. var patches = [];
  19843. var root = obj;
  19844. var observer;
  19845. var mirror = getMirror(obj);
  19846. if (!mirror) {
  19847. mirror = new Mirror(obj);
  19848. beforeDict.push(mirror);
  19849. } else {
  19850. observer = getObserverFromMirror(mirror, callback);
  19851. }
  19852. if (observer) {
  19853. return observer;
  19854. }
  19855. if (Object.observe) {
  19856. observer = function(arr) {
  19857. _unobserve(observer, obj);
  19858. _observe(observer, obj);
  19859. var a = 0,
  19860. alen = arr.length;
  19861. while (a < alen) {
  19862. if (!(arr[a].name === 'length' && _isArray(arr[a].object)) && !(arr[a].name === '__Jasmine_been_here_before__')) {
  19863. var type = arr[a].type;
  19864. switch (type) {
  19865. case 'new':
  19866. type = 'add';
  19867. break;
  19868. case 'deleted':
  19869. type = 'delete';
  19870. break;
  19871. case 'updated':
  19872. type = 'update';
  19873. break;
  19874. }
  19875. observeOps[type].call(arr[a], patches, getPath(root, arr[a].object));
  19876. }
  19877. a++;
  19878. }
  19879. if (patches) {
  19880. if (callback) {
  19881. callback(patches);
  19882. }
  19883. }
  19884. observer.patches = patches;
  19885. patches = [];
  19886. };
  19887. } else {
  19888. observer = {};
  19889. mirror.value = JSON.parse(JSON.stringify(obj));
  19890. if (callback) {
  19891. observer.callback = callback;
  19892. observer.next = null;
  19893. var intervals = this.intervals || [100, 1000, 10000, 60000];
  19894. var currentInterval = 0;
  19895. var dirtyCheck = function() {
  19896. generate(observer);
  19897. };
  19898. var fastCheck = function() {
  19899. clearTimeout(observer.next);
  19900. observer.next = setTimeout(function() {
  19901. dirtyCheck();
  19902. currentInterval = 0;
  19903. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  19904. }, 0);
  19905. };
  19906. var slowCheck = function() {
  19907. dirtyCheck();
  19908. if (currentInterval == intervals.length) {
  19909. currentInterval = intervals.length - 1;
  19910. }
  19911. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  19912. };
  19913. if (typeof window !== 'undefined') {
  19914. if (window.addEventListener) {
  19915. window.addEventListener('mousedown', fastCheck);
  19916. window.addEventListener('mouseup', fastCheck);
  19917. window.addEventListener('keydown', fastCheck);
  19918. } else {
  19919. window.attachEvent('onmousedown', fastCheck);
  19920. window.attachEvent('onmouseup', fastCheck);
  19921. window.attachEvent('onkeydown', fastCheck);
  19922. }
  19923. }
  19924. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  19925. }
  19926. }
  19927. observer.patches = patches;
  19928. observer.object = obj;
  19929. mirror.observers.push(new ObserverInfo(callback, observer));
  19930. return _observe(observer, obj);
  19931. }
  19932. jsonpatch.observe = observe;
  19933. function _observe(observer, obj) {
  19934. if (Object.observe) {
  19935. Object.observe(obj, observer);
  19936. for (var key in obj) {
  19937. if (obj.hasOwnProperty(key)) {
  19938. var v = obj[key];
  19939. if (v && typeof(v) === "object") {
  19940. _observe(observer, v);
  19941. }
  19942. }
  19943. }
  19944. }
  19945. return observer;
  19946. }
  19947. function _unobserve(observer, obj) {
  19948. if (Object.observe) {
  19949. Object.unobserve(obj, observer);
  19950. for (var key in obj) {
  19951. if (obj.hasOwnProperty(key)) {
  19952. var v = obj[key];
  19953. if (v && typeof(v) === "object") {
  19954. _unobserve(observer, v);
  19955. }
  19956. }
  19957. }
  19958. }
  19959. return observer;
  19960. }
  19961. function generate(observer) {
  19962. if (Object.observe) {
  19963. Object.deliverChangeRecords(observer);
  19964. } else {
  19965. var mirror;
  19966. for (var i = 0,
  19967. ilen = beforeDict.length; i < ilen; i++) {
  19968. if (beforeDict[i].obj === observer.object) {
  19969. mirror = beforeDict[i];
  19970. break;
  19971. }
  19972. }
  19973. if (mirror) {
  19974. _generate(mirror.value, observer.object, observer.patches, "");
  19975. }
  19976. }
  19977. var temp = observer.patches;
  19978. if (temp.length > 0) {
  19979. observer.patches = [];
  19980. if (observer.callback) {
  19981. observer.callback(temp);
  19982. }
  19983. }
  19984. return temp;
  19985. }
  19986. jsonpatch.generate = generate;
  19987. var _objectKeys;
  19988. if (Object.keys) {
  19989. _objectKeys = Object.keys;
  19990. } else {
  19991. _objectKeys = function(obj) {
  19992. var keys = [];
  19993. for (var o in obj) {
  19994. if (obj.hasOwnProperty(o)) {
  19995. keys.push(o);
  19996. }
  19997. }
  19998. return keys;
  19999. };
  20000. }
  20001. function _generate(mirror, obj, patches, path) {
  20002. var newKeys = _objectKeys(obj);
  20003. var oldKeys = _objectKeys(mirror);
  20004. var changed = false;
  20005. var deleted = false;
  20006. for (var t = oldKeys.length - 1; t >= 0; t--) {
  20007. var key = oldKeys[t];
  20008. var oldVal = mirror[key];
  20009. if (obj.hasOwnProperty(key)) {
  20010. var newVal = obj[key];
  20011. if (oldVal instanceof Object) {
  20012. _generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key));
  20013. } else {
  20014. if (oldVal != newVal) {
  20015. changed = true;
  20016. patches.push({
  20017. op: "replace",
  20018. path: path + "/" + escapePathComponent(key),
  20019. value: newVal
  20020. });
  20021. mirror[key] = newVal;
  20022. }
  20023. }
  20024. } else {
  20025. patches.push({
  20026. op: "remove",
  20027. path: path + "/" + escapePathComponent(key)
  20028. });
  20029. delete mirror[key];
  20030. deleted = true;
  20031. }
  20032. }
  20033. if (!deleted && newKeys.length == oldKeys.length) {
  20034. return;
  20035. }
  20036. for (var t = 0; t < newKeys.length; t++) {
  20037. var key = newKeys[t];
  20038. if (!mirror.hasOwnProperty(key)) {
  20039. patches.push({
  20040. op: "add",
  20041. path: path + "/" + escapePathComponent(key),
  20042. value: obj[key]
  20043. });
  20044. mirror[key] = JSON.parse(JSON.stringify(obj[key]));
  20045. }
  20046. }
  20047. }
  20048. var _isArray;
  20049. if (Array.isArray) {
  20050. _isArray = Array.isArray;
  20051. } else {
  20052. _isArray = function(obj) {
  20053. return obj.push && typeof obj.length === 'number';
  20054. };
  20055. }
  20056. function apply(tree, patches) {
  20057. var result = false,
  20058. p = 0,
  20059. plen = patches.length,
  20060. patch;
  20061. while (p < plen) {
  20062. patch = patches[p];
  20063. var keys = patch.path.split('/');
  20064. var obj = tree;
  20065. var t = 1;
  20066. var len = keys.length;
  20067. while (true) {
  20068. if (_isArray(obj)) {
  20069. var index = parseInt(keys[t], 10);
  20070. t++;
  20071. if (t >= len) {
  20072. result = arrOps[patch.op].call(patch, obj, index, tree);
  20073. break;
  20074. }
  20075. obj = obj[index];
  20076. } else {
  20077. var key = keys[t];
  20078. if (key.indexOf('~') != -1) {
  20079. key = key.replace(/~1/g, '/').replace(/~0/g, '~');
  20080. }
  20081. t++;
  20082. if (t >= len) {
  20083. result = objOps[patch.op].call(patch, obj, key, tree);
  20084. break;
  20085. }
  20086. obj = obj[key];
  20087. }
  20088. }
  20089. p++;
  20090. }
  20091. return result;
  20092. }
  20093. jsonpatch.apply = apply;
  20094. })(jsonpatch || (jsonpatch = {}));
  20095. if (typeof exports !== "undefined") {
  20096. exports.apply = jsonpatch.apply;
  20097. exports.observe = jsonpatch.observe;
  20098. exports.unobserve = jsonpatch.unobserve;
  20099. exports.generate = jsonpatch.generate;
  20100. }
  20101. //#
  20102. },{}],"moment":[function(require,module,exports){
  20103. //! moment.js
  20104. //! version : 2.10.6
  20105. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  20106. //! license : MIT
  20107. //! momentjs.com
  20108. (function (global, factory) {
  20109. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  20110. typeof define === 'function' && define.amd ? define(factory) :
  20111. global.moment = factory()
  20112. }(this, function () { 'use strict';
  20113. var hookCallback;
  20114. function utils_hooks__hooks () {
  20115. return hookCallback.apply(null, arguments);
  20116. }
  20117. // This is done to register the method called with moment()
  20118. // without creating circular dependencies.
  20119. function setHookCallback (callback) {
  20120. hookCallback = callback;
  20121. }
  20122. function isArray(input) {
  20123. return Object.prototype.toString.call(input) === '[object Array]';
  20124. }
  20125. function isDate(input) {
  20126. return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
  20127. }
  20128. function map(arr, fn) {
  20129. var res = [], i;
  20130. for (i = 0; i < arr.length; ++i) {
  20131. res.push(fn(arr[i], i));
  20132. }
  20133. return res;
  20134. }
  20135. function hasOwnProp(a, b) {
  20136. return Object.prototype.hasOwnProperty.call(a, b);
  20137. }
  20138. function extend(a, b) {
  20139. for (var i in b) {
  20140. if (hasOwnProp(b, i)) {
  20141. a[i] = b[i];
  20142. }
  20143. }
  20144. if (hasOwnProp(b, 'toString')) {
  20145. a.toString = b.toString;
  20146. }
  20147. if (hasOwnProp(b, 'valueOf')) {
  20148. a.valueOf = b.valueOf;
  20149. }
  20150. return a;
  20151. }
  20152. function create_utc__createUTC (input, format, locale, strict) {
  20153. return createLocalOrUTC(input, format, locale, strict, true).utc();
  20154. }
  20155. function defaultParsingFlags() {
  20156. // We need to deep clone this object.
  20157. return {
  20158. empty : false,
  20159. unusedTokens : [],
  20160. unusedInput : [],
  20161. overflow : -2,
  20162. charsLeftOver : 0,
  20163. nullInput : false,
  20164. invalidMonth : null,
  20165. invalidFormat : false,
  20166. userInvalidated : false,
  20167. iso : false
  20168. };
  20169. }
  20170. function getParsingFlags(m) {
  20171. if (m._pf == null) {
  20172. m._pf = defaultParsingFlags();
  20173. }
  20174. return m._pf;
  20175. }
  20176. function valid__isValid(m) {
  20177. if (m._isValid == null) {
  20178. var flags = getParsingFlags(m);
  20179. m._isValid = !isNaN(m._d.getTime()) &&
  20180. flags.overflow < 0 &&
  20181. !flags.empty &&
  20182. !flags.invalidMonth &&
  20183. !flags.invalidWeekday &&
  20184. !flags.nullInput &&
  20185. !flags.invalidFormat &&
  20186. !flags.userInvalidated;
  20187. if (m._strict) {
  20188. m._isValid = m._isValid &&
  20189. flags.charsLeftOver === 0 &&
  20190. flags.unusedTokens.length === 0 &&
  20191. flags.bigHour === undefined;
  20192. }
  20193. }
  20194. return m._isValid;
  20195. }
  20196. function valid__createInvalid (flags) {
  20197. var m = create_utc__createUTC(NaN);
  20198. if (flags != null) {
  20199. extend(getParsingFlags(m), flags);
  20200. }
  20201. else {
  20202. getParsingFlags(m).userInvalidated = true;
  20203. }
  20204. return m;
  20205. }
  20206. var momentProperties = utils_hooks__hooks.momentProperties = [];
  20207. function copyConfig(to, from) {
  20208. var i, prop, val;
  20209. if (typeof from._isAMomentObject !== 'undefined') {
  20210. to._isAMomentObject = from._isAMomentObject;
  20211. }
  20212. if (typeof from._i !== 'undefined') {
  20213. to._i = from._i;
  20214. }
  20215. if (typeof from._f !== 'undefined') {
  20216. to._f = from._f;
  20217. }
  20218. if (typeof from._l !== 'undefined') {
  20219. to._l = from._l;
  20220. }
  20221. if (typeof from._strict !== 'undefined') {
  20222. to._strict = from._strict;
  20223. }
  20224. if (typeof from._tzm !== 'undefined') {
  20225. to._tzm = from._tzm;
  20226. }
  20227. if (typeof from._isUTC !== 'undefined') {
  20228. to._isUTC = from._isUTC;
  20229. }
  20230. if (typeof from._offset !== 'undefined') {
  20231. to._offset = from._offset;
  20232. }
  20233. if (typeof from._pf !== 'undefined') {
  20234. to._pf = getParsingFlags(from);
  20235. }
  20236. if (typeof from._locale !== 'undefined') {
  20237. to._locale = from._locale;
  20238. }
  20239. if (momentProperties.length > 0) {
  20240. for (i in momentProperties) {
  20241. prop = momentProperties[i];
  20242. val = from[prop];
  20243. if (typeof val !== 'undefined') {
  20244. to[prop] = val;
  20245. }
  20246. }
  20247. }
  20248. return to;
  20249. }
  20250. var updateInProgress = false;
  20251. // Moment prototype object
  20252. function Moment(config) {
  20253. copyConfig(this, config);
  20254. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  20255. // Prevent infinite loop in case updateOffset creates new moment
  20256. // objects.
  20257. if (updateInProgress === false) {
  20258. updateInProgress = true;
  20259. utils_hooks__hooks.updateOffset(this);
  20260. updateInProgress = false;
  20261. }
  20262. }
  20263. function isMoment (obj) {
  20264. return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
  20265. }
  20266. function absFloor (number) {
  20267. if (number < 0) {
  20268. return Math.ceil(number);
  20269. } else {
  20270. return Math.floor(number);
  20271. }
  20272. }
  20273. function toInt(argumentForCoercion) {
  20274. var coercedNumber = +argumentForCoercion,
  20275. value = 0;
  20276. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  20277. value = absFloor(coercedNumber);
  20278. }
  20279. return value;
  20280. }
  20281. function compareArrays(array1, array2, dontConvert) {
  20282. var len = Math.min(array1.length, array2.length),
  20283. lengthDiff = Math.abs(array1.length - array2.length),
  20284. diffs = 0,
  20285. i;
  20286. for (i = 0; i < len; i++) {
  20287. if ((dontConvert && array1[i] !== array2[i]) ||
  20288. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
  20289. diffs++;
  20290. }
  20291. }
  20292. return diffs + lengthDiff;
  20293. }
  20294. function Locale() {
  20295. }
  20296. var locales = {};
  20297. var globalLocale;
  20298. function normalizeLocale(key) {
  20299. return key ? key.toLowerCase().replace('_', '-') : key;
  20300. }
  20301. // pick the locale from the array
  20302. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  20303. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  20304. function chooseLocale(names) {
  20305. var i = 0, j, next, locale, split;
  20306. while (i < names.length) {
  20307. split = normalizeLocale(names[i]).split('-');
  20308. j = split.length;
  20309. next = normalizeLocale(names[i + 1]);
  20310. next = next ? next.split('-') : null;
  20311. while (j > 0) {
  20312. locale = loadLocale(split.slice(0, j).join('-'));
  20313. if (locale) {
  20314. return locale;
  20315. }
  20316. if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
  20317. //the next array item is better than a shallower substring of this one
  20318. break;
  20319. }
  20320. j--;
  20321. }
  20322. i++;
  20323. }
  20324. return null;
  20325. }
  20326. function loadLocale(name) {
  20327. var oldLocale = null;
  20328. // TODO: Find a better way to register and load all the locales in Node
  20329. if (!locales[name] && typeof module !== 'undefined' &&
  20330. module && module.exports) {
  20331. try {
  20332. oldLocale = globalLocale._abbr;
  20333. require('./locale/' + name);
  20334. // because defineLocale currently also sets the global locale, we
  20335. // want to undo that for lazy loaded locales
  20336. locale_locales__getSetGlobalLocale(oldLocale);
  20337. } catch (e) { }
  20338. }
  20339. return locales[name];
  20340. }
  20341. // This function will load locale and then set the global locale. If
  20342. // no arguments are passed in, it will simply return the current global
  20343. // locale key.
  20344. function locale_locales__getSetGlobalLocale (key, values) {
  20345. var data;
  20346. if (key) {
  20347. if (typeof values === 'undefined') {
  20348. data = locale_locales__getLocale(key);
  20349. }
  20350. else {
  20351. data = defineLocale(key, values);
  20352. }
  20353. if (data) {
  20354. // moment.duration._locale = moment._locale = data;
  20355. globalLocale = data;
  20356. }
  20357. }
  20358. return globalLocale._abbr;
  20359. }
  20360. function defineLocale (name, values) {
  20361. if (values !== null) {
  20362. values.abbr = name;
  20363. locales[name] = locales[name] || new Locale();
  20364. locales[name].set(values);
  20365. // backwards compat for now: also set the locale
  20366. locale_locales__getSetGlobalLocale(name);
  20367. return locales[name];
  20368. } else {
  20369. // useful for testing
  20370. delete locales[name];
  20371. return null;
  20372. }
  20373. }
  20374. // returns locale data
  20375. function locale_locales__getLocale (key) {
  20376. var locale;
  20377. if (key && key._locale && key._locale._abbr) {
  20378. key = key._locale._abbr;
  20379. }
  20380. if (!key) {
  20381. return globalLocale;
  20382. }
  20383. if (!isArray(key)) {
  20384. //short-circuit everything else
  20385. locale = loadLocale(key);
  20386. if (locale) {
  20387. return locale;
  20388. }
  20389. key = [key];
  20390. }
  20391. return chooseLocale(key);
  20392. }
  20393. var aliases = {};
  20394. function addUnitAlias (unit, shorthand) {
  20395. var lowerCase = unit.toLowerCase();
  20396. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  20397. }
  20398. function normalizeUnits(units) {
  20399. return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
  20400. }
  20401. function normalizeObjectUnits(inputObject) {
  20402. var normalizedInput = {},
  20403. normalizedProp,
  20404. prop;
  20405. for (prop in inputObject) {
  20406. if (hasOwnProp(inputObject, prop)) {
  20407. normalizedProp = normalizeUnits(prop);
  20408. if (normalizedProp) {
  20409. normalizedInput[normalizedProp] = inputObject[prop];
  20410. }
  20411. }
  20412. }
  20413. return normalizedInput;
  20414. }
  20415. function makeGetSet (unit, keepTime) {
  20416. return function (value) {
  20417. if (value != null) {
  20418. get_set__set(this, unit, value);
  20419. utils_hooks__hooks.updateOffset(this, keepTime);
  20420. return this;
  20421. } else {
  20422. return get_set__get(this, unit);
  20423. }
  20424. };
  20425. }
  20426. function get_set__get (mom, unit) {
  20427. return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
  20428. }
  20429. function get_set__set (mom, unit, value) {
  20430. return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  20431. }
  20432. // MOMENTS
  20433. function getSet (units, value) {
  20434. var unit;
  20435. if (typeof units === 'object') {
  20436. for (unit in units) {
  20437. this.set(unit, units[unit]);
  20438. }
  20439. } else {
  20440. units = normalizeUnits(units);
  20441. if (typeof this[units] === 'function') {
  20442. return this[units](value);
  20443. }
  20444. }
  20445. return this;
  20446. }
  20447. function zeroFill(number, targetLength, forceSign) {
  20448. var absNumber = '' + Math.abs(number),
  20449. zerosToFill = targetLength - absNumber.length,
  20450. sign = number >= 0;
  20451. return (sign ? (forceSign ? '+' : '') : '-') +
  20452. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
  20453. }
  20454. var formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
  20455. var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
  20456. var formatFunctions = {};
  20457. var formatTokenFunctions = {};
  20458. // token: 'M'
  20459. // padded: ['MM', 2]
  20460. // ordinal: 'Mo'
  20461. // callback: function () { this.month() + 1 }
  20462. function addFormatToken (token, padded, ordinal, callback) {
  20463. var func = callback;
  20464. if (typeof callback === 'string') {
  20465. func = function () {
  20466. return this[callback]();
  20467. };
  20468. }
  20469. if (token) {
  20470. formatTokenFunctions[token] = func;
  20471. }
  20472. if (padded) {
  20473. formatTokenFunctions[padded[0]] = function () {
  20474. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  20475. };
  20476. }
  20477. if (ordinal) {
  20478. formatTokenFunctions[ordinal] = function () {
  20479. return this.localeData().ordinal(func.apply(this, arguments), token);
  20480. };
  20481. }
  20482. }
  20483. function removeFormattingTokens(input) {
  20484. if (input.match(/\[[\s\S]/)) {
  20485. return input.replace(/^\[|\]$/g, '');
  20486. }
  20487. return input.replace(/\\/g, '');
  20488. }
  20489. function makeFormatFunction(format) {
  20490. var array = format.match(formattingTokens), i, length;
  20491. for (i = 0, length = array.length; i < length; i++) {
  20492. if (formatTokenFunctions[array[i]]) {
  20493. array[i] = formatTokenFunctions[array[i]];
  20494. } else {
  20495. array[i] = removeFormattingTokens(array[i]);
  20496. }
  20497. }
  20498. return function (mom) {
  20499. var output = '';
  20500. for (i = 0; i < length; i++) {
  20501. output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
  20502. }
  20503. return output;
  20504. };
  20505. }
  20506. // format date using native date object
  20507. function formatMoment(m, format) {
  20508. if (!m.isValid()) {
  20509. return m.localeData().invalidDate();
  20510. }
  20511. format = expandFormat(format, m.localeData());
  20512. formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
  20513. return formatFunctions[format](m);
  20514. }
  20515. function expandFormat(format, locale) {
  20516. var i = 5;
  20517. function replaceLongDateFormatTokens(input) {
  20518. return locale.longDateFormat(input) || input;
  20519. }
  20520. localFormattingTokens.lastIndex = 0;
  20521. while (i >= 0 && localFormattingTokens.test(format)) {
  20522. format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
  20523. localFormattingTokens.lastIndex = 0;
  20524. i -= 1;
  20525. }
  20526. return format;
  20527. }
  20528. var match1 = /\d/; // 0 - 9
  20529. var match2 = /\d\d/; // 00 - 99
  20530. var match3 = /\d{3}/; // 000 - 999
  20531. var match4 = /\d{4}/; // 0000 - 9999
  20532. var match6 = /[+-]?\d{6}/; // -999999 - 999999
  20533. var match1to2 = /\d\d?/; // 0 - 99
  20534. var match1to3 = /\d{1,3}/; // 0 - 999
  20535. var match1to4 = /\d{1,4}/; // 0 - 9999
  20536. var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
  20537. var matchUnsigned = /\d+/; // 0 - inf
  20538. var matchSigned = /[+-]?\d+/; // -inf - inf
  20539. var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
  20540. var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
  20541. // any word (or two) characters or numbers including two/three word month in arabic.
  20542. var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
  20543. var regexes = {};
  20544. function isFunction (sth) {
  20545. // https://github.com/moment/moment/issues/2325
  20546. return typeof sth === 'function' &&
  20547. Object.prototype.toString.call(sth) === '[object Function]';
  20548. }
  20549. function addRegexToken (token, regex, strictRegex) {
  20550. regexes[token] = isFunction(regex) ? regex : function (isStrict) {
  20551. return (isStrict && strictRegex) ? strictRegex : regex;
  20552. };
  20553. }
  20554. function getParseRegexForToken (token, config) {
  20555. if (!hasOwnProp(regexes, token)) {
  20556. return new RegExp(unescapeFormat(token));
  20557. }
  20558. return regexes[token](config._strict, config._locale);
  20559. }
  20560. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  20561. function unescapeFormat(s) {
  20562. return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
  20563. return p1 || p2 || p3 || p4;
  20564. }).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  20565. }
  20566. var tokens = {};
  20567. function addParseToken (token, callback) {
  20568. var i, func = callback;
  20569. if (typeof token === 'string') {
  20570. token = [token];
  20571. }
  20572. if (typeof callback === 'number') {
  20573. func = function (input, array) {
  20574. array[callback] = toInt(input);
  20575. };
  20576. }
  20577. for (i = 0; i < token.length; i++) {
  20578. tokens[token[i]] = func;
  20579. }
  20580. }
  20581. function addWeekParseToken (token, callback) {
  20582. addParseToken(token, function (input, array, config, token) {
  20583. config._w = config._w || {};
  20584. callback(input, config._w, config, token);
  20585. });
  20586. }
  20587. function addTimeToArrayFromToken(token, input, config) {
  20588. if (input != null && hasOwnProp(tokens, token)) {
  20589. tokens[token](input, config._a, config, token);
  20590. }
  20591. }
  20592. var YEAR = 0;
  20593. var MONTH = 1;
  20594. var DATE = 2;
  20595. var HOUR = 3;
  20596. var MINUTE = 4;
  20597. var SECOND = 5;
  20598. var MILLISECOND = 6;
  20599. function daysInMonth(year, month) {
  20600. return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
  20601. }
  20602. // FORMATTING
  20603. addFormatToken('M', ['MM', 2], 'Mo', function () {
  20604. return this.month() + 1;
  20605. });
  20606. addFormatToken('MMM', 0, 0, function (format) {
  20607. return this.localeData().monthsShort(this, format);
  20608. });
  20609. addFormatToken('MMMM', 0, 0, function (format) {
  20610. return this.localeData().months(this, format);
  20611. });
  20612. // ALIASES
  20613. addUnitAlias('month', 'M');
  20614. // PARSING
  20615. addRegexToken('M', match1to2);
  20616. addRegexToken('MM', match1to2, match2);
  20617. addRegexToken('MMM', matchWord);
  20618. addRegexToken('MMMM', matchWord);
  20619. addParseToken(['M', 'MM'], function (input, array) {
  20620. array[MONTH] = toInt(input) - 1;
  20621. });
  20622. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  20623. var month = config._locale.monthsParse(input, token, config._strict);
  20624. // if we didn't find a month name, mark the date as invalid.
  20625. if (month != null) {
  20626. array[MONTH] = month;
  20627. } else {
  20628. getParsingFlags(config).invalidMonth = input;
  20629. }
  20630. });
  20631. // LOCALES
  20632. var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
  20633. function localeMonths (m) {
  20634. return this._months[m.month()];
  20635. }
  20636. var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
  20637. function localeMonthsShort (m) {
  20638. return this._monthsShort[m.month()];
  20639. }
  20640. function localeMonthsParse (monthName, format, strict) {
  20641. var i, mom, regex;
  20642. if (!this._monthsParse) {
  20643. this._monthsParse = [];
  20644. this._longMonthsParse = [];
  20645. this._shortMonthsParse = [];
  20646. }
  20647. for (i = 0; i < 12; i++) {
  20648. // make the regex if we don't have it already
  20649. mom = create_utc__createUTC([2000, i]);
  20650. if (strict && !this._longMonthsParse[i]) {
  20651. this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
  20652. this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
  20653. }
  20654. if (!strict && !this._monthsParse[i]) {
  20655. regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  20656. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  20657. }
  20658. // test the regex
  20659. if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
  20660. return i;
  20661. } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
  20662. return i;
  20663. } else if (!strict && this._monthsParse[i].test(monthName)) {
  20664. return i;
  20665. }
  20666. }
  20667. }
  20668. // MOMENTS
  20669. function setMonth (mom, value) {
  20670. var dayOfMonth;
  20671. // TODO: Move this out of here!
  20672. if (typeof value === 'string') {
  20673. value = mom.localeData().monthsParse(value);
  20674. // TODO: Another silent failure?
  20675. if (typeof value !== 'number') {
  20676. return mom;
  20677. }
  20678. }
  20679. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  20680. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  20681. return mom;
  20682. }
  20683. function getSetMonth (value) {
  20684. if (value != null) {
  20685. setMonth(this, value);
  20686. utils_hooks__hooks.updateOffset(this, true);
  20687. return this;
  20688. } else {
  20689. return get_set__get(this, 'Month');
  20690. }
  20691. }
  20692. function getDaysInMonth () {
  20693. return daysInMonth(this.year(), this.month());
  20694. }
  20695. function checkOverflow (m) {
  20696. var overflow;
  20697. var a = m._a;
  20698. if (a && getParsingFlags(m).overflow === -2) {
  20699. overflow =
  20700. a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
  20701. a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
  20702. a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
  20703. a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
  20704. a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
  20705. a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
  20706. -1;
  20707. if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
  20708. overflow = DATE;
  20709. }
  20710. getParsingFlags(m).overflow = overflow;
  20711. }
  20712. return m;
  20713. }
  20714. function warn(msg) {
  20715. if (utils_hooks__hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
  20716. console.warn('Deprecation warning: ' + msg);
  20717. }
  20718. }
  20719. function deprecate(msg, fn) {
  20720. var firstTime = true;
  20721. return extend(function () {
  20722. if (firstTime) {
  20723. warn(msg + '\n' + (new Error()).stack);
  20724. firstTime = false;
  20725. }
  20726. return fn.apply(this, arguments);
  20727. }, fn);
  20728. }
  20729. var deprecations = {};
  20730. function deprecateSimple(name, msg) {
  20731. if (!deprecations[name]) {
  20732. warn(msg);
  20733. deprecations[name] = true;
  20734. }
  20735. }
  20736. utils_hooks__hooks.suppressDeprecationWarnings = false;
  20737. var from_string__isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
  20738. var isoDates = [
  20739. ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
  20740. ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
  20741. ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
  20742. ['GGGG-[W]WW', /\d{4}-W\d{2}/],
  20743. ['YYYY-DDD', /\d{4}-\d{3}/]
  20744. ];
  20745. // iso time formats and regexes
  20746. var isoTimes = [
  20747. ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
  20748. ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
  20749. ['HH:mm', /(T| )\d\d:\d\d/],
  20750. ['HH', /(T| )\d\d/]
  20751. ];
  20752. var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
  20753. // date from iso format
  20754. function configFromISO(config) {
  20755. var i, l,
  20756. string = config._i,
  20757. match = from_string__isoRegex.exec(string);
  20758. if (match) {
  20759. getParsingFlags(config).iso = true;
  20760. for (i = 0, l = isoDates.length; i < l; i++) {
  20761. if (isoDates[i][1].exec(string)) {
  20762. config._f = isoDates[i][0];
  20763. break;
  20764. }
  20765. }
  20766. for (i = 0, l = isoTimes.length; i < l; i++) {
  20767. if (isoTimes[i][1].exec(string)) {
  20768. // match[6] should be 'T' or space
  20769. config._f += (match[6] || ' ') + isoTimes[i][0];
  20770. break;
  20771. }
  20772. }
  20773. if (string.match(matchOffset)) {
  20774. config._f += 'Z';
  20775. }
  20776. configFromStringAndFormat(config);
  20777. } else {
  20778. config._isValid = false;
  20779. }
  20780. }
  20781. // date from iso format or fallback
  20782. function configFromString(config) {
  20783. var matched = aspNetJsonRegex.exec(config._i);
  20784. if (matched !== null) {
  20785. config._d = new Date(+matched[1]);
  20786. return;
  20787. }
  20788. configFromISO(config);
  20789. if (config._isValid === false) {
  20790. delete config._isValid;
  20791. utils_hooks__hooks.createFromInputFallback(config);
  20792. }
  20793. }
  20794. utils_hooks__hooks.createFromInputFallback = deprecate(
  20795. 'moment construction falls back to js Date. This is ' +
  20796. 'discouraged and will be removed in upcoming major ' +
  20797. 'release. Please refer to ' +
  20798. 'https://github.com/moment/moment/issues/1407 for more info.',
  20799. function (config) {
  20800. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  20801. }
  20802. );
  20803. function createDate (y, m, d, h, M, s, ms) {
  20804. //can't just apply() to create a date:
  20805. //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
  20806. var date = new Date(y, m, d, h, M, s, ms);
  20807. //the date constructor doesn't accept years < 1970
  20808. if (y < 1970) {
  20809. date.setFullYear(y);
  20810. }
  20811. return date;
  20812. }
  20813. function createUTCDate (y) {
  20814. var date = new Date(Date.UTC.apply(null, arguments));
  20815. if (y < 1970) {
  20816. date.setUTCFullYear(y);
  20817. }
  20818. return date;
  20819. }
  20820. addFormatToken(0, ['YY', 2], 0, function () {
  20821. return this.year() % 100;
  20822. });
  20823. addFormatToken(0, ['YYYY', 4], 0, 'year');
  20824. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  20825. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  20826. // ALIASES
  20827. addUnitAlias('year', 'y');
  20828. // PARSING
  20829. addRegexToken('Y', matchSigned);
  20830. addRegexToken('YY', match1to2, match2);
  20831. addRegexToken('YYYY', match1to4, match4);
  20832. addRegexToken('YYYYY', match1to6, match6);
  20833. addRegexToken('YYYYYY', match1to6, match6);
  20834. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  20835. addParseToken('YYYY', function (input, array) {
  20836. array[YEAR] = input.length === 2 ? utils_hooks__hooks.parseTwoDigitYear(input) : toInt(input);
  20837. });
  20838. addParseToken('YY', function (input, array) {
  20839. array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
  20840. });
  20841. // HELPERS
  20842. function daysInYear(year) {
  20843. return isLeapYear(year) ? 366 : 365;
  20844. }
  20845. function isLeapYear(year) {
  20846. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  20847. }
  20848. // HOOKS
  20849. utils_hooks__hooks.parseTwoDigitYear = function (input) {
  20850. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  20851. };
  20852. // MOMENTS
  20853. var getSetYear = makeGetSet('FullYear', false);
  20854. function getIsLeapYear () {
  20855. return isLeapYear(this.year());
  20856. }
  20857. addFormatToken('w', ['ww', 2], 'wo', 'week');
  20858. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  20859. // ALIASES
  20860. addUnitAlias('week', 'w');
  20861. addUnitAlias('isoWeek', 'W');
  20862. // PARSING
  20863. addRegexToken('w', match1to2);
  20864. addRegexToken('ww', match1to2, match2);
  20865. addRegexToken('W', match1to2);
  20866. addRegexToken('WW', match1to2, match2);
  20867. addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
  20868. week[token.substr(0, 1)] = toInt(input);
  20869. });
  20870. // HELPERS
  20871. // firstDayOfWeek 0 = sun, 6 = sat
  20872. // the day of the week that starts the week
  20873. // (usually sunday or monday)
  20874. // firstDayOfWeekOfYear 0 = sun, 6 = sat
  20875. // the first week is the week that contains the first
  20876. // of this day of the week
  20877. // (eg. ISO weeks use thursday (4))
  20878. function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
  20879. var end = firstDayOfWeekOfYear - firstDayOfWeek,
  20880. daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
  20881. adjustedMoment;
  20882. if (daysToDayOfWeek > end) {
  20883. daysToDayOfWeek -= 7;
  20884. }
  20885. if (daysToDayOfWeek < end - 7) {
  20886. daysToDayOfWeek += 7;
  20887. }
  20888. adjustedMoment = local__createLocal(mom).add(daysToDayOfWeek, 'd');
  20889. return {
  20890. week: Math.ceil(adjustedMoment.dayOfYear() / 7),
  20891. year: adjustedMoment.year()
  20892. };
  20893. }
  20894. // LOCALES
  20895. function localeWeek (mom) {
  20896. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  20897. }
  20898. var defaultLocaleWeek = {
  20899. dow : 0, // Sunday is the first day of the week.
  20900. doy : 6 // The week that contains Jan 1st is the first week of the year.
  20901. };
  20902. function localeFirstDayOfWeek () {
  20903. return this._week.dow;
  20904. }
  20905. function localeFirstDayOfYear () {
  20906. return this._week.doy;
  20907. }
  20908. // MOMENTS
  20909. function getSetWeek (input) {
  20910. var week = this.localeData().week(this);
  20911. return input == null ? week : this.add((input - week) * 7, 'd');
  20912. }
  20913. function getSetISOWeek (input) {
  20914. var week = weekOfYear(this, 1, 4).week;
  20915. return input == null ? week : this.add((input - week) * 7, 'd');
  20916. }
  20917. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  20918. // ALIASES
  20919. addUnitAlias('dayOfYear', 'DDD');
  20920. // PARSING
  20921. addRegexToken('DDD', match1to3);
  20922. addRegexToken('DDDD', match3);
  20923. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  20924. config._dayOfYear = toInt(input);
  20925. });
  20926. // HELPERS
  20927. //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  20928. function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
  20929. var week1Jan = 6 + firstDayOfWeek - firstDayOfWeekOfYear, janX = createUTCDate(year, 0, 1 + week1Jan), d = janX.getUTCDay(), dayOfYear;
  20930. if (d < firstDayOfWeek) {
  20931. d += 7;
  20932. }
  20933. weekday = weekday != null ? 1 * weekday : firstDayOfWeek;
  20934. dayOfYear = 1 + week1Jan + 7 * (week - 1) - d + weekday;
  20935. return {
  20936. year: dayOfYear > 0 ? year : year - 1,
  20937. dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
  20938. };
  20939. }
  20940. // MOMENTS
  20941. function getSetDayOfYear (input) {
  20942. var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
  20943. return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
  20944. }
  20945. // Pick the first defined of two or three arguments.
  20946. function defaults(a, b, c) {
  20947. if (a != null) {
  20948. return a;
  20949. }
  20950. if (b != null) {
  20951. return b;
  20952. }
  20953. return c;
  20954. }
  20955. function currentDateArray(config) {
  20956. var now = new Date();
  20957. if (config._useUTC) {
  20958. return [now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()];
  20959. }
  20960. return [now.getFullYear(), now.getMonth(), now.getDate()];
  20961. }
  20962. // convert an array to a date.
  20963. // the array should mirror the parameters below
  20964. // note: all values past the year are optional and will default to the lowest possible value.
  20965. // [year, month, day , hour, minute, second, millisecond]
  20966. function configFromArray (config) {
  20967. var i, date, input = [], currentDate, yearToUse;
  20968. if (config._d) {
  20969. return;
  20970. }
  20971. currentDate = currentDateArray(config);
  20972. //compute day of the year from weeks and weekdays
  20973. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  20974. dayOfYearFromWeekInfo(config);
  20975. }
  20976. //if the day of the year is set, figure out what it is
  20977. if (config._dayOfYear) {
  20978. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  20979. if (config._dayOfYear > daysInYear(yearToUse)) {
  20980. getParsingFlags(config)._overflowDayOfYear = true;
  20981. }
  20982. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  20983. config._a[MONTH] = date.getUTCMonth();
  20984. config._a[DATE] = date.getUTCDate();
  20985. }
  20986. // Default to current date.
  20987. // * if no year, month, day of month are given, default to today
  20988. // * if day of month is given, default month and year
  20989. // * if month is given, default only year
  20990. // * if year is given, don't default anything
  20991. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  20992. config._a[i] = input[i] = currentDate[i];
  20993. }
  20994. // Zero out whatever was not defaulted, including time
  20995. for (; i < 7; i++) {
  20996. config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
  20997. }
  20998. // Check for 24:00:00.000
  20999. if (config._a[HOUR] === 24 &&
  21000. config._a[MINUTE] === 0 &&
  21001. config._a[SECOND] === 0 &&
  21002. config._a[MILLISECOND] === 0) {
  21003. config._nextDay = true;
  21004. config._a[HOUR] = 0;
  21005. }
  21006. config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
  21007. // Apply timezone offset from input. The actual utcOffset can be changed
  21008. // with parseZone.
  21009. if (config._tzm != null) {
  21010. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  21011. }
  21012. if (config._nextDay) {
  21013. config._a[HOUR] = 24;
  21014. }
  21015. }
  21016. function dayOfYearFromWeekInfo(config) {
  21017. var w, weekYear, week, weekday, dow, doy, temp;
  21018. w = config._w;
  21019. if (w.GG != null || w.W != null || w.E != null) {
  21020. dow = 1;
  21021. doy = 4;
  21022. // TODO: We need to take the current isoWeekYear, but that depends on
  21023. // how we interpret now (local, utc, fixed offset). So create
  21024. // a now version of current config (take local/utc/offset flags, and
  21025. // create now).
  21026. weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(local__createLocal(), 1, 4).year);
  21027. week = defaults(w.W, 1);
  21028. weekday = defaults(w.E, 1);
  21029. } else {
  21030. dow = config._locale._week.dow;
  21031. doy = config._locale._week.doy;
  21032. weekYear = defaults(w.gg, config._a[YEAR], weekOfYear(local__createLocal(), dow, doy).year);
  21033. week = defaults(w.w, 1);
  21034. if (w.d != null) {
  21035. // weekday -- low day numbers are considered next week
  21036. weekday = w.d;
  21037. if (weekday < dow) {
  21038. ++week;
  21039. }
  21040. } else if (w.e != null) {
  21041. // local weekday -- counting starts from begining of week
  21042. weekday = w.e + dow;
  21043. } else {
  21044. // default to begining of week
  21045. weekday = dow;
  21046. }
  21047. }
  21048. temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
  21049. config._a[YEAR] = temp.year;
  21050. config._dayOfYear = temp.dayOfYear;
  21051. }
  21052. utils_hooks__hooks.ISO_8601 = function () {};
  21053. // date from string and format string
  21054. function configFromStringAndFormat(config) {
  21055. // TODO: Move this to another part of the creation flow to prevent circular deps
  21056. if (config._f === utils_hooks__hooks.ISO_8601) {
  21057. configFromISO(config);
  21058. return;
  21059. }
  21060. config._a = [];
  21061. getParsingFlags(config).empty = true;
  21062. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  21063. var string = '' + config._i,
  21064. i, parsedInput, tokens, token, skipped,
  21065. stringLength = string.length,
  21066. totalParsedInputLength = 0;
  21067. tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
  21068. for (i = 0; i < tokens.length; i++) {
  21069. token = tokens[i];
  21070. parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
  21071. if (parsedInput) {
  21072. skipped = string.substr(0, string.indexOf(parsedInput));
  21073. if (skipped.length > 0) {
  21074. getParsingFlags(config).unusedInput.push(skipped);
  21075. }
  21076. string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
  21077. totalParsedInputLength += parsedInput.length;
  21078. }
  21079. // don't parse if it's not a known token
  21080. if (formatTokenFunctions[token]) {
  21081. if (parsedInput) {
  21082. getParsingFlags(config).empty = false;
  21083. }
  21084. else {
  21085. getParsingFlags(config).unusedTokens.push(token);
  21086. }
  21087. addTimeToArrayFromToken(token, parsedInput, config);
  21088. }
  21089. else if (config._strict && !parsedInput) {
  21090. getParsingFlags(config).unusedTokens.push(token);
  21091. }
  21092. }
  21093. // add remaining unparsed input length to the string
  21094. getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
  21095. if (string.length > 0) {
  21096. getParsingFlags(config).unusedInput.push(string);
  21097. }
  21098. // clear _12h flag if hour is <= 12
  21099. if (getParsingFlags(config).bigHour === true &&
  21100. config._a[HOUR] <= 12 &&
  21101. config._a[HOUR] > 0) {
  21102. getParsingFlags(config).bigHour = undefined;
  21103. }
  21104. // handle meridiem
  21105. config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
  21106. configFromArray(config);
  21107. checkOverflow(config);
  21108. }
  21109. function meridiemFixWrap (locale, hour, meridiem) {
  21110. var isPm;
  21111. if (meridiem == null) {
  21112. // nothing to do
  21113. return hour;
  21114. }
  21115. if (locale.meridiemHour != null) {
  21116. return locale.meridiemHour(hour, meridiem);
  21117. } else if (locale.isPM != null) {
  21118. // Fallback
  21119. isPm = locale.isPM(meridiem);
  21120. if (isPm && hour < 12) {
  21121. hour += 12;
  21122. }
  21123. if (!isPm && hour === 12) {
  21124. hour = 0;
  21125. }
  21126. return hour;
  21127. } else {
  21128. // this is not supposed to happen
  21129. return hour;
  21130. }
  21131. }
  21132. function configFromStringAndArray(config) {
  21133. var tempConfig,
  21134. bestMoment,
  21135. scoreToBeat,
  21136. i,
  21137. currentScore;
  21138. if (config._f.length === 0) {
  21139. getParsingFlags(config).invalidFormat = true;
  21140. config._d = new Date(NaN);
  21141. return;
  21142. }
  21143. for (i = 0; i < config._f.length; i++) {
  21144. currentScore = 0;
  21145. tempConfig = copyConfig({}, config);
  21146. if (config._useUTC != null) {
  21147. tempConfig._useUTC = config._useUTC;
  21148. }
  21149. tempConfig._f = config._f[i];
  21150. configFromStringAndFormat(tempConfig);
  21151. if (!valid__isValid(tempConfig)) {
  21152. continue;
  21153. }
  21154. // if there is any input that was not parsed add a penalty for that format
  21155. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  21156. //or tokens
  21157. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  21158. getParsingFlags(tempConfig).score = currentScore;
  21159. if (scoreToBeat == null || currentScore < scoreToBeat) {
  21160. scoreToBeat = currentScore;
  21161. bestMoment = tempConfig;
  21162. }
  21163. }
  21164. extend(config, bestMoment || tempConfig);
  21165. }
  21166. function configFromObject(config) {
  21167. if (config._d) {
  21168. return;
  21169. }
  21170. var i = normalizeObjectUnits(config._i);
  21171. config._a = [i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond];
  21172. configFromArray(config);
  21173. }
  21174. function createFromConfig (config) {
  21175. var res = new Moment(checkOverflow(prepareConfig(config)));
  21176. if (res._nextDay) {
  21177. // Adding is smart enough around DST
  21178. res.add(1, 'd');
  21179. res._nextDay = undefined;
  21180. }
  21181. return res;
  21182. }
  21183. function prepareConfig (config) {
  21184. var input = config._i,
  21185. format = config._f;
  21186. config._locale = config._locale || locale_locales__getLocale(config._l);
  21187. if (input === null || (format === undefined && input === '')) {
  21188. return valid__createInvalid({nullInput: true});
  21189. }
  21190. if (typeof input === 'string') {
  21191. config._i = input = config._locale.preparse(input);
  21192. }
  21193. if (isMoment(input)) {
  21194. return new Moment(checkOverflow(input));
  21195. } else if (isArray(format)) {
  21196. configFromStringAndArray(config);
  21197. } else if (format) {
  21198. configFromStringAndFormat(config);
  21199. } else if (isDate(input)) {
  21200. config._d = input;
  21201. } else {
  21202. configFromInput(config);
  21203. }
  21204. return config;
  21205. }
  21206. function configFromInput(config) {
  21207. var input = config._i;
  21208. if (input === undefined) {
  21209. config._d = new Date();
  21210. } else if (isDate(input)) {
  21211. config._d = new Date(+input);
  21212. } else if (typeof input === 'string') {
  21213. configFromString(config);
  21214. } else if (isArray(input)) {
  21215. config._a = map(input.slice(0), function (obj) {
  21216. return parseInt(obj, 10);
  21217. });
  21218. configFromArray(config);
  21219. } else if (typeof(input) === 'object') {
  21220. configFromObject(config);
  21221. } else if (typeof(input) === 'number') {
  21222. // from milliseconds
  21223. config._d = new Date(input);
  21224. } else {
  21225. utils_hooks__hooks.createFromInputFallback(config);
  21226. }
  21227. }
  21228. function createLocalOrUTC (input, format, locale, strict, isUTC) {
  21229. var c = {};
  21230. if (typeof(locale) === 'boolean') {
  21231. strict = locale;
  21232. locale = undefined;
  21233. }
  21234. // object construction must be done this way.
  21235. // https://github.com/moment/moment/issues/1423
  21236. c._isAMomentObject = true;
  21237. c._useUTC = c._isUTC = isUTC;
  21238. c._l = locale;
  21239. c._i = input;
  21240. c._f = format;
  21241. c._strict = strict;
  21242. return createFromConfig(c);
  21243. }
  21244. function local__createLocal (input, format, locale, strict) {
  21245. return createLocalOrUTC(input, format, locale, strict, false);
  21246. }
  21247. var prototypeMin = deprecate(
  21248. 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
  21249. function () {
  21250. var other = local__createLocal.apply(null, arguments);
  21251. return other < this ? this : other;
  21252. }
  21253. );
  21254. var prototypeMax = deprecate(
  21255. 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
  21256. function () {
  21257. var other = local__createLocal.apply(null, arguments);
  21258. return other > this ? this : other;
  21259. }
  21260. );
  21261. // Pick a moment m from moments so that m[fn](other) is true for all
  21262. // other. This relies on the function fn to be transitive.
  21263. //
  21264. // moments should either be an array of moment objects or an array, whose
  21265. // first element is an array of moment objects.
  21266. function pickBy(fn, moments) {
  21267. var res, i;
  21268. if (moments.length === 1 && isArray(moments[0])) {
  21269. moments = moments[0];
  21270. }
  21271. if (!moments.length) {
  21272. return local__createLocal();
  21273. }
  21274. res = moments[0];
  21275. for (i = 1; i < moments.length; ++i) {
  21276. if (!moments[i].isValid() || moments[i][fn](res)) {
  21277. res = moments[i];
  21278. }
  21279. }
  21280. return res;
  21281. }
  21282. // TODO: Use [].sort instead?
  21283. function min () {
  21284. var args = [].slice.call(arguments, 0);
  21285. return pickBy('isBefore', args);
  21286. }
  21287. function max () {
  21288. var args = [].slice.call(arguments, 0);
  21289. return pickBy('isAfter', args);
  21290. }
  21291. function Duration (duration) {
  21292. var normalizedInput = normalizeObjectUnits(duration),
  21293. years = normalizedInput.year || 0,
  21294. quarters = normalizedInput.quarter || 0,
  21295. months = normalizedInput.month || 0,
  21296. weeks = normalizedInput.week || 0,
  21297. days = normalizedInput.day || 0,
  21298. hours = normalizedInput.hour || 0,
  21299. minutes = normalizedInput.minute || 0,
  21300. seconds = normalizedInput.second || 0,
  21301. milliseconds = normalizedInput.millisecond || 0;
  21302. // representation for dateAddRemove
  21303. this._milliseconds = +milliseconds +
  21304. seconds * 1e3 + // 1000
  21305. minutes * 6e4 + // 1000 * 60
  21306. hours * 36e5; // 1000 * 60 * 60
  21307. // Because of dateAddRemove treats 24 hours as different from a
  21308. // day when working around DST, we need to store them separately
  21309. this._days = +days +
  21310. weeks * 7;
  21311. // It is impossible translate months into days without knowing
  21312. // which months you are are talking about, so we have to store
  21313. // it separately.
  21314. this._months = +months +
  21315. quarters * 3 +
  21316. years * 12;
  21317. this._data = {};
  21318. this._locale = locale_locales__getLocale();
  21319. this._bubble();
  21320. }
  21321. function isDuration (obj) {
  21322. return obj instanceof Duration;
  21323. }
  21324. function offset (token, separator) {
  21325. addFormatToken(token, 0, 0, function () {
  21326. var offset = this.utcOffset();
  21327. var sign = '+';
  21328. if (offset < 0) {
  21329. offset = -offset;
  21330. sign = '-';
  21331. }
  21332. return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
  21333. });
  21334. }
  21335. offset('Z', ':');
  21336. offset('ZZ', '');
  21337. // PARSING
  21338. addRegexToken('Z', matchOffset);
  21339. addRegexToken('ZZ', matchOffset);
  21340. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  21341. config._useUTC = true;
  21342. config._tzm = offsetFromString(input);
  21343. });
  21344. // HELPERS
  21345. // timezone chunker
  21346. // '+10:00' > ['10', '00']
  21347. // '-1530' > ['-15', '30']
  21348. var chunkOffset = /([\+\-]|\d\d)/gi;
  21349. function offsetFromString(string) {
  21350. var matches = ((string || '').match(matchOffset) || []);
  21351. var chunk = matches[matches.length - 1] || [];
  21352. var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  21353. var minutes = +(parts[1] * 60) + toInt(parts[2]);
  21354. return parts[0] === '+' ? minutes : -minutes;
  21355. }
  21356. // Return a moment from input, that is local/utc/zone equivalent to model.
  21357. function cloneWithOffset(input, model) {
  21358. var res, diff;
  21359. if (model._isUTC) {
  21360. res = model.clone();
  21361. diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
  21362. // Use low-level api, because this fn is low-level api.
  21363. res._d.setTime(+res._d + diff);
  21364. utils_hooks__hooks.updateOffset(res, false);
  21365. return res;
  21366. } else {
  21367. return local__createLocal(input).local();
  21368. }
  21369. }
  21370. function getDateOffset (m) {
  21371. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  21372. // https://github.com/moment/moment/pull/1871
  21373. return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
  21374. }
  21375. // HOOKS
  21376. // This function will be called whenever a moment is mutated.
  21377. // It is intended to keep the offset in sync with the timezone.
  21378. utils_hooks__hooks.updateOffset = function () {};
  21379. // MOMENTS
  21380. // keepLocalTime = true means only change the timezone, without
  21381. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  21382. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  21383. // +0200, so we adjust the time as needed, to be valid.
  21384. //
  21385. // Keeping the time actually adds/subtracts (one hour)
  21386. // from the actual represented time. That is why we call updateOffset
  21387. // a second time. In case it wants us to change the offset again
  21388. // _changeInProgress == true case, then we have to adjust, because
  21389. // there is no such time in the given timezone.
  21390. function getSetOffset (input, keepLocalTime) {
  21391. var offset = this._offset || 0,
  21392. localAdjust;
  21393. if (input != null) {
  21394. if (typeof input === 'string') {
  21395. input = offsetFromString(input);
  21396. }
  21397. if (Math.abs(input) < 16) {
  21398. input = input * 60;
  21399. }
  21400. if (!this._isUTC && keepLocalTime) {
  21401. localAdjust = getDateOffset(this);
  21402. }
  21403. this._offset = input;
  21404. this._isUTC = true;
  21405. if (localAdjust != null) {
  21406. this.add(localAdjust, 'm');
  21407. }
  21408. if (offset !== input) {
  21409. if (!keepLocalTime || this._changeInProgress) {
  21410. add_subtract__addSubtract(this, create__createDuration(input - offset, 'm'), 1, false);
  21411. } else if (!this._changeInProgress) {
  21412. this._changeInProgress = true;
  21413. utils_hooks__hooks.updateOffset(this, true);
  21414. this._changeInProgress = null;
  21415. }
  21416. }
  21417. return this;
  21418. } else {
  21419. return this._isUTC ? offset : getDateOffset(this);
  21420. }
  21421. }
  21422. function getSetZone (input, keepLocalTime) {
  21423. if (input != null) {
  21424. if (typeof input !== 'string') {
  21425. input = -input;
  21426. }
  21427. this.utcOffset(input, keepLocalTime);
  21428. return this;
  21429. } else {
  21430. return -this.utcOffset();
  21431. }
  21432. }
  21433. function setOffsetToUTC (keepLocalTime) {
  21434. return this.utcOffset(0, keepLocalTime);
  21435. }
  21436. function setOffsetToLocal (keepLocalTime) {
  21437. if (this._isUTC) {
  21438. this.utcOffset(0, keepLocalTime);
  21439. this._isUTC = false;
  21440. if (keepLocalTime) {
  21441. this.subtract(getDateOffset(this), 'm');
  21442. }
  21443. }
  21444. return this;
  21445. }
  21446. function setOffsetToParsedOffset () {
  21447. if (this._tzm) {
  21448. this.utcOffset(this._tzm);
  21449. } else if (typeof this._i === 'string') {
  21450. this.utcOffset(offsetFromString(this._i));
  21451. }
  21452. return this;
  21453. }
  21454. function hasAlignedHourOffset (input) {
  21455. input = input ? local__createLocal(input).utcOffset() : 0;
  21456. return (this.utcOffset() - input) % 60 === 0;
  21457. }
  21458. function isDaylightSavingTime () {
  21459. return (
  21460. this.utcOffset() > this.clone().month(0).utcOffset() ||
  21461. this.utcOffset() > this.clone().month(5).utcOffset()
  21462. );
  21463. }
  21464. function isDaylightSavingTimeShifted () {
  21465. if (typeof this._isDSTShifted !== 'undefined') {
  21466. return this._isDSTShifted;
  21467. }
  21468. var c = {};
  21469. copyConfig(c, this);
  21470. c = prepareConfig(c);
  21471. if (c._a) {
  21472. var other = c._isUTC ? create_utc__createUTC(c._a) : local__createLocal(c._a);
  21473. this._isDSTShifted = this.isValid() &&
  21474. compareArrays(c._a, other.toArray()) > 0;
  21475. } else {
  21476. this._isDSTShifted = false;
  21477. }
  21478. return this._isDSTShifted;
  21479. }
  21480. function isLocal () {
  21481. return !this._isUTC;
  21482. }
  21483. function isUtcOffset () {
  21484. return this._isUTC;
  21485. }
  21486. function isUtc () {
  21487. return this._isUTC && this._offset === 0;
  21488. }
  21489. var aspNetRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
  21490. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  21491. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  21492. var create__isoRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;
  21493. function create__createDuration (input, key) {
  21494. var duration = input,
  21495. // matching against regexp is expensive, do it on demand
  21496. match = null,
  21497. sign,
  21498. ret,
  21499. diffRes;
  21500. if (isDuration(input)) {
  21501. duration = {
  21502. ms : input._milliseconds,
  21503. d : input._days,
  21504. M : input._months
  21505. };
  21506. } else if (typeof input === 'number') {
  21507. duration = {};
  21508. if (key) {
  21509. duration[key] = input;
  21510. } else {
  21511. duration.milliseconds = input;
  21512. }
  21513. } else if (!!(match = aspNetRegex.exec(input))) {
  21514. sign = (match[1] === '-') ? -1 : 1;
  21515. duration = {
  21516. y : 0,
  21517. d : toInt(match[DATE]) * sign,
  21518. h : toInt(match[HOUR]) * sign,
  21519. m : toInt(match[MINUTE]) * sign,
  21520. s : toInt(match[SECOND]) * sign,
  21521. ms : toInt(match[MILLISECOND]) * sign
  21522. };
  21523. } else if (!!(match = create__isoRegex.exec(input))) {
  21524. sign = (match[1] === '-') ? -1 : 1;
  21525. duration = {
  21526. y : parseIso(match[2], sign),
  21527. M : parseIso(match[3], sign),
  21528. d : parseIso(match[4], sign),
  21529. h : parseIso(match[5], sign),
  21530. m : parseIso(match[6], sign),
  21531. s : parseIso(match[7], sign),
  21532. w : parseIso(match[8], sign)
  21533. };
  21534. } else if (duration == null) {// checks for null or undefined
  21535. duration = {};
  21536. } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
  21537. diffRes = momentsDifference(local__createLocal(duration.from), local__createLocal(duration.to));
  21538. duration = {};
  21539. duration.ms = diffRes.milliseconds;
  21540. duration.M = diffRes.months;
  21541. }
  21542. ret = new Duration(duration);
  21543. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  21544. ret._locale = input._locale;
  21545. }
  21546. return ret;
  21547. }
  21548. create__createDuration.fn = Duration.prototype;
  21549. function parseIso (inp, sign) {
  21550. // We'd normally use ~~inp for this, but unfortunately it also
  21551. // converts floats to ints.
  21552. // inp may be undefined, so careful calling replace on it.
  21553. var res = inp && parseFloat(inp.replace(',', '.'));
  21554. // apply sign while we're at it
  21555. return (isNaN(res) ? 0 : res) * sign;
  21556. }
  21557. function positiveMomentsDifference(base, other) {
  21558. var res = {milliseconds: 0, months: 0};
  21559. res.months = other.month() - base.month() +
  21560. (other.year() - base.year()) * 12;
  21561. if (base.clone().add(res.months, 'M').isAfter(other)) {
  21562. --res.months;
  21563. }
  21564. res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
  21565. return res;
  21566. }
  21567. function momentsDifference(base, other) {
  21568. var res;
  21569. other = cloneWithOffset(other, base);
  21570. if (base.isBefore(other)) {
  21571. res = positiveMomentsDifference(base, other);
  21572. } else {
  21573. res = positiveMomentsDifference(other, base);
  21574. res.milliseconds = -res.milliseconds;
  21575. res.months = -res.months;
  21576. }
  21577. return res;
  21578. }
  21579. function createAdder(direction, name) {
  21580. return function (val, period) {
  21581. var dur, tmp;
  21582. //invert the arguments, but complain about it
  21583. if (period !== null && !isNaN(+period)) {
  21584. deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
  21585. tmp = val; val = period; period = tmp;
  21586. }
  21587. val = typeof val === 'string' ? +val : val;
  21588. dur = create__createDuration(val, period);
  21589. add_subtract__addSubtract(this, dur, direction);
  21590. return this;
  21591. };
  21592. }
  21593. function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) {
  21594. var milliseconds = duration._milliseconds,
  21595. days = duration._days,
  21596. months = duration._months;
  21597. updateOffset = updateOffset == null ? true : updateOffset;
  21598. if (milliseconds) {
  21599. mom._d.setTime(+mom._d + milliseconds * isAdding);
  21600. }
  21601. if (days) {
  21602. get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
  21603. }
  21604. if (months) {
  21605. setMonth(mom, get_set__get(mom, 'Month') + months * isAdding);
  21606. }
  21607. if (updateOffset) {
  21608. utils_hooks__hooks.updateOffset(mom, days || months);
  21609. }
  21610. }
  21611. var add_subtract__add = createAdder(1, 'add');
  21612. var add_subtract__subtract = createAdder(-1, 'subtract');
  21613. function moment_calendar__calendar (time, formats) {
  21614. // We want to compare the start of today, vs this.
  21615. // Getting start-of-today depends on whether we're local/utc/offset or not.
  21616. var now = time || local__createLocal(),
  21617. sod = cloneWithOffset(now, this).startOf('day'),
  21618. diff = this.diff(sod, 'days', true),
  21619. format = diff < -6 ? 'sameElse' :
  21620. diff < -1 ? 'lastWeek' :
  21621. diff < 0 ? 'lastDay' :
  21622. diff < 1 ? 'sameDay' :
  21623. diff < 2 ? 'nextDay' :
  21624. diff < 7 ? 'nextWeek' : 'sameElse';
  21625. return this.format(formats && formats[format] || this.localeData().calendar(format, this, local__createLocal(now)));
  21626. }
  21627. function clone () {
  21628. return new Moment(this);
  21629. }
  21630. function isAfter (input, units) {
  21631. var inputMs;
  21632. units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
  21633. if (units === 'millisecond') {
  21634. input = isMoment(input) ? input : local__createLocal(input);
  21635. return +this > +input;
  21636. } else {
  21637. inputMs = isMoment(input) ? +input : +local__createLocal(input);
  21638. return inputMs < +this.clone().startOf(units);
  21639. }
  21640. }
  21641. function isBefore (input, units) {
  21642. var inputMs;
  21643. units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
  21644. if (units === 'millisecond') {
  21645. input = isMoment(input) ? input : local__createLocal(input);
  21646. return +this < +input;
  21647. } else {
  21648. inputMs = isMoment(input) ? +input : +local__createLocal(input);
  21649. return +this.clone().endOf(units) < inputMs;
  21650. }
  21651. }
  21652. function isBetween (from, to, units) {
  21653. return this.isAfter(from, units) && this.isBefore(to, units);
  21654. }
  21655. function isSame (input, units) {
  21656. var inputMs;
  21657. units = normalizeUnits(units || 'millisecond');
  21658. if (units === 'millisecond') {
  21659. input = isMoment(input) ? input : local__createLocal(input);
  21660. return +this === +input;
  21661. } else {
  21662. inputMs = +local__createLocal(input);
  21663. return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
  21664. }
  21665. }
  21666. function diff (input, units, asFloat) {
  21667. var that = cloneWithOffset(input, this),
  21668. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4,
  21669. delta, output;
  21670. units = normalizeUnits(units);
  21671. if (units === 'year' || units === 'month' || units === 'quarter') {
  21672. output = monthDiff(this, that);
  21673. if (units === 'quarter') {
  21674. output = output / 3;
  21675. } else if (units === 'year') {
  21676. output = output / 12;
  21677. }
  21678. } else {
  21679. delta = this - that;
  21680. output = units === 'second' ? delta / 1e3 : // 1000
  21681. units === 'minute' ? delta / 6e4 : // 1000 * 60
  21682. units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
  21683. units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
  21684. units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
  21685. delta;
  21686. }
  21687. return asFloat ? output : absFloor(output);
  21688. }
  21689. function monthDiff (a, b) {
  21690. // difference in months
  21691. var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
  21692. // b is in (anchor - 1 month, anchor + 1 month)
  21693. anchor = a.clone().add(wholeMonthDiff, 'months'),
  21694. anchor2, adjust;
  21695. if (b - anchor < 0) {
  21696. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  21697. // linear across the month
  21698. adjust = (b - anchor) / (anchor - anchor2);
  21699. } else {
  21700. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  21701. // linear across the month
  21702. adjust = (b - anchor) / (anchor2 - anchor);
  21703. }
  21704. return -(wholeMonthDiff + adjust);
  21705. }
  21706. utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  21707. function toString () {
  21708. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  21709. }
  21710. function moment_format__toISOString () {
  21711. var m = this.clone().utc();
  21712. if (0 < m.year() && m.year() <= 9999) {
  21713. if ('function' === typeof Date.prototype.toISOString) {
  21714. // native implementation is ~50x faster, use it when we can
  21715. return this.toDate().toISOString();
  21716. } else {
  21717. return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  21718. }
  21719. } else {
  21720. return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  21721. }
  21722. }
  21723. function format (inputString) {
  21724. var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
  21725. return this.localeData().postformat(output);
  21726. }
  21727. function from (time, withoutSuffix) {
  21728. if (!this.isValid()) {
  21729. return this.localeData().invalidDate();
  21730. }
  21731. return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
  21732. }
  21733. function fromNow (withoutSuffix) {
  21734. return this.from(local__createLocal(), withoutSuffix);
  21735. }
  21736. function to (time, withoutSuffix) {
  21737. if (!this.isValid()) {
  21738. return this.localeData().invalidDate();
  21739. }
  21740. return create__createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
  21741. }
  21742. function toNow (withoutSuffix) {
  21743. return this.to(local__createLocal(), withoutSuffix);
  21744. }
  21745. function locale (key) {
  21746. var newLocaleData;
  21747. if (key === undefined) {
  21748. return this._locale._abbr;
  21749. } else {
  21750. newLocaleData = locale_locales__getLocale(key);
  21751. if (newLocaleData != null) {
  21752. this._locale = newLocaleData;
  21753. }
  21754. return this;
  21755. }
  21756. }
  21757. var lang = deprecate(
  21758. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  21759. function (key) {
  21760. if (key === undefined) {
  21761. return this.localeData();
  21762. } else {
  21763. return this.locale(key);
  21764. }
  21765. }
  21766. );
  21767. function localeData () {
  21768. return this._locale;
  21769. }
  21770. function startOf (units) {
  21771. units = normalizeUnits(units);
  21772. // the following switch intentionally omits break keywords
  21773. // to utilize falling through the cases.
  21774. switch (units) {
  21775. case 'year':
  21776. this.month(0);
  21777. /* falls through */
  21778. case 'quarter':
  21779. case 'month':
  21780. this.date(1);
  21781. /* falls through */
  21782. case 'week':
  21783. case 'isoWeek':
  21784. case 'day':
  21785. this.hours(0);
  21786. /* falls through */
  21787. case 'hour':
  21788. this.minutes(0);
  21789. /* falls through */
  21790. case 'minute':
  21791. this.seconds(0);
  21792. /* falls through */
  21793. case 'second':
  21794. this.milliseconds(0);
  21795. }
  21796. // weeks are a special case
  21797. if (units === 'week') {
  21798. this.weekday(0);
  21799. }
  21800. if (units === 'isoWeek') {
  21801. this.isoWeekday(1);
  21802. }
  21803. // quarters are also special
  21804. if (units === 'quarter') {
  21805. this.month(Math.floor(this.month() / 3) * 3);
  21806. }
  21807. return this;
  21808. }
  21809. function endOf (units) {
  21810. units = normalizeUnits(units);
  21811. if (units === undefined || units === 'millisecond') {
  21812. return this;
  21813. }
  21814. return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
  21815. }
  21816. function to_type__valueOf () {
  21817. return +this._d - ((this._offset || 0) * 60000);
  21818. }
  21819. function unix () {
  21820. return Math.floor(+this / 1000);
  21821. }
  21822. function toDate () {
  21823. return this._offset ? new Date(+this) : this._d;
  21824. }
  21825. function toArray () {
  21826. var m = this;
  21827. return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
  21828. }
  21829. function toObject () {
  21830. var m = this;
  21831. return {
  21832. years: m.year(),
  21833. months: m.month(),
  21834. date: m.date(),
  21835. hours: m.hours(),
  21836. minutes: m.minutes(),
  21837. seconds: m.seconds(),
  21838. milliseconds: m.milliseconds()
  21839. };
  21840. }
  21841. function moment_valid__isValid () {
  21842. return valid__isValid(this);
  21843. }
  21844. function parsingFlags () {
  21845. return extend({}, getParsingFlags(this));
  21846. }
  21847. function invalidAt () {
  21848. return getParsingFlags(this).overflow;
  21849. }
  21850. addFormatToken(0, ['gg', 2], 0, function () {
  21851. return this.weekYear() % 100;
  21852. });
  21853. addFormatToken(0, ['GG', 2], 0, function () {
  21854. return this.isoWeekYear() % 100;
  21855. });
  21856. function addWeekYearFormatToken (token, getter) {
  21857. addFormatToken(0, [token, token.length], 0, getter);
  21858. }
  21859. addWeekYearFormatToken('gggg', 'weekYear');
  21860. addWeekYearFormatToken('ggggg', 'weekYear');
  21861. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  21862. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  21863. // ALIASES
  21864. addUnitAlias('weekYear', 'gg');
  21865. addUnitAlias('isoWeekYear', 'GG');
  21866. // PARSING
  21867. addRegexToken('G', matchSigned);
  21868. addRegexToken('g', matchSigned);
  21869. addRegexToken('GG', match1to2, match2);
  21870. addRegexToken('gg', match1to2, match2);
  21871. addRegexToken('GGGG', match1to4, match4);
  21872. addRegexToken('gggg', match1to4, match4);
  21873. addRegexToken('GGGGG', match1to6, match6);
  21874. addRegexToken('ggggg', match1to6, match6);
  21875. addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
  21876. week[token.substr(0, 2)] = toInt(input);
  21877. });
  21878. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  21879. week[token] = utils_hooks__hooks.parseTwoDigitYear(input);
  21880. });
  21881. // HELPERS
  21882. function weeksInYear(year, dow, doy) {
  21883. return weekOfYear(local__createLocal([year, 11, 31 + dow - doy]), dow, doy).week;
  21884. }
  21885. // MOMENTS
  21886. function getSetWeekYear (input) {
  21887. var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
  21888. return input == null ? year : this.add((input - year), 'y');
  21889. }
  21890. function getSetISOWeekYear (input) {
  21891. var year = weekOfYear(this, 1, 4).year;
  21892. return input == null ? year : this.add((input - year), 'y');
  21893. }
  21894. function getISOWeeksInYear () {
  21895. return weeksInYear(this.year(), 1, 4);
  21896. }
  21897. function getWeeksInYear () {
  21898. var weekInfo = this.localeData()._week;
  21899. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  21900. }
  21901. addFormatToken('Q', 0, 0, 'quarter');
  21902. // ALIASES
  21903. addUnitAlias('quarter', 'Q');
  21904. // PARSING
  21905. addRegexToken('Q', match1);
  21906. addParseToken('Q', function (input, array) {
  21907. array[MONTH] = (toInt(input) - 1) * 3;
  21908. });
  21909. // MOMENTS
  21910. function getSetQuarter (input) {
  21911. return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
  21912. }
  21913. addFormatToken('D', ['DD', 2], 'Do', 'date');
  21914. // ALIASES
  21915. addUnitAlias('date', 'D');
  21916. // PARSING
  21917. addRegexToken('D', match1to2);
  21918. addRegexToken('DD', match1to2, match2);
  21919. addRegexToken('Do', function (isStrict, locale) {
  21920. return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
  21921. });
  21922. addParseToken(['D', 'DD'], DATE);
  21923. addParseToken('Do', function (input, array) {
  21924. array[DATE] = toInt(input.match(match1to2)[0], 10);
  21925. });
  21926. // MOMENTS
  21927. var getSetDayOfMonth = makeGetSet('Date', true);
  21928. addFormatToken('d', 0, 'do', 'day');
  21929. addFormatToken('dd', 0, 0, function (format) {
  21930. return this.localeData().weekdaysMin(this, format);
  21931. });
  21932. addFormatToken('ddd', 0, 0, function (format) {
  21933. return this.localeData().weekdaysShort(this, format);
  21934. });
  21935. addFormatToken('dddd', 0, 0, function (format) {
  21936. return this.localeData().weekdays(this, format);
  21937. });
  21938. addFormatToken('e', 0, 0, 'weekday');
  21939. addFormatToken('E', 0, 0, 'isoWeekday');
  21940. // ALIASES
  21941. addUnitAlias('day', 'd');
  21942. addUnitAlias('weekday', 'e');
  21943. addUnitAlias('isoWeekday', 'E');
  21944. // PARSING
  21945. addRegexToken('d', match1to2);
  21946. addRegexToken('e', match1to2);
  21947. addRegexToken('E', match1to2);
  21948. addRegexToken('dd', matchWord);
  21949. addRegexToken('ddd', matchWord);
  21950. addRegexToken('dddd', matchWord);
  21951. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config) {
  21952. var weekday = config._locale.weekdaysParse(input);
  21953. // if we didn't get a weekday name, mark the date as invalid
  21954. if (weekday != null) {
  21955. week.d = weekday;
  21956. } else {
  21957. getParsingFlags(config).invalidWeekday = input;
  21958. }
  21959. });
  21960. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  21961. week[token] = toInt(input);
  21962. });
  21963. // HELPERS
  21964. function parseWeekday(input, locale) {
  21965. if (typeof input !== 'string') {
  21966. return input;
  21967. }
  21968. if (!isNaN(input)) {
  21969. return parseInt(input, 10);
  21970. }
  21971. input = locale.weekdaysParse(input);
  21972. if (typeof input === 'number') {
  21973. return input;
  21974. }
  21975. return null;
  21976. }
  21977. // LOCALES
  21978. var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
  21979. function localeWeekdays (m) {
  21980. return this._weekdays[m.day()];
  21981. }
  21982. var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
  21983. function localeWeekdaysShort (m) {
  21984. return this._weekdaysShort[m.day()];
  21985. }
  21986. var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
  21987. function localeWeekdaysMin (m) {
  21988. return this._weekdaysMin[m.day()];
  21989. }
  21990. function localeWeekdaysParse (weekdayName) {
  21991. var i, mom, regex;
  21992. this._weekdaysParse = this._weekdaysParse || [];
  21993. for (i = 0; i < 7; i++) {
  21994. // make the regex if we don't have it already
  21995. if (!this._weekdaysParse[i]) {
  21996. mom = local__createLocal([2000, 1]).day(i);
  21997. regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
  21998. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  21999. }
  22000. // test the regex
  22001. if (this._weekdaysParse[i].test(weekdayName)) {
  22002. return i;
  22003. }
  22004. }
  22005. }
  22006. // MOMENTS
  22007. function getSetDayOfWeek (input) {
  22008. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  22009. if (input != null) {
  22010. input = parseWeekday(input, this.localeData());
  22011. return this.add(input - day, 'd');
  22012. } else {
  22013. return day;
  22014. }
  22015. }
  22016. function getSetLocaleDayOfWeek (input) {
  22017. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  22018. return input == null ? weekday : this.add(input - weekday, 'd');
  22019. }
  22020. function getSetISODayOfWeek (input) {
  22021. // behaves the same as moment#day except
  22022. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  22023. // as a setter, sunday should belong to the previous week.
  22024. return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
  22025. }
  22026. addFormatToken('H', ['HH', 2], 0, 'hour');
  22027. addFormatToken('h', ['hh', 2], 0, function () {
  22028. return this.hours() % 12 || 12;
  22029. });
  22030. function meridiem (token, lowercase) {
  22031. addFormatToken(token, 0, 0, function () {
  22032. return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
  22033. });
  22034. }
  22035. meridiem('a', true);
  22036. meridiem('A', false);
  22037. // ALIASES
  22038. addUnitAlias('hour', 'h');
  22039. // PARSING
  22040. function matchMeridiem (isStrict, locale) {
  22041. return locale._meridiemParse;
  22042. }
  22043. addRegexToken('a', matchMeridiem);
  22044. addRegexToken('A', matchMeridiem);
  22045. addRegexToken('H', match1to2);
  22046. addRegexToken('h', match1to2);
  22047. addRegexToken('HH', match1to2, match2);
  22048. addRegexToken('hh', match1to2, match2);
  22049. addParseToken(['H', 'HH'], HOUR);
  22050. addParseToken(['a', 'A'], function (input, array, config) {
  22051. config._isPm = config._locale.isPM(input);
  22052. config._meridiem = input;
  22053. });
  22054. addParseToken(['h', 'hh'], function (input, array, config) {
  22055. array[HOUR] = toInt(input);
  22056. getParsingFlags(config).bigHour = true;
  22057. });
  22058. // LOCALES
  22059. function localeIsPM (input) {
  22060. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  22061. // Using charAt should be more compatible.
  22062. return ((input + '').toLowerCase().charAt(0) === 'p');
  22063. }
  22064. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
  22065. function localeMeridiem (hours, minutes, isLower) {
  22066. if (hours > 11) {
  22067. return isLower ? 'pm' : 'PM';
  22068. } else {
  22069. return isLower ? 'am' : 'AM';
  22070. }
  22071. }
  22072. // MOMENTS
  22073. // Setting the hour should keep the time, because the user explicitly
  22074. // specified which hour he wants. So trying to maintain the same hour (in
  22075. // a new timezone) makes sense. Adding/subtracting hours does not follow
  22076. // this rule.
  22077. var getSetHour = makeGetSet('Hours', true);
  22078. addFormatToken('m', ['mm', 2], 0, 'minute');
  22079. // ALIASES
  22080. addUnitAlias('minute', 'm');
  22081. // PARSING
  22082. addRegexToken('m', match1to2);
  22083. addRegexToken('mm', match1to2, match2);
  22084. addParseToken(['m', 'mm'], MINUTE);
  22085. // MOMENTS
  22086. var getSetMinute = makeGetSet('Minutes', false);
  22087. addFormatToken('s', ['ss', 2], 0, 'second');
  22088. // ALIASES
  22089. addUnitAlias('second', 's');
  22090. // PARSING
  22091. addRegexToken('s', match1to2);
  22092. addRegexToken('ss', match1to2, match2);
  22093. addParseToken(['s', 'ss'], SECOND);
  22094. // MOMENTS
  22095. var getSetSecond = makeGetSet('Seconds', false);
  22096. addFormatToken('S', 0, 0, function () {
  22097. return ~~(this.millisecond() / 100);
  22098. });
  22099. addFormatToken(0, ['SS', 2], 0, function () {
  22100. return ~~(this.millisecond() / 10);
  22101. });
  22102. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  22103. addFormatToken(0, ['SSSS', 4], 0, function () {
  22104. return this.millisecond() * 10;
  22105. });
  22106. addFormatToken(0, ['SSSSS', 5], 0, function () {
  22107. return this.millisecond() * 100;
  22108. });
  22109. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  22110. return this.millisecond() * 1000;
  22111. });
  22112. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  22113. return this.millisecond() * 10000;
  22114. });
  22115. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  22116. return this.millisecond() * 100000;
  22117. });
  22118. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  22119. return this.millisecond() * 1000000;
  22120. });
  22121. // ALIASES
  22122. addUnitAlias('millisecond', 'ms');
  22123. // PARSING
  22124. addRegexToken('S', match1to3, match1);
  22125. addRegexToken('SS', match1to3, match2);
  22126. addRegexToken('SSS', match1to3, match3);
  22127. var token;
  22128. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  22129. addRegexToken(token, matchUnsigned);
  22130. }
  22131. function parseMs(input, array) {
  22132. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  22133. }
  22134. for (token = 'S'; token.length <= 9; token += 'S') {
  22135. addParseToken(token, parseMs);
  22136. }
  22137. // MOMENTS
  22138. var getSetMillisecond = makeGetSet('Milliseconds', false);
  22139. addFormatToken('z', 0, 0, 'zoneAbbr');
  22140. addFormatToken('zz', 0, 0, 'zoneName');
  22141. // MOMENTS
  22142. function getZoneAbbr () {
  22143. return this._isUTC ? 'UTC' : '';
  22144. }
  22145. function getZoneName () {
  22146. return this._isUTC ? 'Coordinated Universal Time' : '';
  22147. }
  22148. var momentPrototype__proto = Moment.prototype;
  22149. momentPrototype__proto.add = add_subtract__add;
  22150. momentPrototype__proto.calendar = moment_calendar__calendar;
  22151. momentPrototype__proto.clone = clone;
  22152. momentPrototype__proto.diff = diff;
  22153. momentPrototype__proto.endOf = endOf;
  22154. momentPrototype__proto.format = format;
  22155. momentPrototype__proto.from = from;
  22156. momentPrototype__proto.fromNow = fromNow;
  22157. momentPrototype__proto.to = to;
  22158. momentPrototype__proto.toNow = toNow;
  22159. momentPrototype__proto.get = getSet;
  22160. momentPrototype__proto.invalidAt = invalidAt;
  22161. momentPrototype__proto.isAfter = isAfter;
  22162. momentPrototype__proto.isBefore = isBefore;
  22163. momentPrototype__proto.isBetween = isBetween;
  22164. momentPrototype__proto.isSame = isSame;
  22165. momentPrototype__proto.isValid = moment_valid__isValid;
  22166. momentPrototype__proto.lang = lang;
  22167. momentPrototype__proto.locale = locale;
  22168. momentPrototype__proto.localeData = localeData;
  22169. momentPrototype__proto.max = prototypeMax;
  22170. momentPrototype__proto.min = prototypeMin;
  22171. momentPrototype__proto.parsingFlags = parsingFlags;
  22172. momentPrototype__proto.set = getSet;
  22173. momentPrototype__proto.startOf = startOf;
  22174. momentPrototype__proto.subtract = add_subtract__subtract;
  22175. momentPrototype__proto.toArray = toArray;
  22176. momentPrototype__proto.toObject = toObject;
  22177. momentPrototype__proto.toDate = toDate;
  22178. momentPrototype__proto.toISOString = moment_format__toISOString;
  22179. momentPrototype__proto.toJSON = moment_format__toISOString;
  22180. momentPrototype__proto.toString = toString;
  22181. momentPrototype__proto.unix = unix;
  22182. momentPrototype__proto.valueOf = to_type__valueOf;
  22183. // Year
  22184. momentPrototype__proto.year = getSetYear;
  22185. momentPrototype__proto.isLeapYear = getIsLeapYear;
  22186. // Week Year
  22187. momentPrototype__proto.weekYear = getSetWeekYear;
  22188. momentPrototype__proto.isoWeekYear = getSetISOWeekYear;
  22189. // Quarter
  22190. momentPrototype__proto.quarter = momentPrototype__proto.quarters = getSetQuarter;
  22191. // Month
  22192. momentPrototype__proto.month = getSetMonth;
  22193. momentPrototype__proto.daysInMonth = getDaysInMonth;
  22194. // Week
  22195. momentPrototype__proto.week = momentPrototype__proto.weeks = getSetWeek;
  22196. momentPrototype__proto.isoWeek = momentPrototype__proto.isoWeeks = getSetISOWeek;
  22197. momentPrototype__proto.weeksInYear = getWeeksInYear;
  22198. momentPrototype__proto.isoWeeksInYear = getISOWeeksInYear;
  22199. // Day
  22200. momentPrototype__proto.date = getSetDayOfMonth;
  22201. momentPrototype__proto.day = momentPrototype__proto.days = getSetDayOfWeek;
  22202. momentPrototype__proto.weekday = getSetLocaleDayOfWeek;
  22203. momentPrototype__proto.isoWeekday = getSetISODayOfWeek;
  22204. momentPrototype__proto.dayOfYear = getSetDayOfYear;
  22205. // Hour
  22206. momentPrototype__proto.hour = momentPrototype__proto.hours = getSetHour;
  22207. // Minute
  22208. momentPrototype__proto.minute = momentPrototype__proto.minutes = getSetMinute;
  22209. // Second
  22210. momentPrototype__proto.second = momentPrototype__proto.seconds = getSetSecond;
  22211. // Millisecond
  22212. momentPrototype__proto.millisecond = momentPrototype__proto.milliseconds = getSetMillisecond;
  22213. // Offset
  22214. momentPrototype__proto.utcOffset = getSetOffset;
  22215. momentPrototype__proto.utc = setOffsetToUTC;
  22216. momentPrototype__proto.local = setOffsetToLocal;
  22217. momentPrototype__proto.parseZone = setOffsetToParsedOffset;
  22218. momentPrototype__proto.hasAlignedHourOffset = hasAlignedHourOffset;
  22219. momentPrototype__proto.isDST = isDaylightSavingTime;
  22220. momentPrototype__proto.isDSTShifted = isDaylightSavingTimeShifted;
  22221. momentPrototype__proto.isLocal = isLocal;
  22222. momentPrototype__proto.isUtcOffset = isUtcOffset;
  22223. momentPrototype__proto.isUtc = isUtc;
  22224. momentPrototype__proto.isUTC = isUtc;
  22225. // Timezone
  22226. momentPrototype__proto.zoneAbbr = getZoneAbbr;
  22227. momentPrototype__proto.zoneName = getZoneName;
  22228. // Deprecations
  22229. momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
  22230. momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
  22231. momentPrototype__proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
  22232. momentPrototype__proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779', getSetZone);
  22233. var momentPrototype = momentPrototype__proto;
  22234. function moment__createUnix (input) {
  22235. return local__createLocal(input * 1000);
  22236. }
  22237. function moment__createInZone () {
  22238. return local__createLocal.apply(null, arguments).parseZone();
  22239. }
  22240. var defaultCalendar = {
  22241. sameDay : '[Today at] LT',
  22242. nextDay : '[Tomorrow at] LT',
  22243. nextWeek : 'dddd [at] LT',
  22244. lastDay : '[Yesterday at] LT',
  22245. lastWeek : '[Last] dddd [at] LT',
  22246. sameElse : 'L'
  22247. };
  22248. function locale_calendar__calendar (key, mom, now) {
  22249. var output = this._calendar[key];
  22250. return typeof output === 'function' ? output.call(mom, now) : output;
  22251. }
  22252. var defaultLongDateFormat = {
  22253. LTS : 'h:mm:ss A',
  22254. LT : 'h:mm A',
  22255. L : 'MM/DD/YYYY',
  22256. LL : 'MMMM D, YYYY',
  22257. LLL : 'MMMM D, YYYY h:mm A',
  22258. LLLL : 'dddd, MMMM D, YYYY h:mm A'
  22259. };
  22260. function longDateFormat (key) {
  22261. var format = this._longDateFormat[key],
  22262. formatUpper = this._longDateFormat[key.toUpperCase()];
  22263. if (format || !formatUpper) {
  22264. return format;
  22265. }
  22266. this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
  22267. return val.slice(1);
  22268. });
  22269. return this._longDateFormat[key];
  22270. }
  22271. var defaultInvalidDate = 'Invalid date';
  22272. function invalidDate () {
  22273. return this._invalidDate;
  22274. }
  22275. var defaultOrdinal = '%d';
  22276. var defaultOrdinalParse = /\d{1,2}/;
  22277. function ordinal (number) {
  22278. return this._ordinal.replace('%d', number);
  22279. }
  22280. function preParsePostFormat (string) {
  22281. return string;
  22282. }
  22283. var defaultRelativeTime = {
  22284. future : 'in %s',
  22285. past : '%s ago',
  22286. s : 'a few seconds',
  22287. m : 'a minute',
  22288. mm : '%d minutes',
  22289. h : 'an hour',
  22290. hh : '%d hours',
  22291. d : 'a day',
  22292. dd : '%d days',
  22293. M : 'a month',
  22294. MM : '%d months',
  22295. y : 'a year',
  22296. yy : '%d years'
  22297. };
  22298. function relative__relativeTime (number, withoutSuffix, string, isFuture) {
  22299. var output = this._relativeTime[string];
  22300. return (typeof output === 'function') ?
  22301. output(number, withoutSuffix, string, isFuture) :
  22302. output.replace(/%d/i, number);
  22303. }
  22304. function pastFuture (diff, output) {
  22305. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  22306. return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
  22307. }
  22308. function locale_set__set (config) {
  22309. var prop, i;
  22310. for (i in config) {
  22311. prop = config[i];
  22312. if (typeof prop === 'function') {
  22313. this[i] = prop;
  22314. } else {
  22315. this['_' + i] = prop;
  22316. }
  22317. }
  22318. // Lenient ordinal parsing accepts just a number in addition to
  22319. // number + (possibly) stuff coming from _ordinalParseLenient.
  22320. this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
  22321. }
  22322. var prototype__proto = Locale.prototype;
  22323. prototype__proto._calendar = defaultCalendar;
  22324. prototype__proto.calendar = locale_calendar__calendar;
  22325. prototype__proto._longDateFormat = defaultLongDateFormat;
  22326. prototype__proto.longDateFormat = longDateFormat;
  22327. prototype__proto._invalidDate = defaultInvalidDate;
  22328. prototype__proto.invalidDate = invalidDate;
  22329. prototype__proto._ordinal = defaultOrdinal;
  22330. prototype__proto.ordinal = ordinal;
  22331. prototype__proto._ordinalParse = defaultOrdinalParse;
  22332. prototype__proto.preparse = preParsePostFormat;
  22333. prototype__proto.postformat = preParsePostFormat;
  22334. prototype__proto._relativeTime = defaultRelativeTime;
  22335. prototype__proto.relativeTime = relative__relativeTime;
  22336. prototype__proto.pastFuture = pastFuture;
  22337. prototype__proto.set = locale_set__set;
  22338. // Month
  22339. prototype__proto.months = localeMonths;
  22340. prototype__proto._months = defaultLocaleMonths;
  22341. prototype__proto.monthsShort = localeMonthsShort;
  22342. prototype__proto._monthsShort = defaultLocaleMonthsShort;
  22343. prototype__proto.monthsParse = localeMonthsParse;
  22344. // Week
  22345. prototype__proto.week = localeWeek;
  22346. prototype__proto._week = defaultLocaleWeek;
  22347. prototype__proto.firstDayOfYear = localeFirstDayOfYear;
  22348. prototype__proto.firstDayOfWeek = localeFirstDayOfWeek;
  22349. // Day of Week
  22350. prototype__proto.weekdays = localeWeekdays;
  22351. prototype__proto._weekdays = defaultLocaleWeekdays;
  22352. prototype__proto.weekdaysMin = localeWeekdaysMin;
  22353. prototype__proto._weekdaysMin = defaultLocaleWeekdaysMin;
  22354. prototype__proto.weekdaysShort = localeWeekdaysShort;
  22355. prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
  22356. prototype__proto.weekdaysParse = localeWeekdaysParse;
  22357. // Hours
  22358. prototype__proto.isPM = localeIsPM;
  22359. prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
  22360. prototype__proto.meridiem = localeMeridiem;
  22361. function lists__get (format, index, field, setter) {
  22362. var locale = locale_locales__getLocale();
  22363. var utc = create_utc__createUTC().set(setter, index);
  22364. return locale[field](utc, format);
  22365. }
  22366. function list (format, index, field, count, setter) {
  22367. if (typeof format === 'number') {
  22368. index = format;
  22369. format = undefined;
  22370. }
  22371. format = format || '';
  22372. if (index != null) {
  22373. return lists__get(format, index, field, setter);
  22374. }
  22375. var i;
  22376. var out = [];
  22377. for (i = 0; i < count; i++) {
  22378. out[i] = lists__get(format, i, field, setter);
  22379. }
  22380. return out;
  22381. }
  22382. function lists__listMonths (format, index) {
  22383. return list(format, index, 'months', 12, 'month');
  22384. }
  22385. function lists__listMonthsShort (format, index) {
  22386. return list(format, index, 'monthsShort', 12, 'month');
  22387. }
  22388. function lists__listWeekdays (format, index) {
  22389. return list(format, index, 'weekdays', 7, 'day');
  22390. }
  22391. function lists__listWeekdaysShort (format, index) {
  22392. return list(format, index, 'weekdaysShort', 7, 'day');
  22393. }
  22394. function lists__listWeekdaysMin (format, index) {
  22395. return list(format, index, 'weekdaysMin', 7, 'day');
  22396. }
  22397. locale_locales__getSetGlobalLocale('en', {
  22398. ordinalParse: /\d{1,2}(th|st|nd|rd)/,
  22399. ordinal : function (number) {
  22400. var b = number % 10,
  22401. output = (toInt(number % 100 / 10) === 1) ? 'th' :
  22402. (b === 1) ? 'st' :
  22403. (b === 2) ? 'nd' :
  22404. (b === 3) ? 'rd' : 'th';
  22405. return number + output;
  22406. }
  22407. });
  22408. // Side effect imports
  22409. utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale);
  22410. utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale);
  22411. var mathAbs = Math.abs;
  22412. function duration_abs__abs () {
  22413. var data = this._data;
  22414. this._milliseconds = mathAbs(this._milliseconds);
  22415. this._days = mathAbs(this._days);
  22416. this._months = mathAbs(this._months);
  22417. data.milliseconds = mathAbs(data.milliseconds);
  22418. data.seconds = mathAbs(data.seconds);
  22419. data.minutes = mathAbs(data.minutes);
  22420. data.hours = mathAbs(data.hours);
  22421. data.months = mathAbs(data.months);
  22422. data.years = mathAbs(data.years);
  22423. return this;
  22424. }
  22425. function duration_add_subtract__addSubtract (duration, input, value, direction) {
  22426. var other = create__createDuration(input, value);
  22427. duration._milliseconds += direction * other._milliseconds;
  22428. duration._days += direction * other._days;
  22429. duration._months += direction * other._months;
  22430. return duration._bubble();
  22431. }
  22432. // supports only 2.0-style add(1, 's') or add(duration)
  22433. function duration_add_subtract__add (input, value) {
  22434. return duration_add_subtract__addSubtract(this, input, value, 1);
  22435. }
  22436. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  22437. function duration_add_subtract__subtract (input, value) {
  22438. return duration_add_subtract__addSubtract(this, input, value, -1);
  22439. }
  22440. function absCeil (number) {
  22441. if (number < 0) {
  22442. return Math.floor(number);
  22443. } else {
  22444. return Math.ceil(number);
  22445. }
  22446. }
  22447. function bubble () {
  22448. var milliseconds = this._milliseconds;
  22449. var days = this._days;
  22450. var months = this._months;
  22451. var data = this._data;
  22452. var seconds, minutes, hours, years, monthsFromDays;
  22453. // if we have a mix of positive and negative values, bubble down first
  22454. // check: https://github.com/moment/moment/issues/2166
  22455. if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
  22456. (milliseconds <= 0 && days <= 0 && months <= 0))) {
  22457. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  22458. days = 0;
  22459. months = 0;
  22460. }
  22461. // The following code bubbles up values, see the tests for
  22462. // examples of what that means.
  22463. data.milliseconds = milliseconds % 1000;
  22464. seconds = absFloor(milliseconds / 1000);
  22465. data.seconds = seconds % 60;
  22466. minutes = absFloor(seconds / 60);
  22467. data.minutes = minutes % 60;
  22468. hours = absFloor(minutes / 60);
  22469. data.hours = hours % 24;
  22470. days += absFloor(hours / 24);
  22471. // convert days to months
  22472. monthsFromDays = absFloor(daysToMonths(days));
  22473. months += monthsFromDays;
  22474. days -= absCeil(monthsToDays(monthsFromDays));
  22475. // 12 months -> 1 year
  22476. years = absFloor(months / 12);
  22477. months %= 12;
  22478. data.days = days;
  22479. data.months = months;
  22480. data.years = years;
  22481. return this;
  22482. }
  22483. function daysToMonths (days) {
  22484. // 400 years have 146097 days (taking into account leap year rules)
  22485. // 400 years have 12 months === 4800
  22486. return days * 4800 / 146097;
  22487. }
  22488. function monthsToDays (months) {
  22489. // the reverse of daysToMonths
  22490. return months * 146097 / 4800;
  22491. }
  22492. function as (units) {
  22493. var days;
  22494. var months;
  22495. var milliseconds = this._milliseconds;
  22496. units = normalizeUnits(units);
  22497. if (units === 'month' || units === 'year') {
  22498. days = this._days + milliseconds / 864e5;
  22499. months = this._months + daysToMonths(days);
  22500. return units === 'month' ? months : months / 12;
  22501. } else {
  22502. // handle milliseconds separately because of floating point math errors (issue #1867)
  22503. days = this._days + Math.round(monthsToDays(this._months));
  22504. switch (units) {
  22505. case 'week' : return days / 7 + milliseconds / 6048e5;
  22506. case 'day' : return days + milliseconds / 864e5;
  22507. case 'hour' : return days * 24 + milliseconds / 36e5;
  22508. case 'minute' : return days * 1440 + milliseconds / 6e4;
  22509. case 'second' : return days * 86400 + milliseconds / 1000;
  22510. // Math.floor prevents floating point math errors here
  22511. case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
  22512. default: throw new Error('Unknown unit ' + units);
  22513. }
  22514. }
  22515. }
  22516. // TODO: Use this.as('ms')?
  22517. function duration_as__valueOf () {
  22518. return (
  22519. this._milliseconds +
  22520. this._days * 864e5 +
  22521. (this._months % 12) * 2592e6 +
  22522. toInt(this._months / 12) * 31536e6
  22523. );
  22524. }
  22525. function makeAs (alias) {
  22526. return function () {
  22527. return this.as(alias);
  22528. };
  22529. }
  22530. var asMilliseconds = makeAs('ms');
  22531. var asSeconds = makeAs('s');
  22532. var asMinutes = makeAs('m');
  22533. var asHours = makeAs('h');
  22534. var asDays = makeAs('d');
  22535. var asWeeks = makeAs('w');
  22536. var asMonths = makeAs('M');
  22537. var asYears = makeAs('y');
  22538. function duration_get__get (units) {
  22539. units = normalizeUnits(units);
  22540. return this[units + 's']();
  22541. }
  22542. function makeGetter(name) {
  22543. return function () {
  22544. return this._data[name];
  22545. };
  22546. }
  22547. var milliseconds = makeGetter('milliseconds');
  22548. var seconds = makeGetter('seconds');
  22549. var minutes = makeGetter('minutes');
  22550. var hours = makeGetter('hours');
  22551. var days = makeGetter('days');
  22552. var months = makeGetter('months');
  22553. var years = makeGetter('years');
  22554. function weeks () {
  22555. return absFloor(this.days() / 7);
  22556. }
  22557. var round = Math.round;
  22558. var thresholds = {
  22559. s: 45, // seconds to minute
  22560. m: 45, // minutes to hour
  22561. h: 22, // hours to day
  22562. d: 26, // days to month
  22563. M: 11 // months to year
  22564. };
  22565. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  22566. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  22567. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  22568. }
  22569. function duration_humanize__relativeTime (posNegDuration, withoutSuffix, locale) {
  22570. var duration = create__createDuration(posNegDuration).abs();
  22571. var seconds = round(duration.as('s'));
  22572. var minutes = round(duration.as('m'));
  22573. var hours = round(duration.as('h'));
  22574. var days = round(duration.as('d'));
  22575. var months = round(duration.as('M'));
  22576. var years = round(duration.as('y'));
  22577. var a = seconds < thresholds.s && ['s', seconds] ||
  22578. minutes === 1 && ['m'] ||
  22579. minutes < thresholds.m && ['mm', minutes] ||
  22580. hours === 1 && ['h'] ||
  22581. hours < thresholds.h && ['hh', hours] ||
  22582. days === 1 && ['d'] ||
  22583. days < thresholds.d && ['dd', days] ||
  22584. months === 1 && ['M'] ||
  22585. months < thresholds.M && ['MM', months] ||
  22586. years === 1 && ['y'] || ['yy', years];
  22587. a[2] = withoutSuffix;
  22588. a[3] = +posNegDuration > 0;
  22589. a[4] = locale;
  22590. return substituteTimeAgo.apply(null, a);
  22591. }
  22592. // This function allows you to set a threshold for relative time strings
  22593. function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {
  22594. if (thresholds[threshold] === undefined) {
  22595. return false;
  22596. }
  22597. if (limit === undefined) {
  22598. return thresholds[threshold];
  22599. }
  22600. thresholds[threshold] = limit;
  22601. return true;
  22602. }
  22603. function humanize (withSuffix) {
  22604. var locale = this.localeData();
  22605. var output = duration_humanize__relativeTime(this, !withSuffix, locale);
  22606. if (withSuffix) {
  22607. output = locale.pastFuture(+this, output);
  22608. }
  22609. return locale.postformat(output);
  22610. }
  22611. var iso_string__abs = Math.abs;
  22612. function iso_string__toISOString() {
  22613. // for ISO strings we do not use the normal bubbling rules:
  22614. // * milliseconds bubble up until they become hours
  22615. // * days do not bubble at all
  22616. // * months bubble up until they become years
  22617. // This is because there is no context-free conversion between hours and days
  22618. // (think of clock changes)
  22619. // and also not between days and months (28-31 days per month)
  22620. var seconds = iso_string__abs(this._milliseconds) / 1000;
  22621. var days = iso_string__abs(this._days);
  22622. var months = iso_string__abs(this._months);
  22623. var minutes, hours, years;
  22624. // 3600 seconds -> 60 minutes -> 1 hour
  22625. minutes = absFloor(seconds / 60);
  22626. hours = absFloor(minutes / 60);
  22627. seconds %= 60;
  22628. minutes %= 60;
  22629. // 12 months -> 1 year
  22630. years = absFloor(months / 12);
  22631. months %= 12;
  22632. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  22633. var Y = years;
  22634. var M = months;
  22635. var D = days;
  22636. var h = hours;
  22637. var m = minutes;
  22638. var s = seconds;
  22639. var total = this.asSeconds();
  22640. if (!total) {
  22641. // this is the same as C#'s (Noda) and python (isodate)...
  22642. // but not other JS (goog.date)
  22643. return 'P0D';
  22644. }
  22645. return (total < 0 ? '-' : '') +
  22646. 'P' +
  22647. (Y ? Y + 'Y' : '') +
  22648. (M ? M + 'M' : '') +
  22649. (D ? D + 'D' : '') +
  22650. ((h || m || s) ? 'T' : '') +
  22651. (h ? h + 'H' : '') +
  22652. (m ? m + 'M' : '') +
  22653. (s ? s + 'S' : '');
  22654. }
  22655. var duration_prototype__proto = Duration.prototype;
  22656. duration_prototype__proto.abs = duration_abs__abs;
  22657. duration_prototype__proto.add = duration_add_subtract__add;
  22658. duration_prototype__proto.subtract = duration_add_subtract__subtract;
  22659. duration_prototype__proto.as = as;
  22660. duration_prototype__proto.asMilliseconds = asMilliseconds;
  22661. duration_prototype__proto.asSeconds = asSeconds;
  22662. duration_prototype__proto.asMinutes = asMinutes;
  22663. duration_prototype__proto.asHours = asHours;
  22664. duration_prototype__proto.asDays = asDays;
  22665. duration_prototype__proto.asWeeks = asWeeks;
  22666. duration_prototype__proto.asMonths = asMonths;
  22667. duration_prototype__proto.asYears = asYears;
  22668. duration_prototype__proto.valueOf = duration_as__valueOf;
  22669. duration_prototype__proto._bubble = bubble;
  22670. duration_prototype__proto.get = duration_get__get;
  22671. duration_prototype__proto.milliseconds = milliseconds;
  22672. duration_prototype__proto.seconds = seconds;
  22673. duration_prototype__proto.minutes = minutes;
  22674. duration_prototype__proto.hours = hours;
  22675. duration_prototype__proto.days = days;
  22676. duration_prototype__proto.weeks = weeks;
  22677. duration_prototype__proto.months = months;
  22678. duration_prototype__proto.years = years;
  22679. duration_prototype__proto.humanize = humanize;
  22680. duration_prototype__proto.toISOString = iso_string__toISOString;
  22681. duration_prototype__proto.toString = iso_string__toISOString;
  22682. duration_prototype__proto.toJSON = iso_string__toISOString;
  22683. duration_prototype__proto.locale = locale;
  22684. duration_prototype__proto.localeData = localeData;
  22685. // Deprecations
  22686. duration_prototype__proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', iso_string__toISOString);
  22687. duration_prototype__proto.lang = lang;
  22688. // Side effect imports
  22689. addFormatToken('X', 0, 0, 'unix');
  22690. addFormatToken('x', 0, 0, 'valueOf');
  22691. // PARSING
  22692. addRegexToken('x', matchSigned);
  22693. addRegexToken('X', matchTimestamp);
  22694. addParseToken('X', function (input, array, config) {
  22695. config._d = new Date(parseFloat(input, 10) * 1000);
  22696. });
  22697. addParseToken('x', function (input, array, config) {
  22698. config._d = new Date(toInt(input));
  22699. });
  22700. // Side effect imports
  22701. utils_hooks__hooks.version = '2.10.6';
  22702. setHookCallback(local__createLocal);
  22703. utils_hooks__hooks.fn = momentPrototype;
  22704. utils_hooks__hooks.min = min;
  22705. utils_hooks__hooks.max = max;
  22706. utils_hooks__hooks.utc = create_utc__createUTC;
  22707. utils_hooks__hooks.unix = moment__createUnix;
  22708. utils_hooks__hooks.months = lists__listMonths;
  22709. utils_hooks__hooks.isDate = isDate;
  22710. utils_hooks__hooks.locale = locale_locales__getSetGlobalLocale;
  22711. utils_hooks__hooks.invalid = valid__createInvalid;
  22712. utils_hooks__hooks.duration = create__createDuration;
  22713. utils_hooks__hooks.isMoment = isMoment;
  22714. utils_hooks__hooks.weekdays = lists__listWeekdays;
  22715. utils_hooks__hooks.parseZone = moment__createInZone;
  22716. utils_hooks__hooks.localeData = locale_locales__getLocale;
  22717. utils_hooks__hooks.isDuration = isDuration;
  22718. utils_hooks__hooks.monthsShort = lists__listMonthsShort;
  22719. utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
  22720. utils_hooks__hooks.defineLocale = defineLocale;
  22721. utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
  22722. utils_hooks__hooks.normalizeUnits = normalizeUnits;
  22723. utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
  22724. var _moment = utils_hooks__hooks;
  22725. return _moment;
  22726. }));
  22727. },{}],"numeral":[function(require,module,exports){
  22728. "use strict";
  22729. (function() {
  22730. var numeral,
  22731. VERSION = '1.5.3',
  22732. languages = {},
  22733. currentLanguage = 'en',
  22734. zeroFormat = null,
  22735. defaultFormat = '0,0',
  22736. hasModule = (typeof module !== 'undefined' && module.exports);
  22737. function Numeral(number) {
  22738. this._value = number;
  22739. }
  22740. function toFixed(value, precision, roundingFunction, optionals) {
  22741. var power = Math.pow(10, precision),
  22742. optionalsRegExp,
  22743. output;
  22744. output = (roundingFunction(value * power) / power).toFixed(precision);
  22745. if (optionals) {
  22746. optionalsRegExp = new RegExp('0{1,' + optionals + '}$');
  22747. output = output.replace(optionalsRegExp, '');
  22748. }
  22749. return output;
  22750. }
  22751. function formatNumeral(n, format, roundingFunction) {
  22752. var output;
  22753. if (format.indexOf('$') > -1) {
  22754. output = formatCurrency(n, format, roundingFunction);
  22755. } else if (format.indexOf('%') > -1) {
  22756. output = formatPercentage(n, format, roundingFunction);
  22757. } else if (format.indexOf(':') > -1) {
  22758. output = formatTime(n, format);
  22759. } else {
  22760. output = formatNumber(n._value, format, roundingFunction);
  22761. }
  22762. return output;
  22763. }
  22764. function unformatNumeral(n, string) {
  22765. var stringOriginal = string,
  22766. thousandRegExp,
  22767. millionRegExp,
  22768. billionRegExp,
  22769. trillionRegExp,
  22770. suffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
  22771. bytesMultiplier = false,
  22772. power;
  22773. if (string.indexOf(':') > -1) {
  22774. n._value = unformatTime(string);
  22775. } else {
  22776. if (string === zeroFormat) {
  22777. n._value = 0;
  22778. } else {
  22779. if (languages[currentLanguage].delimiters.decimal !== '.') {
  22780. string = string.replace(/\./g, '').replace(languages[currentLanguage].delimiters.decimal, '.');
  22781. }
  22782. thousandRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.thousand + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
  22783. millionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.million + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
  22784. billionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.billion + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
  22785. trillionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
  22786. for (power = 0; power <= suffixes.length; power++) {
  22787. bytesMultiplier = (string.indexOf(suffixes[power]) > -1) ? Math.pow(1024, power + 1) : false;
  22788. if (bytesMultiplier) {
  22789. break;
  22790. }
  22791. }
  22792. n._value = ((bytesMultiplier) ? bytesMultiplier : 1) * ((stringOriginal.match(thousandRegExp)) ? Math.pow(10, 3) : 1) * ((stringOriginal.match(millionRegExp)) ? Math.pow(10, 6) : 1) * ((stringOriginal.match(billionRegExp)) ? Math.pow(10, 9) : 1) * ((stringOriginal.match(trillionRegExp)) ? Math.pow(10, 12) : 1) * ((string.indexOf('%') > -1) ? 0.01 : 1) * (((string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2) ? 1 : -1) * Number(string.replace(/[^0-9\.]+/g, ''));
  22793. n._value = (bytesMultiplier) ? Math.ceil(n._value) : n._value;
  22794. }
  22795. }
  22796. return n._value;
  22797. }
  22798. function formatCurrency(n, format, roundingFunction) {
  22799. var symbolIndex = format.indexOf('$'),
  22800. openParenIndex = format.indexOf('('),
  22801. minusSignIndex = format.indexOf('-'),
  22802. space = '',
  22803. spliceIndex,
  22804. output;
  22805. if (format.indexOf(' $') > -1) {
  22806. space = ' ';
  22807. format = format.replace(' $', '');
  22808. } else if (format.indexOf('$ ') > -1) {
  22809. space = ' ';
  22810. format = format.replace('$ ', '');
  22811. } else {
  22812. format = format.replace('$', '');
  22813. }
  22814. output = formatNumber(n._value, format, roundingFunction);
  22815. if (symbolIndex <= 1) {
  22816. if (output.indexOf('(') > -1 || output.indexOf('-') > -1) {
  22817. output = output.split('');
  22818. spliceIndex = 1;
  22819. if (symbolIndex < openParenIndex || symbolIndex < minusSignIndex) {
  22820. spliceIndex = 0;
  22821. }
  22822. output.splice(spliceIndex, 0, languages[currentLanguage].currency.symbol + space);
  22823. output = output.join('');
  22824. } else {
  22825. output = languages[currentLanguage].currency.symbol + space + output;
  22826. }
  22827. } else {
  22828. if (output.indexOf(')') > -1) {
  22829. output = output.split('');
  22830. output.splice(-1, 0, space + languages[currentLanguage].currency.symbol);
  22831. output = output.join('');
  22832. } else {
  22833. output = output + space + languages[currentLanguage].currency.symbol;
  22834. }
  22835. }
  22836. return output;
  22837. }
  22838. function formatPercentage(n, format, roundingFunction) {
  22839. var space = '',
  22840. output,
  22841. value = n._value * 100;
  22842. if (format.indexOf(' %') > -1) {
  22843. space = ' ';
  22844. format = format.replace(' %', '');
  22845. } else {
  22846. format = format.replace('%', '');
  22847. }
  22848. output = formatNumber(value, format, roundingFunction);
  22849. if (output.indexOf(')') > -1) {
  22850. output = output.split('');
  22851. output.splice(-1, 0, space + '%');
  22852. output = output.join('');
  22853. } else {
  22854. output = output + space + '%';
  22855. }
  22856. return output;
  22857. }
  22858. function formatTime(n) {
  22859. var hours = Math.floor(n._value / 60 / 60),
  22860. minutes = Math.floor((n._value - (hours * 60 * 60)) / 60),
  22861. seconds = Math.round(n._value - (hours * 60 * 60) - (minutes * 60));
  22862. return hours + ':' + ((minutes < 10) ? '0' + minutes : minutes) + ':' + ((seconds < 10) ? '0' + seconds : seconds);
  22863. }
  22864. function unformatTime(string) {
  22865. var timeArray = string.split(':'),
  22866. seconds = 0;
  22867. if (timeArray.length === 3) {
  22868. seconds = seconds + (Number(timeArray[0]) * 60 * 60);
  22869. seconds = seconds + (Number(timeArray[1]) * 60);
  22870. seconds = seconds + Number(timeArray[2]);
  22871. } else if (timeArray.length === 2) {
  22872. seconds = seconds + (Number(timeArray[0]) * 60);
  22873. seconds = seconds + Number(timeArray[1]);
  22874. }
  22875. return Number(seconds);
  22876. }
  22877. function formatNumber(value, format, roundingFunction) {
  22878. var negP = false,
  22879. signed = false,
  22880. optDec = false,
  22881. abbr = '',
  22882. abbrK = false,
  22883. abbrM = false,
  22884. abbrB = false,
  22885. abbrT = false,
  22886. abbrForce = false,
  22887. bytes = '',
  22888. ord = '',
  22889. abs = Math.abs(value),
  22890. suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
  22891. min,
  22892. max,
  22893. power,
  22894. w,
  22895. precision,
  22896. thousands,
  22897. d = '',
  22898. neg = false;
  22899. if (value === 0 && zeroFormat !== null) {
  22900. return zeroFormat;
  22901. } else {
  22902. if (format.indexOf('(') > -1) {
  22903. negP = true;
  22904. format = format.slice(1, -1);
  22905. } else if (format.indexOf('+') > -1) {
  22906. signed = true;
  22907. format = format.replace(/\+/g, '');
  22908. }
  22909. if (format.indexOf('a') > -1) {
  22910. abbrK = format.indexOf('aK') >= 0;
  22911. abbrM = format.indexOf('aM') >= 0;
  22912. abbrB = format.indexOf('aB') >= 0;
  22913. abbrT = format.indexOf('aT') >= 0;
  22914. abbrForce = abbrK || abbrM || abbrB || abbrT;
  22915. if (format.indexOf(' a') > -1) {
  22916. abbr = ' ';
  22917. format = format.replace(' a', '');
  22918. } else {
  22919. format = format.replace('a', '');
  22920. }
  22921. if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) {
  22922. abbr = abbr + languages[currentLanguage].abbreviations.trillion;
  22923. value = value / Math.pow(10, 12);
  22924. } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) {
  22925. abbr = abbr + languages[currentLanguage].abbreviations.billion;
  22926. value = value / Math.pow(10, 9);
  22927. } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) {
  22928. abbr = abbr + languages[currentLanguage].abbreviations.million;
  22929. value = value / Math.pow(10, 6);
  22930. } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) {
  22931. abbr = abbr + languages[currentLanguage].abbreviations.thousand;
  22932. value = value / Math.pow(10, 3);
  22933. }
  22934. }
  22935. if (format.indexOf('b') > -1) {
  22936. if (format.indexOf(' b') > -1) {
  22937. bytes = ' ';
  22938. format = format.replace(' b', '');
  22939. } else {
  22940. format = format.replace('b', '');
  22941. }
  22942. for (power = 0; power <= suffixes.length; power++) {
  22943. min = Math.pow(1024, power);
  22944. max = Math.pow(1024, power + 1);
  22945. if (value >= min && value < max) {
  22946. bytes = bytes + suffixes[power];
  22947. if (min > 0) {
  22948. value = value / min;
  22949. }
  22950. break;
  22951. }
  22952. }
  22953. }
  22954. if (format.indexOf('o') > -1) {
  22955. if (format.indexOf(' o') > -1) {
  22956. ord = ' ';
  22957. format = format.replace(' o', '');
  22958. } else {
  22959. format = format.replace('o', '');
  22960. }
  22961. ord = ord + languages[currentLanguage].ordinal(value);
  22962. }
  22963. if (format.indexOf('[.]') > -1) {
  22964. optDec = true;
  22965. format = format.replace('[.]', '.');
  22966. }
  22967. w = value.toString().split('.')[0];
  22968. precision = format.split('.')[1];
  22969. thousands = format.indexOf(',');
  22970. if (precision) {
  22971. if (precision.indexOf('[') > -1) {
  22972. precision = precision.replace(']', '');
  22973. precision = precision.split('[');
  22974. d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length);
  22975. } else {
  22976. d = toFixed(value, precision.length, roundingFunction);
  22977. }
  22978. w = d.split('.')[0];
  22979. if (d.split('.')[1].length) {
  22980. d = languages[currentLanguage].delimiters.decimal + d.split('.')[1];
  22981. } else {
  22982. d = '';
  22983. }
  22984. if (optDec && Number(d.slice(1)) === 0) {
  22985. d = '';
  22986. }
  22987. } else {
  22988. w = toFixed(value, null, roundingFunction);
  22989. }
  22990. if (w.indexOf('-') > -1) {
  22991. w = w.slice(1);
  22992. neg = true;
  22993. }
  22994. if (thousands > -1) {
  22995. w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + languages[currentLanguage].delimiters.thousands);
  22996. }
  22997. if (format.indexOf('.') === 0) {
  22998. w = '';
  22999. }
  23000. return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((ord) ? ord : '') + ((abbr) ? abbr : '') + ((bytes) ? bytes : '') + ((negP && neg) ? ')' : '');
  23001. }
  23002. }
  23003. numeral = function(input) {
  23004. if (numeral.isNumeral(input)) {
  23005. input = input.value();
  23006. } else if (input === 0 || typeof input === 'undefined') {
  23007. input = 0;
  23008. } else if (!Number(input)) {
  23009. input = numeral.fn.unformat(input);
  23010. }
  23011. return new Numeral(Number(input));
  23012. };
  23013. numeral.version = VERSION;
  23014. numeral.isNumeral = function(obj) {
  23015. return obj instanceof Numeral;
  23016. };
  23017. numeral.language = function(key, values) {
  23018. if (!key) {
  23019. return currentLanguage;
  23020. }
  23021. if (key && !values) {
  23022. if (!languages[key]) {
  23023. throw new Error('Unknown language : ' + key);
  23024. }
  23025. currentLanguage = key;
  23026. }
  23027. if (values || !languages[key]) {
  23028. loadLanguage(key, values);
  23029. }
  23030. return numeral;
  23031. };
  23032. numeral.languageData = function(key) {
  23033. if (!key) {
  23034. return languages[currentLanguage];
  23035. }
  23036. if (!languages[key]) {
  23037. throw new Error('Unknown language : ' + key);
  23038. }
  23039. return languages[key];
  23040. };
  23041. numeral.language('en', {
  23042. delimiters: {
  23043. thousands: ',',
  23044. decimal: '.'
  23045. },
  23046. abbreviations: {
  23047. thousand: 'k',
  23048. million: 'm',
  23049. billion: 'b',
  23050. trillion: 't'
  23051. },
  23052. ordinal: function(number) {
  23053. var b = number % 10;
  23054. return (~~(number % 100 / 10) === 1) ? 'th' : (b === 1) ? 'st' : (b === 2) ? 'nd' : (b === 3) ? 'rd' : 'th';
  23055. },
  23056. currency: {symbol: '$'}
  23057. });
  23058. numeral.zeroFormat = function(format) {
  23059. zeroFormat = typeof(format) === 'string' ? format : null;
  23060. };
  23061. numeral.defaultFormat = function(format) {
  23062. defaultFormat = typeof(format) === 'string' ? format : '0.0';
  23063. };
  23064. numeral.validate = function(val, culture) {
  23065. var _decimalSep,
  23066. _thousandSep,
  23067. _currSymbol,
  23068. _valArray,
  23069. _abbrObj,
  23070. _thousandRegEx,
  23071. languageData,
  23072. temp;
  23073. if (typeof val !== 'string') {
  23074. val += '';
  23075. if (console.warn) {
  23076. console.warn('Numeral.js: Value is not string. It has been co-erced to: ', val);
  23077. }
  23078. }
  23079. val = val.trim();
  23080. if (val === '') {
  23081. return false;
  23082. }
  23083. val = val.replace(/^[+-]?/, '');
  23084. try {
  23085. languageData = numeral.languageData(culture);
  23086. } catch (e) {
  23087. languageData = numeral.languageData(numeral.language());
  23088. }
  23089. _currSymbol = languageData.currency.symbol;
  23090. _abbrObj = languageData.abbreviations;
  23091. _decimalSep = languageData.delimiters.decimal;
  23092. if (languageData.delimiters.thousands === '.') {
  23093. _thousandSep = '\\.';
  23094. } else {
  23095. _thousandSep = languageData.delimiters.thousands;
  23096. }
  23097. temp = val.match(/^[^\d\.\,]+/);
  23098. if (temp !== null) {
  23099. val = val.substr(1);
  23100. if (temp[0] !== _currSymbol) {
  23101. return false;
  23102. }
  23103. }
  23104. temp = val.match(/[^\d]+$/);
  23105. if (temp !== null) {
  23106. val = val.slice(0, -1);
  23107. if (temp[0] !== _abbrObj.thousand && temp[0] !== _abbrObj.million && temp[0] !== _abbrObj.billion && temp[0] !== _abbrObj.trillion) {
  23108. return false;
  23109. }
  23110. }
  23111. if (!!val.match(/^\d+$/)) {
  23112. return true;
  23113. }
  23114. _thousandRegEx = new RegExp(_thousandSep + '{2}');
  23115. if (!val.match(/[^\d.,]/g)) {
  23116. _valArray = val.split(_decimalSep);
  23117. if (_valArray.length > 2) {
  23118. return false;
  23119. } else {
  23120. if (_valArray.length < 2) {
  23121. return (!!_valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx));
  23122. } else {
  23123. if (_valArray[0] === '') {
  23124. return (!_valArray[0].match(_thousandRegEx) && !!_valArray[1].match(/^\d+$/));
  23125. } else if (_valArray[0].length === 1) {
  23126. return (!!_valArray[0].match(/^\d+$/) && !_valArray[0].match(_thousandRegEx) && !!_valArray[1].match(/^\d+$/));
  23127. } else {
  23128. return (!!_valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx) && !!_valArray[1].match(/^\d+$/));
  23129. }
  23130. }
  23131. }
  23132. }
  23133. return false;
  23134. };
  23135. function loadLanguage(key, values) {
  23136. languages[key] = values;
  23137. }
  23138. if ('function' !== typeof Array.prototype.reduce) {
  23139. Array.prototype.reduce = function(callback, opt_initialValue) {
  23140. 'use strict';
  23141. if (null === this || 'undefined' === typeof this) {
  23142. throw new TypeError('Array.prototype.reduce called on null or undefined');
  23143. }
  23144. if ('function' !== typeof callback) {
  23145. throw new TypeError(callback + ' is not a function');
  23146. }
  23147. var index,
  23148. value,
  23149. length = this.length >>> 0,
  23150. isValueSet = false;
  23151. if (1 < arguments.length) {
  23152. value = opt_initialValue;
  23153. isValueSet = true;
  23154. }
  23155. for (index = 0; length > index; ++index) {
  23156. if (this.hasOwnProperty(index)) {
  23157. if (isValueSet) {
  23158. value = callback(value, this[index], index, this);
  23159. } else {
  23160. value = this[index];
  23161. isValueSet = true;
  23162. }
  23163. }
  23164. }
  23165. if (!isValueSet) {
  23166. throw new TypeError('Reduce of empty array with no initial value');
  23167. }
  23168. return value;
  23169. };
  23170. }
  23171. function multiplier(x) {
  23172. var parts = x.toString().split('.');
  23173. if (parts.length < 2) {
  23174. return 1;
  23175. }
  23176. return Math.pow(10, parts[1].length);
  23177. }
  23178. function correctionFactor() {
  23179. var args = Array.prototype.slice.call(arguments);
  23180. return args.reduce(function(prev, next) {
  23181. var mp = multiplier(prev),
  23182. mn = multiplier(next);
  23183. return mp > mn ? mp : mn;
  23184. }, -Infinity);
  23185. }
  23186. numeral.fn = Numeral.prototype = {
  23187. clone: function() {
  23188. return numeral(this);
  23189. },
  23190. format: function(inputString, roundingFunction) {
  23191. return formatNumeral(this, inputString ? inputString : defaultFormat, (roundingFunction !== undefined) ? roundingFunction : Math.round);
  23192. },
  23193. unformat: function(inputString) {
  23194. if (Object.prototype.toString.call(inputString) === '[object Number]') {
  23195. return inputString;
  23196. }
  23197. return unformatNumeral(this, inputString ? inputString : defaultFormat);
  23198. },
  23199. value: function() {
  23200. return this._value;
  23201. },
  23202. valueOf: function() {
  23203. return this._value;
  23204. },
  23205. set: function(value) {
  23206. this._value = Number(value);
  23207. return this;
  23208. },
  23209. add: function(value) {
  23210. var corrFactor = correctionFactor.call(null, this._value, value);
  23211. function cback(accum, curr, currI, O) {
  23212. return accum + corrFactor * curr;
  23213. }
  23214. this._value = [this._value, value].reduce(cback, 0) / corrFactor;
  23215. return this;
  23216. },
  23217. subtract: function(value) {
  23218. var corrFactor = correctionFactor.call(null, this._value, value);
  23219. function cback(accum, curr, currI, O) {
  23220. return accum - corrFactor * curr;
  23221. }
  23222. this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor;
  23223. return this;
  23224. },
  23225. multiply: function(value) {
  23226. function cback(accum, curr, currI, O) {
  23227. var corrFactor = correctionFactor(accum, curr);
  23228. return (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor);
  23229. }
  23230. this._value = [this._value, value].reduce(cback, 1);
  23231. return this;
  23232. },
  23233. divide: function(value) {
  23234. function cback(accum, curr, currI, O) {
  23235. var corrFactor = correctionFactor(accum, curr);
  23236. return (accum * corrFactor) / (curr * corrFactor);
  23237. }
  23238. this._value = [this._value, value].reduce(cback);
  23239. return this;
  23240. },
  23241. difference: function(value) {
  23242. return Math.abs(numeral(this._value).subtract(value).value());
  23243. }
  23244. };
  23245. if (hasModule) {
  23246. module.exports = numeral;
  23247. }
  23248. if (typeof ender === 'undefined') {
  23249. this['numeral'] = numeral;
  23250. }
  23251. if (typeof define === 'function' && define.amd) {
  23252. define([], function() {
  23253. return numeral;
  23254. });
  23255. }
  23256. }).call(window);
  23257. //#
  23258. },{}],"pikaday":[function(require,module,exports){
  23259. /*!
  23260. * Pikaday
  23261. *
  23262. * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
  23263. */
  23264. (function (root, factory)
  23265. {
  23266. 'use strict';
  23267. var moment;
  23268. if (typeof exports === 'object') {
  23269. // CommonJS module
  23270. // Load moment.js as an optional dependency
  23271. try { moment = require('moment'); } catch (e) {}
  23272. module.exports = factory(moment);
  23273. } else if (typeof define === 'function' && define.amd) {
  23274. // AMD. Register as an anonymous module.
  23275. define(function (req)
  23276. {
  23277. // Load moment.js as an optional dependency
  23278. var id = 'moment';
  23279. try { moment = req(id); } catch (e) {}
  23280. return factory(moment);
  23281. });
  23282. } else {
  23283. root.Pikaday = factory(root.moment);
  23284. }
  23285. }(this, function (moment)
  23286. {
  23287. 'use strict';
  23288. /**
  23289. * feature detection and helper functions
  23290. */
  23291. var hasMoment = typeof moment === 'function',
  23292. hasEventListeners = !!window.addEventListener,
  23293. document = window.document,
  23294. sto = window.setTimeout,
  23295. addEvent = function(el, e, callback, capture)
  23296. {
  23297. if (hasEventListeners) {
  23298. el.addEventListener(e, callback, !!capture);
  23299. } else {
  23300. el.attachEvent('on' + e, callback);
  23301. }
  23302. },
  23303. removeEvent = function(el, e, callback, capture)
  23304. {
  23305. if (hasEventListeners) {
  23306. el.removeEventListener(e, callback, !!capture);
  23307. } else {
  23308. el.detachEvent('on' + e, callback);
  23309. }
  23310. },
  23311. fireEvent = function(el, eventName, data)
  23312. {
  23313. var ev;
  23314. if (document.createEvent) {
  23315. ev = document.createEvent('HTMLEvents');
  23316. ev.initEvent(eventName, true, false);
  23317. ev = extend(ev, data);
  23318. el.dispatchEvent(ev);
  23319. } else if (document.createEventObject) {
  23320. ev = document.createEventObject();
  23321. ev = extend(ev, data);
  23322. el.fireEvent('on' + eventName, ev);
  23323. }
  23324. },
  23325. trim = function(str)
  23326. {
  23327. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,'');
  23328. },
  23329. hasClass = function(el, cn)
  23330. {
  23331. return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1;
  23332. },
  23333. addClass = function(el, cn)
  23334. {
  23335. if (!hasClass(el, cn)) {
  23336. el.className = (el.className === '') ? cn : el.className + ' ' + cn;
  23337. }
  23338. },
  23339. removeClass = function(el, cn)
  23340. {
  23341. el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' '));
  23342. },
  23343. isArray = function(obj)
  23344. {
  23345. return (/Array/).test(Object.prototype.toString.call(obj));
  23346. },
  23347. isDate = function(obj)
  23348. {
  23349. return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
  23350. },
  23351. isWeekend = function(date)
  23352. {
  23353. var day = date.getDay();
  23354. return day === 0 || day === 6;
  23355. },
  23356. isLeapYear = function(year)
  23357. {
  23358. // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
  23359. return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
  23360. },
  23361. getDaysInMonth = function(year, month)
  23362. {
  23363. return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
  23364. },
  23365. setToStartOfDay = function(date)
  23366. {
  23367. if (isDate(date)) date.setHours(0,0,0,0);
  23368. },
  23369. compareDates = function(a,b)
  23370. {
  23371. // weak date comparison (use setToStartOfDay(date) to ensure correct result)
  23372. return a.getTime() === b.getTime();
  23373. },
  23374. extend = function(to, from, overwrite)
  23375. {
  23376. var prop, hasProp;
  23377. for (prop in from) {
  23378. hasProp = to[prop] !== undefined;
  23379. if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) {
  23380. if (isDate(from[prop])) {
  23381. if (overwrite) {
  23382. to[prop] = new Date(from[prop].getTime());
  23383. }
  23384. }
  23385. else if (isArray(from[prop])) {
  23386. if (overwrite) {
  23387. to[prop] = from[prop].slice(0);
  23388. }
  23389. } else {
  23390. to[prop] = extend({}, from[prop], overwrite);
  23391. }
  23392. } else if (overwrite || !hasProp) {
  23393. to[prop] = from[prop];
  23394. }
  23395. }
  23396. return to;
  23397. },
  23398. adjustCalendar = function(calendar) {
  23399. if (calendar.month < 0) {
  23400. calendar.year -= Math.ceil(Math.abs(calendar.month)/12);
  23401. calendar.month += 12;
  23402. }
  23403. if (calendar.month > 11) {
  23404. calendar.year += Math.floor(Math.abs(calendar.month)/12);
  23405. calendar.month -= 12;
  23406. }
  23407. return calendar;
  23408. },
  23409. /**
  23410. * defaults and localisation
  23411. */
  23412. defaults = {
  23413. // bind the picker to a form field
  23414. field: null,
  23415. // automatically show/hide the picker on `field` focus (default `true` if `field` is set)
  23416. bound: undefined,
  23417. // position of the datepicker, relative to the field (default to bottom & left)
  23418. // ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
  23419. position: 'bottom left',
  23420. // automatically fit in the viewport even if it means repositioning from the position option
  23421. reposition: true,
  23422. // the default output format for `.toString()` and `field` value
  23423. format: 'YYYY-MM-DD',
  23424. // the initial date to view when first opened
  23425. defaultDate: null,
  23426. // make the `defaultDate` the initial selected value
  23427. setDefaultDate: false,
  23428. // first day of week (0: Sunday, 1: Monday etc)
  23429. firstDay: 0,
  23430. // the minimum/earliest date that can be selected
  23431. minDate: null,
  23432. // the maximum/latest date that can be selected
  23433. maxDate: null,
  23434. // number of years either side, or array of upper/lower range
  23435. yearRange: 10,
  23436. // show week numbers at head of row
  23437. showWeekNumber: false,
  23438. // used internally (don't config outside)
  23439. minYear: 0,
  23440. maxYear: 9999,
  23441. minMonth: undefined,
  23442. maxMonth: undefined,
  23443. startRange: null,
  23444. endRange: null,
  23445. isRTL: false,
  23446. // Additional text to append to the year in the calendar title
  23447. yearSuffix: '',
  23448. // Render the month after year in the calendar title
  23449. showMonthAfterYear: false,
  23450. // how many months are visible
  23451. numberOfMonths: 1,
  23452. // when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`)
  23453. // only used for the first display or when a selected date is not visible
  23454. mainCalendar: 'left',
  23455. // Specify a DOM element to render the calendar in
  23456. container: undefined,
  23457. // internationalization
  23458. i18n: {
  23459. previousMonth : 'Previous Month',
  23460. nextMonth : 'Next Month',
  23461. months : ['January','February','March','April','May','June','July','August','September','October','November','December'],
  23462. weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
  23463. weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
  23464. },
  23465. // Theme Classname
  23466. theme: null,
  23467. // callback function
  23468. onSelect: null,
  23469. onOpen: null,
  23470. onClose: null,
  23471. onDraw: null
  23472. },
  23473. /**
  23474. * templating functions to abstract HTML rendering
  23475. */
  23476. renderDayName = function(opts, day, abbr)
  23477. {
  23478. day += opts.firstDay;
  23479. while (day >= 7) {
  23480. day -= 7;
  23481. }
  23482. return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day];
  23483. },
  23484. renderDay = function(opts)
  23485. {
  23486. if (opts.isEmpty) {
  23487. return '<td class="is-empty"></td>';
  23488. }
  23489. var arr = [];
  23490. if (opts.isDisabled) {
  23491. arr.push('is-disabled');
  23492. }
  23493. if (opts.isToday) {
  23494. arr.push('is-today');
  23495. }
  23496. if (opts.isSelected) {
  23497. arr.push('is-selected');
  23498. }
  23499. if (opts.isInRange) {
  23500. arr.push('is-inrange');
  23501. }
  23502. if (opts.isStartRange) {
  23503. arr.push('is-startrange');
  23504. }
  23505. if (opts.isEndRange) {
  23506. arr.push('is-endrange');
  23507. }
  23508. return '<td data-day="' + opts.day + '" class="' + arr.join(' ') + '">' +
  23509. '<button class="pika-button pika-day" type="button" ' +
  23510. 'data-pika-year="' + opts.year + '" data-pika-month="' + opts.month + '" data-pika-day="' + opts.day + '">' +
  23511. opts.day +
  23512. '</button>' +
  23513. '</td>';
  23514. },
  23515. renderWeek = function (d, m, y) {
  23516. // Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified.
  23517. var onejan = new Date(y, 0, 1),
  23518. weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay()+1)/7);
  23519. return '<td class="pika-week">' + weekNum + '</td>';
  23520. },
  23521. renderRow = function(days, isRTL)
  23522. {
  23523. return '<tr>' + (isRTL ? days.reverse() : days).join('') + '</tr>';
  23524. },
  23525. renderBody = function(rows)
  23526. {
  23527. return '<tbody>' + rows.join('') + '</tbody>';
  23528. },
  23529. renderHead = function(opts)
  23530. {
  23531. var i, arr = [];
  23532. if (opts.showWeekNumber) {
  23533. arr.push('<th></th>');
  23534. }
  23535. for (i = 0; i < 7; i++) {
  23536. arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
  23537. }
  23538. return '<thead>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</thead>';
  23539. },
  23540. renderTitle = function(instance, c, year, month, refYear)
  23541. {
  23542. var i, j, arr,
  23543. opts = instance._o,
  23544. isMinYear = year === opts.minYear,
  23545. isMaxYear = year === opts.maxYear,
  23546. html = '<div class="pika-title">',
  23547. monthHtml,
  23548. yearHtml,
  23549. prev = true,
  23550. next = true;
  23551. for (arr = [], i = 0; i < 12; i++) {
  23552. arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' +
  23553. (i === month ? ' selected': '') +
  23554. ((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled' : '') + '>' +
  23555. opts.i18n.months[i] + '</option>');
  23556. }
  23557. monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select class="pika-select pika-select-month" tabindex="-1">' + arr.join('') + '</select></div>';
  23558. if (isArray(opts.yearRange)) {
  23559. i = opts.yearRange[0];
  23560. j = opts.yearRange[1] + 1;
  23561. } else {
  23562. i = year - opts.yearRange;
  23563. j = 1 + year + opts.yearRange;
  23564. }
  23565. for (arr = []; i < j && i <= opts.maxYear; i++) {
  23566. if (i >= opts.minYear) {
  23567. arr.push('<option value="' + i + '"' + (i === year ? ' selected': '') + '>' + (i) + '</option>');
  23568. }
  23569. }
  23570. yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select class="pika-select pika-select-year" tabindex="-1">' + arr.join('') + '</select></div>';
  23571. if (opts.showMonthAfterYear) {
  23572. html += yearHtml + monthHtml;
  23573. } else {
  23574. html += monthHtml + yearHtml;
  23575. }
  23576. if (isMinYear && (month === 0 || opts.minMonth >= month)) {
  23577. prev = false;
  23578. }
  23579. if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
  23580. next = false;
  23581. }
  23582. if (c === 0) {
  23583. html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
  23584. }
  23585. if (c === (instance._o.numberOfMonths - 1) ) {
  23586. html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
  23587. }
  23588. return html += '</div>';
  23589. },
  23590. renderTable = function(opts, data)
  23591. {
  23592. return '<table cellpadding="0" cellspacing="0" class="pika-table">' + renderHead(opts) + renderBody(data) + '</table>';
  23593. },
  23594. /**
  23595. * Pikaday constructor
  23596. */
  23597. Pikaday = function(options)
  23598. {
  23599. var self = this,
  23600. opts = self.config(options);
  23601. self._onMouseDown = function(e)
  23602. {
  23603. if (!self._v) {
  23604. return;
  23605. }
  23606. e = e || window.event;
  23607. var target = e.target || e.srcElement;
  23608. if (!target) {
  23609. return;
  23610. }
  23611. if (!hasClass(target, 'is-disabled')) {
  23612. if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty')) {
  23613. self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day')));
  23614. if (opts.bound) {
  23615. sto(function() {
  23616. self.hide();
  23617. if (opts.field) {
  23618. opts.field.blur();
  23619. }
  23620. }, 100);
  23621. }
  23622. }
  23623. else if (hasClass(target, 'pika-prev')) {
  23624. self.prevMonth();
  23625. }
  23626. else if (hasClass(target, 'pika-next')) {
  23627. self.nextMonth();
  23628. }
  23629. }
  23630. if (!hasClass(target, 'pika-select')) {
  23631. // if this is touch event prevent mouse events emulation
  23632. if (e.preventDefault) {
  23633. e.preventDefault();
  23634. } else {
  23635. e.returnValue = false;
  23636. return false;
  23637. }
  23638. } else {
  23639. self._c = true;
  23640. }
  23641. };
  23642. self._onChange = function(e)
  23643. {
  23644. e = e || window.event;
  23645. var target = e.target || e.srcElement;
  23646. if (!target) {
  23647. return;
  23648. }
  23649. if (hasClass(target, 'pika-select-month')) {
  23650. self.gotoMonth(target.value);
  23651. }
  23652. else if (hasClass(target, 'pika-select-year')) {
  23653. self.gotoYear(target.value);
  23654. }
  23655. };
  23656. self._onInputChange = function(e)
  23657. {
  23658. var date;
  23659. if (e.firedBy === self) {
  23660. return;
  23661. }
  23662. if (hasMoment) {
  23663. date = moment(opts.field.value, opts.format);
  23664. date = (date && date.isValid()) ? date.toDate() : null;
  23665. }
  23666. else {
  23667. date = new Date(Date.parse(opts.field.value));
  23668. }
  23669. if (isDate(date)) {
  23670. self.setDate(date);
  23671. }
  23672. if (!self._v) {
  23673. self.show();
  23674. }
  23675. };
  23676. self._onInputFocus = function()
  23677. {
  23678. self.show();
  23679. };
  23680. self._onInputClick = function()
  23681. {
  23682. self.show();
  23683. };
  23684. self._onInputBlur = function()
  23685. {
  23686. // IE allows pika div to gain focus; catch blur the input field
  23687. var pEl = document.activeElement;
  23688. do {
  23689. if (hasClass(pEl, 'pika-single')) {
  23690. return;
  23691. }
  23692. }
  23693. while ((pEl = pEl.parentNode));
  23694. if (!self._c) {
  23695. self._b = sto(function() {
  23696. self.hide();
  23697. }, 50);
  23698. }
  23699. self._c = false;
  23700. };
  23701. self._onClick = function(e)
  23702. {
  23703. e = e || window.event;
  23704. var target = e.target || e.srcElement,
  23705. pEl = target;
  23706. if (!target) {
  23707. return;
  23708. }
  23709. if (!hasEventListeners && hasClass(target, 'pika-select')) {
  23710. if (!target.onchange) {
  23711. target.setAttribute('onchange', 'return;');
  23712. addEvent(target, 'change', self._onChange);
  23713. }
  23714. }
  23715. do {
  23716. if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) {
  23717. return;
  23718. }
  23719. }
  23720. while ((pEl = pEl.parentNode));
  23721. if (self._v && target !== opts.trigger && pEl !== opts.trigger) {
  23722. self.hide();
  23723. }
  23724. };
  23725. self.el = document.createElement('div');
  23726. self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '') + (opts.theme ? ' ' + opts.theme : '');
  23727. addEvent(self.el, 'mousedown', self._onMouseDown, true);
  23728. addEvent(self.el, 'touchend', self._onMouseDown, true);
  23729. addEvent(self.el, 'change', self._onChange);
  23730. if (opts.field) {
  23731. if (opts.container) {
  23732. opts.container.appendChild(self.el);
  23733. } else if (opts.bound) {
  23734. document.body.appendChild(self.el);
  23735. } else {
  23736. opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling);
  23737. }
  23738. addEvent(opts.field, 'change', self._onInputChange);
  23739. if (!opts.defaultDate) {
  23740. if (hasMoment && opts.field.value) {
  23741. opts.defaultDate = moment(opts.field.value, opts.format).toDate();
  23742. } else {
  23743. opts.defaultDate = new Date(Date.parse(opts.field.value));
  23744. }
  23745. opts.setDefaultDate = true;
  23746. }
  23747. }
  23748. var defDate = opts.defaultDate;
  23749. if (isDate(defDate)) {
  23750. if (opts.setDefaultDate) {
  23751. self.setDate(defDate, true);
  23752. } else {
  23753. self.gotoDate(defDate);
  23754. }
  23755. } else {
  23756. self.gotoDate(new Date());
  23757. }
  23758. if (opts.bound) {
  23759. this.hide();
  23760. self.el.className += ' is-bound';
  23761. addEvent(opts.trigger, 'click', self._onInputClick);
  23762. addEvent(opts.trigger, 'focus', self._onInputFocus);
  23763. addEvent(opts.trigger, 'blur', self._onInputBlur);
  23764. } else {
  23765. this.show();
  23766. }
  23767. };
  23768. /**
  23769. * public Pikaday API
  23770. */
  23771. Pikaday.prototype = {
  23772. /**
  23773. * configure functionality
  23774. */
  23775. config: function(options)
  23776. {
  23777. if (!this._o) {
  23778. this._o = extend({}, defaults, true);
  23779. }
  23780. var opts = extend(this._o, options, true);
  23781. opts.isRTL = !!opts.isRTL;
  23782. opts.field = (opts.field && opts.field.nodeName) ? opts.field : null;
  23783. opts.theme = (typeof opts.theme) === 'string' && opts.theme ? opts.theme : null;
  23784. opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field);
  23785. opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field;
  23786. opts.disableWeekends = !!opts.disableWeekends;
  23787. opts.disableDayFn = (typeof opts.disableDayFn) === 'function' ? opts.disableDayFn : null;
  23788. var nom = parseInt(opts.numberOfMonths, 10) || 1;
  23789. opts.numberOfMonths = nom > 4 ? 4 : nom;
  23790. if (!isDate(opts.minDate)) {
  23791. opts.minDate = false;
  23792. }
  23793. if (!isDate(opts.maxDate)) {
  23794. opts.maxDate = false;
  23795. }
  23796. if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) {
  23797. opts.maxDate = opts.minDate = false;
  23798. }
  23799. if (opts.minDate) {
  23800. this.setMinDate(opts.minDate);
  23801. }
  23802. if (opts.maxDate) {
  23803. this.setMaxDate(opts.maxDate);
  23804. }
  23805. if (isArray(opts.yearRange)) {
  23806. var fallback = new Date().getFullYear() - 10;
  23807. opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback;
  23808. opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback;
  23809. } else {
  23810. opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange;
  23811. if (opts.yearRange > 100) {
  23812. opts.yearRange = 100;
  23813. }
  23814. }
  23815. return opts;
  23816. },
  23817. /**
  23818. * return a formatted string of the current selection (using Moment.js if available)
  23819. */
  23820. toString: function(format)
  23821. {
  23822. return !isDate(this._d) ? '' : hasMoment ? moment(this._d).format(format || this._o.format) : this._d.toDateString();
  23823. },
  23824. /**
  23825. * return a Moment.js object of the current selection (if available)
  23826. */
  23827. getMoment: function()
  23828. {
  23829. return hasMoment ? moment(this._d) : null;
  23830. },
  23831. /**
  23832. * set the current selection from a Moment.js object (if available)
  23833. */
  23834. setMoment: function(date, preventOnSelect)
  23835. {
  23836. if (hasMoment && moment.isMoment(date)) {
  23837. this.setDate(date.toDate(), preventOnSelect);
  23838. }
  23839. },
  23840. /**
  23841. * return a Date object of the current selection
  23842. */
  23843. getDate: function()
  23844. {
  23845. return isDate(this._d) ? new Date(this._d.getTime()) : null;
  23846. },
  23847. /**
  23848. * set the current selection
  23849. */
  23850. setDate: function(date, preventOnSelect)
  23851. {
  23852. if (!date) {
  23853. this._d = null;
  23854. if (this._o.field) {
  23855. this._o.field.value = '';
  23856. fireEvent(this._o.field, 'change', { firedBy: this });
  23857. }
  23858. return this.draw();
  23859. }
  23860. if (typeof date === 'string') {
  23861. date = new Date(Date.parse(date));
  23862. }
  23863. if (!isDate(date)) {
  23864. return;
  23865. }
  23866. var min = this._o.minDate,
  23867. max = this._o.maxDate;
  23868. if (isDate(min) && date < min) {
  23869. date = min;
  23870. } else if (isDate(max) && date > max) {
  23871. date = max;
  23872. }
  23873. this._d = new Date(date.getTime());
  23874. setToStartOfDay(this._d);
  23875. this.gotoDate(this._d);
  23876. if (this._o.field) {
  23877. this._o.field.value = this.toString();
  23878. fireEvent(this._o.field, 'change', { firedBy: this });
  23879. }
  23880. if (!preventOnSelect && typeof this._o.onSelect === 'function') {
  23881. this._o.onSelect.call(this, this.getDate());
  23882. }
  23883. },
  23884. /**
  23885. * change view to a specific date
  23886. */
  23887. gotoDate: function(date)
  23888. {
  23889. var newCalendar = true;
  23890. if (!isDate(date)) {
  23891. return;
  23892. }
  23893. if (this.calendars) {
  23894. var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1),
  23895. lastVisibleDate = new Date(this.calendars[this.calendars.length-1].year, this.calendars[this.calendars.length-1].month, 1),
  23896. visibleDate = date.getTime();
  23897. // get the end of the month
  23898. lastVisibleDate.setMonth(lastVisibleDate.getMonth()+1);
  23899. lastVisibleDate.setDate(lastVisibleDate.getDate()-1);
  23900. newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate);
  23901. }
  23902. if (newCalendar) {
  23903. this.calendars = [{
  23904. month: date.getMonth(),
  23905. year: date.getFullYear()
  23906. }];
  23907. if (this._o.mainCalendar === 'right') {
  23908. this.calendars[0].month += 1 - this._o.numberOfMonths;
  23909. }
  23910. }
  23911. this.adjustCalendars();
  23912. },
  23913. adjustCalendars: function() {
  23914. this.calendars[0] = adjustCalendar(this.calendars[0]);
  23915. for (var c = 1; c < this._o.numberOfMonths; c++) {
  23916. this.calendars[c] = adjustCalendar({
  23917. month: this.calendars[0].month + c,
  23918. year: this.calendars[0].year
  23919. });
  23920. }
  23921. this.draw();
  23922. },
  23923. gotoToday: function()
  23924. {
  23925. this.gotoDate(new Date());
  23926. },
  23927. /**
  23928. * change view to a specific month (zero-index, e.g. 0: January)
  23929. */
  23930. gotoMonth: function(month)
  23931. {
  23932. if (!isNaN(month)) {
  23933. this.calendars[0].month = parseInt(month, 10);
  23934. this.adjustCalendars();
  23935. }
  23936. },
  23937. nextMonth: function()
  23938. {
  23939. this.calendars[0].month++;
  23940. this.adjustCalendars();
  23941. },
  23942. prevMonth: function()
  23943. {
  23944. this.calendars[0].month--;
  23945. this.adjustCalendars();
  23946. },
  23947. /**
  23948. * change view to a specific full year (e.g. "2012")
  23949. */
  23950. gotoYear: function(year)
  23951. {
  23952. if (!isNaN(year)) {
  23953. this.calendars[0].year = parseInt(year, 10);
  23954. this.adjustCalendars();
  23955. }
  23956. },
  23957. /**
  23958. * change the minDate
  23959. */
  23960. setMinDate: function(value)
  23961. {
  23962. setToStartOfDay(value);
  23963. this._o.minDate = value;
  23964. this._o.minYear = value.getFullYear();
  23965. this._o.minMonth = value.getMonth();
  23966. this.draw();
  23967. },
  23968. /**
  23969. * change the maxDate
  23970. */
  23971. setMaxDate: function(value)
  23972. {
  23973. setToStartOfDay(value);
  23974. this._o.maxDate = value;
  23975. this._o.maxYear = value.getFullYear();
  23976. this._o.maxMonth = value.getMonth();
  23977. this.draw();
  23978. },
  23979. setStartRange: function(value)
  23980. {
  23981. this._o.startRange = value;
  23982. },
  23983. setEndRange: function(value)
  23984. {
  23985. this._o.endRange = value;
  23986. },
  23987. /**
  23988. * refresh the HTML
  23989. */
  23990. draw: function(force)
  23991. {
  23992. if (!this._v && !force) {
  23993. return;
  23994. }
  23995. var opts = this._o,
  23996. minYear = opts.minYear,
  23997. maxYear = opts.maxYear,
  23998. minMonth = opts.minMonth,
  23999. maxMonth = opts.maxMonth,
  24000. html = '';
  24001. if (this._y <= minYear) {
  24002. this._y = minYear;
  24003. if (!isNaN(minMonth) && this._m < minMonth) {
  24004. this._m = minMonth;
  24005. }
  24006. }
  24007. if (this._y >= maxYear) {
  24008. this._y = maxYear;
  24009. if (!isNaN(maxMonth) && this._m > maxMonth) {
  24010. this._m = maxMonth;
  24011. }
  24012. }
  24013. for (var c = 0; c < opts.numberOfMonths; c++) {
  24014. html += '<div class="pika-lendar">' + renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year) + this.render(this.calendars[c].year, this.calendars[c].month) + '</div>';
  24015. }
  24016. this.el.innerHTML = html;
  24017. if (opts.bound) {
  24018. if(opts.field.type !== 'hidden') {
  24019. sto(function() {
  24020. opts.trigger.focus();
  24021. }, 1);
  24022. }
  24023. }
  24024. if (typeof this._o.onDraw === 'function') {
  24025. var self = this;
  24026. sto(function() {
  24027. self._o.onDraw.call(self);
  24028. }, 0);
  24029. }
  24030. },
  24031. adjustPosition: function()
  24032. {
  24033. var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect;
  24034. if (this._o.container) return;
  24035. this.el.style.position = 'absolute';
  24036. field = this._o.trigger;
  24037. pEl = field;
  24038. width = this.el.offsetWidth;
  24039. height = this.el.offsetHeight;
  24040. viewportWidth = window.innerWidth || document.documentElement.clientWidth;
  24041. viewportHeight = window.innerHeight || document.documentElement.clientHeight;
  24042. scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
  24043. if (typeof field.getBoundingClientRect === 'function') {
  24044. clientRect = field.getBoundingClientRect();
  24045. left = clientRect.left + window.pageXOffset;
  24046. top = clientRect.bottom + window.pageYOffset;
  24047. } else {
  24048. left = pEl.offsetLeft;
  24049. top = pEl.offsetTop + pEl.offsetHeight;
  24050. while((pEl = pEl.offsetParent)) {
  24051. left += pEl.offsetLeft;
  24052. top += pEl.offsetTop;
  24053. }
  24054. }
  24055. // default position is bottom & left
  24056. if ((this._o.reposition && left + width > viewportWidth) ||
  24057. (
  24058. this._o.position.indexOf('right') > -1 &&
  24059. left - width + field.offsetWidth > 0
  24060. )
  24061. ) {
  24062. left = left - width + field.offsetWidth;
  24063. }
  24064. if ((this._o.reposition && top + height > viewportHeight + scrollTop) ||
  24065. (
  24066. this._o.position.indexOf('top') > -1 &&
  24067. top - height - field.offsetHeight > 0
  24068. )
  24069. ) {
  24070. top = top - height - field.offsetHeight;
  24071. }
  24072. this.el.style.left = left + 'px';
  24073. this.el.style.top = top + 'px';
  24074. },
  24075. /**
  24076. * render HTML for a particular month
  24077. */
  24078. render: function(year, month)
  24079. {
  24080. var opts = this._o,
  24081. now = new Date(),
  24082. days = getDaysInMonth(year, month),
  24083. before = new Date(year, month, 1).getDay(),
  24084. data = [],
  24085. row = [];
  24086. setToStartOfDay(now);
  24087. if (opts.firstDay > 0) {
  24088. before -= opts.firstDay;
  24089. if (before < 0) {
  24090. before += 7;
  24091. }
  24092. }
  24093. var cells = days + before,
  24094. after = cells;
  24095. while(after > 7) {
  24096. after -= 7;
  24097. }
  24098. cells += 7 - after;
  24099. for (var i = 0, r = 0; i < cells; i++)
  24100. {
  24101. var day = new Date(year, month, 1 + (i - before)),
  24102. isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
  24103. isToday = compareDates(day, now),
  24104. isEmpty = i < before || i >= (days + before),
  24105. isStartRange = opts.startRange && compareDates(opts.startRange, day),
  24106. isEndRange = opts.endRange && compareDates(opts.endRange, day),
  24107. isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange,
  24108. isDisabled = (opts.minDate && day < opts.minDate) ||
  24109. (opts.maxDate && day > opts.maxDate) ||
  24110. (opts.disableWeekends && isWeekend(day)) ||
  24111. (opts.disableDayFn && opts.disableDayFn(day)),
  24112. dayConfig = {
  24113. day: 1 + (i - before),
  24114. month: month,
  24115. year: year,
  24116. isSelected: isSelected,
  24117. isToday: isToday,
  24118. isDisabled: isDisabled,
  24119. isEmpty: isEmpty,
  24120. isStartRange: isStartRange,
  24121. isEndRange: isEndRange,
  24122. isInRange: isInRange
  24123. };
  24124. row.push(renderDay(dayConfig));
  24125. if (++r === 7) {
  24126. if (opts.showWeekNumber) {
  24127. row.unshift(renderWeek(i - before, month, year));
  24128. }
  24129. data.push(renderRow(row, opts.isRTL));
  24130. row = [];
  24131. r = 0;
  24132. }
  24133. }
  24134. return renderTable(opts, data);
  24135. },
  24136. isVisible: function()
  24137. {
  24138. return this._v;
  24139. },
  24140. show: function()
  24141. {
  24142. if (!this._v) {
  24143. removeClass(this.el, 'is-hidden');
  24144. this._v = true;
  24145. this.draw();
  24146. if (this._o.bound) {
  24147. addEvent(document, 'click', this._onClick);
  24148. this.adjustPosition();
  24149. }
  24150. if (typeof this._o.onOpen === 'function') {
  24151. this._o.onOpen.call(this);
  24152. }
  24153. }
  24154. },
  24155. hide: function()
  24156. {
  24157. var v = this._v;
  24158. if (v !== false) {
  24159. if (this._o.bound) {
  24160. removeEvent(document, 'click', this._onClick);
  24161. }
  24162. this.el.style.position = 'static'; // reset
  24163. this.el.style.left = 'auto';
  24164. this.el.style.top = 'auto';
  24165. addClass(this.el, 'is-hidden');
  24166. this._v = false;
  24167. if (v !== undefined && typeof this._o.onClose === 'function') {
  24168. this._o.onClose.call(this);
  24169. }
  24170. }
  24171. },
  24172. /**
  24173. * GAME OVER
  24174. */
  24175. destroy: function()
  24176. {
  24177. this.hide();
  24178. removeEvent(this.el, 'mousedown', this._onMouseDown, true);
  24179. removeEvent(this.el, 'touchend', this._onMouseDown, true);
  24180. removeEvent(this.el, 'change', this._onChange);
  24181. if (this._o.field) {
  24182. removeEvent(this._o.field, 'change', this._onInputChange);
  24183. if (this._o.bound) {
  24184. removeEvent(this._o.trigger, 'click', this._onInputClick);
  24185. removeEvent(this._o.trigger, 'focus', this._onInputFocus);
  24186. removeEvent(this._o.trigger, 'blur', this._onInputBlur);
  24187. }
  24188. }
  24189. if (this.el.parentNode) {
  24190. this.el.parentNode.removeChild(this.el);
  24191. }
  24192. }
  24193. };
  24194. return Pikaday;
  24195. }));
  24196. },{"moment":"moment"}],"zeroclipboard":[function(require,module,exports){
  24197. /*!
  24198. * ZeroClipboard
  24199. * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
  24200. * Copyright (c) 2009-2014 Jon Rohan, James M. Greene
  24201. * Licensed MIT
  24202. * http://zeroclipboard.org/
  24203. * v2.2.0
  24204. */
  24205. (function(window, undefined) {
  24206. "use strict";
  24207. /**
  24208. * Store references to critically important global functions that may be
  24209. * overridden on certain web pages.
  24210. */
  24211. var _window = window, _document = _window.document, _navigator = _window.navigator, _setTimeout = _window.setTimeout, _clearTimeout = _window.clearTimeout, _setInterval = _window.setInterval, _clearInterval = _window.clearInterval, _getComputedStyle = _window.getComputedStyle, _encodeURIComponent = _window.encodeURIComponent, _ActiveXObject = _window.ActiveXObject, _Error = _window.Error, _parseInt = _window.Number.parseInt || _window.parseInt, _parseFloat = _window.Number.parseFloat || _window.parseFloat, _isNaN = _window.Number.isNaN || _window.isNaN, _now = _window.Date.now, _keys = _window.Object.keys, _defineProperty = _window.Object.defineProperty, _hasOwn = _window.Object.prototype.hasOwnProperty, _slice = _window.Array.prototype.slice, _unwrap = function() {
  24212. var unwrapper = function(el) {
  24213. return el;
  24214. };
  24215. if (typeof _window.wrap === "function" && typeof _window.unwrap === "function") {
  24216. try {
  24217. var div = _document.createElement("div");
  24218. var unwrappedDiv = _window.unwrap(div);
  24219. if (div.nodeType === 1 && unwrappedDiv && unwrappedDiv.nodeType === 1) {
  24220. unwrapper = _window.unwrap;
  24221. }
  24222. } catch (e) {}
  24223. }
  24224. return unwrapper;
  24225. }();
  24226. /**
  24227. * Convert an `arguments` object into an Array.
  24228. *
  24229. * @returns The arguments as an Array
  24230. * @private
  24231. */
  24232. var _args = function(argumentsObj) {
  24233. return _slice.call(argumentsObj, 0);
  24234. };
  24235. /**
  24236. * Shallow-copy the owned, enumerable properties of one object over to another, similar to jQuery's `$.extend`.
  24237. *
  24238. * @returns The target object, augmented
  24239. * @private
  24240. */
  24241. var _extend = function() {
  24242. var i, len, arg, prop, src, copy, args = _args(arguments), target = args[0] || {};
  24243. for (i = 1, len = args.length; i < len; i++) {
  24244. if ((arg = args[i]) != null) {
  24245. for (prop in arg) {
  24246. if (_hasOwn.call(arg, prop)) {
  24247. src = target[prop];
  24248. copy = arg[prop];
  24249. if (target !== copy && copy !== undefined) {
  24250. target[prop] = copy;
  24251. }
  24252. }
  24253. }
  24254. }
  24255. }
  24256. return target;
  24257. };
  24258. /**
  24259. * Return a deep copy of the source object or array.
  24260. *
  24261. * @returns Object or Array
  24262. * @private
  24263. */
  24264. var _deepCopy = function(source) {
  24265. var copy, i, len, prop;
  24266. if (typeof source !== "object" || source == null || typeof source.nodeType === "number") {
  24267. copy = source;
  24268. } else if (typeof source.length === "number") {
  24269. copy = [];
  24270. for (i = 0, len = source.length; i < len; i++) {
  24271. if (_hasOwn.call(source, i)) {
  24272. copy[i] = _deepCopy(source[i]);
  24273. }
  24274. }
  24275. } else {
  24276. copy = {};
  24277. for (prop in source) {
  24278. if (_hasOwn.call(source, prop)) {
  24279. copy[prop] = _deepCopy(source[prop]);
  24280. }
  24281. }
  24282. }
  24283. return copy;
  24284. };
  24285. /**
  24286. * Makes a shallow copy of `obj` (like `_extend`) but filters its properties based on a list of `keys` to keep.
  24287. * The inverse of `_omit`, mostly. The big difference is that these properties do NOT need to be enumerable to
  24288. * be kept.
  24289. *
  24290. * @returns A new filtered object.
  24291. * @private
  24292. */
  24293. var _pick = function(obj, keys) {
  24294. var newObj = {};
  24295. for (var i = 0, len = keys.length; i < len; i++) {
  24296. if (keys[i] in obj) {
  24297. newObj[keys[i]] = obj[keys[i]];
  24298. }
  24299. }
  24300. return newObj;
  24301. };
  24302. /**
  24303. * Makes a shallow copy of `obj` (like `_extend`) but filters its properties based on a list of `keys` to omit.
  24304. * The inverse of `_pick`.
  24305. *
  24306. * @returns A new filtered object.
  24307. * @private
  24308. */
  24309. var _omit = function(obj, keys) {
  24310. var newObj = {};
  24311. for (var prop in obj) {
  24312. if (keys.indexOf(prop) === -1) {
  24313. newObj[prop] = obj[prop];
  24314. }
  24315. }
  24316. return newObj;
  24317. };
  24318. /**
  24319. * Remove all owned, enumerable properties from an object.
  24320. *
  24321. * @returns The original object without its owned, enumerable properties.
  24322. * @private
  24323. */
  24324. var _deleteOwnProperties = function(obj) {
  24325. if (obj) {
  24326. for (var prop in obj) {
  24327. if (_hasOwn.call(obj, prop)) {
  24328. delete obj[prop];
  24329. }
  24330. }
  24331. }
  24332. return obj;
  24333. };
  24334. /**
  24335. * Determine if an element is contained within another element.
  24336. *
  24337. * @returns Boolean
  24338. * @private
  24339. */
  24340. var _containedBy = function(el, ancestorEl) {
  24341. if (el && el.nodeType === 1 && el.ownerDocument && ancestorEl && (ancestorEl.nodeType === 1 && ancestorEl.ownerDocument && ancestorEl.ownerDocument === el.ownerDocument || ancestorEl.nodeType === 9 && !ancestorEl.ownerDocument && ancestorEl === el.ownerDocument)) {
  24342. do {
  24343. if (el === ancestorEl) {
  24344. return true;
  24345. }
  24346. el = el.parentNode;
  24347. } while (el);
  24348. }
  24349. return false;
  24350. };
  24351. /**
  24352. * Get the URL path's parent directory.
  24353. *
  24354. * @returns String or `undefined`
  24355. * @private
  24356. */
  24357. var _getDirPathOfUrl = function(url) {
  24358. var dir;
  24359. if (typeof url === "string" && url) {
  24360. dir = url.split("#")[0].split("?")[0];
  24361. dir = url.slice(0, url.lastIndexOf("/") + 1);
  24362. }
  24363. return dir;
  24364. };
  24365. /**
  24366. * Get the current script's URL by throwing an `Error` and analyzing it.
  24367. *
  24368. * @returns String or `undefined`
  24369. * @private
  24370. */
  24371. var _getCurrentScriptUrlFromErrorStack = function(stack) {
  24372. var url, matches;
  24373. if (typeof stack === "string" && stack) {
  24374. matches = stack.match(/^(?:|[^:@]*@|.+\)@(?=http[s]?|file)|.+?\s+(?: at |@)(?:[^:\(]+ )*[\(]?)((?:http[s]?|file):\/\/[\/]?.+?\/[^:\)]*?)(?::\d+)(?::\d+)?/);
  24375. if (matches && matches[1]) {
  24376. url = matches[1];
  24377. } else {
  24378. matches = stack.match(/\)@((?:http[s]?|file):\/\/[\/]?.+?\/[^:\)]*?)(?::\d+)(?::\d+)?/);
  24379. if (matches && matches[1]) {
  24380. url = matches[1];
  24381. }
  24382. }
  24383. }
  24384. return url;
  24385. };
  24386. /**
  24387. * Get the current script's URL by throwing an `Error` and analyzing it.
  24388. *
  24389. * @returns String or `undefined`
  24390. * @private
  24391. */
  24392. var _getCurrentScriptUrlFromError = function() {
  24393. var url, err;
  24394. try {
  24395. throw new _Error();
  24396. } catch (e) {
  24397. err = e;
  24398. }
  24399. if (err) {
  24400. url = err.sourceURL || err.fileName || _getCurrentScriptUrlFromErrorStack(err.stack);
  24401. }
  24402. return url;
  24403. };
  24404. /**
  24405. * Get the current script's URL.
  24406. *
  24407. * @returns String or `undefined`
  24408. * @private
  24409. */
  24410. var _getCurrentScriptUrl = function() {
  24411. var jsPath, scripts, i;
  24412. if (_document.currentScript && (jsPath = _document.currentScript.src)) {
  24413. return jsPath;
  24414. }
  24415. scripts = _document.getElementsByTagName("script");
  24416. if (scripts.length === 1) {
  24417. return scripts[0].src || undefined;
  24418. }
  24419. if ("readyState" in scripts[0]) {
  24420. for (i = scripts.length; i--; ) {
  24421. if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) {
  24422. return jsPath;
  24423. }
  24424. }
  24425. }
  24426. if (_document.readyState === "loading" && (jsPath = scripts[scripts.length - 1].src)) {
  24427. return jsPath;
  24428. }
  24429. if (jsPath = _getCurrentScriptUrlFromError()) {
  24430. return jsPath;
  24431. }
  24432. return undefined;
  24433. };
  24434. /**
  24435. * Get the unanimous parent directory of ALL script tags.
  24436. * If any script tags are either (a) inline or (b) from differing parent
  24437. * directories, this method must return `undefined`.
  24438. *
  24439. * @returns String or `undefined`
  24440. * @private
  24441. */
  24442. var _getUnanimousScriptParentDir = function() {
  24443. var i, jsDir, jsPath, scripts = _document.getElementsByTagName("script");
  24444. for (i = scripts.length; i--; ) {
  24445. if (!(jsPath = scripts[i].src)) {
  24446. jsDir = null;
  24447. break;
  24448. }
  24449. jsPath = _getDirPathOfUrl(jsPath);
  24450. if (jsDir == null) {
  24451. jsDir = jsPath;
  24452. } else if (jsDir !== jsPath) {
  24453. jsDir = null;
  24454. break;
  24455. }
  24456. }
  24457. return jsDir || undefined;
  24458. };
  24459. /**
  24460. * Get the presumed location of the "ZeroClipboard.swf" file, based on the location
  24461. * of the executing JavaScript file (e.g. "ZeroClipboard.js", etc.).
  24462. *
  24463. * @returns String
  24464. * @private
  24465. */
  24466. var _getDefaultSwfPath = function() {
  24467. var jsDir = _getDirPathOfUrl(_getCurrentScriptUrl()) || _getUnanimousScriptParentDir() || "";
  24468. return jsDir + "ZeroClipboard.swf";
  24469. };
  24470. /**
  24471. * Keep track of if the page is framed (in an `iframe`). This can never change.
  24472. * @private
  24473. */
  24474. var _pageIsFramed = function() {
  24475. return window.opener == null && (!!window.top && window != window.top || !!window.parent && window != window.parent);
  24476. }();
  24477. /**
  24478. * Keep track of the state of the Flash object.
  24479. * @private
  24480. */
  24481. var _flashState = {
  24482. bridge: null,
  24483. version: "0.0.0",
  24484. pluginType: "unknown",
  24485. disabled: null,
  24486. outdated: null,
  24487. sandboxed: null,
  24488. unavailable: null,
  24489. degraded: null,
  24490. deactivated: null,
  24491. overdue: null,
  24492. ready: null
  24493. };
  24494. /**
  24495. * The minimum Flash Player version required to use ZeroClipboard completely.
  24496. * @readonly
  24497. * @private
  24498. */
  24499. var _minimumFlashVersion = "11.0.0";
  24500. /**
  24501. * The ZeroClipboard library version number, as reported by Flash, at the time the SWF was compiled.
  24502. */
  24503. var _zcSwfVersion;
  24504. /**
  24505. * Keep track of all event listener registrations.
  24506. * @private
  24507. */
  24508. var _handlers = {};
  24509. /**
  24510. * Keep track of the currently activated element.
  24511. * @private
  24512. */
  24513. var _currentElement;
  24514. /**
  24515. * Keep track of the element that was activated when a `copy` process started.
  24516. * @private
  24517. */
  24518. var _copyTarget;
  24519. /**
  24520. * Keep track of data for the pending clipboard transaction.
  24521. * @private
  24522. */
  24523. var _clipData = {};
  24524. /**
  24525. * Keep track of data formats for the pending clipboard transaction.
  24526. * @private
  24527. */
  24528. var _clipDataFormatMap = null;
  24529. /**
  24530. * Keep track of the Flash availability check timeout.
  24531. * @private
  24532. */
  24533. var _flashCheckTimeout = 0;
  24534. /**
  24535. * Keep track of SWF network errors interval polling.
  24536. * @private
  24537. */
  24538. var _swfFallbackCheckInterval = 0;
  24539. /**
  24540. * The `message` store for events
  24541. * @private
  24542. */
  24543. var _eventMessages = {
  24544. ready: "Flash communication is established",
  24545. error: {
  24546. "flash-disabled": "Flash is disabled or not installed. May also be attempting to run Flash in a sandboxed iframe, which is impossible.",
  24547. "flash-outdated": "Flash is too outdated to support ZeroClipboard",
  24548. "flash-sandboxed": "Attempting to run Flash in a sandboxed iframe, which is impossible",
  24549. "flash-unavailable": "Flash is unable to communicate bidirectionally with JavaScript",
  24550. "flash-degraded": "Flash is unable to preserve data fidelity when communicating with JavaScript",
  24551. "flash-deactivated": "Flash is too outdated for your browser and/or is configured as click-to-activate.\nThis may also mean that the ZeroClipboard SWF object could not be loaded, so please check your `swfPath` configuration and/or network connectivity.\nMay also be attempting to run Flash in a sandboxed iframe, which is impossible.",
  24552. "flash-overdue": "Flash communication was established but NOT within the acceptable time limit",
  24553. "version-mismatch": "ZeroClipboard JS version number does not match ZeroClipboard SWF version number",
  24554. "clipboard-error": "At least one error was thrown while ZeroClipboard was attempting to inject your data into the clipboard",
  24555. "config-mismatch": "ZeroClipboard configuration does not match Flash's reality",
  24556. "swf-not-found": "The ZeroClipboard SWF object could not be loaded, so please check your `swfPath` configuration and/or network connectivity"
  24557. }
  24558. };
  24559. /**
  24560. * The `name`s of `error` events that can only occur is Flash has at least
  24561. * been able to load the SWF successfully.
  24562. * @private
  24563. */
  24564. var _errorsThatOnlyOccurAfterFlashLoads = [ "flash-unavailable", "flash-degraded", "flash-overdue", "version-mismatch", "config-mismatch", "clipboard-error" ];
  24565. /**
  24566. * The `name`s of `error` events that should likely result in the `_flashState`
  24567. * variable's property values being updated.
  24568. * @private
  24569. */
  24570. var _flashStateErrorNames = [ "flash-disabled", "flash-outdated", "flash-sandboxed", "flash-unavailable", "flash-degraded", "flash-deactivated", "flash-overdue" ];
  24571. /**
  24572. * A RegExp to match the `name` property of `error` events related to Flash.
  24573. * @private
  24574. */
  24575. var _flashStateErrorNameMatchingRegex = new RegExp("^flash-(" + _flashStateErrorNames.map(function(errorName) {
  24576. return errorName.replace(/^flash-/, "");
  24577. }).join("|") + ")$");
  24578. /**
  24579. * A RegExp to match the `name` property of `error` events related to Flash,
  24580. * which is enabled.
  24581. * @private
  24582. */
  24583. var _flashStateEnabledErrorNameMatchingRegex = new RegExp("^flash-(" + _flashStateErrorNames.slice(1).map(function(errorName) {
  24584. return errorName.replace(/^flash-/, "");
  24585. }).join("|") + ")$");
  24586. /**
  24587. * ZeroClipboard configuration defaults for the Core module.
  24588. * @private
  24589. */
  24590. var _globalConfig = {
  24591. swfPath: _getDefaultSwfPath(),
  24592. trustedDomains: window.location.host ? [ window.location.host ] : [],
  24593. cacheBust: true,
  24594. forceEnhancedClipboard: false,
  24595. flashLoadTimeout: 3e4,
  24596. autoActivate: true,
  24597. bubbleEvents: true,
  24598. containerId: "global-zeroclipboard-html-bridge",
  24599. containerClass: "global-zeroclipboard-container",
  24600. swfObjectId: "global-zeroclipboard-flash-bridge",
  24601. hoverClass: "zeroclipboard-is-hover",
  24602. activeClass: "zeroclipboard-is-active",
  24603. forceHandCursor: false,
  24604. title: null,
  24605. zIndex: 999999999
  24606. };
  24607. /**
  24608. * The underlying implementation of `ZeroClipboard.config`.
  24609. * @private
  24610. */
  24611. var _config = function(options) {
  24612. if (typeof options === "object" && options !== null) {
  24613. for (var prop in options) {
  24614. if (_hasOwn.call(options, prop)) {
  24615. if (/^(?:forceHandCursor|title|zIndex|bubbleEvents)$/.test(prop)) {
  24616. _globalConfig[prop] = options[prop];
  24617. } else if (_flashState.bridge == null) {
  24618. if (prop === "containerId" || prop === "swfObjectId") {
  24619. if (_isValidHtml4Id(options[prop])) {
  24620. _globalConfig[prop] = options[prop];
  24621. } else {
  24622. throw new Error("The specified `" + prop + "` value is not valid as an HTML4 Element ID");
  24623. }
  24624. } else {
  24625. _globalConfig[prop] = options[prop];
  24626. }
  24627. }
  24628. }
  24629. }
  24630. }
  24631. if (typeof options === "string" && options) {
  24632. if (_hasOwn.call(_globalConfig, options)) {
  24633. return _globalConfig[options];
  24634. }
  24635. return;
  24636. }
  24637. return _deepCopy(_globalConfig);
  24638. };
  24639. /**
  24640. * The underlying implementation of `ZeroClipboard.state`.
  24641. * @private
  24642. */
  24643. var _state = function() {
  24644. _detectSandbox();
  24645. return {
  24646. browser: _pick(_navigator, [ "userAgent", "platform", "appName" ]),
  24647. flash: _omit(_flashState, [ "bridge" ]),
  24648. zeroclipboard: {
  24649. version: ZeroClipboard.version,
  24650. config: ZeroClipboard.config()
  24651. }
  24652. };
  24653. };
  24654. /**
  24655. * The underlying implementation of `ZeroClipboard.isFlashUnusable`.
  24656. * @private
  24657. */
  24658. var _isFlashUnusable = function() {
  24659. return !!(_flashState.disabled || _flashState.outdated || _flashState.sandboxed || _flashState.unavailable || _flashState.degraded || _flashState.deactivated);
  24660. };
  24661. /**
  24662. * The underlying implementation of `ZeroClipboard.on`.
  24663. * @private
  24664. */
  24665. var _on = function(eventType, listener) {
  24666. var i, len, events, added = {};
  24667. if (typeof eventType === "string" && eventType) {
  24668. events = eventType.toLowerCase().split(/\s+/);
  24669. } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
  24670. for (i in eventType) {
  24671. if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
  24672. ZeroClipboard.on(i, eventType[i]);
  24673. }
  24674. }
  24675. }
  24676. if (events && events.length) {
  24677. for (i = 0, len = events.length; i < len; i++) {
  24678. eventType = events[i].replace(/^on/, "");
  24679. added[eventType] = true;
  24680. if (!_handlers[eventType]) {
  24681. _handlers[eventType] = [];
  24682. }
  24683. _handlers[eventType].push(listener);
  24684. }
  24685. if (added.ready && _flashState.ready) {
  24686. ZeroClipboard.emit({
  24687. type: "ready"
  24688. });
  24689. }
  24690. if (added.error) {
  24691. for (i = 0, len = _flashStateErrorNames.length; i < len; i++) {
  24692. if (_flashState[_flashStateErrorNames[i].replace(/^flash-/, "")] === true) {
  24693. ZeroClipboard.emit({
  24694. type: "error",
  24695. name: _flashStateErrorNames[i]
  24696. });
  24697. break;
  24698. }
  24699. }
  24700. if (_zcSwfVersion !== undefined && ZeroClipboard.version !== _zcSwfVersion) {
  24701. ZeroClipboard.emit({
  24702. type: "error",
  24703. name: "version-mismatch",
  24704. jsVersion: ZeroClipboard.version,
  24705. swfVersion: _zcSwfVersion
  24706. });
  24707. }
  24708. }
  24709. }
  24710. return ZeroClipboard;
  24711. };
  24712. /**
  24713. * The underlying implementation of `ZeroClipboard.off`.
  24714. * @private
  24715. */
  24716. var _off = function(eventType, listener) {
  24717. var i, len, foundIndex, events, perEventHandlers;
  24718. if (arguments.length === 0) {
  24719. events = _keys(_handlers);
  24720. } else if (typeof eventType === "string" && eventType) {
  24721. events = eventType.split(/\s+/);
  24722. } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
  24723. for (i in eventType) {
  24724. if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
  24725. ZeroClipboard.off(i, eventType[i]);
  24726. }
  24727. }
  24728. }
  24729. if (events && events.length) {
  24730. for (i = 0, len = events.length; i < len; i++) {
  24731. eventType = events[i].toLowerCase().replace(/^on/, "");
  24732. perEventHandlers = _handlers[eventType];
  24733. if (perEventHandlers && perEventHandlers.length) {
  24734. if (listener) {
  24735. foundIndex = perEventHandlers.indexOf(listener);
  24736. while (foundIndex !== -1) {
  24737. perEventHandlers.splice(foundIndex, 1);
  24738. foundIndex = perEventHandlers.indexOf(listener, foundIndex);
  24739. }
  24740. } else {
  24741. perEventHandlers.length = 0;
  24742. }
  24743. }
  24744. }
  24745. }
  24746. return ZeroClipboard;
  24747. };
  24748. /**
  24749. * The underlying implementation of `ZeroClipboard.handlers`.
  24750. * @private
  24751. */
  24752. var _listeners = function(eventType) {
  24753. var copy;
  24754. if (typeof eventType === "string" && eventType) {
  24755. copy = _deepCopy(_handlers[eventType]) || null;
  24756. } else {
  24757. copy = _deepCopy(_handlers);
  24758. }
  24759. return copy;
  24760. };
  24761. /**
  24762. * The underlying implementation of `ZeroClipboard.emit`.
  24763. * @private
  24764. */
  24765. var _emit = function(event) {
  24766. var eventCopy, returnVal, tmp;
  24767. event = _createEvent(event);
  24768. if (!event) {
  24769. return;
  24770. }
  24771. if (_preprocessEvent(event)) {
  24772. return;
  24773. }
  24774. if (event.type === "ready" && _flashState.overdue === true) {
  24775. return ZeroClipboard.emit({
  24776. type: "error",
  24777. name: "flash-overdue"
  24778. });
  24779. }
  24780. eventCopy = _extend({}, event);
  24781. _dispatchCallbacks.call(this, eventCopy);
  24782. if (event.type === "copy") {
  24783. tmp = _mapClipDataToFlash(_clipData);
  24784. returnVal = tmp.data;
  24785. _clipDataFormatMap = tmp.formatMap;
  24786. }
  24787. return returnVal;
  24788. };
  24789. /**
  24790. * The underlying implementation of `ZeroClipboard.create`.
  24791. * @private
  24792. */
  24793. var _create = function() {
  24794. var previousState = _flashState.sandboxed;
  24795. _detectSandbox();
  24796. if (typeof _flashState.ready !== "boolean") {
  24797. _flashState.ready = false;
  24798. }
  24799. if (_flashState.sandboxed !== previousState && _flashState.sandboxed === true) {
  24800. _flashState.ready = false;
  24801. ZeroClipboard.emit({
  24802. type: "error",
  24803. name: "flash-sandboxed"
  24804. });
  24805. } else if (!ZeroClipboard.isFlashUnusable() && _flashState.bridge === null) {
  24806. var maxWait = _globalConfig.flashLoadTimeout;
  24807. if (typeof maxWait === "number" && maxWait >= 0) {
  24808. _flashCheckTimeout = _setTimeout(function() {
  24809. if (typeof _flashState.deactivated !== "boolean") {
  24810. _flashState.deactivated = true;
  24811. }
  24812. if (_flashState.deactivated === true) {
  24813. ZeroClipboard.emit({
  24814. type: "error",
  24815. name: "flash-deactivated"
  24816. });
  24817. }
  24818. }, maxWait);
  24819. }
  24820. _flashState.overdue = false;
  24821. _embedSwf();
  24822. }
  24823. };
  24824. /**
  24825. * The underlying implementation of `ZeroClipboard.destroy`.
  24826. * @private
  24827. */
  24828. var _destroy = function() {
  24829. ZeroClipboard.clearData();
  24830. ZeroClipboard.blur();
  24831. ZeroClipboard.emit("destroy");
  24832. _unembedSwf();
  24833. ZeroClipboard.off();
  24834. };
  24835. /**
  24836. * The underlying implementation of `ZeroClipboard.setData`.
  24837. * @private
  24838. */
  24839. var _setData = function(format, data) {
  24840. var dataObj;
  24841. if (typeof format === "object" && format && typeof data === "undefined") {
  24842. dataObj = format;
  24843. ZeroClipboard.clearData();
  24844. } else if (typeof format === "string" && format) {
  24845. dataObj = {};
  24846. dataObj[format] = data;
  24847. } else {
  24848. return;
  24849. }
  24850. for (var dataFormat in dataObj) {
  24851. if (typeof dataFormat === "string" && dataFormat && _hasOwn.call(dataObj, dataFormat) && typeof dataObj[dataFormat] === "string" && dataObj[dataFormat]) {
  24852. _clipData[dataFormat] = dataObj[dataFormat];
  24853. }
  24854. }
  24855. };
  24856. /**
  24857. * The underlying implementation of `ZeroClipboard.clearData`.
  24858. * @private
  24859. */
  24860. var _clearData = function(format) {
  24861. if (typeof format === "undefined") {
  24862. _deleteOwnProperties(_clipData);
  24863. _clipDataFormatMap = null;
  24864. } else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
  24865. delete _clipData[format];
  24866. }
  24867. };
  24868. /**
  24869. * The underlying implementation of `ZeroClipboard.getData`.
  24870. * @private
  24871. */
  24872. var _getData = function(format) {
  24873. if (typeof format === "undefined") {
  24874. return _deepCopy(_clipData);
  24875. } else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
  24876. return _clipData[format];
  24877. }
  24878. };
  24879. /**
  24880. * The underlying implementation of `ZeroClipboard.focus`/`ZeroClipboard.activate`.
  24881. * @private
  24882. */
  24883. var _focus = function(element) {
  24884. if (!(element && element.nodeType === 1)) {
  24885. return;
  24886. }
  24887. if (_currentElement) {
  24888. _removeClass(_currentElement, _globalConfig.activeClass);
  24889. if (_currentElement !== element) {
  24890. _removeClass(_currentElement, _globalConfig.hoverClass);
  24891. }
  24892. }
  24893. _currentElement = element;
  24894. _addClass(element, _globalConfig.hoverClass);
  24895. var newTitle = element.getAttribute("title") || _globalConfig.title;
  24896. if (typeof newTitle === "string" && newTitle) {
  24897. var htmlBridge = _getHtmlBridge(_flashState.bridge);
  24898. if (htmlBridge) {
  24899. htmlBridge.setAttribute("title", newTitle);
  24900. }
  24901. }
  24902. var useHandCursor = _globalConfig.forceHandCursor === true || _getStyle(element, "cursor") === "pointer";
  24903. _setHandCursor(useHandCursor);
  24904. _reposition();
  24905. };
  24906. /**
  24907. * The underlying implementation of `ZeroClipboard.blur`/`ZeroClipboard.deactivate`.
  24908. * @private
  24909. */
  24910. var _blur = function() {
  24911. var htmlBridge = _getHtmlBridge(_flashState.bridge);
  24912. if (htmlBridge) {
  24913. htmlBridge.removeAttribute("title");
  24914. htmlBridge.style.left = "0px";
  24915. htmlBridge.style.top = "-9999px";
  24916. htmlBridge.style.width = "1px";
  24917. htmlBridge.style.height = "1px";
  24918. }
  24919. if (_currentElement) {
  24920. _removeClass(_currentElement, _globalConfig.hoverClass);
  24921. _removeClass(_currentElement, _globalConfig.activeClass);
  24922. _currentElement = null;
  24923. }
  24924. };
  24925. /**
  24926. * The underlying implementation of `ZeroClipboard.activeElement`.
  24927. * @private
  24928. */
  24929. var _activeElement = function() {
  24930. return _currentElement || null;
  24931. };
  24932. /**
  24933. * Check if a value is a valid HTML4 `ID` or `Name` token.
  24934. * @private
  24935. */
  24936. var _isValidHtml4Id = function(id) {
  24937. return typeof id === "string" && id && /^[A-Za-z][A-Za-z0-9_:\-\.]*$/.test(id);
  24938. };
  24939. /**
  24940. * Create or update an `event` object, based on the `eventType`.
  24941. * @private
  24942. */
  24943. var _createEvent = function(event) {
  24944. var eventType;
  24945. if (typeof event === "string" && event) {
  24946. eventType = event;
  24947. event = {};
  24948. } else if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
  24949. eventType = event.type;
  24950. }
  24951. if (!eventType) {
  24952. return;
  24953. }
  24954. eventType = eventType.toLowerCase();
  24955. if (!event.target && (/^(copy|aftercopy|_click)$/.test(eventType) || eventType === "error" && event.name === "clipboard-error")) {
  24956. event.target = _copyTarget;
  24957. }
  24958. _extend(event, {
  24959. type: eventType,
  24960. target: event.target || _currentElement || null,
  24961. relatedTarget: event.relatedTarget || null,
  24962. currentTarget: _flashState && _flashState.bridge || null,
  24963. timeStamp: event.timeStamp || _now() || null
  24964. });
  24965. var msg = _eventMessages[event.type];
  24966. if (event.type === "error" && event.name && msg) {
  24967. msg = msg[event.name];
  24968. }
  24969. if (msg) {
  24970. event.message = msg;
  24971. }
  24972. if (event.type === "ready") {
  24973. _extend(event, {
  24974. target: null,
  24975. version: _flashState.version
  24976. });
  24977. }
  24978. if (event.type === "error") {
  24979. if (_flashStateErrorNameMatchingRegex.test(event.name)) {
  24980. _extend(event, {
  24981. target: null,
  24982. minimumVersion: _minimumFlashVersion
  24983. });
  24984. }
  24985. if (_flashStateEnabledErrorNameMatchingRegex.test(event.name)) {
  24986. _extend(event, {
  24987. version: _flashState.version
  24988. });
  24989. }
  24990. }
  24991. if (event.type === "copy") {
  24992. event.clipboardData = {
  24993. setData: ZeroClipboard.setData,
  24994. clearData: ZeroClipboard.clearData
  24995. };
  24996. }
  24997. if (event.type === "aftercopy") {
  24998. event = _mapClipResultsFromFlash(event, _clipDataFormatMap);
  24999. }
  25000. if (event.target && !event.relatedTarget) {
  25001. event.relatedTarget = _getRelatedTarget(event.target);
  25002. }
  25003. return _addMouseData(event);
  25004. };
  25005. /**
  25006. * Get a relatedTarget from the target's `data-clipboard-target` attribute
  25007. * @private
  25008. */
  25009. var _getRelatedTarget = function(targetEl) {
  25010. var relatedTargetId = targetEl && targetEl.getAttribute && targetEl.getAttribute("data-clipboard-target");
  25011. return relatedTargetId ? _document.getElementById(relatedTargetId) : null;
  25012. };
  25013. /**
  25014. * Add element and position data to `MouseEvent` instances
  25015. * @private
  25016. */
  25017. var _addMouseData = function(event) {
  25018. if (event && /^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
  25019. var srcElement = event.target;
  25020. var fromElement = event.type === "_mouseover" && event.relatedTarget ? event.relatedTarget : undefined;
  25021. var toElement = event.type === "_mouseout" && event.relatedTarget ? event.relatedTarget : undefined;
  25022. var pos = _getElementPosition(srcElement);
  25023. var screenLeft = _window.screenLeft || _window.screenX || 0;
  25024. var screenTop = _window.screenTop || _window.screenY || 0;
  25025. var scrollLeft = _document.body.scrollLeft + _document.documentElement.scrollLeft;
  25026. var scrollTop = _document.body.scrollTop + _document.documentElement.scrollTop;
  25027. var pageX = pos.left + (typeof event._stageX === "number" ? event._stageX : 0);
  25028. var pageY = pos.top + (typeof event._stageY === "number" ? event._stageY : 0);
  25029. var clientX = pageX - scrollLeft;
  25030. var clientY = pageY - scrollTop;
  25031. var screenX = screenLeft + clientX;
  25032. var screenY = screenTop + clientY;
  25033. var moveX = typeof event.movementX === "number" ? event.movementX : 0;
  25034. var moveY = typeof event.movementY === "number" ? event.movementY : 0;
  25035. delete event._stageX;
  25036. delete event._stageY;
  25037. _extend(event, {
  25038. srcElement: srcElement,
  25039. fromElement: fromElement,
  25040. toElement: toElement,
  25041. screenX: screenX,
  25042. screenY: screenY,
  25043. pageX: pageX,
  25044. pageY: pageY,
  25045. clientX: clientX,
  25046. clientY: clientY,
  25047. x: clientX,
  25048. y: clientY,
  25049. movementX: moveX,
  25050. movementY: moveY,
  25051. offsetX: 0,
  25052. offsetY: 0,
  25053. layerX: 0,
  25054. layerY: 0
  25055. });
  25056. }
  25057. return event;
  25058. };
  25059. /**
  25060. * Determine if an event's registered handlers should be execute synchronously or asynchronously.
  25061. *
  25062. * @returns {boolean}
  25063. * @private
  25064. */
  25065. var _shouldPerformAsync = function(event) {
  25066. var eventType = event && typeof event.type === "string" && event.type || "";
  25067. return !/^(?:(?:before)?copy|destroy)$/.test(eventType);
  25068. };
  25069. /**
  25070. * Control if a callback should be executed asynchronously or not.
  25071. *
  25072. * @returns `undefined`
  25073. * @private
  25074. */
  25075. var _dispatchCallback = function(func, context, args, async) {
  25076. if (async) {
  25077. _setTimeout(function() {
  25078. func.apply(context, args);
  25079. }, 0);
  25080. } else {
  25081. func.apply(context, args);
  25082. }
  25083. };
  25084. /**
  25085. * Handle the actual dispatching of events to client instances.
  25086. *
  25087. * @returns `undefined`
  25088. * @private
  25089. */
  25090. var _dispatchCallbacks = function(event) {
  25091. if (!(typeof event === "object" && event && event.type)) {
  25092. return;
  25093. }
  25094. var async = _shouldPerformAsync(event);
  25095. var wildcardTypeHandlers = _handlers["*"] || [];
  25096. var specificTypeHandlers = _handlers[event.type] || [];
  25097. var handlers = wildcardTypeHandlers.concat(specificTypeHandlers);
  25098. if (handlers && handlers.length) {
  25099. var i, len, func, context, eventCopy, originalContext = this;
  25100. for (i = 0, len = handlers.length; i < len; i++) {
  25101. func = handlers[i];
  25102. context = originalContext;
  25103. if (typeof func === "string" && typeof _window[func] === "function") {
  25104. func = _window[func];
  25105. }
  25106. if (typeof func === "object" && func && typeof func.handleEvent === "function") {
  25107. context = func;
  25108. func = func.handleEvent;
  25109. }
  25110. if (typeof func === "function") {
  25111. eventCopy = _extend({}, event);
  25112. _dispatchCallback(func, context, [ eventCopy ], async);
  25113. }
  25114. }
  25115. }
  25116. return this;
  25117. };
  25118. /**
  25119. * Check an `error` event's `name` property to see if Flash has
  25120. * already loaded, which rules out possible `iframe` sandboxing.
  25121. * @private
  25122. */
  25123. var _getSandboxStatusFromErrorEvent = function(event) {
  25124. var isSandboxed = null;
  25125. if (_pageIsFramed === false || event && event.type === "error" && event.name && _errorsThatOnlyOccurAfterFlashLoads.indexOf(event.name) !== -1) {
  25126. isSandboxed = false;
  25127. }
  25128. return isSandboxed;
  25129. };
  25130. /**
  25131. * Preprocess any special behaviors, reactions, or state changes after receiving this event.
  25132. * Executes only once per event emitted, NOT once per client.
  25133. * @private
  25134. */
  25135. var _preprocessEvent = function(event) {
  25136. var element = event.target || _currentElement || null;
  25137. var sourceIsSwf = event._source === "swf";
  25138. delete event._source;
  25139. switch (event.type) {
  25140. case "error":
  25141. var isSandboxed = event.name === "flash-sandboxed" || _getSandboxStatusFromErrorEvent(event);
  25142. if (typeof isSandboxed === "boolean") {
  25143. _flashState.sandboxed = isSandboxed;
  25144. }
  25145. if (_flashStateErrorNames.indexOf(event.name) !== -1) {
  25146. _extend(_flashState, {
  25147. disabled: event.name === "flash-disabled",
  25148. outdated: event.name === "flash-outdated",
  25149. unavailable: event.name === "flash-unavailable",
  25150. degraded: event.name === "flash-degraded",
  25151. deactivated: event.name === "flash-deactivated",
  25152. overdue: event.name === "flash-overdue",
  25153. ready: false
  25154. });
  25155. } else if (event.name === "version-mismatch") {
  25156. _zcSwfVersion = event.swfVersion;
  25157. _extend(_flashState, {
  25158. disabled: false,
  25159. outdated: false,
  25160. unavailable: false,
  25161. degraded: false,
  25162. deactivated: false,
  25163. overdue: false,
  25164. ready: false
  25165. });
  25166. }
  25167. _clearTimeoutsAndPolling();
  25168. break;
  25169. case "ready":
  25170. _zcSwfVersion = event.swfVersion;
  25171. var wasDeactivated = _flashState.deactivated === true;
  25172. _extend(_flashState, {
  25173. disabled: false,
  25174. outdated: false,
  25175. sandboxed: false,
  25176. unavailable: false,
  25177. degraded: false,
  25178. deactivated: false,
  25179. overdue: wasDeactivated,
  25180. ready: !wasDeactivated
  25181. });
  25182. _clearTimeoutsAndPolling();
  25183. break;
  25184. case "beforecopy":
  25185. _copyTarget = element;
  25186. break;
  25187. case "copy":
  25188. var textContent, htmlContent, targetEl = event.relatedTarget;
  25189. if (!(_clipData["text/html"] || _clipData["text/plain"]) && targetEl && (htmlContent = targetEl.value || targetEl.outerHTML || targetEl.innerHTML) && (textContent = targetEl.value || targetEl.textContent || targetEl.innerText)) {
  25190. event.clipboardData.clearData();
  25191. event.clipboardData.setData("text/plain", textContent);
  25192. if (htmlContent !== textContent) {
  25193. event.clipboardData.setData("text/html", htmlContent);
  25194. }
  25195. } else if (!_clipData["text/plain"] && event.target && (textContent = event.target.getAttribute("data-clipboard-text"))) {
  25196. event.clipboardData.clearData();
  25197. event.clipboardData.setData("text/plain", textContent);
  25198. }
  25199. break;
  25200. case "aftercopy":
  25201. _queueEmitClipboardErrors(event);
  25202. ZeroClipboard.clearData();
  25203. if (element && element !== _safeActiveElement() && element.focus) {
  25204. element.focus();
  25205. }
  25206. break;
  25207. case "_mouseover":
  25208. ZeroClipboard.focus(element);
  25209. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  25210. if (element && element !== event.relatedTarget && !_containedBy(event.relatedTarget, element)) {
  25211. _fireMouseEvent(_extend({}, event, {
  25212. type: "mouseenter",
  25213. bubbles: false,
  25214. cancelable: false
  25215. }));
  25216. }
  25217. _fireMouseEvent(_extend({}, event, {
  25218. type: "mouseover"
  25219. }));
  25220. }
  25221. break;
  25222. case "_mouseout":
  25223. ZeroClipboard.blur();
  25224. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  25225. if (element && element !== event.relatedTarget && !_containedBy(event.relatedTarget, element)) {
  25226. _fireMouseEvent(_extend({}, event, {
  25227. type: "mouseleave",
  25228. bubbles: false,
  25229. cancelable: false
  25230. }));
  25231. }
  25232. _fireMouseEvent(_extend({}, event, {
  25233. type: "mouseout"
  25234. }));
  25235. }
  25236. break;
  25237. case "_mousedown":
  25238. _addClass(element, _globalConfig.activeClass);
  25239. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  25240. _fireMouseEvent(_extend({}, event, {
  25241. type: event.type.slice(1)
  25242. }));
  25243. }
  25244. break;
  25245. case "_mouseup":
  25246. _removeClass(element, _globalConfig.activeClass);
  25247. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  25248. _fireMouseEvent(_extend({}, event, {
  25249. type: event.type.slice(1)
  25250. }));
  25251. }
  25252. break;
  25253. case "_click":
  25254. _copyTarget = null;
  25255. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  25256. _fireMouseEvent(_extend({}, event, {
  25257. type: event.type.slice(1)
  25258. }));
  25259. }
  25260. break;
  25261. case "_mousemove":
  25262. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  25263. _fireMouseEvent(_extend({}, event, {
  25264. type: event.type.slice(1)
  25265. }));
  25266. }
  25267. break;
  25268. }
  25269. if (/^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
  25270. return true;
  25271. }
  25272. };
  25273. /**
  25274. * Check an "aftercopy" event for clipboard errors and emit a corresponding "error" event.
  25275. * @private
  25276. */
  25277. var _queueEmitClipboardErrors = function(aftercopyEvent) {
  25278. if (aftercopyEvent.errors && aftercopyEvent.errors.length > 0) {
  25279. var errorEvent = _deepCopy(aftercopyEvent);
  25280. _extend(errorEvent, {
  25281. type: "error",
  25282. name: "clipboard-error"
  25283. });
  25284. delete errorEvent.success;
  25285. _setTimeout(function() {
  25286. ZeroClipboard.emit(errorEvent);
  25287. }, 0);
  25288. }
  25289. };
  25290. /**
  25291. * Dispatch a synthetic MouseEvent.
  25292. *
  25293. * @returns `undefined`
  25294. * @private
  25295. */
  25296. var _fireMouseEvent = function(event) {
  25297. if (!(event && typeof event.type === "string" && event)) {
  25298. return;
  25299. }
  25300. var e, target = event.target || null, doc = target && target.ownerDocument || _document, defaults = {
  25301. view: doc.defaultView || _window,
  25302. canBubble: true,
  25303. cancelable: true,
  25304. detail: event.type === "click" ? 1 : 0,
  25305. button: typeof event.which === "number" ? event.which - 1 : typeof event.button === "number" ? event.button : doc.createEvent ? 0 : 1
  25306. }, args = _extend(defaults, event);
  25307. if (!target) {
  25308. return;
  25309. }
  25310. if (doc.createEvent && target.dispatchEvent) {
  25311. args = [ args.type, args.canBubble, args.cancelable, args.view, args.detail, args.screenX, args.screenY, args.clientX, args.clientY, args.ctrlKey, args.altKey, args.shiftKey, args.metaKey, args.button, args.relatedTarget ];
  25312. e = doc.createEvent("MouseEvents");
  25313. if (e.initMouseEvent) {
  25314. e.initMouseEvent.apply(e, args);
  25315. e._source = "js";
  25316. target.dispatchEvent(e);
  25317. }
  25318. }
  25319. };
  25320. /**
  25321. * Continuously poll the DOM until either:
  25322. * (a) the fallback content becomes visible, or
  25323. * (b) we receive an event from SWF (handled elsewhere)
  25324. *
  25325. * IMPORTANT:
  25326. * This is NOT a necessary check but it can result in significantly faster
  25327. * detection of bad `swfPath` configuration and/or network/server issues [in
  25328. * supported browsers] than waiting for the entire `flashLoadTimeout` duration
  25329. * to elapse before detecting that the SWF cannot be loaded. The detection
  25330. * duration can be anywhere from 10-30 times faster [in supported browsers] by
  25331. * using this approach.
  25332. *
  25333. * @returns `undefined`
  25334. * @private
  25335. */
  25336. var _watchForSwfFallbackContent = function() {
  25337. var maxWait = _globalConfig.flashLoadTimeout;
  25338. if (typeof maxWait === "number" && maxWait >= 0) {
  25339. var pollWait = Math.min(1e3, maxWait / 10);
  25340. var fallbackContentId = _globalConfig.swfObjectId + "_fallbackContent";
  25341. _swfFallbackCheckInterval = _setInterval(function() {
  25342. var el = _document.getElementById(fallbackContentId);
  25343. if (_isElementVisible(el)) {
  25344. _clearTimeoutsAndPolling();
  25345. _flashState.deactivated = null;
  25346. ZeroClipboard.emit({
  25347. type: "error",
  25348. name: "swf-not-found"
  25349. });
  25350. }
  25351. }, pollWait);
  25352. }
  25353. };
  25354. /**
  25355. * Create the HTML bridge element to embed the Flash object into.
  25356. * @private
  25357. */
  25358. var _createHtmlBridge = function() {
  25359. var container = _document.createElement("div");
  25360. container.id = _globalConfig.containerId;
  25361. container.className = _globalConfig.containerClass;
  25362. container.style.position = "absolute";
  25363. container.style.left = "0px";
  25364. container.style.top = "-9999px";
  25365. container.style.width = "1px";
  25366. container.style.height = "1px";
  25367. container.style.zIndex = "" + _getSafeZIndex(_globalConfig.zIndex);
  25368. return container;
  25369. };
  25370. /**
  25371. * Get the HTML element container that wraps the Flash bridge object/element.
  25372. * @private
  25373. */
  25374. var _getHtmlBridge = function(flashBridge) {
  25375. var htmlBridge = flashBridge && flashBridge.parentNode;
  25376. while (htmlBridge && htmlBridge.nodeName === "OBJECT" && htmlBridge.parentNode) {
  25377. htmlBridge = htmlBridge.parentNode;
  25378. }
  25379. return htmlBridge || null;
  25380. };
  25381. /**
  25382. * Create the SWF object.
  25383. *
  25384. * @returns The SWF object reference.
  25385. * @private
  25386. */
  25387. var _embedSwf = function() {
  25388. var len, flashBridge = _flashState.bridge, container = _getHtmlBridge(flashBridge);
  25389. if (!flashBridge) {
  25390. var allowScriptAccess = _determineScriptAccess(_window.location.host, _globalConfig);
  25391. var allowNetworking = allowScriptAccess === "never" ? "none" : "all";
  25392. var flashvars = _vars(_extend({
  25393. jsVersion: ZeroClipboard.version
  25394. }, _globalConfig));
  25395. var swfUrl = _globalConfig.swfPath + _cacheBust(_globalConfig.swfPath, _globalConfig);
  25396. container = _createHtmlBridge();
  25397. var divToBeReplaced = _document.createElement("div");
  25398. container.appendChild(divToBeReplaced);
  25399. _document.body.appendChild(container);
  25400. var tmpDiv = _document.createElement("div");
  25401. var usingActiveX = _flashState.pluginType === "activex";
  25402. tmpDiv.innerHTML = '<object id="' + _globalConfig.swfObjectId + '" name="' + _globalConfig.swfObjectId + '" ' + 'width="100%" height="100%" ' + (usingActiveX ? 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' : 'type="application/x-shockwave-flash" data="' + swfUrl + '"') + ">" + (usingActiveX ? '<param name="movie" value="' + swfUrl + '"/>' : "") + '<param name="allowScriptAccess" value="' + allowScriptAccess + '"/>' + '<param name="allowNetworking" value="' + allowNetworking + '"/>' + '<param name="menu" value="false"/>' + '<param name="wmode" value="transparent"/>' + '<param name="flashvars" value="' + flashvars + '"/>' + '<div id="' + _globalConfig.swfObjectId + '_fallbackContent">&nbsp;</div>' + "</object>";
  25403. flashBridge = tmpDiv.firstChild;
  25404. tmpDiv = null;
  25405. _unwrap(flashBridge).ZeroClipboard = ZeroClipboard;
  25406. container.replaceChild(flashBridge, divToBeReplaced);
  25407. _watchForSwfFallbackContent();
  25408. }
  25409. if (!flashBridge) {
  25410. flashBridge = _document[_globalConfig.swfObjectId];
  25411. if (flashBridge && (len = flashBridge.length)) {
  25412. flashBridge = flashBridge[len - 1];
  25413. }
  25414. if (!flashBridge && container) {
  25415. flashBridge = container.firstChild;
  25416. }
  25417. }
  25418. _flashState.bridge = flashBridge || null;
  25419. return flashBridge;
  25420. };
  25421. /**
  25422. * Destroy the SWF object.
  25423. * @private
  25424. */
  25425. var _unembedSwf = function() {
  25426. var flashBridge = _flashState.bridge;
  25427. if (flashBridge) {
  25428. var htmlBridge = _getHtmlBridge(flashBridge);
  25429. if (htmlBridge) {
  25430. if (_flashState.pluginType === "activex" && "readyState" in flashBridge) {
  25431. flashBridge.style.display = "none";
  25432. (function removeSwfFromIE() {
  25433. if (flashBridge.readyState === 4) {
  25434. for (var prop in flashBridge) {
  25435. if (typeof flashBridge[prop] === "function") {
  25436. flashBridge[prop] = null;
  25437. }
  25438. }
  25439. if (flashBridge.parentNode) {
  25440. flashBridge.parentNode.removeChild(flashBridge);
  25441. }
  25442. if (htmlBridge.parentNode) {
  25443. htmlBridge.parentNode.removeChild(htmlBridge);
  25444. }
  25445. } else {
  25446. _setTimeout(removeSwfFromIE, 10);
  25447. }
  25448. })();
  25449. } else {
  25450. if (flashBridge.parentNode) {
  25451. flashBridge.parentNode.removeChild(flashBridge);
  25452. }
  25453. if (htmlBridge.parentNode) {
  25454. htmlBridge.parentNode.removeChild(htmlBridge);
  25455. }
  25456. }
  25457. }
  25458. _clearTimeoutsAndPolling();
  25459. _flashState.ready = null;
  25460. _flashState.bridge = null;
  25461. _flashState.deactivated = null;
  25462. _zcSwfVersion = undefined;
  25463. }
  25464. };
  25465. /**
  25466. * Map the data format names of the "clipData" to Flash-friendly names.
  25467. *
  25468. * @returns A new transformed object.
  25469. * @private
  25470. */
  25471. var _mapClipDataToFlash = function(clipData) {
  25472. var newClipData = {}, formatMap = {};
  25473. if (!(typeof clipData === "object" && clipData)) {
  25474. return;
  25475. }
  25476. for (var dataFormat in clipData) {
  25477. if (dataFormat && _hasOwn.call(clipData, dataFormat) && typeof clipData[dataFormat] === "string" && clipData[dataFormat]) {
  25478. switch (dataFormat.toLowerCase()) {
  25479. case "text/plain":
  25480. case "text":
  25481. case "air:text":
  25482. case "flash:text":
  25483. newClipData.text = clipData[dataFormat];
  25484. formatMap.text = dataFormat;
  25485. break;
  25486. case "text/html":
  25487. case "html":
  25488. case "air:html":
  25489. case "flash:html":
  25490. newClipData.html = clipData[dataFormat];
  25491. formatMap.html = dataFormat;
  25492. break;
  25493. case "application/rtf":
  25494. case "text/rtf":
  25495. case "rtf":
  25496. case "richtext":
  25497. case "air:rtf":
  25498. case "flash:rtf":
  25499. newClipData.rtf = clipData[dataFormat];
  25500. formatMap.rtf = dataFormat;
  25501. break;
  25502. default:
  25503. break;
  25504. }
  25505. }
  25506. }
  25507. return {
  25508. data: newClipData,
  25509. formatMap: formatMap
  25510. };
  25511. };
  25512. /**
  25513. * Map the data format names from Flash-friendly names back to their original "clipData" names (via a format mapping).
  25514. *
  25515. * @returns A new transformed object.
  25516. * @private
  25517. */
  25518. var _mapClipResultsFromFlash = function(clipResults, formatMap) {
  25519. if (!(typeof clipResults === "object" && clipResults && typeof formatMap === "object" && formatMap)) {
  25520. return clipResults;
  25521. }
  25522. var newResults = {};
  25523. for (var prop in clipResults) {
  25524. if (_hasOwn.call(clipResults, prop)) {
  25525. if (prop === "errors") {
  25526. newResults[prop] = clipResults[prop] ? clipResults[prop].slice() : [];
  25527. for (var i = 0, len = newResults[prop].length; i < len; i++) {
  25528. newResults[prop][i].format = formatMap[newResults[prop][i].format];
  25529. }
  25530. } else if (prop !== "success" && prop !== "data") {
  25531. newResults[prop] = clipResults[prop];
  25532. } else {
  25533. newResults[prop] = {};
  25534. var tmpHash = clipResults[prop];
  25535. for (var dataFormat in tmpHash) {
  25536. if (dataFormat && _hasOwn.call(tmpHash, dataFormat) && _hasOwn.call(formatMap, dataFormat)) {
  25537. newResults[prop][formatMap[dataFormat]] = tmpHash[dataFormat];
  25538. }
  25539. }
  25540. }
  25541. }
  25542. }
  25543. return newResults;
  25544. };
  25545. /**
  25546. * Will look at a path, and will create a "?noCache={time}" or "&noCache={time}"
  25547. * query param string to return. Does NOT append that string to the original path.
  25548. * This is useful because ExternalInterface often breaks when a Flash SWF is cached.
  25549. *
  25550. * @returns The `noCache` query param with necessary "?"/"&" prefix.
  25551. * @private
  25552. */
  25553. var _cacheBust = function(path, options) {
  25554. var cacheBust = options == null || options && options.cacheBust === true;
  25555. if (cacheBust) {
  25556. return (path.indexOf("?") === -1 ? "?" : "&") + "noCache=" + _now();
  25557. } else {
  25558. return "";
  25559. }
  25560. };
  25561. /**
  25562. * Creates a query string for the FlashVars param.
  25563. * Does NOT include the cache-busting query param.
  25564. *
  25565. * @returns FlashVars query string
  25566. * @private
  25567. */
  25568. var _vars = function(options) {
  25569. var i, len, domain, domains, str = "", trustedOriginsExpanded = [];
  25570. if (options.trustedDomains) {
  25571. if (typeof options.trustedDomains === "string") {
  25572. domains = [ options.trustedDomains ];
  25573. } else if (typeof options.trustedDomains === "object" && "length" in options.trustedDomains) {
  25574. domains = options.trustedDomains;
  25575. }
  25576. }
  25577. if (domains && domains.length) {
  25578. for (i = 0, len = domains.length; i < len; i++) {
  25579. if (_hasOwn.call(domains, i) && domains[i] && typeof domains[i] === "string") {
  25580. domain = _extractDomain(domains[i]);
  25581. if (!domain) {
  25582. continue;
  25583. }
  25584. if (domain === "*") {
  25585. trustedOriginsExpanded.length = 0;
  25586. trustedOriginsExpanded.push(domain);
  25587. break;
  25588. }
  25589. trustedOriginsExpanded.push.apply(trustedOriginsExpanded, [ domain, "//" + domain, _window.location.protocol + "//" + domain ]);
  25590. }
  25591. }
  25592. }
  25593. if (trustedOriginsExpanded.length) {
  25594. str += "trustedOrigins=" + _encodeURIComponent(trustedOriginsExpanded.join(","));
  25595. }
  25596. if (options.forceEnhancedClipboard === true) {
  25597. str += (str ? "&" : "") + "forceEnhancedClipboard=true";
  25598. }
  25599. if (typeof options.swfObjectId === "string" && options.swfObjectId) {
  25600. str += (str ? "&" : "") + "swfObjectId=" + _encodeURIComponent(options.swfObjectId);
  25601. }
  25602. if (typeof options.jsVersion === "string" && options.jsVersion) {
  25603. str += (str ? "&" : "") + "jsVersion=" + _encodeURIComponent(options.jsVersion);
  25604. }
  25605. return str;
  25606. };
  25607. /**
  25608. * Extract the domain (e.g. "github.com") from an origin (e.g. "https://github.com") or
  25609. * URL (e.g. "https://github.com/zeroclipboard/zeroclipboard/").
  25610. *
  25611. * @returns the domain
  25612. * @private
  25613. */
  25614. var _extractDomain = function(originOrUrl) {
  25615. if (originOrUrl == null || originOrUrl === "") {
  25616. return null;
  25617. }
  25618. originOrUrl = originOrUrl.replace(/^\s+|\s+$/g, "");
  25619. if (originOrUrl === "") {
  25620. return null;
  25621. }
  25622. var protocolIndex = originOrUrl.indexOf("//");
  25623. originOrUrl = protocolIndex === -1 ? originOrUrl : originOrUrl.slice(protocolIndex + 2);
  25624. var pathIndex = originOrUrl.indexOf("/");
  25625. originOrUrl = pathIndex === -1 ? originOrUrl : protocolIndex === -1 || pathIndex === 0 ? null : originOrUrl.slice(0, pathIndex);
  25626. if (originOrUrl && originOrUrl.slice(-4).toLowerCase() === ".swf") {
  25627. return null;
  25628. }
  25629. return originOrUrl || null;
  25630. };
  25631. /**
  25632. * Set `allowScriptAccess` based on `trustedDomains` and `window.location.host` vs. `swfPath`.
  25633. *
  25634. * @returns The appropriate script access level.
  25635. * @private
  25636. */
  25637. var _determineScriptAccess = function() {
  25638. var _extractAllDomains = function(origins) {
  25639. var i, len, tmp, resultsArray = [];
  25640. if (typeof origins === "string") {
  25641. origins = [ origins ];
  25642. }
  25643. if (!(typeof origins === "object" && origins && typeof origins.length === "number")) {
  25644. return resultsArray;
  25645. }
  25646. for (i = 0, len = origins.length; i < len; i++) {
  25647. if (_hasOwn.call(origins, i) && (tmp = _extractDomain(origins[i]))) {
  25648. if (tmp === "*") {
  25649. resultsArray.length = 0;
  25650. resultsArray.push("*");
  25651. break;
  25652. }
  25653. if (resultsArray.indexOf(tmp) === -1) {
  25654. resultsArray.push(tmp);
  25655. }
  25656. }
  25657. }
  25658. return resultsArray;
  25659. };
  25660. return function(currentDomain, configOptions) {
  25661. var swfDomain = _extractDomain(configOptions.swfPath);
  25662. if (swfDomain === null) {
  25663. swfDomain = currentDomain;
  25664. }
  25665. var trustedDomains = _extractAllDomains(configOptions.trustedDomains);
  25666. var len = trustedDomains.length;
  25667. if (len > 0) {
  25668. if (len === 1 && trustedDomains[0] === "*") {
  25669. return "always";
  25670. }
  25671. if (trustedDomains.indexOf(currentDomain) !== -1) {
  25672. if (len === 1 && currentDomain === swfDomain) {
  25673. return "sameDomain";
  25674. }
  25675. return "always";
  25676. }
  25677. }
  25678. return "never";
  25679. };
  25680. }();
  25681. /**
  25682. * Get the currently active/focused DOM element.
  25683. *
  25684. * @returns the currently active/focused element, or `null`
  25685. * @private
  25686. */
  25687. var _safeActiveElement = function() {
  25688. try {
  25689. return _document.activeElement;
  25690. } catch (err) {
  25691. return null;
  25692. }
  25693. };
  25694. /**
  25695. * Add a class to an element, if it doesn't already have it.
  25696. *
  25697. * @returns The element, with its new class added.
  25698. * @private
  25699. */
  25700. var _addClass = function(element, value) {
  25701. var c, cl, className, classNames = [];
  25702. if (typeof value === "string" && value) {
  25703. classNames = value.split(/\s+/);
  25704. }
  25705. if (element && element.nodeType === 1 && classNames.length > 0) {
  25706. if (element.classList) {
  25707. for (c = 0, cl = classNames.length; c < cl; c++) {
  25708. element.classList.add(classNames[c]);
  25709. }
  25710. } else if (element.hasOwnProperty("className")) {
  25711. className = " " + element.className + " ";
  25712. for (c = 0, cl = classNames.length; c < cl; c++) {
  25713. if (className.indexOf(" " + classNames[c] + " ") === -1) {
  25714. className += classNames[c] + " ";
  25715. }
  25716. }
  25717. element.className = className.replace(/^\s+|\s+$/g, "");
  25718. }
  25719. }
  25720. return element;
  25721. };
  25722. /**
  25723. * Remove a class from an element, if it has it.
  25724. *
  25725. * @returns The element, with its class removed.
  25726. * @private
  25727. */
  25728. var _removeClass = function(element, value) {
  25729. var c, cl, className, classNames = [];
  25730. if (typeof value === "string" && value) {
  25731. classNames = value.split(/\s+/);
  25732. }
  25733. if (element && element.nodeType === 1 && classNames.length > 0) {
  25734. if (element.classList && element.classList.length > 0) {
  25735. for (c = 0, cl = classNames.length; c < cl; c++) {
  25736. element.classList.remove(classNames[c]);
  25737. }
  25738. } else if (element.className) {
  25739. className = (" " + element.className + " ").replace(/[\r\n\t]/g, " ");
  25740. for (c = 0, cl = classNames.length; c < cl; c++) {
  25741. className = className.replace(" " + classNames[c] + " ", " ");
  25742. }
  25743. element.className = className.replace(/^\s+|\s+$/g, "");
  25744. }
  25745. }
  25746. return element;
  25747. };
  25748. /**
  25749. * Attempt to interpret the element's CSS styling. If `prop` is `"cursor"`,
  25750. * then we assume that it should be a hand ("pointer") cursor if the element
  25751. * is an anchor element ("a" tag).
  25752. *
  25753. * @returns The computed style property.
  25754. * @private
  25755. */
  25756. var _getStyle = function(el, prop) {
  25757. var value = _getComputedStyle(el, null).getPropertyValue(prop);
  25758. if (prop === "cursor") {
  25759. if (!value || value === "auto") {
  25760. if (el.nodeName === "A") {
  25761. return "pointer";
  25762. }
  25763. }
  25764. }
  25765. return value;
  25766. };
  25767. /**
  25768. * Get the absolutely positioned coordinates of a DOM element.
  25769. *
  25770. * @returns Object containing the element's position, width, and height.
  25771. * @private
  25772. */
  25773. var _getElementPosition = function(el) {
  25774. var pos = {
  25775. left: 0,
  25776. top: 0,
  25777. width: 0,
  25778. height: 0
  25779. };
  25780. if (el.getBoundingClientRect) {
  25781. var elRect = el.getBoundingClientRect();
  25782. var pageXOffset = _window.pageXOffset;
  25783. var pageYOffset = _window.pageYOffset;
  25784. var leftBorderWidth = _document.documentElement.clientLeft || 0;
  25785. var topBorderWidth = _document.documentElement.clientTop || 0;
  25786. var leftBodyOffset = 0;
  25787. var topBodyOffset = 0;
  25788. if (_getStyle(_document.body, "position") === "relative") {
  25789. var bodyRect = _document.body.getBoundingClientRect();
  25790. var htmlRect = _document.documentElement.getBoundingClientRect();
  25791. leftBodyOffset = bodyRect.left - htmlRect.left || 0;
  25792. topBodyOffset = bodyRect.top - htmlRect.top || 0;
  25793. }
  25794. pos.left = elRect.left + pageXOffset - leftBorderWidth - leftBodyOffset;
  25795. pos.top = elRect.top + pageYOffset - topBorderWidth - topBodyOffset;
  25796. pos.width = "width" in elRect ? elRect.width : elRect.right - elRect.left;
  25797. pos.height = "height" in elRect ? elRect.height : elRect.bottom - elRect.top;
  25798. }
  25799. return pos;
  25800. };
  25801. /**
  25802. * Determine is an element is visible somewhere within the document (page).
  25803. *
  25804. * @returns Boolean
  25805. * @private
  25806. */
  25807. var _isElementVisible = function(el) {
  25808. if (!el) {
  25809. return false;
  25810. }
  25811. var styles = _getComputedStyle(el, null);
  25812. var hasCssHeight = _parseFloat(styles.height) > 0;
  25813. var hasCssWidth = _parseFloat(styles.width) > 0;
  25814. var hasCssTop = _parseFloat(styles.top) >= 0;
  25815. var hasCssLeft = _parseFloat(styles.left) >= 0;
  25816. var cssKnows = hasCssHeight && hasCssWidth && hasCssTop && hasCssLeft;
  25817. var rect = cssKnows ? null : _getElementPosition(el);
  25818. var isVisible = styles.display !== "none" && styles.visibility !== "collapse" && (cssKnows || !!rect && (hasCssHeight || rect.height > 0) && (hasCssWidth || rect.width > 0) && (hasCssTop || rect.top >= 0) && (hasCssLeft || rect.left >= 0));
  25819. return isVisible;
  25820. };
  25821. /**
  25822. * Clear all existing timeouts and interval polling delegates.
  25823. *
  25824. * @returns `undefined`
  25825. * @private
  25826. */
  25827. var _clearTimeoutsAndPolling = function() {
  25828. _clearTimeout(_flashCheckTimeout);
  25829. _flashCheckTimeout = 0;
  25830. _clearInterval(_swfFallbackCheckInterval);
  25831. _swfFallbackCheckInterval = 0;
  25832. };
  25833. /**
  25834. * Reposition the Flash object to cover the currently activated element.
  25835. *
  25836. * @returns `undefined`
  25837. * @private
  25838. */
  25839. var _reposition = function() {
  25840. var htmlBridge;
  25841. if (_currentElement && (htmlBridge = _getHtmlBridge(_flashState.bridge))) {
  25842. var pos = _getElementPosition(_currentElement);
  25843. _extend(htmlBridge.style, {
  25844. width: pos.width + "px",
  25845. height: pos.height + "px",
  25846. top: pos.top + "px",
  25847. left: pos.left + "px",
  25848. zIndex: "" + _getSafeZIndex(_globalConfig.zIndex)
  25849. });
  25850. }
  25851. };
  25852. /**
  25853. * Sends a signal to the Flash object to display the hand cursor if `true`.
  25854. *
  25855. * @returns `undefined`
  25856. * @private
  25857. */
  25858. var _setHandCursor = function(enabled) {
  25859. if (_flashState.ready === true) {
  25860. if (_flashState.bridge && typeof _flashState.bridge.setHandCursor === "function") {
  25861. _flashState.bridge.setHandCursor(enabled);
  25862. } else {
  25863. _flashState.ready = false;
  25864. }
  25865. }
  25866. };
  25867. /**
  25868. * Get a safe value for `zIndex`
  25869. *
  25870. * @returns an integer, or "auto"
  25871. * @private
  25872. */
  25873. var _getSafeZIndex = function(val) {
  25874. if (/^(?:auto|inherit)$/.test(val)) {
  25875. return val;
  25876. }
  25877. var zIndex;
  25878. if (typeof val === "number" && !_isNaN(val)) {
  25879. zIndex = val;
  25880. } else if (typeof val === "string") {
  25881. zIndex = _getSafeZIndex(_parseInt(val, 10));
  25882. }
  25883. return typeof zIndex === "number" ? zIndex : "auto";
  25884. };
  25885. /**
  25886. * Attempt to detect if ZeroClipboard is executing inside of a sandboxed iframe.
  25887. * If it is, Flash Player cannot be used, so ZeroClipboard is dead in the water.
  25888. *
  25889. * @see {@link http://lists.w3.org/Archives/Public/public-whatwg-archive/2014Dec/0002.html}
  25890. * @see {@link https://github.com/zeroclipboard/zeroclipboard/issues/511}
  25891. * @see {@link http://zeroclipboard.org/test-iframes.html}
  25892. *
  25893. * @returns `true` (is sandboxed), `false` (is not sandboxed), or `null` (uncertain)
  25894. * @private
  25895. */
  25896. var _detectSandbox = function(doNotReassessFlashSupport) {
  25897. var effectiveScriptOrigin, frame, frameError, previousState = _flashState.sandboxed, isSandboxed = null;
  25898. doNotReassessFlashSupport = doNotReassessFlashSupport === true;
  25899. if (_pageIsFramed === false) {
  25900. isSandboxed = false;
  25901. } else {
  25902. try {
  25903. frame = window.frameElement || null;
  25904. } catch (e) {
  25905. frameError = {
  25906. name: e.name,
  25907. message: e.message
  25908. };
  25909. }
  25910. if (frame && frame.nodeType === 1 && frame.nodeName === "IFRAME") {
  25911. try {
  25912. isSandboxed = frame.hasAttribute("sandbox");
  25913. } catch (e) {
  25914. isSandboxed = null;
  25915. }
  25916. } else {
  25917. try {
  25918. effectiveScriptOrigin = document.domain || null;
  25919. } catch (e) {
  25920. effectiveScriptOrigin = null;
  25921. }
  25922. if (effectiveScriptOrigin === null || frameError && frameError.name === "SecurityError" && /(^|[\s\(\[@])sandbox(es|ed|ing|[\s\.,!\)\]@]|$)/.test(frameError.message.toLowerCase())) {
  25923. isSandboxed = true;
  25924. }
  25925. }
  25926. }
  25927. _flashState.sandboxed = isSandboxed;
  25928. if (previousState !== isSandboxed && !doNotReassessFlashSupport) {
  25929. _detectFlashSupport(_ActiveXObject);
  25930. }
  25931. return isSandboxed;
  25932. };
  25933. /**
  25934. * Detect the Flash Player status, version, and plugin type.
  25935. *
  25936. * @see {@link https://code.google.com/p/doctype-mirror/wiki/ArticleDetectFlash#The_code}
  25937. * @see {@link http://stackoverflow.com/questions/12866060/detecting-pepper-ppapi-flash-with-javascript}
  25938. *
  25939. * @returns `undefined`
  25940. * @private
  25941. */
  25942. var _detectFlashSupport = function(ActiveXObject) {
  25943. var plugin, ax, mimeType, hasFlash = false, isActiveX = false, isPPAPI = false, flashVersion = "";
  25944. /**
  25945. * Derived from Apple's suggested sniffer.
  25946. * @param {String} desc e.g. "Shockwave Flash 7.0 r61"
  25947. * @returns {String} "7.0.61"
  25948. * @private
  25949. */
  25950. function parseFlashVersion(desc) {
  25951. var matches = desc.match(/[\d]+/g);
  25952. matches.length = 3;
  25953. return matches.join(".");
  25954. }
  25955. function isPepperFlash(flashPlayerFileName) {
  25956. return !!flashPlayerFileName && (flashPlayerFileName = flashPlayerFileName.toLowerCase()) && (/^(pepflashplayer\.dll|libpepflashplayer\.so|pepperflashplayer\.plugin)$/.test(flashPlayerFileName) || flashPlayerFileName.slice(-13) === "chrome.plugin");
  25957. }
  25958. function inspectPlugin(plugin) {
  25959. if (plugin) {
  25960. hasFlash = true;
  25961. if (plugin.version) {
  25962. flashVersion = parseFlashVersion(plugin.version);
  25963. }
  25964. if (!flashVersion && plugin.description) {
  25965. flashVersion = parseFlashVersion(plugin.description);
  25966. }
  25967. if (plugin.filename) {
  25968. isPPAPI = isPepperFlash(plugin.filename);
  25969. }
  25970. }
  25971. }
  25972. if (_navigator.plugins && _navigator.plugins.length) {
  25973. plugin = _navigator.plugins["Shockwave Flash"];
  25974. inspectPlugin(plugin);
  25975. if (_navigator.plugins["Shockwave Flash 2.0"]) {
  25976. hasFlash = true;
  25977. flashVersion = "2.0.0.11";
  25978. }
  25979. } else if (_navigator.mimeTypes && _navigator.mimeTypes.length) {
  25980. mimeType = _navigator.mimeTypes["application/x-shockwave-flash"];
  25981. plugin = mimeType && mimeType.enabledPlugin;
  25982. inspectPlugin(plugin);
  25983. } else if (typeof ActiveXObject !== "undefined") {
  25984. isActiveX = true;
  25985. try {
  25986. ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
  25987. hasFlash = true;
  25988. flashVersion = parseFlashVersion(ax.GetVariable("$version"));
  25989. } catch (e1) {
  25990. try {
  25991. ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
  25992. hasFlash = true;
  25993. flashVersion = "6.0.21";
  25994. } catch (e2) {
  25995. try {
  25996. ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  25997. hasFlash = true;
  25998. flashVersion = parseFlashVersion(ax.GetVariable("$version"));
  25999. } catch (e3) {
  26000. isActiveX = false;
  26001. }
  26002. }
  26003. }
  26004. }
  26005. _flashState.disabled = hasFlash !== true;
  26006. _flashState.outdated = flashVersion && _parseFloat(flashVersion) < _parseFloat(_minimumFlashVersion);
  26007. _flashState.version = flashVersion || "0.0.0";
  26008. _flashState.pluginType = isPPAPI ? "pepper" : isActiveX ? "activex" : hasFlash ? "netscape" : "unknown";
  26009. };
  26010. /**
  26011. * Invoke the Flash detection algorithms immediately upon inclusion so we're not waiting later.
  26012. */
  26013. _detectFlashSupport(_ActiveXObject);
  26014. /**
  26015. * Always assess the `sandboxed` state of the page at important Flash-related moments.
  26016. */
  26017. _detectSandbox(true);
  26018. /**
  26019. * A shell constructor for `ZeroClipboard` client instances.
  26020. *
  26021. * @constructor
  26022. */
  26023. var ZeroClipboard = function() {
  26024. if (!(this instanceof ZeroClipboard)) {
  26025. return new ZeroClipboard();
  26026. }
  26027. if (typeof ZeroClipboard._createClient === "function") {
  26028. ZeroClipboard._createClient.apply(this, _args(arguments));
  26029. }
  26030. };
  26031. /**
  26032. * The ZeroClipboard library's version number.
  26033. *
  26034. * @static
  26035. * @readonly
  26036. * @property {string}
  26037. */
  26038. _defineProperty(ZeroClipboard, "version", {
  26039. value: "2.2.0",
  26040. writable: false,
  26041. configurable: true,
  26042. enumerable: true
  26043. });
  26044. /**
  26045. * Update or get a copy of the ZeroClipboard global configuration.
  26046. * Returns a copy of the current/updated configuration.
  26047. *
  26048. * @returns Object
  26049. * @static
  26050. */
  26051. ZeroClipboard.config = function() {
  26052. return _config.apply(this, _args(arguments));
  26053. };
  26054. /**
  26055. * Diagnostic method that describes the state of the browser, Flash Player, and ZeroClipboard.
  26056. *
  26057. * @returns Object
  26058. * @static
  26059. */
  26060. ZeroClipboard.state = function() {
  26061. return _state.apply(this, _args(arguments));
  26062. };
  26063. /**
  26064. * Check if Flash is unusable for any reason: disabled, outdated, deactivated, etc.
  26065. *
  26066. * @returns Boolean
  26067. * @static
  26068. */
  26069. ZeroClipboard.isFlashUnusable = function() {
  26070. return _isFlashUnusable.apply(this, _args(arguments));
  26071. };
  26072. /**
  26073. * Register an event listener.
  26074. *
  26075. * @returns `ZeroClipboard`
  26076. * @static
  26077. */
  26078. ZeroClipboard.on = function() {
  26079. return _on.apply(this, _args(arguments));
  26080. };
  26081. /**
  26082. * Unregister an event listener.
  26083. * If no `listener` function/object is provided, it will unregister all listeners for the provided `eventType`.
  26084. * If no `eventType` is provided, it will unregister all listeners for every event type.
  26085. *
  26086. * @returns `ZeroClipboard`
  26087. * @static
  26088. */
  26089. ZeroClipboard.off = function() {
  26090. return _off.apply(this, _args(arguments));
  26091. };
  26092. /**
  26093. * Retrieve event listeners for an `eventType`.
  26094. * If no `eventType` is provided, it will retrieve all listeners for every event type.
  26095. *
  26096. * @returns array of listeners for the `eventType`; if no `eventType`, then a map/hash object of listeners for all event types; or `null`
  26097. */
  26098. ZeroClipboard.handlers = function() {
  26099. return _listeners.apply(this, _args(arguments));
  26100. };
  26101. /**
  26102. * Event emission receiver from the Flash object, forwarding to any registered JavaScript event listeners.
  26103. *
  26104. * @returns For the "copy" event, returns the Flash-friendly "clipData" object; otherwise `undefined`.
  26105. * @static
  26106. */
  26107. ZeroClipboard.emit = function() {
  26108. return _emit.apply(this, _args(arguments));
  26109. };
  26110. /**
  26111. * Create and embed the Flash object.
  26112. *
  26113. * @returns The Flash object
  26114. * @static
  26115. */
  26116. ZeroClipboard.create = function() {
  26117. return _create.apply(this, _args(arguments));
  26118. };
  26119. /**
  26120. * Self-destruct and clean up everything, including the embedded Flash object.
  26121. *
  26122. * @returns `undefined`
  26123. * @static
  26124. */
  26125. ZeroClipboard.destroy = function() {
  26126. return _destroy.apply(this, _args(arguments));
  26127. };
  26128. /**
  26129. * Set the pending data for clipboard injection.
  26130. *
  26131. * @returns `undefined`
  26132. * @static
  26133. */
  26134. ZeroClipboard.setData = function() {
  26135. return _setData.apply(this, _args(arguments));
  26136. };
  26137. /**
  26138. * Clear the pending data for clipboard injection.
  26139. * If no `format` is provided, all pending data formats will be cleared.
  26140. *
  26141. * @returns `undefined`
  26142. * @static
  26143. */
  26144. ZeroClipboard.clearData = function() {
  26145. return _clearData.apply(this, _args(arguments));
  26146. };
  26147. /**
  26148. * Get a copy of the pending data for clipboard injection.
  26149. * If no `format` is provided, a copy of ALL pending data formats will be returned.
  26150. *
  26151. * @returns `String` or `Object`
  26152. * @static
  26153. */
  26154. ZeroClipboard.getData = function() {
  26155. return _getData.apply(this, _args(arguments));
  26156. };
  26157. /**
  26158. * Sets the current HTML object that the Flash object should overlay. This will put the global
  26159. * Flash object on top of the current element; depending on the setup, this may also set the
  26160. * pending clipboard text data as well as the Flash object's wrapping element's title attribute
  26161. * based on the underlying HTML element and ZeroClipboard configuration.
  26162. *
  26163. * @returns `undefined`
  26164. * @static
  26165. */
  26166. ZeroClipboard.focus = ZeroClipboard.activate = function() {
  26167. return _focus.apply(this, _args(arguments));
  26168. };
  26169. /**
  26170. * Un-overlays the Flash object. This will put the global Flash object off-screen; depending on
  26171. * the setup, this may also unset the Flash object's wrapping element's title attribute based on
  26172. * the underlying HTML element and ZeroClipboard configuration.
  26173. *
  26174. * @returns `undefined`
  26175. * @static
  26176. */
  26177. ZeroClipboard.blur = ZeroClipboard.deactivate = function() {
  26178. return _blur.apply(this, _args(arguments));
  26179. };
  26180. /**
  26181. * Returns the currently focused/"activated" HTML element that the Flash object is wrapping.
  26182. *
  26183. * @returns `HTMLElement` or `null`
  26184. * @static
  26185. */
  26186. ZeroClipboard.activeElement = function() {
  26187. return _activeElement.apply(this, _args(arguments));
  26188. };
  26189. /**
  26190. * Keep track of the ZeroClipboard client instance counter.
  26191. */
  26192. var _clientIdCounter = 0;
  26193. /**
  26194. * Keep track of the state of the client instances.
  26195. *
  26196. * Entry structure:
  26197. * _clientMeta[client.id] = {
  26198. * instance: client,
  26199. * elements: [],
  26200. * handlers: {}
  26201. * };
  26202. */
  26203. var _clientMeta = {};
  26204. /**
  26205. * Keep track of the ZeroClipboard clipped elements counter.
  26206. */
  26207. var _elementIdCounter = 0;
  26208. /**
  26209. * Keep track of the state of the clipped element relationships to clients.
  26210. *
  26211. * Entry structure:
  26212. * _elementMeta[element.zcClippingId] = [client1.id, client2.id];
  26213. */
  26214. var _elementMeta = {};
  26215. /**
  26216. * Keep track of the state of the mouse event handlers for clipped elements.
  26217. *
  26218. * Entry structure:
  26219. * _mouseHandlers[element.zcClippingId] = {
  26220. * mouseover: function(event) {},
  26221. * mouseout: function(event) {},
  26222. * mouseenter: function(event) {},
  26223. * mouseleave: function(event) {},
  26224. * mousemove: function(event) {}
  26225. * };
  26226. */
  26227. var _mouseHandlers = {};
  26228. /**
  26229. * Extending the ZeroClipboard configuration defaults for the Client module.
  26230. */
  26231. _extend(_globalConfig, {
  26232. autoActivate: true
  26233. });
  26234. /**
  26235. * The real constructor for `ZeroClipboard` client instances.
  26236. * @private
  26237. */
  26238. var _clientConstructor = function(elements) {
  26239. var client = this;
  26240. client.id = "" + _clientIdCounter++;
  26241. _clientMeta[client.id] = {
  26242. instance: client,
  26243. elements: [],
  26244. handlers: {}
  26245. };
  26246. if (elements) {
  26247. client.clip(elements);
  26248. }
  26249. ZeroClipboard.on("*", function(event) {
  26250. return client.emit(event);
  26251. });
  26252. ZeroClipboard.on("destroy", function() {
  26253. client.destroy();
  26254. });
  26255. ZeroClipboard.create();
  26256. };
  26257. /**
  26258. * The underlying implementation of `ZeroClipboard.Client.prototype.on`.
  26259. * @private
  26260. */
  26261. var _clientOn = function(eventType, listener) {
  26262. var i, len, events, added = {}, meta = _clientMeta[this.id], handlers = meta && meta.handlers;
  26263. if (!meta) {
  26264. throw new Error("Attempted to add new listener(s) to a destroyed ZeroClipboard client instance");
  26265. }
  26266. if (typeof eventType === "string" && eventType) {
  26267. events = eventType.toLowerCase().split(/\s+/);
  26268. } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
  26269. for (i in eventType) {
  26270. if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
  26271. this.on(i, eventType[i]);
  26272. }
  26273. }
  26274. }
  26275. if (events && events.length) {
  26276. for (i = 0, len = events.length; i < len; i++) {
  26277. eventType = events[i].replace(/^on/, "");
  26278. added[eventType] = true;
  26279. if (!handlers[eventType]) {
  26280. handlers[eventType] = [];
  26281. }
  26282. handlers[eventType].push(listener);
  26283. }
  26284. if (added.ready && _flashState.ready) {
  26285. this.emit({
  26286. type: "ready",
  26287. client: this
  26288. });
  26289. }
  26290. if (added.error) {
  26291. for (i = 0, len = _flashStateErrorNames.length; i < len; i++) {
  26292. if (_flashState[_flashStateErrorNames[i].replace(/^flash-/, "")]) {
  26293. this.emit({
  26294. type: "error",
  26295. name: _flashStateErrorNames[i],
  26296. client: this
  26297. });
  26298. break;
  26299. }
  26300. }
  26301. if (_zcSwfVersion !== undefined && ZeroClipboard.version !== _zcSwfVersion) {
  26302. this.emit({
  26303. type: "error",
  26304. name: "version-mismatch",
  26305. jsVersion: ZeroClipboard.version,
  26306. swfVersion: _zcSwfVersion
  26307. });
  26308. }
  26309. }
  26310. }
  26311. return this;
  26312. };
  26313. /**
  26314. * The underlying implementation of `ZeroClipboard.Client.prototype.off`.
  26315. * @private
  26316. */
  26317. var _clientOff = function(eventType, listener) {
  26318. var i, len, foundIndex, events, perEventHandlers, meta = _clientMeta[this.id], handlers = meta && meta.handlers;
  26319. if (!handlers) {
  26320. return this;
  26321. }
  26322. if (arguments.length === 0) {
  26323. events = _keys(handlers);
  26324. } else if (typeof eventType === "string" && eventType) {
  26325. events = eventType.split(/\s+/);
  26326. } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
  26327. for (i in eventType) {
  26328. if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
  26329. this.off(i, eventType[i]);
  26330. }
  26331. }
  26332. }
  26333. if (events && events.length) {
  26334. for (i = 0, len = events.length; i < len; i++) {
  26335. eventType = events[i].toLowerCase().replace(/^on/, "");
  26336. perEventHandlers = handlers[eventType];
  26337. if (perEventHandlers && perEventHandlers.length) {
  26338. if (listener) {
  26339. foundIndex = perEventHandlers.indexOf(listener);
  26340. while (foundIndex !== -1) {
  26341. perEventHandlers.splice(foundIndex, 1);
  26342. foundIndex = perEventHandlers.indexOf(listener, foundIndex);
  26343. }
  26344. } else {
  26345. perEventHandlers.length = 0;
  26346. }
  26347. }
  26348. }
  26349. }
  26350. return this;
  26351. };
  26352. /**
  26353. * The underlying implementation of `ZeroClipboard.Client.prototype.handlers`.
  26354. * @private
  26355. */
  26356. var _clientListeners = function(eventType) {
  26357. var copy = null, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
  26358. if (handlers) {
  26359. if (typeof eventType === "string" && eventType) {
  26360. copy = handlers[eventType] ? handlers[eventType].slice(0) : [];
  26361. } else {
  26362. copy = _deepCopy(handlers);
  26363. }
  26364. }
  26365. return copy;
  26366. };
  26367. /**
  26368. * The underlying implementation of `ZeroClipboard.Client.prototype.emit`.
  26369. * @private
  26370. */
  26371. var _clientEmit = function(event) {
  26372. if (_clientShouldEmit.call(this, event)) {
  26373. if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
  26374. event = _extend({}, event);
  26375. }
  26376. var eventCopy = _extend({}, _createEvent(event), {
  26377. client: this
  26378. });
  26379. _clientDispatchCallbacks.call(this, eventCopy);
  26380. }
  26381. return this;
  26382. };
  26383. /**
  26384. * The underlying implementation of `ZeroClipboard.Client.prototype.clip`.
  26385. * @private
  26386. */
  26387. var _clientClip = function(elements) {
  26388. if (!_clientMeta[this.id]) {
  26389. throw new Error("Attempted to clip element(s) to a destroyed ZeroClipboard client instance");
  26390. }
  26391. elements = _prepClip(elements);
  26392. for (var i = 0; i < elements.length; i++) {
  26393. if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
  26394. if (!elements[i].zcClippingId) {
  26395. elements[i].zcClippingId = "zcClippingId_" + _elementIdCounter++;
  26396. _elementMeta[elements[i].zcClippingId] = [ this.id ];
  26397. if (_globalConfig.autoActivate === true) {
  26398. _addMouseHandlers(elements[i]);
  26399. }
  26400. } else if (_elementMeta[elements[i].zcClippingId].indexOf(this.id) === -1) {
  26401. _elementMeta[elements[i].zcClippingId].push(this.id);
  26402. }
  26403. var clippedElements = _clientMeta[this.id] && _clientMeta[this.id].elements;
  26404. if (clippedElements.indexOf(elements[i]) === -1) {
  26405. clippedElements.push(elements[i]);
  26406. }
  26407. }
  26408. }
  26409. return this;
  26410. };
  26411. /**
  26412. * The underlying implementation of `ZeroClipboard.Client.prototype.unclip`.
  26413. * @private
  26414. */
  26415. var _clientUnclip = function(elements) {
  26416. var meta = _clientMeta[this.id];
  26417. if (!meta) {
  26418. return this;
  26419. }
  26420. var clippedElements = meta.elements;
  26421. var arrayIndex;
  26422. if (typeof elements === "undefined") {
  26423. elements = clippedElements.slice(0);
  26424. } else {
  26425. elements = _prepClip(elements);
  26426. }
  26427. for (var i = elements.length; i--; ) {
  26428. if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
  26429. arrayIndex = 0;
  26430. while ((arrayIndex = clippedElements.indexOf(elements[i], arrayIndex)) !== -1) {
  26431. clippedElements.splice(arrayIndex, 1);
  26432. }
  26433. var clientIds = _elementMeta[elements[i].zcClippingId];
  26434. if (clientIds) {
  26435. arrayIndex = 0;
  26436. while ((arrayIndex = clientIds.indexOf(this.id, arrayIndex)) !== -1) {
  26437. clientIds.splice(arrayIndex, 1);
  26438. }
  26439. if (clientIds.length === 0) {
  26440. if (_globalConfig.autoActivate === true) {
  26441. _removeMouseHandlers(elements[i]);
  26442. }
  26443. delete elements[i].zcClippingId;
  26444. }
  26445. }
  26446. }
  26447. }
  26448. return this;
  26449. };
  26450. /**
  26451. * The underlying implementation of `ZeroClipboard.Client.prototype.elements`.
  26452. * @private
  26453. */
  26454. var _clientElements = function() {
  26455. var meta = _clientMeta[this.id];
  26456. return meta && meta.elements ? meta.elements.slice(0) : [];
  26457. };
  26458. /**
  26459. * The underlying implementation of `ZeroClipboard.Client.prototype.destroy`.
  26460. * @private
  26461. */
  26462. var _clientDestroy = function() {
  26463. if (!_clientMeta[this.id]) {
  26464. return;
  26465. }
  26466. this.unclip();
  26467. this.off();
  26468. delete _clientMeta[this.id];
  26469. };
  26470. /**
  26471. * Inspect an Event to see if the Client (`this`) should honor it for emission.
  26472. * @private
  26473. */
  26474. var _clientShouldEmit = function(event) {
  26475. if (!(event && event.type)) {
  26476. return false;
  26477. }
  26478. if (event.client && event.client !== this) {
  26479. return false;
  26480. }
  26481. var meta = _clientMeta[this.id];
  26482. var clippedEls = meta && meta.elements;
  26483. var hasClippedEls = !!clippedEls && clippedEls.length > 0;
  26484. var goodTarget = !event.target || hasClippedEls && clippedEls.indexOf(event.target) !== -1;
  26485. var goodRelTarget = event.relatedTarget && hasClippedEls && clippedEls.indexOf(event.relatedTarget) !== -1;
  26486. var goodClient = event.client && event.client === this;
  26487. if (!meta || !(goodTarget || goodRelTarget || goodClient)) {
  26488. return false;
  26489. }
  26490. return true;
  26491. };
  26492. /**
  26493. * Handle the actual dispatching of events to a client instance.
  26494. *
  26495. * @returns `undefined`
  26496. * @private
  26497. */
  26498. var _clientDispatchCallbacks = function(event) {
  26499. var meta = _clientMeta[this.id];
  26500. if (!(typeof event === "object" && event && event.type && meta)) {
  26501. return;
  26502. }
  26503. var async = _shouldPerformAsync(event);
  26504. var wildcardTypeHandlers = meta && meta.handlers["*"] || [];
  26505. var specificTypeHandlers = meta && meta.handlers[event.type] || [];
  26506. var handlers = wildcardTypeHandlers.concat(specificTypeHandlers);
  26507. if (handlers && handlers.length) {
  26508. var i, len, func, context, eventCopy, originalContext = this;
  26509. for (i = 0, len = handlers.length; i < len; i++) {
  26510. func = handlers[i];
  26511. context = originalContext;
  26512. if (typeof func === "string" && typeof _window[func] === "function") {
  26513. func = _window[func];
  26514. }
  26515. if (typeof func === "object" && func && typeof func.handleEvent === "function") {
  26516. context = func;
  26517. func = func.handleEvent;
  26518. }
  26519. if (typeof func === "function") {
  26520. eventCopy = _extend({}, event);
  26521. _dispatchCallback(func, context, [ eventCopy ], async);
  26522. }
  26523. }
  26524. }
  26525. };
  26526. /**
  26527. * Prepares the elements for clipping/unclipping.
  26528. *
  26529. * @returns An Array of elements.
  26530. * @private
  26531. */
  26532. var _prepClip = function(elements) {
  26533. if (typeof elements === "string") {
  26534. elements = [];
  26535. }
  26536. return typeof elements.length !== "number" ? [ elements ] : elements;
  26537. };
  26538. /**
  26539. * Add a `mouseover` handler function for a clipped element.
  26540. *
  26541. * @returns `undefined`
  26542. * @private
  26543. */
  26544. var _addMouseHandlers = function(element) {
  26545. if (!(element && element.nodeType === 1)) {
  26546. return;
  26547. }
  26548. var _suppressMouseEvents = function(event) {
  26549. if (!(event || (event = _window.event))) {
  26550. return;
  26551. }
  26552. if (event._source !== "js") {
  26553. event.stopImmediatePropagation();
  26554. event.preventDefault();
  26555. }
  26556. delete event._source;
  26557. };
  26558. var _elementMouseOver = function(event) {
  26559. if (!(event || (event = _window.event))) {
  26560. return;
  26561. }
  26562. _suppressMouseEvents(event);
  26563. ZeroClipboard.focus(element);
  26564. };
  26565. element.addEventListener("mouseover", _elementMouseOver, false);
  26566. element.addEventListener("mouseout", _suppressMouseEvents, false);
  26567. element.addEventListener("mouseenter", _suppressMouseEvents, false);
  26568. element.addEventListener("mouseleave", _suppressMouseEvents, false);
  26569. element.addEventListener("mousemove", _suppressMouseEvents, false);
  26570. _mouseHandlers[element.zcClippingId] = {
  26571. mouseover: _elementMouseOver,
  26572. mouseout: _suppressMouseEvents,
  26573. mouseenter: _suppressMouseEvents,
  26574. mouseleave: _suppressMouseEvents,
  26575. mousemove: _suppressMouseEvents
  26576. };
  26577. };
  26578. /**
  26579. * Remove a `mouseover` handler function for a clipped element.
  26580. *
  26581. * @returns `undefined`
  26582. * @private
  26583. */
  26584. var _removeMouseHandlers = function(element) {
  26585. if (!(element && element.nodeType === 1)) {
  26586. return;
  26587. }
  26588. var mouseHandlers = _mouseHandlers[element.zcClippingId];
  26589. if (!(typeof mouseHandlers === "object" && mouseHandlers)) {
  26590. return;
  26591. }
  26592. var key, val, mouseEvents = [ "move", "leave", "enter", "out", "over" ];
  26593. for (var i = 0, len = mouseEvents.length; i < len; i++) {
  26594. key = "mouse" + mouseEvents[i];
  26595. val = mouseHandlers[key];
  26596. if (typeof val === "function") {
  26597. element.removeEventListener(key, val, false);
  26598. }
  26599. }
  26600. delete _mouseHandlers[element.zcClippingId];
  26601. };
  26602. /**
  26603. * Creates a new ZeroClipboard client instance.
  26604. * Optionally, auto-`clip` an element or collection of elements.
  26605. *
  26606. * @constructor
  26607. */
  26608. ZeroClipboard._createClient = function() {
  26609. _clientConstructor.apply(this, _args(arguments));
  26610. };
  26611. /**
  26612. * Register an event listener to the client.
  26613. *
  26614. * @returns `this`
  26615. */
  26616. ZeroClipboard.prototype.on = function() {
  26617. return _clientOn.apply(this, _args(arguments));
  26618. };
  26619. /**
  26620. * Unregister an event handler from the client.
  26621. * If no `listener` function/object is provided, it will unregister all handlers for the provided `eventType`.
  26622. * If no `eventType` is provided, it will unregister all handlers for every event type.
  26623. *
  26624. * @returns `this`
  26625. */
  26626. ZeroClipboard.prototype.off = function() {
  26627. return _clientOff.apply(this, _args(arguments));
  26628. };
  26629. /**
  26630. * Retrieve event listeners for an `eventType` from the client.
  26631. * If no `eventType` is provided, it will retrieve all listeners for every event type.
  26632. *
  26633. * @returns array of listeners for the `eventType`; if no `eventType`, then a map/hash object of listeners for all event types; or `null`
  26634. */
  26635. ZeroClipboard.prototype.handlers = function() {
  26636. return _clientListeners.apply(this, _args(arguments));
  26637. };
  26638. /**
  26639. * Event emission receiver from the Flash object for this client's registered JavaScript event listeners.
  26640. *
  26641. * @returns For the "copy" event, returns the Flash-friendly "clipData" object; otherwise `undefined`.
  26642. */
  26643. ZeroClipboard.prototype.emit = function() {
  26644. return _clientEmit.apply(this, _args(arguments));
  26645. };
  26646. /**
  26647. * Register clipboard actions for new element(s) to the client.
  26648. *
  26649. * @returns `this`
  26650. */
  26651. ZeroClipboard.prototype.clip = function() {
  26652. return _clientClip.apply(this, _args(arguments));
  26653. };
  26654. /**
  26655. * Unregister the clipboard actions of previously registered element(s) on the page.
  26656. * If no elements are provided, ALL registered elements will be unregistered.
  26657. *
  26658. * @returns `this`
  26659. */
  26660. ZeroClipboard.prototype.unclip = function() {
  26661. return _clientUnclip.apply(this, _args(arguments));
  26662. };
  26663. /**
  26664. * Get all of the elements to which this client is clipped.
  26665. *
  26666. * @returns array of clipped elements
  26667. */
  26668. ZeroClipboard.prototype.elements = function() {
  26669. return _clientElements.apply(this, _args(arguments));
  26670. };
  26671. /**
  26672. * Self-destruct and clean up everything for a single client.
  26673. * This will NOT destroy the embedded Flash object.
  26674. *
  26675. * @returns `undefined`
  26676. */
  26677. ZeroClipboard.prototype.destroy = function() {
  26678. return _clientDestroy.apply(this, _args(arguments));
  26679. };
  26680. /**
  26681. * Stores the pending plain text to inject into the clipboard.
  26682. *
  26683. * @returns `this`
  26684. */
  26685. ZeroClipboard.prototype.setText = function(text) {
  26686. if (!_clientMeta[this.id]) {
  26687. throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
  26688. }
  26689. ZeroClipboard.setData("text/plain", text);
  26690. return this;
  26691. };
  26692. /**
  26693. * Stores the pending HTML text to inject into the clipboard.
  26694. *
  26695. * @returns `this`
  26696. */
  26697. ZeroClipboard.prototype.setHtml = function(html) {
  26698. if (!_clientMeta[this.id]) {
  26699. throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
  26700. }
  26701. ZeroClipboard.setData("text/html", html);
  26702. return this;
  26703. };
  26704. /**
  26705. * Stores the pending rich text (RTF) to inject into the clipboard.
  26706. *
  26707. * @returns `this`
  26708. */
  26709. ZeroClipboard.prototype.setRichText = function(richText) {
  26710. if (!_clientMeta[this.id]) {
  26711. throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
  26712. }
  26713. ZeroClipboard.setData("application/rtf", richText);
  26714. return this;
  26715. };
  26716. /**
  26717. * Stores the pending data to inject into the clipboard.
  26718. *
  26719. * @returns `this`
  26720. */
  26721. ZeroClipboard.prototype.setData = function() {
  26722. if (!_clientMeta[this.id]) {
  26723. throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
  26724. }
  26725. ZeroClipboard.setData.apply(this, _args(arguments));
  26726. return this;
  26727. };
  26728. /**
  26729. * Clears the pending data to inject into the clipboard.
  26730. * If no `format` is provided, all pending data formats will be cleared.
  26731. *
  26732. * @returns `this`
  26733. */
  26734. ZeroClipboard.prototype.clearData = function() {
  26735. if (!_clientMeta[this.id]) {
  26736. throw new Error("Attempted to clear pending clipboard data from a destroyed ZeroClipboard client instance");
  26737. }
  26738. ZeroClipboard.clearData.apply(this, _args(arguments));
  26739. return this;
  26740. };
  26741. /**
  26742. * Gets a copy of the pending data to inject into the clipboard.
  26743. * If no `format` is provided, a copy of ALL pending data formats will be returned.
  26744. *
  26745. * @returns `String` or `Object`
  26746. */
  26747. ZeroClipboard.prototype.getData = function() {
  26748. if (!_clientMeta[this.id]) {
  26749. throw new Error("Attempted to get pending clipboard data from a destroyed ZeroClipboard client instance");
  26750. }
  26751. return ZeroClipboard.getData.apply(this, _args(arguments));
  26752. };
  26753. if (typeof define === "function" && define.amd) {
  26754. define(function() {
  26755. return ZeroClipboard;
  26756. });
  26757. } else if (typeof module === "object" && module && typeof module.exports === "object" && module.exports) {
  26758. module.exports = ZeroClipboard;
  26759. } else {
  26760. window.ZeroClipboard = ZeroClipboard;
  26761. }
  26762. })(function() {
  26763. return this || window;
  26764. }());
  26765. },{}]},{},[23,59,61,60,62,83,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,100,101,102,90,91,92,93,94,95,31,35,32,33,40,34,36,37,38,39])("zeroclipboard")
  26766. });