| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181 |
- /*!
- * Handsontable 0.15.0
- * Handsontable is a JavaScript library for editable tables with basic copy-paste compatibility with Excel and Google Docs
- *
- * Copyright (c) 2012-2014 Marcin Warpechowski
- * Copyright 2015 Handsoncode sp. z o.o. <hello@handsontable.com>
- * Licensed under the MIT license.
- * http://handsontable.com/
- *
- * Date: Fri Jun 19 2015 09:15:37 GMT+0200 (CEST)
- */
- /*jslint white: true, browser: true, plusplus: true, indent: 4, maxerr: 50 */
-
- window.Handsontable = {
- version: '0.15.0',
- buildDate: 'Fri Jun 19 2015 09:15:37 GMT+0200 (CEST)'
- };
- (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) {
- (function outer (modules, cache, entry) {
- // Save the require from previous bundle to this closure if any
- var previousRequire = typeof require == "function" && require;
- var globalNS = JSON.parse('{"zeroclipboard":"ZeroClipboard","copyPaste":"copyPaste","SheetClip":"SheetClip","jsonpatch":"jsonpatch","moment":"moment","numeral":"numeral","pikaday":"Pikaday","autoResize":"autoResize"}') || {};
-
- function newRequire(name, jumped){
- if(!cache[name]) {
-
- if(!modules[name]) {
- // if we cannot find the the module within our internal map or
- // cache jump to the current global require ie. the last bundle
- // that was added to the page.
- var currentRequire = typeof require == "function" && require;
- if (!jumped && currentRequire) return currentRequire(name, true);
-
- // If there are other bundles on this page the require from the
- // previous one is saved to 'previousRequire'. Repeat this as
- // many times as there are bundles until the module is found or
- // we exhaust the require chain.
- if (previousRequire) return previousRequire(name, true);
-
- // Try find module from global scope
- if (globalNS[name] && typeof window[globalNS[name]] !== 'undefined') {
- return window[globalNS[name]];
- }
-
- var err = new Error('Cannot find module \'' + name + '\'');
- err.code = 'MODULE_NOT_FOUND';
- throw err;
- }
- var m = cache[name] = {exports:{}};
- modules[name][0].call(m.exports, function(x){
- var id = modules[name][1][x];
- return newRequire(id ? id : x);
- },m,m.exports,outer,modules,cache,entry);
- }
-
- return cache[name].exports;
- }
- for(var i=0;i<entry.length;i++) newRequire(entry[i]);
-
- // Override the current require with this new one
- return newRequire;
- })(modules, cache, entry);
-
- return function() {
- return Handsontable;
- };
- })
- ({1:[function(require,module,exports){
- "use strict";
- if (window.jQuery) {
- (function(window, $, Handsontable) {
- $.fn.handsontable = function(action) {
- var i,
- ilen,
- args,
- output,
- userSettings,
- $this = this.first(),
- instance = $this.data('handsontable');
- if (typeof action !== 'string') {
- userSettings = action || {};
- if (instance) {
- instance.updateSettings(userSettings);
- } else {
- instance = new Handsontable.Core($this[0], userSettings);
- $this.data('handsontable', instance);
- instance.init();
- }
- return $this;
- } else {
- args = [];
- if (arguments.length > 1) {
- for (i = 1, ilen = arguments.length; i < ilen; i++) {
- args.push(arguments[i]);
- }
- }
- if (instance) {
- if (typeof instance[action] !== 'undefined') {
- output = instance[action].apply(instance, args);
- if (action === 'destroy') {
- $this.removeData();
- }
- } else {
- throw new Error('Handsontable do not provide action: ' + action);
- }
- }
- return output;
- }
- };
- })(window, jQuery, Handsontable);
- }
-
- //#
- },{}],2:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableBorder: {get: function() {
- return WalkontableBorder;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47__46__46__47_eventManager_46_js__,
- $__cell_47_coords_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../dom.js"), $___46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47__46__46__47__46__46__47_eventManager_46_js__ = require("./../../../eventManager.js"), $___46__46__47__46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var WalkontableCellCoords = ($__cell_47_coords_46_js__ = require("./cell/coords.js"), $__cell_47_coords_46_js__ && $__cell_47_coords_46_js__.__esModule && $__cell_47_coords_46_js__ || {default: $__cell_47_coords_46_js__}).WalkontableCellCoords;
- function WalkontableBorder(instance, settings) {
- var style;
- var createMultipleSelectorHandles = function() {
- this.selectionHandles = {
- topLeft: document.createElement('DIV'),
- topLeftHitArea: document.createElement('DIV'),
- bottomRight: document.createElement('DIV'),
- bottomRightHitArea: document.createElement('DIV')
- };
- var width = 10,
- hitAreaWidth = 40;
- this.selectionHandles.topLeft.className = 'topLeftSelectionHandle';
- this.selectionHandles.topLeftHitArea.className = 'topLeftSelectionHandle-HitArea';
- this.selectionHandles.bottomRight.className = 'bottomRightSelectionHandle';
- this.selectionHandles.bottomRightHitArea.className = 'bottomRightSelectionHandle-HitArea';
- this.selectionHandles.styles = {
- topLeft: this.selectionHandles.topLeft.style,
- topLeftHitArea: this.selectionHandles.topLeftHitArea.style,
- bottomRight: this.selectionHandles.bottomRight.style,
- bottomRightHitArea: this.selectionHandles.bottomRightHitArea.style
- };
- var hitAreaStyle = {
- 'position': 'absolute',
- 'height': hitAreaWidth + 'px',
- 'width': hitAreaWidth + 'px',
- 'border-radius': parseInt(hitAreaWidth / 1.5, 10) + 'px'
- };
- for (var prop in hitAreaStyle) {
- if (hitAreaStyle.hasOwnProperty(prop)) {
- this.selectionHandles.styles.bottomRightHitArea[prop] = hitAreaStyle[prop];
- this.selectionHandles.styles.topLeftHitArea[prop] = hitAreaStyle[prop];
- }
- }
- var handleStyle = {
- 'position': 'absolute',
- 'height': width + 'px',
- 'width': width + 'px',
- 'border-radius': parseInt(width / 1.5, 10) + 'px',
- 'background': '#F5F5FF',
- 'border': '1px solid #4285c8'
- };
- for (var prop in handleStyle) {
- if (handleStyle.hasOwnProperty(prop)) {
- this.selectionHandles.styles.bottomRight[prop] = handleStyle[prop];
- this.selectionHandles.styles.topLeft[prop] = handleStyle[prop];
- }
- }
- this.main.appendChild(this.selectionHandles.topLeft);
- this.main.appendChild(this.selectionHandles.bottomRight);
- this.main.appendChild(this.selectionHandles.topLeftHitArea);
- this.main.appendChild(this.selectionHandles.bottomRightHitArea);
- };
- if (!settings) {
- return;
- }
- var eventManager = eventManagerObject(instance);
- this.instance = instance;
- this.settings = settings;
- this.main = document.createElement("div");
- style = this.main.style;
- style.position = 'absolute';
- style.top = 0;
- style.left = 0;
- var borderDivs = ['top', 'left', 'bottom', 'right', 'corner'];
- for (var i = 0; i < 5; i++) {
- var position = borderDivs[i];
- var DIV = document.createElement('DIV');
- DIV.className = 'wtBorder ' + (this.settings.className || '');
- if (this.settings[position] && this.settings[position].hide) {
- DIV.className += " hidden";
- }
- style = DIV.style;
- style.backgroundColor = (this.settings[position] && this.settings[position].color) ? this.settings[position].color : settings.border.color;
- style.height = (this.settings[position] && this.settings[position].width) ? this.settings[position].width + 'px' : settings.border.width + 'px';
- style.width = (this.settings[position] && this.settings[position].width) ? this.settings[position].width + 'px' : settings.border.width + 'px';
- this.main.appendChild(DIV);
- }
- this.top = this.main.childNodes[0];
- this.left = this.main.childNodes[1];
- this.bottom = this.main.childNodes[2];
- this.right = this.main.childNodes[3];
- this.topStyle = this.top.style;
- this.leftStyle = this.left.style;
- this.bottomStyle = this.bottom.style;
- this.rightStyle = this.right.style;
- this.cornerDefaultStyle = {
- width: '5px',
- height: '5px',
- borderWidth: '2px',
- borderStyle: 'solid',
- borderColor: '#FFF'
- };
- this.corner = this.main.childNodes[4];
- this.corner.className += ' corner';
- this.cornerStyle = this.corner.style;
- this.cornerStyle.width = this.cornerDefaultStyle.width;
- this.cornerStyle.height = this.cornerDefaultStyle.height;
- this.cornerStyle.border = [this.cornerDefaultStyle.borderWidth, this.cornerDefaultStyle.borderStyle, this.cornerDefaultStyle.borderColor].join(' ');
- if (Handsontable.mobileBrowser) {
- createMultipleSelectorHandles.call(this);
- }
- this.disappear();
- if (!instance.wtTable.bordersHolder) {
- instance.wtTable.bordersHolder = document.createElement('div');
- instance.wtTable.bordersHolder.className = 'htBorders';
- instance.wtTable.spreader.appendChild(instance.wtTable.bordersHolder);
- }
- instance.wtTable.bordersHolder.insertBefore(this.main, instance.wtTable.bordersHolder.firstChild);
- var down = false;
- eventManager.addEventListener(document.body, 'mousedown', function() {
- down = true;
- });
- eventManager.addEventListener(document.body, 'mouseup', function() {
- down = false;
- });
- for (var c = 0,
- len = this.main.childNodes.length; c < len; c++) {
- eventManager.addEventListener(this.main.childNodes[c], 'mouseenter', function(event) {
- if (!down || !instance.getSetting('hideBorderOnMouseDownOver')) {
- return;
- }
- event.preventDefault();
- event.stopImmediatePropagation();
- var bounds = this.getBoundingClientRect();
- this.style.display = 'none';
- var isOutside = function(event) {
- if (event.clientY < Math.floor(bounds.top)) {
- return true;
- }
- if (event.clientY > Math.ceil(bounds.top + bounds.height)) {
- return true;
- }
- if (event.clientX < Math.floor(bounds.left)) {
- return true;
- }
- if (event.clientX > Math.ceil(bounds.left + bounds.width)) {
- return true;
- }
- };
- var handler = function(event) {
- if (isOutside(event)) {
- eventManager.removeEventListener(document.body, 'mousemove', handler);
- this.style.display = 'block';
- }
- };
- eventManager.addEventListener(document.body, 'mousemove', handler);
- });
- }
- }
- WalkontableBorder.prototype.appear = function(corners) {
- if (this.disabled) {
- return;
- }
- var instance = this.instance;
- var isMultiple,
- fromTD,
- toTD,
- fromOffset,
- toOffset,
- containerOffset,
- top,
- minTop,
- left,
- minLeft,
- height,
- width,
- fromRow,
- fromColumn,
- toRow,
- toColumn,
- i,
- ilen,
- s;
- var isPartRange = function() {
- if (this.instance.selections.area.cellRange) {
- if (toRow != this.instance.selections.area.cellRange.to.row || toColumn != this.instance.selections.area.cellRange.to.col) {
- return true;
- }
- }
- return false;
- };
- var updateMultipleSelectionHandlesPosition = function(top, left, width, height) {
- var handleWidth = parseInt(this.selectionHandles.styles.topLeft.width, 10),
- hitAreaWidth = parseInt(this.selectionHandles.styles.topLeftHitArea.width, 10);
- this.selectionHandles.styles.topLeft.top = parseInt(top - handleWidth, 10) + "px";
- this.selectionHandles.styles.topLeft.left = parseInt(left - handleWidth, 10) + "px";
- this.selectionHandles.styles.topLeftHitArea.top = parseInt(top - (hitAreaWidth / 4) * 3, 10) + "px";
- this.selectionHandles.styles.topLeftHitArea.left = parseInt(left - (hitAreaWidth / 4) * 3, 10) + "px";
- this.selectionHandles.styles.bottomRight.top = parseInt(top + height, 10) + "px";
- this.selectionHandles.styles.bottomRight.left = parseInt(left + width, 10) + "px";
- this.selectionHandles.styles.bottomRightHitArea.top = parseInt(top + height - hitAreaWidth / 4, 10) + "px";
- this.selectionHandles.styles.bottomRightHitArea.left = parseInt(left + width - hitAreaWidth / 4, 10) + "px";
- if (this.settings.border.multipleSelectionHandlesVisible && this.settings.border.multipleSelectionHandlesVisible()) {
- this.selectionHandles.styles.topLeft.display = "block";
- this.selectionHandles.styles.topLeftHitArea.display = "block";
- if (!isPartRange.call(this)) {
- this.selectionHandles.styles.bottomRight.display = "block";
- this.selectionHandles.styles.bottomRightHitArea.display = "block";
- } else {
- this.selectionHandles.styles.bottomRight.display = "none";
- this.selectionHandles.styles.bottomRightHitArea.display = "none";
- }
- } else {
- this.selectionHandles.styles.topLeft.display = "none";
- this.selectionHandles.styles.bottomRight.display = "none";
- this.selectionHandles.styles.topLeftHitArea.display = "none";
- this.selectionHandles.styles.bottomRightHitArea.display = "none";
- }
- if (fromRow == this.instance.wtSettings.getSetting('fixedRowsTop') || fromColumn == this.instance.wtSettings.getSetting('fixedColumnsLeft')) {
- this.selectionHandles.styles.topLeft.zIndex = "9999";
- this.selectionHandles.styles.topLeftHitArea.zIndex = "9999";
- } else {
- this.selectionHandles.styles.topLeft.zIndex = "";
- this.selectionHandles.styles.topLeftHitArea.zIndex = "";
- }
- };
- if (instance.cloneOverlay instanceof WalkontableTopOverlay || instance.cloneOverlay instanceof WalkontableCornerOverlay) {
- ilen = instance.getSetting('fixedRowsTop');
- } else {
- ilen = instance.wtTable.getRenderedRowsCount();
- }
- for (i = 0; i < ilen; i++) {
- s = instance.wtTable.rowFilter.renderedToSource(i);
- if (s >= corners[0] && s <= corners[2]) {
- fromRow = s;
- break;
- }
- }
- for (i = ilen - 1; i >= 0; i--) {
- s = instance.wtTable.rowFilter.renderedToSource(i);
- if (s >= corners[0] && s <= corners[2]) {
- toRow = s;
- break;
- }
- }
- ilen = instance.wtTable.getRenderedColumnsCount();
- for (i = 0; i < ilen; i++) {
- s = instance.wtTable.columnFilter.renderedToSource(i);
- if (s >= corners[1] && s <= corners[3]) {
- fromColumn = s;
- break;
- }
- }
- for (i = ilen - 1; i >= 0; i--) {
- s = instance.wtTable.columnFilter.renderedToSource(i);
- if (s >= corners[1] && s <= corners[3]) {
- toColumn = s;
- break;
- }
- }
- if (fromRow !== void 0 && fromColumn !== void 0) {
- isMultiple = (fromRow !== toRow || fromColumn !== toColumn);
- fromTD = instance.wtTable.getCell(new WalkontableCellCoords(fromRow, fromColumn));
- toTD = isMultiple ? instance.wtTable.getCell(new WalkontableCellCoords(toRow, toColumn)) : fromTD;
- fromOffset = dom.offset(fromTD);
- toOffset = isMultiple ? dom.offset(toTD) : fromOffset;
- containerOffset = dom.offset(instance.wtTable.TABLE);
- minTop = fromOffset.top;
- height = toOffset.top + dom.outerHeight(toTD) - minTop;
- minLeft = fromOffset.left;
- width = toOffset.left + dom.outerWidth(toTD) - minLeft;
- top = minTop - containerOffset.top - 1;
- left = minLeft - containerOffset.left - 1;
- var style = dom.getComputedStyle(fromTD);
- if (parseInt(style.borderTopWidth, 10) > 0) {
- top += 1;
- height = height > 0 ? height - 1 : 0;
- }
- if (parseInt(style.borderLeftWidth, 10) > 0) {
- left += 1;
- width = width > 0 ? width - 1 : 0;
- }
- } else {
- this.disappear();
- return;
- }
- this.topStyle.top = top + 'px';
- this.topStyle.left = left + 'px';
- this.topStyle.width = width + 'px';
- this.topStyle.display = 'block';
- this.leftStyle.top = top + 'px';
- this.leftStyle.left = left + 'px';
- this.leftStyle.height = height + 'px';
- this.leftStyle.display = 'block';
- var delta = Math.floor(this.settings.border.width / 2);
- this.bottomStyle.top = top + height - delta + 'px';
- this.bottomStyle.left = left + 'px';
- this.bottomStyle.width = width + 'px';
- this.bottomStyle.display = 'block';
- this.rightStyle.top = top + 'px';
- this.rightStyle.left = left + width - delta + 'px';
- this.rightStyle.height = height + 1 + 'px';
- this.rightStyle.display = 'block';
- if (Handsontable.mobileBrowser || (!this.hasSetting(this.settings.border.cornerVisible) || isPartRange.call(this))) {
- this.cornerStyle.display = 'none';
- } else {
- this.cornerStyle.top = top + height - 4 + 'px';
- this.cornerStyle.left = left + width - 4 + 'px';
- this.cornerStyle.borderRightWidth = this.cornerDefaultStyle.borderWidth;
- this.cornerStyle.width = this.cornerDefaultStyle.width;
- this.cornerStyle.display = 'block';
- if (toColumn === this.instance.getSetting('totalColumns') - 1) {
- var trimmingContainer = dom.getTrimmingContainer(instance.wtTable.TABLE),
- cornerOverlappingContainer = toTD.offsetLeft + dom.outerWidth(toTD) >= dom.innerWidth(trimmingContainer);
- if (cornerOverlappingContainer) {
- this.cornerStyle.left = Math.floor(left + width - 3 - parseInt(this.cornerDefaultStyle.width) / 2) + "px";
- this.cornerStyle.borderRightWidth = 0;
- }
- }
- }
- if (Handsontable.mobileBrowser) {
- updateMultipleSelectionHandlesPosition.call(this, top, left, width, height);
- }
- };
- WalkontableBorder.prototype.disappear = function() {
- this.topStyle.display = 'none';
- this.leftStyle.display = 'none';
- this.bottomStyle.display = 'none';
- this.rightStyle.display = 'none';
- this.cornerStyle.display = 'none';
- if (Handsontable.mobileBrowser) {
- this.selectionHandles.styles.topLeft.display = 'none';
- this.selectionHandles.styles.bottomRight.display = 'none';
- }
- };
- WalkontableBorder.prototype.hasSetting = function(setting) {
- if (typeof setting === 'function') {
- return setting();
- }
- return !!setting;
- };
- ;
- window.WalkontableBorder = WalkontableBorder;
-
- //#
- },{"./../../../dom.js":27,"./../../../eventManager.js":41,"./cell/coords.js":5}],3:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableViewportColumnsCalculator: {get: function() {
- return WalkontableViewportColumnsCalculator;
- }},
- __esModule: {value: true}
- });
- var privatePool = new WeakMap();
- var WalkontableViewportColumnsCalculator = function WalkontableViewportColumnsCalculator(viewportWidth, scrollOffset, totalColumns, columnWidthFn, overrideFn, onlyFullyVisible, stretchH) {
- privatePool.set(this, {
- viewportWidth: viewportWidth,
- scrollOffset: scrollOffset,
- totalColumns: totalColumns,
- columnWidthFn: columnWidthFn,
- overrideFn: overrideFn,
- onlyFullyVisible: onlyFullyVisible
- });
- this.count = 0;
- this.startColumn = null;
- this.endColumn = null;
- this.startPosition = null;
- this.stretchAllRatio = 0;
- this.stretchLastWidth = 0;
- this.stretch = stretchH;
- this.totalTargetWidth = 0;
- this.needVerifyLastColumnWidth = true;
- this.stretchAllColumnsWidth = [];
- this.calculate();
- };
- var $WalkontableViewportColumnsCalculator = WalkontableViewportColumnsCalculator;
- ($traceurRuntime.createClass)(WalkontableViewportColumnsCalculator, {
- calculate: function() {
- var sum = 0;
- var needReverse = true;
- var startPositions = [];
- var columnWidth;
- var priv = privatePool.get(this);
- var onlyFullyVisible = priv.onlyFullyVisible;
- var overrideFn = priv.overrideFn;
- var scrollOffset = priv.scrollOffset;
- var totalColumns = priv.totalColumns;
- var viewportWidth = priv.viewportWidth;
- for (var i = 0; i < totalColumns; i++) {
- columnWidth = this._getColumnWidth(i);
- if (sum <= scrollOffset && !onlyFullyVisible) {
- this.startColumn = i;
- }
- if (sum >= scrollOffset && sum + columnWidth <= scrollOffset + viewportWidth) {
- if (this.startColumn == null) {
- this.startColumn = i;
- }
- this.endColumn = i;
- }
- startPositions.push(sum);
- sum += columnWidth;
- if (!onlyFullyVisible) {
- this.endColumn = i;
- }
- if (sum >= scrollOffset + viewportWidth) {
- needReverse = false;
- break;
- }
- }
- if (this.endColumn === totalColumns - 1 && needReverse) {
- this.startColumn = this.endColumn;
- while (this.startColumn > 0) {
- var viewportSum = startPositions[this.endColumn] + columnWidth - startPositions[this.startColumn - 1];
- if (viewportSum <= viewportWidth || !onlyFullyVisible) {
- this.startColumn--;
- }
- if (viewportSum > viewportWidth) {
- break;
- }
- }
- }
- if (this.startColumn !== null && overrideFn) {
- overrideFn(this);
- }
- this.startPosition = startPositions[this.startColumn];
- if (this.startPosition == void 0) {
- this.startPosition = null;
- }
- if (this.startColumn !== null) {
- this.count = this.endColumn - this.startColumn + 1;
- }
- },
- refreshStretching: function(totalWidth) {
- if (this.stretch === 'none') {
- return;
- }
- var sumAll = 0;
- var columnWidth;
- var remainingSize;
- var priv = privatePool.get(this);
- var totalColumns = priv.totalColumns;
- for (var i = 0; i < totalColumns; i++) {
- columnWidth = this._getColumnWidth(i);
- sumAll += columnWidth;
- }
- this.totalTargetWidth = totalWidth;
- remainingSize = sumAll - totalWidth;
- if (this.stretch === 'all' && remainingSize < 0) {
- this.stretchAllRatio = totalWidth / sumAll;
- this.stretchAllColumnsWidth = [];
- this.needVerifyLastColumnWidth = true;
- } else if (this.stretch === 'last' && totalWidth !== Infinity) {
- this.stretchLastWidth = -remainingSize + this._getColumnWidth(totalColumns - 1);
- }
- },
- getStretchedColumnWidth: function(column, baseWidth) {
- var result = null;
- if (this.stretch === 'all' && this.stretchAllRatio !== 0) {
- result = this._getStretchedAllColumnWidth(column, baseWidth);
- } else if (this.stretch === 'last' && this.stretchLastWidth !== 0) {
- result = this._getStretchedLastColumnWidth(column);
- }
- return result;
- },
- _getStretchedAllColumnWidth: function(column, baseWidth) {
- var sumRatioWidth = 0;
- var priv = privatePool.get(this);
- var totalColumns = priv.totalColumns;
- if (!this.stretchAllColumnsWidth[column]) {
- this.stretchAllColumnsWidth[column] = Math.round(baseWidth * this.stretchAllRatio);
- }
- if (this.stretchAllColumnsWidth.length === totalColumns && this.needVerifyLastColumnWidth) {
- this.needVerifyLastColumnWidth = false;
- for (var i = 0; i < this.stretchAllColumnsWidth.length; i++) {
- sumRatioWidth += this.stretchAllColumnsWidth[i];
- }
- if (sumRatioWidth !== this.totalTargetWidth) {
- this.stretchAllColumnsWidth[this.stretchAllColumnsWidth.length - 1] += this.totalTargetWidth - sumRatioWidth;
- }
- }
- return this.stretchAllColumnsWidth[column];
- },
- _getStretchedLastColumnWidth: function(column) {
- var priv = privatePool.get(this);
- var totalColumns = priv.totalColumns;
- if (column === totalColumns - 1) {
- return this.stretchLastWidth;
- }
- return null;
- },
- _getColumnWidth: function(column) {
- var width = privatePool.get(this).columnWidthFn(column);
- if (width === undefined) {
- width = $WalkontableViewportColumnsCalculator.DEFAULT_WIDTH;
- }
- return width;
- }
- }, {get DEFAULT_WIDTH() {
- return 50;
- }});
- ;
- window.WalkontableViewportColumnsCalculator = WalkontableViewportColumnsCalculator;
-
- //#
- },{}],4:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableViewportRowsCalculator: {get: function() {
- return WalkontableViewportRowsCalculator;
- }},
- __esModule: {value: true}
- });
- var privatePool = new WeakMap();
- var WalkontableViewportRowsCalculator = function WalkontableViewportRowsCalculator(viewportHeight, scrollOffset, totalRows, rowHeightFn, overrideFn, onlyFullyVisible) {
- privatePool.set(this, {
- viewportHeight: viewportHeight,
- scrollOffset: scrollOffset,
- totalRows: totalRows,
- rowHeightFn: rowHeightFn,
- overrideFn: overrideFn,
- onlyFullyVisible: onlyFullyVisible
- });
- this.count = 0;
- this.startRow = null;
- this.endRow = null;
- this.startPosition = null;
- this.calculate();
- };
- var $WalkontableViewportRowsCalculator = WalkontableViewportRowsCalculator;
- ($traceurRuntime.createClass)(WalkontableViewportRowsCalculator, {calculate: function() {
- var sum = 0;
- var needReverse = true;
- var startPositions = [];
- var priv = privatePool.get(this);
- var onlyFullyVisible = priv.onlyFullyVisible;
- var overrideFn = priv.overrideFn;
- var rowHeightFn = priv.rowHeightFn;
- var scrollOffset = priv.scrollOffset;
- var totalRows = priv.totalRows;
- var viewportHeight = priv.viewportHeight;
- for (var i = 0; i < totalRows; i++) {
- var rowHeight = rowHeightFn(i);
- if (rowHeight === undefined) {
- rowHeight = $WalkontableViewportRowsCalculator.DEFAULT_HEIGHT;
- }
- if (sum <= scrollOffset && !onlyFullyVisible) {
- this.startRow = i;
- }
- if (sum >= scrollOffset && sum + rowHeight <= scrollOffset + viewportHeight) {
- if (this.startRow === null) {
- this.startRow = i;
- }
- this.endRow = i;
- }
- startPositions.push(sum);
- sum += rowHeight;
- if (!onlyFullyVisible) {
- this.endRow = i;
- }
- if (sum >= scrollOffset + viewportHeight) {
- needReverse = false;
- break;
- }
- }
- if (this.endRow === totalRows - 1 && needReverse) {
- this.startRow = this.endRow;
- while (this.startRow > 0) {
- var viewportSum = startPositions[this.endRow] + rowHeight - startPositions[this.startRow - 1];
- if (viewportSum <= viewportHeight || !onlyFullyVisible) {
- this.startRow--;
- }
- if (viewportSum >= viewportHeight) {
- break;
- }
- }
- }
- if (this.startRow !== null && overrideFn) {
- overrideFn(this);
- }
- this.startPosition = startPositions[this.startRow];
- if (this.startPosition == void 0) {
- this.startPosition = null;
- }
- if (this.startRow !== null) {
- this.count = this.endRow - this.startRow + 1;
- }
- }}, {get DEFAULT_HEIGHT() {
- return 23;
- }});
- ;
- window.WalkontableViewportRowsCalculator = WalkontableViewportRowsCalculator;
-
- //#
- },{}],5:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableCellCoords: {get: function() {
- return WalkontableCellCoords;
- }},
- __esModule: {value: true}
- });
- var WalkontableCellCoords = function WalkontableCellCoords(row, col) {
- if (typeof row !== 'undefined' && typeof col !== 'undefined') {
- this.row = row;
- this.col = col;
- } else {
- this.row = null;
- this.col = null;
- }
- };
- ($traceurRuntime.createClass)(WalkontableCellCoords, {
- isValid: function(wotInstance) {
- if (this.row < 0 || this.col < 0) {
- return false;
- }
- if (this.row >= wotInstance.getSetting('totalRows') || this.col >= wotInstance.getSetting('totalColumns')) {
- return false;
- }
- return true;
- },
- isEqual: function(cellCoords) {
- if (cellCoords === this) {
- return true;
- }
- return this.row === cellCoords.row && this.col === cellCoords.col;
- },
- isSouthEastOf: function(testedCoords) {
- return this.row >= testedCoords.row && this.col >= testedCoords.col;
- },
- isNorthWestOf: function(testedCoords) {
- return this.row <= testedCoords.row && this.col <= testedCoords.col;
- },
- isSouthWestOf: function(testedCoords) {
- return this.row >= testedCoords.row && this.col <= testedCoords.col;
- },
- isNorthEastOf: function(testedCoords) {
- return this.row <= testedCoords.row && this.col >= testedCoords.col;
- }
- }, {});
- ;
- window.WalkontableCellCoords = WalkontableCellCoords;
-
- //#
- },{}],6:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableCellRange: {get: function() {
- return WalkontableCellRange;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_cell_47_coords_46_js__;
- var WalkontableCellCoords = ($___46__46__47_cell_47_coords_46_js__ = require("./../cell/coords.js"), $___46__46__47_cell_47_coords_46_js__ && $___46__46__47_cell_47_coords_46_js__.__esModule && $___46__46__47_cell_47_coords_46_js__ || {default: $___46__46__47_cell_47_coords_46_js__}).WalkontableCellCoords;
- var WalkontableCellRange = function WalkontableCellRange(highlight, from, to) {
- this.highlight = highlight;
- this.from = from;
- this.to = to;
- };
- var $WalkontableCellRange = WalkontableCellRange;
- ($traceurRuntime.createClass)(WalkontableCellRange, {
- isValid: function(wotInstance) {
- return this.from.isValid(wotInstance) && this.to.isValid(wotInstance);
- },
- isSingle: function() {
- return this.from.row === this.to.row && this.from.col === this.to.col;
- },
- getHeight: function() {
- return Math.max(this.from.row, this.to.row) - Math.min(this.from.row, this.to.row) + 1;
- },
- getWidth: function() {
- return Math.max(this.from.col, this.to.col) - Math.min(this.from.col, this.to.col) + 1;
- },
- includes: function(cellCoords) {
- var topLeft = this.getTopLeftCorner();
- var bottomRight = this.getBottomRightCorner();
- if (cellCoords.row < 0) {
- cellCoords.row = 0;
- }
- if (cellCoords.col < 0) {
- cellCoords.col = 0;
- }
- return topLeft.row <= cellCoords.row && bottomRight.row >= cellCoords.row && topLeft.col <= cellCoords.col && bottomRight.col >= cellCoords.col;
- },
- includesRange: function(testedRange) {
- return this.includes(testedRange.getTopLeftCorner()) && this.includes(testedRange.getBottomRightCorner());
- },
- isEqual: function(testedRange) {
- 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));
- },
- overlaps: function(testedRange) {
- return testedRange.isSouthEastOf(this.getTopLeftCorner()) && testedRange.isNorthWestOf(this.getBottomRightCorner());
- },
- isSouthEastOf: function(testedCoords) {
- return this.getTopLeftCorner().isSouthEastOf(testedCoords) || this.getBottomRightCorner().isSouthEastOf(testedCoords);
- },
- isNorthWestOf: function(testedCoords) {
- return this.getTopLeftCorner().isNorthWestOf(testedCoords) || this.getBottomRightCorner().isNorthWestOf(testedCoords);
- },
- expand: function(cellCoords) {
- var topLeft = this.getTopLeftCorner();
- var bottomRight = this.getBottomRightCorner();
- if (cellCoords.row < topLeft.row || cellCoords.col < topLeft.col || cellCoords.row > bottomRight.row || cellCoords.col > bottomRight.col) {
- this.from = new WalkontableCellCoords(Math.min(topLeft.row, cellCoords.row), Math.min(topLeft.col, cellCoords.col));
- this.to = new WalkontableCellCoords(Math.max(bottomRight.row, cellCoords.row), Math.max(bottomRight.col, cellCoords.col));
- return true;
- }
- return false;
- },
- expandByRange: function(expandingRange) {
- if (this.includesRange(expandingRange) || !this.overlaps(expandingRange)) {
- return false;
- }
- var topLeft = this.getTopLeftCorner();
- var bottomRight = this.getBottomRightCorner();
- var topRight = this.getTopRightCorner();
- var bottomLeft = this.getBottomLeftCorner();
- var expandingTopLeft = expandingRange.getTopLeftCorner();
- var expandingBottomRight = expandingRange.getBottomRightCorner();
- var resultTopRow = Math.min(topLeft.row, expandingTopLeft.row);
- var resultTopCol = Math.min(topLeft.col, expandingTopLeft.col);
- var resultBottomRow = Math.max(bottomRight.row, expandingBottomRight.row);
- var resultBottomCol = Math.max(bottomRight.col, expandingBottomRight.col);
- var finalFrom = new WalkontableCellCoords(resultTopRow, resultTopCol),
- finalTo = new WalkontableCellCoords(resultBottomRow, resultBottomCol);
- var isCorner = new $WalkontableCellRange(finalFrom, finalFrom, finalTo).isCorner(this.from, expandingRange),
- onlyMerge = expandingRange.isEqual(new $WalkontableCellRange(finalFrom, finalFrom, finalTo));
- if (isCorner && !onlyMerge) {
- if (this.from.col > finalFrom.col) {
- finalFrom.col = resultBottomCol;
- finalTo.col = resultTopCol;
- }
- if (this.from.row > finalFrom.row) {
- finalFrom.row = resultBottomRow;
- finalTo.row = resultTopRow;
- }
- }
- this.from = finalFrom;
- this.to = finalTo;
- return true;
- },
- getDirection: function() {
- if (this.from.isNorthWestOf(this.to)) {
- return 'NW-SE';
- } else if (this.from.isNorthEastOf(this.to)) {
- return 'NE-SW';
- } else if (this.from.isSouthEastOf(this.to)) {
- return 'SE-NW';
- } else if (this.from.isSouthWestOf(this.to)) {
- return 'SW-NE';
- }
- },
- setDirection: function(direction) {
- switch (direction) {
- case 'NW-SE':
- this.from = this.getTopLeftCorner();
- this.to = this.getBottomRightCorner();
- break;
- case 'NE-SW':
- this.from = this.getTopRightCorner();
- this.to = this.getBottomLeftCorner();
- break;
- case 'SE-NW':
- this.from = this.getBottomRightCorner();
- this.to = this.getTopLeftCorner();
- break;
- case 'SW-NE':
- this.from = this.getBottomLeftCorner();
- this.to = this.getTopRightCorner();
- break;
- }
- },
- getTopLeftCorner: function() {
- return new WalkontableCellCoords(Math.min(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
- },
- getBottomRightCorner: function() {
- return new WalkontableCellCoords(Math.max(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
- },
- getTopRightCorner: function() {
- return new WalkontableCellCoords(Math.min(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
- },
- getBottomLeftCorner: function() {
- return new WalkontableCellCoords(Math.max(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
- },
- isCorner: function(coords, expandedRange) {
- if (expandedRange) {
- if (expandedRange.includes(coords)) {
- 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))) {
- return true;
- }
- }
- }
- return coords.isEqual(this.getTopLeftCorner()) || coords.isEqual(this.getTopRightCorner()) || coords.isEqual(this.getBottomLeftCorner()) || coords.isEqual(this.getBottomRightCorner());
- },
- getOppositeCorner: function(coords, expandedRange) {
- if (!(coords instanceof WalkontableCellCoords)) {
- return false;
- }
- if (expandedRange) {
- if (expandedRange.includes(coords)) {
- if (this.getTopLeftCorner().isEqual(new WalkontableCellCoords(expandedRange.from.row, expandedRange.from.col))) {
- return this.getBottomRightCorner();
- }
- if (this.getTopRightCorner().isEqual(new WalkontableCellCoords(expandedRange.from.row, expandedRange.to.col))) {
- return this.getBottomLeftCorner();
- }
- if (this.getBottomLeftCorner().isEqual(new WalkontableCellCoords(expandedRange.to.row, expandedRange.from.col))) {
- return this.getTopRightCorner();
- }
- if (this.getBottomRightCorner().isEqual(new WalkontableCellCoords(expandedRange.to.row, expandedRange.to.col))) {
- return this.getTopLeftCorner();
- }
- }
- }
- if (coords.isEqual(this.getBottomRightCorner())) {
- return this.getTopLeftCorner();
- } else if (coords.isEqual(this.getTopLeftCorner())) {
- return this.getBottomRightCorner();
- } else if (coords.isEqual(this.getTopRightCorner())) {
- return this.getBottomLeftCorner();
- } else if (coords.isEqual(this.getBottomLeftCorner())) {
- return this.getTopRightCorner();
- }
- },
- getBordersSharedWith: function(range) {
- if (!this.includesRange(range)) {
- return [];
- }
- var thisBorders = {
- top: Math.min(this.from.row, this.to.row),
- bottom: Math.max(this.from.row, this.to.row),
- left: Math.min(this.from.col, this.to.col),
- right: Math.max(this.from.col, this.to.col)
- };
- var rangeBorders = {
- top: Math.min(range.from.row, range.to.row),
- bottom: Math.max(range.from.row, range.to.row),
- left: Math.min(range.from.col, range.to.col),
- right: Math.max(range.from.col, range.to.col)
- };
- var result = [];
- if (thisBorders.top == rangeBorders.top) {
- result.push('top');
- }
- if (thisBorders.right == rangeBorders.right) {
- result.push('right');
- }
- if (thisBorders.bottom == rangeBorders.bottom) {
- result.push('bottom');
- }
- if (thisBorders.left == rangeBorders.left) {
- result.push('left');
- }
- return result;
- },
- getInner: function() {
- var topLeft = this.getTopLeftCorner();
- var bottomRight = this.getBottomRightCorner();
- var out = [];
- for (var r = topLeft.row; r <= bottomRight.row; r++) {
- for (var c = topLeft.col; c <= bottomRight.col; c++) {
- if (!(this.from.row === r && this.from.col === c) && !(this.to.row === r && this.to.col === c)) {
- out.push(new WalkontableCellCoords(r, c));
- }
- }
- }
- return out;
- },
- getAll: function() {
- var topLeft = this.getTopLeftCorner();
- var bottomRight = this.getBottomRightCorner();
- var out = [];
- for (var r = topLeft.row; r <= bottomRight.row; r++) {
- for (var c = topLeft.col; c <= bottomRight.col; c++) {
- if (topLeft.row === r && topLeft.col === c) {
- out.push(topLeft);
- } else if (bottomRight.row === r && bottomRight.col === c) {
- out.push(bottomRight);
- } else {
- out.push(new WalkontableCellCoords(r, c));
- }
- }
- }
- return out;
- },
- forAll: function(callback) {
- var topLeft = this.getTopLeftCorner();
- var bottomRight = this.getBottomRightCorner();
- for (var r = topLeft.row; r <= bottomRight.row; r++) {
- for (var c = topLeft.col; c <= bottomRight.col; c++) {
- var breakIteration = callback(r, c);
- if (breakIteration === false) {
- return;
- }
- }
- }
- }
- }, {});
- ;
- window.WalkontableCellRange = WalkontableCellRange;
-
- //#
- },{"./../cell/coords.js":5}],7:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- Walkontable: {get: function() {
- return Walkontable;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47__46__46__47_helpers_46_js__,
- $__event_46_js__,
- $__overlays_46_js__,
- $__scroll_46_js__,
- $__settings_46_js__,
- $__table_46_js__,
- $__viewport_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../dom.js"), $___46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_dom_46_js__});
- var randomString = ($___46__46__47__46__46__47__46__46__47_helpers_46_js__ = require("./../../../helpers.js"), $___46__46__47__46__46__47__46__46__47_helpers_46_js__ && $___46__46__47__46__46__47__46__46__47_helpers_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_helpers_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_helpers_46_js__}).randomString;
- var WalkontableEvent = ($__event_46_js__ = require("./event.js"), $__event_46_js__ && $__event_46_js__.__esModule && $__event_46_js__ || {default: $__event_46_js__}).WalkontableEvent;
- var WalkontableOverlays = ($__overlays_46_js__ = require("./overlays.js"), $__overlays_46_js__ && $__overlays_46_js__.__esModule && $__overlays_46_js__ || {default: $__overlays_46_js__}).WalkontableOverlays;
- var WalkontableScroll = ($__scroll_46_js__ = require("./scroll.js"), $__scroll_46_js__ && $__scroll_46_js__.__esModule && $__scroll_46_js__ || {default: $__scroll_46_js__}).WalkontableScroll;
- var WalkontableSettings = ($__settings_46_js__ = require("./settings.js"), $__settings_46_js__ && $__settings_46_js__.__esModule && $__settings_46_js__ || {default: $__settings_46_js__}).WalkontableSettings;
- var WalkontableTable = ($__table_46_js__ = require("./table.js"), $__table_46_js__ && $__table_46_js__.__esModule && $__table_46_js__ || {default: $__table_46_js__}).WalkontableTable;
- var WalkontableViewport = ($__viewport_46_js__ = require("./viewport.js"), $__viewport_46_js__ && $__viewport_46_js__.__esModule && $__viewport_46_js__ || {default: $__viewport_46_js__}).WalkontableViewport;
- var Walkontable = function Walkontable(settings) {
- var originalHeaders = [];
- this.guid = 'wt_' + randomString();
- if (settings.cloneSource) {
- this.cloneSource = settings.cloneSource;
- this.cloneOverlay = settings.cloneOverlay;
- this.wtSettings = settings.cloneSource.wtSettings;
- this.wtTable = new WalkontableTable(this, settings.table, settings.wtRootElement);
- this.wtScroll = new WalkontableScroll(this);
- this.wtViewport = settings.cloneSource.wtViewport;
- this.wtEvent = new WalkontableEvent(this);
- this.selections = this.cloneSource.selections;
- } else {
- this.wtSettings = new WalkontableSettings(this, settings);
- this.wtTable = new WalkontableTable(this, settings.table);
- this.wtScroll = new WalkontableScroll(this);
- this.wtViewport = new WalkontableViewport(this);
- this.wtEvent = new WalkontableEvent(this);
- this.selections = this.getSetting('selections');
- this.wtOverlays = new WalkontableOverlays(this);
- }
- if (this.wtTable.THEAD.childNodes.length && this.wtTable.THEAD.childNodes[0].childNodes.length) {
- for (var c = 0,
- clen = this.wtTable.THEAD.childNodes[0].childNodes.length; c < clen; c++) {
- originalHeaders.push(this.wtTable.THEAD.childNodes[0].childNodes[c].innerHTML);
- }
- if (!this.getSetting('columnHeaders').length) {
- this.update('columnHeaders', [function(column, TH) {
- dom.fastInnerText(TH, originalHeaders[column]);
- }]);
- }
- }
- this.drawn = false;
- this.drawInterrupted = false;
- };
- ($traceurRuntime.createClass)(Walkontable, {
- draw: function() {
- var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
- this.drawInterrupted = false;
- if (!fastDraw && !dom.isVisible(this.wtTable.TABLE)) {
- this.drawInterrupted = true;
- } else {
- this.wtTable.draw(fastDraw);
- }
- return this;
- },
- getCell: function(coords) {
- var topmost = arguments[1] !== (void 0) ? arguments[1] : false;
- if (!topmost) {
- return this.wtTable.getCell(coords);
- }
- var fixedRows = this.wtSettings.getSetting('fixedRowsTop');
- var fixedColumns = this.wtSettings.getSetting('fixedColumnsLeft');
- if (coords.row < fixedRows && coords.col < fixedColumns) {
- return this.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell(coords);
- } else if (coords.row < fixedRows) {
- return this.wtOverlays.topOverlay.clone.wtTable.getCell(coords);
- } else if (coords.col < fixedColumns) {
- return this.wtOverlays.leftOverlay.clone.wtTable.getCell(coords);
- }
- return this.wtTable.getCell(coords);
- },
- update: function(settings, value) {
- return this.wtSettings.update(settings, value);
- },
- scrollVertical: function(row) {
- this.wtOverlays.topOverlay.scrollTo(row);
- this.getSetting('onScrollVertically');
- return this;
- },
- scrollHorizontal: function(column) {
- this.wtOverlays.leftOverlay.scrollTo(column);
- this.getSetting('onScrollHorizontally');
- return this;
- },
- scrollViewport: function(coords) {
- this.wtScroll.scrollViewport(coords);
- return this;
- },
- getViewport: function() {
- return [this.wtTable.getFirstVisibleRow(), this.wtTable.getFirstVisibleColumn(), this.wtTable.getLastVisibleRow(), this.wtTable.getLastVisibleColumn()];
- },
- getOverlayName: function() {
- return this.cloneOverlay ? this.cloneOverlay.type : 'master';
- },
- getSetting: function(key, param1, param2, param3, param4) {
- return this.wtSettings.getSetting(key, param1, param2, param3, param4);
- },
- hasSetting: function(key) {
- return this.wtSettings.has(key);
- },
- destroy: function() {
- this.wtOverlays.destroy();
- if (this.wtEvent) {
- this.wtEvent.destroy();
- }
- }
- }, {});
- ;
- window.Walkontable = Walkontable;
-
- //#
- },{"./../../../dom.js":27,"./../../../helpers.js":42,"./event.js":8,"./overlays.js":16,"./scroll.js":17,"./settings.js":19,"./table.js":20,"./viewport.js":22}],8:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableEvent: {get: function() {
- return WalkontableEvent;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47__46__46__47_eventManager_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../dom.js"), $___46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47__46__46__47__46__46__47_eventManager_46_js__ = require("./../../../eventManager.js"), $___46__46__47__46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- function WalkontableEvent(instance) {
- var that = this;
- var eventManager = eventManagerObject(instance);
- this.instance = instance;
- var dblClickOrigin = [null, null];
- this.dblClickTimeout = [null, null];
- var onMouseDown = function(event) {
- var cell = that.parentCell(event.realTarget);
- if (dom.hasClass(event.realTarget, 'corner')) {
- that.instance.getSetting('onCellCornerMouseDown', event, event.realTarget);
- } else if (cell.TD) {
- if (that.instance.hasSetting('onCellMouseDown')) {
- that.instance.getSetting('onCellMouseDown', event, cell.coords, cell.TD, that.instance);
- }
- }
- if (event.button !== 2) {
- if (cell.TD) {
- dblClickOrigin[0] = cell.TD;
- clearTimeout(that.dblClickTimeout[0]);
- that.dblClickTimeout[0] = setTimeout(function() {
- dblClickOrigin[0] = null;
- }, 1000);
- }
- }
- };
- var onTouchMove = function(event) {
- that.instance.touchMoving = true;
- };
- var longTouchTimeout;
- var onTouchStart = function(event) {
- var container = this;
- eventManager.addEventListener(this, 'touchmove', onTouchMove);
- that.checkIfTouchMove = setTimeout(function() {
- if (that.instance.touchMoving === true) {
- that.instance.touchMoving = void 0;
- eventManager.removeEventListener("touchmove", onTouchMove, false);
- return;
- } else {
- onMouseDown(event);
- }
- }, 30);
- };
- var lastMouseOver;
- var onMouseOver = function(event) {
- var table,
- td;
- if (that.instance.hasSetting('onCellMouseOver')) {
- table = that.instance.wtTable.TABLE;
- td = dom.closest(event.realTarget, ['TD', 'TH'], table);
- if (td && td !== lastMouseOver && dom.isChildOf(td, table)) {
- lastMouseOver = td;
- that.instance.getSetting('onCellMouseOver', event, that.instance.wtTable.getCoords(td), td, that.instance);
- }
- }
- };
- var onMouseUp = function(event) {
- if (event.button !== 2) {
- var cell = that.parentCell(event.realTarget);
- if (cell.TD === dblClickOrigin[0] && cell.TD === dblClickOrigin[1]) {
- if (dom.hasClass(event.realTarget, 'corner')) {
- that.instance.getSetting('onCellCornerDblClick', event, cell.coords, cell.TD, that.instance);
- } else {
- that.instance.getSetting('onCellDblClick', event, cell.coords, cell.TD, that.instance);
- }
- dblClickOrigin[0] = null;
- dblClickOrigin[1] = null;
- } else if (cell.TD === dblClickOrigin[0]) {
- dblClickOrigin[1] = cell.TD;
- clearTimeout(that.dblClickTimeout[1]);
- that.dblClickTimeout[1] = setTimeout(function() {
- dblClickOrigin[1] = null;
- }, 500);
- }
- }
- };
- var onTouchEnd = function(event) {
- clearTimeout(longTouchTimeout);
- event.preventDefault();
- onMouseUp(event);
- };
- eventManager.addEventListener(this.instance.wtTable.holder, 'mousedown', onMouseDown);
- eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseover', onMouseOver);
- eventManager.addEventListener(this.instance.wtTable.holder, 'mouseup', onMouseUp);
- if (this.instance.wtTable.holder.parentNode.parentNode && Handsontable.mobileBrowser && !that.instance.wtTable.isWorkingOnClone()) {
- var classSelector = "." + this.instance.wtTable.holder.parentNode.className.split(" ").join(".");
- eventManager.addEventListener(this.instance.wtTable.holder, 'touchstart', function(event) {
- that.instance.touchApplied = true;
- if (dom.isChildOf(event.target, classSelector)) {
- onTouchStart.call(event.target, event);
- }
- });
- eventManager.addEventListener(this.instance.wtTable.holder, 'touchend', function(event) {
- that.instance.touchApplied = false;
- if (dom.isChildOf(event.target, classSelector)) {
- onTouchEnd.call(event.target, event);
- }
- });
- if (!that.instance.momentumScrolling) {
- that.instance.momentumScrolling = {};
- }
- eventManager.addEventListener(this.instance.wtTable.holder, 'scroll', function(event) {
- clearTimeout(that.instance.momentumScrolling._timeout);
- if (!that.instance.momentumScrolling.ongoing) {
- that.instance.getSetting('onBeforeTouchScroll');
- }
- that.instance.momentumScrolling.ongoing = true;
- that.instance.momentumScrolling._timeout = setTimeout(function() {
- if (!that.instance.touchApplied) {
- that.instance.momentumScrolling.ongoing = false;
- that.instance.getSetting('onAfterMomentumScroll');
- }
- }, 200);
- });
- }
- eventManager.addEventListener(window, 'resize', function() {
- if (that.instance.getSetting('stretchH') !== 'none') {
- that.instance.draw();
- }
- });
- this.destroy = function() {
- clearTimeout(this.dblClickTimeout[0]);
- clearTimeout(this.dblClickTimeout[1]);
- eventManager.clear();
- };
- }
- WalkontableEvent.prototype.parentCell = function(elem) {
- var cell = {};
- var TABLE = this.instance.wtTable.TABLE;
- var TD = dom.closest(elem, ['TD', 'TH'], TABLE);
- if (TD && dom.isChildOf(TD, TABLE)) {
- cell.coords = this.instance.wtTable.getCoords(TD);
- cell.TD = TD;
- } else if (dom.hasClass(elem, 'wtBorder') && dom.hasClass(elem, 'current')) {
- cell.coords = this.instance.selections.current.cellRange.highlight;
- cell.TD = this.instance.wtTable.getCell(cell.coords);
- } else if (dom.hasClass(elem, 'wtBorder') && dom.hasClass(elem, 'area')) {
- if (this.instance.selections.area.cellRange) {
- cell.coords = this.instance.selections.area.cellRange.to;
- cell.TD = this.instance.wtTable.getCell(cell.coords);
- }
- }
- return cell;
- };
- ;
- window.WalkontableEvent = WalkontableEvent;
-
- //#
- },{"./../../../dom.js":27,"./../../../eventManager.js":41}],9:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableColumnFilter: {get: function() {
- return WalkontableColumnFilter;
- }},
- __esModule: {value: true}
- });
- var WalkontableColumnFilter = function WalkontableColumnFilter(offset, total, countTH) {
- this.offset = offset;
- this.total = total;
- this.countTH = countTH;
- };
- ($traceurRuntime.createClass)(WalkontableColumnFilter, {
- offsetted: function(index) {
- return index + this.offset;
- },
- unOffsetted: function(index) {
- return index - this.offset;
- },
- renderedToSource: function(index) {
- return this.offsetted(index);
- },
- sourceToRendered: function(index) {
- return this.unOffsetted(index);
- },
- offsettedTH: function(index) {
- return index - this.countTH;
- },
- unOffsettedTH: function(index) {
- return index + this.countTH;
- },
- visibleRowHeadedColumnToSourceColumn: function(index) {
- return this.renderedToSource(this.offsettedTH(index));
- },
- sourceColumnToVisibleRowHeadedColumn: function(index) {
- return this.unOffsettedTH(this.sourceToRendered(index));
- }
- }, {});
- ;
- window.WalkontableColumnFilter = WalkontableColumnFilter;
-
- //#
- },{}],10:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableRowFilter: {get: function() {
- return WalkontableRowFilter;
- }},
- __esModule: {value: true}
- });
- var WalkontableRowFilter = function WalkontableRowFilter(offset, total, countTH) {
- this.offset = offset;
- this.total = total;
- this.countTH = countTH;
- };
- ($traceurRuntime.createClass)(WalkontableRowFilter, {
- offsetted: function(index) {
- return index + this.offset;
- },
- unOffsetted: function(index) {
- return index - this.offset;
- },
- renderedToSource: function(index) {
- return this.offsetted(index);
- },
- sourceToRendered: function(index) {
- return this.unOffsetted(index);
- },
- offsettedTH: function(index) {
- return index - this.countTH;
- },
- unOffsettedTH: function(index) {
- return index + this.countTH;
- },
- visibleColHeadedRowToSourceRow: function(index) {
- return this.renderedToSource(this.offsettedTH(index));
- },
- sourceRowToVisibleColHeadedRow: function(index) {
- return this.unOffsettedTH(this.sourceToRendered(index));
- }
- }, {});
- ;
- window.WalkontableRowFilter = WalkontableRowFilter;
-
- //#
- },{}],11:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableOverlay: {get: function() {
- return WalkontableOverlay;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_46_js__,
- $___46__46__47__46__46__47__46__46__47__46__46__47_eventManager_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../../dom.js"), $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__});
- var defineGetter = ($___46__46__47__46__46__47__46__46__47__46__46__47_helpers_46_js__ = require("./../../../../helpers.js"), $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_46_js__ && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_46_js__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_46_js__}).defineGetter;
- var eventManagerObject = ($___46__46__47__46__46__47__46__46__47__46__46__47_eventManager_46_js__ = require("./../../../../eventManager.js"), $___46__46__47__46__46__47__46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47__46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var WalkontableOverlay = function WalkontableOverlay(wotInstance) {
- defineGetter(this, 'wot', wotInstance, {writable: false});
- this.instance = this.wot;
- this.type = '';
- this.TABLE = this.wot.wtTable.TABLE;
- this.hider = this.wot.wtTable.hider;
- this.spreader = this.wot.wtTable.spreader;
- this.holder = this.wot.wtTable.holder;
- this.wtRootElement = this.wot.wtTable.wtRootElement;
- this.trimmingContainer = dom.getTrimmingContainer(this.hider.parentNode.parentNode);
- this.mainTableScrollableElement = dom.getScrollableElement(this.wot.wtTable.TABLE);
- this.needFullRender = this.shouldBeRendered();
- this.isElementSizesAdjusted = false;
- };
- var $WalkontableOverlay = WalkontableOverlay;
- ($traceurRuntime.createClass)(WalkontableOverlay, {
- shouldBeRendered: function() {
- return true;
- },
- makeClone: function(direction) {
- if ($WalkontableOverlay.CLONE_TYPES.indexOf(direction) === -1) {
- throw new Error('Clone type "' + direction + '" is not supported.');
- }
- var clone = document.createElement('DIV');
- var clonedTable = document.createElement('TABLE');
- clone.className = 'ht_clone_' + direction + ' handsontable';
- clone.style.position = 'absolute';
- clone.style.top = 0;
- clone.style.left = 0;
- clone.style.overflow = 'hidden';
- clonedTable.className = this.wot.wtTable.TABLE.className;
- clone.appendChild(clonedTable);
- this.type = direction;
- this.wot.wtTable.wtRootElement.parentNode.appendChild(clone);
- return new Walkontable({
- cloneSource: this.wot,
- cloneOverlay: this,
- table: clonedTable
- });
- },
- refresh: function() {
- var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
- var nextCycleRenderFlag = this.shouldBeRendered();
- if (this.clone && (this.needFullRender || nextCycleRenderFlag)) {
- this.clone.draw(fastDraw);
- }
- this.needFullRender = nextCycleRenderFlag;
- },
- destroy: function() {
- eventManagerObject(this.clone).clear();
- }
- }, {
- get CLONE_TOP() {
- return 'top';
- },
- get CLONE_LEFT() {
- return 'left';
- },
- get CLONE_CORNER() {
- return 'corner';
- },
- get CLONE_DEBUG() {
- return 'debug';
- },
- get CLONE_TYPES() {
- return [$WalkontableOverlay.CLONE_TOP, $WalkontableOverlay.CLONE_LEFT, $WalkontableOverlay.CLONE_CORNER, $WalkontableOverlay.CLONE_DEBUG];
- }
- });
- ;
- window.WalkontableOverlay = WalkontableOverlay;
-
- //#
- },{"./../../../../dom.js":27,"./../../../../eventManager.js":41,"./../../../../helpers.js":42}],12:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableCornerOverlay: {get: function() {
- return WalkontableCornerOverlay;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__,
- $___95_base_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../../dom.js"), $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__});
- var WalkontableOverlay = ($___95_base_46_js__ = require("./_base.js"), $___95_base_46_js__ && $___95_base_46_js__.__esModule && $___95_base_46_js__ || {default: $___95_base_46_js__}).WalkontableOverlay;
- var WalkontableCornerOverlay = function WalkontableCornerOverlay(wotInstance) {
- $traceurRuntime.superConstructor($WalkontableCornerOverlay).call(this, wotInstance);
- this.clone = this.makeClone(WalkontableOverlay.CLONE_CORNER);
- };
- var $WalkontableCornerOverlay = WalkontableCornerOverlay;
- ($traceurRuntime.createClass)(WalkontableCornerOverlay, {
- shouldBeRendered: function() {
- return (this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length) && (this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length) ? true : false;
- },
- resetFixedPosition: function() {
- if (!this.wot.wtTable.holder.parentNode) {
- return;
- }
- var overlayRoot = this.clone.wtTable.holder.parentNode;
- var tableHeight = dom.outerHeight(this.clone.wtTable.TABLE);
- var tableWidth = dom.outerWidth(this.clone.wtTable.TABLE);
- if (this.trimmingContainer === window) {
- var box = this.wot.wtTable.hider.getBoundingClientRect();
- var top = Math.ceil(box.top);
- var left = Math.ceil(box.left);
- var bottom = Math.ceil(box.bottom);
- var right = Math.ceil(box.right);
- var finalLeft;
- var finalTop;
- if (left < 0 && (right - overlayRoot.offsetWidth) > 0) {
- finalLeft = -left + 'px';
- } else {
- finalLeft = '0';
- }
- if (top < 0 && (bottom - overlayRoot.offsetHeight) > 0) {
- finalTop = -top + 'px';
- } else {
- finalTop = '0';
- }
- dom.setOverlayPosition(overlayRoot, finalLeft, finalTop);
- }
- overlayRoot.style.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
- overlayRoot.style.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
- }
- }, {}, WalkontableOverlay);
- ;
- window.WalkontableCornerOverlay = WalkontableCornerOverlay;
-
- //#
- },{"./../../../../dom.js":27,"./_base.js":11}],13:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableDebugOverlay: {get: function() {
- return WalkontableDebugOverlay;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__,
- $___95_base_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../../dom.js"), $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__});
- var WalkontableOverlay = ($___95_base_46_js__ = require("./_base.js"), $___95_base_46_js__ && $___95_base_46_js__.__esModule && $___95_base_46_js__ || {default: $___95_base_46_js__}).WalkontableOverlay;
- var WalkontableDebugOverlay = function WalkontableDebugOverlay(wotInstance) {
- $traceurRuntime.superConstructor($WalkontableDebugOverlay).call(this, wotInstance);
- this.clone = this.makeClone(WalkontableOverlay.CLONE_DEBUG);
- this.clone.wtTable.holder.style.opacity = 0.4;
- this.clone.wtTable.holder.style.textShadow = '0 0 2px #ff0000';
- dom.addClass(this.clone.wtTable.holder.parentNode, 'wtDebugVisible');
- };
- var $WalkontableDebugOverlay = WalkontableDebugOverlay;
- ($traceurRuntime.createClass)(WalkontableDebugOverlay, {}, {}, WalkontableOverlay);
- ;
- window.WalkontableDebugOverlay = WalkontableDebugOverlay;
-
- //#
- },{"./../../../../dom.js":27,"./_base.js":11}],14:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableLeftOverlay: {get: function() {
- return WalkontableLeftOverlay;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__,
- $___95_base_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../../dom.js"), $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__});
- var WalkontableOverlay = ($___95_base_46_js__ = require("./_base.js"), $___95_base_46_js__ && $___95_base_46_js__.__esModule && $___95_base_46_js__ || {default: $___95_base_46_js__}).WalkontableOverlay;
- var WalkontableLeftOverlay = function WalkontableLeftOverlay(wotInstance) {
- $traceurRuntime.superConstructor($WalkontableLeftOverlay).call(this, wotInstance);
- this.clone = this.makeClone(WalkontableOverlay.CLONE_LEFT);
- };
- var $WalkontableLeftOverlay = WalkontableLeftOverlay;
- ($traceurRuntime.createClass)(WalkontableLeftOverlay, {
- shouldBeRendered: function() {
- return this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length ? true : false;
- },
- resetFixedPosition: function() {
- if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
- return;
- }
- var overlayRoot = this.clone.wtTable.holder.parentNode;
- var headerPosition = 0;
- if (this.trimmingContainer === window) {
- var box = this.wot.wtTable.hider.getBoundingClientRect();
- var left = Math.ceil(box.left);
- var right = Math.ceil(box.right);
- var finalLeft;
- var finalTop;
- finalTop = this.wot.wtTable.hider.style.top;
- finalTop = finalTop === '' ? 0 : finalTop;
- if (left < 0 && (right - overlayRoot.offsetWidth) > 0) {
- finalLeft = -left;
- } else {
- finalLeft = 0;
- }
- headerPosition = finalLeft;
- finalLeft = finalLeft + 'px';
- dom.setOverlayPosition(overlayRoot, finalLeft, finalTop);
- } else {
- headerPosition = this.getScrollPosition();
- }
- this.adjustHeaderBordersPosition(headerPosition);
- },
- setScrollPosition: function(pos) {
- if (this.mainTableScrollableElement === window) {
- window.scrollTo(pos, dom.getWindowScrollTop());
- } else {
- this.mainTableScrollableElement.scrollLeft = pos;
- }
- },
- onScroll: function() {
- this.wot.getSetting('onScrollHorizontally');
- },
- sumCellSizes: function(from, to) {
- var sum = 0;
- var defaultColumnWidth = this.wot.wtSettings.defaultColumnWidth;
- while (from < to) {
- sum += this.wot.wtTable.getStretchedColumnWidth(from) || defaultColumnWidth;
- from++;
- }
- return sum;
- },
- adjustElementsSize: function() {
- var force = arguments[0] !== (void 0) ? arguments[0] : false;
- if (this.needFullRender || force) {
- this.adjustRootElementSize();
- this.adjustRootChildsSize();
- if (!force) {
- this.isElementSizesAdjusted = true;
- }
- }
- },
- adjustRootElementSize: function() {
- var masterHolder = this.wot.wtTable.holder;
- var scrollbarHeight = masterHolder.clientHeight !== masterHolder.offsetHeight ? dom.getScrollbarWidth() : 0;
- var overlayRoot = this.clone.wtTable.holder.parentNode;
- var overlayRootStyle = overlayRoot.style;
- var tableWidth;
- if (this.trimmingContainer !== window) {
- overlayRootStyle.height = this.wot.wtViewport.getWorkspaceHeight() - scrollbarHeight + 'px';
- }
- this.clone.wtTable.holder.style.height = overlayRootStyle.height;
- tableWidth = dom.outerWidth(this.clone.wtTable.TABLE);
- overlayRootStyle.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
- },
- adjustRootChildsSize: function() {
- var scrollbarWidth = dom.getScrollbarWidth();
- this.clone.wtTable.hider.style.height = this.hider.style.height;
- this.clone.wtTable.holder.style.height = this.clone.wtTable.holder.parentNode.style.height;
- if (scrollbarWidth === 0) {
- scrollbarWidth = 30;
- }
- this.clone.wtTable.holder.style.width = parseInt(this.clone.wtTable.holder.parentNode.style.width, 10) + scrollbarWidth + 'px';
- },
- applyToDOM: function() {
- var total = this.wot.getSetting('totalColumns');
- if (!this.isElementSizesAdjusted) {
- this.adjustElementsSize();
- }
- if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
- this.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
- } else if (total === 0) {
- this.spreader.style.left = '0';
- } else {
- throw new Error('Incorrect value of the columnsRenderCalculator');
- }
- this.spreader.style.right = '';
- if (this.needFullRender) {
- this.syncOverlayOffset();
- }
- },
- syncOverlayOffset: function() {
- if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
- this.clone.wtTable.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
- } else {
- this.clone.wtTable.spreader.style.top = '';
- }
- },
- scrollTo: function(sourceCol, beyondRendered) {
- var newX = this.getTableParentOffset();
- var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
- var mainHolder = sourceInstance.wtTable.holder;
- var scrollbarCompensation = 0;
- if (beyondRendered && mainHolder.offsetWidth !== mainHolder.clientWidth) {
- scrollbarCompensation = dom.getScrollbarWidth();
- }
- if (beyondRendered) {
- newX += this.sumCellSizes(0, sourceCol + 1);
- newX -= this.wot.wtViewport.getViewportWidth();
- } else {
- newX += this.sumCellSizes(this.wot.getSetting('fixedColumnsLeft'), sourceCol);
- }
- newX += scrollbarCompensation;
- this.setScrollPosition(newX);
- },
- getTableParentOffset: function() {
- if (this.trimmingContainer === window) {
- return this.wot.wtTable.holderOffset.left;
- } else {
- return 0;
- }
- },
- getScrollPosition: function() {
- return dom.getScrollLeft(this.mainTableScrollableElement);
- },
- adjustHeaderBordersPosition: function(position) {
- if (this.wot.getSetting('fixedColumnsLeft') === 0 && this.wot.getSetting('rowHeaders').length > 0) {
- var masterParent = this.wot.wtTable.holder.parentNode;
- var previousState = dom.hasClass(masterParent, 'innerBorderLeft');
- if (position) {
- dom.addClass(masterParent, 'innerBorderLeft');
- } else {
- dom.removeClass(masterParent, 'innerBorderLeft');
- }
- if (!previousState && position || previousState && !position) {
- this.wot.wtOverlays.adjustElementsSize();
- }
- }
- }
- }, {}, WalkontableOverlay);
- ;
- window.WalkontableLeftOverlay = WalkontableLeftOverlay;
-
- //#
- },{"./../../../../dom.js":27,"./_base.js":11}],15:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableTopOverlay: {get: function() {
- return WalkontableTopOverlay;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__,
- $___95_base_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../../dom.js"), $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__});
- var WalkontableOverlay = ($___95_base_46_js__ = require("./_base.js"), $___95_base_46_js__ && $___95_base_46_js__.__esModule && $___95_base_46_js__ || {default: $___95_base_46_js__}).WalkontableOverlay;
- var WalkontableTopOverlay = function WalkontableTopOverlay(wotInstance) {
- $traceurRuntime.superConstructor($WalkontableTopOverlay).call(this, wotInstance);
- this.clone = this.makeClone(WalkontableOverlay.CLONE_TOP);
- };
- var $WalkontableTopOverlay = WalkontableTopOverlay;
- ($traceurRuntime.createClass)(WalkontableTopOverlay, {
- shouldBeRendered: function() {
- return this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length ? true : false;
- },
- resetFixedPosition: function() {
- if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
- return;
- }
- var overlayRoot = this.clone.wtTable.holder.parentNode;
- var headerPosition = 0;
- if (this.wot.wtOverlays.leftOverlay.trimmingContainer === window) {
- var box = this.wot.wtTable.hider.getBoundingClientRect();
- var top = Math.ceil(box.top);
- var bottom = Math.ceil(box.bottom);
- var finalLeft;
- var finalTop;
- finalLeft = this.wot.wtTable.hider.style.left;
- finalLeft = finalLeft === '' ? 0 : finalLeft;
- if (top < 0 && (bottom - overlayRoot.offsetHeight) > 0) {
- finalTop = -top;
- } else {
- finalTop = 0;
- }
- headerPosition = finalTop;
- finalTop = finalTop + 'px';
- dom.setOverlayPosition(overlayRoot, finalLeft, finalTop);
- } else {
- headerPosition = this.getScrollPosition();
- }
- this.adjustHeaderBordersPosition(headerPosition);
- },
- setScrollPosition: function(pos) {
- if (this.mainTableScrollableElement === window) {
- window.scrollTo(dom.getWindowScrollLeft(), pos);
- } else {
- this.mainTableScrollableElement.scrollTop = pos;
- }
- },
- onScroll: function() {
- this.wot.getSetting('onScrollVertically');
- },
- sumCellSizes: function(from, to) {
- var sum = 0;
- var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
- while (from < to) {
- sum += this.wot.wtTable.getRowHeight(from) || defaultRowHeight;
- from++;
- }
- return sum;
- },
- adjustElementsSize: function() {
- var force = arguments[0] !== (void 0) ? arguments[0] : false;
- if (this.needFullRender || force) {
- this.adjustRootElementSize();
- this.adjustRootChildsSize();
- if (!force) {
- this.isElementSizesAdjusted = true;
- }
- }
- },
- adjustRootElementSize: function() {
- var masterHolder = this.wot.wtTable.holder;
- var scrollbarWidth = masterHolder.clientWidth !== masterHolder.offsetWidth ? dom.getScrollbarWidth() : 0;
- var overlayRoot = this.clone.wtTable.holder.parentNode;
- var overlayRootStyle = overlayRoot.style;
- var tableHeight;
- if (this.trimmingContainer !== window) {
- overlayRootStyle.width = this.wot.wtViewport.getWorkspaceWidth() - scrollbarWidth + 'px';
- }
- this.clone.wtTable.holder.style.width = overlayRootStyle.width;
- tableHeight = dom.outerHeight(this.clone.wtTable.TABLE);
- overlayRootStyle.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
- },
- adjustRootChildsSize: function() {
- var scrollbarWidth = dom.getScrollbarWidth();
- this.clone.wtTable.hider.style.width = this.hider.style.width;
- this.clone.wtTable.holder.style.width = this.clone.wtTable.holder.parentNode.style.width;
- if (scrollbarWidth === 0) {
- scrollbarWidth = 30;
- }
- this.clone.wtTable.holder.style.height = parseInt(this.clone.wtTable.holder.parentNode.style.height, 10) + scrollbarWidth + 'px';
- },
- applyToDOM: function() {
- var total = this.wot.getSetting('totalRows');
- if (!this.isElementSizesAdjusted) {
- this.adjustElementsSize();
- }
- if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
- this.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
- } else if (total === 0) {
- this.spreader.style.top = '0';
- } else {
- throw new Error("Incorrect value of the rowsRenderCalculator");
- }
- this.spreader.style.bottom = '';
- if (this.needFullRender) {
- this.syncOverlayOffset();
- }
- },
- syncOverlayOffset: function() {
- if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
- this.clone.wtTable.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
- } else {
- this.clone.wtTable.spreader.style.left = '';
- }
- },
- scrollTo: function(sourceRow, bottomEdge) {
- var newY = this.getTableParentOffset();
- var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
- var mainHolder = sourceInstance.wtTable.holder;
- var scrollbarCompensation = 0;
- if (bottomEdge && mainHolder.offsetHeight !== mainHolder.clientHeight) {
- scrollbarCompensation = dom.getScrollbarWidth();
- }
- if (bottomEdge) {
- newY += this.sumCellSizes(0, sourceRow + 1);
- newY -= this.wot.wtViewport.getViewportHeight();
- newY += 1;
- } else {
- newY += this.sumCellSizes(this.wot.getSetting('fixedRowsTop'), sourceRow);
- }
- newY += scrollbarCompensation;
- this.setScrollPosition(newY);
- },
- getTableParentOffset: function() {
- if (this.mainTableScrollableElement === window) {
- return this.wot.wtTable.holderOffset.top;
- } else {
- return 0;
- }
- },
- getScrollPosition: function() {
- return dom.getScrollTop(this.mainTableScrollableElement);
- },
- adjustHeaderBordersPosition: function(position) {
- if (this.wot.getSetting('fixedRowsTop') === 0 && this.wot.getSetting('columnHeaders').length > 0) {
- var masterParent = this.wot.wtTable.holder.parentNode;
- var previousState = dom.hasClass(masterParent, 'innerBorderTop');
- if (position) {
- dom.addClass(masterParent, 'innerBorderTop');
- } else {
- dom.removeClass(masterParent, 'innerBorderTop');
- }
- if (!previousState && position || previousState && !position) {
- this.wot.wtOverlays.adjustElementsSize();
- }
- }
- if (this.wot.getSetting('rowHeaders').length === 0) {
- var secondHeaderCell = this.clone.wtTable.THEAD.querySelector('th:nth-of-type(2)');
- if (secondHeaderCell) {
- secondHeaderCell.style['border-left-width'] = 0;
- }
- }
- }
- }, {}, WalkontableOverlay);
- ;
- window.WalkontableTopOverlay = WalkontableTopOverlay;
-
- //#
- },{"./../../../../dom.js":27,"./_base.js":11}],16:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableOverlays: {get: function() {
- return WalkontableOverlays;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47__46__46__47_eventManager_46_js__,
- $__overlay_47_corner_46_js__,
- $__overlay_47_debug_46_js__,
- $__overlay_47_left_46_js__,
- $__overlay_47_top_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../dom.js"), $___46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_dom_46_js__});
- var EventManager = ($___46__46__47__46__46__47__46__46__47_eventManager_46_js__ = require("./../../../eventManager.js"), $___46__46__47__46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_eventManager_46_js__}).EventManager;
- var WalkontableCornerOverlay = ($__overlay_47_corner_46_js__ = require("./overlay/corner.js"), $__overlay_47_corner_46_js__ && $__overlay_47_corner_46_js__.__esModule && $__overlay_47_corner_46_js__ || {default: $__overlay_47_corner_46_js__}).WalkontableCornerOverlay;
- 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;
- 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;
- 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;
- var WalkontableOverlays = function WalkontableOverlays(wotInstance) {
- this.wot = wotInstance;
- this.instance = this.wot;
- this.eventManager = new EventManager(this.wot);
- this.wot.update('scrollbarWidth', dom.getScrollbarWidth());
- this.wot.update('scrollbarHeight', dom.getScrollbarWidth());
- this.mainTableScrollableElement = dom.getScrollableElement(this.wot.wtTable.TABLE);
- this.topOverlay = new WalkontableTopOverlay(this.wot);
- this.leftOverlay = new WalkontableLeftOverlay(this.wot);
- if (this.topOverlay.needFullRender && this.leftOverlay.needFullRender) {
- this.topLeftCornerOverlay = new WalkontableCornerOverlay(this.wot);
- }
- if (this.wot.getSetting('debug')) {
- this.debug = new WalkontableDebugOverlay(this.wot);
- }
- this.destroyed = false;
- this.keyPressed = false;
- this.spreaderLastSize = {
- width: null,
- height: null
- };
- this.overlayScrollPositions = {
- 'master': {
- top: 0,
- left: 0
- },
- 'top': {
- top: null,
- left: 0
- },
- 'left': {
- top: 0,
- left: null
- }
- };
- this.registerListeners();
- };
- ($traceurRuntime.createClass)(WalkontableOverlays, {
- refreshAll: function() {
- if (!this.wot.drawn) {
- return;
- }
- if (!this.wot.wtTable.holder.parentNode) {
- this.destroy();
- return;
- }
- this.wot.draw(true);
- this.topOverlay.onScroll();
- this.leftOverlay.onScroll();
- },
- registerListeners: function() {
- var $__5 = this;
- this.eventManager.addEventListener(document.documentElement, 'keydown', (function() {
- return $__5.onKeyDown();
- }));
- this.eventManager.addEventListener(document.documentElement, 'keyup', (function() {
- return $__5.onKeyUp();
- }));
- this.eventManager.addEventListener(this.mainTableScrollableElement, 'scroll', (function(event) {
- return $__5.onTableScroll(event);
- }));
- if (this.topOverlay.needFullRender) {
- this.eventManager.addEventListener(this.topOverlay.clone.wtTable.holder, 'scroll', (function(event) {
- return $__5.onTableScroll(event);
- }));
- this.eventManager.addEventListener(this.topOverlay.clone.wtTable.holder, 'wheel', (function(event) {
- return $__5.onTableScroll(event);
- }));
- }
- if (this.leftOverlay.needFullRender) {
- this.eventManager.addEventListener(this.leftOverlay.clone.wtTable.holder, 'scroll', (function(event) {
- return $__5.onTableScroll(event);
- }));
- this.eventManager.addEventListener(this.leftOverlay.clone.wtTable.holder, 'wheel', (function(event) {
- return $__5.onTableScroll(event);
- }));
- }
- if (this.topOverlay.trimmingContainer !== window && this.leftOverlay.trimmingContainer !== window) {
- this.eventManager.addEventListener(window, 'wheel', (function(event) {
- var overlay;
- var deltaY = event.wheelDeltaY || event.deltaY;
- var deltaX = event.wheelDeltaX || event.deltaX;
- if ($__5.topOverlay.clone.wtTable.holder.contains(event.target)) {
- overlay = 'top';
- } else if ($__5.leftOverlay.clone.wtTable.holder.contains(event.target)) {
- overlay = 'left';
- }
- if (overlay == 'top' && deltaY !== 0) {
- event.preventDefault();
- } else if (overlay == 'left' && deltaX !== 0) {
- event.preventDefault();
- }
- }));
- }
- },
- onTableScroll: function(event) {
- if (Handsontable.mobileBrowser) {
- return;
- }
- if (this.keyPressed && this.mainTableScrollableElement !== window && !event.target.contains(this.mainTableScrollableElement)) {
- return;
- }
- if (event.type === 'scroll') {
- this.syncScrollPositions(event);
- } else {
- this.translateMouseWheelToScroll(event);
- }
- },
- onKeyDown: function() {
- this.keyPressed = true;
- },
- onKeyUp: function() {
- this.keyPressed = false;
- },
- translateMouseWheelToScroll: function(event) {
- var topOverlay = this.topOverlay.clone.wtTable.holder;
- var leftOverlay = this.leftOverlay.clone.wtTable.holder;
- var eventMockup = {type: 'wheel'};
- var tempElem = event.target;
- var deltaY = event.wheelDeltaY || (-1) * event.deltaY;
- var deltaX = event.wheelDeltaX || (-1) * event.deltaX;
- var parentHolder;
- while (tempElem != document && tempElem != null) {
- if (tempElem.className.indexOf('wtHolder') > -1) {
- parentHolder = tempElem;
- break;
- }
- tempElem = tempElem.parentNode;
- }
- eventMockup.target = parentHolder;
- if (parentHolder == topOverlay) {
- this.syncScrollPositions(eventMockup, (-0.2) * deltaY);
- } else if (parentHolder == leftOverlay) {
- this.syncScrollPositions(eventMockup, (-0.2) * deltaX);
- }
- return false;
- },
- syncScrollPositions: function(event) {
- var fakeScrollValue = arguments[1] !== (void 0) ? arguments[1] : null;
- if (this.destroyed) {
- return;
- }
- if (arguments.length === 0) {
- this.syncScrollWithMaster();
- return;
- }
- var master = this.mainTableScrollableElement;
- var target = event.target;
- var tempScrollValue = 0;
- var scrollValueChanged = false;
- var topOverlay;
- var leftOverlay;
- if (this.topOverlay.needFullRender) {
- topOverlay = this.topOverlay.clone.wtTable.holder;
- }
- if (this.leftOverlay.needFullRender) {
- leftOverlay = this.leftOverlay.clone.wtTable.holder;
- }
- if (target === document) {
- target = window;
- }
- if (target === master) {
- tempScrollValue = dom.getScrollLeft(target);
- if (this.overlayScrollPositions.master.left !== tempScrollValue) {
- this.overlayScrollPositions.master.left = tempScrollValue;
- scrollValueChanged = true;
- if (topOverlay) {
- topOverlay.scrollLeft = tempScrollValue;
- }
- }
- tempScrollValue = dom.getScrollTop(target);
- if (this.overlayScrollPositions.master.top !== tempScrollValue) {
- this.overlayScrollPositions.master.top = tempScrollValue;
- scrollValueChanged = true;
- if (leftOverlay) {
- leftOverlay.scrollTop = tempScrollValue;
- }
- }
- } else if (target === topOverlay) {
- tempScrollValue = dom.getScrollLeft(target);
- if (this.overlayScrollPositions.top.left !== tempScrollValue) {
- this.overlayScrollPositions.top.left = tempScrollValue;
- scrollValueChanged = true;
- master.scrollLeft = tempScrollValue;
- }
- if (fakeScrollValue !== null) {
- scrollValueChanged = true;
- master.scrollTop += fakeScrollValue;
- }
- } else if (target === leftOverlay) {
- tempScrollValue = dom.getScrollTop(target);
- if (this.overlayScrollPositions.left.top !== tempScrollValue) {
- this.overlayScrollPositions.left.top = tempScrollValue;
- scrollValueChanged = true;
- master.scrollTop = tempScrollValue;
- }
- if (fakeScrollValue !== null) {
- scrollValueChanged = true;
- master.scrollLeft += fakeScrollValue;
- }
- }
- if (!this.keyPressed && scrollValueChanged && event.type === 'scroll') {
- this.refreshAll();
- }
- },
- syncScrollWithMaster: function() {
- var master = this.topOverlay.mainTableScrollableElement;
- if (this.topOverlay.needFullRender) {
- this.topOverlay.clone.wtTable.holder.scrollLeft = master.scrollLeft;
- }
- if (this.leftOverlay.needFullRender) {
- this.leftOverlay.clone.wtTable.holder.scrollTop = master.scrollTop;
- }
- },
- destroy: function() {
- this.eventManager.clear();
- this.topOverlay.destroy();
- this.leftOverlay.destroy();
- if (this.topLeftCornerOverlay) {
- this.topLeftCornerOverlay.destroy();
- }
- if (this.debug) {
- this.debug.destroy();
- }
- this.destroyed = true;
- },
- refresh: function() {
- var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
- if (this.topOverlay.isElementSizesAdjusted && this.leftOverlay.isElementSizesAdjusted) {
- var container = this.wot.wtTable.wtRootElement.parentNode || this.wot.wtTable.wtRootElement;
- var width = container.clientWidth;
- var height = container.clientHeight;
- if (width !== this.spreaderLastSize.width || height !== this.spreaderLastSize.height) {
- this.spreaderLastSize.width = width;
- this.spreaderLastSize.height = height;
- this.adjustElementsSize();
- }
- }
- this.leftOverlay.refresh(fastDraw);
- this.topOverlay.refresh(fastDraw);
- if (this.topLeftCornerOverlay) {
- this.topLeftCornerOverlay.refresh(fastDraw);
- }
- if (this.debug) {
- this.debug.refresh(fastDraw);
- }
- },
- adjustElementsSize: function() {
- var force = arguments[0] !== (void 0) ? arguments[0] : false;
- var totalColumns = this.wot.getSetting('totalColumns');
- var totalRows = this.wot.getSetting('totalRows');
- var headerRowSize = this.wot.wtViewport.getRowHeaderWidth();
- var headerColumnSize = this.wot.wtViewport.getColumnHeaderHeight();
- var hiderStyle = this.wot.wtTable.hider.style;
- hiderStyle.width = (headerRowSize + this.leftOverlay.sumCellSizes(0, totalColumns)) + 'px';
- hiderStyle.height = (headerColumnSize + this.topOverlay.sumCellSizes(0, totalRows) + 1) + 'px';
- this.topOverlay.adjustElementsSize(force);
- this.leftOverlay.adjustElementsSize(force);
- },
- applyToDOM: function() {
- if (!this.topOverlay.isElementSizesAdjusted || !this.leftOverlay.isElementSizesAdjusted) {
- this.adjustElementsSize();
- }
- this.topOverlay.applyToDOM();
- this.leftOverlay.applyToDOM();
- }
- }, {});
- ;
- window.WalkontableOverlays = WalkontableOverlays;
-
- //#
- },{"./../../../dom.js":27,"./../../../eventManager.js":41,"./overlay/corner.js":12,"./overlay/debug.js":13,"./overlay/left.js":14,"./overlay/top.js":15}],17:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableScroll: {get: function() {
- return WalkontableScroll;
- }},
- __esModule: {value: true}
- });
- var WalkontableScroll = function WalkontableScroll(wotInstance) {
- this.wot = wotInstance;
- this.instance = wotInstance;
- };
- ($traceurRuntime.createClass)(WalkontableScroll, {scrollViewport: function(coords) {
- if (!this.wot.drawn) {
- return;
- }
- var totalRows = this.wot.getSetting('totalRows');
- var totalColumns = this.wot.getSetting('totalColumns');
- if (coords.row < 0 || coords.row > totalRows - 1) {
- throw new Error('row ' + coords.row + ' does not exist');
- }
- if (coords.col < 0 || coords.col > totalColumns - 1) {
- throw new Error('column ' + coords.col + ' does not exist');
- }
- if (coords.row > this.instance.wtTable.getLastVisibleRow()) {
- this.wot.wtOverlays.topOverlay.scrollTo(coords.row, true);
- } else if (coords.row >= this.instance.getSetting('fixedRowsTop') && coords.row < this.instance.wtTable.getFirstVisibleRow()) {
- this.wot.wtOverlays.topOverlay.scrollTo(coords.row);
- }
- if (coords.col > this.instance.wtTable.getLastVisibleColumn()) {
- this.wot.wtOverlays.leftOverlay.scrollTo(coords.col, true);
- } else if (coords.col >= this.instance.getSetting('fixedColumnsLeft') && coords.col < this.instance.wtTable.getFirstVisibleColumn()) {
- this.wot.wtOverlays.leftOverlay.scrollTo(coords.col);
- }
- }}, {});
- ;
- window.WalkontableScroll = WalkontableScroll;
-
- //#
- },{}],18:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableSelection: {get: function() {
- return WalkontableSelection;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
- $__border_46_js__,
- $__cell_47_coords_46_js__,
- $__cell_47_range_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../dom.js"), $___46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_dom_46_js__});
- var WalkontableBorder = ($__border_46_js__ = require("./border.js"), $__border_46_js__ && $__border_46_js__.__esModule && $__border_46_js__ || {default: $__border_46_js__}).WalkontableBorder;
- var WalkontableCellCoords = ($__cell_47_coords_46_js__ = require("./cell/coords.js"), $__cell_47_coords_46_js__ && $__cell_47_coords_46_js__.__esModule && $__cell_47_coords_46_js__ || {default: $__cell_47_coords_46_js__}).WalkontableCellCoords;
- var WalkontableCellRange = ($__cell_47_range_46_js__ = require("./cell/range.js"), $__cell_47_range_46_js__ && $__cell_47_range_46_js__.__esModule && $__cell_47_range_46_js__ || {default: $__cell_47_range_46_js__}).WalkontableCellRange;
- var WalkontableSelection = function WalkontableSelection(settings, cellRange) {
- this.settings = settings;
- this.cellRange = cellRange || null;
- this.instanceBorders = {};
- };
- ($traceurRuntime.createClass)(WalkontableSelection, {
- getBorder: function(wotInstance) {
- if (this.instanceBorders[wotInstance.guid]) {
- return this.instanceBorders[wotInstance.guid];
- }
- this.instanceBorders[wotInstance.guid] = new WalkontableBorder(wotInstance, this.settings);
- },
- isEmpty: function() {
- return this.cellRange === null;
- },
- add: function(coords) {
- if (this.isEmpty()) {
- this.cellRange = new WalkontableCellRange(coords, coords, coords);
- } else {
- this.cellRange.expand(coords);
- }
- },
- replace: function(oldCoords, newCoords) {
- if (!this.isEmpty()) {
- if (this.cellRange.from.isEqual(oldCoords)) {
- this.cellRange.from = newCoords;
- return true;
- }
- if (this.cellRange.to.isEqual(oldCoords)) {
- this.cellRange.to = newCoords;
- return true;
- }
- }
- return false;
- },
- clear: function() {
- this.cellRange = null;
- },
- getCorners: function() {
- var topLeft = this.cellRange.getTopLeftCorner();
- var bottomRight = this.cellRange.getBottomRightCorner();
- return [topLeft.row, topLeft.col, bottomRight.row, bottomRight.col];
- },
- addClassAtCoords: function(wotInstance, sourceRow, sourceColumn, className) {
- var TD = wotInstance.wtTable.getCell(new WalkontableCellCoords(sourceRow, sourceColumn));
- if (typeof TD === 'object') {
- dom.addClass(TD, className);
- }
- },
- draw: function(wotInstance) {
- if (this.isEmpty()) {
- if (this.settings.border) {
- var border = this.getBorder(wotInstance);
- if (border) {
- border.disappear();
- }
- }
- return;
- }
- var renderedRows = wotInstance.wtTable.getRenderedRowsCount();
- var renderedColumns = wotInstance.wtTable.getRenderedColumnsCount();
- var corners = this.getCorners();
- var sourceRow,
- sourceCol,
- TH;
- for (var column = 0; column < renderedColumns; column++) {
- sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
- if (sourceCol >= corners[1] && sourceCol <= corners[3]) {
- TH = wotInstance.wtTable.getColumnHeader(sourceCol);
- if (TH && this.settings.highlightColumnClassName) {
- dom.addClass(TH, this.settings.highlightColumnClassName);
- }
- }
- }
- for (var row = 0; row < renderedRows; row++) {
- sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row);
- if (sourceRow >= corners[0] && sourceRow <= corners[2]) {
- TH = wotInstance.wtTable.getRowHeader(sourceRow);
- if (TH && this.settings.highlightRowClassName) {
- dom.addClass(TH, this.settings.highlightRowClassName);
- }
- }
- for (var column$__4 = 0; column$__4 < renderedColumns; column$__4++) {
- sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column$__4);
- if (sourceRow >= corners[0] && sourceRow <= corners[2] && sourceCol >= corners[1] && sourceCol <= corners[3]) {
- if (this.settings.className) {
- this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.className);
- }
- } else if (sourceRow >= corners[0] && sourceRow <= corners[2]) {
- if (this.settings.highlightRowClassName) {
- this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightRowClassName);
- }
- } else if (sourceCol >= corners[1] && sourceCol <= corners[3]) {
- if (this.settings.highlightColumnClassName) {
- this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightColumnClassName);
- }
- }
- }
- }
- wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className);
- if (this.settings.border) {
- var border$__5 = this.getBorder(wotInstance);
- if (border$__5) {
- border$__5.appear(corners);
- }
- }
- }
- }, {});
- ;
- window.WalkontableSelection = WalkontableSelection;
-
- //#
- },{"./../../../dom.js":27,"./border.js":2,"./cell/coords.js":5,"./cell/range.js":6}],19:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableSettings: {get: function() {
- return WalkontableSettings;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47_dom_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../dom.js"), $___46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_dom_46_js__});
- var WalkontableSettings = function WalkontableSettings(wotInstance, settings) {
- var $__0 = this;
- this.wot = wotInstance;
- this.instance = wotInstance;
- this.defaults = {
- table: void 0,
- debug: false,
- stretchH: 'none',
- currentRowClassName: null,
- currentColumnClassName: null,
- data: void 0,
- fixedColumnsLeft: 0,
- fixedRowsTop: 0,
- rowHeaders: function() {
- return [];
- },
- columnHeaders: function() {
- return [];
- },
- totalRows: void 0,
- totalColumns: void 0,
- cellRenderer: (function(row, column, TD) {
- var cellData = $__0.getSetting('data', row, column);
- dom.fastInnerText(TD, cellData === void 0 || cellData === null ? '' : cellData);
- }),
- columnWidth: function(col) {
- return;
- },
- rowHeight: function(row) {
- return;
- },
- defaultRowHeight: 23,
- defaultColumnWidth: 50,
- selections: null,
- hideBorderOnMouseDownOver: false,
- viewportRowCalculatorOverride: null,
- viewportColumnCalculatorOverride: null,
- onCellMouseDown: null,
- onCellMouseOver: null,
- onCellDblClick: null,
- onCellCornerMouseDown: null,
- onCellCornerDblClick: null,
- beforeDraw: null,
- onDraw: null,
- onBeforeDrawBorders: null,
- onScrollVertically: null,
- onScrollHorizontally: null,
- onBeforeTouchScroll: null,
- onAfterMomentumScroll: null,
- scrollbarWidth: 10,
- scrollbarHeight: 10,
- renderAllRows: false,
- groups: false
- };
- this.settings = {};
- for (var i in this.defaults) {
- if (this.defaults.hasOwnProperty(i)) {
- if (settings[i] !== void 0) {
- this.settings[i] = settings[i];
- } else if (this.defaults[i] === void 0) {
- throw new Error('A required setting "' + i + '" was not provided');
- } else {
- this.settings[i] = this.defaults[i];
- }
- }
- }
- };
- ($traceurRuntime.createClass)(WalkontableSettings, {
- update: function(settings, value) {
- if (value === void 0) {
- for (var i in settings) {
- if (settings.hasOwnProperty(i)) {
- this.settings[i] = settings[i];
- }
- }
- } else {
- this.settings[settings] = value;
- }
- return this.wot;
- },
- getSetting: function(key, param1, param2, param3, param4) {
- if (typeof this.settings[key] === 'function') {
- return this.settings[key](param1, param2, param3, param4);
- } else if (param1 !== void 0 && Array.isArray(this.settings[key])) {
- return this.settings[key][param1];
- } else {
- return this.settings[key];
- }
- },
- has: function(key) {
- return !!this.settings[key];
- }
- }, {});
- ;
- window.WalkontableSettings = WalkontableSettings;
-
- //#
- },{"./../../../dom.js":27}],20:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableTable: {get: function() {
- return WalkontableTable;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
- $__cell_47_coords_46_js__,
- $__cell_47_range_46_js__,
- $__filter_47_column_46_js__,
- $__overlay_47_corner_46_js__,
- $__overlay_47_debug_46_js__,
- $__overlay_47_left_46_js__,
- $__filter_47_row_46_js__,
- $__tableRenderer_46_js__,
- $__overlay_47_top_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../dom.js"), $___46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_dom_46_js__});
- var WalkontableCellCoords = ($__cell_47_coords_46_js__ = require("./cell/coords.js"), $__cell_47_coords_46_js__ && $__cell_47_coords_46_js__.__esModule && $__cell_47_coords_46_js__ || {default: $__cell_47_coords_46_js__}).WalkontableCellCoords;
- var WalkontableCellRange = ($__cell_47_range_46_js__ = require("./cell/range.js"), $__cell_47_range_46_js__ && $__cell_47_range_46_js__.__esModule && $__cell_47_range_46_js__ || {default: $__cell_47_range_46_js__}).WalkontableCellRange;
- var WalkontableColumnFilter = ($__filter_47_column_46_js__ = require("./filter/column.js"), $__filter_47_column_46_js__ && $__filter_47_column_46_js__.__esModule && $__filter_47_column_46_js__ || {default: $__filter_47_column_46_js__}).WalkontableColumnFilter;
- var WalkontableCornerOverlay = ($__overlay_47_corner_46_js__ = require("./overlay/corner.js"), $__overlay_47_corner_46_js__ && $__overlay_47_corner_46_js__.__esModule && $__overlay_47_corner_46_js__ || {default: $__overlay_47_corner_46_js__}).WalkontableCornerOverlay;
- 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;
- 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;
- var WalkontableRowFilter = ($__filter_47_row_46_js__ = require("./filter/row.js"), $__filter_47_row_46_js__ && $__filter_47_row_46_js__.__esModule && $__filter_47_row_46_js__ || {default: $__filter_47_row_46_js__}).WalkontableRowFilter;
- var WalkontableTableRenderer = ($__tableRenderer_46_js__ = require("./tableRenderer.js"), $__tableRenderer_46_js__ && $__tableRenderer_46_js__.__esModule && $__tableRenderer_46_js__ || {default: $__tableRenderer_46_js__}).WalkontableTableRenderer;
- 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;
- function WalkontableTable(instance, table) {
- this.instance = instance;
- this.TABLE = table;
- dom.removeTextNodes(this.TABLE);
- var parent = this.TABLE.parentNode;
- if (!parent || parent.nodeType !== 1 || !dom.hasClass(parent, 'wtHolder')) {
- var spreader = document.createElement('DIV');
- spreader.className = 'wtSpreader';
- if (parent) {
- parent.insertBefore(spreader, this.TABLE);
- }
- spreader.appendChild(this.TABLE);
- }
- this.spreader = this.TABLE.parentNode;
- this.spreader.style.position = 'relative';
- parent = this.spreader.parentNode;
- if (!parent || parent.nodeType !== 1 || !dom.hasClass(parent, 'wtHolder')) {
- var hider = document.createElement('DIV');
- hider.className = 'wtHider';
- if (parent) {
- parent.insertBefore(hider, this.spreader);
- }
- hider.appendChild(this.spreader);
- }
- this.hider = this.spreader.parentNode;
- parent = this.hider.parentNode;
- if (!parent || parent.nodeType !== 1 || !dom.hasClass(parent, 'wtHolder')) {
- var holder = document.createElement('DIV');
- holder.style.position = 'relative';
- holder.className = 'wtHolder';
- if (parent) {
- parent.insertBefore(holder, this.hider);
- }
- if (!instance.cloneSource) {
- holder.parentNode.className += 'ht_master handsontable';
- }
- holder.appendChild(this.hider);
- }
- this.holder = this.hider.parentNode;
- this.wtRootElement = this.holder.parentNode;
- this.alignOverlaysWithTrimmingContainer();
- this.TBODY = this.TABLE.getElementsByTagName('TBODY')[0];
- if (!this.TBODY) {
- this.TBODY = document.createElement('TBODY');
- this.TABLE.appendChild(this.TBODY);
- }
- this.THEAD = this.TABLE.getElementsByTagName('THEAD')[0];
- if (!this.THEAD) {
- this.THEAD = document.createElement('THEAD');
- this.TABLE.insertBefore(this.THEAD, this.TBODY);
- }
- this.COLGROUP = this.TABLE.getElementsByTagName('COLGROUP')[0];
- if (!this.COLGROUP) {
- this.COLGROUP = document.createElement('COLGROUP');
- this.TABLE.insertBefore(this.COLGROUP, this.THEAD);
- }
- if (this.instance.getSetting('columnHeaders').length) {
- if (!this.THEAD.childNodes.length) {
- var TR = document.createElement('TR');
- this.THEAD.appendChild(TR);
- }
- }
- this.colgroupChildrenLength = this.COLGROUP.childNodes.length;
- this.theadChildrenLength = this.THEAD.firstChild ? this.THEAD.firstChild.childNodes.length : 0;
- this.tbodyChildrenLength = this.TBODY.childNodes.length;
- this.rowFilter = null;
- this.columnFilter = null;
- }
- WalkontableTable.prototype.alignOverlaysWithTrimmingContainer = function() {
- var trimmingElement = dom.getTrimmingContainer(this.wtRootElement);
- if (!this.isWorkingOnClone()) {
- this.holder.parentNode.style.position = 'relative';
- if (trimmingElement !== window) {
- this.holder.style.width = dom.getStyle(trimmingElement, 'width');
- this.holder.style.height = dom.getStyle(trimmingElement, 'height');
- this.holder.style.overflow = '';
- } else {
- this.holder.style.overflow = 'visible';
- this.wtRootElement.style.overflow = 'visible';
- }
- }
- };
- WalkontableTable.prototype.isWorkingOnClone = function() {
- return !!this.instance.cloneSource;
- };
- WalkontableTable.prototype.draw = function(fastDraw) {
- if (!this.isWorkingOnClone()) {
- this.holderOffset = dom.offset(this.holder);
- fastDraw = this.instance.wtViewport.createRenderCalculators(fastDraw);
- }
- if (!fastDraw) {
- if (this.isWorkingOnClone()) {
- this.tableOffset = this.instance.cloneSource.wtTable.tableOffset;
- } else {
- this.tableOffset = dom.offset(this.TABLE);
- }
- var startRow;
- if (this.instance.cloneOverlay instanceof WalkontableDebugOverlay || this.instance.cloneOverlay instanceof WalkontableTopOverlay || this.instance.cloneOverlay instanceof WalkontableCornerOverlay) {
- startRow = 0;
- } else {
- startRow = this.instance.wtViewport.rowsRenderCalculator.startRow;
- }
- var startColumn;
- if (this.instance.cloneOverlay instanceof WalkontableDebugOverlay || this.instance.cloneOverlay instanceof WalkontableLeftOverlay || this.instance.cloneOverlay instanceof WalkontableCornerOverlay) {
- startColumn = 0;
- } else {
- startColumn = this.instance.wtViewport.columnsRenderCalculator.startColumn;
- }
- this.rowFilter = new WalkontableRowFilter(startRow, this.instance.getSetting('totalRows'), this.instance.getSetting('columnHeaders').length);
- this.columnFilter = new WalkontableColumnFilter(startColumn, this.instance.getSetting('totalColumns'), this.instance.getSetting('rowHeaders').length);
- this._doDraw();
- this.alignOverlaysWithTrimmingContainer();
- } else {
- if (!this.isWorkingOnClone()) {
- this.instance.wtViewport.createVisibleCalculators();
- }
- if (this.instance.wtOverlays) {
- this.instance.wtOverlays.refresh(true);
- }
- }
- this.refreshSelections(fastDraw);
- if (!this.isWorkingOnClone()) {
- this.instance.wtOverlays.topOverlay.resetFixedPosition();
- this.instance.wtOverlays.leftOverlay.resetFixedPosition();
- if (this.instance.wtOverlays.topLeftCornerOverlay) {
- this.instance.wtOverlays.topLeftCornerOverlay.resetFixedPosition();
- }
- }
- this.instance.drawn = true;
- return this;
- };
- WalkontableTable.prototype._doDraw = function() {
- var wtRenderer = new WalkontableTableRenderer(this);
- wtRenderer.render();
- };
- WalkontableTable.prototype.removeClassFromCells = function(className) {
- var nodes = this.TABLE.querySelectorAll('.' + className);
- for (var i = 0,
- ilen = nodes.length; i < ilen; i++) {
- dom.removeClass(nodes[i], className);
- }
- };
- WalkontableTable.prototype.refreshSelections = function(fastDraw) {
- var i,
- len;
- if (!this.instance.selections) {
- return;
- }
- len = this.instance.selections.length;
- if (fastDraw) {
- for (i = 0; i < len; i++) {
- if (this.instance.selections[i].settings.className) {
- this.removeClassFromCells(this.instance.selections[i].settings.className);
- }
- if (this.instance.selections[i].settings.highlightRowClassName) {
- this.removeClassFromCells(this.instance.selections[i].settings.highlightRowClassName);
- }
- if (this.instance.selections[i].settings.highlightColumnClassName) {
- this.removeClassFromCells(this.instance.selections[i].settings.highlightColumnClassName);
- }
- }
- }
- for (i = 0; i < len; i++) {
- this.instance.selections[i].draw(this.instance, fastDraw);
- }
- };
- WalkontableTable.prototype.getCell = function(coords) {
- if (this.isRowBeforeRenderedRows(coords.row)) {
- return -1;
- } else if (this.isRowAfterRenderedRows(coords.row)) {
- return -2;
- }
- var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(coords.row)];
- if (TR) {
- return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(coords.col)];
- }
- };
- WalkontableTable.prototype.getColumnHeader = function(col, level) {
- if (!level) {
- level = 0;
- }
- var TR = this.THEAD.childNodes[level];
- if (TR) {
- return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(col)];
- }
- };
- WalkontableTable.prototype.getRowHeader = function(row) {
- if (this.columnFilter.sourceColumnToVisibleRowHeadedColumn(0) === 0) {
- return null;
- }
- var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
- if (TR) {
- return TR.childNodes[0];
- }
- };
- WalkontableTable.prototype.getCoords = function(TD) {
- var TR = TD.parentNode;
- var row = dom.index(TR);
- if (TR.parentNode === this.THEAD) {
- row = this.rowFilter.visibleColHeadedRowToSourceRow(row);
- } else {
- row = this.rowFilter.renderedToSource(row);
- }
- return new WalkontableCellCoords(row, this.columnFilter.visibleRowHeadedColumnToSourceColumn(TD.cellIndex));
- };
- WalkontableTable.prototype.getTrForRow = function(row) {
- return this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
- };
- WalkontableTable.prototype.getFirstRenderedRow = function() {
- return this.instance.wtViewport.rowsRenderCalculator.startRow;
- };
- WalkontableTable.prototype.getFirstVisibleRow = function() {
- return this.instance.wtViewport.rowsVisibleCalculator.startRow;
- };
- WalkontableTable.prototype.getFirstRenderedColumn = function() {
- return this.instance.wtViewport.columnsRenderCalculator.startColumn;
- };
- WalkontableTable.prototype.getFirstVisibleColumn = function() {
- return this.instance.wtViewport.columnsVisibleCalculator.startColumn;
- };
- WalkontableTable.prototype.getLastRenderedRow = function() {
- return this.instance.wtViewport.rowsRenderCalculator.endRow;
- };
- WalkontableTable.prototype.getLastVisibleRow = function() {
- return this.instance.wtViewport.rowsVisibleCalculator.endRow;
- };
- WalkontableTable.prototype.getLastRenderedColumn = function() {
- return this.instance.wtViewport.columnsRenderCalculator.endColumn;
- };
- WalkontableTable.prototype.getLastVisibleColumn = function() {
- return this.instance.wtViewport.columnsVisibleCalculator.endColumn;
- };
- WalkontableTable.prototype.isRowBeforeRenderedRows = function(r) {
- return (this.rowFilter.sourceToRendered(r) < 0 && r >= 0);
- };
- WalkontableTable.prototype.isRowAfterViewport = function(r) {
- return (r > this.getLastVisibleRow());
- };
- WalkontableTable.prototype.isRowAfterRenderedRows = function(r) {
- return (r > this.getLastRenderedRow());
- };
- WalkontableTable.prototype.isColumnBeforeViewport = function(c) {
- return (this.columnFilter.sourceToRendered(c) < 0 && c >= 0);
- };
- WalkontableTable.prototype.isColumnAfterViewport = function(c) {
- return (c > this.getLastVisibleColumn());
- };
- WalkontableTable.prototype.isLastRowFullyVisible = function() {
- return (this.getLastVisibleRow() === this.getLastRenderedRow());
- };
- WalkontableTable.prototype.isLastColumnFullyVisible = function() {
- return (this.getLastVisibleColumn() === this.getLastRenderedColumn);
- };
- WalkontableTable.prototype.getRenderedColumnsCount = function() {
- if (this.instance.cloneOverlay instanceof WalkontableDebugOverlay) {
- return this.instance.getSetting('totalColumns');
- } else if (this.instance.cloneOverlay instanceof WalkontableLeftOverlay || this.instance.cloneOverlay instanceof WalkontableCornerOverlay) {
- return this.instance.getSetting('fixedColumnsLeft');
- } else {
- return this.instance.wtViewport.columnsRenderCalculator.count;
- }
- };
- WalkontableTable.prototype.getRenderedRowsCount = function() {
- if (this.instance.cloneOverlay instanceof WalkontableDebugOverlay) {
- return this.instance.getSetting('totalRows');
- } else if (this.instance.cloneOverlay instanceof WalkontableTopOverlay || this.instance.cloneOverlay instanceof WalkontableCornerOverlay) {
- return this.instance.getSetting('fixedRowsTop');
- }
- return this.instance.wtViewport.rowsRenderCalculator.count;
- };
- WalkontableTable.prototype.getVisibleRowsCount = function() {
- return this.instance.wtViewport.rowsVisibleCalculator.count;
- };
- WalkontableTable.prototype.allRowsInViewport = function() {
- return this.instance.getSetting('totalRows') == this.getVisibleRowsCount();
- };
- WalkontableTable.prototype.getRowHeight = function(sourceRow) {
- var height = this.instance.wtSettings.settings.rowHeight(sourceRow),
- oversizedHeight = this.instance.wtViewport.oversizedRows[sourceRow];
- if (oversizedHeight !== void 0) {
- height = height ? Math.max(height, oversizedHeight) : oversizedHeight;
- }
- return height;
- };
- WalkontableTable.prototype.getColumnHeaderHeight = function(level) {
- var height = this.instance.wtSettings.settings.defaultRowHeight,
- oversizedHeight = this.instance.wtViewport.oversizedColumnHeaders[level];
- if (oversizedHeight !== void 0) {
- height = height ? Math.max(height, oversizedHeight) : oversizedHeight;
- }
- return height;
- };
- WalkontableTable.prototype.getVisibleColumnsCount = function() {
- return this.instance.wtViewport.columnsVisibleCalculator.count;
- };
- WalkontableTable.prototype.allColumnsInViewport = function() {
- return this.instance.getSetting('totalColumns') == this.getVisibleColumnsCount();
- };
- WalkontableTable.prototype.getColumnWidth = function(sourceColumn) {
- var width = this.instance.wtSettings.settings.columnWidth;
- if (typeof width === 'function') {
- width = width(sourceColumn);
- } else if (typeof width === 'object') {
- width = width[sourceColumn];
- }
- var oversizedWidth = this.instance.wtViewport.oversizedCols[sourceColumn];
- if (oversizedWidth !== void 0) {
- width = width ? Math.max(width, oversizedWidth) : oversizedWidth;
- }
- return width;
- };
- WalkontableTable.prototype.getStretchedColumnWidth = function(sourceColumn) {
- var width = this.getColumnWidth(sourceColumn) || this.instance.wtSettings.settings.defaultColumnWidth,
- calculator = this.instance.wtViewport.columnsRenderCalculator,
- stretchedWidth;
- if (calculator) {
- stretchedWidth = calculator.getStretchedColumnWidth(sourceColumn, width);
- if (stretchedWidth) {
- width = stretchedWidth;
- }
- }
- return width;
- };
- ;
- window.WalkontableTable = WalkontableTable;
-
- //#
- },{"./../../../dom.js":27,"./cell/coords.js":5,"./cell/range.js":6,"./filter/column.js":9,"./filter/row.js":10,"./overlay/corner.js":12,"./overlay/debug.js":13,"./overlay/left.js":14,"./overlay/top.js":15,"./tableRenderer.js":21}],21:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableTableRenderer: {get: function() {
- return WalkontableTableRenderer;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47_dom_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../dom.js"), $___46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_dom_46_js__});
- var isRenderedColumnHeaders = {};
- var WalkontableTableRenderer = function WalkontableTableRenderer(wtTable) {
- this.wtTable = wtTable;
- this.wot = wtTable.instance;
- this.instance = wtTable.instance;
- this.rowFilter = wtTable.rowFilter;
- this.columnFilter = wtTable.columnFilter;
- this.TABLE = wtTable.TABLE;
- this.THEAD = wtTable.THEAD;
- this.TBODY = wtTable.TBODY;
- this.COLGROUP = wtTable.COLGROUP;
- this.rowHeaders = [];
- this.rowHeaderCount = 0;
- this.columnHeaders = [];
- this.columnHeaderCount = 0;
- this.fixedRowsTop = 0;
- };
- ($traceurRuntime.createClass)(WalkontableTableRenderer, {
- render: function() {
- if (!this.wtTable.isWorkingOnClone()) {
- this.wot.getSetting('beforeDraw', true);
- }
- this.rowHeaders = this.wot.getSetting('rowHeaders');
- this.rowHeaderCount = this.rowHeaders.length;
- this.fixedRowsTop = this.wot.getSetting('fixedRowsTop');
- this.columnHeaders = this.wot.getSetting('columnHeaders');
- this.columnHeaderCount = this.columnHeaders.length;
- var columnsToRender = this.wtTable.getRenderedColumnsCount();
- var rowsToRender = this.wtTable.getRenderedRowsCount();
- var totalColumns = this.wot.getSetting('totalColumns');
- var totalRows = this.wot.getSetting('totalRows');
- var workspaceWidth;
- var adjusted = false;
- if (totalColumns > 0) {
- this.adjustAvailableNodes();
- adjusted = true;
- this.renderColGroups();
- this.renderColumnHeaders();
- this.renderRows(totalRows, rowsToRender, columnsToRender);
- if (!this.wtTable.isWorkingOnClone()) {
- workspaceWidth = this.wot.wtViewport.getWorkspaceWidth();
- this.wot.wtViewport.containerWidth = null;
- } else {
- this.adjustColumnHeaderHeights();
- }
- this.adjustColumnWidths(columnsToRender);
- }
- if (!adjusted) {
- this.adjustAvailableNodes();
- }
- this.removeRedundantRows(rowsToRender);
- if (!this.wtTable.isWorkingOnClone()) {
- this.markOversizedRows();
- this.wot.wtViewport.createVisibleCalculators();
- this.wot.wtOverlays.refresh(false);
- this.wot.wtOverlays.applyToDOM();
- if (workspaceWidth !== this.wot.wtViewport.getWorkspaceWidth()) {
- this.wot.wtViewport.containerWidth = null;
- var firstRendered = this.wtTable.getFirstRenderedColumn();
- var lastRendered = this.wtTable.getLastRenderedColumn();
- for (var i = firstRendered; i < lastRendered; i++) {
- var width = this.wtTable.getStretchedColumnWidth(i);
- var renderedIndex = this.columnFilter.sourceToRendered(i);
- this.COLGROUP.childNodes[renderedIndex + this.rowHeaderCount].style.width = width + 'px';
- }
- }
- this.wot.getSetting('onDraw', true);
- }
- },
- removeRedundantRows: function(renderedRowsCount) {
- while (this.wtTable.tbodyChildrenLength > renderedRowsCount) {
- this.TBODY.removeChild(this.TBODY.lastChild);
- this.wtTable.tbodyChildrenLength--;
- }
- },
- renderRows: function(totalRows, rowsToRender, columnsToRender) {
- var lastTD,
- TR;
- var visibleRowIndex = 0;
- var sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
- var isWorkingOnClone = this.wtTable.isWorkingOnClone();
- while (sourceRowIndex < totalRows && sourceRowIndex >= 0) {
- if (visibleRowIndex > 1000) {
- throw new Error('Security brake: Too much TRs. Please define height for your table, which will enforce scrollbars.');
- }
- if (rowsToRender !== void 0 && visibleRowIndex === rowsToRender) {
- break;
- }
- TR = this.getOrCreateTrForRow(visibleRowIndex, TR);
- this.renderRowHeaders(sourceRowIndex, TR);
- this.adjustColumns(TR, columnsToRender + this.rowHeaderCount);
- lastTD = this.renderCells(sourceRowIndex, TR, columnsToRender);
- if (!isWorkingOnClone) {
- this.resetOversizedRow(sourceRowIndex);
- }
- if (TR.firstChild) {
- var height = this.wot.wtTable.getRowHeight(sourceRowIndex);
- if (height) {
- TR.firstChild.style.height = height + 'px';
- } else {
- TR.firstChild.style.height = '';
- }
- }
- visibleRowIndex++;
- sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
- }
- },
- resetOversizedRow: function(sourceRow) {
- if (this.wot.wtViewport.oversizedRows && this.wot.wtViewport.oversizedRows[sourceRow]) {
- this.wot.wtViewport.oversizedRows[sourceRow] = void 0;
- }
- },
- markOversizedRows: function() {
- var rowCount = this.instance.wtTable.TBODY.childNodes.length;
- var expectedTableHeight = rowCount * this.instance.wtSettings.settings.defaultRowHeight;
- var actualTableHeight = dom.innerHeight(this.instance.wtTable.TBODY) - 1;
- var previousRowHeight;
- var rowInnerHeight;
- var sourceRowIndex;
- var currentTr;
- var rowHeader;
- if (expectedTableHeight === actualTableHeight) {
- return;
- }
- while (rowCount) {
- rowCount--;
- sourceRowIndex = this.instance.wtTable.rowFilter.renderedToSource(rowCount);
- previousRowHeight = this.instance.wtTable.getRowHeight(sourceRowIndex);
- currentTr = this.instance.wtTable.getTrForRow(sourceRowIndex);
- rowHeader = currentTr.querySelector('th');
- if (rowHeader) {
- rowInnerHeight = dom.innerHeight(rowHeader);
- } else {
- rowInnerHeight = dom.innerHeight(currentTr) - 1;
- }
- if ((!previousRowHeight && this.instance.wtSettings.settings.defaultRowHeight < rowInnerHeight || previousRowHeight < rowInnerHeight)) {
- this.instance.wtViewport.oversizedRows[sourceRowIndex] = rowInnerHeight;
- }
- }
- },
- adjustColumnHeaderHeights: function() {
- var columnHeaders = this.wot.getSetting('columnHeaders');
- var childs = this.wot.wtTable.THEAD.childNodes;
- var oversizedCols = this.wot.wtViewport.oversizedColumnHeaders;
- for (var i = 0,
- len = columnHeaders.length; i < len; i++) {
- if (oversizedCols[i]) {
- if (childs[i].childNodes.length === 0) {
- return;
- }
- childs[i].childNodes[0].style.height = oversizedCols[i] + 'px';
- }
- }
- },
- markIfOversizedColumnHeader: function(col) {
- var level = this.wot.getSetting('columnHeaders').length;
- var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
- var sourceColIndex;
- var previousColHeaderHeight;
- var currentHeader;
- var currentHeaderHeight;
- sourceColIndex = this.wot.wtTable.columnFilter.renderedToSource(col);
- while (level) {
- level--;
- previousColHeaderHeight = this.wot.wtTable.getColumnHeaderHeight(level);
- currentHeader = this.wot.wtTable.getColumnHeader(sourceColIndex, level);
- if (!currentHeader) {
- continue;
- }
- currentHeaderHeight = dom.innerHeight(currentHeader);
- if (!previousColHeaderHeight && defaultRowHeight < currentHeaderHeight || previousColHeaderHeight < currentHeaderHeight) {
- this.wot.wtViewport.oversizedColumnHeaders[level] = currentHeaderHeight;
- }
- }
- },
- renderCells: function(sourceRowIndex, TR, columnsToRender) {
- var TD;
- var sourceColIndex;
- for (var visibleColIndex = 0; visibleColIndex < columnsToRender; visibleColIndex++) {
- sourceColIndex = this.columnFilter.renderedToSource(visibleColIndex);
- if (visibleColIndex === 0) {
- TD = TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(sourceColIndex)];
- } else {
- TD = TD.nextSibling;
- }
- if (TD.nodeName == 'TH') {
- TD = replaceThWithTd(TD, TR);
- }
- if (!dom.hasClass(TD, 'hide')) {
- TD.className = '';
- }
- TD.removeAttribute('style');
- this.wot.wtSettings.settings.cellRenderer(sourceRowIndex, sourceColIndex, TD);
- }
- return TD;
- },
- adjustColumnWidths: function(columnsToRender) {
- var scrollbarCompensation = 0;
- var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
- var mainHolder = sourceInstance.wtTable.holder;
- if (mainHolder.offsetHeight < mainHolder.scrollHeight) {
- scrollbarCompensation = dom.getScrollbarWidth();
- }
- this.wot.wtViewport.columnsRenderCalculator.refreshStretching(this.wot.wtViewport.getViewportWidth() - scrollbarCompensation);
- for (var renderedColIndex = 0; renderedColIndex < columnsToRender; renderedColIndex++) {
- var width = this.wtTable.getStretchedColumnWidth(this.columnFilter.renderedToSource(renderedColIndex));
- this.COLGROUP.childNodes[renderedColIndex + this.rowHeaderCount].style.width = width + 'px';
- }
- },
- appendToTbody: function(TR) {
- this.TBODY.appendChild(TR);
- this.wtTable.tbodyChildrenLength++;
- },
- getOrCreateTrForRow: function(rowIndex, currentTr) {
- var TR;
- if (rowIndex >= this.wtTable.tbodyChildrenLength) {
- TR = this.createRow();
- this.appendToTbody(TR);
- } else if (rowIndex === 0) {
- TR = this.TBODY.firstChild;
- } else {
- TR = currentTr.nextSibling;
- }
- return TR;
- },
- createRow: function() {
- var TR = document.createElement('TR');
- for (var visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
- TR.appendChild(document.createElement('TH'));
- }
- return TR;
- },
- renderRowHeader: function(row, col, TH) {
- TH.className = '';
- TH.removeAttribute('style');
- this.rowHeaders[col](row, TH, col);
- },
- renderRowHeaders: function(row, TR) {
- for (var TH = TR.firstChild,
- visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
- if (!TH) {
- TH = document.createElement('TH');
- TR.appendChild(TH);
- } else if (TH.nodeName == 'TD') {
- TH = replaceTdWithTh(TH, TR);
- }
- this.renderRowHeader(row, visibleColIndex, TH);
- TH = TH.nextSibling;
- }
- },
- adjustAvailableNodes: function() {
- this.adjustColGroups();
- this.adjustThead();
- },
- renderColumnHeaders: function() {
- var overlayName = this.wot.getOverlayName();
- if (!this.columnHeaderCount) {
- return;
- }
- var columnCount = this.wtTable.getRenderedColumnsCount();
- for (var i = 0; i < this.columnHeaderCount; i++) {
- var TR = this.getTrForColumnHeaders(i);
- for (var renderedColumnIndex = (-1) * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
- var sourceCol = this.columnFilter.renderedToSource(renderedColumnIndex);
- this.renderColumnHeader(i, sourceCol, TR.childNodes[renderedColumnIndex + this.rowHeaderCount]);
- if (!isRenderedColumnHeaders[overlayName] && !this.wtTable.isWorkingOnClone()) {
- this.markIfOversizedColumnHeader(renderedColumnIndex);
- }
- }
- }
- isRenderedColumnHeaders[overlayName] = true;
- },
- adjustColGroups: function() {
- var columnCount = this.wtTable.getRenderedColumnsCount();
- while (this.wtTable.colgroupChildrenLength < columnCount + this.rowHeaderCount) {
- this.COLGROUP.appendChild(document.createElement('COL'));
- this.wtTable.colgroupChildrenLength++;
- }
- while (this.wtTable.colgroupChildrenLength > columnCount + this.rowHeaderCount) {
- this.COLGROUP.removeChild(this.COLGROUP.lastChild);
- this.wtTable.colgroupChildrenLength--;
- }
- },
- adjustThead: function() {
- var columnCount = this.wtTable.getRenderedColumnsCount();
- var TR = this.THEAD.firstChild;
- if (this.columnHeaders.length) {
- for (var i = 0,
- len = this.columnHeaders.length; i < len; i++) {
- TR = this.THEAD.childNodes[i];
- if (!TR) {
- TR = document.createElement('TR');
- this.THEAD.appendChild(TR);
- }
- this.theadChildrenLength = TR.childNodes.length;
- while (this.theadChildrenLength < columnCount + this.rowHeaderCount) {
- TR.appendChild(document.createElement('TH'));
- this.theadChildrenLength++;
- }
- while (this.theadChildrenLength > columnCount + this.rowHeaderCount) {
- TR.removeChild(TR.lastChild);
- this.theadChildrenLength--;
- }
- }
- var theadChildrenLength = this.THEAD.childNodes.length;
- if (theadChildrenLength > this.columnHeaders.length) {
- for (var i$__1 = this.columnHeaders.length; i$__1 < theadChildrenLength; i$__1++) {
- this.THEAD.removeChild(this.THEAD.lastChild);
- }
- }
- } else if (TR) {
- dom.empty(TR);
- }
- },
- getTrForColumnHeaders: function(index) {
- return this.THEAD.childNodes[index];
- },
- renderColumnHeader: function(row, col, TH) {
- TH.className = '';
- TH.removeAttribute('style');
- return this.columnHeaders[row](col, TH, row);
- },
- renderColGroups: function() {
- for (var colIndex = 0; colIndex < this.wtTable.colgroupChildrenLength; colIndex++) {
- if (colIndex < this.rowHeaderCount) {
- dom.addClass(this.COLGROUP.childNodes[colIndex], 'rowHeader');
- } else {
- dom.removeClass(this.COLGROUP.childNodes[colIndex], 'rowHeader');
- }
- }
- },
- adjustColumns: function(TR, desiredCount) {
- var count = TR.childNodes.length;
- while (count < desiredCount) {
- var TD = document.createElement('TD');
- TR.appendChild(TD);
- count++;
- }
- while (count > desiredCount) {
- TR.removeChild(TR.lastChild);
- count--;
- }
- },
- removeRedundantColumns: function(columnsToRender) {
- while (this.wtTable.tbodyChildrenLength > columnsToRender) {
- this.TBODY.removeChild(this.TBODY.lastChild);
- this.wtTable.tbodyChildrenLength--;
- }
- }
- }, {});
- function replaceTdWithTh(TD, TR) {
- var TH = document.createElement('TH');
- TR.insertBefore(TH, TD);
- TR.removeChild(TD);
- return TH;
- }
- function replaceThWithTd(TH, TR) {
- var TD = document.createElement('TD');
- TR.insertBefore(TD, TH);
- TR.removeChild(TH);
- return TD;
- }
- ;
- window.WalkontableTableRenderer = WalkontableTableRenderer;
-
- //#
- },{"./../../../dom.js":27}],22:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- WalkontableViewport: {get: function() {
- return WalkontableViewport;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47__46__46__47_eventManager_46_js__,
- $__calculator_47_viewportColumns_46_js__,
- $__calculator_47_viewportRows_46_js__;
- var dom = ($___46__46__47__46__46__47__46__46__47_dom_46_js__ = require("./../../../dom.js"), $___46__46__47__46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47__46__46__47__46__46__47_eventManager_46_js__ = require("./../../../eventManager.js"), $___46__46__47__46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var WalkontableViewportColumnsCalculator = ($__calculator_47_viewportColumns_46_js__ = require("./calculator/viewportColumns.js"), $__calculator_47_viewportColumns_46_js__ && $__calculator_47_viewportColumns_46_js__.__esModule && $__calculator_47_viewportColumns_46_js__ || {default: $__calculator_47_viewportColumns_46_js__}).WalkontableViewportColumnsCalculator;
- var WalkontableViewportRowsCalculator = ($__calculator_47_viewportRows_46_js__ = require("./calculator/viewportRows.js"), $__calculator_47_viewportRows_46_js__ && $__calculator_47_viewportRows_46_js__.__esModule && $__calculator_47_viewportRows_46_js__ || {default: $__calculator_47_viewportRows_46_js__}).WalkontableViewportRowsCalculator;
- var WalkontableViewport = function WalkontableViewport(wotInstance) {
- var $__3 = this;
- this.wot = wotInstance;
- this.instance = this.wot;
- this.oversizedRows = [];
- this.oversizedCols = [];
- this.oversizedColumnHeaders = [];
- this.clientHeight = 0;
- this.containerWidth = NaN;
- this.rowHeaderWidth = NaN;
- this.rowsVisibleCalculator = null;
- this.columnsVisibleCalculator = null;
- var eventManager = eventManagerObject(wotInstance);
- eventManager.addEventListener(window, 'resize', (function() {
- $__3.clientHeight = $__3.getWorkspaceHeight();
- }));
- };
- ($traceurRuntime.createClass)(WalkontableViewport, {
- getWorkspaceHeight: function() {
- var trimmingContainer = this.instance.wtOverlays.topOverlay.trimmingContainer;
- var elemHeight;
- var height = 0;
- if (trimmingContainer === window) {
- height = document.documentElement.clientHeight;
- } else {
- elemHeight = dom.outerHeight(trimmingContainer);
- height = (elemHeight > 0 && trimmingContainer.clientHeight > 0) ? trimmingContainer.clientHeight : Infinity;
- }
- return height;
- },
- getWorkspaceWidth: function() {
- var width;
- var totalColumns = this.instance.getSetting("totalColumns");
- var trimmingContainer = this.instance.wtOverlays.leftOverlay.trimmingContainer;
- var overflow;
- var stretchSetting = this.instance.getSetting('stretchH');
- var docOffsetWidth = document.documentElement.offsetWidth;
- if (Handsontable.freezeOverlays) {
- width = Math.min(docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
- } else {
- width = Math.min(this.getContainerFillWidth(), docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
- }
- if (trimmingContainer === window && totalColumns > 0 && this.sumColumnWidths(0, totalColumns - 1) > width) {
- return document.documentElement.clientWidth;
- }
- if (trimmingContainer !== window) {
- overflow = dom.getStyle(this.instance.wtOverlays.leftOverlay.trimmingContainer, 'overflow');
- if (overflow == "scroll" || overflow == "hidden" || overflow == "auto") {
- return Math.max(width, trimmingContainer.clientWidth);
- }
- }
- if (stretchSetting === 'none' || !stretchSetting) {
- return Math.max(width, dom.outerWidth(this.instance.wtTable.TABLE));
- } else {
- return width;
- }
- },
- hasVerticalScroll: function() {
- return this.getWorkspaceActualHeight() > this.getWorkspaceHeight();
- },
- hasHorizontalScroll: function() {
- return this.getWorkspaceActualWidth() > this.getWorkspaceWidth();
- },
- sumColumnWidths: function(from, length) {
- var sum = 0;
- var defaultColumnWidth = this.instance.wtSettings.defaultColumnWidth;
- while (from < length) {
- sum += this.wot.wtTable.getColumnWidth(from) || defaultColumnWidth;
- from++;
- }
- return sum;
- },
- getContainerFillWidth: function() {
- if (this.containerWidth) {
- return this.containerWidth;
- }
- var mainContainer = this.instance.wtTable.holder;
- var fillWidth;
- var dummyElement;
- dummyElement = document.createElement("DIV");
- dummyElement.style.width = "100%";
- dummyElement.style.height = "1px";
- mainContainer.appendChild(dummyElement);
- fillWidth = dummyElement.offsetWidth;
- this.containerWidth = fillWidth;
- mainContainer.removeChild(dummyElement);
- return fillWidth;
- },
- getWorkspaceOffset: function() {
- return dom.offset(this.wot.wtTable.TABLE);
- },
- getWorkspaceActualHeight: function() {
- return dom.outerHeight(this.wot.wtTable.TABLE);
- },
- getWorkspaceActualWidth: function() {
- return dom.outerWidth(this.wot.wtTable.TABLE) || dom.outerWidth(this.wot.wtTable.TBODY) || dom.outerWidth(this.wot.wtTable.THEAD);
- },
- getColumnHeaderHeight: function() {
- if (isNaN(this.columnHeaderHeight)) {
- this.columnHeaderHeight = dom.outerHeight(this.wot.wtTable.THEAD);
- }
- return this.columnHeaderHeight;
- },
- getViewportHeight: function() {
- var containerHeight = this.getWorkspaceHeight();
- var columnHeaderHeight;
- if (containerHeight === Infinity) {
- return containerHeight;
- }
- columnHeaderHeight = this.getColumnHeaderHeight();
- if (columnHeaderHeight > 0) {
- containerHeight -= columnHeaderHeight;
- }
- return containerHeight;
- },
- getRowHeaderWidth: function() {
- if (this.wot.cloneSource) {
- return this.wot.cloneSource.wtViewport.getRowHeaderWidth();
- }
- if (isNaN(this.rowHeaderWidth)) {
- var rowHeaders = this.instance.getSetting('rowHeaders');
- if (rowHeaders.length) {
- var TH = this.instance.wtTable.TABLE.querySelector('TH');
- this.rowHeaderWidth = 0;
- for (var i = 0,
- len = rowHeaders.length; i < len; i++) {
- if (TH) {
- this.rowHeaderWidth += dom.outerWidth(TH);
- TH = TH.nextSibling;
- } else {
- this.rowHeaderWidth += 50;
- }
- }
- } else {
- this.rowHeaderWidth = 0;
- }
- }
- return this.rowHeaderWidth;
- },
- getViewportWidth: function() {
- var containerWidth = this.getWorkspaceWidth();
- var rowHeaderWidth;
- if (containerWidth === Infinity) {
- return containerWidth;
- }
- rowHeaderWidth = this.getRowHeaderWidth();
- if (rowHeaderWidth > 0) {
- return containerWidth - rowHeaderWidth;
- }
- return containerWidth;
- },
- createRowsCalculator: function() {
- var visible = arguments[0] !== (void 0) ? arguments[0] : false;
- var $__3 = this;
- var height;
- var pos;
- var fixedRowsTop;
- this.rowHeaderWidth = NaN;
- if (this.wot.wtSettings.settings.renderAllRows) {
- height = Infinity;
- } else {
- height = this.getViewportHeight();
- }
- pos = dom.getScrollTop(this.wot.wtOverlays.mainTableScrollableElement) - this.wot.wtOverlays.topOverlay.getTableParentOffset();
- if (pos < 0) {
- pos = 0;
- }
- fixedRowsTop = this.wot.getSetting('fixedRowsTop');
- if (fixedRowsTop) {
- var fixedRowsHeight = this.wot.wtOverlays.topOverlay.sumCellSizes(0, fixedRowsTop);
- pos += fixedRowsHeight;
- height -= fixedRowsHeight;
- }
- return new WalkontableViewportRowsCalculator(height, pos, this.wot.getSetting('totalRows'), (function(sourceRow) {
- return $__3.wot.wtTable.getRowHeight(sourceRow);
- }), visible ? null : this.wot.wtSettings.settings.viewportRowCalculatorOverride, visible);
- },
- createColumnsCalculator: function() {
- var visible = arguments[0] !== (void 0) ? arguments[0] : false;
- var $__3 = this;
- var width = this.getViewportWidth();
- var pos;
- var fixedColumnsLeft;
- this.columnHeaderHeight = NaN;
- pos = this.wot.wtOverlays.leftOverlay.getScrollPosition() - this.wot.wtOverlays.topOverlay.getTableParentOffset();
- if (pos < 0) {
- pos = 0;
- }
- fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
- if (fixedColumnsLeft) {
- var fixedColumnsWidth = this.wot.wtOverlays.leftOverlay.sumCellSizes(0, fixedColumnsLeft);
- pos += fixedColumnsWidth;
- width -= fixedColumnsWidth;
- }
- if (this.wot.wtTable.holder.clientWidth !== this.wot.wtTable.holder.offsetWidth) {
- width -= dom.getScrollbarWidth();
- }
- return new WalkontableViewportColumnsCalculator(width, pos, this.wot.getSetting('totalColumns'), (function(sourceCol) {
- return $__3.wot.wtTable.getColumnWidth(sourceCol);
- }), visible ? null : this.wot.wtSettings.settings.viewportColumnCalculatorOverride, visible, this.wot.getSetting('stretchH'));
- },
- createRenderCalculators: function() {
- var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
- if (fastDraw) {
- var proposedRowsVisibleCalculator = this.createRowsCalculator(true);
- var proposedColumnsVisibleCalculator = this.createColumnsCalculator(true);
- if (!(this.areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) && this.areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator))) {
- fastDraw = false;
- }
- }
- if (!fastDraw) {
- this.rowsRenderCalculator = this.createRowsCalculator();
- this.columnsRenderCalculator = this.createColumnsCalculator();
- }
- this.rowsVisibleCalculator = null;
- this.columnsVisibleCalculator = null;
- return fastDraw;
- },
- createVisibleCalculators: function() {
- this.rowsVisibleCalculator = this.createRowsCalculator(true);
- this.columnsVisibleCalculator = this.createColumnsCalculator(true);
- },
- areAllProposedVisibleRowsAlreadyRendered: function(proposedRowsVisibleCalculator) {
- if (this.rowsVisibleCalculator) {
- if (proposedRowsVisibleCalculator.startRow < this.rowsRenderCalculator.startRow || (proposedRowsVisibleCalculator.startRow === this.rowsRenderCalculator.startRow && proposedRowsVisibleCalculator.startRow > 0)) {
- return false;
- } else if (proposedRowsVisibleCalculator.endRow > this.rowsRenderCalculator.endRow || (proposedRowsVisibleCalculator.endRow === this.rowsRenderCalculator.endRow && proposedRowsVisibleCalculator.endRow < this.wot.getSetting('totalRows') - 1)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- },
- areAllProposedVisibleColumnsAlreadyRendered: function(proposedColumnsVisibleCalculator) {
- if (this.columnsVisibleCalculator) {
- if (proposedColumnsVisibleCalculator.startColumn < this.columnsRenderCalculator.startColumn || (proposedColumnsVisibleCalculator.startColumn === this.columnsRenderCalculator.startColumn && proposedColumnsVisibleCalculator.startColumn > 0)) {
- return false;
- } else if (proposedColumnsVisibleCalculator.endColumn > this.columnsRenderCalculator.endColumn || (proposedColumnsVisibleCalculator.endColumn === this.columnsRenderCalculator.endColumn && proposedColumnsVisibleCalculator.endColumn < this.wot.getSetting('totalColumns') - 1)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- }
- }, {});
- ;
- window.WalkontableViewport = WalkontableViewport;
-
- //#
- },{"./../../../dom.js":27,"./../../../eventManager.js":41,"./calculator/viewportColumns.js":3,"./calculator/viewportRows.js":4}],23:[function(require,module,exports){
- "use strict";
- var $__shims_47_array_46_filter_46_js__,
- $__shims_47_array_46_indexOf_46_js__,
- $__shims_47_array_46_isArray_46_js__,
- $__shims_47_classes_46_js__,
- $__shims_47_object_46_keys_46_js__,
- $__shims_47_string_46_trim_46_js__,
- $__shims_47_weakmap_46_js__,
- $__pluginHooks_46_js__,
- $__core_46_js__,
- $__renderers_47__95_cellDecorator_46_js__,
- $__cellTypes_46_js__,
- $___46__46__47_plugins_47_jqueryHandsontable_46_js__;
- var version = Handsontable.version;
- var buildDate = Handsontable.buildDate;
- window.Handsontable = function Handsontable(rootElement, userSettings) {
- var instance = new Handsontable.Core(rootElement, userSettings || {});
- instance.init();
- return instance;
- };
- Handsontable.version = version;
- Handsontable.buildDate = buildDate;
- ($__shims_47_array_46_filter_46_js__ = require("./shims/array.filter.js"), $__shims_47_array_46_filter_46_js__ && $__shims_47_array_46_filter_46_js__.__esModule && $__shims_47_array_46_filter_46_js__ || {default: $__shims_47_array_46_filter_46_js__});
- ($__shims_47_array_46_indexOf_46_js__ = require("./shims/array.indexOf.js"), $__shims_47_array_46_indexOf_46_js__ && $__shims_47_array_46_indexOf_46_js__.__esModule && $__shims_47_array_46_indexOf_46_js__ || {default: $__shims_47_array_46_indexOf_46_js__});
- ($__shims_47_array_46_isArray_46_js__ = require("./shims/array.isArray.js"), $__shims_47_array_46_isArray_46_js__ && $__shims_47_array_46_isArray_46_js__.__esModule && $__shims_47_array_46_isArray_46_js__ || {default: $__shims_47_array_46_isArray_46_js__});
- ($__shims_47_classes_46_js__ = require("./shims/classes.js"), $__shims_47_classes_46_js__ && $__shims_47_classes_46_js__.__esModule && $__shims_47_classes_46_js__ || {default: $__shims_47_classes_46_js__});
- ($__shims_47_object_46_keys_46_js__ = require("./shims/object.keys.js"), $__shims_47_object_46_keys_46_js__ && $__shims_47_object_46_keys_46_js__.__esModule && $__shims_47_object_46_keys_46_js__ || {default: $__shims_47_object_46_keys_46_js__});
- ($__shims_47_string_46_trim_46_js__ = require("./shims/string.trim.js"), $__shims_47_string_46_trim_46_js__ && $__shims_47_string_46_trim_46_js__.__esModule && $__shims_47_string_46_trim_46_js__ || {default: $__shims_47_string_46_trim_46_js__});
- ($__shims_47_weakmap_46_js__ = require("./shims/weakmap.js"), $__shims_47_weakmap_46_js__ && $__shims_47_weakmap_46_js__.__esModule && $__shims_47_weakmap_46_js__ || {default: $__shims_47_weakmap_46_js__});
- Handsontable.plugins = {};
- var Hooks = ($__pluginHooks_46_js__ = require("./pluginHooks.js"), $__pluginHooks_46_js__ && $__pluginHooks_46_js__.__esModule && $__pluginHooks_46_js__ || {default: $__pluginHooks_46_js__}).Hooks;
- if (!Handsontable.hooks) {
- Handsontable.hooks = new Hooks();
- }
- ($__core_46_js__ = require("./core.js"), $__core_46_js__ && $__core_46_js__.__esModule && $__core_46_js__ || {default: $__core_46_js__});
- ($__renderers_47__95_cellDecorator_46_js__ = require("./renderers/_cellDecorator.js"), $__renderers_47__95_cellDecorator_46_js__ && $__renderers_47__95_cellDecorator_46_js__.__esModule && $__renderers_47__95_cellDecorator_46_js__ || {default: $__renderers_47__95_cellDecorator_46_js__});
- ($__cellTypes_46_js__ = require("./cellTypes.js"), $__cellTypes_46_js__ && $__cellTypes_46_js__.__esModule && $__cellTypes_46_js__ || {default: $__cellTypes_46_js__});
- ($___46__46__47_plugins_47_jqueryHandsontable_46_js__ = require("./../plugins/jqueryHandsontable.js"), $___46__46__47_plugins_47_jqueryHandsontable_46_js__ && $___46__46__47_plugins_47_jqueryHandsontable_46_js__.__esModule && $___46__46__47_plugins_47_jqueryHandsontable_46_js__ || {default: $___46__46__47_plugins_47_jqueryHandsontable_46_js__});
-
- //#
- },{"./../plugins/jqueryHandsontable.js":1,"./cellTypes.js":24,"./core.js":25,"./pluginHooks.js":44,"./renderers/_cellDecorator.js":71,"./shims/array.filter.js":78,"./shims/array.indexOf.js":79,"./shims/array.isArray.js":80,"./shims/classes.js":81,"./shims/object.keys.js":82,"./shims/string.trim.js":83,"./shims/weakmap.js":84}],24:[function(require,module,exports){
- "use strict";
- var $__helpers_46_js__,
- $__editors_46_js__,
- $__renderers_46_js__,
- $__editors_47_autocompleteEditor_46_js__,
- $__editors_47_checkboxEditor_46_js__,
- $__editors_47_dateEditor_46_js__,
- $__editors_47_dropdownEditor_46_js__,
- $__editors_47_handsontableEditor_46_js__,
- $__editors_47_mobileTextEditor_46_js__,
- $__editors_47_numericEditor_46_js__,
- $__editors_47_passwordEditor_46_js__,
- $__editors_47_selectEditor_46_js__,
- $__editors_47_textEditor_46_js__,
- $__renderers_47_autocompleteRenderer_46_js__,
- $__renderers_47_checkboxRenderer_46_js__,
- $__renderers_47_htmlRenderer_46_js__,
- $__renderers_47_numericRenderer_46_js__,
- $__renderers_47_passwordRenderer_46_js__,
- $__renderers_47_textRenderer_46_js__,
- $__validators_47_autocompleteValidator_46_js__,
- $__validators_47_dateValidator_46_js__,
- $__validators_47_numericValidator_46_js__;
- var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
- var getEditorConstructor = ($__editors_46_js__ = require("./editors.js"), $__editors_46_js__ && $__editors_46_js__.__esModule && $__editors_46_js__ || {default: $__editors_46_js__}).getEditorConstructor;
- var getRenderer = ($__renderers_46_js__ = require("./renderers.js"), $__renderers_46_js__ && $__renderers_46_js__.__esModule && $__renderers_46_js__ || {default: $__renderers_46_js__}).getRenderer;
- var AutocompleteEditor = ($__editors_47_autocompleteEditor_46_js__ = require("./editors/autocompleteEditor.js"), $__editors_47_autocompleteEditor_46_js__ && $__editors_47_autocompleteEditor_46_js__.__esModule && $__editors_47_autocompleteEditor_46_js__ || {default: $__editors_47_autocompleteEditor_46_js__}).AutocompleteEditor;
- var CheckboxEditor = ($__editors_47_checkboxEditor_46_js__ = require("./editors/checkboxEditor.js"), $__editors_47_checkboxEditor_46_js__ && $__editors_47_checkboxEditor_46_js__.__esModule && $__editors_47_checkboxEditor_46_js__ || {default: $__editors_47_checkboxEditor_46_js__}).CheckboxEditor;
- var DateEditor = ($__editors_47_dateEditor_46_js__ = require("./editors/dateEditor.js"), $__editors_47_dateEditor_46_js__ && $__editors_47_dateEditor_46_js__.__esModule && $__editors_47_dateEditor_46_js__ || {default: $__editors_47_dateEditor_46_js__}).DateEditor;
- var DropdownEditor = ($__editors_47_dropdownEditor_46_js__ = require("./editors/dropdownEditor.js"), $__editors_47_dropdownEditor_46_js__ && $__editors_47_dropdownEditor_46_js__.__esModule && $__editors_47_dropdownEditor_46_js__ || {default: $__editors_47_dropdownEditor_46_js__}).DropdownEditor;
- var HandsontableEditor = ($__editors_47_handsontableEditor_46_js__ = require("./editors/handsontableEditor.js"), $__editors_47_handsontableEditor_46_js__ && $__editors_47_handsontableEditor_46_js__.__esModule && $__editors_47_handsontableEditor_46_js__ || {default: $__editors_47_handsontableEditor_46_js__}).HandsontableEditor;
- var MobileTextEditor = ($__editors_47_mobileTextEditor_46_js__ = require("./editors/mobileTextEditor.js"), $__editors_47_mobileTextEditor_46_js__ && $__editors_47_mobileTextEditor_46_js__.__esModule && $__editors_47_mobileTextEditor_46_js__ || {default: $__editors_47_mobileTextEditor_46_js__}).MobileTextEditor;
- var NumericEditor = ($__editors_47_numericEditor_46_js__ = require("./editors/numericEditor.js"), $__editors_47_numericEditor_46_js__ && $__editors_47_numericEditor_46_js__.__esModule && $__editors_47_numericEditor_46_js__ || {default: $__editors_47_numericEditor_46_js__}).NumericEditor;
- var PasswordEditor = ($__editors_47_passwordEditor_46_js__ = require("./editors/passwordEditor.js"), $__editors_47_passwordEditor_46_js__ && $__editors_47_passwordEditor_46_js__.__esModule && $__editors_47_passwordEditor_46_js__ || {default: $__editors_47_passwordEditor_46_js__}).PasswordEditor;
- var SelectEditor = ($__editors_47_selectEditor_46_js__ = require("./editors/selectEditor.js"), $__editors_47_selectEditor_46_js__ && $__editors_47_selectEditor_46_js__.__esModule && $__editors_47_selectEditor_46_js__ || {default: $__editors_47_selectEditor_46_js__}).SelectEditor;
- var TextEditor = ($__editors_47_textEditor_46_js__ = require("./editors/textEditor.js"), $__editors_47_textEditor_46_js__ && $__editors_47_textEditor_46_js__.__esModule && $__editors_47_textEditor_46_js__ || {default: $__editors_47_textEditor_46_js__}).TextEditor;
- var AutocompleteRenderer = ($__renderers_47_autocompleteRenderer_46_js__ = require("./renderers/autocompleteRenderer.js"), $__renderers_47_autocompleteRenderer_46_js__ && $__renderers_47_autocompleteRenderer_46_js__.__esModule && $__renderers_47_autocompleteRenderer_46_js__ || {default: $__renderers_47_autocompleteRenderer_46_js__}).AutocompleteRenderer;
- var CheckboxRenderer = ($__renderers_47_checkboxRenderer_46_js__ = require("./renderers/checkboxRenderer.js"), $__renderers_47_checkboxRenderer_46_js__ && $__renderers_47_checkboxRenderer_46_js__.__esModule && $__renderers_47_checkboxRenderer_46_js__ || {default: $__renderers_47_checkboxRenderer_46_js__}).CheckboxRenderer;
- var HtmlRenderer = ($__renderers_47_htmlRenderer_46_js__ = require("./renderers/htmlRenderer.js"), $__renderers_47_htmlRenderer_46_js__ && $__renderers_47_htmlRenderer_46_js__.__esModule && $__renderers_47_htmlRenderer_46_js__ || {default: $__renderers_47_htmlRenderer_46_js__}).HtmlRenderer;
- var NumericRenderer = ($__renderers_47_numericRenderer_46_js__ = require("./renderers/numericRenderer.js"), $__renderers_47_numericRenderer_46_js__ && $__renderers_47_numericRenderer_46_js__.__esModule && $__renderers_47_numericRenderer_46_js__ || {default: $__renderers_47_numericRenderer_46_js__}).NumericRenderer;
- var PasswordRenderer = ($__renderers_47_passwordRenderer_46_js__ = require("./renderers/passwordRenderer.js"), $__renderers_47_passwordRenderer_46_js__ && $__renderers_47_passwordRenderer_46_js__.__esModule && $__renderers_47_passwordRenderer_46_js__ || {default: $__renderers_47_passwordRenderer_46_js__}).PasswordRenderer;
- var TextRenderer = ($__renderers_47_textRenderer_46_js__ = require("./renderers/textRenderer.js"), $__renderers_47_textRenderer_46_js__ && $__renderers_47_textRenderer_46_js__.__esModule && $__renderers_47_textRenderer_46_js__ || {default: $__renderers_47_textRenderer_46_js__}).TextRenderer;
- var AutocompleteValidator = ($__validators_47_autocompleteValidator_46_js__ = require("./validators/autocompleteValidator.js"), $__validators_47_autocompleteValidator_46_js__ && $__validators_47_autocompleteValidator_46_js__.__esModule && $__validators_47_autocompleteValidator_46_js__ || {default: $__validators_47_autocompleteValidator_46_js__}).AutocompleteValidator;
- var DateValidator = ($__validators_47_dateValidator_46_js__ = require("./validators/dateValidator.js"), $__validators_47_dateValidator_46_js__ && $__validators_47_dateValidator_46_js__.__esModule && $__validators_47_dateValidator_46_js__ || {default: $__validators_47_dateValidator_46_js__}).DateValidator;
- var NumericValidator = ($__validators_47_numericValidator_46_js__ = require("./validators/numericValidator.js"), $__validators_47_numericValidator_46_js__ && $__validators_47_numericValidator_46_js__.__esModule && $__validators_47_numericValidator_46_js__ || {default: $__validators_47_numericValidator_46_js__}).NumericValidator;
- Handsontable.mobileBrowser = helper.isMobileBrowser();
- Handsontable.AutocompleteCell = {
- editor: getEditorConstructor('autocomplete'),
- renderer: getRenderer('autocomplete'),
- validator: Handsontable.AutocompleteValidator
- };
- Handsontable.CheckboxCell = {
- editor: getEditorConstructor('checkbox'),
- renderer: getRenderer('checkbox')
- };
- Handsontable.TextCell = {
- editor: Handsontable.mobileBrowser ? getEditorConstructor('mobile') : getEditorConstructor('text'),
- renderer: getRenderer('text')
- };
- Handsontable.NumericCell = {
- editor: getEditorConstructor('numeric'),
- renderer: getRenderer('numeric'),
- validator: Handsontable.NumericValidator,
- dataType: 'number'
- };
- Handsontable.DateCell = {
- editor: getEditorConstructor('date'),
- validator: Handsontable.DateValidator,
- renderer: getRenderer('autocomplete')
- };
- Handsontable.HandsontableCell = {
- editor: getEditorConstructor('handsontable'),
- renderer: getRenderer('autocomplete')
- };
- Handsontable.PasswordCell = {
- editor: getEditorConstructor('password'),
- renderer: getRenderer('password'),
- copyable: false
- };
- Handsontable.DropdownCell = {
- editor: getEditorConstructor('dropdown'),
- renderer: getRenderer('autocomplete'),
- validator: Handsontable.AutocompleteValidator
- };
- Handsontable.cellTypes = {
- text: Handsontable.TextCell,
- date: Handsontable.DateCell,
- numeric: Handsontable.NumericCell,
- checkbox: Handsontable.CheckboxCell,
- autocomplete: Handsontable.AutocompleteCell,
- handsontable: Handsontable.HandsontableCell,
- password: Handsontable.PasswordCell,
- dropdown: Handsontable.DropdownCell
- };
- Handsontable.cellLookup = {validator: {
- numeric: Handsontable.NumericValidator,
- autocomplete: Handsontable.AutocompleteValidator
- }};
-
- //#
- },{"./editors.js":29,"./editors/autocompleteEditor.js":31,"./editors/checkboxEditor.js":32,"./editors/dateEditor.js":33,"./editors/dropdownEditor.js":34,"./editors/handsontableEditor.js":35,"./editors/mobileTextEditor.js":36,"./editors/numericEditor.js":37,"./editors/passwordEditor.js":38,"./editors/selectEditor.js":39,"./editors/textEditor.js":40,"./helpers.js":42,"./renderers.js":70,"./renderers/autocompleteRenderer.js":72,"./renderers/checkboxRenderer.js":73,"./renderers/htmlRenderer.js":74,"./renderers/numericRenderer.js":75,"./renderers/passwordRenderer.js":76,"./renderers/textRenderer.js":77,"./validators/autocompleteValidator.js":86,"./validators/dateValidator.js":87,"./validators/numericValidator.js":88}],25:[function(require,module,exports){
- "use strict";
- var $__dom_46_js__,
- $__helpers_46_js__,
- $__numeral__,
- $__dataMap_46_js__,
- $__editorManager_46_js__,
- $__eventManager_46_js__,
- $__plugins_46_js__,
- $__renderers_46_js__,
- $__tableView_46_js__,
- $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
- $__3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__,
- $__3rdparty_47_walkontable_47_src_47_selection_46_js__;
- var dom = ($__dom_46_js__ = require("./dom.js"), $__dom_46_js__ && $__dom_46_js__.__esModule && $__dom_46_js__ || {default: $__dom_46_js__});
- var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
- var numeral = ($__numeral__ = require("numeral"), $__numeral__ && $__numeral__.__esModule && $__numeral__ || {default: $__numeral__}).default;
- var DataMap = ($__dataMap_46_js__ = require("./dataMap.js"), $__dataMap_46_js__ && $__dataMap_46_js__.__esModule && $__dataMap_46_js__ || {default: $__dataMap_46_js__}).DataMap;
- var EditorManager = ($__editorManager_46_js__ = require("./editorManager.js"), $__editorManager_46_js__ && $__editorManager_46_js__.__esModule && $__editorManager_46_js__ || {default: $__editorManager_46_js__}).EditorManager;
- var eventManagerObject = ($__eventManager_46_js__ = require("./eventManager.js"), $__eventManager_46_js__ && $__eventManager_46_js__.__esModule && $__eventManager_46_js__ || {default: $__eventManager_46_js__}).eventManager;
- var getPlugin = ($__plugins_46_js__ = require("./plugins.js"), $__plugins_46_js__ && $__plugins_46_js__.__esModule && $__plugins_46_js__ || {default: $__plugins_46_js__}).getPlugin;
- var getRenderer = ($__renderers_46_js__ = require("./renderers.js"), $__renderers_46_js__ && $__renderers_46_js__.__esModule && $__renderers_46_js__ || {default: $__renderers_46_js__}).getRenderer;
- var TableView = ($__tableView_46_js__ = require("./tableView.js"), $__tableView_46_js__ && $__tableView_46_js__.__esModule && $__tableView_46_js__ || {default: $__tableView_46_js__}).TableView;
- var WalkontableCellCoords = ($__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ = require("./3rdparty/walkontable/src/cell/coords.js"), $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ && $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__.__esModule && $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ || {default: $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__}).WalkontableCellCoords;
- var WalkontableCellRange = ($__3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ = require("./3rdparty/walkontable/src/cell/range.js"), $__3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ && $__3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__.__esModule && $__3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ || {default: $__3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__}).WalkontableCellRange;
- var WalkontableSelection = ($__3rdparty_47_walkontable_47_src_47_selection_46_js__ = require("./3rdparty/walkontable/src/selection.js"), $__3rdparty_47_walkontable_47_src_47_selection_46_js__ && $__3rdparty_47_walkontable_47_src_47_selection_46_js__.__esModule && $__3rdparty_47_walkontable_47_src_47_selection_46_js__ || {default: $__3rdparty_47_walkontable_47_src_47_selection_46_js__}).WalkontableSelection;
- Handsontable.activeGuid = null;
- Handsontable.Core = function Core(rootElement, userSettings) {
- var priv,
- datamap,
- grid,
- selection,
- editorManager,
- instance = this,
- GridSettings = function() {},
- eventManager = eventManagerObject(instance);
- helper.extend(GridSettings.prototype, DefaultSettings.prototype);
- helper.extend(GridSettings.prototype, userSettings);
- helper.extend(GridSettings.prototype, expandType(userSettings));
- this.rootElement = rootElement;
- this.isHotTableEnv = dom.isChildOfWebComponentTable(this.rootElement);
- Handsontable.eventManager.isHotTableEnv = this.isHotTableEnv;
- this.container = document.createElement('DIV');
- rootElement.insertBefore(this.container, rootElement.firstChild);
- this.guid = 'ht_' + helper.randomString();
- if (!this.rootElement.id || this.rootElement.id.substring(0, 3) === "ht_") {
- this.rootElement.id = this.guid;
- }
- priv = {
- cellSettings: [],
- columnSettings: [],
- columnsSettingConflicts: ['data', 'width'],
- settings: new GridSettings(),
- selRange: null,
- isPopulated: null,
- scrollable: null,
- firstRun: true
- };
- grid = {
- alter: function(action, index, amount, source, keepEmptyRows) {
- var delta;
- amount = amount || 1;
- switch (action) {
- case "insert_row":
- if (instance.getSettings().maxRows === instance.countRows()) {
- return;
- }
- delta = datamap.createRow(index, amount);
- if (delta) {
- if (selection.isSelected() && priv.selRange.from.row >= index) {
- priv.selRange.from.row = priv.selRange.from.row + delta;
- selection.transformEnd(delta, 0);
- } else {
- selection.refreshBorders();
- }
- }
- break;
- case "insert_col":
- delta = datamap.createCol(index, amount);
- if (delta) {
- if (Array.isArray(instance.getSettings().colHeaders)) {
- var spliceArray = [index, 0];
- spliceArray.length += delta;
- Array.prototype.splice.apply(instance.getSettings().colHeaders, spliceArray);
- }
- if (selection.isSelected() && priv.selRange.from.col >= index) {
- priv.selRange.from.col = priv.selRange.from.col + delta;
- selection.transformEnd(0, delta);
- } else {
- selection.refreshBorders();
- }
- }
- break;
- case "remove_row":
- index = instance.runHooks('modifyCol', index);
- datamap.removeRow(index, amount);
- priv.cellSettings.splice(index, amount);
- var fixedRowsTop = instance.getSettings().fixedRowsTop;
- if (fixedRowsTop >= index + 1) {
- instance.getSettings().fixedRowsTop -= Math.min(amount, fixedRowsTop - index);
- }
- grid.adjustRowsAndCols();
- selection.refreshBorders();
- break;
- case "remove_col":
- datamap.removeCol(index, amount);
- for (var row = 0,
- len = datamap.getAll().length; row < len; row++) {
- if (row in priv.cellSettings) {
- priv.cellSettings[row].splice(index, amount);
- }
- }
- var fixedColumnsLeft = instance.getSettings().fixedColumnsLeft;
- if (fixedColumnsLeft >= index + 1) {
- instance.getSettings().fixedColumnsLeft -= Math.min(amount, fixedColumnsLeft - index);
- }
- if (Array.isArray(instance.getSettings().colHeaders)) {
- if (typeof index == 'undefined') {
- index = -1;
- }
- instance.getSettings().colHeaders.splice(index, amount);
- }
- grid.adjustRowsAndCols();
- selection.refreshBorders();
- break;
- default:
- throw new Error('There is no such action "' + action + '"');
- break;
- }
- if (!keepEmptyRows) {
- grid.adjustRowsAndCols();
- }
- },
- adjustRowsAndCols: function() {
- if (priv.settings.minRows) {
- var rows = instance.countRows();
- if (rows < priv.settings.minRows) {
- for (var r = 0,
- minRows = priv.settings.minRows; r < minRows - rows; r++) {
- datamap.createRow(instance.countRows(), 1, true);
- }
- }
- }
- if (priv.settings.minSpareRows) {
- var emptyRows = instance.countEmptyRows(true);
- if (emptyRows < priv.settings.minSpareRows) {
- for (; emptyRows < priv.settings.minSpareRows && instance.countRows() < priv.settings.maxRows; emptyRows++) {
- datamap.createRow(instance.countRows(), 1, true);
- }
- }
- }
- {
- var emptyCols;
- if (priv.settings.minCols || priv.settings.minSpareCols) {
- emptyCols = instance.countEmptyCols(true);
- }
- if (priv.settings.minCols && !priv.settings.columns && instance.countCols() < priv.settings.minCols) {
- for (; instance.countCols() < priv.settings.minCols; emptyCols++) {
- datamap.createCol(instance.countCols(), 1, true);
- }
- }
- if (priv.settings.minSpareCols && !priv.settings.columns && instance.dataType === 'array' && emptyCols < priv.settings.minSpareCols) {
- for (; emptyCols < priv.settings.minSpareCols && instance.countCols() < priv.settings.maxCols; emptyCols++) {
- datamap.createCol(instance.countCols(), 1, true);
- }
- }
- }
- var rowCount = instance.countRows();
- var colCount = instance.countCols();
- if (rowCount === 0 || colCount === 0) {
- selection.deselect();
- }
- if (selection.isSelected()) {
- var selectionChanged = false;
- var fromRow = priv.selRange.from.row;
- var fromCol = priv.selRange.from.col;
- var toRow = priv.selRange.to.row;
- var toCol = priv.selRange.to.col;
- if (fromRow > rowCount - 1) {
- fromRow = rowCount - 1;
- selectionChanged = true;
- if (toRow > fromRow) {
- toRow = fromRow;
- }
- } else if (toRow > rowCount - 1) {
- toRow = rowCount - 1;
- selectionChanged = true;
- if (fromRow > toRow) {
- fromRow = toRow;
- }
- }
- if (fromCol > colCount - 1) {
- fromCol = colCount - 1;
- selectionChanged = true;
- if (toCol > fromCol) {
- toCol = fromCol;
- }
- } else if (toCol > colCount - 1) {
- toCol = colCount - 1;
- selectionChanged = true;
- if (fromCol > toCol) {
- fromCol = toCol;
- }
- }
- if (selectionChanged) {
- instance.selectCell(fromRow, fromCol, toRow, toCol);
- }
- }
- if (instance.view) {
- instance.view.wt.wtOverlays.adjustElementsSize();
- }
- },
- populateFromArray: function(start, input, end, source, method, direction, deltas) {
- var r,
- rlen,
- c,
- clen,
- setData = [],
- current = {};
- rlen = input.length;
- if (rlen === 0) {
- return false;
- }
- var repeatCol,
- repeatRow,
- cmax,
- rmax;
- switch (method) {
- case 'shift_down':
- repeatCol = end ? end.col - start.col + 1 : 0;
- repeatRow = end ? end.row - start.row + 1 : 0;
- input = helper.translateRowsToColumns(input);
- for (c = 0, clen = input.length, cmax = Math.max(clen, repeatCol); c < cmax; c++) {
- if (c < clen) {
- for (r = 0, rlen = input[c].length; r < repeatRow - rlen; r++) {
- input[c].push(input[c][r % rlen]);
- }
- input[c].unshift(start.col + c, start.row, 0);
- instance.spliceCol.apply(instance, input[c]);
- } else {
- input[c % clen][0] = start.col + c;
- instance.spliceCol.apply(instance, input[c % clen]);
- }
- }
- break;
- case 'shift_right':
- repeatCol = end ? end.col - start.col + 1 : 0;
- repeatRow = end ? end.row - start.row + 1 : 0;
- for (r = 0, rlen = input.length, rmax = Math.max(rlen, repeatRow); r < rmax; r++) {
- if (r < rlen) {
- for (c = 0, clen = input[r].length; c < repeatCol - clen; c++) {
- input[r].push(input[r][c % clen]);
- }
- input[r].unshift(start.row + r, start.col, 0);
- instance.spliceRow.apply(instance, input[r]);
- } else {
- input[r % rlen][0] = start.row + r;
- instance.spliceRow.apply(instance, input[r % rlen]);
- }
- }
- break;
- case 'overwrite':
- default:
- current.row = start.row;
- current.col = start.col;
- var iterators = {
- row: 0,
- col: 0
- },
- selected = {
- row: (end && start) ? (end.row - start.row + 1) : 1,
- col: (end && start) ? (end.col - start.col + 1) : 1
- },
- pushData = true;
- if (['up', 'left'].indexOf(direction) !== -1) {
- iterators = {
- row: Math.ceil(selected.row / rlen) || 1,
- col: Math.ceil(selected.col / input[0].length) || 1
- };
- } else if (['down', 'right'].indexOf(direction) !== -1) {
- iterators = {
- row: 1,
- col: 1
- };
- }
- for (r = 0; r < rlen; r++) {
- if ((end && current.row > end.row) || (!priv.settings.allowInsertRow && current.row > instance.countRows() - 1) || (current.row >= priv.settings.maxRows)) {
- break;
- }
- current.col = start.col;
- clen = input[r] ? input[r].length : 0;
- for (c = 0; c < clen; c++) {
- if ((end && current.col > end.col) || (!priv.settings.allowInsertColumn && current.col > instance.countCols() - 1) || (current.col >= priv.settings.maxCols)) {
- break;
- }
- if (!instance.getCellMeta(current.row, current.col).readOnly) {
- var result,
- value = input[r][c],
- orgValue = instance.getDataAtCell(current.row, current.col),
- index = {
- row: r,
- col: c
- },
- valueSchema,
- orgValueSchema;
- if (source === 'autofill') {
- result = instance.runHooks('beforeAutofillInsidePopulate', index, direction, input, deltas, iterators, selected);
- if (result) {
- iterators = typeof(result.iterators) !== 'undefined' ? result.iterators : iterators;
- value = typeof(result.value) !== 'undefined' ? result.value : value;
- }
- }
- if (value !== null && typeof value === 'object') {
- if (orgValue === null || typeof orgValue !== 'object') {
- pushData = false;
- } else {
- orgValueSchema = Handsontable.helper.duckSchema(orgValue[0] || orgValue);
- valueSchema = Handsontable.helper.duckSchema(value[0] || value);
- if (Handsontable.helper.isObjectEquals(orgValueSchema, valueSchema)) {
- value = Handsontable.helper.deepClone(value);
- } else {
- pushData = false;
- }
- }
- } else if (orgValue !== null && typeof orgValue === 'object') {
- pushData = false;
- }
- if (pushData) {
- setData.push([current.row, current.col, value]);
- }
- pushData = true;
- }
- current.col++;
- if (end && c === clen - 1) {
- c = -1;
- if (['down', 'right'].indexOf(direction) !== -1) {
- iterators.col++;
- } else if (['up', 'left'].indexOf(direction) !== -1) {
- if (iterators.col > 1) {
- iterators.col--;
- }
- }
- }
- }
- current.row++;
- iterators.col = 1;
- if (end && r === rlen - 1) {
- r = -1;
- if (['down', 'right'].indexOf(direction) !== -1) {
- iterators.row++;
- } else if (['up', 'left'].indexOf(direction) !== -1) {
- if (iterators.row > 1) {
- iterators.row--;
- }
- }
- }
- }
- instance.setDataAtCell(setData, null, null, source || 'populateFromArray');
- break;
- }
- }
- };
- this.selection = selection = {
- inProgress: false,
- selectedHeader: {
- cols: false,
- rows: false
- },
- setSelectedHeaders: function(rows, cols) {
- instance.selection.selectedHeader.rows = rows;
- instance.selection.selectedHeader.cols = cols;
- },
- begin: function() {
- instance.selection.inProgress = true;
- },
- finish: function() {
- var sel = instance.getSelected();
- Handsontable.hooks.run(instance, "afterSelectionEnd", sel[0], sel[1], sel[2], sel[3]);
- Handsontable.hooks.run(instance, "afterSelectionEndByProp", sel[0], instance.colToProp(sel[1]), sel[2], instance.colToProp(sel[3]));
- instance.selection.inProgress = false;
- },
- isInProgress: function() {
- return instance.selection.inProgress;
- },
- setRangeStart: function(coords, keepEditorOpened) {
- Handsontable.hooks.run(instance, "beforeSetRangeStart", coords);
- priv.selRange = new WalkontableCellRange(coords, coords, coords);
- selection.setRangeEnd(coords, null, keepEditorOpened);
- },
- setRangeEnd: function(coords, scrollToCell, keepEditorOpened) {
- if (priv.selRange === null) {
- return;
- }
- var disableVisualSelection;
- Handsontable.hooks.run(instance, "beforeSetRangeEnd", coords);
- instance.selection.begin();
- priv.selRange.to = new WalkontableCellCoords(coords.row, coords.col);
- if (!priv.settings.multiSelect) {
- priv.selRange.from = coords;
- }
- instance.view.wt.selections.current.clear();
- disableVisualSelection = instance.getCellMeta(priv.selRange.highlight.row, priv.selRange.highlight.col).disableVisualSelection;
- if (typeof disableVisualSelection === 'string') {
- disableVisualSelection = [disableVisualSelection];
- }
- if (disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('current') === -1) {
- instance.view.wt.selections.current.add(priv.selRange.highlight);
- }
- instance.view.wt.selections.area.clear();
- if ((disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('area') === -1) && selection.isMultiple()) {
- instance.view.wt.selections.area.add(priv.selRange.from);
- instance.view.wt.selections.area.add(priv.selRange.to);
- }
- if (priv.settings.currentRowClassName || priv.settings.currentColClassName) {
- instance.view.wt.selections.highlight.clear();
- instance.view.wt.selections.highlight.add(priv.selRange.from);
- instance.view.wt.selections.highlight.add(priv.selRange.to);
- }
- Handsontable.hooks.run(instance, "afterSelection", priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col);
- 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));
- if (scrollToCell !== false && instance.view.mainViewIsActive()) {
- if (priv.selRange.from && !selection.isMultiple()) {
- instance.view.scrollViewport(priv.selRange.from);
- } else {
- instance.view.scrollViewport(coords);
- }
- }
- selection.refreshBorders(null, keepEditorOpened);
- },
- refreshBorders: function(revertOriginal, keepEditor) {
- if (!keepEditor) {
- editorManager.destroyEditor(revertOriginal);
- }
- instance.view.render();
- if (selection.isSelected() && !keepEditor) {
- editorManager.prepareEditor();
- }
- },
- isMultiple: function() {
- var isMultiple = !(priv.selRange.to.col === priv.selRange.from.col && priv.selRange.to.row === priv.selRange.from.row),
- modifier = Handsontable.hooks.run(instance, 'afterIsMultipleSelection', isMultiple);
- if (isMultiple) {
- return modifier;
- }
- },
- transformStart: function(rowDelta, colDelta, force, keepEditorOpened) {
- var delta = new WalkontableCellCoords(rowDelta, colDelta),
- rowTransformDir = 0,
- colTransformDir = 0,
- totalRows,
- totalCols,
- coords;
- instance.runHooks('modifyTransformStart', delta);
- totalRows = instance.countRows();
- totalCols = instance.countCols();
- if (priv.selRange.highlight.row + rowDelta > totalRows - 1) {
- if (force && priv.settings.minSpareRows > 0) {
- instance.alter("insert_row", totalRows);
- totalRows = instance.countRows();
- } else if (priv.settings.autoWrapCol) {
- delta.row = 1 - totalRows;
- delta.col = priv.selRange.highlight.col + delta.col == totalCols - 1 ? 1 - totalCols : 1;
- }
- } else if (priv.settings.autoWrapCol && priv.selRange.highlight.row + delta.row < 0 && priv.selRange.highlight.col + delta.col >= 0) {
- delta.row = totalRows - 1;
- delta.col = priv.selRange.highlight.col + delta.col == 0 ? totalCols - 1 : -1;
- }
- if (priv.selRange.highlight.col + delta.col > totalCols - 1) {
- if (force && priv.settings.minSpareCols > 0) {
- instance.alter("insert_col", totalCols);
- totalCols = instance.countCols();
- } else if (priv.settings.autoWrapRow) {
- delta.row = priv.selRange.highlight.row + delta.row == totalRows - 1 ? 1 - totalRows : 1;
- delta.col = 1 - totalCols;
- }
- } else if (priv.settings.autoWrapRow && priv.selRange.highlight.col + delta.col < 0 && priv.selRange.highlight.row + delta.row >= 0) {
- delta.row = priv.selRange.highlight.row + delta.row == 0 ? totalRows - 1 : -1;
- delta.col = totalCols - 1;
- }
- coords = new WalkontableCellCoords(priv.selRange.highlight.row + delta.row, priv.selRange.highlight.col + delta.col);
- if (coords.row < 0) {
- rowTransformDir = -1;
- coords.row = 0;
- } else if (coords.row > 0 && coords.row >= totalRows) {
- rowTransformDir = 1;
- coords.row = totalRows - 1;
- }
- if (coords.col < 0) {
- colTransformDir = -1;
- coords.col = 0;
- } else if (coords.col > 0 && coords.col >= totalCols) {
- colTransformDir = 1;
- coords.col = totalCols - 1;
- }
- instance.runHooks('afterModifyTransformStart', coords, rowTransformDir, colTransformDir);
- selection.setRangeStart(coords, keepEditorOpened);
- },
- transformEnd: function(rowDelta, colDelta) {
- var delta = new WalkontableCellCoords(rowDelta, colDelta),
- rowTransformDir = 0,
- colTransformDir = 0,
- totalRows,
- totalCols,
- coords;
- instance.runHooks('modifyTransformEnd', delta);
- totalRows = instance.countRows();
- totalCols = instance.countCols();
- coords = new WalkontableCellCoords(priv.selRange.to.row + delta.row, priv.selRange.to.col + delta.col);
- if (coords.row < 0) {
- rowTransformDir = -1;
- coords.row = 0;
- } else if (coords.row > 0 && coords.row >= totalRows) {
- rowTransformDir = 1;
- coords.row = totalRows - 1;
- }
- if (coords.col < 0) {
- colTransformDir = -1;
- coords.col = 0;
- } else if (coords.col > 0 && coords.col >= totalCols) {
- colTransformDir = 1;
- coords.col = totalCols - 1;
- }
- instance.runHooks('afterModifyTransformEnd', coords, rowTransformDir, colTransformDir);
- selection.setRangeEnd(coords, true);
- },
- isSelected: function() {
- return (priv.selRange !== null);
- },
- inInSelection: function(coords) {
- if (!selection.isSelected()) {
- return false;
- }
- return priv.selRange.includes(coords);
- },
- deselect: function() {
- if (!selection.isSelected()) {
- return;
- }
- instance.selection.inProgress = false;
- priv.selRange = null;
- instance.view.wt.selections.current.clear();
- instance.view.wt.selections.area.clear();
- if (priv.settings.currentRowClassName || priv.settings.currentColClassName) {
- instance.view.wt.selections.highlight.clear();
- }
- editorManager.destroyEditor();
- selection.refreshBorders();
- Handsontable.hooks.run(instance, 'afterDeselect');
- },
- selectAll: function() {
- if (!priv.settings.multiSelect) {
- return;
- }
- selection.setRangeStart(new WalkontableCellCoords(0, 0));
- selection.setRangeEnd(new WalkontableCellCoords(instance.countRows() - 1, instance.countCols() - 1), false);
- },
- empty: function() {
- if (!selection.isSelected()) {
- return;
- }
- var topLeft = priv.selRange.getTopLeftCorner();
- var bottomRight = priv.selRange.getBottomRightCorner();
- var r,
- c,
- changes = [];
- for (r = topLeft.row; r <= bottomRight.row; r++) {
- for (c = topLeft.col; c <= bottomRight.col; c++) {
- if (!instance.getCellMeta(r, c).readOnly) {
- changes.push([r, c, '']);
- }
- }
- }
- instance.setDataAtCell(changes);
- }
- };
- this.init = function() {
- Handsontable.hooks.run(instance, 'beforeInit');
- if (Handsontable.mobileBrowser) {
- dom.addClass(instance.rootElement, 'mobile');
- }
- this.updateSettings(priv.settings, true);
- this.view = new TableView(this);
- editorManager = new EditorManager(instance, priv, selection, datamap);
- this.forceFullRender = true;
- this.view.render();
- if (typeof priv.firstRun === 'object') {
- Handsontable.hooks.run(instance, 'afterChange', priv.firstRun[0], priv.firstRun[1]);
- priv.firstRun = false;
- }
- Handsontable.hooks.run(instance, 'afterInit');
- };
- function ValidatorsQueue() {
- var resolved = false;
- return {
- validatorsInQueue: 0,
- addValidatorToQueue: function() {
- this.validatorsInQueue++;
- resolved = false;
- },
- removeValidatorFormQueue: function() {
- this.validatorsInQueue = this.validatorsInQueue - 1 < 0 ? 0 : this.validatorsInQueue - 1;
- this.checkIfQueueIsEmpty();
- },
- onQueueEmpty: function() {},
- checkIfQueueIsEmpty: function() {
- if (this.validatorsInQueue == 0 && resolved == false) {
- resolved = true;
- this.onQueueEmpty();
- }
- }
- };
- }
- function validateChanges(changes, source, callback) {
- var waitingForValidator = new ValidatorsQueue();
- waitingForValidator.onQueueEmpty = resolve;
- for (var i = changes.length - 1; i >= 0; i--) {
- if (changes[i] === null) {
- changes.splice(i, 1);
- } else {
- var row = changes[i][0];
- var col = datamap.propToCol(changes[i][1]);
- var logicalCol = instance.runHooks('modifyCol', col);
- var cellProperties = instance.getCellMeta(row, logicalCol);
- if (cellProperties.type === 'numeric' && typeof changes[i][3] === 'string') {
- if (changes[i][3].length > 0 && (/^-?[\d\s]*(\.|\,)?\d*$/.test(changes[i][3]) || cellProperties.format)) {
- var len = changes[i][3].length;
- if (typeof cellProperties.language == 'undefined') {
- numeral.language('en');
- } else if (changes[i][3].indexOf(".") === len - 3 && changes[i][3].indexOf(",") === -1) {
- numeral.language('en');
- } else {
- numeral.language(cellProperties.language);
- }
- if (numeral.validate(changes[i][3])) {
- changes[i][3] = numeral().unformat(changes[i][3]);
- }
- }
- }
- if (instance.getCellValidator(cellProperties)) {
- waitingForValidator.addValidatorToQueue();
- instance.validateCell(changes[i][3], cellProperties, (function(i, cellProperties) {
- return function(result) {
- if (typeof result !== 'boolean') {
- throw new Error("Validation error: result is not boolean");
- }
- if (result === false && cellProperties.allowInvalid === false) {
- changes.splice(i, 1);
- cellProperties.valid = true;
- --i;
- }
- waitingForValidator.removeValidatorFormQueue();
- };
- })(i, cellProperties), source);
- }
- }
- }
- waitingForValidator.checkIfQueueIsEmpty();
- function resolve() {
- var beforeChangeResult;
- if (changes.length) {
- beforeChangeResult = Handsontable.hooks.run(instance, "beforeChange", changes, source);
- if (typeof beforeChangeResult === 'function') {
- 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).");
- } else if (beforeChangeResult === false) {
- changes.splice(0, changes.length);
- }
- }
- callback();
- }
- }
- function applyChanges(changes, source) {
- var i = changes.length - 1;
- if (i < 0) {
- return;
- }
- for (; 0 <= i; i--) {
- if (changes[i] === null) {
- changes.splice(i, 1);
- continue;
- }
- if (changes[i][2] == null && changes[i][3] == null) {
- continue;
- }
- if (priv.settings.allowInsertRow) {
- while (changes[i][0] > instance.countRows() - 1) {
- datamap.createRow();
- }
- }
- if (instance.dataType === 'array' && priv.settings.allowInsertColumn) {
- while (datamap.propToCol(changes[i][1]) > instance.countCols() - 1) {
- datamap.createCol();
- }
- }
- datamap.set(changes[i][0], changes[i][1], changes[i][3]);
- }
- instance.forceFullRender = true;
- grid.adjustRowsAndCols();
- Handsontable.hooks.run(instance, 'beforeChangeRender', changes, source);
- selection.refreshBorders(null, true);
- Handsontable.hooks.run(instance, 'afterChange', changes, source || 'edit');
- }
- this.validateCell = function(value, cellProperties, callback, source) {
- var validator = instance.getCellValidator(cellProperties);
- function done(valid) {
- var col = cellProperties.col,
- row = cellProperties.row,
- td = instance.getCell(row, col, true);
- if (td) {
- instance.view.wt.wtSettings.settings.cellRenderer(row, col, td);
- }
- callback(valid);
- }
- if (Object.prototype.toString.call(validator) === '[object RegExp]') {
- validator = (function(validator) {
- return function(value, callback) {
- callback(validator.test(value));
- };
- })(validator);
- }
- if (typeof validator == 'function') {
- value = Handsontable.hooks.run(instance, "beforeValidate", value, cellProperties.row, cellProperties.prop, source);
- instance._registerTimeout(setTimeout(function() {
- validator.call(cellProperties, value, function(valid) {
- valid = Handsontable.hooks.run(instance, "afterValidate", valid, value, cellProperties.row, cellProperties.prop, source);
- cellProperties.valid = valid;
- done(valid);
- Handsontable.hooks.run(instance, "postAfterValidate", valid, value, cellProperties.row, cellProperties.prop, source);
- });
- }, 0));
- } else {
- cellProperties.valid = true;
- done(cellProperties.valid);
- }
- };
- function setDataInputToArray(row, propOrCol, value) {
- if (typeof row === "object") {
- return row;
- } else {
- return [[row, propOrCol, value]];
- }
- }
- this.setDataAtCell = function(row, col, value, source) {
- var input = setDataInputToArray(row, col, value),
- i,
- ilen,
- changes = [],
- prop;
- for (i = 0, ilen = input.length; i < ilen; i++) {
- if (typeof input[i] !== 'object') {
- throw new Error('Method `setDataAtCell` accepts row number or changes array of arrays as its first parameter');
- }
- if (typeof input[i][1] !== 'number') {
- throw new Error('Method `setDataAtCell` accepts row and column number as its parameters. If you want to use object property name, use method `setDataAtRowProp`');
- }
- prop = datamap.colToProp(input[i][1]);
- changes.push([input[i][0], prop, datamap.get(input[i][0], prop), input[i][2]]);
- }
- if (!source && typeof row === "object") {
- source = col;
- }
- validateChanges(changes, source, function() {
- applyChanges(changes, source);
- });
- };
- this.setDataAtRowProp = function(row, prop, value, source) {
- var input = setDataInputToArray(row, prop, value),
- i,
- ilen,
- changes = [];
- for (i = 0, ilen = input.length; i < ilen; i++) {
- changes.push([input[i][0], input[i][1], datamap.get(input[i][0], input[i][1]), input[i][2]]);
- }
- if (!source && typeof row === "object") {
- source = prop;
- }
- validateChanges(changes, source, function() {
- applyChanges(changes, source);
- });
- };
- this.listen = function() {
- Handsontable.activeGuid = instance.guid;
- if (document.activeElement && document.activeElement !== document.body) {
- document.activeElement.blur();
- } else if (!document.activeElement) {
- document.body.focus();
- }
- };
- this.unlisten = function() {
- Handsontable.activeGuid = null;
- };
- this.isListening = function() {
- return Handsontable.activeGuid === instance.guid;
- };
- this.destroyEditor = function(revertOriginal) {
- selection.refreshBorders(revertOriginal);
- };
- this.populateFromArray = function(row, col, input, endRow, endCol, source, method, direction, deltas) {
- var c;
- if (!(typeof input === 'object' && typeof input[0] === 'object')) {
- throw new Error("populateFromArray parameter `input` must be an array of arrays");
- }
- c = typeof endRow === 'number' ? new WalkontableCellCoords(endRow, endCol) : null;
- return grid.populateFromArray(new WalkontableCellCoords(row, col), input, c, source, method, direction, deltas);
- };
- this.spliceCol = function(col, index, amount) {
- return datamap.spliceCol.apply(datamap, arguments);
- };
- this.spliceRow = function(row, index, amount) {
- return datamap.spliceRow.apply(datamap, arguments);
- };
- this.getSelected = function() {
- if (selection.isSelected()) {
- return [priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col];
- }
- };
- this.getSelectedRange = function() {
- if (selection.isSelected()) {
- return priv.selRange;
- }
- };
- this.render = function() {
- if (instance.view) {
- instance.forceFullRender = true;
- selection.refreshBorders(null, true);
- }
- };
- this.loadData = function(data) {
- if (typeof data === 'object' && data !== null) {
- if (!(data.push && data.splice)) {
- data = [data];
- }
- } else if (data === null) {
- data = [];
- var row;
- for (var r = 0,
- rlen = priv.settings.startRows; r < rlen; r++) {
- row = [];
- for (var c = 0,
- clen = priv.settings.startCols; c < clen; c++) {
- row.push(null);
- }
- data.push(row);
- }
- } else {
- throw new Error("loadData only accepts array of objects or array of arrays (" + typeof data + " given)");
- }
- priv.isPopulated = false;
- GridSettings.prototype.data = data;
- if (Array.isArray(priv.settings.dataSchema) || Array.isArray(data[0])) {
- instance.dataType = 'array';
- } else if (typeof priv.settings.dataSchema === 'function') {
- instance.dataType = 'function';
- } else {
- instance.dataType = 'object';
- }
- datamap = new DataMap(instance, priv, GridSettings);
- clearCellSettingCache();
- grid.adjustRowsAndCols();
- Handsontable.hooks.run(instance, 'afterLoadData');
- if (priv.firstRun) {
- priv.firstRun = [null, 'loadData'];
- } else {
- Handsontable.hooks.run(instance, 'afterChange', null, 'loadData');
- instance.render();
- }
- priv.isPopulated = true;
- function clearCellSettingCache() {
- priv.cellSettings.length = 0;
- }
- };
- this.getData = function(r, c, r2, c2) {
- if (typeof r === 'undefined') {
- return datamap.getAll();
- } else {
- return datamap.getRange(new WalkontableCellCoords(r, c), new WalkontableCellCoords(r2, c2), datamap.DESTINATION_RENDERER);
- }
- };
- this.getCopyableData = function(startRow, startCol, endRow, endCol) {
- return datamap.getCopyableText(new WalkontableCellCoords(startRow, startCol), new WalkontableCellCoords(endRow, endCol));
- };
- this.getSchema = function() {
- return datamap.getSchema();
- };
- this.updateSettings = function(settings, init) {
- var i,
- clen;
- if (typeof settings.rows !== "undefined") {
- throw new Error("'rows' setting is no longer supported. do you mean startRows, minRows or maxRows?");
- }
- if (typeof settings.cols !== "undefined") {
- throw new Error("'cols' setting is no longer supported. do you mean startCols, minCols or maxCols?");
- }
- for (i in settings) {
- if (i === 'data') {
- continue;
- } else {
- if (Handsontable.hooks.getRegistered().indexOf(i) > -1) {
- if (typeof settings[i] === 'function' || Array.isArray(settings[i])) {
- instance.addHook(i, settings[i]);
- }
- } else {
- if (!init && settings.hasOwnProperty(i)) {
- GridSettings.prototype[i] = settings[i];
- }
- }
- }
- }
- if (settings.data === void 0 && priv.settings.data === void 0) {
- instance.loadData(null);
- } else if (settings.data !== void 0) {
- instance.loadData(settings.data);
- } else if (settings.columns !== void 0) {
- datamap.createMap();
- }
- clen = instance.countCols();
- priv.cellSettings.length = 0;
- if (clen > 0) {
- var proto,
- column;
- for (i = 0; i < clen; i++) {
- priv.columnSettings[i] = helper.columnFactory(GridSettings, priv.columnsSettingConflicts);
- proto = priv.columnSettings[i].prototype;
- if (GridSettings.prototype.columns) {
- column = GridSettings.prototype.columns[i];
- helper.extend(proto, column);
- helper.extend(proto, expandType(column));
- }
- }
- }
- if (typeof settings.cell !== 'undefined') {
- for (i in settings.cell) {
- if (settings.cell.hasOwnProperty(i)) {
- var cell = settings.cell[i];
- instance.setCellMetaObject(cell.row, cell.col, cell);
- }
- }
- }
- Handsontable.hooks.run(instance, 'afterCellMetaReset');
- if (typeof settings.className !== "undefined") {
- if (GridSettings.prototype.className) {
- dom.removeClass(instance.rootElement, GridSettings.prototype.className);
- }
- if (settings.className) {
- dom.addClass(instance.rootElement, settings.className);
- }
- }
- if (typeof settings.height != 'undefined') {
- var height = settings.height;
- if (typeof height == 'function') {
- height = height();
- }
- instance.rootElement.style.height = height + 'px';
- }
- if (typeof settings.width != 'undefined') {
- var width = settings.width;
- if (typeof width == 'function') {
- width = width();
- }
- instance.rootElement.style.width = width + 'px';
- }
- if (height) {
- instance.rootElement.style.overflow = 'hidden';
- }
- if (!init) {
- Handsontable.hooks.run(instance, 'afterUpdateSettings');
- }
- grid.adjustRowsAndCols();
- if (instance.view && !priv.firstRun) {
- instance.forceFullRender = true;
- selection.refreshBorders(null, true);
- }
- };
- this.getValue = function() {
- var sel = instance.getSelected();
- if (GridSettings.prototype.getValue) {
- if (typeof GridSettings.prototype.getValue === 'function') {
- return GridSettings.prototype.getValue.call(instance);
- } else if (sel) {
- return instance.getData()[sel[0]][GridSettings.prototype.getValue];
- }
- } else if (sel) {
- return instance.getDataAtCell(sel[0], sel[1]);
- }
- };
- function expandType(obj) {
- if (!obj.hasOwnProperty('type')) {
- return;
- }
- var type,
- expandedType = {};
- if (typeof obj.type === 'object') {
- type = obj.type;
- } else if (typeof obj.type === 'string') {
- type = Handsontable.cellTypes[obj.type];
- if (type === void 0) {
- 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');
- }
- }
- for (var i in type) {
- if (type.hasOwnProperty(i) && !obj.hasOwnProperty(i)) {
- expandedType[i] = type[i];
- }
- }
- return expandedType;
- }
- this.getSettings = function() {
- return priv.settings;
- };
- this.clear = function() {
- selection.selectAll();
- selection.empty();
- };
- this.alter = function(action, index, amount, source, keepEmptyRows) {
- grid.alter(action, index, amount, source, keepEmptyRows);
- };
- this.getCell = function(row, col, topmost) {
- return instance.view.getCellAtCoords(new WalkontableCellCoords(row, col), topmost);
- };
- this.getCoords = function(elem) {
- return this.view.wt.wtTable.getCoords.call(this.view.wt.wtTable, elem);
- };
- this.colToProp = function(col) {
- return datamap.colToProp(col);
- };
- this.propToCol = function(prop) {
- return datamap.propToCol(prop);
- };
- this.getDataAtCell = function(row, col) {
- return datamap.get(row, datamap.colToProp(col));
- };
- this.getDataAtRowProp = function(row, prop) {
- return datamap.get(row, prop);
- };
- this.getDataAtCol = function(col) {
- var out = [];
- return out.concat.apply(out, datamap.getRange(new WalkontableCellCoords(0, col), new WalkontableCellCoords(priv.settings.data.length - 1, col), datamap.DESTINATION_RENDERER));
- };
- this.getDataAtProp = function(prop) {
- var out = [],
- range;
- range = datamap.getRange(new WalkontableCellCoords(0, datamap.propToCol(prop)), new WalkontableCellCoords(priv.settings.data.length - 1, datamap.propToCol(prop)), datamap.DESTINATION_RENDERER);
- return out.concat.apply(out, range);
- };
- this.getSourceDataAtCol = function(col) {
- var out = [],
- data = priv.settings.data;
- for (var i = 0; i < data.length; i++) {
- out.push(data[i][col]);
- }
- return out;
- };
- this.getSourceDataAtRow = function(row) {
- return priv.settings.data[row];
- };
- this.getDataAtRow = function(row) {
- var data = datamap.getRange(new WalkontableCellCoords(row, 0), new WalkontableCellCoords(row, this.countCols() - 1), datamap.DESTINATION_RENDERER);
- return data[0];
- };
- this.removeCellMeta = function(row, col, key) {
- var cellMeta = instance.getCellMeta(row, col);
- if (cellMeta[key] != undefined) {
- delete priv.cellSettings[row][col][key];
- }
- };
- this.setCellMetaObject = function(row, col, prop) {
- if (typeof prop === 'object') {
- for (var key in prop) {
- if (prop.hasOwnProperty(key)) {
- var value = prop[key];
- this.setCellMeta(row, col, key, value);
- }
- }
- }
- };
- this.setCellMeta = function(row, col, key, val) {
- if (!priv.cellSettings[row]) {
- priv.cellSettings[row] = [];
- }
- if (!priv.cellSettings[row][col]) {
- priv.cellSettings[row][col] = new priv.columnSettings[col]();
- }
- priv.cellSettings[row][col][key] = val;
- Handsontable.hooks.run(instance, 'afterSetCellMeta', row, col, key, val);
- };
- this.getCellMeta = function(row, col) {
- var prop = datamap.colToProp(col),
- cellProperties;
- row = translateRowIndex(row);
- col = translateColIndex(col);
- if (!priv.columnSettings[col]) {
- priv.columnSettings[col] = helper.columnFactory(GridSettings, priv.columnsSettingConflicts);
- }
- if (!priv.cellSettings[row]) {
- priv.cellSettings[row] = [];
- }
- if (!priv.cellSettings[row][col]) {
- priv.cellSettings[row][col] = new priv.columnSettings[col]();
- }
- cellProperties = priv.cellSettings[row][col];
- cellProperties.row = row;
- cellProperties.col = col;
- cellProperties.prop = prop;
- cellProperties.instance = instance;
- Handsontable.hooks.run(instance, 'beforeGetCellMeta', row, col, cellProperties);
- helper.extend(cellProperties, expandType(cellProperties));
- if (cellProperties.cells) {
- var settings = cellProperties.cells.call(cellProperties, row, col, prop);
- if (settings) {
- helper.extend(cellProperties, settings);
- helper.extend(cellProperties, expandType(settings));
- }
- }
- Handsontable.hooks.run(instance, 'afterGetCellMeta', row, col, cellProperties);
- return cellProperties;
- };
- this.isColumnModificationAllowed = function() {
- return !(instance.dataType === 'object' || instance.getSettings().columns);
- };
- function translateRowIndex(row) {
- return Handsontable.hooks.run(instance, 'modifyRow', row);
- }
- function translateColIndex(col) {
- return Handsontable.hooks.run(instance, 'modifyCol', col);
- }
- var rendererLookup = helper.cellMethodLookupFactory('renderer');
- this.getCellRenderer = function(row, col) {
- var renderer = rendererLookup.call(this, row, col);
- return getRenderer(renderer);
- };
- this.getCellEditor = helper.cellMethodLookupFactory('editor');
- this.getCellValidator = helper.cellMethodLookupFactory('validator');
- this.validateCells = function(callback) {
- var waitingForValidator = new ValidatorsQueue();
- waitingForValidator.onQueueEmpty = callback;
- var i = instance.countRows() - 1;
- while (i >= 0) {
- var j = instance.countCols() - 1;
- while (j >= 0) {
- waitingForValidator.addValidatorToQueue();
- instance.validateCell(instance.getDataAtCell(i, j), instance.getCellMeta(i, j), function() {
- waitingForValidator.removeValidatorFormQueue();
- }, 'validateCells');
- j--;
- }
- i--;
- }
- waitingForValidator.checkIfQueueIsEmpty();
- };
- this.getRowHeader = function(row) {
- if (row === void 0) {
- var out = [];
- for (var i = 0,
- ilen = instance.countRows(); i < ilen; i++) {
- out.push(instance.getRowHeader(i));
- }
- return out;
- } else if (Array.isArray(priv.settings.rowHeaders) && priv.settings.rowHeaders[row] !== void 0) {
- return priv.settings.rowHeaders[row];
- } else if (typeof priv.settings.rowHeaders === 'function') {
- return priv.settings.rowHeaders(row);
- } else if (priv.settings.rowHeaders && typeof priv.settings.rowHeaders !== 'string' && typeof priv.settings.rowHeaders !== 'number') {
- return row + 1;
- } else {
- return priv.settings.rowHeaders;
- }
- };
- this.hasRowHeaders = function() {
- return !!priv.settings.rowHeaders;
- };
- this.hasColHeaders = function() {
- if (priv.settings.colHeaders !== void 0 && priv.settings.colHeaders !== null) {
- return !!priv.settings.colHeaders;
- }
- for (var i = 0,
- ilen = instance.countCols(); i < ilen; i++) {
- if (instance.getColHeader(i)) {
- return true;
- }
- }
- return false;
- };
- this.getColHeader = function(col) {
- if (col === void 0) {
- var out = [];
- for (var i = 0,
- ilen = instance.countCols(); i < ilen; i++) {
- out.push(instance.getColHeader(i));
- }
- return out;
- } else {
- var baseCol = col;
- col = Handsontable.hooks.run(instance, 'modifyCol', col);
- if (priv.settings.columns && priv.settings.columns[col] && priv.settings.columns[col].title) {
- return priv.settings.columns[col].title;
- } else if (Array.isArray(priv.settings.colHeaders) && priv.settings.colHeaders[col] !== void 0) {
- return priv.settings.colHeaders[col];
- } else if (typeof priv.settings.colHeaders === 'function') {
- return priv.settings.colHeaders(col);
- } else if (priv.settings.colHeaders && typeof priv.settings.colHeaders !== 'string' && typeof priv.settings.colHeaders !== 'number') {
- return helper.spreadsheetColumnLabel(baseCol);
- } else {
- return priv.settings.colHeaders;
- }
- }
- };
- this._getColWidthFromSettings = function(col) {
- var cellProperties = instance.getCellMeta(0, col);
- var width = cellProperties.width;
- if (width === void 0 || width === priv.settings.width) {
- width = cellProperties.colWidths;
- }
- if (width !== void 0 && width !== null) {
- switch (typeof width) {
- case 'object':
- width = width[col];
- break;
- case 'function':
- width = width(col);
- break;
- }
- if (typeof width === 'string') {
- width = parseInt(width, 10);
- }
- }
- return width;
- };
- this.getColWidth = function(col) {
- var width = instance._getColWidthFromSettings(col);
- if (!width) {
- width = 50;
- }
- width = Handsontable.hooks.run(instance, 'modifyColWidth', width, col);
- return width;
- };
- this._getRowHeightFromSettings = function(row) {
- var height = priv.settings.rowHeights;
- if (height !== void 0 && height !== null) {
- switch (typeof height) {
- case 'object':
- height = height[row];
- break;
- case 'function':
- height = height(row);
- break;
- }
- if (typeof height === 'string') {
- height = parseInt(height, 10);
- }
- }
- return height;
- };
- this.getRowHeight = function(row) {
- var height = instance._getRowHeightFromSettings(row);
- height = Handsontable.hooks.run(instance, 'modifyRowHeight', height, row);
- return height;
- };
- this.countRows = function() {
- return priv.settings.data.length;
- };
- this.countCols = function() {
- if (instance.dataType === 'object' || instance.dataType === 'function') {
- if (priv.settings.columns && priv.settings.columns.length) {
- return priv.settings.columns.length;
- } else {
- return datamap.colToPropCache.length;
- }
- } else if (instance.dataType === 'array') {
- if (priv.settings.columns && priv.settings.columns.length) {
- return priv.settings.columns.length;
- } else if (priv.settings.data && priv.settings.data[0] && priv.settings.data[0].length) {
- return priv.settings.data[0].length;
- } else {
- return 0;
- }
- }
- };
- this.rowOffset = function() {
- return instance.view.wt.wtTable.getFirstRenderedRow();
- };
- this.colOffset = function() {
- return instance.view.wt.wtTable.getFirstRenderedColumn();
- };
- this.countRenderedRows = function() {
- return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedRowsCount() : -1;
- };
- this.countVisibleRows = function() {
- return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleRowsCount() : -1;
- };
- this.countRenderedCols = function() {
- return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedColumnsCount() : -1;
- };
- this.countVisibleCols = function() {
- return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleColumnsCount() : -1;
- };
- this.countEmptyRows = function(ending) {
- var i = instance.countRows() - 1,
- empty = 0,
- row;
- while (i >= 0) {
- row = Handsontable.hooks.run(this, 'modifyRow', i);
- if (instance.isEmptyRow(row)) {
- empty++;
- } else if (ending) {
- break;
- }
- i--;
- }
- return empty;
- };
- this.countEmptyCols = function(ending) {
- if (instance.countRows() < 1) {
- return 0;
- }
- var i = instance.countCols() - 1,
- empty = 0;
- while (i >= 0) {
- if (instance.isEmptyCol(i)) {
- empty++;
- } else if (ending) {
- break;
- }
- i--;
- }
- return empty;
- };
- this.isEmptyRow = function(row) {
- return priv.settings.isEmptyRow.call(instance, row);
- };
- this.isEmptyCol = function(col) {
- return priv.settings.isEmptyCol.call(instance, col);
- };
- this.selectCell = function(row, col, endRow, endCol, scrollToCell, changeListener) {
- var coords;
- changeListener = typeof changeListener === 'undefined' || changeListener === true;
- if (typeof row !== 'number' || row < 0 || row >= instance.countRows()) {
- return false;
- }
- if (typeof col !== 'number' || col < 0 || col >= instance.countCols()) {
- return false;
- }
- if (typeof endRow !== 'undefined') {
- if (typeof endRow !== 'number' || endRow < 0 || endRow >= instance.countRows()) {
- return false;
- }
- if (typeof endCol !== 'number' || endCol < 0 || endCol >= instance.countCols()) {
- return false;
- }
- }
- coords = new WalkontableCellCoords(row, col);
- priv.selRange = new WalkontableCellRange(coords, coords, coords);
- if (document.activeElement && document.activeElement !== document.documentElement && document.activeElement !== document.body) {
- document.activeElement.blur();
- }
- if (changeListener) {
- instance.listen();
- }
- if (typeof endRow === 'undefined') {
- selection.setRangeEnd(priv.selRange.from, scrollToCell);
- } else {
- selection.setRangeEnd(new WalkontableCellCoords(endRow, endCol), scrollToCell);
- }
- instance.selection.finish();
- return true;
- };
- this.selectCellByProp = function(row, prop, endRow, endProp, scrollToCell) {
- arguments[1] = datamap.propToCol(arguments[1]);
- if (typeof arguments[3] !== "undefined") {
- arguments[3] = datamap.propToCol(arguments[3]);
- }
- return instance.selectCell.apply(instance, arguments);
- };
- this.deselectCell = function() {
- selection.deselect();
- };
- this.destroy = function() {
- instance._clearTimeouts();
- if (instance.view) {
- instance.view.destroy();
- }
- dom.empty(instance.rootElement);
- eventManager.clear();
- Handsontable.hooks.run(instance, 'afterDestroy');
- Handsontable.hooks.destroy(instance);
- for (var i in instance) {
- if (instance.hasOwnProperty(i)) {
- if (typeof instance[i] === "function") {
- if (i !== "runHooks") {
- instance[i] = postMortem;
- }
- } else if (i !== "guid") {
- instance[i] = null;
- }
- }
- }
- priv = null;
- datamap = null;
- grid = null;
- selection = null;
- editorManager = null;
- instance = null;
- GridSettings = null;
- };
- function postMortem() {
- throw new Error("This method cannot be called because this Handsontable instance has been destroyed");
- }
- this.getActiveEditor = function() {
- return editorManager.getActiveEditor();
- };
- this.getPlugin = function(pluginName) {
- return getPlugin(this, pluginName);
- };
- this.getInstance = function() {
- return instance;
- };
- this.addHook = function(key, callback) {
- Handsontable.hooks.add(key, callback, instance);
- };
- this.addHookOnce = function(key, callback) {
- Handsontable.hooks.once(key, callback, instance);
- };
- this.removeHook = function(key, callback) {
- Handsontable.hooks.remove(key, callback, instance);
- };
- this.runHooks = function(key, p1, p2, p3, p4, p5, p6) {
- return Handsontable.hooks.run(instance, key, p1, p2, p3, p4, p5, p6);
- };
- this.timeouts = [];
- this._registerTimeout = function(handle) {
- this.timeouts.push(handle);
- };
- this._clearTimeouts = function() {
- for (var i = 0,
- ilen = this.timeouts.length; i < ilen; i++) {
- clearTimeout(this.timeouts[i]);
- }
- };
- this.version = Handsontable.version;
- };
- var DefaultSettings = function() {};
- DefaultSettings.prototype = {
- data: void 0,
- dataSchema: void 0,
- width: void 0,
- height: void 0,
- startRows: 5,
- startCols: 5,
- rowHeaders: null,
- colHeaders: null,
- colWidths: void 0,
- columns: void 0,
- cells: void 0,
- cell: [],
- comments: false,
- customBorders: false,
- minRows: 0,
- minCols: 0,
- maxRows: Infinity,
- maxCols: Infinity,
- minSpareRows: 0,
- minSpareCols: 0,
- allowInsertRow: true,
- allowInsertColumn: true,
- allowRemoveRow: true,
- allowRemoveColumn: true,
- multiSelect: true,
- fillHandle: true,
- fixedRowsTop: 0,
- fixedColumnsLeft: 0,
- outsideClickDeselects: true,
- enterBeginsEditing: true,
- enterMoves: {
- row: 1,
- col: 0
- },
- tabMoves: {
- row: 0,
- col: 1
- },
- autoWrapRow: false,
- autoWrapCol: false,
- copyRowsLimit: 1000,
- copyColsLimit: 1000,
- pasteMode: 'overwrite',
- persistentState: false,
- currentRowClassName: void 0,
- currentColClassName: void 0,
- stretchH: 'none',
- isEmptyRow: function(row) {
- var col,
- colLen,
- value,
- meta;
- for (col = 0, colLen = this.countCols(); col < colLen; col++) {
- value = this.getDataAtCell(row, col);
- if (value !== '' && value !== null && typeof value !== 'undefined') {
- if (typeof value === 'object') {
- meta = this.getCellMeta(row, col);
- return helper.isObjectEquals(this.getSchema()[meta.prop], value);
- }
- return false;
- }
- }
- return true;
- },
- isEmptyCol: function(col) {
- var row,
- rowLen,
- value;
- for (row = 0, rowLen = this.countRows(); row < rowLen; row++) {
- value = this.getDataAtCell(row, col);
- if (value !== '' && value !== null && typeof value !== 'undefined') {
- return false;
- }
- }
- return true;
- },
- observeDOMVisibility: true,
- allowInvalid: true,
- invalidCellClassName: 'htInvalid',
- placeholder: false,
- placeholderCellClassName: 'htPlaceholder',
- readOnlyCellClassName: 'htDimmed',
- renderer: void 0,
- commentedCellClassName: 'htCommentCell',
- fragmentSelection: false,
- readOnly: false,
- search: false,
- type: 'text',
- copyable: true,
- editor: void 0,
- autoComplete: void 0,
- debug: false,
- wordWrap: true,
- noWordWrapClassName: 'htNoWrap',
- contextMenu: void 0,
- undo: void 0,
- columnSorting: void 0,
- manualColumnMove: void 0,
- manualColumnResize: void 0,
- manualRowMove: void 0,
- manualRowResize: void 0,
- mergeCells: false,
- viewportRowRenderingOffset: 10,
- viewportColumnRenderingOffset: 10,
- groups: void 0,
- validator: void 0,
- disableVisualSelection: false,
- sortIndicator: false,
- manualColumnFreeze: void 0,
- trimWhitespace: true,
- settings: void 0,
- source: void 0,
- title: void 0,
- checkedTemplate: void 0,
- uncheckedTemplate: void 0,
- format: void 0,
- className: void 0
- };
- Handsontable.DefaultSettings = DefaultSettings;
-
- //#
- },{"./3rdparty/walkontable/src/cell/coords.js":5,"./3rdparty/walkontable/src/cell/range.js":6,"./3rdparty/walkontable/src/selection.js":18,"./dataMap.js":26,"./dom.js":27,"./editorManager.js":28,"./eventManager.js":41,"./helpers.js":42,"./plugins.js":45,"./renderers.js":70,"./tableView.js":85,"numeral":"numeral"}],26:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- DataMap: {get: function() {
- return DataMap;
- }},
- __esModule: {value: true}
- });
- var $__helpers_46_js__,
- $__multiMap_46_js__,
- $__SheetClip__;
- var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
- var MultiMap = ($__multiMap_46_js__ = require("./multiMap.js"), $__multiMap_46_js__ && $__multiMap_46_js__.__esModule && $__multiMap_46_js__ || {default: $__multiMap_46_js__}).MultiMap;
- var SheetClip = ($__SheetClip__ = require("SheetClip"), $__SheetClip__ && $__SheetClip__.__esModule && $__SheetClip__ || {default: $__SheetClip__}).default;
- ;
- Handsontable.DataMap = DataMap;
- function DataMap(instance, priv, GridSettings) {
- this.instance = instance;
- this.priv = priv;
- this.GridSettings = GridSettings;
- this.dataSource = this.instance.getSettings().data;
- if (this.dataSource[0]) {
- this.duckSchema = this.recursiveDuckSchema(this.dataSource[0]);
- } else {
- this.duckSchema = {};
- }
- this.createMap();
- }
- DataMap.prototype.DESTINATION_RENDERER = 1;
- DataMap.prototype.DESTINATION_CLIPBOARD_GENERATOR = 2;
- DataMap.prototype.recursiveDuckSchema = function(object) {
- return Handsontable.helper.duckSchema(object);
- };
- DataMap.prototype.recursiveDuckColumns = function(schema, lastCol, parent) {
- var prop,
- i;
- if (typeof lastCol === 'undefined') {
- lastCol = 0;
- parent = '';
- }
- if (typeof schema === "object" && !Array.isArray(schema)) {
- for (i in schema) {
- if (schema.hasOwnProperty(i)) {
- if (schema[i] === null) {
- prop = parent + i;
- this.colToPropCache.push(prop);
- this.propToColCache.set(prop, lastCol);
- lastCol++;
- } else {
- lastCol = this.recursiveDuckColumns(schema[i], lastCol, i + '.');
- }
- }
- }
- }
- return lastCol;
- };
- DataMap.prototype.createMap = function() {
- var i,
- ilen,
- schema = this.getSchema();
- if (typeof schema === "undefined") {
- throw new Error("trying to create `columns` definition but you didnt' provide `schema` nor `data`");
- }
- this.colToPropCache = [];
- this.propToColCache = new MultiMap();
- var columns = this.instance.getSettings().columns;
- if (columns) {
- for (i = 0, ilen = columns.length; i < ilen; i++) {
- if (typeof columns[i].data != 'undefined') {
- this.colToPropCache[i] = columns[i].data;
- this.propToColCache.set(columns[i].data, i);
- }
- }
- } else {
- this.recursiveDuckColumns(schema);
- }
- };
- DataMap.prototype.colToProp = function(col) {
- col = Handsontable.hooks.run(this.instance, 'modifyCol', col);
- if (this.colToPropCache && typeof this.colToPropCache[col] !== 'undefined') {
- return this.colToPropCache[col];
- }
- return col;
- };
- DataMap.prototype.propToCol = function(prop) {
- var col;
- if (typeof this.propToColCache.get(prop) !== 'undefined') {
- col = this.propToColCache.get(prop);
- } else {
- col = prop;
- }
- col = Handsontable.hooks.run(this.instance, 'modifyCol', col);
- return col;
- };
- DataMap.prototype.getSchema = function() {
- var schema = this.instance.getSettings().dataSchema;
- if (schema) {
- if (typeof schema === 'function') {
- return schema();
- }
- return schema;
- }
- return this.duckSchema;
- };
- DataMap.prototype.createRow = function(index, amount, createdAutomatically) {
- var row,
- colCount = this.instance.countCols(),
- numberOfCreatedRows = 0,
- currentIndex;
- if (!amount) {
- amount = 1;
- }
- if (typeof index !== 'number' || index >= this.instance.countRows()) {
- index = this.instance.countRows();
- }
- currentIndex = index;
- var maxRows = this.instance.getSettings().maxRows;
- while (numberOfCreatedRows < amount && this.instance.countRows() < maxRows) {
- if (this.instance.dataType === 'array') {
- row = [];
- for (var c = 0; c < colCount; c++) {
- row.push(null);
- }
- } else if (this.instance.dataType === 'function') {
- row = this.instance.getSettings().dataSchema(index);
- } else {
- row = {};
- helper.deepExtend(row, this.getSchema());
- }
- if (index === this.instance.countRows()) {
- this.dataSource.push(row);
- } else {
- this.dataSource.splice(index, 0, row);
- }
- numberOfCreatedRows++;
- currentIndex++;
- }
- Handsontable.hooks.run(this.instance, 'afterCreateRow', index, numberOfCreatedRows, createdAutomatically);
- this.instance.forceFullRender = true;
- return numberOfCreatedRows;
- };
- DataMap.prototype.createCol = function(index, amount, createdAutomatically) {
- if (!this.instance.isColumnModificationAllowed()) {
- 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.");
- }
- var rlen = this.instance.countRows(),
- data = this.dataSource,
- constructor,
- numberOfCreatedCols = 0,
- currentIndex;
- if (!amount) {
- amount = 1;
- }
- currentIndex = index;
- var maxCols = this.instance.getSettings().maxCols;
- while (numberOfCreatedCols < amount && this.instance.countCols() < maxCols) {
- constructor = helper.columnFactory(this.GridSettings, this.priv.columnsSettingConflicts);
- if (typeof index !== 'number' || index >= this.instance.countCols()) {
- for (var r = 0; r < rlen; r++) {
- if (typeof data[r] === 'undefined') {
- data[r] = [];
- }
- data[r].push(null);
- }
- this.priv.columnSettings.push(constructor);
- } else {
- for (var r = 0; r < rlen; r++) {
- data[r].splice(currentIndex, 0, null);
- }
- this.priv.columnSettings.splice(currentIndex, 0, constructor);
- }
- numberOfCreatedCols++;
- currentIndex++;
- }
- Handsontable.hooks.run(this.instance, 'afterCreateCol', index, numberOfCreatedCols, createdAutomatically);
- this.instance.forceFullRender = true;
- return numberOfCreatedCols;
- };
- DataMap.prototype.removeRow = function(index, amount) {
- if (!amount) {
- amount = 1;
- }
- if (typeof index !== 'number') {
- index = -amount;
- }
- index = (this.instance.countRows() + index) % this.instance.countRows();
- var logicRows = this.physicalRowsToLogical(index, amount);
- var actionWasNotCancelled = Handsontable.hooks.run(this.instance, 'beforeRemoveRow', index, amount);
- if (actionWasNotCancelled === false) {
- return;
- }
- var data = this.dataSource;
- var newData = data.filter(function(row, index) {
- return logicRows.indexOf(index) == -1;
- });
- data.length = 0;
- Array.prototype.push.apply(data, newData);
- Handsontable.hooks.run(this.instance, 'afterRemoveRow', index, amount);
- this.instance.forceFullRender = true;
- };
- DataMap.prototype.removeCol = function(index, amount) {
- if (this.instance.dataType === 'object' || this.instance.getSettings().columns) {
- throw new Error("cannot remove column with object data source or columns option specified");
- }
- if (!amount) {
- amount = 1;
- }
- if (typeof index !== 'number') {
- index = -amount;
- }
- index = (this.instance.countCols() + index) % this.instance.countCols();
- var actionWasNotCancelled = Handsontable.hooks.run(this.instance, 'beforeRemoveCol', index, amount);
- if (actionWasNotCancelled === false) {
- return;
- }
- var data = this.dataSource;
- for (var r = 0,
- rlen = this.instance.countRows(); r < rlen; r++) {
- data[r].splice(index, amount);
- }
- this.priv.columnSettings.splice(index, amount);
- Handsontable.hooks.run(this.instance, 'afterRemoveCol', index, amount);
- this.instance.forceFullRender = true;
- };
- DataMap.prototype.spliceCol = function(col, index, amount) {
- var elements = 4 <= arguments.length ? [].slice.call(arguments, 3) : [];
- var colData = this.instance.getDataAtCol(col);
- var removed = colData.slice(index, index + amount);
- var after = colData.slice(index + amount);
- helper.extendArray(elements, after);
- var i = 0;
- while (i < amount) {
- elements.push(null);
- i++;
- }
- helper.to2dArray(elements);
- this.instance.populateFromArray(index, col, elements, null, null, 'spliceCol');
- return removed;
- };
- DataMap.prototype.spliceRow = function(row, index, amount) {
- var elements = 4 <= arguments.length ? [].slice.call(arguments, 3) : [];
- var rowData = this.instance.getSourceDataAtRow(row);
- var removed = rowData.slice(index, index + amount);
- var after = rowData.slice(index + amount);
- helper.extendArray(elements, after);
- var i = 0;
- while (i < amount) {
- elements.push(null);
- i++;
- }
- this.instance.populateFromArray(row, index, [elements], null, null, 'spliceRow');
- return removed;
- };
- DataMap.prototype.get = function(row, prop) {
- row = Handsontable.hooks.run(this.instance, 'modifyRow', row);
- if (typeof prop === 'string' && prop.indexOf('.') > -1) {
- var sliced = prop.split(".");
- var out = this.dataSource[row];
- if (!out) {
- return null;
- }
- for (var i = 0,
- ilen = sliced.length; i < ilen; i++) {
- out = out[sliced[i]];
- if (typeof out === 'undefined') {
- return null;
- }
- }
- return out;
- } else if (typeof prop === 'function') {
- return prop(this.dataSource.slice(row, row + 1)[0]);
- } else {
- return this.dataSource[row] ? this.dataSource[row][prop] : null;
- }
- };
- var copyableLookup = helper.cellMethodLookupFactory('copyable', false);
- DataMap.prototype.getCopyable = function(row, prop) {
- if (copyableLookup.call(this.instance, row, this.propToCol(prop))) {
- return this.get(row, prop);
- }
- return '';
- };
- DataMap.prototype.set = function(row, prop, value, source) {
- row = Handsontable.hooks.run(this.instance, 'modifyRow', row, source || "datamapGet");
- if (typeof prop === 'string' && prop.indexOf('.') > -1) {
- var sliced = prop.split(".");
- var out = this.dataSource[row];
- for (var i = 0,
- ilen = sliced.length - 1; i < ilen; i++) {
- if (typeof out[sliced[i]] === 'undefined') {
- out[sliced[i]] = {};
- }
- out = out[sliced[i]];
- }
- out[sliced[i]] = value;
- } else if (typeof prop === 'function') {
- prop(this.dataSource.slice(row, row + 1)[0], value);
- } else {
- this.dataSource[row][prop] = value;
- }
- };
- DataMap.prototype.physicalRowsToLogical = function(index, amount) {
- var totalRows = this.instance.countRows();
- var physicRow = (totalRows + index) % totalRows;
- var logicRows = [];
- var rowsToRemove = amount;
- var row;
- while (physicRow < totalRows && rowsToRemove) {
- row = Handsontable.hooks.run(this.instance, 'modifyRow', physicRow);
- logicRows.push(row);
- rowsToRemove--;
- physicRow++;
- }
- return logicRows;
- };
- DataMap.prototype.clear = function() {
- for (var r = 0; r < this.instance.countRows(); r++) {
- for (var c = 0; c < this.instance.countCols(); c++) {
- this.set(r, this.colToProp(c), '');
- }
- }
- };
- DataMap.prototype.getAll = function() {
- return this.dataSource;
- };
- DataMap.prototype.getRange = function(start, end, destination) {
- var r,
- rlen,
- c,
- clen,
- output = [],
- row;
- var getFn = destination === this.DESTINATION_CLIPBOARD_GENERATOR ? this.getCopyable : this.get;
- rlen = Math.max(start.row, end.row);
- clen = Math.max(start.col, end.col);
- for (r = Math.min(start.row, end.row); r <= rlen; r++) {
- row = [];
- for (c = Math.min(start.col, end.col); c <= clen; c++) {
- row.push(getFn.call(this, r, this.colToProp(c)));
- }
- output.push(row);
- }
- return output;
- };
- DataMap.prototype.getText = function(start, end) {
- return SheetClip.stringify(this.getRange(start, end, this.DESTINATION_RENDERER));
- };
- DataMap.prototype.getCopyableText = function(start, end) {
- return SheetClip.stringify(this.getRange(start, end, this.DESTINATION_CLIPBOARD_GENERATOR));
- };
-
- //#
- },{"./helpers.js":42,"./multiMap.js":43,"SheetClip":"SheetClip"}],27:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- enableImmediatePropagation: {get: function() {
- return enableImmediatePropagation;
- }},
- closest: {get: function() {
- return closest;
- }},
- isChildOf: {get: function() {
- return isChildOf;
- }},
- isChildOfWebComponentTable: {get: function() {
- return isChildOfWebComponentTable;
- }},
- polymerWrap: {get: function() {
- return polymerWrap;
- }},
- polymerUnwrap: {get: function() {
- return polymerUnwrap;
- }},
- isWebComponentSupportedNatively: {get: function() {
- return isWebComponentSupportedNatively;
- }},
- index: {get: function() {
- return index;
- }},
- hasClass: {get: function() {
- return hasClass;
- }},
- addClass: {get: function() {
- return addClass;
- }},
- removeClass: {get: function() {
- return removeClass;
- }},
- removeTextNodes: {get: function() {
- return removeTextNodes;
- }},
- empty: {get: function() {
- return empty;
- }},
- HTML_CHARACTERS: {get: function() {
- return HTML_CHARACTERS;
- }},
- fastInnerHTML: {get: function() {
- return fastInnerHTML;
- }},
- fastInnerText: {get: function() {
- return fastInnerText;
- }},
- isVisible: {get: function() {
- return isVisible;
- }},
- offset: {get: function() {
- return offset;
- }},
- getWindowScrollTop: {get: function() {
- return getWindowScrollTop;
- }},
- getWindowScrollLeft: {get: function() {
- return getWindowScrollLeft;
- }},
- getScrollTop: {get: function() {
- return getScrollTop;
- }},
- getScrollLeft: {get: function() {
- return getScrollLeft;
- }},
- getScrollableElement: {get: function() {
- return getScrollableElement;
- }},
- getTrimmingContainer: {get: function() {
- return getTrimmingContainer;
- }},
- getStyle: {get: function() {
- return getStyle;
- }},
- getComputedStyle: {get: function() {
- return getComputedStyle;
- }},
- outerWidth: {get: function() {
- return outerWidth;
- }},
- outerHeight: {get: function() {
- return outerHeight;
- }},
- innerHeight: {get: function() {
- return innerHeight;
- }},
- innerWidth: {get: function() {
- return innerWidth;
- }},
- addEvent: {get: function() {
- return addEvent;
- }},
- removeEvent: {get: function() {
- return removeEvent;
- }},
- hasCaptionProblem: {get: function() {
- return hasCaptionProblem;
- }},
- getCaretPosition: {get: function() {
- return getCaretPosition;
- }},
- getSelectionEndPosition: {get: function() {
- return getSelectionEndPosition;
- }},
- setCaretPosition: {get: function() {
- return setCaretPosition;
- }},
- getScrollbarWidth: {get: function() {
- return getScrollbarWidth;
- }},
- isIE8: {get: function() {
- return isIE8;
- }},
- isIE9: {get: function() {
- return isIE9;
- }},
- isSafari: {get: function() {
- return isSafari;
- }},
- setOverlayPosition: {get: function() {
- return setOverlayPosition;
- }},
- getCssTransform: {get: function() {
- return getCssTransform;
- }},
- resetCssTransform: {get: function() {
- return resetCssTransform;
- }},
- __esModule: {value: true}
- });
- function enableImmediatePropagation(event) {
- if (event != null && event.isImmediatePropagationEnabled == null) {
- event.stopImmediatePropagation = function() {
- this.isImmediatePropagationEnabled = false;
- this.cancelBubble = true;
- };
- event.isImmediatePropagationEnabled = true;
- event.isImmediatePropagationStopped = function() {
- return !this.isImmediatePropagationEnabled;
- };
- }
- }
- function closest(element, nodes, until) {
- while (element != null && element !== until) {
- if (element.nodeType === Node.ELEMENT_NODE && (nodes.indexOf(element.nodeName) > -1 || nodes.indexOf(element) > -1)) {
- return element;
- }
- if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
- element = element.host;
- } else {
- element = element.parentNode;
- }
- }
- return null;
- }
- function isChildOf(child, parent) {
- var node = child.parentNode;
- var queriedParents = [];
- if (typeof parent === "string") {
- queriedParents = Array.prototype.slice.call(document.querySelectorAll(parent), 0);
- } else {
- queriedParents.push(parent);
- }
- while (node != null) {
- if (queriedParents.indexOf(node) > -1) {
- return true;
- }
- node = node.parentNode;
- }
- return false;
- }
- function isChildOfWebComponentTable(element) {
- var hotTableName = 'hot-table',
- result = false,
- parentNode;
- parentNode = polymerWrap(element);
- function isHotTable(element) {
- return element.nodeType === Node.ELEMENT_NODE && element.nodeName === hotTableName.toUpperCase();
- }
- while (parentNode != null) {
- if (isHotTable(parentNode)) {
- result = true;
- break;
- } else if (parentNode.host && parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
- result = isHotTable(parentNode.host);
- if (result) {
- break;
- }
- parentNode = parentNode.host;
- }
- parentNode = parentNode.parentNode;
- }
- return result;
- }
- function polymerWrap(element) {
- return typeof Polymer !== 'undefined' && typeof wrap === 'function' ? wrap(element) : element;
- }
- function polymerUnwrap(element) {
- return typeof Polymer !== 'undefined' && typeof unwrap === 'function' ? unwrap(element) : element;
- }
- function isWebComponentSupportedNatively() {
- var test = document.createElement('div');
- return test.createShadowRoot && test.createShadowRoot.toString().match(/\[native code\]/) ? true : false;
- }
- function index(elem) {
- var i = 0;
- if (elem.previousSibling) {
- while (elem = elem.previousSibling) {
- ++i;
- }
- }
- return i;
- }
- var classListSupport = document.documentElement.classList ? true : false;
- var _hasClass,
- _addClass,
- _removeClass;
- function filterEmptyClassNames(classNames) {
- var len = 0,
- result = [];
- if (!classNames || !classNames.length) {
- return result;
- }
- while (classNames[len]) {
- result.push(classNames[len]);
- len++;
- }
- return result;
- }
- if (classListSupport) {
- var isSupportMultipleClassesArg = (function() {
- var element = document.createElement('div');
- element.classList.add('test', 'test2');
- return element.classList.contains('test2');
- }());
- _hasClass = function _hasClass(element, className) {
- if (className === '') {
- return false;
- }
- return element.classList.contains(className);
- };
- _addClass = function _addClass(element, className) {
- var len = 0;
- if (typeof className === 'string') {
- className = className.split(' ');
- }
- className = filterEmptyClassNames(className);
- if (isSupportMultipleClassesArg) {
- element.classList.add.apply(element.classList, className);
- } else {
- while (className && className[len]) {
- element.classList.add(className[len]);
- len++;
- }
- }
- };
- _removeClass = function _removeClass(element, className) {
- var len = 0;
- if (typeof className === 'string') {
- className = className.split(' ');
- }
- className = filterEmptyClassNames(className);
- if (isSupportMultipleClassesArg) {
- element.classList.remove.apply(element.classList, className);
- } else {
- while (className && className[len]) {
- element.classList.remove(className[len]);
- len++;
- }
- }
- };
- } else {
- var createClassNameRegExp = function createClassNameRegExp(className) {
- return new RegExp('(\\s|^)' + className + '(\\s|$)');
- };
- _hasClass = function _hasClass(element, className) {
- return element.className.match(createClassNameRegExp(className)) ? true : false;
- };
- _addClass = function _addClass(element, className) {
- var len = 0,
- _className = element.className;
- if (typeof className === 'string') {
- className = className.split(' ');
- }
- if (_className === '') {
- _className = className.join(' ');
- } else {
- while (className && className[len]) {
- if (!createClassNameRegExp(className[len]).test(_className)) {
- _className += ' ' + className[len];
- }
- len++;
- }
- }
- element.className = _className;
- };
- _removeClass = function _removeClass(element, className) {
- var len = 0,
- _className = element.className;
- if (typeof className === 'string') {
- className = className.split(' ');
- }
- while (className && className[len]) {
- _className = _className.replace(createClassNameRegExp(className[len]), ' ').trim();
- len++;
- }
- if (element.className !== _className) {
- element.className = _className;
- }
- };
- }
- function hasClass(element, className) {
- return _hasClass(element, className);
- }
- function addClass(element, className) {
- return _addClass(element, className);
- }
- function removeClass(element, className) {
- return _removeClass(element, className);
- }
- function removeTextNodes(elem, parent) {
- if (elem.nodeType === 3) {
- parent.removeChild(elem);
- } else if (['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR'].indexOf(elem.nodeName) > -1) {
- var childs = elem.childNodes;
- for (var i = childs.length - 1; i >= 0; i--) {
- removeTextNodes(childs[i], elem);
- }
- }
- }
- function empty(element) {
- var child;
- while (child = element.lastChild) {
- element.removeChild(child);
- }
- }
- var HTML_CHARACTERS = /(<(.*)>|&(.*);)/;
- function fastInnerHTML(element, content) {
- if (HTML_CHARACTERS.test(content)) {
- element.innerHTML = content;
- } else {
- fastInnerText(element, content);
- }
- }
- var textContextSupport = document.createTextNode('test').textContent ? true : false;
- function fastInnerText(element, content) {
- var child = element.firstChild;
- if (child && child.nodeType === 3 && child.nextSibling === null) {
- if (textContextSupport) {
- child.textContent = content;
- } else {
- child.data = content;
- }
- } else {
- empty(element);
- element.appendChild(document.createTextNode(content));
- }
- }
- function isVisible(elem) {
- var next = elem;
- while (polymerUnwrap(next) !== document.documentElement) {
- if (next === null) {
- return false;
- } else if (next.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
- if (next.host) {
- if (next.host.impl) {
- return isVisible(next.host.impl);
- } else if (next.host) {
- return isVisible(next.host);
- } else {
- throw new Error("Lost in Web Components world");
- }
- } else {
- return false;
- }
- } else if (next.style.display === 'none') {
- return false;
- }
- next = next.parentNode;
- }
- return true;
- }
- function offset(elem) {
- var offsetLeft,
- offsetTop,
- lastElem,
- docElem,
- box;
- docElem = document.documentElement;
- if (hasCaptionProblem() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') {
- box = elem.getBoundingClientRect();
- return {
- top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
- left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)
- };
- }
- offsetLeft = elem.offsetLeft;
- offsetTop = elem.offsetTop;
- lastElem = elem;
- while (elem = elem.offsetParent) {
- if (elem === document.body) {
- break;
- }
- offsetLeft += elem.offsetLeft;
- offsetTop += elem.offsetTop;
- lastElem = elem;
- }
- if (lastElem && lastElem.style.position === 'fixed') {
- offsetLeft += window.pageXOffset || docElem.scrollLeft;
- offsetTop += window.pageYOffset || docElem.scrollTop;
- }
- return {
- left: offsetLeft,
- top: offsetTop
- };
- }
- function getWindowScrollTop() {
- var res = window.scrollY;
- if (res == void 0) {
- res = document.documentElement.scrollTop;
- }
- return res;
- }
- function getWindowScrollLeft() {
- var res = window.scrollX;
- if (res == void 0) {
- res = document.documentElement.scrollLeft;
- }
- return res;
- }
- function getScrollTop(elem) {
- if (elem === window) {
- return getWindowScrollTop(elem);
- } else {
- return elem.scrollTop;
- }
- }
- function getScrollLeft(elem) {
- if (elem === window) {
- return getWindowScrollLeft(elem);
- } else {
- return elem.scrollLeft;
- }
- }
- function getScrollableElement(element) {
- var el = element.parentNode,
- props = ['auto', 'scroll'],
- overflow,
- overflowX,
- overflowY,
- computedStyle = '',
- computedOverflow = '',
- computedOverflowY = '',
- computedOverflowX = '';
- while (el && el.style && document.body !== el) {
- overflow = el.style.overflow;
- overflowX = el.style.overflowX;
- overflowY = el.style.overflowY;
- if (overflow == 'scroll' || overflowX == 'scroll' || overflowY == 'scroll') {
- return el;
- } else if (window.getComputedStyle) {
- computedStyle = window.getComputedStyle(el);
- computedOverflow = computedStyle.getPropertyValue('overflow');
- computedOverflowY = computedStyle.getPropertyValue('overflow-y');
- computedOverflowX = computedStyle.getPropertyValue('overflow-x');
- if (computedOverflow === 'scroll' || computedOverflowX === 'scroll' || computedOverflowY === 'scroll') {
- return el;
- }
- }
- if (el.clientHeight <= el.scrollHeight && (props.indexOf(overflowY) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowY) !== -1)) {
- return el;
- }
- if (el.clientWidth <= el.scrollWidth && (props.indexOf(overflowX) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowX) !== -1)) {
- return el;
- }
- el = el.parentNode;
- }
- return window;
- }
- function getTrimmingContainer(base) {
- var el = base.parentNode;
- while (el && el.style && document.body !== el) {
- if (el.style.overflow !== 'visible' && el.style.overflow !== '') {
- return el;
- } else if (window.getComputedStyle) {
- var computedStyle = window.getComputedStyle(el);
- if (computedStyle.getPropertyValue('overflow') !== 'visible' && computedStyle.getPropertyValue('overflow') !== '') {
- return el;
- }
- }
- el = el.parentNode;
- }
- return window;
- }
- function getStyle(elem, prop) {
- if (!elem) {
- return;
- } else if (elem === window) {
- if (prop === 'width') {
- return window.innerWidth + 'px';
- } else if (prop === 'height') {
- return window.innerHeight + 'px';
- }
- return;
- }
- var styleProp = elem.style[prop],
- computedStyle;
- if (styleProp !== "" && styleProp !== void 0) {
- return styleProp;
- } else {
- computedStyle = getComputedStyle(elem);
- if (computedStyle[prop] !== "" && computedStyle[prop] !== void 0) {
- return computedStyle[prop];
- }
- return void 0;
- }
- }
- function getComputedStyle(elem) {
- return elem.currentStyle || document.defaultView.getComputedStyle(elem);
- }
- function outerWidth(elem) {
- return elem.offsetWidth;
- }
- function outerHeight(elem) {
- if (hasCaptionProblem() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') {
- return elem.offsetHeight + elem.firstChild.offsetHeight;
- } else {
- return elem.offsetHeight;
- }
- }
- function innerHeight(elem) {
- return elem.clientHeight || elem.innerHeight;
- }
- function innerWidth(elem) {
- return elem.clientWidth || elem.innerWidth;
- }
- function addEvent(element, event, callback) {
- if (window.addEventListener) {
- element.addEventListener(event, callback, false);
- } else {
- element.attachEvent('on' + event, callback);
- }
- }
- function removeEvent(element, event, callback) {
- if (window.removeEventListener) {
- element.removeEventListener(event, callback, false);
- } else {
- element.detachEvent('on' + event, callback);
- }
- }
- var _hasCaptionProblem;
- function detectCaptionProblem() {
- var TABLE = document.createElement('TABLE');
- TABLE.style.borderSpacing = 0;
- TABLE.style.borderWidth = 0;
- TABLE.style.padding = 0;
- var TBODY = document.createElement('TBODY');
- TABLE.appendChild(TBODY);
- TBODY.appendChild(document.createElement('TR'));
- TBODY.firstChild.appendChild(document.createElement('TD'));
- TBODY.firstChild.firstChild.innerHTML = '<tr><td>t<br>t</td></tr>';
- var CAPTION = document.createElement('CAPTION');
- CAPTION.innerHTML = 'c<br>c<br>c<br>c';
- CAPTION.style.padding = 0;
- CAPTION.style.margin = 0;
- TABLE.insertBefore(CAPTION, TBODY);
- document.body.appendChild(TABLE);
- _hasCaptionProblem = (TABLE.offsetHeight < 2 * TABLE.lastChild.offsetHeight);
- document.body.removeChild(TABLE);
- }
- function hasCaptionProblem() {
- if (_hasCaptionProblem === void 0) {
- detectCaptionProblem();
- }
- return _hasCaptionProblem;
- }
- function getCaretPosition(el) {
- if (el.selectionStart) {
- return el.selectionStart;
- } else if (document.selection) {
- el.focus();
- var r = document.selection.createRange();
- if (r == null) {
- return 0;
- }
- var re = el.createTextRange();
- var rc = re.duplicate();
- re.moveToBookmark(r.getBookmark());
- rc.setEndPoint('EndToStart', re);
- return rc.text.length;
- }
- return 0;
- }
- function getSelectionEndPosition(el) {
- if (el.selectionEnd) {
- return el.selectionEnd;
- } else if (document.selection) {
- var r = document.selection.createRange();
- if (r == null) {
- return 0;
- }
- var re = el.createTextRange();
- return re.text.indexOf(r.text) + r.text.length;
- }
- }
- function setCaretPosition(el, pos, endPos) {
- if (endPos === void 0) {
- endPos = pos;
- }
- if (el.setSelectionRange) {
- el.focus();
- try {
- el.setSelectionRange(pos, endPos);
- } catch (err) {
- var elementParent = el.parentNode;
- var parentDisplayValue = elementParent.style.display;
- elementParent.style.display = 'block';
- el.setSelectionRange(pos, endPos);
- elementParent.style.display = parentDisplayValue;
- }
- } else if (el.createTextRange) {
- var range = el.createTextRange();
- range.collapse(true);
- range.moveEnd('character', endPos);
- range.moveStart('character', pos);
- range.select();
- }
- }
- var cachedScrollbarWidth;
- function walkontableCalculateScrollbarWidth() {
- var inner = document.createElement('p');
- inner.style.width = "100%";
- inner.style.height = "200px";
- var outer = document.createElement('div');
- outer.style.position = "absolute";
- outer.style.top = "0px";
- outer.style.left = "0px";
- outer.style.visibility = "hidden";
- outer.style.width = "200px";
- outer.style.height = "150px";
- outer.style.overflow = "hidden";
- outer.appendChild(inner);
- (document.body || document.documentElement).appendChild(outer);
- var w1 = inner.offsetWidth;
- outer.style.overflow = 'scroll';
- var w2 = inner.offsetWidth;
- if (w1 == w2) {
- w2 = outer.clientWidth;
- }
- (document.body || document.documentElement).removeChild(outer);
- return (w1 - w2);
- }
- function getScrollbarWidth() {
- if (cachedScrollbarWidth === void 0) {
- cachedScrollbarWidth = walkontableCalculateScrollbarWidth();
- }
- return cachedScrollbarWidth;
- }
- var _isIE8 = !(document.createTextNode('test').textContent);
- function isIE8() {
- return isIE8;
- }
- var _isIE9 = !!(document.documentMode);
- function isIE9() {
- return _isIE9;
- }
- var _isSafari = (/Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor));
- function isSafari() {
- return _isSafari;
- }
- function setOverlayPosition(overlayElem, left, top) {
- if (_isIE8 || _isIE9) {
- overlayElem.style.top = top;
- overlayElem.style.left = left;
- } else if (_isSafari) {
- overlayElem.style['-webkit-transform'] = 'translate3d(' + left + ',' + top + ',0)';
- } else {
- overlayElem.style.transform = 'translate3d(' + left + ',' + top + ',0)';
- }
- }
- function getCssTransform(elem) {
- var transform;
- if (elem.style['transform'] && (transform = elem.style['transform']) !== '') {
- return ['transform', transform];
- } else if (elem.style['-webkit-transform'] && (transform = elem.style['-webkit-transform']) !== '') {
- return ['-webkit-transform', transform];
- }
- return -1;
- }
- function resetCssTransform(elem) {
- if (elem['transform'] && elem['transform'] !== '') {
- elem['transform'] = '';
- } else if (elem['-webkit-transform'] && elem['-webkit-transform'] !== '') {
- elem['-webkit-transform'] = '';
- }
- }
- window.Handsontable = window.Handsontable || {};
- Handsontable.Dom = {
- addClass: addClass,
- addEvent: addEvent,
- closest: closest,
- empty: empty,
- enableImmediatePropagation: enableImmediatePropagation,
- fastInnerHTML: fastInnerHTML,
- fastInnerText: fastInnerText,
- getCaretPosition: getCaretPosition,
- getComputedStyle: getComputedStyle,
- getCssTransform: getCssTransform,
- getScrollableElement: getScrollableElement,
- getScrollbarWidth: getScrollbarWidth,
- getScrollLeft: getScrollLeft,
- getScrollTop: getScrollTop,
- getStyle: getStyle,
- getSelectionEndPosition: getSelectionEndPosition,
- getTrimmingContainer: getTrimmingContainer,
- getWindowScrollLeft: getWindowScrollLeft,
- getWindowScrollTop: getWindowScrollTop,
- hasCaptionProblem: hasCaptionProblem,
- hasClass: hasClass,
- HTML_CHARACTERS: HTML_CHARACTERS,
- index: index,
- innerHeight: innerHeight,
- innerWidth: innerWidth,
- isChildOf: isChildOf,
- isChildOfWebComponentTable: isChildOfWebComponentTable,
- isIE8: isIE8,
- isIE9: isIE9,
- isSafari: isSafari,
- isVisible: isVisible,
- isWebComponentSupportedNatively: isWebComponentSupportedNatively,
- offset: offset,
- outerHeight: outerHeight,
- outerWidth: outerWidth,
- polymerUnwrap: polymerUnwrap,
- polymerWrap: polymerWrap,
- removeClass: removeClass,
- removeEvent: removeEvent,
- removeTextNodes: removeTextNodes,
- resetCssTransform: resetCssTransform,
- setCaretPosition: setCaretPosition,
- setOverlayPosition: setOverlayPosition
- };
-
- //#
- },{}],28:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- EditorManager: {get: function() {
- return EditorManager;
- }},
- __esModule: {value: true}
- });
- var $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
- $__helpers_46_js__,
- $__dom_46_js__,
- $__editors_46_js__,
- $__eventManager_46_js__;
- var WalkontableCellCoords = ($__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ = require("./3rdparty/walkontable/src/cell/coords.js"), $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ && $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__.__esModule && $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ || {default: $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__}).WalkontableCellCoords;
- var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
- var dom = ($__dom_46_js__ = require("./dom.js"), $__dom_46_js__ && $__dom_46_js__.__esModule && $__dom_46_js__ || {default: $__dom_46_js__});
- var getEditor = ($__editors_46_js__ = require("./editors.js"), $__editors_46_js__ && $__editors_46_js__.__esModule && $__editors_46_js__ || {default: $__editors_46_js__}).getEditor;
- var eventManagerObject = ($__eventManager_46_js__ = require("./eventManager.js"), $__eventManager_46_js__ && $__eventManager_46_js__.__esModule && $__eventManager_46_js__ || {default: $__eventManager_46_js__}).eventManager;
- ;
- Handsontable.EditorManager = EditorManager;
- function EditorManager(instance, priv, selection) {
- var _this = this,
- keyCodes = helper.keyCode,
- destroyed = false,
- eventManager,
- activeEditor;
- eventManager = eventManagerObject(instance);
- function moveSelectionAfterEnter(shiftKey) {
- var enterMoves = typeof priv.settings.enterMoves === 'function' ? priv.settings.enterMoves(event) : priv.settings.enterMoves;
- if (shiftKey) {
- selection.transformStart(-enterMoves.row, -enterMoves.col);
- } else {
- selection.transformStart(enterMoves.row, enterMoves.col, true);
- }
- }
- function moveSelectionUp(shiftKey) {
- if (shiftKey) {
- selection.transformEnd(-1, 0);
- } else {
- selection.transformStart(-1, 0);
- }
- }
- function moveSelectionDown(shiftKey) {
- if (shiftKey) {
- selection.transformEnd(1, 0);
- } else {
- selection.transformStart(1, 0);
- }
- }
- function moveSelectionRight(shiftKey) {
- if (shiftKey) {
- selection.transformEnd(0, 1);
- } else {
- selection.transformStart(0, 1);
- }
- }
- function moveSelectionLeft(shiftKey) {
- if (shiftKey) {
- selection.transformEnd(0, -1);
- } else {
- selection.transformStart(0, -1);
- }
- }
- function onKeyDown(event) {
- var ctrlDown,
- rangeModifier;
- if (!instance.isListening()) {
- return;
- }
- Handsontable.hooks.run(instance, 'beforeKeyDown', event);
- if (destroyed) {
- return;
- }
- dom.enableImmediatePropagation(event);
- if (event.isImmediatePropagationStopped()) {
- return;
- }
- priv.lastKeyCode = event.keyCode;
- if (!selection.isSelected()) {
- return;
- }
- ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
- if (activeEditor && !activeEditor.isWaiting()) {
- if (!helper.isMetaKey(event.keyCode) && !ctrlDown && !_this.isEditorOpened()) {
- _this.openEditor("", event);
- return;
- }
- }
- rangeModifier = event.shiftKey ? selection.setRangeEnd : selection.setRangeStart;
- switch (event.keyCode) {
- case keyCodes.A:
- if (!_this.isEditorOpened() && ctrlDown) {
- selection.selectAll();
- event.preventDefault();
- helper.stopPropagation(event);
- }
- break;
- case keyCodes.ARROW_UP:
- if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
- _this.closeEditorAndSaveChanges(ctrlDown);
- }
- moveSelectionUp(event.shiftKey);
- event.preventDefault();
- helper.stopPropagation(event);
- break;
- case keyCodes.ARROW_DOWN:
- if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
- _this.closeEditorAndSaveChanges(ctrlDown);
- }
- moveSelectionDown(event.shiftKey);
- event.preventDefault();
- helper.stopPropagation(event);
- break;
- case keyCodes.ARROW_RIGHT:
- if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
- _this.closeEditorAndSaveChanges(ctrlDown);
- }
- moveSelectionRight(event.shiftKey);
- event.preventDefault();
- helper.stopPropagation(event);
- break;
- case keyCodes.ARROW_LEFT:
- if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
- _this.closeEditorAndSaveChanges(ctrlDown);
- }
- moveSelectionLeft(event.shiftKey);
- event.preventDefault();
- helper.stopPropagation(event);
- break;
- case keyCodes.TAB:
- var tabMoves = typeof priv.settings.tabMoves === 'function' ? priv.settings.tabMoves(event) : priv.settings.tabMoves;
- if (event.shiftKey) {
- selection.transformStart(-tabMoves.row, -tabMoves.col);
- } else {
- selection.transformStart(tabMoves.row, tabMoves.col, true);
- }
- event.preventDefault();
- helper.stopPropagation(event);
- break;
- case keyCodes.BACKSPACE:
- case keyCodes.DELETE:
- selection.empty(event);
- _this.prepareEditor();
- event.preventDefault();
- break;
- case keyCodes.F2:
- _this.openEditor(null, event);
- event.preventDefault();
- break;
- case keyCodes.ENTER:
- if (_this.isEditorOpened()) {
- if (activeEditor && activeEditor.state !== Handsontable.EditorState.WAITING) {
- _this.closeEditorAndSaveChanges(ctrlDown);
- }
- moveSelectionAfterEnter(event.shiftKey);
- } else {
- if (instance.getSettings().enterBeginsEditing) {
- _this.openEditor(null, event);
- } else {
- moveSelectionAfterEnter(event.shiftKey);
- }
- }
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case keyCodes.ESCAPE:
- if (_this.isEditorOpened()) {
- _this.closeEditorAndRestoreOriginalValue(ctrlDown);
- }
- event.preventDefault();
- break;
- case keyCodes.HOME:
- if (event.ctrlKey || event.metaKey) {
- rangeModifier(new WalkontableCellCoords(0, priv.selRange.from.col));
- } else {
- rangeModifier(new WalkontableCellCoords(priv.selRange.from.row, 0));
- }
- event.preventDefault();
- helper.stopPropagation(event);
- break;
- case keyCodes.END:
- if (event.ctrlKey || event.metaKey) {
- rangeModifier(new WalkontableCellCoords(instance.countRows() - 1, priv.selRange.from.col));
- } else {
- rangeModifier(new WalkontableCellCoords(priv.selRange.from.row, instance.countCols() - 1));
- }
- event.preventDefault();
- helper.stopPropagation(event);
- break;
- case keyCodes.PAGE_UP:
- selection.transformStart(-instance.countVisibleRows(), 0);
- event.preventDefault();
- helper.stopPropagation(event);
- break;
- case keyCodes.PAGE_DOWN:
- selection.transformStart(instance.countVisibleRows(), 0);
- event.preventDefault();
- helper.stopPropagation(event);
- break;
- }
- }
- function init() {
- instance.addHook('afterDocumentKeyDown', onKeyDown);
- eventManager.addEventListener(document.documentElement, 'keydown', function(event) {
- instance.runHooks('afterDocumentKeyDown', event);
- });
- function onDblClick(event, coords, elem) {
- if (elem.nodeName == "TD") {
- _this.openEditor();
- }
- }
- instance.view.wt.update('onCellDblClick', onDblClick);
- instance.addHook('afterDestroy', function() {
- destroyed = true;
- });
- }
- this.destroyEditor = function(revertOriginal) {
- this.closeEditor(revertOriginal);
- };
- this.getActiveEditor = function() {
- return activeEditor;
- };
- this.prepareEditor = function() {
- var row,
- col,
- prop,
- td,
- originalValue,
- cellProperties,
- editorClass;
- if (activeEditor && activeEditor.isWaiting()) {
- this.closeEditor(false, false, function(dataSaved) {
- if (dataSaved) {
- _this.prepareEditor();
- }
- });
- return;
- }
- row = priv.selRange.highlight.row;
- col = priv.selRange.highlight.col;
- prop = instance.colToProp(col);
- td = instance.getCell(row, col);
- originalValue = instance.getDataAtCell(row, col);
- cellProperties = instance.getCellMeta(row, col);
- editorClass = instance.getCellEditor(cellProperties);
- if (editorClass) {
- activeEditor = Handsontable.editors.getEditor(editorClass, instance);
- activeEditor.prepare(row, col, prop, td, originalValue, cellProperties);
- } else {
- activeEditor = void 0;
- }
- };
- this.isEditorOpened = function() {
- return activeEditor && activeEditor.isOpened();
- };
- this.openEditor = function(initialValue, event) {
- if (activeEditor && !activeEditor.cellProperties.readOnly) {
- activeEditor.beginEditing(initialValue, event);
- } else if (activeEditor && activeEditor.cellProperties.readOnly) {
- if (event && event.keyCode === helper.keyCode.ENTER) {
- moveSelectionAfterEnter();
- }
- }
- };
- this.closeEditor = function(restoreOriginalValue, ctrlDown, callback) {
- if (!activeEditor) {
- if (callback) {
- callback(false);
- }
- } else {
- activeEditor.finishEditing(restoreOriginalValue, ctrlDown, callback);
- }
- };
- this.closeEditorAndSaveChanges = function(ctrlDown) {
- return this.closeEditor(false, ctrlDown);
- };
- this.closeEditorAndRestoreOriginalValue = function(ctrlDown) {
- return this.closeEditor(true, ctrlDown);
- };
- init();
- }
-
- //#
- },{"./3rdparty/walkontable/src/cell/coords.js":5,"./dom.js":27,"./editors.js":29,"./eventManager.js":41,"./helpers.js":42}],29:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- registerEditor: {get: function() {
- return registerEditor;
- }},
- getEditor: {get: function() {
- return getEditor;
- }},
- hasEditor: {get: function() {
- return hasEditor;
- }},
- getEditorConstructor: {get: function() {
- return getEditorConstructor;
- }},
- __esModule: {value: true}
- });
- var $__helpers_46_js__;
- var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
- ;
- var registeredEditorNames = {},
- registeredEditorClasses = new WeakMap();
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.registerEditor = registerEditor;
- Handsontable.editors.getEditor = getEditor;
- function RegisteredEditor(editorClass) {
- var Clazz,
- instances;
- instances = {};
- Clazz = editorClass;
- this.getConstructor = function() {
- return editorClass;
- };
- this.getInstance = function(hotInstance) {
- if (!(hotInstance.guid in instances)) {
- instances[hotInstance.guid] = new Clazz(hotInstance);
- }
- return instances[hotInstance.guid];
- };
- }
- function registerEditor(editorName, editorClass) {
- var editor = new RegisteredEditor(editorClass);
- if (typeof editorName === "string") {
- registeredEditorNames[editorName] = editor;
- }
- registeredEditorClasses.set(editorClass, editor);
- }
- function getEditor(editorName, hotInstance) {
- var editor;
- if (typeof editorName == 'function') {
- if (!(registeredEditorClasses.get(editorName))) {
- registerEditor(null, editorName);
- }
- editor = registeredEditorClasses.get(editorName);
- } else if (typeof editorName == 'string') {
- editor = registeredEditorNames[editorName];
- } else {
- throw Error('Only strings and functions can be passed as "editor" parameter ');
- }
- if (!editor) {
- throw Error('No editor registered under name "' + editorName + '"');
- }
- return editor.getInstance(hotInstance);
- }
- function getEditorConstructor(editorName) {
- var editor;
- if (typeof editorName == 'string') {
- editor = registeredEditorNames[editorName];
- } else {
- throw Error('Only strings and functions can be passed as "editor" parameter ');
- }
- if (!editor) {
- throw Error('No editor registered under name "' + editorName + '"');
- }
- return editor.getConstructor();
- }
- function hasEditor(editorName) {
- return registeredEditorNames[editorName] ? true : false;
- }
-
- //#
- },{"./helpers.js":42}],30:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- BaseEditor: {get: function() {
- return BaseEditor;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_helpers_46_js__,
- $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__;
- var helper = ($___46__46__47_helpers_46_js__ = require("./../helpers.js"), $___46__46__47_helpers_46_js__ && $___46__46__47_helpers_46_js__.__esModule && $___46__46__47_helpers_46_js__ || {default: $___46__46__47_helpers_46_js__});
- var WalkontableCellCoords = ($___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ = require("./../3rdparty/walkontable/src/cell/coords.js"), $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ && $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__.__esModule && $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ || {default: $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__}).WalkontableCellCoords;
- ;
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.BaseEditor = BaseEditor;
- Handsontable.EditorState = {
- VIRGIN: 'STATE_VIRGIN',
- EDITING: 'STATE_EDITING',
- WAITING: 'STATE_WAITING',
- FINISHED: 'STATE_FINISHED'
- };
- function BaseEditor(instance) {
- this.instance = instance;
- this.state = Handsontable.EditorState.VIRGIN;
- this._opened = false;
- this._closeCallback = null;
- this.init();
- }
- BaseEditor.prototype._fireCallbacks = function(result) {
- if (this._closeCallback) {
- this._closeCallback(result);
- this._closeCallback = null;
- }
- };
- BaseEditor.prototype.init = function() {};
- BaseEditor.prototype.getValue = function() {
- throw Error('Editor getValue() method unimplemented');
- };
- BaseEditor.prototype.setValue = function(newValue) {
- throw Error('Editor setValue() method unimplemented');
- };
- BaseEditor.prototype.open = function() {
- throw Error('Editor open() method unimplemented');
- };
- BaseEditor.prototype.close = function() {
- throw Error('Editor close() method unimplemented');
- };
- BaseEditor.prototype.prepare = function(row, col, prop, td, originalValue, cellProperties) {
- this.TD = td;
- this.row = row;
- this.col = col;
- this.prop = prop;
- this.originalValue = originalValue;
- this.cellProperties = cellProperties;
- this.state = Handsontable.EditorState.VIRGIN;
- };
- BaseEditor.prototype.extend = function() {
- var baseClass = this.constructor;
- function Editor() {
- baseClass.apply(this, arguments);
- }
- function inherit(Child, Parent) {
- function Bridge() {}
- Bridge.prototype = Parent.prototype;
- Child.prototype = new Bridge();
- Child.prototype.constructor = Child;
- return Child;
- }
- return inherit(Editor, baseClass);
- };
- BaseEditor.prototype.saveValue = function(val, ctrlDown) {
- var sel,
- tmp;
- if (ctrlDown) {
- sel = this.instance.getSelected();
- if (sel[0] > sel[2]) {
- tmp = sel[0];
- sel[0] = sel[2];
- sel[2] = tmp;
- }
- if (sel[1] > sel[3]) {
- tmp = sel[1];
- sel[1] = sel[3];
- sel[3] = tmp;
- }
- this.instance.populateFromArray(sel[0], sel[1], val, sel[2], sel[3], 'edit');
- } else {
- this.instance.populateFromArray(this.row, this.col, val, null, null, 'edit');
- }
- };
- BaseEditor.prototype.beginEditing = function(initialValue, event) {
- if (this.state != Handsontable.EditorState.VIRGIN) {
- return;
- }
- this.instance.view.scrollViewport(new WalkontableCellCoords(this.row, this.col));
- this.instance.view.render();
- this.state = Handsontable.EditorState.EDITING;
- initialValue = typeof initialValue == 'string' ? initialValue : this.originalValue;
- this.setValue(helper.stringify(initialValue));
- this.open(event);
- this._opened = true;
- this.focus();
- this.instance.view.render();
- };
- BaseEditor.prototype.finishEditing = function(restoreOriginalValue, ctrlDown, callback) {
- var _this = this,
- val;
- if (callback) {
- var previousCloseCallback = this._closeCallback;
- this._closeCallback = function(result) {
- if (previousCloseCallback) {
- previousCloseCallback(result);
- }
- callback(result);
- };
- }
- if (this.isWaiting()) {
- return;
- }
- if (this.state == Handsontable.EditorState.VIRGIN) {
- this.instance._registerTimeout(setTimeout(function() {
- _this._fireCallbacks(true);
- }, 0));
- return;
- }
- if (this.state == Handsontable.EditorState.EDITING) {
- if (restoreOriginalValue) {
- this.cancelChanges();
- this.instance.view.render();
- return;
- }
- if (this.instance.getSettings().trimWhitespace) {
- val = [[typeof this.getValue() === 'string' ? String.prototype.trim.call(this.getValue() || '') : this.getValue()]];
- } else {
- val = [[this.getValue()]];
- }
- this.state = Handsontable.EditorState.WAITING;
- this.saveValue(val, ctrlDown);
- if (this.instance.getCellValidator(this.cellProperties)) {
- this.instance.addHookOnce('postAfterValidate', function(result) {
- _this.state = Handsontable.EditorState.FINISHED;
- _this.discardEditor(result);
- });
- } else {
- this.state = Handsontable.EditorState.FINISHED;
- this.discardEditor(true);
- }
- }
- };
- BaseEditor.prototype.cancelChanges = function() {
- this.state = Handsontable.EditorState.FINISHED;
- this.discardEditor();
- };
- BaseEditor.prototype.discardEditor = function(result) {
- if (this.state !== Handsontable.EditorState.FINISHED) {
- return;
- }
- if (result === false && this.cellProperties.allowInvalid !== true) {
- this.instance.selectCell(this.row, this.col);
- this.focus();
- this.state = Handsontable.EditorState.EDITING;
- this._fireCallbacks(false);
- } else {
- this.close();
- this._opened = false;
- this.state = Handsontable.EditorState.VIRGIN;
- this._fireCallbacks(true);
- }
- };
- BaseEditor.prototype.isOpened = function() {
- return this._opened;
- };
- BaseEditor.prototype.isWaiting = function() {
- return this.state === Handsontable.EditorState.WAITING;
- };
-
- //#
- },{"./../3rdparty/walkontable/src/cell/coords.js":5,"./../helpers.js":42}],31:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- AutocompleteEditor: {get: function() {
- return AutocompleteEditor;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_helpers_46_js__,
- $___46__46__47_dom_46_js__,
- $___46__46__47_editors_46_js__,
- $__handsontableEditor_46_js__;
- var helper = ($___46__46__47_helpers_46_js__ = require("./../helpers.js"), $___46__46__47_helpers_46_js__ && $___46__46__47_helpers_46_js__.__esModule && $___46__46__47_helpers_46_js__ || {default: $___46__46__47_helpers_46_js__});
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var $__0 = ($___46__46__47_editors_46_js__ = require("./../editors.js"), $___46__46__47_editors_46_js__ && $___46__46__47_editors_46_js__.__esModule && $___46__46__47_editors_46_js__ || {default: $___46__46__47_editors_46_js__}),
- getEditorConstructor = $__0.getEditorConstructor,
- registerEditor = $__0.registerEditor;
- var HandsontableEditor = ($__handsontableEditor_46_js__ = require("./handsontableEditor.js"), $__handsontableEditor_46_js__ && $__handsontableEditor_46_js__.__esModule && $__handsontableEditor_46_js__ || {default: $__handsontableEditor_46_js__}).HandsontableEditor;
- var AutocompleteEditor = HandsontableEditor.prototype.extend();
- ;
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.AutocompleteEditor = AutocompleteEditor;
- AutocompleteEditor.prototype.init = function() {
- HandsontableEditor.prototype.init.apply(this, arguments);
- this.query = null;
- this.choices = [];
- };
- AutocompleteEditor.prototype.createElements = function() {
- HandsontableEditor.prototype.createElements.apply(this, arguments);
- dom.addClass(this.htContainer, 'autocompleteEditor');
- dom.addClass(this.htContainer, window.navigator.platform.indexOf('Mac') !== -1 ? 'htMacScroll' : '');
- };
- var skipOne = false;
- function onBeforeKeyDown(event) {
- skipOne = false;
- var editor = this.getActiveEditor();
- var keyCodes = helper.keyCode;
- if (helper.isPrintableChar(event.keyCode) || event.keyCode === keyCodes.BACKSPACE || event.keyCode === keyCodes.DELETE || event.keyCode === keyCodes.INSERT) {
- var timeOffset = 0;
- if (event.keyCode === keyCodes.C && (event.ctrlKey || event.metaKey)) {
- return;
- }
- if (!editor.isOpened()) {
- timeOffset += 10;
- }
- editor.instance._registerTimeout(setTimeout(function() {
- editor.queryChoices(editor.TEXTAREA.value);
- skipOne = true;
- }, timeOffset));
- }
- }
- AutocompleteEditor.prototype.prepare = function() {
- this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
- HandsontableEditor.prototype.prepare.apply(this, arguments);
- };
- AutocompleteEditor.prototype.open = function() {
- HandsontableEditor.prototype.open.apply(this, arguments);
- var choicesListHot = this.htEditor.getInstance();
- var that = this;
- this.TEXTAREA.style.visibility = 'visible';
- this.focus();
- choicesListHot.updateSettings({
- 'colWidths': [dom.outerWidth(this.TEXTAREA) - 2],
- width: dom.outerWidth(this.TEXTAREA) + dom.getScrollbarWidth() + 2,
- afterRenderer: function(TD, row, col, prop, value) {
- var caseSensitive = this.getCellMeta(row, col).filteringCaseSensitive === true,
- indexOfMatch,
- match,
- value = Handsontable.helper.stringify(value);
- if (value) {
- indexOfMatch = caseSensitive ? value.indexOf(this.query) : value.toLowerCase().indexOf(that.query.toLowerCase());
- if (indexOfMatch != -1) {
- match = value.substr(indexOfMatch, that.query.length);
- TD.innerHTML = value.replace(match, '<strong>' + match + '</strong>');
- }
- }
- }
- });
- this.htEditor.view.wt.wtTable.holder.parentNode.style['padding-right'] = dom.getScrollbarWidth() + 2 + 'px';
- if (skipOne) {
- skipOne = false;
- }
- that.instance._registerTimeout(setTimeout(function() {
- that.queryChoices(that.TEXTAREA.value);
- }, 0));
- };
- AutocompleteEditor.prototype.close = function() {
- HandsontableEditor.prototype.close.apply(this, arguments);
- };
- AutocompleteEditor.prototype.queryChoices = function(query) {
- this.query = query;
- if (typeof this.cellProperties.source == 'function') {
- var that = this;
- this.cellProperties.source(query, function(choices) {
- that.updateChoicesList(choices);
- });
- } else if (Array.isArray(this.cellProperties.source)) {
- var choices;
- if (!query || this.cellProperties.filter === false) {
- choices = this.cellProperties.source;
- } else {
- var filteringCaseSensitive = this.cellProperties.filteringCaseSensitive === true;
- var lowerCaseQuery = query.toLowerCase();
- choices = this.cellProperties.source.filter(function(choice) {
- if (filteringCaseSensitive) {
- return choice.indexOf(query) != -1;
- } else {
- return choice.toLowerCase().indexOf(lowerCaseQuery) != -1;
- }
- });
- }
- this.updateChoicesList(choices);
- } else {
- this.updateChoicesList([]);
- }
- };
- AutocompleteEditor.prototype.updateChoicesList = function(choices) {
- var pos = dom.getCaretPosition(this.TEXTAREA),
- endPos = dom.getSelectionEndPosition(this.TEXTAREA);
- var orderByRelevance = AutocompleteEditor.sortByRelevance(this.getValue(), choices, this.cellProperties.filteringCaseSensitive);
- var highlightIndex;
- if (this.cellProperties.filter != false) {
- var sorted = [];
- for (var i = 0,
- choicesCount = orderByRelevance.length; i < choicesCount; i++) {
- sorted.push(choices[orderByRelevance[i]]);
- }
- highlightIndex = 0;
- choices = sorted;
- } else {
- highlightIndex = orderByRelevance[0];
- }
- this.choices = choices;
- this.htEditor.loadData(helper.pivot([choices]));
- this.updateDropdownHeight();
- if (this.cellProperties.strict === true) {
- this.highlightBestMatchingChoice(highlightIndex);
- }
- this.instance.listen();
- this.TEXTAREA.focus();
- dom.setCaretPosition(this.TEXTAREA, pos, (pos != endPos ? endPos : void 0));
- };
- AutocompleteEditor.prototype.updateDropdownHeight = function() {
- this.htEditor.updateSettings({height: this.getDropdownHeight()});
- this.htEditor.view.wt.wtTable.alignOverlaysWithTrimmingContainer();
- };
- AutocompleteEditor.prototype.finishEditing = function(restoreOriginalValue) {
- if (!restoreOriginalValue) {
- this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
- }
- HandsontableEditor.prototype.finishEditing.apply(this, arguments);
- };
- AutocompleteEditor.prototype.highlightBestMatchingChoice = function(index) {
- if (typeof index === "number") {
- this.htEditor.selectCell(index, 0);
- } else {
- this.htEditor.deselectCell();
- }
- };
- AutocompleteEditor.sortByRelevance = function(value, choices, caseSensitive) {
- var choicesRelevance = [],
- currentItem,
- valueLength = value.length,
- valueIndex,
- charsLeft,
- result = [],
- i,
- choicesCount;
- if (valueLength === 0) {
- for (i = 0, choicesCount = choices.length; i < choicesCount; i++) {
- result.push(i);
- }
- return result;
- }
- for (i = 0, choicesCount = choices.length; i < choicesCount; i++) {
- currentItem = Handsontable.helper.stringify(choices[i]);
- if (caseSensitive) {
- valueIndex = currentItem.indexOf(value);
- } else {
- valueIndex = currentItem.toLowerCase().indexOf(value.toLowerCase());
- }
- if (valueIndex == -1) {
- continue;
- }
- charsLeft = currentItem.length - valueIndex - valueLength;
- choicesRelevance.push({
- baseIndex: i,
- index: valueIndex,
- charsLeft: charsLeft,
- value: currentItem
- });
- }
- choicesRelevance.sort(function(a, b) {
- if (b.index === -1) {
- return -1;
- }
- if (a.index === -1) {
- return 1;
- }
- if (a.index < b.index) {
- return -1;
- } else if (b.index < a.index) {
- return 1;
- } else if (a.index === b.index) {
- if (a.charsLeft < b.charsLeft) {
- return -1;
- } else if (a.charsLeft > b.charsLeft) {
- return 1;
- } else {
- return 0;
- }
- }
- });
- for (i = 0, choicesCount = choicesRelevance.length; i < choicesCount; i++) {
- result.push(choicesRelevance[i].baseIndex);
- }
- return result;
- };
- AutocompleteEditor.prototype.getDropdownHeight = function() {
- var firstRowHeight = this.htEditor.getInstance().getRowHeight(0) || 23;
- return this.choices.length >= 10 ? 10 * firstRowHeight : this.choices.length * firstRowHeight + 8;
- };
- registerEditor('autocomplete', AutocompleteEditor);
-
- //#
- },{"./../dom.js":27,"./../editors.js":29,"./../helpers.js":42,"./handsontableEditor.js":35}],32:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- CheckboxEditor: {get: function() {
- return CheckboxEditor;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_editors_46_js__,
- $___95_baseEditor_46_js__;
- var registerEditor = ($___46__46__47_editors_46_js__ = require("./../editors.js"), $___46__46__47_editors_46_js__ && $___46__46__47_editors_46_js__.__esModule && $___46__46__47_editors_46_js__ || {default: $___46__46__47_editors_46_js__}).registerEditor;
- var BaseEditor = ($___95_baseEditor_46_js__ = require("./_baseEditor.js"), $___95_baseEditor_46_js__ && $___95_baseEditor_46_js__.__esModule && $___95_baseEditor_46_js__ || {default: $___95_baseEditor_46_js__}).BaseEditor;
- var CheckboxEditor = BaseEditor.prototype.extend();
- ;
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.CheckboxEditor = CheckboxEditor;
- CheckboxEditor.prototype.beginEditing = function() {
- var checkbox = this.TD.querySelector('input[type="checkbox"]');
- if (checkbox) {
- checkbox.click();
- }
- };
- CheckboxEditor.prototype.finishEditing = function() {};
- CheckboxEditor.prototype.init = function() {};
- CheckboxEditor.prototype.open = function() {};
- CheckboxEditor.prototype.close = function() {};
- CheckboxEditor.prototype.getValue = function() {};
- CheckboxEditor.prototype.setValue = function() {};
- CheckboxEditor.prototype.focus = function() {};
- registerEditor('checkbox', CheckboxEditor);
-
- //#
- },{"./../editors.js":29,"./_baseEditor.js":30}],33:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- DateEditor: {get: function() {
- return DateEditor;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_helpers_46_js__,
- $___46__46__47_dom_46_js__,
- $___46__46__47_editors_46_js__,
- $__textEditor_46_js__,
- $___46__46__47_eventManager_46_js__,
- $__moment__,
- $__pikaday__;
- var helper = ($___46__46__47_helpers_46_js__ = require("./../helpers.js"), $___46__46__47_helpers_46_js__ && $___46__46__47_helpers_46_js__.__esModule && $___46__46__47_helpers_46_js__ || {default: $___46__46__47_helpers_46_js__});
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var $__0 = ($___46__46__47_editors_46_js__ = require("./../editors.js"), $___46__46__47_editors_46_js__ && $___46__46__47_editors_46_js__.__esModule && $___46__46__47_editors_46_js__ || {default: $___46__46__47_editors_46_js__}),
- getEditor = $__0.getEditor,
- registerEditor = $__0.registerEditor;
- var TextEditor = ($__textEditor_46_js__ = require("./textEditor.js"), $__textEditor_46_js__ && $__textEditor_46_js__.__esModule && $__textEditor_46_js__ || {default: $__textEditor_46_js__}).TextEditor;
- var eventManagerObject = ($___46__46__47_eventManager_46_js__ = require("./../eventManager.js"), $___46__46__47_eventManager_46_js__ && $___46__46__47_eventManager_46_js__.__esModule && $___46__46__47_eventManager_46_js__ || {default: $___46__46__47_eventManager_46_js__}).eventManager;
- var moment = ($__moment__ = require("moment"), $__moment__ && $__moment__.__esModule && $__moment__ || {default: $__moment__}).default;
- var Pikaday = ($__pikaday__ = require("pikaday"), $__pikaday__ && $__pikaday__.__esModule && $__pikaday__ || {default: $__pikaday__}).default;
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.DateEditor = DateEditor;
- var DateEditor = function DateEditor(hotInstance) {
- this.$datePicker = null;
- this.datePicker = null;
- this.datePickerStyle = null;
- this.defaultDateFormat = 'DD/MM/YYYY';
- this.isCellEdited = false;
- this.parentDestroyed = false;
- $traceurRuntime.superGet(this, $DateEditor.prototype, "constructor").call(this, hotInstance);
- };
- var $DateEditor = DateEditor;
- ($traceurRuntime.createClass)(DateEditor, {
- init: function() {
- var $__5 = this;
- if (typeof moment !== 'function') {
- throw new Error("You need to include moment.js to your project.");
- }
- if (typeof Pikaday !== 'function') {
- throw new Error("You need to include Pikaday to your project.");
- }
- $traceurRuntime.superGet(this, $DateEditor.prototype, "init").call(this);
- this.instance.addHook('afterDestroy', (function() {
- $__5.parentDestroyed = true;
- $__5.destroyElements();
- }));
- },
- createElements: function() {
- var $__5 = this;
- $traceurRuntime.superGet(this, $DateEditor.prototype, "createElements").call(this);
- this.datePicker = document.createElement('DIV');
- this.datePickerStyle = this.datePicker.style;
- this.datePickerStyle.position = 'absolute';
- this.datePickerStyle.top = 0;
- this.datePickerStyle.left = 0;
- this.datePickerStyle.zIndex = 9999;
- dom.addClass(this.datePicker, 'htDatepickerHolder');
- document.body.appendChild(this.datePicker);
- var htInput = this.TEXTAREA;
- var defaultOptions = {
- format: this.defaultDateFormat,
- field: htInput,
- trigger: htInput,
- container: this.datePicker,
- reposition: false,
- bound: false,
- onSelect: (function(dateStr) {
- if (!isNaN(dateStr.getTime())) {
- dateStr = moment(dateStr).format($__5.cellProperties.dateFormat || $__5.defaultDateFormat);
- }
- $__5.setValue(dateStr);
- $__5.hideDatepicker();
- }),
- onClose: (function() {
- if (!$__5.parentDestroyed) {
- $__5.finishEditing(false);
- }
- })
- };
- this.$datePicker = new Pikaday(defaultOptions);
- var eventManager = eventManagerObject(this);
- eventManager.addEventListener(this.datePicker, 'mousedown', (function(event) {
- helper.stopPropagation(event);
- }));
- this.hideDatepicker();
- },
- destroyElements: function() {
- this.$datePicker.destroy();
- },
- prepare: function(row, col, prop, td, originalValue, cellProperties) {
- this._opened = false;
- $traceurRuntime.superGet(this, $DateEditor.prototype, "prepare").call(this, row, col, prop, td, originalValue, cellProperties);
- },
- open: function() {
- var event = arguments[0] !== (void 0) ? arguments[0] : null;
- $traceurRuntime.superGet(this, $DateEditor.prototype, "open").call(this);
- this.showDatepicker(event);
- },
- close: function() {
- var $__5 = this;
- this._opened = false;
- this.instance._registerTimeout(setTimeout((function() {
- $__5.instance.selection.refreshBorders();
- }), 0));
- $traceurRuntime.superGet(this, $DateEditor.prototype, "close").call(this);
- },
- finishEditing: function() {
- var isCancelled = arguments[0] !== (void 0) ? arguments[0] : false;
- var ctrlDown = arguments[1] !== (void 0) ? arguments[1] : false;
- if (isCancelled) {
- var value = this.originalValue;
- if (value !== void 0) {
- this.setValue(value);
- }
- }
- this.hideDatepicker();
- $traceurRuntime.superGet(this, $DateEditor.prototype, "finishEditing").call(this, isCancelled, ctrlDown);
- },
- showDatepicker: function(event) {
- var offset = this.TD.getBoundingClientRect();
- var dateFormat = this.cellProperties.dateFormat || this.defaultDateFormat;
- var datePickerConfig = this.$datePicker.config();
- var dateStr;
- var isMouseDown = this.instance.view.isMouseDown();
- var isMeta = event ? helper.isMetaKey(event.keyCode) : false;
- this.datePickerStyle.top = (window.pageYOffset + offset.top + dom.outerHeight(this.TD)) + 'px';
- this.datePickerStyle.left = (window.pageXOffset + offset.left) + 'px';
- this.$datePicker._onInputFocus = function() {};
- datePickerConfig.format = dateFormat;
- if (this.originalValue) {
- dateStr = this.originalValue;
- if (moment(dateStr, dateFormat, true).isValid()) {
- this.$datePicker.setMoment(moment(dateStr, dateFormat), true);
- }
- if (!isMeta && !isMouseDown) {
- this.setValue('');
- }
- } else {
- if (this.cellProperties.defaultDate) {
- dateStr = this.cellProperties.defaultDate;
- datePickerConfig.defaultDate = dateStr;
- if (moment(dateStr, dateFormat, true).isValid()) {
- this.$datePicker.setMoment(moment(dateStr, dateFormat), true);
- }
- if (!isMeta && !isMouseDown) {
- this.setValue('');
- }
- } else {
- this.$datePicker.gotoToday();
- }
- }
- this.datePickerStyle.display = 'block';
- this.$datePicker.show();
- },
- hideDatepicker: function() {
- this.datePickerStyle.display = 'none';
- this.$datePicker.hide();
- }
- }, {}, TextEditor);
- ;
- registerEditor('date', DateEditor);
-
- //#
- },{"./../dom.js":27,"./../editors.js":29,"./../eventManager.js":41,"./../helpers.js":42,"./textEditor.js":40,"moment":"moment","pikaday":"pikaday"}],34:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- DropdownEditor: {get: function() {
- return DropdownEditor;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_editors_46_js__,
- $__autocompleteEditor_46_js__;
- var $__0 = ($___46__46__47_editors_46_js__ = require("./../editors.js"), $___46__46__47_editors_46_js__ && $___46__46__47_editors_46_js__.__esModule && $___46__46__47_editors_46_js__ || {default: $___46__46__47_editors_46_js__}),
- getEditor = $__0.getEditor,
- registerEditor = $__0.registerEditor;
- var AutocompleteEditor = ($__autocompleteEditor_46_js__ = require("./autocompleteEditor.js"), $__autocompleteEditor_46_js__ && $__autocompleteEditor_46_js__.__esModule && $__autocompleteEditor_46_js__ || {default: $__autocompleteEditor_46_js__}).AutocompleteEditor;
- var DropdownEditor = AutocompleteEditor.prototype.extend();
- ;
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.DropdownEditor = DropdownEditor;
- DropdownEditor.prototype.prepare = function() {
- AutocompleteEditor.prototype.prepare.apply(this, arguments);
- this.cellProperties.filter = false;
- this.cellProperties.strict = true;
- };
- registerEditor('dropdown', DropdownEditor);
-
- //#
- },{"./../editors.js":29,"./autocompleteEditor.js":31}],35:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- HandsontableEditor: {get: function() {
- return HandsontableEditor;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_helpers_46_js__,
- $___46__46__47_dom_46_js__,
- $___46__46__47_editors_46_js__,
- $__textEditor_46_js__;
- var helper = ($___46__46__47_helpers_46_js__ = require("./../helpers.js"), $___46__46__47_helpers_46_js__ && $___46__46__47_helpers_46_js__.__esModule && $___46__46__47_helpers_46_js__ || {default: $___46__46__47_helpers_46_js__});
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var $__0 = ($___46__46__47_editors_46_js__ = require("./../editors.js"), $___46__46__47_editors_46_js__ && $___46__46__47_editors_46_js__.__esModule && $___46__46__47_editors_46_js__ || {default: $___46__46__47_editors_46_js__}),
- getEditor = $__0.getEditor,
- registerEditor = $__0.registerEditor;
- var TextEditor = ($__textEditor_46_js__ = require("./textEditor.js"), $__textEditor_46_js__ && $__textEditor_46_js__.__esModule && $__textEditor_46_js__ || {default: $__textEditor_46_js__}).TextEditor;
- var HandsontableEditor = TextEditor.prototype.extend();
- ;
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.HandsontableEditor = HandsontableEditor;
- HandsontableEditor.prototype.createElements = function() {
- TextEditor.prototype.createElements.apply(this, arguments);
- var DIV = document.createElement('DIV');
- DIV.className = 'handsontableEditor';
- this.TEXTAREA_PARENT.appendChild(DIV);
- this.htContainer = DIV;
- this.htEditor = new Handsontable(DIV);
- this.assignHooks();
- };
- HandsontableEditor.prototype.prepare = function(td, row, col, prop, value, cellProperties) {
- TextEditor.prototype.prepare.apply(this, arguments);
- var parent = this;
- var options = {
- startRows: 0,
- startCols: 0,
- minRows: 0,
- minCols: 0,
- className: 'listbox',
- copyPaste: false,
- cells: function() {
- return {readOnly: true};
- },
- fillHandle: false,
- afterOnCellMouseDown: function() {
- var value = this.getValue();
- if (value !== void 0) {
- parent.setValue(value);
- }
- parent.instance.destroyEditor();
- }
- };
- if (this.cellProperties.handsontable) {
- helper.extend(options, cellProperties.handsontable);
- }
- if (this.htEditor) {
- this.htEditor.destroy();
- }
- this.htEditor = new Handsontable(this.htContainer, options);
- };
- var onBeforeKeyDown = function(event) {
- if (event != null && event.isImmediatePropagationEnabled == null) {
- event.stopImmediatePropagation = function() {
- this.isImmediatePropagationEnabled = false;
- this.cancelBubble = true;
- };
- event.isImmediatePropagationEnabled = true;
- event.isImmediatePropagationStopped = function() {
- return !this.isImmediatePropagationEnabled;
- };
- }
- if (event.isImmediatePropagationStopped()) {
- return;
- }
- var editor = this.getActiveEditor();
- var innerHOT = editor.htEditor.getInstance();
- var rowToSelect;
- if (event.keyCode == helper.keyCode.ARROW_DOWN) {
- if (!innerHOT.getSelected()) {
- rowToSelect = 0;
- } else {
- var selectedRow = innerHOT.getSelected()[0];
- var lastRow = innerHOT.countRows() - 1;
- rowToSelect = Math.min(lastRow, selectedRow + 1);
- }
- } else if (event.keyCode == helper.keyCode.ARROW_UP) {
- if (innerHOT.getSelected()) {
- var selectedRow = innerHOT.getSelected()[0];
- rowToSelect = selectedRow - 1;
- }
- }
- if (rowToSelect !== void 0) {
- if (rowToSelect < 0) {
- innerHOT.deselectCell();
- } else {
- innerHOT.selectCell(rowToSelect, 0);
- }
- event.preventDefault();
- event.stopImmediatePropagation();
- editor.instance.listen();
- editor.TEXTAREA.focus();
- }
- };
- HandsontableEditor.prototype.open = function() {
- this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
- TextEditor.prototype.open.apply(this, arguments);
- this.htEditor.render();
- if (this.cellProperties.strict) {
- this.htEditor.selectCell(0, 0);
- this.TEXTAREA.style.visibility = 'hidden';
- } else {
- this.htEditor.deselectCell();
- this.TEXTAREA.style.visibility = 'visible';
- }
- dom.setCaretPosition(this.TEXTAREA, 0, this.TEXTAREA.value.length);
- };
- HandsontableEditor.prototype.close = function() {
- this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
- this.instance.listen();
- TextEditor.prototype.close.apply(this, arguments);
- };
- HandsontableEditor.prototype.focus = function() {
- this.instance.listen();
- TextEditor.prototype.focus.apply(this, arguments);
- };
- HandsontableEditor.prototype.beginEditing = function(initialValue) {
- var onBeginEditing = this.instance.getSettings().onBeginEditing;
- if (onBeginEditing && onBeginEditing() === false) {
- return;
- }
- TextEditor.prototype.beginEditing.apply(this, arguments);
- };
- HandsontableEditor.prototype.finishEditing = function(isCancelled, ctrlDown) {
- if (this.htEditor.isListening()) {
- this.instance.listen();
- }
- if (this.htEditor.getSelected()) {
- var value = this.htEditor.getInstance().getValue();
- if (value !== void 0) {
- this.setValue(value);
- }
- }
- return TextEditor.prototype.finishEditing.apply(this, arguments);
- };
- HandsontableEditor.prototype.assignHooks = function() {
- var _this = this;
- this.instance.addHook('afterDestroy', function() {
- if (_this.htEditor) {
- _this.htEditor.destroy();
- }
- });
- };
- registerEditor('handsontable', HandsontableEditor);
-
- //#
- },{"./../dom.js":27,"./../editors.js":29,"./../helpers.js":42,"./textEditor.js":40}],36:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- MobileTextEditor: {get: function() {
- return MobileTextEditor;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_helpers_46_js__,
- $___46__46__47_dom_46_js__,
- $___46__46__47_editors_46_js__,
- $___95_baseEditor_46_js__,
- $___46__46__47_eventManager_46_js__;
- var helper = ($___46__46__47_helpers_46_js__ = require("./../helpers.js"), $___46__46__47_helpers_46_js__ && $___46__46__47_helpers_46_js__.__esModule && $___46__46__47_helpers_46_js__ || {default: $___46__46__47_helpers_46_js__});
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var $__0 = ($___46__46__47_editors_46_js__ = require("./../editors.js"), $___46__46__47_editors_46_js__ && $___46__46__47_editors_46_js__.__esModule && $___46__46__47_editors_46_js__ || {default: $___46__46__47_editors_46_js__}),
- getEditor = $__0.getEditor,
- registerEditor = $__0.registerEditor;
- var BaseEditor = ($___95_baseEditor_46_js__ = require("./_baseEditor.js"), $___95_baseEditor_46_js__ && $___95_baseEditor_46_js__.__esModule && $___95_baseEditor_46_js__ || {default: $___95_baseEditor_46_js__}).BaseEditor;
- var eventManagerObject = ($___46__46__47_eventManager_46_js__ = require("./../eventManager.js"), $___46__46__47_eventManager_46_js__ && $___46__46__47_eventManager_46_js__.__esModule && $___46__46__47_eventManager_46_js__ || {default: $___46__46__47_eventManager_46_js__}).eventManager;
- var MobileTextEditor = BaseEditor.prototype.extend(),
- domDimensionsCache = {};
- ;
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.MobileTextEditor = MobileTextEditor;
- var createControls = function() {
- this.controls = {};
- this.controls.leftButton = document.createElement('DIV');
- this.controls.leftButton.className = 'leftButton';
- this.controls.rightButton = document.createElement('DIV');
- this.controls.rightButton.className = 'rightButton';
- this.controls.upButton = document.createElement('DIV');
- this.controls.upButton.className = 'upButton';
- this.controls.downButton = document.createElement('DIV');
- this.controls.downButton.className = 'downButton';
- for (var button in this.controls) {
- if (this.controls.hasOwnProperty(button)) {
- this.positionControls.appendChild(this.controls[button]);
- }
- }
- };
- MobileTextEditor.prototype.valueChanged = function() {
- return this.initValue != this.getValue();
- };
- MobileTextEditor.prototype.init = function() {
- var that = this;
- this.eventManager = eventManagerObject(this.instance);
- this.createElements();
- this.bindEvents();
- this.instance.addHook('afterDestroy', function() {
- that.destroy();
- });
- };
- MobileTextEditor.prototype.getValue = function() {
- return this.TEXTAREA.value;
- };
- MobileTextEditor.prototype.setValue = function(newValue) {
- this.initValue = newValue;
- this.TEXTAREA.value = newValue;
- };
- MobileTextEditor.prototype.createElements = function() {
- this.editorContainer = document.createElement('DIV');
- this.editorContainer.className = "htMobileEditorContainer";
- this.cellPointer = document.createElement('DIV');
- this.cellPointer.className = "cellPointer";
- this.moveHandle = document.createElement('DIV');
- this.moveHandle.className = "moveHandle";
- this.inputPane = document.createElement('DIV');
- this.inputPane.className = "inputs";
- this.positionControls = document.createElement('DIV');
- this.positionControls.className = "positionControls";
- this.TEXTAREA = document.createElement('TEXTAREA');
- dom.addClass(this.TEXTAREA, 'handsontableInput');
- this.inputPane.appendChild(this.TEXTAREA);
- this.editorContainer.appendChild(this.cellPointer);
- this.editorContainer.appendChild(this.moveHandle);
- this.editorContainer.appendChild(this.inputPane);
- this.editorContainer.appendChild(this.positionControls);
- createControls.call(this);
- document.body.appendChild(this.editorContainer);
- };
- MobileTextEditor.prototype.onBeforeKeyDown = function(event) {
- var instance = this;
- var that = instance.getActiveEditor();
- dom.enableImmediatePropagation(event);
- if (event.target !== that.TEXTAREA || event.isImmediatePropagationStopped()) {
- return;
- }
- var keyCodes = helper.keyCode;
- switch (event.keyCode) {
- case keyCodes.ENTER:
- that.close();
- event.preventDefault();
- break;
- case keyCodes.BACKSPACE:
- event.stopImmediatePropagation();
- break;
- }
- };
- MobileTextEditor.prototype.open = function() {
- this.instance.addHook('beforeKeyDown', this.onBeforeKeyDown);
- dom.addClass(this.editorContainer, 'active');
- dom.removeClass(this.cellPointer, 'hidden');
- this.updateEditorPosition();
- };
- MobileTextEditor.prototype.focus = function() {
- this.TEXTAREA.focus();
- dom.setCaretPosition(this.TEXTAREA, this.TEXTAREA.value.length);
- };
- MobileTextEditor.prototype.close = function() {
- this.TEXTAREA.blur();
- this.instance.removeHook('beforeKeyDown', this.onBeforeKeyDown);
- dom.removeClass(this.editorContainer, 'active');
- };
- MobileTextEditor.prototype.scrollToView = function() {
- var coords = this.instance.getSelectedRange().highlight;
- this.instance.view.scrollViewport(coords);
- };
- MobileTextEditor.prototype.hideCellPointer = function() {
- if (!dom.hasClass(this.cellPointer, 'hidden')) {
- dom.addClass(this.cellPointer, 'hidden');
- }
- };
- MobileTextEditor.prototype.updateEditorPosition = function(x, y) {
- if (x && y) {
- x = parseInt(x, 10);
- y = parseInt(y, 10);
- this.editorContainer.style.top = y + "px";
- this.editorContainer.style.left = x + "px";
- } else {
- var selection = this.instance.getSelected(),
- selectedCell = this.instance.getCell(selection[0], selection[1]);
- if (!domDimensionsCache.cellPointer) {
- domDimensionsCache.cellPointer = {
- height: dom.outerHeight(this.cellPointer),
- width: dom.outerWidth(this.cellPointer)
- };
- }
- if (!domDimensionsCache.editorContainer) {
- domDimensionsCache.editorContainer = {width: dom.outerWidth(this.editorContainer)};
- }
- if (selectedCell !== undefined) {
- var scrollLeft = this.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer == window ? 0 : dom.getScrollLeft(this.instance.view.wt.wtOverlays.leftOverlay.holder);
- var scrollTop = this.instance.view.wt.wtOverlays.topOverlay.trimmingContainer == window ? 0 : dom.getScrollTop(this.instance.view.wt.wtOverlays.topOverlay.holder);
- var selectedCellOffset = dom.offset(selectedCell),
- selectedCellWidth = dom.outerWidth(selectedCell),
- currentScrollPosition = {
- x: scrollLeft,
- y: scrollTop
- };
- this.editorContainer.style.top = parseInt(selectedCellOffset.top + dom.outerHeight(selectedCell) - currentScrollPosition.y + domDimensionsCache.cellPointer.height, 10) + "px";
- this.editorContainer.style.left = parseInt((window.innerWidth / 2) - (domDimensionsCache.editorContainer.width / 2), 10) + "px";
- if (selectedCellOffset.left + selectedCellWidth / 2 > parseInt(this.editorContainer.style.left, 10) + domDimensionsCache.editorContainer.width) {
- this.editorContainer.style.left = window.innerWidth - domDimensionsCache.editorContainer.width + "px";
- } else if (selectedCellOffset.left + selectedCellWidth / 2 < parseInt(this.editorContainer.style.left, 10) + 20) {
- this.editorContainer.style.left = 0 + "px";
- }
- this.cellPointer.style.left = parseInt(selectedCellOffset.left - (domDimensionsCache.cellPointer.width / 2) - dom.offset(this.editorContainer).left + (selectedCellWidth / 2) - currentScrollPosition.x, 10) + "px";
- }
- }
- };
- MobileTextEditor.prototype.updateEditorData = function() {
- var selected = this.instance.getSelected(),
- selectedValue = this.instance.getDataAtCell(selected[0], selected[1]);
- this.row = selected[0];
- this.col = selected[1];
- this.setValue(selectedValue);
- this.updateEditorPosition();
- };
- MobileTextEditor.prototype.prepareAndSave = function() {
- var val;
- if (!this.valueChanged()) {
- return true;
- }
- if (this.instance.getSettings().trimWhitespace) {
- val = [[String.prototype.trim.call(this.getValue())]];
- } else {
- val = [[this.getValue()]];
- }
- this.saveValue(val);
- };
- MobileTextEditor.prototype.bindEvents = function() {
- var that = this;
- this.eventManager.addEventListener(this.controls.leftButton, "touchend", function(event) {
- that.prepareAndSave();
- that.instance.selection.transformStart(0, -1, null, true);
- that.updateEditorData();
- event.preventDefault();
- });
- this.eventManager.addEventListener(this.controls.rightButton, "touchend", function(event) {
- that.prepareAndSave();
- that.instance.selection.transformStart(0, 1, null, true);
- that.updateEditorData();
- event.preventDefault();
- });
- this.eventManager.addEventListener(this.controls.upButton, "touchend", function(event) {
- that.prepareAndSave();
- that.instance.selection.transformStart(-1, 0, null, true);
- that.updateEditorData();
- event.preventDefault();
- });
- this.eventManager.addEventListener(this.controls.downButton, "touchend", function(event) {
- that.prepareAndSave();
- that.instance.selection.transformStart(1, 0, null, true);
- that.updateEditorData();
- event.preventDefault();
- });
- this.eventManager.addEventListener(this.moveHandle, "touchstart", function(event) {
- if (event.touches.length == 1) {
- var touch = event.touches[0],
- onTouchPosition = {
- x: that.editorContainer.offsetLeft,
- y: that.editorContainer.offsetTop
- },
- onTouchOffset = {
- x: touch.pageX - onTouchPosition.x,
- y: touch.pageY - onTouchPosition.y
- };
- that.eventManager.addEventListener(this, "touchmove", function(event) {
- var touch = event.touches[0];
- that.updateEditorPosition(touch.pageX - onTouchOffset.x, touch.pageY - onTouchOffset.y);
- that.hideCellPointer();
- event.preventDefault();
- });
- }
- });
- this.eventManager.addEventListener(document.body, "touchend", function(event) {
- if (!dom.isChildOf(event.target, that.editorContainer) && !dom.isChildOf(event.target, that.instance.rootElement)) {
- that.close();
- }
- });
- this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.leftOverlay.holder, "scroll", function(event) {
- if (that.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer != window) {
- that.hideCellPointer();
- }
- });
- this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.topOverlay.holder, "scroll", function(event) {
- if (that.instance.view.wt.wtOverlays.topOverlay.trimmingContainer != window) {
- that.hideCellPointer();
- }
- });
- };
- MobileTextEditor.prototype.destroy = function() {
- this.eventManager.clear();
- this.editorContainer.parentNode.removeChild(this.editorContainer);
- };
- registerEditor('mobile', MobileTextEditor);
-
- //#
- },{"./../dom.js":27,"./../editors.js":29,"./../eventManager.js":41,"./../helpers.js":42,"./_baseEditor.js":30}],37:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- NumericEditor: {get: function() {
- return NumericEditor;
- }},
- __esModule: {value: true}
- });
- var $__numeral__,
- $___46__46__47_editors_46_js__,
- $__textEditor_46_js__;
- var numeral = ($__numeral__ = require("numeral"), $__numeral__ && $__numeral__.__esModule && $__numeral__ || {default: $__numeral__}).default;
- var $__1 = ($___46__46__47_editors_46_js__ = require("./../editors.js"), $___46__46__47_editors_46_js__ && $___46__46__47_editors_46_js__.__esModule && $___46__46__47_editors_46_js__ || {default: $___46__46__47_editors_46_js__}),
- getEditor = $__1.getEditor,
- registerEditor = $__1.registerEditor;
- var TextEditor = ($__textEditor_46_js__ = require("./textEditor.js"), $__textEditor_46_js__ && $__textEditor_46_js__.__esModule && $__textEditor_46_js__ || {default: $__textEditor_46_js__}).TextEditor;
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.NumericEditor = NumericEditor;
- var NumericEditor = function NumericEditor() {
- $traceurRuntime.superConstructor($NumericEditor).apply(this, arguments);
- };
- var $NumericEditor = NumericEditor;
- ($traceurRuntime.createClass)(NumericEditor, {beginEditing: function(initialValue) {
- if (typeof(initialValue) === 'undefined' && this.originalValue) {
- if (typeof this.cellProperties.language !== 'undefined') {
- numeral.language(this.cellProperties.language);
- }
- var decimalDelimiter = numeral.languageData().delimiters.decimal;
- initialValue = ('' + this.originalValue).replace('.', decimalDelimiter);
- }
- $traceurRuntime.superGet(this, $NumericEditor.prototype, "beginEditing").call(this, initialValue);
- }}, {}, TextEditor);
- ;
- registerEditor('numeric', NumericEditor);
-
- //#
- },{"./../editors.js":29,"./textEditor.js":40,"numeral":"numeral"}],38:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- PasswordEditor: {get: function() {
- return PasswordEditor;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_dom_46_js__,
- $___46__46__47_editors_46_js__,
- $__textEditor_46_js__;
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var $__0 = ($___46__46__47_editors_46_js__ = require("./../editors.js"), $___46__46__47_editors_46_js__ && $___46__46__47_editors_46_js__.__esModule && $___46__46__47_editors_46_js__ || {default: $___46__46__47_editors_46_js__}),
- getEditor = $__0.getEditor,
- registerEditor = $__0.registerEditor;
- var TextEditor = ($__textEditor_46_js__ = require("./textEditor.js"), $__textEditor_46_js__ && $__textEditor_46_js__.__esModule && $__textEditor_46_js__ || {default: $__textEditor_46_js__}).TextEditor;
- var PasswordEditor = TextEditor.prototype.extend();
- ;
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.PasswordEditor = PasswordEditor;
- PasswordEditor.prototype.createElements = function() {
- TextEditor.prototype.createElements.apply(this, arguments);
- this.TEXTAREA = document.createElement('input');
- this.TEXTAREA.setAttribute('type', 'password');
- this.TEXTAREA.className = 'handsontableInput';
- this.textareaStyle = this.TEXTAREA.style;
- this.textareaStyle.width = 0;
- this.textareaStyle.height = 0;
- dom.empty(this.TEXTAREA_PARENT);
- this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
- };
- registerEditor('password', PasswordEditor);
-
- //#
- },{"./../dom.js":27,"./../editors.js":29,"./textEditor.js":40}],39:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- SelectEditor: {get: function() {
- return SelectEditor;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_dom_46_js__,
- $___46__46__47_helpers_46_js__,
- $___46__46__47_editors_46_js__,
- $___95_baseEditor_46_js__;
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var helper = ($___46__46__47_helpers_46_js__ = require("./../helpers.js"), $___46__46__47_helpers_46_js__ && $___46__46__47_helpers_46_js__.__esModule && $___46__46__47_helpers_46_js__ || {default: $___46__46__47_helpers_46_js__});
- var $__0 = ($___46__46__47_editors_46_js__ = require("./../editors.js"), $___46__46__47_editors_46_js__ && $___46__46__47_editors_46_js__.__esModule && $___46__46__47_editors_46_js__ || {default: $___46__46__47_editors_46_js__}),
- getEditor = $__0.getEditor,
- registerEditor = $__0.registerEditor;
- var BaseEditor = ($___95_baseEditor_46_js__ = require("./_baseEditor.js"), $___95_baseEditor_46_js__ && $___95_baseEditor_46_js__.__esModule && $___95_baseEditor_46_js__ || {default: $___95_baseEditor_46_js__}).BaseEditor;
- var SelectEditor = BaseEditor.prototype.extend();
- ;
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.SelectEditor = SelectEditor;
- SelectEditor.prototype.init = function() {
- this.select = document.createElement('SELECT');
- dom.addClass(this.select, 'htSelectEditor');
- this.select.style.display = 'none';
- this.instance.rootElement.appendChild(this.select);
- };
- SelectEditor.prototype.prepare = function() {
- BaseEditor.prototype.prepare.apply(this, arguments);
- var selectOptions = this.cellProperties.selectOptions;
- var options;
- if (typeof selectOptions == 'function') {
- options = this.prepareOptions(selectOptions(this.row, this.col, this.prop));
- } else {
- options = this.prepareOptions(selectOptions);
- }
- dom.empty(this.select);
- for (var option in options) {
- if (options.hasOwnProperty(option)) {
- var optionElement = document.createElement('OPTION');
- optionElement.value = option;
- dom.fastInnerHTML(optionElement, options[option]);
- this.select.appendChild(optionElement);
- }
- }
- };
- SelectEditor.prototype.prepareOptions = function(optionsToPrepare) {
- var preparedOptions = {};
- if (Array.isArray(optionsToPrepare)) {
- for (var i = 0,
- len = optionsToPrepare.length; i < len; i++) {
- preparedOptions[optionsToPrepare[i]] = optionsToPrepare[i];
- }
- } else if (typeof optionsToPrepare == 'object') {
- preparedOptions = optionsToPrepare;
- }
- return preparedOptions;
- };
- SelectEditor.prototype.getValue = function() {
- return this.select.value;
- };
- SelectEditor.prototype.setValue = function(value) {
- this.select.value = value;
- };
- var onBeforeKeyDown = function(event) {
- var instance = this;
- var editor = instance.getActiveEditor();
- if (event != null && event.isImmediatePropagationEnabled == null) {
- event.stopImmediatePropagation = function() {
- this.isImmediatePropagationEnabled = false;
- };
- event.isImmediatePropagationEnabled = true;
- event.isImmediatePropagationStopped = function() {
- return !this.isImmediatePropagationEnabled;
- };
- }
- switch (event.keyCode) {
- case helper.keyCode.ARROW_UP:
- var previousOptionIndex = editor.select.selectedIndex - 1;
- if (previousOptionIndex >= 0) {
- editor.select[previousOptionIndex].selected = true;
- }
- event.stopImmediatePropagation();
- event.preventDefault();
- break;
- case helper.keyCode.ARROW_DOWN:
- var nextOptionIndex = editor.select.selectedIndex + 1;
- if (nextOptionIndex <= editor.select.length - 1) {
- editor.select[nextOptionIndex].selected = true;
- }
- event.stopImmediatePropagation();
- event.preventDefault();
- break;
- }
- };
- SelectEditor.prototype.checkEditorSection = function() {
- if (this.row < this.instance.getSettings().fixedRowsTop) {
- if (this.col < this.instance.getSettings().fixedColumnsLeft) {
- return 'corner';
- } else {
- return 'top';
- }
- } else {
- if (this.col < this.instance.getSettings().fixedColumnsLeft) {
- return 'left';
- }
- }
- };
- SelectEditor.prototype.open = function() {
- var width = dom.outerWidth(this.TD);
- var height = dom.outerHeight(this.TD);
- var rootOffset = dom.offset(this.instance.rootElement);
- var tdOffset = dom.offset(this.TD);
- var editorSection = this.checkEditorSection();
- var cssTransformOffset;
- switch (editorSection) {
- case 'top':
- cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
- break;
- case 'left':
- cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
- break;
- case 'corner':
- cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
- break;
- }
- var selectStyle = this.select.style;
- if (cssTransformOffset && cssTransformOffset != -1) {
- selectStyle[cssTransformOffset[0]] = cssTransformOffset[1];
- } else {
- dom.resetCssTransform(this.select);
- }
- selectStyle.height = height + 'px';
- selectStyle.minWidth = width + 'px';
- selectStyle.top = tdOffset.top - rootOffset.top + 'px';
- selectStyle.left = tdOffset.left - rootOffset.left + 'px';
- selectStyle.margin = '0px';
- selectStyle.display = '';
- this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
- };
- SelectEditor.prototype.close = function() {
- this.select.style.display = 'none';
- this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
- };
- SelectEditor.prototype.focus = function() {
- this.select.focus();
- };
- registerEditor('select', SelectEditor);
-
- //#
- },{"./../dom.js":27,"./../editors.js":29,"./../helpers.js":42,"./_baseEditor.js":30}],40:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- TextEditor: {get: function() {
- return TextEditor;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_dom_46_js__,
- $___46__46__47_helpers_46_js__,
- $__autoResize__,
- $___95_baseEditor_46_js__,
- $___46__46__47_eventManager_46_js__,
- $___46__46__47_editors_46_js__;
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var helper = ($___46__46__47_helpers_46_js__ = require("./../helpers.js"), $___46__46__47_helpers_46_js__ && $___46__46__47_helpers_46_js__.__esModule && $___46__46__47_helpers_46_js__ || {default: $___46__46__47_helpers_46_js__});
- var autoResize = ($__autoResize__ = require("autoResize"), $__autoResize__ && $__autoResize__.__esModule && $__autoResize__ || {default: $__autoResize__}).default;
- var BaseEditor = ($___95_baseEditor_46_js__ = require("./_baseEditor.js"), $___95_baseEditor_46_js__ && $___95_baseEditor_46_js__.__esModule && $___95_baseEditor_46_js__ || {default: $___95_baseEditor_46_js__}).BaseEditor;
- var eventManagerObject = ($___46__46__47_eventManager_46_js__ = require("./../eventManager.js"), $___46__46__47_eventManager_46_js__ && $___46__46__47_eventManager_46_js__.__esModule && $___46__46__47_eventManager_46_js__ || {default: $___46__46__47_eventManager_46_js__}).eventManager;
- var $__3 = ($___46__46__47_editors_46_js__ = require("./../editors.js"), $___46__46__47_editors_46_js__ && $___46__46__47_editors_46_js__.__esModule && $___46__46__47_editors_46_js__ || {default: $___46__46__47_editors_46_js__}),
- getEditor = $__3.getEditor,
- registerEditor = $__3.registerEditor;
- var TextEditor = BaseEditor.prototype.extend();
- ;
- Handsontable.editors = Handsontable.editors || {};
- Handsontable.editors.TextEditor = TextEditor;
- TextEditor.prototype.init = function() {
- var that = this;
- this.createElements();
- this.eventManager = eventManagerObject(this);
- this.bindEvents();
- this.autoResize = autoResize();
- this.instance.addHook('afterDestroy', function() {
- that.destroy();
- });
- };
- TextEditor.prototype.getValue = function() {
- return this.TEXTAREA.value;
- };
- TextEditor.prototype.setValue = function(newValue) {
- this.TEXTAREA.value = newValue;
- };
- var onBeforeKeyDown = function onBeforeKeyDown(event) {
- var instance = this,
- that = instance.getActiveEditor(),
- keyCodes,
- ctrlDown;
- keyCodes = helper.keyCode;
- ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
- dom.enableImmediatePropagation(event);
- if (event.target !== that.TEXTAREA || event.isImmediatePropagationStopped()) {
- return;
- }
- if (event.keyCode === 17 || event.keyCode === 224 || event.keyCode === 91 || event.keyCode === 93) {
- event.stopImmediatePropagation();
- return;
- }
- switch (event.keyCode) {
- case keyCodes.ARROW_RIGHT:
- case keyCodes.ARROW_LEFT:
- case keyCodes.ARROW_UP:
- case keyCodes.ARROW_DOWN:
- if (!that.isWaiting()) {
- event.stopImmediatePropagation();
- }
- break;
- case keyCodes.ENTER:
- var selected = that.instance.getSelected();
- var isMultipleSelection = !(selected[0] === selected[2] && selected[1] === selected[3]);
- if ((ctrlDown && !isMultipleSelection) || event.altKey) {
- if (that.isOpened()) {
- var caretPosition = dom.getCaretPosition(that.TEXTAREA),
- value = that.getValue();
- var newValue = value.slice(0, caretPosition) + '\n' + value.slice(caretPosition);
- that.setValue(newValue);
- dom.setCaretPosition(that.TEXTAREA, caretPosition + 1);
- } else {
- that.beginEditing(that.originalValue + '\n');
- }
- event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- case keyCodes.A:
- case keyCodes.X:
- case keyCodes.C:
- case keyCodes.V:
- if (ctrlDown) {
- event.stopImmediatePropagation();
- }
- break;
- case keyCodes.BACKSPACE:
- case keyCodes.DELETE:
- case keyCodes.HOME:
- case keyCodes.END:
- event.stopImmediatePropagation();
- break;
- }
- that.autoResize.resize(String.fromCharCode(event.keyCode));
- };
- TextEditor.prototype.open = function() {
- this.refreshDimensions();
- this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
- };
- TextEditor.prototype.close = function() {
- this.textareaParentStyle.display = 'none';
- this.autoResize.unObserve();
- if (document.activeElement === this.TEXTAREA) {
- this.instance.listen();
- }
- this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
- };
- TextEditor.prototype.focus = function() {
- this.TEXTAREA.focus();
- dom.setCaretPosition(this.TEXTAREA, this.TEXTAREA.value.length);
- };
- TextEditor.prototype.createElements = function() {
- this.TEXTAREA = document.createElement('TEXTAREA');
- dom.addClass(this.TEXTAREA, 'handsontableInput');
- this.textareaStyle = this.TEXTAREA.style;
- this.textareaStyle.width = 0;
- this.textareaStyle.height = 0;
- this.TEXTAREA_PARENT = document.createElement('DIV');
- dom.addClass(this.TEXTAREA_PARENT, 'handsontableInputHolder');
- this.textareaParentStyle = this.TEXTAREA_PARENT.style;
- this.textareaParentStyle.top = 0;
- this.textareaParentStyle.left = 0;
- this.textareaParentStyle.display = 'none';
- this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
- this.instance.rootElement.appendChild(this.TEXTAREA_PARENT);
- var that = this;
- this.instance._registerTimeout(setTimeout(function() {
- that.refreshDimensions();
- }, 0));
- };
- TextEditor.prototype.checkEditorSection = function() {
- if (this.row < this.instance.getSettings().fixedRowsTop) {
- if (this.col < this.instance.getSettings().fixedColumnsLeft) {
- return 'corner';
- } else {
- return 'top';
- }
- } else {
- if (this.col < this.instance.getSettings().fixedColumnsLeft) {
- return 'left';
- }
- }
- };
- TextEditor.prototype.getEditedCell = function() {
- var editorSection = this.checkEditorSection(),
- editedCell;
- switch (editorSection) {
- case 'top':
- editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
- row: this.row,
- col: this.col
- });
- this.textareaParentStyle.zIndex = 101;
- break;
- case 'corner':
- editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
- row: this.row,
- col: this.col
- });
- this.textareaParentStyle.zIndex = 103;
- break;
- case 'left':
- editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
- row: this.row,
- col: this.col
- });
- this.textareaParentStyle.zIndex = 102;
- break;
- default:
- editedCell = this.instance.getCell(this.row, this.col);
- this.textareaParentStyle.zIndex = "";
- break;
- }
- return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
- };
- TextEditor.prototype.refreshDimensions = function() {
- if (this.state !== Handsontable.EditorState.EDITING) {
- return;
- }
- this.TD = this.getEditedCell();
- if (!this.TD) {
- return;
- }
- var currentOffset = dom.offset(this.TD),
- containerOffset = dom.offset(this.instance.rootElement),
- scrollableContainer = dom.getScrollableElement(this.TD),
- editTop = currentOffset.top - containerOffset.top - 1 - (scrollableContainer.scrollTop || 0),
- editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0),
- settings = this.instance.getSettings(),
- rowHeadersCount = settings.rowHeaders ? 1 : 0,
- colHeadersCount = settings.colHeaders ? 1 : 0,
- editorSection = this.checkEditorSection(),
- backgroundColor = this.TD.style.backgroundColor,
- cssTransformOffset;
- switch (editorSection) {
- case 'top':
- cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
- break;
- case 'left':
- cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
- break;
- case 'corner':
- cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
- break;
- }
- if (editTop < 0) {
- editTop = 0;
- }
- if (editLeft < 0) {
- editLeft = 0;
- }
- if (colHeadersCount && this.instance.getSelected()[0] === 0) {
- editTop += 1;
- }
- if (rowHeadersCount && this.instance.getSelected()[1] === 0) {
- editLeft += 1;
- }
- if (cssTransformOffset && cssTransformOffset != -1) {
- this.textareaParentStyle[cssTransformOffset[0]] = cssTransformOffset[1];
- } else {
- dom.resetCssTransform(this.textareaParentStyle);
- }
- this.textareaParentStyle.top = editTop + 'px';
- this.textareaParentStyle.left = editLeft + 'px';
- var cellTopOffset = this.TD.offsetTop - this.instance.view.wt.wtOverlays.topOverlay.getScrollPosition(),
- cellLeftOffset = this.TD.offsetLeft - this.instance.view.wt.wtOverlays.leftOverlay.getScrollPosition();
- var width = dom.innerWidth(this.TD) - 8,
- maxWidth = this.instance.view.maximumVisibleElementWidth(cellLeftOffset) - 10,
- height = this.TD.scrollHeight + 1,
- maxHeight = this.instance.view.maximumVisibleElementHeight(cellTopOffset) - 2;
- if (parseInt(this.TD.style.borderTopWidth, 10) > 0) {
- height -= 1;
- }
- if (parseInt(this.TD.style.borderLeftWidth, 10) > 0) {
- if (rowHeadersCount > 0) {
- width -= 1;
- }
- }
- this.TEXTAREA.style.fontSize = dom.getComputedStyle(this.TD).fontSize;
- this.TEXTAREA.style.fontFamily = dom.getComputedStyle(this.TD).fontFamily;
- this.TEXTAREA.style.backgroundColor = '';
- this.TEXTAREA.style.backgroundColor = backgroundColor ? backgroundColor : dom.getComputedStyle(this.TEXTAREA).backgroundColor;
- this.autoResize.init(this.TEXTAREA, {
- minHeight: Math.min(height, maxHeight),
- maxHeight: maxHeight,
- minWidth: Math.min(width, maxWidth),
- maxWidth: maxWidth
- }, true);
- this.textareaParentStyle.display = 'block';
- };
- TextEditor.prototype.bindEvents = function() {
- var editor = this;
- this.eventManager.addEventListener(this.TEXTAREA, 'cut', function(event) {
- helper.stopPropagation(event);
- });
- this.eventManager.addEventListener(this.TEXTAREA, 'paste', function(event) {
- helper.stopPropagation(event);
- });
- this.instance.addHook('afterScrollVertically', function() {
- editor.refreshDimensions();
- });
- this.instance.addHook('afterColumnResize', function() {
- editor.refreshDimensions();
- editor.focus();
- });
- this.instance.addHook('afterRowResize', function() {
- editor.refreshDimensions();
- editor.focus();
- });
- this.instance.addHook('afterDestroy', function() {
- editor.eventManager.clear();
- });
- };
- TextEditor.prototype.destroy = function() {
- this.eventManager.clear();
- };
- registerEditor('text', TextEditor);
-
- //#
- },{"./../dom.js":27,"./../editors.js":29,"./../eventManager.js":41,"./../helpers.js":42,"./_baseEditor.js":30,"autoResize":"autoResize"}],41:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- EventManager: {get: function() {
- return EventManager;
- }},
- eventManager: {get: function() {
- return eventManager;
- }},
- __esModule: {value: true}
- });
- var $__dom_46_js__;
- var dom = ($__dom_46_js__ = require("./dom.js"), $__dom_46_js__ && $__dom_46_js__.__esModule && $__dom_46_js__ || {default: $__dom_46_js__});
- var EventManager = function EventManager() {
- var context = arguments[0] !== (void 0) ? arguments[0] : null;
- this.context = context || this;
- if (!this.context.eventListeners) {
- this.context.eventListeners = [];
- }
- };
- ($traceurRuntime.createClass)(EventManager, {
- addEventListener: function(element, eventName, callback) {
- var $__0 = this;
- var context = this.context;
- function callbackProxy(event) {
- if (event.target == void 0 && event.srcElement != void 0) {
- if (event.definePoperty) {
- event.definePoperty('target', {value: event.srcElement});
- } else {
- event.target = event.srcElement;
- }
- }
- if (event.preventDefault == void 0) {
- if (event.definePoperty) {
- event.definePoperty('preventDefault', {value: function() {
- this.returnValue = false;
- }});
- } else {
- event.preventDefault = function() {
- this.returnValue = false;
- };
- }
- }
- event = extendEvent(context, event);
- callback.call(this, event);
- }
- this.context.eventListeners.push({
- element: element,
- event: eventName,
- callback: callback,
- callbackProxy: callbackProxy
- });
- if (window.addEventListener) {
- element.addEventListener(eventName, callbackProxy, false);
- } else {
- element.attachEvent('on' + eventName, callbackProxy);
- }
- Handsontable.countEventManagerListeners++;
- return (function() {
- $__0.removeEventListener(element, eventName, callback);
- });
- },
- removeEventListener: function(element, eventName, callback) {
- var len = this.context.eventListeners.length;
- var tmpEvent;
- while (len--) {
- tmpEvent = this.context.eventListeners[len];
- if (tmpEvent.event == eventName && tmpEvent.element == element) {
- if (callback && callback != tmpEvent.callback) {
- continue;
- }
- this.context.eventListeners.splice(len, 1);
- if (tmpEvent.element.removeEventListener) {
- tmpEvent.element.removeEventListener(tmpEvent.event, tmpEvent.callbackProxy, false);
- } else {
- tmpEvent.element.detachEvent('on' + tmpEvent.event, tmpEvent.callbackProxy);
- }
- Handsontable.countEventManagerListeners--;
- }
- }
- },
- clearEvents: function() {
- var len = this.context.eventListeners.length;
- while (len--) {
- var event = this.context.eventListeners[len];
- if (event) {
- this.removeEventListener(event.element, event.event, event.callback);
- }
- }
- },
- clear: function() {
- this.clearEvents();
- },
- fireEvent: function(element, eventName) {
- var options = {
- bubbles: true,
- cancelable: (eventName !== 'mousemove'),
- view: window,
- detail: 0,
- screenX: 0,
- screenY: 0,
- clientX: 1,
- clientY: 1,
- ctrlKey: false,
- altKey: false,
- shiftKey: false,
- metaKey: false,
- button: 0,
- relatedTarget: undefined
- };
- var event;
- if (document.createEvent) {
- event = document.createEvent('MouseEvents');
- 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);
- } else {
- event = document.createEventObject();
- }
- if (element.dispatchEvent) {
- element.dispatchEvent(event);
- } else {
- element.fireEvent('on' + eventName, event);
- }
- }
- }, {});
- function extendEvent(context, event) {
- var componentName = 'HOT-TABLE';
- var isHotTableSpotted;
- var fromElement;
- var realTarget;
- var target;
- var len;
- event.isTargetWebComponent = false;
- event.realTarget = event.target;
- if (!Handsontable.eventManager.isHotTableEnv) {
- return event;
- }
- event = dom.polymerWrap(event);
- len = event.path ? event.path.length : 0;
- while (len--) {
- if (event.path[len].nodeName === componentName) {
- isHotTableSpotted = true;
- } else if (isHotTableSpotted && event.path[len].shadowRoot) {
- target = event.path[len];
- break;
- }
- if (len === 0 && !target) {
- target = event.path[len];
- }
- }
- if (!target) {
- target = event.target;
- }
- event.isTargetWebComponent = true;
- if (dom.isWebComponentSupportedNatively()) {
- event.realTarget = event.srcElement || event.toElement;
- } else if (context instanceof Handsontable.Core || context instanceof Walkontable) {
- if (context instanceof Handsontable.Core) {
- fromElement = context.view.wt.wtTable.TABLE;
- } else if (context instanceof Walkontable) {
- fromElement = context.wtTable.TABLE.parentNode.parentNode;
- }
- realTarget = dom.closest(event.target, [componentName], fromElement);
- if (realTarget) {
- event.realTarget = fromElement.querySelector(componentName) || event.target;
- } else {
- event.realTarget = event.target;
- }
- }
- Object.defineProperty(event, 'target', {
- get: function() {
- return dom.polymerWrap(target);
- },
- enumerable: true,
- configurable: true
- });
- return event;
- }
- ;
- window.Handsontable = window.Handsontable || {};
- Handsontable.countEventManagerListeners = 0;
- Handsontable.eventManager = eventManager;
- function eventManager(context) {
- return new EventManager(context);
- }
-
- //#
- },{"./dom.js":27}],42:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- isPrintableChar: {get: function() {
- return isPrintableChar;
- }},
- isMetaKey: {get: function() {
- return isMetaKey;
- }},
- isCtrlKey: {get: function() {
- return isCtrlKey;
- }},
- stringify: {get: function() {
- return stringify;
- }},
- toUpperCaseFirst: {get: function() {
- return toUpperCaseFirst;
- }},
- equalsIgnoreCase: {get: function() {
- return equalsIgnoreCase;
- }},
- duckSchema: {get: function() {
- return duckSchema;
- }},
- spreadsheetColumnLabel: {get: function() {
- return spreadsheetColumnLabel;
- }},
- createSpreadsheetData: {get: function() {
- return createSpreadsheetData;
- }},
- createSpreadsheetObjectData: {get: function() {
- return createSpreadsheetObjectData;
- }},
- isNumeric: {get: function() {
- return isNumeric;
- }},
- randomString: {get: function() {
- return randomString;
- }},
- inherit: {get: function() {
- return inherit;
- }},
- extend: {get: function() {
- return extend;
- }},
- deepExtend: {get: function() {
- return deepExtend;
- }},
- deepClone: {get: function() {
- return deepClone;
- }},
- isObjectEquals: {get: function() {
- return isObjectEquals;
- }},
- getPrototypeOf: {get: function() {
- return getPrototypeOf;
- }},
- columnFactory: {get: function() {
- return columnFactory;
- }},
- translateRowsToColumns: {get: function() {
- return translateRowsToColumns;
- }},
- to2dArray: {get: function() {
- return to2dArray;
- }},
- extendArray: {get: function() {
- return extendArray;
- }},
- isInput: {get: function() {
- return isInput;
- }},
- isOutsideInput: {get: function() {
- return isOutsideInput;
- }},
- keyCode: {get: function() {
- return keyCode;
- }},
- isObject: {get: function() {
- return isObject;
- }},
- pivot: {get: function() {
- return pivot;
- }},
- proxy: {get: function() {
- return proxy;
- }},
- cellMethodLookupFactory: {get: function() {
- return cellMethodLookupFactory;
- }},
- isMobileBrowser: {get: function() {
- return isMobileBrowser;
- }},
- isTouchSupported: {get: function() {
- return isTouchSupported;
- }},
- stopPropagation: {get: function() {
- return stopPropagation;
- }},
- pageX: {get: function() {
- return pageX;
- }},
- pageY: {get: function() {
- return pageY;
- }},
- defineGetter: {get: function() {
- return defineGetter;
- }},
- requestAnimationFrame: {get: function() {
- return requestAnimationFrame;
- }},
- cancelAnimationFrame: {get: function() {
- return cancelAnimationFrame;
- }},
- __esModule: {value: true}
- });
- var $__dom_46_js__;
- var dom = ($__dom_46_js__ = require("./dom.js"), $__dom_46_js__ && $__dom_46_js__.__esModule && $__dom_46_js__ || {default: $__dom_46_js__});
- function isPrintableChar(keyCode) {
- 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));
- }
- function isMetaKey(_keyCode) {
- var metaKeys = [keyCode.ARROW_DOWN, keyCode.ARROW_UP, keyCode.ARROW_LEFT, keyCode.ARROW_RIGHT, keyCode.HOME, keyCode.END, keyCode.DELETE, keyCode.BACKSPACE, keyCode.F1, keyCode.F2, keyCode.F3, keyCode.F4, keyCode.F5, keyCode.F6, keyCode.F7, keyCode.F8, keyCode.F9, keyCode.F10, keyCode.F11, keyCode.F12, keyCode.TAB, keyCode.PAGE_DOWN, keyCode.PAGE_UP, keyCode.ENTER, keyCode.ESCAPE, keyCode.SHIFT, keyCode.CAPS_LOCK, keyCode.ALT];
- return metaKeys.indexOf(_keyCode) != -1;
- }
- function isCtrlKey(_keyCode) {
- return [keyCode.CONTROL_LEFT, 224, keyCode.COMMAND_LEFT, keyCode.COMMAND_RIGHT].indexOf(_keyCode) != -1;
- }
- function stringify(value) {
- switch (typeof value) {
- case 'string':
- case 'number':
- return value + '';
- case 'object':
- if (value === null) {
- return '';
- } else {
- return value.toString();
- }
- break;
- case 'undefined':
- return '';
- default:
- return value.toString();
- }
- }
- function toUpperCaseFirst(string) {
- return string[0].toUpperCase() + string.substr(1);
- }
- function equalsIgnoreCase() {
- for (var strings = [],
- $__0 = 0; $__0 < arguments.length; $__0++)
- strings[$__0] = arguments[$__0];
- var unique = [];
- var length = strings.length;
- while (length--) {
- var string = stringify(strings[length]).toLowerCase();
- if (unique.indexOf(string) === -1) {
- unique.push(string);
- }
- }
- return unique.length === 1;
- }
- function duckSchema(object) {
- var schema;
- if (Array.isArray(object)) {
- schema = [];
- } else {
- schema = {};
- for (var i in object) {
- if (object.hasOwnProperty(i)) {
- if (object[i] && typeof object[i] === 'object' && !Array.isArray(object[i])) {
- schema[i] = duckSchema(object[i]);
- } else if (Array.isArray(object[i])) {
- if (object[i].length && typeof object[i][0] === 'object' && !Array.isArray(object[i][0])) {
- schema[i] = [duckSchema(object[i][0])];
- } else {
- schema[i] = [];
- }
- } else {
- schema[i] = null;
- }
- }
- }
- }
- return schema;
- }
- function spreadsheetColumnLabel(index) {
- var dividend = index + 1;
- var columnLabel = '';
- var modulo;
- while (dividend > 0) {
- modulo = (dividend - 1) % 26;
- columnLabel = String.fromCharCode(65 + modulo) + columnLabel;
- dividend = parseInt((dividend - modulo) / 26, 10);
- }
- return columnLabel;
- }
- function createSpreadsheetData(rowCount, colCount) {
- rowCount = typeof rowCount === 'number' ? rowCount : 100;
- colCount = typeof colCount === 'number' ? colCount : 4;
- var rows = [],
- i,
- j;
- for (i = 0; i < rowCount; i++) {
- var row = [];
- for (j = 0; j < colCount; j++) {
- row.push(spreadsheetColumnLabel(j) + (i + 1));
- }
- rows.push(row);
- }
- return rows;
- }
- function createSpreadsheetObjectData(rowCount, colCount) {
- rowCount = typeof rowCount === 'number' ? rowCount : 100;
- colCount = typeof colCount === 'number' ? colCount : 4;
- var rows = [],
- i,
- j;
- for (i = 0; i < rowCount; i++) {
- var row = {};
- for (j = 0; j < colCount; j++) {
- row['prop' + j] = spreadsheetColumnLabel(j) + (i + 1);
- }
- rows.push(row);
- }
- return rows;
- }
- function isNumeric(n) {
- var t = typeof n;
- 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;
- }
- function randomString() {
- function s4() {
- return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
- }
- return s4() + s4() + s4() + s4();
- }
- function inherit(Child, Parent) {
- Parent.prototype.constructor = Parent;
- Child.prototype = new Parent();
- Child.prototype.constructor = Child;
- return Child;
- }
- function extend(target, extension) {
- for (var i in extension) {
- if (extension.hasOwnProperty(i)) {
- target[i] = extension[i];
- }
- }
- }
- function deepExtend(target, extension) {
- for (var key in extension) {
- if (extension.hasOwnProperty(key)) {
- if (extension[key] && typeof extension[key] === 'object') {
- if (!target[key]) {
- if (Array.isArray(extension[key])) {
- target[key] = [];
- } else {
- target[key] = {};
- }
- }
- deepExtend(target[key], extension[key]);
- } else {
- target[key] = extension[key];
- }
- }
- }
- }
- function deepClone(obj) {
- if (typeof obj === "object") {
- return JSON.parse(JSON.stringify(obj));
- } else {
- return obj;
- }
- }
- function isObjectEquals(object1, object2) {
- return JSON.stringify(object1) === JSON.stringify(object2);
- }
- function getPrototypeOf(obj) {
- var prototype;
- if (typeof obj.__proto__ == "object") {
- prototype = obj.__proto__;
- } else {
- var oldConstructor,
- constructor = obj.constructor;
- if (typeof obj.constructor == "function") {
- oldConstructor = constructor;
- if (delete obj.constructor) {
- constructor = obj.constructor;
- obj.constructor = oldConstructor;
- }
- }
- prototype = constructor ? constructor.prototype : null;
- }
- return prototype;
- }
- function columnFactory(GridSettings, conflictList) {
- function ColumnSettings() {}
- inherit(ColumnSettings, GridSettings);
- for (var i = 0,
- len = conflictList.length; i < len; i++) {
- ColumnSettings.prototype[conflictList[i]] = void 0;
- }
- return ColumnSettings;
- }
- function translateRowsToColumns(input) {
- var i,
- ilen,
- j,
- jlen,
- output = [],
- olen = 0;
- for (i = 0, ilen = input.length; i < ilen; i++) {
- for (j = 0, jlen = input[i].length; j < jlen; j++) {
- if (j == olen) {
- output.push([]);
- olen++;
- }
- output[j].push(input[i][j]);
- }
- }
- return output;
- }
- function to2dArray(arr) {
- var i = 0,
- ilen = arr.length;
- while (i < ilen) {
- arr[i] = [arr[i]];
- i++;
- }
- }
- function extendArray(arr, extension) {
- var i = 0,
- ilen = extension.length;
- while (i < ilen) {
- arr.push(extension[i]);
- i++;
- }
- }
- function isInput(element) {
- var inputs = ['INPUT', 'SELECT', 'TEXTAREA'];
- return inputs.indexOf(element.nodeName) > -1 || element.contentEditable === 'true';
- }
- function isOutsideInput(element) {
- return isInput(element) && element.className.indexOf('handsontableInput') == -1 && element.className.indexOf('copyPaste') == -1;
- }
- var keyCode = {
- MOUSE_LEFT: 1,
- MOUSE_RIGHT: 3,
- MOUSE_MIDDLE: 2,
- BACKSPACE: 8,
- COMMA: 188,
- INSERT: 45,
- DELETE: 46,
- END: 35,
- ENTER: 13,
- ESCAPE: 27,
- CONTROL_LEFT: 91,
- COMMAND_LEFT: 17,
- COMMAND_RIGHT: 93,
- ALT: 18,
- HOME: 36,
- PAGE_DOWN: 34,
- PAGE_UP: 33,
- PERIOD: 190,
- SPACE: 32,
- SHIFT: 16,
- CAPS_LOCK: 20,
- TAB: 9,
- ARROW_RIGHT: 39,
- ARROW_LEFT: 37,
- ARROW_UP: 38,
- ARROW_DOWN: 40,
- F1: 112,
- F2: 113,
- F3: 114,
- F4: 115,
- F5: 116,
- F6: 117,
- F7: 118,
- F8: 119,
- F9: 120,
- F10: 121,
- F11: 122,
- F12: 123,
- A: 65,
- X: 88,
- C: 67,
- V: 86
- };
- function isObject(obj) {
- return Object.prototype.toString.call(obj) == '[object Object]';
- }
- function pivot(arr) {
- var pivotedArr = [];
- if (!arr || arr.length === 0 || !arr[0] || arr[0].length === 0) {
- return pivotedArr;
- }
- var rowCount = arr.length;
- var colCount = arr[0].length;
- for (var i = 0; i < rowCount; i++) {
- for (var j = 0; j < colCount; j++) {
- if (!pivotedArr[j]) {
- pivotedArr[j] = [];
- }
- pivotedArr[j][i] = arr[i][j];
- }
- }
- return pivotedArr;
- }
- function proxy(fun, context) {
- return function() {
- return fun.apply(context, arguments);
- };
- }
- function cellMethodLookupFactory(methodName, allowUndefined) {
- allowUndefined = typeof allowUndefined == 'undefined' ? true : allowUndefined;
- return function cellMethodLookup(row, col) {
- return (function getMethodFromProperties(properties) {
- if (!properties) {
- return;
- } else if (properties.hasOwnProperty(methodName) && properties[methodName] !== void 0) {
- return properties[methodName];
- } else if (properties.hasOwnProperty('type') && properties.type) {
- var type;
- if (typeof properties.type != 'string') {
- throw new Error('Cell type must be a string ');
- }
- type = translateTypeNameToObject(properties.type);
- if (type.hasOwnProperty(methodName)) {
- return type[methodName];
- } else if (allowUndefined) {
- return;
- }
- }
- return getMethodFromProperties(getPrototypeOf(properties));
- })(typeof row == 'number' ? this.getCellMeta(row, col) : row);
- };
- function translateTypeNameToObject(typeName) {
- var type = Handsontable.cellTypes[typeName];
- if (typeof type == 'undefined') {
- 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');
- }
- return type;
- }
- }
- function isMobileBrowser(userAgent) {
- if (!userAgent) {
- userAgent = navigator.userAgent;
- }
- return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent));
- }
- function isTouchSupported() {
- return ('ontouchstart' in window);
- }
- function stopPropagation(event) {
- if (typeof(event.stopPropagation) === 'function') {
- event.stopPropagation();
- } else {
- event.cancelBubble = true;
- }
- }
- function pageX(event) {
- if (event.pageX) {
- return event.pageX;
- }
- var scrollLeft = dom.getWindowScrollLeft();
- var cursorX = event.clientX + scrollLeft;
- return cursorX;
- }
- function pageY(event) {
- if (event.pageY) {
- return event.pageY;
- }
- var scrollTop = dom.getWindowScrollTop();
- var cursorY = event.clientY + scrollTop;
- return cursorY;
- }
- function defineGetter(object, property, value, options) {
- options.value = value;
- options.writable = options.writable === false ? false : true;
- options.enumerable = options.enumerable === false ? false : true;
- options.configurable = options.configurable === false ? false : true;
- Object.defineProperty(object, property, options);
- }
- var lastTime = 0;
- var vendors = ['ms', 'moz', 'webkit', 'o'];
- var _requestAnimationFrame = window.requestAnimationFrame;
- var _cancelAnimationFrame = window.cancelAnimationFrame;
- for (var x = 0; x < vendors.length && !_requestAnimationFrame; ++x) {
- _requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
- _cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
- }
- if (!_requestAnimationFrame) {
- _requestAnimationFrame = function(callback) {
- var currTime = new Date().getTime();
- var timeToCall = Math.max(0, 16 - (currTime - lastTime));
- var id = window.setTimeout(function() {
- callback(currTime + timeToCall);
- }, timeToCall);
- lastTime = currTime + timeToCall;
- return id;
- };
- }
- if (!_cancelAnimationFrame) {
- _cancelAnimationFrame = function(id) {
- clearTimeout(id);
- };
- }
- function requestAnimationFrame(callback) {
- return _requestAnimationFrame.call(window, callback);
- }
- function cancelAnimationFrame(id) {
- _cancelAnimationFrame.call(window, id);
- }
- window.Handsontable = window.Handsontable || {};
- Handsontable.helper = {
- cancelAnimationFrame: cancelAnimationFrame,
- cellMethodLookupFactory: cellMethodLookupFactory,
- columnFactory: columnFactory,
- createSpreadsheetData: createSpreadsheetData,
- createSpreadsheetObjectData: createSpreadsheetObjectData,
- deepClone: deepClone,
- deepExtend: deepExtend,
- defineGetter: defineGetter,
- duckSchema: duckSchema,
- equalsIgnoreCase: equalsIgnoreCase,
- extend: extend,
- extendArray: extendArray,
- getPrototypeOf: getPrototypeOf,
- inherit: inherit,
- isCtrlKey: isCtrlKey,
- isInput: isInput,
- isMetaKey: isMetaKey,
- isMobileBrowser: isMobileBrowser,
- isNumeric: isNumeric,
- isObject: isObject,
- isObjectEquals: isObjectEquals,
- isOutsideInput: isOutsideInput,
- isPrintableChar: isPrintableChar,
- isTouchSupported: isTouchSupported,
- keyCode: keyCode,
- pageX: pageX,
- pageY: pageY,
- pivot: pivot,
- proxy: proxy,
- randomString: randomString,
- requestAnimationFrame: requestAnimationFrame,
- spreadsheetColumnLabel: spreadsheetColumnLabel,
- stopPropagation: stopPropagation,
- stringify: stringify,
- to2dArray: to2dArray,
- toUpperCaseFirst: toUpperCaseFirst,
- translateRowsToColumns: translateRowsToColumns
- };
-
- //#
- },{"./dom.js":27}],43:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- MultiMap: {get: function() {
- return MultiMap;
- }},
- __esModule: {value: true}
- });
- ;
- window.MultiMap = MultiMap;
- function MultiMap() {
- var map = {
- arrayMap: [],
- weakMap: new WeakMap()
- };
- return {
- 'get': function(key) {
- if (canBeAnArrayMapKey(key)) {
- return map.arrayMap[key];
- } else if (canBeAWeakMapKey(key)) {
- return map.weakMap.get(key);
- }
- },
- 'set': function(key, value) {
- if (canBeAnArrayMapKey(key)) {
- map.arrayMap[key] = value;
- } else if (canBeAWeakMapKey(key)) {
- map.weakMap.set(key, value);
- } else {
- throw new Error('Invalid key type');
- }
- },
- 'delete': function(key) {
- if (canBeAnArrayMapKey(key)) {
- delete map.arrayMap[key];
- } else if (canBeAWeakMapKey(key)) {
- map.weakMap['delete'](key);
- }
- }
- };
- function canBeAnArrayMapKey(obj) {
- return obj !== null && !isNaNSymbol(obj) && (typeof obj == 'string' || typeof obj == 'number');
- }
- function canBeAWeakMapKey(obj) {
- return obj !== null && (typeof obj == 'object' || typeof obj == 'function');
- }
- function isNaNSymbol(obj) {
- return obj !== obj;
- }
- }
-
- //#
- },{}],44:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- Hooks: {get: function() {
- return Hooks;
- }},
- __esModule: {value: true}
- });
- var $__eventManager_46_js__;
- var REGISTERED_HOOKS = ["afterCellMetaReset", "afterChange", "afterChangesObserved", "afterColumnMove", "afterColumnResize", "afterContextMenuDefaultOptions", "afterContextMenuHide", "afterContextMenuShow", "afterCopyLimit", "afterCreateCol", "afterCreateRow", "afterDeselect", "afterDestroy", "afterDocumentKeyDown", "afterGetCellMeta", "afterGetColHeader", "afterGetRowHeader", "afterInit", "afterIsMultipleSelectionCheck", "afterLoadData", "afterMomentumScroll", "afterOnCellCornerMouseDown", "afterOnCellMouseDown", "afterOnCellMouseOver", "afterRemoveCol", "afterRemoveRow", "afterRender", "afterRenderer", "afterRowMove", "afterRowResize", "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", "modifyCol", "modifyColWidth", "modifyRow", "modifyRowHeight", "persistentStateLoad", "persistentStateReset", "persistentStateSave"];
- var EventManager = ($__eventManager_46_js__ = require("./eventManager.js"), $__eventManager_46_js__ && $__eventManager_46_js__.__esModule && $__eventManager_46_js__ || {default: $__eventManager_46_js__}).EventManager;
- var Hooks = function Hooks() {
- this.globalBucket = this.createEmptyBucket();
- };
- ($traceurRuntime.createClass)(Hooks, {
- createEmptyBucket: function() {
- var handler = Object.create(null);
- for (var i = 0,
- len = REGISTERED_HOOKS.length; i < len; i++) {
- handler[REGISTERED_HOOKS[i]] = [];
- }
- return handler;
- },
- getBucket: function() {
- var context = arguments[0] !== (void 0) ? arguments[0] : null;
- if (context) {
- if (!context.pluginHookBucket) {
- context.pluginHookBucket = this.createEmptyBucket();
- }
- return context.pluginHookBucket;
- }
- return this.globalBucket;
- },
- add: function(key, callback) {
- var context = arguments[2] !== (void 0) ? arguments[2] : null;
- if (Array.isArray(callback)) {
- for (var i = 0,
- len = callback.length; i < len; i++) {
- this.add(key, callback[i]);
- }
- } else {
- var bucket = this.getBucket(context);
- if (typeof bucket[key] === 'undefined') {
- this.register(key);
- bucket[key] = [];
- }
- callback.skip = false;
- if (bucket[key].indexOf(callback) === -1) {
- bucket[key].push(callback);
- }
- }
- return this;
- },
- once: function(key, callback) {
- var context = arguments[2] !== (void 0) ? arguments[2] : null;
- if (Array.isArray(callback)) {
- for (var i = 0,
- len = callback.length; i < len; i++) {
- callback[i].runOnce = true;
- this.add(key, callback[i], context);
- }
- } else {
- callback.runOnce = true;
- this.add(key, callback, context);
- }
- },
- remove: function(key, callback) {
- var context = arguments[2] !== (void 0) ? arguments[2] : null;
- var bucket = this.getBucket(context);
- if (typeof bucket[key] !== 'undefined') {
- if (bucket[key].indexOf(callback) >= 0) {
- callback.skip = true;
- return true;
- }
- }
- return false;
- },
- run: function(context, key, p1, p2, p3, p4, p5, p6) {
- {
- var globalHandlers = this.globalBucket[key];
- var len = globalHandlers ? globalHandlers.length : 0;
- for (var i = 0; i < len; i++) {
- if (globalHandlers[i].skip) {
- continue;
- }
- var res = globalHandlers[i].call(context, p1, p2, p3, p4, p5, p6);
- if (res !== void 0) {
- p1 = res;
- }
- if (globalHandlers[i].runOnce) {
- this.remove(key, globalHandlers[i]);
- }
- }
- }
- {
- var localHandlers = this.getBucket(context)[key];
- var len$__2 = localHandlers ? localHandlers.length : 0;
- for (var i$__3 = 0; i$__3 < len$__2; i$__3++) {
- if (localHandlers[i$__3].skip) {
- continue;
- }
- var res$__4 = localHandlers[i$__3].call(context, p1, p2, p3, p4, p5, p6);
- if (res$__4 !== void 0) {
- p1 = res$__4;
- }
- if (localHandlers[i$__3].runOnce) {
- this.remove(key, localHandlers[i$__3], context);
- }
- }
- }
- return p1;
- },
- destroy: function() {
- var context = arguments[0] !== (void 0) ? arguments[0] : null;
- var bucket = this.getBucket(context);
- for (var key in bucket) {
- for (var i = 0,
- len = bucket[key].length; i < len; i++) {
- this.remove(key, bucket[key], context);
- }
- }
- },
- register: function(key) {
- if (!this.isRegistered(key)) {
- REGISTERED_HOOKS.push(key);
- }
- },
- deregister: function(key) {
- if (this.isRegistered(key)) {
- REGISTERED_HOOKS.splice(REGISTERED_HOOKS.indexOf(key), 1);
- }
- },
- isRegistered: function(key) {
- return REGISTERED_HOOKS.indexOf(key) >= 0;
- },
- getRegistered: function() {
- return REGISTERED_HOOKS;
- }
- }, {});
- ;
-
- //#
- },{"./eventManager.js":41}],45:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- registerPlugin: {get: function() {
- return registerPlugin;
- }},
- getPlugin: {get: function() {
- return getPlugin;
- }},
- __esModule: {value: true}
- });
- ;
- var registeredPlugins = new WeakMap();
- function registerPlugin(pluginName, PluginClass) {
- Handsontable.hooks.add('beforeInit', function() {
- var holder;
- pluginName = pluginName.toLowerCase();
- if (!registeredPlugins.has(this)) {
- registeredPlugins.set(this, {});
- }
- holder = registeredPlugins.get(this);
- if (!holder[pluginName]) {
- holder[pluginName] = new PluginClass(this);
- }
- });
- Handsontable.hooks.add('afterDestroy', function() {
- var i,
- pluginsHolder;
- if (registeredPlugins.has(this)) {
- pluginsHolder = registeredPlugins.get(this);
- for (i in pluginsHolder) {
- if (pluginsHolder.hasOwnProperty(i)) {
- pluginsHolder[i].destroy();
- }
- }
- registeredPlugins.delete(this);
- }
- });
- }
- function getPlugin(instance, pluginName) {
- if (typeof pluginName != 'string') {
- throw Error('Only strings can be passed as "plugin" parameter');
- }
- var _pluginName = pluginName.toLowerCase();
- if (!registeredPlugins.has(instance) || !registeredPlugins.get(instance)[_pluginName]) {
- throw Error('No plugin registered under name "' + pluginName + '"');
- }
- return registeredPlugins.get(instance)[_pluginName];
- }
-
- //#
- },{}],46:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- default: {get: function() {
- return $__default;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_helpers_46_js__;
- var defineGetter = ($___46__46__47_helpers_46_js__ = require("./../helpers.js"), $___46__46__47_helpers_46_js__ && $___46__46__47_helpers_46_js__.__esModule && $___46__46__47_helpers_46_js__ || {default: $___46__46__47_helpers_46_js__}).defineGetter;
- var BasePlugin = function BasePlugin(hotInstance) {
- defineGetter(this, 'hot', hotInstance, {writable: false});
- };
- ($traceurRuntime.createClass)(BasePlugin, {destroy: function() {
- delete this.hot;
- }}, {});
- var $__default = BasePlugin;
-
- //#
- },{"./../helpers.js":42}],47:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- AutoColumnSize: {get: function() {
- return AutoColumnSize;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_helpers_46_js__,
- $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__;
- var helper = ($___46__46__47__46__46__47_helpers_46_js__ = require("./../../helpers.js"), $___46__46__47__46__46__47_helpers_46_js__ && $___46__46__47__46__46__47_helpers_46_js__.__esModule && $___46__46__47__46__46__47_helpers_46_js__ || {default: $___46__46__47__46__46__47_helpers_46_js__});
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- ;
- function AutoColumnSize() {
- var plugin = this,
- sampleCount = 5;
- this.beforeInit = function() {
- var instance = this;
- instance.autoColumnWidths = [];
- if (instance.getSettings().autoColumnSize !== false) {
- if (!instance.autoColumnSizeTmp) {
- instance.autoColumnSizeTmp = {
- table: null,
- tableStyle: null,
- theadTh: null,
- tbody: null,
- container: null,
- containerStyle: null,
- determineBeforeNextRender: true
- };
- instance.addHook('beforeRender', htAutoColumnSize.determineIfChanged);
- instance.addHook('modifyColWidth', htAutoColumnSize.modifyColWidth);
- instance.addHook('afterDestroy', htAutoColumnSize.afterDestroy);
- instance.determineColumnWidth = plugin.determineColumnWidth;
- }
- } else {
- if (instance.autoColumnSizeTmp) {
- instance.removeHook('beforeRender', htAutoColumnSize.determineIfChanged);
- instance.removeHook('modifyColWidth', htAutoColumnSize.modifyColWidth);
- instance.removeHook('afterDestroy', htAutoColumnSize.afterDestroy);
- delete instance.determineColumnWidth;
- plugin.afterDestroy.call(instance);
- }
- }
- };
- this.determineIfChanged = function(force) {
- if (force) {
- htAutoColumnSize.determineColumnsWidth.apply(this, arguments);
- }
- };
- this.determineColumnWidth = function(col) {
- var instance = this,
- tmp = instance.autoColumnSizeTmp;
- if (!tmp.container) {
- createTmpContainer.call(tmp, instance);
- }
- tmp.container.className = instance.rootElement.className + ' htAutoColumnSize';
- tmp.table.className = instance.table.className;
- var rows = instance.countRows();
- var samples = {};
- for (var r = 0; r < rows; r++) {
- var value = instance.getDataAtCell(r, col);
- if (!Array.isArray(value)) {
- value = helper.stringify(value);
- }
- var len = value.length;
- if (!samples[len]) {
- samples[len] = {
- needed: sampleCount,
- strings: []
- };
- }
- if (samples[len].needed) {
- samples[len].strings.push({
- value: value,
- row: r
- });
- samples[len].needed--;
- }
- }
- var settings = instance.getSettings();
- if (settings.colHeaders) {
- instance.view.appendColHeader(col, tmp.theadTh);
- }
- dom.empty(tmp.tbody);
- for (var i in samples) {
- if (samples.hasOwnProperty(i)) {
- for (var j = 0,
- jlen = samples[i].strings.length; j < jlen; j++) {
- var row = samples[i].strings[j].row;
- var cellProperties = instance.getCellMeta(row, col);
- cellProperties.col = col;
- cellProperties.row = row;
- var renderer = instance.getCellRenderer(cellProperties);
- var tr = document.createElement('tr');
- var td = document.createElement('td');
- renderer(instance, td, row, col, instance.colToProp(col), samples[i].strings[j].value, cellProperties);
- r++;
- tr.appendChild(td);
- tmp.tbody.appendChild(tr);
- }
- }
- }
- var parent = instance.rootElement.parentNode;
- parent.appendChild(tmp.container);
- var width = dom.outerWidth(tmp.table);
- parent.removeChild(tmp.container);
- return width;
- };
- this.determineColumnsWidth = function() {
- var instance = this;
- var settings = this.getSettings();
- if (settings.autoColumnSize || !settings.colWidths) {
- var cols = this.countCols();
- for (var c = 0; c < cols; c++) {
- if (!instance._getColWidthFromSettings(c)) {
- this.autoColumnWidths[c] = plugin.determineColumnWidth.call(instance, c);
- }
- }
- }
- if (this.view.wt) {
- this.view.wt.wtOverlays.adjustElementsSize(true);
- }
- };
- this.modifyColWidth = function(width, col) {
- if (this.autoColumnWidths[col] && this.autoColumnWidths[col] > width) {
- return this.autoColumnWidths[col];
- }
- return width;
- };
- this.afterDestroy = function() {
- var instance = this;
- if (instance.autoColumnSizeTmp && instance.autoColumnSizeTmp.container && instance.autoColumnSizeTmp.container.parentNode) {
- instance.autoColumnSizeTmp.container.parentNode.removeChild(instance.autoColumnSizeTmp.container);
- }
- instance.autoColumnSizeTmp = null;
- };
- function createTmpContainer(instance) {
- var d = document,
- tmp = this;
- tmp.table = d.createElement('table');
- tmp.theadTh = d.createElement('th');
- tmp.table.appendChild(d.createElement('thead')).appendChild(d.createElement('tr')).appendChild(tmp.theadTh);
- tmp.tableStyle = tmp.table.style;
- tmp.tableStyle.tableLayout = 'auto';
- tmp.tableStyle.width = 'auto';
- tmp.tbody = d.createElement('tbody');
- tmp.table.appendChild(tmp.tbody);
- tmp.container = d.createElement('div');
- tmp.container.className = instance.rootElement.className + ' hidden';
- tmp.containerStyle = tmp.container.style;
- tmp.container.appendChild(tmp.table);
- }
- }
- var htAutoColumnSize = new AutoColumnSize();
- Handsontable.hooks.add('beforeInit', htAutoColumnSize.beforeInit);
- Handsontable.hooks.add('afterUpdateSettings', htAutoColumnSize.beforeInit);
-
- //#
- },{"./../../dom.js":27,"./../../helpers.js":42,"./../../plugins.js":45}],48:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- Autofill: {get: function() {
- return Autofill;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_eventManager_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__,
- $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__;
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47__46__46__47_eventManager_46_js__ = require("./../../eventManager.js"), $___46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- var WalkontableCellCoords = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ = require("./../../3rdparty/walkontable/src/cell/coords.js"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__}).WalkontableCellCoords;
- ;
- function getDeltas(start, end, data, direction) {
- var rlength = data.length,
- clength = data ? data[0].length : 0,
- deltas = [],
- arr = [],
- diffRow,
- diffCol,
- startValue,
- endValue,
- delta;
- diffRow = end.row - start.row;
- diffCol = end.col - start.col;
- if (['down', 'up'].indexOf(direction) !== -1) {
- for (var col = 0; col <= diffCol; col++) {
- startValue = parseInt(data[0][col], 10);
- endValue = parseInt(data[rlength - 1][col], 10);
- delta = (direction === 'down' ? (endValue - startValue) : (startValue - endValue)) / (rlength - 1) || 0;
- arr.push(delta);
- }
- deltas.push(arr);
- }
- if (['right', 'left'].indexOf(direction) !== -1) {
- for (var row = 0; row <= diffRow; row++) {
- startValue = parseInt(data[row][0], 10);
- endValue = parseInt(data[row][clength - 1], 10);
- delta = (direction === 'right' ? (endValue - startValue) : (startValue - endValue)) / (clength - 1) || 0;
- arr = [];
- arr.push(delta);
- deltas.push(arr);
- }
- }
- return deltas;
- }
- function Autofill(instance) {
- var _this = this,
- mouseDownOnCellCorner = false,
- wtOnCellCornerMouseDown,
- wtOnCellMouseOver,
- eventManager;
- this.instance = instance;
- this.addingStarted = false;
- eventManager = eventManagerObject(instance);
- function mouseUpCallback(event) {
- if (!instance.autofill) {
- return true;
- }
- if (instance.autofill.handle && instance.autofill.handle.isDragged) {
- if (instance.autofill.handle.isDragged > 1) {
- instance.autofill.apply();
- }
- instance.autofill.handle.isDragged = 0;
- mouseDownOnCellCorner = false;
- }
- }
- function mouseMoveCallback(event) {
- var tableBottom,
- tableRight;
- if (!_this.instance.autofill) {
- return false;
- }
- tableBottom = dom.offset(_this.instance.table).top - (window.pageYOffset || document.documentElement.scrollTop) + dom.outerHeight(_this.instance.table);
- tableRight = dom.offset(_this.instance.table).left - (window.pageXOffset || document.documentElement.scrollLeft) + dom.outerWidth(_this.instance.table);
- if (_this.addingStarted === false && _this.instance.autofill.handle.isDragged > 0 && event.clientY > tableBottom && event.clientX <= tableRight) {
- _this.instance.mouseDragOutside = true;
- _this.addingStarted = true;
- } else {
- _this.instance.mouseDragOutside = false;
- }
- if (_this.instance.mouseDragOutside) {
- setTimeout(function() {
- _this.addingStarted = false;
- _this.instance.alter('insert_row');
- }, 200);
- }
- }
- eventManager.addEventListener(document, 'mouseup', mouseUpCallback);
- eventManager.addEventListener(document, 'mousemove', mouseMoveCallback);
- wtOnCellCornerMouseDown = this.instance.view.wt.wtSettings.settings.onCellCornerMouseDown;
- this.instance.view.wt.wtSettings.settings.onCellCornerMouseDown = function(event) {
- instance.autofill.handle.isDragged = 1;
- mouseDownOnCellCorner = true;
- wtOnCellCornerMouseDown(event);
- };
- wtOnCellMouseOver = this.instance.view.wt.wtSettings.settings.onCellMouseOver;
- this.instance.view.wt.wtSettings.settings.onCellMouseOver = function(event, coords, TD, wt) {
- if (instance.autofill && mouseDownOnCellCorner && !instance.view.isMouseDown() && instance.autofill.handle && instance.autofill.handle.isDragged) {
- instance.autofill.handle.isDragged++;
- instance.autofill.showBorder(coords);
- instance.autofill.checkIfNewRowNeeded();
- }
- wtOnCellMouseOver(event, coords, TD, wt);
- };
- this.instance.view.wt.wtSettings.settings.onCellCornerDblClick = function() {
- instance.autofill.selectAdjacent();
- };
- }
- Autofill.prototype.init = function() {
- this.handle = {};
- };
- Autofill.prototype.disable = function() {
- this.handle.disabled = true;
- };
- Autofill.prototype.selectAdjacent = function() {
- var select,
- data,
- r,
- maxR,
- c;
- if (this.instance.selection.isMultiple()) {
- select = this.instance.view.wt.selections.area.getCorners();
- } else {
- select = this.instance.view.wt.selections.current.getCorners();
- }
- data = this.instance.getData();
- rows: for (r = select[2] + 1; r < this.instance.countRows(); r++) {
- for (c = select[1]; c <= select[3]; c++) {
- if (data[r][c]) {
- break rows;
- }
- }
- if (!!data[r][select[1] - 1] || !!data[r][select[3] + 1]) {
- maxR = r;
- }
- }
- if (maxR) {
- this.instance.view.wt.selections.fill.clear();
- this.instance.view.wt.selections.fill.add(new WalkontableCellCoords(select[0], select[1]));
- this.instance.view.wt.selections.fill.add(new WalkontableCellCoords(maxR, select[3]));
- this.apply();
- }
- };
- Autofill.prototype.apply = function() {
- var drag,
- select,
- start,
- end,
- _data,
- direction,
- deltas,
- selRange;
- this.handle.isDragged = 0;
- drag = this.instance.view.wt.selections.fill.getCorners();
- if (!drag) {
- return;
- }
- this.instance.view.wt.selections.fill.clear();
- if (this.instance.selection.isMultiple()) {
- select = this.instance.view.wt.selections.area.getCorners();
- } else {
- select = this.instance.view.wt.selections.current.getCorners();
- }
- Handsontable.hooks.run(this.instance, 'afterAutofillApplyValues', select, drag);
- if (drag[0] === select[0] && drag[1] < select[1]) {
- direction = 'left';
- start = new WalkontableCellCoords(drag[0], drag[1]);
- end = new WalkontableCellCoords(drag[2], select[1] - 1);
- } else if (drag[0] === select[0] && drag[3] > select[3]) {
- direction = 'right';
- start = new WalkontableCellCoords(drag[0], select[3] + 1);
- end = new WalkontableCellCoords(drag[2], drag[3]);
- } else if (drag[0] < select[0] && drag[1] === select[1]) {
- direction = 'up';
- start = new WalkontableCellCoords(drag[0], drag[1]);
- end = new WalkontableCellCoords(select[0] - 1, drag[3]);
- } else if (drag[2] > select[2] && drag[1] === select[1]) {
- direction = 'down';
- start = new WalkontableCellCoords(select[2] + 1, drag[1]);
- end = new WalkontableCellCoords(drag[2], drag[3]);
- }
- if (start && start.row > -1 && start.col > -1) {
- selRange = {
- from: this.instance.getSelectedRange().from,
- to: this.instance.getSelectedRange().to
- };
- _data = this.instance.getData(selRange.from.row, selRange.from.col, selRange.to.row, selRange.to.col);
- deltas = getDeltas(start, end, _data, direction);
- Handsontable.hooks.run(this.instance, 'beforeAutofill', start, end, _data);
- this.instance.populateFromArray(start.row, start.col, _data, end.row, end.col, 'autofill', null, direction, deltas);
- this.instance.selection.setRangeStart(new WalkontableCellCoords(drag[0], drag[1]));
- this.instance.selection.setRangeEnd(new WalkontableCellCoords(drag[2], drag[3]));
- } else {
- this.instance.selection.refreshBorders();
- }
- };
- Autofill.prototype.showBorder = function(coords) {
- var topLeft = this.instance.getSelectedRange().getTopLeftCorner(),
- bottomRight = this.instance.getSelectedRange().getBottomRightCorner();
- if (this.instance.getSettings().fillHandle !== 'horizontal' && (bottomRight.row < coords.row || topLeft.row > coords.row)) {
- coords = new WalkontableCellCoords(coords.row, bottomRight.col);
- } else if (this.instance.getSettings().fillHandle !== 'vertical') {
- coords = new WalkontableCellCoords(bottomRight.row, coords.col);
- } else {
- return;
- }
- this.instance.view.wt.selections.fill.clear();
- this.instance.view.wt.selections.fill.add(this.instance.getSelectedRange().from);
- this.instance.view.wt.selections.fill.add(this.instance.getSelectedRange().to);
- this.instance.view.wt.selections.fill.add(coords);
- this.instance.view.render();
- };
- Autofill.prototype.checkIfNewRowNeeded = function() {
- var fillCorners,
- selection,
- tableRows = this.instance.countRows(),
- that = this;
- if (this.instance.view.wt.selections.fill.cellRange && this.addingStarted === false) {
- selection = this.instance.getSelected();
- fillCorners = this.instance.view.wt.selections.fill.getCorners();
- if (selection[2] < tableRows - 1 && fillCorners[2] === tableRows - 1) {
- this.addingStarted = true;
- this.instance._registerTimeout(setTimeout(function() {
- that.instance.alter('insert_row');
- that.addingStarted = false;
- }, 200));
- }
- }
- };
- Handsontable.hooks.add('afterInit', function() {
- var autofill = new Autofill(this);
- if (typeof this.getSettings().fillHandle !== 'undefined') {
- if (autofill.handle && this.getSettings().fillHandle === false) {
- autofill.disable();
- } else if (!autofill.handle && this.getSettings().fillHandle !== false) {
- this.autofill = autofill;
- this.autofill.init();
- }
- }
- });
- Handsontable.Autofill = Autofill;
-
- //#
- },{"./../../3rdparty/walkontable/src/cell/coords.js":5,"./../../dom.js":27,"./../../eventManager.js":41,"./../../plugins.js":45}],49:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- default: {get: function() {
- return $__default;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_eventManager_46_js__,
- $___46__46__47__95_base_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__;
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47__46__46__47_eventManager_46_js__ = require("./../../eventManager.js"), $___46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- 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;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- var ColumnSorting = function ColumnSorting(hotInstance) {
- var $__3 = this;
- $traceurRuntime.superConstructor($ColumnSorting).call(this, hotInstance);
- var _this = this;
- this.sortIndicators = [];
- this.hot.addHook('afterInit', (function() {
- return $__3.init.call($__3, 'afterInit');
- }));
- this.hot.addHook('afterUpdateSettings', (function() {
- return $__3.init.call($__3, 'afterUpdateSettings');
- }));
- this.hot.addHook('modifyRow', function() {
- return _this.translateRow.apply(_this, arguments);
- });
- this.hot.addHook('afterGetColHeader', function() {
- return _this.getColHeader.apply(_this, arguments);
- });
- Handsontable.hooks.register('beforeColumnSort');
- Handsontable.hooks.register('afterColumnSort');
- };
- var $ColumnSorting = ColumnSorting;
- ($traceurRuntime.createClass)(ColumnSorting, {
- init: function(source) {
- var sortingSettings = this.hot.getSettings().columnSorting,
- _this = this;
- this.hot.sortingEnabled = !!(sortingSettings);
- if (this.hot.sortingEnabled) {
- this.hot.sortIndex = [];
- var loadedSortingState = this.loadSortingState(),
- sortingColumn,
- sortingOrder;
- if (typeof loadedSortingState != 'undefined') {
- sortingColumn = loadedSortingState.sortColumn;
- sortingOrder = loadedSortingState.sortOrder;
- } else {
- sortingColumn = sortingSettings.column;
- sortingOrder = sortingSettings.sortOrder;
- }
- this.sortByColumn(sortingColumn, sortingOrder);
- this.hot.sort = function() {
- var args = Array.prototype.slice.call(arguments);
- return _this.sortByColumn.apply(_this, args);
- };
- if (typeof this.hot.getSettings().observeChanges == 'undefined') {
- this.enableObserveChangesPlugin();
- }
- if (source == 'afterInit') {
- this.bindColumnSortingAfterClick();
- this.hot.addHook('afterCreateRow', function() {
- _this.afterCreateRow.apply(_this, arguments);
- });
- this.hot.addHook('afterRemoveRow', function() {
- _this.afterRemoveRow.apply(_this, arguments);
- });
- this.hot.addHook('afterLoadData', function() {
- _this.init.apply(_this, arguments);
- });
- }
- } else {
- this.hot.sort = void 0;
- this.hot.removeHook('afterCreateRow', this.afterCreateRow);
- this.hot.removeHook('afterRemoveRow', this.afterRemoveRow);
- this.hot.removeHook('afterLoadData', this.init);
- }
- },
- setSortingColumn: function(col, order) {
- if (typeof col == 'undefined') {
- this.hot.sortColumn = void 0;
- this.hot.sortOrder = void 0;
- return;
- } else if (this.hot.sortColumn === col && typeof order == 'undefined') {
- if (this.hot.sortOrder === false) {
- this.hot.sortOrder = void 0;
- } else {
- this.hot.sortOrder = !this.hot.sortOrder;
- }
- } else {
- this.hot.sortOrder = typeof order != 'undefined' ? order : true;
- }
- this.hot.sortColumn = col;
- },
- sortByColumn: function(col, order) {
- this.setSortingColumn(col, order);
- if (typeof this.hot.sortColumn == 'undefined') {
- return;
- }
- Handsontable.hooks.run(this.hot, 'beforeColumnSort', this.hot.sortColumn, this.hot.sortOrder);
- this.sort();
- this.hot.render();
- this.saveSortingState();
- Handsontable.hooks.run(this.hot, 'afterColumnSort', this.hot.sortColumn, this.hot.sortOrder);
- },
- saveSortingState: function() {
- var sortingState = {};
- if (typeof this.hot.sortColumn != 'undefined') {
- sortingState.sortColumn = this.hot.sortColumn;
- }
- if (typeof this.hot.sortOrder != 'undefined') {
- sortingState.sortOrder = this.hot.sortOrder;
- }
- if (sortingState.hasOwnProperty('sortColumn') || sortingState.hasOwnProperty('sortOrder')) {
- Handsontable.hooks.run(this.hot, 'persistentStateSave', 'columnSorting', sortingState);
- }
- },
- loadSortingState: function() {
- var storedState = {};
- Handsontable.hooks.run(this.hot, 'persistentStateLoad', 'columnSorting', storedState);
- return storedState.value;
- },
- bindColumnSortingAfterClick: function() {
- var eventManager = eventManagerObject(this.hot),
- _this = this;
- eventManager.addEventListener(this.hot.rootElement, 'click', function(e) {
- if (dom.hasClass(e.target, 'columnSorting')) {
- var col = getColumn(e.target);
- if (col !== this.lastSortedColumn) {
- _this.sortOrderClass = 'ascending';
- } else {
- switch (_this.hot.sortOrder) {
- case void 0:
- _this.sortOrderClass = 'ascending';
- break;
- case true:
- _this.sortOrderClass = 'descending';
- break;
- case false:
- _this.sortOrderClass = void 0;
- }
- }
- this.lastSortedColumn = col;
- _this.sortByColumn(col);
- }
- });
- function countRowHeaders() {
- var THs = _this.hot.view.TBODY.querySelector('tr').querySelectorAll('th');
- return THs.length;
- }
- function getColumn(target) {
- var TH = dom.closest(target, 'TH');
- return dom.index(TH) - countRowHeaders();
- }
- },
- enableObserveChangesPlugin: function() {
- var _this = this;
- this.hot._registerTimeout(setTimeout(function() {
- _this.hot.updateSettings({observeChanges: true});
- }, 0));
- },
- defaultSort: function(sortOrder) {
- return function(a, b) {
- if (typeof a[1] == "string") {
- a[1] = a[1].toLowerCase();
- }
- if (typeof b[1] == "string") {
- b[1] = b[1].toLowerCase();
- }
- if (a[1] === b[1]) {
- return 0;
- }
- if (a[1] === null || a[1] === "") {
- return 1;
- }
- if (b[1] === null || b[1] === "") {
- return -1;
- }
- if (a[1] < b[1]) {
- return sortOrder ? -1 : 1;
- }
- if (a[1] > b[1]) {
- return sortOrder ? 1 : -1;
- }
- return 0;
- };
- },
- dateSort: function(sortOrder) {
- return function(a, b) {
- if (a[1] === b[1]) {
- return 0;
- }
- if (a[1] === null) {
- return 1;
- }
- if (b[1] === null) {
- return -1;
- }
- var aDate = new Date(a[1]);
- var bDate = new Date(b[1]);
- if (aDate < bDate) {
- return sortOrder ? -1 : 1;
- }
- if (aDate > bDate) {
- return sortOrder ? 1 : -1;
- }
- return 0;
- };
- },
- sort: function() {
- if (typeof this.hot.sortOrder == 'undefined') {
- return;
- }
- var colMeta,
- sortFunction;
- this.hot.sortingEnabled = false;
- this.hot.sortIndex.length = 0;
- var colOffset = this.hot.colOffset();
- for (var i = 0,
- ilen = this.hot.countRows() - this.hot.getSettings().minSpareRows; i < ilen; i++) {
- this.hot.sortIndex.push([i, this.hot.getDataAtCell(i, this.hot.sortColumn + colOffset)]);
- }
- colMeta = this.hot.getCellMeta(0, this.hot.sortColumn);
- this.sortIndicators[this.hot.sortColumn] = colMeta.sortIndicator;
- switch (colMeta.type) {
- case 'date':
- sortFunction = this.dateSort;
- break;
- default:
- sortFunction = this.defaultSort;
- }
- this.hot.sortIndex.sort(sortFunction(this.hot.sortOrder));
- for (var i = this.hot.sortIndex.length; i < this.hot.countRows(); i++) {
- this.hot.sortIndex.push([i, this.hot.getDataAtCell(i, this.hot.sortColumn + colOffset)]);
- }
- this.hot.sortingEnabled = true;
- },
- translateRow: function(row) {
- if (this.hot.sortingEnabled && (typeof this.hot.sortOrder !== 'undefined') && this.hot.sortIndex && this.hot.sortIndex.length && this.hot.sortIndex[row]) {
- return this.hot.sortIndex[row][0];
- }
- return row;
- },
- untranslateRow: function(row) {
- if (this.hot.sortingEnabled && this.hot.sortIndex && this.hot.sortIndex.length) {
- for (var i = 0; i < this.hot.sortIndex.length; i++) {
- if (this.hot.sortIndex[i][0] == row) {
- return i;
- }
- }
- }
- },
- getColHeader: function(col, TH) {
- var headerLink = TH.querySelector('.colHeader');
- if (this.hot.getSettings().columnSorting && col >= 0) {
- dom.addClass(headerLink, 'columnSorting');
- }
- dom.removeClass(headerLink, 'descending');
- dom.removeClass(headerLink, 'ascending');
- if (this.sortIndicators[col]) {
- if (col === this.hot.sortColumn) {
- if (this.sortOrderClass === 'ascending') {
- dom.addClass(headerLink, 'ascending');
- } else if (this.sortOrderClass === 'descending') {
- dom.addClass(headerLink, 'descending');
- }
- }
- }
- },
- isSorted: function() {
- return typeof this.hot.sortColumn != 'undefined';
- },
- afterCreateRow: function(index, amount) {
- if (!this.isSorted()) {
- return;
- }
- for (var i = 0; i < this.hot.sortIndex.length; i++) {
- if (this.hot.sortIndex[i][0] >= index) {
- this.hot.sortIndex[i][0] += amount;
- }
- }
- for (var i = 0; i < amount; i++) {
- this.hot.sortIndex.splice(index + i, 0, [index + i, this.hot.getData()[index + i][this.hot.sortColumn + this.hot.colOffset()]]);
- }
- this.saveSortingState();
- },
- afterRemoveRow: function(index, amount) {
- if (!this.isSorted()) {
- return;
- }
- var physicalRemovedIndex = this.translateRow(index);
- this.hot.sortIndex.splice(index, amount);
- for (var i = 0; i < this.hot.sortIndex.length; i++) {
- if (this.hot.sortIndex[i][0] > physicalRemovedIndex) {
- this.hot.sortIndex[i][0] -= amount;
- }
- }
- this.saveSortingState();
- }
- }, {}, BasePlugin);
- var $__default = ColumnSorting;
- registerPlugin('columnSorting', ColumnSorting);
-
- //#
- },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../plugins.js":45,"./../_base.js":46}],50:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- CommentEditor: {get: function() {
- return CommentEditor;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_dom_46_js__;
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var CommentEditor = function CommentEditor() {
- this.editor = this.createEditor();
- this.editorStyle = this.editor.style;
- this.editorStyle.position = 'absolute';
- this.editorStyle.zIndex = 100;
- this.hide();
- };
- var $CommentEditor = CommentEditor;
- ($traceurRuntime.createClass)(CommentEditor, {
- setPosition: function(x, y) {
- this.editorStyle.left = x + 'px';
- this.editorStyle.top = y + 'px';
- },
- show: function() {
- this.editorStyle.display = 'block';
- },
- hide: function() {
- this.editorStyle.display = 'none';
- },
- isVisible: function() {
- return this.editorStyle.display === 'block';
- },
- setValue: function() {
- var value = arguments[0] !== (void 0) ? arguments[0] : '';
- value = value || '';
- this.getInputElement().value = value;
- },
- getValue: function() {
- return this.getInputElement().value;
- },
- isFocused: function() {
- return document.activeElement === this.getInputElement();
- },
- focus: function() {
- this.getInputElement().focus();
- },
- createEditor: function() {
- var container = document.querySelector('.' + $CommentEditor.CLASS_EDITOR_CONTAINER);
- var editor;
- var textArea;
- if (!container) {
- container = document.createElement('div');
- dom.addClass(container, $CommentEditor.CLASS_EDITOR_CONTAINER);
- document.body.appendChild(container);
- }
- editor = document.createElement('div');
- dom.addClass(editor, $CommentEditor.CLASS_EDITOR);
- textArea = document.createElement('textarea');
- dom.addClass(textArea, $CommentEditor.CLASS_INPUT);
- editor.appendChild(textArea);
- container.appendChild(editor);
- return editor;
- },
- getInputElement: function() {
- return this.editor.querySelector('.' + $CommentEditor.CLASS_INPUT);
- },
- destroy: function() {
- this.editor.parentNode.removeChild(this.editor);
- this.editor = null;
- this.editorStyle = null;
- }
- }, {
- get CLASS_EDITOR_CONTAINER() {
- return 'htCommentsContainer';
- },
- get CLASS_EDITOR() {
- return 'htComments';
- },
- get CLASS_INPUT() {
- return 'htCommentTextArea';
- },
- get CLASS_CELL() {
- return 'htCommentCell';
- }
- });
- ;
-
- //#
- },{"./../../dom.js":27}],51:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- Comments: {get: function() {
- return Comments;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_eventManager_46_js__,
- $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__,
- $___46__46__47__95_base_46_js__,
- $__commentEditor_46_js__;
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var EventManager = ($___46__46__47__46__46__47_eventManager_46_js__ = require("./../../eventManager.js"), $___46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47_eventManager_46_js__}).EventManager;
- var WalkontableCellCoords = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ = require("./../../3rdparty/walkontable/src/cell/coords.js"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__}).WalkontableCellCoords;
- var $__2 = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}),
- registerPlugin = $__2.registerPlugin,
- getPlugin = $__2.getPlugin;
- 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;
- var CommentEditor = ($__commentEditor_46_js__ = require("./commentEditor.js"), $__commentEditor_46_js__ && $__commentEditor_46_js__.__esModule && $__commentEditor_46_js__ || {default: $__commentEditor_46_js__}).CommentEditor;
- var Comments = function Comments(hotInstance) {
- var $__5 = this;
- $traceurRuntime.superConstructor($Comments).call(this, hotInstance);
- if (!this.hot.getSettings().comments) {
- return;
- }
- this.editor = new CommentEditor();
- this.eventManager = new EventManager(this);
- this.range = {};
- this.mouseDown = false;
- this.contextMenuEvent = false;
- this.timer = null;
- this.hot.addHook('afterInit', (function() {
- return $__5.registerListeners();
- }));
- this.hot.addHook('afterContextMenuDefaultOptions', (function(options) {
- return $__5.addToContextMenu(options);
- }));
- this.hot.addHook('afterRenderer', (function(TD, row, col, prop, value, cellProperties) {
- return $__5.onAfterRenderer(TD, cellProperties);
- }));
- this.hot.addHook('afterScrollVertically', (function() {
- return $__5.refreshEditorPosition();
- }));
- this.hot.addHook('afterColumnResize', (function() {
- return $__5.refreshEditorPosition();
- }));
- this.hot.addHook('afterRowResize', (function() {
- return $__5.refreshEditorPosition();
- }));
- };
- var $Comments = Comments;
- ($traceurRuntime.createClass)(Comments, {
- registerListeners: function() {
- var $__5 = this;
- this.eventManager.addEventListener(document, 'mouseover', (function(event) {
- return $__5.onMouseOver(event);
- }));
- this.eventManager.addEventListener(document, 'mousedown', (function(event) {
- return $__5.onMouseDown(event);
- }));
- this.eventManager.addEventListener(document, 'mousemove', (function(event) {
- return $__5.onMouseMove(event);
- }));
- this.eventManager.addEventListener(document, 'mouseup', (function(event) {
- return $__5.onMouseUp(event);
- }));
- this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', (function(event) {
- return $__5.onEditorBlur(event);
- }));
- },
- setRange: function(range) {
- this.range = range;
- },
- clearRange: function() {
- this.range = {};
- },
- targetIsCellWithComment: function(event) {
- return dom.hasClass(event.target, 'htCommentCell') && dom.closest(event.target, [this.hot.rootElement]) ? true : false;
- },
- targetIsCommentTextArea: function(event) {
- return this.editor.getInputElement() === event.target;
- },
- saveComment: function() {
- if (!this.range.from) {
- throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
- }
- var comment = this.editor.getValue();
- var row = this.range.from.row;
- var col = this.range.from.col;
- this.hot.setCellMeta(row, col, 'comment', comment);
- this.hot.render();
- },
- saveCommentAtCell: function(row, col) {
- this.setRange({from: new WalkontableCellCoords(row, col)});
- this.saveComment();
- },
- removeComment: function() {
- if (!this.range.from) {
- throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
- }
- this.hot.removeCellMeta(this.range.from.row, this.range.from.col, 'comment');
- this.hot.render();
- this.hide();
- },
- removeCommentAtCell: function(row, col) {
- this.setRange({from: new WalkontableCellCoords(row, col)});
- this.removeComment();
- },
- show: function() {
- if (!this.range.from) {
- throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
- }
- var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
- this.refreshEditorPosition(true);
- this.editor.setValue(meta.comment || '');
- this.editor.show();
- return true;
- },
- showAtCell: function(row, col) {
- this.setRange({from: new WalkontableCellCoords(row, col)});
- return this.show();
- },
- hide: function() {
- this.editor.hide();
- },
- refreshEditorPosition: function() {
- var force = arguments[0] !== (void 0) ? arguments[0] : false;
- if (!force && (!this.range.from || !this.editor.isVisible())) {
- return;
- }
- var TD = this.hot.view.wt.wtTable.getCell(this.range.from);
- var offset = dom.offset(TD);
- var lastColWidth = this.hot.getColWidth(this.range.from.col);
- var cellTopOffset = offset.top;
- var cellLeftOffset = offset.left;
- var verticalCompensation = 0;
- var horizontalCompensation = 0;
- if (this.hot.view.wt.wtViewport.hasVerticalScroll()) {
- cellTopOffset = cellTopOffset - this.hot.view.wt.wtOverlays.topOverlay.getScrollPosition();
- verticalCompensation = 20;
- }
- if (this.hot.view.wt.wtViewport.hasHorizontalScroll()) {
- cellLeftOffset = cellLeftOffset - this.hot.view.wt.wtOverlays.leftOverlay.getScrollPosition();
- horizontalCompensation = 20;
- }
- var x = cellLeftOffset + lastColWidth;
- var y = cellTopOffset;
- var rect = this.hot.view.wt.wtTable.holder.getBoundingClientRect();
- var holderPos = {
- left: rect.left + dom.getWindowScrollLeft() + horizontalCompensation,
- right: rect.right + dom.getWindowScrollLeft() - 15,
- top: rect.top + dom.getWindowScrollTop() + verticalCompensation,
- bottom: rect.bottom + dom.getWindowScrollTop()
- };
- if (x <= holderPos.left || x > holderPos.right || y <= holderPos.top || y > holderPos.bottom) {
- this.hide();
- } else {
- this.editor.setPosition(x, y);
- }
- },
- onMouseDown: function(event) {
- this.mouseDown = true;
- if (!this.hot.view || !this.hot.view.wt) {
- return;
- }
- if (!this.contextMenuEvent && !this.targetIsCommentTextArea(event) && !this.targetIsCellWithComment(event)) {
- this.hide();
- }
- this.contextMenuEvent = false;
- },
- onMouseOver: function(event) {
- if (this.mouseDown || this.editor.isFocused()) {
- return;
- }
- if (this.targetIsCellWithComment(event)) {
- var coordinates = this.hot.view.wt.wtTable.getCoords(event.target);
- var range = {from: new WalkontableCellCoords(coordinates.row, coordinates.col)};
- this.setRange(range);
- this.show();
- } else if (!this.targetIsCommentTextArea(event) && !this.editor.isFocused()) {
- this.hide();
- }
- },
- onMouseMove: function(event) {
- var $__5 = this;
- if (this.targetIsCommentTextArea(event)) {
- this.mouseDown = true;
- clearTimeout(this.timer);
- this.timer = setTimeout((function() {
- $__5.mouseDown = false;
- }), 200);
- }
- },
- onMouseUp: function(event) {
- this.mouseDown = false;
- },
- onAfterRenderer: function(TD, cellProperties) {
- if (cellProperties.comment) {
- dom.addClass(TD, cellProperties.commentedCellClassName);
- }
- },
- onEditorBlur: function(event) {
- this.saveComment();
- },
- checkSelectionCommentsConsistency: function() {
- var hasComment = false;
- var cell = this.hot.getSelectedRange().from;
- if (this.hot.getCellMeta(cell.row, cell.col).comment) {
- hasComment = true;
- }
- return hasComment;
- },
- onContextMenuAddComment: function() {
- var $__5 = this;
- var coords = this.hot.getSelectedRange();
- this.contextMenuEvent = true;
- this.setRange({from: coords.from});
- this.show();
- setTimeout((function() {
- if ($__5.hot) {
- $__5.hot.deselectCell();
- $__5.editor.focus();
- }
- }), 10);
- },
- onContextMenuRemoveComment: function(key, selection) {
- this.contextMenuEvent = true;
- this.removeCommentAtCell(selection.start.row, selection.start.col);
- },
- addToContextMenu: function(defaultOptions) {
- var $__5 = this;
- defaultOptions.items.push(Handsontable.ContextMenu.SEPARATOR, {
- key: 'commentsAddEdit',
- name: (function() {
- return $__5.checkSelectionCommentsConsistency() ? 'Edit Comment' : 'Add Comment';
- }),
- callback: (function() {
- return $__5.onContextMenuAddComment();
- }),
- disabled: function() {
- return false;
- }
- }, {
- key: 'commentsRemove',
- name: function() {
- return 'Delete Comment';
- },
- callback: (function(key, selection) {
- return $__5.onContextMenuRemoveComment(key, selection);
- }),
- disabled: (function() {
- return !$__5.checkSelectionCommentsConsistency();
- })
- });
- },
- destroy: function() {
- if (this.eventManager) {
- this.eventManager.clear();
- }
- if (this.editor) {
- this.editor.destroy();
- }
- $traceurRuntime.superGet(this, $Comments.prototype, "destroy").call(this);
- }
- }, {}, BasePlugin);
- ;
- registerPlugin('comments', Comments);
-
- //#
- },{"./../../3rdparty/walkontable/src/cell/coords.js":5,"./../../dom.js":27,"./../../eventManager.js":41,"./../../plugins.js":45,"./../_base.js":46,"./commentEditor.js":50}],52:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- ContextMenu: {get: function() {
- return ContextMenu;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_helpers_46_js__,
- $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_eventManager_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__;
- var helper = ($___46__46__47__46__46__47_helpers_46_js__ = require("./../../helpers.js"), $___46__46__47__46__46__47_helpers_46_js__ && $___46__46__47__46__46__47_helpers_46_js__.__esModule && $___46__46__47__46__46__47_helpers_46_js__ || {default: $___46__46__47__46__46__47_helpers_46_js__});
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47__46__46__47_eventManager_46_js__ = require("./../../eventManager.js"), $___46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- ;
- function ContextMenu(instance, customOptions) {
- this.instance = instance;
- var contextMenu = this;
- contextMenu.menus = [];
- contextMenu.htMenus = {};
- contextMenu.triggerRows = [];
- contextMenu.eventManager = eventManagerObject(contextMenu);
- this.enabled = true;
- this.instance.addHook('afterDestroy', function() {
- contextMenu.destroy();
- });
- this.defaultOptions = {items: [{
- key: 'row_above',
- name: 'Insert row above',
- callback: function(key, selection) {
- this.alter("insert_row", selection.start.row);
- },
- disabled: function() {
- var selected = this.getSelected(),
- entireColumnSelection = [0, selected[1], this.countRows() - 1, selected[1]],
- columnSelected = entireColumnSelection.join(',') == selected.join(',');
- return selected[0] < 0 || this.countRows() >= this.getSettings().maxRows || columnSelected;
- }
- }, {
- key: 'row_below',
- name: 'Insert row below',
- callback: function(key, selection) {
- this.alter("insert_row", selection.end.row + 1);
- },
- disabled: function() {
- var selected = this.getSelected(),
- entireColumnSelection = [0, selected[1], this.countRows() - 1, selected[1]],
- columnSelected = entireColumnSelection.join(',') == selected.join(',');
- return this.getSelected()[0] < 0 || this.countRows() >= this.getSettings().maxRows || columnSelected;
- }
- }, ContextMenu.SEPARATOR, {
- key: 'col_left',
- name: 'Insert column on the left',
- callback: function(key, selection) {
- this.alter("insert_col", selection.start.col);
- },
- disabled: function() {
- if (!this.isColumnModificationAllowed()) {
- return true;
- }
- var selected = this.getSelected(),
- entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1],
- rowSelected = entireRowSelection.join(',') == selected.join(',');
- return this.getSelected()[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
- }
- }, {
- key: 'col_right',
- name: 'Insert column on the right',
- callback: function(key, selection) {
- this.alter("insert_col", selection.end.col + 1);
- },
- disabled: function() {
- if (!this.isColumnModificationAllowed()) {
- return true;
- }
- var selected = this.getSelected(),
- entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1],
- rowSelected = entireRowSelection.join(',') == selected.join(',');
- return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
- }
- }, ContextMenu.SEPARATOR, {
- key: 'remove_row',
- name: 'Remove row',
- callback: function(key, selection) {
- var amount = selection.end.row - selection.start.row + 1;
- this.alter("remove_row", selection.start.row, amount);
- },
- disabled: function() {
- var selected = this.getSelected(),
- entireColumnSelection = [0, selected[1], this.countRows() - 1, selected[1]],
- columnSelected = entireColumnSelection.join(',') == selected.join(',');
- return (selected[0] < 0 || columnSelected);
- }
- }, {
- key: 'remove_col',
- name: 'Remove column',
- callback: function(key, selection) {
- var amount = selection.end.col - selection.start.col + 1;
- this.alter("remove_col", selection.start.col, amount);
- },
- disabled: function() {
- if (!this.isColumnModificationAllowed()) {
- return true;
- }
- var selected = this.getSelected(),
- entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1],
- rowSelected = entireRowSelection.join(',') == selected.join(',');
- return (selected[1] < 0 || rowSelected);
- }
- }, ContextMenu.SEPARATOR, {
- key: 'undo',
- name: 'Undo',
- callback: function() {
- this.undo();
- },
- disabled: function() {
- return this.undoRedo && !this.undoRedo.isUndoAvailable();
- }
- }, {
- key: 'redo',
- name: 'Redo',
- callback: function() {
- this.redo();
- },
- disabled: function() {
- return this.undoRedo && !this.undoRedo.isRedoAvailable();
- }
- }, ContextMenu.SEPARATOR, {
- key: 'make_read_only',
- name: function() {
- var label = "Read only";
- var atLeastOneReadOnly = contextMenu.checkSelectionReadOnlyConsistency(this);
- if (atLeastOneReadOnly) {
- label = contextMenu.markSelected(label);
- }
- return label;
- },
- callback: function() {
- var atLeastOneReadOnly = contextMenu.checkSelectionReadOnlyConsistency(this);
- var that = this;
- this.getSelectedRange().forAll(function(r, c) {
- that.getCellMeta(r, c).readOnly = atLeastOneReadOnly ? false : true;
- });
- this.render();
- }
- }, ContextMenu.SEPARATOR, {
- key: 'alignment',
- name: 'Alignment',
- submenu: {items: [{
- name: function() {
- var label = "Left";
- var hasClass = contextMenu.checkSelectionAlignment(this, 'htLeft');
- if (hasClass) {
- label = contextMenu.markSelected(label);
- }
- return label;
- },
- callback: function() {
- align.call(this, this.getSelectedRange(), 'horizontal', 'htLeft');
- },
- disabled: false
- }, {
- name: function() {
- var label = "Center";
- var hasClass = contextMenu.checkSelectionAlignment(this, 'htCenter');
- if (hasClass) {
- label = contextMenu.markSelected(label);
- }
- return label;
- },
- callback: function() {
- align.call(this, this.getSelectedRange(), 'horizontal', 'htCenter');
- },
- disabled: false
- }, {
- name: function() {
- var label = "Right";
- var hasClass = contextMenu.checkSelectionAlignment(this, 'htRight');
- if (hasClass) {
- label = contextMenu.markSelected(label);
- }
- return label;
- },
- callback: function() {
- align.call(this, this.getSelectedRange(), 'horizontal', 'htRight');
- },
- disabled: false
- }, {
- name: function() {
- var label = "Justify";
- var hasClass = contextMenu.checkSelectionAlignment(this, 'htJustify');
- if (hasClass) {
- label = contextMenu.markSelected(label);
- }
- return label;
- },
- callback: function() {
- align.call(this, this.getSelectedRange(), 'horizontal', 'htJustify');
- },
- disabled: false
- }, ContextMenu.SEPARATOR, {
- name: function() {
- var label = "Top";
- var hasClass = contextMenu.checkSelectionAlignment(this, 'htTop');
- if (hasClass) {
- label = contextMenu.markSelected(label);
- }
- return label;
- },
- callback: function() {
- align.call(this, this.getSelectedRange(), 'vertical', 'htTop');
- },
- disabled: false
- }, {
- name: function() {
- var label = "Middle";
- var hasClass = contextMenu.checkSelectionAlignment(this, 'htMiddle');
- if (hasClass) {
- label = contextMenu.markSelected(label);
- }
- return label;
- },
- callback: function() {
- align.call(this, this.getSelectedRange(), 'vertical', 'htMiddle');
- },
- disabled: false
- }, {
- name: function() {
- var label = "Bottom";
- var hasClass = contextMenu.checkSelectionAlignment(this, 'htBottom');
- if (hasClass) {
- label = contextMenu.markSelected(label);
- }
- return label;
- },
- callback: function() {
- align.call(this, this.getSelectedRange(), 'vertical', 'htBottom');
- },
- disabled: false
- }]}
- }]};
- contextMenu.options = {};
- helper.extend(contextMenu.options, this.options);
- this.bindMouseEvents();
- this.markSelected = function(label) {
- return "<span class='selected'>" + String.fromCharCode(10003) + "</span>" + label;
- };
- this.checkSelectionAlignment = function(hot, className) {
- var hasAlignment = false;
- hot.getSelectedRange().forAll(function(r, c) {
- var metaClassName = hot.getCellMeta(r, c).className;
- if (metaClassName && metaClassName.indexOf(className) != -1) {
- hasAlignment = true;
- return false;
- }
- });
- return hasAlignment;
- };
- if (!this.instance.getSettings().allowInsertRow) {
- var rowAboveIndex = findIndexByKey(this.defaultOptions.items, 'row_above');
- this.defaultOptions.items.splice(rowAboveIndex, 1);
- var rowBelowIndex = findIndexByKey(this.defaultOptions.items, 'row_above');
- this.defaultOptions.items.splice(rowBelowIndex, 1);
- this.defaultOptions.items.splice(rowBelowIndex, 1);
- }
- if (!this.instance.getSettings().allowInsertColumn) {
- var colLeftIndex = findIndexByKey(this.defaultOptions.items, 'col_left');
- this.defaultOptions.items.splice(colLeftIndex, 1);
- var colRightIndex = findIndexByKey(this.defaultOptions.items, 'col_right');
- this.defaultOptions.items.splice(colRightIndex, 1);
- this.defaultOptions.items.splice(colRightIndex, 1);
- }
- var removeRow = false;
- var removeCol = false;
- var removeRowIndex,
- removeColumnIndex;
- if (!this.instance.getSettings().allowRemoveRow) {
- removeRowIndex = findIndexByKey(this.defaultOptions.items, 'remove_row');
- this.defaultOptions.items.splice(removeRowIndex, 1);
- removeRow = true;
- }
- if (!this.instance.getSettings().allowRemoveColumn) {
- removeColumnIndex = findIndexByKey(this.defaultOptions.items, 'remove_col');
- this.defaultOptions.items.splice(removeColumnIndex, 1);
- removeCol = true;
- }
- if (removeRow && removeCol) {
- this.defaultOptions.items.splice(removeColumnIndex, 1);
- }
- this.checkSelectionReadOnlyConsistency = function(hot) {
- var atLeastOneReadOnly = false;
- hot.getSelectedRange().forAll(function(r, c) {
- if (hot.getCellMeta(r, c).readOnly) {
- atLeastOneReadOnly = true;
- return false;
- }
- });
- return atLeastOneReadOnly;
- };
- Handsontable.hooks.run(instance, 'afterContextMenuDefaultOptions', this.defaultOptions);
- }
- ContextMenu.prototype.createMenu = function(menuName, row) {
- if (menuName) {
- menuName = menuName.replace(/ /g, '_');
- menuName = 'htContextSubMenu_' + menuName;
- }
- var menu;
- if (menuName) {
- menu = document.querySelector('.htContextMenu.' + menuName);
- } else {
- menu = document.querySelector('.htContextMenu');
- }
- if (!menu) {
- menu = document.createElement('DIV');
- dom.addClass(menu, 'htContextMenu');
- if (menuName) {
- dom.addClass(menu, menuName);
- }
- document.getElementsByTagName('body')[0].appendChild(menu);
- }
- if (this.menus.indexOf(menu) < 0) {
- this.menus.push(menu);
- row = row || 0;
- this.triggerRows.push(row);
- }
- return menu;
- };
- ContextMenu.prototype.bindMouseEvents = function() {
- function contextMenuOpenListener(event) {
- var settings = this.instance.getSettings(),
- showRowHeaders = this.instance.getSettings().rowHeaders,
- showColHeaders = this.instance.getSettings().colHeaders,
- containsCornerHeader,
- element,
- items,
- menu;
- function isValidElement(element) {
- return element.nodeName === 'TD' || element.parentNode.nodeName === 'TD';
- }
- element = event.realTarget;
- this.closeAll();
- event.preventDefault();
- helper.stopPropagation(event);
- if (!(showRowHeaders || showColHeaders)) {
- if (!isValidElement(element) && !(dom.hasClass(element, 'current') && dom.hasClass(element, 'wtBorder'))) {
- return;
- }
- } else if (showRowHeaders && showColHeaders) {
- containsCornerHeader = element.parentNode.querySelectorAll('.cornerHeader').length > 0;
- if (containsCornerHeader) {
- return;
- }
- }
- menu = this.createMenu();
- items = this.getItems(settings.contextMenu);
- this.show(menu, items);
- this.setMenuPosition(event, menu);
- this.eventManager.addEventListener(document.documentElement, 'mousedown', helper.proxy(ContextMenu.prototype.closeAll, this));
- }
- var eventManager = eventManagerObject(this.instance);
- eventManager.addEventListener(this.instance.rootElement, 'contextmenu', helper.proxy(contextMenuOpenListener, this));
- };
- ContextMenu.prototype.bindTableEvents = function() {
- this._afterScrollCallback = function() {};
- this.instance.addHook('afterScrollVertically', this._afterScrollCallback);
- this.instance.addHook('afterScrollHorizontally', this._afterScrollCallback);
- };
- ContextMenu.prototype.unbindTableEvents = function() {
- if (this._afterScrollCallback) {
- this.instance.removeHook('afterScrollVertically', this._afterScrollCallback);
- this.instance.removeHook('afterScrollHorizontally', this._afterScrollCallback);
- this._afterScrollCallback = null;
- }
- };
- ContextMenu.prototype.performAction = function(event, hot) {
- var contextMenu = this;
- var selectedItemIndex = hot.getSelected()[0];
- var selectedItem = hot.getData()[selectedItemIndex];
- if (selectedItem.disabled === true || (typeof selectedItem.disabled == 'function' && selectedItem.disabled.call(this.instance) === true)) {
- return;
- }
- if (!selectedItem.hasOwnProperty('submenu')) {
- if (typeof selectedItem.callback != 'function') {
- return;
- }
- var selRange = this.instance.getSelectedRange();
- var normalizedSelection = ContextMenu.utils.normalizeSelection(selRange);
- selectedItem.callback.call(this.instance, selectedItem.key, normalizedSelection, event);
- contextMenu.closeAll();
- }
- };
- ContextMenu.prototype.unbindMouseEvents = function() {
- this.eventManager.clear();
- var eventManager = eventManagerObject(this.instance);
- eventManager.removeEventListener(this.instance.rootElement, 'contextmenu');
- };
- ContextMenu.prototype.show = function(menu, items) {
- var that = this;
- menu.removeAttribute('style');
- menu.style.display = 'block';
- var settings = {
- data: items,
- colHeaders: false,
- colWidths: [200],
- readOnly: true,
- copyPaste: false,
- columns: [{
- data: 'name',
- renderer: helper.proxy(this.renderer, this)
- }],
- renderAllRows: true,
- beforeKeyDown: function(event) {
- that.onBeforeKeyDown(event, htContextMenu);
- },
- afterOnCellMouseOver: function(event, coords, TD) {
- that.onCellMouseOver(event, coords, TD, htContextMenu);
- }
- };
- var htContextMenu = new Handsontable(menu, settings);
- htContextMenu.isHotTableEnv = this.instance.isHotTableEnv;
- Handsontable.eventManager.isHotTableEnv = this.instance.isHotTableEnv;
- this.eventManager.removeEventListener(menu, 'mousedown');
- this.eventManager.addEventListener(menu, 'mousedown', function(event) {
- that.performAction(event, htContextMenu);
- });
- this.bindTableEvents();
- htContextMenu.listen();
- this.htMenus[htContextMenu.guid] = htContextMenu;
- Handsontable.hooks.run(this.instance, 'afterContextMenuShow', htContextMenu);
- };
- ContextMenu.prototype.close = function(menu) {
- this.hide(menu);
- this.eventManager.clear();
- this.unbindTableEvents();
- this.instance.listen();
- };
- ContextMenu.prototype.closeAll = function() {
- while (this.menus.length > 0) {
- var menu = this.menus.pop();
- if (menu) {
- this.close(menu);
- }
- }
- this.triggerRows = [];
- };
- ContextMenu.prototype.closeLastOpenedSubMenu = function() {
- var menu = this.menus.pop();
- if (menu) {
- this.hide(menu);
- }
- };
- ContextMenu.prototype.hide = function(menu) {
- menu.style.display = 'none';
- var instance = this.htMenus[menu.id];
- Handsontable.hooks.run(this.instance, 'afterContextMenuHide', instance);
- instance.destroy();
- delete this.htMenus[menu.id];
- };
- ContextMenu.prototype.renderer = function(instance, TD, row, col, prop, value) {
- var contextMenu = this;
- var item = instance.getData()[row];
- var wrapper = document.createElement('DIV');
- if (typeof value === 'function') {
- value = value.call(this.instance);
- }
- dom.empty(TD);
- TD.appendChild(wrapper);
- if (itemIsSeparator(item)) {
- dom.addClass(TD, 'htSeparator');
- } else {
- dom.fastInnerHTML(wrapper, value);
- }
- if (itemIsDisabled(item)) {
- dom.addClass(TD, 'htDisabled');
- this.eventManager.addEventListener(wrapper, 'mouseenter', function() {
- instance.deselectCell();
- });
- } else {
- if (isSubMenu(item)) {
- dom.addClass(TD, 'htSubmenu');
- this.eventManager.addEventListener(wrapper, 'mouseenter', function() {
- instance.selectCell(row, col);
- });
- } else {
- dom.removeClass(TD, 'htSubmenu');
- dom.removeClass(TD, 'htDisabled');
- this.eventManager.addEventListener(wrapper, 'mouseenter', function() {
- instance.selectCell(row, col);
- });
- }
- }
- function isSubMenu(item) {
- return item.hasOwnProperty('submenu');
- }
- function itemIsSeparator(item) {
- return new RegExp(ContextMenu.SEPARATOR.name, 'i').test(item.name);
- }
- function itemIsDisabled(item) {
- return item.disabled === true || (typeof item.disabled == 'function' && item.disabled.call(contextMenu.instance) === true);
- }
- };
- ContextMenu.prototype.onCellMouseOver = function(event, coords, TD, hot) {
- var menusLength = this.menus.length;
- if (menusLength > 0) {
- var lastMenu = this.menus[menusLength - 1];
- if (lastMenu.id != hot.guid) {
- this.closeLastOpenedSubMenu();
- }
- } else {
- this.closeLastOpenedSubMenu();
- }
- if (TD.className.indexOf('htSubmenu') != -1) {
- var selectedItem = hot.getData()[coords.row];
- var items = this.getItems(selectedItem.submenu);
- var subMenu = this.createMenu(selectedItem.name, coords.row);
- var tdCoords = TD.getBoundingClientRect();
- this.show(subMenu, items);
- this.setSubMenuPosition(tdCoords, subMenu);
- }
- };
- ContextMenu.prototype.onBeforeKeyDown = function(event, instance) {
- dom.enableImmediatePropagation(event);
- var contextMenu = this;
- var selection = instance.getSelected();
- switch (event.keyCode) {
- case helper.keyCode.ESCAPE:
- contextMenu.closeAll();
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case helper.keyCode.ENTER:
- if (selection) {
- contextMenu.performAction(event, instance);
- }
- break;
- case helper.keyCode.ARROW_DOWN:
- if (!selection) {
- selectFirstCell(instance, contextMenu);
- } else {
- selectNextCell(selection[0], selection[1], instance, contextMenu);
- }
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case helper.keyCode.ARROW_UP:
- if (!selection) {
- selectLastCell(instance, contextMenu);
- } else {
- selectPrevCell(selection[0], selection[1], instance, contextMenu);
- }
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case helper.keyCode.ARROW_RIGHT:
- if (selection) {
- var row = selection[0];
- var cell = instance.getCell(selection[0], 0);
- if (ContextMenu.utils.hasSubMenu(cell)) {
- openSubMenu(instance, contextMenu, cell, row);
- }
- }
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case helper.keyCode.ARROW_LEFT:
- if (selection) {
- if (instance.rootElement.className.indexOf('htContextSubMenu_') != -1) {
- contextMenu.closeLastOpenedSubMenu();
- var index = contextMenu.menus.length;
- if (index > 0) {
- var menu = contextMenu.menus[index - 1];
- var triggerRow = contextMenu.triggerRows.pop();
- instance = this.htMenus[menu.id];
- instance.selectCell(triggerRow, 0);
- }
- }
- event.preventDefault();
- event.stopImmediatePropagation();
- }
- break;
- }
- function selectFirstCell(instance) {
- var firstCell = instance.getCell(0, 0);
- if (ContextMenu.utils.isSeparator(firstCell) || ContextMenu.utils.isDisabled(firstCell)) {
- selectNextCell(0, 0, instance);
- } else {
- instance.selectCell(0, 0);
- }
- }
- function selectLastCell(instance) {
- var lastRow = instance.countRows() - 1;
- var lastCell = instance.getCell(lastRow, 0);
- if (ContextMenu.utils.isSeparator(lastCell) || ContextMenu.utils.isDisabled(lastCell)) {
- selectPrevCell(lastRow, 0, instance);
- } else {
- instance.selectCell(lastRow, 0);
- }
- }
- function selectNextCell(row, col, instance) {
- var nextRow = row + 1;
- var nextCell = nextRow < instance.countRows() ? instance.getCell(nextRow, col) : null;
- if (!nextCell) {
- return;
- }
- if (ContextMenu.utils.isSeparator(nextCell) || ContextMenu.utils.isDisabled(nextCell)) {
- selectNextCell(nextRow, col, instance);
- } else {
- instance.selectCell(nextRow, col);
- }
- }
- function selectPrevCell(row, col, instance) {
- var prevRow = row - 1;
- var prevCell = prevRow >= 0 ? instance.getCell(prevRow, col) : null;
- if (!prevCell) {
- return;
- }
- if (ContextMenu.utils.isSeparator(prevCell) || ContextMenu.utils.isDisabled(prevCell)) {
- selectPrevCell(prevRow, col, instance);
- } else {
- instance.selectCell(prevRow, col);
- }
- }
- function openSubMenu(instance, contextMenu, cell, row) {
- var selectedItem = instance.getData()[row];
- var items = contextMenu.getItems(selectedItem.submenu);
- var subMenu = contextMenu.createMenu(selectedItem.name, row);
- var coords = cell.getBoundingClientRect();
- var subMenuInstance = contextMenu.show(subMenu, items);
- contextMenu.setSubMenuPosition(coords, subMenu);
- subMenuInstance.selectCell(0, 0);
- }
- };
- function findByKey(items, key) {
- for (var i = 0,
- ilen = items.length; i < ilen; i++) {
- if (items[i].key === key) {
- return items[i];
- }
- }
- }
- function findIndexByKey(items, key) {
- for (var i = 0,
- ilen = items.length; i < ilen; i++) {
- if (items[i].key === key) {
- return i;
- }
- }
- }
- ContextMenu.prototype.getItems = function(items) {
- var menu,
- item;
- function ContextMenuItem(rawItem) {
- if (typeof rawItem == 'string') {
- this.name = rawItem;
- } else {
- helper.extend(this, rawItem);
- }
- }
- ContextMenuItem.prototype = items;
- if (items && items.items) {
- items = items.items;
- }
- if (items === true) {
- items = this.defaultOptions.items;
- }
- if (1 == 1) {
- menu = [];
- for (var key in items) {
- if (items.hasOwnProperty(key)) {
- if (typeof items[key] === 'string') {
- item = findByKey(this.defaultOptions.items, items[key]);
- } else {
- item = findByKey(this.defaultOptions.items, key);
- }
- if (!item) {
- item = items[key];
- }
- item = new ContextMenuItem(item);
- if (typeof items[key] === 'object') {
- helper.extend(item, items[key]);
- }
- if (!item.key) {
- item.key = key;
- }
- menu.push(item);
- }
- }
- }
- return menu;
- };
- ContextMenu.prototype.setSubMenuPosition = function(coords, menu) {
- var scrollTop = dom.getWindowScrollTop();
- var scrollLeft = dom.getWindowScrollLeft();
- var cursor = {
- top: scrollTop + coords.top,
- topRelative: coords.top,
- left: coords.left,
- leftRelative: coords.left - scrollLeft,
- scrollTop: scrollTop,
- scrollLeft: scrollLeft,
- cellHeight: coords.height,
- cellWidth: coords.width
- };
- if (this.menuFitsBelowCursor(cursor, menu, document.body.clientWidth)) {
- this.positionMenuBelowCursor(cursor, menu, true);
- } else {
- if (this.menuFitsAboveCursor(cursor, menu)) {
- this.positionMenuAboveCursor(cursor, menu, true);
- } else {
- this.positionMenuBelowCursor(cursor, menu, true);
- }
- }
- if (this.menuFitsOnRightOfCursor(cursor, menu, document.body.clientWidth)) {
- this.positionMenuOnRightOfCursor(cursor, menu, true);
- } else {
- this.positionMenuOnLeftOfCursor(cursor, menu, true);
- }
- };
- ContextMenu.prototype.setMenuPosition = function(event, menu) {
- var scrollTop = dom.getWindowScrollTop();
- var scrollLeft = dom.getWindowScrollLeft();
- var cursorY = event.pageY || (event.clientY + scrollTop);
- var cursorX = event.pageX || (event.clientX + scrollLeft);
- var cursor = {
- top: cursorY,
- topRelative: cursorY - scrollTop,
- left: cursorX,
- leftRelative: cursorX - scrollLeft,
- scrollTop: scrollTop,
- scrollLeft: scrollLeft,
- cellHeight: event.target.clientHeight,
- cellWidth: event.target.clientWidth
- };
- if (this.menuFitsBelowCursor(cursor, menu, document.body.clientHeight)) {
- this.positionMenuBelowCursor(cursor, menu);
- } else {
- if (this.menuFitsAboveCursor(cursor, menu)) {
- this.positionMenuAboveCursor(cursor, menu);
- } else {
- this.positionMenuBelowCursor(cursor, menu);
- }
- }
- if (this.menuFitsOnRightOfCursor(cursor, menu, document.body.clientWidth)) {
- this.positionMenuOnRightOfCursor(cursor, menu);
- } else {
- this.positionMenuOnLeftOfCursor(cursor, menu);
- }
- };
- ContextMenu.prototype.menuFitsAboveCursor = function(cursor, menu) {
- return cursor.topRelative >= menu.offsetHeight;
- };
- ContextMenu.prototype.menuFitsBelowCursor = function(cursor, menu, viewportHeight) {
- return cursor.topRelative + menu.offsetHeight <= viewportHeight;
- };
- ContextMenu.prototype.menuFitsOnRightOfCursor = function(cursor, menu, viewportHeight) {
- return cursor.leftRelative + menu.offsetWidth <= viewportHeight;
- };
- ContextMenu.prototype.positionMenuBelowCursor = function(cursor, menu) {
- menu.style.top = cursor.top + 'px';
- };
- ContextMenu.prototype.positionMenuAboveCursor = function(cursor, menu, subMenu) {
- if (subMenu) {
- menu.style.top = (cursor.top + cursor.cellHeight - menu.offsetHeight) + 'px';
- } else {
- menu.style.top = (cursor.top - menu.offsetHeight) + 'px';
- }
- };
- ContextMenu.prototype.positionMenuOnRightOfCursor = function(cursor, menu, subMenu) {
- if (subMenu) {
- menu.style.left = 1 + cursor.left + cursor.cellWidth + 'px';
- } else {
- menu.style.left = 1 + cursor.left + 'px';
- }
- };
- ContextMenu.prototype.positionMenuOnLeftOfCursor = function(cursor, menu, subMenu) {
- if (subMenu) {
- menu.style.left = (cursor.left - menu.offsetWidth) + 'px';
- } else {
- menu.style.left = (cursor.left - menu.offsetWidth) + 'px';
- }
- };
- ContextMenu.utils = {};
- ContextMenu.utils.normalizeSelection = function(selRange) {
- return {
- start: selRange.getTopLeftCorner(),
- end: selRange.getBottomRightCorner()
- };
- };
- ContextMenu.utils.isSeparator = function(cell) {
- return dom.hasClass(cell, 'htSeparator');
- };
- ContextMenu.utils.hasSubMenu = function(cell) {
- return dom.hasClass(cell, 'htSubmenu');
- };
- ContextMenu.utils.isDisabled = function(cell) {
- return dom.hasClass(cell, 'htDisabled');
- };
- ContextMenu.prototype.enable = function() {
- if (!this.enabled) {
- this.enabled = true;
- this.bindMouseEvents();
- }
- };
- ContextMenu.prototype.disable = function() {
- if (this.enabled) {
- this.enabled = false;
- this.closeAll();
- this.unbindMouseEvents();
- this.unbindTableEvents();
- }
- };
- ContextMenu.prototype.destroy = function() {
- this.closeAll();
- while (this.menus.length > 0) {
- var menu = this.menus.pop();
- this.triggerRows.pop();
- if (menu) {
- this.close(menu);
- if (!this.isMenuEnabledByOtherHotInstance()) {
- this.removeMenu(menu);
- }
- }
- }
- this.unbindMouseEvents();
- this.unbindTableEvents();
- };
- ContextMenu.prototype.isMenuEnabledByOtherHotInstance = function() {
- var hotContainers = document.querySelectorAll('.handsontable');
- var menuEnabled = false;
- for (var i = 0,
- len = hotContainers.length; i < len; i++) {
- var instance = this.htMenus[hotContainers[i].id];
- if (instance && instance.getSettings().contextMenu) {
- menuEnabled = true;
- break;
- }
- }
- return menuEnabled;
- };
- ContextMenu.prototype.removeMenu = function(menu) {
- if (menu.parentNode) {
- this.menu.parentNode.removeChild(menu);
- }
- };
- ContextMenu.prototype.align = function(range, type, alignment) {
- align.call(this, range, type, alignment);
- };
- ContextMenu.SEPARATOR = {name: "---------"};
- function updateHeight() {
- if (this.rootElement.className.indexOf('htContextMenu')) {
- return;
- }
- var realSeparatorHeight = 0,
- realEntrySize = 0,
- dataSize = this.getSettings().data.length,
- currentHiderWidth = parseInt(this.view.wt.wtTable.hider.style.width, 10);
- for (var i = 0; i < dataSize; i++) {
- if (this.getSettings().data[i].name == ContextMenu.SEPARATOR.name) {
- realSeparatorHeight += 1;
- } else {
- realEntrySize += 26;
- }
- }
- this.view.wt.wtTable.holder.style.width = currentHiderWidth + 22 + "px";
- this.view.wt.wtTable.holder.style.height = realEntrySize + realSeparatorHeight + 4 + "px";
- }
- function prepareVerticalAlignClass(className, alignment) {
- if (className.indexOf(alignment) != -1) {
- return className;
- }
- className = className.replace('htTop', '').replace('htMiddle', '').replace('htBottom', '').replace(' ', '');
- className += " " + alignment;
- return className;
- }
- function prepareHorizontalAlignClass(className, alignment) {
- if (className.indexOf(alignment) != -1) {
- return className;
- }
- className = className.replace('htLeft', '').replace('htCenter', '').replace('htRight', '').replace('htJustify', '').replace(' ', '');
- className += " " + alignment;
- return className;
- }
- function getAlignmentClasses(range) {
- var classesArray = {};
- for (var row = range.from.row; row <= range.to.row; row++) {
- for (var col = range.from.col; col <= range.to.col; col++) {
- if (!classesArray[row]) {
- classesArray[row] = [];
- }
- classesArray[row][col] = this.getCellMeta(row, col).className;
- }
- }
- return classesArray;
- }
- function doAlign(row, col, type, alignment) {
- var cellMeta = this.getCellMeta(row, col),
- className = alignment;
- if (cellMeta.className) {
- if (type === 'vertical') {
- className = prepareVerticalAlignClass(cellMeta.className, alignment);
- } else {
- className = prepareHorizontalAlignClass(cellMeta.className, alignment);
- }
- }
- this.setCellMeta(row, col, 'className', className);
- }
- function align(range, type, alignment) {
- var stateBefore = getAlignmentClasses.call(this, range);
- this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
- if (range.from.row == range.to.row && range.from.col == range.to.col) {
- doAlign.call(this, range.from.row, range.from.col, type, alignment);
- } else {
- for (var row = range.from.row; row <= range.to.row; row++) {
- for (var col = range.from.col; col <= range.to.col; col++) {
- doAlign.call(this, row, col, type, alignment);
- }
- }
- }
- this.render();
- }
- function init() {
- var instance = this;
- var contextMenuSetting = instance.getSettings().contextMenu;
- var customOptions = helper.isObject(contextMenuSetting) ? contextMenuSetting : {};
- if (contextMenuSetting) {
- if (!instance.contextMenu) {
- instance.contextMenu = new ContextMenu(instance, customOptions);
- }
- instance.contextMenu.enable();
- } else if (instance.contextMenu) {
- instance.contextMenu.destroy();
- delete instance.contextMenu;
- }
- }
- Handsontable.hooks.add('afterInit', init);
- Handsontable.hooks.add('afterUpdateSettings', init);
- Handsontable.hooks.add('afterInit', updateHeight);
- Handsontable.hooks.register('afterContextMenuDefaultOptions');
- Handsontable.hooks.register('afterContextMenuShow');
- Handsontable.hooks.register('afterContextMenuHide');
- Handsontable.ContextMenu = ContextMenu;
-
- //#
- },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../helpers.js":42,"./../../plugins.js":45}],53:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- ContextMenuCopyPaste: {get: function() {
- return ContextMenuCopyPaste;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_eventManager_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__,
- $___46__46__47__95_base_46_js__,
- $__zeroclipboard__;
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47__46__46__47_eventManager_46_js__ = require("./../../eventManager.js"), $___46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- 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;
- var ZeroClipboard = ($__zeroclipboard__ = require("zeroclipboard"), $__zeroclipboard__ && $__zeroclipboard__.__esModule && $__zeroclipboard__ || {default: $__zeroclipboard__}).default;
- var ContextMenuCopyPaste = function ContextMenuCopyPaste(hotInstance) {
- var $__4 = this;
- $traceurRuntime.superConstructor($ContextMenuCopyPaste).call(this, hotInstance);
- this.swfPath = null;
- this.hotContextMenu = null;
- this.outsideClickDeselectsCache = null;
- this.hot.addHook('afterContextMenuShow', (function(htContextMenu) {
- return $__4.setupZeroClipboard(htContextMenu);
- }));
- this.hot.addHook('afterInit', (function() {
- return $__4.afterInit();
- }));
- this.hot.addHook('afterContextMenuDefaultOptions', (function(options) {
- return $__4.addToContextMenu(options);
- }));
- };
- var $ContextMenuCopyPaste = ContextMenuCopyPaste;
- ($traceurRuntime.createClass)(ContextMenuCopyPaste, {
- afterInit: function() {
- if (!this.hot.getSettings().contextMenuCopyPaste) {
- return;
- } else if (typeof this.hot.getSettings().contextMenuCopyPaste == 'object') {
- this.swfPath = this.hot.getSettings().contextMenuCopyPaste.swfPath;
- }
- if (typeof ZeroClipboard === 'undefined') {
- throw new Error("To be able to use the Copy/Paste feature from the context menu, you need to manualy include ZeroClipboard.js file to your website.");
- }
- try {
- new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
- } catch (exception) {
- if ('undefined' == typeof navigator.mimeTypes['application/x-shockwave-flash']) {
- throw new Error("To be able to use the Copy/Paste feature from the context menu, your browser needs to have Flash Plugin installed.");
- }
- }
- this.prepareZeroClipboard();
- },
- prepareZeroClipboard: function() {
- if (this.swfPath) {
- ZeroClipboard.config({swfPath: this.swfPath});
- }
- },
- getCopyValue: function() {
- this.hot.copyPaste.setCopyableText();
- return this.hot.copyPaste.copyPasteInstance.elTextarea.value;
- },
- addToContextMenu: function(defaultOptions) {
- if (!this.hot.getSettings().contextMenuCopyPaste) {
- return;
- }
- defaultOptions.items.unshift({
- key: 'copy',
- name: 'Copy'
- }, {
- key: 'paste',
- name: 'Paste',
- callback: function() {
- this.copyPaste.triggerPaste();
- }
- }, Handsontable.ContextMenu.SEPARATOR);
- },
- setupZeroClipboard: function(hotContextMenu) {
- var $__4 = this;
- var data,
- zeroClipboardInstance;
- if (!this.hot.getSettings().contextMenuCopyPaste) {
- return;
- }
- this.hotContextMenu = hotContextMenu;
- data = this.hotContextMenu.getData();
- for (var i = 0,
- ilen = data.length; i < ilen; i++) {
- if (data[i].key === 'copy') {
- zeroClipboardInstance = new ZeroClipboard(this.hotContextMenu.getCell(i, 0));
- zeroClipboardInstance.off();
- zeroClipboardInstance.on('copy', (function(event) {
- var clipboard = event.clipboardData;
- clipboard.setData('text/plain', $__4.getCopyValue());
- $__4.hot.getSettings().outsideClickDeselects = $__4.outsideClickDeselectsCache;
- }));
- this.bindEvents();
- break;
- }
- }
- },
- removeCurrentClass: function() {
- if (this.hotContextMenu.rootElement) {
- var element = this.hotContextMenu.rootElement.querySelector('td.current');
- if (element) {
- dom.removeClass(element, 'current');
- }
- }
- this.outsideClickDeselectsCache = this.hot.getSettings().outsideClickDeselects;
- this.hot.getSettings().outsideClickDeselects = false;
- },
- removeZeroClipboardClass: function() {
- if (this.hotContextMenu.rootElement) {
- var element = this.hotContextMenu.rootElement.querySelector('td.zeroclipboard-is-hover');
- if (element) {
- dom.removeClass(element, 'zeroclipboard-is-hover');
- }
- }
- this.hot.getSettings().outsideClickDeselects = this.outsideClickDeselectsCache;
- },
- bindEvents: function() {
- var $__4 = this;
- var eventManager = eventManagerObject(this.hotContextMenu);
- eventManager.addEventListener(document, 'mouseenter', (function() {
- return $__4.removeCurrentClass();
- }));
- eventManager.addEventListener(document, 'mouseleave', (function() {
- return $__4.removeZeroClipboardClass();
- }));
- }
- }, {}, BasePlugin);
- ;
- registerPlugin('contextMenuCopyPaste', ContextMenuCopyPaste);
-
- //#
- },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../plugins.js":45,"./../_base.js":46,"zeroclipboard":"zeroclipboard"}],54:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- CopyPaste: {get: function() {
- return CopyPaste;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_helpers_46_js__,
- $__copyPaste__,
- $__SheetClip__,
- $___46__46__47__46__46__47_plugins_46_js__,
- $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
- $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__;
- var helper = ($___46__46__47__46__46__47_helpers_46_js__ = require("./../../helpers.js"), $___46__46__47__46__46__47_helpers_46_js__ && $___46__46__47__46__46__47_helpers_46_js__.__esModule && $___46__46__47__46__46__47_helpers_46_js__ || {default: $___46__46__47__46__46__47_helpers_46_js__});
- var copyPaste = ($__copyPaste__ = require("copyPaste"), $__copyPaste__ && $__copyPaste__.__esModule && $__copyPaste__ || {default: $__copyPaste__}).default;
- var SheetClip = ($__SheetClip__ = require("SheetClip"), $__SheetClip__ && $__SheetClip__.__esModule && $__SheetClip__ || {default: $__SheetClip__}).default;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- var WalkontableCellCoords = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ = require("./../../3rdparty/walkontable/src/cell/coords.js"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__}).WalkontableCellCoords;
- var WalkontableCellRange = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ = require("./../../3rdparty/walkontable/src/cell/range.js"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__}).WalkontableCellRange;
- ;
- function CopyPastePlugin(instance) {
- var _this = this;
- this.copyPasteInstance = copyPaste();
- this.copyPasteInstance.onCut(onCut);
- this.copyPasteInstance.onPaste(onPaste);
- instance.addHook('beforeKeyDown', onBeforeKeyDown);
- function onCut() {
- if (!instance.isListening()) {
- return;
- }
- instance.selection.empty();
- }
- function onPaste(str) {
- var input,
- inputArray,
- selected,
- coordsFrom,
- coordsTo,
- cellRange,
- topLeftCorner,
- bottomRightCorner,
- areaStart,
- areaEnd;
- if (!instance.isListening() || !instance.selection.isSelected()) {
- return;
- }
- input = str;
- inputArray = SheetClip.parse(input);
- selected = instance.getSelected();
- coordsFrom = new WalkontableCellCoords(selected[0], selected[1]);
- coordsTo = new WalkontableCellCoords(selected[2], selected[3]);
- cellRange = new WalkontableCellRange(coordsFrom, coordsFrom, coordsTo);
- topLeftCorner = cellRange.getTopLeftCorner();
- bottomRightCorner = cellRange.getBottomRightCorner();
- areaStart = topLeftCorner;
- areaEnd = new WalkontableCellCoords(Math.max(bottomRightCorner.row, inputArray.length - 1 + topLeftCorner.row), Math.max(bottomRightCorner.col, inputArray[0].length - 1 + topLeftCorner.col));
- instance.addHookOnce('afterChange', function(changes, source) {
- if (changes && changes.length) {
- this.selectCell(areaStart.row, areaStart.col, areaEnd.row, areaEnd.col);
- }
- });
- instance.populateFromArray(areaStart.row, areaStart.col, inputArray, areaEnd.row, areaEnd.col, 'paste', instance.getSettings().pasteMode);
- }
- function onBeforeKeyDown(event) {
- var ctrlDown;
- if (instance.getSelected() && instance.getActiveEditor() && !instance.getActiveEditor().isOpened()) {
- if (helper.isCtrlKey(event.keyCode)) {
- _this.setCopyableText();
- event.stopImmediatePropagation();
- return;
- }
- ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
- if (event.keyCode == helper.keyCode.A && ctrlDown) {
- instance._registerTimeout(setTimeout(helper.proxy(_this.setCopyableText, _this), 0));
- }
- }
- }
- this.destroy = function() {
- this.copyPasteInstance.removeCallback(onCut);
- this.copyPasteInstance.removeCallback(onPaste);
- this.copyPasteInstance.destroy();
- instance.removeHook('beforeKeyDown', onBeforeKeyDown);
- };
- instance.addHook('afterDestroy', helper.proxy(this.destroy, this));
- this.triggerPaste = helper.proxy(this.copyPasteInstance.triggerPaste, this.copyPasteInstance);
- this.triggerCut = helper.proxy(this.copyPasteInstance.triggerCut, this.copyPasteInstance);
- this.setCopyableText = function() {
- var settings = instance.getSettings();
- var copyRowsLimit = settings.copyRowsLimit;
- var copyColsLimit = settings.copyColsLimit;
- var selRange = instance.getSelectedRange();
- var topLeft = selRange.getTopLeftCorner();
- var bottomRight = selRange.getBottomRightCorner();
- var startRow = topLeft.row;
- var startCol = topLeft.col;
- var endRow = bottomRight.row;
- var endCol = bottomRight.col;
- var finalEndRow = Math.min(endRow, startRow + copyRowsLimit - 1);
- var finalEndCol = Math.min(endCol, startCol + copyColsLimit - 1);
- instance.copyPaste.copyPasteInstance.copyable(instance.getCopyableData(startRow, startCol, finalEndRow, finalEndCol));
- if (endRow !== finalEndRow || endCol !== finalEndCol) {
- Handsontable.hooks.run(instance, "afterCopyLimit", endRow - startRow + 1, endCol - startCol + 1, copyRowsLimit, copyColsLimit);
- }
- };
- }
- function init() {
- var instance = this,
- pluginEnabled = instance.getSettings().copyPaste !== false;
- if (pluginEnabled && !instance.copyPaste) {
- instance.copyPaste = new CopyPastePlugin(instance);
- } else if (!pluginEnabled && instance.copyPaste) {
- instance.copyPaste.destroy();
- delete instance.copyPaste;
- }
- }
- Handsontable.hooks.add('afterInit', init);
- Handsontable.hooks.add('afterUpdateSettings', init);
- Handsontable.hooks.register('afterCopyLimit');
-
- //#
- },{"./../../3rdparty/walkontable/src/cell/coords.js":5,"./../../3rdparty/walkontable/src/cell/range.js":6,"./../../helpers.js":42,"./../../plugins.js":45,"SheetClip":"SheetClip","copyPaste":"copyPaste"}],55:[function(require,module,exports){
- "use strict";
- var $___46__46__47__46__46__47_plugins_46_js__,
- $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__,
- $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection_46_js__;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- var WalkontableCellRange = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ = require("./../../3rdparty/walkontable/src/cell/range.js"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__}).WalkontableCellRange;
- var WalkontableSelection = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection_46_js__ = require("./../../3rdparty/walkontable/src/selection.js"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection_46_js__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection_46_js__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection_46_js__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection_46_js__}).WalkontableSelection;
- function CustomBorders() {}
- var instance;
- var checkEnable = function(customBorders) {
- if (typeof customBorders === "boolean") {
- if (customBorders === true) {
- return true;
- }
- }
- if (typeof customBorders === "object") {
- if (customBorders.length > 0) {
- return true;
- }
- }
- return false;
- };
- var init = function() {
- if (checkEnable(this.getSettings().customBorders)) {
- if (!this.customBorders) {
- instance = this;
- this.customBorders = new CustomBorders();
- }
- }
- };
- var getSettingIndex = function(className) {
- for (var i = 0; i < instance.view.wt.selections.length; i++) {
- if (instance.view.wt.selections[i].settings.className == className) {
- return i;
- }
- }
- return -1;
- };
- var insertBorderIntoSettings = function(border) {
- var coordinates = {
- row: border.row,
- col: border.col
- };
- var selection = new WalkontableSelection(border, new WalkontableCellRange(coordinates, coordinates, coordinates));
- var index = getSettingIndex(border.className);
- if (index >= 0) {
- instance.view.wt.selections[index] = selection;
- } else {
- instance.view.wt.selections.push(selection);
- }
- };
- var prepareBorderFromCustomAdded = function(row, col, borderObj) {
- var border = createEmptyBorders(row, col);
- border = extendDefaultBorder(border, borderObj);
- this.setCellMeta(row, col, 'borders', border);
- insertBorderIntoSettings(border);
- };
- var prepareBorderFromCustomAddedRange = function(rowObj) {
- var range = rowObj.range;
- for (var row = range.from.row; row <= range.to.row; row++) {
- for (var col = range.from.col; col <= range.to.col; col++) {
- var border = createEmptyBorders(row, col);
- var add = 0;
- if (row == range.from.row) {
- add++;
- if (rowObj.hasOwnProperty('top')) {
- border.top = rowObj.top;
- }
- }
- if (row == range.to.row) {
- add++;
- if (rowObj.hasOwnProperty('bottom')) {
- border.bottom = rowObj.bottom;
- }
- }
- if (col == range.from.col) {
- add++;
- if (rowObj.hasOwnProperty('left')) {
- border.left = rowObj.left;
- }
- }
- if (col == range.to.col) {
- add++;
- if (rowObj.hasOwnProperty('right')) {
- border.right = rowObj.right;
- }
- }
- if (add > 0) {
- this.setCellMeta(row, col, 'borders', border);
- insertBorderIntoSettings(border);
- }
- }
- }
- };
- var createClassName = function(row, col) {
- return "border_row" + row + "col" + col;
- };
- var createDefaultCustomBorder = function() {
- return {
- width: 1,
- color: '#000'
- };
- };
- var createSingleEmptyBorder = function() {
- return {hide: true};
- };
- var createDefaultHtBorder = function() {
- return {
- width: 1,
- color: '#000',
- cornerVisible: false
- };
- };
- var createEmptyBorders = function(row, col) {
- return {
- className: createClassName(row, col),
- border: createDefaultHtBorder(),
- row: row,
- col: col,
- top: createSingleEmptyBorder(),
- right: createSingleEmptyBorder(),
- bottom: createSingleEmptyBorder(),
- left: createSingleEmptyBorder()
- };
- };
- var extendDefaultBorder = function(defaultBorder, customBorder) {
- if (customBorder.hasOwnProperty('border')) {
- defaultBorder.border = customBorder.border;
- }
- if (customBorder.hasOwnProperty('top')) {
- defaultBorder.top = customBorder.top;
- }
- if (customBorder.hasOwnProperty('right')) {
- defaultBorder.right = customBorder.right;
- }
- if (customBorder.hasOwnProperty('bottom')) {
- defaultBorder.bottom = customBorder.bottom;
- }
- if (customBorder.hasOwnProperty('left')) {
- defaultBorder.left = customBorder.left;
- }
- return defaultBorder;
- };
- var removeBordersFromDom = function(borderClassName) {
- var borders = document.querySelectorAll("." + borderClassName);
- for (var i = 0; i < borders.length; i++) {
- if (borders[i]) {
- if (borders[i].nodeName != 'TD') {
- var parent = borders[i].parentNode;
- if (parent.parentNode) {
- parent.parentNode.removeChild(parent);
- }
- }
- }
- }
- };
- var removeAllBorders = function(row, col) {
- var borderClassName = createClassName(row, col);
- removeBordersFromDom(borderClassName);
- this.removeCellMeta(row, col, 'borders');
- };
- var setBorder = function(row, col, place, remove) {
- var bordersMeta = this.getCellMeta(row, col).borders;
- if (!bordersMeta || bordersMeta.border == undefined) {
- bordersMeta = createEmptyBorders(row, col);
- }
- if (remove) {
- bordersMeta[place] = createSingleEmptyBorder();
- } else {
- bordersMeta[place] = createDefaultCustomBorder();
- }
- this.setCellMeta(row, col, 'borders', bordersMeta);
- var borderClassName = createClassName(row, col);
- removeBordersFromDom(borderClassName);
- insertBorderIntoSettings(bordersMeta);
- this.render();
- };
- var prepareBorder = function(range, place, remove) {
- if (range.from.row == range.to.row && range.from.col == range.to.col) {
- if (place == "noBorders") {
- removeAllBorders.call(this, range.from.row, range.from.col);
- } else {
- setBorder.call(this, range.from.row, range.from.col, place, remove);
- }
- } else {
- switch (place) {
- case "noBorders":
- for (var column = range.from.col; column <= range.to.col; column++) {
- for (var row = range.from.row; row <= range.to.row; row++) {
- removeAllBorders.call(this, row, column);
- }
- }
- break;
- case "top":
- for (var topCol = range.from.col; topCol <= range.to.col; topCol++) {
- setBorder.call(this, range.from.row, topCol, place, remove);
- }
- break;
- case "right":
- for (var rowRight = range.from.row; rowRight <= range.to.row; rowRight++) {
- setBorder.call(this, rowRight, range.to.col, place);
- }
- break;
- case "bottom":
- for (var bottomCol = range.from.col; bottomCol <= range.to.col; bottomCol++) {
- setBorder.call(this, range.to.row, bottomCol, place);
- }
- break;
- case "left":
- for (var rowLeft = range.from.row; rowLeft <= range.to.row; rowLeft++) {
- setBorder.call(this, rowLeft, range.from.col, place);
- }
- break;
- }
- }
- };
- var checkSelectionBorders = function(hot, direction) {
- var atLeastOneHasBorder = false;
- hot.getSelectedRange().forAll(function(r, c) {
- var metaBorders = hot.getCellMeta(r, c).borders;
- if (metaBorders) {
- if (direction) {
- if (!metaBorders[direction].hasOwnProperty('hide')) {
- atLeastOneHasBorder = true;
- return false;
- }
- } else {
- atLeastOneHasBorder = true;
- return false;
- }
- }
- });
- return atLeastOneHasBorder;
- };
- var markSelected = function(label) {
- return "<span class='selected'>" + String.fromCharCode(10003) + "</span>" + label;
- };
- var addBordersOptionsToContextMenu = function(defaultOptions) {
- if (!this.getSettings().customBorders) {
- return;
- }
- defaultOptions.items.push(Handsontable.ContextMenu.SEPARATOR);
- defaultOptions.items.push({
- key: 'borders',
- name: 'Borders',
- submenu: {items: {
- top: {
- name: function() {
- var label = "Top";
- var hasBorder = checkSelectionBorders(this, 'top');
- if (hasBorder) {
- label = markSelected(label);
- }
- return label;
- },
- callback: function() {
- var hasBorder = checkSelectionBorders(this, 'top');
- prepareBorder.call(this, this.getSelectedRange(), 'top', hasBorder);
- },
- disabled: false
- },
- right: {
- name: function() {
- var label = 'Right';
- var hasBorder = checkSelectionBorders(this, 'right');
- if (hasBorder) {
- label = markSelected(label);
- }
- return label;
- },
- callback: function() {
- var hasBorder = checkSelectionBorders(this, 'right');
- prepareBorder.call(this, this.getSelectedRange(), 'right', hasBorder);
- },
- disabled: false
- },
- bottom: {
- name: function() {
- var label = 'Bottom';
- var hasBorder = checkSelectionBorders(this, 'bottom');
- if (hasBorder) {
- label = markSelected(label);
- }
- return label;
- },
- callback: function() {
- var hasBorder = checkSelectionBorders(this, 'bottom');
- prepareBorder.call(this, this.getSelectedRange(), 'bottom', hasBorder);
- },
- disabled: false
- },
- left: {
- name: function() {
- var label = 'Left';
- var hasBorder = checkSelectionBorders(this, 'left');
- if (hasBorder) {
- label = markSelected(label);
- }
- return label;
- },
- callback: function() {
- var hasBorder = checkSelectionBorders(this, 'left');
- prepareBorder.call(this, this.getSelectedRange(), 'left', hasBorder);
- },
- disabled: false
- },
- remove: {
- name: 'Remove border(s)',
- callback: function() {
- prepareBorder.call(this, this.getSelectedRange(), 'noBorders');
- },
- disabled: function() {
- return !checkSelectionBorders(this);
- }
- }
- }}
- });
- };
- Handsontable.hooks.add('beforeInit', init);
- Handsontable.hooks.add('afterContextMenuDefaultOptions', addBordersOptionsToContextMenu);
- Handsontable.hooks.add('afterInit', function() {
- var customBorders = this.getSettings().customBorders;
- if (customBorders) {
- for (var i = 0; i < customBorders.length; i++) {
- if (customBorders[i].range) {
- prepareBorderFromCustomAddedRange.call(this, customBorders[i]);
- } else {
- prepareBorderFromCustomAdded.call(this, customBorders[i].row, customBorders[i].col, customBorders[i]);
- }
- }
- this.render();
- this.view.wt.draw(true);
- }
- });
- Handsontable.CustomBorders = CustomBorders;
-
- //#
- },{"./../../3rdparty/walkontable/src/cell/range.js":6,"./../../3rdparty/walkontable/src/selection.js":18,"./../../plugins.js":45}],56:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- DragToScroll: {get: function() {
- return DragToScroll;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_eventManager_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__;
- var eventManagerObject = ($___46__46__47__46__46__47_eventManager_46_js__ = require("./../../eventManager.js"), $___46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- ;
- Handsontable.plugins.DragToScroll = DragToScroll;
- function DragToScroll() {
- this.boundaries = null;
- this.callback = null;
- }
- DragToScroll.prototype.setBoundaries = function(boundaries) {
- this.boundaries = boundaries;
- };
- DragToScroll.prototype.setCallback = function(callback) {
- this.callback = callback;
- };
- DragToScroll.prototype.check = function(x, y) {
- var diffX = 0;
- var diffY = 0;
- if (y < this.boundaries.top) {
- diffY = y - this.boundaries.top;
- } else if (y > this.boundaries.bottom) {
- diffY = y - this.boundaries.bottom;
- }
- if (x < this.boundaries.left) {
- diffX = x - this.boundaries.left;
- } else if (x > this.boundaries.right) {
- diffX = x - this.boundaries.right;
- }
- this.callback(diffX, diffY);
- };
- var dragToScroll;
- var instance;
- if (typeof Handsontable !== 'undefined') {
- var setupListening = function(instance) {
- instance.dragToScrollListening = false;
- var scrollHandler = instance.view.wt.wtTable.holder;
- dragToScroll = new DragToScroll();
- if (scrollHandler === window) {
- return;
- } else {
- dragToScroll.setBoundaries(scrollHandler.getBoundingClientRect());
- }
- dragToScroll.setCallback(function(scrollX, scrollY) {
- if (scrollX < 0) {
- scrollHandler.scrollLeft -= 50;
- } else if (scrollX > 0) {
- scrollHandler.scrollLeft += 50;
- }
- if (scrollY < 0) {
- scrollHandler.scrollTop -= 20;
- } else if (scrollY > 0) {
- scrollHandler.scrollTop += 20;
- }
- });
- instance.dragToScrollListening = true;
- };
- }
- Handsontable.hooks.add('afterInit', function() {
- var instance = this;
- var eventManager = eventManagerObject(this);
- eventManager.addEventListener(document, 'mouseup', function() {
- instance.dragToScrollListening = false;
- });
- eventManager.addEventListener(document, 'mousemove', function(event) {
- if (instance.dragToScrollListening) {
- dragToScroll.check(event.clientX, event.clientY);
- }
- });
- });
- Handsontable.hooks.add('afterDestroy', function() {
- eventManagerObject(this).clear();
- });
- Handsontable.hooks.add('afterOnCellMouseDown', function() {
- setupListening(this);
- });
- Handsontable.hooks.add('afterOnCellCornerMouseDown', function() {
- setupListening(this);
- });
- Handsontable.plugins.DragToScroll = DragToScroll;
-
- //#
- },{"./../../eventManager.js":41,"./../../plugins.js":45}],57:[function(require,module,exports){
- "use strict";
- var $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__;
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- function Grouping(instance) {
- var groups = [];
- var item = {
- id: '',
- level: 0,
- hidden: 0,
- rows: [],
- cols: []
- };
- var counters = {
- rows: 0,
- cols: 0
- };
- var levels = {
- rows: 0,
- cols: 0
- };
- var hiddenRows = [];
- var hiddenCols = [];
- var classes = {
- 'groupIndicatorContainer': 'htGroupIndicatorContainer',
- 'groupIndicator': function(direction) {
- return 'ht' + direction + 'Group';
- },
- 'groupStart': 'htGroupStart',
- 'collapseButton': 'htCollapseButton',
- 'expandButton': 'htExpandButton',
- 'collapseGroupId': function(id) {
- return 'htCollapse-' + id;
- },
- 'collapseFromLevel': function(direction, level) {
- return 'htCollapse' + direction + 'FromLevel-' + level;
- },
- 'clickable': 'clickable',
- 'levelTrigger': 'htGroupLevelTrigger'
- };
- var compare = function(property, orderDirection) {
- return function(item1, item2) {
- return typeof(orderDirection) === 'undefined' || orderDirection === 'asc' ? item1[property] - item2[property] : item2[property] - item1[property];
- };
- };
- var range = function(from, to) {
- var arr = [];
- while (from <= to) {
- arr.push(from++);
- }
- return arr;
- };
- var getRangeGroups = function(dataType, from, to) {
- var cells = [],
- cell = {
- row: null,
- col: null
- };
- if (dataType == "cols") {
- while (from <= to) {
- cell = {
- row: -1,
- col: from++
- };
- cells.push(cell);
- }
- } else {
- while (from <= to) {
- cell = {
- row: from++,
- col: -1
- };
- cells.push(cell);
- }
- }
- var cellsGroups = getCellsGroups(cells),
- totalRows = 0,
- totalCols = 0;
- for (var i = 0; i < cellsGroups.length; i++) {
- totalRows += cellsGroups[i].filter(function(item) {
- return item['rows'];
- }).length;
- totalCols += cellsGroups[i].filter(function(item) {
- return item['cols'];
- }).length;
- }
- return {
- total: {
- rows: totalRows,
- cols: totalCols
- },
- groups: cellsGroups
- };
- };
- var getCellsGroups = function(cells) {
- var _groups = [];
- for (var i = 0; i < cells.length; i++) {
- _groups.push(getCellGroups(cells[i]));
- }
- return _groups;
- };
- var getCellGroups = function(coords, groupLevel, groupType) {
- var row = coords.row,
- col = coords.col;
- var tmpRow = (row === -1 ? 0 : row),
- tmpCol = (col === -1 ? 0 : col);
- var _groups = [];
- for (var i = 0; i < groups.length; i++) {
- var group = groups[i],
- id = group['id'],
- level = group['level'],
- rows = group['rows'] || [],
- cols = group['cols'] || [];
- if (_groups.indexOf(id) === -1) {
- if (rows.indexOf(tmpRow) !== -1 || cols.indexOf(tmpCol) !== -1) {
- _groups.push(group);
- }
- }
- }
- if (col === -1) {
- _groups = _groups.concat(getColGroups());
- } else if (row === -1) {
- _groups = _groups.concat(getRowGroups());
- }
- if (groupLevel) {
- _groups = _groups.filter(function(item) {
- return item['level'] === groupLevel;
- });
- }
- if (groupType) {
- if (groupType === 'cols') {
- _groups = _groups.filter(function(item) {
- return item['cols'];
- });
- } else if (groupType === 'rows') {
- _groups = _groups.filter(function(item) {
- return item['rows'];
- });
- }
- }
- var tmp = [];
- return _groups.filter(function(item) {
- if (tmp.indexOf(item.id) === -1) {
- tmp.push(item.id);
- return item;
- }
- });
- };
- var getGroupById = function(id) {
- for (var i = 0,
- groupsLength = groups.length; i < groupsLength; i++) {
- if (groups[i].id == id) {
- return groups[i];
- }
- }
- return false;
- };
- var getGroupByRowAndLevel = function(row, level) {
- for (var i = 0,
- groupsLength = groups.length; i < groupsLength; i++) {
- if (groups[i].level == level && groups[i].rows && groups[i].rows.indexOf(row) > -1) {
- return groups[i];
- }
- }
- return false;
- };
- var getGroupByColAndLevel = function(col, level) {
- for (var i = 0,
- groupsLength = groups.length; i < groupsLength; i++) {
- if (groups[i].level == level && groups[i].cols && groups[i].cols.indexOf(col) > -1) {
- return groups[i];
- }
- }
- return false;
- };
- var getColGroups = function() {
- var result = [];
- for (var i = 0,
- groupsLength = groups.length; i < groupsLength; i++) {
- if (Array.isArray(groups[i]['cols'])) {
- result.push(groups[i]);
- }
- }
- return result;
- };
- var getColGroupsByLevel = function(level) {
- var result = [];
- for (var i = 0,
- groupsLength = groups.length; i < groupsLength; i++) {
- if (groups[i]['cols'] && groups[i]['level'] === level) {
- result.push(groups[i]);
- }
- }
- return result;
- };
- var getRowGroups = function() {
- var result = [];
- for (var i = 0,
- groupsLength = groups.length; i < groupsLength; i++) {
- if (Array.isArray(groups[i]['rows'])) {
- result.push(groups[i]);
- }
- }
- return result;
- };
- var getRowGroupsByLevel = function(level) {
- var result = [];
- for (var i = 0,
- groupsLength = groups.length; i < groupsLength; i++) {
- if (groups[i]['rows'] && groups[i]['level'] === level) {
- result.push(groups[i]);
- }
- }
- return result;
- };
- var getLastLevelColsInRange = function(rangeGroups) {
- var level = 0;
- if (rangeGroups.length) {
- rangeGroups.forEach(function(items) {
- items = items.filter(function(item) {
- return item['cols'];
- });
- if (items.length) {
- var sortedGroup = items.sort(compare('level', 'desc')),
- lastLevel = sortedGroup[0].level;
- if (level < lastLevel) {
- level = lastLevel;
- }
- }
- });
- }
- return level;
- };
- var getLastLevelRowsInRange = function(rangeGroups) {
- var level = 0;
- if (rangeGroups.length) {
- rangeGroups.forEach(function(items) {
- items = items.filter(function(item) {
- return item['rows'];
- });
- if (items.length) {
- var sortedGroup = items.sort(compare('level', 'desc')),
- lastLevel = sortedGroup[0].level;
- if (level < lastLevel) {
- level = lastLevel;
- }
- }
- });
- }
- return level;
- };
- var groupCols = function(from, to) {
- var rangeGroups = getRangeGroups("cols", from, to),
- lastLevel = getLastLevelColsInRange(rangeGroups.groups);
- if (lastLevel === levels.cols) {
- levels.cols++;
- } else if (lastLevel > levels.cols) {
- levels.cols = lastLevel + 1;
- }
- if (!counters.cols) {
- counters.cols = getColGroups().length;
- }
- counters.cols++;
- groups.push({
- id: 'c' + counters.cols,
- level: lastLevel + 1,
- cols: range(from, to),
- hidden: 0
- });
- };
- var groupRows = function(from, to) {
- var rangeGroups = getRangeGroups("rows", from, to),
- lastLevel = getLastLevelRowsInRange(rangeGroups.groups);
- levels.rows = Math.max(levels.rows, lastLevel + 1);
- if (!counters.rows) {
- counters.rows = getRowGroups().length;
- }
- counters.rows++;
- groups.push({
- id: 'r' + counters.rows,
- level: lastLevel + 1,
- rows: range(from, to),
- hidden: 0
- });
- };
- var showHideGroups = function(hidden, groups) {
- var level;
- for (var i = 0,
- groupsLength = groups.length; i < groupsLength; i++) {
- groups[i].hidden = hidden;
- level = groups[i].level;
- if (!hiddenRows[level]) {
- hiddenRows[level] = [];
- }
- if (!hiddenCols[level]) {
- hiddenCols[level] = [];
- }
- if (groups[i].rows) {
- for (var j = 0,
- rowsLength = groups[i].rows.length; j < rowsLength; j++) {
- if (hidden > 0) {
- hiddenRows[level][groups[i].rows[j]] = true;
- } else {
- hiddenRows[level][groups[i].rows[j]] = void 0;
- }
- }
- } else if (groups[i].cols) {
- for (var j = 0,
- colsLength = groups[i].cols.length; j < colsLength; j++) {
- if (hidden > 0) {
- hiddenCols[level][groups[i].cols[j]] = true;
- } else {
- hiddenCols[level][groups[i].cols[j]] = void 0;
- }
- }
- }
- }
- };
- var nextIndexSharesLevel = function(dimension, currentPosition, level, currentGroupId) {
- var nextCellGroupId,
- levelsByOrder;
- switch (dimension) {
- case 'rows':
- nextCellGroupId = getGroupByRowAndLevel(currentPosition + 1, level).id;
- levelsByOrder = Handsontable.Grouping.getGroupLevelsByRows();
- break;
- case 'cols':
- nextCellGroupId = getGroupByColAndLevel(currentPosition + 1, level).id;
- levelsByOrder = Handsontable.Grouping.getGroupLevelsByCols();
- break;
- }
- return !!(levelsByOrder[currentPosition + 1] && levelsByOrder[currentPosition + 1].indexOf(level) > -1 && currentGroupId == nextCellGroupId);
- };
- var previousIndexSharesLevel = function(dimension, currentPosition, level, currentGroupId) {
- var previousCellGroupId,
- levelsByOrder;
- switch (dimension) {
- case 'rows':
- previousCellGroupId = getGroupByRowAndLevel(currentPosition - 1, level).id;
- levelsByOrder = Handsontable.Grouping.getGroupLevelsByRows();
- break;
- case 'cols':
- previousCellGroupId = getGroupByColAndLevel(currentPosition - 1, level).id;
- levelsByOrder = Handsontable.Grouping.getGroupLevelsByCols();
- break;
- }
- return !!(levelsByOrder[currentPosition - 1] && levelsByOrder[currentPosition - 1].indexOf(level) > -1 && currentGroupId == previousCellGroupId);
- };
- var isLastIndexOfTheLine = function(dimension, index, level, currentGroupId) {
- if (index === 0) {
- return false;
- }
- var levelsByOrder,
- entriesLength,
- previousSharesLevel = previousIndexSharesLevel(dimension, index, level, currentGroupId),
- nextSharesLevel = nextIndexSharesLevel(dimension, index, level, currentGroupId),
- nextIsHidden = false;
- switch (dimension) {
- case 'rows':
- levelsByOrder = Handsontable.Grouping.getGroupLevelsByRows();
- entriesLength = instance.countRows();
- for (var i = 0; i <= levels.rows; i++) {
- if (hiddenRows[i] && hiddenRows[i][index + 1]) {
- nextIsHidden = true;
- break;
- }
- }
- break;
- case 'cols':
- levelsByOrder = Handsontable.Grouping.getGroupLevelsByCols();
- entriesLength = instance.countCols();
- for (var i = 0; i <= levels.cols; i++) {
- if (hiddenCols[i] && hiddenCols[i][index + 1]) {
- nextIsHidden = true;
- break;
- }
- }
- break;
- }
- if (previousSharesLevel) {
- if (index == entriesLength - 1) {
- return true;
- } else if (!nextSharesLevel || (nextSharesLevel && nextIsHidden)) {
- return true;
- } else if (!levelsByOrder[index + 1]) {
- return true;
- }
- }
- return false;
- };
- var isLastHidden = function(dataType) {
- var levelAmount;
- switch (dataType) {
- case 'rows':
- levelAmount = levels.rows;
- for (var j = 0; j <= levelAmount; j++) {
- if (hiddenRows[j] && hiddenRows[j][instance.countRows() - 1]) {
- return true;
- }
- }
- break;
- case 'cols':
- levelAmount = levels.cols;
- for (var j = 0; j <= levelAmount; j++) {
- if (hiddenCols[j] && hiddenCols[j][instance.countCols() - 1]) {
- return true;
- }
- }
- break;
- }
- return false;
- };
- var isFirstIndexOfTheLine = function(dimension, index, level, currentGroupId) {
- var levelsByOrder,
- entriesLength,
- currentGroup = getGroupById(currentGroupId),
- previousAreHidden = false,
- arePreviousHidden = function(dimension) {
- var hidden = false,
- hiddenArr = dimension == 'rows' ? hiddenRows : hiddenCols;
- for (var i = 0; i <= levels[dimension]; i++) {
- tempInd = index;
- while (currentGroup[dimension].indexOf(tempInd) > -1) {
- hidden = !!(hiddenArr[i] && hiddenArr[i][tempInd]);
- tempInd--;
- }
- if (hidden) {
- break;
- }
- }
- return hidden;
- },
- previousSharesLevel = previousIndexSharesLevel(dimension, index, level, currentGroupId),
- nextSharesLevel = nextIndexSharesLevel(dimension, index, level, currentGroupId),
- tempInd;
- switch (dimension) {
- case 'rows':
- levelsByOrder = Handsontable.Grouping.getGroupLevelsByRows();
- entriesLength = instance.countRows();
- previousAreHidden = arePreviousHidden(dimension);
- break;
- case 'cols':
- levelsByOrder = Handsontable.Grouping.getGroupLevelsByCols();
- entriesLength = instance.countCols();
- previousAreHidden = arePreviousHidden(dimension);
- break;
- }
- if (index == entriesLength - 1) {
- return false;
- } else if (index === 0) {
- if (nextSharesLevel) {
- return true;
- }
- } else if (!previousSharesLevel || (previousSharesLevel && previousAreHidden)) {
- if (nextSharesLevel) {
- return true;
- }
- } else if (!levelsByOrder[index - 1]) {
- if (nextSharesLevel) {
- return true;
- }
- }
- return false;
- };
- var addGroupExpander = function(dataType, index, level, id, elem) {
- var previousIndexGroupId;
- switch (dataType) {
- case 'rows':
- previousIndexGroupId = getGroupByRowAndLevel(index - 1, level).id;
- break;
- case 'cols':
- previousIndexGroupId = getGroupByColAndLevel(index - 1, level).id;
- break;
- }
- if (!previousIndexGroupId) {
- return null;
- }
- if (index > 0) {
- if (previousIndexSharesLevel(dataType, index - 1, level, previousIndexGroupId) && previousIndexGroupId != id) {
- var expanderButton = document.createElement('DIV');
- dom.addClass(expanderButton, classes.expandButton);
- expanderButton.id = 'htExpand-' + previousIndexGroupId;
- expanderButton.appendChild(document.createTextNode('+'));
- expanderButton.setAttribute('data-level', level);
- expanderButton.setAttribute('data-type', dataType);
- expanderButton.setAttribute('data-hidden', "1");
- elem.appendChild(expanderButton);
- return expanderButton;
- }
- }
- return null;
- };
- var isCollapsed = function(currentPosition) {
- var rowGroups = getRowGroups(),
- colGroups = getColGroups();
- for (var i = 0,
- rowGroupsCount = rowGroups.length; i < rowGroupsCount; i++) {
- if (rowGroups[i].rows.indexOf(currentPosition.row) > -1 && rowGroups[i].hidden) {
- return true;
- }
- }
- if (currentPosition.col === null) {
- return false;
- }
- for (var i = 0,
- colGroupsCount = colGroups.length; i < colGroupsCount; i++) {
- if (colGroups[i].cols.indexOf(currentPosition.col) > -1 && colGroups[i].hidden) {
- return true;
- }
- }
- return false;
- };
- return {
- getGroups: function() {
- return groups;
- },
- getLevels: function() {
- return levels;
- },
- instance: instance,
- baseSpareRows: instance.getSettings().minSpareRows,
- baseSpareCols: instance.getSettings().minSpareCols,
- getRowGroups: getRowGroups,
- getColGroups: getColGroups,
- init: function() {
- var groupsSetting = instance.getSettings().groups;
- if (groupsSetting) {
- if (Array.isArray(groupsSetting)) {
- Handsontable.Grouping.initGroups(groupsSetting);
- }
- }
- },
- initGroups: function(initialGroups) {
- var that = this;
- groups = [];
- initialGroups.forEach(function(item) {
- var _group = [],
- isRow = false,
- isCol = false;
- if (Array.isArray(item.rows)) {
- _group = item.rows;
- isRow = true;
- } else if (Array.isArray(item.cols)) {
- _group = item.cols;
- isCol = true;
- }
- var from = _group[0],
- to = _group[_group.length - 1];
- if (isRow) {
- groupRows(from, to);
- } else if (isCol) {
- groupCols(from, to);
- }
- });
- },
- resetGroups: function() {
- groups = [];
- counters = {
- rows: 0,
- cols: 0
- };
- levels = {
- rows: 0,
- cols: 0
- };
- var allOccurrences;
- for (var i in classes) {
- if (typeof classes[i] != 'function') {
- allOccurrences = document.querySelectorAll('.' + classes[i]);
- for (var j = 0,
- occurrencesLength = allOccurrences.length; j < occurrencesLength; j++) {
- dom.removeClass(allOccurrences[j], classes[i]);
- }
- }
- }
- var otherClasses = ['htGroupColClosest', 'htGroupCol'];
- for (var i = 0,
- otherClassesLength = otherClasses.length; i < otherClassesLength; i++) {
- allOccurrences = document.querySelectorAll('.' + otherClasses[i]);
- for (var j = 0,
- occurrencesLength = allOccurrences.length; j < occurrencesLength; j++) {
- dom.removeClass(allOccurrences[j], otherClasses[i]);
- }
- }
- },
- updateGroups: function() {
- var groupSettings = this.getSettings().groups;
- Handsontable.Grouping.resetGroups();
- Handsontable.Grouping.initGroups(groupSettings);
- },
- afterGetRowHeader: function(row, TH) {
- var currentRowHidden = false;
- for (var i = 0,
- levels = hiddenRows.length; i < levels; i++) {
- if (hiddenRows[i] && hiddenRows[i][row] === true) {
- currentRowHidden = true;
- }
- }
- if (currentRowHidden) {
- dom.addClass(TH.parentNode, 'hidden');
- } else if (!currentRowHidden && dom.hasClass(TH.parentNode, 'hidden')) {
- dom.removeClass(TH.parentNode, 'hidden');
- }
- },
- afterGetColHeader: function(col, TH) {
- var rowHeaders = this.view.wt.wtSettings.getSetting('rowHeaders').length,
- thisColgroup = instance.rootElement.querySelectorAll('colgroup col:nth-child(' + parseInt(col + rowHeaders + 1, 10) + ')');
- if (thisColgroup.length === 0) {
- return;
- }
- var currentColHidden = false;
- for (var i = 0,
- levels = hiddenCols.length; i < levels; i++) {
- if (hiddenCols[i] && hiddenCols[i][col] === true) {
- currentColHidden = true;
- }
- }
- if (currentColHidden) {
- for (var i = 0,
- colsAmount = thisColgroup.length; i < colsAmount; i++) {
- dom.addClass(thisColgroup[i], 'hidden');
- }
- } else if (!currentColHidden && dom.hasClass(thisColgroup[0], 'hidden')) {
- for (var i = 0,
- colsAmount = thisColgroup.length; i < colsAmount; i++) {
- dom.removeClass(thisColgroup[i], 'hidden');
- }
- }
- },
- groupIndicatorsFactory: function(renderersArr, direction) {
- var groupsLevelsList,
- getCurrentLevel,
- getCurrentGroupId,
- dataType,
- getGroupByIndexAndLevel,
- headersType,
- currentHeaderModifier,
- createLevelTriggers;
- switch (direction) {
- case 'horizontal':
- groupsLevelsList = Handsontable.Grouping.getGroupLevelsByCols();
- getCurrentLevel = function(elem) {
- return Array.prototype.indexOf.call(elem.parentNode.parentNode.childNodes, elem.parentNode) + 1;
- };
- getCurrentGroupId = function(col, level) {
- return getGroupByColAndLevel(col, level).id;
- };
- dataType = 'cols';
- getGroupByIndexAndLevel = function(col, level) {
- return getGroupByColAndLevel(col - 1, level);
- };
- headersType = "columnHeaders";
- currentHeaderModifier = function(headerRenderers) {
- if (headerRenderers.length === 1) {
- var oldFn = headerRenderers[0];
- headerRenderers[0] = function(index, elem, level) {
- if (index < -1) {
- makeGroupIndicatorsForLevel()(index, elem, level);
- } else {
- dom.removeClass(elem, classes.groupIndicatorContainer);
- oldFn(index, elem, level);
- }
- };
- }
- return function() {
- return headerRenderers;
- };
- };
- createLevelTriggers = true;
- break;
- case 'vertical':
- groupsLevelsList = Handsontable.Grouping.getGroupLevelsByRows();
- getCurrentLevel = function(elem) {
- return dom.index(elem) + 1;
- };
- getCurrentGroupId = function(row, level) {
- return getGroupByRowAndLevel(row, level).id;
- };
- dataType = 'rows';
- getGroupByIndexAndLevel = function(row, level) {
- return getGroupByRowAndLevel(row - 1, level);
- };
- headersType = "rowHeaders";
- currentHeaderModifier = function(headerRenderers) {
- return headerRenderers;
- };
- break;
- }
- var createButton = function(parent) {
- var button = document.createElement('div');
- parent.appendChild(button);
- return {
- button: button,
- addClass: function(className) {
- dom.addClass(button, className);
- }
- };
- };
- var makeGroupIndicatorsForLevel = function() {
- var directionClassname = direction.charAt(0).toUpperCase() + direction.slice(1);
- return function(index, elem, level) {
- level++;
- var child,
- collapseButton;
- while (child = elem.lastChild) {
- elem.removeChild(child);
- }
- dom.addClass(elem, classes.groupIndicatorContainer);
- var currentGroupId = getCurrentGroupId(index, level);
- if (index > -1 && (groupsLevelsList[index] && groupsLevelsList[index].indexOf(level) > -1)) {
- collapseButton = createButton(elem);
- collapseButton.addClass(classes.groupIndicator(directionClassname));
- if (isFirstIndexOfTheLine(dataType, index, level, currentGroupId)) {
- collapseButton.addClass(classes.groupStart);
- }
- if (isLastIndexOfTheLine(dataType, index, level, currentGroupId)) {
- collapseButton.button.appendChild(document.createTextNode('-'));
- collapseButton.addClass(classes.collapseButton);
- collapseButton.button.id = classes.collapseGroupId(currentGroupId);
- collapseButton.button.setAttribute('data-level', level);
- collapseButton.button.setAttribute('data-type', dataType);
- }
- }
- if (createLevelTriggers) {
- var rowInd = dom.index(elem.parentNode);
- if (index === -1 || (index < -1 && rowInd === Handsontable.Grouping.getLevels().cols + 1) || (rowInd === 0 && Handsontable.Grouping.getLevels().cols === 0)) {
- collapseButton = createButton(elem);
- collapseButton.addClass(classes.levelTrigger);
- if (index === -1) {
- collapseButton.button.id = classes.collapseFromLevel("Cols", level);
- collapseButton.button.appendChild(document.createTextNode(level));
- } else if (index < -1 && rowInd === Handsontable.Grouping.getLevels().cols + 1 || (rowInd === 0 && Handsontable.Grouping.getLevels().cols === 0)) {
- var colInd = dom.index(elem) + 1;
- collapseButton.button.id = classes.collapseFromLevel("Rows", colInd);
- collapseButton.button.appendChild(document.createTextNode(colInd));
- }
- }
- }
- var expanderButton = addGroupExpander(dataType, index, level, currentGroupId, elem);
- if (index > 0) {
- var previousGroupObj = getGroupByIndexAndLevel(index - 1, level);
- if (expanderButton && previousGroupObj.hidden) {
- dom.addClass(expanderButton, classes.clickable);
- }
- }
- updateHeaderWidths();
- };
- };
- renderersArr = currentHeaderModifier(renderersArr);
- if (counters[dataType] > 0) {
- for (var i = 0; i < levels[dataType] + 1; i++) {
- if (!Array.isArray(renderersArr)) {
- renderersArr = typeof renderersArr === 'function' ? renderersArr() : new Array(renderersArr);
- }
- renderersArr.unshift(makeGroupIndicatorsForLevel());
- }
- }
- },
- getGroupLevelsByRows: function() {
- var rowGroups = getRowGroups(),
- result = [];
- for (var i = 0,
- groupsLength = rowGroups.length; i < groupsLength; i++) {
- if (rowGroups[i].rows) {
- for (var j = 0,
- groupRowsLength = rowGroups[i].rows.length; j < groupRowsLength; j++) {
- if (!result[rowGroups[i].rows[j]]) {
- result[rowGroups[i].rows[j]] = [];
- }
- result[rowGroups[i].rows[j]].push(rowGroups[i].level);
- }
- }
- }
- return result;
- },
- getGroupLevelsByCols: function() {
- var colGroups = getColGroups(),
- result = [];
- for (var i = 0,
- groupsLength = colGroups.length; i < groupsLength; i++) {
- if (colGroups[i].cols) {
- for (var j = 0,
- groupColsLength = colGroups[i].cols.length; j < groupColsLength; j++) {
- if (!result[colGroups[i].cols[j]]) {
- result[colGroups[i].cols[j]] = [];
- }
- result[colGroups[i].cols[j]].push(colGroups[i].level);
- }
- }
- }
- return result;
- },
- toggleGroupVisibility: function(event, coords, TD) {
- if (dom.hasClass(event.target, classes.expandButton) || dom.hasClass(event.target, classes.collapseButton) || dom.hasClass(event.target, classes.levelTrigger)) {
- var element = event.target,
- elemIdSplit = element.id.split('-');
- var groups = [],
- id,
- level,
- type,
- hidden;
- var prepareGroupData = function(componentElement) {
- if (componentElement) {
- element = componentElement;
- }
- elemIdSplit = element.id.split('-');
- id = elemIdSplit[1];
- level = parseInt(element.getAttribute('data-level'), 10);
- type = element.getAttribute('data-type');
- hidden = parseInt(element.getAttribute('data-hidden'));
- if (isNaN(hidden)) {
- hidden = 1;
- } else {
- hidden = (hidden ? 0 : 1);
- }
- element.setAttribute('data-hidden', hidden.toString());
- groups.push(getGroupById(id));
- };
- if (element.className.indexOf(classes.levelTrigger) > -1) {
- var groupsInLevel,
- groupsToExpand = [],
- groupsToCollapse = [],
- levelType = element.id.indexOf("Rows") > -1 ? "rows" : "cols";
- for (var i = 1,
- levelsCount = levels[levelType]; i <= levelsCount; i++) {
- groupsInLevel = levelType == "rows" ? getRowGroupsByLevel(i) : getColGroupsByLevel(i);
- if (i >= parseInt(elemIdSplit[1], 10)) {
- for (var j = 0,
- groupCount = groupsInLevel.length; j < groupCount; j++) {
- groupsToCollapse.push(groupsInLevel[j]);
- }
- } else {
- for (var j = 0,
- groupCount = groupsInLevel.length; j < groupCount; j++) {
- groupsToExpand.push(groupsInLevel[j]);
- }
- }
- }
- showHideGroups(true, groupsToCollapse);
- showHideGroups(false, groupsToExpand);
- } else {
- prepareGroupData();
- showHideGroups(hidden, groups);
- }
- type = type || levelType;
- var lastHidden = isLastHidden(type),
- typeUppercase = type.charAt(0).toUpperCase() + type.slice(1),
- spareElements = Handsontable.Grouping['baseSpare' + typeUppercase];
- if (lastHidden) {
- if (spareElements == 0) {
- instance.alter('insert_' + type.slice(0, -1), instance['count' + typeUppercase]());
- Handsontable.Grouping["dummy" + type.slice(0, -1)] = true;
- }
- } else {
- if (spareElements == 0) {
- if (Handsontable.Grouping["dummy" + type.slice(0, -1)]) {
- instance.alter('remove_' + type.slice(0, -1), instance['count' + typeUppercase]() - 1);
- Handsontable.Grouping["dummy" + type.slice(0, -1)] = false;
- }
- }
- }
- instance.render();
- event.stopImmediatePropagation();
- }
- },
- modifySelectionFactory: function(position) {
- var instance = this.instance;
- var currentlySelected,
- nextPosition = new WalkontableCellCoords(0, 0),
- nextVisible = function(direction, currentPosition) {
- var updateDelta = 0;
- switch (direction) {
- case 'down':
- while (isCollapsed(currentPosition)) {
- updateDelta++;
- currentPosition.row += 1;
- }
- break;
- case 'up':
- while (isCollapsed(currentPosition)) {
- updateDelta--;
- currentPosition.row -= 1;
- }
- break;
- case 'right':
- while (isCollapsed(currentPosition)) {
- updateDelta++;
- currentPosition.col += 1;
- }
- break;
- case 'left':
- while (isCollapsed(currentPosition)) {
- updateDelta--;
- currentPosition.col -= 1;
- }
- break;
- }
- return updateDelta;
- },
- updateDelta = function(delta, nextPosition) {
- if (delta.row > 0) {
- if (isCollapsed(nextPosition)) {
- delta.row += nextVisible('down', nextPosition);
- }
- } else if (delta.row < 0) {
- if (isCollapsed(nextPosition)) {
- delta.row += nextVisible('up', nextPosition);
- }
- }
- if (delta.col > 0) {
- if (isCollapsed(nextPosition)) {
- delta.col += nextVisible('right', nextPosition);
- }
- } else if (delta.col < 0) {
- if (isCollapsed(nextPosition)) {
- delta.col += nextVisible('left', nextPosition);
- }
- }
- };
- switch (position) {
- case 'start':
- return function(delta) {
- currentlySelected = instance.getSelected();
- nextPosition.row = currentlySelected[0] + delta.row;
- nextPosition.col = currentlySelected[1] + delta.col;
- updateDelta(delta, nextPosition);
- };
- break;
- case 'end':
- return function(delta) {
- currentlySelected = instance.getSelected();
- nextPosition.row = currentlySelected[2] + delta.row;
- nextPosition.col = currentlySelected[3] + delta.col;
- updateDelta(delta, nextPosition);
- };
- break;
- }
- },
- modifyRowHeight: function(height, row) {
- if (instance.view.wt.wtTable.rowFilter && isCollapsed({
- row: row,
- col: null
- })) {
- return 0;
- }
- },
- validateGroups: function() {
- var areRangesOverlapping = function(a, b) {
- if ((a[0] < b[0] && a[1] < b[1] && b[0] <= a[1]) || (a[0] > b[0] && b[1] < a[1] && a[0] <= b[1])) {
- return true;
- }
- };
- var configGroups = instance.getSettings().groups,
- cols = [],
- rows = [];
- for (var i = 0,
- groupsLength = configGroups.length; i < groupsLength; i++) {
- if (configGroups[i].rows) {
- if (configGroups[i].rows.length === 1) {
- throw new Error("Grouping error: Group {" + configGroups[i].rows[0] + "} is invalid. Cannot define single-entry groups.");
- return false;
- } else if (configGroups[i].rows.length === 0) {
- throw new Error("Grouping error: Cannot define empty groups.");
- return false;
- }
- rows.push(configGroups[i].rows);
- for (var j = 0,
- rowsLength = rows.length; j < rowsLength; j++) {
- if (areRangesOverlapping(configGroups[i].rows, rows[j])) {
- throw new Error("Grouping error: ranges {" + configGroups[i].rows[0] + ", " + configGroups[i].rows[1] + "} and {" + rows[j][0] + ", " + rows[j][1] + "} are overlapping.");
- return false;
- }
- }
- } else if (configGroups[i].cols) {
- if (configGroups[i].cols.length === 1) {
- throw new Error("Grouping error: Group {" + configGroups[i].cols[0] + "} is invalid. Cannot define single-entry groups.");
- return false;
- } else if (configGroups[i].cols.length === 0) {
- throw new Error("Grouping error: Cannot define empty groups.");
- return false;
- }
- cols.push(configGroups[i].cols);
- for (var j = 0,
- colsLength = cols.length; j < colsLength; j++) {
- if (areRangesOverlapping(configGroups[i].cols, cols[j])) {
- throw new Error("Grouping error: ranges {" + configGroups[i].cols[0] + ", " + configGroups[i].cols[1] + "} and {" + cols[j][0] + ", " + cols[j][1] + "} are overlapping.");
- return false;
- }
- }
- }
- }
- return true;
- },
- afterGetRowHeaderRenderers: function(arr) {
- Handsontable.Grouping.groupIndicatorsFactory(arr, 'vertical');
- },
- afterGetColumnHeaderRenderers: function(arr) {
- Handsontable.Grouping.groupIndicatorsFactory(arr, 'horizontal');
- },
- hookProxy: function(fn, arg) {
- return function() {
- if (instance.getSettings().groups) {
- return arg ? Handsontable.Grouping[fn](arg).apply(this, arguments) : Handsontable.Grouping[fn].apply(this, arguments);
- } else {
- return void 0;
- }
- };
- }
- };
- }
- Grouping.prototype.beforeInit = function() {};
- var init = function() {
- var instance = this,
- groupingSetting = !!(instance.getSettings().groups);
- if (groupingSetting) {
- var headerUpdates = {};
- Handsontable.Grouping = new Grouping(instance);
- if (!instance.getSettings().rowHeaders) {
- headerUpdates.rowHeaders = true;
- }
- if (!instance.getSettings().colHeaders) {
- headerUpdates.colHeaders = true;
- }
- if (headerUpdates.colHeaders || headerUpdates.rowHeaders) {
- instance.updateSettings(headerUpdates);
- }
- var groupConfigValid = Handsontable.Grouping.validateGroups();
- if (!groupConfigValid) {
- return;
- }
- instance.addHook('beforeInit', Handsontable.Grouping.hookProxy('init'));
- instance.addHook('afterUpdateSettings', Handsontable.Grouping.hookProxy('updateGroups'));
- instance.addHook('afterGetColumnHeaderRenderers', Handsontable.Grouping.hookProxy('afterGetColumnHeaderRenderers'));
- instance.addHook('afterGetRowHeaderRenderers', Handsontable.Grouping.hookProxy('afterGetRowHeaderRenderers'));
- instance.addHook('afterGetRowHeader', Handsontable.Grouping.hookProxy('afterGetRowHeader'));
- instance.addHook('afterGetColHeader', Handsontable.Grouping.hookProxy('afterGetColHeader'));
- instance.addHook('beforeOnCellMouseDown', Handsontable.Grouping.hookProxy('toggleGroupVisibility'));
- instance.addHook('modifyTransformStart', Handsontable.Grouping.hookProxy('modifySelectionFactory', 'start'));
- instance.addHook('modifyTransformEnd', Handsontable.Grouping.hookProxy('modifySelectionFactory', 'end'));
- instance.addHook('modifyRowHeight', Handsontable.Grouping.hookProxy('modifyRowHeight'));
- }
- };
- var updateHeaderWidths = function() {
- var colgroups = document.querySelectorAll('colgroup');
- for (var i = 0,
- colgroupsLength = colgroups.length; i < colgroupsLength; i++) {
- var rowHeaders = colgroups[i].querySelectorAll('col.rowHeader');
- if (rowHeaders.length === 0) {
- return;
- }
- for (var j = 0,
- rowHeadersLength = rowHeaders.length + 1; j < rowHeadersLength; j++) {
- if (rowHeadersLength == 2) {
- return;
- }
- if (j < Handsontable.Grouping.getLevels().rows + 1) {
- if (j == Handsontable.Grouping.getLevels().rows) {
- dom.addClass(rowHeaders[j], 'htGroupColClosest');
- } else {
- dom.addClass(rowHeaders[j], 'htGroupCol');
- }
- }
- }
- }
- };
- Handsontable.hooks.add('beforeInit', init);
- Handsontable.hooks.add('afterUpdateSettings', function() {
- if (this.getSettings().groups && !Handsontable.Grouping) {
- init.call(this, arguments);
- } else if (!this.getSettings().groups && Handsontable.Grouping) {
- Handsontable.Grouping.resetGroups();
- Handsontable.Grouping = void 0;
- }
- });
- Handsontable.plugins.Grouping = Grouping;
-
- //#
- },{"./../../dom.js":27,"./../../plugins.js":45}],58:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- ManualColumnFreeze: {get: function() {
- return ManualColumnFreeze;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_plugins_46_js__;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- ;
- function ManualColumnFreeze(instance) {
- var fixedColumnsCount = instance.getSettings().fixedColumnsLeft;
- var init = function() {
- if (typeof instance.manualColumnPositionsPluginUsages !== 'undefined') {
- instance.manualColumnPositionsPluginUsages.push('manualColumnFreeze');
- } else {
- instance.manualColumnPositionsPluginUsages = ['manualColumnFreeze'];
- }
- bindHooks();
- };
- function addContextMenuEntry(defaultOptions) {
- defaultOptions.items.push(Handsontable.ContextMenu.SEPARATOR, {
- key: 'freeze_column',
- name: function() {
- var selectedColumn = instance.getSelected()[1];
- if (selectedColumn > fixedColumnsCount - 1) {
- return 'Freeze this column';
- } else {
- return 'Unfreeze this column';
- }
- },
- disabled: function() {
- var selection = instance.getSelected();
- return selection[1] !== selection[3];
- },
- callback: function() {
- var selectedColumn = instance.getSelected()[1];
- if (selectedColumn > fixedColumnsCount - 1) {
- freezeColumn(selectedColumn);
- } else {
- unfreezeColumn(selectedColumn);
- }
- }
- });
- }
- function addFixedColumn() {
- instance.updateSettings({fixedColumnsLeft: fixedColumnsCount + 1});
- fixedColumnsCount++;
- }
- function removeFixedColumn() {
- instance.updateSettings({fixedColumnsLeft: fixedColumnsCount - 1});
- fixedColumnsCount--;
- }
- function checkPositionData(col) {
- if (!instance.manualColumnPositions || instance.manualColumnPositions.length === 0) {
- if (!instance.manualColumnPositions) {
- instance.manualColumnPositions = [];
- }
- }
- if (col) {
- if (!instance.manualColumnPositions[col]) {
- createPositionData(col + 1);
- }
- } else {
- createPositionData(instance.countCols());
- }
- }
- function createPositionData(len) {
- if (instance.manualColumnPositions.length < len) {
- for (var i = instance.manualColumnPositions.length; i < len; i++) {
- instance.manualColumnPositions[i] = i;
- }
- }
- }
- function modifyColumnOrder(col, actualCol, returnCol, action) {
- if (returnCol == null) {
- returnCol = col;
- }
- if (action === 'freeze') {
- instance.manualColumnPositions.splice(fixedColumnsCount, 0, instance.manualColumnPositions.splice(actualCol, 1)[0]);
- } else if (action === 'unfreeze') {
- instance.manualColumnPositions.splice(returnCol, 0, instance.manualColumnPositions.splice(actualCol, 1)[0]);
- }
- }
- function getBestColumnReturnPosition(col) {
- var i = fixedColumnsCount,
- j = getModifiedColumnIndex(i),
- initialCol = getModifiedColumnIndex(col);
- while (j < initialCol) {
- i++;
- j = getModifiedColumnIndex(i);
- }
- return i - 1;
- }
- function freezeColumn(col) {
- if (col <= fixedColumnsCount - 1) {
- return;
- }
- var modifiedColumn = getModifiedColumnIndex(col) || col;
- checkPositionData(modifiedColumn);
- modifyColumnOrder(modifiedColumn, col, null, 'freeze');
- addFixedColumn();
- instance.view.wt.wtOverlays.leftOverlay.refresh();
- instance.view.wt.wtOverlays.adjustElementsSize();
- }
- function unfreezeColumn(col) {
- if (col > fixedColumnsCount - 1) {
- return;
- }
- var returnCol = getBestColumnReturnPosition(col);
- var modifiedColumn = getModifiedColumnIndex(col) || col;
- checkPositionData(modifiedColumn);
- modifyColumnOrder(modifiedColumn, col, returnCol, 'unfreeze');
- removeFixedColumn();
- instance.view.wt.wtOverlays.leftOverlay.refresh();
- }
- function getModifiedColumnIndex(col) {
- return instance.manualColumnPositions[col];
- }
- function onModifyCol(col) {
- if (this.manualColumnPositionsPluginUsages.length > 1) {
- return col;
- }
- return getModifiedColumnIndex(col);
- }
- function bindHooks() {
- instance.addHook('modifyCol', onModifyCol);
- instance.addHook('afterContextMenuDefaultOptions', addContextMenuEntry);
- }
- return {
- init: init,
- freezeColumn: freezeColumn,
- unfreezeColumn: unfreezeColumn,
- helpers: {
- addFixedColumn: addFixedColumn,
- removeFixedColumn: removeFixedColumn,
- checkPositionData: checkPositionData,
- modifyColumnOrder: modifyColumnOrder,
- getBestColumnReturnPosition: getBestColumnReturnPosition
- }
- };
- }
- var init = function init() {
- if (!this.getSettings().manualColumnFreeze) {
- return;
- }
- var mcfPlugin;
- Handsontable.plugins.manualColumnFreeze = ManualColumnFreeze;
- this.manualColumnFreeze = new ManualColumnFreeze(this);
- mcfPlugin = this.manualColumnFreeze;
- mcfPlugin.init.call(this);
- };
- Handsontable.hooks.add('beforeInit', init);
-
- //#
- },{"./../../plugins.js":45}],59:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- ManualColumnMove: {get: function() {
- return ManualColumnMove;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_helpers_46_js__,
- $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_eventManager_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__;
- var helper = ($___46__46__47__46__46__47_helpers_46_js__ = require("./../../helpers.js"), $___46__46__47__46__46__47_helpers_46_js__ && $___46__46__47__46__46__47_helpers_46_js__.__esModule && $___46__46__47__46__46__47_helpers_46_js__ || {default: $___46__46__47__46__46__47_helpers_46_js__});
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47__46__46__47_eventManager_46_js__ = require("./../../eventManager.js"), $___46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- ;
- function ManualColumnMove() {
- var startCol,
- endCol,
- startX,
- startOffset,
- currentCol,
- instance,
- currentTH,
- handle = document.createElement('DIV'),
- guide = document.createElement('DIV'),
- eventManager = eventManagerObject(this);
- handle.className = 'manualColumnMover';
- guide.className = 'manualColumnMoverGuide';
- var saveManualColumnPositions = function() {
- var instance = this;
- Handsontable.hooks.run(instance, 'persistentStateSave', 'manualColumnPositions', instance.manualColumnPositions);
- };
- var loadManualColumnPositions = function() {
- var instance = this;
- var storedState = {};
- Handsontable.hooks.run(instance, 'persistentStateLoad', 'manualColumnPositions', storedState);
- return storedState.value;
- };
- function setupHandlePosition(TH) {
- instance = this;
- currentTH = TH;
- var col = this.view.wt.wtTable.getCoords(TH).col;
- if (col >= 0) {
- currentCol = col;
- var box = currentTH.getBoundingClientRect();
- startOffset = box.left;
- handle.style.top = box.top + 'px';
- handle.style.left = startOffset + 'px';
- instance.rootElement.appendChild(handle);
- }
- }
- function refreshHandlePosition(TH, delta) {
- var box = TH.getBoundingClientRect();
- var handleWidth = 6;
- if (delta > 0) {
- handle.style.left = (box.left + box.width - handleWidth) + 'px';
- } else {
- handle.style.left = box.left + 'px';
- }
- }
- function setupGuidePosition() {
- var instance = this;
- dom.addClass(handle, 'active');
- dom.addClass(guide, 'active');
- var box = currentTH.getBoundingClientRect();
- guide.style.width = box.width + 'px';
- guide.style.height = instance.view.maximumVisibleElementHeight(0) + 'px';
- guide.style.top = handle.style.top;
- guide.style.left = startOffset + 'px';
- instance.rootElement.appendChild(guide);
- }
- function refreshGuidePosition(diff) {
- guide.style.left = startOffset + diff + 'px';
- }
- function hideHandleAndGuide() {
- dom.removeClass(handle, 'active');
- dom.removeClass(guide, 'active');
- }
- var checkColumnHeader = function(element) {
- if (element.tagName != 'BODY') {
- if (element.parentNode.tagName == 'THEAD') {
- return true;
- } else {
- element = element.parentNode;
- return checkColumnHeader(element);
- }
- }
- return false;
- };
- var getTHFromTargetElement = function(element) {
- if (element.tagName != 'TABLE') {
- if (element.tagName == 'TH') {
- return element;
- } else {
- return getTHFromTargetElement(element.parentNode);
- }
- }
- return null;
- };
- var bindEvents = function() {
- var instance = this;
- var pressed;
- eventManager.addEventListener(instance.rootElement, 'mouseover', function(e) {
- if (checkColumnHeader(e.target)) {
- var th = getTHFromTargetElement(e.target);
- if (th) {
- if (pressed) {
- var col = instance.view.wt.wtTable.getCoords(th).col;
- if (col >= 0) {
- endCol = col;
- refreshHandlePosition(e.target, endCol - startCol);
- }
- } else {
- setupHandlePosition.call(instance, th);
- }
- }
- }
- });
- eventManager.addEventListener(instance.rootElement, 'mousedown', function(e) {
- if (dom.hasClass(e.target, 'manualColumnMover')) {
- startX = helper.pageX(e);
- setupGuidePosition.call(instance);
- pressed = instance;
- startCol = currentCol;
- endCol = currentCol;
- }
- });
- eventManager.addEventListener(window, 'mousemove', function(e) {
- if (pressed) {
- refreshGuidePosition(helper.pageX(e) - startX);
- }
- });
- eventManager.addEventListener(window, 'mouseup', function(e) {
- if (pressed) {
- hideHandleAndGuide();
- pressed = false;
- createPositionData(instance.manualColumnPositions, instance.countCols());
- instance.manualColumnPositions.splice(endCol, 0, instance.manualColumnPositions.splice(startCol, 1)[0]);
- instance.forceFullRender = true;
- instance.view.render();
- saveManualColumnPositions.call(instance);
- Handsontable.hooks.run(instance, 'afterColumnMove', startCol, endCol);
- setupHandlePosition.call(instance, currentTH);
- }
- });
- instance.addHook('afterDestroy', unbindEvents);
- };
- var unbindEvents = function() {
- eventManager.clear();
- };
- var createPositionData = function(positionArr, len) {
- if (positionArr.length < len) {
- for (var i = positionArr.length; i < len; i++) {
- positionArr[i] = i;
- }
- }
- };
- this.beforeInit = function() {
- this.manualColumnPositions = [];
- };
- this.init = function(source) {
- var instance = this;
- var manualColMoveEnabled = !!(this.getSettings().manualColumnMove);
- if (manualColMoveEnabled) {
- var initialManualColumnPositions = this.getSettings().manualColumnMove;
- var loadedManualColumnPositions = loadManualColumnPositions.call(instance);
- if (typeof loadedManualColumnPositions != 'undefined') {
- this.manualColumnPositions = loadedManualColumnPositions;
- } else if (Array.isArray(initialManualColumnPositions)) {
- this.manualColumnPositions = initialManualColumnPositions;
- } else {
- this.manualColumnPositions = [];
- }
- if (source == 'afterInit') {
- if (typeof instance.manualColumnPositionsPluginUsages != 'undefined') {
- instance.manualColumnPositionsPluginUsages.push('manualColumnMove');
- } else {
- instance.manualColumnPositionsPluginUsages = ['manualColumnMove'];
- }
- bindEvents.call(this);
- if (this.manualColumnPositions.length > 0) {
- this.forceFullRender = true;
- this.render();
- }
- }
- } else {
- var pluginUsagesIndex = instance.manualColumnPositionsPluginUsages ? instance.manualColumnPositionsPluginUsages.indexOf('manualColumnMove') : -1;
- if (pluginUsagesIndex > -1) {
- unbindEvents.call(this);
- this.manualColumnPositions = [];
- instance.manualColumnPositionsPluginUsages[pluginUsagesIndex] = void 0;
- }
- }
- };
- this.modifyCol = function(col) {
- if (this.getSettings().manualColumnMove) {
- if (typeof this.manualColumnPositions[col] === 'undefined') {
- createPositionData(this.manualColumnPositions, col + 1);
- }
- return this.manualColumnPositions[col];
- }
- return col;
- };
- this.afterRemoveCol = function(index, amount) {
- if (!this.getSettings().manualColumnMove) {
- return;
- }
- var rmindx,
- colpos = this.manualColumnPositions;
- rmindx = colpos.splice(index, amount);
- colpos = colpos.map(function(colpos) {
- var i,
- newpos = colpos;
- for (i = 0; i < rmindx.length; i++) {
- if (colpos > rmindx[i]) {
- newpos--;
- }
- }
- return newpos;
- });
- this.manualColumnPositions = colpos;
- };
- this.afterCreateCol = function(index, amount) {
- if (!this.getSettings().manualColumnMove) {
- return;
- }
- var colpos = this.manualColumnPositions;
- if (!colpos.length) {
- return;
- }
- var addindx = [];
- for (var i = 0; i < amount; i++) {
- addindx.push(index + i);
- }
- if (index >= colpos.length) {
- colpos.concat(addindx);
- } else {
- colpos = colpos.map(function(colpos) {
- return (colpos >= index) ? (colpos + amount) : colpos;
- });
- colpos.splice.apply(colpos, [index, 0].concat(addindx));
- }
- this.manualColumnPositions = colpos;
- };
- }
- var htManualColumnMove = new ManualColumnMove();
- Handsontable.hooks.add('beforeInit', htManualColumnMove.beforeInit);
- Handsontable.hooks.add('afterInit', function() {
- htManualColumnMove.init.call(this, 'afterInit');
- });
- Handsontable.hooks.add('afterUpdateSettings', function() {
- htManualColumnMove.init.call(this, 'afterUpdateSettings');
- });
- Handsontable.hooks.add('modifyCol', htManualColumnMove.modifyCol);
- Handsontable.hooks.add('afterRemoveCol', htManualColumnMove.afterRemoveCol);
- Handsontable.hooks.add('afterCreateCol', htManualColumnMove.afterCreateCol);
- Handsontable.hooks.register('afterColumnMove');
-
- //#
- },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../helpers.js":42,"./../../plugins.js":45}],60:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- ManualColumnResize: {get: function() {
- return ManualColumnResize;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_helpers_46_js__,
- $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_eventManager_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__;
- var helper = ($___46__46__47__46__46__47_helpers_46_js__ = require("./../../helpers.js"), $___46__46__47__46__46__47_helpers_46_js__ && $___46__46__47__46__46__47_helpers_46_js__.__esModule && $___46__46__47__46__46__47_helpers_46_js__ || {default: $___46__46__47__46__46__47_helpers_46_js__});
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47__46__46__47_eventManager_46_js__ = require("./../../eventManager.js"), $___46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- ;
- function ManualColumnResize() {
- var currentTH,
- currentCol,
- currentWidth,
- instance,
- newSize,
- startX,
- startWidth,
- startOffset,
- handle = document.createElement('DIV'),
- guide = document.createElement('DIV'),
- eventManager = eventManagerObject(this);
- handle.className = 'manualColumnResizer';
- guide.className = 'manualColumnResizerGuide';
- var saveManualColumnWidths = function() {
- var instance = this;
- Handsontable.hooks.run(instance, 'persistentStateSave', 'manualColumnWidths', instance.manualColumnWidths);
- };
- var loadManualColumnWidths = function() {
- var instance = this;
- var storedState = {};
- Handsontable.hooks.run(instance, 'persistentStateLoad', 'manualColumnWidths', storedState);
- return storedState.value;
- };
- function setupHandlePosition(TH) {
- instance = this;
- currentTH = TH;
- var col = this.view.wt.wtTable.getCoords(TH).col;
- if (col >= 0) {
- currentCol = col;
- var box = currentTH.getBoundingClientRect();
- startOffset = box.left - 6;
- startWidth = parseInt(box.width, 10);
- handle.style.top = box.top + 'px';
- handle.style.left = startOffset + startWidth + 'px';
- instance.rootElement.appendChild(handle);
- }
- }
- function refreshHandlePosition() {
- handle.style.left = startOffset + currentWidth + 'px';
- }
- function setupGuidePosition() {
- var instance = this;
- dom.addClass(handle, 'active');
- dom.addClass(guide, 'active');
- guide.style.top = handle.style.top;
- guide.style.left = handle.style.left;
- guide.style.height = instance.view.maximumVisibleElementHeight(0) + 'px';
- instance.rootElement.appendChild(guide);
- }
- function refreshGuidePosition() {
- guide.style.left = handle.style.left;
- }
- function hideHandleAndGuide() {
- dom.removeClass(handle, 'active');
- dom.removeClass(guide, 'active');
- }
- var checkColumnHeader = function(element) {
- if (element.tagName != 'BODY') {
- if (element.parentNode.tagName == 'THEAD') {
- return true;
- } else {
- element = element.parentNode;
- return checkColumnHeader(element);
- }
- }
- return false;
- };
- var getTHFromTargetElement = function(element) {
- if (element.tagName != 'TABLE') {
- if (element.tagName == 'TH') {
- return element;
- } else {
- return getTHFromTargetElement(element.parentNode);
- }
- }
- return null;
- };
- var bindEvents = function() {
- var instance = this;
- var pressed;
- var dblclick = 0;
- var autoresizeTimeout = null;
- eventManager.addEventListener(instance.rootElement, 'mouseover', function(e) {
- if (checkColumnHeader(e.target)) {
- var th = getTHFromTargetElement(e.target);
- if (th) {
- if (!pressed) {
- setupHandlePosition.call(instance, th);
- }
- }
- }
- });
- eventManager.addEventListener(instance.rootElement, 'mousedown', function(e) {
- if (dom.hasClass(e.target, 'manualColumnResizer')) {
- setupGuidePosition.call(instance);
- pressed = instance;
- if (autoresizeTimeout == null) {
- autoresizeTimeout = setTimeout(function() {
- if (dblclick >= 2) {
- newSize = instance.determineColumnWidth.call(instance, currentCol);
- setManualSize(currentCol, newSize);
- instance.forceFullRender = true;
- instance.view.render();
- Handsontable.hooks.run(instance, 'afterColumnResize', currentCol, newSize);
- }
- dblclick = 0;
- autoresizeTimeout = null;
- }, 500);
- instance._registerTimeout(autoresizeTimeout);
- }
- dblclick++;
- startX = helper.pageX(e);
- newSize = startWidth;
- }
- });
- eventManager.addEventListener(window, 'mousemove', function(e) {
- if (pressed) {
- currentWidth = startWidth + (helper.pageX(e) - startX);
- newSize = setManualSize(currentCol, currentWidth);
- refreshHandlePosition();
- refreshGuidePosition();
- }
- });
- eventManager.addEventListener(window, 'mouseup', function() {
- if (pressed) {
- hideHandleAndGuide();
- pressed = false;
- if (newSize != startWidth) {
- instance.forceFullRender = true;
- instance.view.render();
- instance.view.wt.wtOverlays.adjustElementsSize();
- saveManualColumnWidths.call(instance);
- Handsontable.hooks.run(instance, 'afterColumnResize', currentCol, newSize);
- }
- setupHandlePosition.call(instance, currentTH);
- }
- });
- instance.addHook('afterDestroy', unbindEvents);
- };
- var unbindEvents = function() {
- eventManager.clear();
- };
- this.beforeInit = function() {
- this.manualColumnWidths = [];
- };
- this.init = function(source) {
- var instance = this;
- var manualColumnWidthEnabled = !!(this.getSettings().manualColumnResize);
- if (manualColumnWidthEnabled) {
- var initialColumnWidths = this.getSettings().manualColumnResize;
- var loadedManualColumnWidths = loadManualColumnWidths.call(instance);
- if (typeof instance.manualColumnWidthsPluginUsages != 'undefined') {
- instance.manualColumnWidthsPluginUsages.push('manualColumnResize');
- } else {
- instance.manualColumnWidthsPluginUsages = ['manualColumnResize'];
- }
- if (typeof loadedManualColumnWidths != 'undefined') {
- this.manualColumnWidths = loadedManualColumnWidths;
- } else if (Array.isArray(initialColumnWidths)) {
- this.manualColumnWidths = initialColumnWidths;
- } else {
- this.manualColumnWidths = [];
- }
- if (source == 'afterInit') {
- bindEvents.call(this);
- if (this.manualColumnWidths.length > 0) {
- this.forceFullRender = true;
- this.render();
- }
- }
- } else {
- var pluginUsagesIndex = instance.manualColumnWidthsPluginUsages ? instance.manualColumnWidthsPluginUsages.indexOf('manualColumnResize') : -1;
- if (pluginUsagesIndex > -1) {
- unbindEvents.call(this);
- this.manualColumnWidths = [];
- }
- }
- };
- var setManualSize = function(col, width) {
- width = Math.max(width, 20);
- col = Handsontable.hooks.run(instance, 'modifyCol', col);
- instance.manualColumnWidths[col] = width;
- return width;
- };
- this.modifyColWidth = function(width, col) {
- col = this.runHooks('modifyCol', col);
- if (this.getSettings().manualColumnResize && this.manualColumnWidths[col]) {
- return this.manualColumnWidths[col];
- }
- return width;
- };
- }
- var htManualColumnResize = new ManualColumnResize();
- Handsontable.hooks.add('beforeInit', htManualColumnResize.beforeInit);
- Handsontable.hooks.add('afterInit', function() {
- htManualColumnResize.init.call(this, 'afterInit');
- });
- Handsontable.hooks.add('afterUpdateSettings', function() {
- htManualColumnResize.init.call(this, 'afterUpdateSettings');
- });
- Handsontable.hooks.add('modifyColWidth', htManualColumnResize.modifyColWidth);
- Handsontable.hooks.register('afterColumnResize');
-
- //#
- },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../helpers.js":42,"./../../plugins.js":45}],61:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- ManualRowMove: {get: function() {
- return ManualRowMove;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_helpers_46_js__,
- $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_eventManager_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__;
- var helper = ($___46__46__47__46__46__47_helpers_46_js__ = require("./../../helpers.js"), $___46__46__47__46__46__47_helpers_46_js__ && $___46__46__47__46__46__47_helpers_46_js__.__esModule && $___46__46__47__46__46__47_helpers_46_js__ || {default: $___46__46__47__46__46__47_helpers_46_js__});
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47__46__46__47_eventManager_46_js__ = require("./../../eventManager.js"), $___46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- ;
- function ManualRowMove() {
- var startRow,
- endRow,
- startY,
- startOffset,
- currentRow,
- currentTH,
- handle = document.createElement('DIV'),
- guide = document.createElement('DIV'),
- eventManager = eventManagerObject(this);
- handle.className = 'manualRowMover';
- guide.className = 'manualRowMoverGuide';
- var saveManualRowPositions = function() {
- var instance = this;
- Handsontable.hooks.run(instance, 'persistentStateSave', 'manualRowPositions', instance.manualRowPositions);
- };
- var loadManualRowPositions = function() {
- var instance = this,
- storedState = {};
- Handsontable.hooks.run(instance, 'persistentStateLoad', 'manualRowPositions', storedState);
- return storedState.value;
- };
- function setupHandlePosition(TH) {
- var instance = this;
- currentTH = TH;
- var row = this.view.wt.wtTable.getCoords(TH).row;
- if (row >= 0) {
- currentRow = row;
- var box = currentTH.getBoundingClientRect();
- startOffset = box.top;
- handle.style.top = startOffset + 'px';
- handle.style.left = box.left + 'px';
- instance.rootElement.appendChild(handle);
- }
- }
- function refreshHandlePosition(TH, delta) {
- var box = TH.getBoundingClientRect();
- var handleHeight = 6;
- if (delta > 0) {
- handle.style.top = (box.top + box.height - handleHeight) + 'px';
- } else {
- handle.style.top = box.top + 'px';
- }
- }
- function setupGuidePosition() {
- var instance = this;
- dom.addClass(handle, 'active');
- dom.addClass(guide, 'active');
- var box = currentTH.getBoundingClientRect();
- guide.style.width = instance.view.maximumVisibleElementWidth(0) + 'px';
- guide.style.height = box.height + 'px';
- guide.style.top = startOffset + 'px';
- guide.style.left = handle.style.left;
- instance.rootElement.appendChild(guide);
- }
- function refreshGuidePosition(diff) {
- guide.style.top = startOffset + diff + 'px';
- }
- function hideHandleAndGuide() {
- dom.removeClass(handle, 'active');
- dom.removeClass(guide, 'active');
- }
- var checkRowHeader = function(element) {
- if (element.tagName != 'BODY') {
- if (element.parentNode.tagName == 'TBODY') {
- return true;
- } else {
- element = element.parentNode;
- return checkRowHeader(element);
- }
- }
- return false;
- };
- var getTHFromTargetElement = function(element) {
- if (element.tagName != 'TABLE') {
- if (element.tagName == 'TH') {
- return element;
- } else {
- return getTHFromTargetElement(element.parentNode);
- }
- }
- return null;
- };
- var bindEvents = function() {
- var instance = this;
- var pressed;
- eventManager.addEventListener(instance.rootElement, 'mouseover', function(e) {
- if (checkRowHeader(e.target)) {
- var th = getTHFromTargetElement(e.target);
- if (th) {
- if (pressed) {
- endRow = instance.view.wt.wtTable.getCoords(th).row;
- refreshHandlePosition(th, endRow - startRow);
- } else {
- setupHandlePosition.call(instance, th);
- }
- }
- }
- });
- eventManager.addEventListener(instance.rootElement, 'mousedown', function(e) {
- if (dom.hasClass(e.target, 'manualRowMover')) {
- startY = helper.pageY(e);
- setupGuidePosition.call(instance);
- pressed = instance;
- startRow = currentRow;
- endRow = currentRow;
- }
- });
- eventManager.addEventListener(window, 'mousemove', function(e) {
- if (pressed) {
- refreshGuidePosition(helper.pageY(e) - startY);
- }
- });
- eventManager.addEventListener(window, 'mouseup', function(e) {
- if (pressed) {
- hideHandleAndGuide();
- pressed = false;
- createPositionData(instance.manualRowPositions, instance.countRows());
- instance.manualRowPositions.splice(endRow, 0, instance.manualRowPositions.splice(startRow, 1)[0]);
- instance.forceFullRender = true;
- instance.view.render();
- saveManualRowPositions.call(instance);
- Handsontable.hooks.run(instance, 'afterRowMove', startRow, endRow);
- setupHandlePosition.call(instance, currentTH);
- }
- });
- instance.addHook('afterDestroy', unbindEvents);
- };
- var unbindEvents = function() {
- eventManager.clear();
- };
- var createPositionData = function(positionArr, len) {
- if (positionArr.length < len) {
- for (var i = positionArr.length; i < len; i++) {
- positionArr[i] = i;
- }
- }
- };
- this.beforeInit = function() {
- this.manualRowPositions = [];
- };
- this.init = function(source) {
- var instance = this;
- var manualRowMoveEnabled = !!(instance.getSettings().manualRowMove);
- if (manualRowMoveEnabled) {
- var initialManualRowPositions = instance.getSettings().manualRowMove;
- var loadedManualRowPostions = loadManualRowPositions.call(instance);
- if (typeof instance.manualRowPositionsPluginUsages != 'undefined') {
- instance.manualRowPositionsPluginUsages.push('manualColumnMove');
- } else {
- instance.manualRowPositionsPluginUsages = ['manualColumnMove'];
- }
- if (typeof loadedManualRowPostions != 'undefined') {
- this.manualRowPositions = loadedManualRowPostions;
- } else if (Array.isArray(initialManualRowPositions)) {
- this.manualRowPositions = initialManualRowPositions;
- } else {
- this.manualRowPositions = [];
- }
- if (source === 'afterInit') {
- bindEvents.call(this);
- if (this.manualRowPositions.length > 0) {
- instance.forceFullRender = true;
- instance.render();
- }
- }
- } else {
- var pluginUsagesIndex = instance.manualRowPositionsPluginUsages ? instance.manualRowPositionsPluginUsages.indexOf('manualColumnMove') : -1;
- if (pluginUsagesIndex > -1) {
- unbindEvents.call(this);
- instance.manualRowPositions = [];
- instance.manualRowPositionsPluginUsages[pluginUsagesIndex] = void 0;
- }
- }
- };
- this.modifyRow = function(row) {
- var instance = this;
- if (instance.getSettings().manualRowMove) {
- if (typeof instance.manualRowPositions[row] === 'undefined') {
- createPositionData(this.manualRowPositions, row + 1);
- }
- return instance.manualRowPositions[row];
- }
- return row;
- };
- }
- var htManualRowMove = new ManualRowMove();
- Handsontable.hooks.add('beforeInit', htManualRowMove.beforeInit);
- Handsontable.hooks.add('afterInit', function() {
- htManualRowMove.init.call(this, 'afterInit');
- });
- Handsontable.hooks.add('afterUpdateSettings', function() {
- htManualRowMove.init.call(this, 'afterUpdateSettings');
- });
- Handsontable.hooks.add('modifyRow', htManualRowMove.modifyRow);
- Handsontable.hooks.register('afterRowMove');
-
- //#
- },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../helpers.js":42,"./../../plugins.js":45}],62:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- ManualRowResize: {get: function() {
- return ManualRowResize;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_helpers_46_js__,
- $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_eventManager_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__;
- var helper = ($___46__46__47__46__46__47_helpers_46_js__ = require("./../../helpers.js"), $___46__46__47__46__46__47_helpers_46_js__ && $___46__46__47__46__46__47_helpers_46_js__.__esModule && $___46__46__47__46__46__47_helpers_46_js__ || {default: $___46__46__47__46__46__47_helpers_46_js__});
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47__46__46__47_eventManager_46_js__ = require("./../../eventManager.js"), $___46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- ;
- function ManualRowResize() {
- var currentTH,
- currentRow,
- currentHeight,
- instance,
- newSize,
- startY,
- startHeight,
- startOffset,
- handle = document.createElement('DIV'),
- guide = document.createElement('DIV'),
- eventManager = eventManagerObject(this);
- handle.className = 'manualRowResizer';
- guide.className = 'manualRowResizerGuide';
- var saveManualRowHeights = function() {
- var instance = this;
- Handsontable.hooks.run(instance, 'persistentStateSave', 'manualRowHeights', instance.manualRowHeights);
- };
- var loadManualRowHeights = function() {
- var instance = this,
- storedState = {};
- Handsontable.hooks.run(instance, 'persistentStateLoad', 'manualRowHeights', storedState);
- return storedState.value;
- };
- function setupHandlePosition(TH) {
- instance = this;
- currentTH = TH;
- var row = this.view.wt.wtTable.getCoords(TH).row;
- if (row >= 0) {
- currentRow = row;
- var box = currentTH.getBoundingClientRect();
- startOffset = box.top - 6;
- startHeight = parseInt(box.height, 10);
- handle.style.left = box.left + 'px';
- handle.style.top = startOffset + startHeight + 'px';
- instance.rootElement.appendChild(handle);
- }
- }
- function refreshHandlePosition() {
- handle.style.top = startOffset + currentHeight + 'px';
- }
- function setupGuidePosition() {
- var instance = this;
- dom.addClass(handle, 'active');
- dom.addClass(guide, 'active');
- guide.style.top = handle.style.top;
- guide.style.left = handle.style.left;
- guide.style.width = instance.view.maximumVisibleElementWidth(0) + 'px';
- instance.rootElement.appendChild(guide);
- }
- function refreshGuidePosition() {
- guide.style.top = handle.style.top;
- }
- function hideHandleAndGuide() {
- dom.removeClass(handle, 'active');
- dom.removeClass(guide, 'active');
- }
- var checkRowHeader = function(element) {
- if (element.tagName != 'BODY') {
- if (element.parentNode.tagName == 'TBODY') {
- return true;
- } else {
- element = element.parentNode;
- return checkRowHeader(element);
- }
- }
- return false;
- };
- var getTHFromTargetElement = function(element) {
- if (element.tagName != 'TABLE') {
- if (element.tagName == 'TH') {
- return element;
- } else {
- return getTHFromTargetElement(element.parentNode);
- }
- }
- return null;
- };
- var bindEvents = function() {
- var instance = this;
- var pressed;
- var dblclick = 0;
- var autoresizeTimeout = null;
- eventManager.addEventListener(instance.rootElement, 'mouseover', function(e) {
- if (checkRowHeader(e.target)) {
- var th = getTHFromTargetElement(e.target);
- if (th) {
- if (!pressed) {
- setupHandlePosition.call(instance, th);
- }
- }
- }
- });
- eventManager.addEventListener(instance.rootElement, 'mousedown', function(e) {
- if (dom.hasClass(e.target, 'manualRowResizer')) {
- setupGuidePosition.call(instance);
- pressed = instance;
- if (autoresizeTimeout == null) {
- autoresizeTimeout = setTimeout(function() {
- if (dblclick >= 2) {
- setManualSize(currentRow, null);
- instance.forceFullRender = true;
- instance.view.render();
- Handsontable.hooks.run(instance, 'afterRowResize', currentRow, newSize);
- }
- dblclick = 0;
- autoresizeTimeout = null;
- }, 500);
- instance._registerTimeout(autoresizeTimeout);
- }
- dblclick++;
- startY = helper.pageY(e);
- newSize = startHeight;
- }
- });
- eventManager.addEventListener(window, 'mousemove', function(e) {
- if (pressed) {
- currentHeight = startHeight + (helper.pageY(e) - startY);
- newSize = setManualSize(currentRow, currentHeight);
- refreshHandlePosition();
- refreshGuidePosition();
- }
- });
- eventManager.addEventListener(window, 'mouseup', function(e) {
- if (pressed) {
- hideHandleAndGuide();
- pressed = false;
- if (newSize != startHeight) {
- instance.forceFullRender = true;
- instance.view.render();
- saveManualRowHeights.call(instance);
- Handsontable.hooks.run(instance, 'afterRowResize', currentRow, newSize);
- }
- setupHandlePosition.call(instance, currentTH);
- }
- });
- instance.addHook('afterDestroy', unbindEvents);
- };
- var unbindEvents = function() {
- eventManager.clear();
- };
- this.beforeInit = function() {
- this.manualRowHeights = [];
- };
- this.init = function(source) {
- var instance = this;
- var manualColumnHeightEnabled = !!(this.getSettings().manualRowResize);
- if (manualColumnHeightEnabled) {
- var initialRowHeights = this.getSettings().manualRowResize;
- var loadedManualRowHeights = loadManualRowHeights.call(instance);
- if (typeof instance.manualRowHeightsPluginUsages != 'undefined') {
- instance.manualRowHeightsPluginUsages.push('manualRowResize');
- } else {
- instance.manualRowHeightsPluginUsages = ['manualRowResize'];
- }
- if (typeof loadedManualRowHeights != 'undefined') {
- this.manualRowHeights = loadedManualRowHeights;
- } else if (Array.isArray(initialRowHeights)) {
- this.manualRowHeights = initialRowHeights;
- } else {
- this.manualRowHeights = [];
- }
- if (source === 'afterInit') {
- bindEvents.call(this);
- if (this.manualRowHeights.length > 0) {
- this.forceFullRender = true;
- this.render();
- }
- } else {
- this.forceFullRender = true;
- this.render();
- }
- } else {
- var pluginUsagesIndex = instance.manualRowHeightsPluginUsages ? instance.manualRowHeightsPluginUsages.indexOf('manualRowResize') : -1;
- if (pluginUsagesIndex > -1) {
- unbindEvents.call(this);
- this.manualRowHeights = [];
- instance.manualRowHeightsPluginUsages[pluginUsagesIndex] = void 0;
- }
- }
- };
- var setManualSize = function(row, height) {
- row = Handsontable.hooks.run(instance, 'modifyRow', row);
- instance.manualRowHeights[row] = height;
- return height;
- };
- this.modifyRowHeight = function(height, row) {
- if (this.getSettings().manualRowResize) {
- row = this.runHooks('modifyRow', row);
- if (this.manualRowHeights[row] !== void 0) {
- return this.manualRowHeights[row];
- }
- }
- return height;
- };
- }
- var htManualRowResize = new ManualRowResize();
- Handsontable.hooks.add('beforeInit', htManualRowResize.beforeInit);
- Handsontable.hooks.add('afterInit', function() {
- htManualRowResize.init.call(this, 'afterInit');
- });
- Handsontable.hooks.add('afterUpdateSettings', function() {
- htManualRowResize.init.call(this, 'afterUpdateSettings');
- });
- Handsontable.hooks.add('modifyRowHeight', htManualRowResize.modifyRowHeight);
- Handsontable.hooks.register('afterRowResize');
-
- //#
- },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../helpers.js":42,"./../../plugins.js":45}],63:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- MergeCells: {get: function() {
- return MergeCells;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_plugins_46_js__,
- $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
- $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__,
- $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table_46_js__;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- var WalkontableCellCoords = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ = require("./../../3rdparty/walkontable/src/cell/coords.js"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__}).WalkontableCellCoords;
- var WalkontableCellRange = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ = require("./../../3rdparty/walkontable/src/cell/range.js"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__}).WalkontableCellRange;
- var WalkontableTable = ($___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table_46_js__ = require("./../../3rdparty/walkontable/src/table.js"), $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table_46_js__ && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table_46_js__.__esModule && $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table_46_js__ || {default: $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table_46_js__}).WalkontableTable;
- ;
- function CellInfoCollection() {
- var collection = [];
- collection.getInfo = function(row, col) {
- for (var i = 0,
- ilen = this.length; i < ilen; i++) {
- 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) {
- return this[i];
- }
- }
- };
- collection.setInfo = function(info) {
- for (var i = 0,
- ilen = this.length; i < ilen; i++) {
- if (this[i].row === info.row && this[i].col === info.col) {
- this[i] = info;
- return;
- }
- }
- this.push(info);
- };
- collection.removeInfo = function(row, col) {
- for (var i = 0,
- ilen = this.length; i < ilen; i++) {
- if (this[i].row === row && this[i].col === col) {
- this.splice(i, 1);
- break;
- }
- }
- };
- return collection;
- }
- function MergeCells(mergeCellsSetting) {
- this.mergedCellInfoCollection = new CellInfoCollection();
- if (Array.isArray(mergeCellsSetting)) {
- for (var i = 0,
- ilen = mergeCellsSetting.length; i < ilen; i++) {
- this.mergedCellInfoCollection.setInfo(mergeCellsSetting[i]);
- }
- }
- }
- MergeCells.prototype.canMergeRange = function(cellRange) {
- return !cellRange.isSingle();
- };
- MergeCells.prototype.mergeRange = function(cellRange) {
- if (!this.canMergeRange(cellRange)) {
- return;
- }
- var topLeft = cellRange.getTopLeftCorner();
- var bottomRight = cellRange.getBottomRightCorner();
- var mergeParent = {};
- mergeParent.row = topLeft.row;
- mergeParent.col = topLeft.col;
- mergeParent.rowspan = bottomRight.row - topLeft.row + 1;
- mergeParent.colspan = bottomRight.col - topLeft.col + 1;
- this.mergedCellInfoCollection.setInfo(mergeParent);
- };
- MergeCells.prototype.mergeOrUnmergeSelection = function(cellRange) {
- var info = this.mergedCellInfoCollection.getInfo(cellRange.from.row, cellRange.from.col);
- if (info) {
- this.unmergeSelection(cellRange.from);
- } else {
- this.mergeSelection(cellRange);
- }
- };
- MergeCells.prototype.mergeSelection = function(cellRange) {
- this.mergeRange(cellRange);
- };
- MergeCells.prototype.unmergeSelection = function(cellRange) {
- var info = this.mergedCellInfoCollection.getInfo(cellRange.row, cellRange.col);
- this.mergedCellInfoCollection.removeInfo(info.row, info.col);
- };
- MergeCells.prototype.applySpanProperties = function(TD, row, col) {
- var info = this.mergedCellInfoCollection.getInfo(row, col);
- if (info) {
- if (info.row === row && info.col === col) {
- TD.setAttribute('rowspan', info.rowspan);
- TD.setAttribute('colspan', info.colspan);
- } else {
- TD.removeAttribute('rowspan');
- TD.removeAttribute('colspan');
- TD.style.display = "none";
- }
- } else {
- TD.removeAttribute('rowspan');
- TD.removeAttribute('colspan');
- }
- };
- MergeCells.prototype.modifyTransform = function(hook, currentSelectedRange, delta) {
- var sameRowspan = function(merged, coords) {
- if (coords.row >= merged.row && coords.row <= (merged.row + merged.rowspan - 1)) {
- return true;
- }
- return false;
- },
- sameColspan = function(merged, coords) {
- if (coords.col >= merged.col && coords.col <= (merged.col + merged.colspan - 1)) {
- return true;
- }
- return false;
- },
- getNextPosition = function(newDelta) {
- return new WalkontableCellCoords(currentSelectedRange.to.row + newDelta.row, currentSelectedRange.to.col + newDelta.col);
- };
- var newDelta = {
- row: delta.row,
- col: delta.col
- };
- if (hook == 'modifyTransformStart') {
- if (!this.lastDesiredCoords) {
- this.lastDesiredCoords = new WalkontableCellCoords(null, null);
- }
- var currentPosition = new WalkontableCellCoords(currentSelectedRange.highlight.row, currentSelectedRange.highlight.col),
- mergedParent = this.mergedCellInfoCollection.getInfo(currentPosition.row, currentPosition.col),
- currentRangeContainsMerge;
- for (var i = 0,
- mergesLength = this.mergedCellInfoCollection.length; i < mergesLength; i++) {
- var range = this.mergedCellInfoCollection[i];
- range = new WalkontableCellCoords(range.row + range.rowspan - 1, range.col + range.colspan - 1);
- if (currentSelectedRange.includes(range)) {
- currentRangeContainsMerge = true;
- break;
- }
- }
- if (mergedParent) {
- var mergeTopLeft = new WalkontableCellCoords(mergedParent.row, mergedParent.col),
- mergeBottomRight = new WalkontableCellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1),
- mergeRange = new WalkontableCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
- if (!mergeRange.includes(this.lastDesiredCoords)) {
- this.lastDesiredCoords = new WalkontableCellCoords(null, null);
- }
- newDelta.row = this.lastDesiredCoords.row ? this.lastDesiredCoords.row - currentPosition.row : newDelta.row;
- newDelta.col = this.lastDesiredCoords.col ? this.lastDesiredCoords.col - currentPosition.col : newDelta.col;
- if (delta.row > 0) {
- newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
- } else if (delta.row < 0) {
- newDelta.row = currentPosition.row - mergedParent.row + delta.row;
- }
- if (delta.col > 0) {
- newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
- } else if (delta.col < 0) {
- newDelta.col = currentPosition.col - mergedParent.col + delta.col;
- }
- }
- var nextPosition = new WalkontableCellCoords(currentSelectedRange.highlight.row + newDelta.row, currentSelectedRange.highlight.col + newDelta.col),
- nextParentIsMerged = this.mergedCellInfoCollection.getInfo(nextPosition.row, nextPosition.col);
- if (nextParentIsMerged) {
- this.lastDesiredCoords = nextPosition;
- newDelta = {
- row: nextParentIsMerged.row - currentPosition.row,
- col: nextParentIsMerged.col - currentPosition.col
- };
- }
- } else if (hook == 'modifyTransformEnd') {
- for (var i = 0,
- mergesLength = this.mergedCellInfoCollection.length; i < mergesLength; i++) {
- var currentMerge = this.mergedCellInfoCollection[i],
- mergeTopLeft = new WalkontableCellCoords(currentMerge.row, currentMerge.col),
- mergeBottomRight = new WalkontableCellCoords(currentMerge.row + currentMerge.rowspan - 1, currentMerge.col + currentMerge.colspan - 1),
- mergedRange = new WalkontableCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight),
- sharedBorders = currentSelectedRange.getBordersSharedWith(mergedRange);
- if (mergedRange.isEqual(currentSelectedRange)) {
- currentSelectedRange.setDirection("NW-SE");
- } else if (sharedBorders.length > 0) {
- var mergeHighlighted = (currentSelectedRange.highlight.isEqual(mergedRange.from));
- if (sharedBorders.indexOf('top') > -1) {
- if (currentSelectedRange.to.isSouthEastOf(mergedRange.from) && mergeHighlighted) {
- currentSelectedRange.setDirection("NW-SE");
- } else if (currentSelectedRange.to.isSouthWestOf(mergedRange.from) && mergeHighlighted) {
- currentSelectedRange.setDirection("NE-SW");
- }
- } else if (sharedBorders.indexOf('bottom') > -1) {
- if (currentSelectedRange.to.isNorthEastOf(mergedRange.from) && mergeHighlighted) {
- currentSelectedRange.setDirection("SW-NE");
- } else if (currentSelectedRange.to.isNorthWestOf(mergedRange.from) && mergeHighlighted) {
- currentSelectedRange.setDirection("SE-NW");
- }
- }
- }
- var nextPosition = getNextPosition(newDelta),
- withinRowspan = sameRowspan(currentMerge, nextPosition),
- withinColspan = sameColspan(currentMerge, nextPosition);
- if (currentSelectedRange.includesRange(mergedRange) && (mergedRange.includes(nextPosition) || withinRowspan || withinColspan)) {
- if (withinRowspan) {
- if (newDelta.row < 0) {
- newDelta.row -= currentMerge.rowspan - 1;
- } else if (newDelta.row > 0) {
- newDelta.row += currentMerge.rowspan - 1;
- }
- }
- if (withinColspan) {
- if (newDelta.col < 0) {
- newDelta.col -= currentMerge.colspan - 1;
- } else if (newDelta.col > 0) {
- newDelta.col += currentMerge.colspan - 1;
- }
- }
- }
- }
- }
- if (newDelta.row !== 0) {
- delta.row = newDelta.row;
- }
- if (newDelta.col !== 0) {
- delta.col = newDelta.col;
- }
- };
- var beforeInit = function() {
- var instance = this;
- var mergeCellsSetting = instance.getSettings().mergeCells;
- if (mergeCellsSetting) {
- if (!instance.mergeCells) {
- instance.mergeCells = new MergeCells(mergeCellsSetting);
- }
- }
- };
- var afterInit = function() {
- var instance = this;
- if (instance.mergeCells) {
- instance.view.wt.wtTable.getCell = function(coords) {
- if (instance.getSettings().mergeCells) {
- var mergeParent = instance.mergeCells.mergedCellInfoCollection.getInfo(coords.row, coords.col);
- if (mergeParent) {
- coords = mergeParent;
- }
- }
- return WalkontableTable.prototype.getCell.call(this, coords);
- };
- }
- };
- var onBeforeKeyDown = function(event) {
- if (!this.mergeCells) {
- return;
- }
- var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
- if (ctrlDown) {
- if (event.keyCode === 77) {
- this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange());
- this.render();
- event.stopImmediatePropagation();
- }
- }
- };
- var addMergeActionsToContextMenu = function(defaultOptions) {
- if (!this.getSettings().mergeCells) {
- return;
- }
- defaultOptions.items.push(Handsontable.ContextMenu.SEPARATOR);
- defaultOptions.items.push({
- key: 'mergeCells',
- name: function() {
- var sel = this.getSelected();
- var info = this.mergeCells.mergedCellInfoCollection.getInfo(sel[0], sel[1]);
- if (info) {
- return 'Unmerge cells';
- } else {
- return 'Merge cells';
- }
- },
- callback: function() {
- this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange());
- this.render();
- },
- disabled: function() {
- return false;
- }
- });
- };
- var afterRenderer = function(TD, row, col, prop, value, cellProperties) {
- if (this.mergeCells) {
- this.mergeCells.applySpanProperties(TD, row, col);
- }
- };
- var modifyTransformFactory = function(hook) {
- return function(delta) {
- var mergeCellsSetting = this.getSettings().mergeCells;
- if (mergeCellsSetting) {
- var currentSelectedRange = this.getSelectedRange();
- this.mergeCells.modifyTransform(hook, currentSelectedRange, delta);
- if (hook === "modifyTransformEnd") {
- var totalRows = this.countRows();
- var totalCols = this.countCols();
- if (currentSelectedRange.from.row < 0) {
- currentSelectedRange.from.row = 0;
- } else if (currentSelectedRange.from.row > 0 && currentSelectedRange.from.row >= totalRows) {
- currentSelectedRange.from.row = currentSelectedRange.from - 1;
- }
- if (currentSelectedRange.from.col < 0) {
- currentSelectedRange.from.col = 0;
- } else if (currentSelectedRange.from.col > 0 && currentSelectedRange.from.col >= totalCols) {
- currentSelectedRange.from.col = totalCols - 1;
- }
- }
- }
- };
- };
- var beforeSetRangeEnd = function(coords) {
- this.lastDesiredCoords = null;
- var mergeCellsSetting = this.getSettings().mergeCells;
- if (mergeCellsSetting) {
- var selRange = this.getSelectedRange();
- selRange.highlight = new WalkontableCellCoords(selRange.highlight.row, selRange.highlight.col);
- selRange.to = coords;
- var rangeExpanded = false;
- do {
- rangeExpanded = false;
- for (var i = 0,
- ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) {
- var cellInfo = this.mergeCells.mergedCellInfoCollection[i];
- var mergedCellTopLeft = new WalkontableCellCoords(cellInfo.row, cellInfo.col);
- var mergedCellBottomRight = new WalkontableCellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1);
- var mergedCellRange = new WalkontableCellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
- if (selRange.expandByRange(mergedCellRange)) {
- coords.row = selRange.to.row;
- coords.col = selRange.to.col;
- rangeExpanded = true;
- }
- }
- } while (rangeExpanded);
- }
- };
- var beforeDrawAreaBorders = function(corners, className) {
- if (className && className == 'area') {
- var mergeCellsSetting = this.getSettings().mergeCells;
- if (mergeCellsSetting) {
- var selRange = this.getSelectedRange();
- var startRange = new WalkontableCellRange(selRange.from, selRange.from, selRange.from);
- var stopRange = new WalkontableCellRange(selRange.to, selRange.to, selRange.to);
- for (var i = 0,
- ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) {
- var cellInfo = this.mergeCells.mergedCellInfoCollection[i];
- var mergedCellTopLeft = new WalkontableCellCoords(cellInfo.row, cellInfo.col);
- var mergedCellBottomRight = new WalkontableCellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1);
- var mergedCellRange = new WalkontableCellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
- if (startRange.expandByRange(mergedCellRange)) {
- corners[0] = startRange.from.row;
- corners[1] = startRange.from.col;
- }
- if (stopRange.expandByRange(mergedCellRange)) {
- corners[2] = stopRange.from.row;
- corners[3] = stopRange.from.col;
- }
- }
- }
- }
- };
- var afterGetCellMeta = function(row, col, cellProperties) {
- var mergeCellsSetting = this.getSettings().mergeCells;
- if (mergeCellsSetting) {
- var mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(row, col);
- if (mergeParent && (mergeParent.row != row || mergeParent.col != col)) {
- cellProperties.copyable = false;
- }
- }
- };
- var afterViewportRowCalculatorOverride = function(calc) {
- var mergeCellsSetting = this.getSettings().mergeCells;
- if (mergeCellsSetting) {
- var colCount = this.countCols();
- var mergeParent;
- for (var c = 0; c < colCount; c++) {
- mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.startRow, c);
- if (mergeParent) {
- if (mergeParent.row < calc.startRow) {
- calc.startRow = mergeParent.row;
- return afterViewportRowCalculatorOverride.call(this, calc);
- }
- }
- mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.endRow, c);
- if (mergeParent) {
- var mergeEnd = mergeParent.row + mergeParent.rowspan - 1;
- if (mergeEnd > calc.endRow) {
- calc.endRow = mergeEnd;
- return afterViewportRowCalculatorOverride.call(this, calc);
- }
- }
- }
- }
- };
- var afterViewportColumnCalculatorOverride = function(calc) {
- var mergeCellsSetting = this.getSettings().mergeCells;
- if (mergeCellsSetting) {
- var rowCount = this.countRows();
- var mergeParent;
- for (var r = 0; r < rowCount; r++) {
- mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.startColumn);
- if (mergeParent) {
- if (mergeParent.col < calc.startColumn) {
- calc.startColumn = mergeParent.col;
- return afterViewportColumnCalculatorOverride.call(this, calc);
- }
- }
- mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.endColumn);
- if (mergeParent) {
- var mergeEnd = mergeParent.col + mergeParent.colspan - 1;
- if (mergeEnd > calc.endColumn) {
- calc.endColumn = mergeEnd;
- return afterViewportColumnCalculatorOverride.call(this, calc);
- }
- }
- }
- }
- };
- var isMultipleSelection = function(isMultiple) {
- if (isMultiple && this.mergeCells) {
- var mergedCells = this.mergeCells.mergedCellInfoCollection,
- selectionRange = this.getSelectedRange();
- for (var group in mergedCells) {
- 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) {
- return false;
- }
- }
- }
- return isMultiple;
- };
- function afterAutofillApplyValues(select, drag) {
- var mergeCellsSetting = this.getSettings().mergeCells;
- if (!mergeCellsSetting || this.selection.isMultiple()) {
- return;
- }
- var info = this.mergeCells.mergedCellInfoCollection.getInfo(select[0], select[1]);
- if (info) {
- select[0] = info.row;
- select[1] = info.col;
- select[2] = info.row + info.rowspan - 1;
- select[3] = info.col + info.colspan - 1;
- }
- }
- Handsontable.hooks.add('beforeInit', beforeInit);
- Handsontable.hooks.add('afterInit', afterInit);
- Handsontable.hooks.add('beforeKeyDown', onBeforeKeyDown);
- Handsontable.hooks.add('modifyTransformStart', modifyTransformFactory('modifyTransformStart'));
- Handsontable.hooks.add('modifyTransformEnd', modifyTransformFactory('modifyTransformEnd'));
- Handsontable.hooks.add('beforeSetRangeEnd', beforeSetRangeEnd);
- Handsontable.hooks.add('beforeDrawBorders', beforeDrawAreaBorders);
- Handsontable.hooks.add('afterIsMultipleSelection', isMultipleSelection);
- Handsontable.hooks.add('afterRenderer', afterRenderer);
- Handsontable.hooks.add('afterContextMenuDefaultOptions', addMergeActionsToContextMenu);
- Handsontable.hooks.add('afterGetCellMeta', afterGetCellMeta);
- Handsontable.hooks.add('afterViewportRowCalculatorOverride', afterViewportRowCalculatorOverride);
- Handsontable.hooks.add('afterViewportColumnCalculatorOverride', afterViewportColumnCalculatorOverride);
- Handsontable.hooks.add('afterAutofillApplyValues', afterAutofillApplyValues);
- Handsontable.MergeCells = MergeCells;
-
- //#
- },{"./../../3rdparty/walkontable/src/cell/coords.js":5,"./../../3rdparty/walkontable/src/cell/range.js":6,"./../../3rdparty/walkontable/src/table.js":20,"./../../plugins.js":45}],64:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- default: {get: function() {
- return $__default;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__95_base_46_js__,
- $___46__46__47__46__46__47_eventManager_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__;
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- 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;
- var eventManagerObject = ($___46__46__47__46__46__47_eventManager_46_js__ = require("./../../eventManager.js"), $___46__46__47__46__46__47_eventManager_46_js__ && $___46__46__47__46__46__47_eventManager_46_js__.__esModule && $___46__46__47__46__46__47_eventManager_46_js__ || {default: $___46__46__47__46__46__47_eventManager_46_js__}).eventManager;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- var MultipleSelectionHandles = function MultipleSelectionHandles(hotInstance) {
- var $__3 = this;
- $traceurRuntime.superConstructor($MultipleSelectionHandles).call(this, hotInstance);
- this.dragged = [];
- this.eventManager = eventManagerObject(this.hot);
- this.bindTouchEvents();
- this.hot.addHook('afterInit', (function() {
- return $__3.init();
- }));
- };
- var $MultipleSelectionHandles = MultipleSelectionHandles;
- ($traceurRuntime.createClass)(MultipleSelectionHandles, {
- init: function() {
- this.lastSetCell = null;
- Handsontable.plugins.multipleSelectionHandles = new $MultipleSelectionHandles(this.hot);
- },
- bindTouchEvents: function() {
- var _this = this;
- function removeFromDragged(query) {
- if (_this.dragged.length === 1) {
- _this.dragged.splice(0, _this.dragged.length);
- return true;
- }
- var entryPosition = _this.dragged.indexOf(query);
- if (entryPosition == -1) {
- return false;
- } else if (entryPosition === 0) {
- _this.dragged = _this.dragged.slice(0, 1);
- } else if (entryPosition == 1) {
- _this.dragged = _this.dragged.slice(-1);
- }
- }
- this.eventManager.addEventListener(this.hot.rootElement, 'touchstart', function(event) {
- var selectedRange;
- if (dom.hasClass(event.target, "topLeftSelectionHandle-HitArea")) {
- selectedRange = _this.hot.getSelectedRange();
- _this.dragged.push("topLeft");
- _this.touchStartRange = {
- width: selectedRange.getWidth(),
- height: selectedRange.getHeight(),
- direction: selectedRange.getDirection()
- };
- event.preventDefault();
- return false;
- } else if (dom.hasClass(event.target, "bottomRightSelectionHandle-HitArea")) {
- selectedRange = _this.hot.getSelectedRange();
- _this.dragged.push("bottomRight");
- _this.touchStartRange = {
- width: selectedRange.getWidth(),
- height: selectedRange.getHeight(),
- direction: selectedRange.getDirection()
- };
- event.preventDefault();
- return false;
- }
- });
- this.eventManager.addEventListener(this.hot.rootElement, 'touchend', function(event) {
- if (dom.hasClass(event.target, "topLeftSelectionHandle-HitArea")) {
- removeFromDragged.call(_this, "topLeft");
- _this.touchStartRange = void 0;
- event.preventDefault();
- return false;
- } else if (dom.hasClass(event.target, "bottomRightSelectionHandle-HitArea")) {
- removeFromDragged.call(_this, "bottomRight");
- _this.touchStartRange = void 0;
- event.preventDefault();
- return false;
- }
- });
- this.eventManager.addEventListener(this.hot.rootElement, 'touchmove', function(event) {
- var scrollTop = dom.getWindowScrollTop(),
- scrollLeft = dom.getWindowScrollLeft(),
- endTarget,
- targetCoords,
- selectedRange,
- rangeWidth,
- rangeHeight,
- rangeDirection,
- newRangeCoords;
- if (_this.dragged.length === 0) {
- return;
- }
- endTarget = document.elementFromPoint(event.touches[0].screenX - scrollLeft, event.touches[0].screenY - scrollTop);
- if (!endTarget || endTarget === _this.lastSetCell) {
- return;
- }
- if (endTarget.nodeName == "TD" || endTarget.nodeName == "TH") {
- targetCoords = _this.hot.getCoords(endTarget);
- if (targetCoords.col == -1) {
- targetCoords.col = 0;
- }
- selectedRange = _this.hot.getSelectedRange();
- rangeWidth = selectedRange.getWidth();
- rangeHeight = selectedRange.getHeight();
- rangeDirection = selectedRange.getDirection();
- if (rangeWidth == 1 && rangeHeight == 1) {
- _this.hot.selection.setRangeEnd(targetCoords);
- }
- newRangeCoords = _this.getCurrentRangeCoords(selectedRange, targetCoords, _this.touchStartRange.direction, rangeDirection, _this.dragged[0]);
- if (newRangeCoords.start !== null) {
- _this.hot.selection.setRangeStart(newRangeCoords.start);
- }
- _this.hot.selection.setRangeEnd(newRangeCoords.end);
- _this.lastSetCell = endTarget;
- }
- event.preventDefault();
- });
- },
- getCurrentRangeCoords: function(selectedRange, currentTouch, touchStartDirection, currentDirection, draggedHandle) {
- var topLeftCorner = selectedRange.getTopLeftCorner(),
- bottomRightCorner = selectedRange.getBottomRightCorner(),
- bottomLeftCorner = selectedRange.getBottomLeftCorner(),
- topRightCorner = selectedRange.getTopRightCorner();
- var newCoords = {
- start: null,
- end: null
- };
- switch (touchStartDirection) {
- case "NE-SW":
- switch (currentDirection) {
- case "NE-SW":
- case "NW-SE":
- if (draggedHandle == "topLeft") {
- newCoords = {
- start: new WalkontableCellCoords(currentTouch.row, selectedRange.highlight.col),
- end: new WalkontableCellCoords(bottomLeftCorner.row, currentTouch.col)
- };
- } else {
- newCoords = {
- start: new WalkontableCellCoords(selectedRange.highlight.row, currentTouch.col),
- end: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col)
- };
- }
- break;
- case "SE-NW":
- if (draggedHandle == "bottomRight") {
- newCoords = {
- start: new WalkontableCellCoords(bottomRightCorner.row, currentTouch.col),
- end: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col)
- };
- }
- break;
- }
- break;
- case "NW-SE":
- switch (currentDirection) {
- case "NE-SW":
- if (draggedHandle == "topLeft") {
- newCoords = {
- start: currentTouch,
- end: bottomLeftCorner
- };
- } else {
- newCoords.end = currentTouch;
- }
- break;
- case "NW-SE":
- if (draggedHandle == "topLeft") {
- newCoords = {
- start: currentTouch,
- end: bottomRightCorner
- };
- } else {
- newCoords.end = currentTouch;
- }
- break;
- case "SE-NW":
- if (draggedHandle == "topLeft") {
- newCoords = {
- start: currentTouch,
- end: topLeftCorner
- };
- } else {
- newCoords.end = currentTouch;
- }
- break;
- case "SW-NE":
- if (draggedHandle == "topLeft") {
- newCoords = {
- start: currentTouch,
- end: topRightCorner
- };
- } else {
- newCoords.end = currentTouch;
- }
- break;
- }
- break;
- case "SW-NE":
- switch (currentDirection) {
- case "NW-SE":
- if (draggedHandle == "bottomRight") {
- newCoords = {
- start: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col),
- end: new WalkontableCellCoords(bottomLeftCorner.row, currentTouch.col)
- };
- } else {
- newCoords = {
- start: new WalkontableCellCoords(topLeftCorner.row, currentTouch.col),
- end: new WalkontableCellCoords(currentTouch.row, bottomRightCorner.col)
- };
- }
- break;
- case "SW-NE":
- if (draggedHandle == "topLeft") {
- newCoords = {
- start: new WalkontableCellCoords(selectedRange.highlight.row, currentTouch.col),
- end: new WalkontableCellCoords(currentTouch.row, bottomRightCorner.col)
- };
- } else {
- newCoords = {
- start: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col),
- end: new WalkontableCellCoords(topLeftCorner.row, currentTouch.col)
- };
- }
- break;
- case "SE-NW":
- if (draggedHandle == "bottomRight") {
- newCoords = {
- start: new WalkontableCellCoords(currentTouch.row, topRightCorner.col),
- end: new WalkontableCellCoords(topLeftCorner.row, currentTouch.col)
- };
- } else if (draggedHandle == "topLeft") {
- newCoords = {
- start: bottomLeftCorner,
- end: currentTouch
- };
- }
- break;
- }
- break;
- case "SE-NW":
- switch (currentDirection) {
- case "NW-SE":
- case "NE-SW":
- case "SW-NE":
- if (draggedHandle == "topLeft") {
- newCoords.end = currentTouch;
- }
- break;
- case "SE-NW":
- if (draggedHandle == "topLeft") {
- newCoords.end = currentTouch;
- } else {
- newCoords = {
- start: currentTouch,
- end: topLeftCorner
- };
- }
- break;
- }
- break;
- }
- return newCoords;
- },
- isDragged: function() {
- return this.dragged.length > 0;
- }
- }, {}, BasePlugin);
- var $__default = MultipleSelectionHandles;
- registerPlugin('multipleSelectionHandles', MultipleSelectionHandles);
-
- //#
- },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../plugins.js":45,"./../_base.js":46}],65:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- ObserveChanges: {get: function() {
- return ObserveChanges;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_plugins_46_js__,
- $__jsonpatch__;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- var jsonpatch = ($__jsonpatch__ = require("jsonpatch"), $__jsonpatch__ && $__jsonpatch__.__esModule && $__jsonpatch__ || {default: $__jsonpatch__}).default;
- ;
- function ObserveChanges() {}
- Handsontable.hooks.add('afterLoadData', init);
- Handsontable.hooks.add('afterUpdateSettings', init);
- Handsontable.hooks.register('afterChangesObserved');
- function init() {
- var instance = this;
- var pluginEnabled = instance.getSettings().observeChanges;
- if (pluginEnabled) {
- if (instance.observer) {
- destroy.call(instance);
- }
- createObserver.call(instance);
- bindEvents.call(instance);
- } else if (!pluginEnabled) {
- destroy.call(instance);
- }
- }
- function createObserver() {
- var instance = this;
- instance.observeChangesActive = true;
- instance.pauseObservingChanges = function() {
- instance.observeChangesActive = false;
- };
- instance.resumeObservingChanges = function() {
- instance.observeChangesActive = true;
- };
- instance.observedData = instance.getData();
- instance.observer = jsonpatch.observe(instance.observedData, function(patches) {
- if (instance.observeChangesActive) {
- runHookForOperation.call(instance, patches);
- instance.render();
- }
- instance.runHooks('afterChangesObserved');
- });
- }
- function runHookForOperation(rawPatches) {
- var instance = this;
- var patches = cleanPatches(rawPatches);
- for (var i = 0,
- len = patches.length; i < len; i++) {
- var patch = patches[i];
- var parsedPath = parsePath(patch.path);
- switch (patch.op) {
- case 'add':
- if (isNaN(parsedPath.col)) {
- instance.runHooks('afterCreateRow', parsedPath.row);
- } else {
- instance.runHooks('afterCreateCol', parsedPath.col);
- }
- break;
- case 'remove':
- if (isNaN(parsedPath.col)) {
- instance.runHooks('afterRemoveRow', parsedPath.row, 1);
- } else {
- instance.runHooks('afterRemoveCol', parsedPath.col, 1);
- }
- break;
- case 'replace':
- instance.runHooks('afterChange', [parsedPath.row, parsedPath.col, null, patch.value], 'external');
- break;
- }
- }
- function cleanPatches(rawPatches) {
- var patches;
- patches = removeLengthRelatedPatches(rawPatches);
- patches = removeMultipleAddOrRemoveColPatches(patches);
- return patches;
- }
- function removeMultipleAddOrRemoveColPatches(rawPatches) {
- var newOrRemovedColumns = [];
- return rawPatches.filter(function(patch) {
- var parsedPath = parsePath(patch.path);
- if (['add', 'remove'].indexOf(patch.op) != -1 && !isNaN(parsedPath.col)) {
- if (newOrRemovedColumns.indexOf(parsedPath.col) != -1) {
- return false;
- } else {
- newOrRemovedColumns.push(parsedPath.col);
- }
- }
- return true;
- });
- }
- function removeLengthRelatedPatches(rawPatches) {
- return rawPatches.filter(function(patch) {
- return !/[/]length/ig.test(patch.path);
- });
- }
- function parsePath(path) {
- var match = path.match(/^\/(\d+)\/?(.*)?$/);
- return {
- row: parseInt(match[1], 10),
- col: /^\d*$/.test(match[2]) ? parseInt(match[2], 10) : match[2]
- };
- }
- }
- function destroy() {
- var instance = this;
- if (instance.observer) {
- destroyObserver.call(instance);
- unbindEvents.call(instance);
- }
- }
- function destroyObserver() {
- var instance = this;
- jsonpatch.unobserve(instance.observedData, instance.observer);
- delete instance.observeChangesActive;
- delete instance.pauseObservingChanges;
- delete instance.resumeObservingChanges;
- }
- function bindEvents() {
- var instance = this;
- instance.addHook('afterDestroy', destroy);
- instance.addHook('afterCreateRow', afterTableAlter);
- instance.addHook('afterRemoveRow', afterTableAlter);
- instance.addHook('afterCreateCol', afterTableAlter);
- instance.addHook('afterRemoveCol', afterTableAlter);
- instance.addHook('afterChange', function(changes, source) {
- if (source != 'loadData') {
- afterTableAlter.call(this);
- }
- });
- }
- function unbindEvents() {
- var instance = this;
- instance.removeHook('afterDestroy', destroy);
- instance.removeHook('afterCreateRow', afterTableAlter);
- instance.removeHook('afterRemoveRow', afterTableAlter);
- instance.removeHook('afterCreateCol', afterTableAlter);
- instance.removeHook('afterRemoveCol', afterTableAlter);
- instance.removeHook('afterChange', afterTableAlter);
- }
- function afterTableAlter() {
- var instance = this;
- instance.pauseObservingChanges();
- instance.addHookOnce('afterChangesObserved', function() {
- instance.resumeObservingChanges();
- });
- }
-
- //#
- },{"./../../plugins.js":45,"jsonpatch":"jsonpatch"}],66:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- HandsontablePersistentState: {get: function() {
- return HandsontablePersistentState;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_plugins_46_js__;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- ;
- function Storage(prefix) {
- var savedKeys;
- var saveSavedKeys = function() {
- window.localStorage[prefix + '__' + 'persistentStateKeys'] = JSON.stringify(savedKeys);
- };
- var loadSavedKeys = function() {
- var keysJSON = window.localStorage[prefix + '__' + 'persistentStateKeys'];
- var keys = typeof keysJSON == 'string' ? JSON.parse(keysJSON) : void 0;
- savedKeys = keys ? keys : [];
- };
- var clearSavedKeys = function() {
- savedKeys = [];
- saveSavedKeys();
- };
- loadSavedKeys();
- this.saveValue = function(key, value) {
- window.localStorage[prefix + '_' + key] = JSON.stringify(value);
- if (savedKeys.indexOf(key) == -1) {
- savedKeys.push(key);
- saveSavedKeys();
- }
- };
- this.loadValue = function(key, defaultValue) {
- key = typeof key != 'undefined' ? key : defaultValue;
- var value = window.localStorage[prefix + '_' + key];
- return typeof value == "undefined" ? void 0 : JSON.parse(value);
- };
- this.reset = function(key) {
- window.localStorage.removeItem(prefix + '_' + key);
- };
- this.resetAll = function() {
- for (var index = 0; index < savedKeys.length; index++) {
- window.localStorage.removeItem(prefix + '_' + savedKeys[index]);
- }
- clearSavedKeys();
- };
- }
- function HandsontablePersistentState() {
- var plugin = this;
- this.init = function() {
- var instance = this,
- pluginSettings = instance.getSettings().persistentState;
- plugin.enabled = !!(pluginSettings);
- if (!plugin.enabled) {
- removeHooks.call(instance);
- return;
- }
- if (!instance.storage) {
- instance.storage = new Storage(instance.rootElement.id);
- }
- instance.resetState = plugin.resetValue;
- addHooks.call(instance);
- };
- this.saveValue = function(key, value) {
- var instance = this;
- instance.storage.saveValue(key, value);
- };
- this.loadValue = function(key, saveTo) {
- var instance = this;
- saveTo.value = instance.storage.loadValue(key);
- };
- this.resetValue = function(key) {
- var instance = this;
- if (typeof key != 'undefined') {
- instance.storage.reset(key);
- } else {
- instance.storage.resetAll();
- }
- };
- var hooks = {
- 'persistentStateSave': plugin.saveValue,
- 'persistentStateLoad': plugin.loadValue,
- 'persistentStateReset': plugin.resetValue
- };
- for (var hookName in hooks) {
- if (hooks.hasOwnProperty(hookName)) {
- Handsontable.hooks.register(hookName);
- }
- }
- function addHooks() {
- var instance = this;
- for (var hookName in hooks) {
- if (hooks.hasOwnProperty(hookName)) {
- instance.addHook(hookName, hooks[hookName]);
- }
- }
- }
- function removeHooks() {
- var instance = this;
- for (var hookName in hooks) {
- if (hooks.hasOwnProperty(hookName)) {
- instance.removeHook(hookName, hooks[hookName]);
- }
- }
- }
- }
- var htPersistentState = new HandsontablePersistentState();
- Handsontable.hooks.add('beforeInit', htPersistentState.init);
- Handsontable.hooks.add('afterUpdateSettings', htPersistentState.init);
-
- //#
- },{"./../../plugins.js":45}],67:[function(require,module,exports){
- "use strict";
- var $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__46__46__47_renderers_46_js__;
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- var $__0 = ($___46__46__47__46__46__47_renderers_46_js__ = require("./../../renderers.js"), $___46__46__47__46__46__47_renderers_46_js__ && $___46__46__47__46__46__47_renderers_46_js__.__esModule && $___46__46__47__46__46__47_renderers_46_js__ || {default: $___46__46__47__46__46__47_renderers_46_js__}),
- registerRenderer = $__0.registerRenderer,
- getRenderer = $__0.getRenderer;
- Handsontable.Search = function Search(instance) {
- this.query = function(queryStr, callback, queryMethod) {
- var rowCount = instance.countRows();
- var colCount = instance.countCols();
- var queryResult = [];
- if (!callback) {
- callback = Handsontable.Search.global.getDefaultCallback();
- }
- if (!queryMethod) {
- queryMethod = Handsontable.Search.global.getDefaultQueryMethod();
- }
- for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) {
- for (var colIndex = 0; colIndex < colCount; colIndex++) {
- var cellData = instance.getDataAtCell(rowIndex, colIndex);
- var cellProperties = instance.getCellMeta(rowIndex, colIndex);
- var cellCallback = cellProperties.search.callback || callback;
- var cellQueryMethod = cellProperties.search.queryMethod || queryMethod;
- var testResult = cellQueryMethod(queryStr, cellData);
- if (testResult) {
- var singleResult = {
- row: rowIndex,
- col: colIndex,
- data: cellData
- };
- queryResult.push(singleResult);
- }
- if (cellCallback) {
- cellCallback(instance, rowIndex, colIndex, cellData, testResult);
- }
- }
- }
- return queryResult;
- };
- };
- Handsontable.Search.DEFAULT_CALLBACK = function(instance, row, col, data, testResult) {
- instance.getCellMeta(row, col).isSearchResult = testResult;
- };
- Handsontable.Search.DEFAULT_QUERY_METHOD = function(query, value) {
- if (typeof query == 'undefined' || query == null || !query.toLowerCase || query.length === 0) {
- return false;
- }
- if (typeof value == 'undefined' || value == null) {
- return false;
- }
- return value.toString().toLowerCase().indexOf(query.toLowerCase()) != -1;
- };
- Handsontable.Search.DEFAULT_SEARCH_RESULT_CLASS = 'htSearchResult';
- Handsontable.Search.global = (function() {
- var defaultCallback = Handsontable.Search.DEFAULT_CALLBACK;
- var defaultQueryMethod = Handsontable.Search.DEFAULT_QUERY_METHOD;
- var defaultSearchResultClass = Handsontable.Search.DEFAULT_SEARCH_RESULT_CLASS;
- return {
- getDefaultCallback: function() {
- return defaultCallback;
- },
- setDefaultCallback: function(newDefaultCallback) {
- defaultCallback = newDefaultCallback;
- },
- getDefaultQueryMethod: function() {
- return defaultQueryMethod;
- },
- setDefaultQueryMethod: function(newDefaultQueryMethod) {
- defaultQueryMethod = newDefaultQueryMethod;
- },
- getDefaultSearchResultClass: function() {
- return defaultSearchResultClass;
- },
- setDefaultSearchResultClass: function(newSearchResultClass) {
- defaultSearchResultClass = newSearchResultClass;
- }
- };
- })();
- Handsontable.SearchCellDecorator = function(instance, TD, row, col, prop, value, cellProperties) {
- var searchResultClass = (cellProperties.search !== null && typeof cellProperties.search == 'object' && cellProperties.search.searchResultClass) || Handsontable.Search.global.getDefaultSearchResultClass();
- if (cellProperties.isSearchResult) {
- dom.addClass(TD, searchResultClass);
- } else {
- dom.removeClass(TD, searchResultClass);
- }
- };
- var originalBaseRenderer = getRenderer('base');
- registerRenderer('base', function(instance, TD, row, col, prop, value, cellProperties) {
- originalBaseRenderer.apply(this, arguments);
- Handsontable.SearchCellDecorator.apply(this, arguments);
- });
- function init() {
- var instance = this;
- var pluginEnabled = !!instance.getSettings().search;
- if (pluginEnabled) {
- instance.search = new Handsontable.Search(instance);
- } else {
- delete instance.search;
- }
- }
- Handsontable.hooks.add('afterInit', init);
- Handsontable.hooks.add('afterUpdateSettings', init);
-
- //#
- },{"./../../dom.js":27,"./../../renderers.js":70}],68:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- TouchScroll: {get: function() {
- return TouchScroll;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47__46__46__47_dom_46_js__,
- $___46__46__47__95_base_46_js__,
- $___46__46__47__46__46__47_plugins_46_js__;
- var dom = ($___46__46__47__46__46__47_dom_46_js__ = require("./../../dom.js"), $___46__46__47__46__46__47_dom_46_js__ && $___46__46__47__46__46__47_dom_46_js__.__esModule && $___46__46__47__46__46__47_dom_46_js__ || {default: $___46__46__47__46__46__47_dom_46_js__});
- 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;
- var registerPlugin = ($___46__46__47__46__46__47_plugins_46_js__ = require("./../../plugins.js"), $___46__46__47__46__46__47_plugins_46_js__ && $___46__46__47__46__46__47_plugins_46_js__.__esModule && $___46__46__47__46__46__47_plugins_46_js__ || {default: $___46__46__47__46__46__47_plugins_46_js__}).registerPlugin;
- var TouchScroll = function TouchScroll(hotInstance) {
- var $__2 = this;
- $traceurRuntime.superConstructor($TouchScroll).call(this, hotInstance);
- this.hot.addHook('afterInit', (function() {
- return $__2.init();
- }));
- this.hot.addHook('afterUpdateSettings', (function() {
- return $__2.onAfterUpdateSettings();
- }));
- this.scrollbars = [];
- this.clones = [];
- };
- var $TouchScroll = TouchScroll;
- ($traceurRuntime.createClass)(TouchScroll, {
- init: function() {
- this.registerEvents();
- this.onAfterUpdateSettings();
- },
- onAfterUpdateSettings: function() {
- var _this = this;
- this.hot.addHookOnce('afterRender', function() {
- var wtOverlays = _this.hot.view.wt.wtOverlays;
- _this.scrollbars = [];
- _this.scrollbars.push(wtOverlays.topOverlay);
- _this.scrollbars.push(wtOverlays.leftOverlay);
- if (wtOverlays.topLeftCornerOverlay) {
- _this.scrollbars.push(wtOverlays.topLeftCornerOverlay);
- }
- _this.clones = [];
- if (wtOverlays.topOverlay.needFullRender) {
- _this.clones.push(wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
- }
- if (wtOverlays.leftOverlay.needFullRender) {
- _this.clones.push(wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
- }
- if (wtOverlays.topLeftCornerOverlay) {
- _this.clones.push(wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
- }
- });
- },
- registerEvents: function() {
- var $__2 = this;
- this.hot.addHook('beforeTouchScroll', (function() {
- return $__2.onBeforeTouchScroll();
- }));
- this.hot.addHook('afterMomentumScroll', (function() {
- return $__2.onAfterMomentumScroll();
- }));
- },
- onBeforeTouchScroll: function() {
- Handsontable.freezeOverlays = true;
- for (var i = 0,
- cloneCount = this.clones.length; i < cloneCount; i++) {
- dom.addClass(this.clones[i], 'hide-tween');
- }
- },
- onAfterMomentumScroll: function() {
- Handsontable.freezeOverlays = false;
- var _that = this;
- for (var i = 0,
- cloneCount = this.clones.length; i < cloneCount; i++) {
- dom.removeClass(this.clones[i], 'hide-tween');
- }
- for (var i$__4 = 0,
- cloneCount$__5 = this.clones.length; i$__4 < cloneCount$__5; i$__4++) {
- dom.addClass(this.clones[i$__4], 'show-tween');
- }
- setTimeout(function() {
- for (var i = 0,
- cloneCount = _that.clones.length; i < cloneCount; i++) {
- dom.removeClass(_that.clones[i], 'show-tween');
- }
- }, 400);
- for (var i$__6 = 0,
- cloneCount$__7 = this.scrollbars.length; i$__6 < cloneCount$__7; i$__6++) {
- this.scrollbars[i$__6].refresh();
- this.scrollbars[i$__6].resetFixedPosition();
- }
- this.hot.view.wt.wtOverlays.syncScrollWithMaster();
- }
- }, {}, BasePlugin);
- ;
- registerPlugin('touchScroll', TouchScroll);
-
- //#
- },{"./../../dom.js":27,"./../../plugins.js":45,"./../_base.js":46}],69:[function(require,module,exports){
- "use strict";
- var $___46__46__47__46__46__47_helpers_46_js__;
- var helper = ($___46__46__47__46__46__47_helpers_46_js__ = require("./../../helpers.js"), $___46__46__47__46__46__47_helpers_46_js__ && $___46__46__47__46__46__47_helpers_46_js__.__esModule && $___46__46__47__46__46__47_helpers_46_js__ || {default: $___46__46__47__46__46__47_helpers_46_js__});
- Handsontable.UndoRedo = function(instance) {
- var plugin = this;
- this.instance = instance;
- this.doneActions = [];
- this.undoneActions = [];
- this.ignoreNewActions = false;
- instance.addHook("afterChange", function(changes, origin) {
- if (changes) {
- var action = new Handsontable.UndoRedo.ChangeAction(changes);
- plugin.done(action);
- }
- });
- instance.addHook("afterCreateRow", function(index, amount, createdAutomatically) {
- if (createdAutomatically) {
- return;
- }
- var action = new Handsontable.UndoRedo.CreateRowAction(index, amount);
- plugin.done(action);
- });
- instance.addHook("beforeRemoveRow", function(index, amount) {
- var originalData = plugin.instance.getData();
- index = (originalData.length + index) % originalData.length;
- var removedData = originalData.slice(index, index + amount);
- var action = new Handsontable.UndoRedo.RemoveRowAction(index, removedData);
- plugin.done(action);
- });
- instance.addHook("afterCreateCol", function(index, amount, createdAutomatically) {
- if (createdAutomatically) {
- return;
- }
- var action = new Handsontable.UndoRedo.CreateColumnAction(index, amount);
- plugin.done(action);
- });
- instance.addHook("beforeRemoveCol", function(index, amount) {
- var originalData = plugin.instance.getData();
- index = (plugin.instance.countCols() + index) % plugin.instance.countCols();
- var removedData = [];
- for (var i = 0,
- len = originalData.length; i < len; i++) {
- removedData[i] = originalData[i].slice(index, index + amount);
- }
- var headers;
- if (Array.isArray(instance.getSettings().colHeaders)) {
- headers = instance.getSettings().colHeaders.slice(index, index + removedData.length);
- }
- var action = new Handsontable.UndoRedo.RemoveColumnAction(index, removedData, headers);
- plugin.done(action);
- });
- instance.addHook("beforeCellAlignment", function(stateBefore, range, type, alignment) {
- var action = new Handsontable.UndoRedo.CellAlignmentAction(stateBefore, range, type, alignment);
- plugin.done(action);
- });
- };
- Handsontable.UndoRedo.prototype.done = function(action) {
- if (!this.ignoreNewActions) {
- this.doneActions.push(action);
- this.undoneActions.length = 0;
- }
- };
- Handsontable.UndoRedo.prototype.undo = function() {
- if (this.isUndoAvailable()) {
- var action = this.doneActions.pop();
- this.ignoreNewActions = true;
- var that = this;
- action.undo(this.instance, function() {
- that.ignoreNewActions = false;
- that.undoneActions.push(action);
- });
- }
- };
- Handsontable.UndoRedo.prototype.redo = function() {
- if (this.isRedoAvailable()) {
- var action = this.undoneActions.pop();
- this.ignoreNewActions = true;
- var that = this;
- action.redo(this.instance, function() {
- that.ignoreNewActions = false;
- that.doneActions.push(action);
- });
- }
- };
- Handsontable.UndoRedo.prototype.isUndoAvailable = function() {
- return this.doneActions.length > 0;
- };
- Handsontable.UndoRedo.prototype.isRedoAvailable = function() {
- return this.undoneActions.length > 0;
- };
- Handsontable.UndoRedo.prototype.clear = function() {
- this.doneActions.length = 0;
- this.undoneActions.length = 0;
- };
- Handsontable.UndoRedo.Action = function() {};
- Handsontable.UndoRedo.Action.prototype.undo = function() {};
- Handsontable.UndoRedo.Action.prototype.redo = function() {};
- Handsontable.UndoRedo.ChangeAction = function(changes) {
- this.changes = changes;
- };
- helper.inherit(Handsontable.UndoRedo.ChangeAction, Handsontable.UndoRedo.Action);
- Handsontable.UndoRedo.ChangeAction.prototype.undo = function(instance, undoneCallback) {
- var data = helper.deepClone(this.changes),
- emptyRowsAtTheEnd = instance.countEmptyRows(true),
- emptyColsAtTheEnd = instance.countEmptyCols(true);
- for (var i = 0,
- len = data.length; i < len; i++) {
- data[i].splice(3, 1);
- }
- instance.addHookOnce('afterChange', undoneCallback);
- instance.setDataAtRowProp(data, null, null, 'undo');
- for (var i = 0,
- len = data.length; i < len; i++) {
- if (instance.getSettings().minSpareRows && data[i][0] + 1 + instance.getSettings().minSpareRows === instance.countRows() && emptyRowsAtTheEnd == instance.getSettings().minSpareRows) {
- instance.alter('remove_row', parseInt(data[i][0] + 1, 10), instance.getSettings().minSpareRows);
- instance.undoRedo.doneActions.pop();
- }
- if (instance.getSettings().minSpareCols && data[i][1] + 1 + instance.getSettings().minSpareCols === instance.countCols() && emptyColsAtTheEnd == instance.getSettings().minSpareCols) {
- instance.alter('remove_col', parseInt(data[i][1] + 1, 10), instance.getSettings().minSpareCols);
- instance.undoRedo.doneActions.pop();
- }
- }
- };
- Handsontable.UndoRedo.ChangeAction.prototype.redo = function(instance, onFinishCallback) {
- var data = helper.deepClone(this.changes);
- for (var i = 0,
- len = data.length; i < len; i++) {
- data[i].splice(2, 1);
- }
- instance.addHookOnce('afterChange', onFinishCallback);
- instance.setDataAtRowProp(data, null, null, 'redo');
- };
- Handsontable.UndoRedo.CreateRowAction = function(index, amount) {
- this.index = index;
- this.amount = amount;
- };
- helper.inherit(Handsontable.UndoRedo.CreateRowAction, Handsontable.UndoRedo.Action);
- Handsontable.UndoRedo.CreateRowAction.prototype.undo = function(instance, undoneCallback) {
- var rowCount = instance.countRows(),
- minSpareRows = instance.getSettings().minSpareRows;
- if (this.index >= rowCount && this.index - minSpareRows < rowCount) {
- this.index -= minSpareRows;
- }
- instance.addHookOnce('afterRemoveRow', undoneCallback);
- instance.alter('remove_row', this.index, this.amount);
- };
- Handsontable.UndoRedo.CreateRowAction.prototype.redo = function(instance, redoneCallback) {
- instance.addHookOnce('afterCreateRow', redoneCallback);
- instance.alter('insert_row', this.index + 1, this.amount);
- };
- Handsontable.UndoRedo.RemoveRowAction = function(index, data) {
- this.index = index;
- this.data = data;
- };
- helper.inherit(Handsontable.UndoRedo.RemoveRowAction, Handsontable.UndoRedo.Action);
- Handsontable.UndoRedo.RemoveRowAction.prototype.undo = function(instance, undoneCallback) {
- var spliceArgs = [this.index, 0];
- Array.prototype.push.apply(spliceArgs, this.data);
- Array.prototype.splice.apply(instance.getData(), spliceArgs);
- instance.addHookOnce('afterRender', undoneCallback);
- instance.render();
- };
- Handsontable.UndoRedo.RemoveRowAction.prototype.redo = function(instance, redoneCallback) {
- instance.addHookOnce('afterRemoveRow', redoneCallback);
- instance.alter('remove_row', this.index, this.data.length);
- };
- Handsontable.UndoRedo.CreateColumnAction = function(index, amount) {
- this.index = index;
- this.amount = amount;
- };
- helper.inherit(Handsontable.UndoRedo.CreateColumnAction, Handsontable.UndoRedo.Action);
- Handsontable.UndoRedo.CreateColumnAction.prototype.undo = function(instance, undoneCallback) {
- instance.addHookOnce('afterRemoveCol', undoneCallback);
- instance.alter('remove_col', this.index, this.amount);
- };
- Handsontable.UndoRedo.CreateColumnAction.prototype.redo = function(instance, redoneCallback) {
- instance.addHookOnce('afterCreateCol', redoneCallback);
- instance.alter('insert_col', this.index + 1, this.amount);
- };
- Handsontable.UndoRedo.CellAlignmentAction = function(stateBefore, range, type, alignment) {
- this.stateBefore = stateBefore;
- this.range = range;
- this.type = type;
- this.alignment = alignment;
- };
- Handsontable.UndoRedo.CellAlignmentAction.prototype.undo = function(instance, undoneCallback) {
- if (!instance.contextMenu) {
- return;
- }
- for (var row = this.range.from.row; row <= this.range.to.row; row++) {
- for (var col = this.range.from.col; col <= this.range.to.col; col++) {
- instance.setCellMeta(row, col, 'className', this.stateBefore[row][col] || ' htLeft');
- }
- }
- instance.addHookOnce('afterRender', undoneCallback);
- instance.render();
- };
- Handsontable.UndoRedo.CellAlignmentAction.prototype.redo = function(instance, undoneCallback) {
- if (!instance.contextMenu) {
- return;
- }
- for (var row = this.range.from.row; row <= this.range.to.row; row++) {
- for (var col = this.range.from.col; col <= this.range.to.col; col++) {
- instance.contextMenu.align.call(instance, this.range, this.type, this.alignment);
- }
- }
- instance.addHookOnce('afterRender', undoneCallback);
- instance.render();
- };
- Handsontable.UndoRedo.RemoveColumnAction = function(index, data, headers) {
- this.index = index;
- this.data = data;
- this.amount = this.data[0].length;
- this.headers = headers;
- };
- helper.inherit(Handsontable.UndoRedo.RemoveColumnAction, Handsontable.UndoRedo.Action);
- Handsontable.UndoRedo.RemoveColumnAction.prototype.undo = function(instance, undoneCallback) {
- var row,
- spliceArgs;
- for (var i = 0,
- len = instance.getData().length; i < len; i++) {
- row = instance.getSourceDataAtRow(i);
- spliceArgs = [this.index, 0];
- Array.prototype.push.apply(spliceArgs, this.data[i]);
- Array.prototype.splice.apply(row, spliceArgs);
- }
- if (typeof this.headers != 'undefined') {
- spliceArgs = [this.index, 0];
- Array.prototype.push.apply(spliceArgs, this.headers);
- Array.prototype.splice.apply(instance.getSettings().colHeaders, spliceArgs);
- }
- instance.addHookOnce('afterRender', undoneCallback);
- instance.render();
- };
- Handsontable.UndoRedo.RemoveColumnAction.prototype.redo = function(instance, redoneCallback) {
- instance.addHookOnce('afterRemoveCol', redoneCallback);
- instance.alter('remove_col', this.index, this.amount);
- };
- function init() {
- var instance = this;
- var pluginEnabled = typeof instance.getSettings().undo == 'undefined' || instance.getSettings().undo;
- if (pluginEnabled) {
- if (!instance.undoRedo) {
- instance.undoRedo = new Handsontable.UndoRedo(instance);
- exposeUndoRedoMethods(instance);
- instance.addHook('beforeKeyDown', onBeforeKeyDown);
- instance.addHook('afterChange', onAfterChange);
- }
- } else {
- if (instance.undoRedo) {
- delete instance.undoRedo;
- removeExposedUndoRedoMethods(instance);
- instance.removeHook('beforeKeyDown', onBeforeKeyDown);
- instance.removeHook('afterChange', onAfterChange);
- }
- }
- }
- function onBeforeKeyDown(event) {
- var instance = this;
- var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
- if (ctrlDown) {
- if (event.keyCode === 89 || (event.shiftKey && event.keyCode === 90)) {
- instance.undoRedo.redo();
- event.stopImmediatePropagation();
- } else if (event.keyCode === 90) {
- instance.undoRedo.undo();
- event.stopImmediatePropagation();
- }
- }
- }
- function onAfterChange(changes, source) {
- var instance = this;
- if (source == 'loadData') {
- return instance.undoRedo.clear();
- }
- }
- function exposeUndoRedoMethods(instance) {
- instance.undo = function() {
- return instance.undoRedo.undo();
- };
- instance.redo = function() {
- return instance.undoRedo.redo();
- };
- instance.isUndoAvailable = function() {
- return instance.undoRedo.isUndoAvailable();
- };
- instance.isRedoAvailable = function() {
- return instance.undoRedo.isRedoAvailable();
- };
- instance.clearUndo = function() {
- return instance.undoRedo.clear();
- };
- }
- function removeExposedUndoRedoMethods(instance) {
- delete instance.undo;
- delete instance.redo;
- delete instance.isUndoAvailable;
- delete instance.isRedoAvailable;
- delete instance.clearUndo;
- }
- Handsontable.hooks.add('afterInit', init);
- Handsontable.hooks.add('afterUpdateSettings', init);
-
- //#
- },{"./../../helpers.js":42}],70:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- registerRenderer: {get: function() {
- return registerRenderer;
- }},
- getRenderer: {get: function() {
- return getRenderer;
- }},
- hasRenderer: {get: function() {
- return hasRenderer;
- }},
- __esModule: {value: true}
- });
- var $__helpers_46_js__;
- var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
- ;
- var registeredRenderers = {};
- Handsontable.renderers = Handsontable.renderers || {};
- Handsontable.renderers.registerRenderer = registerRenderer;
- Handsontable.renderers.getRenderer = getRenderer;
- function registerRenderer(rendererName, rendererFunction) {
- var registerName;
- registeredRenderers[rendererName] = rendererFunction;
- registerName = helper.toUpperCaseFirst(rendererName) + 'Renderer';
- Handsontable.renderers[registerName] = rendererFunction;
- Handsontable[registerName] = rendererFunction;
- }
- function getRenderer(rendererName) {
- if (typeof rendererName == 'function') {
- return rendererName;
- }
- if (typeof rendererName != 'string') {
- throw Error('Only strings and functions can be passed as "renderer" parameter');
- }
- if (!(rendererName in registeredRenderers)) {
- throw Error('No editor registered under name "' + rendererName + '"');
- }
- return registeredRenderers[rendererName];
- }
- function hasRenderer(rendererName) {
- return rendererName in registeredRenderers;
- }
-
- //#
- },{"./helpers.js":42}],71:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- cellDecorator: {get: function() {
- return cellDecorator;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_dom_46_js__,
- $___46__46__47_renderers_46_js__;
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var registerRenderer = ($___46__46__47_renderers_46_js__ = require("./../renderers.js"), $___46__46__47_renderers_46_js__ && $___46__46__47_renderers_46_js__.__esModule && $___46__46__47_renderers_46_js__ || {default: $___46__46__47_renderers_46_js__}).registerRenderer;
- ;
- registerRenderer('base', cellDecorator);
- Handsontable.renderers.cellDecorator = cellDecorator;
- function cellDecorator(instance, TD, row, col, prop, value, cellProperties) {
- if (cellProperties.className) {
- if (TD.className) {
- TD.className = TD.className + " " + cellProperties.className;
- } else {
- TD.className = cellProperties.className;
- }
- }
- if (cellProperties.readOnly) {
- dom.addClass(TD, cellProperties.readOnlyCellClassName);
- }
- if (cellProperties.valid === false && cellProperties.invalidCellClassName) {
- dom.addClass(TD, cellProperties.invalidCellClassName);
- } else {
- dom.removeClass(TD, cellProperties.invalidCellClassName);
- }
- if (cellProperties.wordWrap === false && cellProperties.noWordWrapClassName) {
- dom.addClass(TD, cellProperties.noWordWrapClassName);
- }
- if (!value && cellProperties.placeholder) {
- dom.addClass(TD, cellProperties.placeholderCellClassName);
- }
- }
-
- //#
- },{"./../dom.js":27,"./../renderers.js":70}],72:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- autocompleteRenderer: {get: function() {
- return autocompleteRenderer;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_dom_46_js__,
- $___46__46__47_eventManager_46_js__,
- $___46__46__47_renderers_46_js__,
- $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__;
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var eventManagerObject = ($___46__46__47_eventManager_46_js__ = require("./../eventManager.js"), $___46__46__47_eventManager_46_js__ && $___46__46__47_eventManager_46_js__.__esModule && $___46__46__47_eventManager_46_js__ || {default: $___46__46__47_eventManager_46_js__}).eventManager;
- var $__1 = ($___46__46__47_renderers_46_js__ = require("./../renderers.js"), $___46__46__47_renderers_46_js__ && $___46__46__47_renderers_46_js__.__esModule && $___46__46__47_renderers_46_js__ || {default: $___46__46__47_renderers_46_js__}),
- getRenderer = $__1.getRenderer,
- registerRenderer = $__1.registerRenderer;
- var WalkontableCellCoords = ($___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ = require("./../3rdparty/walkontable/src/cell/coords.js"), $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ && $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__.__esModule && $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ || {default: $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__}).WalkontableCellCoords;
- ;
- var clonableWRAPPER = document.createElement('DIV');
- clonableWRAPPER.className = 'htAutocompleteWrapper';
- var clonableARROW = document.createElement('DIV');
- clonableARROW.className = 'htAutocompleteArrow';
- clonableARROW.appendChild(document.createTextNode(String.fromCharCode(9660)));
- var wrapTdContentWithWrapper = function(TD, WRAPPER) {
- WRAPPER.innerHTML = TD.innerHTML;
- dom.empty(TD);
- TD.appendChild(WRAPPER);
- };
- registerRenderer('autocomplete', autocompleteRenderer);
- function autocompleteRenderer(instance, TD, row, col, prop, value, cellProperties) {
- var WRAPPER = clonableWRAPPER.cloneNode(true);
- var ARROW = clonableARROW.cloneNode(true);
- getRenderer('text')(instance, TD, row, col, prop, value, cellProperties);
- TD.appendChild(ARROW);
- dom.addClass(TD, 'htAutocomplete');
- if (!TD.firstChild) {
- TD.appendChild(document.createTextNode(String.fromCharCode(160)));
- }
- if (!instance.acArrowListener) {
- var eventManager = eventManagerObject(instance);
- instance.acArrowListener = function(event) {
- if (dom.hasClass(event.target, 'htAutocompleteArrow')) {
- instance.view.wt.getSetting('onCellDblClick', null, new WalkontableCellCoords(row, col), TD);
- }
- };
- eventManager.addEventListener(instance.rootElement, 'mousedown', instance.acArrowListener);
- instance.addHookOnce('afterDestroy', function() {
- eventManager.clear();
- });
- }
- }
-
- //#
- },{"./../3rdparty/walkontable/src/cell/coords.js":5,"./../dom.js":27,"./../eventManager.js":41,"./../renderers.js":70}],73:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- checkboxRenderer: {get: function() {
- return checkboxRenderer;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_dom_46_js__,
- $___46__46__47_helpers_46_js__,
- $___46__46__47_eventManager_46_js__,
- $___46__46__47_renderers_46_js__;
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var helper = ($___46__46__47_helpers_46_js__ = require("./../helpers.js"), $___46__46__47_helpers_46_js__ && $___46__46__47_helpers_46_js__.__esModule && $___46__46__47_helpers_46_js__ || {default: $___46__46__47_helpers_46_js__});
- var EventManager = ($___46__46__47_eventManager_46_js__ = require("./../eventManager.js"), $___46__46__47_eventManager_46_js__ && $___46__46__47_eventManager_46_js__.__esModule && $___46__46__47_eventManager_46_js__ || {default: $___46__46__47_eventManager_46_js__}).EventManager;
- var $__1 = ($___46__46__47_renderers_46_js__ = require("./../renderers.js"), $___46__46__47_renderers_46_js__ && $___46__46__47_renderers_46_js__.__esModule && $___46__46__47_renderers_46_js__ || {default: $___46__46__47_renderers_46_js__}),
- getRenderer = $__1.getRenderer,
- registerRenderer = $__1.registerRenderer;
- var clonableINPUT = document.createElement('INPUT');
- clonableINPUT.className = 'htCheckboxRendererInput';
- clonableINPUT.type = 'checkbox';
- clonableINPUT.setAttribute('autocomplete', 'off');
- var isListeningKeyDownEvent = new WeakMap();
- function checkboxRenderer(instance, TD, row, col, prop, value, cellProperties) {
- var eventManager = new EventManager(instance);
- var input = clonableINPUT.cloneNode(false);
- if (typeof cellProperties.checkedTemplate === 'undefined') {
- cellProperties.checkedTemplate = true;
- }
- if (typeof cellProperties.uncheckedTemplate === 'undefined') {
- cellProperties.uncheckedTemplate = false;
- }
- dom.empty(TD);
- if (value === cellProperties.checkedTemplate || helper.equalsIgnoreCase(value, cellProperties.checkedTemplate)) {
- input.checked = true;
- TD.appendChild(input);
- } else if (value === cellProperties.uncheckedTemplate || helper.equalsIgnoreCase(value, cellProperties.uncheckedTemplate)) {
- TD.appendChild(input);
- } else if (value === null) {
- dom.addClass(input, 'noValue');
- TD.appendChild(input);
- } else {
- dom.fastInnerText(TD, '#bad value#');
- }
- if (cellProperties.readOnly) {
- eventManager.addEventListener(input, 'click', preventDefault);
- } else {
- eventManager.addEventListener(input, 'mousedown', stopPropagation);
- eventManager.addEventListener(input, 'mouseup', stopPropagation);
- eventManager.addEventListener(input, 'change', (function(event) {
- instance.setDataAtRowProp(row, prop, event.target.checked ? cellProperties.checkedTemplate : cellProperties.uncheckedTemplate);
- }));
- }
- if (!isListeningKeyDownEvent.has(instance)) {
- isListeningKeyDownEvent.set(instance, true);
- instance.addHook('beforeKeyDown', onBeforeKeyDown);
- }
- function onBeforeKeyDown(event) {
- var allowedKeys = [helper.keyCode.SPACE, helper.keyCode.ENTER, helper.keyCode.DELETE, helper.keyCode.BACKSPACE];
- dom.enableImmediatePropagation(event);
- if (allowedKeys.indexOf(event.keyCode) !== -1 && !event.isImmediatePropagationStopped()) {
- eachSelectedCheckboxCell(function() {
- event.stopImmediatePropagation();
- event.preventDefault();
- });
- }
- if (event.keyCode == helper.keyCode.SPACE || event.keyCode == helper.keyCode.ENTER) {
- toggleSelected();
- }
- if (event.keyCode == helper.keyCode.DELETE || event.keyCode == helper.keyCode.BACKSPACE) {
- toggleSelected(false);
- }
- }
- function toggleSelected() {
- var checked = arguments[0] !== (void 0) ? arguments[0] : null;
- eachSelectedCheckboxCell(function(checkboxes) {
- for (var i = 0,
- len = checkboxes.length; i < len; i++) {
- toggleCheckbox(checkboxes[i], checked);
- }
- });
- }
- function toggleCheckbox(checkbox) {
- var checked = arguments[1] !== (void 0) ? arguments[1] : null;
- if (checked === null) {
- checkbox.checked = !checkbox.checked;
- } else {
- checkbox.checked = checked;
- }
- eventManager.fireEvent(checkbox, 'change');
- }
- function eachSelectedCheckboxCell(callback) {
- var selRange = instance.getSelectedRange();
- var topLeft = selRange.getTopLeftCorner();
- var bottomRight = selRange.getBottomRightCorner();
- for (var row = topLeft.row; row <= bottomRight.row; row++) {
- for (var col = topLeft.col; col <= bottomRight.col; col++) {
- var cell = instance.getCell(row, col);
- var cellProperties$__2 = instance.getCellMeta(row, col);
- var checkboxes = cell.querySelectorAll('input[type=checkbox]');
- if (checkboxes.length > 0 && !cellProperties$__2.readOnly) {
- callback(checkboxes);
- }
- }
- }
- }
- function preventDefault(event) {
- event.preventDefault();
- }
- function stopPropagation(event) {
- helper.stopPropagation(event);
- }
- }
- ;
- registerRenderer('checkbox', checkboxRenderer);
-
- //#
- },{"./../dom.js":27,"./../eventManager.js":41,"./../helpers.js":42,"./../renderers.js":70}],74:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- htmlRenderer: {get: function() {
- return htmlRenderer;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_dom_46_js__,
- $___46__46__47_renderers_46_js__;
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var $__0 = ($___46__46__47_renderers_46_js__ = require("./../renderers.js"), $___46__46__47_renderers_46_js__ && $___46__46__47_renderers_46_js__.__esModule && $___46__46__47_renderers_46_js__ || {default: $___46__46__47_renderers_46_js__}),
- getRenderer = $__0.getRenderer,
- registerRenderer = $__0.registerRenderer;
- ;
- registerRenderer('html', htmlRenderer);
- function htmlRenderer(instance, TD, row, col, prop, value, cellProperties) {
- getRenderer('base').apply(this, arguments);
- dom.fastInnerHTML(TD, value);
- }
-
- //#
- },{"./../dom.js":27,"./../renderers.js":70}],75:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- numericRenderer: {get: function() {
- return numericRenderer;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_dom_46_js__,
- $___46__46__47_helpers_46_js__,
- $__numeral__,
- $___46__46__47_renderers_46_js__;
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var helper = ($___46__46__47_helpers_46_js__ = require("./../helpers.js"), $___46__46__47_helpers_46_js__ && $___46__46__47_helpers_46_js__.__esModule && $___46__46__47_helpers_46_js__ || {default: $___46__46__47_helpers_46_js__});
- var numeral = ($__numeral__ = require("numeral"), $__numeral__ && $__numeral__.__esModule && $__numeral__ || {default: $__numeral__}).default;
- var $__1 = ($___46__46__47_renderers_46_js__ = require("./../renderers.js"), $___46__46__47_renderers_46_js__ && $___46__46__47_renderers_46_js__.__esModule && $___46__46__47_renderers_46_js__ || {default: $___46__46__47_renderers_46_js__}),
- getRenderer = $__1.getRenderer,
- registerRenderer = $__1.registerRenderer;
- ;
- registerRenderer('numeric', numericRenderer);
- function numericRenderer(instance, TD, row, col, prop, value, cellProperties) {
- if (helper.isNumeric(value)) {
- if (typeof cellProperties.language !== 'undefined') {
- numeral.language(cellProperties.language);
- }
- value = numeral(value).format(cellProperties.format || '0');
- dom.addClass(TD, 'htNumeric');
- }
- getRenderer('text')(instance, TD, row, col, prop, value, cellProperties);
- }
-
- //#
- },{"./../dom.js":27,"./../helpers.js":42,"./../renderers.js":70,"numeral":"numeral"}],76:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- passwordRenderer: {get: function() {
- return passwordRenderer;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_dom_46_js__,
- $___46__46__47_renderers_46_js__;
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var $__0 = ($___46__46__47_renderers_46_js__ = require("./../renderers.js"), $___46__46__47_renderers_46_js__ && $___46__46__47_renderers_46_js__.__esModule && $___46__46__47_renderers_46_js__ || {default: $___46__46__47_renderers_46_js__}),
- getRenderer = $__0.getRenderer,
- registerRenderer = $__0.registerRenderer;
- ;
- registerRenderer('password', passwordRenderer);
- function passwordRenderer(instance, TD, row, col, prop, value, cellProperties) {
- getRenderer('text').apply(this, arguments);
- value = TD.innerHTML;
- var hash;
- var hashLength = cellProperties.hashLength || value.length;
- var hashSymbol = cellProperties.hashSymbol || '*';
- for (hash = ''; hash.split(hashSymbol).length - 1 < hashLength; hash += hashSymbol) {}
- dom.fastInnerHTML(TD, hash);
- }
-
- //#
- },{"./../dom.js":27,"./../renderers.js":70}],77:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- textRenderer: {get: function() {
- return textRenderer;
- }},
- __esModule: {value: true}
- });
- var $___46__46__47_dom_46_js__,
- $___46__46__47_helpers_46_js__,
- $___46__46__47_renderers_46_js__;
- var dom = ($___46__46__47_dom_46_js__ = require("./../dom.js"), $___46__46__47_dom_46_js__ && $___46__46__47_dom_46_js__.__esModule && $___46__46__47_dom_46_js__ || {default: $___46__46__47_dom_46_js__});
- var helper = ($___46__46__47_helpers_46_js__ = require("./../helpers.js"), $___46__46__47_helpers_46_js__ && $___46__46__47_helpers_46_js__.__esModule && $___46__46__47_helpers_46_js__ || {default: $___46__46__47_helpers_46_js__});
- var $__0 = ($___46__46__47_renderers_46_js__ = require("./../renderers.js"), $___46__46__47_renderers_46_js__ && $___46__46__47_renderers_46_js__.__esModule && $___46__46__47_renderers_46_js__ || {default: $___46__46__47_renderers_46_js__}),
- getRenderer = $__0.getRenderer,
- registerRenderer = $__0.registerRenderer;
- ;
- registerRenderer('text', textRenderer);
- function textRenderer(instance, TD, row, col, prop, value, cellProperties) {
- getRenderer('base').apply(this, arguments);
- if (!value && cellProperties.placeholder) {
- value = cellProperties.placeholder;
- }
- var escaped = helper.stringify(value);
- if (!instance.getSettings().trimWhitespace) {
- escaped = escaped.replace(/ /g, String.fromCharCode(160));
- }
- if (cellProperties.rendererTemplate) {
- dom.empty(TD);
- var TEMPLATE = document.createElement('TEMPLATE');
- TEMPLATE.setAttribute('bind', '{{}}');
- TEMPLATE.innerHTML = cellProperties.rendererTemplate;
- HTMLTemplateElement.decorate(TEMPLATE);
- TEMPLATE.model = instance.getSourceDataAtRow(row);
- TD.appendChild(TEMPLATE);
- } else {
- dom.fastInnerText(TD, escaped);
- }
- }
-
- //#
- },{"./../dom.js":27,"./../helpers.js":42,"./../renderers.js":70}],78:[function(require,module,exports){
- "use strict";
- if (!Array.prototype.filter) {
- Array.prototype.filter = function(fun, thisp) {
- "use strict";
- if (typeof this === "undefined" || this === null) {
- throw new TypeError();
- }
- if (typeof fun !== "function") {
- throw new TypeError();
- }
- thisp = thisp || this;
- if (isNodeList(thisp)) {
- thisp = convertNodeListToArray(thisp);
- }
- var len = thisp.length,
- res = [],
- i,
- val;
- for (i = 0; i < len; i += 1) {
- if (thisp.hasOwnProperty(i)) {
- val = thisp[i];
- if (fun.call(thisp, val, i, thisp)) {
- res.push(val);
- }
- }
- }
- return res;
- function isNodeList(object) {
- return /NodeList/i.test(object.item);
- }
- function convertNodeListToArray(nodeList) {
- var array = [];
- for (var i = 0,
- len = nodeList.length; i < len; i++) {
- array[i] = nodeList[i];
- }
- return array;
- }
- };
- }
-
- //#
- },{}],79:[function(require,module,exports){
- "use strict";
- if (!Array.prototype.indexOf) {
- Array.prototype.indexOf = function(elt) {
- var len = this.length >>> 0;
- var from = Number(arguments[1]) || 0;
- from = (from < 0) ? Math.ceil(from) : Math.floor(from);
- if (from < 0) {
- from += len;
- }
- for (; from < len; from++) {
- if (from in this && this[from] === elt) {
- return from;
- }
- }
- return -1;
- };
- }
-
- //#
- },{}],80:[function(require,module,exports){
- "use strict";
- if (!Array.isArray) {
- Array.isArray = function(obj) {
- return Object.prototype.toString.call(obj) == '[object Array]';
- };
- }
-
- //#
- },{}],81:[function(require,module,exports){
- "use strict";
- (function(global) {
- 'use strict';
- if (global.$traceurRuntime) {
- return;
- }
- var $Object = Object;
- var $TypeError = TypeError;
- var $create = $Object.create;
- var $defineProperties = $Object.defineProperties;
- var $defineProperty = $Object.defineProperty;
- var $freeze = $Object.freeze;
- var $getOwnPropertyDescriptor = $Object.getOwnPropertyDescriptor;
- var $getOwnPropertyNames = $Object.getOwnPropertyNames;
- var $keys = $Object.keys;
- var $hasOwnProperty = $Object.prototype.hasOwnProperty;
- var $toString = $Object.prototype.toString;
- var $preventExtensions = Object.preventExtensions;
- var $seal = Object.seal;
- var $isExtensible = Object.isExtensible;
- function nonEnum(value) {
- return {
- configurable: true,
- enumerable: false,
- value: value,
- writable: true
- };
- }
- var method = nonEnum;
- var counter = 0;
- function newUniqueString() {
- return '__$' + Math.floor(Math.random() * 1e9) + '$' + ++counter + '$__';
- }
- var symbolInternalProperty = newUniqueString();
- var symbolDescriptionProperty = newUniqueString();
- var symbolDataProperty = newUniqueString();
- var symbolValues = $create(null);
- var privateNames = $create(null);
- function isPrivateName(s) {
- return privateNames[s];
- }
- function createPrivateName() {
- var s = newUniqueString();
- privateNames[s] = true;
- return s;
- }
- function isShimSymbol(symbol) {
- return typeof symbol === 'object' && symbol instanceof SymbolValue;
- }
- function typeOf(v) {
- if (isShimSymbol(v))
- return 'symbol';
- return typeof v;
- }
- function Symbol(description) {
- var value = new SymbolValue(description);
- if (!(this instanceof Symbol))
- return value;
- throw new TypeError('Symbol cannot be new\'ed');
- }
- $defineProperty(Symbol.prototype, 'constructor', nonEnum(Symbol));
- $defineProperty(Symbol.prototype, 'toString', method(function() {
- var symbolValue = this[symbolDataProperty];
- if (!getOption('symbols'))
- return symbolValue[symbolInternalProperty];
- if (!symbolValue)
- throw TypeError('Conversion from symbol to string');
- var desc = symbolValue[symbolDescriptionProperty];
- if (desc === undefined)
- desc = '';
- return 'Symbol(' + desc + ')';
- }));
- $defineProperty(Symbol.prototype, 'valueOf', method(function() {
- var symbolValue = this[symbolDataProperty];
- if (!symbolValue)
- throw TypeError('Conversion from symbol to string');
- if (!getOption('symbols'))
- return symbolValue[symbolInternalProperty];
- return symbolValue;
- }));
- function SymbolValue(description) {
- var key = newUniqueString();
- $defineProperty(this, symbolDataProperty, {value: this});
- $defineProperty(this, symbolInternalProperty, {value: key});
- $defineProperty(this, symbolDescriptionProperty, {value: description});
- freeze(this);
- symbolValues[key] = this;
- }
- $defineProperty(SymbolValue.prototype, 'constructor', nonEnum(Symbol));
- $defineProperty(SymbolValue.prototype, 'toString', {
- value: Symbol.prototype.toString,
- enumerable: false
- });
- $defineProperty(SymbolValue.prototype, 'valueOf', {
- value: Symbol.prototype.valueOf,
- enumerable: false
- });
- var hashProperty = createPrivateName();
- var hashPropertyDescriptor = {value: undefined};
- var hashObjectProperties = {
- hash: {value: undefined},
- self: {value: undefined}
- };
- var hashCounter = 0;
- function getOwnHashObject(object) {
- var hashObject = object[hashProperty];
- if (hashObject && hashObject.self === object)
- return hashObject;
- if ($isExtensible(object)) {
- hashObjectProperties.hash.value = hashCounter++;
- hashObjectProperties.self.value = object;
- hashPropertyDescriptor.value = $create(null, hashObjectProperties);
- $defineProperty(object, hashProperty, hashPropertyDescriptor);
- return hashPropertyDescriptor.value;
- }
- return undefined;
- }
- function freeze(object) {
- getOwnHashObject(object);
- return $freeze.apply(this, arguments);
- }
- function preventExtensions(object) {
- getOwnHashObject(object);
- return $preventExtensions.apply(this, arguments);
- }
- function seal(object) {
- getOwnHashObject(object);
- return $seal.apply(this, arguments);
- }
- freeze(SymbolValue.prototype);
- function isSymbolString(s) {
- return symbolValues[s] || privateNames[s];
- }
- function toProperty(name) {
- if (isShimSymbol(name))
- return name[symbolInternalProperty];
- return name;
- }
- function removeSymbolKeys(array) {
- var rv = [];
- for (var i = 0; i < array.length; i++) {
- if (!isSymbolString(array[i])) {
- rv.push(array[i]);
- }
- }
- return rv;
- }
- function getOwnPropertyNames(object) {
- return removeSymbolKeys($getOwnPropertyNames(object));
- }
- function keys(object) {
- return removeSymbolKeys($keys(object));
- }
- function getOwnPropertySymbols(object) {
- var rv = [];
- var names = $getOwnPropertyNames(object);
- for (var i = 0; i < names.length; i++) {
- var symbol = symbolValues[names[i]];
- if (symbol) {
- rv.push(symbol);
- }
- }
- return rv;
- }
- function getOwnPropertyDescriptor(object, name) {
- return $getOwnPropertyDescriptor(object, toProperty(name));
- }
- function hasOwnProperty(name) {
- return $hasOwnProperty.call(this, toProperty(name));
- }
- function getOption(name) {
- return global.traceur && global.traceur.options[name];
- }
- function defineProperty(object, name, descriptor) {
- if (isShimSymbol(name)) {
- name = name[symbolInternalProperty];
- }
- $defineProperty(object, name, descriptor);
- return object;
- }
- function polyfillObject(Object) {
- $defineProperty(Object, 'defineProperty', {value: defineProperty});
- $defineProperty(Object, 'getOwnPropertyNames', {value: getOwnPropertyNames});
- $defineProperty(Object, 'getOwnPropertyDescriptor', {value: getOwnPropertyDescriptor});
- $defineProperty(Object.prototype, 'hasOwnProperty', {value: hasOwnProperty});
- $defineProperty(Object, 'freeze', {value: freeze});
- $defineProperty(Object, 'preventExtensions', {value: preventExtensions});
- $defineProperty(Object, 'seal', {value: seal});
- $defineProperty(Object, 'keys', {value: keys});
- }
- function exportStar(object) {
- for (var i = 1; i < arguments.length; i++) {
- var names = $getOwnPropertyNames(arguments[i]);
- for (var j = 0; j < names.length; j++) {
- var name = names[j];
- if (isSymbolString(name))
- continue;
- (function(mod, name) {
- $defineProperty(object, name, {
- get: function() {
- return mod[name];
- },
- enumerable: true
- });
- })(arguments[i], names[j]);
- }
- }
- return object;
- }
- function isObject(x) {
- return x != null && (typeof x === 'object' || typeof x === 'function');
- }
- function toObject(x) {
- if (x == null)
- throw $TypeError();
- return $Object(x);
- }
- function checkObjectCoercible(argument) {
- if (argument == null) {
- throw new TypeError('Value cannot be converted to an Object');
- }
- return argument;
- }
- function polyfillSymbol(global, Symbol) {
- if (!global.Symbol) {
- global.Symbol = Symbol;
- Object.getOwnPropertySymbols = getOwnPropertySymbols;
- }
- if (!global.Symbol.iterator) {
- global.Symbol.iterator = Symbol('Symbol.iterator');
- }
- }
- function setupGlobals(global) {
- polyfillSymbol(global, Symbol);
- global.Reflect = global.Reflect || {};
- global.Reflect.global = global.Reflect.global || global;
- polyfillObject(global.Object);
- }
- setupGlobals(global);
- global.$traceurRuntime = {
- checkObjectCoercible: checkObjectCoercible,
- createPrivateName: createPrivateName,
- defineProperties: $defineProperties,
- defineProperty: $defineProperty,
- exportStar: exportStar,
- getOwnHashObject: getOwnHashObject,
- getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
- getOwnPropertyNames: $getOwnPropertyNames,
- isObject: isObject,
- isPrivateName: isPrivateName,
- isSymbolString: isSymbolString,
- keys: $keys,
- setupGlobals: setupGlobals,
- toObject: toObject,
- toProperty: toProperty,
- typeof: typeOf
- };
- })(window);
- (function() {
- 'use strict';
- var path;
- function relativeRequire(callerPath, requiredPath) {
- path = path || typeof require !== 'undefined' && require('path');
- function isDirectory(path) {
- return path.slice(-1) === '/';
- }
- function isAbsolute(path) {
- return path[0] === '/';
- }
- function isRelative(path) {
- return path[0] === '.';
- }
- if (isDirectory(requiredPath) || isAbsolute(requiredPath))
- return;
- return isRelative(requiredPath) ? require(path.resolve(path.dirname(callerPath), requiredPath)) : require(requiredPath);
- }
- $traceurRuntime.require = relativeRequire;
- })();
- (function() {
- 'use strict';
- function spread() {
- var rv = [],
- j = 0,
- iterResult;
- for (var i = 0; i < arguments.length; i++) {
- var valueToSpread = $traceurRuntime.checkObjectCoercible(arguments[i]);
- if (typeof valueToSpread[$traceurRuntime.toProperty(Symbol.iterator)] !== 'function') {
- throw new TypeError('Cannot spread non-iterable object.');
- }
- var iter = valueToSpread[$traceurRuntime.toProperty(Symbol.iterator)]();
- while (!(iterResult = iter.next()).done) {
- rv[j++] = iterResult.value;
- }
- }
- return rv;
- }
- $traceurRuntime.spread = spread;
- })();
- (function() {
- 'use strict';
- var $Object = Object;
- var $TypeError = TypeError;
- var $create = $Object.create;
- var $defineProperties = $traceurRuntime.defineProperties;
- var $defineProperty = $traceurRuntime.defineProperty;
- var $getOwnPropertyDescriptor = $traceurRuntime.getOwnPropertyDescriptor;
- var $getOwnPropertyNames = $traceurRuntime.getOwnPropertyNames;
- var $getPrototypeOf = Object.getPrototypeOf;
- var $__0 = Object,
- getOwnPropertyNames = $__0.getOwnPropertyNames,
- getOwnPropertySymbols = $__0.getOwnPropertySymbols;
- function superDescriptor(homeObject, name) {
- var proto = $getPrototypeOf(homeObject);
- do {
- var result = $getOwnPropertyDescriptor(proto, name);
- if (result)
- return result;
- proto = $getPrototypeOf(proto);
- } while (proto);
- return undefined;
- }
- function superConstructor(ctor) {
- return ctor.__proto__;
- }
- function superCall(self, homeObject, name, args) {
- return superGet(self, homeObject, name).apply(self, args);
- }
- function superGet(self, homeObject, name) {
- var descriptor = superDescriptor(homeObject, name);
- if (descriptor) {
- if (!descriptor.get)
- return descriptor.value;
- return descriptor.get.call(self);
- }
- return undefined;
- }
- function superSet(self, homeObject, name, value) {
- var descriptor = superDescriptor(homeObject, name);
- if (descriptor && descriptor.set) {
- descriptor.set.call(self, value);
- return value;
- }
- throw $TypeError(("super has no setter '" + name + "'."));
- }
- function getDescriptors(object) {
- var descriptors = {};
- var names = getOwnPropertyNames(object);
- for (var i = 0; i < names.length; i++) {
- var name = names[i];
- descriptors[name] = $getOwnPropertyDescriptor(object, name);
- }
- var symbols = getOwnPropertySymbols(object);
- for (var i = 0; i < symbols.length; i++) {
- var symbol = symbols[i];
- descriptors[$traceurRuntime.toProperty(symbol)] = $getOwnPropertyDescriptor(object, $traceurRuntime.toProperty(symbol));
- }
- return descriptors;
- }
- function createClass(ctor, object, staticObject, superClass) {
- $defineProperty(object, 'constructor', {
- value: ctor,
- configurable: true,
- enumerable: false,
- writable: true
- });
- if (arguments.length > 3) {
- if (typeof superClass === 'function')
- ctor.__proto__ = superClass;
- ctor.prototype = $create(getProtoParent(superClass), getDescriptors(object));
- } else {
- ctor.prototype = object;
- }
- $defineProperty(ctor, 'prototype', {
- configurable: false,
- writable: false
- });
- return $defineProperties(ctor, getDescriptors(staticObject));
- }
- function getProtoParent(superClass) {
- if (typeof superClass === 'function') {
- var prototype = superClass.prototype;
- if ($Object(prototype) === prototype || prototype === null)
- return superClass.prototype;
- throw new $TypeError('super prototype must be an Object or null');
- }
- if (superClass === null)
- return null;
- throw new $TypeError(("Super expression must either be null or a function, not " + typeof superClass + "."));
- }
- function defaultSuperCall(self, homeObject, args) {
- if ($getPrototypeOf(homeObject) !== null)
- superCall(self, homeObject, 'constructor', args);
- }
- $traceurRuntime.createClass = createClass;
- $traceurRuntime.defaultSuperCall = defaultSuperCall;
- $traceurRuntime.superCall = superCall;
- $traceurRuntime.superConstructor = superConstructor;
- $traceurRuntime.superGet = superGet;
- $traceurRuntime.superSet = superSet;
- })();
-
- //#
- },{"path":undefined}],82:[function(require,module,exports){
- "use strict";
- if (!Object.keys) {
- Object.keys = (function() {
- 'use strict';
- var hasOwnProperty = Object.prototype.hasOwnProperty,
- hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
- dontEnums = ['toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor'],
- dontEnumsLength = dontEnums.length;
- return function(obj) {
- if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
- throw new TypeError('Object.keys called on non-object');
- }
- var result = [],
- prop,
- i;
- for (prop in obj) {
- if (hasOwnProperty.call(obj, prop)) {
- result.push(prop);
- }
- }
- if (hasDontEnumBug) {
- for (i = 0; i < dontEnumsLength; i++) {
- if (hasOwnProperty.call(obj, dontEnums[i])) {
- result.push(dontEnums[i]);
- }
- }
- }
- return result;
- };
- }());
- }
-
- //#
- },{}],83:[function(require,module,exports){
- "use strict";
- if (!String.prototype.trim) {
- var trimRegex = /^\s+|\s+$/g;
- String.prototype.trim = function() {
- return this.replace(trimRegex, '');
- };
- }
-
- //#
- },{}],84:[function(require,module,exports){
- "use strict";
- if (typeof WeakMap === 'undefined') {
- (function() {
- var defineProperty = Object.defineProperty;
- try {
- var properDefineProperty = true;
- defineProperty(function() {}, 'foo', {});
- } catch (e) {
- properDefineProperty = false;
- }
- var counter = +(new Date) % 1e9;
- var WeakMap = function() {
- this.name = '__st' + (Math.random() * 1e9 >>> 0) + (counter++ + '__');
- if (!properDefineProperty) {
- this._wmCache = [];
- }
- };
- if (properDefineProperty) {
- WeakMap.prototype = {
- set: function(key, value) {
- var entry = key[this.name];
- if (entry && entry[0] === key)
- entry[1] = value;
- else
- defineProperty(key, this.name, {
- value: [key, value],
- writable: true
- });
- },
- get: function(key) {
- var entry;
- return (entry = key[this.name]) && entry[0] === key ? entry[1] : undefined;
- },
- has: function(key) {
- return this.get(key) ? true : false;
- },
- 'delete': function(key) {
- this.set(key, undefined);
- }
- };
- } else {
- WeakMap.prototype = {
- set: function(key, value) {
- if (typeof key == 'undefined' || typeof value == 'undefined')
- return;
- for (var i = 0,
- len = this._wmCache.length; i < len; i++) {
- if (this._wmCache[i].key == key) {
- this._wmCache[i].value = value;
- return;
- }
- }
- this._wmCache.push({
- key: key,
- value: value
- });
- },
- get: function(key) {
- if (typeof key == 'undefined')
- return;
- for (var i = 0,
- len = this._wmCache.length; i < len; i++) {
- if (this._wmCache[i].key == key) {
- return this._wmCache[i].value;
- }
- }
- return void 0;
- },
- has: function(key) {
- return this.get(key) ? true : false;
- },
- 'delete': function(key) {
- if (typeof key == 'undefined')
- return;
- for (var i = 0,
- len = this._wmCache.length; i < len; i++) {
- if (this._wmCache[i].key == key) {
- Array.prototype.slice.call(this._wmCache, i, 1);
- }
- }
- }
- };
- }
- window.WeakMap = WeakMap;
- })();
- }
-
- //#
- },{}],85:[function(require,module,exports){
- "use strict";
- Object.defineProperties(exports, {
- TableView: {get: function() {
- return TableView;
- }},
- __esModule: {value: true}
- });
- var $__dom_46_js__,
- $__helpers_46_js__,
- $__eventManager_46_js__,
- $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
- $__3rdparty_47_walkontable_47_src_47_selection_46_js__,
- $__3rdparty_47_walkontable_47_src_47_core_46_js__;
- var dom = ($__dom_46_js__ = require("./dom.js"), $__dom_46_js__ && $__dom_46_js__.__esModule && $__dom_46_js__ || {default: $__dom_46_js__});
- var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
- var eventManagerObject = ($__eventManager_46_js__ = require("./eventManager.js"), $__eventManager_46_js__ && $__eventManager_46_js__.__esModule && $__eventManager_46_js__ || {default: $__eventManager_46_js__}).eventManager;
- var WalkontableCellCoords = ($__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ = require("./3rdparty/walkontable/src/cell/coords.js"), $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ && $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__.__esModule && $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__ || {default: $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__}).WalkontableCellCoords;
- var WalkontableSelection = ($__3rdparty_47_walkontable_47_src_47_selection_46_js__ = require("./3rdparty/walkontable/src/selection.js"), $__3rdparty_47_walkontable_47_src_47_selection_46_js__ && $__3rdparty_47_walkontable_47_src_47_selection_46_js__.__esModule && $__3rdparty_47_walkontable_47_src_47_selection_46_js__ || {default: $__3rdparty_47_walkontable_47_src_47_selection_46_js__}).WalkontableSelection;
- var Walkontable = ($__3rdparty_47_walkontable_47_src_47_core_46_js__ = require("./3rdparty/walkontable/src/core.js"), $__3rdparty_47_walkontable_47_src_47_core_46_js__ && $__3rdparty_47_walkontable_47_src_47_core_46_js__.__esModule && $__3rdparty_47_walkontable_47_src_47_core_46_js__ || {default: $__3rdparty_47_walkontable_47_src_47_core_46_js__}).Walkontable;
- Handsontable.TableView = TableView;
- function TableView(instance) {
- var that = this;
- this.eventManager = eventManagerObject(instance);
- this.instance = instance;
- this.settings = instance.getSettings();
- var originalStyle = instance.rootElement.getAttribute('style');
- if (originalStyle) {
- instance.rootElement.setAttribute('data-originalstyle', originalStyle);
- }
- dom.addClass(instance.rootElement, 'handsontable');
- var table = document.createElement('TABLE');
- table.className = 'htCore';
- this.THEAD = document.createElement('THEAD');
- table.appendChild(this.THEAD);
- this.TBODY = document.createElement('TBODY');
- table.appendChild(this.TBODY);
- instance.table = table;
- instance.container.insertBefore(table, instance.container.firstChild);
- this.eventManager.addEventListener(instance.rootElement, 'mousedown', function(event) {
- if (!that.isTextSelectionAllowed(event.target)) {
- clearTextSelection();
- event.preventDefault();
- window.focus();
- }
- });
- this.eventManager.addEventListener(document.documentElement, 'keyup', function(event) {
- if (instance.selection.isInProgress() && !event.shiftKey) {
- instance.selection.finish();
- }
- });
- var isMouseDown;
- this.isMouseDown = function() {
- return isMouseDown;
- };
- this.eventManager.addEventListener(document.documentElement, 'mouseup', function(event) {
- if (instance.selection.isInProgress() && event.which === 1) {
- instance.selection.finish();
- }
- isMouseDown = false;
- if (helper.isOutsideInput(document.activeElement)) {
- instance.unlisten();
- }
- });
- this.eventManager.addEventListener(document.documentElement, 'mousedown', function(event) {
- var next = event.target;
- var eventX = event.x || event.clientX;
- var eventY = event.y || event.clientY;
- if (isMouseDown) {
- return;
- }
- if (next !== instance.view.wt.wtTable.holder) {
- while (next !== document.documentElement) {
- if (next === null) {
- if (event.isTargetWebComponent) {
- break;
- }
- return;
- }
- if (next === instance.rootElement) {
- return;
- }
- next = next.parentNode;
- }
- } else {
- var scrollbarWidth = Handsontable.Dom.getScrollbarWidth();
- if (document.elementFromPoint(eventX + scrollbarWidth, eventY) !== instance.view.wt.wtTable.holder || document.elementFromPoint(eventX, eventY + scrollbarWidth) !== instance.view.wt.wtTable.holder) {
- return;
- }
- }
- if (that.settings.outsideClickDeselects) {
- instance.deselectCell();
- } else {
- instance.destroyEditor();
- }
- });
- this.eventManager.addEventListener(table, 'selectstart', function(event) {
- if (that.settings.fragmentSelection) {
- return;
- }
- event.preventDefault();
- });
- var clearTextSelection = function() {
- if (window.getSelection) {
- if (window.getSelection().empty) {
- window.getSelection().empty();
- } else if (window.getSelection().removeAllRanges) {
- window.getSelection().removeAllRanges();
- }
- } else if (document.selection) {
- document.selection.empty();
- }
- };
- var selections = [new WalkontableSelection({
- className: 'current',
- border: {
- width: 2,
- color: '#5292F7',
- cornerVisible: function() {
- return that.settings.fillHandle && !that.isCellEdited() && !instance.selection.isMultiple();
- },
- multipleSelectionHandlesVisible: function() {
- return !that.isCellEdited() && !instance.selection.isMultiple();
- }
- }
- }), new WalkontableSelection({
- className: 'area',
- border: {
- width: 1,
- color: '#89AFF9',
- cornerVisible: function() {
- return that.settings.fillHandle && !that.isCellEdited() && instance.selection.isMultiple();
- },
- multipleSelectionHandlesVisible: function() {
- return !that.isCellEdited() && instance.selection.isMultiple();
- }
- }
- }), new WalkontableSelection({
- className: 'highlight',
- highlightRowClassName: that.settings.currentRowClassName,
- highlightColumnClassName: that.settings.currentColClassName
- }), new WalkontableSelection({
- className: 'fill',
- border: {
- width: 1,
- color: 'red'
- }
- })];
- selections.current = selections[0];
- selections.area = selections[1];
- selections.highlight = selections[2];
- selections.fill = selections[3];
- var walkontableConfig = {
- debug: function() {
- return that.settings.debug;
- },
- table: table,
- stretchH: this.settings.stretchH,
- data: instance.getDataAtCell,
- totalRows: instance.countRows,
- totalColumns: instance.countCols,
- fixedColumnsLeft: function() {
- return that.settings.fixedColumnsLeft;
- },
- fixedRowsTop: function() {
- return that.settings.fixedRowsTop;
- },
- renderAllRows: that.settings.renderAllRows,
- rowHeaders: function() {
- var arr = [];
- if (instance.hasRowHeaders()) {
- arr.push(function(index, TH) {
- that.appendRowHeader(index, TH);
- });
- }
- Handsontable.hooks.run(instance, 'afterGetRowHeaderRenderers', arr);
- return arr;
- },
- columnHeaders: function() {
- var arr = [];
- if (instance.hasColHeaders()) {
- arr.push(function(index, TH) {
- that.appendColHeader(index, TH);
- });
- }
- Handsontable.hooks.run(instance, 'afterGetColumnHeaderRenderers', arr);
- return arr;
- },
- columnWidth: instance.getColWidth,
- rowHeight: instance.getRowHeight,
- cellRenderer: function(row, col, TD) {
- var prop = that.instance.colToProp(col),
- cellProperties = that.instance.getCellMeta(row, col),
- renderer = that.instance.getCellRenderer(cellProperties);
- var value = that.instance.getDataAtRowProp(row, prop);
- renderer(that.instance, TD, row, col, prop, value, cellProperties);
- Handsontable.hooks.run(that.instance, 'afterRenderer', TD, row, col, prop, value, cellProperties);
- },
- selections: selections,
- hideBorderOnMouseDownOver: function() {
- return that.settings.fragmentSelection;
- },
- onCellMouseDown: function(event, coords, TD, wt) {
- instance.listen();
- that.activeWt = wt;
- isMouseDown = true;
- dom.enableImmediatePropagation(event);
- Handsontable.hooks.run(instance, 'beforeOnCellMouseDown', event, coords, TD);
- if (!event.isImmediatePropagationStopped()) {
- if (event.button === 2 && instance.selection.inInSelection(coords)) {} else if (event.shiftKey) {
- if (coords.row >= 0 && coords.col >= 0) {
- instance.selection.setRangeEnd(coords);
- }
- } else {
- if ((coords.row < 0 || coords.col < 0) && (coords.row >= 0 || coords.col >= 0)) {
- if (coords.row < 0) {
- instance.selectCell(0, coords.col, instance.countRows() - 1, coords.col);
- instance.selection.setSelectedHeaders(false, true);
- }
- if (coords.col < 0) {
- instance.selectCell(coords.row, 0, coords.row, instance.countCols() - 1);
- instance.selection.setSelectedHeaders(true, false);
- }
- } else {
- coords.row = coords.row < 0 ? 0 : coords.row;
- coords.col = coords.col < 0 ? 0 : coords.col;
- instance.selection.setRangeStart(coords);
- }
- }
- Handsontable.hooks.run(instance, 'afterOnCellMouseDown', event, coords, TD);
- that.activeWt = that.wt;
- }
- },
- onCellMouseOver: function(event, coords, TD, wt) {
- that.activeWt = wt;
- if (coords.row >= 0 && coords.col >= 0) {
- if (isMouseDown) {
- instance.selection.setRangeEnd(coords);
- }
- } else {
- if (isMouseDown) {
- if (coords.row < 0) {
- instance.selection.setRangeEnd(new WalkontableCellCoords(instance.countRows() - 1, coords.col));
- instance.selection.setSelectedHeaders(false, true);
- }
- if (coords.col < 0) {
- instance.selection.setRangeEnd(new WalkontableCellCoords(coords.row, instance.countCols() - 1));
- instance.selection.setSelectedHeaders(true, false);
- }
- }
- }
- Handsontable.hooks.run(instance, 'afterOnCellMouseOver', event, coords, TD);
- that.activeWt = that.wt;
- },
- onCellCornerMouseDown: function(event) {
- event.preventDefault();
- Handsontable.hooks.run(instance, 'afterOnCellCornerMouseDown', event);
- },
- beforeDraw: function(force) {
- that.beforeRender(force);
- },
- onDraw: function(force) {
- that.onDraw(force);
- },
- onScrollVertically: function() {
- instance.runHooks('afterScrollVertically');
- },
- onScrollHorizontally: function() {
- instance.runHooks('afterScrollHorizontally');
- },
- onBeforeDrawBorders: function(corners, borderClassName) {
- instance.runHooks('beforeDrawBorders', corners, borderClassName);
- },
- onBeforeTouchScroll: function() {
- instance.runHooks('beforeTouchScroll');
- },
- onAfterMomentumScroll: function() {
- instance.runHooks('afterMomentumScroll');
- },
- viewportRowCalculatorOverride: function(calc) {
- if (that.settings.viewportRowRenderingOffset) {
- calc.startRow = Math.max(calc.startRow - that.settings.viewportRowRenderingOffset, 0);
- calc.endRow = Math.min(calc.endRow + that.settings.viewportRowRenderingOffset, instance.countRows() - 1);
- }
- instance.runHooks('afterViewportRowCalculatorOverride', calc);
- },
- viewportColumnCalculatorOverride: function(calc) {
- if (that.settings.viewportColumnRenderingOffset) {
- calc.startColumn = Math.max(calc.startColumn - that.settings.viewportColumnRenderingOffset, 0);
- calc.endColumn = Math.min(calc.endColumn + that.settings.viewportColumnRenderingOffset, instance.countCols() - 1);
- }
- instance.runHooks('afterViewportColumnCalculatorOverride', calc);
- }
- };
- Handsontable.hooks.run(instance, 'beforeInitWalkontable', walkontableConfig);
- this.wt = new Walkontable(walkontableConfig);
- this.activeWt = this.wt;
- this.eventManager.addEventListener(that.wt.wtTable.spreader, 'mousedown', function(event) {
- if (event.target === that.wt.wtTable.spreader && event.which === 3) {
- helper.stopPropagation(event);
- }
- });
- this.eventManager.addEventListener(that.wt.wtTable.spreader, 'contextmenu', function(event) {
- if (event.target === that.wt.wtTable.spreader && event.which === 3) {
- helper.stopPropagation(event);
- }
- });
- this.eventManager.addEventListener(document.documentElement, 'click', function() {
- if (that.settings.observeDOMVisibility) {
- if (that.wt.drawInterrupted) {
- that.instance.forceFullRender = true;
- that.render();
- }
- }
- });
- }
- TableView.prototype.isTextSelectionAllowed = function(el) {
- if (helper.isInput(el)) {
- return true;
- }
- if (this.settings.fragmentSelection && dom.isChildOf(el, this.TBODY)) {
- return true;
- }
- return false;
- };
- TableView.prototype.isCellEdited = function() {
- var activeEditor = this.instance.getActiveEditor();
- return activeEditor && activeEditor.isOpened();
- };
- TableView.prototype.beforeRender = function(force) {
- if (force) {
- Handsontable.hooks.run(this.instance, 'beforeRender', this.instance.forceFullRender);
- }
- };
- TableView.prototype.onDraw = function(force) {
- if (force) {
- Handsontable.hooks.run(this.instance, 'afterRender', this.instance.forceFullRender);
- }
- };
- TableView.prototype.render = function() {
- this.wt.draw(!this.instance.forceFullRender);
- this.instance.forceFullRender = false;
- };
- TableView.prototype.getCellAtCoords = function(coords, topmost) {
- var td = this.wt.getCell(coords, topmost);
- if (td < 0) {
- return null;
- } else {
- return td;
- }
- };
- TableView.prototype.scrollViewport = function(coords) {
- this.wt.scrollViewport(coords);
- };
- TableView.prototype.appendRowHeader = function(row, TH) {
- if (TH.firstChild) {
- var container = TH.firstChild;
- if (!dom.hasClass(container, 'relative')) {
- dom.empty(TH);
- this.appendRowHeader(row, TH);
- return;
- }
- this.updateCellHeader(container.firstChild, row, this.instance.getRowHeader);
- } else {
- var div = document.createElement('div');
- var span = document.createElement('span');
- div.className = 'relative';
- span.className = 'colHeader';
- this.updateCellHeader(span, row, this.instance.getRowHeader);
- div.appendChild(span);
- TH.appendChild(div);
- }
- Handsontable.hooks.run(this.instance, 'afterGetRowHeader', row, TH);
- };
- TableView.prototype.appendColHeader = function(col, TH) {
- if (TH.firstChild) {
- var container = TH.firstChild;
- if (!dom.hasClass(container, 'relative')) {
- dom.empty(TH);
- this.appendRowHeader(col, TH);
- return;
- }
- this.updateCellHeader(container.firstChild, col, this.instance.getColHeader);
- } else {
- var div = document.createElement('div');
- var span = document.createElement('span');
- div.className = 'relative';
- span.className = 'colHeader';
- this.updateCellHeader(span, col, this.instance.getColHeader);
- div.appendChild(span);
- TH.appendChild(div);
- }
- Handsontable.hooks.run(this.instance, 'afterGetColHeader', col, TH);
- };
- TableView.prototype.updateCellHeader = function(element, index, content) {
- if (index > -1) {
- dom.fastInnerHTML(element, content(index));
- } else {
- dom.fastInnerText(element, String.fromCharCode(160));
- dom.addClass(element, 'cornerHeader');
- }
- };
- TableView.prototype.maximumVisibleElementWidth = function(leftOffset) {
- var workspaceWidth = this.wt.wtViewport.getWorkspaceWidth();
- var maxWidth = workspaceWidth - leftOffset;
- return maxWidth > 0 ? maxWidth : 0;
- };
- TableView.prototype.maximumVisibleElementHeight = function(topOffset) {
- var workspaceHeight = this.wt.wtViewport.getWorkspaceHeight();
- var maxHeight = workspaceHeight - topOffset;
- return maxHeight > 0 ? maxHeight : 0;
- };
- TableView.prototype.mainViewIsActive = function() {
- return this.wt === this.activeWt;
- };
- TableView.prototype.destroy = function() {
- this.wt.destroy();
- this.eventManager.clear();
- };
- ;
-
- //#
- },{"./3rdparty/walkontable/src/cell/coords.js":5,"./3rdparty/walkontable/src/core.js":7,"./3rdparty/walkontable/src/selection.js":18,"./dom.js":27,"./eventManager.js":41,"./helpers.js":42}],86:[function(require,module,exports){
- "use strict";
- var process = function(value, callback) {
- var originalVal = value;
- var lowercaseVal = typeof originalVal === 'string' ? originalVal.toLowerCase() : null;
- return function(source) {
- var found = false;
- for (var s = 0,
- slen = source.length; s < slen; s++) {
- if (originalVal === source[s]) {
- found = true;
- break;
- } else if (lowercaseVal === Handsontable.helper.stringify(source[s]).toLowerCase()) {
- found = true;
- break;
- }
- }
- callback(found);
- };
- };
- Handsontable.AutocompleteValidator = function(value, callback) {
- if (this.strict && this.source) {
- if (typeof this.source === 'function') {
- this.source(value, process(value, callback));
- } else {
- process(value, callback)(this.source);
- }
- } else {
- callback(true);
- }
- };
-
- //#
- },{}],87:[function(require,module,exports){
- "use strict";
- var $__moment__,
- $___46__46__47_editors_46_js__;
- var moment = ($__moment__ = require("moment"), $__moment__ && $__moment__.__esModule && $__moment__ || {default: $__moment__}).default;
- var getEditor = ($___46__46__47_editors_46_js__ = require("./../editors.js"), $___46__46__47_editors_46_js__ && $___46__46__47_editors_46_js__.__esModule && $___46__46__47_editors_46_js__ || {default: $___46__46__47_editors_46_js__}).getEditor;
- Handsontable.DateValidator = function(value, callback) {
- var valid = true;
- var dateEditor = getEditor('date', this.instance);
- if (value === null) {
- value = '';
- }
- var isValidDate = moment(new Date(value)).isValid();
- var isValidFormat = moment(value, this.dateFormat || dateEditor.defaultDateFormat, true).isValid();
- if (!isValidDate) {
- valid = false;
- }
- if (!isValidDate && isValidFormat) {
- valid = true;
- }
- if (isValidDate && !isValidFormat) {
- if (this.correctFormat === true) {
- var correctedValue = correctFormat(value, this.dateFormat);
- this.instance.setDataAtCell(this.row, this.col, correctedValue, 'dateValidator');
- valid = true;
- } else {
- valid = false;
- }
- }
- callback(valid);
- };
- var correctFormat = function correctFormat(value, dateFormat) {
- var date = moment(new Date(value));
- if (date.format('YYYY').length > 4) {
- date.year((date.year() + '').substr(0, 4));
- }
- return date.format(dateFormat);
- };
-
- //#
- },{"./../editors.js":29,"moment":"moment"}],88:[function(require,module,exports){
- "use strict";
- Handsontable.NumericValidator = function(value, callback) {
- if (value === null) {
- value = '';
- }
- callback(/^-?\d*(\.|\,)?\d*$/.test(value));
- };
-
- //#
- },{}],"SheetClip":[function(require,module,exports){
- "use strict";
- (function(global) {
- "use strict";
- function countQuotes(str) {
- return str.split('"').length - 1;
- }
- var SheetClip = {
- parse: function(str) {
- var r,
- rLen,
- rows,
- arr = [],
- a = 0,
- c,
- cLen,
- multiline,
- last;
- rows = str.split('\n');
- if (rows.length > 1 && rows[rows.length - 1] === '') {
- rows.pop();
- }
- for (r = 0, rLen = rows.length; r < rLen; r += 1) {
- rows[r] = rows[r].split('\t');
- for (c = 0, cLen = rows[r].length; c < cLen; c += 1) {
- if (!arr[a]) {
- arr[a] = [];
- }
- if (multiline && c === 0) {
- last = arr[a].length - 1;
- arr[a][last] = arr[a][last] + '\n' + rows[r][0];
- if (multiline && (countQuotes(rows[r][0]) & 1)) {
- multiline = false;
- arr[a][last] = arr[a][last].substring(0, arr[a][last].length - 1).replace(/""/g, '"');
- }
- } else {
- if (c === cLen - 1 && rows[r][c].indexOf('"') === 0 && (countQuotes(rows[r][c]) & 1)) {
- arr[a].push(rows[r][c].substring(1).replace(/""/g, '"'));
- multiline = true;
- } else {
- arr[a].push(rows[r][c].replace(/""/g, '"'));
- multiline = false;
- }
- }
- }
- if (!multiline) {
- a += 1;
- }
- }
- return arr;
- },
- stringify: function(arr) {
- var r,
- rLen,
- c,
- cLen,
- str = '',
- val;
- for (r = 0, rLen = arr.length; r < rLen; r += 1) {
- cLen = arr[r].length;
- for (c = 0; c < cLen; c += 1) {
- if (c > 0) {
- str += '\t';
- }
- val = arr[r][c];
- if (typeof val === 'string') {
- if (val.indexOf('\n') > -1) {
- str += '"' + val.replace(/"/g, '""') + '"';
- } else {
- str += val;
- }
- } else if (val === null || val === void 0) {
- str += '';
- } else {
- str += val;
- }
- }
- str += '\n';
- }
- return str;
- }
- };
- if (typeof exports !== 'undefined') {
- exports.parse = SheetClip.parse;
- exports.stringify = SheetClip.stringify;
- } else {
- global.SheetClip = SheetClip;
- }
- }(window));
-
- //#
- },{}],"autoResize":[function(require,module,exports){
- "use strict";
- function autoResize() {
- var defaults = {
- minHeight: 200,
- maxHeight: 300,
- minWidth: 100,
- maxWidth: 300
- },
- el,
- body = document.body,
- text = document.createTextNode(''),
- span = document.createElement('SPAN'),
- observe = function(element, event, handler) {
- if (window.attachEvent) {
- element.attachEvent('on' + event, handler);
- } else {
- element.addEventListener(event, handler, false);
- }
- },
- unObserve = function(element, event, handler) {
- if (window.removeEventListener) {
- element.removeEventListener(event, handler, false);
- } else {
- element.detachEvent('on' + event, handler);
- }
- },
- resize = function(newChar) {
- var width,
- scrollHeight;
- if (!newChar) {
- newChar = "";
- } else if (!/^[a-zA-Z \.,\\\/\|0-9]$/.test(newChar)) {
- newChar = ".";
- }
- if (text.textContent !== void 0) {
- text.textContent = el.value + newChar;
- } else {
- text.data = el.value + newChar;
- }
- span.style.fontSize = Handsontable.Dom.getComputedStyle(el).fontSize;
- span.style.fontFamily = Handsontable.Dom.getComputedStyle(el).fontFamily;
- span.style.whiteSpace = "pre";
- body.appendChild(span);
- width = span.clientWidth + 2;
- body.removeChild(span);
- el.style.height = defaults.minHeight + 'px';
- if (defaults.minWidth > width) {
- el.style.width = defaults.minWidth + 'px';
- } else if (width > defaults.maxWidth) {
- el.style.width = defaults.maxWidth + 'px';
- } else {
- el.style.width = width + 'px';
- }
- scrollHeight = el.scrollHeight ? el.scrollHeight - 1 : 0;
- if (defaults.minHeight > scrollHeight) {
- el.style.height = defaults.minHeight + 'px';
- } else if (defaults.maxHeight < scrollHeight) {
- el.style.height = defaults.maxHeight + 'px';
- el.style.overflowY = 'visible';
- } else {
- el.style.height = scrollHeight + 'px';
- }
- },
- delayedResize = function() {
- window.setTimeout(resize, 0);
- },
- extendDefaults = function(config) {
- if (config && config.minHeight) {
- if (config.minHeight == 'inherit') {
- defaults.minHeight = el.clientHeight;
- } else {
- var minHeight = parseInt(config.minHeight);
- if (!isNaN(minHeight)) {
- defaults.minHeight = minHeight;
- }
- }
- }
- if (config && config.maxHeight) {
- if (config.maxHeight == 'inherit') {
- defaults.maxHeight = el.clientHeight;
- } else {
- var maxHeight = parseInt(config.maxHeight);
- if (!isNaN(maxHeight)) {
- defaults.maxHeight = maxHeight;
- }
- }
- }
- if (config && config.minWidth) {
- if (config.minWidth == 'inherit') {
- defaults.minWidth = el.clientWidth;
- } else {
- var minWidth = parseInt(config.minWidth);
- if (!isNaN(minWidth)) {
- defaults.minWidth = minWidth;
- }
- }
- }
- if (config && config.maxWidth) {
- if (config.maxWidth == 'inherit') {
- defaults.maxWidth = el.clientWidth;
- } else {
- var maxWidth = parseInt(config.maxWidth);
- if (!isNaN(maxWidth)) {
- defaults.maxWidth = maxWidth;
- }
- }
- }
- if (!span.firstChild) {
- span.className = "autoResize";
- span.style.display = 'inline-block';
- span.appendChild(text);
- }
- },
- init = function(el_, config, doObserve) {
- el = el_;
- extendDefaults(config);
- if (el.nodeName == 'TEXTAREA') {
- el.style.resize = 'none';
- el.style.overflowY = '';
- el.style.height = defaults.minHeight + 'px';
- el.style.minWidth = defaults.minWidth + 'px';
- el.style.maxWidth = defaults.maxWidth + 'px';
- el.style.overflowY = 'hidden';
- }
- if (doObserve) {
- observe(el, 'change', resize);
- observe(el, 'cut', delayedResize);
- observe(el, 'paste', delayedResize);
- observe(el, 'drop', delayedResize);
- observe(el, 'keydown', delayedResize);
- }
- resize();
- };
- return {
- init: function(el_, config, doObserve) {
- init(el_, config, doObserve);
- },
- unObserve: function() {
- unObserve(el, 'change', resize);
- unObserve(el, 'cut', delayedResize);
- unObserve(el, 'paste', delayedResize);
- unObserve(el, 'drop', delayedResize);
- unObserve(el, 'keydown', delayedResize);
- },
- resize: resize
- };
- }
- if (typeof exports !== 'undefined') {
- module.exports = autoResize;
- }
-
- //#
- },{}],"copyPaste":[function(require,module,exports){
- "use strict";
- var instance;
- function copyPaste() {
- if (!instance) {
- instance = new CopyPasteClass();
- } else if (instance.hasBeenDestroyed()) {
- instance.init();
- }
- instance.refCounter++;
- return instance;
- }
- if (typeof exports !== 'undefined') {
- module.exports = copyPaste;
- }
- function CopyPasteClass() {
- this.refCounter = 0;
- this.init();
- }
- CopyPasteClass.prototype.init = function() {
- var style,
- parent;
- this.copyCallbacks = [];
- this.cutCallbacks = [];
- this.pasteCallbacks = [];
- parent = document.body;
- if (document.getElementById('CopyPasteDiv')) {
- this.elDiv = document.getElementById('CopyPasteDiv');
- this.elTextarea = this.elDiv.firstChild;
- } else {
- this.elDiv = document.createElement('div');
- this.elDiv.id = 'CopyPasteDiv';
- style = this.elDiv.style;
- style.position = 'fixed';
- style.top = '-10000px';
- style.left = '-10000px';
- parent.appendChild(this.elDiv);
- this.elTextarea = document.createElement('textarea');
- this.elTextarea.className = 'copyPaste';
- this.elTextarea.onpaste = function(event) {
- var clipboardContents,
- temp;
- if ('WebkitAppearance' in document.documentElement.style) {
- clipboardContents = event.clipboardData.getData("Text");
- if (navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1) {
- temp = clipboardContents.split('\n');
- temp.pop();
- clipboardContents = temp.join('\n');
- }
- this.value = clipboardContents;
- return false;
- }
- };
- style = this.elTextarea.style;
- style.width = '10000px';
- style.height = '10000px';
- style.overflow = 'hidden';
- this.elDiv.appendChild(this.elTextarea);
- if (typeof style.opacity !== 'undefined') {
- style.opacity = 0;
- }
- }
- this.onKeyDownRef = this.onKeyDown.bind(this);
- document.documentElement.addEventListener('keydown', this.onKeyDownRef, false);
- };
- CopyPasteClass.prototype.onKeyDown = function(event) {
- var _this = this,
- isCtrlDown = false;
- function isActiveElementEditable() {
- var element = document.activeElement;
- if (element.shadowRoot && element.shadowRoot.activeElement) {
- element = element.shadowRoot.activeElement;
- }
- return ['INPUT', 'SELECT', 'TEXTAREA'].indexOf(element.nodeName) > -1 || element.contentEditable === 'true';
- }
- if (event.metaKey) {
- isCtrlDown = true;
- } else if (event.ctrlKey && navigator.userAgent.indexOf('Mac') === -1) {
- isCtrlDown = true;
- }
- if (isCtrlDown) {
- if (document.activeElement !== this.elTextarea && (this.getSelectionText() !== '' || isActiveElementEditable())) {
- return;
- }
- this.selectNodeText(this.elTextarea);
- setTimeout(function() {
- if (document.activeElement !== _this.elTextarea) {
- _this.selectNodeText(_this.elTextarea);
- }
- }, 0);
- }
- if (isCtrlDown && (event.keyCode === 67 || event.keyCode === 86 || event.keyCode === 88)) {
- if (event.keyCode === 88) {
- setTimeout(function() {
- _this.triggerCut(event);
- }, 0);
- } else if (event.keyCode === 86) {
- setTimeout(function() {
- _this.triggerPaste(event);
- }, 0);
- }
- }
- };
- CopyPasteClass.prototype.selectNodeText = function(element) {
- if (element) {
- element.select();
- }
- };
- CopyPasteClass.prototype.getSelectionText = function() {
- var text = '';
- if (window.getSelection) {
- text = window.getSelection().toString();
- } else if (document.selection && document.selection.type !== 'Control') {
- text = document.selection.createRange().text;
- }
- return text;
- };
- CopyPasteClass.prototype.copyable = function(string) {
- if (typeof string !== 'string' && string.toString === void 0) {
- throw new Error('copyable requires string parameter');
- }
- this.elTextarea.value = string;
- this.selectNodeText(this.elTextarea);
- };
- CopyPasteClass.prototype.onCut = function(callback) {
- this.cutCallbacks.push(callback);
- };
- CopyPasteClass.prototype.onPaste = function(callback) {
- this.pasteCallbacks.push(callback);
- };
- CopyPasteClass.prototype.removeCallback = function(callback) {
- var i,
- len;
- for (i = 0, len = this.copyCallbacks.length; i < len; i++) {
- if (this.copyCallbacks[i] === callback) {
- this.copyCallbacks.splice(i, 1);
- return true;
- }
- }
- for (i = 0, len = this.cutCallbacks.length; i < len; i++) {
- if (this.cutCallbacks[i] === callback) {
- this.cutCallbacks.splice(i, 1);
- return true;
- }
- }
- for (i = 0, len = this.pasteCallbacks.length; i < len; i++) {
- if (this.pasteCallbacks[i] === callback) {
- this.pasteCallbacks.splice(i, 1);
- return true;
- }
- }
- return false;
- };
- CopyPasteClass.prototype.triggerCut = function(event) {
- var _this = this;
- if (_this.cutCallbacks) {
- setTimeout(function() {
- for (var i = 0,
- len = _this.cutCallbacks.length; i < len; i++) {
- _this.cutCallbacks[i](event);
- }
- }, 50);
- }
- };
- CopyPasteClass.prototype.triggerPaste = function(event, string) {
- var _this = this;
- if (_this.pasteCallbacks) {
- setTimeout(function() {
- var val = string || _this.elTextarea.value;
- for (var i = 0,
- len = _this.pasteCallbacks.length; i < len; i++) {
- _this.pasteCallbacks[i](val, event);
- }
- }, 50);
- }
- };
- CopyPasteClass.prototype.destroy = function() {
- if (!this.hasBeenDestroyed() && --this.refCounter === 0) {
- if (this.elDiv && this.elDiv.parentNode) {
- this.elDiv.parentNode.removeChild(this.elDiv);
- this.elDiv = null;
- this.elTextarea = null;
- }
- document.documentElement.removeEventListener('keydown', this.onKeyDownRef);
- }
- };
- CopyPasteClass.prototype.hasBeenDestroyed = function() {
- return !this.refCounter;
- };
-
- //#
- },{}],"jsonpatch":[function(require,module,exports){
- "use strict";
- var jsonpatch;
- (function(jsonpatch) {
- var objOps = {
- add: function(obj, key) {
- obj[key] = this.value;
- return true;
- },
- remove: function(obj, key) {
- delete obj[key];
- return true;
- },
- replace: function(obj, key) {
- obj[key] = this.value;
- return true;
- },
- move: function(obj, key, tree) {
- var temp = {
- op: "_get",
- path: this.from
- };
- apply(tree, [temp]);
- apply(tree, [{
- op: "remove",
- path: this.from
- }]);
- apply(tree, [{
- op: "add",
- path: this.path,
- value: temp.value
- }]);
- return true;
- },
- copy: function(obj, key, tree) {
- var temp = {
- op: "_get",
- path: this.from
- };
- apply(tree, [temp]);
- apply(tree, [{
- op: "add",
- path: this.path,
- value: temp.value
- }]);
- return true;
- },
- test: function(obj, key) {
- return (JSON.stringify(obj[key]) === JSON.stringify(this.value));
- },
- _get: function(obj, key) {
- this.value = obj[key];
- }
- };
- var arrOps = {
- add: function(arr, i) {
- arr.splice(i, 0, this.value);
- return true;
- },
- remove: function(arr, i) {
- arr.splice(i, 1);
- return true;
- },
- replace: function(arr, i) {
- arr[i] = this.value;
- return true;
- },
- move: objOps.move,
- copy: objOps.copy,
- test: objOps.test,
- _get: objOps._get
- };
- var observeOps = {
- add: function(patches, path) {
- var patch = {
- op: "add",
- path: path + escapePathComponent(this.name),
- value: this.object[this.name]
- };
- patches.push(patch);
- },
- 'delete': function(patches, path) {
- var patch = {
- op: "remove",
- path: path + escapePathComponent(this.name)
- };
- patches.push(patch);
- },
- update: function(patches, path) {
- var patch = {
- op: "replace",
- path: path + escapePathComponent(this.name),
- value: this.object[this.name]
- };
- patches.push(patch);
- }
- };
- function escapePathComponent(str) {
- if (str.indexOf('/') === -1 && str.indexOf('~') === -1) {
- return str;
- }
- return str.replace(/~/g, '~0').replace(/\//g, '~1');
- }
- function _getPathRecursive(root, obj) {
- var found;
- for (var key in root) {
- if (root.hasOwnProperty(key)) {
- if (root[key] === obj) {
- return escapePathComponent(key) + '/';
- } else if (typeof root[key] === 'object') {
- found = _getPathRecursive(root[key], obj);
- if (found != '') {
- return escapePathComponent(key) + '/' + found;
- }
- }
- }
- }
- return '';
- }
- function getPath(root, obj) {
- if (root === obj) {
- return '/';
- }
- var path = _getPathRecursive(root, obj);
- if (path === '') {
- throw new Error("Object not found in root");
- }
- return '/' + path;
- }
- var beforeDict = [];
- jsonpatch.intervals;
- var Mirror = (function() {
- function Mirror(obj) {
- this.observers = [];
- this.obj = obj;
- }
- return Mirror;
- })();
- var ObserverInfo = (function() {
- function ObserverInfo(callback, observer) {
- this.callback = callback;
- this.observer = observer;
- }
- return ObserverInfo;
- })();
- function getMirror(obj) {
- for (var i = 0,
- ilen = beforeDict.length; i < ilen; i++) {
- if (beforeDict[i].obj === obj) {
- return beforeDict[i];
- }
- }
- }
- function getObserverFromMirror(mirror, callback) {
- for (var j = 0,
- jlen = mirror.observers.length; j < jlen; j++) {
- if (mirror.observers[j].callback === callback) {
- return mirror.observers[j].observer;
- }
- }
- }
- function removeObserverFromMirror(mirror, observer) {
- for (var j = 0,
- jlen = mirror.observers.length; j < jlen; j++) {
- if (mirror.observers[j].observer === observer) {
- mirror.observers.splice(j, 1);
- return;
- }
- }
- }
- function unobserve(root, observer) {
- generate(observer);
- if (Object.observe) {
- _unobserve(observer, root);
- } else {
- clearTimeout(observer.next);
- }
- var mirror = getMirror(root);
- removeObserverFromMirror(mirror, observer);
- }
- jsonpatch.unobserve = unobserve;
- function observe(obj, callback) {
- var patches = [];
- var root = obj;
- var observer;
- var mirror = getMirror(obj);
- if (!mirror) {
- mirror = new Mirror(obj);
- beforeDict.push(mirror);
- } else {
- observer = getObserverFromMirror(mirror, callback);
- }
- if (observer) {
- return observer;
- }
- if (Object.observe) {
- observer = function(arr) {
- _unobserve(observer, obj);
- _observe(observer, obj);
- var a = 0,
- alen = arr.length;
- while (a < alen) {
- if (!(arr[a].name === 'length' && _isArray(arr[a].object)) && !(arr[a].name === '__Jasmine_been_here_before__')) {
- var type = arr[a].type;
- switch (type) {
- case 'new':
- type = 'add';
- break;
- case 'deleted':
- type = 'delete';
- break;
- case 'updated':
- type = 'update';
- break;
- }
- observeOps[type].call(arr[a], patches, getPath(root, arr[a].object));
- }
- a++;
- }
- if (patches) {
- if (callback) {
- callback(patches);
- }
- }
- observer.patches = patches;
- patches = [];
- };
- } else {
- observer = {};
- mirror.value = JSON.parse(JSON.stringify(obj));
- if (callback) {
- observer.callback = callback;
- observer.next = null;
- var intervals = this.intervals || [100, 1000, 10000, 60000];
- var currentInterval = 0;
- var dirtyCheck = function() {
- generate(observer);
- };
- var fastCheck = function() {
- clearTimeout(observer.next);
- observer.next = setTimeout(function() {
- dirtyCheck();
- currentInterval = 0;
- observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
- }, 0);
- };
- var slowCheck = function() {
- dirtyCheck();
- if (currentInterval == intervals.length) {
- currentInterval = intervals.length - 1;
- }
- observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
- };
- if (typeof window !== 'undefined') {
- if (window.addEventListener) {
- window.addEventListener('mousedown', fastCheck);
- window.addEventListener('mouseup', fastCheck);
- window.addEventListener('keydown', fastCheck);
- } else {
- window.attachEvent('onmousedown', fastCheck);
- window.attachEvent('onmouseup', fastCheck);
- window.attachEvent('onkeydown', fastCheck);
- }
- }
- observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
- }
- }
- observer.patches = patches;
- observer.object = obj;
- mirror.observers.push(new ObserverInfo(callback, observer));
- return _observe(observer, obj);
- }
- jsonpatch.observe = observe;
- function _observe(observer, obj) {
- if (Object.observe) {
- Object.observe(obj, observer);
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- var v = obj[key];
- if (v && typeof(v) === "object") {
- _observe(observer, v);
- }
- }
- }
- }
- return observer;
- }
- function _unobserve(observer, obj) {
- if (Object.observe) {
- Object.unobserve(obj, observer);
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- var v = obj[key];
- if (v && typeof(v) === "object") {
- _unobserve(observer, v);
- }
- }
- }
- }
- return observer;
- }
- function generate(observer) {
- if (Object.observe) {
- Object.deliverChangeRecords(observer);
- } else {
- var mirror;
- for (var i = 0,
- ilen = beforeDict.length; i < ilen; i++) {
- if (beforeDict[i].obj === observer.object) {
- mirror = beforeDict[i];
- break;
- }
- }
- _generate(mirror.value, observer.object, observer.patches, "");
- }
- var temp = observer.patches;
- if (temp.length > 0) {
- observer.patches = [];
- if (observer.callback) {
- observer.callback(temp);
- }
- }
- return temp;
- }
- jsonpatch.generate = generate;
- var _objectKeys;
- if (Object.keys) {
- _objectKeys = Object.keys;
- } else {
- _objectKeys = function(obj) {
- var keys = [];
- for (var o in obj) {
- if (obj.hasOwnProperty(o)) {
- keys.push(o);
- }
- }
- return keys;
- };
- }
- function _generate(mirror, obj, patches, path) {
- var newKeys = _objectKeys(obj);
- var oldKeys = _objectKeys(mirror);
- var changed = false;
- var deleted = false;
- for (var t = oldKeys.length - 1; t >= 0; t--) {
- var key = oldKeys[t];
- var oldVal = mirror[key];
- if (obj.hasOwnProperty(key)) {
- var newVal = obj[key];
- if (oldVal instanceof Object) {
- _generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key));
- } else {
- if (oldVal != newVal) {
- changed = true;
- patches.push({
- op: "replace",
- path: path + "/" + escapePathComponent(key),
- value: newVal
- });
- mirror[key] = newVal;
- }
- }
- } else {
- patches.push({
- op: "remove",
- path: path + "/" + escapePathComponent(key)
- });
- delete mirror[key];
- deleted = true;
- }
- }
- if (!deleted && newKeys.length == oldKeys.length) {
- return;
- }
- for (var t = 0; t < newKeys.length; t++) {
- var key = newKeys[t];
- if (!mirror.hasOwnProperty(key)) {
- patches.push({
- op: "add",
- path: path + "/" + escapePathComponent(key),
- value: obj[key]
- });
- mirror[key] = JSON.parse(JSON.stringify(obj[key]));
- }
- }
- }
- var _isArray;
- if (Array.isArray) {
- _isArray = Array.isArray;
- } else {
- _isArray = function(obj) {
- return obj.push && typeof obj.length === 'number';
- };
- }
- function apply(tree, patches) {
- var result = false,
- p = 0,
- plen = patches.length,
- patch;
- while (p < plen) {
- patch = patches[p];
- var keys = patch.path.split('/');
- var obj = tree;
- var t = 1;
- var len = keys.length;
- while (true) {
- if (_isArray(obj)) {
- var index = parseInt(keys[t], 10);
- t++;
- if (t >= len) {
- result = arrOps[patch.op].call(patch, obj, index, tree);
- break;
- }
- obj = obj[index];
- } else {
- var key = keys[t];
- if (key.indexOf('~') != -1) {
- key = key.replace(/~1/g, '/').replace(/~0/g, '~');
- }
- t++;
- if (t >= len) {
- result = objOps[patch.op].call(patch, obj, key, tree);
- break;
- }
- obj = obj[key];
- }
- }
- p++;
- }
- return result;
- }
- jsonpatch.apply = apply;
- })(jsonpatch || (jsonpatch = {}));
- if (typeof exports !== "undefined") {
- exports.apply = jsonpatch.apply;
- exports.observe = jsonpatch.observe;
- exports.unobserve = jsonpatch.unobserve;
- exports.generate = jsonpatch.generate;
- }
-
- //#
- },{}],"moment":[function(require,module,exports){
- //! moment.js
- //! version : 2.10.3
- //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
- //! license : MIT
- //! momentjs.com
-
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
- typeof define === 'function' && define.amd ? define(factory) :
- global.moment = factory()
- }(this, function () { 'use strict';
-
- var hookCallback;
-
- function utils_hooks__hooks () {
- return hookCallback.apply(null, arguments);
- }
-
- // This is done to register the method called with moment()
- // without creating circular dependencies.
- function setHookCallback (callback) {
- hookCallback = callback;
- }
-
- function isArray(input) {
- return Object.prototype.toString.call(input) === '[object Array]';
- }
-
- function isDate(input) {
- return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
- }
-
- function map(arr, fn) {
- var res = [], i;
- for (i = 0; i < arr.length; ++i) {
- res.push(fn(arr[i], i));
- }
- return res;
- }
-
- function hasOwnProp(a, b) {
- return Object.prototype.hasOwnProperty.call(a, b);
- }
-
- function extend(a, b) {
- for (var i in b) {
- if (hasOwnProp(b, i)) {
- a[i] = b[i];
- }
- }
-
- if (hasOwnProp(b, 'toString')) {
- a.toString = b.toString;
- }
-
- if (hasOwnProp(b, 'valueOf')) {
- a.valueOf = b.valueOf;
- }
-
- return a;
- }
-
- function create_utc__createUTC (input, format, locale, strict) {
- return createLocalOrUTC(input, format, locale, strict, true).utc();
- }
-
- function defaultParsingFlags() {
- // We need to deep clone this object.
- return {
- empty : false,
- unusedTokens : [],
- unusedInput : [],
- overflow : -2,
- charsLeftOver : 0,
- nullInput : false,
- invalidMonth : null,
- invalidFormat : false,
- userInvalidated : false,
- iso : false
- };
- }
-
- function getParsingFlags(m) {
- if (m._pf == null) {
- m._pf = defaultParsingFlags();
- }
- return m._pf;
- }
-
- function valid__isValid(m) {
- if (m._isValid == null) {
- var flags = getParsingFlags(m);
- m._isValid = !isNaN(m._d.getTime()) &&
- flags.overflow < 0 &&
- !flags.empty &&
- !flags.invalidMonth &&
- !flags.nullInput &&
- !flags.invalidFormat &&
- !flags.userInvalidated;
-
- if (m._strict) {
- m._isValid = m._isValid &&
- flags.charsLeftOver === 0 &&
- flags.unusedTokens.length === 0 &&
- flags.bigHour === undefined;
- }
- }
- return m._isValid;
- }
-
- function valid__createInvalid (flags) {
- var m = create_utc__createUTC(NaN);
- if (flags != null) {
- extend(getParsingFlags(m), flags);
- }
- else {
- getParsingFlags(m).userInvalidated = true;
- }
-
- return m;
- }
-
- var momentProperties = utils_hooks__hooks.momentProperties = [];
-
- function copyConfig(to, from) {
- var i, prop, val;
-
- if (typeof from._isAMomentObject !== 'undefined') {
- to._isAMomentObject = from._isAMomentObject;
- }
- if (typeof from._i !== 'undefined') {
- to._i = from._i;
- }
- if (typeof from._f !== 'undefined') {
- to._f = from._f;
- }
- if (typeof from._l !== 'undefined') {
- to._l = from._l;
- }
- if (typeof from._strict !== 'undefined') {
- to._strict = from._strict;
- }
- if (typeof from._tzm !== 'undefined') {
- to._tzm = from._tzm;
- }
- if (typeof from._isUTC !== 'undefined') {
- to._isUTC = from._isUTC;
- }
- if (typeof from._offset !== 'undefined') {
- to._offset = from._offset;
- }
- if (typeof from._pf !== 'undefined') {
- to._pf = getParsingFlags(from);
- }
- if (typeof from._locale !== 'undefined') {
- to._locale = from._locale;
- }
-
- if (momentProperties.length > 0) {
- for (i in momentProperties) {
- prop = momentProperties[i];
- val = from[prop];
- if (typeof val !== 'undefined') {
- to[prop] = val;
- }
- }
- }
-
- return to;
- }
-
- var updateInProgress = false;
-
- // Moment prototype object
- function Moment(config) {
- copyConfig(this, config);
- this._d = new Date(+config._d);
- // Prevent infinite loop in case updateOffset creates new moment
- // objects.
- if (updateInProgress === false) {
- updateInProgress = true;
- utils_hooks__hooks.updateOffset(this);
- updateInProgress = false;
- }
- }
-
- function isMoment (obj) {
- return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
- }
-
- function toInt(argumentForCoercion) {
- var coercedNumber = +argumentForCoercion,
- value = 0;
-
- if (coercedNumber !== 0 && isFinite(coercedNumber)) {
- if (coercedNumber >= 0) {
- value = Math.floor(coercedNumber);
- } else {
- value = Math.ceil(coercedNumber);
- }
- }
-
- return value;
- }
-
- function compareArrays(array1, array2, dontConvert) {
- var len = Math.min(array1.length, array2.length),
- lengthDiff = Math.abs(array1.length - array2.length),
- diffs = 0,
- i;
- for (i = 0; i < len; i++) {
- if ((dontConvert && array1[i] !== array2[i]) ||
- (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
- diffs++;
- }
- }
- return diffs + lengthDiff;
- }
-
- function Locale() {
- }
-
- var locales = {};
- var globalLocale;
-
- function normalizeLocale(key) {
- return key ? key.toLowerCase().replace('_', '-') : key;
- }
-
- // pick the locale from the array
- // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
- // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
- function chooseLocale(names) {
- var i = 0, j, next, locale, split;
-
- while (i < names.length) {
- split = normalizeLocale(names[i]).split('-');
- j = split.length;
- next = normalizeLocale(names[i + 1]);
- next = next ? next.split('-') : null;
- while (j > 0) {
- locale = loadLocale(split.slice(0, j).join('-'));
- if (locale) {
- return locale;
- }
- if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
- //the next array item is better than a shallower substring of this one
- break;
- }
- j--;
- }
- i++;
- }
- return null;
- }
-
- function loadLocale(name) {
- var oldLocale = null;
- // TODO: Find a better way to register and load all the locales in Node
- if (!locales[name] && typeof module !== 'undefined' &&
- module && module.exports) {
- try {
- oldLocale = globalLocale._abbr;
- require('./locale/' + name);
- // because defineLocale currently also sets the global locale, we
- // want to undo that for lazy loaded locales
- locale_locales__getSetGlobalLocale(oldLocale);
- } catch (e) { }
- }
- return locales[name];
- }
-
- // This function will load locale and then set the global locale. If
- // no arguments are passed in, it will simply return the current global
- // locale key.
- function locale_locales__getSetGlobalLocale (key, values) {
- var data;
- if (key) {
- if (typeof values === 'undefined') {
- data = locale_locales__getLocale(key);
- }
- else {
- data = defineLocale(key, values);
- }
-
- if (data) {
- // moment.duration._locale = moment._locale = data;
- globalLocale = data;
- }
- }
-
- return globalLocale._abbr;
- }
-
- function defineLocale (name, values) {
- if (values !== null) {
- values.abbr = name;
- if (!locales[name]) {
- locales[name] = new Locale();
- }
- locales[name].set(values);
-
- // backwards compat for now: also set the locale
- locale_locales__getSetGlobalLocale(name);
-
- return locales[name];
- } else {
- // useful for testing
- delete locales[name];
- return null;
- }
- }
-
- // returns locale data
- function locale_locales__getLocale (key) {
- var locale;
-
- if (key && key._locale && key._locale._abbr) {
- key = key._locale._abbr;
- }
-
- if (!key) {
- return globalLocale;
- }
-
- if (!isArray(key)) {
- //short-circuit everything else
- locale = loadLocale(key);
- if (locale) {
- return locale;
- }
- key = [key];
- }
-
- return chooseLocale(key);
- }
-
- var aliases = {};
-
- function addUnitAlias (unit, shorthand) {
- var lowerCase = unit.toLowerCase();
- aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
- }
-
- function normalizeUnits(units) {
- return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
- }
-
- function normalizeObjectUnits(inputObject) {
- var normalizedInput = {},
- normalizedProp,
- prop;
-
- for (prop in inputObject) {
- if (hasOwnProp(inputObject, prop)) {
- normalizedProp = normalizeUnits(prop);
- if (normalizedProp) {
- normalizedInput[normalizedProp] = inputObject[prop];
- }
- }
- }
-
- return normalizedInput;
- }
-
- function makeGetSet (unit, keepTime) {
- return function (value) {
- if (value != null) {
- get_set__set(this, unit, value);
- utils_hooks__hooks.updateOffset(this, keepTime);
- return this;
- } else {
- return get_set__get(this, unit);
- }
- };
- }
-
- function get_set__get (mom, unit) {
- return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
- }
-
- function get_set__set (mom, unit, value) {
- return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
- }
-
- // MOMENTS
-
- function getSet (units, value) {
- var unit;
- if (typeof units === 'object') {
- for (unit in units) {
- this.set(unit, units[unit]);
- }
- } else {
- units = normalizeUnits(units);
- if (typeof this[units] === 'function') {
- return this[units](value);
- }
- }
- return this;
- }
-
- function zeroFill(number, targetLength, forceSign) {
- var output = '' + Math.abs(number),
- sign = number >= 0;
-
- while (output.length < targetLength) {
- output = '0' + output;
- }
- return (sign ? (forceSign ? '+' : '') : '-') + output;
- }
-
- 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,4}|x|X|zz?|ZZ?|.)/g;
-
- var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
-
- var formatFunctions = {};
-
- var formatTokenFunctions = {};
-
- // token: 'M'
- // padded: ['MM', 2]
- // ordinal: 'Mo'
- // callback: function () { this.month() + 1 }
- function addFormatToken (token, padded, ordinal, callback) {
- var func = callback;
- if (typeof callback === 'string') {
- func = function () {
- return this[callback]();
- };
- }
- if (token) {
- formatTokenFunctions[token] = func;
- }
- if (padded) {
- formatTokenFunctions[padded[0]] = function () {
- return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
- };
- }
- if (ordinal) {
- formatTokenFunctions[ordinal] = function () {
- return this.localeData().ordinal(func.apply(this, arguments), token);
- };
- }
- }
-
- function removeFormattingTokens(input) {
- if (input.match(/\[[\s\S]/)) {
- return input.replace(/^\[|\]$/g, '');
- }
- return input.replace(/\\/g, '');
- }
-
- function makeFormatFunction(format) {
- var array = format.match(formattingTokens), i, length;
-
- for (i = 0, length = array.length; i < length; i++) {
- if (formatTokenFunctions[array[i]]) {
- array[i] = formatTokenFunctions[array[i]];
- } else {
- array[i] = removeFormattingTokens(array[i]);
- }
- }
-
- return function (mom) {
- var output = '';
- for (i = 0; i < length; i++) {
- output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
- }
- return output;
- };
- }
-
- // format date using native date object
- function formatMoment(m, format) {
- if (!m.isValid()) {
- return m.localeData().invalidDate();
- }
-
- format = expandFormat(format, m.localeData());
-
- if (!formatFunctions[format]) {
- formatFunctions[format] = makeFormatFunction(format);
- }
-
- return formatFunctions[format](m);
- }
-
- function expandFormat(format, locale) {
- var i = 5;
-
- function replaceLongDateFormatTokens(input) {
- return locale.longDateFormat(input) || input;
- }
-
- localFormattingTokens.lastIndex = 0;
- while (i >= 0 && localFormattingTokens.test(format)) {
- format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
- localFormattingTokens.lastIndex = 0;
- i -= 1;
- }
-
- return format;
- }
-
- var match1 = /\d/; // 0 - 9
- var match2 = /\d\d/; // 00 - 99
- var match3 = /\d{3}/; // 000 - 999
- var match4 = /\d{4}/; // 0000 - 9999
- var match6 = /[+-]?\d{6}/; // -999999 - 999999
- var match1to2 = /\d\d?/; // 0 - 99
- var match1to3 = /\d{1,3}/; // 0 - 999
- var match1to4 = /\d{1,4}/; // 0 - 9999
- var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
-
- var matchUnsigned = /\d+/; // 0 - inf
- var matchSigned = /[+-]?\d+/; // -inf - inf
-
- var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
-
- var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
-
- // any word (or two) characters or numbers including two/three word month in arabic.
- var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
-
- var regexes = {};
-
- function addRegexToken (token, regex, strictRegex) {
- regexes[token] = typeof regex === 'function' ? regex : function (isStrict) {
- return (isStrict && strictRegex) ? strictRegex : regex;
- };
- }
-
- function getParseRegexForToken (token, config) {
- if (!hasOwnProp(regexes, token)) {
- return new RegExp(unescapeFormat(token));
- }
-
- return regexes[token](config._strict, config._locale);
- }
-
- // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
- function unescapeFormat(s) {
- return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
- return p1 || p2 || p3 || p4;
- }).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
- }
-
- var tokens = {};
-
- function addParseToken (token, callback) {
- var i, func = callback;
- if (typeof token === 'string') {
- token = [token];
- }
- if (typeof callback === 'number') {
- func = function (input, array) {
- array[callback] = toInt(input);
- };
- }
- for (i = 0; i < token.length; i++) {
- tokens[token[i]] = func;
- }
- }
-
- function addWeekParseToken (token, callback) {
- addParseToken(token, function (input, array, config, token) {
- config._w = config._w || {};
- callback(input, config._w, config, token);
- });
- }
-
- function addTimeToArrayFromToken(token, input, config) {
- if (input != null && hasOwnProp(tokens, token)) {
- tokens[token](input, config._a, config, token);
- }
- }
-
- var YEAR = 0;
- var MONTH = 1;
- var DATE = 2;
- var HOUR = 3;
- var MINUTE = 4;
- var SECOND = 5;
- var MILLISECOND = 6;
-
- function daysInMonth(year, month) {
- return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
- }
-
- // FORMATTING
-
- addFormatToken('M', ['MM', 2], 'Mo', function () {
- return this.month() + 1;
- });
-
- addFormatToken('MMM', 0, 0, function (format) {
- return this.localeData().monthsShort(this, format);
- });
-
- addFormatToken('MMMM', 0, 0, function (format) {
- return this.localeData().months(this, format);
- });
-
- // ALIASES
-
- addUnitAlias('month', 'M');
-
- // PARSING
-
- addRegexToken('M', match1to2);
- addRegexToken('MM', match1to2, match2);
- addRegexToken('MMM', matchWord);
- addRegexToken('MMMM', matchWord);
-
- addParseToken(['M', 'MM'], function (input, array) {
- array[MONTH] = toInt(input) - 1;
- });
-
- addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
- var month = config._locale.monthsParse(input, token, config._strict);
- // if we didn't find a month name, mark the date as invalid.
- if (month != null) {
- array[MONTH] = month;
- } else {
- getParsingFlags(config).invalidMonth = input;
- }
- });
-
- // LOCALES
-
- var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
- function localeMonths (m) {
- return this._months[m.month()];
- }
-
- var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
- function localeMonthsShort (m) {
- return this._monthsShort[m.month()];
- }
-
- function localeMonthsParse (monthName, format, strict) {
- var i, mom, regex;
-
- if (!this._monthsParse) {
- this._monthsParse = [];
- this._longMonthsParse = [];
- this._shortMonthsParse = [];
- }
-
- for (i = 0; i < 12; i++) {
- // make the regex if we don't have it already
- mom = create_utc__createUTC([2000, i]);
- if (strict && !this._longMonthsParse[i]) {
- this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
- this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
- }
- if (!strict && !this._monthsParse[i]) {
- regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
- this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
- }
- // test the regex
- if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
- return i;
- } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
- return i;
- } else if (!strict && this._monthsParse[i].test(monthName)) {
- return i;
- }
- }
- }
-
- // MOMENTS
-
- function setMonth (mom, value) {
- var dayOfMonth;
-
- // TODO: Move this out of here!
- if (typeof value === 'string') {
- value = mom.localeData().monthsParse(value);
- // TODO: Another silent failure?
- if (typeof value !== 'number') {
- return mom;
- }
- }
-
- dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
- mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
- return mom;
- }
-
- function getSetMonth (value) {
- if (value != null) {
- setMonth(this, value);
- utils_hooks__hooks.updateOffset(this, true);
- return this;
- } else {
- return get_set__get(this, 'Month');
- }
- }
-
- function getDaysInMonth () {
- return daysInMonth(this.year(), this.month());
- }
-
- function checkOverflow (m) {
- var overflow;
- var a = m._a;
-
- if (a && getParsingFlags(m).overflow === -2) {
- overflow =
- a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
- a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
- a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
- a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
- a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
- a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
- -1;
-
- if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
- overflow = DATE;
- }
-
- getParsingFlags(m).overflow = overflow;
- }
-
- return m;
- }
-
- function warn(msg) {
- if (utils_hooks__hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
- console.warn('Deprecation warning: ' + msg);
- }
- }
-
- function deprecate(msg, fn) {
- var firstTime = true,
- msgWithStack = msg + '\n' + (new Error()).stack;
-
- return extend(function () {
- if (firstTime) {
- warn(msgWithStack);
- firstTime = false;
- }
- return fn.apply(this, arguments);
- }, fn);
- }
-
- var deprecations = {};
-
- function deprecateSimple(name, msg) {
- if (!deprecations[name]) {
- warn(msg);
- deprecations[name] = true;
- }
- }
-
- utils_hooks__hooks.suppressDeprecationWarnings = false;
-
- 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)?)?$/;
-
- var isoDates = [
- ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
- ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
- ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
- ['GGGG-[W]WW', /\d{4}-W\d{2}/],
- ['YYYY-DDD', /\d{4}-\d{3}/]
- ];
-
- // iso time formats and regexes
- var isoTimes = [
- ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
- ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
- ['HH:mm', /(T| )\d\d:\d\d/],
- ['HH', /(T| )\d\d/]
- ];
-
- var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
-
- // date from iso format
- function configFromISO(config) {
- var i, l,
- string = config._i,
- match = from_string__isoRegex.exec(string);
-
- if (match) {
- getParsingFlags(config).iso = true;
- for (i = 0, l = isoDates.length; i < l; i++) {
- if (isoDates[i][1].exec(string)) {
- // match[5] should be 'T' or undefined
- config._f = isoDates[i][0] + (match[6] || ' ');
- break;
- }
- }
- for (i = 0, l = isoTimes.length; i < l; i++) {
- if (isoTimes[i][1].exec(string)) {
- config._f += isoTimes[i][0];
- break;
- }
- }
- if (string.match(matchOffset)) {
- config._f += 'Z';
- }
- configFromStringAndFormat(config);
- } else {
- config._isValid = false;
- }
- }
-
- // date from iso format or fallback
- function configFromString(config) {
- var matched = aspNetJsonRegex.exec(config._i);
-
- if (matched !== null) {
- config._d = new Date(+matched[1]);
- return;
- }
-
- configFromISO(config);
- if (config._isValid === false) {
- delete config._isValid;
- utils_hooks__hooks.createFromInputFallback(config);
- }
- }
-
- utils_hooks__hooks.createFromInputFallback = deprecate(
- 'moment construction falls back to js Date. This is ' +
- 'discouraged and will be removed in upcoming major ' +
- 'release. Please refer to ' +
- 'https://github.com/moment/moment/issues/1407 for more info.',
- function (config) {
- config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
- }
- );
-
- function createDate (y, m, d, h, M, s, ms) {
- //can't just apply() to create a date:
- //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
- var date = new Date(y, m, d, h, M, s, ms);
-
- //the date constructor doesn't accept years < 1970
- if (y < 1970) {
- date.setFullYear(y);
- }
- return date;
- }
-
- function createUTCDate (y) {
- var date = new Date(Date.UTC.apply(null, arguments));
- if (y < 1970) {
- date.setUTCFullYear(y);
- }
- return date;
- }
-
- addFormatToken(0, ['YY', 2], 0, function () {
- return this.year() % 100;
- });
-
- addFormatToken(0, ['YYYY', 4], 0, 'year');
- addFormatToken(0, ['YYYYY', 5], 0, 'year');
- addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
-
- // ALIASES
-
- addUnitAlias('year', 'y');
-
- // PARSING
-
- addRegexToken('Y', matchSigned);
- addRegexToken('YY', match1to2, match2);
- addRegexToken('YYYY', match1to4, match4);
- addRegexToken('YYYYY', match1to6, match6);
- addRegexToken('YYYYYY', match1to6, match6);
-
- addParseToken(['YYYY', 'YYYYY', 'YYYYYY'], YEAR);
- addParseToken('YY', function (input, array) {
- array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
- });
-
- // HELPERS
-
- function daysInYear(year) {
- return isLeapYear(year) ? 366 : 365;
- }
-
- function isLeapYear(year) {
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
- }
-
- // HOOKS
-
- utils_hooks__hooks.parseTwoDigitYear = function (input) {
- return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
- };
-
- // MOMENTS
-
- var getSetYear = makeGetSet('FullYear', false);
-
- function getIsLeapYear () {
- return isLeapYear(this.year());
- }
-
- addFormatToken('w', ['ww', 2], 'wo', 'week');
- addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
-
- // ALIASES
-
- addUnitAlias('week', 'w');
- addUnitAlias('isoWeek', 'W');
-
- // PARSING
-
- addRegexToken('w', match1to2);
- addRegexToken('ww', match1to2, match2);
- addRegexToken('W', match1to2);
- addRegexToken('WW', match1to2, match2);
-
- addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
- week[token.substr(0, 1)] = toInt(input);
- });
-
- // HELPERS
-
- // firstDayOfWeek 0 = sun, 6 = sat
- // the day of the week that starts the week
- // (usually sunday or monday)
- // firstDayOfWeekOfYear 0 = sun, 6 = sat
- // the first week is the week that contains the first
- // of this day of the week
- // (eg. ISO weeks use thursday (4))
- function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
- var end = firstDayOfWeekOfYear - firstDayOfWeek,
- daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
- adjustedMoment;
-
-
- if (daysToDayOfWeek > end) {
- daysToDayOfWeek -= 7;
- }
-
- if (daysToDayOfWeek < end - 7) {
- daysToDayOfWeek += 7;
- }
-
- adjustedMoment = local__createLocal(mom).add(daysToDayOfWeek, 'd');
- return {
- week: Math.ceil(adjustedMoment.dayOfYear() / 7),
- year: adjustedMoment.year()
- };
- }
-
- // LOCALES
-
- function localeWeek (mom) {
- return weekOfYear(mom, this._week.dow, this._week.doy).week;
- }
-
- var defaultLocaleWeek = {
- dow : 0, // Sunday is the first day of the week.
- doy : 6 // The week that contains Jan 1st is the first week of the year.
- };
-
- function localeFirstDayOfWeek () {
- return this._week.dow;
- }
-
- function localeFirstDayOfYear () {
- return this._week.doy;
- }
-
- // MOMENTS
-
- function getSetWeek (input) {
- var week = this.localeData().week(this);
- return input == null ? week : this.add((input - week) * 7, 'd');
- }
-
- function getSetISOWeek (input) {
- var week = weekOfYear(this, 1, 4).week;
- return input == null ? week : this.add((input - week) * 7, 'd');
- }
-
- addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
-
- // ALIASES
-
- addUnitAlias('dayOfYear', 'DDD');
-
- // PARSING
-
- addRegexToken('DDD', match1to3);
- addRegexToken('DDDD', match3);
- addParseToken(['DDD', 'DDDD'], function (input, array, config) {
- config._dayOfYear = toInt(input);
- });
-
- // HELPERS
-
- //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
- function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
- var d = createUTCDate(year, 0, 1).getUTCDay();
- var daysToAdd;
- var dayOfYear;
-
- d = d === 0 ? 7 : d;
- weekday = weekday != null ? weekday : firstDayOfWeek;
- daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0);
- dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1;
-
- return {
- year : dayOfYear > 0 ? year : year - 1,
- dayOfYear : dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
- };
- }
-
- // MOMENTS
-
- function getSetDayOfYear (input) {
- var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
- return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
- }
-
- // Pick the first defined of two or three arguments.
- function defaults(a, b, c) {
- if (a != null) {
- return a;
- }
- if (b != null) {
- return b;
- }
- return c;
- }
-
- function currentDateArray(config) {
- var now = new Date();
- if (config._useUTC) {
- return [now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()];
- }
- return [now.getFullYear(), now.getMonth(), now.getDate()];
- }
-
- // convert an array to a date.
- // the array should mirror the parameters below
- // note: all values past the year are optional and will default to the lowest possible value.
- // [year, month, day , hour, minute, second, millisecond]
- function configFromArray (config) {
- var i, date, input = [], currentDate, yearToUse;
-
- if (config._d) {
- return;
- }
-
- currentDate = currentDateArray(config);
-
- //compute day of the year from weeks and weekdays
- if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
- dayOfYearFromWeekInfo(config);
- }
-
- //if the day of the year is set, figure out what it is
- if (config._dayOfYear) {
- yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
-
- if (config._dayOfYear > daysInYear(yearToUse)) {
- getParsingFlags(config)._overflowDayOfYear = true;
- }
-
- date = createUTCDate(yearToUse, 0, config._dayOfYear);
- config._a[MONTH] = date.getUTCMonth();
- config._a[DATE] = date.getUTCDate();
- }
-
- // Default to current date.
- // * if no year, month, day of month are given, default to today
- // * if day of month is given, default month and year
- // * if month is given, default only year
- // * if year is given, don't default anything
- for (i = 0; i < 3 && config._a[i] == null; ++i) {
- config._a[i] = input[i] = currentDate[i];
- }
-
- // Zero out whatever was not defaulted, including time
- for (; i < 7; i++) {
- config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
- }
-
- // Check for 24:00:00.000
- if (config._a[HOUR] === 24 &&
- config._a[MINUTE] === 0 &&
- config._a[SECOND] === 0 &&
- config._a[MILLISECOND] === 0) {
- config._nextDay = true;
- config._a[HOUR] = 0;
- }
-
- config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
- // Apply timezone offset from input. The actual utcOffset can be changed
- // with parseZone.
- if (config._tzm != null) {
- config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
- }
-
- if (config._nextDay) {
- config._a[HOUR] = 24;
- }
- }
-
- function dayOfYearFromWeekInfo(config) {
- var w, weekYear, week, weekday, dow, doy, temp;
-
- w = config._w;
- if (w.GG != null || w.W != null || w.E != null) {
- dow = 1;
- doy = 4;
-
- // TODO: We need to take the current isoWeekYear, but that depends on
- // how we interpret now (local, utc, fixed offset). So create
- // a now version of current config (take local/utc/offset flags, and
- // create now).
- weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(local__createLocal(), 1, 4).year);
- week = defaults(w.W, 1);
- weekday = defaults(w.E, 1);
- } else {
- dow = config._locale._week.dow;
- doy = config._locale._week.doy;
-
- weekYear = defaults(w.gg, config._a[YEAR], weekOfYear(local__createLocal(), dow, doy).year);
- week = defaults(w.w, 1);
-
- if (w.d != null) {
- // weekday -- low day numbers are considered next week
- weekday = w.d;
- if (weekday < dow) {
- ++week;
- }
- } else if (w.e != null) {
- // local weekday -- counting starts from begining of week
- weekday = w.e + dow;
- } else {
- // default to begining of week
- weekday = dow;
- }
- }
- temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
-
- config._a[YEAR] = temp.year;
- config._dayOfYear = temp.dayOfYear;
- }
-
- utils_hooks__hooks.ISO_8601 = function () {};
-
- // date from string and format string
- function configFromStringAndFormat(config) {
- // TODO: Move this to another part of the creation flow to prevent circular deps
- if (config._f === utils_hooks__hooks.ISO_8601) {
- configFromISO(config);
- return;
- }
-
- config._a = [];
- getParsingFlags(config).empty = true;
-
- // This array is used to make a Date, either with `new Date` or `Date.UTC`
- var string = '' + config._i,
- i, parsedInput, tokens, token, skipped,
- stringLength = string.length,
- totalParsedInputLength = 0;
-
- tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
-
- for (i = 0; i < tokens.length; i++) {
- token = tokens[i];
- parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
- if (parsedInput) {
- skipped = string.substr(0, string.indexOf(parsedInput));
- if (skipped.length > 0) {
- getParsingFlags(config).unusedInput.push(skipped);
- }
- string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
- totalParsedInputLength += parsedInput.length;
- }
- // don't parse if it's not a known token
- if (formatTokenFunctions[token]) {
- if (parsedInput) {
- getParsingFlags(config).empty = false;
- }
- else {
- getParsingFlags(config).unusedTokens.push(token);
- }
- addTimeToArrayFromToken(token, parsedInput, config);
- }
- else if (config._strict && !parsedInput) {
- getParsingFlags(config).unusedTokens.push(token);
- }
- }
-
- // add remaining unparsed input length to the string
- getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
- if (string.length > 0) {
- getParsingFlags(config).unusedInput.push(string);
- }
-
- // clear _12h flag if hour is <= 12
- if (getParsingFlags(config).bigHour === true &&
- config._a[HOUR] <= 12 &&
- config._a[HOUR] > 0) {
- getParsingFlags(config).bigHour = undefined;
- }
- // handle meridiem
- config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
-
- configFromArray(config);
- checkOverflow(config);
- }
-
-
- function meridiemFixWrap (locale, hour, meridiem) {
- var isPm;
-
- if (meridiem == null) {
- // nothing to do
- return hour;
- }
- if (locale.meridiemHour != null) {
- return locale.meridiemHour(hour, meridiem);
- } else if (locale.isPM != null) {
- // Fallback
- isPm = locale.isPM(meridiem);
- if (isPm && hour < 12) {
- hour += 12;
- }
- if (!isPm && hour === 12) {
- hour = 0;
- }
- return hour;
- } else {
- // this is not supposed to happen
- return hour;
- }
- }
-
- function configFromStringAndArray(config) {
- var tempConfig,
- bestMoment,
-
- scoreToBeat,
- i,
- currentScore;
-
- if (config._f.length === 0) {
- getParsingFlags(config).invalidFormat = true;
- config._d = new Date(NaN);
- return;
- }
-
- for (i = 0; i < config._f.length; i++) {
- currentScore = 0;
- tempConfig = copyConfig({}, config);
- if (config._useUTC != null) {
- tempConfig._useUTC = config._useUTC;
- }
- tempConfig._f = config._f[i];
- configFromStringAndFormat(tempConfig);
-
- if (!valid__isValid(tempConfig)) {
- continue;
- }
-
- // if there is any input that was not parsed add a penalty for that format
- currentScore += getParsingFlags(tempConfig).charsLeftOver;
-
- //or tokens
- currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
-
- getParsingFlags(tempConfig).score = currentScore;
-
- if (scoreToBeat == null || currentScore < scoreToBeat) {
- scoreToBeat = currentScore;
- bestMoment = tempConfig;
- }
- }
-
- extend(config, bestMoment || tempConfig);
- }
-
- function configFromObject(config) {
- if (config._d) {
- return;
- }
-
- var i = normalizeObjectUnits(config._i);
- config._a = [i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond];
-
- configFromArray(config);
- }
-
- function createFromConfig (config) {
- var input = config._i,
- format = config._f,
- res;
-
- config._locale = config._locale || locale_locales__getLocale(config._l);
-
- if (input === null || (format === undefined && input === '')) {
- return valid__createInvalid({nullInput: true});
- }
-
- if (typeof input === 'string') {
- config._i = input = config._locale.preparse(input);
- }
-
- if (isMoment(input)) {
- return new Moment(checkOverflow(input));
- } else if (isArray(format)) {
- configFromStringAndArray(config);
- } else if (format) {
- configFromStringAndFormat(config);
- } else if (isDate(input)) {
- config._d = input;
- } else {
- configFromInput(config);
- }
-
- res = new Moment(checkOverflow(config));
- if (res._nextDay) {
- // Adding is smart enough around DST
- res.add(1, 'd');
- res._nextDay = undefined;
- }
-
- return res;
- }
-
- function configFromInput(config) {
- var input = config._i;
- if (input === undefined) {
- config._d = new Date();
- } else if (isDate(input)) {
- config._d = new Date(+input);
- } else if (typeof input === 'string') {
- configFromString(config);
- } else if (isArray(input)) {
- config._a = map(input.slice(0), function (obj) {
- return parseInt(obj, 10);
- });
- configFromArray(config);
- } else if (typeof(input) === 'object') {
- configFromObject(config);
- } else if (typeof(input) === 'number') {
- // from milliseconds
- config._d = new Date(input);
- } else {
- utils_hooks__hooks.createFromInputFallback(config);
- }
- }
-
- function createLocalOrUTC (input, format, locale, strict, isUTC) {
- var c = {};
-
- if (typeof(locale) === 'boolean') {
- strict = locale;
- locale = undefined;
- }
- // object construction must be done this way.
- // https://github.com/moment/moment/issues/1423
- c._isAMomentObject = true;
- c._useUTC = c._isUTC = isUTC;
- c._l = locale;
- c._i = input;
- c._f = format;
- c._strict = strict;
-
- return createFromConfig(c);
- }
-
- function local__createLocal (input, format, locale, strict) {
- return createLocalOrUTC(input, format, locale, strict, false);
- }
-
- var prototypeMin = deprecate(
- 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
- function () {
- var other = local__createLocal.apply(null, arguments);
- return other < this ? this : other;
- }
- );
-
- var prototypeMax = deprecate(
- 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
- function () {
- var other = local__createLocal.apply(null, arguments);
- return other > this ? this : other;
- }
- );
-
- // Pick a moment m from moments so that m[fn](other) is true for all
- // other. This relies on the function fn to be transitive.
- //
- // moments should either be an array of moment objects or an array, whose
- // first element is an array of moment objects.
- function pickBy(fn, moments) {
- var res, i;
- if (moments.length === 1 && isArray(moments[0])) {
- moments = moments[0];
- }
- if (!moments.length) {
- return local__createLocal();
- }
- res = moments[0];
- for (i = 1; i < moments.length; ++i) {
- if (moments[i][fn](res)) {
- res = moments[i];
- }
- }
- return res;
- }
-
- // TODO: Use [].sort instead?
- function min () {
- var args = [].slice.call(arguments, 0);
-
- return pickBy('isBefore', args);
- }
-
- function max () {
- var args = [].slice.call(arguments, 0);
-
- return pickBy('isAfter', args);
- }
-
- function Duration (duration) {
- var normalizedInput = normalizeObjectUnits(duration),
- years = normalizedInput.year || 0,
- quarters = normalizedInput.quarter || 0,
- months = normalizedInput.month || 0,
- weeks = normalizedInput.week || 0,
- days = normalizedInput.day || 0,
- hours = normalizedInput.hour || 0,
- minutes = normalizedInput.minute || 0,
- seconds = normalizedInput.second || 0,
- milliseconds = normalizedInput.millisecond || 0;
-
- // representation for dateAddRemove
- this._milliseconds = +milliseconds +
- seconds * 1e3 + // 1000
- minutes * 6e4 + // 1000 * 60
- hours * 36e5; // 1000 * 60 * 60
- // Because of dateAddRemove treats 24 hours as different from a
- // day when working around DST, we need to store them separately
- this._days = +days +
- weeks * 7;
- // It is impossible translate months into days without knowing
- // which months you are are talking about, so we have to store
- // it separately.
- this._months = +months +
- quarters * 3 +
- years * 12;
-
- this._data = {};
-
- this._locale = locale_locales__getLocale();
-
- this._bubble();
- }
-
- function isDuration (obj) {
- return obj instanceof Duration;
- }
-
- function offset (token, separator) {
- addFormatToken(token, 0, 0, function () {
- var offset = this.utcOffset();
- var sign = '+';
- if (offset < 0) {
- offset = -offset;
- sign = '-';
- }
- return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
- });
- }
-
- offset('Z', ':');
- offset('ZZ', '');
-
- // PARSING
-
- addRegexToken('Z', matchOffset);
- addRegexToken('ZZ', matchOffset);
- addParseToken(['Z', 'ZZ'], function (input, array, config) {
- config._useUTC = true;
- config._tzm = offsetFromString(input);
- });
-
- // HELPERS
-
- // timezone chunker
- // '+10:00' > ['10', '00']
- // '-1530' > ['-15', '30']
- var chunkOffset = /([\+\-]|\d\d)/gi;
-
- function offsetFromString(string) {
- var matches = ((string || '').match(matchOffset) || []);
- var chunk = matches[matches.length - 1] || [];
- var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
- var minutes = +(parts[1] * 60) + toInt(parts[2]);
-
- return parts[0] === '+' ? minutes : -minutes;
- }
-
- // Return a moment from input, that is local/utc/zone equivalent to model.
- function cloneWithOffset(input, model) {
- var res, diff;
- if (model._isUTC) {
- res = model.clone();
- diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
- // Use low-level api, because this fn is low-level api.
- res._d.setTime(+res._d + diff);
- utils_hooks__hooks.updateOffset(res, false);
- return res;
- } else {
- return local__createLocal(input).local();
- }
- return model._isUTC ? local__createLocal(input).zone(model._offset || 0) : local__createLocal(input).local();
- }
-
- function getDateOffset (m) {
- // On Firefox.24 Date#getTimezoneOffset returns a floating point.
- // https://github.com/moment/moment/pull/1871
- return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
- }
-
- // HOOKS
-
- // This function will be called whenever a moment is mutated.
- // It is intended to keep the offset in sync with the timezone.
- utils_hooks__hooks.updateOffset = function () {};
-
- // MOMENTS
-
- // keepLocalTime = true means only change the timezone, without
- // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
- // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
- // +0200, so we adjust the time as needed, to be valid.
- //
- // Keeping the time actually adds/subtracts (one hour)
- // from the actual represented time. That is why we call updateOffset
- // a second time. In case it wants us to change the offset again
- // _changeInProgress == true case, then we have to adjust, because
- // there is no such time in the given timezone.
- function getSetOffset (input, keepLocalTime) {
- var offset = this._offset || 0,
- localAdjust;
- if (input != null) {
- if (typeof input === 'string') {
- input = offsetFromString(input);
- }
- if (Math.abs(input) < 16) {
- input = input * 60;
- }
- if (!this._isUTC && keepLocalTime) {
- localAdjust = getDateOffset(this);
- }
- this._offset = input;
- this._isUTC = true;
- if (localAdjust != null) {
- this.add(localAdjust, 'm');
- }
- if (offset !== input) {
- if (!keepLocalTime || this._changeInProgress) {
- add_subtract__addSubtract(this, create__createDuration(input - offset, 'm'), 1, false);
- } else if (!this._changeInProgress) {
- this._changeInProgress = true;
- utils_hooks__hooks.updateOffset(this, true);
- this._changeInProgress = null;
- }
- }
- return this;
- } else {
- return this._isUTC ? offset : getDateOffset(this);
- }
- }
-
- function getSetZone (input, keepLocalTime) {
- if (input != null) {
- if (typeof input !== 'string') {
- input = -input;
- }
-
- this.utcOffset(input, keepLocalTime);
-
- return this;
- } else {
- return -this.utcOffset();
- }
- }
-
- function setOffsetToUTC (keepLocalTime) {
- return this.utcOffset(0, keepLocalTime);
- }
-
- function setOffsetToLocal (keepLocalTime) {
- if (this._isUTC) {
- this.utcOffset(0, keepLocalTime);
- this._isUTC = false;
-
- if (keepLocalTime) {
- this.subtract(getDateOffset(this), 'm');
- }
- }
- return this;
- }
-
- function setOffsetToParsedOffset () {
- if (this._tzm) {
- this.utcOffset(this._tzm);
- } else if (typeof this._i === 'string') {
- this.utcOffset(offsetFromString(this._i));
- }
- return this;
- }
-
- function hasAlignedHourOffset (input) {
- if (!input) {
- input = 0;
- }
- else {
- input = local__createLocal(input).utcOffset();
- }
-
- return (this.utcOffset() - input) % 60 === 0;
- }
-
- function isDaylightSavingTime () {
- return (
- this.utcOffset() > this.clone().month(0).utcOffset() ||
- this.utcOffset() > this.clone().month(5).utcOffset()
- );
- }
-
- function isDaylightSavingTimeShifted () {
- if (this._a) {
- var other = this._isUTC ? create_utc__createUTC(this._a) : local__createLocal(this._a);
- return this.isValid() && compareArrays(this._a, other.toArray()) > 0;
- }
-
- return false;
- }
-
- function isLocal () {
- return !this._isUTC;
- }
-
- function isUtcOffset () {
- return this._isUTC;
- }
-
- function isUtc () {
- return this._isUTC && this._offset === 0;
- }
-
- var aspNetRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
-
- // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
- // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
- 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)$/;
-
- function create__createDuration (input, key) {
- var duration = input,
- // matching against regexp is expensive, do it on demand
- match = null,
- sign,
- ret,
- diffRes;
-
- if (isDuration(input)) {
- duration = {
- ms : input._milliseconds,
- d : input._days,
- M : input._months
- };
- } else if (typeof input === 'number') {
- duration = {};
- if (key) {
- duration[key] = input;
- } else {
- duration.milliseconds = input;
- }
- } else if (!!(match = aspNetRegex.exec(input))) {
- sign = (match[1] === '-') ? -1 : 1;
- duration = {
- y : 0,
- d : toInt(match[DATE]) * sign,
- h : toInt(match[HOUR]) * sign,
- m : toInt(match[MINUTE]) * sign,
- s : toInt(match[SECOND]) * sign,
- ms : toInt(match[MILLISECOND]) * sign
- };
- } else if (!!(match = create__isoRegex.exec(input))) {
- sign = (match[1] === '-') ? -1 : 1;
- duration = {
- y : parseIso(match[2], sign),
- M : parseIso(match[3], sign),
- d : parseIso(match[4], sign),
- h : parseIso(match[5], sign),
- m : parseIso(match[6], sign),
- s : parseIso(match[7], sign),
- w : parseIso(match[8], sign)
- };
- } else if (duration == null) {// checks for null or undefined
- duration = {};
- } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
- diffRes = momentsDifference(local__createLocal(duration.from), local__createLocal(duration.to));
-
- duration = {};
- duration.ms = diffRes.milliseconds;
- duration.M = diffRes.months;
- }
-
- ret = new Duration(duration);
-
- if (isDuration(input) && hasOwnProp(input, '_locale')) {
- ret._locale = input._locale;
- }
-
- return ret;
- }
-
- create__createDuration.fn = Duration.prototype;
-
- function parseIso (inp, sign) {
- // We'd normally use ~~inp for this, but unfortunately it also
- // converts floats to ints.
- // inp may be undefined, so careful calling replace on it.
- var res = inp && parseFloat(inp.replace(',', '.'));
- // apply sign while we're at it
- return (isNaN(res) ? 0 : res) * sign;
- }
-
- function positiveMomentsDifference(base, other) {
- var res = {milliseconds: 0, months: 0};
-
- res.months = other.month() - base.month() +
- (other.year() - base.year()) * 12;
- if (base.clone().add(res.months, 'M').isAfter(other)) {
- --res.months;
- }
-
- res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
-
- return res;
- }
-
- function momentsDifference(base, other) {
- var res;
- other = cloneWithOffset(other, base);
- if (base.isBefore(other)) {
- res = positiveMomentsDifference(base, other);
- } else {
- res = positiveMomentsDifference(other, base);
- res.milliseconds = -res.milliseconds;
- res.months = -res.months;
- }
-
- return res;
- }
-
- function createAdder(direction, name) {
- return function (val, period) {
- var dur, tmp;
- //invert the arguments, but complain about it
- if (period !== null && !isNaN(+period)) {
- deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
- tmp = val; val = period; period = tmp;
- }
-
- val = typeof val === 'string' ? +val : val;
- dur = create__createDuration(val, period);
- add_subtract__addSubtract(this, dur, direction);
- return this;
- };
- }
-
- function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) {
- var milliseconds = duration._milliseconds,
- days = duration._days,
- months = duration._months;
- updateOffset = updateOffset == null ? true : updateOffset;
-
- if (milliseconds) {
- mom._d.setTime(+mom._d + milliseconds * isAdding);
- }
- if (days) {
- get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
- }
- if (months) {
- setMonth(mom, get_set__get(mom, 'Month') + months * isAdding);
- }
- if (updateOffset) {
- utils_hooks__hooks.updateOffset(mom, days || months);
- }
- }
-
- var add_subtract__add = createAdder(1, 'add');
- var add_subtract__subtract = createAdder(-1, 'subtract');
-
- function moment_calendar__calendar (time) {
- // We want to compare the start of today, vs this.
- // Getting start-of-today depends on whether we're local/utc/offset or not.
- var now = time || local__createLocal(),
- sod = cloneWithOffset(now, this).startOf('day'),
- diff = this.diff(sod, 'days', true),
- format = diff < -6 ? 'sameElse' :
- diff < -1 ? 'lastWeek' :
- diff < 0 ? 'lastDay' :
- diff < 1 ? 'sameDay' :
- diff < 2 ? 'nextDay' :
- diff < 7 ? 'nextWeek' : 'sameElse';
- return this.format(this.localeData().calendar(format, this, local__createLocal(now)));
- }
-
- function clone () {
- return new Moment(this);
- }
-
- function isAfter (input, units) {
- var inputMs;
- units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
- if (units === 'millisecond') {
- input = isMoment(input) ? input : local__createLocal(input);
- return +this > +input;
- } else {
- inputMs = isMoment(input) ? +input : +local__createLocal(input);
- return inputMs < +this.clone().startOf(units);
- }
- }
-
- function isBefore (input, units) {
- var inputMs;
- units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
- if (units === 'millisecond') {
- input = isMoment(input) ? input : local__createLocal(input);
- return +this < +input;
- } else {
- inputMs = isMoment(input) ? +input : +local__createLocal(input);
- return +this.clone().endOf(units) < inputMs;
- }
- }
-
- function isBetween (from, to, units) {
- return this.isAfter(from, units) && this.isBefore(to, units);
- }
-
- function isSame (input, units) {
- var inputMs;
- units = normalizeUnits(units || 'millisecond');
- if (units === 'millisecond') {
- input = isMoment(input) ? input : local__createLocal(input);
- return +this === +input;
- } else {
- inputMs = +local__createLocal(input);
- return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
- }
- }
-
- function absFloor (number) {
- if (number < 0) {
- return Math.ceil(number);
- } else {
- return Math.floor(number);
- }
- }
-
- function diff (input, units, asFloat) {
- var that = cloneWithOffset(input, this),
- zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4,
- delta, output;
-
- units = normalizeUnits(units);
-
- if (units === 'year' || units === 'month' || units === 'quarter') {
- output = monthDiff(this, that);
- if (units === 'quarter') {
- output = output / 3;
- } else if (units === 'year') {
- output = output / 12;
- }
- } else {
- delta = this - that;
- output = units === 'second' ? delta / 1e3 : // 1000
- units === 'minute' ? delta / 6e4 : // 1000 * 60
- units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
- units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
- units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
- delta;
- }
- return asFloat ? output : absFloor(output);
- }
-
- function monthDiff (a, b) {
- // difference in months
- var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
- // b is in (anchor - 1 month, anchor + 1 month)
- anchor = a.clone().add(wholeMonthDiff, 'months'),
- anchor2, adjust;
-
- if (b - anchor < 0) {
- anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
- // linear across the month
- adjust = (b - anchor) / (anchor - anchor2);
- } else {
- anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
- // linear across the month
- adjust = (b - anchor) / (anchor2 - anchor);
- }
-
- return -(wholeMonthDiff + adjust);
- }
-
- utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
-
- function toString () {
- return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
- }
-
- function moment_format__toISOString () {
- var m = this.clone().utc();
- if (0 < m.year() && m.year() <= 9999) {
- if ('function' === typeof Date.prototype.toISOString) {
- // native implementation is ~50x faster, use it when we can
- return this.toDate().toISOString();
- } else {
- return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
- }
- } else {
- return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
- }
- }
-
- function format (inputString) {
- var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
- return this.localeData().postformat(output);
- }
-
- function from (time, withoutSuffix) {
- if (!this.isValid()) {
- return this.localeData().invalidDate();
- }
- return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
- }
-
- function fromNow (withoutSuffix) {
- return this.from(local__createLocal(), withoutSuffix);
- }
-
- function to (time, withoutSuffix) {
- if (!this.isValid()) {
- return this.localeData().invalidDate();
- }
- return create__createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
- }
-
- function toNow (withoutSuffix) {
- return this.to(local__createLocal(), withoutSuffix);
- }
-
- function locale (key) {
- var newLocaleData;
-
- if (key === undefined) {
- return this._locale._abbr;
- } else {
- newLocaleData = locale_locales__getLocale(key);
- if (newLocaleData != null) {
- this._locale = newLocaleData;
- }
- return this;
- }
- }
-
- var lang = deprecate(
- 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
- function (key) {
- if (key === undefined) {
- return this.localeData();
- } else {
- return this.locale(key);
- }
- }
- );
-
- function localeData () {
- return this._locale;
- }
-
- function startOf (units) {
- units = normalizeUnits(units);
- // the following switch intentionally omits break keywords
- // to utilize falling through the cases.
- switch (units) {
- case 'year':
- this.month(0);
- /* falls through */
- case 'quarter':
- case 'month':
- this.date(1);
- /* falls through */
- case 'week':
- case 'isoWeek':
- case 'day':
- this.hours(0);
- /* falls through */
- case 'hour':
- this.minutes(0);
- /* falls through */
- case 'minute':
- this.seconds(0);
- /* falls through */
- case 'second':
- this.milliseconds(0);
- }
-
- // weeks are a special case
- if (units === 'week') {
- this.weekday(0);
- }
- if (units === 'isoWeek') {
- this.isoWeekday(1);
- }
-
- // quarters are also special
- if (units === 'quarter') {
- this.month(Math.floor(this.month() / 3) * 3);
- }
-
- return this;
- }
-
- function endOf (units) {
- units = normalizeUnits(units);
- if (units === undefined || units === 'millisecond') {
- return this;
- }
- return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
- }
-
- function to_type__valueOf () {
- return +this._d - ((this._offset || 0) * 60000);
- }
-
- function unix () {
- return Math.floor(+this / 1000);
- }
-
- function toDate () {
- return this._offset ? new Date(+this) : this._d;
- }
-
- function toArray () {
- var m = this;
- return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
- }
-
- function moment_valid__isValid () {
- return valid__isValid(this);
- }
-
- function parsingFlags () {
- return extend({}, getParsingFlags(this));
- }
-
- function invalidAt () {
- return getParsingFlags(this).overflow;
- }
-
- addFormatToken(0, ['gg', 2], 0, function () {
- return this.weekYear() % 100;
- });
-
- addFormatToken(0, ['GG', 2], 0, function () {
- return this.isoWeekYear() % 100;
- });
-
- function addWeekYearFormatToken (token, getter) {
- addFormatToken(0, [token, token.length], 0, getter);
- }
-
- addWeekYearFormatToken('gggg', 'weekYear');
- addWeekYearFormatToken('ggggg', 'weekYear');
- addWeekYearFormatToken('GGGG', 'isoWeekYear');
- addWeekYearFormatToken('GGGGG', 'isoWeekYear');
-
- // ALIASES
-
- addUnitAlias('weekYear', 'gg');
- addUnitAlias('isoWeekYear', 'GG');
-
- // PARSING
-
- addRegexToken('G', matchSigned);
- addRegexToken('g', matchSigned);
- addRegexToken('GG', match1to2, match2);
- addRegexToken('gg', match1to2, match2);
- addRegexToken('GGGG', match1to4, match4);
- addRegexToken('gggg', match1to4, match4);
- addRegexToken('GGGGG', match1to6, match6);
- addRegexToken('ggggg', match1to6, match6);
-
- addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
- week[token.substr(0, 2)] = toInt(input);
- });
-
- addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
- week[token] = utils_hooks__hooks.parseTwoDigitYear(input);
- });
-
- // HELPERS
-
- function weeksInYear(year, dow, doy) {
- return weekOfYear(local__createLocal([year, 11, 31 + dow - doy]), dow, doy).week;
- }
-
- // MOMENTS
-
- function getSetWeekYear (input) {
- var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
- return input == null ? year : this.add((input - year), 'y');
- }
-
- function getSetISOWeekYear (input) {
- var year = weekOfYear(this, 1, 4).year;
- return input == null ? year : this.add((input - year), 'y');
- }
-
- function getISOWeeksInYear () {
- return weeksInYear(this.year(), 1, 4);
- }
-
- function getWeeksInYear () {
- var weekInfo = this.localeData()._week;
- return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
- }
-
- addFormatToken('Q', 0, 0, 'quarter');
-
- // ALIASES
-
- addUnitAlias('quarter', 'Q');
-
- // PARSING
-
- addRegexToken('Q', match1);
- addParseToken('Q', function (input, array) {
- array[MONTH] = (toInt(input) - 1) * 3;
- });
-
- // MOMENTS
-
- function getSetQuarter (input) {
- return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
- }
-
- addFormatToken('D', ['DD', 2], 'Do', 'date');
-
- // ALIASES
-
- addUnitAlias('date', 'D');
-
- // PARSING
-
- addRegexToken('D', match1to2);
- addRegexToken('DD', match1to2, match2);
- addRegexToken('Do', function (isStrict, locale) {
- return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
- });
-
- addParseToken(['D', 'DD'], DATE);
- addParseToken('Do', function (input, array) {
- array[DATE] = toInt(input.match(match1to2)[0], 10);
- });
-
- // MOMENTS
-
- var getSetDayOfMonth = makeGetSet('Date', true);
-
- addFormatToken('d', 0, 'do', 'day');
-
- addFormatToken('dd', 0, 0, function (format) {
- return this.localeData().weekdaysMin(this, format);
- });
-
- addFormatToken('ddd', 0, 0, function (format) {
- return this.localeData().weekdaysShort(this, format);
- });
-
- addFormatToken('dddd', 0, 0, function (format) {
- return this.localeData().weekdays(this, format);
- });
-
- addFormatToken('e', 0, 0, 'weekday');
- addFormatToken('E', 0, 0, 'isoWeekday');
-
- // ALIASES
-
- addUnitAlias('day', 'd');
- addUnitAlias('weekday', 'e');
- addUnitAlias('isoWeekday', 'E');
-
- // PARSING
-
- addRegexToken('d', match1to2);
- addRegexToken('e', match1to2);
- addRegexToken('E', match1to2);
- addRegexToken('dd', matchWord);
- addRegexToken('ddd', matchWord);
- addRegexToken('dddd', matchWord);
-
- addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config) {
- var weekday = config._locale.weekdaysParse(input);
- // if we didn't get a weekday name, mark the date as invalid
- if (weekday != null) {
- week.d = weekday;
- } else {
- getParsingFlags(config).invalidWeekday = input;
- }
- });
-
- addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
- week[token] = toInt(input);
- });
-
- // HELPERS
-
- function parseWeekday(input, locale) {
- if (typeof input === 'string') {
- if (!isNaN(input)) {
- input = parseInt(input, 10);
- }
- else {
- input = locale.weekdaysParse(input);
- if (typeof input !== 'number') {
- return null;
- }
- }
- }
- return input;
- }
-
- // LOCALES
-
- var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
- function localeWeekdays (m) {
- return this._weekdays[m.day()];
- }
-
- var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
- function localeWeekdaysShort (m) {
- return this._weekdaysShort[m.day()];
- }
-
- var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
- function localeWeekdaysMin (m) {
- return this._weekdaysMin[m.day()];
- }
-
- function localeWeekdaysParse (weekdayName) {
- var i, mom, regex;
-
- if (!this._weekdaysParse) {
- this._weekdaysParse = [];
- }
-
- for (i = 0; i < 7; i++) {
- // make the regex if we don't have it already
- if (!this._weekdaysParse[i]) {
- mom = local__createLocal([2000, 1]).day(i);
- regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
- this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
- }
- // test the regex
- if (this._weekdaysParse[i].test(weekdayName)) {
- return i;
- }
- }
- }
-
- // MOMENTS
-
- function getSetDayOfWeek (input) {
- var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
- if (input != null) {
- input = parseWeekday(input, this.localeData());
- return this.add(input - day, 'd');
- } else {
- return day;
- }
- }
-
- function getSetLocaleDayOfWeek (input) {
- var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
- return input == null ? weekday : this.add(input - weekday, 'd');
- }
-
- function getSetISODayOfWeek (input) {
- // behaves the same as moment#day except
- // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
- // as a setter, sunday should belong to the previous week.
- return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
- }
-
- addFormatToken('H', ['HH', 2], 0, 'hour');
- addFormatToken('h', ['hh', 2], 0, function () {
- return this.hours() % 12 || 12;
- });
-
- function meridiem (token, lowercase) {
- addFormatToken(token, 0, 0, function () {
- return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
- });
- }
-
- meridiem('a', true);
- meridiem('A', false);
-
- // ALIASES
-
- addUnitAlias('hour', 'h');
-
- // PARSING
-
- function matchMeridiem (isStrict, locale) {
- return locale._meridiemParse;
- }
-
- addRegexToken('a', matchMeridiem);
- addRegexToken('A', matchMeridiem);
- addRegexToken('H', match1to2);
- addRegexToken('h', match1to2);
- addRegexToken('HH', match1to2, match2);
- addRegexToken('hh', match1to2, match2);
-
- addParseToken(['H', 'HH'], HOUR);
- addParseToken(['a', 'A'], function (input, array, config) {
- config._isPm = config._locale.isPM(input);
- config._meridiem = input;
- });
- addParseToken(['h', 'hh'], function (input, array, config) {
- array[HOUR] = toInt(input);
- getParsingFlags(config).bigHour = true;
- });
-
- // LOCALES
-
- function localeIsPM (input) {
- // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
- // Using charAt should be more compatible.
- return ((input + '').toLowerCase().charAt(0) === 'p');
- }
-
- var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
- function localeMeridiem (hours, minutes, isLower) {
- if (hours > 11) {
- return isLower ? 'pm' : 'PM';
- } else {
- return isLower ? 'am' : 'AM';
- }
- }
-
-
- // MOMENTS
-
- // Setting the hour should keep the time, because the user explicitly
- // specified which hour he wants. So trying to maintain the same hour (in
- // a new timezone) makes sense. Adding/subtracting hours does not follow
- // this rule.
- var getSetHour = makeGetSet('Hours', true);
-
- addFormatToken('m', ['mm', 2], 0, 'minute');
-
- // ALIASES
-
- addUnitAlias('minute', 'm');
-
- // PARSING
-
- addRegexToken('m', match1to2);
- addRegexToken('mm', match1to2, match2);
- addParseToken(['m', 'mm'], MINUTE);
-
- // MOMENTS
-
- var getSetMinute = makeGetSet('Minutes', false);
-
- addFormatToken('s', ['ss', 2], 0, 'second');
-
- // ALIASES
-
- addUnitAlias('second', 's');
-
- // PARSING
-
- addRegexToken('s', match1to2);
- addRegexToken('ss', match1to2, match2);
- addParseToken(['s', 'ss'], SECOND);
-
- // MOMENTS
-
- var getSetSecond = makeGetSet('Seconds', false);
-
- addFormatToken('S', 0, 0, function () {
- return ~~(this.millisecond() / 100);
- });
-
- addFormatToken(0, ['SS', 2], 0, function () {
- return ~~(this.millisecond() / 10);
- });
-
- function millisecond__milliseconds (token) {
- addFormatToken(0, [token, 3], 0, 'millisecond');
- }
-
- millisecond__milliseconds('SSS');
- millisecond__milliseconds('SSSS');
-
- // ALIASES
-
- addUnitAlias('millisecond', 'ms');
-
- // PARSING
-
- addRegexToken('S', match1to3, match1);
- addRegexToken('SS', match1to3, match2);
- addRegexToken('SSS', match1to3, match3);
- addRegexToken('SSSS', matchUnsigned);
- addParseToken(['S', 'SS', 'SSS', 'SSSS'], function (input, array) {
- array[MILLISECOND] = toInt(('0.' + input) * 1000);
- });
-
- // MOMENTS
-
- var getSetMillisecond = makeGetSet('Milliseconds', false);
-
- addFormatToken('z', 0, 0, 'zoneAbbr');
- addFormatToken('zz', 0, 0, 'zoneName');
-
- // MOMENTS
-
- function getZoneAbbr () {
- return this._isUTC ? 'UTC' : '';
- }
-
- function getZoneName () {
- return this._isUTC ? 'Coordinated Universal Time' : '';
- }
-
- var momentPrototype__proto = Moment.prototype;
-
- momentPrototype__proto.add = add_subtract__add;
- momentPrototype__proto.calendar = moment_calendar__calendar;
- momentPrototype__proto.clone = clone;
- momentPrototype__proto.diff = diff;
- momentPrototype__proto.endOf = endOf;
- momentPrototype__proto.format = format;
- momentPrototype__proto.from = from;
- momentPrototype__proto.fromNow = fromNow;
- momentPrototype__proto.to = to;
- momentPrototype__proto.toNow = toNow;
- momentPrototype__proto.get = getSet;
- momentPrototype__proto.invalidAt = invalidAt;
- momentPrototype__proto.isAfter = isAfter;
- momentPrototype__proto.isBefore = isBefore;
- momentPrototype__proto.isBetween = isBetween;
- momentPrototype__proto.isSame = isSame;
- momentPrototype__proto.isValid = moment_valid__isValid;
- momentPrototype__proto.lang = lang;
- momentPrototype__proto.locale = locale;
- momentPrototype__proto.localeData = localeData;
- momentPrototype__proto.max = prototypeMax;
- momentPrototype__proto.min = prototypeMin;
- momentPrototype__proto.parsingFlags = parsingFlags;
- momentPrototype__proto.set = getSet;
- momentPrototype__proto.startOf = startOf;
- momentPrototype__proto.subtract = add_subtract__subtract;
- momentPrototype__proto.toArray = toArray;
- momentPrototype__proto.toDate = toDate;
- momentPrototype__proto.toISOString = moment_format__toISOString;
- momentPrototype__proto.toJSON = moment_format__toISOString;
- momentPrototype__proto.toString = toString;
- momentPrototype__proto.unix = unix;
- momentPrototype__proto.valueOf = to_type__valueOf;
-
- // Year
- momentPrototype__proto.year = getSetYear;
- momentPrototype__proto.isLeapYear = getIsLeapYear;
-
- // Week Year
- momentPrototype__proto.weekYear = getSetWeekYear;
- momentPrototype__proto.isoWeekYear = getSetISOWeekYear;
-
- // Quarter
- momentPrototype__proto.quarter = momentPrototype__proto.quarters = getSetQuarter;
-
- // Month
- momentPrototype__proto.month = getSetMonth;
- momentPrototype__proto.daysInMonth = getDaysInMonth;
-
- // Week
- momentPrototype__proto.week = momentPrototype__proto.weeks = getSetWeek;
- momentPrototype__proto.isoWeek = momentPrototype__proto.isoWeeks = getSetISOWeek;
- momentPrototype__proto.weeksInYear = getWeeksInYear;
- momentPrototype__proto.isoWeeksInYear = getISOWeeksInYear;
-
- // Day
- momentPrototype__proto.date = getSetDayOfMonth;
- momentPrototype__proto.day = momentPrototype__proto.days = getSetDayOfWeek;
- momentPrototype__proto.weekday = getSetLocaleDayOfWeek;
- momentPrototype__proto.isoWeekday = getSetISODayOfWeek;
- momentPrototype__proto.dayOfYear = getSetDayOfYear;
-
- // Hour
- momentPrototype__proto.hour = momentPrototype__proto.hours = getSetHour;
-
- // Minute
- momentPrototype__proto.minute = momentPrototype__proto.minutes = getSetMinute;
-
- // Second
- momentPrototype__proto.second = momentPrototype__proto.seconds = getSetSecond;
-
- // Millisecond
- momentPrototype__proto.millisecond = momentPrototype__proto.milliseconds = getSetMillisecond;
-
- // Offset
- momentPrototype__proto.utcOffset = getSetOffset;
- momentPrototype__proto.utc = setOffsetToUTC;
- momentPrototype__proto.local = setOffsetToLocal;
- momentPrototype__proto.parseZone = setOffsetToParsedOffset;
- momentPrototype__proto.hasAlignedHourOffset = hasAlignedHourOffset;
- momentPrototype__proto.isDST = isDaylightSavingTime;
- momentPrototype__proto.isDSTShifted = isDaylightSavingTimeShifted;
- momentPrototype__proto.isLocal = isLocal;
- momentPrototype__proto.isUtcOffset = isUtcOffset;
- momentPrototype__proto.isUtc = isUtc;
- momentPrototype__proto.isUTC = isUtc;
-
- // Timezone
- momentPrototype__proto.zoneAbbr = getZoneAbbr;
- momentPrototype__proto.zoneName = getZoneName;
-
- // Deprecations
- momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
- momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
- momentPrototype__proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
- momentPrototype__proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779', getSetZone);
-
- var momentPrototype = momentPrototype__proto;
-
- function moment__createUnix (input) {
- return local__createLocal(input * 1000);
- }
-
- function moment__createInZone () {
- return local__createLocal.apply(null, arguments).parseZone();
- }
-
- var defaultCalendar = {
- sameDay : '[Today at] LT',
- nextDay : '[Tomorrow at] LT',
- nextWeek : 'dddd [at] LT',
- lastDay : '[Yesterday at] LT',
- lastWeek : '[Last] dddd [at] LT',
- sameElse : 'L'
- };
-
- function locale_calendar__calendar (key, mom, now) {
- var output = this._calendar[key];
- return typeof output === 'function' ? output.call(mom, now) : output;
- }
-
- var defaultLongDateFormat = {
- LTS : 'h:mm:ss A',
- LT : 'h:mm A',
- L : 'MM/DD/YYYY',
- LL : 'MMMM D, YYYY',
- LLL : 'MMMM D, YYYY LT',
- LLLL : 'dddd, MMMM D, YYYY LT'
- };
-
- function longDateFormat (key) {
- var output = this._longDateFormat[key];
- if (!output && this._longDateFormat[key.toUpperCase()]) {
- output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) {
- return val.slice(1);
- });
- this._longDateFormat[key] = output;
- }
- return output;
- }
-
- var defaultInvalidDate = 'Invalid date';
-
- function invalidDate () {
- return this._invalidDate;
- }
-
- var defaultOrdinal = '%d';
- var defaultOrdinalParse = /\d{1,2}/;
-
- function ordinal (number) {
- return this._ordinal.replace('%d', number);
- }
-
- function preParsePostFormat (string) {
- return string;
- }
-
- var defaultRelativeTime = {
- future : 'in %s',
- past : '%s ago',
- s : 'a few seconds',
- m : 'a minute',
- mm : '%d minutes',
- h : 'an hour',
- hh : '%d hours',
- d : 'a day',
- dd : '%d days',
- M : 'a month',
- MM : '%d months',
- y : 'a year',
- yy : '%d years'
- };
-
- function relative__relativeTime (number, withoutSuffix, string, isFuture) {
- var output = this._relativeTime[string];
- return (typeof output === 'function') ?
- output(number, withoutSuffix, string, isFuture) :
- output.replace(/%d/i, number);
- }
-
- function pastFuture (diff, output) {
- var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
- return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
- }
-
- function locale_set__set (config) {
- var prop, i;
- for (i in config) {
- prop = config[i];
- if (typeof prop === 'function') {
- this[i] = prop;
- } else {
- this['_' + i] = prop;
- }
- }
- // Lenient ordinal parsing accepts just a number in addition to
- // number + (possibly) stuff coming from _ordinalParseLenient.
- this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
- }
-
- var prototype__proto = Locale.prototype;
-
- prototype__proto._calendar = defaultCalendar;
- prototype__proto.calendar = locale_calendar__calendar;
- prototype__proto._longDateFormat = defaultLongDateFormat;
- prototype__proto.longDateFormat = longDateFormat;
- prototype__proto._invalidDate = defaultInvalidDate;
- prototype__proto.invalidDate = invalidDate;
- prototype__proto._ordinal = defaultOrdinal;
- prototype__proto.ordinal = ordinal;
- prototype__proto._ordinalParse = defaultOrdinalParse;
- prototype__proto.preparse = preParsePostFormat;
- prototype__proto.postformat = preParsePostFormat;
- prototype__proto._relativeTime = defaultRelativeTime;
- prototype__proto.relativeTime = relative__relativeTime;
- prototype__proto.pastFuture = pastFuture;
- prototype__proto.set = locale_set__set;
-
- // Month
- prototype__proto.months = localeMonths;
- prototype__proto._months = defaultLocaleMonths;
- prototype__proto.monthsShort = localeMonthsShort;
- prototype__proto._monthsShort = defaultLocaleMonthsShort;
- prototype__proto.monthsParse = localeMonthsParse;
-
- // Week
- prototype__proto.week = localeWeek;
- prototype__proto._week = defaultLocaleWeek;
- prototype__proto.firstDayOfYear = localeFirstDayOfYear;
- prototype__proto.firstDayOfWeek = localeFirstDayOfWeek;
-
- // Day of Week
- prototype__proto.weekdays = localeWeekdays;
- prototype__proto._weekdays = defaultLocaleWeekdays;
- prototype__proto.weekdaysMin = localeWeekdaysMin;
- prototype__proto._weekdaysMin = defaultLocaleWeekdaysMin;
- prototype__proto.weekdaysShort = localeWeekdaysShort;
- prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
- prototype__proto.weekdaysParse = localeWeekdaysParse;
-
- // Hours
- prototype__proto.isPM = localeIsPM;
- prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
- prototype__proto.meridiem = localeMeridiem;
-
- function lists__get (format, index, field, setter) {
- var locale = locale_locales__getLocale();
- var utc = create_utc__createUTC().set(setter, index);
- return locale[field](utc, format);
- }
-
- function list (format, index, field, count, setter) {
- if (typeof format === 'number') {
- index = format;
- format = undefined;
- }
-
- format = format || '';
-
- if (index != null) {
- return lists__get(format, index, field, setter);
- }
-
- var i;
- var out = [];
- for (i = 0; i < count; i++) {
- out[i] = lists__get(format, i, field, setter);
- }
- return out;
- }
-
- function lists__listMonths (format, index) {
- return list(format, index, 'months', 12, 'month');
- }
-
- function lists__listMonthsShort (format, index) {
- return list(format, index, 'monthsShort', 12, 'month');
- }
-
- function lists__listWeekdays (format, index) {
- return list(format, index, 'weekdays', 7, 'day');
- }
-
- function lists__listWeekdaysShort (format, index) {
- return list(format, index, 'weekdaysShort', 7, 'day');
- }
-
- function lists__listWeekdaysMin (format, index) {
- return list(format, index, 'weekdaysMin', 7, 'day');
- }
-
- locale_locales__getSetGlobalLocale('en', {
- ordinalParse: /\d{1,2}(th|st|nd|rd)/,
- ordinal : function (number) {
- var b = number % 10,
- output = (toInt(number % 100 / 10) === 1) ? 'th' :
- (b === 1) ? 'st' :
- (b === 2) ? 'nd' :
- (b === 3) ? 'rd' : 'th';
- return number + output;
- }
- });
-
- // Side effect imports
- utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale);
- utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale);
-
- var mathAbs = Math.abs;
-
- function duration_abs__abs () {
- var data = this._data;
-
- this._milliseconds = mathAbs(this._milliseconds);
- this._days = mathAbs(this._days);
- this._months = mathAbs(this._months);
-
- data.milliseconds = mathAbs(data.milliseconds);
- data.seconds = mathAbs(data.seconds);
- data.minutes = mathAbs(data.minutes);
- data.hours = mathAbs(data.hours);
- data.months = mathAbs(data.months);
- data.years = mathAbs(data.years);
-
- return this;
- }
-
- function duration_add_subtract__addSubtract (duration, input, value, direction) {
- var other = create__createDuration(input, value);
-
- duration._milliseconds += direction * other._milliseconds;
- duration._days += direction * other._days;
- duration._months += direction * other._months;
-
- return duration._bubble();
- }
-
- // supports only 2.0-style add(1, 's') or add(duration)
- function duration_add_subtract__add (input, value) {
- return duration_add_subtract__addSubtract(this, input, value, 1);
- }
-
- // supports only 2.0-style subtract(1, 's') or subtract(duration)
- function duration_add_subtract__subtract (input, value) {
- return duration_add_subtract__addSubtract(this, input, value, -1);
- }
-
- function bubble () {
- var milliseconds = this._milliseconds;
- var days = this._days;
- var months = this._months;
- var data = this._data;
- var seconds, minutes, hours, years = 0;
-
- // The following code bubbles up values, see the tests for
- // examples of what that means.
- data.milliseconds = milliseconds % 1000;
-
- seconds = absFloor(milliseconds / 1000);
- data.seconds = seconds % 60;
-
- minutes = absFloor(seconds / 60);
- data.minutes = minutes % 60;
-
- hours = absFloor(minutes / 60);
- data.hours = hours % 24;
-
- days += absFloor(hours / 24);
-
- // Accurately convert days to years, assume start from year 0.
- years = absFloor(daysToYears(days));
- days -= absFloor(yearsToDays(years));
-
- // 30 days to a month
- // TODO (iskren): Use anchor date (like 1st Jan) to compute this.
- months += absFloor(days / 30);
- days %= 30;
-
- // 12 months -> 1 year
- years += absFloor(months / 12);
- months %= 12;
-
- data.days = days;
- data.months = months;
- data.years = years;
-
- return this;
- }
-
- function daysToYears (days) {
- // 400 years have 146097 days (taking into account leap year rules)
- return days * 400 / 146097;
- }
-
- function yearsToDays (years) {
- // years * 365 + absFloor(years / 4) -
- // absFloor(years / 100) + absFloor(years / 400);
- return years * 146097 / 400;
- }
-
- function as (units) {
- var days;
- var months;
- var milliseconds = this._milliseconds;
-
- units = normalizeUnits(units);
-
- if (units === 'month' || units === 'year') {
- days = this._days + milliseconds / 864e5;
- months = this._months + daysToYears(days) * 12;
- return units === 'month' ? months : months / 12;
- } else {
- // handle milliseconds separately because of floating point math errors (issue #1867)
- days = this._days + Math.round(yearsToDays(this._months / 12));
- switch (units) {
- case 'week' : return days / 7 + milliseconds / 6048e5;
- case 'day' : return days + milliseconds / 864e5;
- case 'hour' : return days * 24 + milliseconds / 36e5;
- case 'minute' : return days * 1440 + milliseconds / 6e4;
- case 'second' : return days * 86400 + milliseconds / 1000;
- // Math.floor prevents floating point math errors here
- case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
- default: throw new Error('Unknown unit ' + units);
- }
- }
- }
-
- // TODO: Use this.as('ms')?
- function duration_as__valueOf () {
- return (
- this._milliseconds +
- this._days * 864e5 +
- (this._months % 12) * 2592e6 +
- toInt(this._months / 12) * 31536e6
- );
- }
-
- function makeAs (alias) {
- return function () {
- return this.as(alias);
- };
- }
-
- var asMilliseconds = makeAs('ms');
- var asSeconds = makeAs('s');
- var asMinutes = makeAs('m');
- var asHours = makeAs('h');
- var asDays = makeAs('d');
- var asWeeks = makeAs('w');
- var asMonths = makeAs('M');
- var asYears = makeAs('y');
-
- function duration_get__get (units) {
- units = normalizeUnits(units);
- return this[units + 's']();
- }
-
- function makeGetter(name) {
- return function () {
- return this._data[name];
- };
- }
-
- var duration_get__milliseconds = makeGetter('milliseconds');
- var seconds = makeGetter('seconds');
- var minutes = makeGetter('minutes');
- var hours = makeGetter('hours');
- var days = makeGetter('days');
- var months = makeGetter('months');
- var years = makeGetter('years');
-
- function weeks () {
- return absFloor(this.days() / 7);
- }
-
- var round = Math.round;
- var thresholds = {
- s: 45, // seconds to minute
- m: 45, // minutes to hour
- h: 22, // hours to day
- d: 26, // days to month
- M: 11 // months to year
- };
-
- // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
- function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
- return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
- }
-
- function duration_humanize__relativeTime (posNegDuration, withoutSuffix, locale) {
- var duration = create__createDuration(posNegDuration).abs();
- var seconds = round(duration.as('s'));
- var minutes = round(duration.as('m'));
- var hours = round(duration.as('h'));
- var days = round(duration.as('d'));
- var months = round(duration.as('M'));
- var years = round(duration.as('y'));
-
- var a = seconds < thresholds.s && ['s', seconds] ||
- minutes === 1 && ['m'] ||
- minutes < thresholds.m && ['mm', minutes] ||
- hours === 1 && ['h'] ||
- hours < thresholds.h && ['hh', hours] ||
- days === 1 && ['d'] ||
- days < thresholds.d && ['dd', days] ||
- months === 1 && ['M'] ||
- months < thresholds.M && ['MM', months] ||
- years === 1 && ['y'] || ['yy', years];
-
- a[2] = withoutSuffix;
- a[3] = +posNegDuration > 0;
- a[4] = locale;
- return substituteTimeAgo.apply(null, a);
- }
-
- // This function allows you to set a threshold for relative time strings
- function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {
- if (thresholds[threshold] === undefined) {
- return false;
- }
- if (limit === undefined) {
- return thresholds[threshold];
- }
- thresholds[threshold] = limit;
- return true;
- }
-
- function humanize (withSuffix) {
- var locale = this.localeData();
- var output = duration_humanize__relativeTime(this, !withSuffix, locale);
-
- if (withSuffix) {
- output = locale.pastFuture(+this, output);
- }
-
- return locale.postformat(output);
- }
-
- var iso_string__abs = Math.abs;
-
- function iso_string__toISOString() {
- // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
- var Y = iso_string__abs(this.years());
- var M = iso_string__abs(this.months());
- var D = iso_string__abs(this.days());
- var h = iso_string__abs(this.hours());
- var m = iso_string__abs(this.minutes());
- var s = iso_string__abs(this.seconds() + this.milliseconds() / 1000);
- var total = this.asSeconds();
-
- if (!total) {
- // this is the same as C#'s (Noda) and python (isodate)...
- // but not other JS (goog.date)
- return 'P0D';
- }
-
- return (total < 0 ? '-' : '') +
- 'P' +
- (Y ? Y + 'Y' : '') +
- (M ? M + 'M' : '') +
- (D ? D + 'D' : '') +
- ((h || m || s) ? 'T' : '') +
- (h ? h + 'H' : '') +
- (m ? m + 'M' : '') +
- (s ? s + 'S' : '');
- }
-
- var duration_prototype__proto = Duration.prototype;
-
- duration_prototype__proto.abs = duration_abs__abs;
- duration_prototype__proto.add = duration_add_subtract__add;
- duration_prototype__proto.subtract = duration_add_subtract__subtract;
- duration_prototype__proto.as = as;
- duration_prototype__proto.asMilliseconds = asMilliseconds;
- duration_prototype__proto.asSeconds = asSeconds;
- duration_prototype__proto.asMinutes = asMinutes;
- duration_prototype__proto.asHours = asHours;
- duration_prototype__proto.asDays = asDays;
- duration_prototype__proto.asWeeks = asWeeks;
- duration_prototype__proto.asMonths = asMonths;
- duration_prototype__proto.asYears = asYears;
- duration_prototype__proto.valueOf = duration_as__valueOf;
- duration_prototype__proto._bubble = bubble;
- duration_prototype__proto.get = duration_get__get;
- duration_prototype__proto.milliseconds = duration_get__milliseconds;
- duration_prototype__proto.seconds = seconds;
- duration_prototype__proto.minutes = minutes;
- duration_prototype__proto.hours = hours;
- duration_prototype__proto.days = days;
- duration_prototype__proto.weeks = weeks;
- duration_prototype__proto.months = months;
- duration_prototype__proto.years = years;
- duration_prototype__proto.humanize = humanize;
- duration_prototype__proto.toISOString = iso_string__toISOString;
- duration_prototype__proto.toString = iso_string__toISOString;
- duration_prototype__proto.toJSON = iso_string__toISOString;
- duration_prototype__proto.locale = locale;
- duration_prototype__proto.localeData = localeData;
-
- // Deprecations
- duration_prototype__proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', iso_string__toISOString);
- duration_prototype__proto.lang = lang;
-
- // Side effect imports
-
- addFormatToken('X', 0, 0, 'unix');
- addFormatToken('x', 0, 0, 'valueOf');
-
- // PARSING
-
- addRegexToken('x', matchSigned);
- addRegexToken('X', matchTimestamp);
- addParseToken('X', function (input, array, config) {
- config._d = new Date(parseFloat(input, 10) * 1000);
- });
- addParseToken('x', function (input, array, config) {
- config._d = new Date(toInt(input));
- });
-
- // Side effect imports
-
-
- utils_hooks__hooks.version = '2.10.3';
-
- setHookCallback(local__createLocal);
-
- utils_hooks__hooks.fn = momentPrototype;
- utils_hooks__hooks.min = min;
- utils_hooks__hooks.max = max;
- utils_hooks__hooks.utc = create_utc__createUTC;
- utils_hooks__hooks.unix = moment__createUnix;
- utils_hooks__hooks.months = lists__listMonths;
- utils_hooks__hooks.isDate = isDate;
- utils_hooks__hooks.locale = locale_locales__getSetGlobalLocale;
- utils_hooks__hooks.invalid = valid__createInvalid;
- utils_hooks__hooks.duration = create__createDuration;
- utils_hooks__hooks.isMoment = isMoment;
- utils_hooks__hooks.weekdays = lists__listWeekdays;
- utils_hooks__hooks.parseZone = moment__createInZone;
- utils_hooks__hooks.localeData = locale_locales__getLocale;
- utils_hooks__hooks.isDuration = isDuration;
- utils_hooks__hooks.monthsShort = lists__listMonthsShort;
- utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
- utils_hooks__hooks.defineLocale = defineLocale;
- utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
- utils_hooks__hooks.normalizeUnits = normalizeUnits;
- utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
-
- var _moment = utils_hooks__hooks;
-
- return _moment;
-
- }));
- },{}],"numeral":[function(require,module,exports){
- "use strict";
- (function() {
- var numeral,
- VERSION = '1.5.3',
- languages = {},
- currentLanguage = 'en',
- zeroFormat = null,
- defaultFormat = '0,0',
- hasModule = (typeof module !== 'undefined' && module.exports);
- function Numeral(number) {
- this._value = number;
- }
- function toFixed(value, precision, roundingFunction, optionals) {
- var power = Math.pow(10, precision),
- optionalsRegExp,
- output;
- output = (roundingFunction(value * power) / power).toFixed(precision);
- if (optionals) {
- optionalsRegExp = new RegExp('0{1,' + optionals + '}$');
- output = output.replace(optionalsRegExp, '');
- }
- return output;
- }
- function formatNumeral(n, format, roundingFunction) {
- var output;
- if (format.indexOf('$') > -1) {
- output = formatCurrency(n, format, roundingFunction);
- } else if (format.indexOf('%') > -1) {
- output = formatPercentage(n, format, roundingFunction);
- } else if (format.indexOf(':') > -1) {
- output = formatTime(n, format);
- } else {
- output = formatNumber(n._value, format, roundingFunction);
- }
- return output;
- }
- function unformatNumeral(n, string) {
- var stringOriginal = string,
- thousandRegExp,
- millionRegExp,
- billionRegExp,
- trillionRegExp,
- suffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
- bytesMultiplier = false,
- power;
- if (string.indexOf(':') > -1) {
- n._value = unformatTime(string);
- } else {
- if (string === zeroFormat) {
- n._value = 0;
- } else {
- if (languages[currentLanguage].delimiters.decimal !== '.') {
- string = string.replace(/\./g, '').replace(languages[currentLanguage].delimiters.decimal, '.');
- }
- thousandRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.thousand + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
- millionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.million + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
- billionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.billion + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
- trillionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
- for (power = 0; power <= suffixes.length; power++) {
- bytesMultiplier = (string.indexOf(suffixes[power]) > -1) ? Math.pow(1024, power + 1) : false;
- if (bytesMultiplier) {
- break;
- }
- }
- 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, ''));
- n._value = (bytesMultiplier) ? Math.ceil(n._value) : n._value;
- }
- }
- return n._value;
- }
- function formatCurrency(n, format, roundingFunction) {
- var symbolIndex = format.indexOf('$'),
- openParenIndex = format.indexOf('('),
- minusSignIndex = format.indexOf('-'),
- space = '',
- spliceIndex,
- output;
- if (format.indexOf(' $') > -1) {
- space = ' ';
- format = format.replace(' $', '');
- } else if (format.indexOf('$ ') > -1) {
- space = ' ';
- format = format.replace('$ ', '');
- } else {
- format = format.replace('$', '');
- }
- output = formatNumber(n._value, format, roundingFunction);
- if (symbolIndex <= 1) {
- if (output.indexOf('(') > -1 || output.indexOf('-') > -1) {
- output = output.split('');
- spliceIndex = 1;
- if (symbolIndex < openParenIndex || symbolIndex < minusSignIndex) {
- spliceIndex = 0;
- }
- output.splice(spliceIndex, 0, languages[currentLanguage].currency.symbol + space);
- output = output.join('');
- } else {
- output = languages[currentLanguage].currency.symbol + space + output;
- }
- } else {
- if (output.indexOf(')') > -1) {
- output = output.split('');
- output.splice(-1, 0, space + languages[currentLanguage].currency.symbol);
- output = output.join('');
- } else {
- output = output + space + languages[currentLanguage].currency.symbol;
- }
- }
- return output;
- }
- function formatPercentage(n, format, roundingFunction) {
- var space = '',
- output,
- value = n._value * 100;
- if (format.indexOf(' %') > -1) {
- space = ' ';
- format = format.replace(' %', '');
- } else {
- format = format.replace('%', '');
- }
- output = formatNumber(value, format, roundingFunction);
- if (output.indexOf(')') > -1) {
- output = output.split('');
- output.splice(-1, 0, space + '%');
- output = output.join('');
- } else {
- output = output + space + '%';
- }
- return output;
- }
- function formatTime(n) {
- var hours = Math.floor(n._value / 60 / 60),
- minutes = Math.floor((n._value - (hours * 60 * 60)) / 60),
- seconds = Math.round(n._value - (hours * 60 * 60) - (minutes * 60));
- return hours + ':' + ((minutes < 10) ? '0' + minutes : minutes) + ':' + ((seconds < 10) ? '0' + seconds : seconds);
- }
- function unformatTime(string) {
- var timeArray = string.split(':'),
- seconds = 0;
- if (timeArray.length === 3) {
- seconds = seconds + (Number(timeArray[0]) * 60 * 60);
- seconds = seconds + (Number(timeArray[1]) * 60);
- seconds = seconds + Number(timeArray[2]);
- } else if (timeArray.length === 2) {
- seconds = seconds + (Number(timeArray[0]) * 60);
- seconds = seconds + Number(timeArray[1]);
- }
- return Number(seconds);
- }
- function formatNumber(value, format, roundingFunction) {
- var negP = false,
- signed = false,
- optDec = false,
- abbr = '',
- abbrK = false,
- abbrM = false,
- abbrB = false,
- abbrT = false,
- abbrForce = false,
- bytes = '',
- ord = '',
- abs = Math.abs(value),
- suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
- min,
- max,
- power,
- w,
- precision,
- thousands,
- d = '',
- neg = false;
- if (value === 0 && zeroFormat !== null) {
- return zeroFormat;
- } else {
- if (format.indexOf('(') > -1) {
- negP = true;
- format = format.slice(1, -1);
- } else if (format.indexOf('+') > -1) {
- signed = true;
- format = format.replace(/\+/g, '');
- }
- if (format.indexOf('a') > -1) {
- abbrK = format.indexOf('aK') >= 0;
- abbrM = format.indexOf('aM') >= 0;
- abbrB = format.indexOf('aB') >= 0;
- abbrT = format.indexOf('aT') >= 0;
- abbrForce = abbrK || abbrM || abbrB || abbrT;
- if (format.indexOf(' a') > -1) {
- abbr = ' ';
- format = format.replace(' a', '');
- } else {
- format = format.replace('a', '');
- }
- if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) {
- abbr = abbr + languages[currentLanguage].abbreviations.trillion;
- value = value / Math.pow(10, 12);
- } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) {
- abbr = abbr + languages[currentLanguage].abbreviations.billion;
- value = value / Math.pow(10, 9);
- } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) {
- abbr = abbr + languages[currentLanguage].abbreviations.million;
- value = value / Math.pow(10, 6);
- } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) {
- abbr = abbr + languages[currentLanguage].abbreviations.thousand;
- value = value / Math.pow(10, 3);
- }
- }
- if (format.indexOf('b') > -1) {
- if (format.indexOf(' b') > -1) {
- bytes = ' ';
- format = format.replace(' b', '');
- } else {
- format = format.replace('b', '');
- }
- for (power = 0; power <= suffixes.length; power++) {
- min = Math.pow(1024, power);
- max = Math.pow(1024, power + 1);
- if (value >= min && value < max) {
- bytes = bytes + suffixes[power];
- if (min > 0) {
- value = value / min;
- }
- break;
- }
- }
- }
- if (format.indexOf('o') > -1) {
- if (format.indexOf(' o') > -1) {
- ord = ' ';
- format = format.replace(' o', '');
- } else {
- format = format.replace('o', '');
- }
- ord = ord + languages[currentLanguage].ordinal(value);
- }
- if (format.indexOf('[.]') > -1) {
- optDec = true;
- format = format.replace('[.]', '.');
- }
- w = value.toString().split('.')[0];
- precision = format.split('.')[1];
- thousands = format.indexOf(',');
- if (precision) {
- if (precision.indexOf('[') > -1) {
- precision = precision.replace(']', '');
- precision = precision.split('[');
- d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length);
- } else {
- d = toFixed(value, precision.length, roundingFunction);
- }
- w = d.split('.')[0];
- if (d.split('.')[1].length) {
- d = languages[currentLanguage].delimiters.decimal + d.split('.')[1];
- } else {
- d = '';
- }
- if (optDec && Number(d.slice(1)) === 0) {
- d = '';
- }
- } else {
- w = toFixed(value, null, roundingFunction);
- }
- if (w.indexOf('-') > -1) {
- w = w.slice(1);
- neg = true;
- }
- if (thousands > -1) {
- w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + languages[currentLanguage].delimiters.thousands);
- }
- if (format.indexOf('.') === 0) {
- w = '';
- }
- return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((ord) ? ord : '') + ((abbr) ? abbr : '') + ((bytes) ? bytes : '') + ((negP && neg) ? ')' : '');
- }
- }
- numeral = function(input) {
- if (numeral.isNumeral(input)) {
- input = input.value();
- } else if (input === 0 || typeof input === 'undefined') {
- input = 0;
- } else if (!Number(input)) {
- input = numeral.fn.unformat(input);
- }
- return new Numeral(Number(input));
- };
- numeral.version = VERSION;
- numeral.isNumeral = function(obj) {
- return obj instanceof Numeral;
- };
- numeral.language = function(key, values) {
- if (!key) {
- return currentLanguage;
- }
- if (key && !values) {
- if (!languages[key]) {
- throw new Error('Unknown language : ' + key);
- }
- currentLanguage = key;
- }
- if (values || !languages[key]) {
- loadLanguage(key, values);
- }
- return numeral;
- };
- numeral.languageData = function(key) {
- if (!key) {
- return languages[currentLanguage];
- }
- if (!languages[key]) {
- throw new Error('Unknown language : ' + key);
- }
- return languages[key];
- };
- numeral.language('en', {
- delimiters: {
- thousands: ',',
- decimal: '.'
- },
- abbreviations: {
- thousand: 'k',
- million: 'm',
- billion: 'b',
- trillion: 't'
- },
- ordinal: function(number) {
- var b = number % 10;
- return (~~(number % 100 / 10) === 1) ? 'th' : (b === 1) ? 'st' : (b === 2) ? 'nd' : (b === 3) ? 'rd' : 'th';
- },
- currency: {symbol: '$'}
- });
- numeral.zeroFormat = function(format) {
- zeroFormat = typeof(format) === 'string' ? format : null;
- };
- numeral.defaultFormat = function(format) {
- defaultFormat = typeof(format) === 'string' ? format : '0.0';
- };
- numeral.validate = function(val, culture) {
- var _decimalSep,
- _thousandSep,
- _currSymbol,
- _valArray,
- _abbrObj,
- _thousandRegEx,
- languageData,
- temp;
- if (typeof val !== 'string') {
- val += '';
- if (console.warn) {
- console.warn('Numeral.js: Value is not string. It has been co-erced to: ', val);
- }
- }
- val = val.trim();
- if (val === '') {
- return false;
- }
- val = val.replace(/^[+-]?/, '');
- try {
- languageData = numeral.languageData(culture);
- } catch (e) {
- languageData = numeral.languageData(numeral.language());
- }
- _currSymbol = languageData.currency.symbol;
- _abbrObj = languageData.abbreviations;
- _decimalSep = languageData.delimiters.decimal;
- if (languageData.delimiters.thousands === '.') {
- _thousandSep = '\\.';
- } else {
- _thousandSep = languageData.delimiters.thousands;
- }
- temp = val.match(/^[^\d\.\,]+/);
- if (temp !== null) {
- val = val.substr(1);
- if (temp[0] !== _currSymbol) {
- return false;
- }
- }
- temp = val.match(/[^\d]+$/);
- if (temp !== null) {
- val = val.slice(0, -1);
- if (temp[0] !== _abbrObj.thousand && temp[0] !== _abbrObj.million && temp[0] !== _abbrObj.billion && temp[0] !== _abbrObj.trillion) {
- return false;
- }
- }
- if (!!val.match(/^\d+$/)) {
- return true;
- }
- _thousandRegEx = new RegExp(_thousandSep + '{2}');
- if (!val.match(/[^\d.,]/g)) {
- _valArray = val.split(_decimalSep);
- if (_valArray.length > 2) {
- return false;
- } else {
- if (_valArray.length < 2) {
- return (!!_valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx));
- } else {
- if (_valArray[0] === '') {
- return (!_valArray[0].match(_thousandRegEx) && !!_valArray[1].match(/^\d+$/));
- } else if (_valArray[0].length === 1) {
- return (!!_valArray[0].match(/^\d+$/) && !_valArray[0].match(_thousandRegEx) && !!_valArray[1].match(/^\d+$/));
- } else {
- return (!!_valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx) && !!_valArray[1].match(/^\d+$/));
- }
- }
- }
- }
- return false;
- };
- function loadLanguage(key, values) {
- languages[key] = values;
- }
- if ('function' !== typeof Array.prototype.reduce) {
- Array.prototype.reduce = function(callback, opt_initialValue) {
- 'use strict';
- if (null === this || 'undefined' === typeof this) {
- throw new TypeError('Array.prototype.reduce called on null or undefined');
- }
- if ('function' !== typeof callback) {
- throw new TypeError(callback + ' is not a function');
- }
- var index,
- value,
- length = this.length >>> 0,
- isValueSet = false;
- if (1 < arguments.length) {
- value = opt_initialValue;
- isValueSet = true;
- }
- for (index = 0; length > index; ++index) {
- if (this.hasOwnProperty(index)) {
- if (isValueSet) {
- value = callback(value, this[index], index, this);
- } else {
- value = this[index];
- isValueSet = true;
- }
- }
- }
- if (!isValueSet) {
- throw new TypeError('Reduce of empty array with no initial value');
- }
- return value;
- };
- }
- function multiplier(x) {
- var parts = x.toString().split('.');
- if (parts.length < 2) {
- return 1;
- }
- return Math.pow(10, parts[1].length);
- }
- function correctionFactor() {
- var args = Array.prototype.slice.call(arguments);
- return args.reduce(function(prev, next) {
- var mp = multiplier(prev),
- mn = multiplier(next);
- return mp > mn ? mp : mn;
- }, -Infinity);
- }
- numeral.fn = Numeral.prototype = {
- clone: function() {
- return numeral(this);
- },
- format: function(inputString, roundingFunction) {
- return formatNumeral(this, inputString ? inputString : defaultFormat, (roundingFunction !== undefined) ? roundingFunction : Math.round);
- },
- unformat: function(inputString) {
- if (Object.prototype.toString.call(inputString) === '[object Number]') {
- return inputString;
- }
- return unformatNumeral(this, inputString ? inputString : defaultFormat);
- },
- value: function() {
- return this._value;
- },
- valueOf: function() {
- return this._value;
- },
- set: function(value) {
- this._value = Number(value);
- return this;
- },
- add: function(value) {
- var corrFactor = correctionFactor.call(null, this._value, value);
- function cback(accum, curr, currI, O) {
- return accum + corrFactor * curr;
- }
- this._value = [this._value, value].reduce(cback, 0) / corrFactor;
- return this;
- },
- subtract: function(value) {
- var corrFactor = correctionFactor.call(null, this._value, value);
- function cback(accum, curr, currI, O) {
- return accum - corrFactor * curr;
- }
- this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor;
- return this;
- },
- multiply: function(value) {
- function cback(accum, curr, currI, O) {
- var corrFactor = correctionFactor(accum, curr);
- return (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor);
- }
- this._value = [this._value, value].reduce(cback, 1);
- return this;
- },
- divide: function(value) {
- function cback(accum, curr, currI, O) {
- var corrFactor = correctionFactor(accum, curr);
- return (accum * corrFactor) / (curr * corrFactor);
- }
- this._value = [this._value, value].reduce(cback);
- return this;
- },
- difference: function(value) {
- return Math.abs(numeral(this._value).subtract(value).value());
- }
- };
- if (hasModule) {
- module.exports = numeral;
- }
- if (typeof ender === 'undefined') {
- this['numeral'] = numeral;
- }
- if (typeof define === 'function' && define.amd) {
- define([], function() {
- return numeral;
- });
- }
- }).call(window);
-
- //#
- },{}],"pikaday":[function(require,module,exports){
- /*!
- * Pikaday
- *
- * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
- */
-
- (function (root, factory)
- {
- 'use strict';
-
- var moment;
- if (typeof exports === 'object') {
- // CommonJS module
- // Load moment.js as an optional dependency
- try { moment = require('moment'); } catch (e) {}
- module.exports = factory(moment);
- } else if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(function (req)
- {
- // Load moment.js as an optional dependency
- var id = 'moment';
- try { moment = req(id); } catch (e) {}
- return factory(moment);
- });
- } else {
- root.Pikaday = factory(root.moment);
- }
- }(this, function (moment)
- {
- 'use strict';
-
- /**
- * feature detection and helper functions
- */
- var hasMoment = typeof moment === 'function',
-
- hasEventListeners = !!window.addEventListener,
-
- document = window.document,
-
- sto = window.setTimeout,
-
- addEvent = function(el, e, callback, capture)
- {
- if (hasEventListeners) {
- el.addEventListener(e, callback, !!capture);
- } else {
- el.attachEvent('on' + e, callback);
- }
- },
-
- removeEvent = function(el, e, callback, capture)
- {
- if (hasEventListeners) {
- el.removeEventListener(e, callback, !!capture);
- } else {
- el.detachEvent('on' + e, callback);
- }
- },
-
- fireEvent = function(el, eventName, data)
- {
- var ev;
-
- if (document.createEvent) {
- ev = document.createEvent('HTMLEvents');
- ev.initEvent(eventName, true, false);
- ev = extend(ev, data);
- el.dispatchEvent(ev);
- } else if (document.createEventObject) {
- ev = document.createEventObject();
- ev = extend(ev, data);
- el.fireEvent('on' + eventName, ev);
- }
- },
-
- trim = function(str)
- {
- return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,'');
- },
-
- hasClass = function(el, cn)
- {
- return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1;
- },
-
- addClass = function(el, cn)
- {
- if (!hasClass(el, cn)) {
- el.className = (el.className === '') ? cn : el.className + ' ' + cn;
- }
- },
-
- removeClass = function(el, cn)
- {
- el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' '));
- },
-
- isArray = function(obj)
- {
- return (/Array/).test(Object.prototype.toString.call(obj));
- },
-
- isDate = function(obj)
- {
- return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
- },
-
- isWeekend = function(date)
- {
- var day = date.getDay();
- return day === 0 || day === 6;
- },
-
- isLeapYear = function(year)
- {
- // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
- return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
- },
-
- getDaysInMonth = function(year, month)
- {
- return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
- },
-
- setToStartOfDay = function(date)
- {
- if (isDate(date)) date.setHours(0,0,0,0);
- },
-
- compareDates = function(a,b)
- {
- // weak date comparison (use setToStartOfDay(date) to ensure correct result)
- return a.getTime() === b.getTime();
- },
-
- extend = function(to, from, overwrite)
- {
- var prop, hasProp;
- for (prop in from) {
- hasProp = to[prop] !== undefined;
- if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) {
- if (isDate(from[prop])) {
- if (overwrite) {
- to[prop] = new Date(from[prop].getTime());
- }
- }
- else if (isArray(from[prop])) {
- if (overwrite) {
- to[prop] = from[prop].slice(0);
- }
- } else {
- to[prop] = extend({}, from[prop], overwrite);
- }
- } else if (overwrite || !hasProp) {
- to[prop] = from[prop];
- }
- }
- return to;
- },
-
- adjustCalendar = function(calendar) {
- if (calendar.month < 0) {
- calendar.year -= Math.ceil(Math.abs(calendar.month)/12);
- calendar.month += 12;
- }
- if (calendar.month > 11) {
- calendar.year += Math.floor(Math.abs(calendar.month)/12);
- calendar.month -= 12;
- }
- return calendar;
- },
-
- /**
- * defaults and localisation
- */
- defaults = {
-
- // bind the picker to a form field
- field: null,
-
- // automatically show/hide the picker on `field` focus (default `true` if `field` is set)
- bound: undefined,
-
- // position of the datepicker, relative to the field (default to bottom & left)
- // ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
- position: 'bottom left',
-
- // automatically fit in the viewport even if it means repositioning from the position option
- reposition: true,
-
- // the default output format for `.toString()` and `field` value
- format: 'YYYY-MM-DD',
-
- // the initial date to view when first opened
- defaultDate: null,
-
- // make the `defaultDate` the initial selected value
- setDefaultDate: false,
-
- // first day of week (0: Sunday, 1: Monday etc)
- firstDay: 0,
-
- // the minimum/earliest date that can be selected
- minDate: null,
- // the maximum/latest date that can be selected
- maxDate: null,
-
- // number of years either side, or array of upper/lower range
- yearRange: 10,
-
- // show week numbers at head of row
- showWeekNumber: false,
-
- // used internally (don't config outside)
- minYear: 0,
- maxYear: 9999,
- minMonth: undefined,
- maxMonth: undefined,
-
- isRTL: false,
-
- // Additional text to append to the year in the calendar title
- yearSuffix: '',
-
- // Render the month after year in the calendar title
- showMonthAfterYear: false,
-
- // how many months are visible
- numberOfMonths: 1,
-
- // when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`)
- // only used for the first display or when a selected date is not visible
- mainCalendar: 'left',
-
- // Specify a DOM element to render the calendar in
- container: undefined,
-
- // internationalization
- i18n: {
- previousMonth : 'Previous Month',
- nextMonth : 'Next Month',
- months : ['January','February','March','April','May','June','July','August','September','October','November','December'],
- weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
- weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
- },
-
- // callback function
- onSelect: null,
- onOpen: null,
- onClose: null,
- onDraw: null
- },
-
-
- /**
- * templating functions to abstract HTML rendering
- */
- renderDayName = function(opts, day, abbr)
- {
- day += opts.firstDay;
- while (day >= 7) {
- day -= 7;
- }
- return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day];
- },
-
- renderDay = function(d, m, y, isSelected, isToday, isDisabled, isEmpty)
- {
- if (isEmpty) {
- return '<td class="is-empty"></td>';
- }
- var arr = [];
- if (isDisabled) {
- arr.push('is-disabled');
- }
- if (isToday) {
- arr.push('is-today');
- }
- if (isSelected) {
- arr.push('is-selected');
- }
- return '<td data-day="' + d + '" class="' + arr.join(' ') + '">' +
- '<button class="pika-button pika-day" type="button" ' +
- 'data-pika-year="' + y + '" data-pika-month="' + m + '" data-pika-day="' + d + '">' +
- d +
- '</button>' +
- '</td>';
- },
-
- renderWeek = function (d, m, y) {
- // Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified.
- var onejan = new Date(y, 0, 1),
- weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay()+1)/7);
- return '<td class="pika-week">' + weekNum + '</td>';
- },
-
- renderRow = function(days, isRTL)
- {
- return '<tr>' + (isRTL ? days.reverse() : days).join('') + '</tr>';
- },
-
- renderBody = function(rows)
- {
- return '<tbody>' + rows.join('') + '</tbody>';
- },
-
- renderHead = function(opts)
- {
- var i, arr = [];
- if (opts.showWeekNumber) {
- arr.push('<th></th>');
- }
- for (i = 0; i < 7; i++) {
- arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
- }
- return '<thead>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</thead>';
- },
-
- renderTitle = function(instance, c, year, month, refYear)
- {
- var i, j, arr,
- opts = instance._o,
- isMinYear = year === opts.minYear,
- isMaxYear = year === opts.maxYear,
- html = '<div class="pika-title">',
- monthHtml,
- yearHtml,
- prev = true,
- next = true;
-
- for (arr = [], i = 0; i < 12; i++) {
- arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' +
- (i === month ? ' selected': '') +
- ((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled' : '') + '>' +
- opts.i18n.months[i] + '</option>');
- }
- monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select class="pika-select pika-select-month">' + arr.join('') + '</select></div>';
-
- if (isArray(opts.yearRange)) {
- i = opts.yearRange[0];
- j = opts.yearRange[1] + 1;
- } else {
- i = year - opts.yearRange;
- j = 1 + year + opts.yearRange;
- }
-
- for (arr = []; i < j && i <= opts.maxYear; i++) {
- if (i >= opts.minYear) {
- arr.push('<option value="' + i + '"' + (i === year ? ' selected': '') + '>' + (i) + '</option>');
- }
- }
- yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select class="pika-select pika-select-year">' + arr.join('') + '</select></div>';
-
- if (opts.showMonthAfterYear) {
- html += yearHtml + monthHtml;
- } else {
- html += monthHtml + yearHtml;
- }
-
- if (isMinYear && (month === 0 || opts.minMonth >= month)) {
- prev = false;
- }
-
- if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
- next = false;
- }
-
- if (c === 0) {
- html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
- }
- if (c === (instance._o.numberOfMonths - 1) ) {
- html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
- }
-
- return html += '</div>';
- },
-
- renderTable = function(opts, data)
- {
- return '<table cellpadding="0" cellspacing="0" class="pika-table">' + renderHead(opts) + renderBody(data) + '</table>';
- },
-
-
- /**
- * Pikaday constructor
- */
- Pikaday = function(options)
- {
- var self = this,
- opts = self.config(options);
-
- self._onMouseDown = function(e)
- {
- if (!self._v) {
- return;
- }
- e = e || window.event;
- var target = e.target || e.srcElement;
- if (!target) {
- return;
- }
-
- if (!hasClass(target, 'is-disabled')) {
- if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty')) {
- self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day')));
- if (opts.bound) {
- sto(function() {
- self.hide();
- if (opts.field) {
- opts.field.blur();
- }
- }, 100);
- }
- return;
- }
- else if (hasClass(target, 'pika-prev')) {
- self.prevMonth();
- }
- else if (hasClass(target, 'pika-next')) {
- self.nextMonth();
- }
- }
- if (!hasClass(target, 'pika-select')) {
- if (e.preventDefault) {
- e.preventDefault();
- } else {
- e.returnValue = false;
- return false;
- }
- } else {
- self._c = true;
- }
- };
-
- self._onChange = function(e)
- {
- e = e || window.event;
- var target = e.target || e.srcElement;
- if (!target) {
- return;
- }
- if (hasClass(target, 'pika-select-month')) {
- self.gotoMonth(target.value);
- }
- else if (hasClass(target, 'pika-select-year')) {
- self.gotoYear(target.value);
- }
- };
-
- self._onInputChange = function(e)
- {
- var date;
-
- if (e.firedBy === self) {
- return;
- }
- if (hasMoment) {
- date = moment(opts.field.value, opts.format);
- date = (date && date.isValid()) ? date.toDate() : null;
- }
- else {
- date = new Date(Date.parse(opts.field.value));
- }
- self.setDate(isDate(date) ? date : null);
- if (!self._v) {
- self.show();
- }
- };
-
- self._onInputFocus = function()
- {
- self.show();
- };
-
- self._onInputClick = function()
- {
- self.show();
- };
-
- self._onInputBlur = function()
- {
- // IE allows pika div to gain focus; catch blur the input field
- var pEl = document.activeElement;
- do {
- if (hasClass(pEl, 'pika-single')) {
- return;
- }
- }
- while ((pEl = pEl.parentNode));
-
- if (!self._c) {
- self._b = sto(function() {
- self.hide();
- }, 50);
- }
- self._c = false;
- };
-
- self._onClick = function(e)
- {
- e = e || window.event;
- var target = e.target || e.srcElement,
- pEl = target;
- if (!target) {
- return;
- }
- if (!hasEventListeners && hasClass(target, 'pika-select')) {
- if (!target.onchange) {
- target.setAttribute('onchange', 'return;');
- addEvent(target, 'change', self._onChange);
- }
- }
- do {
- if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) {
- return;
- }
- }
- while ((pEl = pEl.parentNode));
- if (self._v && target !== opts.trigger && pEl !== opts.trigger) {
- self.hide();
- }
- };
-
- self.el = document.createElement('div');
- self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '');
-
- addEvent(self.el, 'mousedown', self._onMouseDown, true);
- addEvent(self.el, 'change', self._onChange);
-
- if (opts.field) {
- if (opts.container) {
- opts.container.appendChild(self.el);
- } else if (opts.bound) {
- document.body.appendChild(self.el);
- } else {
- opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling);
- }
- addEvent(opts.field, 'change', self._onInputChange);
-
- if (!opts.defaultDate) {
- if (hasMoment && opts.field.value) {
- opts.defaultDate = moment(opts.field.value, opts.format).toDate();
- } else {
- opts.defaultDate = new Date(Date.parse(opts.field.value));
- }
- opts.setDefaultDate = true;
- }
- }
-
- var defDate = opts.defaultDate;
-
- if (isDate(defDate)) {
- if (opts.setDefaultDate) {
- self.setDate(defDate, true);
- } else {
- self.gotoDate(defDate);
- }
- } else {
- self.gotoDate(new Date());
- }
-
- if (opts.bound) {
- this.hide();
- self.el.className += ' is-bound';
- addEvent(opts.trigger, 'click', self._onInputClick);
- addEvent(opts.trigger, 'focus', self._onInputFocus);
- addEvent(opts.trigger, 'blur', self._onInputBlur);
- } else {
- this.show();
- }
- };
-
-
- /**
- * public Pikaday API
- */
- Pikaday.prototype = {
-
-
- /**
- * configure functionality
- */
- config: function(options)
- {
- if (!this._o) {
- this._o = extend({}, defaults, true);
- }
-
- var opts = extend(this._o, options, true);
-
- opts.isRTL = !!opts.isRTL;
-
- opts.field = (opts.field && opts.field.nodeName) ? opts.field : null;
-
- opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field);
-
- opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field;
-
- opts.disableWeekends = !!opts.disableWeekends;
-
- opts.disableDayFn = (typeof opts.disableDayFn) == "function" ? opts.disableDayFn : null;
-
- var nom = parseInt(opts.numberOfMonths, 10) || 1;
- opts.numberOfMonths = nom > 4 ? 4 : nom;
-
- if (!isDate(opts.minDate)) {
- opts.minDate = false;
- }
- if (!isDate(opts.maxDate)) {
- opts.maxDate = false;
- }
- if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) {
- opts.maxDate = opts.minDate = false;
- }
- if (opts.minDate) {
- setToStartOfDay(opts.minDate);
- opts.minYear = opts.minDate.getFullYear();
- opts.minMonth = opts.minDate.getMonth();
- }
- if (opts.maxDate) {
- setToStartOfDay(opts.maxDate);
- opts.maxYear = opts.maxDate.getFullYear();
- opts.maxMonth = opts.maxDate.getMonth();
- }
-
- if (isArray(opts.yearRange)) {
- var fallback = new Date().getFullYear() - 10;
- opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback;
- opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback;
- } else {
- opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange;
- if (opts.yearRange > 100) {
- opts.yearRange = 100;
- }
- }
-
- return opts;
- },
-
- /**
- * return a formatted string of the current selection (using Moment.js if available)
- */
- toString: function(format)
- {
- return !isDate(this._d) ? '' : hasMoment ? moment(this._d).format(format || this._o.format) : this._d.toDateString();
- },
-
- /**
- * return a Moment.js object of the current selection (if available)
- */
- getMoment: function()
- {
- return hasMoment ? moment(this._d) : null;
- },
-
- /**
- * set the current selection from a Moment.js object (if available)
- */
- setMoment: function(date, preventOnSelect)
- {
- if (hasMoment && moment.isMoment(date)) {
- this.setDate(date.toDate(), preventOnSelect);
- }
- },
-
- /**
- * return a Date object of the current selection
- */
- getDate: function()
- {
- return isDate(this._d) ? new Date(this._d.getTime()) : null;
- },
-
- /**
- * set the current selection
- */
- setDate: function(date, preventOnSelect)
- {
- if (!date) {
- this._d = null;
-
- if (this._o.field) {
- this._o.field.value = '';
- fireEvent(this._o.field, 'change', { firedBy: this });
- }
-
- return this.draw();
- }
- if (typeof date === 'string') {
- date = new Date(Date.parse(date));
- }
- if (!isDate(date)) {
- return;
- }
-
- var min = this._o.minDate,
- max = this._o.maxDate;
-
- if (isDate(min) && date < min) {
- date = min;
- } else if (isDate(max) && date > max) {
- date = max;
- }
-
- this._d = new Date(date.getTime());
- setToStartOfDay(this._d);
- this.gotoDate(this._d);
-
- if (this._o.field) {
- this._o.field.value = this.toString();
- fireEvent(this._o.field, 'change', { firedBy: this });
- }
- if (!preventOnSelect && typeof this._o.onSelect === 'function') {
- this._o.onSelect.call(this, this.getDate());
- }
- },
-
- /**
- * change view to a specific date
- */
- gotoDate: function(date)
- {
- var newCalendar = true;
-
- if (!isDate(date)) {
- return;
- }
-
- if (this.calendars) {
- var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1),
- lastVisibleDate = new Date(this.calendars[this.calendars.length-1].year, this.calendars[this.calendars.length-1].month, 1),
- visibleDate = date.getTime();
- // get the end of the month
- lastVisibleDate.setMonth(lastVisibleDate.getMonth()+1);
- lastVisibleDate.setDate(lastVisibleDate.getDate()-1);
- newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate);
- }
-
- if (newCalendar) {
- this.calendars = [{
- month: date.getMonth(),
- year: date.getFullYear()
- }];
- if (this._o.mainCalendar === 'right') {
- this.calendars[0].month += 1 - this._o.numberOfMonths;
- }
- }
-
- this.adjustCalendars();
- },
-
- adjustCalendars: function() {
- this.calendars[0] = adjustCalendar(this.calendars[0]);
- for (var c = 1; c < this._o.numberOfMonths; c++) {
- this.calendars[c] = adjustCalendar({
- month: this.calendars[0].month + c,
- year: this.calendars[0].year
- });
- }
- this.draw();
- },
-
- gotoToday: function()
- {
- this.gotoDate(new Date());
- },
-
- /**
- * change view to a specific month (zero-index, e.g. 0: January)
- */
- gotoMonth: function(month)
- {
- if (!isNaN(month)) {
- this.calendars[0].month = parseInt(month, 10);
- this.adjustCalendars();
- }
- },
-
- nextMonth: function()
- {
- this.calendars[0].month++;
- this.adjustCalendars();
- },
-
- prevMonth: function()
- {
- this.calendars[0].month--;
- this.adjustCalendars();
- },
-
- /**
- * change view to a specific full year (e.g. "2012")
- */
- gotoYear: function(year)
- {
- if (!isNaN(year)) {
- this.calendars[0].year = parseInt(year, 10);
- this.adjustCalendars();
- }
- },
-
- /**
- * change the minDate
- */
- setMinDate: function(value)
- {
- this._o.minDate = value;
- },
-
- /**
- * change the maxDate
- */
- setMaxDate: function(value)
- {
- this._o.maxDate = value;
- },
-
- /**
- * refresh the HTML
- */
- draw: function(force)
- {
- if (!this._v && !force) {
- return;
- }
- var opts = this._o,
- minYear = opts.minYear,
- maxYear = opts.maxYear,
- minMonth = opts.minMonth,
- maxMonth = opts.maxMonth,
- html = '';
-
- if (this._y <= minYear) {
- this._y = minYear;
- if (!isNaN(minMonth) && this._m < minMonth) {
- this._m = minMonth;
- }
- }
- if (this._y >= maxYear) {
- this._y = maxYear;
- if (!isNaN(maxMonth) && this._m > maxMonth) {
- this._m = maxMonth;
- }
- }
-
- for (var c = 0; c < opts.numberOfMonths; c++) {
- 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>';
- }
-
- this.el.innerHTML = html;
-
- if (opts.bound) {
- if(opts.field.type !== 'hidden') {
- sto(function() {
- opts.trigger.focus();
- }, 1);
- }
- }
-
- if (typeof this._o.onDraw === 'function') {
- var self = this;
- sto(function() {
- self._o.onDraw.call(self);
- }, 0);
- }
- },
-
- adjustPosition: function()
- {
- if (this._o.container) return;
- var field = this._o.trigger, pEl = field,
- width = this.el.offsetWidth, height = this.el.offsetHeight,
- viewportWidth = window.innerWidth || document.documentElement.clientWidth,
- viewportHeight = window.innerHeight || document.documentElement.clientHeight,
- scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop,
- left, top, clientRect;
-
- if (typeof field.getBoundingClientRect === 'function') {
- clientRect = field.getBoundingClientRect();
- left = clientRect.left + window.pageXOffset;
- top = clientRect.bottom + window.pageYOffset;
- } else {
- left = pEl.offsetLeft;
- top = pEl.offsetTop + pEl.offsetHeight;
- while((pEl = pEl.offsetParent)) {
- left += pEl.offsetLeft;
- top += pEl.offsetTop;
- }
- }
-
- // default position is bottom & left
- if ((this._o.reposition && left + width > viewportWidth) ||
- (
- this._o.position.indexOf('right') > -1 &&
- left - width + field.offsetWidth > 0
- )
- ) {
- left = left - width + field.offsetWidth;
- }
- if ((this._o.reposition && top + height > viewportHeight + scrollTop) ||
- (
- this._o.position.indexOf('top') > -1 &&
- top - height - field.offsetHeight > 0
- )
- ) {
- top = top - height - field.offsetHeight;
- }
-
- this.el.style.cssText = [
- 'position: absolute',
- 'left: ' + left + 'px',
- 'top: ' + top + 'px'
- ].join(';');
- },
-
- /**
- * render HTML for a particular month
- */
- render: function(year, month)
- {
- var opts = this._o,
- now = new Date(),
- days = getDaysInMonth(year, month),
- before = new Date(year, month, 1).getDay(),
- data = [],
- row = [];
- setToStartOfDay(now);
- if (opts.firstDay > 0) {
- before -= opts.firstDay;
- if (before < 0) {
- before += 7;
- }
- }
- var cells = days + before,
- after = cells;
- while(after > 7) {
- after -= 7;
- }
- cells += 7 - after;
- for (var i = 0, r = 0; i < cells; i++)
- {
- var day = new Date(year, month, 1 + (i - before)),
- isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
- isToday = compareDates(day, now),
- isEmpty = i < before || i >= (days + before),
- isDisabled = (opts.minDate && day < opts.minDate) ||
- (opts.maxDate && day > opts.maxDate) ||
- (opts.disableWeekends && isWeekend(day)) ||
- (opts.disableDayFn && opts.disableDayFn(day));
-
- row.push(renderDay(1 + (i - before), month, year, isSelected, isToday, isDisabled, isEmpty));
-
- if (++r === 7) {
- if (opts.showWeekNumber) {
- row.unshift(renderWeek(i - before, month, year));
- }
- data.push(renderRow(row, opts.isRTL));
- row = [];
- r = 0;
- }
- }
- return renderTable(opts, data);
- },
-
- isVisible: function()
- {
- return this._v;
- },
-
- show: function()
- {
- if (!this._v) {
- removeClass(this.el, 'is-hidden');
- this._v = true;
- this.draw();
- if (this._o.bound) {
- addEvent(document, 'click', this._onClick);
- this.adjustPosition();
- }
- if (typeof this._o.onOpen === 'function') {
- this._o.onOpen.call(this);
- }
- }
- },
-
- hide: function()
- {
- var v = this._v;
- if (v !== false) {
- if (this._o.bound) {
- removeEvent(document, 'click', this._onClick);
- }
- this.el.style.cssText = '';
- addClass(this.el, 'is-hidden');
- this._v = false;
- if (v !== undefined && typeof this._o.onClose === 'function') {
- this._o.onClose.call(this);
- }
- }
- },
-
- /**
- * GAME OVER
- */
- destroy: function()
- {
- this.hide();
- removeEvent(this.el, 'mousedown', this._onMouseDown, true);
- removeEvent(this.el, 'change', this._onChange);
- if (this._o.field) {
- removeEvent(this._o.field, 'change', this._onInputChange);
- if (this._o.bound) {
- removeEvent(this._o.trigger, 'click', this._onInputClick);
- removeEvent(this._o.trigger, 'focus', this._onInputFocus);
- removeEvent(this._o.trigger, 'blur', this._onInputBlur);
- }
- }
- if (this.el.parentNode) {
- this.el.parentNode.removeChild(this.el);
- }
- }
-
- };
-
- return Pikaday;
-
- }));
-
- },{"moment":"moment"}],"zeroclipboard":[function(require,module,exports){
- /*!
- * ZeroClipboard
- * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
- * Copyright (c) 2009-2014 Jon Rohan, James M. Greene
- * Licensed MIT
- * http://zeroclipboard.org/
- * v2.2.0
- */
- (function(window, undefined) {
- "use strict";
- /**
- * Store references to critically important global functions that may be
- * overridden on certain web pages.
- */
- 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() {
- var unwrapper = function(el) {
- return el;
- };
- if (typeof _window.wrap === "function" && typeof _window.unwrap === "function") {
- try {
- var div = _document.createElement("div");
- var unwrappedDiv = _window.unwrap(div);
- if (div.nodeType === 1 && unwrappedDiv && unwrappedDiv.nodeType === 1) {
- unwrapper = _window.unwrap;
- }
- } catch (e) {}
- }
- return unwrapper;
- }();
- /**
- * Convert an `arguments` object into an Array.
- *
- * @returns The arguments as an Array
- * @private
- */
- var _args = function(argumentsObj) {
- return _slice.call(argumentsObj, 0);
- };
- /**
- * Shallow-copy the owned, enumerable properties of one object over to another, similar to jQuery's `$.extend`.
- *
- * @returns The target object, augmented
- * @private
- */
- var _extend = function() {
- var i, len, arg, prop, src, copy, args = _args(arguments), target = args[0] || {};
- for (i = 1, len = args.length; i < len; i++) {
- if ((arg = args[i]) != null) {
- for (prop in arg) {
- if (_hasOwn.call(arg, prop)) {
- src = target[prop];
- copy = arg[prop];
- if (target !== copy && copy !== undefined) {
- target[prop] = copy;
- }
- }
- }
- }
- }
- return target;
- };
- /**
- * Return a deep copy of the source object or array.
- *
- * @returns Object or Array
- * @private
- */
- var _deepCopy = function(source) {
- var copy, i, len, prop;
- if (typeof source !== "object" || source == null || typeof source.nodeType === "number") {
- copy = source;
- } else if (typeof source.length === "number") {
- copy = [];
- for (i = 0, len = source.length; i < len; i++) {
- if (_hasOwn.call(source, i)) {
- copy[i] = _deepCopy(source[i]);
- }
- }
- } else {
- copy = {};
- for (prop in source) {
- if (_hasOwn.call(source, prop)) {
- copy[prop] = _deepCopy(source[prop]);
- }
- }
- }
- return copy;
- };
- /**
- * Makes a shallow copy of `obj` (like `_extend`) but filters its properties based on a list of `keys` to keep.
- * The inverse of `_omit`, mostly. The big difference is that these properties do NOT need to be enumerable to
- * be kept.
- *
- * @returns A new filtered object.
- * @private
- */
- var _pick = function(obj, keys) {
- var newObj = {};
- for (var i = 0, len = keys.length; i < len; i++) {
- if (keys[i] in obj) {
- newObj[keys[i]] = obj[keys[i]];
- }
- }
- return newObj;
- };
- /**
- * Makes a shallow copy of `obj` (like `_extend`) but filters its properties based on a list of `keys` to omit.
- * The inverse of `_pick`.
- *
- * @returns A new filtered object.
- * @private
- */
- var _omit = function(obj, keys) {
- var newObj = {};
- for (var prop in obj) {
- if (keys.indexOf(prop) === -1) {
- newObj[prop] = obj[prop];
- }
- }
- return newObj;
- };
- /**
- * Remove all owned, enumerable properties from an object.
- *
- * @returns The original object without its owned, enumerable properties.
- * @private
- */
- var _deleteOwnProperties = function(obj) {
- if (obj) {
- for (var prop in obj) {
- if (_hasOwn.call(obj, prop)) {
- delete obj[prop];
- }
- }
- }
- return obj;
- };
- /**
- * Determine if an element is contained within another element.
- *
- * @returns Boolean
- * @private
- */
- var _containedBy = function(el, ancestorEl) {
- 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)) {
- do {
- if (el === ancestorEl) {
- return true;
- }
- el = el.parentNode;
- } while (el);
- }
- return false;
- };
- /**
- * Get the URL path's parent directory.
- *
- * @returns String or `undefined`
- * @private
- */
- var _getDirPathOfUrl = function(url) {
- var dir;
- if (typeof url === "string" && url) {
- dir = url.split("#")[0].split("?")[0];
- dir = url.slice(0, url.lastIndexOf("/") + 1);
- }
- return dir;
- };
- /**
- * Get the current script's URL by throwing an `Error` and analyzing it.
- *
- * @returns String or `undefined`
- * @private
- */
- var _getCurrentScriptUrlFromErrorStack = function(stack) {
- var url, matches;
- if (typeof stack === "string" && stack) {
- matches = stack.match(/^(?:|[^:@]*@|.+\)@(?=http[s]?|file)|.+?\s+(?: at |@)(?:[^:\(]+ )*[\(]?)((?:http[s]?|file):\/\/[\/]?.+?\/[^:\)]*?)(?::\d+)(?::\d+)?/);
- if (matches && matches[1]) {
- url = matches[1];
- } else {
- matches = stack.match(/\)@((?:http[s]?|file):\/\/[\/]?.+?\/[^:\)]*?)(?::\d+)(?::\d+)?/);
- if (matches && matches[1]) {
- url = matches[1];
- }
- }
- }
- return url;
- };
- /**
- * Get the current script's URL by throwing an `Error` and analyzing it.
- *
- * @returns String or `undefined`
- * @private
- */
- var _getCurrentScriptUrlFromError = function() {
- var url, err;
- try {
- throw new _Error();
- } catch (e) {
- err = e;
- }
- if (err) {
- url = err.sourceURL || err.fileName || _getCurrentScriptUrlFromErrorStack(err.stack);
- }
- return url;
- };
- /**
- * Get the current script's URL.
- *
- * @returns String or `undefined`
- * @private
- */
- var _getCurrentScriptUrl = function() {
- var jsPath, scripts, i;
- if (_document.currentScript && (jsPath = _document.currentScript.src)) {
- return jsPath;
- }
- scripts = _document.getElementsByTagName("script");
- if (scripts.length === 1) {
- return scripts[0].src || undefined;
- }
- if ("readyState" in scripts[0]) {
- for (i = scripts.length; i--; ) {
- if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) {
- return jsPath;
- }
- }
- }
- if (_document.readyState === "loading" && (jsPath = scripts[scripts.length - 1].src)) {
- return jsPath;
- }
- if (jsPath = _getCurrentScriptUrlFromError()) {
- return jsPath;
- }
- return undefined;
- };
- /**
- * Get the unanimous parent directory of ALL script tags.
- * If any script tags are either (a) inline or (b) from differing parent
- * directories, this method must return `undefined`.
- *
- * @returns String or `undefined`
- * @private
- */
- var _getUnanimousScriptParentDir = function() {
- var i, jsDir, jsPath, scripts = _document.getElementsByTagName("script");
- for (i = scripts.length; i--; ) {
- if (!(jsPath = scripts[i].src)) {
- jsDir = null;
- break;
- }
- jsPath = _getDirPathOfUrl(jsPath);
- if (jsDir == null) {
- jsDir = jsPath;
- } else if (jsDir !== jsPath) {
- jsDir = null;
- break;
- }
- }
- return jsDir || undefined;
- };
- /**
- * Get the presumed location of the "ZeroClipboard.swf" file, based on the location
- * of the executing JavaScript file (e.g. "ZeroClipboard.js", etc.).
- *
- * @returns String
- * @private
- */
- var _getDefaultSwfPath = function() {
- var jsDir = _getDirPathOfUrl(_getCurrentScriptUrl()) || _getUnanimousScriptParentDir() || "";
- return jsDir + "ZeroClipboard.swf";
- };
- /**
- * Keep track of if the page is framed (in an `iframe`). This can never change.
- * @private
- */
- var _pageIsFramed = function() {
- return window.opener == null && (!!window.top && window != window.top || !!window.parent && window != window.parent);
- }();
- /**
- * Keep track of the state of the Flash object.
- * @private
- */
- var _flashState = {
- bridge: null,
- version: "0.0.0",
- pluginType: "unknown",
- disabled: null,
- outdated: null,
- sandboxed: null,
- unavailable: null,
- degraded: null,
- deactivated: null,
- overdue: null,
- ready: null
- };
- /**
- * The minimum Flash Player version required to use ZeroClipboard completely.
- * @readonly
- * @private
- */
- var _minimumFlashVersion = "11.0.0";
- /**
- * The ZeroClipboard library version number, as reported by Flash, at the time the SWF was compiled.
- */
- var _zcSwfVersion;
- /**
- * Keep track of all event listener registrations.
- * @private
- */
- var _handlers = {};
- /**
- * Keep track of the currently activated element.
- * @private
- */
- var _currentElement;
- /**
- * Keep track of the element that was activated when a `copy` process started.
- * @private
- */
- var _copyTarget;
- /**
- * Keep track of data for the pending clipboard transaction.
- * @private
- */
- var _clipData = {};
- /**
- * Keep track of data formats for the pending clipboard transaction.
- * @private
- */
- var _clipDataFormatMap = null;
- /**
- * Keep track of the Flash availability check timeout.
- * @private
- */
- var _flashCheckTimeout = 0;
- /**
- * Keep track of SWF network errors interval polling.
- * @private
- */
- var _swfFallbackCheckInterval = 0;
- /**
- * The `message` store for events
- * @private
- */
- var _eventMessages = {
- ready: "Flash communication is established",
- error: {
- "flash-disabled": "Flash is disabled or not installed. May also be attempting to run Flash in a sandboxed iframe, which is impossible.",
- "flash-outdated": "Flash is too outdated to support ZeroClipboard",
- "flash-sandboxed": "Attempting to run Flash in a sandboxed iframe, which is impossible",
- "flash-unavailable": "Flash is unable to communicate bidirectionally with JavaScript",
- "flash-degraded": "Flash is unable to preserve data fidelity when communicating with JavaScript",
- "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.",
- "flash-overdue": "Flash communication was established but NOT within the acceptable time limit",
- "version-mismatch": "ZeroClipboard JS version number does not match ZeroClipboard SWF version number",
- "clipboard-error": "At least one error was thrown while ZeroClipboard was attempting to inject your data into the clipboard",
- "config-mismatch": "ZeroClipboard configuration does not match Flash's reality",
- "swf-not-found": "The ZeroClipboard SWF object could not be loaded, so please check your `swfPath` configuration and/or network connectivity"
- }
- };
- /**
- * The `name`s of `error` events that can only occur is Flash has at least
- * been able to load the SWF successfully.
- * @private
- */
- var _errorsThatOnlyOccurAfterFlashLoads = [ "flash-unavailable", "flash-degraded", "flash-overdue", "version-mismatch", "config-mismatch", "clipboard-error" ];
- /**
- * The `name`s of `error` events that should likely result in the `_flashState`
- * variable's property values being updated.
- * @private
- */
- var _flashStateErrorNames = [ "flash-disabled", "flash-outdated", "flash-sandboxed", "flash-unavailable", "flash-degraded", "flash-deactivated", "flash-overdue" ];
- /**
- * A RegExp to match the `name` property of `error` events related to Flash.
- * @private
- */
- var _flashStateErrorNameMatchingRegex = new RegExp("^flash-(" + _flashStateErrorNames.map(function(errorName) {
- return errorName.replace(/^flash-/, "");
- }).join("|") + ")$");
- /**
- * A RegExp to match the `name` property of `error` events related to Flash,
- * which is enabled.
- * @private
- */
- var _flashStateEnabledErrorNameMatchingRegex = new RegExp("^flash-(" + _flashStateErrorNames.slice(1).map(function(errorName) {
- return errorName.replace(/^flash-/, "");
- }).join("|") + ")$");
- /**
- * ZeroClipboard configuration defaults for the Core module.
- * @private
- */
- var _globalConfig = {
- swfPath: _getDefaultSwfPath(),
- trustedDomains: window.location.host ? [ window.location.host ] : [],
- cacheBust: true,
- forceEnhancedClipboard: false,
- flashLoadTimeout: 3e4,
- autoActivate: true,
- bubbleEvents: true,
- containerId: "global-zeroclipboard-html-bridge",
- containerClass: "global-zeroclipboard-container",
- swfObjectId: "global-zeroclipboard-flash-bridge",
- hoverClass: "zeroclipboard-is-hover",
- activeClass: "zeroclipboard-is-active",
- forceHandCursor: false,
- title: null,
- zIndex: 999999999
- };
- /**
- * The underlying implementation of `ZeroClipboard.config`.
- * @private
- */
- var _config = function(options) {
- if (typeof options === "object" && options !== null) {
- for (var prop in options) {
- if (_hasOwn.call(options, prop)) {
- if (/^(?:forceHandCursor|title|zIndex|bubbleEvents)$/.test(prop)) {
- _globalConfig[prop] = options[prop];
- } else if (_flashState.bridge == null) {
- if (prop === "containerId" || prop === "swfObjectId") {
- if (_isValidHtml4Id(options[prop])) {
- _globalConfig[prop] = options[prop];
- } else {
- throw new Error("The specified `" + prop + "` value is not valid as an HTML4 Element ID");
- }
- } else {
- _globalConfig[prop] = options[prop];
- }
- }
- }
- }
- }
- if (typeof options === "string" && options) {
- if (_hasOwn.call(_globalConfig, options)) {
- return _globalConfig[options];
- }
- return;
- }
- return _deepCopy(_globalConfig);
- };
- /**
- * The underlying implementation of `ZeroClipboard.state`.
- * @private
- */
- var _state = function() {
- _detectSandbox();
- return {
- browser: _pick(_navigator, [ "userAgent", "platform", "appName" ]),
- flash: _omit(_flashState, [ "bridge" ]),
- zeroclipboard: {
- version: ZeroClipboard.version,
- config: ZeroClipboard.config()
- }
- };
- };
- /**
- * The underlying implementation of `ZeroClipboard.isFlashUnusable`.
- * @private
- */
- var _isFlashUnusable = function() {
- return !!(_flashState.disabled || _flashState.outdated || _flashState.sandboxed || _flashState.unavailable || _flashState.degraded || _flashState.deactivated);
- };
- /**
- * The underlying implementation of `ZeroClipboard.on`.
- * @private
- */
- var _on = function(eventType, listener) {
- var i, len, events, added = {};
- if (typeof eventType === "string" && eventType) {
- events = eventType.toLowerCase().split(/\s+/);
- } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
- for (i in eventType) {
- if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
- ZeroClipboard.on(i, eventType[i]);
- }
- }
- }
- if (events && events.length) {
- for (i = 0, len = events.length; i < len; i++) {
- eventType = events[i].replace(/^on/, "");
- added[eventType] = true;
- if (!_handlers[eventType]) {
- _handlers[eventType] = [];
- }
- _handlers[eventType].push(listener);
- }
- if (added.ready && _flashState.ready) {
- ZeroClipboard.emit({
- type: "ready"
- });
- }
- if (added.error) {
- for (i = 0, len = _flashStateErrorNames.length; i < len; i++) {
- if (_flashState[_flashStateErrorNames[i].replace(/^flash-/, "")] === true) {
- ZeroClipboard.emit({
- type: "error",
- name: _flashStateErrorNames[i]
- });
- break;
- }
- }
- if (_zcSwfVersion !== undefined && ZeroClipboard.version !== _zcSwfVersion) {
- ZeroClipboard.emit({
- type: "error",
- name: "version-mismatch",
- jsVersion: ZeroClipboard.version,
- swfVersion: _zcSwfVersion
- });
- }
- }
- }
- return ZeroClipboard;
- };
- /**
- * The underlying implementation of `ZeroClipboard.off`.
- * @private
- */
- var _off = function(eventType, listener) {
- var i, len, foundIndex, events, perEventHandlers;
- if (arguments.length === 0) {
- events = _keys(_handlers);
- } else if (typeof eventType === "string" && eventType) {
- events = eventType.split(/\s+/);
- } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
- for (i in eventType) {
- if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
- ZeroClipboard.off(i, eventType[i]);
- }
- }
- }
- if (events && events.length) {
- for (i = 0, len = events.length; i < len; i++) {
- eventType = events[i].toLowerCase().replace(/^on/, "");
- perEventHandlers = _handlers[eventType];
- if (perEventHandlers && perEventHandlers.length) {
- if (listener) {
- foundIndex = perEventHandlers.indexOf(listener);
- while (foundIndex !== -1) {
- perEventHandlers.splice(foundIndex, 1);
- foundIndex = perEventHandlers.indexOf(listener, foundIndex);
- }
- } else {
- perEventHandlers.length = 0;
- }
- }
- }
- }
- return ZeroClipboard;
- };
- /**
- * The underlying implementation of `ZeroClipboard.handlers`.
- * @private
- */
- var _listeners = function(eventType) {
- var copy;
- if (typeof eventType === "string" && eventType) {
- copy = _deepCopy(_handlers[eventType]) || null;
- } else {
- copy = _deepCopy(_handlers);
- }
- return copy;
- };
- /**
- * The underlying implementation of `ZeroClipboard.emit`.
- * @private
- */
- var _emit = function(event) {
- var eventCopy, returnVal, tmp;
- event = _createEvent(event);
- if (!event) {
- return;
- }
- if (_preprocessEvent(event)) {
- return;
- }
- if (event.type === "ready" && _flashState.overdue === true) {
- return ZeroClipboard.emit({
- type: "error",
- name: "flash-overdue"
- });
- }
- eventCopy = _extend({}, event);
- _dispatchCallbacks.call(this, eventCopy);
- if (event.type === "copy") {
- tmp = _mapClipDataToFlash(_clipData);
- returnVal = tmp.data;
- _clipDataFormatMap = tmp.formatMap;
- }
- return returnVal;
- };
- /**
- * The underlying implementation of `ZeroClipboard.create`.
- * @private
- */
- var _create = function() {
- var previousState = _flashState.sandboxed;
- _detectSandbox();
- if (typeof _flashState.ready !== "boolean") {
- _flashState.ready = false;
- }
- if (_flashState.sandboxed !== previousState && _flashState.sandboxed === true) {
- _flashState.ready = false;
- ZeroClipboard.emit({
- type: "error",
- name: "flash-sandboxed"
- });
- } else if (!ZeroClipboard.isFlashUnusable() && _flashState.bridge === null) {
- var maxWait = _globalConfig.flashLoadTimeout;
- if (typeof maxWait === "number" && maxWait >= 0) {
- _flashCheckTimeout = _setTimeout(function() {
- if (typeof _flashState.deactivated !== "boolean") {
- _flashState.deactivated = true;
- }
- if (_flashState.deactivated === true) {
- ZeroClipboard.emit({
- type: "error",
- name: "flash-deactivated"
- });
- }
- }, maxWait);
- }
- _flashState.overdue = false;
- _embedSwf();
- }
- };
- /**
- * The underlying implementation of `ZeroClipboard.destroy`.
- * @private
- */
- var _destroy = function() {
- ZeroClipboard.clearData();
- ZeroClipboard.blur();
- ZeroClipboard.emit("destroy");
- _unembedSwf();
- ZeroClipboard.off();
- };
- /**
- * The underlying implementation of `ZeroClipboard.setData`.
- * @private
- */
- var _setData = function(format, data) {
- var dataObj;
- if (typeof format === "object" && format && typeof data === "undefined") {
- dataObj = format;
- ZeroClipboard.clearData();
- } else if (typeof format === "string" && format) {
- dataObj = {};
- dataObj[format] = data;
- } else {
- return;
- }
- for (var dataFormat in dataObj) {
- if (typeof dataFormat === "string" && dataFormat && _hasOwn.call(dataObj, dataFormat) && typeof dataObj[dataFormat] === "string" && dataObj[dataFormat]) {
- _clipData[dataFormat] = dataObj[dataFormat];
- }
- }
- };
- /**
- * The underlying implementation of `ZeroClipboard.clearData`.
- * @private
- */
- var _clearData = function(format) {
- if (typeof format === "undefined") {
- _deleteOwnProperties(_clipData);
- _clipDataFormatMap = null;
- } else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
- delete _clipData[format];
- }
- };
- /**
- * The underlying implementation of `ZeroClipboard.getData`.
- * @private
- */
- var _getData = function(format) {
- if (typeof format === "undefined") {
- return _deepCopy(_clipData);
- } else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
- return _clipData[format];
- }
- };
- /**
- * The underlying implementation of `ZeroClipboard.focus`/`ZeroClipboard.activate`.
- * @private
- */
- var _focus = function(element) {
- if (!(element && element.nodeType === 1)) {
- return;
- }
- if (_currentElement) {
- _removeClass(_currentElement, _globalConfig.activeClass);
- if (_currentElement !== element) {
- _removeClass(_currentElement, _globalConfig.hoverClass);
- }
- }
- _currentElement = element;
- _addClass(element, _globalConfig.hoverClass);
- var newTitle = element.getAttribute("title") || _globalConfig.title;
- if (typeof newTitle === "string" && newTitle) {
- var htmlBridge = _getHtmlBridge(_flashState.bridge);
- if (htmlBridge) {
- htmlBridge.setAttribute("title", newTitle);
- }
- }
- var useHandCursor = _globalConfig.forceHandCursor === true || _getStyle(element, "cursor") === "pointer";
- _setHandCursor(useHandCursor);
- _reposition();
- };
- /**
- * The underlying implementation of `ZeroClipboard.blur`/`ZeroClipboard.deactivate`.
- * @private
- */
- var _blur = function() {
- var htmlBridge = _getHtmlBridge(_flashState.bridge);
- if (htmlBridge) {
- htmlBridge.removeAttribute("title");
- htmlBridge.style.left = "0px";
- htmlBridge.style.top = "-9999px";
- htmlBridge.style.width = "1px";
- htmlBridge.style.height = "1px";
- }
- if (_currentElement) {
- _removeClass(_currentElement, _globalConfig.hoverClass);
- _removeClass(_currentElement, _globalConfig.activeClass);
- _currentElement = null;
- }
- };
- /**
- * The underlying implementation of `ZeroClipboard.activeElement`.
- * @private
- */
- var _activeElement = function() {
- return _currentElement || null;
- };
- /**
- * Check if a value is a valid HTML4 `ID` or `Name` token.
- * @private
- */
- var _isValidHtml4Id = function(id) {
- return typeof id === "string" && id && /^[A-Za-z][A-Za-z0-9_:\-\.]*$/.test(id);
- };
- /**
- * Create or update an `event` object, based on the `eventType`.
- * @private
- */
- var _createEvent = function(event) {
- var eventType;
- if (typeof event === "string" && event) {
- eventType = event;
- event = {};
- } else if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
- eventType = event.type;
- }
- if (!eventType) {
- return;
- }
- eventType = eventType.toLowerCase();
- if (!event.target && (/^(copy|aftercopy|_click)$/.test(eventType) || eventType === "error" && event.name === "clipboard-error")) {
- event.target = _copyTarget;
- }
- _extend(event, {
- type: eventType,
- target: event.target || _currentElement || null,
- relatedTarget: event.relatedTarget || null,
- currentTarget: _flashState && _flashState.bridge || null,
- timeStamp: event.timeStamp || _now() || null
- });
- var msg = _eventMessages[event.type];
- if (event.type === "error" && event.name && msg) {
- msg = msg[event.name];
- }
- if (msg) {
- event.message = msg;
- }
- if (event.type === "ready") {
- _extend(event, {
- target: null,
- version: _flashState.version
- });
- }
- if (event.type === "error") {
- if (_flashStateErrorNameMatchingRegex.test(event.name)) {
- _extend(event, {
- target: null,
- minimumVersion: _minimumFlashVersion
- });
- }
- if (_flashStateEnabledErrorNameMatchingRegex.test(event.name)) {
- _extend(event, {
- version: _flashState.version
- });
- }
- }
- if (event.type === "copy") {
- event.clipboardData = {
- setData: ZeroClipboard.setData,
- clearData: ZeroClipboard.clearData
- };
- }
- if (event.type === "aftercopy") {
- event = _mapClipResultsFromFlash(event, _clipDataFormatMap);
- }
- if (event.target && !event.relatedTarget) {
- event.relatedTarget = _getRelatedTarget(event.target);
- }
- return _addMouseData(event);
- };
- /**
- * Get a relatedTarget from the target's `data-clipboard-target` attribute
- * @private
- */
- var _getRelatedTarget = function(targetEl) {
- var relatedTargetId = targetEl && targetEl.getAttribute && targetEl.getAttribute("data-clipboard-target");
- return relatedTargetId ? _document.getElementById(relatedTargetId) : null;
- };
- /**
- * Add element and position data to `MouseEvent` instances
- * @private
- */
- var _addMouseData = function(event) {
- if (event && /^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
- var srcElement = event.target;
- var fromElement = event.type === "_mouseover" && event.relatedTarget ? event.relatedTarget : undefined;
- var toElement = event.type === "_mouseout" && event.relatedTarget ? event.relatedTarget : undefined;
- var pos = _getElementPosition(srcElement);
- var screenLeft = _window.screenLeft || _window.screenX || 0;
- var screenTop = _window.screenTop || _window.screenY || 0;
- var scrollLeft = _document.body.scrollLeft + _document.documentElement.scrollLeft;
- var scrollTop = _document.body.scrollTop + _document.documentElement.scrollTop;
- var pageX = pos.left + (typeof event._stageX === "number" ? event._stageX : 0);
- var pageY = pos.top + (typeof event._stageY === "number" ? event._stageY : 0);
- var clientX = pageX - scrollLeft;
- var clientY = pageY - scrollTop;
- var screenX = screenLeft + clientX;
- var screenY = screenTop + clientY;
- var moveX = typeof event.movementX === "number" ? event.movementX : 0;
- var moveY = typeof event.movementY === "number" ? event.movementY : 0;
- delete event._stageX;
- delete event._stageY;
- _extend(event, {
- srcElement: srcElement,
- fromElement: fromElement,
- toElement: toElement,
- screenX: screenX,
- screenY: screenY,
- pageX: pageX,
- pageY: pageY,
- clientX: clientX,
- clientY: clientY,
- x: clientX,
- y: clientY,
- movementX: moveX,
- movementY: moveY,
- offsetX: 0,
- offsetY: 0,
- layerX: 0,
- layerY: 0
- });
- }
- return event;
- };
- /**
- * Determine if an event's registered handlers should be execute synchronously or asynchronously.
- *
- * @returns {boolean}
- * @private
- */
- var _shouldPerformAsync = function(event) {
- var eventType = event && typeof event.type === "string" && event.type || "";
- return !/^(?:(?:before)?copy|destroy)$/.test(eventType);
- };
- /**
- * Control if a callback should be executed asynchronously or not.
- *
- * @returns `undefined`
- * @private
- */
- var _dispatchCallback = function(func, context, args, async) {
- if (async) {
- _setTimeout(function() {
- func.apply(context, args);
- }, 0);
- } else {
- func.apply(context, args);
- }
- };
- /**
- * Handle the actual dispatching of events to client instances.
- *
- * @returns `undefined`
- * @private
- */
- var _dispatchCallbacks = function(event) {
- if (!(typeof event === "object" && event && event.type)) {
- return;
- }
- var async = _shouldPerformAsync(event);
- var wildcardTypeHandlers = _handlers["*"] || [];
- var specificTypeHandlers = _handlers[event.type] || [];
- var handlers = wildcardTypeHandlers.concat(specificTypeHandlers);
- if (handlers && handlers.length) {
- var i, len, func, context, eventCopy, originalContext = this;
- for (i = 0, len = handlers.length; i < len; i++) {
- func = handlers[i];
- context = originalContext;
- if (typeof func === "string" && typeof _window[func] === "function") {
- func = _window[func];
- }
- if (typeof func === "object" && func && typeof func.handleEvent === "function") {
- context = func;
- func = func.handleEvent;
- }
- if (typeof func === "function") {
- eventCopy = _extend({}, event);
- _dispatchCallback(func, context, [ eventCopy ], async);
- }
- }
- }
- return this;
- };
- /**
- * Check an `error` event's `name` property to see if Flash has
- * already loaded, which rules out possible `iframe` sandboxing.
- * @private
- */
- var _getSandboxStatusFromErrorEvent = function(event) {
- var isSandboxed = null;
- if (_pageIsFramed === false || event && event.type === "error" && event.name && _errorsThatOnlyOccurAfterFlashLoads.indexOf(event.name) !== -1) {
- isSandboxed = false;
- }
- return isSandboxed;
- };
- /**
- * Preprocess any special behaviors, reactions, or state changes after receiving this event.
- * Executes only once per event emitted, NOT once per client.
- * @private
- */
- var _preprocessEvent = function(event) {
- var element = event.target || _currentElement || null;
- var sourceIsSwf = event._source === "swf";
- delete event._source;
- switch (event.type) {
- case "error":
- var isSandboxed = event.name === "flash-sandboxed" || _getSandboxStatusFromErrorEvent(event);
- if (typeof isSandboxed === "boolean") {
- _flashState.sandboxed = isSandboxed;
- }
- if (_flashStateErrorNames.indexOf(event.name) !== -1) {
- _extend(_flashState, {
- disabled: event.name === "flash-disabled",
- outdated: event.name === "flash-outdated",
- unavailable: event.name === "flash-unavailable",
- degraded: event.name === "flash-degraded",
- deactivated: event.name === "flash-deactivated",
- overdue: event.name === "flash-overdue",
- ready: false
- });
- } else if (event.name === "version-mismatch") {
- _zcSwfVersion = event.swfVersion;
- _extend(_flashState, {
- disabled: false,
- outdated: false,
- unavailable: false,
- degraded: false,
- deactivated: false,
- overdue: false,
- ready: false
- });
- }
- _clearTimeoutsAndPolling();
- break;
-
- case "ready":
- _zcSwfVersion = event.swfVersion;
- var wasDeactivated = _flashState.deactivated === true;
- _extend(_flashState, {
- disabled: false,
- outdated: false,
- sandboxed: false,
- unavailable: false,
- degraded: false,
- deactivated: false,
- overdue: wasDeactivated,
- ready: !wasDeactivated
- });
- _clearTimeoutsAndPolling();
- break;
-
- case "beforecopy":
- _copyTarget = element;
- break;
-
- case "copy":
- var textContent, htmlContent, targetEl = event.relatedTarget;
- if (!(_clipData["text/html"] || _clipData["text/plain"]) && targetEl && (htmlContent = targetEl.value || targetEl.outerHTML || targetEl.innerHTML) && (textContent = targetEl.value || targetEl.textContent || targetEl.innerText)) {
- event.clipboardData.clearData();
- event.clipboardData.setData("text/plain", textContent);
- if (htmlContent !== textContent) {
- event.clipboardData.setData("text/html", htmlContent);
- }
- } else if (!_clipData["text/plain"] && event.target && (textContent = event.target.getAttribute("data-clipboard-text"))) {
- event.clipboardData.clearData();
- event.clipboardData.setData("text/plain", textContent);
- }
- break;
-
- case "aftercopy":
- _queueEmitClipboardErrors(event);
- ZeroClipboard.clearData();
- if (element && element !== _safeActiveElement() && element.focus) {
- element.focus();
- }
- break;
-
- case "_mouseover":
- ZeroClipboard.focus(element);
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- if (element && element !== event.relatedTarget && !_containedBy(event.relatedTarget, element)) {
- _fireMouseEvent(_extend({}, event, {
- type: "mouseenter",
- bubbles: false,
- cancelable: false
- }));
- }
- _fireMouseEvent(_extend({}, event, {
- type: "mouseover"
- }));
- }
- break;
-
- case "_mouseout":
- ZeroClipboard.blur();
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- if (element && element !== event.relatedTarget && !_containedBy(event.relatedTarget, element)) {
- _fireMouseEvent(_extend({}, event, {
- type: "mouseleave",
- bubbles: false,
- cancelable: false
- }));
- }
- _fireMouseEvent(_extend({}, event, {
- type: "mouseout"
- }));
- }
- break;
-
- case "_mousedown":
- _addClass(element, _globalConfig.activeClass);
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- _fireMouseEvent(_extend({}, event, {
- type: event.type.slice(1)
- }));
- }
- break;
-
- case "_mouseup":
- _removeClass(element, _globalConfig.activeClass);
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- _fireMouseEvent(_extend({}, event, {
- type: event.type.slice(1)
- }));
- }
- break;
-
- case "_click":
- _copyTarget = null;
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- _fireMouseEvent(_extend({}, event, {
- type: event.type.slice(1)
- }));
- }
- break;
-
- case "_mousemove":
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- _fireMouseEvent(_extend({}, event, {
- type: event.type.slice(1)
- }));
- }
- break;
- }
- if (/^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
- return true;
- }
- };
- /**
- * Check an "aftercopy" event for clipboard errors and emit a corresponding "error" event.
- * @private
- */
- var _queueEmitClipboardErrors = function(aftercopyEvent) {
- if (aftercopyEvent.errors && aftercopyEvent.errors.length > 0) {
- var errorEvent = _deepCopy(aftercopyEvent);
- _extend(errorEvent, {
- type: "error",
- name: "clipboard-error"
- });
- delete errorEvent.success;
- _setTimeout(function() {
- ZeroClipboard.emit(errorEvent);
- }, 0);
- }
- };
- /**
- * Dispatch a synthetic MouseEvent.
- *
- * @returns `undefined`
- * @private
- */
- var _fireMouseEvent = function(event) {
- if (!(event && typeof event.type === "string" && event)) {
- return;
- }
- var e, target = event.target || null, doc = target && target.ownerDocument || _document, defaults = {
- view: doc.defaultView || _window,
- canBubble: true,
- cancelable: true,
- detail: event.type === "click" ? 1 : 0,
- button: typeof event.which === "number" ? event.which - 1 : typeof event.button === "number" ? event.button : doc.createEvent ? 0 : 1
- }, args = _extend(defaults, event);
- if (!target) {
- return;
- }
- if (doc.createEvent && target.dispatchEvent) {
- 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 ];
- e = doc.createEvent("MouseEvents");
- if (e.initMouseEvent) {
- e.initMouseEvent.apply(e, args);
- e._source = "js";
- target.dispatchEvent(e);
- }
- }
- };
- /**
- * Continuously poll the DOM until either:
- * (a) the fallback content becomes visible, or
- * (b) we receive an event from SWF (handled elsewhere)
- *
- * IMPORTANT:
- * This is NOT a necessary check but it can result in significantly faster
- * detection of bad `swfPath` configuration and/or network/server issues [in
- * supported browsers] than waiting for the entire `flashLoadTimeout` duration
- * to elapse before detecting that the SWF cannot be loaded. The detection
- * duration can be anywhere from 10-30 times faster [in supported browsers] by
- * using this approach.
- *
- * @returns `undefined`
- * @private
- */
- var _watchForSwfFallbackContent = function() {
- var maxWait = _globalConfig.flashLoadTimeout;
- if (typeof maxWait === "number" && maxWait >= 0) {
- var pollWait = Math.min(1e3, maxWait / 10);
- var fallbackContentId = _globalConfig.swfObjectId + "_fallbackContent";
- _swfFallbackCheckInterval = _setInterval(function() {
- var el = _document.getElementById(fallbackContentId);
- if (_isElementVisible(el)) {
- _clearTimeoutsAndPolling();
- _flashState.deactivated = null;
- ZeroClipboard.emit({
- type: "error",
- name: "swf-not-found"
- });
- }
- }, pollWait);
- }
- };
- /**
- * Create the HTML bridge element to embed the Flash object into.
- * @private
- */
- var _createHtmlBridge = function() {
- var container = _document.createElement("div");
- container.id = _globalConfig.containerId;
- container.className = _globalConfig.containerClass;
- container.style.position = "absolute";
- container.style.left = "0px";
- container.style.top = "-9999px";
- container.style.width = "1px";
- container.style.height = "1px";
- container.style.zIndex = "" + _getSafeZIndex(_globalConfig.zIndex);
- return container;
- };
- /**
- * Get the HTML element container that wraps the Flash bridge object/element.
- * @private
- */
- var _getHtmlBridge = function(flashBridge) {
- var htmlBridge = flashBridge && flashBridge.parentNode;
- while (htmlBridge && htmlBridge.nodeName === "OBJECT" && htmlBridge.parentNode) {
- htmlBridge = htmlBridge.parentNode;
- }
- return htmlBridge || null;
- };
- /**
- * Create the SWF object.
- *
- * @returns The SWF object reference.
- * @private
- */
- var _embedSwf = function() {
- var len, flashBridge = _flashState.bridge, container = _getHtmlBridge(flashBridge);
- if (!flashBridge) {
- var allowScriptAccess = _determineScriptAccess(_window.location.host, _globalConfig);
- var allowNetworking = allowScriptAccess === "never" ? "none" : "all";
- var flashvars = _vars(_extend({
- jsVersion: ZeroClipboard.version
- }, _globalConfig));
- var swfUrl = _globalConfig.swfPath + _cacheBust(_globalConfig.swfPath, _globalConfig);
- container = _createHtmlBridge();
- var divToBeReplaced = _document.createElement("div");
- container.appendChild(divToBeReplaced);
- _document.body.appendChild(container);
- var tmpDiv = _document.createElement("div");
- var usingActiveX = _flashState.pluginType === "activex";
- 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"> </div>' + "</object>";
- flashBridge = tmpDiv.firstChild;
- tmpDiv = null;
- _unwrap(flashBridge).ZeroClipboard = ZeroClipboard;
- container.replaceChild(flashBridge, divToBeReplaced);
- _watchForSwfFallbackContent();
- }
- if (!flashBridge) {
- flashBridge = _document[_globalConfig.swfObjectId];
- if (flashBridge && (len = flashBridge.length)) {
- flashBridge = flashBridge[len - 1];
- }
- if (!flashBridge && container) {
- flashBridge = container.firstChild;
- }
- }
- _flashState.bridge = flashBridge || null;
- return flashBridge;
- };
- /**
- * Destroy the SWF object.
- * @private
- */
- var _unembedSwf = function() {
- var flashBridge = _flashState.bridge;
- if (flashBridge) {
- var htmlBridge = _getHtmlBridge(flashBridge);
- if (htmlBridge) {
- if (_flashState.pluginType === "activex" && "readyState" in flashBridge) {
- flashBridge.style.display = "none";
- (function removeSwfFromIE() {
- if (flashBridge.readyState === 4) {
- for (var prop in flashBridge) {
- if (typeof flashBridge[prop] === "function") {
- flashBridge[prop] = null;
- }
- }
- if (flashBridge.parentNode) {
- flashBridge.parentNode.removeChild(flashBridge);
- }
- if (htmlBridge.parentNode) {
- htmlBridge.parentNode.removeChild(htmlBridge);
- }
- } else {
- _setTimeout(removeSwfFromIE, 10);
- }
- })();
- } else {
- if (flashBridge.parentNode) {
- flashBridge.parentNode.removeChild(flashBridge);
- }
- if (htmlBridge.parentNode) {
- htmlBridge.parentNode.removeChild(htmlBridge);
- }
- }
- }
- _clearTimeoutsAndPolling();
- _flashState.ready = null;
- _flashState.bridge = null;
- _flashState.deactivated = null;
- _zcSwfVersion = undefined;
- }
- };
- /**
- * Map the data format names of the "clipData" to Flash-friendly names.
- *
- * @returns A new transformed object.
- * @private
- */
- var _mapClipDataToFlash = function(clipData) {
- var newClipData = {}, formatMap = {};
- if (!(typeof clipData === "object" && clipData)) {
- return;
- }
- for (var dataFormat in clipData) {
- if (dataFormat && _hasOwn.call(clipData, dataFormat) && typeof clipData[dataFormat] === "string" && clipData[dataFormat]) {
- switch (dataFormat.toLowerCase()) {
- case "text/plain":
- case "text":
- case "air:text":
- case "flash:text":
- newClipData.text = clipData[dataFormat];
- formatMap.text = dataFormat;
- break;
-
- case "text/html":
- case "html":
- case "air:html":
- case "flash:html":
- newClipData.html = clipData[dataFormat];
- formatMap.html = dataFormat;
- break;
-
- case "application/rtf":
- case "text/rtf":
- case "rtf":
- case "richtext":
- case "air:rtf":
- case "flash:rtf":
- newClipData.rtf = clipData[dataFormat];
- formatMap.rtf = dataFormat;
- break;
-
- default:
- break;
- }
- }
- }
- return {
- data: newClipData,
- formatMap: formatMap
- };
- };
- /**
- * Map the data format names from Flash-friendly names back to their original "clipData" names (via a format mapping).
- *
- * @returns A new transformed object.
- * @private
- */
- var _mapClipResultsFromFlash = function(clipResults, formatMap) {
- if (!(typeof clipResults === "object" && clipResults && typeof formatMap === "object" && formatMap)) {
- return clipResults;
- }
- var newResults = {};
- for (var prop in clipResults) {
- if (_hasOwn.call(clipResults, prop)) {
- if (prop === "errors") {
- newResults[prop] = clipResults[prop] ? clipResults[prop].slice() : [];
- for (var i = 0, len = newResults[prop].length; i < len; i++) {
- newResults[prop][i].format = formatMap[newResults[prop][i].format];
- }
- } else if (prop !== "success" && prop !== "data") {
- newResults[prop] = clipResults[prop];
- } else {
- newResults[prop] = {};
- var tmpHash = clipResults[prop];
- for (var dataFormat in tmpHash) {
- if (dataFormat && _hasOwn.call(tmpHash, dataFormat) && _hasOwn.call(formatMap, dataFormat)) {
- newResults[prop][formatMap[dataFormat]] = tmpHash[dataFormat];
- }
- }
- }
- }
- }
- return newResults;
- };
- /**
- * Will look at a path, and will create a "?noCache={time}" or "&noCache={time}"
- * query param string to return. Does NOT append that string to the original path.
- * This is useful because ExternalInterface often breaks when a Flash SWF is cached.
- *
- * @returns The `noCache` query param with necessary "?"/"&" prefix.
- * @private
- */
- var _cacheBust = function(path, options) {
- var cacheBust = options == null || options && options.cacheBust === true;
- if (cacheBust) {
- return (path.indexOf("?") === -1 ? "?" : "&") + "noCache=" + _now();
- } else {
- return "";
- }
- };
- /**
- * Creates a query string for the FlashVars param.
- * Does NOT include the cache-busting query param.
- *
- * @returns FlashVars query string
- * @private
- */
- var _vars = function(options) {
- var i, len, domain, domains, str = "", trustedOriginsExpanded = [];
- if (options.trustedDomains) {
- if (typeof options.trustedDomains === "string") {
- domains = [ options.trustedDomains ];
- } else if (typeof options.trustedDomains === "object" && "length" in options.trustedDomains) {
- domains = options.trustedDomains;
- }
- }
- if (domains && domains.length) {
- for (i = 0, len = domains.length; i < len; i++) {
- if (_hasOwn.call(domains, i) && domains[i] && typeof domains[i] === "string") {
- domain = _extractDomain(domains[i]);
- if (!domain) {
- continue;
- }
- if (domain === "*") {
- trustedOriginsExpanded.length = 0;
- trustedOriginsExpanded.push(domain);
- break;
- }
- trustedOriginsExpanded.push.apply(trustedOriginsExpanded, [ domain, "//" + domain, _window.location.protocol + "//" + domain ]);
- }
- }
- }
- if (trustedOriginsExpanded.length) {
- str += "trustedOrigins=" + _encodeURIComponent(trustedOriginsExpanded.join(","));
- }
- if (options.forceEnhancedClipboard === true) {
- str += (str ? "&" : "") + "forceEnhancedClipboard=true";
- }
- if (typeof options.swfObjectId === "string" && options.swfObjectId) {
- str += (str ? "&" : "") + "swfObjectId=" + _encodeURIComponent(options.swfObjectId);
- }
- if (typeof options.jsVersion === "string" && options.jsVersion) {
- str += (str ? "&" : "") + "jsVersion=" + _encodeURIComponent(options.jsVersion);
- }
- return str;
- };
- /**
- * Extract the domain (e.g. "github.com") from an origin (e.g. "https://github.com") or
- * URL (e.g. "https://github.com/zeroclipboard/zeroclipboard/").
- *
- * @returns the domain
- * @private
- */
- var _extractDomain = function(originOrUrl) {
- if (originOrUrl == null || originOrUrl === "") {
- return null;
- }
- originOrUrl = originOrUrl.replace(/^\s+|\s+$/g, "");
- if (originOrUrl === "") {
- return null;
- }
- var protocolIndex = originOrUrl.indexOf("//");
- originOrUrl = protocolIndex === -1 ? originOrUrl : originOrUrl.slice(protocolIndex + 2);
- var pathIndex = originOrUrl.indexOf("/");
- originOrUrl = pathIndex === -1 ? originOrUrl : protocolIndex === -1 || pathIndex === 0 ? null : originOrUrl.slice(0, pathIndex);
- if (originOrUrl && originOrUrl.slice(-4).toLowerCase() === ".swf") {
- return null;
- }
- return originOrUrl || null;
- };
- /**
- * Set `allowScriptAccess` based on `trustedDomains` and `window.location.host` vs. `swfPath`.
- *
- * @returns The appropriate script access level.
- * @private
- */
- var _determineScriptAccess = function() {
- var _extractAllDomains = function(origins) {
- var i, len, tmp, resultsArray = [];
- if (typeof origins === "string") {
- origins = [ origins ];
- }
- if (!(typeof origins === "object" && origins && typeof origins.length === "number")) {
- return resultsArray;
- }
- for (i = 0, len = origins.length; i < len; i++) {
- if (_hasOwn.call(origins, i) && (tmp = _extractDomain(origins[i]))) {
- if (tmp === "*") {
- resultsArray.length = 0;
- resultsArray.push("*");
- break;
- }
- if (resultsArray.indexOf(tmp) === -1) {
- resultsArray.push(tmp);
- }
- }
- }
- return resultsArray;
- };
- return function(currentDomain, configOptions) {
- var swfDomain = _extractDomain(configOptions.swfPath);
- if (swfDomain === null) {
- swfDomain = currentDomain;
- }
- var trustedDomains = _extractAllDomains(configOptions.trustedDomains);
- var len = trustedDomains.length;
- if (len > 0) {
- if (len === 1 && trustedDomains[0] === "*") {
- return "always";
- }
- if (trustedDomains.indexOf(currentDomain) !== -1) {
- if (len === 1 && currentDomain === swfDomain) {
- return "sameDomain";
- }
- return "always";
- }
- }
- return "never";
- };
- }();
- /**
- * Get the currently active/focused DOM element.
- *
- * @returns the currently active/focused element, or `null`
- * @private
- */
- var _safeActiveElement = function() {
- try {
- return _document.activeElement;
- } catch (err) {
- return null;
- }
- };
- /**
- * Add a class to an element, if it doesn't already have it.
- *
- * @returns The element, with its new class added.
- * @private
- */
- var _addClass = function(element, value) {
- var c, cl, className, classNames = [];
- if (typeof value === "string" && value) {
- classNames = value.split(/\s+/);
- }
- if (element && element.nodeType === 1 && classNames.length > 0) {
- if (element.classList) {
- for (c = 0, cl = classNames.length; c < cl; c++) {
- element.classList.add(classNames[c]);
- }
- } else if (element.hasOwnProperty("className")) {
- className = " " + element.className + " ";
- for (c = 0, cl = classNames.length; c < cl; c++) {
- if (className.indexOf(" " + classNames[c] + " ") === -1) {
- className += classNames[c] + " ";
- }
- }
- element.className = className.replace(/^\s+|\s+$/g, "");
- }
- }
- return element;
- };
- /**
- * Remove a class from an element, if it has it.
- *
- * @returns The element, with its class removed.
- * @private
- */
- var _removeClass = function(element, value) {
- var c, cl, className, classNames = [];
- if (typeof value === "string" && value) {
- classNames = value.split(/\s+/);
- }
- if (element && element.nodeType === 1 && classNames.length > 0) {
- if (element.classList && element.classList.length > 0) {
- for (c = 0, cl = classNames.length; c < cl; c++) {
- element.classList.remove(classNames[c]);
- }
- } else if (element.className) {
- className = (" " + element.className + " ").replace(/[\r\n\t]/g, " ");
- for (c = 0, cl = classNames.length; c < cl; c++) {
- className = className.replace(" " + classNames[c] + " ", " ");
- }
- element.className = className.replace(/^\s+|\s+$/g, "");
- }
- }
- return element;
- };
- /**
- * Attempt to interpret the element's CSS styling. If `prop` is `"cursor"`,
- * then we assume that it should be a hand ("pointer") cursor if the element
- * is an anchor element ("a" tag).
- *
- * @returns The computed style property.
- * @private
- */
- var _getStyle = function(el, prop) {
- var value = _getComputedStyle(el, null).getPropertyValue(prop);
- if (prop === "cursor") {
- if (!value || value === "auto") {
- if (el.nodeName === "A") {
- return "pointer";
- }
- }
- }
- return value;
- };
- /**
- * Get the absolutely positioned coordinates of a DOM element.
- *
- * @returns Object containing the element's position, width, and height.
- * @private
- */
- var _getElementPosition = function(el) {
- var pos = {
- left: 0,
- top: 0,
- width: 0,
- height: 0
- };
- if (el.getBoundingClientRect) {
- var elRect = el.getBoundingClientRect();
- var pageXOffset = _window.pageXOffset;
- var pageYOffset = _window.pageYOffset;
- var leftBorderWidth = _document.documentElement.clientLeft || 0;
- var topBorderWidth = _document.documentElement.clientTop || 0;
- var leftBodyOffset = 0;
- var topBodyOffset = 0;
- if (_getStyle(_document.body, "position") === "relative") {
- var bodyRect = _document.body.getBoundingClientRect();
- var htmlRect = _document.documentElement.getBoundingClientRect();
- leftBodyOffset = bodyRect.left - htmlRect.left || 0;
- topBodyOffset = bodyRect.top - htmlRect.top || 0;
- }
- pos.left = elRect.left + pageXOffset - leftBorderWidth - leftBodyOffset;
- pos.top = elRect.top + pageYOffset - topBorderWidth - topBodyOffset;
- pos.width = "width" in elRect ? elRect.width : elRect.right - elRect.left;
- pos.height = "height" in elRect ? elRect.height : elRect.bottom - elRect.top;
- }
- return pos;
- };
- /**
- * Determine is an element is visible somewhere within the document (page).
- *
- * @returns Boolean
- * @private
- */
- var _isElementVisible = function(el) {
- if (!el) {
- return false;
- }
- var styles = _getComputedStyle(el, null);
- var hasCssHeight = _parseFloat(styles.height) > 0;
- var hasCssWidth = _parseFloat(styles.width) > 0;
- var hasCssTop = _parseFloat(styles.top) >= 0;
- var hasCssLeft = _parseFloat(styles.left) >= 0;
- var cssKnows = hasCssHeight && hasCssWidth && hasCssTop && hasCssLeft;
- var rect = cssKnows ? null : _getElementPosition(el);
- 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));
- return isVisible;
- };
- /**
- * Clear all existing timeouts and interval polling delegates.
- *
- * @returns `undefined`
- * @private
- */
- var _clearTimeoutsAndPolling = function() {
- _clearTimeout(_flashCheckTimeout);
- _flashCheckTimeout = 0;
- _clearInterval(_swfFallbackCheckInterval);
- _swfFallbackCheckInterval = 0;
- };
- /**
- * Reposition the Flash object to cover the currently activated element.
- *
- * @returns `undefined`
- * @private
- */
- var _reposition = function() {
- var htmlBridge;
- if (_currentElement && (htmlBridge = _getHtmlBridge(_flashState.bridge))) {
- var pos = _getElementPosition(_currentElement);
- _extend(htmlBridge.style, {
- width: pos.width + "px",
- height: pos.height + "px",
- top: pos.top + "px",
- left: pos.left + "px",
- zIndex: "" + _getSafeZIndex(_globalConfig.zIndex)
- });
- }
- };
- /**
- * Sends a signal to the Flash object to display the hand cursor if `true`.
- *
- * @returns `undefined`
- * @private
- */
- var _setHandCursor = function(enabled) {
- if (_flashState.ready === true) {
- if (_flashState.bridge && typeof _flashState.bridge.setHandCursor === "function") {
- _flashState.bridge.setHandCursor(enabled);
- } else {
- _flashState.ready = false;
- }
- }
- };
- /**
- * Get a safe value for `zIndex`
- *
- * @returns an integer, or "auto"
- * @private
- */
- var _getSafeZIndex = function(val) {
- if (/^(?:auto|inherit)$/.test(val)) {
- return val;
- }
- var zIndex;
- if (typeof val === "number" && !_isNaN(val)) {
- zIndex = val;
- } else if (typeof val === "string") {
- zIndex = _getSafeZIndex(_parseInt(val, 10));
- }
- return typeof zIndex === "number" ? zIndex : "auto";
- };
- /**
- * Attempt to detect if ZeroClipboard is executing inside of a sandboxed iframe.
- * If it is, Flash Player cannot be used, so ZeroClipboard is dead in the water.
- *
- * @see {@link http://lists.w3.org/Archives/Public/public-whatwg-archive/2014Dec/0002.html}
- * @see {@link https://github.com/zeroclipboard/zeroclipboard/issues/511}
- * @see {@link http://zeroclipboard.org/test-iframes.html}
- *
- * @returns `true` (is sandboxed), `false` (is not sandboxed), or `null` (uncertain)
- * @private
- */
- var _detectSandbox = function(doNotReassessFlashSupport) {
- var effectiveScriptOrigin, frame, frameError, previousState = _flashState.sandboxed, isSandboxed = null;
- doNotReassessFlashSupport = doNotReassessFlashSupport === true;
- if (_pageIsFramed === false) {
- isSandboxed = false;
- } else {
- try {
- frame = window.frameElement || null;
- } catch (e) {
- frameError = {
- name: e.name,
- message: e.message
- };
- }
- if (frame && frame.nodeType === 1 && frame.nodeName === "IFRAME") {
- try {
- isSandboxed = frame.hasAttribute("sandbox");
- } catch (e) {
- isSandboxed = null;
- }
- } else {
- try {
- effectiveScriptOrigin = document.domain || null;
- } catch (e) {
- effectiveScriptOrigin = null;
- }
- if (effectiveScriptOrigin === null || frameError && frameError.name === "SecurityError" && /(^|[\s\(\[@])sandbox(es|ed|ing|[\s\.,!\)\]@]|$)/.test(frameError.message.toLowerCase())) {
- isSandboxed = true;
- }
- }
- }
- _flashState.sandboxed = isSandboxed;
- if (previousState !== isSandboxed && !doNotReassessFlashSupport) {
- _detectFlashSupport(_ActiveXObject);
- }
- return isSandboxed;
- };
- /**
- * Detect the Flash Player status, version, and plugin type.
- *
- * @see {@link https://code.google.com/p/doctype-mirror/wiki/ArticleDetectFlash#The_code}
- * @see {@link http://stackoverflow.com/questions/12866060/detecting-pepper-ppapi-flash-with-javascript}
- *
- * @returns `undefined`
- * @private
- */
- var _detectFlashSupport = function(ActiveXObject) {
- var plugin, ax, mimeType, hasFlash = false, isActiveX = false, isPPAPI = false, flashVersion = "";
- /**
- * Derived from Apple's suggested sniffer.
- * @param {String} desc e.g. "Shockwave Flash 7.0 r61"
- * @returns {String} "7.0.61"
- * @private
- */
- function parseFlashVersion(desc) {
- var matches = desc.match(/[\d]+/g);
- matches.length = 3;
- return matches.join(".");
- }
- function isPepperFlash(flashPlayerFileName) {
- return !!flashPlayerFileName && (flashPlayerFileName = flashPlayerFileName.toLowerCase()) && (/^(pepflashplayer\.dll|libpepflashplayer\.so|pepperflashplayer\.plugin)$/.test(flashPlayerFileName) || flashPlayerFileName.slice(-13) === "chrome.plugin");
- }
- function inspectPlugin(plugin) {
- if (plugin) {
- hasFlash = true;
- if (plugin.version) {
- flashVersion = parseFlashVersion(plugin.version);
- }
- if (!flashVersion && plugin.description) {
- flashVersion = parseFlashVersion(plugin.description);
- }
- if (plugin.filename) {
- isPPAPI = isPepperFlash(plugin.filename);
- }
- }
- }
- if (_navigator.plugins && _navigator.plugins.length) {
- plugin = _navigator.plugins["Shockwave Flash"];
- inspectPlugin(plugin);
- if (_navigator.plugins["Shockwave Flash 2.0"]) {
- hasFlash = true;
- flashVersion = "2.0.0.11";
- }
- } else if (_navigator.mimeTypes && _navigator.mimeTypes.length) {
- mimeType = _navigator.mimeTypes["application/x-shockwave-flash"];
- plugin = mimeType && mimeType.enabledPlugin;
- inspectPlugin(plugin);
- } else if (typeof ActiveXObject !== "undefined") {
- isActiveX = true;
- try {
- ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
- hasFlash = true;
- flashVersion = parseFlashVersion(ax.GetVariable("$version"));
- } catch (e1) {
- try {
- ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
- hasFlash = true;
- flashVersion = "6.0.21";
- } catch (e2) {
- try {
- ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- hasFlash = true;
- flashVersion = parseFlashVersion(ax.GetVariable("$version"));
- } catch (e3) {
- isActiveX = false;
- }
- }
- }
- }
- _flashState.disabled = hasFlash !== true;
- _flashState.outdated = flashVersion && _parseFloat(flashVersion) < _parseFloat(_minimumFlashVersion);
- _flashState.version = flashVersion || "0.0.0";
- _flashState.pluginType = isPPAPI ? "pepper" : isActiveX ? "activex" : hasFlash ? "netscape" : "unknown";
- };
- /**
- * Invoke the Flash detection algorithms immediately upon inclusion so we're not waiting later.
- */
- _detectFlashSupport(_ActiveXObject);
- /**
- * Always assess the `sandboxed` state of the page at important Flash-related moments.
- */
- _detectSandbox(true);
- /**
- * A shell constructor for `ZeroClipboard` client instances.
- *
- * @constructor
- */
- var ZeroClipboard = function() {
- if (!(this instanceof ZeroClipboard)) {
- return new ZeroClipboard();
- }
- if (typeof ZeroClipboard._createClient === "function") {
- ZeroClipboard._createClient.apply(this, _args(arguments));
- }
- };
- /**
- * The ZeroClipboard library's version number.
- *
- * @static
- * @readonly
- * @property {string}
- */
- _defineProperty(ZeroClipboard, "version", {
- value: "2.2.0",
- writable: false,
- configurable: true,
- enumerable: true
- });
- /**
- * Update or get a copy of the ZeroClipboard global configuration.
- * Returns a copy of the current/updated configuration.
- *
- * @returns Object
- * @static
- */
- ZeroClipboard.config = function() {
- return _config.apply(this, _args(arguments));
- };
- /**
- * Diagnostic method that describes the state of the browser, Flash Player, and ZeroClipboard.
- *
- * @returns Object
- * @static
- */
- ZeroClipboard.state = function() {
- return _state.apply(this, _args(arguments));
- };
- /**
- * Check if Flash is unusable for any reason: disabled, outdated, deactivated, etc.
- *
- * @returns Boolean
- * @static
- */
- ZeroClipboard.isFlashUnusable = function() {
- return _isFlashUnusable.apply(this, _args(arguments));
- };
- /**
- * Register an event listener.
- *
- * @returns `ZeroClipboard`
- * @static
- */
- ZeroClipboard.on = function() {
- return _on.apply(this, _args(arguments));
- };
- /**
- * Unregister an event listener.
- * If no `listener` function/object is provided, it will unregister all listeners for the provided `eventType`.
- * If no `eventType` is provided, it will unregister all listeners for every event type.
- *
- * @returns `ZeroClipboard`
- * @static
- */
- ZeroClipboard.off = function() {
- return _off.apply(this, _args(arguments));
- };
- /**
- * Retrieve event listeners for an `eventType`.
- * If no `eventType` is provided, it will retrieve all listeners for every event type.
- *
- * @returns array of listeners for the `eventType`; if no `eventType`, then a map/hash object of listeners for all event types; or `null`
- */
- ZeroClipboard.handlers = function() {
- return _listeners.apply(this, _args(arguments));
- };
- /**
- * Event emission receiver from the Flash object, forwarding to any registered JavaScript event listeners.
- *
- * @returns For the "copy" event, returns the Flash-friendly "clipData" object; otherwise `undefined`.
- * @static
- */
- ZeroClipboard.emit = function() {
- return _emit.apply(this, _args(arguments));
- };
- /**
- * Create and embed the Flash object.
- *
- * @returns The Flash object
- * @static
- */
- ZeroClipboard.create = function() {
- return _create.apply(this, _args(arguments));
- };
- /**
- * Self-destruct and clean up everything, including the embedded Flash object.
- *
- * @returns `undefined`
- * @static
- */
- ZeroClipboard.destroy = function() {
- return _destroy.apply(this, _args(arguments));
- };
- /**
- * Set the pending data for clipboard injection.
- *
- * @returns `undefined`
- * @static
- */
- ZeroClipboard.setData = function() {
- return _setData.apply(this, _args(arguments));
- };
- /**
- * Clear the pending data for clipboard injection.
- * If no `format` is provided, all pending data formats will be cleared.
- *
- * @returns `undefined`
- * @static
- */
- ZeroClipboard.clearData = function() {
- return _clearData.apply(this, _args(arguments));
- };
- /**
- * Get a copy of the pending data for clipboard injection.
- * If no `format` is provided, a copy of ALL pending data formats will be returned.
- *
- * @returns `String` or `Object`
- * @static
- */
- ZeroClipboard.getData = function() {
- return _getData.apply(this, _args(arguments));
- };
- /**
- * Sets the current HTML object that the Flash object should overlay. This will put the global
- * Flash object on top of the current element; depending on the setup, this may also set the
- * pending clipboard text data as well as the Flash object's wrapping element's title attribute
- * based on the underlying HTML element and ZeroClipboard configuration.
- *
- * @returns `undefined`
- * @static
- */
- ZeroClipboard.focus = ZeroClipboard.activate = function() {
- return _focus.apply(this, _args(arguments));
- };
- /**
- * Un-overlays the Flash object. This will put the global Flash object off-screen; depending on
- * the setup, this may also unset the Flash object's wrapping element's title attribute based on
- * the underlying HTML element and ZeroClipboard configuration.
- *
- * @returns `undefined`
- * @static
- */
- ZeroClipboard.blur = ZeroClipboard.deactivate = function() {
- return _blur.apply(this, _args(arguments));
- };
- /**
- * Returns the currently focused/"activated" HTML element that the Flash object is wrapping.
- *
- * @returns `HTMLElement` or `null`
- * @static
- */
- ZeroClipboard.activeElement = function() {
- return _activeElement.apply(this, _args(arguments));
- };
- /**
- * Keep track of the ZeroClipboard client instance counter.
- */
- var _clientIdCounter = 0;
- /**
- * Keep track of the state of the client instances.
- *
- * Entry structure:
- * _clientMeta[client.id] = {
- * instance: client,
- * elements: [],
- * handlers: {}
- * };
- */
- var _clientMeta = {};
- /**
- * Keep track of the ZeroClipboard clipped elements counter.
- */
- var _elementIdCounter = 0;
- /**
- * Keep track of the state of the clipped element relationships to clients.
- *
- * Entry structure:
- * _elementMeta[element.zcClippingId] = [client1.id, client2.id];
- */
- var _elementMeta = {};
- /**
- * Keep track of the state of the mouse event handlers for clipped elements.
- *
- * Entry structure:
- * _mouseHandlers[element.zcClippingId] = {
- * mouseover: function(event) {},
- * mouseout: function(event) {},
- * mouseenter: function(event) {},
- * mouseleave: function(event) {},
- * mousemove: function(event) {}
- * };
- */
- var _mouseHandlers = {};
- /**
- * Extending the ZeroClipboard configuration defaults for the Client module.
- */
- _extend(_globalConfig, {
- autoActivate: true
- });
- /**
- * The real constructor for `ZeroClipboard` client instances.
- * @private
- */
- var _clientConstructor = function(elements) {
- var client = this;
- client.id = "" + _clientIdCounter++;
- _clientMeta[client.id] = {
- instance: client,
- elements: [],
- handlers: {}
- };
- if (elements) {
- client.clip(elements);
- }
- ZeroClipboard.on("*", function(event) {
- return client.emit(event);
- });
- ZeroClipboard.on("destroy", function() {
- client.destroy();
- });
- ZeroClipboard.create();
- };
- /**
- * The underlying implementation of `ZeroClipboard.Client.prototype.on`.
- * @private
- */
- var _clientOn = function(eventType, listener) {
- var i, len, events, added = {}, meta = _clientMeta[this.id], handlers = meta && meta.handlers;
- if (!meta) {
- throw new Error("Attempted to add new listener(s) to a destroyed ZeroClipboard client instance");
- }
- if (typeof eventType === "string" && eventType) {
- events = eventType.toLowerCase().split(/\s+/);
- } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
- for (i in eventType) {
- if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
- this.on(i, eventType[i]);
- }
- }
- }
- if (events && events.length) {
- for (i = 0, len = events.length; i < len; i++) {
- eventType = events[i].replace(/^on/, "");
- added[eventType] = true;
- if (!handlers[eventType]) {
- handlers[eventType] = [];
- }
- handlers[eventType].push(listener);
- }
- if (added.ready && _flashState.ready) {
- this.emit({
- type: "ready",
- client: this
- });
- }
- if (added.error) {
- for (i = 0, len = _flashStateErrorNames.length; i < len; i++) {
- if (_flashState[_flashStateErrorNames[i].replace(/^flash-/, "")]) {
- this.emit({
- type: "error",
- name: _flashStateErrorNames[i],
- client: this
- });
- break;
- }
- }
- if (_zcSwfVersion !== undefined && ZeroClipboard.version !== _zcSwfVersion) {
- this.emit({
- type: "error",
- name: "version-mismatch",
- jsVersion: ZeroClipboard.version,
- swfVersion: _zcSwfVersion
- });
- }
- }
- }
- return this;
- };
- /**
- * The underlying implementation of `ZeroClipboard.Client.prototype.off`.
- * @private
- */
- var _clientOff = function(eventType, listener) {
- var i, len, foundIndex, events, perEventHandlers, meta = _clientMeta[this.id], handlers = meta && meta.handlers;
- if (!handlers) {
- return this;
- }
- if (arguments.length === 0) {
- events = _keys(handlers);
- } else if (typeof eventType === "string" && eventType) {
- events = eventType.split(/\s+/);
- } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
- for (i in eventType) {
- if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
- this.off(i, eventType[i]);
- }
- }
- }
- if (events && events.length) {
- for (i = 0, len = events.length; i < len; i++) {
- eventType = events[i].toLowerCase().replace(/^on/, "");
- perEventHandlers = handlers[eventType];
- if (perEventHandlers && perEventHandlers.length) {
- if (listener) {
- foundIndex = perEventHandlers.indexOf(listener);
- while (foundIndex !== -1) {
- perEventHandlers.splice(foundIndex, 1);
- foundIndex = perEventHandlers.indexOf(listener, foundIndex);
- }
- } else {
- perEventHandlers.length = 0;
- }
- }
- }
- }
- return this;
- };
- /**
- * The underlying implementation of `ZeroClipboard.Client.prototype.handlers`.
- * @private
- */
- var _clientListeners = function(eventType) {
- var copy = null, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
- if (handlers) {
- if (typeof eventType === "string" && eventType) {
- copy = handlers[eventType] ? handlers[eventType].slice(0) : [];
- } else {
- copy = _deepCopy(handlers);
- }
- }
- return copy;
- };
- /**
- * The underlying implementation of `ZeroClipboard.Client.prototype.emit`.
- * @private
- */
- var _clientEmit = function(event) {
- if (_clientShouldEmit.call(this, event)) {
- if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
- event = _extend({}, event);
- }
- var eventCopy = _extend({}, _createEvent(event), {
- client: this
- });
- _clientDispatchCallbacks.call(this, eventCopy);
- }
- return this;
- };
- /**
- * The underlying implementation of `ZeroClipboard.Client.prototype.clip`.
- * @private
- */
- var _clientClip = function(elements) {
- if (!_clientMeta[this.id]) {
- throw new Error("Attempted to clip element(s) to a destroyed ZeroClipboard client instance");
- }
- elements = _prepClip(elements);
- for (var i = 0; i < elements.length; i++) {
- if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
- if (!elements[i].zcClippingId) {
- elements[i].zcClippingId = "zcClippingId_" + _elementIdCounter++;
- _elementMeta[elements[i].zcClippingId] = [ this.id ];
- if (_globalConfig.autoActivate === true) {
- _addMouseHandlers(elements[i]);
- }
- } else if (_elementMeta[elements[i].zcClippingId].indexOf(this.id) === -1) {
- _elementMeta[elements[i].zcClippingId].push(this.id);
- }
- var clippedElements = _clientMeta[this.id] && _clientMeta[this.id].elements;
- if (clippedElements.indexOf(elements[i]) === -1) {
- clippedElements.push(elements[i]);
- }
- }
- }
- return this;
- };
- /**
- * The underlying implementation of `ZeroClipboard.Client.prototype.unclip`.
- * @private
- */
- var _clientUnclip = function(elements) {
- var meta = _clientMeta[this.id];
- if (!meta) {
- return this;
- }
- var clippedElements = meta.elements;
- var arrayIndex;
- if (typeof elements === "undefined") {
- elements = clippedElements.slice(0);
- } else {
- elements = _prepClip(elements);
- }
- for (var i = elements.length; i--; ) {
- if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
- arrayIndex = 0;
- while ((arrayIndex = clippedElements.indexOf(elements[i], arrayIndex)) !== -1) {
- clippedElements.splice(arrayIndex, 1);
- }
- var clientIds = _elementMeta[elements[i].zcClippingId];
- if (clientIds) {
- arrayIndex = 0;
- while ((arrayIndex = clientIds.indexOf(this.id, arrayIndex)) !== -1) {
- clientIds.splice(arrayIndex, 1);
- }
- if (clientIds.length === 0) {
- if (_globalConfig.autoActivate === true) {
- _removeMouseHandlers(elements[i]);
- }
- delete elements[i].zcClippingId;
- }
- }
- }
- }
- return this;
- };
- /**
- * The underlying implementation of `ZeroClipboard.Client.prototype.elements`.
- * @private
- */
- var _clientElements = function() {
- var meta = _clientMeta[this.id];
- return meta && meta.elements ? meta.elements.slice(0) : [];
- };
- /**
- * The underlying implementation of `ZeroClipboard.Client.prototype.destroy`.
- * @private
- */
- var _clientDestroy = function() {
- if (!_clientMeta[this.id]) {
- return;
- }
- this.unclip();
- this.off();
- delete _clientMeta[this.id];
- };
- /**
- * Inspect an Event to see if the Client (`this`) should honor it for emission.
- * @private
- */
- var _clientShouldEmit = function(event) {
- if (!(event && event.type)) {
- return false;
- }
- if (event.client && event.client !== this) {
- return false;
- }
- var meta = _clientMeta[this.id];
- var clippedEls = meta && meta.elements;
- var hasClippedEls = !!clippedEls && clippedEls.length > 0;
- var goodTarget = !event.target || hasClippedEls && clippedEls.indexOf(event.target) !== -1;
- var goodRelTarget = event.relatedTarget && hasClippedEls && clippedEls.indexOf(event.relatedTarget) !== -1;
- var goodClient = event.client && event.client === this;
- if (!meta || !(goodTarget || goodRelTarget || goodClient)) {
- return false;
- }
- return true;
- };
- /**
- * Handle the actual dispatching of events to a client instance.
- *
- * @returns `undefined`
- * @private
- */
- var _clientDispatchCallbacks = function(event) {
- var meta = _clientMeta[this.id];
- if (!(typeof event === "object" && event && event.type && meta)) {
- return;
- }
- var async = _shouldPerformAsync(event);
- var wildcardTypeHandlers = meta && meta.handlers["*"] || [];
- var specificTypeHandlers = meta && meta.handlers[event.type] || [];
- var handlers = wildcardTypeHandlers.concat(specificTypeHandlers);
- if (handlers && handlers.length) {
- var i, len, func, context, eventCopy, originalContext = this;
- for (i = 0, len = handlers.length; i < len; i++) {
- func = handlers[i];
- context = originalContext;
- if (typeof func === "string" && typeof _window[func] === "function") {
- func = _window[func];
- }
- if (typeof func === "object" && func && typeof func.handleEvent === "function") {
- context = func;
- func = func.handleEvent;
- }
- if (typeof func === "function") {
- eventCopy = _extend({}, event);
- _dispatchCallback(func, context, [ eventCopy ], async);
- }
- }
- }
- };
- /**
- * Prepares the elements for clipping/unclipping.
- *
- * @returns An Array of elements.
- * @private
- */
- var _prepClip = function(elements) {
- if (typeof elements === "string") {
- elements = [];
- }
- return typeof elements.length !== "number" ? [ elements ] : elements;
- };
- /**
- * Add a `mouseover` handler function for a clipped element.
- *
- * @returns `undefined`
- * @private
- */
- var _addMouseHandlers = function(element) {
- if (!(element && element.nodeType === 1)) {
- return;
- }
- var _suppressMouseEvents = function(event) {
- if (!(event || (event = _window.event))) {
- return;
- }
- if (event._source !== "js") {
- event.stopImmediatePropagation();
- event.preventDefault();
- }
- delete event._source;
- };
- var _elementMouseOver = function(event) {
- if (!(event || (event = _window.event))) {
- return;
- }
- _suppressMouseEvents(event);
- ZeroClipboard.focus(element);
- };
- element.addEventListener("mouseover", _elementMouseOver, false);
- element.addEventListener("mouseout", _suppressMouseEvents, false);
- element.addEventListener("mouseenter", _suppressMouseEvents, false);
- element.addEventListener("mouseleave", _suppressMouseEvents, false);
- element.addEventListener("mousemove", _suppressMouseEvents, false);
- _mouseHandlers[element.zcClippingId] = {
- mouseover: _elementMouseOver,
- mouseout: _suppressMouseEvents,
- mouseenter: _suppressMouseEvents,
- mouseleave: _suppressMouseEvents,
- mousemove: _suppressMouseEvents
- };
- };
- /**
- * Remove a `mouseover` handler function for a clipped element.
- *
- * @returns `undefined`
- * @private
- */
- var _removeMouseHandlers = function(element) {
- if (!(element && element.nodeType === 1)) {
- return;
- }
- var mouseHandlers = _mouseHandlers[element.zcClippingId];
- if (!(typeof mouseHandlers === "object" && mouseHandlers)) {
- return;
- }
- var key, val, mouseEvents = [ "move", "leave", "enter", "out", "over" ];
- for (var i = 0, len = mouseEvents.length; i < len; i++) {
- key = "mouse" + mouseEvents[i];
- val = mouseHandlers[key];
- if (typeof val === "function") {
- element.removeEventListener(key, val, false);
- }
- }
- delete _mouseHandlers[element.zcClippingId];
- };
- /**
- * Creates a new ZeroClipboard client instance.
- * Optionally, auto-`clip` an element or collection of elements.
- *
- * @constructor
- */
- ZeroClipboard._createClient = function() {
- _clientConstructor.apply(this, _args(arguments));
- };
- /**
- * Register an event listener to the client.
- *
- * @returns `this`
- */
- ZeroClipboard.prototype.on = function() {
- return _clientOn.apply(this, _args(arguments));
- };
- /**
- * Unregister an event handler from the client.
- * If no `listener` function/object is provided, it will unregister all handlers for the provided `eventType`.
- * If no `eventType` is provided, it will unregister all handlers for every event type.
- *
- * @returns `this`
- */
- ZeroClipboard.prototype.off = function() {
- return _clientOff.apply(this, _args(arguments));
- };
- /**
- * Retrieve event listeners for an `eventType` from the client.
- * If no `eventType` is provided, it will retrieve all listeners for every event type.
- *
- * @returns array of listeners for the `eventType`; if no `eventType`, then a map/hash object of listeners for all event types; or `null`
- */
- ZeroClipboard.prototype.handlers = function() {
- return _clientListeners.apply(this, _args(arguments));
- };
- /**
- * Event emission receiver from the Flash object for this client's registered JavaScript event listeners.
- *
- * @returns For the "copy" event, returns the Flash-friendly "clipData" object; otherwise `undefined`.
- */
- ZeroClipboard.prototype.emit = function() {
- return _clientEmit.apply(this, _args(arguments));
- };
- /**
- * Register clipboard actions for new element(s) to the client.
- *
- * @returns `this`
- */
- ZeroClipboard.prototype.clip = function() {
- return _clientClip.apply(this, _args(arguments));
- };
- /**
- * Unregister the clipboard actions of previously registered element(s) on the page.
- * If no elements are provided, ALL registered elements will be unregistered.
- *
- * @returns `this`
- */
- ZeroClipboard.prototype.unclip = function() {
- return _clientUnclip.apply(this, _args(arguments));
- };
- /**
- * Get all of the elements to which this client is clipped.
- *
- * @returns array of clipped elements
- */
- ZeroClipboard.prototype.elements = function() {
- return _clientElements.apply(this, _args(arguments));
- };
- /**
- * Self-destruct and clean up everything for a single client.
- * This will NOT destroy the embedded Flash object.
- *
- * @returns `undefined`
- */
- ZeroClipboard.prototype.destroy = function() {
- return _clientDestroy.apply(this, _args(arguments));
- };
- /**
- * Stores the pending plain text to inject into the clipboard.
- *
- * @returns `this`
- */
- ZeroClipboard.prototype.setText = function(text) {
- if (!_clientMeta[this.id]) {
- throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
- }
- ZeroClipboard.setData("text/plain", text);
- return this;
- };
- /**
- * Stores the pending HTML text to inject into the clipboard.
- *
- * @returns `this`
- */
- ZeroClipboard.prototype.setHtml = function(html) {
- if (!_clientMeta[this.id]) {
- throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
- }
- ZeroClipboard.setData("text/html", html);
- return this;
- };
- /**
- * Stores the pending rich text (RTF) to inject into the clipboard.
- *
- * @returns `this`
- */
- ZeroClipboard.prototype.setRichText = function(richText) {
- if (!_clientMeta[this.id]) {
- throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
- }
- ZeroClipboard.setData("application/rtf", richText);
- return this;
- };
- /**
- * Stores the pending data to inject into the clipboard.
- *
- * @returns `this`
- */
- ZeroClipboard.prototype.setData = function() {
- if (!_clientMeta[this.id]) {
- throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
- }
- ZeroClipboard.setData.apply(this, _args(arguments));
- return this;
- };
- /**
- * Clears the pending data to inject into the clipboard.
- * If no `format` is provided, all pending data formats will be cleared.
- *
- * @returns `this`
- */
- ZeroClipboard.prototype.clearData = function() {
- if (!_clientMeta[this.id]) {
- throw new Error("Attempted to clear pending clipboard data from a destroyed ZeroClipboard client instance");
- }
- ZeroClipboard.clearData.apply(this, _args(arguments));
- return this;
- };
- /**
- * Gets a copy of the pending data to inject into the clipboard.
- * If no `format` is provided, a copy of ALL pending data formats will be returned.
- *
- * @returns `String` or `Object`
- */
- ZeroClipboard.prototype.getData = function() {
- if (!_clientMeta[this.id]) {
- throw new Error("Attempted to get pending clipboard data from a destroyed ZeroClipboard client instance");
- }
- return ZeroClipboard.getData.apply(this, _args(arguments));
- };
- if (typeof define === "function" && define.amd) {
- define(function() {
- return ZeroClipboard;
- });
- } else if (typeof module === "object" && module && typeof module.exports === "object" && module.exports) {
- module.exports = ZeroClipboard;
- } else {
- window.ZeroClipboard = ZeroClipboard;
- }
- })(function() {
- return this || window;
- }());
- },{}]},{},[23,47,48,49,65,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,86,87,88,72,73,74,75,76,77,31,35,32,33,40,34,36,37,38,39])("zeroclipboard")
- });
|