Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

handsontable.full.js 899KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181
  1. /*!
  2. * Handsontable 0.15.0
  3. * Handsontable is a JavaScript library for editable tables with basic copy-paste compatibility with Excel and Google Docs
  4. *
  5. * Copyright (c) 2012-2014 Marcin Warpechowski
  6. * Copyright 2015 Handsoncode sp. z o.o. <hello@handsontable.com>
  7. * Licensed under the MIT license.
  8. * http://handsontable.com/
  9. *
  10. * Date: Fri Jun 19 2015 09:15:37 GMT+0200 (CEST)
  11. */
  12. /*jslint white: true, browser: true, plusplus: true, indent: 4, maxerr: 50 */
  13. window.Handsontable = {
  14. version: '0.15.0',
  15. buildDate: 'Fri Jun 19 2015 09:15:37 GMT+0200 (CEST)'
  16. };
  17. (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) {
  18. (function outer (modules, cache, entry) {
  19. // Save the require from previous bundle to this closure if any
  20. var previousRequire = typeof require == "function" && require;
  21. var globalNS = JSON.parse('{"zeroclipboard":"ZeroClipboard","copyPaste":"copyPaste","SheetClip":"SheetClip","jsonpatch":"jsonpatch","moment":"moment","numeral":"numeral","pikaday":"Pikaday","autoResize":"autoResize"}') || {};
  22. function newRequire(name, jumped){
  23. if(!cache[name]) {
  24. if(!modules[name]) {
  25. // if we cannot find the the module within our internal map or
  26. // cache jump to the current global require ie. the last bundle
  27. // that was added to the page.
  28. var currentRequire = typeof require == "function" && require;
  29. if (!jumped && currentRequire) return currentRequire(name, true);
  30. // If there are other bundles on this page the require from the
  31. // previous one is saved to 'previousRequire'. Repeat this as
  32. // many times as there are bundles until the module is found or
  33. // we exhaust the require chain.
  34. if (previousRequire) return previousRequire(name, true);
  35. // Try find module from global scope
  36. if (globalNS[name] && typeof window[globalNS[name]] !== 'undefined') {
  37. return window[globalNS[name]];
  38. }
  39. var err = new Error('Cannot find module \'' + name + '\'');
  40. err.code = 'MODULE_NOT_FOUND';
  41. throw err;
  42. }
  43. var m = cache[name] = {exports:{}};
  44. modules[name][0].call(m.exports, function(x){
  45. var id = modules[name][1][x];
  46. return newRequire(id ? id : x);
  47. },m,m.exports,outer,modules,cache,entry);
  48. }
  49. return cache[name].exports;
  50. }
  51. for(var i=0;i<entry.length;i++) newRequire(entry[i]);
  52. // Override the current require with this new one
  53. return newRequire;
  54. })(modules, cache, entry);
  55. return function() {
  56. return Handsontable;
  57. };
  58. })
  59. ({1:[function(require,module,exports){
  60. "use strict";
  61. if (window.jQuery) {
  62. (function(window, $, Handsontable) {
  63. $.fn.handsontable = function(action) {
  64. var i,
  65. ilen,
  66. args,
  67. output,
  68. userSettings,
  69. $this = this.first(),
  70. instance = $this.data('handsontable');
  71. if (typeof action !== 'string') {
  72. userSettings = action || {};
  73. if (instance) {
  74. instance.updateSettings(userSettings);
  75. } else {
  76. instance = new Handsontable.Core($this[0], userSettings);
  77. $this.data('handsontable', instance);
  78. instance.init();
  79. }
  80. return $this;
  81. } else {
  82. args = [];
  83. if (arguments.length > 1) {
  84. for (i = 1, ilen = arguments.length; i < ilen; i++) {
  85. args.push(arguments[i]);
  86. }
  87. }
  88. if (instance) {
  89. if (typeof instance[action] !== 'undefined') {
  90. output = instance[action].apply(instance, args);
  91. if (action === 'destroy') {
  92. $this.removeData();
  93. }
  94. } else {
  95. throw new Error('Handsontable do not provide action: ' + action);
  96. }
  97. }
  98. return output;
  99. }
  100. };
  101. })(window, jQuery, Handsontable);
  102. }
  103. //#
  104. },{}],2:[function(require,module,exports){
  105. "use strict";
  106. Object.defineProperties(exports, {
  107. WalkontableBorder: {get: function() {
  108. return WalkontableBorder;
  109. }},
  110. __esModule: {value: true}
  111. });
  112. var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
  113. $___46__46__47__46__46__47__46__46__47_eventManager_46_js__,
  114. $__cell_47_coords_46_js__;
  115. 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__});
  116. 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;
  117. 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;
  118. function WalkontableBorder(instance, settings) {
  119. var style;
  120. var createMultipleSelectorHandles = function() {
  121. this.selectionHandles = {
  122. topLeft: document.createElement('DIV'),
  123. topLeftHitArea: document.createElement('DIV'),
  124. bottomRight: document.createElement('DIV'),
  125. bottomRightHitArea: document.createElement('DIV')
  126. };
  127. var width = 10,
  128. hitAreaWidth = 40;
  129. this.selectionHandles.topLeft.className = 'topLeftSelectionHandle';
  130. this.selectionHandles.topLeftHitArea.className = 'topLeftSelectionHandle-HitArea';
  131. this.selectionHandles.bottomRight.className = 'bottomRightSelectionHandle';
  132. this.selectionHandles.bottomRightHitArea.className = 'bottomRightSelectionHandle-HitArea';
  133. this.selectionHandles.styles = {
  134. topLeft: this.selectionHandles.topLeft.style,
  135. topLeftHitArea: this.selectionHandles.topLeftHitArea.style,
  136. bottomRight: this.selectionHandles.bottomRight.style,
  137. bottomRightHitArea: this.selectionHandles.bottomRightHitArea.style
  138. };
  139. var hitAreaStyle = {
  140. 'position': 'absolute',
  141. 'height': hitAreaWidth + 'px',
  142. 'width': hitAreaWidth + 'px',
  143. 'border-radius': parseInt(hitAreaWidth / 1.5, 10) + 'px'
  144. };
  145. for (var prop in hitAreaStyle) {
  146. if (hitAreaStyle.hasOwnProperty(prop)) {
  147. this.selectionHandles.styles.bottomRightHitArea[prop] = hitAreaStyle[prop];
  148. this.selectionHandles.styles.topLeftHitArea[prop] = hitAreaStyle[prop];
  149. }
  150. }
  151. var handleStyle = {
  152. 'position': 'absolute',
  153. 'height': width + 'px',
  154. 'width': width + 'px',
  155. 'border-radius': parseInt(width / 1.5, 10) + 'px',
  156. 'background': '#F5F5FF',
  157. 'border': '1px solid #4285c8'
  158. };
  159. for (var prop in handleStyle) {
  160. if (handleStyle.hasOwnProperty(prop)) {
  161. this.selectionHandles.styles.bottomRight[prop] = handleStyle[prop];
  162. this.selectionHandles.styles.topLeft[prop] = handleStyle[prop];
  163. }
  164. }
  165. this.main.appendChild(this.selectionHandles.topLeft);
  166. this.main.appendChild(this.selectionHandles.bottomRight);
  167. this.main.appendChild(this.selectionHandles.topLeftHitArea);
  168. this.main.appendChild(this.selectionHandles.bottomRightHitArea);
  169. };
  170. if (!settings) {
  171. return;
  172. }
  173. var eventManager = eventManagerObject(instance);
  174. this.instance = instance;
  175. this.settings = settings;
  176. this.main = document.createElement("div");
  177. style = this.main.style;
  178. style.position = 'absolute';
  179. style.top = 0;
  180. style.left = 0;
  181. var borderDivs = ['top', 'left', 'bottom', 'right', 'corner'];
  182. for (var i = 0; i < 5; i++) {
  183. var position = borderDivs[i];
  184. var DIV = document.createElement('DIV');
  185. DIV.className = 'wtBorder ' + (this.settings.className || '');
  186. if (this.settings[position] && this.settings[position].hide) {
  187. DIV.className += " hidden";
  188. }
  189. style = DIV.style;
  190. style.backgroundColor = (this.settings[position] && this.settings[position].color) ? this.settings[position].color : settings.border.color;
  191. style.height = (this.settings[position] && this.settings[position].width) ? this.settings[position].width + 'px' : settings.border.width + 'px';
  192. style.width = (this.settings[position] && this.settings[position].width) ? this.settings[position].width + 'px' : settings.border.width + 'px';
  193. this.main.appendChild(DIV);
  194. }
  195. this.top = this.main.childNodes[0];
  196. this.left = this.main.childNodes[1];
  197. this.bottom = this.main.childNodes[2];
  198. this.right = this.main.childNodes[3];
  199. this.topStyle = this.top.style;
  200. this.leftStyle = this.left.style;
  201. this.bottomStyle = this.bottom.style;
  202. this.rightStyle = this.right.style;
  203. this.cornerDefaultStyle = {
  204. width: '5px',
  205. height: '5px',
  206. borderWidth: '2px',
  207. borderStyle: 'solid',
  208. borderColor: '#FFF'
  209. };
  210. this.corner = this.main.childNodes[4];
  211. this.corner.className += ' corner';
  212. this.cornerStyle = this.corner.style;
  213. this.cornerStyle.width = this.cornerDefaultStyle.width;
  214. this.cornerStyle.height = this.cornerDefaultStyle.height;
  215. this.cornerStyle.border = [this.cornerDefaultStyle.borderWidth, this.cornerDefaultStyle.borderStyle, this.cornerDefaultStyle.borderColor].join(' ');
  216. if (Handsontable.mobileBrowser) {
  217. createMultipleSelectorHandles.call(this);
  218. }
  219. this.disappear();
  220. if (!instance.wtTable.bordersHolder) {
  221. instance.wtTable.bordersHolder = document.createElement('div');
  222. instance.wtTable.bordersHolder.className = 'htBorders';
  223. instance.wtTable.spreader.appendChild(instance.wtTable.bordersHolder);
  224. }
  225. instance.wtTable.bordersHolder.insertBefore(this.main, instance.wtTable.bordersHolder.firstChild);
  226. var down = false;
  227. eventManager.addEventListener(document.body, 'mousedown', function() {
  228. down = true;
  229. });
  230. eventManager.addEventListener(document.body, 'mouseup', function() {
  231. down = false;
  232. });
  233. for (var c = 0,
  234. len = this.main.childNodes.length; c < len; c++) {
  235. eventManager.addEventListener(this.main.childNodes[c], 'mouseenter', function(event) {
  236. if (!down || !instance.getSetting('hideBorderOnMouseDownOver')) {
  237. return;
  238. }
  239. event.preventDefault();
  240. event.stopImmediatePropagation();
  241. var bounds = this.getBoundingClientRect();
  242. this.style.display = 'none';
  243. var isOutside = function(event) {
  244. if (event.clientY < Math.floor(bounds.top)) {
  245. return true;
  246. }
  247. if (event.clientY > Math.ceil(bounds.top + bounds.height)) {
  248. return true;
  249. }
  250. if (event.clientX < Math.floor(bounds.left)) {
  251. return true;
  252. }
  253. if (event.clientX > Math.ceil(bounds.left + bounds.width)) {
  254. return true;
  255. }
  256. };
  257. var handler = function(event) {
  258. if (isOutside(event)) {
  259. eventManager.removeEventListener(document.body, 'mousemove', handler);
  260. this.style.display = 'block';
  261. }
  262. };
  263. eventManager.addEventListener(document.body, 'mousemove', handler);
  264. });
  265. }
  266. }
  267. WalkontableBorder.prototype.appear = function(corners) {
  268. if (this.disabled) {
  269. return;
  270. }
  271. var instance = this.instance;
  272. var isMultiple,
  273. fromTD,
  274. toTD,
  275. fromOffset,
  276. toOffset,
  277. containerOffset,
  278. top,
  279. minTop,
  280. left,
  281. minLeft,
  282. height,
  283. width,
  284. fromRow,
  285. fromColumn,
  286. toRow,
  287. toColumn,
  288. i,
  289. ilen,
  290. s;
  291. var isPartRange = function() {
  292. if (this.instance.selections.area.cellRange) {
  293. if (toRow != this.instance.selections.area.cellRange.to.row || toColumn != this.instance.selections.area.cellRange.to.col) {
  294. return true;
  295. }
  296. }
  297. return false;
  298. };
  299. var updateMultipleSelectionHandlesPosition = function(top, left, width, height) {
  300. var handleWidth = parseInt(this.selectionHandles.styles.topLeft.width, 10),
  301. hitAreaWidth = parseInt(this.selectionHandles.styles.topLeftHitArea.width, 10);
  302. this.selectionHandles.styles.topLeft.top = parseInt(top - handleWidth, 10) + "px";
  303. this.selectionHandles.styles.topLeft.left = parseInt(left - handleWidth, 10) + "px";
  304. this.selectionHandles.styles.topLeftHitArea.top = parseInt(top - (hitAreaWidth / 4) * 3, 10) + "px";
  305. this.selectionHandles.styles.topLeftHitArea.left = parseInt(left - (hitAreaWidth / 4) * 3, 10) + "px";
  306. this.selectionHandles.styles.bottomRight.top = parseInt(top + height, 10) + "px";
  307. this.selectionHandles.styles.bottomRight.left = parseInt(left + width, 10) + "px";
  308. this.selectionHandles.styles.bottomRightHitArea.top = parseInt(top + height - hitAreaWidth / 4, 10) + "px";
  309. this.selectionHandles.styles.bottomRightHitArea.left = parseInt(left + width - hitAreaWidth / 4, 10) + "px";
  310. if (this.settings.border.multipleSelectionHandlesVisible && this.settings.border.multipleSelectionHandlesVisible()) {
  311. this.selectionHandles.styles.topLeft.display = "block";
  312. this.selectionHandles.styles.topLeftHitArea.display = "block";
  313. if (!isPartRange.call(this)) {
  314. this.selectionHandles.styles.bottomRight.display = "block";
  315. this.selectionHandles.styles.bottomRightHitArea.display = "block";
  316. } else {
  317. this.selectionHandles.styles.bottomRight.display = "none";
  318. this.selectionHandles.styles.bottomRightHitArea.display = "none";
  319. }
  320. } else {
  321. this.selectionHandles.styles.topLeft.display = "none";
  322. this.selectionHandles.styles.bottomRight.display = "none";
  323. this.selectionHandles.styles.topLeftHitArea.display = "none";
  324. this.selectionHandles.styles.bottomRightHitArea.display = "none";
  325. }
  326. if (fromRow == this.instance.wtSettings.getSetting('fixedRowsTop') || fromColumn == this.instance.wtSettings.getSetting('fixedColumnsLeft')) {
  327. this.selectionHandles.styles.topLeft.zIndex = "9999";
  328. this.selectionHandles.styles.topLeftHitArea.zIndex = "9999";
  329. } else {
  330. this.selectionHandles.styles.topLeft.zIndex = "";
  331. this.selectionHandles.styles.topLeftHitArea.zIndex = "";
  332. }
  333. };
  334. if (instance.cloneOverlay instanceof WalkontableTopOverlay || instance.cloneOverlay instanceof WalkontableCornerOverlay) {
  335. ilen = instance.getSetting('fixedRowsTop');
  336. } else {
  337. ilen = instance.wtTable.getRenderedRowsCount();
  338. }
  339. for (i = 0; i < ilen; i++) {
  340. s = instance.wtTable.rowFilter.renderedToSource(i);
  341. if (s >= corners[0] && s <= corners[2]) {
  342. fromRow = s;
  343. break;
  344. }
  345. }
  346. for (i = ilen - 1; i >= 0; i--) {
  347. s = instance.wtTable.rowFilter.renderedToSource(i);
  348. if (s >= corners[0] && s <= corners[2]) {
  349. toRow = s;
  350. break;
  351. }
  352. }
  353. ilen = instance.wtTable.getRenderedColumnsCount();
  354. for (i = 0; i < ilen; i++) {
  355. s = instance.wtTable.columnFilter.renderedToSource(i);
  356. if (s >= corners[1] && s <= corners[3]) {
  357. fromColumn = s;
  358. break;
  359. }
  360. }
  361. for (i = ilen - 1; i >= 0; i--) {
  362. s = instance.wtTable.columnFilter.renderedToSource(i);
  363. if (s >= corners[1] && s <= corners[3]) {
  364. toColumn = s;
  365. break;
  366. }
  367. }
  368. if (fromRow !== void 0 && fromColumn !== void 0) {
  369. isMultiple = (fromRow !== toRow || fromColumn !== toColumn);
  370. fromTD = instance.wtTable.getCell(new WalkontableCellCoords(fromRow, fromColumn));
  371. toTD = isMultiple ? instance.wtTable.getCell(new WalkontableCellCoords(toRow, toColumn)) : fromTD;
  372. fromOffset = dom.offset(fromTD);
  373. toOffset = isMultiple ? dom.offset(toTD) : fromOffset;
  374. containerOffset = dom.offset(instance.wtTable.TABLE);
  375. minTop = fromOffset.top;
  376. height = toOffset.top + dom.outerHeight(toTD) - minTop;
  377. minLeft = fromOffset.left;
  378. width = toOffset.left + dom.outerWidth(toTD) - minLeft;
  379. top = minTop - containerOffset.top - 1;
  380. left = minLeft - containerOffset.left - 1;
  381. var style = dom.getComputedStyle(fromTD);
  382. if (parseInt(style.borderTopWidth, 10) > 0) {
  383. top += 1;
  384. height = height > 0 ? height - 1 : 0;
  385. }
  386. if (parseInt(style.borderLeftWidth, 10) > 0) {
  387. left += 1;
  388. width = width > 0 ? width - 1 : 0;
  389. }
  390. } else {
  391. this.disappear();
  392. return;
  393. }
  394. this.topStyle.top = top + 'px';
  395. this.topStyle.left = left + 'px';
  396. this.topStyle.width = width + 'px';
  397. this.topStyle.display = 'block';
  398. this.leftStyle.top = top + 'px';
  399. this.leftStyle.left = left + 'px';
  400. this.leftStyle.height = height + 'px';
  401. this.leftStyle.display = 'block';
  402. var delta = Math.floor(this.settings.border.width / 2);
  403. this.bottomStyle.top = top + height - delta + 'px';
  404. this.bottomStyle.left = left + 'px';
  405. this.bottomStyle.width = width + 'px';
  406. this.bottomStyle.display = 'block';
  407. this.rightStyle.top = top + 'px';
  408. this.rightStyle.left = left + width - delta + 'px';
  409. this.rightStyle.height = height + 1 + 'px';
  410. this.rightStyle.display = 'block';
  411. if (Handsontable.mobileBrowser || (!this.hasSetting(this.settings.border.cornerVisible) || isPartRange.call(this))) {
  412. this.cornerStyle.display = 'none';
  413. } else {
  414. this.cornerStyle.top = top + height - 4 + 'px';
  415. this.cornerStyle.left = left + width - 4 + 'px';
  416. this.cornerStyle.borderRightWidth = this.cornerDefaultStyle.borderWidth;
  417. this.cornerStyle.width = this.cornerDefaultStyle.width;
  418. this.cornerStyle.display = 'block';
  419. if (toColumn === this.instance.getSetting('totalColumns') - 1) {
  420. var trimmingContainer = dom.getTrimmingContainer(instance.wtTable.TABLE),
  421. cornerOverlappingContainer = toTD.offsetLeft + dom.outerWidth(toTD) >= dom.innerWidth(trimmingContainer);
  422. if (cornerOverlappingContainer) {
  423. this.cornerStyle.left = Math.floor(left + width - 3 - parseInt(this.cornerDefaultStyle.width) / 2) + "px";
  424. this.cornerStyle.borderRightWidth = 0;
  425. }
  426. }
  427. }
  428. if (Handsontable.mobileBrowser) {
  429. updateMultipleSelectionHandlesPosition.call(this, top, left, width, height);
  430. }
  431. };
  432. WalkontableBorder.prototype.disappear = function() {
  433. this.topStyle.display = 'none';
  434. this.leftStyle.display = 'none';
  435. this.bottomStyle.display = 'none';
  436. this.rightStyle.display = 'none';
  437. this.cornerStyle.display = 'none';
  438. if (Handsontable.mobileBrowser) {
  439. this.selectionHandles.styles.topLeft.display = 'none';
  440. this.selectionHandles.styles.bottomRight.display = 'none';
  441. }
  442. };
  443. WalkontableBorder.prototype.hasSetting = function(setting) {
  444. if (typeof setting === 'function') {
  445. return setting();
  446. }
  447. return !!setting;
  448. };
  449. ;
  450. window.WalkontableBorder = WalkontableBorder;
  451. //#
  452. },{"./../../../dom.js":27,"./../../../eventManager.js":41,"./cell/coords.js":5}],3:[function(require,module,exports){
  453. "use strict";
  454. Object.defineProperties(exports, {
  455. WalkontableViewportColumnsCalculator: {get: function() {
  456. return WalkontableViewportColumnsCalculator;
  457. }},
  458. __esModule: {value: true}
  459. });
  460. var privatePool = new WeakMap();
  461. var WalkontableViewportColumnsCalculator = function WalkontableViewportColumnsCalculator(viewportWidth, scrollOffset, totalColumns, columnWidthFn, overrideFn, onlyFullyVisible, stretchH) {
  462. privatePool.set(this, {
  463. viewportWidth: viewportWidth,
  464. scrollOffset: scrollOffset,
  465. totalColumns: totalColumns,
  466. columnWidthFn: columnWidthFn,
  467. overrideFn: overrideFn,
  468. onlyFullyVisible: onlyFullyVisible
  469. });
  470. this.count = 0;
  471. this.startColumn = null;
  472. this.endColumn = null;
  473. this.startPosition = null;
  474. this.stretchAllRatio = 0;
  475. this.stretchLastWidth = 0;
  476. this.stretch = stretchH;
  477. this.totalTargetWidth = 0;
  478. this.needVerifyLastColumnWidth = true;
  479. this.stretchAllColumnsWidth = [];
  480. this.calculate();
  481. };
  482. var $WalkontableViewportColumnsCalculator = WalkontableViewportColumnsCalculator;
  483. ($traceurRuntime.createClass)(WalkontableViewportColumnsCalculator, {
  484. calculate: function() {
  485. var sum = 0;
  486. var needReverse = true;
  487. var startPositions = [];
  488. var columnWidth;
  489. var priv = privatePool.get(this);
  490. var onlyFullyVisible = priv.onlyFullyVisible;
  491. var overrideFn = priv.overrideFn;
  492. var scrollOffset = priv.scrollOffset;
  493. var totalColumns = priv.totalColumns;
  494. var viewportWidth = priv.viewportWidth;
  495. for (var i = 0; i < totalColumns; i++) {
  496. columnWidth = this._getColumnWidth(i);
  497. if (sum <= scrollOffset && !onlyFullyVisible) {
  498. this.startColumn = i;
  499. }
  500. if (sum >= scrollOffset && sum + columnWidth <= scrollOffset + viewportWidth) {
  501. if (this.startColumn == null) {
  502. this.startColumn = i;
  503. }
  504. this.endColumn = i;
  505. }
  506. startPositions.push(sum);
  507. sum += columnWidth;
  508. if (!onlyFullyVisible) {
  509. this.endColumn = i;
  510. }
  511. if (sum >= scrollOffset + viewportWidth) {
  512. needReverse = false;
  513. break;
  514. }
  515. }
  516. if (this.endColumn === totalColumns - 1 && needReverse) {
  517. this.startColumn = this.endColumn;
  518. while (this.startColumn > 0) {
  519. var viewportSum = startPositions[this.endColumn] + columnWidth - startPositions[this.startColumn - 1];
  520. if (viewportSum <= viewportWidth || !onlyFullyVisible) {
  521. this.startColumn--;
  522. }
  523. if (viewportSum > viewportWidth) {
  524. break;
  525. }
  526. }
  527. }
  528. if (this.startColumn !== null && overrideFn) {
  529. overrideFn(this);
  530. }
  531. this.startPosition = startPositions[this.startColumn];
  532. if (this.startPosition == void 0) {
  533. this.startPosition = null;
  534. }
  535. if (this.startColumn !== null) {
  536. this.count = this.endColumn - this.startColumn + 1;
  537. }
  538. },
  539. refreshStretching: function(totalWidth) {
  540. if (this.stretch === 'none') {
  541. return;
  542. }
  543. var sumAll = 0;
  544. var columnWidth;
  545. var remainingSize;
  546. var priv = privatePool.get(this);
  547. var totalColumns = priv.totalColumns;
  548. for (var i = 0; i < totalColumns; i++) {
  549. columnWidth = this._getColumnWidth(i);
  550. sumAll += columnWidth;
  551. }
  552. this.totalTargetWidth = totalWidth;
  553. remainingSize = sumAll - totalWidth;
  554. if (this.stretch === 'all' && remainingSize < 0) {
  555. this.stretchAllRatio = totalWidth / sumAll;
  556. this.stretchAllColumnsWidth = [];
  557. this.needVerifyLastColumnWidth = true;
  558. } else if (this.stretch === 'last' && totalWidth !== Infinity) {
  559. this.stretchLastWidth = -remainingSize + this._getColumnWidth(totalColumns - 1);
  560. }
  561. },
  562. getStretchedColumnWidth: function(column, baseWidth) {
  563. var result = null;
  564. if (this.stretch === 'all' && this.stretchAllRatio !== 0) {
  565. result = this._getStretchedAllColumnWidth(column, baseWidth);
  566. } else if (this.stretch === 'last' && this.stretchLastWidth !== 0) {
  567. result = this._getStretchedLastColumnWidth(column);
  568. }
  569. return result;
  570. },
  571. _getStretchedAllColumnWidth: function(column, baseWidth) {
  572. var sumRatioWidth = 0;
  573. var priv = privatePool.get(this);
  574. var totalColumns = priv.totalColumns;
  575. if (!this.stretchAllColumnsWidth[column]) {
  576. this.stretchAllColumnsWidth[column] = Math.round(baseWidth * this.stretchAllRatio);
  577. }
  578. if (this.stretchAllColumnsWidth.length === totalColumns && this.needVerifyLastColumnWidth) {
  579. this.needVerifyLastColumnWidth = false;
  580. for (var i = 0; i < this.stretchAllColumnsWidth.length; i++) {
  581. sumRatioWidth += this.stretchAllColumnsWidth[i];
  582. }
  583. if (sumRatioWidth !== this.totalTargetWidth) {
  584. this.stretchAllColumnsWidth[this.stretchAllColumnsWidth.length - 1] += this.totalTargetWidth - sumRatioWidth;
  585. }
  586. }
  587. return this.stretchAllColumnsWidth[column];
  588. },
  589. _getStretchedLastColumnWidth: function(column) {
  590. var priv = privatePool.get(this);
  591. var totalColumns = priv.totalColumns;
  592. if (column === totalColumns - 1) {
  593. return this.stretchLastWidth;
  594. }
  595. return null;
  596. },
  597. _getColumnWidth: function(column) {
  598. var width = privatePool.get(this).columnWidthFn(column);
  599. if (width === undefined) {
  600. width = $WalkontableViewportColumnsCalculator.DEFAULT_WIDTH;
  601. }
  602. return width;
  603. }
  604. }, {get DEFAULT_WIDTH() {
  605. return 50;
  606. }});
  607. ;
  608. window.WalkontableViewportColumnsCalculator = WalkontableViewportColumnsCalculator;
  609. //#
  610. },{}],4:[function(require,module,exports){
  611. "use strict";
  612. Object.defineProperties(exports, {
  613. WalkontableViewportRowsCalculator: {get: function() {
  614. return WalkontableViewportRowsCalculator;
  615. }},
  616. __esModule: {value: true}
  617. });
  618. var privatePool = new WeakMap();
  619. var WalkontableViewportRowsCalculator = function WalkontableViewportRowsCalculator(viewportHeight, scrollOffset, totalRows, rowHeightFn, overrideFn, onlyFullyVisible) {
  620. privatePool.set(this, {
  621. viewportHeight: viewportHeight,
  622. scrollOffset: scrollOffset,
  623. totalRows: totalRows,
  624. rowHeightFn: rowHeightFn,
  625. overrideFn: overrideFn,
  626. onlyFullyVisible: onlyFullyVisible
  627. });
  628. this.count = 0;
  629. this.startRow = null;
  630. this.endRow = null;
  631. this.startPosition = null;
  632. this.calculate();
  633. };
  634. var $WalkontableViewportRowsCalculator = WalkontableViewportRowsCalculator;
  635. ($traceurRuntime.createClass)(WalkontableViewportRowsCalculator, {calculate: function() {
  636. var sum = 0;
  637. var needReverse = true;
  638. var startPositions = [];
  639. var priv = privatePool.get(this);
  640. var onlyFullyVisible = priv.onlyFullyVisible;
  641. var overrideFn = priv.overrideFn;
  642. var rowHeightFn = priv.rowHeightFn;
  643. var scrollOffset = priv.scrollOffset;
  644. var totalRows = priv.totalRows;
  645. var viewportHeight = priv.viewportHeight;
  646. for (var i = 0; i < totalRows; i++) {
  647. var rowHeight = rowHeightFn(i);
  648. if (rowHeight === undefined) {
  649. rowHeight = $WalkontableViewportRowsCalculator.DEFAULT_HEIGHT;
  650. }
  651. if (sum <= scrollOffset && !onlyFullyVisible) {
  652. this.startRow = i;
  653. }
  654. if (sum >= scrollOffset && sum + rowHeight <= scrollOffset + viewportHeight) {
  655. if (this.startRow === null) {
  656. this.startRow = i;
  657. }
  658. this.endRow = i;
  659. }
  660. startPositions.push(sum);
  661. sum += rowHeight;
  662. if (!onlyFullyVisible) {
  663. this.endRow = i;
  664. }
  665. if (sum >= scrollOffset + viewportHeight) {
  666. needReverse = false;
  667. break;
  668. }
  669. }
  670. if (this.endRow === totalRows - 1 && needReverse) {
  671. this.startRow = this.endRow;
  672. while (this.startRow > 0) {
  673. var viewportSum = startPositions[this.endRow] + rowHeight - startPositions[this.startRow - 1];
  674. if (viewportSum <= viewportHeight || !onlyFullyVisible) {
  675. this.startRow--;
  676. }
  677. if (viewportSum >= viewportHeight) {
  678. break;
  679. }
  680. }
  681. }
  682. if (this.startRow !== null && overrideFn) {
  683. overrideFn(this);
  684. }
  685. this.startPosition = startPositions[this.startRow];
  686. if (this.startPosition == void 0) {
  687. this.startPosition = null;
  688. }
  689. if (this.startRow !== null) {
  690. this.count = this.endRow - this.startRow + 1;
  691. }
  692. }}, {get DEFAULT_HEIGHT() {
  693. return 23;
  694. }});
  695. ;
  696. window.WalkontableViewportRowsCalculator = WalkontableViewportRowsCalculator;
  697. //#
  698. },{}],5:[function(require,module,exports){
  699. "use strict";
  700. Object.defineProperties(exports, {
  701. WalkontableCellCoords: {get: function() {
  702. return WalkontableCellCoords;
  703. }},
  704. __esModule: {value: true}
  705. });
  706. var WalkontableCellCoords = function WalkontableCellCoords(row, col) {
  707. if (typeof row !== 'undefined' && typeof col !== 'undefined') {
  708. this.row = row;
  709. this.col = col;
  710. } else {
  711. this.row = null;
  712. this.col = null;
  713. }
  714. };
  715. ($traceurRuntime.createClass)(WalkontableCellCoords, {
  716. isValid: function(wotInstance) {
  717. if (this.row < 0 || this.col < 0) {
  718. return false;
  719. }
  720. if (this.row >= wotInstance.getSetting('totalRows') || this.col >= wotInstance.getSetting('totalColumns')) {
  721. return false;
  722. }
  723. return true;
  724. },
  725. isEqual: function(cellCoords) {
  726. if (cellCoords === this) {
  727. return true;
  728. }
  729. return this.row === cellCoords.row && this.col === cellCoords.col;
  730. },
  731. isSouthEastOf: function(testedCoords) {
  732. return this.row >= testedCoords.row && this.col >= testedCoords.col;
  733. },
  734. isNorthWestOf: function(testedCoords) {
  735. return this.row <= testedCoords.row && this.col <= testedCoords.col;
  736. },
  737. isSouthWestOf: function(testedCoords) {
  738. return this.row >= testedCoords.row && this.col <= testedCoords.col;
  739. },
  740. isNorthEastOf: function(testedCoords) {
  741. return this.row <= testedCoords.row && this.col >= testedCoords.col;
  742. }
  743. }, {});
  744. ;
  745. window.WalkontableCellCoords = WalkontableCellCoords;
  746. //#
  747. },{}],6:[function(require,module,exports){
  748. "use strict";
  749. Object.defineProperties(exports, {
  750. WalkontableCellRange: {get: function() {
  751. return WalkontableCellRange;
  752. }},
  753. __esModule: {value: true}
  754. });
  755. var $___46__46__47_cell_47_coords_46_js__;
  756. 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;
  757. var WalkontableCellRange = function WalkontableCellRange(highlight, from, to) {
  758. this.highlight = highlight;
  759. this.from = from;
  760. this.to = to;
  761. };
  762. var $WalkontableCellRange = WalkontableCellRange;
  763. ($traceurRuntime.createClass)(WalkontableCellRange, {
  764. isValid: function(wotInstance) {
  765. return this.from.isValid(wotInstance) && this.to.isValid(wotInstance);
  766. },
  767. isSingle: function() {
  768. return this.from.row === this.to.row && this.from.col === this.to.col;
  769. },
  770. getHeight: function() {
  771. return Math.max(this.from.row, this.to.row) - Math.min(this.from.row, this.to.row) + 1;
  772. },
  773. getWidth: function() {
  774. return Math.max(this.from.col, this.to.col) - Math.min(this.from.col, this.to.col) + 1;
  775. },
  776. includes: function(cellCoords) {
  777. var topLeft = this.getTopLeftCorner();
  778. var bottomRight = this.getBottomRightCorner();
  779. if (cellCoords.row < 0) {
  780. cellCoords.row = 0;
  781. }
  782. if (cellCoords.col < 0) {
  783. cellCoords.col = 0;
  784. }
  785. return topLeft.row <= cellCoords.row && bottomRight.row >= cellCoords.row && topLeft.col <= cellCoords.col && bottomRight.col >= cellCoords.col;
  786. },
  787. includesRange: function(testedRange) {
  788. return this.includes(testedRange.getTopLeftCorner()) && this.includes(testedRange.getBottomRightCorner());
  789. },
  790. isEqual: function(testedRange) {
  791. 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));
  792. },
  793. overlaps: function(testedRange) {
  794. return testedRange.isSouthEastOf(this.getTopLeftCorner()) && testedRange.isNorthWestOf(this.getBottomRightCorner());
  795. },
  796. isSouthEastOf: function(testedCoords) {
  797. return this.getTopLeftCorner().isSouthEastOf(testedCoords) || this.getBottomRightCorner().isSouthEastOf(testedCoords);
  798. },
  799. isNorthWestOf: function(testedCoords) {
  800. return this.getTopLeftCorner().isNorthWestOf(testedCoords) || this.getBottomRightCorner().isNorthWestOf(testedCoords);
  801. },
  802. expand: function(cellCoords) {
  803. var topLeft = this.getTopLeftCorner();
  804. var bottomRight = this.getBottomRightCorner();
  805. if (cellCoords.row < topLeft.row || cellCoords.col < topLeft.col || cellCoords.row > bottomRight.row || cellCoords.col > bottomRight.col) {
  806. this.from = new WalkontableCellCoords(Math.min(topLeft.row, cellCoords.row), Math.min(topLeft.col, cellCoords.col));
  807. this.to = new WalkontableCellCoords(Math.max(bottomRight.row, cellCoords.row), Math.max(bottomRight.col, cellCoords.col));
  808. return true;
  809. }
  810. return false;
  811. },
  812. expandByRange: function(expandingRange) {
  813. if (this.includesRange(expandingRange) || !this.overlaps(expandingRange)) {
  814. return false;
  815. }
  816. var topLeft = this.getTopLeftCorner();
  817. var bottomRight = this.getBottomRightCorner();
  818. var topRight = this.getTopRightCorner();
  819. var bottomLeft = this.getBottomLeftCorner();
  820. var expandingTopLeft = expandingRange.getTopLeftCorner();
  821. var expandingBottomRight = expandingRange.getBottomRightCorner();
  822. var resultTopRow = Math.min(topLeft.row, expandingTopLeft.row);
  823. var resultTopCol = Math.min(topLeft.col, expandingTopLeft.col);
  824. var resultBottomRow = Math.max(bottomRight.row, expandingBottomRight.row);
  825. var resultBottomCol = Math.max(bottomRight.col, expandingBottomRight.col);
  826. var finalFrom = new WalkontableCellCoords(resultTopRow, resultTopCol),
  827. finalTo = new WalkontableCellCoords(resultBottomRow, resultBottomCol);
  828. var isCorner = new $WalkontableCellRange(finalFrom, finalFrom, finalTo).isCorner(this.from, expandingRange),
  829. onlyMerge = expandingRange.isEqual(new $WalkontableCellRange(finalFrom, finalFrom, finalTo));
  830. if (isCorner && !onlyMerge) {
  831. if (this.from.col > finalFrom.col) {
  832. finalFrom.col = resultBottomCol;
  833. finalTo.col = resultTopCol;
  834. }
  835. if (this.from.row > finalFrom.row) {
  836. finalFrom.row = resultBottomRow;
  837. finalTo.row = resultTopRow;
  838. }
  839. }
  840. this.from = finalFrom;
  841. this.to = finalTo;
  842. return true;
  843. },
  844. getDirection: function() {
  845. if (this.from.isNorthWestOf(this.to)) {
  846. return 'NW-SE';
  847. } else if (this.from.isNorthEastOf(this.to)) {
  848. return 'NE-SW';
  849. } else if (this.from.isSouthEastOf(this.to)) {
  850. return 'SE-NW';
  851. } else if (this.from.isSouthWestOf(this.to)) {
  852. return 'SW-NE';
  853. }
  854. },
  855. setDirection: function(direction) {
  856. switch (direction) {
  857. case 'NW-SE':
  858. this.from = this.getTopLeftCorner();
  859. this.to = this.getBottomRightCorner();
  860. break;
  861. case 'NE-SW':
  862. this.from = this.getTopRightCorner();
  863. this.to = this.getBottomLeftCorner();
  864. break;
  865. case 'SE-NW':
  866. this.from = this.getBottomRightCorner();
  867. this.to = this.getTopLeftCorner();
  868. break;
  869. case 'SW-NE':
  870. this.from = this.getBottomLeftCorner();
  871. this.to = this.getTopRightCorner();
  872. break;
  873. }
  874. },
  875. getTopLeftCorner: function() {
  876. return new WalkontableCellCoords(Math.min(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  877. },
  878. getBottomRightCorner: function() {
  879. return new WalkontableCellCoords(Math.max(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  880. },
  881. getTopRightCorner: function() {
  882. return new WalkontableCellCoords(Math.min(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  883. },
  884. getBottomLeftCorner: function() {
  885. return new WalkontableCellCoords(Math.max(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  886. },
  887. isCorner: function(coords, expandedRange) {
  888. if (expandedRange) {
  889. if (expandedRange.includes(coords)) {
  890. 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))) {
  891. return true;
  892. }
  893. }
  894. }
  895. return coords.isEqual(this.getTopLeftCorner()) || coords.isEqual(this.getTopRightCorner()) || coords.isEqual(this.getBottomLeftCorner()) || coords.isEqual(this.getBottomRightCorner());
  896. },
  897. getOppositeCorner: function(coords, expandedRange) {
  898. if (!(coords instanceof WalkontableCellCoords)) {
  899. return false;
  900. }
  901. if (expandedRange) {
  902. if (expandedRange.includes(coords)) {
  903. if (this.getTopLeftCorner().isEqual(new WalkontableCellCoords(expandedRange.from.row, expandedRange.from.col))) {
  904. return this.getBottomRightCorner();
  905. }
  906. if (this.getTopRightCorner().isEqual(new WalkontableCellCoords(expandedRange.from.row, expandedRange.to.col))) {
  907. return this.getBottomLeftCorner();
  908. }
  909. if (this.getBottomLeftCorner().isEqual(new WalkontableCellCoords(expandedRange.to.row, expandedRange.from.col))) {
  910. return this.getTopRightCorner();
  911. }
  912. if (this.getBottomRightCorner().isEqual(new WalkontableCellCoords(expandedRange.to.row, expandedRange.to.col))) {
  913. return this.getTopLeftCorner();
  914. }
  915. }
  916. }
  917. if (coords.isEqual(this.getBottomRightCorner())) {
  918. return this.getTopLeftCorner();
  919. } else if (coords.isEqual(this.getTopLeftCorner())) {
  920. return this.getBottomRightCorner();
  921. } else if (coords.isEqual(this.getTopRightCorner())) {
  922. return this.getBottomLeftCorner();
  923. } else if (coords.isEqual(this.getBottomLeftCorner())) {
  924. return this.getTopRightCorner();
  925. }
  926. },
  927. getBordersSharedWith: function(range) {
  928. if (!this.includesRange(range)) {
  929. return [];
  930. }
  931. var thisBorders = {
  932. top: Math.min(this.from.row, this.to.row),
  933. bottom: Math.max(this.from.row, this.to.row),
  934. left: Math.min(this.from.col, this.to.col),
  935. right: Math.max(this.from.col, this.to.col)
  936. };
  937. var rangeBorders = {
  938. top: Math.min(range.from.row, range.to.row),
  939. bottom: Math.max(range.from.row, range.to.row),
  940. left: Math.min(range.from.col, range.to.col),
  941. right: Math.max(range.from.col, range.to.col)
  942. };
  943. var result = [];
  944. if (thisBorders.top == rangeBorders.top) {
  945. result.push('top');
  946. }
  947. if (thisBorders.right == rangeBorders.right) {
  948. result.push('right');
  949. }
  950. if (thisBorders.bottom == rangeBorders.bottom) {
  951. result.push('bottom');
  952. }
  953. if (thisBorders.left == rangeBorders.left) {
  954. result.push('left');
  955. }
  956. return result;
  957. },
  958. getInner: function() {
  959. var topLeft = this.getTopLeftCorner();
  960. var bottomRight = this.getBottomRightCorner();
  961. var out = [];
  962. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  963. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  964. if (!(this.from.row === r && this.from.col === c) && !(this.to.row === r && this.to.col === c)) {
  965. out.push(new WalkontableCellCoords(r, c));
  966. }
  967. }
  968. }
  969. return out;
  970. },
  971. getAll: function() {
  972. var topLeft = this.getTopLeftCorner();
  973. var bottomRight = this.getBottomRightCorner();
  974. var out = [];
  975. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  976. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  977. if (topLeft.row === r && topLeft.col === c) {
  978. out.push(topLeft);
  979. } else if (bottomRight.row === r && bottomRight.col === c) {
  980. out.push(bottomRight);
  981. } else {
  982. out.push(new WalkontableCellCoords(r, c));
  983. }
  984. }
  985. }
  986. return out;
  987. },
  988. forAll: function(callback) {
  989. var topLeft = this.getTopLeftCorner();
  990. var bottomRight = this.getBottomRightCorner();
  991. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  992. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  993. var breakIteration = callback(r, c);
  994. if (breakIteration === false) {
  995. return;
  996. }
  997. }
  998. }
  999. }
  1000. }, {});
  1001. ;
  1002. window.WalkontableCellRange = WalkontableCellRange;
  1003. //#
  1004. },{"./../cell/coords.js":5}],7:[function(require,module,exports){
  1005. "use strict";
  1006. Object.defineProperties(exports, {
  1007. Walkontable: {get: function() {
  1008. return Walkontable;
  1009. }},
  1010. __esModule: {value: true}
  1011. });
  1012. var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
  1013. $___46__46__47__46__46__47__46__46__47_helpers_46_js__,
  1014. $__event_46_js__,
  1015. $__overlays_46_js__,
  1016. $__scroll_46_js__,
  1017. $__settings_46_js__,
  1018. $__table_46_js__,
  1019. $__viewport_46_js__;
  1020. 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__});
  1021. 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;
  1022. var WalkontableEvent = ($__event_46_js__ = require("./event.js"), $__event_46_js__ && $__event_46_js__.__esModule && $__event_46_js__ || {default: $__event_46_js__}).WalkontableEvent;
  1023. var WalkontableOverlays = ($__overlays_46_js__ = require("./overlays.js"), $__overlays_46_js__ && $__overlays_46_js__.__esModule && $__overlays_46_js__ || {default: $__overlays_46_js__}).WalkontableOverlays;
  1024. var WalkontableScroll = ($__scroll_46_js__ = require("./scroll.js"), $__scroll_46_js__ && $__scroll_46_js__.__esModule && $__scroll_46_js__ || {default: $__scroll_46_js__}).WalkontableScroll;
  1025. var WalkontableSettings = ($__settings_46_js__ = require("./settings.js"), $__settings_46_js__ && $__settings_46_js__.__esModule && $__settings_46_js__ || {default: $__settings_46_js__}).WalkontableSettings;
  1026. var WalkontableTable = ($__table_46_js__ = require("./table.js"), $__table_46_js__ && $__table_46_js__.__esModule && $__table_46_js__ || {default: $__table_46_js__}).WalkontableTable;
  1027. var WalkontableViewport = ($__viewport_46_js__ = require("./viewport.js"), $__viewport_46_js__ && $__viewport_46_js__.__esModule && $__viewport_46_js__ || {default: $__viewport_46_js__}).WalkontableViewport;
  1028. var Walkontable = function Walkontable(settings) {
  1029. var originalHeaders = [];
  1030. this.guid = 'wt_' + randomString();
  1031. if (settings.cloneSource) {
  1032. this.cloneSource = settings.cloneSource;
  1033. this.cloneOverlay = settings.cloneOverlay;
  1034. this.wtSettings = settings.cloneSource.wtSettings;
  1035. this.wtTable = new WalkontableTable(this, settings.table, settings.wtRootElement);
  1036. this.wtScroll = new WalkontableScroll(this);
  1037. this.wtViewport = settings.cloneSource.wtViewport;
  1038. this.wtEvent = new WalkontableEvent(this);
  1039. this.selections = this.cloneSource.selections;
  1040. } else {
  1041. this.wtSettings = new WalkontableSettings(this, settings);
  1042. this.wtTable = new WalkontableTable(this, settings.table);
  1043. this.wtScroll = new WalkontableScroll(this);
  1044. this.wtViewport = new WalkontableViewport(this);
  1045. this.wtEvent = new WalkontableEvent(this);
  1046. this.selections = this.getSetting('selections');
  1047. this.wtOverlays = new WalkontableOverlays(this);
  1048. }
  1049. if (this.wtTable.THEAD.childNodes.length && this.wtTable.THEAD.childNodes[0].childNodes.length) {
  1050. for (var c = 0,
  1051. clen = this.wtTable.THEAD.childNodes[0].childNodes.length; c < clen; c++) {
  1052. originalHeaders.push(this.wtTable.THEAD.childNodes[0].childNodes[c].innerHTML);
  1053. }
  1054. if (!this.getSetting('columnHeaders').length) {
  1055. this.update('columnHeaders', [function(column, TH) {
  1056. dom.fastInnerText(TH, originalHeaders[column]);
  1057. }]);
  1058. }
  1059. }
  1060. this.drawn = false;
  1061. this.drawInterrupted = false;
  1062. };
  1063. ($traceurRuntime.createClass)(Walkontable, {
  1064. draw: function() {
  1065. var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
  1066. this.drawInterrupted = false;
  1067. if (!fastDraw && !dom.isVisible(this.wtTable.TABLE)) {
  1068. this.drawInterrupted = true;
  1069. } else {
  1070. this.wtTable.draw(fastDraw);
  1071. }
  1072. return this;
  1073. },
  1074. getCell: function(coords) {
  1075. var topmost = arguments[1] !== (void 0) ? arguments[1] : false;
  1076. if (!topmost) {
  1077. return this.wtTable.getCell(coords);
  1078. }
  1079. var fixedRows = this.wtSettings.getSetting('fixedRowsTop');
  1080. var fixedColumns = this.wtSettings.getSetting('fixedColumnsLeft');
  1081. if (coords.row < fixedRows && coords.col < fixedColumns) {
  1082. return this.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell(coords);
  1083. } else if (coords.row < fixedRows) {
  1084. return this.wtOverlays.topOverlay.clone.wtTable.getCell(coords);
  1085. } else if (coords.col < fixedColumns) {
  1086. return this.wtOverlays.leftOverlay.clone.wtTable.getCell(coords);
  1087. }
  1088. return this.wtTable.getCell(coords);
  1089. },
  1090. update: function(settings, value) {
  1091. return this.wtSettings.update(settings, value);
  1092. },
  1093. scrollVertical: function(row) {
  1094. this.wtOverlays.topOverlay.scrollTo(row);
  1095. this.getSetting('onScrollVertically');
  1096. return this;
  1097. },
  1098. scrollHorizontal: function(column) {
  1099. this.wtOverlays.leftOverlay.scrollTo(column);
  1100. this.getSetting('onScrollHorizontally');
  1101. return this;
  1102. },
  1103. scrollViewport: function(coords) {
  1104. this.wtScroll.scrollViewport(coords);
  1105. return this;
  1106. },
  1107. getViewport: function() {
  1108. return [this.wtTable.getFirstVisibleRow(), this.wtTable.getFirstVisibleColumn(), this.wtTable.getLastVisibleRow(), this.wtTable.getLastVisibleColumn()];
  1109. },
  1110. getOverlayName: function() {
  1111. return this.cloneOverlay ? this.cloneOverlay.type : 'master';
  1112. },
  1113. getSetting: function(key, param1, param2, param3, param4) {
  1114. return this.wtSettings.getSetting(key, param1, param2, param3, param4);
  1115. },
  1116. hasSetting: function(key) {
  1117. return this.wtSettings.has(key);
  1118. },
  1119. destroy: function() {
  1120. this.wtOverlays.destroy();
  1121. if (this.wtEvent) {
  1122. this.wtEvent.destroy();
  1123. }
  1124. }
  1125. }, {});
  1126. ;
  1127. window.Walkontable = Walkontable;
  1128. //#
  1129. },{"./../../../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){
  1130. "use strict";
  1131. Object.defineProperties(exports, {
  1132. WalkontableEvent: {get: function() {
  1133. return WalkontableEvent;
  1134. }},
  1135. __esModule: {value: true}
  1136. });
  1137. var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
  1138. $___46__46__47__46__46__47__46__46__47_eventManager_46_js__;
  1139. 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__});
  1140. 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;
  1141. function WalkontableEvent(instance) {
  1142. var that = this;
  1143. var eventManager = eventManagerObject(instance);
  1144. this.instance = instance;
  1145. var dblClickOrigin = [null, null];
  1146. this.dblClickTimeout = [null, null];
  1147. var onMouseDown = function(event) {
  1148. var cell = that.parentCell(event.realTarget);
  1149. if (dom.hasClass(event.realTarget, 'corner')) {
  1150. that.instance.getSetting('onCellCornerMouseDown', event, event.realTarget);
  1151. } else if (cell.TD) {
  1152. if (that.instance.hasSetting('onCellMouseDown')) {
  1153. that.instance.getSetting('onCellMouseDown', event, cell.coords, cell.TD, that.instance);
  1154. }
  1155. }
  1156. if (event.button !== 2) {
  1157. if (cell.TD) {
  1158. dblClickOrigin[0] = cell.TD;
  1159. clearTimeout(that.dblClickTimeout[0]);
  1160. that.dblClickTimeout[0] = setTimeout(function() {
  1161. dblClickOrigin[0] = null;
  1162. }, 1000);
  1163. }
  1164. }
  1165. };
  1166. var onTouchMove = function(event) {
  1167. that.instance.touchMoving = true;
  1168. };
  1169. var longTouchTimeout;
  1170. var onTouchStart = function(event) {
  1171. var container = this;
  1172. eventManager.addEventListener(this, 'touchmove', onTouchMove);
  1173. that.checkIfTouchMove = setTimeout(function() {
  1174. if (that.instance.touchMoving === true) {
  1175. that.instance.touchMoving = void 0;
  1176. eventManager.removeEventListener("touchmove", onTouchMove, false);
  1177. return;
  1178. } else {
  1179. onMouseDown(event);
  1180. }
  1181. }, 30);
  1182. };
  1183. var lastMouseOver;
  1184. var onMouseOver = function(event) {
  1185. var table,
  1186. td;
  1187. if (that.instance.hasSetting('onCellMouseOver')) {
  1188. table = that.instance.wtTable.TABLE;
  1189. td = dom.closest(event.realTarget, ['TD', 'TH'], table);
  1190. if (td && td !== lastMouseOver && dom.isChildOf(td, table)) {
  1191. lastMouseOver = td;
  1192. that.instance.getSetting('onCellMouseOver', event, that.instance.wtTable.getCoords(td), td, that.instance);
  1193. }
  1194. }
  1195. };
  1196. var onMouseUp = function(event) {
  1197. if (event.button !== 2) {
  1198. var cell = that.parentCell(event.realTarget);
  1199. if (cell.TD === dblClickOrigin[0] && cell.TD === dblClickOrigin[1]) {
  1200. if (dom.hasClass(event.realTarget, 'corner')) {
  1201. that.instance.getSetting('onCellCornerDblClick', event, cell.coords, cell.TD, that.instance);
  1202. } else {
  1203. that.instance.getSetting('onCellDblClick', event, cell.coords, cell.TD, that.instance);
  1204. }
  1205. dblClickOrigin[0] = null;
  1206. dblClickOrigin[1] = null;
  1207. } else if (cell.TD === dblClickOrigin[0]) {
  1208. dblClickOrigin[1] = cell.TD;
  1209. clearTimeout(that.dblClickTimeout[1]);
  1210. that.dblClickTimeout[1] = setTimeout(function() {
  1211. dblClickOrigin[1] = null;
  1212. }, 500);
  1213. }
  1214. }
  1215. };
  1216. var onTouchEnd = function(event) {
  1217. clearTimeout(longTouchTimeout);
  1218. event.preventDefault();
  1219. onMouseUp(event);
  1220. };
  1221. eventManager.addEventListener(this.instance.wtTable.holder, 'mousedown', onMouseDown);
  1222. eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseover', onMouseOver);
  1223. eventManager.addEventListener(this.instance.wtTable.holder, 'mouseup', onMouseUp);
  1224. if (this.instance.wtTable.holder.parentNode.parentNode && Handsontable.mobileBrowser && !that.instance.wtTable.isWorkingOnClone()) {
  1225. var classSelector = "." + this.instance.wtTable.holder.parentNode.className.split(" ").join(".");
  1226. eventManager.addEventListener(this.instance.wtTable.holder, 'touchstart', function(event) {
  1227. that.instance.touchApplied = true;
  1228. if (dom.isChildOf(event.target, classSelector)) {
  1229. onTouchStart.call(event.target, event);
  1230. }
  1231. });
  1232. eventManager.addEventListener(this.instance.wtTable.holder, 'touchend', function(event) {
  1233. that.instance.touchApplied = false;
  1234. if (dom.isChildOf(event.target, classSelector)) {
  1235. onTouchEnd.call(event.target, event);
  1236. }
  1237. });
  1238. if (!that.instance.momentumScrolling) {
  1239. that.instance.momentumScrolling = {};
  1240. }
  1241. eventManager.addEventListener(this.instance.wtTable.holder, 'scroll', function(event) {
  1242. clearTimeout(that.instance.momentumScrolling._timeout);
  1243. if (!that.instance.momentumScrolling.ongoing) {
  1244. that.instance.getSetting('onBeforeTouchScroll');
  1245. }
  1246. that.instance.momentumScrolling.ongoing = true;
  1247. that.instance.momentumScrolling._timeout = setTimeout(function() {
  1248. if (!that.instance.touchApplied) {
  1249. that.instance.momentumScrolling.ongoing = false;
  1250. that.instance.getSetting('onAfterMomentumScroll');
  1251. }
  1252. }, 200);
  1253. });
  1254. }
  1255. eventManager.addEventListener(window, 'resize', function() {
  1256. if (that.instance.getSetting('stretchH') !== 'none') {
  1257. that.instance.draw();
  1258. }
  1259. });
  1260. this.destroy = function() {
  1261. clearTimeout(this.dblClickTimeout[0]);
  1262. clearTimeout(this.dblClickTimeout[1]);
  1263. eventManager.clear();
  1264. };
  1265. }
  1266. WalkontableEvent.prototype.parentCell = function(elem) {
  1267. var cell = {};
  1268. var TABLE = this.instance.wtTable.TABLE;
  1269. var TD = dom.closest(elem, ['TD', 'TH'], TABLE);
  1270. if (TD && dom.isChildOf(TD, TABLE)) {
  1271. cell.coords = this.instance.wtTable.getCoords(TD);
  1272. cell.TD = TD;
  1273. } else if (dom.hasClass(elem, 'wtBorder') && dom.hasClass(elem, 'current')) {
  1274. cell.coords = this.instance.selections.current.cellRange.highlight;
  1275. cell.TD = this.instance.wtTable.getCell(cell.coords);
  1276. } else if (dom.hasClass(elem, 'wtBorder') && dom.hasClass(elem, 'area')) {
  1277. if (this.instance.selections.area.cellRange) {
  1278. cell.coords = this.instance.selections.area.cellRange.to;
  1279. cell.TD = this.instance.wtTable.getCell(cell.coords);
  1280. }
  1281. }
  1282. return cell;
  1283. };
  1284. ;
  1285. window.WalkontableEvent = WalkontableEvent;
  1286. //#
  1287. },{"./../../../dom.js":27,"./../../../eventManager.js":41}],9:[function(require,module,exports){
  1288. "use strict";
  1289. Object.defineProperties(exports, {
  1290. WalkontableColumnFilter: {get: function() {
  1291. return WalkontableColumnFilter;
  1292. }},
  1293. __esModule: {value: true}
  1294. });
  1295. var WalkontableColumnFilter = function WalkontableColumnFilter(offset, total, countTH) {
  1296. this.offset = offset;
  1297. this.total = total;
  1298. this.countTH = countTH;
  1299. };
  1300. ($traceurRuntime.createClass)(WalkontableColumnFilter, {
  1301. offsetted: function(index) {
  1302. return index + this.offset;
  1303. },
  1304. unOffsetted: function(index) {
  1305. return index - this.offset;
  1306. },
  1307. renderedToSource: function(index) {
  1308. return this.offsetted(index);
  1309. },
  1310. sourceToRendered: function(index) {
  1311. return this.unOffsetted(index);
  1312. },
  1313. offsettedTH: function(index) {
  1314. return index - this.countTH;
  1315. },
  1316. unOffsettedTH: function(index) {
  1317. return index + this.countTH;
  1318. },
  1319. visibleRowHeadedColumnToSourceColumn: function(index) {
  1320. return this.renderedToSource(this.offsettedTH(index));
  1321. },
  1322. sourceColumnToVisibleRowHeadedColumn: function(index) {
  1323. return this.unOffsettedTH(this.sourceToRendered(index));
  1324. }
  1325. }, {});
  1326. ;
  1327. window.WalkontableColumnFilter = WalkontableColumnFilter;
  1328. //#
  1329. },{}],10:[function(require,module,exports){
  1330. "use strict";
  1331. Object.defineProperties(exports, {
  1332. WalkontableRowFilter: {get: function() {
  1333. return WalkontableRowFilter;
  1334. }},
  1335. __esModule: {value: true}
  1336. });
  1337. var WalkontableRowFilter = function WalkontableRowFilter(offset, total, countTH) {
  1338. this.offset = offset;
  1339. this.total = total;
  1340. this.countTH = countTH;
  1341. };
  1342. ($traceurRuntime.createClass)(WalkontableRowFilter, {
  1343. offsetted: function(index) {
  1344. return index + this.offset;
  1345. },
  1346. unOffsetted: function(index) {
  1347. return index - this.offset;
  1348. },
  1349. renderedToSource: function(index) {
  1350. return this.offsetted(index);
  1351. },
  1352. sourceToRendered: function(index) {
  1353. return this.unOffsetted(index);
  1354. },
  1355. offsettedTH: function(index) {
  1356. return index - this.countTH;
  1357. },
  1358. unOffsettedTH: function(index) {
  1359. return index + this.countTH;
  1360. },
  1361. visibleColHeadedRowToSourceRow: function(index) {
  1362. return this.renderedToSource(this.offsettedTH(index));
  1363. },
  1364. sourceRowToVisibleColHeadedRow: function(index) {
  1365. return this.unOffsettedTH(this.sourceToRendered(index));
  1366. }
  1367. }, {});
  1368. ;
  1369. window.WalkontableRowFilter = WalkontableRowFilter;
  1370. //#
  1371. },{}],11:[function(require,module,exports){
  1372. "use strict";
  1373. Object.defineProperties(exports, {
  1374. WalkontableOverlay: {get: function() {
  1375. return WalkontableOverlay;
  1376. }},
  1377. __esModule: {value: true}
  1378. });
  1379. var $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__,
  1380. $___46__46__47__46__46__47__46__46__47__46__46__47_helpers_46_js__,
  1381. $___46__46__47__46__46__47__46__46__47__46__46__47_eventManager_46_js__;
  1382. 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__});
  1383. 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;
  1384. 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;
  1385. var WalkontableOverlay = function WalkontableOverlay(wotInstance) {
  1386. defineGetter(this, 'wot', wotInstance, {writable: false});
  1387. this.instance = this.wot;
  1388. this.type = '';
  1389. this.TABLE = this.wot.wtTable.TABLE;
  1390. this.hider = this.wot.wtTable.hider;
  1391. this.spreader = this.wot.wtTable.spreader;
  1392. this.holder = this.wot.wtTable.holder;
  1393. this.wtRootElement = this.wot.wtTable.wtRootElement;
  1394. this.trimmingContainer = dom.getTrimmingContainer(this.hider.parentNode.parentNode);
  1395. this.mainTableScrollableElement = dom.getScrollableElement(this.wot.wtTable.TABLE);
  1396. this.needFullRender = this.shouldBeRendered();
  1397. this.isElementSizesAdjusted = false;
  1398. };
  1399. var $WalkontableOverlay = WalkontableOverlay;
  1400. ($traceurRuntime.createClass)(WalkontableOverlay, {
  1401. shouldBeRendered: function() {
  1402. return true;
  1403. },
  1404. makeClone: function(direction) {
  1405. if ($WalkontableOverlay.CLONE_TYPES.indexOf(direction) === -1) {
  1406. throw new Error('Clone type "' + direction + '" is not supported.');
  1407. }
  1408. var clone = document.createElement('DIV');
  1409. var clonedTable = document.createElement('TABLE');
  1410. clone.className = 'ht_clone_' + direction + ' handsontable';
  1411. clone.style.position = 'absolute';
  1412. clone.style.top = 0;
  1413. clone.style.left = 0;
  1414. clone.style.overflow = 'hidden';
  1415. clonedTable.className = this.wot.wtTable.TABLE.className;
  1416. clone.appendChild(clonedTable);
  1417. this.type = direction;
  1418. this.wot.wtTable.wtRootElement.parentNode.appendChild(clone);
  1419. return new Walkontable({
  1420. cloneSource: this.wot,
  1421. cloneOverlay: this,
  1422. table: clonedTable
  1423. });
  1424. },
  1425. refresh: function() {
  1426. var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
  1427. var nextCycleRenderFlag = this.shouldBeRendered();
  1428. if (this.clone && (this.needFullRender || nextCycleRenderFlag)) {
  1429. this.clone.draw(fastDraw);
  1430. }
  1431. this.needFullRender = nextCycleRenderFlag;
  1432. },
  1433. destroy: function() {
  1434. eventManagerObject(this.clone).clear();
  1435. }
  1436. }, {
  1437. get CLONE_TOP() {
  1438. return 'top';
  1439. },
  1440. get CLONE_LEFT() {
  1441. return 'left';
  1442. },
  1443. get CLONE_CORNER() {
  1444. return 'corner';
  1445. },
  1446. get CLONE_DEBUG() {
  1447. return 'debug';
  1448. },
  1449. get CLONE_TYPES() {
  1450. return [$WalkontableOverlay.CLONE_TOP, $WalkontableOverlay.CLONE_LEFT, $WalkontableOverlay.CLONE_CORNER, $WalkontableOverlay.CLONE_DEBUG];
  1451. }
  1452. });
  1453. ;
  1454. window.WalkontableOverlay = WalkontableOverlay;
  1455. //#
  1456. },{"./../../../../dom.js":27,"./../../../../eventManager.js":41,"./../../../../helpers.js":42}],12:[function(require,module,exports){
  1457. "use strict";
  1458. Object.defineProperties(exports, {
  1459. WalkontableCornerOverlay: {get: function() {
  1460. return WalkontableCornerOverlay;
  1461. }},
  1462. __esModule: {value: true}
  1463. });
  1464. var $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__,
  1465. $___95_base_46_js__;
  1466. 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__});
  1467. 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;
  1468. var WalkontableCornerOverlay = function WalkontableCornerOverlay(wotInstance) {
  1469. $traceurRuntime.superConstructor($WalkontableCornerOverlay).call(this, wotInstance);
  1470. this.clone = this.makeClone(WalkontableOverlay.CLONE_CORNER);
  1471. };
  1472. var $WalkontableCornerOverlay = WalkontableCornerOverlay;
  1473. ($traceurRuntime.createClass)(WalkontableCornerOverlay, {
  1474. shouldBeRendered: function() {
  1475. return (this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length) && (this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length) ? true : false;
  1476. },
  1477. resetFixedPosition: function() {
  1478. if (!this.wot.wtTable.holder.parentNode) {
  1479. return;
  1480. }
  1481. var overlayRoot = this.clone.wtTable.holder.parentNode;
  1482. var tableHeight = dom.outerHeight(this.clone.wtTable.TABLE);
  1483. var tableWidth = dom.outerWidth(this.clone.wtTable.TABLE);
  1484. if (this.trimmingContainer === window) {
  1485. var box = this.wot.wtTable.hider.getBoundingClientRect();
  1486. var top = Math.ceil(box.top);
  1487. var left = Math.ceil(box.left);
  1488. var bottom = Math.ceil(box.bottom);
  1489. var right = Math.ceil(box.right);
  1490. var finalLeft;
  1491. var finalTop;
  1492. if (left < 0 && (right - overlayRoot.offsetWidth) > 0) {
  1493. finalLeft = -left + 'px';
  1494. } else {
  1495. finalLeft = '0';
  1496. }
  1497. if (top < 0 && (bottom - overlayRoot.offsetHeight) > 0) {
  1498. finalTop = -top + 'px';
  1499. } else {
  1500. finalTop = '0';
  1501. }
  1502. dom.setOverlayPosition(overlayRoot, finalLeft, finalTop);
  1503. }
  1504. overlayRoot.style.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  1505. overlayRoot.style.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  1506. }
  1507. }, {}, WalkontableOverlay);
  1508. ;
  1509. window.WalkontableCornerOverlay = WalkontableCornerOverlay;
  1510. //#
  1511. },{"./../../../../dom.js":27,"./_base.js":11}],13:[function(require,module,exports){
  1512. "use strict";
  1513. Object.defineProperties(exports, {
  1514. WalkontableDebugOverlay: {get: function() {
  1515. return WalkontableDebugOverlay;
  1516. }},
  1517. __esModule: {value: true}
  1518. });
  1519. var $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__,
  1520. $___95_base_46_js__;
  1521. 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__});
  1522. 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;
  1523. var WalkontableDebugOverlay = function WalkontableDebugOverlay(wotInstance) {
  1524. $traceurRuntime.superConstructor($WalkontableDebugOverlay).call(this, wotInstance);
  1525. this.clone = this.makeClone(WalkontableOverlay.CLONE_DEBUG);
  1526. this.clone.wtTable.holder.style.opacity = 0.4;
  1527. this.clone.wtTable.holder.style.textShadow = '0 0 2px #ff0000';
  1528. dom.addClass(this.clone.wtTable.holder.parentNode, 'wtDebugVisible');
  1529. };
  1530. var $WalkontableDebugOverlay = WalkontableDebugOverlay;
  1531. ($traceurRuntime.createClass)(WalkontableDebugOverlay, {}, {}, WalkontableOverlay);
  1532. ;
  1533. window.WalkontableDebugOverlay = WalkontableDebugOverlay;
  1534. //#
  1535. },{"./../../../../dom.js":27,"./_base.js":11}],14:[function(require,module,exports){
  1536. "use strict";
  1537. Object.defineProperties(exports, {
  1538. WalkontableLeftOverlay: {get: function() {
  1539. return WalkontableLeftOverlay;
  1540. }},
  1541. __esModule: {value: true}
  1542. });
  1543. var $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__,
  1544. $___95_base_46_js__;
  1545. 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__});
  1546. 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;
  1547. var WalkontableLeftOverlay = function WalkontableLeftOverlay(wotInstance) {
  1548. $traceurRuntime.superConstructor($WalkontableLeftOverlay).call(this, wotInstance);
  1549. this.clone = this.makeClone(WalkontableOverlay.CLONE_LEFT);
  1550. };
  1551. var $WalkontableLeftOverlay = WalkontableLeftOverlay;
  1552. ($traceurRuntime.createClass)(WalkontableLeftOverlay, {
  1553. shouldBeRendered: function() {
  1554. return this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length ? true : false;
  1555. },
  1556. resetFixedPosition: function() {
  1557. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  1558. return;
  1559. }
  1560. var overlayRoot = this.clone.wtTable.holder.parentNode;
  1561. var headerPosition = 0;
  1562. if (this.trimmingContainer === window) {
  1563. var box = this.wot.wtTable.hider.getBoundingClientRect();
  1564. var left = Math.ceil(box.left);
  1565. var right = Math.ceil(box.right);
  1566. var finalLeft;
  1567. var finalTop;
  1568. finalTop = this.wot.wtTable.hider.style.top;
  1569. finalTop = finalTop === '' ? 0 : finalTop;
  1570. if (left < 0 && (right - overlayRoot.offsetWidth) > 0) {
  1571. finalLeft = -left;
  1572. } else {
  1573. finalLeft = 0;
  1574. }
  1575. headerPosition = finalLeft;
  1576. finalLeft = finalLeft + 'px';
  1577. dom.setOverlayPosition(overlayRoot, finalLeft, finalTop);
  1578. } else {
  1579. headerPosition = this.getScrollPosition();
  1580. }
  1581. this.adjustHeaderBordersPosition(headerPosition);
  1582. },
  1583. setScrollPosition: function(pos) {
  1584. if (this.mainTableScrollableElement === window) {
  1585. window.scrollTo(pos, dom.getWindowScrollTop());
  1586. } else {
  1587. this.mainTableScrollableElement.scrollLeft = pos;
  1588. }
  1589. },
  1590. onScroll: function() {
  1591. this.wot.getSetting('onScrollHorizontally');
  1592. },
  1593. sumCellSizes: function(from, to) {
  1594. var sum = 0;
  1595. var defaultColumnWidth = this.wot.wtSettings.defaultColumnWidth;
  1596. while (from < to) {
  1597. sum += this.wot.wtTable.getStretchedColumnWidth(from) || defaultColumnWidth;
  1598. from++;
  1599. }
  1600. return sum;
  1601. },
  1602. adjustElementsSize: function() {
  1603. var force = arguments[0] !== (void 0) ? arguments[0] : false;
  1604. if (this.needFullRender || force) {
  1605. this.adjustRootElementSize();
  1606. this.adjustRootChildsSize();
  1607. if (!force) {
  1608. this.isElementSizesAdjusted = true;
  1609. }
  1610. }
  1611. },
  1612. adjustRootElementSize: function() {
  1613. var masterHolder = this.wot.wtTable.holder;
  1614. var scrollbarHeight = masterHolder.clientHeight !== masterHolder.offsetHeight ? dom.getScrollbarWidth() : 0;
  1615. var overlayRoot = this.clone.wtTable.holder.parentNode;
  1616. var overlayRootStyle = overlayRoot.style;
  1617. var tableWidth;
  1618. if (this.trimmingContainer !== window) {
  1619. overlayRootStyle.height = this.wot.wtViewport.getWorkspaceHeight() - scrollbarHeight + 'px';
  1620. }
  1621. this.clone.wtTable.holder.style.height = overlayRootStyle.height;
  1622. tableWidth = dom.outerWidth(this.clone.wtTable.TABLE);
  1623. overlayRootStyle.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  1624. },
  1625. adjustRootChildsSize: function() {
  1626. var scrollbarWidth = dom.getScrollbarWidth();
  1627. this.clone.wtTable.hider.style.height = this.hider.style.height;
  1628. this.clone.wtTable.holder.style.height = this.clone.wtTable.holder.parentNode.style.height;
  1629. if (scrollbarWidth === 0) {
  1630. scrollbarWidth = 30;
  1631. }
  1632. this.clone.wtTable.holder.style.width = parseInt(this.clone.wtTable.holder.parentNode.style.width, 10) + scrollbarWidth + 'px';
  1633. },
  1634. applyToDOM: function() {
  1635. var total = this.wot.getSetting('totalColumns');
  1636. if (!this.isElementSizesAdjusted) {
  1637. this.adjustElementsSize();
  1638. }
  1639. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  1640. this.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  1641. } else if (total === 0) {
  1642. this.spreader.style.left = '0';
  1643. } else {
  1644. throw new Error('Incorrect value of the columnsRenderCalculator');
  1645. }
  1646. this.spreader.style.right = '';
  1647. if (this.needFullRender) {
  1648. this.syncOverlayOffset();
  1649. }
  1650. },
  1651. syncOverlayOffset: function() {
  1652. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  1653. this.clone.wtTable.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  1654. } else {
  1655. this.clone.wtTable.spreader.style.top = '';
  1656. }
  1657. },
  1658. scrollTo: function(sourceCol, beyondRendered) {
  1659. var newX = this.getTableParentOffset();
  1660. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  1661. var mainHolder = sourceInstance.wtTable.holder;
  1662. var scrollbarCompensation = 0;
  1663. if (beyondRendered && mainHolder.offsetWidth !== mainHolder.clientWidth) {
  1664. scrollbarCompensation = dom.getScrollbarWidth();
  1665. }
  1666. if (beyondRendered) {
  1667. newX += this.sumCellSizes(0, sourceCol + 1);
  1668. newX -= this.wot.wtViewport.getViewportWidth();
  1669. } else {
  1670. newX += this.sumCellSizes(this.wot.getSetting('fixedColumnsLeft'), sourceCol);
  1671. }
  1672. newX += scrollbarCompensation;
  1673. this.setScrollPosition(newX);
  1674. },
  1675. getTableParentOffset: function() {
  1676. if (this.trimmingContainer === window) {
  1677. return this.wot.wtTable.holderOffset.left;
  1678. } else {
  1679. return 0;
  1680. }
  1681. },
  1682. getScrollPosition: function() {
  1683. return dom.getScrollLeft(this.mainTableScrollableElement);
  1684. },
  1685. adjustHeaderBordersPosition: function(position) {
  1686. if (this.wot.getSetting('fixedColumnsLeft') === 0 && this.wot.getSetting('rowHeaders').length > 0) {
  1687. var masterParent = this.wot.wtTable.holder.parentNode;
  1688. var previousState = dom.hasClass(masterParent, 'innerBorderLeft');
  1689. if (position) {
  1690. dom.addClass(masterParent, 'innerBorderLeft');
  1691. } else {
  1692. dom.removeClass(masterParent, 'innerBorderLeft');
  1693. }
  1694. if (!previousState && position || previousState && !position) {
  1695. this.wot.wtOverlays.adjustElementsSize();
  1696. }
  1697. }
  1698. }
  1699. }, {}, WalkontableOverlay);
  1700. ;
  1701. window.WalkontableLeftOverlay = WalkontableLeftOverlay;
  1702. //#
  1703. },{"./../../../../dom.js":27,"./_base.js":11}],15:[function(require,module,exports){
  1704. "use strict";
  1705. Object.defineProperties(exports, {
  1706. WalkontableTopOverlay: {get: function() {
  1707. return WalkontableTopOverlay;
  1708. }},
  1709. __esModule: {value: true}
  1710. });
  1711. var $___46__46__47__46__46__47__46__46__47__46__46__47_dom_46_js__,
  1712. $___95_base_46_js__;
  1713. 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__});
  1714. 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;
  1715. var WalkontableTopOverlay = function WalkontableTopOverlay(wotInstance) {
  1716. $traceurRuntime.superConstructor($WalkontableTopOverlay).call(this, wotInstance);
  1717. this.clone = this.makeClone(WalkontableOverlay.CLONE_TOP);
  1718. };
  1719. var $WalkontableTopOverlay = WalkontableTopOverlay;
  1720. ($traceurRuntime.createClass)(WalkontableTopOverlay, {
  1721. shouldBeRendered: function() {
  1722. return this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length ? true : false;
  1723. },
  1724. resetFixedPosition: function() {
  1725. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  1726. return;
  1727. }
  1728. var overlayRoot = this.clone.wtTable.holder.parentNode;
  1729. var headerPosition = 0;
  1730. if (this.wot.wtOverlays.leftOverlay.trimmingContainer === window) {
  1731. var box = this.wot.wtTable.hider.getBoundingClientRect();
  1732. var top = Math.ceil(box.top);
  1733. var bottom = Math.ceil(box.bottom);
  1734. var finalLeft;
  1735. var finalTop;
  1736. finalLeft = this.wot.wtTable.hider.style.left;
  1737. finalLeft = finalLeft === '' ? 0 : finalLeft;
  1738. if (top < 0 && (bottom - overlayRoot.offsetHeight) > 0) {
  1739. finalTop = -top;
  1740. } else {
  1741. finalTop = 0;
  1742. }
  1743. headerPosition = finalTop;
  1744. finalTop = finalTop + 'px';
  1745. dom.setOverlayPosition(overlayRoot, finalLeft, finalTop);
  1746. } else {
  1747. headerPosition = this.getScrollPosition();
  1748. }
  1749. this.adjustHeaderBordersPosition(headerPosition);
  1750. },
  1751. setScrollPosition: function(pos) {
  1752. if (this.mainTableScrollableElement === window) {
  1753. window.scrollTo(dom.getWindowScrollLeft(), pos);
  1754. } else {
  1755. this.mainTableScrollableElement.scrollTop = pos;
  1756. }
  1757. },
  1758. onScroll: function() {
  1759. this.wot.getSetting('onScrollVertically');
  1760. },
  1761. sumCellSizes: function(from, to) {
  1762. var sum = 0;
  1763. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  1764. while (from < to) {
  1765. sum += this.wot.wtTable.getRowHeight(from) || defaultRowHeight;
  1766. from++;
  1767. }
  1768. return sum;
  1769. },
  1770. adjustElementsSize: function() {
  1771. var force = arguments[0] !== (void 0) ? arguments[0] : false;
  1772. if (this.needFullRender || force) {
  1773. this.adjustRootElementSize();
  1774. this.adjustRootChildsSize();
  1775. if (!force) {
  1776. this.isElementSizesAdjusted = true;
  1777. }
  1778. }
  1779. },
  1780. adjustRootElementSize: function() {
  1781. var masterHolder = this.wot.wtTable.holder;
  1782. var scrollbarWidth = masterHolder.clientWidth !== masterHolder.offsetWidth ? dom.getScrollbarWidth() : 0;
  1783. var overlayRoot = this.clone.wtTable.holder.parentNode;
  1784. var overlayRootStyle = overlayRoot.style;
  1785. var tableHeight;
  1786. if (this.trimmingContainer !== window) {
  1787. overlayRootStyle.width = this.wot.wtViewport.getWorkspaceWidth() - scrollbarWidth + 'px';
  1788. }
  1789. this.clone.wtTable.holder.style.width = overlayRootStyle.width;
  1790. tableHeight = dom.outerHeight(this.clone.wtTable.TABLE);
  1791. overlayRootStyle.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  1792. },
  1793. adjustRootChildsSize: function() {
  1794. var scrollbarWidth = dom.getScrollbarWidth();
  1795. this.clone.wtTable.hider.style.width = this.hider.style.width;
  1796. this.clone.wtTable.holder.style.width = this.clone.wtTable.holder.parentNode.style.width;
  1797. if (scrollbarWidth === 0) {
  1798. scrollbarWidth = 30;
  1799. }
  1800. this.clone.wtTable.holder.style.height = parseInt(this.clone.wtTable.holder.parentNode.style.height, 10) + scrollbarWidth + 'px';
  1801. },
  1802. applyToDOM: function() {
  1803. var total = this.wot.getSetting('totalRows');
  1804. if (!this.isElementSizesAdjusted) {
  1805. this.adjustElementsSize();
  1806. }
  1807. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  1808. this.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  1809. } else if (total === 0) {
  1810. this.spreader.style.top = '0';
  1811. } else {
  1812. throw new Error("Incorrect value of the rowsRenderCalculator");
  1813. }
  1814. this.spreader.style.bottom = '';
  1815. if (this.needFullRender) {
  1816. this.syncOverlayOffset();
  1817. }
  1818. },
  1819. syncOverlayOffset: function() {
  1820. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  1821. this.clone.wtTable.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  1822. } else {
  1823. this.clone.wtTable.spreader.style.left = '';
  1824. }
  1825. },
  1826. scrollTo: function(sourceRow, bottomEdge) {
  1827. var newY = this.getTableParentOffset();
  1828. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  1829. var mainHolder = sourceInstance.wtTable.holder;
  1830. var scrollbarCompensation = 0;
  1831. if (bottomEdge && mainHolder.offsetHeight !== mainHolder.clientHeight) {
  1832. scrollbarCompensation = dom.getScrollbarWidth();
  1833. }
  1834. if (bottomEdge) {
  1835. newY += this.sumCellSizes(0, sourceRow + 1);
  1836. newY -= this.wot.wtViewport.getViewportHeight();
  1837. newY += 1;
  1838. } else {
  1839. newY += this.sumCellSizes(this.wot.getSetting('fixedRowsTop'), sourceRow);
  1840. }
  1841. newY += scrollbarCompensation;
  1842. this.setScrollPosition(newY);
  1843. },
  1844. getTableParentOffset: function() {
  1845. if (this.mainTableScrollableElement === window) {
  1846. return this.wot.wtTable.holderOffset.top;
  1847. } else {
  1848. return 0;
  1849. }
  1850. },
  1851. getScrollPosition: function() {
  1852. return dom.getScrollTop(this.mainTableScrollableElement);
  1853. },
  1854. adjustHeaderBordersPosition: function(position) {
  1855. if (this.wot.getSetting('fixedRowsTop') === 0 && this.wot.getSetting('columnHeaders').length > 0) {
  1856. var masterParent = this.wot.wtTable.holder.parentNode;
  1857. var previousState = dom.hasClass(masterParent, 'innerBorderTop');
  1858. if (position) {
  1859. dom.addClass(masterParent, 'innerBorderTop');
  1860. } else {
  1861. dom.removeClass(masterParent, 'innerBorderTop');
  1862. }
  1863. if (!previousState && position || previousState && !position) {
  1864. this.wot.wtOverlays.adjustElementsSize();
  1865. }
  1866. }
  1867. if (this.wot.getSetting('rowHeaders').length === 0) {
  1868. var secondHeaderCell = this.clone.wtTable.THEAD.querySelector('th:nth-of-type(2)');
  1869. if (secondHeaderCell) {
  1870. secondHeaderCell.style['border-left-width'] = 0;
  1871. }
  1872. }
  1873. }
  1874. }, {}, WalkontableOverlay);
  1875. ;
  1876. window.WalkontableTopOverlay = WalkontableTopOverlay;
  1877. //#
  1878. },{"./../../../../dom.js":27,"./_base.js":11}],16:[function(require,module,exports){
  1879. "use strict";
  1880. Object.defineProperties(exports, {
  1881. WalkontableOverlays: {get: function() {
  1882. return WalkontableOverlays;
  1883. }},
  1884. __esModule: {value: true}
  1885. });
  1886. var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
  1887. $___46__46__47__46__46__47__46__46__47_eventManager_46_js__,
  1888. $__overlay_47_corner_46_js__,
  1889. $__overlay_47_debug_46_js__,
  1890. $__overlay_47_left_46_js__,
  1891. $__overlay_47_top_46_js__;
  1892. 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__});
  1893. 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;
  1894. 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;
  1895. 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;
  1896. 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;
  1897. 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;
  1898. var WalkontableOverlays = function WalkontableOverlays(wotInstance) {
  1899. this.wot = wotInstance;
  1900. this.instance = this.wot;
  1901. this.eventManager = new EventManager(this.wot);
  1902. this.wot.update('scrollbarWidth', dom.getScrollbarWidth());
  1903. this.wot.update('scrollbarHeight', dom.getScrollbarWidth());
  1904. this.mainTableScrollableElement = dom.getScrollableElement(this.wot.wtTable.TABLE);
  1905. this.topOverlay = new WalkontableTopOverlay(this.wot);
  1906. this.leftOverlay = new WalkontableLeftOverlay(this.wot);
  1907. if (this.topOverlay.needFullRender && this.leftOverlay.needFullRender) {
  1908. this.topLeftCornerOverlay = new WalkontableCornerOverlay(this.wot);
  1909. }
  1910. if (this.wot.getSetting('debug')) {
  1911. this.debug = new WalkontableDebugOverlay(this.wot);
  1912. }
  1913. this.destroyed = false;
  1914. this.keyPressed = false;
  1915. this.spreaderLastSize = {
  1916. width: null,
  1917. height: null
  1918. };
  1919. this.overlayScrollPositions = {
  1920. 'master': {
  1921. top: 0,
  1922. left: 0
  1923. },
  1924. 'top': {
  1925. top: null,
  1926. left: 0
  1927. },
  1928. 'left': {
  1929. top: 0,
  1930. left: null
  1931. }
  1932. };
  1933. this.registerListeners();
  1934. };
  1935. ($traceurRuntime.createClass)(WalkontableOverlays, {
  1936. refreshAll: function() {
  1937. if (!this.wot.drawn) {
  1938. return;
  1939. }
  1940. if (!this.wot.wtTable.holder.parentNode) {
  1941. this.destroy();
  1942. return;
  1943. }
  1944. this.wot.draw(true);
  1945. this.topOverlay.onScroll();
  1946. this.leftOverlay.onScroll();
  1947. },
  1948. registerListeners: function() {
  1949. var $__5 = this;
  1950. this.eventManager.addEventListener(document.documentElement, 'keydown', (function() {
  1951. return $__5.onKeyDown();
  1952. }));
  1953. this.eventManager.addEventListener(document.documentElement, 'keyup', (function() {
  1954. return $__5.onKeyUp();
  1955. }));
  1956. this.eventManager.addEventListener(this.mainTableScrollableElement, 'scroll', (function(event) {
  1957. return $__5.onTableScroll(event);
  1958. }));
  1959. if (this.topOverlay.needFullRender) {
  1960. this.eventManager.addEventListener(this.topOverlay.clone.wtTable.holder, 'scroll', (function(event) {
  1961. return $__5.onTableScroll(event);
  1962. }));
  1963. this.eventManager.addEventListener(this.topOverlay.clone.wtTable.holder, 'wheel', (function(event) {
  1964. return $__5.onTableScroll(event);
  1965. }));
  1966. }
  1967. if (this.leftOverlay.needFullRender) {
  1968. this.eventManager.addEventListener(this.leftOverlay.clone.wtTable.holder, 'scroll', (function(event) {
  1969. return $__5.onTableScroll(event);
  1970. }));
  1971. this.eventManager.addEventListener(this.leftOverlay.clone.wtTable.holder, 'wheel', (function(event) {
  1972. return $__5.onTableScroll(event);
  1973. }));
  1974. }
  1975. if (this.topOverlay.trimmingContainer !== window && this.leftOverlay.trimmingContainer !== window) {
  1976. this.eventManager.addEventListener(window, 'wheel', (function(event) {
  1977. var overlay;
  1978. var deltaY = event.wheelDeltaY || event.deltaY;
  1979. var deltaX = event.wheelDeltaX || event.deltaX;
  1980. if ($__5.topOverlay.clone.wtTable.holder.contains(event.target)) {
  1981. overlay = 'top';
  1982. } else if ($__5.leftOverlay.clone.wtTable.holder.contains(event.target)) {
  1983. overlay = 'left';
  1984. }
  1985. if (overlay == 'top' && deltaY !== 0) {
  1986. event.preventDefault();
  1987. } else if (overlay == 'left' && deltaX !== 0) {
  1988. event.preventDefault();
  1989. }
  1990. }));
  1991. }
  1992. },
  1993. onTableScroll: function(event) {
  1994. if (Handsontable.mobileBrowser) {
  1995. return;
  1996. }
  1997. if (this.keyPressed && this.mainTableScrollableElement !== window && !event.target.contains(this.mainTableScrollableElement)) {
  1998. return;
  1999. }
  2000. if (event.type === 'scroll') {
  2001. this.syncScrollPositions(event);
  2002. } else {
  2003. this.translateMouseWheelToScroll(event);
  2004. }
  2005. },
  2006. onKeyDown: function() {
  2007. this.keyPressed = true;
  2008. },
  2009. onKeyUp: function() {
  2010. this.keyPressed = false;
  2011. },
  2012. translateMouseWheelToScroll: function(event) {
  2013. var topOverlay = this.topOverlay.clone.wtTable.holder;
  2014. var leftOverlay = this.leftOverlay.clone.wtTable.holder;
  2015. var eventMockup = {type: 'wheel'};
  2016. var tempElem = event.target;
  2017. var deltaY = event.wheelDeltaY || (-1) * event.deltaY;
  2018. var deltaX = event.wheelDeltaX || (-1) * event.deltaX;
  2019. var parentHolder;
  2020. while (tempElem != document && tempElem != null) {
  2021. if (tempElem.className.indexOf('wtHolder') > -1) {
  2022. parentHolder = tempElem;
  2023. break;
  2024. }
  2025. tempElem = tempElem.parentNode;
  2026. }
  2027. eventMockup.target = parentHolder;
  2028. if (parentHolder == topOverlay) {
  2029. this.syncScrollPositions(eventMockup, (-0.2) * deltaY);
  2030. } else if (parentHolder == leftOverlay) {
  2031. this.syncScrollPositions(eventMockup, (-0.2) * deltaX);
  2032. }
  2033. return false;
  2034. },
  2035. syncScrollPositions: function(event) {
  2036. var fakeScrollValue = arguments[1] !== (void 0) ? arguments[1] : null;
  2037. if (this.destroyed) {
  2038. return;
  2039. }
  2040. if (arguments.length === 0) {
  2041. this.syncScrollWithMaster();
  2042. return;
  2043. }
  2044. var master = this.mainTableScrollableElement;
  2045. var target = event.target;
  2046. var tempScrollValue = 0;
  2047. var scrollValueChanged = false;
  2048. var topOverlay;
  2049. var leftOverlay;
  2050. if (this.topOverlay.needFullRender) {
  2051. topOverlay = this.topOverlay.clone.wtTable.holder;
  2052. }
  2053. if (this.leftOverlay.needFullRender) {
  2054. leftOverlay = this.leftOverlay.clone.wtTable.holder;
  2055. }
  2056. if (target === document) {
  2057. target = window;
  2058. }
  2059. if (target === master) {
  2060. tempScrollValue = dom.getScrollLeft(target);
  2061. if (this.overlayScrollPositions.master.left !== tempScrollValue) {
  2062. this.overlayScrollPositions.master.left = tempScrollValue;
  2063. scrollValueChanged = true;
  2064. if (topOverlay) {
  2065. topOverlay.scrollLeft = tempScrollValue;
  2066. }
  2067. }
  2068. tempScrollValue = dom.getScrollTop(target);
  2069. if (this.overlayScrollPositions.master.top !== tempScrollValue) {
  2070. this.overlayScrollPositions.master.top = tempScrollValue;
  2071. scrollValueChanged = true;
  2072. if (leftOverlay) {
  2073. leftOverlay.scrollTop = tempScrollValue;
  2074. }
  2075. }
  2076. } else if (target === topOverlay) {
  2077. tempScrollValue = dom.getScrollLeft(target);
  2078. if (this.overlayScrollPositions.top.left !== tempScrollValue) {
  2079. this.overlayScrollPositions.top.left = tempScrollValue;
  2080. scrollValueChanged = true;
  2081. master.scrollLeft = tempScrollValue;
  2082. }
  2083. if (fakeScrollValue !== null) {
  2084. scrollValueChanged = true;
  2085. master.scrollTop += fakeScrollValue;
  2086. }
  2087. } else if (target === leftOverlay) {
  2088. tempScrollValue = dom.getScrollTop(target);
  2089. if (this.overlayScrollPositions.left.top !== tempScrollValue) {
  2090. this.overlayScrollPositions.left.top = tempScrollValue;
  2091. scrollValueChanged = true;
  2092. master.scrollTop = tempScrollValue;
  2093. }
  2094. if (fakeScrollValue !== null) {
  2095. scrollValueChanged = true;
  2096. master.scrollLeft += fakeScrollValue;
  2097. }
  2098. }
  2099. if (!this.keyPressed && scrollValueChanged && event.type === 'scroll') {
  2100. this.refreshAll();
  2101. }
  2102. },
  2103. syncScrollWithMaster: function() {
  2104. var master = this.topOverlay.mainTableScrollableElement;
  2105. if (this.topOverlay.needFullRender) {
  2106. this.topOverlay.clone.wtTable.holder.scrollLeft = master.scrollLeft;
  2107. }
  2108. if (this.leftOverlay.needFullRender) {
  2109. this.leftOverlay.clone.wtTable.holder.scrollTop = master.scrollTop;
  2110. }
  2111. },
  2112. destroy: function() {
  2113. this.eventManager.clear();
  2114. this.topOverlay.destroy();
  2115. this.leftOverlay.destroy();
  2116. if (this.topLeftCornerOverlay) {
  2117. this.topLeftCornerOverlay.destroy();
  2118. }
  2119. if (this.debug) {
  2120. this.debug.destroy();
  2121. }
  2122. this.destroyed = true;
  2123. },
  2124. refresh: function() {
  2125. var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
  2126. if (this.topOverlay.isElementSizesAdjusted && this.leftOverlay.isElementSizesAdjusted) {
  2127. var container = this.wot.wtTable.wtRootElement.parentNode || this.wot.wtTable.wtRootElement;
  2128. var width = container.clientWidth;
  2129. var height = container.clientHeight;
  2130. if (width !== this.spreaderLastSize.width || height !== this.spreaderLastSize.height) {
  2131. this.spreaderLastSize.width = width;
  2132. this.spreaderLastSize.height = height;
  2133. this.adjustElementsSize();
  2134. }
  2135. }
  2136. this.leftOverlay.refresh(fastDraw);
  2137. this.topOverlay.refresh(fastDraw);
  2138. if (this.topLeftCornerOverlay) {
  2139. this.topLeftCornerOverlay.refresh(fastDraw);
  2140. }
  2141. if (this.debug) {
  2142. this.debug.refresh(fastDraw);
  2143. }
  2144. },
  2145. adjustElementsSize: function() {
  2146. var force = arguments[0] !== (void 0) ? arguments[0] : false;
  2147. var totalColumns = this.wot.getSetting('totalColumns');
  2148. var totalRows = this.wot.getSetting('totalRows');
  2149. var headerRowSize = this.wot.wtViewport.getRowHeaderWidth();
  2150. var headerColumnSize = this.wot.wtViewport.getColumnHeaderHeight();
  2151. var hiderStyle = this.wot.wtTable.hider.style;
  2152. hiderStyle.width = (headerRowSize + this.leftOverlay.sumCellSizes(0, totalColumns)) + 'px';
  2153. hiderStyle.height = (headerColumnSize + this.topOverlay.sumCellSizes(0, totalRows) + 1) + 'px';
  2154. this.topOverlay.adjustElementsSize(force);
  2155. this.leftOverlay.adjustElementsSize(force);
  2156. },
  2157. applyToDOM: function() {
  2158. if (!this.topOverlay.isElementSizesAdjusted || !this.leftOverlay.isElementSizesAdjusted) {
  2159. this.adjustElementsSize();
  2160. }
  2161. this.topOverlay.applyToDOM();
  2162. this.leftOverlay.applyToDOM();
  2163. }
  2164. }, {});
  2165. ;
  2166. window.WalkontableOverlays = WalkontableOverlays;
  2167. //#
  2168. },{"./../../../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){
  2169. "use strict";
  2170. Object.defineProperties(exports, {
  2171. WalkontableScroll: {get: function() {
  2172. return WalkontableScroll;
  2173. }},
  2174. __esModule: {value: true}
  2175. });
  2176. var WalkontableScroll = function WalkontableScroll(wotInstance) {
  2177. this.wot = wotInstance;
  2178. this.instance = wotInstance;
  2179. };
  2180. ($traceurRuntime.createClass)(WalkontableScroll, {scrollViewport: function(coords) {
  2181. if (!this.wot.drawn) {
  2182. return;
  2183. }
  2184. var totalRows = this.wot.getSetting('totalRows');
  2185. var totalColumns = this.wot.getSetting('totalColumns');
  2186. if (coords.row < 0 || coords.row > totalRows - 1) {
  2187. throw new Error('row ' + coords.row + ' does not exist');
  2188. }
  2189. if (coords.col < 0 || coords.col > totalColumns - 1) {
  2190. throw new Error('column ' + coords.col + ' does not exist');
  2191. }
  2192. if (coords.row > this.instance.wtTable.getLastVisibleRow()) {
  2193. this.wot.wtOverlays.topOverlay.scrollTo(coords.row, true);
  2194. } else if (coords.row >= this.instance.getSetting('fixedRowsTop') && coords.row < this.instance.wtTable.getFirstVisibleRow()) {
  2195. this.wot.wtOverlays.topOverlay.scrollTo(coords.row);
  2196. }
  2197. if (coords.col > this.instance.wtTable.getLastVisibleColumn()) {
  2198. this.wot.wtOverlays.leftOverlay.scrollTo(coords.col, true);
  2199. } else if (coords.col >= this.instance.getSetting('fixedColumnsLeft') && coords.col < this.instance.wtTable.getFirstVisibleColumn()) {
  2200. this.wot.wtOverlays.leftOverlay.scrollTo(coords.col);
  2201. }
  2202. }}, {});
  2203. ;
  2204. window.WalkontableScroll = WalkontableScroll;
  2205. //#
  2206. },{}],18:[function(require,module,exports){
  2207. "use strict";
  2208. Object.defineProperties(exports, {
  2209. WalkontableSelection: {get: function() {
  2210. return WalkontableSelection;
  2211. }},
  2212. __esModule: {value: true}
  2213. });
  2214. var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
  2215. $__border_46_js__,
  2216. $__cell_47_coords_46_js__,
  2217. $__cell_47_range_46_js__;
  2218. 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__});
  2219. var WalkontableBorder = ($__border_46_js__ = require("./border.js"), $__border_46_js__ && $__border_46_js__.__esModule && $__border_46_js__ || {default: $__border_46_js__}).WalkontableBorder;
  2220. 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;
  2221. 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;
  2222. var WalkontableSelection = function WalkontableSelection(settings, cellRange) {
  2223. this.settings = settings;
  2224. this.cellRange = cellRange || null;
  2225. this.instanceBorders = {};
  2226. };
  2227. ($traceurRuntime.createClass)(WalkontableSelection, {
  2228. getBorder: function(wotInstance) {
  2229. if (this.instanceBorders[wotInstance.guid]) {
  2230. return this.instanceBorders[wotInstance.guid];
  2231. }
  2232. this.instanceBorders[wotInstance.guid] = new WalkontableBorder(wotInstance, this.settings);
  2233. },
  2234. isEmpty: function() {
  2235. return this.cellRange === null;
  2236. },
  2237. add: function(coords) {
  2238. if (this.isEmpty()) {
  2239. this.cellRange = new WalkontableCellRange(coords, coords, coords);
  2240. } else {
  2241. this.cellRange.expand(coords);
  2242. }
  2243. },
  2244. replace: function(oldCoords, newCoords) {
  2245. if (!this.isEmpty()) {
  2246. if (this.cellRange.from.isEqual(oldCoords)) {
  2247. this.cellRange.from = newCoords;
  2248. return true;
  2249. }
  2250. if (this.cellRange.to.isEqual(oldCoords)) {
  2251. this.cellRange.to = newCoords;
  2252. return true;
  2253. }
  2254. }
  2255. return false;
  2256. },
  2257. clear: function() {
  2258. this.cellRange = null;
  2259. },
  2260. getCorners: function() {
  2261. var topLeft = this.cellRange.getTopLeftCorner();
  2262. var bottomRight = this.cellRange.getBottomRightCorner();
  2263. return [topLeft.row, topLeft.col, bottomRight.row, bottomRight.col];
  2264. },
  2265. addClassAtCoords: function(wotInstance, sourceRow, sourceColumn, className) {
  2266. var TD = wotInstance.wtTable.getCell(new WalkontableCellCoords(sourceRow, sourceColumn));
  2267. if (typeof TD === 'object') {
  2268. dom.addClass(TD, className);
  2269. }
  2270. },
  2271. draw: function(wotInstance) {
  2272. if (this.isEmpty()) {
  2273. if (this.settings.border) {
  2274. var border = this.getBorder(wotInstance);
  2275. if (border) {
  2276. border.disappear();
  2277. }
  2278. }
  2279. return;
  2280. }
  2281. var renderedRows = wotInstance.wtTable.getRenderedRowsCount();
  2282. var renderedColumns = wotInstance.wtTable.getRenderedColumnsCount();
  2283. var corners = this.getCorners();
  2284. var sourceRow,
  2285. sourceCol,
  2286. TH;
  2287. for (var column = 0; column < renderedColumns; column++) {
  2288. sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
  2289. if (sourceCol >= corners[1] && sourceCol <= corners[3]) {
  2290. TH = wotInstance.wtTable.getColumnHeader(sourceCol);
  2291. if (TH && this.settings.highlightColumnClassName) {
  2292. dom.addClass(TH, this.settings.highlightColumnClassName);
  2293. }
  2294. }
  2295. }
  2296. for (var row = 0; row < renderedRows; row++) {
  2297. sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row);
  2298. if (sourceRow >= corners[0] && sourceRow <= corners[2]) {
  2299. TH = wotInstance.wtTable.getRowHeader(sourceRow);
  2300. if (TH && this.settings.highlightRowClassName) {
  2301. dom.addClass(TH, this.settings.highlightRowClassName);
  2302. }
  2303. }
  2304. for (var column$__4 = 0; column$__4 < renderedColumns; column$__4++) {
  2305. sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column$__4);
  2306. if (sourceRow >= corners[0] && sourceRow <= corners[2] && sourceCol >= corners[1] && sourceCol <= corners[3]) {
  2307. if (this.settings.className) {
  2308. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.className);
  2309. }
  2310. } else if (sourceRow >= corners[0] && sourceRow <= corners[2]) {
  2311. if (this.settings.highlightRowClassName) {
  2312. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightRowClassName);
  2313. }
  2314. } else if (sourceCol >= corners[1] && sourceCol <= corners[3]) {
  2315. if (this.settings.highlightColumnClassName) {
  2316. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightColumnClassName);
  2317. }
  2318. }
  2319. }
  2320. }
  2321. wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className);
  2322. if (this.settings.border) {
  2323. var border$__5 = this.getBorder(wotInstance);
  2324. if (border$__5) {
  2325. border$__5.appear(corners);
  2326. }
  2327. }
  2328. }
  2329. }, {});
  2330. ;
  2331. window.WalkontableSelection = WalkontableSelection;
  2332. //#
  2333. },{"./../../../dom.js":27,"./border.js":2,"./cell/coords.js":5,"./cell/range.js":6}],19:[function(require,module,exports){
  2334. "use strict";
  2335. Object.defineProperties(exports, {
  2336. WalkontableSettings: {get: function() {
  2337. return WalkontableSettings;
  2338. }},
  2339. __esModule: {value: true}
  2340. });
  2341. var $___46__46__47__46__46__47__46__46__47_dom_46_js__;
  2342. 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__});
  2343. var WalkontableSettings = function WalkontableSettings(wotInstance, settings) {
  2344. var $__0 = this;
  2345. this.wot = wotInstance;
  2346. this.instance = wotInstance;
  2347. this.defaults = {
  2348. table: void 0,
  2349. debug: false,
  2350. stretchH: 'none',
  2351. currentRowClassName: null,
  2352. currentColumnClassName: null,
  2353. data: void 0,
  2354. fixedColumnsLeft: 0,
  2355. fixedRowsTop: 0,
  2356. rowHeaders: function() {
  2357. return [];
  2358. },
  2359. columnHeaders: function() {
  2360. return [];
  2361. },
  2362. totalRows: void 0,
  2363. totalColumns: void 0,
  2364. cellRenderer: (function(row, column, TD) {
  2365. var cellData = $__0.getSetting('data', row, column);
  2366. dom.fastInnerText(TD, cellData === void 0 || cellData === null ? '' : cellData);
  2367. }),
  2368. columnWidth: function(col) {
  2369. return;
  2370. },
  2371. rowHeight: function(row) {
  2372. return;
  2373. },
  2374. defaultRowHeight: 23,
  2375. defaultColumnWidth: 50,
  2376. selections: null,
  2377. hideBorderOnMouseDownOver: false,
  2378. viewportRowCalculatorOverride: null,
  2379. viewportColumnCalculatorOverride: null,
  2380. onCellMouseDown: null,
  2381. onCellMouseOver: null,
  2382. onCellDblClick: null,
  2383. onCellCornerMouseDown: null,
  2384. onCellCornerDblClick: null,
  2385. beforeDraw: null,
  2386. onDraw: null,
  2387. onBeforeDrawBorders: null,
  2388. onScrollVertically: null,
  2389. onScrollHorizontally: null,
  2390. onBeforeTouchScroll: null,
  2391. onAfterMomentumScroll: null,
  2392. scrollbarWidth: 10,
  2393. scrollbarHeight: 10,
  2394. renderAllRows: false,
  2395. groups: false
  2396. };
  2397. this.settings = {};
  2398. for (var i in this.defaults) {
  2399. if (this.defaults.hasOwnProperty(i)) {
  2400. if (settings[i] !== void 0) {
  2401. this.settings[i] = settings[i];
  2402. } else if (this.defaults[i] === void 0) {
  2403. throw new Error('A required setting "' + i + '" was not provided');
  2404. } else {
  2405. this.settings[i] = this.defaults[i];
  2406. }
  2407. }
  2408. }
  2409. };
  2410. ($traceurRuntime.createClass)(WalkontableSettings, {
  2411. update: function(settings, value) {
  2412. if (value === void 0) {
  2413. for (var i in settings) {
  2414. if (settings.hasOwnProperty(i)) {
  2415. this.settings[i] = settings[i];
  2416. }
  2417. }
  2418. } else {
  2419. this.settings[settings] = value;
  2420. }
  2421. return this.wot;
  2422. },
  2423. getSetting: function(key, param1, param2, param3, param4) {
  2424. if (typeof this.settings[key] === 'function') {
  2425. return this.settings[key](param1, param2, param3, param4);
  2426. } else if (param1 !== void 0 && Array.isArray(this.settings[key])) {
  2427. return this.settings[key][param1];
  2428. } else {
  2429. return this.settings[key];
  2430. }
  2431. },
  2432. has: function(key) {
  2433. return !!this.settings[key];
  2434. }
  2435. }, {});
  2436. ;
  2437. window.WalkontableSettings = WalkontableSettings;
  2438. //#
  2439. },{"./../../../dom.js":27}],20:[function(require,module,exports){
  2440. "use strict";
  2441. Object.defineProperties(exports, {
  2442. WalkontableTable: {get: function() {
  2443. return WalkontableTable;
  2444. }},
  2445. __esModule: {value: true}
  2446. });
  2447. var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
  2448. $__cell_47_coords_46_js__,
  2449. $__cell_47_range_46_js__,
  2450. $__filter_47_column_46_js__,
  2451. $__overlay_47_corner_46_js__,
  2452. $__overlay_47_debug_46_js__,
  2453. $__overlay_47_left_46_js__,
  2454. $__filter_47_row_46_js__,
  2455. $__tableRenderer_46_js__,
  2456. $__overlay_47_top_46_js__;
  2457. 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__});
  2458. 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;
  2459. 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;
  2460. 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;
  2461. 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;
  2462. 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;
  2463. 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;
  2464. 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;
  2465. var WalkontableTableRenderer = ($__tableRenderer_46_js__ = require("./tableRenderer.js"), $__tableRenderer_46_js__ && $__tableRenderer_46_js__.__esModule && $__tableRenderer_46_js__ || {default: $__tableRenderer_46_js__}).WalkontableTableRenderer;
  2466. 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;
  2467. function WalkontableTable(instance, table) {
  2468. this.instance = instance;
  2469. this.TABLE = table;
  2470. dom.removeTextNodes(this.TABLE);
  2471. var parent = this.TABLE.parentNode;
  2472. if (!parent || parent.nodeType !== 1 || !dom.hasClass(parent, 'wtHolder')) {
  2473. var spreader = document.createElement('DIV');
  2474. spreader.className = 'wtSpreader';
  2475. if (parent) {
  2476. parent.insertBefore(spreader, this.TABLE);
  2477. }
  2478. spreader.appendChild(this.TABLE);
  2479. }
  2480. this.spreader = this.TABLE.parentNode;
  2481. this.spreader.style.position = 'relative';
  2482. parent = this.spreader.parentNode;
  2483. if (!parent || parent.nodeType !== 1 || !dom.hasClass(parent, 'wtHolder')) {
  2484. var hider = document.createElement('DIV');
  2485. hider.className = 'wtHider';
  2486. if (parent) {
  2487. parent.insertBefore(hider, this.spreader);
  2488. }
  2489. hider.appendChild(this.spreader);
  2490. }
  2491. this.hider = this.spreader.parentNode;
  2492. parent = this.hider.parentNode;
  2493. if (!parent || parent.nodeType !== 1 || !dom.hasClass(parent, 'wtHolder')) {
  2494. var holder = document.createElement('DIV');
  2495. holder.style.position = 'relative';
  2496. holder.className = 'wtHolder';
  2497. if (parent) {
  2498. parent.insertBefore(holder, this.hider);
  2499. }
  2500. if (!instance.cloneSource) {
  2501. holder.parentNode.className += 'ht_master handsontable';
  2502. }
  2503. holder.appendChild(this.hider);
  2504. }
  2505. this.holder = this.hider.parentNode;
  2506. this.wtRootElement = this.holder.parentNode;
  2507. this.alignOverlaysWithTrimmingContainer();
  2508. this.TBODY = this.TABLE.getElementsByTagName('TBODY')[0];
  2509. if (!this.TBODY) {
  2510. this.TBODY = document.createElement('TBODY');
  2511. this.TABLE.appendChild(this.TBODY);
  2512. }
  2513. this.THEAD = this.TABLE.getElementsByTagName('THEAD')[0];
  2514. if (!this.THEAD) {
  2515. this.THEAD = document.createElement('THEAD');
  2516. this.TABLE.insertBefore(this.THEAD, this.TBODY);
  2517. }
  2518. this.COLGROUP = this.TABLE.getElementsByTagName('COLGROUP')[0];
  2519. if (!this.COLGROUP) {
  2520. this.COLGROUP = document.createElement('COLGROUP');
  2521. this.TABLE.insertBefore(this.COLGROUP, this.THEAD);
  2522. }
  2523. if (this.instance.getSetting('columnHeaders').length) {
  2524. if (!this.THEAD.childNodes.length) {
  2525. var TR = document.createElement('TR');
  2526. this.THEAD.appendChild(TR);
  2527. }
  2528. }
  2529. this.colgroupChildrenLength = this.COLGROUP.childNodes.length;
  2530. this.theadChildrenLength = this.THEAD.firstChild ? this.THEAD.firstChild.childNodes.length : 0;
  2531. this.tbodyChildrenLength = this.TBODY.childNodes.length;
  2532. this.rowFilter = null;
  2533. this.columnFilter = null;
  2534. }
  2535. WalkontableTable.prototype.alignOverlaysWithTrimmingContainer = function() {
  2536. var trimmingElement = dom.getTrimmingContainer(this.wtRootElement);
  2537. if (!this.isWorkingOnClone()) {
  2538. this.holder.parentNode.style.position = 'relative';
  2539. if (trimmingElement !== window) {
  2540. this.holder.style.width = dom.getStyle(trimmingElement, 'width');
  2541. this.holder.style.height = dom.getStyle(trimmingElement, 'height');
  2542. this.holder.style.overflow = '';
  2543. } else {
  2544. this.holder.style.overflow = 'visible';
  2545. this.wtRootElement.style.overflow = 'visible';
  2546. }
  2547. }
  2548. };
  2549. WalkontableTable.prototype.isWorkingOnClone = function() {
  2550. return !!this.instance.cloneSource;
  2551. };
  2552. WalkontableTable.prototype.draw = function(fastDraw) {
  2553. if (!this.isWorkingOnClone()) {
  2554. this.holderOffset = dom.offset(this.holder);
  2555. fastDraw = this.instance.wtViewport.createRenderCalculators(fastDraw);
  2556. }
  2557. if (!fastDraw) {
  2558. if (this.isWorkingOnClone()) {
  2559. this.tableOffset = this.instance.cloneSource.wtTable.tableOffset;
  2560. } else {
  2561. this.tableOffset = dom.offset(this.TABLE);
  2562. }
  2563. var startRow;
  2564. if (this.instance.cloneOverlay instanceof WalkontableDebugOverlay || this.instance.cloneOverlay instanceof WalkontableTopOverlay || this.instance.cloneOverlay instanceof WalkontableCornerOverlay) {
  2565. startRow = 0;
  2566. } else {
  2567. startRow = this.instance.wtViewport.rowsRenderCalculator.startRow;
  2568. }
  2569. var startColumn;
  2570. if (this.instance.cloneOverlay instanceof WalkontableDebugOverlay || this.instance.cloneOverlay instanceof WalkontableLeftOverlay || this.instance.cloneOverlay instanceof WalkontableCornerOverlay) {
  2571. startColumn = 0;
  2572. } else {
  2573. startColumn = this.instance.wtViewport.columnsRenderCalculator.startColumn;
  2574. }
  2575. this.rowFilter = new WalkontableRowFilter(startRow, this.instance.getSetting('totalRows'), this.instance.getSetting('columnHeaders').length);
  2576. this.columnFilter = new WalkontableColumnFilter(startColumn, this.instance.getSetting('totalColumns'), this.instance.getSetting('rowHeaders').length);
  2577. this._doDraw();
  2578. this.alignOverlaysWithTrimmingContainer();
  2579. } else {
  2580. if (!this.isWorkingOnClone()) {
  2581. this.instance.wtViewport.createVisibleCalculators();
  2582. }
  2583. if (this.instance.wtOverlays) {
  2584. this.instance.wtOverlays.refresh(true);
  2585. }
  2586. }
  2587. this.refreshSelections(fastDraw);
  2588. if (!this.isWorkingOnClone()) {
  2589. this.instance.wtOverlays.topOverlay.resetFixedPosition();
  2590. this.instance.wtOverlays.leftOverlay.resetFixedPosition();
  2591. if (this.instance.wtOverlays.topLeftCornerOverlay) {
  2592. this.instance.wtOverlays.topLeftCornerOverlay.resetFixedPosition();
  2593. }
  2594. }
  2595. this.instance.drawn = true;
  2596. return this;
  2597. };
  2598. WalkontableTable.prototype._doDraw = function() {
  2599. var wtRenderer = new WalkontableTableRenderer(this);
  2600. wtRenderer.render();
  2601. };
  2602. WalkontableTable.prototype.removeClassFromCells = function(className) {
  2603. var nodes = this.TABLE.querySelectorAll('.' + className);
  2604. for (var i = 0,
  2605. ilen = nodes.length; i < ilen; i++) {
  2606. dom.removeClass(nodes[i], className);
  2607. }
  2608. };
  2609. WalkontableTable.prototype.refreshSelections = function(fastDraw) {
  2610. var i,
  2611. len;
  2612. if (!this.instance.selections) {
  2613. return;
  2614. }
  2615. len = this.instance.selections.length;
  2616. if (fastDraw) {
  2617. for (i = 0; i < len; i++) {
  2618. if (this.instance.selections[i].settings.className) {
  2619. this.removeClassFromCells(this.instance.selections[i].settings.className);
  2620. }
  2621. if (this.instance.selections[i].settings.highlightRowClassName) {
  2622. this.removeClassFromCells(this.instance.selections[i].settings.highlightRowClassName);
  2623. }
  2624. if (this.instance.selections[i].settings.highlightColumnClassName) {
  2625. this.removeClassFromCells(this.instance.selections[i].settings.highlightColumnClassName);
  2626. }
  2627. }
  2628. }
  2629. for (i = 0; i < len; i++) {
  2630. this.instance.selections[i].draw(this.instance, fastDraw);
  2631. }
  2632. };
  2633. WalkontableTable.prototype.getCell = function(coords) {
  2634. if (this.isRowBeforeRenderedRows(coords.row)) {
  2635. return -1;
  2636. } else if (this.isRowAfterRenderedRows(coords.row)) {
  2637. return -2;
  2638. }
  2639. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(coords.row)];
  2640. if (TR) {
  2641. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(coords.col)];
  2642. }
  2643. };
  2644. WalkontableTable.prototype.getColumnHeader = function(col, level) {
  2645. if (!level) {
  2646. level = 0;
  2647. }
  2648. var TR = this.THEAD.childNodes[level];
  2649. if (TR) {
  2650. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(col)];
  2651. }
  2652. };
  2653. WalkontableTable.prototype.getRowHeader = function(row) {
  2654. if (this.columnFilter.sourceColumnToVisibleRowHeadedColumn(0) === 0) {
  2655. return null;
  2656. }
  2657. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  2658. if (TR) {
  2659. return TR.childNodes[0];
  2660. }
  2661. };
  2662. WalkontableTable.prototype.getCoords = function(TD) {
  2663. var TR = TD.parentNode;
  2664. var row = dom.index(TR);
  2665. if (TR.parentNode === this.THEAD) {
  2666. row = this.rowFilter.visibleColHeadedRowToSourceRow(row);
  2667. } else {
  2668. row = this.rowFilter.renderedToSource(row);
  2669. }
  2670. return new WalkontableCellCoords(row, this.columnFilter.visibleRowHeadedColumnToSourceColumn(TD.cellIndex));
  2671. };
  2672. WalkontableTable.prototype.getTrForRow = function(row) {
  2673. return this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  2674. };
  2675. WalkontableTable.prototype.getFirstRenderedRow = function() {
  2676. return this.instance.wtViewport.rowsRenderCalculator.startRow;
  2677. };
  2678. WalkontableTable.prototype.getFirstVisibleRow = function() {
  2679. return this.instance.wtViewport.rowsVisibleCalculator.startRow;
  2680. };
  2681. WalkontableTable.prototype.getFirstRenderedColumn = function() {
  2682. return this.instance.wtViewport.columnsRenderCalculator.startColumn;
  2683. };
  2684. WalkontableTable.prototype.getFirstVisibleColumn = function() {
  2685. return this.instance.wtViewport.columnsVisibleCalculator.startColumn;
  2686. };
  2687. WalkontableTable.prototype.getLastRenderedRow = function() {
  2688. return this.instance.wtViewport.rowsRenderCalculator.endRow;
  2689. };
  2690. WalkontableTable.prototype.getLastVisibleRow = function() {
  2691. return this.instance.wtViewport.rowsVisibleCalculator.endRow;
  2692. };
  2693. WalkontableTable.prototype.getLastRenderedColumn = function() {
  2694. return this.instance.wtViewport.columnsRenderCalculator.endColumn;
  2695. };
  2696. WalkontableTable.prototype.getLastVisibleColumn = function() {
  2697. return this.instance.wtViewport.columnsVisibleCalculator.endColumn;
  2698. };
  2699. WalkontableTable.prototype.isRowBeforeRenderedRows = function(r) {
  2700. return (this.rowFilter.sourceToRendered(r) < 0 && r >= 0);
  2701. };
  2702. WalkontableTable.prototype.isRowAfterViewport = function(r) {
  2703. return (r > this.getLastVisibleRow());
  2704. };
  2705. WalkontableTable.prototype.isRowAfterRenderedRows = function(r) {
  2706. return (r > this.getLastRenderedRow());
  2707. };
  2708. WalkontableTable.prototype.isColumnBeforeViewport = function(c) {
  2709. return (this.columnFilter.sourceToRendered(c) < 0 && c >= 0);
  2710. };
  2711. WalkontableTable.prototype.isColumnAfterViewport = function(c) {
  2712. return (c > this.getLastVisibleColumn());
  2713. };
  2714. WalkontableTable.prototype.isLastRowFullyVisible = function() {
  2715. return (this.getLastVisibleRow() === this.getLastRenderedRow());
  2716. };
  2717. WalkontableTable.prototype.isLastColumnFullyVisible = function() {
  2718. return (this.getLastVisibleColumn() === this.getLastRenderedColumn);
  2719. };
  2720. WalkontableTable.prototype.getRenderedColumnsCount = function() {
  2721. if (this.instance.cloneOverlay instanceof WalkontableDebugOverlay) {
  2722. return this.instance.getSetting('totalColumns');
  2723. } else if (this.instance.cloneOverlay instanceof WalkontableLeftOverlay || this.instance.cloneOverlay instanceof WalkontableCornerOverlay) {
  2724. return this.instance.getSetting('fixedColumnsLeft');
  2725. } else {
  2726. return this.instance.wtViewport.columnsRenderCalculator.count;
  2727. }
  2728. };
  2729. WalkontableTable.prototype.getRenderedRowsCount = function() {
  2730. if (this.instance.cloneOverlay instanceof WalkontableDebugOverlay) {
  2731. return this.instance.getSetting('totalRows');
  2732. } else if (this.instance.cloneOverlay instanceof WalkontableTopOverlay || this.instance.cloneOverlay instanceof WalkontableCornerOverlay) {
  2733. return this.instance.getSetting('fixedRowsTop');
  2734. }
  2735. return this.instance.wtViewport.rowsRenderCalculator.count;
  2736. };
  2737. WalkontableTable.prototype.getVisibleRowsCount = function() {
  2738. return this.instance.wtViewport.rowsVisibleCalculator.count;
  2739. };
  2740. WalkontableTable.prototype.allRowsInViewport = function() {
  2741. return this.instance.getSetting('totalRows') == this.getVisibleRowsCount();
  2742. };
  2743. WalkontableTable.prototype.getRowHeight = function(sourceRow) {
  2744. var height = this.instance.wtSettings.settings.rowHeight(sourceRow),
  2745. oversizedHeight = this.instance.wtViewport.oversizedRows[sourceRow];
  2746. if (oversizedHeight !== void 0) {
  2747. height = height ? Math.max(height, oversizedHeight) : oversizedHeight;
  2748. }
  2749. return height;
  2750. };
  2751. WalkontableTable.prototype.getColumnHeaderHeight = function(level) {
  2752. var height = this.instance.wtSettings.settings.defaultRowHeight,
  2753. oversizedHeight = this.instance.wtViewport.oversizedColumnHeaders[level];
  2754. if (oversizedHeight !== void 0) {
  2755. height = height ? Math.max(height, oversizedHeight) : oversizedHeight;
  2756. }
  2757. return height;
  2758. };
  2759. WalkontableTable.prototype.getVisibleColumnsCount = function() {
  2760. return this.instance.wtViewport.columnsVisibleCalculator.count;
  2761. };
  2762. WalkontableTable.prototype.allColumnsInViewport = function() {
  2763. return this.instance.getSetting('totalColumns') == this.getVisibleColumnsCount();
  2764. };
  2765. WalkontableTable.prototype.getColumnWidth = function(sourceColumn) {
  2766. var width = this.instance.wtSettings.settings.columnWidth;
  2767. if (typeof width === 'function') {
  2768. width = width(sourceColumn);
  2769. } else if (typeof width === 'object') {
  2770. width = width[sourceColumn];
  2771. }
  2772. var oversizedWidth = this.instance.wtViewport.oversizedCols[sourceColumn];
  2773. if (oversizedWidth !== void 0) {
  2774. width = width ? Math.max(width, oversizedWidth) : oversizedWidth;
  2775. }
  2776. return width;
  2777. };
  2778. WalkontableTable.prototype.getStretchedColumnWidth = function(sourceColumn) {
  2779. var width = this.getColumnWidth(sourceColumn) || this.instance.wtSettings.settings.defaultColumnWidth,
  2780. calculator = this.instance.wtViewport.columnsRenderCalculator,
  2781. stretchedWidth;
  2782. if (calculator) {
  2783. stretchedWidth = calculator.getStretchedColumnWidth(sourceColumn, width);
  2784. if (stretchedWidth) {
  2785. width = stretchedWidth;
  2786. }
  2787. }
  2788. return width;
  2789. };
  2790. ;
  2791. window.WalkontableTable = WalkontableTable;
  2792. //#
  2793. },{"./../../../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){
  2794. "use strict";
  2795. Object.defineProperties(exports, {
  2796. WalkontableTableRenderer: {get: function() {
  2797. return WalkontableTableRenderer;
  2798. }},
  2799. __esModule: {value: true}
  2800. });
  2801. var $___46__46__47__46__46__47__46__46__47_dom_46_js__;
  2802. 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__});
  2803. var isRenderedColumnHeaders = {};
  2804. var WalkontableTableRenderer = function WalkontableTableRenderer(wtTable) {
  2805. this.wtTable = wtTable;
  2806. this.wot = wtTable.instance;
  2807. this.instance = wtTable.instance;
  2808. this.rowFilter = wtTable.rowFilter;
  2809. this.columnFilter = wtTable.columnFilter;
  2810. this.TABLE = wtTable.TABLE;
  2811. this.THEAD = wtTable.THEAD;
  2812. this.TBODY = wtTable.TBODY;
  2813. this.COLGROUP = wtTable.COLGROUP;
  2814. this.rowHeaders = [];
  2815. this.rowHeaderCount = 0;
  2816. this.columnHeaders = [];
  2817. this.columnHeaderCount = 0;
  2818. this.fixedRowsTop = 0;
  2819. };
  2820. ($traceurRuntime.createClass)(WalkontableTableRenderer, {
  2821. render: function() {
  2822. if (!this.wtTable.isWorkingOnClone()) {
  2823. this.wot.getSetting('beforeDraw', true);
  2824. }
  2825. this.rowHeaders = this.wot.getSetting('rowHeaders');
  2826. this.rowHeaderCount = this.rowHeaders.length;
  2827. this.fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  2828. this.columnHeaders = this.wot.getSetting('columnHeaders');
  2829. this.columnHeaderCount = this.columnHeaders.length;
  2830. var columnsToRender = this.wtTable.getRenderedColumnsCount();
  2831. var rowsToRender = this.wtTable.getRenderedRowsCount();
  2832. var totalColumns = this.wot.getSetting('totalColumns');
  2833. var totalRows = this.wot.getSetting('totalRows');
  2834. var workspaceWidth;
  2835. var adjusted = false;
  2836. if (totalColumns > 0) {
  2837. this.adjustAvailableNodes();
  2838. adjusted = true;
  2839. this.renderColGroups();
  2840. this.renderColumnHeaders();
  2841. this.renderRows(totalRows, rowsToRender, columnsToRender);
  2842. if (!this.wtTable.isWorkingOnClone()) {
  2843. workspaceWidth = this.wot.wtViewport.getWorkspaceWidth();
  2844. this.wot.wtViewport.containerWidth = null;
  2845. } else {
  2846. this.adjustColumnHeaderHeights();
  2847. }
  2848. this.adjustColumnWidths(columnsToRender);
  2849. }
  2850. if (!adjusted) {
  2851. this.adjustAvailableNodes();
  2852. }
  2853. this.removeRedundantRows(rowsToRender);
  2854. if (!this.wtTable.isWorkingOnClone()) {
  2855. this.markOversizedRows();
  2856. this.wot.wtViewport.createVisibleCalculators();
  2857. this.wot.wtOverlays.refresh(false);
  2858. this.wot.wtOverlays.applyToDOM();
  2859. if (workspaceWidth !== this.wot.wtViewport.getWorkspaceWidth()) {
  2860. this.wot.wtViewport.containerWidth = null;
  2861. var firstRendered = this.wtTable.getFirstRenderedColumn();
  2862. var lastRendered = this.wtTable.getLastRenderedColumn();
  2863. for (var i = firstRendered; i < lastRendered; i++) {
  2864. var width = this.wtTable.getStretchedColumnWidth(i);
  2865. var renderedIndex = this.columnFilter.sourceToRendered(i);
  2866. this.COLGROUP.childNodes[renderedIndex + this.rowHeaderCount].style.width = width + 'px';
  2867. }
  2868. }
  2869. this.wot.getSetting('onDraw', true);
  2870. }
  2871. },
  2872. removeRedundantRows: function(renderedRowsCount) {
  2873. while (this.wtTable.tbodyChildrenLength > renderedRowsCount) {
  2874. this.TBODY.removeChild(this.TBODY.lastChild);
  2875. this.wtTable.tbodyChildrenLength--;
  2876. }
  2877. },
  2878. renderRows: function(totalRows, rowsToRender, columnsToRender) {
  2879. var lastTD,
  2880. TR;
  2881. var visibleRowIndex = 0;
  2882. var sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  2883. var isWorkingOnClone = this.wtTable.isWorkingOnClone();
  2884. while (sourceRowIndex < totalRows && sourceRowIndex >= 0) {
  2885. if (visibleRowIndex > 1000) {
  2886. throw new Error('Security brake: Too much TRs. Please define height for your table, which will enforce scrollbars.');
  2887. }
  2888. if (rowsToRender !== void 0 && visibleRowIndex === rowsToRender) {
  2889. break;
  2890. }
  2891. TR = this.getOrCreateTrForRow(visibleRowIndex, TR);
  2892. this.renderRowHeaders(sourceRowIndex, TR);
  2893. this.adjustColumns(TR, columnsToRender + this.rowHeaderCount);
  2894. lastTD = this.renderCells(sourceRowIndex, TR, columnsToRender);
  2895. if (!isWorkingOnClone) {
  2896. this.resetOversizedRow(sourceRowIndex);
  2897. }
  2898. if (TR.firstChild) {
  2899. var height = this.wot.wtTable.getRowHeight(sourceRowIndex);
  2900. if (height) {
  2901. TR.firstChild.style.height = height + 'px';
  2902. } else {
  2903. TR.firstChild.style.height = '';
  2904. }
  2905. }
  2906. visibleRowIndex++;
  2907. sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  2908. }
  2909. },
  2910. resetOversizedRow: function(sourceRow) {
  2911. if (this.wot.wtViewport.oversizedRows && this.wot.wtViewport.oversizedRows[sourceRow]) {
  2912. this.wot.wtViewport.oversizedRows[sourceRow] = void 0;
  2913. }
  2914. },
  2915. markOversizedRows: function() {
  2916. var rowCount = this.instance.wtTable.TBODY.childNodes.length;
  2917. var expectedTableHeight = rowCount * this.instance.wtSettings.settings.defaultRowHeight;
  2918. var actualTableHeight = dom.innerHeight(this.instance.wtTable.TBODY) - 1;
  2919. var previousRowHeight;
  2920. var rowInnerHeight;
  2921. var sourceRowIndex;
  2922. var currentTr;
  2923. var rowHeader;
  2924. if (expectedTableHeight === actualTableHeight) {
  2925. return;
  2926. }
  2927. while (rowCount) {
  2928. rowCount--;
  2929. sourceRowIndex = this.instance.wtTable.rowFilter.renderedToSource(rowCount);
  2930. previousRowHeight = this.instance.wtTable.getRowHeight(sourceRowIndex);
  2931. currentTr = this.instance.wtTable.getTrForRow(sourceRowIndex);
  2932. rowHeader = currentTr.querySelector('th');
  2933. if (rowHeader) {
  2934. rowInnerHeight = dom.innerHeight(rowHeader);
  2935. } else {
  2936. rowInnerHeight = dom.innerHeight(currentTr) - 1;
  2937. }
  2938. if ((!previousRowHeight && this.instance.wtSettings.settings.defaultRowHeight < rowInnerHeight || previousRowHeight < rowInnerHeight)) {
  2939. this.instance.wtViewport.oversizedRows[sourceRowIndex] = rowInnerHeight;
  2940. }
  2941. }
  2942. },
  2943. adjustColumnHeaderHeights: function() {
  2944. var columnHeaders = this.wot.getSetting('columnHeaders');
  2945. var childs = this.wot.wtTable.THEAD.childNodes;
  2946. var oversizedCols = this.wot.wtViewport.oversizedColumnHeaders;
  2947. for (var i = 0,
  2948. len = columnHeaders.length; i < len; i++) {
  2949. if (oversizedCols[i]) {
  2950. if (childs[i].childNodes.length === 0) {
  2951. return;
  2952. }
  2953. childs[i].childNodes[0].style.height = oversizedCols[i] + 'px';
  2954. }
  2955. }
  2956. },
  2957. markIfOversizedColumnHeader: function(col) {
  2958. var level = this.wot.getSetting('columnHeaders').length;
  2959. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  2960. var sourceColIndex;
  2961. var previousColHeaderHeight;
  2962. var currentHeader;
  2963. var currentHeaderHeight;
  2964. sourceColIndex = this.wot.wtTable.columnFilter.renderedToSource(col);
  2965. while (level) {
  2966. level--;
  2967. previousColHeaderHeight = this.wot.wtTable.getColumnHeaderHeight(level);
  2968. currentHeader = this.wot.wtTable.getColumnHeader(sourceColIndex, level);
  2969. if (!currentHeader) {
  2970. continue;
  2971. }
  2972. currentHeaderHeight = dom.innerHeight(currentHeader);
  2973. if (!previousColHeaderHeight && defaultRowHeight < currentHeaderHeight || previousColHeaderHeight < currentHeaderHeight) {
  2974. this.wot.wtViewport.oversizedColumnHeaders[level] = currentHeaderHeight;
  2975. }
  2976. }
  2977. },
  2978. renderCells: function(sourceRowIndex, TR, columnsToRender) {
  2979. var TD;
  2980. var sourceColIndex;
  2981. for (var visibleColIndex = 0; visibleColIndex < columnsToRender; visibleColIndex++) {
  2982. sourceColIndex = this.columnFilter.renderedToSource(visibleColIndex);
  2983. if (visibleColIndex === 0) {
  2984. TD = TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(sourceColIndex)];
  2985. } else {
  2986. TD = TD.nextSibling;
  2987. }
  2988. if (TD.nodeName == 'TH') {
  2989. TD = replaceThWithTd(TD, TR);
  2990. }
  2991. if (!dom.hasClass(TD, 'hide')) {
  2992. TD.className = '';
  2993. }
  2994. TD.removeAttribute('style');
  2995. this.wot.wtSettings.settings.cellRenderer(sourceRowIndex, sourceColIndex, TD);
  2996. }
  2997. return TD;
  2998. },
  2999. adjustColumnWidths: function(columnsToRender) {
  3000. var scrollbarCompensation = 0;
  3001. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  3002. var mainHolder = sourceInstance.wtTable.holder;
  3003. if (mainHolder.offsetHeight < mainHolder.scrollHeight) {
  3004. scrollbarCompensation = dom.getScrollbarWidth();
  3005. }
  3006. this.wot.wtViewport.columnsRenderCalculator.refreshStretching(this.wot.wtViewport.getViewportWidth() - scrollbarCompensation);
  3007. for (var renderedColIndex = 0; renderedColIndex < columnsToRender; renderedColIndex++) {
  3008. var width = this.wtTable.getStretchedColumnWidth(this.columnFilter.renderedToSource(renderedColIndex));
  3009. this.COLGROUP.childNodes[renderedColIndex + this.rowHeaderCount].style.width = width + 'px';
  3010. }
  3011. },
  3012. appendToTbody: function(TR) {
  3013. this.TBODY.appendChild(TR);
  3014. this.wtTable.tbodyChildrenLength++;
  3015. },
  3016. getOrCreateTrForRow: function(rowIndex, currentTr) {
  3017. var TR;
  3018. if (rowIndex >= this.wtTable.tbodyChildrenLength) {
  3019. TR = this.createRow();
  3020. this.appendToTbody(TR);
  3021. } else if (rowIndex === 0) {
  3022. TR = this.TBODY.firstChild;
  3023. } else {
  3024. TR = currentTr.nextSibling;
  3025. }
  3026. return TR;
  3027. },
  3028. createRow: function() {
  3029. var TR = document.createElement('TR');
  3030. for (var visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  3031. TR.appendChild(document.createElement('TH'));
  3032. }
  3033. return TR;
  3034. },
  3035. renderRowHeader: function(row, col, TH) {
  3036. TH.className = '';
  3037. TH.removeAttribute('style');
  3038. this.rowHeaders[col](row, TH, col);
  3039. },
  3040. renderRowHeaders: function(row, TR) {
  3041. for (var TH = TR.firstChild,
  3042. visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  3043. if (!TH) {
  3044. TH = document.createElement('TH');
  3045. TR.appendChild(TH);
  3046. } else if (TH.nodeName == 'TD') {
  3047. TH = replaceTdWithTh(TH, TR);
  3048. }
  3049. this.renderRowHeader(row, visibleColIndex, TH);
  3050. TH = TH.nextSibling;
  3051. }
  3052. },
  3053. adjustAvailableNodes: function() {
  3054. this.adjustColGroups();
  3055. this.adjustThead();
  3056. },
  3057. renderColumnHeaders: function() {
  3058. var overlayName = this.wot.getOverlayName();
  3059. if (!this.columnHeaderCount) {
  3060. return;
  3061. }
  3062. var columnCount = this.wtTable.getRenderedColumnsCount();
  3063. for (var i = 0; i < this.columnHeaderCount; i++) {
  3064. var TR = this.getTrForColumnHeaders(i);
  3065. for (var renderedColumnIndex = (-1) * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
  3066. var sourceCol = this.columnFilter.renderedToSource(renderedColumnIndex);
  3067. this.renderColumnHeader(i, sourceCol, TR.childNodes[renderedColumnIndex + this.rowHeaderCount]);
  3068. if (!isRenderedColumnHeaders[overlayName] && !this.wtTable.isWorkingOnClone()) {
  3069. this.markIfOversizedColumnHeader(renderedColumnIndex);
  3070. }
  3071. }
  3072. }
  3073. isRenderedColumnHeaders[overlayName] = true;
  3074. },
  3075. adjustColGroups: function() {
  3076. var columnCount = this.wtTable.getRenderedColumnsCount();
  3077. while (this.wtTable.colgroupChildrenLength < columnCount + this.rowHeaderCount) {
  3078. this.COLGROUP.appendChild(document.createElement('COL'));
  3079. this.wtTable.colgroupChildrenLength++;
  3080. }
  3081. while (this.wtTable.colgroupChildrenLength > columnCount + this.rowHeaderCount) {
  3082. this.COLGROUP.removeChild(this.COLGROUP.lastChild);
  3083. this.wtTable.colgroupChildrenLength--;
  3084. }
  3085. },
  3086. adjustThead: function() {
  3087. var columnCount = this.wtTable.getRenderedColumnsCount();
  3088. var TR = this.THEAD.firstChild;
  3089. if (this.columnHeaders.length) {
  3090. for (var i = 0,
  3091. len = this.columnHeaders.length; i < len; i++) {
  3092. TR = this.THEAD.childNodes[i];
  3093. if (!TR) {
  3094. TR = document.createElement('TR');
  3095. this.THEAD.appendChild(TR);
  3096. }
  3097. this.theadChildrenLength = TR.childNodes.length;
  3098. while (this.theadChildrenLength < columnCount + this.rowHeaderCount) {
  3099. TR.appendChild(document.createElement('TH'));
  3100. this.theadChildrenLength++;
  3101. }
  3102. while (this.theadChildrenLength > columnCount + this.rowHeaderCount) {
  3103. TR.removeChild(TR.lastChild);
  3104. this.theadChildrenLength--;
  3105. }
  3106. }
  3107. var theadChildrenLength = this.THEAD.childNodes.length;
  3108. if (theadChildrenLength > this.columnHeaders.length) {
  3109. for (var i$__1 = this.columnHeaders.length; i$__1 < theadChildrenLength; i$__1++) {
  3110. this.THEAD.removeChild(this.THEAD.lastChild);
  3111. }
  3112. }
  3113. } else if (TR) {
  3114. dom.empty(TR);
  3115. }
  3116. },
  3117. getTrForColumnHeaders: function(index) {
  3118. return this.THEAD.childNodes[index];
  3119. },
  3120. renderColumnHeader: function(row, col, TH) {
  3121. TH.className = '';
  3122. TH.removeAttribute('style');
  3123. return this.columnHeaders[row](col, TH, row);
  3124. },
  3125. renderColGroups: function() {
  3126. for (var colIndex = 0; colIndex < this.wtTable.colgroupChildrenLength; colIndex++) {
  3127. if (colIndex < this.rowHeaderCount) {
  3128. dom.addClass(this.COLGROUP.childNodes[colIndex], 'rowHeader');
  3129. } else {
  3130. dom.removeClass(this.COLGROUP.childNodes[colIndex], 'rowHeader');
  3131. }
  3132. }
  3133. },
  3134. adjustColumns: function(TR, desiredCount) {
  3135. var count = TR.childNodes.length;
  3136. while (count < desiredCount) {
  3137. var TD = document.createElement('TD');
  3138. TR.appendChild(TD);
  3139. count++;
  3140. }
  3141. while (count > desiredCount) {
  3142. TR.removeChild(TR.lastChild);
  3143. count--;
  3144. }
  3145. },
  3146. removeRedundantColumns: function(columnsToRender) {
  3147. while (this.wtTable.tbodyChildrenLength > columnsToRender) {
  3148. this.TBODY.removeChild(this.TBODY.lastChild);
  3149. this.wtTable.tbodyChildrenLength--;
  3150. }
  3151. }
  3152. }, {});
  3153. function replaceTdWithTh(TD, TR) {
  3154. var TH = document.createElement('TH');
  3155. TR.insertBefore(TH, TD);
  3156. TR.removeChild(TD);
  3157. return TH;
  3158. }
  3159. function replaceThWithTd(TH, TR) {
  3160. var TD = document.createElement('TD');
  3161. TR.insertBefore(TD, TH);
  3162. TR.removeChild(TH);
  3163. return TD;
  3164. }
  3165. ;
  3166. window.WalkontableTableRenderer = WalkontableTableRenderer;
  3167. //#
  3168. },{"./../../../dom.js":27}],22:[function(require,module,exports){
  3169. "use strict";
  3170. Object.defineProperties(exports, {
  3171. WalkontableViewport: {get: function() {
  3172. return WalkontableViewport;
  3173. }},
  3174. __esModule: {value: true}
  3175. });
  3176. var $___46__46__47__46__46__47__46__46__47_dom_46_js__,
  3177. $___46__46__47__46__46__47__46__46__47_eventManager_46_js__,
  3178. $__calculator_47_viewportColumns_46_js__,
  3179. $__calculator_47_viewportRows_46_js__;
  3180. 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__});
  3181. 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;
  3182. 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;
  3183. 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;
  3184. var WalkontableViewport = function WalkontableViewport(wotInstance) {
  3185. var $__3 = this;
  3186. this.wot = wotInstance;
  3187. this.instance = this.wot;
  3188. this.oversizedRows = [];
  3189. this.oversizedCols = [];
  3190. this.oversizedColumnHeaders = [];
  3191. this.clientHeight = 0;
  3192. this.containerWidth = NaN;
  3193. this.rowHeaderWidth = NaN;
  3194. this.rowsVisibleCalculator = null;
  3195. this.columnsVisibleCalculator = null;
  3196. var eventManager = eventManagerObject(wotInstance);
  3197. eventManager.addEventListener(window, 'resize', (function() {
  3198. $__3.clientHeight = $__3.getWorkspaceHeight();
  3199. }));
  3200. };
  3201. ($traceurRuntime.createClass)(WalkontableViewport, {
  3202. getWorkspaceHeight: function() {
  3203. var trimmingContainer = this.instance.wtOverlays.topOverlay.trimmingContainer;
  3204. var elemHeight;
  3205. var height = 0;
  3206. if (trimmingContainer === window) {
  3207. height = document.documentElement.clientHeight;
  3208. } else {
  3209. elemHeight = dom.outerHeight(trimmingContainer);
  3210. height = (elemHeight > 0 && trimmingContainer.clientHeight > 0) ? trimmingContainer.clientHeight : Infinity;
  3211. }
  3212. return height;
  3213. },
  3214. getWorkspaceWidth: function() {
  3215. var width;
  3216. var totalColumns = this.instance.getSetting("totalColumns");
  3217. var trimmingContainer = this.instance.wtOverlays.leftOverlay.trimmingContainer;
  3218. var overflow;
  3219. var stretchSetting = this.instance.getSetting('stretchH');
  3220. var docOffsetWidth = document.documentElement.offsetWidth;
  3221. if (Handsontable.freezeOverlays) {
  3222. width = Math.min(docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  3223. } else {
  3224. width = Math.min(this.getContainerFillWidth(), docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  3225. }
  3226. if (trimmingContainer === window && totalColumns > 0 && this.sumColumnWidths(0, totalColumns - 1) > width) {
  3227. return document.documentElement.clientWidth;
  3228. }
  3229. if (trimmingContainer !== window) {
  3230. overflow = dom.getStyle(this.instance.wtOverlays.leftOverlay.trimmingContainer, 'overflow');
  3231. if (overflow == "scroll" || overflow == "hidden" || overflow == "auto") {
  3232. return Math.max(width, trimmingContainer.clientWidth);
  3233. }
  3234. }
  3235. if (stretchSetting === 'none' || !stretchSetting) {
  3236. return Math.max(width, dom.outerWidth(this.instance.wtTable.TABLE));
  3237. } else {
  3238. return width;
  3239. }
  3240. },
  3241. hasVerticalScroll: function() {
  3242. return this.getWorkspaceActualHeight() > this.getWorkspaceHeight();
  3243. },
  3244. hasHorizontalScroll: function() {
  3245. return this.getWorkspaceActualWidth() > this.getWorkspaceWidth();
  3246. },
  3247. sumColumnWidths: function(from, length) {
  3248. var sum = 0;
  3249. var defaultColumnWidth = this.instance.wtSettings.defaultColumnWidth;
  3250. while (from < length) {
  3251. sum += this.wot.wtTable.getColumnWidth(from) || defaultColumnWidth;
  3252. from++;
  3253. }
  3254. return sum;
  3255. },
  3256. getContainerFillWidth: function() {
  3257. if (this.containerWidth) {
  3258. return this.containerWidth;
  3259. }
  3260. var mainContainer = this.instance.wtTable.holder;
  3261. var fillWidth;
  3262. var dummyElement;
  3263. dummyElement = document.createElement("DIV");
  3264. dummyElement.style.width = "100%";
  3265. dummyElement.style.height = "1px";
  3266. mainContainer.appendChild(dummyElement);
  3267. fillWidth = dummyElement.offsetWidth;
  3268. this.containerWidth = fillWidth;
  3269. mainContainer.removeChild(dummyElement);
  3270. return fillWidth;
  3271. },
  3272. getWorkspaceOffset: function() {
  3273. return dom.offset(this.wot.wtTable.TABLE);
  3274. },
  3275. getWorkspaceActualHeight: function() {
  3276. return dom.outerHeight(this.wot.wtTable.TABLE);
  3277. },
  3278. getWorkspaceActualWidth: function() {
  3279. return dom.outerWidth(this.wot.wtTable.TABLE) || dom.outerWidth(this.wot.wtTable.TBODY) || dom.outerWidth(this.wot.wtTable.THEAD);
  3280. },
  3281. getColumnHeaderHeight: function() {
  3282. if (isNaN(this.columnHeaderHeight)) {
  3283. this.columnHeaderHeight = dom.outerHeight(this.wot.wtTable.THEAD);
  3284. }
  3285. return this.columnHeaderHeight;
  3286. },
  3287. getViewportHeight: function() {
  3288. var containerHeight = this.getWorkspaceHeight();
  3289. var columnHeaderHeight;
  3290. if (containerHeight === Infinity) {
  3291. return containerHeight;
  3292. }
  3293. columnHeaderHeight = this.getColumnHeaderHeight();
  3294. if (columnHeaderHeight > 0) {
  3295. containerHeight -= columnHeaderHeight;
  3296. }
  3297. return containerHeight;
  3298. },
  3299. getRowHeaderWidth: function() {
  3300. if (this.wot.cloneSource) {
  3301. return this.wot.cloneSource.wtViewport.getRowHeaderWidth();
  3302. }
  3303. if (isNaN(this.rowHeaderWidth)) {
  3304. var rowHeaders = this.instance.getSetting('rowHeaders');
  3305. if (rowHeaders.length) {
  3306. var TH = this.instance.wtTable.TABLE.querySelector('TH');
  3307. this.rowHeaderWidth = 0;
  3308. for (var i = 0,
  3309. len = rowHeaders.length; i < len; i++) {
  3310. if (TH) {
  3311. this.rowHeaderWidth += dom.outerWidth(TH);
  3312. TH = TH.nextSibling;
  3313. } else {
  3314. this.rowHeaderWidth += 50;
  3315. }
  3316. }
  3317. } else {
  3318. this.rowHeaderWidth = 0;
  3319. }
  3320. }
  3321. return this.rowHeaderWidth;
  3322. },
  3323. getViewportWidth: function() {
  3324. var containerWidth = this.getWorkspaceWidth();
  3325. var rowHeaderWidth;
  3326. if (containerWidth === Infinity) {
  3327. return containerWidth;
  3328. }
  3329. rowHeaderWidth = this.getRowHeaderWidth();
  3330. if (rowHeaderWidth > 0) {
  3331. return containerWidth - rowHeaderWidth;
  3332. }
  3333. return containerWidth;
  3334. },
  3335. createRowsCalculator: function() {
  3336. var visible = arguments[0] !== (void 0) ? arguments[0] : false;
  3337. var $__3 = this;
  3338. var height;
  3339. var pos;
  3340. var fixedRowsTop;
  3341. this.rowHeaderWidth = NaN;
  3342. if (this.wot.wtSettings.settings.renderAllRows) {
  3343. height = Infinity;
  3344. } else {
  3345. height = this.getViewportHeight();
  3346. }
  3347. pos = dom.getScrollTop(this.wot.wtOverlays.mainTableScrollableElement) - this.wot.wtOverlays.topOverlay.getTableParentOffset();
  3348. if (pos < 0) {
  3349. pos = 0;
  3350. }
  3351. fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  3352. if (fixedRowsTop) {
  3353. var fixedRowsHeight = this.wot.wtOverlays.topOverlay.sumCellSizes(0, fixedRowsTop);
  3354. pos += fixedRowsHeight;
  3355. height -= fixedRowsHeight;
  3356. }
  3357. return new WalkontableViewportRowsCalculator(height, pos, this.wot.getSetting('totalRows'), (function(sourceRow) {
  3358. return $__3.wot.wtTable.getRowHeight(sourceRow);
  3359. }), visible ? null : this.wot.wtSettings.settings.viewportRowCalculatorOverride, visible);
  3360. },
  3361. createColumnsCalculator: function() {
  3362. var visible = arguments[0] !== (void 0) ? arguments[0] : false;
  3363. var $__3 = this;
  3364. var width = this.getViewportWidth();
  3365. var pos;
  3366. var fixedColumnsLeft;
  3367. this.columnHeaderHeight = NaN;
  3368. pos = this.wot.wtOverlays.leftOverlay.getScrollPosition() - this.wot.wtOverlays.topOverlay.getTableParentOffset();
  3369. if (pos < 0) {
  3370. pos = 0;
  3371. }
  3372. fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
  3373. if (fixedColumnsLeft) {
  3374. var fixedColumnsWidth = this.wot.wtOverlays.leftOverlay.sumCellSizes(0, fixedColumnsLeft);
  3375. pos += fixedColumnsWidth;
  3376. width -= fixedColumnsWidth;
  3377. }
  3378. if (this.wot.wtTable.holder.clientWidth !== this.wot.wtTable.holder.offsetWidth) {
  3379. width -= dom.getScrollbarWidth();
  3380. }
  3381. return new WalkontableViewportColumnsCalculator(width, pos, this.wot.getSetting('totalColumns'), (function(sourceCol) {
  3382. return $__3.wot.wtTable.getColumnWidth(sourceCol);
  3383. }), visible ? null : this.wot.wtSettings.settings.viewportColumnCalculatorOverride, visible, this.wot.getSetting('stretchH'));
  3384. },
  3385. createRenderCalculators: function() {
  3386. var fastDraw = arguments[0] !== (void 0) ? arguments[0] : false;
  3387. if (fastDraw) {
  3388. var proposedRowsVisibleCalculator = this.createRowsCalculator(true);
  3389. var proposedColumnsVisibleCalculator = this.createColumnsCalculator(true);
  3390. if (!(this.areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) && this.areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator))) {
  3391. fastDraw = false;
  3392. }
  3393. }
  3394. if (!fastDraw) {
  3395. this.rowsRenderCalculator = this.createRowsCalculator();
  3396. this.columnsRenderCalculator = this.createColumnsCalculator();
  3397. }
  3398. this.rowsVisibleCalculator = null;
  3399. this.columnsVisibleCalculator = null;
  3400. return fastDraw;
  3401. },
  3402. createVisibleCalculators: function() {
  3403. this.rowsVisibleCalculator = this.createRowsCalculator(true);
  3404. this.columnsVisibleCalculator = this.createColumnsCalculator(true);
  3405. },
  3406. areAllProposedVisibleRowsAlreadyRendered: function(proposedRowsVisibleCalculator) {
  3407. if (this.rowsVisibleCalculator) {
  3408. if (proposedRowsVisibleCalculator.startRow < this.rowsRenderCalculator.startRow || (proposedRowsVisibleCalculator.startRow === this.rowsRenderCalculator.startRow && proposedRowsVisibleCalculator.startRow > 0)) {
  3409. return false;
  3410. } else if (proposedRowsVisibleCalculator.endRow > this.rowsRenderCalculator.endRow || (proposedRowsVisibleCalculator.endRow === this.rowsRenderCalculator.endRow && proposedRowsVisibleCalculator.endRow < this.wot.getSetting('totalRows') - 1)) {
  3411. return false;
  3412. } else {
  3413. return true;
  3414. }
  3415. }
  3416. return false;
  3417. },
  3418. areAllProposedVisibleColumnsAlreadyRendered: function(proposedColumnsVisibleCalculator) {
  3419. if (this.columnsVisibleCalculator) {
  3420. if (proposedColumnsVisibleCalculator.startColumn < this.columnsRenderCalculator.startColumn || (proposedColumnsVisibleCalculator.startColumn === this.columnsRenderCalculator.startColumn && proposedColumnsVisibleCalculator.startColumn > 0)) {
  3421. return false;
  3422. } else if (proposedColumnsVisibleCalculator.endColumn > this.columnsRenderCalculator.endColumn || (proposedColumnsVisibleCalculator.endColumn === this.columnsRenderCalculator.endColumn && proposedColumnsVisibleCalculator.endColumn < this.wot.getSetting('totalColumns') - 1)) {
  3423. return false;
  3424. } else {
  3425. return true;
  3426. }
  3427. }
  3428. return false;
  3429. }
  3430. }, {});
  3431. ;
  3432. window.WalkontableViewport = WalkontableViewport;
  3433. //#
  3434. },{"./../../../dom.js":27,"./../../../eventManager.js":41,"./calculator/viewportColumns.js":3,"./calculator/viewportRows.js":4}],23:[function(require,module,exports){
  3435. "use strict";
  3436. var $__shims_47_array_46_filter_46_js__,
  3437. $__shims_47_array_46_indexOf_46_js__,
  3438. $__shims_47_array_46_isArray_46_js__,
  3439. $__shims_47_classes_46_js__,
  3440. $__shims_47_object_46_keys_46_js__,
  3441. $__shims_47_string_46_trim_46_js__,
  3442. $__shims_47_weakmap_46_js__,
  3443. $__pluginHooks_46_js__,
  3444. $__core_46_js__,
  3445. $__renderers_47__95_cellDecorator_46_js__,
  3446. $__cellTypes_46_js__,
  3447. $___46__46__47_plugins_47_jqueryHandsontable_46_js__;
  3448. var version = Handsontable.version;
  3449. var buildDate = Handsontable.buildDate;
  3450. window.Handsontable = function Handsontable(rootElement, userSettings) {
  3451. var instance = new Handsontable.Core(rootElement, userSettings || {});
  3452. instance.init();
  3453. return instance;
  3454. };
  3455. Handsontable.version = version;
  3456. Handsontable.buildDate = buildDate;
  3457. ($__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__});
  3458. ($__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__});
  3459. ($__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__});
  3460. ($__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__});
  3461. ($__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__});
  3462. ($__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__});
  3463. ($__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__});
  3464. Handsontable.plugins = {};
  3465. var Hooks = ($__pluginHooks_46_js__ = require("./pluginHooks.js"), $__pluginHooks_46_js__ && $__pluginHooks_46_js__.__esModule && $__pluginHooks_46_js__ || {default: $__pluginHooks_46_js__}).Hooks;
  3466. if (!Handsontable.hooks) {
  3467. Handsontable.hooks = new Hooks();
  3468. }
  3469. ($__core_46_js__ = require("./core.js"), $__core_46_js__ && $__core_46_js__.__esModule && $__core_46_js__ || {default: $__core_46_js__});
  3470. ($__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__});
  3471. ($__cellTypes_46_js__ = require("./cellTypes.js"), $__cellTypes_46_js__ && $__cellTypes_46_js__.__esModule && $__cellTypes_46_js__ || {default: $__cellTypes_46_js__});
  3472. ($___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__});
  3473. //#
  3474. },{"./../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){
  3475. "use strict";
  3476. var $__helpers_46_js__,
  3477. $__editors_46_js__,
  3478. $__renderers_46_js__,
  3479. $__editors_47_autocompleteEditor_46_js__,
  3480. $__editors_47_checkboxEditor_46_js__,
  3481. $__editors_47_dateEditor_46_js__,
  3482. $__editors_47_dropdownEditor_46_js__,
  3483. $__editors_47_handsontableEditor_46_js__,
  3484. $__editors_47_mobileTextEditor_46_js__,
  3485. $__editors_47_numericEditor_46_js__,
  3486. $__editors_47_passwordEditor_46_js__,
  3487. $__editors_47_selectEditor_46_js__,
  3488. $__editors_47_textEditor_46_js__,
  3489. $__renderers_47_autocompleteRenderer_46_js__,
  3490. $__renderers_47_checkboxRenderer_46_js__,
  3491. $__renderers_47_htmlRenderer_46_js__,
  3492. $__renderers_47_numericRenderer_46_js__,
  3493. $__renderers_47_passwordRenderer_46_js__,
  3494. $__renderers_47_textRenderer_46_js__,
  3495. $__validators_47_autocompleteValidator_46_js__,
  3496. $__validators_47_dateValidator_46_js__,
  3497. $__validators_47_numericValidator_46_js__;
  3498. var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
  3499. var getEditorConstructor = ($__editors_46_js__ = require("./editors.js"), $__editors_46_js__ && $__editors_46_js__.__esModule && $__editors_46_js__ || {default: $__editors_46_js__}).getEditorConstructor;
  3500. var getRenderer = ($__renderers_46_js__ = require("./renderers.js"), $__renderers_46_js__ && $__renderers_46_js__.__esModule && $__renderers_46_js__ || {default: $__renderers_46_js__}).getRenderer;
  3501. 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;
  3502. 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;
  3503. 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;
  3504. 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;
  3505. 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;
  3506. 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;
  3507. 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;
  3508. 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;
  3509. 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;
  3510. 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;
  3511. 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;
  3512. 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;
  3513. 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;
  3514. 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;
  3515. 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;
  3516. 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;
  3517. 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;
  3518. 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;
  3519. 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;
  3520. Handsontable.mobileBrowser = helper.isMobileBrowser();
  3521. Handsontable.AutocompleteCell = {
  3522. editor: getEditorConstructor('autocomplete'),
  3523. renderer: getRenderer('autocomplete'),
  3524. validator: Handsontable.AutocompleteValidator
  3525. };
  3526. Handsontable.CheckboxCell = {
  3527. editor: getEditorConstructor('checkbox'),
  3528. renderer: getRenderer('checkbox')
  3529. };
  3530. Handsontable.TextCell = {
  3531. editor: Handsontable.mobileBrowser ? getEditorConstructor('mobile') : getEditorConstructor('text'),
  3532. renderer: getRenderer('text')
  3533. };
  3534. Handsontable.NumericCell = {
  3535. editor: getEditorConstructor('numeric'),
  3536. renderer: getRenderer('numeric'),
  3537. validator: Handsontable.NumericValidator,
  3538. dataType: 'number'
  3539. };
  3540. Handsontable.DateCell = {
  3541. editor: getEditorConstructor('date'),
  3542. validator: Handsontable.DateValidator,
  3543. renderer: getRenderer('autocomplete')
  3544. };
  3545. Handsontable.HandsontableCell = {
  3546. editor: getEditorConstructor('handsontable'),
  3547. renderer: getRenderer('autocomplete')
  3548. };
  3549. Handsontable.PasswordCell = {
  3550. editor: getEditorConstructor('password'),
  3551. renderer: getRenderer('password'),
  3552. copyable: false
  3553. };
  3554. Handsontable.DropdownCell = {
  3555. editor: getEditorConstructor('dropdown'),
  3556. renderer: getRenderer('autocomplete'),
  3557. validator: Handsontable.AutocompleteValidator
  3558. };
  3559. Handsontable.cellTypes = {
  3560. text: Handsontable.TextCell,
  3561. date: Handsontable.DateCell,
  3562. numeric: Handsontable.NumericCell,
  3563. checkbox: Handsontable.CheckboxCell,
  3564. autocomplete: Handsontable.AutocompleteCell,
  3565. handsontable: Handsontable.HandsontableCell,
  3566. password: Handsontable.PasswordCell,
  3567. dropdown: Handsontable.DropdownCell
  3568. };
  3569. Handsontable.cellLookup = {validator: {
  3570. numeric: Handsontable.NumericValidator,
  3571. autocomplete: Handsontable.AutocompleteValidator
  3572. }};
  3573. //#
  3574. },{"./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){
  3575. "use strict";
  3576. var $__dom_46_js__,
  3577. $__helpers_46_js__,
  3578. $__numeral__,
  3579. $__dataMap_46_js__,
  3580. $__editorManager_46_js__,
  3581. $__eventManager_46_js__,
  3582. $__plugins_46_js__,
  3583. $__renderers_46_js__,
  3584. $__tableView_46_js__,
  3585. $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
  3586. $__3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__,
  3587. $__3rdparty_47_walkontable_47_src_47_selection_46_js__;
  3588. var dom = ($__dom_46_js__ = require("./dom.js"), $__dom_46_js__ && $__dom_46_js__.__esModule && $__dom_46_js__ || {default: $__dom_46_js__});
  3589. var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
  3590. var numeral = ($__numeral__ = require("numeral"), $__numeral__ && $__numeral__.__esModule && $__numeral__ || {default: $__numeral__}).default;
  3591. var DataMap = ($__dataMap_46_js__ = require("./dataMap.js"), $__dataMap_46_js__ && $__dataMap_46_js__.__esModule && $__dataMap_46_js__ || {default: $__dataMap_46_js__}).DataMap;
  3592. var EditorManager = ($__editorManager_46_js__ = require("./editorManager.js"), $__editorManager_46_js__ && $__editorManager_46_js__.__esModule && $__editorManager_46_js__ || {default: $__editorManager_46_js__}).EditorManager;
  3593. var eventManagerObject = ($__eventManager_46_js__ = require("./eventManager.js"), $__eventManager_46_js__ && $__eventManager_46_js__.__esModule && $__eventManager_46_js__ || {default: $__eventManager_46_js__}).eventManager;
  3594. var getPlugin = ($__plugins_46_js__ = require("./plugins.js"), $__plugins_46_js__ && $__plugins_46_js__.__esModule && $__plugins_46_js__ || {default: $__plugins_46_js__}).getPlugin;
  3595. var getRenderer = ($__renderers_46_js__ = require("./renderers.js"), $__renderers_46_js__ && $__renderers_46_js__.__esModule && $__renderers_46_js__ || {default: $__renderers_46_js__}).getRenderer;
  3596. var TableView = ($__tableView_46_js__ = require("./tableView.js"), $__tableView_46_js__ && $__tableView_46_js__.__esModule && $__tableView_46_js__ || {default: $__tableView_46_js__}).TableView;
  3597. 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;
  3598. 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;
  3599. 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;
  3600. Handsontable.activeGuid = null;
  3601. Handsontable.Core = function Core(rootElement, userSettings) {
  3602. var priv,
  3603. datamap,
  3604. grid,
  3605. selection,
  3606. editorManager,
  3607. instance = this,
  3608. GridSettings = function() {},
  3609. eventManager = eventManagerObject(instance);
  3610. helper.extend(GridSettings.prototype, DefaultSettings.prototype);
  3611. helper.extend(GridSettings.prototype, userSettings);
  3612. helper.extend(GridSettings.prototype, expandType(userSettings));
  3613. this.rootElement = rootElement;
  3614. this.isHotTableEnv = dom.isChildOfWebComponentTable(this.rootElement);
  3615. Handsontable.eventManager.isHotTableEnv = this.isHotTableEnv;
  3616. this.container = document.createElement('DIV');
  3617. rootElement.insertBefore(this.container, rootElement.firstChild);
  3618. this.guid = 'ht_' + helper.randomString();
  3619. if (!this.rootElement.id || this.rootElement.id.substring(0, 3) === "ht_") {
  3620. this.rootElement.id = this.guid;
  3621. }
  3622. priv = {
  3623. cellSettings: [],
  3624. columnSettings: [],
  3625. columnsSettingConflicts: ['data', 'width'],
  3626. settings: new GridSettings(),
  3627. selRange: null,
  3628. isPopulated: null,
  3629. scrollable: null,
  3630. firstRun: true
  3631. };
  3632. grid = {
  3633. alter: function(action, index, amount, source, keepEmptyRows) {
  3634. var delta;
  3635. amount = amount || 1;
  3636. switch (action) {
  3637. case "insert_row":
  3638. if (instance.getSettings().maxRows === instance.countRows()) {
  3639. return;
  3640. }
  3641. delta = datamap.createRow(index, amount);
  3642. if (delta) {
  3643. if (selection.isSelected() && priv.selRange.from.row >= index) {
  3644. priv.selRange.from.row = priv.selRange.from.row + delta;
  3645. selection.transformEnd(delta, 0);
  3646. } else {
  3647. selection.refreshBorders();
  3648. }
  3649. }
  3650. break;
  3651. case "insert_col":
  3652. delta = datamap.createCol(index, amount);
  3653. if (delta) {
  3654. if (Array.isArray(instance.getSettings().colHeaders)) {
  3655. var spliceArray = [index, 0];
  3656. spliceArray.length += delta;
  3657. Array.prototype.splice.apply(instance.getSettings().colHeaders, spliceArray);
  3658. }
  3659. if (selection.isSelected() && priv.selRange.from.col >= index) {
  3660. priv.selRange.from.col = priv.selRange.from.col + delta;
  3661. selection.transformEnd(0, delta);
  3662. } else {
  3663. selection.refreshBorders();
  3664. }
  3665. }
  3666. break;
  3667. case "remove_row":
  3668. index = instance.runHooks('modifyCol', index);
  3669. datamap.removeRow(index, amount);
  3670. priv.cellSettings.splice(index, amount);
  3671. var fixedRowsTop = instance.getSettings().fixedRowsTop;
  3672. if (fixedRowsTop >= index + 1) {
  3673. instance.getSettings().fixedRowsTop -= Math.min(amount, fixedRowsTop - index);
  3674. }
  3675. grid.adjustRowsAndCols();
  3676. selection.refreshBorders();
  3677. break;
  3678. case "remove_col":
  3679. datamap.removeCol(index, amount);
  3680. for (var row = 0,
  3681. len = datamap.getAll().length; row < len; row++) {
  3682. if (row in priv.cellSettings) {
  3683. priv.cellSettings[row].splice(index, amount);
  3684. }
  3685. }
  3686. var fixedColumnsLeft = instance.getSettings().fixedColumnsLeft;
  3687. if (fixedColumnsLeft >= index + 1) {
  3688. instance.getSettings().fixedColumnsLeft -= Math.min(amount, fixedColumnsLeft - index);
  3689. }
  3690. if (Array.isArray(instance.getSettings().colHeaders)) {
  3691. if (typeof index == 'undefined') {
  3692. index = -1;
  3693. }
  3694. instance.getSettings().colHeaders.splice(index, amount);
  3695. }
  3696. grid.adjustRowsAndCols();
  3697. selection.refreshBorders();
  3698. break;
  3699. default:
  3700. throw new Error('There is no such action "' + action + '"');
  3701. break;
  3702. }
  3703. if (!keepEmptyRows) {
  3704. grid.adjustRowsAndCols();
  3705. }
  3706. },
  3707. adjustRowsAndCols: function() {
  3708. if (priv.settings.minRows) {
  3709. var rows = instance.countRows();
  3710. if (rows < priv.settings.minRows) {
  3711. for (var r = 0,
  3712. minRows = priv.settings.minRows; r < minRows - rows; r++) {
  3713. datamap.createRow(instance.countRows(), 1, true);
  3714. }
  3715. }
  3716. }
  3717. if (priv.settings.minSpareRows) {
  3718. var emptyRows = instance.countEmptyRows(true);
  3719. if (emptyRows < priv.settings.minSpareRows) {
  3720. for (; emptyRows < priv.settings.minSpareRows && instance.countRows() < priv.settings.maxRows; emptyRows++) {
  3721. datamap.createRow(instance.countRows(), 1, true);
  3722. }
  3723. }
  3724. }
  3725. {
  3726. var emptyCols;
  3727. if (priv.settings.minCols || priv.settings.minSpareCols) {
  3728. emptyCols = instance.countEmptyCols(true);
  3729. }
  3730. if (priv.settings.minCols && !priv.settings.columns && instance.countCols() < priv.settings.minCols) {
  3731. for (; instance.countCols() < priv.settings.minCols; emptyCols++) {
  3732. datamap.createCol(instance.countCols(), 1, true);
  3733. }
  3734. }
  3735. if (priv.settings.minSpareCols && !priv.settings.columns && instance.dataType === 'array' && emptyCols < priv.settings.minSpareCols) {
  3736. for (; emptyCols < priv.settings.minSpareCols && instance.countCols() < priv.settings.maxCols; emptyCols++) {
  3737. datamap.createCol(instance.countCols(), 1, true);
  3738. }
  3739. }
  3740. }
  3741. var rowCount = instance.countRows();
  3742. var colCount = instance.countCols();
  3743. if (rowCount === 0 || colCount === 0) {
  3744. selection.deselect();
  3745. }
  3746. if (selection.isSelected()) {
  3747. var selectionChanged = false;
  3748. var fromRow = priv.selRange.from.row;
  3749. var fromCol = priv.selRange.from.col;
  3750. var toRow = priv.selRange.to.row;
  3751. var toCol = priv.selRange.to.col;
  3752. if (fromRow > rowCount - 1) {
  3753. fromRow = rowCount - 1;
  3754. selectionChanged = true;
  3755. if (toRow > fromRow) {
  3756. toRow = fromRow;
  3757. }
  3758. } else if (toRow > rowCount - 1) {
  3759. toRow = rowCount - 1;
  3760. selectionChanged = true;
  3761. if (fromRow > toRow) {
  3762. fromRow = toRow;
  3763. }
  3764. }
  3765. if (fromCol > colCount - 1) {
  3766. fromCol = colCount - 1;
  3767. selectionChanged = true;
  3768. if (toCol > fromCol) {
  3769. toCol = fromCol;
  3770. }
  3771. } else if (toCol > colCount - 1) {
  3772. toCol = colCount - 1;
  3773. selectionChanged = true;
  3774. if (fromCol > toCol) {
  3775. fromCol = toCol;
  3776. }
  3777. }
  3778. if (selectionChanged) {
  3779. instance.selectCell(fromRow, fromCol, toRow, toCol);
  3780. }
  3781. }
  3782. if (instance.view) {
  3783. instance.view.wt.wtOverlays.adjustElementsSize();
  3784. }
  3785. },
  3786. populateFromArray: function(start, input, end, source, method, direction, deltas) {
  3787. var r,
  3788. rlen,
  3789. c,
  3790. clen,
  3791. setData = [],
  3792. current = {};
  3793. rlen = input.length;
  3794. if (rlen === 0) {
  3795. return false;
  3796. }
  3797. var repeatCol,
  3798. repeatRow,
  3799. cmax,
  3800. rmax;
  3801. switch (method) {
  3802. case 'shift_down':
  3803. repeatCol = end ? end.col - start.col + 1 : 0;
  3804. repeatRow = end ? end.row - start.row + 1 : 0;
  3805. input = helper.translateRowsToColumns(input);
  3806. for (c = 0, clen = input.length, cmax = Math.max(clen, repeatCol); c < cmax; c++) {
  3807. if (c < clen) {
  3808. for (r = 0, rlen = input[c].length; r < repeatRow - rlen; r++) {
  3809. input[c].push(input[c][r % rlen]);
  3810. }
  3811. input[c].unshift(start.col + c, start.row, 0);
  3812. instance.spliceCol.apply(instance, input[c]);
  3813. } else {
  3814. input[c % clen][0] = start.col + c;
  3815. instance.spliceCol.apply(instance, input[c % clen]);
  3816. }
  3817. }
  3818. break;
  3819. case 'shift_right':
  3820. repeatCol = end ? end.col - start.col + 1 : 0;
  3821. repeatRow = end ? end.row - start.row + 1 : 0;
  3822. for (r = 0, rlen = input.length, rmax = Math.max(rlen, repeatRow); r < rmax; r++) {
  3823. if (r < rlen) {
  3824. for (c = 0, clen = input[r].length; c < repeatCol - clen; c++) {
  3825. input[r].push(input[r][c % clen]);
  3826. }
  3827. input[r].unshift(start.row + r, start.col, 0);
  3828. instance.spliceRow.apply(instance, input[r]);
  3829. } else {
  3830. input[r % rlen][0] = start.row + r;
  3831. instance.spliceRow.apply(instance, input[r % rlen]);
  3832. }
  3833. }
  3834. break;
  3835. case 'overwrite':
  3836. default:
  3837. current.row = start.row;
  3838. current.col = start.col;
  3839. var iterators = {
  3840. row: 0,
  3841. col: 0
  3842. },
  3843. selected = {
  3844. row: (end && start) ? (end.row - start.row + 1) : 1,
  3845. col: (end && start) ? (end.col - start.col + 1) : 1
  3846. },
  3847. pushData = true;
  3848. if (['up', 'left'].indexOf(direction) !== -1) {
  3849. iterators = {
  3850. row: Math.ceil(selected.row / rlen) || 1,
  3851. col: Math.ceil(selected.col / input[0].length) || 1
  3852. };
  3853. } else if (['down', 'right'].indexOf(direction) !== -1) {
  3854. iterators = {
  3855. row: 1,
  3856. col: 1
  3857. };
  3858. }
  3859. for (r = 0; r < rlen; r++) {
  3860. if ((end && current.row > end.row) || (!priv.settings.allowInsertRow && current.row > instance.countRows() - 1) || (current.row >= priv.settings.maxRows)) {
  3861. break;
  3862. }
  3863. current.col = start.col;
  3864. clen = input[r] ? input[r].length : 0;
  3865. for (c = 0; c < clen; c++) {
  3866. if ((end && current.col > end.col) || (!priv.settings.allowInsertColumn && current.col > instance.countCols() - 1) || (current.col >= priv.settings.maxCols)) {
  3867. break;
  3868. }
  3869. if (!instance.getCellMeta(current.row, current.col).readOnly) {
  3870. var result,
  3871. value = input[r][c],
  3872. orgValue = instance.getDataAtCell(current.row, current.col),
  3873. index = {
  3874. row: r,
  3875. col: c
  3876. },
  3877. valueSchema,
  3878. orgValueSchema;
  3879. if (source === 'autofill') {
  3880. result = instance.runHooks('beforeAutofillInsidePopulate', index, direction, input, deltas, iterators, selected);
  3881. if (result) {
  3882. iterators = typeof(result.iterators) !== 'undefined' ? result.iterators : iterators;
  3883. value = typeof(result.value) !== 'undefined' ? result.value : value;
  3884. }
  3885. }
  3886. if (value !== null && typeof value === 'object') {
  3887. if (orgValue === null || typeof orgValue !== 'object') {
  3888. pushData = false;
  3889. } else {
  3890. orgValueSchema = Handsontable.helper.duckSchema(orgValue[0] || orgValue);
  3891. valueSchema = Handsontable.helper.duckSchema(value[0] || value);
  3892. if (Handsontable.helper.isObjectEquals(orgValueSchema, valueSchema)) {
  3893. value = Handsontable.helper.deepClone(value);
  3894. } else {
  3895. pushData = false;
  3896. }
  3897. }
  3898. } else if (orgValue !== null && typeof orgValue === 'object') {
  3899. pushData = false;
  3900. }
  3901. if (pushData) {
  3902. setData.push([current.row, current.col, value]);
  3903. }
  3904. pushData = true;
  3905. }
  3906. current.col++;
  3907. if (end && c === clen - 1) {
  3908. c = -1;
  3909. if (['down', 'right'].indexOf(direction) !== -1) {
  3910. iterators.col++;
  3911. } else if (['up', 'left'].indexOf(direction) !== -1) {
  3912. if (iterators.col > 1) {
  3913. iterators.col--;
  3914. }
  3915. }
  3916. }
  3917. }
  3918. current.row++;
  3919. iterators.col = 1;
  3920. if (end && r === rlen - 1) {
  3921. r = -1;
  3922. if (['down', 'right'].indexOf(direction) !== -1) {
  3923. iterators.row++;
  3924. } else if (['up', 'left'].indexOf(direction) !== -1) {
  3925. if (iterators.row > 1) {
  3926. iterators.row--;
  3927. }
  3928. }
  3929. }
  3930. }
  3931. instance.setDataAtCell(setData, null, null, source || 'populateFromArray');
  3932. break;
  3933. }
  3934. }
  3935. };
  3936. this.selection = selection = {
  3937. inProgress: false,
  3938. selectedHeader: {
  3939. cols: false,
  3940. rows: false
  3941. },
  3942. setSelectedHeaders: function(rows, cols) {
  3943. instance.selection.selectedHeader.rows = rows;
  3944. instance.selection.selectedHeader.cols = cols;
  3945. },
  3946. begin: function() {
  3947. instance.selection.inProgress = true;
  3948. },
  3949. finish: function() {
  3950. var sel = instance.getSelected();
  3951. Handsontable.hooks.run(instance, "afterSelectionEnd", sel[0], sel[1], sel[2], sel[3]);
  3952. Handsontable.hooks.run(instance, "afterSelectionEndByProp", sel[0], instance.colToProp(sel[1]), sel[2], instance.colToProp(sel[3]));
  3953. instance.selection.inProgress = false;
  3954. },
  3955. isInProgress: function() {
  3956. return instance.selection.inProgress;
  3957. },
  3958. setRangeStart: function(coords, keepEditorOpened) {
  3959. Handsontable.hooks.run(instance, "beforeSetRangeStart", coords);
  3960. priv.selRange = new WalkontableCellRange(coords, coords, coords);
  3961. selection.setRangeEnd(coords, null, keepEditorOpened);
  3962. },
  3963. setRangeEnd: function(coords, scrollToCell, keepEditorOpened) {
  3964. if (priv.selRange === null) {
  3965. return;
  3966. }
  3967. var disableVisualSelection;
  3968. Handsontable.hooks.run(instance, "beforeSetRangeEnd", coords);
  3969. instance.selection.begin();
  3970. priv.selRange.to = new WalkontableCellCoords(coords.row, coords.col);
  3971. if (!priv.settings.multiSelect) {
  3972. priv.selRange.from = coords;
  3973. }
  3974. instance.view.wt.selections.current.clear();
  3975. disableVisualSelection = instance.getCellMeta(priv.selRange.highlight.row, priv.selRange.highlight.col).disableVisualSelection;
  3976. if (typeof disableVisualSelection === 'string') {
  3977. disableVisualSelection = [disableVisualSelection];
  3978. }
  3979. if (disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('current') === -1) {
  3980. instance.view.wt.selections.current.add(priv.selRange.highlight);
  3981. }
  3982. instance.view.wt.selections.area.clear();
  3983. if ((disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('area') === -1) && selection.isMultiple()) {
  3984. instance.view.wt.selections.area.add(priv.selRange.from);
  3985. instance.view.wt.selections.area.add(priv.selRange.to);
  3986. }
  3987. if (priv.settings.currentRowClassName || priv.settings.currentColClassName) {
  3988. instance.view.wt.selections.highlight.clear();
  3989. instance.view.wt.selections.highlight.add(priv.selRange.from);
  3990. instance.view.wt.selections.highlight.add(priv.selRange.to);
  3991. }
  3992. Handsontable.hooks.run(instance, "afterSelection", priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col);
  3993. 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));
  3994. if (scrollToCell !== false && instance.view.mainViewIsActive()) {
  3995. if (priv.selRange.from && !selection.isMultiple()) {
  3996. instance.view.scrollViewport(priv.selRange.from);
  3997. } else {
  3998. instance.view.scrollViewport(coords);
  3999. }
  4000. }
  4001. selection.refreshBorders(null, keepEditorOpened);
  4002. },
  4003. refreshBorders: function(revertOriginal, keepEditor) {
  4004. if (!keepEditor) {
  4005. editorManager.destroyEditor(revertOriginal);
  4006. }
  4007. instance.view.render();
  4008. if (selection.isSelected() && !keepEditor) {
  4009. editorManager.prepareEditor();
  4010. }
  4011. },
  4012. isMultiple: function() {
  4013. var isMultiple = !(priv.selRange.to.col === priv.selRange.from.col && priv.selRange.to.row === priv.selRange.from.row),
  4014. modifier = Handsontable.hooks.run(instance, 'afterIsMultipleSelection', isMultiple);
  4015. if (isMultiple) {
  4016. return modifier;
  4017. }
  4018. },
  4019. transformStart: function(rowDelta, colDelta, force, keepEditorOpened) {
  4020. var delta = new WalkontableCellCoords(rowDelta, colDelta),
  4021. rowTransformDir = 0,
  4022. colTransformDir = 0,
  4023. totalRows,
  4024. totalCols,
  4025. coords;
  4026. instance.runHooks('modifyTransformStart', delta);
  4027. totalRows = instance.countRows();
  4028. totalCols = instance.countCols();
  4029. if (priv.selRange.highlight.row + rowDelta > totalRows - 1) {
  4030. if (force && priv.settings.minSpareRows > 0) {
  4031. instance.alter("insert_row", totalRows);
  4032. totalRows = instance.countRows();
  4033. } else if (priv.settings.autoWrapCol) {
  4034. delta.row = 1 - totalRows;
  4035. delta.col = priv.selRange.highlight.col + delta.col == totalCols - 1 ? 1 - totalCols : 1;
  4036. }
  4037. } else if (priv.settings.autoWrapCol && priv.selRange.highlight.row + delta.row < 0 && priv.selRange.highlight.col + delta.col >= 0) {
  4038. delta.row = totalRows - 1;
  4039. delta.col = priv.selRange.highlight.col + delta.col == 0 ? totalCols - 1 : -1;
  4040. }
  4041. if (priv.selRange.highlight.col + delta.col > totalCols - 1) {
  4042. if (force && priv.settings.minSpareCols > 0) {
  4043. instance.alter("insert_col", totalCols);
  4044. totalCols = instance.countCols();
  4045. } else if (priv.settings.autoWrapRow) {
  4046. delta.row = priv.selRange.highlight.row + delta.row == totalRows - 1 ? 1 - totalRows : 1;
  4047. delta.col = 1 - totalCols;
  4048. }
  4049. } else if (priv.settings.autoWrapRow && priv.selRange.highlight.col + delta.col < 0 && priv.selRange.highlight.row + delta.row >= 0) {
  4050. delta.row = priv.selRange.highlight.row + delta.row == 0 ? totalRows - 1 : -1;
  4051. delta.col = totalCols - 1;
  4052. }
  4053. coords = new WalkontableCellCoords(priv.selRange.highlight.row + delta.row, priv.selRange.highlight.col + delta.col);
  4054. if (coords.row < 0) {
  4055. rowTransformDir = -1;
  4056. coords.row = 0;
  4057. } else if (coords.row > 0 && coords.row >= totalRows) {
  4058. rowTransformDir = 1;
  4059. coords.row = totalRows - 1;
  4060. }
  4061. if (coords.col < 0) {
  4062. colTransformDir = -1;
  4063. coords.col = 0;
  4064. } else if (coords.col > 0 && coords.col >= totalCols) {
  4065. colTransformDir = 1;
  4066. coords.col = totalCols - 1;
  4067. }
  4068. instance.runHooks('afterModifyTransformStart', coords, rowTransformDir, colTransformDir);
  4069. selection.setRangeStart(coords, keepEditorOpened);
  4070. },
  4071. transformEnd: function(rowDelta, colDelta) {
  4072. var delta = new WalkontableCellCoords(rowDelta, colDelta),
  4073. rowTransformDir = 0,
  4074. colTransformDir = 0,
  4075. totalRows,
  4076. totalCols,
  4077. coords;
  4078. instance.runHooks('modifyTransformEnd', delta);
  4079. totalRows = instance.countRows();
  4080. totalCols = instance.countCols();
  4081. coords = new WalkontableCellCoords(priv.selRange.to.row + delta.row, priv.selRange.to.col + delta.col);
  4082. if (coords.row < 0) {
  4083. rowTransformDir = -1;
  4084. coords.row = 0;
  4085. } else if (coords.row > 0 && coords.row >= totalRows) {
  4086. rowTransformDir = 1;
  4087. coords.row = totalRows - 1;
  4088. }
  4089. if (coords.col < 0) {
  4090. colTransformDir = -1;
  4091. coords.col = 0;
  4092. } else if (coords.col > 0 && coords.col >= totalCols) {
  4093. colTransformDir = 1;
  4094. coords.col = totalCols - 1;
  4095. }
  4096. instance.runHooks('afterModifyTransformEnd', coords, rowTransformDir, colTransformDir);
  4097. selection.setRangeEnd(coords, true);
  4098. },
  4099. isSelected: function() {
  4100. return (priv.selRange !== null);
  4101. },
  4102. inInSelection: function(coords) {
  4103. if (!selection.isSelected()) {
  4104. return false;
  4105. }
  4106. return priv.selRange.includes(coords);
  4107. },
  4108. deselect: function() {
  4109. if (!selection.isSelected()) {
  4110. return;
  4111. }
  4112. instance.selection.inProgress = false;
  4113. priv.selRange = null;
  4114. instance.view.wt.selections.current.clear();
  4115. instance.view.wt.selections.area.clear();
  4116. if (priv.settings.currentRowClassName || priv.settings.currentColClassName) {
  4117. instance.view.wt.selections.highlight.clear();
  4118. }
  4119. editorManager.destroyEditor();
  4120. selection.refreshBorders();
  4121. Handsontable.hooks.run(instance, 'afterDeselect');
  4122. },
  4123. selectAll: function() {
  4124. if (!priv.settings.multiSelect) {
  4125. return;
  4126. }
  4127. selection.setRangeStart(new WalkontableCellCoords(0, 0));
  4128. selection.setRangeEnd(new WalkontableCellCoords(instance.countRows() - 1, instance.countCols() - 1), false);
  4129. },
  4130. empty: function() {
  4131. if (!selection.isSelected()) {
  4132. return;
  4133. }
  4134. var topLeft = priv.selRange.getTopLeftCorner();
  4135. var bottomRight = priv.selRange.getBottomRightCorner();
  4136. var r,
  4137. c,
  4138. changes = [];
  4139. for (r = topLeft.row; r <= bottomRight.row; r++) {
  4140. for (c = topLeft.col; c <= bottomRight.col; c++) {
  4141. if (!instance.getCellMeta(r, c).readOnly) {
  4142. changes.push([r, c, '']);
  4143. }
  4144. }
  4145. }
  4146. instance.setDataAtCell(changes);
  4147. }
  4148. };
  4149. this.init = function() {
  4150. Handsontable.hooks.run(instance, 'beforeInit');
  4151. if (Handsontable.mobileBrowser) {
  4152. dom.addClass(instance.rootElement, 'mobile');
  4153. }
  4154. this.updateSettings(priv.settings, true);
  4155. this.view = new TableView(this);
  4156. editorManager = new EditorManager(instance, priv, selection, datamap);
  4157. this.forceFullRender = true;
  4158. this.view.render();
  4159. if (typeof priv.firstRun === 'object') {
  4160. Handsontable.hooks.run(instance, 'afterChange', priv.firstRun[0], priv.firstRun[1]);
  4161. priv.firstRun = false;
  4162. }
  4163. Handsontable.hooks.run(instance, 'afterInit');
  4164. };
  4165. function ValidatorsQueue() {
  4166. var resolved = false;
  4167. return {
  4168. validatorsInQueue: 0,
  4169. addValidatorToQueue: function() {
  4170. this.validatorsInQueue++;
  4171. resolved = false;
  4172. },
  4173. removeValidatorFormQueue: function() {
  4174. this.validatorsInQueue = this.validatorsInQueue - 1 < 0 ? 0 : this.validatorsInQueue - 1;
  4175. this.checkIfQueueIsEmpty();
  4176. },
  4177. onQueueEmpty: function() {},
  4178. checkIfQueueIsEmpty: function() {
  4179. if (this.validatorsInQueue == 0 && resolved == false) {
  4180. resolved = true;
  4181. this.onQueueEmpty();
  4182. }
  4183. }
  4184. };
  4185. }
  4186. function validateChanges(changes, source, callback) {
  4187. var waitingForValidator = new ValidatorsQueue();
  4188. waitingForValidator.onQueueEmpty = resolve;
  4189. for (var i = changes.length - 1; i >= 0; i--) {
  4190. if (changes[i] === null) {
  4191. changes.splice(i, 1);
  4192. } else {
  4193. var row = changes[i][0];
  4194. var col = datamap.propToCol(changes[i][1]);
  4195. var logicalCol = instance.runHooks('modifyCol', col);
  4196. var cellProperties = instance.getCellMeta(row, logicalCol);
  4197. if (cellProperties.type === 'numeric' && typeof changes[i][3] === 'string') {
  4198. if (changes[i][3].length > 0 && (/^-?[\d\s]*(\.|\,)?\d*$/.test(changes[i][3]) || cellProperties.format)) {
  4199. var len = changes[i][3].length;
  4200. if (typeof cellProperties.language == 'undefined') {
  4201. numeral.language('en');
  4202. } else if (changes[i][3].indexOf(".") === len - 3 && changes[i][3].indexOf(",") === -1) {
  4203. numeral.language('en');
  4204. } else {
  4205. numeral.language(cellProperties.language);
  4206. }
  4207. if (numeral.validate(changes[i][3])) {
  4208. changes[i][3] = numeral().unformat(changes[i][3]);
  4209. }
  4210. }
  4211. }
  4212. if (instance.getCellValidator(cellProperties)) {
  4213. waitingForValidator.addValidatorToQueue();
  4214. instance.validateCell(changes[i][3], cellProperties, (function(i, cellProperties) {
  4215. return function(result) {
  4216. if (typeof result !== 'boolean') {
  4217. throw new Error("Validation error: result is not boolean");
  4218. }
  4219. if (result === false && cellProperties.allowInvalid === false) {
  4220. changes.splice(i, 1);
  4221. cellProperties.valid = true;
  4222. --i;
  4223. }
  4224. waitingForValidator.removeValidatorFormQueue();
  4225. };
  4226. })(i, cellProperties), source);
  4227. }
  4228. }
  4229. }
  4230. waitingForValidator.checkIfQueueIsEmpty();
  4231. function resolve() {
  4232. var beforeChangeResult;
  4233. if (changes.length) {
  4234. beforeChangeResult = Handsontable.hooks.run(instance, "beforeChange", changes, source);
  4235. if (typeof beforeChangeResult === 'function') {
  4236. 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).");
  4237. } else if (beforeChangeResult === false) {
  4238. changes.splice(0, changes.length);
  4239. }
  4240. }
  4241. callback();
  4242. }
  4243. }
  4244. function applyChanges(changes, source) {
  4245. var i = changes.length - 1;
  4246. if (i < 0) {
  4247. return;
  4248. }
  4249. for (; 0 <= i; i--) {
  4250. if (changes[i] === null) {
  4251. changes.splice(i, 1);
  4252. continue;
  4253. }
  4254. if (changes[i][2] == null && changes[i][3] == null) {
  4255. continue;
  4256. }
  4257. if (priv.settings.allowInsertRow) {
  4258. while (changes[i][0] > instance.countRows() - 1) {
  4259. datamap.createRow();
  4260. }
  4261. }
  4262. if (instance.dataType === 'array' && priv.settings.allowInsertColumn) {
  4263. while (datamap.propToCol(changes[i][1]) > instance.countCols() - 1) {
  4264. datamap.createCol();
  4265. }
  4266. }
  4267. datamap.set(changes[i][0], changes[i][1], changes[i][3]);
  4268. }
  4269. instance.forceFullRender = true;
  4270. grid.adjustRowsAndCols();
  4271. Handsontable.hooks.run(instance, 'beforeChangeRender', changes, source);
  4272. selection.refreshBorders(null, true);
  4273. Handsontable.hooks.run(instance, 'afterChange', changes, source || 'edit');
  4274. }
  4275. this.validateCell = function(value, cellProperties, callback, source) {
  4276. var validator = instance.getCellValidator(cellProperties);
  4277. function done(valid) {
  4278. var col = cellProperties.col,
  4279. row = cellProperties.row,
  4280. td = instance.getCell(row, col, true);
  4281. if (td) {
  4282. instance.view.wt.wtSettings.settings.cellRenderer(row, col, td);
  4283. }
  4284. callback(valid);
  4285. }
  4286. if (Object.prototype.toString.call(validator) === '[object RegExp]') {
  4287. validator = (function(validator) {
  4288. return function(value, callback) {
  4289. callback(validator.test(value));
  4290. };
  4291. })(validator);
  4292. }
  4293. if (typeof validator == 'function') {
  4294. value = Handsontable.hooks.run(instance, "beforeValidate", value, cellProperties.row, cellProperties.prop, source);
  4295. instance._registerTimeout(setTimeout(function() {
  4296. validator.call(cellProperties, value, function(valid) {
  4297. valid = Handsontable.hooks.run(instance, "afterValidate", valid, value, cellProperties.row, cellProperties.prop, source);
  4298. cellProperties.valid = valid;
  4299. done(valid);
  4300. Handsontable.hooks.run(instance, "postAfterValidate", valid, value, cellProperties.row, cellProperties.prop, source);
  4301. });
  4302. }, 0));
  4303. } else {
  4304. cellProperties.valid = true;
  4305. done(cellProperties.valid);
  4306. }
  4307. };
  4308. function setDataInputToArray(row, propOrCol, value) {
  4309. if (typeof row === "object") {
  4310. return row;
  4311. } else {
  4312. return [[row, propOrCol, value]];
  4313. }
  4314. }
  4315. this.setDataAtCell = function(row, col, value, source) {
  4316. var input = setDataInputToArray(row, col, value),
  4317. i,
  4318. ilen,
  4319. changes = [],
  4320. prop;
  4321. for (i = 0, ilen = input.length; i < ilen; i++) {
  4322. if (typeof input[i] !== 'object') {
  4323. throw new Error('Method `setDataAtCell` accepts row number or changes array of arrays as its first parameter');
  4324. }
  4325. if (typeof input[i][1] !== 'number') {
  4326. throw new Error('Method `setDataAtCell` accepts row and column number as its parameters. If you want to use object property name, use method `setDataAtRowProp`');
  4327. }
  4328. prop = datamap.colToProp(input[i][1]);
  4329. changes.push([input[i][0], prop, datamap.get(input[i][0], prop), input[i][2]]);
  4330. }
  4331. if (!source && typeof row === "object") {
  4332. source = col;
  4333. }
  4334. validateChanges(changes, source, function() {
  4335. applyChanges(changes, source);
  4336. });
  4337. };
  4338. this.setDataAtRowProp = function(row, prop, value, source) {
  4339. var input = setDataInputToArray(row, prop, value),
  4340. i,
  4341. ilen,
  4342. changes = [];
  4343. for (i = 0, ilen = input.length; i < ilen; i++) {
  4344. changes.push([input[i][0], input[i][1], datamap.get(input[i][0], input[i][1]), input[i][2]]);
  4345. }
  4346. if (!source && typeof row === "object") {
  4347. source = prop;
  4348. }
  4349. validateChanges(changes, source, function() {
  4350. applyChanges(changes, source);
  4351. });
  4352. };
  4353. this.listen = function() {
  4354. Handsontable.activeGuid = instance.guid;
  4355. if (document.activeElement && document.activeElement !== document.body) {
  4356. document.activeElement.blur();
  4357. } else if (!document.activeElement) {
  4358. document.body.focus();
  4359. }
  4360. };
  4361. this.unlisten = function() {
  4362. Handsontable.activeGuid = null;
  4363. };
  4364. this.isListening = function() {
  4365. return Handsontable.activeGuid === instance.guid;
  4366. };
  4367. this.destroyEditor = function(revertOriginal) {
  4368. selection.refreshBorders(revertOriginal);
  4369. };
  4370. this.populateFromArray = function(row, col, input, endRow, endCol, source, method, direction, deltas) {
  4371. var c;
  4372. if (!(typeof input === 'object' && typeof input[0] === 'object')) {
  4373. throw new Error("populateFromArray parameter `input` must be an array of arrays");
  4374. }
  4375. c = typeof endRow === 'number' ? new WalkontableCellCoords(endRow, endCol) : null;
  4376. return grid.populateFromArray(new WalkontableCellCoords(row, col), input, c, source, method, direction, deltas);
  4377. };
  4378. this.spliceCol = function(col, index, amount) {
  4379. return datamap.spliceCol.apply(datamap, arguments);
  4380. };
  4381. this.spliceRow = function(row, index, amount) {
  4382. return datamap.spliceRow.apply(datamap, arguments);
  4383. };
  4384. this.getSelected = function() {
  4385. if (selection.isSelected()) {
  4386. return [priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col];
  4387. }
  4388. };
  4389. this.getSelectedRange = function() {
  4390. if (selection.isSelected()) {
  4391. return priv.selRange;
  4392. }
  4393. };
  4394. this.render = function() {
  4395. if (instance.view) {
  4396. instance.forceFullRender = true;
  4397. selection.refreshBorders(null, true);
  4398. }
  4399. };
  4400. this.loadData = function(data) {
  4401. if (typeof data === 'object' && data !== null) {
  4402. if (!(data.push && data.splice)) {
  4403. data = [data];
  4404. }
  4405. } else if (data === null) {
  4406. data = [];
  4407. var row;
  4408. for (var r = 0,
  4409. rlen = priv.settings.startRows; r < rlen; r++) {
  4410. row = [];
  4411. for (var c = 0,
  4412. clen = priv.settings.startCols; c < clen; c++) {
  4413. row.push(null);
  4414. }
  4415. data.push(row);
  4416. }
  4417. } else {
  4418. throw new Error("loadData only accepts array of objects or array of arrays (" + typeof data + " given)");
  4419. }
  4420. priv.isPopulated = false;
  4421. GridSettings.prototype.data = data;
  4422. if (Array.isArray(priv.settings.dataSchema) || Array.isArray(data[0])) {
  4423. instance.dataType = 'array';
  4424. } else if (typeof priv.settings.dataSchema === 'function') {
  4425. instance.dataType = 'function';
  4426. } else {
  4427. instance.dataType = 'object';
  4428. }
  4429. datamap = new DataMap(instance, priv, GridSettings);
  4430. clearCellSettingCache();
  4431. grid.adjustRowsAndCols();
  4432. Handsontable.hooks.run(instance, 'afterLoadData');
  4433. if (priv.firstRun) {
  4434. priv.firstRun = [null, 'loadData'];
  4435. } else {
  4436. Handsontable.hooks.run(instance, 'afterChange', null, 'loadData');
  4437. instance.render();
  4438. }
  4439. priv.isPopulated = true;
  4440. function clearCellSettingCache() {
  4441. priv.cellSettings.length = 0;
  4442. }
  4443. };
  4444. this.getData = function(r, c, r2, c2) {
  4445. if (typeof r === 'undefined') {
  4446. return datamap.getAll();
  4447. } else {
  4448. return datamap.getRange(new WalkontableCellCoords(r, c), new WalkontableCellCoords(r2, c2), datamap.DESTINATION_RENDERER);
  4449. }
  4450. };
  4451. this.getCopyableData = function(startRow, startCol, endRow, endCol) {
  4452. return datamap.getCopyableText(new WalkontableCellCoords(startRow, startCol), new WalkontableCellCoords(endRow, endCol));
  4453. };
  4454. this.getSchema = function() {
  4455. return datamap.getSchema();
  4456. };
  4457. this.updateSettings = function(settings, init) {
  4458. var i,
  4459. clen;
  4460. if (typeof settings.rows !== "undefined") {
  4461. throw new Error("'rows' setting is no longer supported. do you mean startRows, minRows or maxRows?");
  4462. }
  4463. if (typeof settings.cols !== "undefined") {
  4464. throw new Error("'cols' setting is no longer supported. do you mean startCols, minCols or maxCols?");
  4465. }
  4466. for (i in settings) {
  4467. if (i === 'data') {
  4468. continue;
  4469. } else {
  4470. if (Handsontable.hooks.getRegistered().indexOf(i) > -1) {
  4471. if (typeof settings[i] === 'function' || Array.isArray(settings[i])) {
  4472. instance.addHook(i, settings[i]);
  4473. }
  4474. } else {
  4475. if (!init && settings.hasOwnProperty(i)) {
  4476. GridSettings.prototype[i] = settings[i];
  4477. }
  4478. }
  4479. }
  4480. }
  4481. if (settings.data === void 0 && priv.settings.data === void 0) {
  4482. instance.loadData(null);
  4483. } else if (settings.data !== void 0) {
  4484. instance.loadData(settings.data);
  4485. } else if (settings.columns !== void 0) {
  4486. datamap.createMap();
  4487. }
  4488. clen = instance.countCols();
  4489. priv.cellSettings.length = 0;
  4490. if (clen > 0) {
  4491. var proto,
  4492. column;
  4493. for (i = 0; i < clen; i++) {
  4494. priv.columnSettings[i] = helper.columnFactory(GridSettings, priv.columnsSettingConflicts);
  4495. proto = priv.columnSettings[i].prototype;
  4496. if (GridSettings.prototype.columns) {
  4497. column = GridSettings.prototype.columns[i];
  4498. helper.extend(proto, column);
  4499. helper.extend(proto, expandType(column));
  4500. }
  4501. }
  4502. }
  4503. if (typeof settings.cell !== 'undefined') {
  4504. for (i in settings.cell) {
  4505. if (settings.cell.hasOwnProperty(i)) {
  4506. var cell = settings.cell[i];
  4507. instance.setCellMetaObject(cell.row, cell.col, cell);
  4508. }
  4509. }
  4510. }
  4511. Handsontable.hooks.run(instance, 'afterCellMetaReset');
  4512. if (typeof settings.className !== "undefined") {
  4513. if (GridSettings.prototype.className) {
  4514. dom.removeClass(instance.rootElement, GridSettings.prototype.className);
  4515. }
  4516. if (settings.className) {
  4517. dom.addClass(instance.rootElement, settings.className);
  4518. }
  4519. }
  4520. if (typeof settings.height != 'undefined') {
  4521. var height = settings.height;
  4522. if (typeof height == 'function') {
  4523. height = height();
  4524. }
  4525. instance.rootElement.style.height = height + 'px';
  4526. }
  4527. if (typeof settings.width != 'undefined') {
  4528. var width = settings.width;
  4529. if (typeof width == 'function') {
  4530. width = width();
  4531. }
  4532. instance.rootElement.style.width = width + 'px';
  4533. }
  4534. if (height) {
  4535. instance.rootElement.style.overflow = 'hidden';
  4536. }
  4537. if (!init) {
  4538. Handsontable.hooks.run(instance, 'afterUpdateSettings');
  4539. }
  4540. grid.adjustRowsAndCols();
  4541. if (instance.view && !priv.firstRun) {
  4542. instance.forceFullRender = true;
  4543. selection.refreshBorders(null, true);
  4544. }
  4545. };
  4546. this.getValue = function() {
  4547. var sel = instance.getSelected();
  4548. if (GridSettings.prototype.getValue) {
  4549. if (typeof GridSettings.prototype.getValue === 'function') {
  4550. return GridSettings.prototype.getValue.call(instance);
  4551. } else if (sel) {
  4552. return instance.getData()[sel[0]][GridSettings.prototype.getValue];
  4553. }
  4554. } else if (sel) {
  4555. return instance.getDataAtCell(sel[0], sel[1]);
  4556. }
  4557. };
  4558. function expandType(obj) {
  4559. if (!obj.hasOwnProperty('type')) {
  4560. return;
  4561. }
  4562. var type,
  4563. expandedType = {};
  4564. if (typeof obj.type === 'object') {
  4565. type = obj.type;
  4566. } else if (typeof obj.type === 'string') {
  4567. type = Handsontable.cellTypes[obj.type];
  4568. if (type === void 0) {
  4569. 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');
  4570. }
  4571. }
  4572. for (var i in type) {
  4573. if (type.hasOwnProperty(i) && !obj.hasOwnProperty(i)) {
  4574. expandedType[i] = type[i];
  4575. }
  4576. }
  4577. return expandedType;
  4578. }
  4579. this.getSettings = function() {
  4580. return priv.settings;
  4581. };
  4582. this.clear = function() {
  4583. selection.selectAll();
  4584. selection.empty();
  4585. };
  4586. this.alter = function(action, index, amount, source, keepEmptyRows) {
  4587. grid.alter(action, index, amount, source, keepEmptyRows);
  4588. };
  4589. this.getCell = function(row, col, topmost) {
  4590. return instance.view.getCellAtCoords(new WalkontableCellCoords(row, col), topmost);
  4591. };
  4592. this.getCoords = function(elem) {
  4593. return this.view.wt.wtTable.getCoords.call(this.view.wt.wtTable, elem);
  4594. };
  4595. this.colToProp = function(col) {
  4596. return datamap.colToProp(col);
  4597. };
  4598. this.propToCol = function(prop) {
  4599. return datamap.propToCol(prop);
  4600. };
  4601. this.getDataAtCell = function(row, col) {
  4602. return datamap.get(row, datamap.colToProp(col));
  4603. };
  4604. this.getDataAtRowProp = function(row, prop) {
  4605. return datamap.get(row, prop);
  4606. };
  4607. this.getDataAtCol = function(col) {
  4608. var out = [];
  4609. return out.concat.apply(out, datamap.getRange(new WalkontableCellCoords(0, col), new WalkontableCellCoords(priv.settings.data.length - 1, col), datamap.DESTINATION_RENDERER));
  4610. };
  4611. this.getDataAtProp = function(prop) {
  4612. var out = [],
  4613. range;
  4614. range = datamap.getRange(new WalkontableCellCoords(0, datamap.propToCol(prop)), new WalkontableCellCoords(priv.settings.data.length - 1, datamap.propToCol(prop)), datamap.DESTINATION_RENDERER);
  4615. return out.concat.apply(out, range);
  4616. };
  4617. this.getSourceDataAtCol = function(col) {
  4618. var out = [],
  4619. data = priv.settings.data;
  4620. for (var i = 0; i < data.length; i++) {
  4621. out.push(data[i][col]);
  4622. }
  4623. return out;
  4624. };
  4625. this.getSourceDataAtRow = function(row) {
  4626. return priv.settings.data[row];
  4627. };
  4628. this.getDataAtRow = function(row) {
  4629. var data = datamap.getRange(new WalkontableCellCoords(row, 0), new WalkontableCellCoords(row, this.countCols() - 1), datamap.DESTINATION_RENDERER);
  4630. return data[0];
  4631. };
  4632. this.removeCellMeta = function(row, col, key) {
  4633. var cellMeta = instance.getCellMeta(row, col);
  4634. if (cellMeta[key] != undefined) {
  4635. delete priv.cellSettings[row][col][key];
  4636. }
  4637. };
  4638. this.setCellMetaObject = function(row, col, prop) {
  4639. if (typeof prop === 'object') {
  4640. for (var key in prop) {
  4641. if (prop.hasOwnProperty(key)) {
  4642. var value = prop[key];
  4643. this.setCellMeta(row, col, key, value);
  4644. }
  4645. }
  4646. }
  4647. };
  4648. this.setCellMeta = function(row, col, key, val) {
  4649. if (!priv.cellSettings[row]) {
  4650. priv.cellSettings[row] = [];
  4651. }
  4652. if (!priv.cellSettings[row][col]) {
  4653. priv.cellSettings[row][col] = new priv.columnSettings[col]();
  4654. }
  4655. priv.cellSettings[row][col][key] = val;
  4656. Handsontable.hooks.run(instance, 'afterSetCellMeta', row, col, key, val);
  4657. };
  4658. this.getCellMeta = function(row, col) {
  4659. var prop = datamap.colToProp(col),
  4660. cellProperties;
  4661. row = translateRowIndex(row);
  4662. col = translateColIndex(col);
  4663. if (!priv.columnSettings[col]) {
  4664. priv.columnSettings[col] = helper.columnFactory(GridSettings, priv.columnsSettingConflicts);
  4665. }
  4666. if (!priv.cellSettings[row]) {
  4667. priv.cellSettings[row] = [];
  4668. }
  4669. if (!priv.cellSettings[row][col]) {
  4670. priv.cellSettings[row][col] = new priv.columnSettings[col]();
  4671. }
  4672. cellProperties = priv.cellSettings[row][col];
  4673. cellProperties.row = row;
  4674. cellProperties.col = col;
  4675. cellProperties.prop = prop;
  4676. cellProperties.instance = instance;
  4677. Handsontable.hooks.run(instance, 'beforeGetCellMeta', row, col, cellProperties);
  4678. helper.extend(cellProperties, expandType(cellProperties));
  4679. if (cellProperties.cells) {
  4680. var settings = cellProperties.cells.call(cellProperties, row, col, prop);
  4681. if (settings) {
  4682. helper.extend(cellProperties, settings);
  4683. helper.extend(cellProperties, expandType(settings));
  4684. }
  4685. }
  4686. Handsontable.hooks.run(instance, 'afterGetCellMeta', row, col, cellProperties);
  4687. return cellProperties;
  4688. };
  4689. this.isColumnModificationAllowed = function() {
  4690. return !(instance.dataType === 'object' || instance.getSettings().columns);
  4691. };
  4692. function translateRowIndex(row) {
  4693. return Handsontable.hooks.run(instance, 'modifyRow', row);
  4694. }
  4695. function translateColIndex(col) {
  4696. return Handsontable.hooks.run(instance, 'modifyCol', col);
  4697. }
  4698. var rendererLookup = helper.cellMethodLookupFactory('renderer');
  4699. this.getCellRenderer = function(row, col) {
  4700. var renderer = rendererLookup.call(this, row, col);
  4701. return getRenderer(renderer);
  4702. };
  4703. this.getCellEditor = helper.cellMethodLookupFactory('editor');
  4704. this.getCellValidator = helper.cellMethodLookupFactory('validator');
  4705. this.validateCells = function(callback) {
  4706. var waitingForValidator = new ValidatorsQueue();
  4707. waitingForValidator.onQueueEmpty = callback;
  4708. var i = instance.countRows() - 1;
  4709. while (i >= 0) {
  4710. var j = instance.countCols() - 1;
  4711. while (j >= 0) {
  4712. waitingForValidator.addValidatorToQueue();
  4713. instance.validateCell(instance.getDataAtCell(i, j), instance.getCellMeta(i, j), function() {
  4714. waitingForValidator.removeValidatorFormQueue();
  4715. }, 'validateCells');
  4716. j--;
  4717. }
  4718. i--;
  4719. }
  4720. waitingForValidator.checkIfQueueIsEmpty();
  4721. };
  4722. this.getRowHeader = function(row) {
  4723. if (row === void 0) {
  4724. var out = [];
  4725. for (var i = 0,
  4726. ilen = instance.countRows(); i < ilen; i++) {
  4727. out.push(instance.getRowHeader(i));
  4728. }
  4729. return out;
  4730. } else if (Array.isArray(priv.settings.rowHeaders) && priv.settings.rowHeaders[row] !== void 0) {
  4731. return priv.settings.rowHeaders[row];
  4732. } else if (typeof priv.settings.rowHeaders === 'function') {
  4733. return priv.settings.rowHeaders(row);
  4734. } else if (priv.settings.rowHeaders && typeof priv.settings.rowHeaders !== 'string' && typeof priv.settings.rowHeaders !== 'number') {
  4735. return row + 1;
  4736. } else {
  4737. return priv.settings.rowHeaders;
  4738. }
  4739. };
  4740. this.hasRowHeaders = function() {
  4741. return !!priv.settings.rowHeaders;
  4742. };
  4743. this.hasColHeaders = function() {
  4744. if (priv.settings.colHeaders !== void 0 && priv.settings.colHeaders !== null) {
  4745. return !!priv.settings.colHeaders;
  4746. }
  4747. for (var i = 0,
  4748. ilen = instance.countCols(); i < ilen; i++) {
  4749. if (instance.getColHeader(i)) {
  4750. return true;
  4751. }
  4752. }
  4753. return false;
  4754. };
  4755. this.getColHeader = function(col) {
  4756. if (col === void 0) {
  4757. var out = [];
  4758. for (var i = 0,
  4759. ilen = instance.countCols(); i < ilen; i++) {
  4760. out.push(instance.getColHeader(i));
  4761. }
  4762. return out;
  4763. } else {
  4764. var baseCol = col;
  4765. col = Handsontable.hooks.run(instance, 'modifyCol', col);
  4766. if (priv.settings.columns && priv.settings.columns[col] && priv.settings.columns[col].title) {
  4767. return priv.settings.columns[col].title;
  4768. } else if (Array.isArray(priv.settings.colHeaders) && priv.settings.colHeaders[col] !== void 0) {
  4769. return priv.settings.colHeaders[col];
  4770. } else if (typeof priv.settings.colHeaders === 'function') {
  4771. return priv.settings.colHeaders(col);
  4772. } else if (priv.settings.colHeaders && typeof priv.settings.colHeaders !== 'string' && typeof priv.settings.colHeaders !== 'number') {
  4773. return helper.spreadsheetColumnLabel(baseCol);
  4774. } else {
  4775. return priv.settings.colHeaders;
  4776. }
  4777. }
  4778. };
  4779. this._getColWidthFromSettings = function(col) {
  4780. var cellProperties = instance.getCellMeta(0, col);
  4781. var width = cellProperties.width;
  4782. if (width === void 0 || width === priv.settings.width) {
  4783. width = cellProperties.colWidths;
  4784. }
  4785. if (width !== void 0 && width !== null) {
  4786. switch (typeof width) {
  4787. case 'object':
  4788. width = width[col];
  4789. break;
  4790. case 'function':
  4791. width = width(col);
  4792. break;
  4793. }
  4794. if (typeof width === 'string') {
  4795. width = parseInt(width, 10);
  4796. }
  4797. }
  4798. return width;
  4799. };
  4800. this.getColWidth = function(col) {
  4801. var width = instance._getColWidthFromSettings(col);
  4802. if (!width) {
  4803. width = 50;
  4804. }
  4805. width = Handsontable.hooks.run(instance, 'modifyColWidth', width, col);
  4806. return width;
  4807. };
  4808. this._getRowHeightFromSettings = function(row) {
  4809. var height = priv.settings.rowHeights;
  4810. if (height !== void 0 && height !== null) {
  4811. switch (typeof height) {
  4812. case 'object':
  4813. height = height[row];
  4814. break;
  4815. case 'function':
  4816. height = height(row);
  4817. break;
  4818. }
  4819. if (typeof height === 'string') {
  4820. height = parseInt(height, 10);
  4821. }
  4822. }
  4823. return height;
  4824. };
  4825. this.getRowHeight = function(row) {
  4826. var height = instance._getRowHeightFromSettings(row);
  4827. height = Handsontable.hooks.run(instance, 'modifyRowHeight', height, row);
  4828. return height;
  4829. };
  4830. this.countRows = function() {
  4831. return priv.settings.data.length;
  4832. };
  4833. this.countCols = function() {
  4834. if (instance.dataType === 'object' || instance.dataType === 'function') {
  4835. if (priv.settings.columns && priv.settings.columns.length) {
  4836. return priv.settings.columns.length;
  4837. } else {
  4838. return datamap.colToPropCache.length;
  4839. }
  4840. } else if (instance.dataType === 'array') {
  4841. if (priv.settings.columns && priv.settings.columns.length) {
  4842. return priv.settings.columns.length;
  4843. } else if (priv.settings.data && priv.settings.data[0] && priv.settings.data[0].length) {
  4844. return priv.settings.data[0].length;
  4845. } else {
  4846. return 0;
  4847. }
  4848. }
  4849. };
  4850. this.rowOffset = function() {
  4851. return instance.view.wt.wtTable.getFirstRenderedRow();
  4852. };
  4853. this.colOffset = function() {
  4854. return instance.view.wt.wtTable.getFirstRenderedColumn();
  4855. };
  4856. this.countRenderedRows = function() {
  4857. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedRowsCount() : -1;
  4858. };
  4859. this.countVisibleRows = function() {
  4860. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleRowsCount() : -1;
  4861. };
  4862. this.countRenderedCols = function() {
  4863. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedColumnsCount() : -1;
  4864. };
  4865. this.countVisibleCols = function() {
  4866. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleColumnsCount() : -1;
  4867. };
  4868. this.countEmptyRows = function(ending) {
  4869. var i = instance.countRows() - 1,
  4870. empty = 0,
  4871. row;
  4872. while (i >= 0) {
  4873. row = Handsontable.hooks.run(this, 'modifyRow', i);
  4874. if (instance.isEmptyRow(row)) {
  4875. empty++;
  4876. } else if (ending) {
  4877. break;
  4878. }
  4879. i--;
  4880. }
  4881. return empty;
  4882. };
  4883. this.countEmptyCols = function(ending) {
  4884. if (instance.countRows() < 1) {
  4885. return 0;
  4886. }
  4887. var i = instance.countCols() - 1,
  4888. empty = 0;
  4889. while (i >= 0) {
  4890. if (instance.isEmptyCol(i)) {
  4891. empty++;
  4892. } else if (ending) {
  4893. break;
  4894. }
  4895. i--;
  4896. }
  4897. return empty;
  4898. };
  4899. this.isEmptyRow = function(row) {
  4900. return priv.settings.isEmptyRow.call(instance, row);
  4901. };
  4902. this.isEmptyCol = function(col) {
  4903. return priv.settings.isEmptyCol.call(instance, col);
  4904. };
  4905. this.selectCell = function(row, col, endRow, endCol, scrollToCell, changeListener) {
  4906. var coords;
  4907. changeListener = typeof changeListener === 'undefined' || changeListener === true;
  4908. if (typeof row !== 'number' || row < 0 || row >= instance.countRows()) {
  4909. return false;
  4910. }
  4911. if (typeof col !== 'number' || col < 0 || col >= instance.countCols()) {
  4912. return false;
  4913. }
  4914. if (typeof endRow !== 'undefined') {
  4915. if (typeof endRow !== 'number' || endRow < 0 || endRow >= instance.countRows()) {
  4916. return false;
  4917. }
  4918. if (typeof endCol !== 'number' || endCol < 0 || endCol >= instance.countCols()) {
  4919. return false;
  4920. }
  4921. }
  4922. coords = new WalkontableCellCoords(row, col);
  4923. priv.selRange = new WalkontableCellRange(coords, coords, coords);
  4924. if (document.activeElement && document.activeElement !== document.documentElement && document.activeElement !== document.body) {
  4925. document.activeElement.blur();
  4926. }
  4927. if (changeListener) {
  4928. instance.listen();
  4929. }
  4930. if (typeof endRow === 'undefined') {
  4931. selection.setRangeEnd(priv.selRange.from, scrollToCell);
  4932. } else {
  4933. selection.setRangeEnd(new WalkontableCellCoords(endRow, endCol), scrollToCell);
  4934. }
  4935. instance.selection.finish();
  4936. return true;
  4937. };
  4938. this.selectCellByProp = function(row, prop, endRow, endProp, scrollToCell) {
  4939. arguments[1] = datamap.propToCol(arguments[1]);
  4940. if (typeof arguments[3] !== "undefined") {
  4941. arguments[3] = datamap.propToCol(arguments[3]);
  4942. }
  4943. return instance.selectCell.apply(instance, arguments);
  4944. };
  4945. this.deselectCell = function() {
  4946. selection.deselect();
  4947. };
  4948. this.destroy = function() {
  4949. instance._clearTimeouts();
  4950. if (instance.view) {
  4951. instance.view.destroy();
  4952. }
  4953. dom.empty(instance.rootElement);
  4954. eventManager.clear();
  4955. Handsontable.hooks.run(instance, 'afterDestroy');
  4956. Handsontable.hooks.destroy(instance);
  4957. for (var i in instance) {
  4958. if (instance.hasOwnProperty(i)) {
  4959. if (typeof instance[i] === "function") {
  4960. if (i !== "runHooks") {
  4961. instance[i] = postMortem;
  4962. }
  4963. } else if (i !== "guid") {
  4964. instance[i] = null;
  4965. }
  4966. }
  4967. }
  4968. priv = null;
  4969. datamap = null;
  4970. grid = null;
  4971. selection = null;
  4972. editorManager = null;
  4973. instance = null;
  4974. GridSettings = null;
  4975. };
  4976. function postMortem() {
  4977. throw new Error("This method cannot be called because this Handsontable instance has been destroyed");
  4978. }
  4979. this.getActiveEditor = function() {
  4980. return editorManager.getActiveEditor();
  4981. };
  4982. this.getPlugin = function(pluginName) {
  4983. return getPlugin(this, pluginName);
  4984. };
  4985. this.getInstance = function() {
  4986. return instance;
  4987. };
  4988. this.addHook = function(key, callback) {
  4989. Handsontable.hooks.add(key, callback, instance);
  4990. };
  4991. this.addHookOnce = function(key, callback) {
  4992. Handsontable.hooks.once(key, callback, instance);
  4993. };
  4994. this.removeHook = function(key, callback) {
  4995. Handsontable.hooks.remove(key, callback, instance);
  4996. };
  4997. this.runHooks = function(key, p1, p2, p3, p4, p5, p6) {
  4998. return Handsontable.hooks.run(instance, key, p1, p2, p3, p4, p5, p6);
  4999. };
  5000. this.timeouts = [];
  5001. this._registerTimeout = function(handle) {
  5002. this.timeouts.push(handle);
  5003. };
  5004. this._clearTimeouts = function() {
  5005. for (var i = 0,
  5006. ilen = this.timeouts.length; i < ilen; i++) {
  5007. clearTimeout(this.timeouts[i]);
  5008. }
  5009. };
  5010. this.version = Handsontable.version;
  5011. };
  5012. var DefaultSettings = function() {};
  5013. DefaultSettings.prototype = {
  5014. data: void 0,
  5015. dataSchema: void 0,
  5016. width: void 0,
  5017. height: void 0,
  5018. startRows: 5,
  5019. startCols: 5,
  5020. rowHeaders: null,
  5021. colHeaders: null,
  5022. colWidths: void 0,
  5023. columns: void 0,
  5024. cells: void 0,
  5025. cell: [],
  5026. comments: false,
  5027. customBorders: false,
  5028. minRows: 0,
  5029. minCols: 0,
  5030. maxRows: Infinity,
  5031. maxCols: Infinity,
  5032. minSpareRows: 0,
  5033. minSpareCols: 0,
  5034. allowInsertRow: true,
  5035. allowInsertColumn: true,
  5036. allowRemoveRow: true,
  5037. allowRemoveColumn: true,
  5038. multiSelect: true,
  5039. fillHandle: true,
  5040. fixedRowsTop: 0,
  5041. fixedColumnsLeft: 0,
  5042. outsideClickDeselects: true,
  5043. enterBeginsEditing: true,
  5044. enterMoves: {
  5045. row: 1,
  5046. col: 0
  5047. },
  5048. tabMoves: {
  5049. row: 0,
  5050. col: 1
  5051. },
  5052. autoWrapRow: false,
  5053. autoWrapCol: false,
  5054. copyRowsLimit: 1000,
  5055. copyColsLimit: 1000,
  5056. pasteMode: 'overwrite',
  5057. persistentState: false,
  5058. currentRowClassName: void 0,
  5059. currentColClassName: void 0,
  5060. stretchH: 'none',
  5061. isEmptyRow: function(row) {
  5062. var col,
  5063. colLen,
  5064. value,
  5065. meta;
  5066. for (col = 0, colLen = this.countCols(); col < colLen; col++) {
  5067. value = this.getDataAtCell(row, col);
  5068. if (value !== '' && value !== null && typeof value !== 'undefined') {
  5069. if (typeof value === 'object') {
  5070. meta = this.getCellMeta(row, col);
  5071. return helper.isObjectEquals(this.getSchema()[meta.prop], value);
  5072. }
  5073. return false;
  5074. }
  5075. }
  5076. return true;
  5077. },
  5078. isEmptyCol: function(col) {
  5079. var row,
  5080. rowLen,
  5081. value;
  5082. for (row = 0, rowLen = this.countRows(); row < rowLen; row++) {
  5083. value = this.getDataAtCell(row, col);
  5084. if (value !== '' && value !== null && typeof value !== 'undefined') {
  5085. return false;
  5086. }
  5087. }
  5088. return true;
  5089. },
  5090. observeDOMVisibility: true,
  5091. allowInvalid: true,
  5092. invalidCellClassName: 'htInvalid',
  5093. placeholder: false,
  5094. placeholderCellClassName: 'htPlaceholder',
  5095. readOnlyCellClassName: 'htDimmed',
  5096. renderer: void 0,
  5097. commentedCellClassName: 'htCommentCell',
  5098. fragmentSelection: false,
  5099. readOnly: false,
  5100. search: false,
  5101. type: 'text',
  5102. copyable: true,
  5103. editor: void 0,
  5104. autoComplete: void 0,
  5105. debug: false,
  5106. wordWrap: true,
  5107. noWordWrapClassName: 'htNoWrap',
  5108. contextMenu: void 0,
  5109. undo: void 0,
  5110. columnSorting: void 0,
  5111. manualColumnMove: void 0,
  5112. manualColumnResize: void 0,
  5113. manualRowMove: void 0,
  5114. manualRowResize: void 0,
  5115. mergeCells: false,
  5116. viewportRowRenderingOffset: 10,
  5117. viewportColumnRenderingOffset: 10,
  5118. groups: void 0,
  5119. validator: void 0,
  5120. disableVisualSelection: false,
  5121. sortIndicator: false,
  5122. manualColumnFreeze: void 0,
  5123. trimWhitespace: true,
  5124. settings: void 0,
  5125. source: void 0,
  5126. title: void 0,
  5127. checkedTemplate: void 0,
  5128. uncheckedTemplate: void 0,
  5129. format: void 0,
  5130. className: void 0
  5131. };
  5132. Handsontable.DefaultSettings = DefaultSettings;
  5133. //#
  5134. },{"./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){
  5135. "use strict";
  5136. Object.defineProperties(exports, {
  5137. DataMap: {get: function() {
  5138. return DataMap;
  5139. }},
  5140. __esModule: {value: true}
  5141. });
  5142. var $__helpers_46_js__,
  5143. $__multiMap_46_js__,
  5144. $__SheetClip__;
  5145. var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
  5146. var MultiMap = ($__multiMap_46_js__ = require("./multiMap.js"), $__multiMap_46_js__ && $__multiMap_46_js__.__esModule && $__multiMap_46_js__ || {default: $__multiMap_46_js__}).MultiMap;
  5147. var SheetClip = ($__SheetClip__ = require("SheetClip"), $__SheetClip__ && $__SheetClip__.__esModule && $__SheetClip__ || {default: $__SheetClip__}).default;
  5148. ;
  5149. Handsontable.DataMap = DataMap;
  5150. function DataMap(instance, priv, GridSettings) {
  5151. this.instance = instance;
  5152. this.priv = priv;
  5153. this.GridSettings = GridSettings;
  5154. this.dataSource = this.instance.getSettings().data;
  5155. if (this.dataSource[0]) {
  5156. this.duckSchema = this.recursiveDuckSchema(this.dataSource[0]);
  5157. } else {
  5158. this.duckSchema = {};
  5159. }
  5160. this.createMap();
  5161. }
  5162. DataMap.prototype.DESTINATION_RENDERER = 1;
  5163. DataMap.prototype.DESTINATION_CLIPBOARD_GENERATOR = 2;
  5164. DataMap.prototype.recursiveDuckSchema = function(object) {
  5165. return Handsontable.helper.duckSchema(object);
  5166. };
  5167. DataMap.prototype.recursiveDuckColumns = function(schema, lastCol, parent) {
  5168. var prop,
  5169. i;
  5170. if (typeof lastCol === 'undefined') {
  5171. lastCol = 0;
  5172. parent = '';
  5173. }
  5174. if (typeof schema === "object" && !Array.isArray(schema)) {
  5175. for (i in schema) {
  5176. if (schema.hasOwnProperty(i)) {
  5177. if (schema[i] === null) {
  5178. prop = parent + i;
  5179. this.colToPropCache.push(prop);
  5180. this.propToColCache.set(prop, lastCol);
  5181. lastCol++;
  5182. } else {
  5183. lastCol = this.recursiveDuckColumns(schema[i], lastCol, i + '.');
  5184. }
  5185. }
  5186. }
  5187. }
  5188. return lastCol;
  5189. };
  5190. DataMap.prototype.createMap = function() {
  5191. var i,
  5192. ilen,
  5193. schema = this.getSchema();
  5194. if (typeof schema === "undefined") {
  5195. throw new Error("trying to create `columns` definition but you didnt' provide `schema` nor `data`");
  5196. }
  5197. this.colToPropCache = [];
  5198. this.propToColCache = new MultiMap();
  5199. var columns = this.instance.getSettings().columns;
  5200. if (columns) {
  5201. for (i = 0, ilen = columns.length; i < ilen; i++) {
  5202. if (typeof columns[i].data != 'undefined') {
  5203. this.colToPropCache[i] = columns[i].data;
  5204. this.propToColCache.set(columns[i].data, i);
  5205. }
  5206. }
  5207. } else {
  5208. this.recursiveDuckColumns(schema);
  5209. }
  5210. };
  5211. DataMap.prototype.colToProp = function(col) {
  5212. col = Handsontable.hooks.run(this.instance, 'modifyCol', col);
  5213. if (this.colToPropCache && typeof this.colToPropCache[col] !== 'undefined') {
  5214. return this.colToPropCache[col];
  5215. }
  5216. return col;
  5217. };
  5218. DataMap.prototype.propToCol = function(prop) {
  5219. var col;
  5220. if (typeof this.propToColCache.get(prop) !== 'undefined') {
  5221. col = this.propToColCache.get(prop);
  5222. } else {
  5223. col = prop;
  5224. }
  5225. col = Handsontable.hooks.run(this.instance, 'modifyCol', col);
  5226. return col;
  5227. };
  5228. DataMap.prototype.getSchema = function() {
  5229. var schema = this.instance.getSettings().dataSchema;
  5230. if (schema) {
  5231. if (typeof schema === 'function') {
  5232. return schema();
  5233. }
  5234. return schema;
  5235. }
  5236. return this.duckSchema;
  5237. };
  5238. DataMap.prototype.createRow = function(index, amount, createdAutomatically) {
  5239. var row,
  5240. colCount = this.instance.countCols(),
  5241. numberOfCreatedRows = 0,
  5242. currentIndex;
  5243. if (!amount) {
  5244. amount = 1;
  5245. }
  5246. if (typeof index !== 'number' || index >= this.instance.countRows()) {
  5247. index = this.instance.countRows();
  5248. }
  5249. currentIndex = index;
  5250. var maxRows = this.instance.getSettings().maxRows;
  5251. while (numberOfCreatedRows < amount && this.instance.countRows() < maxRows) {
  5252. if (this.instance.dataType === 'array') {
  5253. row = [];
  5254. for (var c = 0; c < colCount; c++) {
  5255. row.push(null);
  5256. }
  5257. } else if (this.instance.dataType === 'function') {
  5258. row = this.instance.getSettings().dataSchema(index);
  5259. } else {
  5260. row = {};
  5261. helper.deepExtend(row, this.getSchema());
  5262. }
  5263. if (index === this.instance.countRows()) {
  5264. this.dataSource.push(row);
  5265. } else {
  5266. this.dataSource.splice(index, 0, row);
  5267. }
  5268. numberOfCreatedRows++;
  5269. currentIndex++;
  5270. }
  5271. Handsontable.hooks.run(this.instance, 'afterCreateRow', index, numberOfCreatedRows, createdAutomatically);
  5272. this.instance.forceFullRender = true;
  5273. return numberOfCreatedRows;
  5274. };
  5275. DataMap.prototype.createCol = function(index, amount, createdAutomatically) {
  5276. if (!this.instance.isColumnModificationAllowed()) {
  5277. 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.");
  5278. }
  5279. var rlen = this.instance.countRows(),
  5280. data = this.dataSource,
  5281. constructor,
  5282. numberOfCreatedCols = 0,
  5283. currentIndex;
  5284. if (!amount) {
  5285. amount = 1;
  5286. }
  5287. currentIndex = index;
  5288. var maxCols = this.instance.getSettings().maxCols;
  5289. while (numberOfCreatedCols < amount && this.instance.countCols() < maxCols) {
  5290. constructor = helper.columnFactory(this.GridSettings, this.priv.columnsSettingConflicts);
  5291. if (typeof index !== 'number' || index >= this.instance.countCols()) {
  5292. for (var r = 0; r < rlen; r++) {
  5293. if (typeof data[r] === 'undefined') {
  5294. data[r] = [];
  5295. }
  5296. data[r].push(null);
  5297. }
  5298. this.priv.columnSettings.push(constructor);
  5299. } else {
  5300. for (var r = 0; r < rlen; r++) {
  5301. data[r].splice(currentIndex, 0, null);
  5302. }
  5303. this.priv.columnSettings.splice(currentIndex, 0, constructor);
  5304. }
  5305. numberOfCreatedCols++;
  5306. currentIndex++;
  5307. }
  5308. Handsontable.hooks.run(this.instance, 'afterCreateCol', index, numberOfCreatedCols, createdAutomatically);
  5309. this.instance.forceFullRender = true;
  5310. return numberOfCreatedCols;
  5311. };
  5312. DataMap.prototype.removeRow = function(index, amount) {
  5313. if (!amount) {
  5314. amount = 1;
  5315. }
  5316. if (typeof index !== 'number') {
  5317. index = -amount;
  5318. }
  5319. index = (this.instance.countRows() + index) % this.instance.countRows();
  5320. var logicRows = this.physicalRowsToLogical(index, amount);
  5321. var actionWasNotCancelled = Handsontable.hooks.run(this.instance, 'beforeRemoveRow', index, amount);
  5322. if (actionWasNotCancelled === false) {
  5323. return;
  5324. }
  5325. var data = this.dataSource;
  5326. var newData = data.filter(function(row, index) {
  5327. return logicRows.indexOf(index) == -1;
  5328. });
  5329. data.length = 0;
  5330. Array.prototype.push.apply(data, newData);
  5331. Handsontable.hooks.run(this.instance, 'afterRemoveRow', index, amount);
  5332. this.instance.forceFullRender = true;
  5333. };
  5334. DataMap.prototype.removeCol = function(index, amount) {
  5335. if (this.instance.dataType === 'object' || this.instance.getSettings().columns) {
  5336. throw new Error("cannot remove column with object data source or columns option specified");
  5337. }
  5338. if (!amount) {
  5339. amount = 1;
  5340. }
  5341. if (typeof index !== 'number') {
  5342. index = -amount;
  5343. }
  5344. index = (this.instance.countCols() + index) % this.instance.countCols();
  5345. var actionWasNotCancelled = Handsontable.hooks.run(this.instance, 'beforeRemoveCol', index, amount);
  5346. if (actionWasNotCancelled === false) {
  5347. return;
  5348. }
  5349. var data = this.dataSource;
  5350. for (var r = 0,
  5351. rlen = this.instance.countRows(); r < rlen; r++) {
  5352. data[r].splice(index, amount);
  5353. }
  5354. this.priv.columnSettings.splice(index, amount);
  5355. Handsontable.hooks.run(this.instance, 'afterRemoveCol', index, amount);
  5356. this.instance.forceFullRender = true;
  5357. };
  5358. DataMap.prototype.spliceCol = function(col, index, amount) {
  5359. var elements = 4 <= arguments.length ? [].slice.call(arguments, 3) : [];
  5360. var colData = this.instance.getDataAtCol(col);
  5361. var removed = colData.slice(index, index + amount);
  5362. var after = colData.slice(index + amount);
  5363. helper.extendArray(elements, after);
  5364. var i = 0;
  5365. while (i < amount) {
  5366. elements.push(null);
  5367. i++;
  5368. }
  5369. helper.to2dArray(elements);
  5370. this.instance.populateFromArray(index, col, elements, null, null, 'spliceCol');
  5371. return removed;
  5372. };
  5373. DataMap.prototype.spliceRow = function(row, index, amount) {
  5374. var elements = 4 <= arguments.length ? [].slice.call(arguments, 3) : [];
  5375. var rowData = this.instance.getSourceDataAtRow(row);
  5376. var removed = rowData.slice(index, index + amount);
  5377. var after = rowData.slice(index + amount);
  5378. helper.extendArray(elements, after);
  5379. var i = 0;
  5380. while (i < amount) {
  5381. elements.push(null);
  5382. i++;
  5383. }
  5384. this.instance.populateFromArray(row, index, [elements], null, null, 'spliceRow');
  5385. return removed;
  5386. };
  5387. DataMap.prototype.get = function(row, prop) {
  5388. row = Handsontable.hooks.run(this.instance, 'modifyRow', row);
  5389. if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  5390. var sliced = prop.split(".");
  5391. var out = this.dataSource[row];
  5392. if (!out) {
  5393. return null;
  5394. }
  5395. for (var i = 0,
  5396. ilen = sliced.length; i < ilen; i++) {
  5397. out = out[sliced[i]];
  5398. if (typeof out === 'undefined') {
  5399. return null;
  5400. }
  5401. }
  5402. return out;
  5403. } else if (typeof prop === 'function') {
  5404. return prop(this.dataSource.slice(row, row + 1)[0]);
  5405. } else {
  5406. return this.dataSource[row] ? this.dataSource[row][prop] : null;
  5407. }
  5408. };
  5409. var copyableLookup = helper.cellMethodLookupFactory('copyable', false);
  5410. DataMap.prototype.getCopyable = function(row, prop) {
  5411. if (copyableLookup.call(this.instance, row, this.propToCol(prop))) {
  5412. return this.get(row, prop);
  5413. }
  5414. return '';
  5415. };
  5416. DataMap.prototype.set = function(row, prop, value, source) {
  5417. row = Handsontable.hooks.run(this.instance, 'modifyRow', row, source || "datamapGet");
  5418. if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  5419. var sliced = prop.split(".");
  5420. var out = this.dataSource[row];
  5421. for (var i = 0,
  5422. ilen = sliced.length - 1; i < ilen; i++) {
  5423. if (typeof out[sliced[i]] === 'undefined') {
  5424. out[sliced[i]] = {};
  5425. }
  5426. out = out[sliced[i]];
  5427. }
  5428. out[sliced[i]] = value;
  5429. } else if (typeof prop === 'function') {
  5430. prop(this.dataSource.slice(row, row + 1)[0], value);
  5431. } else {
  5432. this.dataSource[row][prop] = value;
  5433. }
  5434. };
  5435. DataMap.prototype.physicalRowsToLogical = function(index, amount) {
  5436. var totalRows = this.instance.countRows();
  5437. var physicRow = (totalRows + index) % totalRows;
  5438. var logicRows = [];
  5439. var rowsToRemove = amount;
  5440. var row;
  5441. while (physicRow < totalRows && rowsToRemove) {
  5442. row = Handsontable.hooks.run(this.instance, 'modifyRow', physicRow);
  5443. logicRows.push(row);
  5444. rowsToRemove--;
  5445. physicRow++;
  5446. }
  5447. return logicRows;
  5448. };
  5449. DataMap.prototype.clear = function() {
  5450. for (var r = 0; r < this.instance.countRows(); r++) {
  5451. for (var c = 0; c < this.instance.countCols(); c++) {
  5452. this.set(r, this.colToProp(c), '');
  5453. }
  5454. }
  5455. };
  5456. DataMap.prototype.getAll = function() {
  5457. return this.dataSource;
  5458. };
  5459. DataMap.prototype.getRange = function(start, end, destination) {
  5460. var r,
  5461. rlen,
  5462. c,
  5463. clen,
  5464. output = [],
  5465. row;
  5466. var getFn = destination === this.DESTINATION_CLIPBOARD_GENERATOR ? this.getCopyable : this.get;
  5467. rlen = Math.max(start.row, end.row);
  5468. clen = Math.max(start.col, end.col);
  5469. for (r = Math.min(start.row, end.row); r <= rlen; r++) {
  5470. row = [];
  5471. for (c = Math.min(start.col, end.col); c <= clen; c++) {
  5472. row.push(getFn.call(this, r, this.colToProp(c)));
  5473. }
  5474. output.push(row);
  5475. }
  5476. return output;
  5477. };
  5478. DataMap.prototype.getText = function(start, end) {
  5479. return SheetClip.stringify(this.getRange(start, end, this.DESTINATION_RENDERER));
  5480. };
  5481. DataMap.prototype.getCopyableText = function(start, end) {
  5482. return SheetClip.stringify(this.getRange(start, end, this.DESTINATION_CLIPBOARD_GENERATOR));
  5483. };
  5484. //#
  5485. },{"./helpers.js":42,"./multiMap.js":43,"SheetClip":"SheetClip"}],27:[function(require,module,exports){
  5486. "use strict";
  5487. Object.defineProperties(exports, {
  5488. enableImmediatePropagation: {get: function() {
  5489. return enableImmediatePropagation;
  5490. }},
  5491. closest: {get: function() {
  5492. return closest;
  5493. }},
  5494. isChildOf: {get: function() {
  5495. return isChildOf;
  5496. }},
  5497. isChildOfWebComponentTable: {get: function() {
  5498. return isChildOfWebComponentTable;
  5499. }},
  5500. polymerWrap: {get: function() {
  5501. return polymerWrap;
  5502. }},
  5503. polymerUnwrap: {get: function() {
  5504. return polymerUnwrap;
  5505. }},
  5506. isWebComponentSupportedNatively: {get: function() {
  5507. return isWebComponentSupportedNatively;
  5508. }},
  5509. index: {get: function() {
  5510. return index;
  5511. }},
  5512. hasClass: {get: function() {
  5513. return hasClass;
  5514. }},
  5515. addClass: {get: function() {
  5516. return addClass;
  5517. }},
  5518. removeClass: {get: function() {
  5519. return removeClass;
  5520. }},
  5521. removeTextNodes: {get: function() {
  5522. return removeTextNodes;
  5523. }},
  5524. empty: {get: function() {
  5525. return empty;
  5526. }},
  5527. HTML_CHARACTERS: {get: function() {
  5528. return HTML_CHARACTERS;
  5529. }},
  5530. fastInnerHTML: {get: function() {
  5531. return fastInnerHTML;
  5532. }},
  5533. fastInnerText: {get: function() {
  5534. return fastInnerText;
  5535. }},
  5536. isVisible: {get: function() {
  5537. return isVisible;
  5538. }},
  5539. offset: {get: function() {
  5540. return offset;
  5541. }},
  5542. getWindowScrollTop: {get: function() {
  5543. return getWindowScrollTop;
  5544. }},
  5545. getWindowScrollLeft: {get: function() {
  5546. return getWindowScrollLeft;
  5547. }},
  5548. getScrollTop: {get: function() {
  5549. return getScrollTop;
  5550. }},
  5551. getScrollLeft: {get: function() {
  5552. return getScrollLeft;
  5553. }},
  5554. getScrollableElement: {get: function() {
  5555. return getScrollableElement;
  5556. }},
  5557. getTrimmingContainer: {get: function() {
  5558. return getTrimmingContainer;
  5559. }},
  5560. getStyle: {get: function() {
  5561. return getStyle;
  5562. }},
  5563. getComputedStyle: {get: function() {
  5564. return getComputedStyle;
  5565. }},
  5566. outerWidth: {get: function() {
  5567. return outerWidth;
  5568. }},
  5569. outerHeight: {get: function() {
  5570. return outerHeight;
  5571. }},
  5572. innerHeight: {get: function() {
  5573. return innerHeight;
  5574. }},
  5575. innerWidth: {get: function() {
  5576. return innerWidth;
  5577. }},
  5578. addEvent: {get: function() {
  5579. return addEvent;
  5580. }},
  5581. removeEvent: {get: function() {
  5582. return removeEvent;
  5583. }},
  5584. hasCaptionProblem: {get: function() {
  5585. return hasCaptionProblem;
  5586. }},
  5587. getCaretPosition: {get: function() {
  5588. return getCaretPosition;
  5589. }},
  5590. getSelectionEndPosition: {get: function() {
  5591. return getSelectionEndPosition;
  5592. }},
  5593. setCaretPosition: {get: function() {
  5594. return setCaretPosition;
  5595. }},
  5596. getScrollbarWidth: {get: function() {
  5597. return getScrollbarWidth;
  5598. }},
  5599. isIE8: {get: function() {
  5600. return isIE8;
  5601. }},
  5602. isIE9: {get: function() {
  5603. return isIE9;
  5604. }},
  5605. isSafari: {get: function() {
  5606. return isSafari;
  5607. }},
  5608. setOverlayPosition: {get: function() {
  5609. return setOverlayPosition;
  5610. }},
  5611. getCssTransform: {get: function() {
  5612. return getCssTransform;
  5613. }},
  5614. resetCssTransform: {get: function() {
  5615. return resetCssTransform;
  5616. }},
  5617. __esModule: {value: true}
  5618. });
  5619. function enableImmediatePropagation(event) {
  5620. if (event != null && event.isImmediatePropagationEnabled == null) {
  5621. event.stopImmediatePropagation = function() {
  5622. this.isImmediatePropagationEnabled = false;
  5623. this.cancelBubble = true;
  5624. };
  5625. event.isImmediatePropagationEnabled = true;
  5626. event.isImmediatePropagationStopped = function() {
  5627. return !this.isImmediatePropagationEnabled;
  5628. };
  5629. }
  5630. }
  5631. function closest(element, nodes, until) {
  5632. while (element != null && element !== until) {
  5633. if (element.nodeType === Node.ELEMENT_NODE && (nodes.indexOf(element.nodeName) > -1 || nodes.indexOf(element) > -1)) {
  5634. return element;
  5635. }
  5636. if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  5637. element = element.host;
  5638. } else {
  5639. element = element.parentNode;
  5640. }
  5641. }
  5642. return null;
  5643. }
  5644. function isChildOf(child, parent) {
  5645. var node = child.parentNode;
  5646. var queriedParents = [];
  5647. if (typeof parent === "string") {
  5648. queriedParents = Array.prototype.slice.call(document.querySelectorAll(parent), 0);
  5649. } else {
  5650. queriedParents.push(parent);
  5651. }
  5652. while (node != null) {
  5653. if (queriedParents.indexOf(node) > -1) {
  5654. return true;
  5655. }
  5656. node = node.parentNode;
  5657. }
  5658. return false;
  5659. }
  5660. function isChildOfWebComponentTable(element) {
  5661. var hotTableName = 'hot-table',
  5662. result = false,
  5663. parentNode;
  5664. parentNode = polymerWrap(element);
  5665. function isHotTable(element) {
  5666. return element.nodeType === Node.ELEMENT_NODE && element.nodeName === hotTableName.toUpperCase();
  5667. }
  5668. while (parentNode != null) {
  5669. if (isHotTable(parentNode)) {
  5670. result = true;
  5671. break;
  5672. } else if (parentNode.host && parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  5673. result = isHotTable(parentNode.host);
  5674. if (result) {
  5675. break;
  5676. }
  5677. parentNode = parentNode.host;
  5678. }
  5679. parentNode = parentNode.parentNode;
  5680. }
  5681. return result;
  5682. }
  5683. function polymerWrap(element) {
  5684. return typeof Polymer !== 'undefined' && typeof wrap === 'function' ? wrap(element) : element;
  5685. }
  5686. function polymerUnwrap(element) {
  5687. return typeof Polymer !== 'undefined' && typeof unwrap === 'function' ? unwrap(element) : element;
  5688. }
  5689. function isWebComponentSupportedNatively() {
  5690. var test = document.createElement('div');
  5691. return test.createShadowRoot && test.createShadowRoot.toString().match(/\[native code\]/) ? true : false;
  5692. }
  5693. function index(elem) {
  5694. var i = 0;
  5695. if (elem.previousSibling) {
  5696. while (elem = elem.previousSibling) {
  5697. ++i;
  5698. }
  5699. }
  5700. return i;
  5701. }
  5702. var classListSupport = document.documentElement.classList ? true : false;
  5703. var _hasClass,
  5704. _addClass,
  5705. _removeClass;
  5706. function filterEmptyClassNames(classNames) {
  5707. var len = 0,
  5708. result = [];
  5709. if (!classNames || !classNames.length) {
  5710. return result;
  5711. }
  5712. while (classNames[len]) {
  5713. result.push(classNames[len]);
  5714. len++;
  5715. }
  5716. return result;
  5717. }
  5718. if (classListSupport) {
  5719. var isSupportMultipleClassesArg = (function() {
  5720. var element = document.createElement('div');
  5721. element.classList.add('test', 'test2');
  5722. return element.classList.contains('test2');
  5723. }());
  5724. _hasClass = function _hasClass(element, className) {
  5725. if (className === '') {
  5726. return false;
  5727. }
  5728. return element.classList.contains(className);
  5729. };
  5730. _addClass = function _addClass(element, className) {
  5731. var len = 0;
  5732. if (typeof className === 'string') {
  5733. className = className.split(' ');
  5734. }
  5735. className = filterEmptyClassNames(className);
  5736. if (isSupportMultipleClassesArg) {
  5737. element.classList.add.apply(element.classList, className);
  5738. } else {
  5739. while (className && className[len]) {
  5740. element.classList.add(className[len]);
  5741. len++;
  5742. }
  5743. }
  5744. };
  5745. _removeClass = function _removeClass(element, className) {
  5746. var len = 0;
  5747. if (typeof className === 'string') {
  5748. className = className.split(' ');
  5749. }
  5750. className = filterEmptyClassNames(className);
  5751. if (isSupportMultipleClassesArg) {
  5752. element.classList.remove.apply(element.classList, className);
  5753. } else {
  5754. while (className && className[len]) {
  5755. element.classList.remove(className[len]);
  5756. len++;
  5757. }
  5758. }
  5759. };
  5760. } else {
  5761. var createClassNameRegExp = function createClassNameRegExp(className) {
  5762. return new RegExp('(\\s|^)' + className + '(\\s|$)');
  5763. };
  5764. _hasClass = function _hasClass(element, className) {
  5765. return element.className.match(createClassNameRegExp(className)) ? true : false;
  5766. };
  5767. _addClass = function _addClass(element, className) {
  5768. var len = 0,
  5769. _className = element.className;
  5770. if (typeof className === 'string') {
  5771. className = className.split(' ');
  5772. }
  5773. if (_className === '') {
  5774. _className = className.join(' ');
  5775. } else {
  5776. while (className && className[len]) {
  5777. if (!createClassNameRegExp(className[len]).test(_className)) {
  5778. _className += ' ' + className[len];
  5779. }
  5780. len++;
  5781. }
  5782. }
  5783. element.className = _className;
  5784. };
  5785. _removeClass = function _removeClass(element, className) {
  5786. var len = 0,
  5787. _className = element.className;
  5788. if (typeof className === 'string') {
  5789. className = className.split(' ');
  5790. }
  5791. while (className && className[len]) {
  5792. _className = _className.replace(createClassNameRegExp(className[len]), ' ').trim();
  5793. len++;
  5794. }
  5795. if (element.className !== _className) {
  5796. element.className = _className;
  5797. }
  5798. };
  5799. }
  5800. function hasClass(element, className) {
  5801. return _hasClass(element, className);
  5802. }
  5803. function addClass(element, className) {
  5804. return _addClass(element, className);
  5805. }
  5806. function removeClass(element, className) {
  5807. return _removeClass(element, className);
  5808. }
  5809. function removeTextNodes(elem, parent) {
  5810. if (elem.nodeType === 3) {
  5811. parent.removeChild(elem);
  5812. } else if (['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR'].indexOf(elem.nodeName) > -1) {
  5813. var childs = elem.childNodes;
  5814. for (var i = childs.length - 1; i >= 0; i--) {
  5815. removeTextNodes(childs[i], elem);
  5816. }
  5817. }
  5818. }
  5819. function empty(element) {
  5820. var child;
  5821. while (child = element.lastChild) {
  5822. element.removeChild(child);
  5823. }
  5824. }
  5825. var HTML_CHARACTERS = /(<(.*)>|&(.*);)/;
  5826. function fastInnerHTML(element, content) {
  5827. if (HTML_CHARACTERS.test(content)) {
  5828. element.innerHTML = content;
  5829. } else {
  5830. fastInnerText(element, content);
  5831. }
  5832. }
  5833. var textContextSupport = document.createTextNode('test').textContent ? true : false;
  5834. function fastInnerText(element, content) {
  5835. var child = element.firstChild;
  5836. if (child && child.nodeType === 3 && child.nextSibling === null) {
  5837. if (textContextSupport) {
  5838. child.textContent = content;
  5839. } else {
  5840. child.data = content;
  5841. }
  5842. } else {
  5843. empty(element);
  5844. element.appendChild(document.createTextNode(content));
  5845. }
  5846. }
  5847. function isVisible(elem) {
  5848. var next = elem;
  5849. while (polymerUnwrap(next) !== document.documentElement) {
  5850. if (next === null) {
  5851. return false;
  5852. } else if (next.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  5853. if (next.host) {
  5854. if (next.host.impl) {
  5855. return isVisible(next.host.impl);
  5856. } else if (next.host) {
  5857. return isVisible(next.host);
  5858. } else {
  5859. throw new Error("Lost in Web Components world");
  5860. }
  5861. } else {
  5862. return false;
  5863. }
  5864. } else if (next.style.display === 'none') {
  5865. return false;
  5866. }
  5867. next = next.parentNode;
  5868. }
  5869. return true;
  5870. }
  5871. function offset(elem) {
  5872. var offsetLeft,
  5873. offsetTop,
  5874. lastElem,
  5875. docElem,
  5876. box;
  5877. docElem = document.documentElement;
  5878. if (hasCaptionProblem() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') {
  5879. box = elem.getBoundingClientRect();
  5880. return {
  5881. top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
  5882. left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)
  5883. };
  5884. }
  5885. offsetLeft = elem.offsetLeft;
  5886. offsetTop = elem.offsetTop;
  5887. lastElem = elem;
  5888. while (elem = elem.offsetParent) {
  5889. if (elem === document.body) {
  5890. break;
  5891. }
  5892. offsetLeft += elem.offsetLeft;
  5893. offsetTop += elem.offsetTop;
  5894. lastElem = elem;
  5895. }
  5896. if (lastElem && lastElem.style.position === 'fixed') {
  5897. offsetLeft += window.pageXOffset || docElem.scrollLeft;
  5898. offsetTop += window.pageYOffset || docElem.scrollTop;
  5899. }
  5900. return {
  5901. left: offsetLeft,
  5902. top: offsetTop
  5903. };
  5904. }
  5905. function getWindowScrollTop() {
  5906. var res = window.scrollY;
  5907. if (res == void 0) {
  5908. res = document.documentElement.scrollTop;
  5909. }
  5910. return res;
  5911. }
  5912. function getWindowScrollLeft() {
  5913. var res = window.scrollX;
  5914. if (res == void 0) {
  5915. res = document.documentElement.scrollLeft;
  5916. }
  5917. return res;
  5918. }
  5919. function getScrollTop(elem) {
  5920. if (elem === window) {
  5921. return getWindowScrollTop(elem);
  5922. } else {
  5923. return elem.scrollTop;
  5924. }
  5925. }
  5926. function getScrollLeft(elem) {
  5927. if (elem === window) {
  5928. return getWindowScrollLeft(elem);
  5929. } else {
  5930. return elem.scrollLeft;
  5931. }
  5932. }
  5933. function getScrollableElement(element) {
  5934. var el = element.parentNode,
  5935. props = ['auto', 'scroll'],
  5936. overflow,
  5937. overflowX,
  5938. overflowY,
  5939. computedStyle = '',
  5940. computedOverflow = '',
  5941. computedOverflowY = '',
  5942. computedOverflowX = '';
  5943. while (el && el.style && document.body !== el) {
  5944. overflow = el.style.overflow;
  5945. overflowX = el.style.overflowX;
  5946. overflowY = el.style.overflowY;
  5947. if (overflow == 'scroll' || overflowX == 'scroll' || overflowY == 'scroll') {
  5948. return el;
  5949. } else if (window.getComputedStyle) {
  5950. computedStyle = window.getComputedStyle(el);
  5951. computedOverflow = computedStyle.getPropertyValue('overflow');
  5952. computedOverflowY = computedStyle.getPropertyValue('overflow-y');
  5953. computedOverflowX = computedStyle.getPropertyValue('overflow-x');
  5954. if (computedOverflow === 'scroll' || computedOverflowX === 'scroll' || computedOverflowY === 'scroll') {
  5955. return el;
  5956. }
  5957. }
  5958. if (el.clientHeight <= el.scrollHeight && (props.indexOf(overflowY) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowY) !== -1)) {
  5959. return el;
  5960. }
  5961. if (el.clientWidth <= el.scrollWidth && (props.indexOf(overflowX) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowX) !== -1)) {
  5962. return el;
  5963. }
  5964. el = el.parentNode;
  5965. }
  5966. return window;
  5967. }
  5968. function getTrimmingContainer(base) {
  5969. var el = base.parentNode;
  5970. while (el && el.style && document.body !== el) {
  5971. if (el.style.overflow !== 'visible' && el.style.overflow !== '') {
  5972. return el;
  5973. } else if (window.getComputedStyle) {
  5974. var computedStyle = window.getComputedStyle(el);
  5975. if (computedStyle.getPropertyValue('overflow') !== 'visible' && computedStyle.getPropertyValue('overflow') !== '') {
  5976. return el;
  5977. }
  5978. }
  5979. el = el.parentNode;
  5980. }
  5981. return window;
  5982. }
  5983. function getStyle(elem, prop) {
  5984. if (!elem) {
  5985. return;
  5986. } else if (elem === window) {
  5987. if (prop === 'width') {
  5988. return window.innerWidth + 'px';
  5989. } else if (prop === 'height') {
  5990. return window.innerHeight + 'px';
  5991. }
  5992. return;
  5993. }
  5994. var styleProp = elem.style[prop],
  5995. computedStyle;
  5996. if (styleProp !== "" && styleProp !== void 0) {
  5997. return styleProp;
  5998. } else {
  5999. computedStyle = getComputedStyle(elem);
  6000. if (computedStyle[prop] !== "" && computedStyle[prop] !== void 0) {
  6001. return computedStyle[prop];
  6002. }
  6003. return void 0;
  6004. }
  6005. }
  6006. function getComputedStyle(elem) {
  6007. return elem.currentStyle || document.defaultView.getComputedStyle(elem);
  6008. }
  6009. function outerWidth(elem) {
  6010. return elem.offsetWidth;
  6011. }
  6012. function outerHeight(elem) {
  6013. if (hasCaptionProblem() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') {
  6014. return elem.offsetHeight + elem.firstChild.offsetHeight;
  6015. } else {
  6016. return elem.offsetHeight;
  6017. }
  6018. }
  6019. function innerHeight(elem) {
  6020. return elem.clientHeight || elem.innerHeight;
  6021. }
  6022. function innerWidth(elem) {
  6023. return elem.clientWidth || elem.innerWidth;
  6024. }
  6025. function addEvent(element, event, callback) {
  6026. if (window.addEventListener) {
  6027. element.addEventListener(event, callback, false);
  6028. } else {
  6029. element.attachEvent('on' + event, callback);
  6030. }
  6031. }
  6032. function removeEvent(element, event, callback) {
  6033. if (window.removeEventListener) {
  6034. element.removeEventListener(event, callback, false);
  6035. } else {
  6036. element.detachEvent('on' + event, callback);
  6037. }
  6038. }
  6039. var _hasCaptionProblem;
  6040. function detectCaptionProblem() {
  6041. var TABLE = document.createElement('TABLE');
  6042. TABLE.style.borderSpacing = 0;
  6043. TABLE.style.borderWidth = 0;
  6044. TABLE.style.padding = 0;
  6045. var TBODY = document.createElement('TBODY');
  6046. TABLE.appendChild(TBODY);
  6047. TBODY.appendChild(document.createElement('TR'));
  6048. TBODY.firstChild.appendChild(document.createElement('TD'));
  6049. TBODY.firstChild.firstChild.innerHTML = '<tr><td>t<br>t</td></tr>';
  6050. var CAPTION = document.createElement('CAPTION');
  6051. CAPTION.innerHTML = 'c<br>c<br>c<br>c';
  6052. CAPTION.style.padding = 0;
  6053. CAPTION.style.margin = 0;
  6054. TABLE.insertBefore(CAPTION, TBODY);
  6055. document.body.appendChild(TABLE);
  6056. _hasCaptionProblem = (TABLE.offsetHeight < 2 * TABLE.lastChild.offsetHeight);
  6057. document.body.removeChild(TABLE);
  6058. }
  6059. function hasCaptionProblem() {
  6060. if (_hasCaptionProblem === void 0) {
  6061. detectCaptionProblem();
  6062. }
  6063. return _hasCaptionProblem;
  6064. }
  6065. function getCaretPosition(el) {
  6066. if (el.selectionStart) {
  6067. return el.selectionStart;
  6068. } else if (document.selection) {
  6069. el.focus();
  6070. var r = document.selection.createRange();
  6071. if (r == null) {
  6072. return 0;
  6073. }
  6074. var re = el.createTextRange();
  6075. var rc = re.duplicate();
  6076. re.moveToBookmark(r.getBookmark());
  6077. rc.setEndPoint('EndToStart', re);
  6078. return rc.text.length;
  6079. }
  6080. return 0;
  6081. }
  6082. function getSelectionEndPosition(el) {
  6083. if (el.selectionEnd) {
  6084. return el.selectionEnd;
  6085. } else if (document.selection) {
  6086. var r = document.selection.createRange();
  6087. if (r == null) {
  6088. return 0;
  6089. }
  6090. var re = el.createTextRange();
  6091. return re.text.indexOf(r.text) + r.text.length;
  6092. }
  6093. }
  6094. function setCaretPosition(el, pos, endPos) {
  6095. if (endPos === void 0) {
  6096. endPos = pos;
  6097. }
  6098. if (el.setSelectionRange) {
  6099. el.focus();
  6100. try {
  6101. el.setSelectionRange(pos, endPos);
  6102. } catch (err) {
  6103. var elementParent = el.parentNode;
  6104. var parentDisplayValue = elementParent.style.display;
  6105. elementParent.style.display = 'block';
  6106. el.setSelectionRange(pos, endPos);
  6107. elementParent.style.display = parentDisplayValue;
  6108. }
  6109. } else if (el.createTextRange) {
  6110. var range = el.createTextRange();
  6111. range.collapse(true);
  6112. range.moveEnd('character', endPos);
  6113. range.moveStart('character', pos);
  6114. range.select();
  6115. }
  6116. }
  6117. var cachedScrollbarWidth;
  6118. function walkontableCalculateScrollbarWidth() {
  6119. var inner = document.createElement('p');
  6120. inner.style.width = "100%";
  6121. inner.style.height = "200px";
  6122. var outer = document.createElement('div');
  6123. outer.style.position = "absolute";
  6124. outer.style.top = "0px";
  6125. outer.style.left = "0px";
  6126. outer.style.visibility = "hidden";
  6127. outer.style.width = "200px";
  6128. outer.style.height = "150px";
  6129. outer.style.overflow = "hidden";
  6130. outer.appendChild(inner);
  6131. (document.body || document.documentElement).appendChild(outer);
  6132. var w1 = inner.offsetWidth;
  6133. outer.style.overflow = 'scroll';
  6134. var w2 = inner.offsetWidth;
  6135. if (w1 == w2) {
  6136. w2 = outer.clientWidth;
  6137. }
  6138. (document.body || document.documentElement).removeChild(outer);
  6139. return (w1 - w2);
  6140. }
  6141. function getScrollbarWidth() {
  6142. if (cachedScrollbarWidth === void 0) {
  6143. cachedScrollbarWidth = walkontableCalculateScrollbarWidth();
  6144. }
  6145. return cachedScrollbarWidth;
  6146. }
  6147. var _isIE8 = !(document.createTextNode('test').textContent);
  6148. function isIE8() {
  6149. return isIE8;
  6150. }
  6151. var _isIE9 = !!(document.documentMode);
  6152. function isIE9() {
  6153. return _isIE9;
  6154. }
  6155. var _isSafari = (/Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor));
  6156. function isSafari() {
  6157. return _isSafari;
  6158. }
  6159. function setOverlayPosition(overlayElem, left, top) {
  6160. if (_isIE8 || _isIE9) {
  6161. overlayElem.style.top = top;
  6162. overlayElem.style.left = left;
  6163. } else if (_isSafari) {
  6164. overlayElem.style['-webkit-transform'] = 'translate3d(' + left + ',' + top + ',0)';
  6165. } else {
  6166. overlayElem.style.transform = 'translate3d(' + left + ',' + top + ',0)';
  6167. }
  6168. }
  6169. function getCssTransform(elem) {
  6170. var transform;
  6171. if (elem.style['transform'] && (transform = elem.style['transform']) !== '') {
  6172. return ['transform', transform];
  6173. } else if (elem.style['-webkit-transform'] && (transform = elem.style['-webkit-transform']) !== '') {
  6174. return ['-webkit-transform', transform];
  6175. }
  6176. return -1;
  6177. }
  6178. function resetCssTransform(elem) {
  6179. if (elem['transform'] && elem['transform'] !== '') {
  6180. elem['transform'] = '';
  6181. } else if (elem['-webkit-transform'] && elem['-webkit-transform'] !== '') {
  6182. elem['-webkit-transform'] = '';
  6183. }
  6184. }
  6185. window.Handsontable = window.Handsontable || {};
  6186. Handsontable.Dom = {
  6187. addClass: addClass,
  6188. addEvent: addEvent,
  6189. closest: closest,
  6190. empty: empty,
  6191. enableImmediatePropagation: enableImmediatePropagation,
  6192. fastInnerHTML: fastInnerHTML,
  6193. fastInnerText: fastInnerText,
  6194. getCaretPosition: getCaretPosition,
  6195. getComputedStyle: getComputedStyle,
  6196. getCssTransform: getCssTransform,
  6197. getScrollableElement: getScrollableElement,
  6198. getScrollbarWidth: getScrollbarWidth,
  6199. getScrollLeft: getScrollLeft,
  6200. getScrollTop: getScrollTop,
  6201. getStyle: getStyle,
  6202. getSelectionEndPosition: getSelectionEndPosition,
  6203. getTrimmingContainer: getTrimmingContainer,
  6204. getWindowScrollLeft: getWindowScrollLeft,
  6205. getWindowScrollTop: getWindowScrollTop,
  6206. hasCaptionProblem: hasCaptionProblem,
  6207. hasClass: hasClass,
  6208. HTML_CHARACTERS: HTML_CHARACTERS,
  6209. index: index,
  6210. innerHeight: innerHeight,
  6211. innerWidth: innerWidth,
  6212. isChildOf: isChildOf,
  6213. isChildOfWebComponentTable: isChildOfWebComponentTable,
  6214. isIE8: isIE8,
  6215. isIE9: isIE9,
  6216. isSafari: isSafari,
  6217. isVisible: isVisible,
  6218. isWebComponentSupportedNatively: isWebComponentSupportedNatively,
  6219. offset: offset,
  6220. outerHeight: outerHeight,
  6221. outerWidth: outerWidth,
  6222. polymerUnwrap: polymerUnwrap,
  6223. polymerWrap: polymerWrap,
  6224. removeClass: removeClass,
  6225. removeEvent: removeEvent,
  6226. removeTextNodes: removeTextNodes,
  6227. resetCssTransform: resetCssTransform,
  6228. setCaretPosition: setCaretPosition,
  6229. setOverlayPosition: setOverlayPosition
  6230. };
  6231. //#
  6232. },{}],28:[function(require,module,exports){
  6233. "use strict";
  6234. Object.defineProperties(exports, {
  6235. EditorManager: {get: function() {
  6236. return EditorManager;
  6237. }},
  6238. __esModule: {value: true}
  6239. });
  6240. var $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
  6241. $__helpers_46_js__,
  6242. $__dom_46_js__,
  6243. $__editors_46_js__,
  6244. $__eventManager_46_js__;
  6245. 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;
  6246. var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
  6247. var dom = ($__dom_46_js__ = require("./dom.js"), $__dom_46_js__ && $__dom_46_js__.__esModule && $__dom_46_js__ || {default: $__dom_46_js__});
  6248. var getEditor = ($__editors_46_js__ = require("./editors.js"), $__editors_46_js__ && $__editors_46_js__.__esModule && $__editors_46_js__ || {default: $__editors_46_js__}).getEditor;
  6249. var eventManagerObject = ($__eventManager_46_js__ = require("./eventManager.js"), $__eventManager_46_js__ && $__eventManager_46_js__.__esModule && $__eventManager_46_js__ || {default: $__eventManager_46_js__}).eventManager;
  6250. ;
  6251. Handsontable.EditorManager = EditorManager;
  6252. function EditorManager(instance, priv, selection) {
  6253. var _this = this,
  6254. keyCodes = helper.keyCode,
  6255. destroyed = false,
  6256. eventManager,
  6257. activeEditor;
  6258. eventManager = eventManagerObject(instance);
  6259. function moveSelectionAfterEnter(shiftKey) {
  6260. var enterMoves = typeof priv.settings.enterMoves === 'function' ? priv.settings.enterMoves(event) : priv.settings.enterMoves;
  6261. if (shiftKey) {
  6262. selection.transformStart(-enterMoves.row, -enterMoves.col);
  6263. } else {
  6264. selection.transformStart(enterMoves.row, enterMoves.col, true);
  6265. }
  6266. }
  6267. function moveSelectionUp(shiftKey) {
  6268. if (shiftKey) {
  6269. selection.transformEnd(-1, 0);
  6270. } else {
  6271. selection.transformStart(-1, 0);
  6272. }
  6273. }
  6274. function moveSelectionDown(shiftKey) {
  6275. if (shiftKey) {
  6276. selection.transformEnd(1, 0);
  6277. } else {
  6278. selection.transformStart(1, 0);
  6279. }
  6280. }
  6281. function moveSelectionRight(shiftKey) {
  6282. if (shiftKey) {
  6283. selection.transformEnd(0, 1);
  6284. } else {
  6285. selection.transformStart(0, 1);
  6286. }
  6287. }
  6288. function moveSelectionLeft(shiftKey) {
  6289. if (shiftKey) {
  6290. selection.transformEnd(0, -1);
  6291. } else {
  6292. selection.transformStart(0, -1);
  6293. }
  6294. }
  6295. function onKeyDown(event) {
  6296. var ctrlDown,
  6297. rangeModifier;
  6298. if (!instance.isListening()) {
  6299. return;
  6300. }
  6301. Handsontable.hooks.run(instance, 'beforeKeyDown', event);
  6302. if (destroyed) {
  6303. return;
  6304. }
  6305. dom.enableImmediatePropagation(event);
  6306. if (event.isImmediatePropagationStopped()) {
  6307. return;
  6308. }
  6309. priv.lastKeyCode = event.keyCode;
  6310. if (!selection.isSelected()) {
  6311. return;
  6312. }
  6313. ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  6314. if (activeEditor && !activeEditor.isWaiting()) {
  6315. if (!helper.isMetaKey(event.keyCode) && !ctrlDown && !_this.isEditorOpened()) {
  6316. _this.openEditor("", event);
  6317. return;
  6318. }
  6319. }
  6320. rangeModifier = event.shiftKey ? selection.setRangeEnd : selection.setRangeStart;
  6321. switch (event.keyCode) {
  6322. case keyCodes.A:
  6323. if (!_this.isEditorOpened() && ctrlDown) {
  6324. selection.selectAll();
  6325. event.preventDefault();
  6326. helper.stopPropagation(event);
  6327. }
  6328. break;
  6329. case keyCodes.ARROW_UP:
  6330. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  6331. _this.closeEditorAndSaveChanges(ctrlDown);
  6332. }
  6333. moveSelectionUp(event.shiftKey);
  6334. event.preventDefault();
  6335. helper.stopPropagation(event);
  6336. break;
  6337. case keyCodes.ARROW_DOWN:
  6338. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  6339. _this.closeEditorAndSaveChanges(ctrlDown);
  6340. }
  6341. moveSelectionDown(event.shiftKey);
  6342. event.preventDefault();
  6343. helper.stopPropagation(event);
  6344. break;
  6345. case keyCodes.ARROW_RIGHT:
  6346. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  6347. _this.closeEditorAndSaveChanges(ctrlDown);
  6348. }
  6349. moveSelectionRight(event.shiftKey);
  6350. event.preventDefault();
  6351. helper.stopPropagation(event);
  6352. break;
  6353. case keyCodes.ARROW_LEFT:
  6354. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  6355. _this.closeEditorAndSaveChanges(ctrlDown);
  6356. }
  6357. moveSelectionLeft(event.shiftKey);
  6358. event.preventDefault();
  6359. helper.stopPropagation(event);
  6360. break;
  6361. case keyCodes.TAB:
  6362. var tabMoves = typeof priv.settings.tabMoves === 'function' ? priv.settings.tabMoves(event) : priv.settings.tabMoves;
  6363. if (event.shiftKey) {
  6364. selection.transformStart(-tabMoves.row, -tabMoves.col);
  6365. } else {
  6366. selection.transformStart(tabMoves.row, tabMoves.col, true);
  6367. }
  6368. event.preventDefault();
  6369. helper.stopPropagation(event);
  6370. break;
  6371. case keyCodes.BACKSPACE:
  6372. case keyCodes.DELETE:
  6373. selection.empty(event);
  6374. _this.prepareEditor();
  6375. event.preventDefault();
  6376. break;
  6377. case keyCodes.F2:
  6378. _this.openEditor(null, event);
  6379. event.preventDefault();
  6380. break;
  6381. case keyCodes.ENTER:
  6382. if (_this.isEditorOpened()) {
  6383. if (activeEditor && activeEditor.state !== Handsontable.EditorState.WAITING) {
  6384. _this.closeEditorAndSaveChanges(ctrlDown);
  6385. }
  6386. moveSelectionAfterEnter(event.shiftKey);
  6387. } else {
  6388. if (instance.getSettings().enterBeginsEditing) {
  6389. _this.openEditor(null, event);
  6390. } else {
  6391. moveSelectionAfterEnter(event.shiftKey);
  6392. }
  6393. }
  6394. event.preventDefault();
  6395. event.stopImmediatePropagation();
  6396. break;
  6397. case keyCodes.ESCAPE:
  6398. if (_this.isEditorOpened()) {
  6399. _this.closeEditorAndRestoreOriginalValue(ctrlDown);
  6400. }
  6401. event.preventDefault();
  6402. break;
  6403. case keyCodes.HOME:
  6404. if (event.ctrlKey || event.metaKey) {
  6405. rangeModifier(new WalkontableCellCoords(0, priv.selRange.from.col));
  6406. } else {
  6407. rangeModifier(new WalkontableCellCoords(priv.selRange.from.row, 0));
  6408. }
  6409. event.preventDefault();
  6410. helper.stopPropagation(event);
  6411. break;
  6412. case keyCodes.END:
  6413. if (event.ctrlKey || event.metaKey) {
  6414. rangeModifier(new WalkontableCellCoords(instance.countRows() - 1, priv.selRange.from.col));
  6415. } else {
  6416. rangeModifier(new WalkontableCellCoords(priv.selRange.from.row, instance.countCols() - 1));
  6417. }
  6418. event.preventDefault();
  6419. helper.stopPropagation(event);
  6420. break;
  6421. case keyCodes.PAGE_UP:
  6422. selection.transformStart(-instance.countVisibleRows(), 0);
  6423. event.preventDefault();
  6424. helper.stopPropagation(event);
  6425. break;
  6426. case keyCodes.PAGE_DOWN:
  6427. selection.transformStart(instance.countVisibleRows(), 0);
  6428. event.preventDefault();
  6429. helper.stopPropagation(event);
  6430. break;
  6431. }
  6432. }
  6433. function init() {
  6434. instance.addHook('afterDocumentKeyDown', onKeyDown);
  6435. eventManager.addEventListener(document.documentElement, 'keydown', function(event) {
  6436. instance.runHooks('afterDocumentKeyDown', event);
  6437. });
  6438. function onDblClick(event, coords, elem) {
  6439. if (elem.nodeName == "TD") {
  6440. _this.openEditor();
  6441. }
  6442. }
  6443. instance.view.wt.update('onCellDblClick', onDblClick);
  6444. instance.addHook('afterDestroy', function() {
  6445. destroyed = true;
  6446. });
  6447. }
  6448. this.destroyEditor = function(revertOriginal) {
  6449. this.closeEditor(revertOriginal);
  6450. };
  6451. this.getActiveEditor = function() {
  6452. return activeEditor;
  6453. };
  6454. this.prepareEditor = function() {
  6455. var row,
  6456. col,
  6457. prop,
  6458. td,
  6459. originalValue,
  6460. cellProperties,
  6461. editorClass;
  6462. if (activeEditor && activeEditor.isWaiting()) {
  6463. this.closeEditor(false, false, function(dataSaved) {
  6464. if (dataSaved) {
  6465. _this.prepareEditor();
  6466. }
  6467. });
  6468. return;
  6469. }
  6470. row = priv.selRange.highlight.row;
  6471. col = priv.selRange.highlight.col;
  6472. prop = instance.colToProp(col);
  6473. td = instance.getCell(row, col);
  6474. originalValue = instance.getDataAtCell(row, col);
  6475. cellProperties = instance.getCellMeta(row, col);
  6476. editorClass = instance.getCellEditor(cellProperties);
  6477. if (editorClass) {
  6478. activeEditor = Handsontable.editors.getEditor(editorClass, instance);
  6479. activeEditor.prepare(row, col, prop, td, originalValue, cellProperties);
  6480. } else {
  6481. activeEditor = void 0;
  6482. }
  6483. };
  6484. this.isEditorOpened = function() {
  6485. return activeEditor && activeEditor.isOpened();
  6486. };
  6487. this.openEditor = function(initialValue, event) {
  6488. if (activeEditor && !activeEditor.cellProperties.readOnly) {
  6489. activeEditor.beginEditing(initialValue, event);
  6490. } else if (activeEditor && activeEditor.cellProperties.readOnly) {
  6491. if (event && event.keyCode === helper.keyCode.ENTER) {
  6492. moveSelectionAfterEnter();
  6493. }
  6494. }
  6495. };
  6496. this.closeEditor = function(restoreOriginalValue, ctrlDown, callback) {
  6497. if (!activeEditor) {
  6498. if (callback) {
  6499. callback(false);
  6500. }
  6501. } else {
  6502. activeEditor.finishEditing(restoreOriginalValue, ctrlDown, callback);
  6503. }
  6504. };
  6505. this.closeEditorAndSaveChanges = function(ctrlDown) {
  6506. return this.closeEditor(false, ctrlDown);
  6507. };
  6508. this.closeEditorAndRestoreOriginalValue = function(ctrlDown) {
  6509. return this.closeEditor(true, ctrlDown);
  6510. };
  6511. init();
  6512. }
  6513. //#
  6514. },{"./3rdparty/walkontable/src/cell/coords.js":5,"./dom.js":27,"./editors.js":29,"./eventManager.js":41,"./helpers.js":42}],29:[function(require,module,exports){
  6515. "use strict";
  6516. Object.defineProperties(exports, {
  6517. registerEditor: {get: function() {
  6518. return registerEditor;
  6519. }},
  6520. getEditor: {get: function() {
  6521. return getEditor;
  6522. }},
  6523. hasEditor: {get: function() {
  6524. return hasEditor;
  6525. }},
  6526. getEditorConstructor: {get: function() {
  6527. return getEditorConstructor;
  6528. }},
  6529. __esModule: {value: true}
  6530. });
  6531. var $__helpers_46_js__;
  6532. var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
  6533. ;
  6534. var registeredEditorNames = {},
  6535. registeredEditorClasses = new WeakMap();
  6536. Handsontable.editors = Handsontable.editors || {};
  6537. Handsontable.editors.registerEditor = registerEditor;
  6538. Handsontable.editors.getEditor = getEditor;
  6539. function RegisteredEditor(editorClass) {
  6540. var Clazz,
  6541. instances;
  6542. instances = {};
  6543. Clazz = editorClass;
  6544. this.getConstructor = function() {
  6545. return editorClass;
  6546. };
  6547. this.getInstance = function(hotInstance) {
  6548. if (!(hotInstance.guid in instances)) {
  6549. instances[hotInstance.guid] = new Clazz(hotInstance);
  6550. }
  6551. return instances[hotInstance.guid];
  6552. };
  6553. }
  6554. function registerEditor(editorName, editorClass) {
  6555. var editor = new RegisteredEditor(editorClass);
  6556. if (typeof editorName === "string") {
  6557. registeredEditorNames[editorName] = editor;
  6558. }
  6559. registeredEditorClasses.set(editorClass, editor);
  6560. }
  6561. function getEditor(editorName, hotInstance) {
  6562. var editor;
  6563. if (typeof editorName == 'function') {
  6564. if (!(registeredEditorClasses.get(editorName))) {
  6565. registerEditor(null, editorName);
  6566. }
  6567. editor = registeredEditorClasses.get(editorName);
  6568. } else if (typeof editorName == 'string') {
  6569. editor = registeredEditorNames[editorName];
  6570. } else {
  6571. throw Error('Only strings and functions can be passed as "editor" parameter ');
  6572. }
  6573. if (!editor) {
  6574. throw Error('No editor registered under name "' + editorName + '"');
  6575. }
  6576. return editor.getInstance(hotInstance);
  6577. }
  6578. function getEditorConstructor(editorName) {
  6579. var editor;
  6580. if (typeof editorName == 'string') {
  6581. editor = registeredEditorNames[editorName];
  6582. } else {
  6583. throw Error('Only strings and functions can be passed as "editor" parameter ');
  6584. }
  6585. if (!editor) {
  6586. throw Error('No editor registered under name "' + editorName + '"');
  6587. }
  6588. return editor.getConstructor();
  6589. }
  6590. function hasEditor(editorName) {
  6591. return registeredEditorNames[editorName] ? true : false;
  6592. }
  6593. //#
  6594. },{"./helpers.js":42}],30:[function(require,module,exports){
  6595. "use strict";
  6596. Object.defineProperties(exports, {
  6597. BaseEditor: {get: function() {
  6598. return BaseEditor;
  6599. }},
  6600. __esModule: {value: true}
  6601. });
  6602. var $___46__46__47_helpers_46_js__,
  6603. $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__;
  6604. 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__});
  6605. 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;
  6606. ;
  6607. Handsontable.editors = Handsontable.editors || {};
  6608. Handsontable.editors.BaseEditor = BaseEditor;
  6609. Handsontable.EditorState = {
  6610. VIRGIN: 'STATE_VIRGIN',
  6611. EDITING: 'STATE_EDITING',
  6612. WAITING: 'STATE_WAITING',
  6613. FINISHED: 'STATE_FINISHED'
  6614. };
  6615. function BaseEditor(instance) {
  6616. this.instance = instance;
  6617. this.state = Handsontable.EditorState.VIRGIN;
  6618. this._opened = false;
  6619. this._closeCallback = null;
  6620. this.init();
  6621. }
  6622. BaseEditor.prototype._fireCallbacks = function(result) {
  6623. if (this._closeCallback) {
  6624. this._closeCallback(result);
  6625. this._closeCallback = null;
  6626. }
  6627. };
  6628. BaseEditor.prototype.init = function() {};
  6629. BaseEditor.prototype.getValue = function() {
  6630. throw Error('Editor getValue() method unimplemented');
  6631. };
  6632. BaseEditor.prototype.setValue = function(newValue) {
  6633. throw Error('Editor setValue() method unimplemented');
  6634. };
  6635. BaseEditor.prototype.open = function() {
  6636. throw Error('Editor open() method unimplemented');
  6637. };
  6638. BaseEditor.prototype.close = function() {
  6639. throw Error('Editor close() method unimplemented');
  6640. };
  6641. BaseEditor.prototype.prepare = function(row, col, prop, td, originalValue, cellProperties) {
  6642. this.TD = td;
  6643. this.row = row;
  6644. this.col = col;
  6645. this.prop = prop;
  6646. this.originalValue = originalValue;
  6647. this.cellProperties = cellProperties;
  6648. this.state = Handsontable.EditorState.VIRGIN;
  6649. };
  6650. BaseEditor.prototype.extend = function() {
  6651. var baseClass = this.constructor;
  6652. function Editor() {
  6653. baseClass.apply(this, arguments);
  6654. }
  6655. function inherit(Child, Parent) {
  6656. function Bridge() {}
  6657. Bridge.prototype = Parent.prototype;
  6658. Child.prototype = new Bridge();
  6659. Child.prototype.constructor = Child;
  6660. return Child;
  6661. }
  6662. return inherit(Editor, baseClass);
  6663. };
  6664. BaseEditor.prototype.saveValue = function(val, ctrlDown) {
  6665. var sel,
  6666. tmp;
  6667. if (ctrlDown) {
  6668. sel = this.instance.getSelected();
  6669. if (sel[0] > sel[2]) {
  6670. tmp = sel[0];
  6671. sel[0] = sel[2];
  6672. sel[2] = tmp;
  6673. }
  6674. if (sel[1] > sel[3]) {
  6675. tmp = sel[1];
  6676. sel[1] = sel[3];
  6677. sel[3] = tmp;
  6678. }
  6679. this.instance.populateFromArray(sel[0], sel[1], val, sel[2], sel[3], 'edit');
  6680. } else {
  6681. this.instance.populateFromArray(this.row, this.col, val, null, null, 'edit');
  6682. }
  6683. };
  6684. BaseEditor.prototype.beginEditing = function(initialValue, event) {
  6685. if (this.state != Handsontable.EditorState.VIRGIN) {
  6686. return;
  6687. }
  6688. this.instance.view.scrollViewport(new WalkontableCellCoords(this.row, this.col));
  6689. this.instance.view.render();
  6690. this.state = Handsontable.EditorState.EDITING;
  6691. initialValue = typeof initialValue == 'string' ? initialValue : this.originalValue;
  6692. this.setValue(helper.stringify(initialValue));
  6693. this.open(event);
  6694. this._opened = true;
  6695. this.focus();
  6696. this.instance.view.render();
  6697. };
  6698. BaseEditor.prototype.finishEditing = function(restoreOriginalValue, ctrlDown, callback) {
  6699. var _this = this,
  6700. val;
  6701. if (callback) {
  6702. var previousCloseCallback = this._closeCallback;
  6703. this._closeCallback = function(result) {
  6704. if (previousCloseCallback) {
  6705. previousCloseCallback(result);
  6706. }
  6707. callback(result);
  6708. };
  6709. }
  6710. if (this.isWaiting()) {
  6711. return;
  6712. }
  6713. if (this.state == Handsontable.EditorState.VIRGIN) {
  6714. this.instance._registerTimeout(setTimeout(function() {
  6715. _this._fireCallbacks(true);
  6716. }, 0));
  6717. return;
  6718. }
  6719. if (this.state == Handsontable.EditorState.EDITING) {
  6720. if (restoreOriginalValue) {
  6721. this.cancelChanges();
  6722. this.instance.view.render();
  6723. return;
  6724. }
  6725. if (this.instance.getSettings().trimWhitespace) {
  6726. val = [[typeof this.getValue() === 'string' ? String.prototype.trim.call(this.getValue() || '') : this.getValue()]];
  6727. } else {
  6728. val = [[this.getValue()]];
  6729. }
  6730. this.state = Handsontable.EditorState.WAITING;
  6731. this.saveValue(val, ctrlDown);
  6732. if (this.instance.getCellValidator(this.cellProperties)) {
  6733. this.instance.addHookOnce('postAfterValidate', function(result) {
  6734. _this.state = Handsontable.EditorState.FINISHED;
  6735. _this.discardEditor(result);
  6736. });
  6737. } else {
  6738. this.state = Handsontable.EditorState.FINISHED;
  6739. this.discardEditor(true);
  6740. }
  6741. }
  6742. };
  6743. BaseEditor.prototype.cancelChanges = function() {
  6744. this.state = Handsontable.EditorState.FINISHED;
  6745. this.discardEditor();
  6746. };
  6747. BaseEditor.prototype.discardEditor = function(result) {
  6748. if (this.state !== Handsontable.EditorState.FINISHED) {
  6749. return;
  6750. }
  6751. if (result === false && this.cellProperties.allowInvalid !== true) {
  6752. this.instance.selectCell(this.row, this.col);
  6753. this.focus();
  6754. this.state = Handsontable.EditorState.EDITING;
  6755. this._fireCallbacks(false);
  6756. } else {
  6757. this.close();
  6758. this._opened = false;
  6759. this.state = Handsontable.EditorState.VIRGIN;
  6760. this._fireCallbacks(true);
  6761. }
  6762. };
  6763. BaseEditor.prototype.isOpened = function() {
  6764. return this._opened;
  6765. };
  6766. BaseEditor.prototype.isWaiting = function() {
  6767. return this.state === Handsontable.EditorState.WAITING;
  6768. };
  6769. //#
  6770. },{"./../3rdparty/walkontable/src/cell/coords.js":5,"./../helpers.js":42}],31:[function(require,module,exports){
  6771. "use strict";
  6772. Object.defineProperties(exports, {
  6773. AutocompleteEditor: {get: function() {
  6774. return AutocompleteEditor;
  6775. }},
  6776. __esModule: {value: true}
  6777. });
  6778. var $___46__46__47_helpers_46_js__,
  6779. $___46__46__47_dom_46_js__,
  6780. $___46__46__47_editors_46_js__,
  6781. $__handsontableEditor_46_js__;
  6782. 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__});
  6783. 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__});
  6784. 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__}),
  6785. getEditorConstructor = $__0.getEditorConstructor,
  6786. registerEditor = $__0.registerEditor;
  6787. var HandsontableEditor = ($__handsontableEditor_46_js__ = require("./handsontableEditor.js"), $__handsontableEditor_46_js__ && $__handsontableEditor_46_js__.__esModule && $__handsontableEditor_46_js__ || {default: $__handsontableEditor_46_js__}).HandsontableEditor;
  6788. var AutocompleteEditor = HandsontableEditor.prototype.extend();
  6789. ;
  6790. Handsontable.editors = Handsontable.editors || {};
  6791. Handsontable.editors.AutocompleteEditor = AutocompleteEditor;
  6792. AutocompleteEditor.prototype.init = function() {
  6793. HandsontableEditor.prototype.init.apply(this, arguments);
  6794. this.query = null;
  6795. this.choices = [];
  6796. };
  6797. AutocompleteEditor.prototype.createElements = function() {
  6798. HandsontableEditor.prototype.createElements.apply(this, arguments);
  6799. dom.addClass(this.htContainer, 'autocompleteEditor');
  6800. dom.addClass(this.htContainer, window.navigator.platform.indexOf('Mac') !== -1 ? 'htMacScroll' : '');
  6801. };
  6802. var skipOne = false;
  6803. function onBeforeKeyDown(event) {
  6804. skipOne = false;
  6805. var editor = this.getActiveEditor();
  6806. var keyCodes = helper.keyCode;
  6807. if (helper.isPrintableChar(event.keyCode) || event.keyCode === keyCodes.BACKSPACE || event.keyCode === keyCodes.DELETE || event.keyCode === keyCodes.INSERT) {
  6808. var timeOffset = 0;
  6809. if (event.keyCode === keyCodes.C && (event.ctrlKey || event.metaKey)) {
  6810. return;
  6811. }
  6812. if (!editor.isOpened()) {
  6813. timeOffset += 10;
  6814. }
  6815. editor.instance._registerTimeout(setTimeout(function() {
  6816. editor.queryChoices(editor.TEXTAREA.value);
  6817. skipOne = true;
  6818. }, timeOffset));
  6819. }
  6820. }
  6821. AutocompleteEditor.prototype.prepare = function() {
  6822. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  6823. HandsontableEditor.prototype.prepare.apply(this, arguments);
  6824. };
  6825. AutocompleteEditor.prototype.open = function() {
  6826. HandsontableEditor.prototype.open.apply(this, arguments);
  6827. var choicesListHot = this.htEditor.getInstance();
  6828. var that = this;
  6829. this.TEXTAREA.style.visibility = 'visible';
  6830. this.focus();
  6831. choicesListHot.updateSettings({
  6832. 'colWidths': [dom.outerWidth(this.TEXTAREA) - 2],
  6833. width: dom.outerWidth(this.TEXTAREA) + dom.getScrollbarWidth() + 2,
  6834. afterRenderer: function(TD, row, col, prop, value) {
  6835. var caseSensitive = this.getCellMeta(row, col).filteringCaseSensitive === true,
  6836. indexOfMatch,
  6837. match,
  6838. value = Handsontable.helper.stringify(value);
  6839. if (value) {
  6840. indexOfMatch = caseSensitive ? value.indexOf(this.query) : value.toLowerCase().indexOf(that.query.toLowerCase());
  6841. if (indexOfMatch != -1) {
  6842. match = value.substr(indexOfMatch, that.query.length);
  6843. TD.innerHTML = value.replace(match, '<strong>' + match + '</strong>');
  6844. }
  6845. }
  6846. }
  6847. });
  6848. this.htEditor.view.wt.wtTable.holder.parentNode.style['padding-right'] = dom.getScrollbarWidth() + 2 + 'px';
  6849. if (skipOne) {
  6850. skipOne = false;
  6851. }
  6852. that.instance._registerTimeout(setTimeout(function() {
  6853. that.queryChoices(that.TEXTAREA.value);
  6854. }, 0));
  6855. };
  6856. AutocompleteEditor.prototype.close = function() {
  6857. HandsontableEditor.prototype.close.apply(this, arguments);
  6858. };
  6859. AutocompleteEditor.prototype.queryChoices = function(query) {
  6860. this.query = query;
  6861. if (typeof this.cellProperties.source == 'function') {
  6862. var that = this;
  6863. this.cellProperties.source(query, function(choices) {
  6864. that.updateChoicesList(choices);
  6865. });
  6866. } else if (Array.isArray(this.cellProperties.source)) {
  6867. var choices;
  6868. if (!query || this.cellProperties.filter === false) {
  6869. choices = this.cellProperties.source;
  6870. } else {
  6871. var filteringCaseSensitive = this.cellProperties.filteringCaseSensitive === true;
  6872. var lowerCaseQuery = query.toLowerCase();
  6873. choices = this.cellProperties.source.filter(function(choice) {
  6874. if (filteringCaseSensitive) {
  6875. return choice.indexOf(query) != -1;
  6876. } else {
  6877. return choice.toLowerCase().indexOf(lowerCaseQuery) != -1;
  6878. }
  6879. });
  6880. }
  6881. this.updateChoicesList(choices);
  6882. } else {
  6883. this.updateChoicesList([]);
  6884. }
  6885. };
  6886. AutocompleteEditor.prototype.updateChoicesList = function(choices) {
  6887. var pos = dom.getCaretPosition(this.TEXTAREA),
  6888. endPos = dom.getSelectionEndPosition(this.TEXTAREA);
  6889. var orderByRelevance = AutocompleteEditor.sortByRelevance(this.getValue(), choices, this.cellProperties.filteringCaseSensitive);
  6890. var highlightIndex;
  6891. if (this.cellProperties.filter != false) {
  6892. var sorted = [];
  6893. for (var i = 0,
  6894. choicesCount = orderByRelevance.length; i < choicesCount; i++) {
  6895. sorted.push(choices[orderByRelevance[i]]);
  6896. }
  6897. highlightIndex = 0;
  6898. choices = sorted;
  6899. } else {
  6900. highlightIndex = orderByRelevance[0];
  6901. }
  6902. this.choices = choices;
  6903. this.htEditor.loadData(helper.pivot([choices]));
  6904. this.updateDropdownHeight();
  6905. if (this.cellProperties.strict === true) {
  6906. this.highlightBestMatchingChoice(highlightIndex);
  6907. }
  6908. this.instance.listen();
  6909. this.TEXTAREA.focus();
  6910. dom.setCaretPosition(this.TEXTAREA, pos, (pos != endPos ? endPos : void 0));
  6911. };
  6912. AutocompleteEditor.prototype.updateDropdownHeight = function() {
  6913. this.htEditor.updateSettings({height: this.getDropdownHeight()});
  6914. this.htEditor.view.wt.wtTable.alignOverlaysWithTrimmingContainer();
  6915. };
  6916. AutocompleteEditor.prototype.finishEditing = function(restoreOriginalValue) {
  6917. if (!restoreOriginalValue) {
  6918. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  6919. }
  6920. HandsontableEditor.prototype.finishEditing.apply(this, arguments);
  6921. };
  6922. AutocompleteEditor.prototype.highlightBestMatchingChoice = function(index) {
  6923. if (typeof index === "number") {
  6924. this.htEditor.selectCell(index, 0);
  6925. } else {
  6926. this.htEditor.deselectCell();
  6927. }
  6928. };
  6929. AutocompleteEditor.sortByRelevance = function(value, choices, caseSensitive) {
  6930. var choicesRelevance = [],
  6931. currentItem,
  6932. valueLength = value.length,
  6933. valueIndex,
  6934. charsLeft,
  6935. result = [],
  6936. i,
  6937. choicesCount;
  6938. if (valueLength === 0) {
  6939. for (i = 0, choicesCount = choices.length; i < choicesCount; i++) {
  6940. result.push(i);
  6941. }
  6942. return result;
  6943. }
  6944. for (i = 0, choicesCount = choices.length; i < choicesCount; i++) {
  6945. currentItem = Handsontable.helper.stringify(choices[i]);
  6946. if (caseSensitive) {
  6947. valueIndex = currentItem.indexOf(value);
  6948. } else {
  6949. valueIndex = currentItem.toLowerCase().indexOf(value.toLowerCase());
  6950. }
  6951. if (valueIndex == -1) {
  6952. continue;
  6953. }
  6954. charsLeft = currentItem.length - valueIndex - valueLength;
  6955. choicesRelevance.push({
  6956. baseIndex: i,
  6957. index: valueIndex,
  6958. charsLeft: charsLeft,
  6959. value: currentItem
  6960. });
  6961. }
  6962. choicesRelevance.sort(function(a, b) {
  6963. if (b.index === -1) {
  6964. return -1;
  6965. }
  6966. if (a.index === -1) {
  6967. return 1;
  6968. }
  6969. if (a.index < b.index) {
  6970. return -1;
  6971. } else if (b.index < a.index) {
  6972. return 1;
  6973. } else if (a.index === b.index) {
  6974. if (a.charsLeft < b.charsLeft) {
  6975. return -1;
  6976. } else if (a.charsLeft > b.charsLeft) {
  6977. return 1;
  6978. } else {
  6979. return 0;
  6980. }
  6981. }
  6982. });
  6983. for (i = 0, choicesCount = choicesRelevance.length; i < choicesCount; i++) {
  6984. result.push(choicesRelevance[i].baseIndex);
  6985. }
  6986. return result;
  6987. };
  6988. AutocompleteEditor.prototype.getDropdownHeight = function() {
  6989. var firstRowHeight = this.htEditor.getInstance().getRowHeight(0) || 23;
  6990. return this.choices.length >= 10 ? 10 * firstRowHeight : this.choices.length * firstRowHeight + 8;
  6991. };
  6992. registerEditor('autocomplete', AutocompleteEditor);
  6993. //#
  6994. },{"./../dom.js":27,"./../editors.js":29,"./../helpers.js":42,"./handsontableEditor.js":35}],32:[function(require,module,exports){
  6995. "use strict";
  6996. Object.defineProperties(exports, {
  6997. CheckboxEditor: {get: function() {
  6998. return CheckboxEditor;
  6999. }},
  7000. __esModule: {value: true}
  7001. });
  7002. var $___46__46__47_editors_46_js__,
  7003. $___95_baseEditor_46_js__;
  7004. 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;
  7005. 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;
  7006. var CheckboxEditor = BaseEditor.prototype.extend();
  7007. ;
  7008. Handsontable.editors = Handsontable.editors || {};
  7009. Handsontable.editors.CheckboxEditor = CheckboxEditor;
  7010. CheckboxEditor.prototype.beginEditing = function() {
  7011. var checkbox = this.TD.querySelector('input[type="checkbox"]');
  7012. if (checkbox) {
  7013. checkbox.click();
  7014. }
  7015. };
  7016. CheckboxEditor.prototype.finishEditing = function() {};
  7017. CheckboxEditor.prototype.init = function() {};
  7018. CheckboxEditor.prototype.open = function() {};
  7019. CheckboxEditor.prototype.close = function() {};
  7020. CheckboxEditor.prototype.getValue = function() {};
  7021. CheckboxEditor.prototype.setValue = function() {};
  7022. CheckboxEditor.prototype.focus = function() {};
  7023. registerEditor('checkbox', CheckboxEditor);
  7024. //#
  7025. },{"./../editors.js":29,"./_baseEditor.js":30}],33:[function(require,module,exports){
  7026. "use strict";
  7027. Object.defineProperties(exports, {
  7028. DateEditor: {get: function() {
  7029. return DateEditor;
  7030. }},
  7031. __esModule: {value: true}
  7032. });
  7033. var $___46__46__47_helpers_46_js__,
  7034. $___46__46__47_dom_46_js__,
  7035. $___46__46__47_editors_46_js__,
  7036. $__textEditor_46_js__,
  7037. $___46__46__47_eventManager_46_js__,
  7038. $__moment__,
  7039. $__pikaday__;
  7040. 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__});
  7041. 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__});
  7042. 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__}),
  7043. getEditor = $__0.getEditor,
  7044. registerEditor = $__0.registerEditor;
  7045. var TextEditor = ($__textEditor_46_js__ = require("./textEditor.js"), $__textEditor_46_js__ && $__textEditor_46_js__.__esModule && $__textEditor_46_js__ || {default: $__textEditor_46_js__}).TextEditor;
  7046. 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;
  7047. var moment = ($__moment__ = require("moment"), $__moment__ && $__moment__.__esModule && $__moment__ || {default: $__moment__}).default;
  7048. var Pikaday = ($__pikaday__ = require("pikaday"), $__pikaday__ && $__pikaday__.__esModule && $__pikaday__ || {default: $__pikaday__}).default;
  7049. Handsontable.editors = Handsontable.editors || {};
  7050. Handsontable.editors.DateEditor = DateEditor;
  7051. var DateEditor = function DateEditor(hotInstance) {
  7052. this.$datePicker = null;
  7053. this.datePicker = null;
  7054. this.datePickerStyle = null;
  7055. this.defaultDateFormat = 'DD/MM/YYYY';
  7056. this.isCellEdited = false;
  7057. this.parentDestroyed = false;
  7058. $traceurRuntime.superGet(this, $DateEditor.prototype, "constructor").call(this, hotInstance);
  7059. };
  7060. var $DateEditor = DateEditor;
  7061. ($traceurRuntime.createClass)(DateEditor, {
  7062. init: function() {
  7063. var $__5 = this;
  7064. if (typeof moment !== 'function') {
  7065. throw new Error("You need to include moment.js to your project.");
  7066. }
  7067. if (typeof Pikaday !== 'function') {
  7068. throw new Error("You need to include Pikaday to your project.");
  7069. }
  7070. $traceurRuntime.superGet(this, $DateEditor.prototype, "init").call(this);
  7071. this.instance.addHook('afterDestroy', (function() {
  7072. $__5.parentDestroyed = true;
  7073. $__5.destroyElements();
  7074. }));
  7075. },
  7076. createElements: function() {
  7077. var $__5 = this;
  7078. $traceurRuntime.superGet(this, $DateEditor.prototype, "createElements").call(this);
  7079. this.datePicker = document.createElement('DIV');
  7080. this.datePickerStyle = this.datePicker.style;
  7081. this.datePickerStyle.position = 'absolute';
  7082. this.datePickerStyle.top = 0;
  7083. this.datePickerStyle.left = 0;
  7084. this.datePickerStyle.zIndex = 9999;
  7085. dom.addClass(this.datePicker, 'htDatepickerHolder');
  7086. document.body.appendChild(this.datePicker);
  7087. var htInput = this.TEXTAREA;
  7088. var defaultOptions = {
  7089. format: this.defaultDateFormat,
  7090. field: htInput,
  7091. trigger: htInput,
  7092. container: this.datePicker,
  7093. reposition: false,
  7094. bound: false,
  7095. onSelect: (function(dateStr) {
  7096. if (!isNaN(dateStr.getTime())) {
  7097. dateStr = moment(dateStr).format($__5.cellProperties.dateFormat || $__5.defaultDateFormat);
  7098. }
  7099. $__5.setValue(dateStr);
  7100. $__5.hideDatepicker();
  7101. }),
  7102. onClose: (function() {
  7103. if (!$__5.parentDestroyed) {
  7104. $__5.finishEditing(false);
  7105. }
  7106. })
  7107. };
  7108. this.$datePicker = new Pikaday(defaultOptions);
  7109. var eventManager = eventManagerObject(this);
  7110. eventManager.addEventListener(this.datePicker, 'mousedown', (function(event) {
  7111. helper.stopPropagation(event);
  7112. }));
  7113. this.hideDatepicker();
  7114. },
  7115. destroyElements: function() {
  7116. this.$datePicker.destroy();
  7117. },
  7118. prepare: function(row, col, prop, td, originalValue, cellProperties) {
  7119. this._opened = false;
  7120. $traceurRuntime.superGet(this, $DateEditor.prototype, "prepare").call(this, row, col, prop, td, originalValue, cellProperties);
  7121. },
  7122. open: function() {
  7123. var event = arguments[0] !== (void 0) ? arguments[0] : null;
  7124. $traceurRuntime.superGet(this, $DateEditor.prototype, "open").call(this);
  7125. this.showDatepicker(event);
  7126. },
  7127. close: function() {
  7128. var $__5 = this;
  7129. this._opened = false;
  7130. this.instance._registerTimeout(setTimeout((function() {
  7131. $__5.instance.selection.refreshBorders();
  7132. }), 0));
  7133. $traceurRuntime.superGet(this, $DateEditor.prototype, "close").call(this);
  7134. },
  7135. finishEditing: function() {
  7136. var isCancelled = arguments[0] !== (void 0) ? arguments[0] : false;
  7137. var ctrlDown = arguments[1] !== (void 0) ? arguments[1] : false;
  7138. if (isCancelled) {
  7139. var value = this.originalValue;
  7140. if (value !== void 0) {
  7141. this.setValue(value);
  7142. }
  7143. }
  7144. this.hideDatepicker();
  7145. $traceurRuntime.superGet(this, $DateEditor.prototype, "finishEditing").call(this, isCancelled, ctrlDown);
  7146. },
  7147. showDatepicker: function(event) {
  7148. var offset = this.TD.getBoundingClientRect();
  7149. var dateFormat = this.cellProperties.dateFormat || this.defaultDateFormat;
  7150. var datePickerConfig = this.$datePicker.config();
  7151. var dateStr;
  7152. var isMouseDown = this.instance.view.isMouseDown();
  7153. var isMeta = event ? helper.isMetaKey(event.keyCode) : false;
  7154. this.datePickerStyle.top = (window.pageYOffset + offset.top + dom.outerHeight(this.TD)) + 'px';
  7155. this.datePickerStyle.left = (window.pageXOffset + offset.left) + 'px';
  7156. this.$datePicker._onInputFocus = function() {};
  7157. datePickerConfig.format = dateFormat;
  7158. if (this.originalValue) {
  7159. dateStr = this.originalValue;
  7160. if (moment(dateStr, dateFormat, true).isValid()) {
  7161. this.$datePicker.setMoment(moment(dateStr, dateFormat), true);
  7162. }
  7163. if (!isMeta && !isMouseDown) {
  7164. this.setValue('');
  7165. }
  7166. } else {
  7167. if (this.cellProperties.defaultDate) {
  7168. dateStr = this.cellProperties.defaultDate;
  7169. datePickerConfig.defaultDate = dateStr;
  7170. if (moment(dateStr, dateFormat, true).isValid()) {
  7171. this.$datePicker.setMoment(moment(dateStr, dateFormat), true);
  7172. }
  7173. if (!isMeta && !isMouseDown) {
  7174. this.setValue('');
  7175. }
  7176. } else {
  7177. this.$datePicker.gotoToday();
  7178. }
  7179. }
  7180. this.datePickerStyle.display = 'block';
  7181. this.$datePicker.show();
  7182. },
  7183. hideDatepicker: function() {
  7184. this.datePickerStyle.display = 'none';
  7185. this.$datePicker.hide();
  7186. }
  7187. }, {}, TextEditor);
  7188. ;
  7189. registerEditor('date', DateEditor);
  7190. //#
  7191. },{"./../dom.js":27,"./../editors.js":29,"./../eventManager.js":41,"./../helpers.js":42,"./textEditor.js":40,"moment":"moment","pikaday":"pikaday"}],34:[function(require,module,exports){
  7192. "use strict";
  7193. Object.defineProperties(exports, {
  7194. DropdownEditor: {get: function() {
  7195. return DropdownEditor;
  7196. }},
  7197. __esModule: {value: true}
  7198. });
  7199. var $___46__46__47_editors_46_js__,
  7200. $__autocompleteEditor_46_js__;
  7201. 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__}),
  7202. getEditor = $__0.getEditor,
  7203. registerEditor = $__0.registerEditor;
  7204. var AutocompleteEditor = ($__autocompleteEditor_46_js__ = require("./autocompleteEditor.js"), $__autocompleteEditor_46_js__ && $__autocompleteEditor_46_js__.__esModule && $__autocompleteEditor_46_js__ || {default: $__autocompleteEditor_46_js__}).AutocompleteEditor;
  7205. var DropdownEditor = AutocompleteEditor.prototype.extend();
  7206. ;
  7207. Handsontable.editors = Handsontable.editors || {};
  7208. Handsontable.editors.DropdownEditor = DropdownEditor;
  7209. DropdownEditor.prototype.prepare = function() {
  7210. AutocompleteEditor.prototype.prepare.apply(this, arguments);
  7211. this.cellProperties.filter = false;
  7212. this.cellProperties.strict = true;
  7213. };
  7214. registerEditor('dropdown', DropdownEditor);
  7215. //#
  7216. },{"./../editors.js":29,"./autocompleteEditor.js":31}],35:[function(require,module,exports){
  7217. "use strict";
  7218. Object.defineProperties(exports, {
  7219. HandsontableEditor: {get: function() {
  7220. return HandsontableEditor;
  7221. }},
  7222. __esModule: {value: true}
  7223. });
  7224. var $___46__46__47_helpers_46_js__,
  7225. $___46__46__47_dom_46_js__,
  7226. $___46__46__47_editors_46_js__,
  7227. $__textEditor_46_js__;
  7228. 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__});
  7229. 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__});
  7230. 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__}),
  7231. getEditor = $__0.getEditor,
  7232. registerEditor = $__0.registerEditor;
  7233. var TextEditor = ($__textEditor_46_js__ = require("./textEditor.js"), $__textEditor_46_js__ && $__textEditor_46_js__.__esModule && $__textEditor_46_js__ || {default: $__textEditor_46_js__}).TextEditor;
  7234. var HandsontableEditor = TextEditor.prototype.extend();
  7235. ;
  7236. Handsontable.editors = Handsontable.editors || {};
  7237. Handsontable.editors.HandsontableEditor = HandsontableEditor;
  7238. HandsontableEditor.prototype.createElements = function() {
  7239. TextEditor.prototype.createElements.apply(this, arguments);
  7240. var DIV = document.createElement('DIV');
  7241. DIV.className = 'handsontableEditor';
  7242. this.TEXTAREA_PARENT.appendChild(DIV);
  7243. this.htContainer = DIV;
  7244. this.htEditor = new Handsontable(DIV);
  7245. this.assignHooks();
  7246. };
  7247. HandsontableEditor.prototype.prepare = function(td, row, col, prop, value, cellProperties) {
  7248. TextEditor.prototype.prepare.apply(this, arguments);
  7249. var parent = this;
  7250. var options = {
  7251. startRows: 0,
  7252. startCols: 0,
  7253. minRows: 0,
  7254. minCols: 0,
  7255. className: 'listbox',
  7256. copyPaste: false,
  7257. cells: function() {
  7258. return {readOnly: true};
  7259. },
  7260. fillHandle: false,
  7261. afterOnCellMouseDown: function() {
  7262. var value = this.getValue();
  7263. if (value !== void 0) {
  7264. parent.setValue(value);
  7265. }
  7266. parent.instance.destroyEditor();
  7267. }
  7268. };
  7269. if (this.cellProperties.handsontable) {
  7270. helper.extend(options, cellProperties.handsontable);
  7271. }
  7272. if (this.htEditor) {
  7273. this.htEditor.destroy();
  7274. }
  7275. this.htEditor = new Handsontable(this.htContainer, options);
  7276. };
  7277. var onBeforeKeyDown = function(event) {
  7278. if (event != null && event.isImmediatePropagationEnabled == null) {
  7279. event.stopImmediatePropagation = function() {
  7280. this.isImmediatePropagationEnabled = false;
  7281. this.cancelBubble = true;
  7282. };
  7283. event.isImmediatePropagationEnabled = true;
  7284. event.isImmediatePropagationStopped = function() {
  7285. return !this.isImmediatePropagationEnabled;
  7286. };
  7287. }
  7288. if (event.isImmediatePropagationStopped()) {
  7289. return;
  7290. }
  7291. var editor = this.getActiveEditor();
  7292. var innerHOT = editor.htEditor.getInstance();
  7293. var rowToSelect;
  7294. if (event.keyCode == helper.keyCode.ARROW_DOWN) {
  7295. if (!innerHOT.getSelected()) {
  7296. rowToSelect = 0;
  7297. } else {
  7298. var selectedRow = innerHOT.getSelected()[0];
  7299. var lastRow = innerHOT.countRows() - 1;
  7300. rowToSelect = Math.min(lastRow, selectedRow + 1);
  7301. }
  7302. } else if (event.keyCode == helper.keyCode.ARROW_UP) {
  7303. if (innerHOT.getSelected()) {
  7304. var selectedRow = innerHOT.getSelected()[0];
  7305. rowToSelect = selectedRow - 1;
  7306. }
  7307. }
  7308. if (rowToSelect !== void 0) {
  7309. if (rowToSelect < 0) {
  7310. innerHOT.deselectCell();
  7311. } else {
  7312. innerHOT.selectCell(rowToSelect, 0);
  7313. }
  7314. event.preventDefault();
  7315. event.stopImmediatePropagation();
  7316. editor.instance.listen();
  7317. editor.TEXTAREA.focus();
  7318. }
  7319. };
  7320. HandsontableEditor.prototype.open = function() {
  7321. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  7322. TextEditor.prototype.open.apply(this, arguments);
  7323. this.htEditor.render();
  7324. if (this.cellProperties.strict) {
  7325. this.htEditor.selectCell(0, 0);
  7326. this.TEXTAREA.style.visibility = 'hidden';
  7327. } else {
  7328. this.htEditor.deselectCell();
  7329. this.TEXTAREA.style.visibility = 'visible';
  7330. }
  7331. dom.setCaretPosition(this.TEXTAREA, 0, this.TEXTAREA.value.length);
  7332. };
  7333. HandsontableEditor.prototype.close = function() {
  7334. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  7335. this.instance.listen();
  7336. TextEditor.prototype.close.apply(this, arguments);
  7337. };
  7338. HandsontableEditor.prototype.focus = function() {
  7339. this.instance.listen();
  7340. TextEditor.prototype.focus.apply(this, arguments);
  7341. };
  7342. HandsontableEditor.prototype.beginEditing = function(initialValue) {
  7343. var onBeginEditing = this.instance.getSettings().onBeginEditing;
  7344. if (onBeginEditing && onBeginEditing() === false) {
  7345. return;
  7346. }
  7347. TextEditor.prototype.beginEditing.apply(this, arguments);
  7348. };
  7349. HandsontableEditor.prototype.finishEditing = function(isCancelled, ctrlDown) {
  7350. if (this.htEditor.isListening()) {
  7351. this.instance.listen();
  7352. }
  7353. if (this.htEditor.getSelected()) {
  7354. var value = this.htEditor.getInstance().getValue();
  7355. if (value !== void 0) {
  7356. this.setValue(value);
  7357. }
  7358. }
  7359. return TextEditor.prototype.finishEditing.apply(this, arguments);
  7360. };
  7361. HandsontableEditor.prototype.assignHooks = function() {
  7362. var _this = this;
  7363. this.instance.addHook('afterDestroy', function() {
  7364. if (_this.htEditor) {
  7365. _this.htEditor.destroy();
  7366. }
  7367. });
  7368. };
  7369. registerEditor('handsontable', HandsontableEditor);
  7370. //#
  7371. },{"./../dom.js":27,"./../editors.js":29,"./../helpers.js":42,"./textEditor.js":40}],36:[function(require,module,exports){
  7372. "use strict";
  7373. Object.defineProperties(exports, {
  7374. MobileTextEditor: {get: function() {
  7375. return MobileTextEditor;
  7376. }},
  7377. __esModule: {value: true}
  7378. });
  7379. var $___46__46__47_helpers_46_js__,
  7380. $___46__46__47_dom_46_js__,
  7381. $___46__46__47_editors_46_js__,
  7382. $___95_baseEditor_46_js__,
  7383. $___46__46__47_eventManager_46_js__;
  7384. 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__});
  7385. 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__});
  7386. 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__}),
  7387. getEditor = $__0.getEditor,
  7388. registerEditor = $__0.registerEditor;
  7389. 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;
  7390. 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;
  7391. var MobileTextEditor = BaseEditor.prototype.extend(),
  7392. domDimensionsCache = {};
  7393. ;
  7394. Handsontable.editors = Handsontable.editors || {};
  7395. Handsontable.editors.MobileTextEditor = MobileTextEditor;
  7396. var createControls = function() {
  7397. this.controls = {};
  7398. this.controls.leftButton = document.createElement('DIV');
  7399. this.controls.leftButton.className = 'leftButton';
  7400. this.controls.rightButton = document.createElement('DIV');
  7401. this.controls.rightButton.className = 'rightButton';
  7402. this.controls.upButton = document.createElement('DIV');
  7403. this.controls.upButton.className = 'upButton';
  7404. this.controls.downButton = document.createElement('DIV');
  7405. this.controls.downButton.className = 'downButton';
  7406. for (var button in this.controls) {
  7407. if (this.controls.hasOwnProperty(button)) {
  7408. this.positionControls.appendChild(this.controls[button]);
  7409. }
  7410. }
  7411. };
  7412. MobileTextEditor.prototype.valueChanged = function() {
  7413. return this.initValue != this.getValue();
  7414. };
  7415. MobileTextEditor.prototype.init = function() {
  7416. var that = this;
  7417. this.eventManager = eventManagerObject(this.instance);
  7418. this.createElements();
  7419. this.bindEvents();
  7420. this.instance.addHook('afterDestroy', function() {
  7421. that.destroy();
  7422. });
  7423. };
  7424. MobileTextEditor.prototype.getValue = function() {
  7425. return this.TEXTAREA.value;
  7426. };
  7427. MobileTextEditor.prototype.setValue = function(newValue) {
  7428. this.initValue = newValue;
  7429. this.TEXTAREA.value = newValue;
  7430. };
  7431. MobileTextEditor.prototype.createElements = function() {
  7432. this.editorContainer = document.createElement('DIV');
  7433. this.editorContainer.className = "htMobileEditorContainer";
  7434. this.cellPointer = document.createElement('DIV');
  7435. this.cellPointer.className = "cellPointer";
  7436. this.moveHandle = document.createElement('DIV');
  7437. this.moveHandle.className = "moveHandle";
  7438. this.inputPane = document.createElement('DIV');
  7439. this.inputPane.className = "inputs";
  7440. this.positionControls = document.createElement('DIV');
  7441. this.positionControls.className = "positionControls";
  7442. this.TEXTAREA = document.createElement('TEXTAREA');
  7443. dom.addClass(this.TEXTAREA, 'handsontableInput');
  7444. this.inputPane.appendChild(this.TEXTAREA);
  7445. this.editorContainer.appendChild(this.cellPointer);
  7446. this.editorContainer.appendChild(this.moveHandle);
  7447. this.editorContainer.appendChild(this.inputPane);
  7448. this.editorContainer.appendChild(this.positionControls);
  7449. createControls.call(this);
  7450. document.body.appendChild(this.editorContainer);
  7451. };
  7452. MobileTextEditor.prototype.onBeforeKeyDown = function(event) {
  7453. var instance = this;
  7454. var that = instance.getActiveEditor();
  7455. dom.enableImmediatePropagation(event);
  7456. if (event.target !== that.TEXTAREA || event.isImmediatePropagationStopped()) {
  7457. return;
  7458. }
  7459. var keyCodes = helper.keyCode;
  7460. switch (event.keyCode) {
  7461. case keyCodes.ENTER:
  7462. that.close();
  7463. event.preventDefault();
  7464. break;
  7465. case keyCodes.BACKSPACE:
  7466. event.stopImmediatePropagation();
  7467. break;
  7468. }
  7469. };
  7470. MobileTextEditor.prototype.open = function() {
  7471. this.instance.addHook('beforeKeyDown', this.onBeforeKeyDown);
  7472. dom.addClass(this.editorContainer, 'active');
  7473. dom.removeClass(this.cellPointer, 'hidden');
  7474. this.updateEditorPosition();
  7475. };
  7476. MobileTextEditor.prototype.focus = function() {
  7477. this.TEXTAREA.focus();
  7478. dom.setCaretPosition(this.TEXTAREA, this.TEXTAREA.value.length);
  7479. };
  7480. MobileTextEditor.prototype.close = function() {
  7481. this.TEXTAREA.blur();
  7482. this.instance.removeHook('beforeKeyDown', this.onBeforeKeyDown);
  7483. dom.removeClass(this.editorContainer, 'active');
  7484. };
  7485. MobileTextEditor.prototype.scrollToView = function() {
  7486. var coords = this.instance.getSelectedRange().highlight;
  7487. this.instance.view.scrollViewport(coords);
  7488. };
  7489. MobileTextEditor.prototype.hideCellPointer = function() {
  7490. if (!dom.hasClass(this.cellPointer, 'hidden')) {
  7491. dom.addClass(this.cellPointer, 'hidden');
  7492. }
  7493. };
  7494. MobileTextEditor.prototype.updateEditorPosition = function(x, y) {
  7495. if (x && y) {
  7496. x = parseInt(x, 10);
  7497. y = parseInt(y, 10);
  7498. this.editorContainer.style.top = y + "px";
  7499. this.editorContainer.style.left = x + "px";
  7500. } else {
  7501. var selection = this.instance.getSelected(),
  7502. selectedCell = this.instance.getCell(selection[0], selection[1]);
  7503. if (!domDimensionsCache.cellPointer) {
  7504. domDimensionsCache.cellPointer = {
  7505. height: dom.outerHeight(this.cellPointer),
  7506. width: dom.outerWidth(this.cellPointer)
  7507. };
  7508. }
  7509. if (!domDimensionsCache.editorContainer) {
  7510. domDimensionsCache.editorContainer = {width: dom.outerWidth(this.editorContainer)};
  7511. }
  7512. if (selectedCell !== undefined) {
  7513. var scrollLeft = this.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer == window ? 0 : dom.getScrollLeft(this.instance.view.wt.wtOverlays.leftOverlay.holder);
  7514. var scrollTop = this.instance.view.wt.wtOverlays.topOverlay.trimmingContainer == window ? 0 : dom.getScrollTop(this.instance.view.wt.wtOverlays.topOverlay.holder);
  7515. var selectedCellOffset = dom.offset(selectedCell),
  7516. selectedCellWidth = dom.outerWidth(selectedCell),
  7517. currentScrollPosition = {
  7518. x: scrollLeft,
  7519. y: scrollTop
  7520. };
  7521. this.editorContainer.style.top = parseInt(selectedCellOffset.top + dom.outerHeight(selectedCell) - currentScrollPosition.y + domDimensionsCache.cellPointer.height, 10) + "px";
  7522. this.editorContainer.style.left = parseInt((window.innerWidth / 2) - (domDimensionsCache.editorContainer.width / 2), 10) + "px";
  7523. if (selectedCellOffset.left + selectedCellWidth / 2 > parseInt(this.editorContainer.style.left, 10) + domDimensionsCache.editorContainer.width) {
  7524. this.editorContainer.style.left = window.innerWidth - domDimensionsCache.editorContainer.width + "px";
  7525. } else if (selectedCellOffset.left + selectedCellWidth / 2 < parseInt(this.editorContainer.style.left, 10) + 20) {
  7526. this.editorContainer.style.left = 0 + "px";
  7527. }
  7528. this.cellPointer.style.left = parseInt(selectedCellOffset.left - (domDimensionsCache.cellPointer.width / 2) - dom.offset(this.editorContainer).left + (selectedCellWidth / 2) - currentScrollPosition.x, 10) + "px";
  7529. }
  7530. }
  7531. };
  7532. MobileTextEditor.prototype.updateEditorData = function() {
  7533. var selected = this.instance.getSelected(),
  7534. selectedValue = this.instance.getDataAtCell(selected[0], selected[1]);
  7535. this.row = selected[0];
  7536. this.col = selected[1];
  7537. this.setValue(selectedValue);
  7538. this.updateEditorPosition();
  7539. };
  7540. MobileTextEditor.prototype.prepareAndSave = function() {
  7541. var val;
  7542. if (!this.valueChanged()) {
  7543. return true;
  7544. }
  7545. if (this.instance.getSettings().trimWhitespace) {
  7546. val = [[String.prototype.trim.call(this.getValue())]];
  7547. } else {
  7548. val = [[this.getValue()]];
  7549. }
  7550. this.saveValue(val);
  7551. };
  7552. MobileTextEditor.prototype.bindEvents = function() {
  7553. var that = this;
  7554. this.eventManager.addEventListener(this.controls.leftButton, "touchend", function(event) {
  7555. that.prepareAndSave();
  7556. that.instance.selection.transformStart(0, -1, null, true);
  7557. that.updateEditorData();
  7558. event.preventDefault();
  7559. });
  7560. this.eventManager.addEventListener(this.controls.rightButton, "touchend", function(event) {
  7561. that.prepareAndSave();
  7562. that.instance.selection.transformStart(0, 1, null, true);
  7563. that.updateEditorData();
  7564. event.preventDefault();
  7565. });
  7566. this.eventManager.addEventListener(this.controls.upButton, "touchend", function(event) {
  7567. that.prepareAndSave();
  7568. that.instance.selection.transformStart(-1, 0, null, true);
  7569. that.updateEditorData();
  7570. event.preventDefault();
  7571. });
  7572. this.eventManager.addEventListener(this.controls.downButton, "touchend", function(event) {
  7573. that.prepareAndSave();
  7574. that.instance.selection.transformStart(1, 0, null, true);
  7575. that.updateEditorData();
  7576. event.preventDefault();
  7577. });
  7578. this.eventManager.addEventListener(this.moveHandle, "touchstart", function(event) {
  7579. if (event.touches.length == 1) {
  7580. var touch = event.touches[0],
  7581. onTouchPosition = {
  7582. x: that.editorContainer.offsetLeft,
  7583. y: that.editorContainer.offsetTop
  7584. },
  7585. onTouchOffset = {
  7586. x: touch.pageX - onTouchPosition.x,
  7587. y: touch.pageY - onTouchPosition.y
  7588. };
  7589. that.eventManager.addEventListener(this, "touchmove", function(event) {
  7590. var touch = event.touches[0];
  7591. that.updateEditorPosition(touch.pageX - onTouchOffset.x, touch.pageY - onTouchOffset.y);
  7592. that.hideCellPointer();
  7593. event.preventDefault();
  7594. });
  7595. }
  7596. });
  7597. this.eventManager.addEventListener(document.body, "touchend", function(event) {
  7598. if (!dom.isChildOf(event.target, that.editorContainer) && !dom.isChildOf(event.target, that.instance.rootElement)) {
  7599. that.close();
  7600. }
  7601. });
  7602. this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.leftOverlay.holder, "scroll", function(event) {
  7603. if (that.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer != window) {
  7604. that.hideCellPointer();
  7605. }
  7606. });
  7607. this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.topOverlay.holder, "scroll", function(event) {
  7608. if (that.instance.view.wt.wtOverlays.topOverlay.trimmingContainer != window) {
  7609. that.hideCellPointer();
  7610. }
  7611. });
  7612. };
  7613. MobileTextEditor.prototype.destroy = function() {
  7614. this.eventManager.clear();
  7615. this.editorContainer.parentNode.removeChild(this.editorContainer);
  7616. };
  7617. registerEditor('mobile', MobileTextEditor);
  7618. //#
  7619. },{"./../dom.js":27,"./../editors.js":29,"./../eventManager.js":41,"./../helpers.js":42,"./_baseEditor.js":30}],37:[function(require,module,exports){
  7620. "use strict";
  7621. Object.defineProperties(exports, {
  7622. NumericEditor: {get: function() {
  7623. return NumericEditor;
  7624. }},
  7625. __esModule: {value: true}
  7626. });
  7627. var $__numeral__,
  7628. $___46__46__47_editors_46_js__,
  7629. $__textEditor_46_js__;
  7630. var numeral = ($__numeral__ = require("numeral"), $__numeral__ && $__numeral__.__esModule && $__numeral__ || {default: $__numeral__}).default;
  7631. 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__}),
  7632. getEditor = $__1.getEditor,
  7633. registerEditor = $__1.registerEditor;
  7634. var TextEditor = ($__textEditor_46_js__ = require("./textEditor.js"), $__textEditor_46_js__ && $__textEditor_46_js__.__esModule && $__textEditor_46_js__ || {default: $__textEditor_46_js__}).TextEditor;
  7635. Handsontable.editors = Handsontable.editors || {};
  7636. Handsontable.editors.NumericEditor = NumericEditor;
  7637. var NumericEditor = function NumericEditor() {
  7638. $traceurRuntime.superConstructor($NumericEditor).apply(this, arguments);
  7639. };
  7640. var $NumericEditor = NumericEditor;
  7641. ($traceurRuntime.createClass)(NumericEditor, {beginEditing: function(initialValue) {
  7642. if (typeof(initialValue) === 'undefined' && this.originalValue) {
  7643. if (typeof this.cellProperties.language !== 'undefined') {
  7644. numeral.language(this.cellProperties.language);
  7645. }
  7646. var decimalDelimiter = numeral.languageData().delimiters.decimal;
  7647. initialValue = ('' + this.originalValue).replace('.', decimalDelimiter);
  7648. }
  7649. $traceurRuntime.superGet(this, $NumericEditor.prototype, "beginEditing").call(this, initialValue);
  7650. }}, {}, TextEditor);
  7651. ;
  7652. registerEditor('numeric', NumericEditor);
  7653. //#
  7654. },{"./../editors.js":29,"./textEditor.js":40,"numeral":"numeral"}],38:[function(require,module,exports){
  7655. "use strict";
  7656. Object.defineProperties(exports, {
  7657. PasswordEditor: {get: function() {
  7658. return PasswordEditor;
  7659. }},
  7660. __esModule: {value: true}
  7661. });
  7662. var $___46__46__47_dom_46_js__,
  7663. $___46__46__47_editors_46_js__,
  7664. $__textEditor_46_js__;
  7665. 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__});
  7666. 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__}),
  7667. getEditor = $__0.getEditor,
  7668. registerEditor = $__0.registerEditor;
  7669. var TextEditor = ($__textEditor_46_js__ = require("./textEditor.js"), $__textEditor_46_js__ && $__textEditor_46_js__.__esModule && $__textEditor_46_js__ || {default: $__textEditor_46_js__}).TextEditor;
  7670. var PasswordEditor = TextEditor.prototype.extend();
  7671. ;
  7672. Handsontable.editors = Handsontable.editors || {};
  7673. Handsontable.editors.PasswordEditor = PasswordEditor;
  7674. PasswordEditor.prototype.createElements = function() {
  7675. TextEditor.prototype.createElements.apply(this, arguments);
  7676. this.TEXTAREA = document.createElement('input');
  7677. this.TEXTAREA.setAttribute('type', 'password');
  7678. this.TEXTAREA.className = 'handsontableInput';
  7679. this.textareaStyle = this.TEXTAREA.style;
  7680. this.textareaStyle.width = 0;
  7681. this.textareaStyle.height = 0;
  7682. dom.empty(this.TEXTAREA_PARENT);
  7683. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  7684. };
  7685. registerEditor('password', PasswordEditor);
  7686. //#
  7687. },{"./../dom.js":27,"./../editors.js":29,"./textEditor.js":40}],39:[function(require,module,exports){
  7688. "use strict";
  7689. Object.defineProperties(exports, {
  7690. SelectEditor: {get: function() {
  7691. return SelectEditor;
  7692. }},
  7693. __esModule: {value: true}
  7694. });
  7695. var $___46__46__47_dom_46_js__,
  7696. $___46__46__47_helpers_46_js__,
  7697. $___46__46__47_editors_46_js__,
  7698. $___95_baseEditor_46_js__;
  7699. 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__});
  7700. 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__});
  7701. 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__}),
  7702. getEditor = $__0.getEditor,
  7703. registerEditor = $__0.registerEditor;
  7704. 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;
  7705. var SelectEditor = BaseEditor.prototype.extend();
  7706. ;
  7707. Handsontable.editors = Handsontable.editors || {};
  7708. Handsontable.editors.SelectEditor = SelectEditor;
  7709. SelectEditor.prototype.init = function() {
  7710. this.select = document.createElement('SELECT');
  7711. dom.addClass(this.select, 'htSelectEditor');
  7712. this.select.style.display = 'none';
  7713. this.instance.rootElement.appendChild(this.select);
  7714. };
  7715. SelectEditor.prototype.prepare = function() {
  7716. BaseEditor.prototype.prepare.apply(this, arguments);
  7717. var selectOptions = this.cellProperties.selectOptions;
  7718. var options;
  7719. if (typeof selectOptions == 'function') {
  7720. options = this.prepareOptions(selectOptions(this.row, this.col, this.prop));
  7721. } else {
  7722. options = this.prepareOptions(selectOptions);
  7723. }
  7724. dom.empty(this.select);
  7725. for (var option in options) {
  7726. if (options.hasOwnProperty(option)) {
  7727. var optionElement = document.createElement('OPTION');
  7728. optionElement.value = option;
  7729. dom.fastInnerHTML(optionElement, options[option]);
  7730. this.select.appendChild(optionElement);
  7731. }
  7732. }
  7733. };
  7734. SelectEditor.prototype.prepareOptions = function(optionsToPrepare) {
  7735. var preparedOptions = {};
  7736. if (Array.isArray(optionsToPrepare)) {
  7737. for (var i = 0,
  7738. len = optionsToPrepare.length; i < len; i++) {
  7739. preparedOptions[optionsToPrepare[i]] = optionsToPrepare[i];
  7740. }
  7741. } else if (typeof optionsToPrepare == 'object') {
  7742. preparedOptions = optionsToPrepare;
  7743. }
  7744. return preparedOptions;
  7745. };
  7746. SelectEditor.prototype.getValue = function() {
  7747. return this.select.value;
  7748. };
  7749. SelectEditor.prototype.setValue = function(value) {
  7750. this.select.value = value;
  7751. };
  7752. var onBeforeKeyDown = function(event) {
  7753. var instance = this;
  7754. var editor = instance.getActiveEditor();
  7755. if (event != null && event.isImmediatePropagationEnabled == null) {
  7756. event.stopImmediatePropagation = function() {
  7757. this.isImmediatePropagationEnabled = false;
  7758. };
  7759. event.isImmediatePropagationEnabled = true;
  7760. event.isImmediatePropagationStopped = function() {
  7761. return !this.isImmediatePropagationEnabled;
  7762. };
  7763. }
  7764. switch (event.keyCode) {
  7765. case helper.keyCode.ARROW_UP:
  7766. var previousOptionIndex = editor.select.selectedIndex - 1;
  7767. if (previousOptionIndex >= 0) {
  7768. editor.select[previousOptionIndex].selected = true;
  7769. }
  7770. event.stopImmediatePropagation();
  7771. event.preventDefault();
  7772. break;
  7773. case helper.keyCode.ARROW_DOWN:
  7774. var nextOptionIndex = editor.select.selectedIndex + 1;
  7775. if (nextOptionIndex <= editor.select.length - 1) {
  7776. editor.select[nextOptionIndex].selected = true;
  7777. }
  7778. event.stopImmediatePropagation();
  7779. event.preventDefault();
  7780. break;
  7781. }
  7782. };
  7783. SelectEditor.prototype.checkEditorSection = function() {
  7784. if (this.row < this.instance.getSettings().fixedRowsTop) {
  7785. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  7786. return 'corner';
  7787. } else {
  7788. return 'top';
  7789. }
  7790. } else {
  7791. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  7792. return 'left';
  7793. }
  7794. }
  7795. };
  7796. SelectEditor.prototype.open = function() {
  7797. var width = dom.outerWidth(this.TD);
  7798. var height = dom.outerHeight(this.TD);
  7799. var rootOffset = dom.offset(this.instance.rootElement);
  7800. var tdOffset = dom.offset(this.TD);
  7801. var editorSection = this.checkEditorSection();
  7802. var cssTransformOffset;
  7803. switch (editorSection) {
  7804. case 'top':
  7805. cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  7806. break;
  7807. case 'left':
  7808. cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  7809. break;
  7810. case 'corner':
  7811. cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  7812. break;
  7813. }
  7814. var selectStyle = this.select.style;
  7815. if (cssTransformOffset && cssTransformOffset != -1) {
  7816. selectStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  7817. } else {
  7818. dom.resetCssTransform(this.select);
  7819. }
  7820. selectStyle.height = height + 'px';
  7821. selectStyle.minWidth = width + 'px';
  7822. selectStyle.top = tdOffset.top - rootOffset.top + 'px';
  7823. selectStyle.left = tdOffset.left - rootOffset.left + 'px';
  7824. selectStyle.margin = '0px';
  7825. selectStyle.display = '';
  7826. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  7827. };
  7828. SelectEditor.prototype.close = function() {
  7829. this.select.style.display = 'none';
  7830. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  7831. };
  7832. SelectEditor.prototype.focus = function() {
  7833. this.select.focus();
  7834. };
  7835. registerEditor('select', SelectEditor);
  7836. //#
  7837. },{"./../dom.js":27,"./../editors.js":29,"./../helpers.js":42,"./_baseEditor.js":30}],40:[function(require,module,exports){
  7838. "use strict";
  7839. Object.defineProperties(exports, {
  7840. TextEditor: {get: function() {
  7841. return TextEditor;
  7842. }},
  7843. __esModule: {value: true}
  7844. });
  7845. var $___46__46__47_dom_46_js__,
  7846. $___46__46__47_helpers_46_js__,
  7847. $__autoResize__,
  7848. $___95_baseEditor_46_js__,
  7849. $___46__46__47_eventManager_46_js__,
  7850. $___46__46__47_editors_46_js__;
  7851. 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__});
  7852. 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__});
  7853. var autoResize = ($__autoResize__ = require("autoResize"), $__autoResize__ && $__autoResize__.__esModule && $__autoResize__ || {default: $__autoResize__}).default;
  7854. 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;
  7855. 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;
  7856. 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__}),
  7857. getEditor = $__3.getEditor,
  7858. registerEditor = $__3.registerEditor;
  7859. var TextEditor = BaseEditor.prototype.extend();
  7860. ;
  7861. Handsontable.editors = Handsontable.editors || {};
  7862. Handsontable.editors.TextEditor = TextEditor;
  7863. TextEditor.prototype.init = function() {
  7864. var that = this;
  7865. this.createElements();
  7866. this.eventManager = eventManagerObject(this);
  7867. this.bindEvents();
  7868. this.autoResize = autoResize();
  7869. this.instance.addHook('afterDestroy', function() {
  7870. that.destroy();
  7871. });
  7872. };
  7873. TextEditor.prototype.getValue = function() {
  7874. return this.TEXTAREA.value;
  7875. };
  7876. TextEditor.prototype.setValue = function(newValue) {
  7877. this.TEXTAREA.value = newValue;
  7878. };
  7879. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  7880. var instance = this,
  7881. that = instance.getActiveEditor(),
  7882. keyCodes,
  7883. ctrlDown;
  7884. keyCodes = helper.keyCode;
  7885. ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  7886. dom.enableImmediatePropagation(event);
  7887. if (event.target !== that.TEXTAREA || event.isImmediatePropagationStopped()) {
  7888. return;
  7889. }
  7890. if (event.keyCode === 17 || event.keyCode === 224 || event.keyCode === 91 || event.keyCode === 93) {
  7891. event.stopImmediatePropagation();
  7892. return;
  7893. }
  7894. switch (event.keyCode) {
  7895. case keyCodes.ARROW_RIGHT:
  7896. case keyCodes.ARROW_LEFT:
  7897. case keyCodes.ARROW_UP:
  7898. case keyCodes.ARROW_DOWN:
  7899. if (!that.isWaiting()) {
  7900. event.stopImmediatePropagation();
  7901. }
  7902. break;
  7903. case keyCodes.ENTER:
  7904. var selected = that.instance.getSelected();
  7905. var isMultipleSelection = !(selected[0] === selected[2] && selected[1] === selected[3]);
  7906. if ((ctrlDown && !isMultipleSelection) || event.altKey) {
  7907. if (that.isOpened()) {
  7908. var caretPosition = dom.getCaretPosition(that.TEXTAREA),
  7909. value = that.getValue();
  7910. var newValue = value.slice(0, caretPosition) + '\n' + value.slice(caretPosition);
  7911. that.setValue(newValue);
  7912. dom.setCaretPosition(that.TEXTAREA, caretPosition + 1);
  7913. } else {
  7914. that.beginEditing(that.originalValue + '\n');
  7915. }
  7916. event.stopImmediatePropagation();
  7917. }
  7918. event.preventDefault();
  7919. break;
  7920. case keyCodes.A:
  7921. case keyCodes.X:
  7922. case keyCodes.C:
  7923. case keyCodes.V:
  7924. if (ctrlDown) {
  7925. event.stopImmediatePropagation();
  7926. }
  7927. break;
  7928. case keyCodes.BACKSPACE:
  7929. case keyCodes.DELETE:
  7930. case keyCodes.HOME:
  7931. case keyCodes.END:
  7932. event.stopImmediatePropagation();
  7933. break;
  7934. }
  7935. that.autoResize.resize(String.fromCharCode(event.keyCode));
  7936. };
  7937. TextEditor.prototype.open = function() {
  7938. this.refreshDimensions();
  7939. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  7940. };
  7941. TextEditor.prototype.close = function() {
  7942. this.textareaParentStyle.display = 'none';
  7943. this.autoResize.unObserve();
  7944. if (document.activeElement === this.TEXTAREA) {
  7945. this.instance.listen();
  7946. }
  7947. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  7948. };
  7949. TextEditor.prototype.focus = function() {
  7950. this.TEXTAREA.focus();
  7951. dom.setCaretPosition(this.TEXTAREA, this.TEXTAREA.value.length);
  7952. };
  7953. TextEditor.prototype.createElements = function() {
  7954. this.TEXTAREA = document.createElement('TEXTAREA');
  7955. dom.addClass(this.TEXTAREA, 'handsontableInput');
  7956. this.textareaStyle = this.TEXTAREA.style;
  7957. this.textareaStyle.width = 0;
  7958. this.textareaStyle.height = 0;
  7959. this.TEXTAREA_PARENT = document.createElement('DIV');
  7960. dom.addClass(this.TEXTAREA_PARENT, 'handsontableInputHolder');
  7961. this.textareaParentStyle = this.TEXTAREA_PARENT.style;
  7962. this.textareaParentStyle.top = 0;
  7963. this.textareaParentStyle.left = 0;
  7964. this.textareaParentStyle.display = 'none';
  7965. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  7966. this.instance.rootElement.appendChild(this.TEXTAREA_PARENT);
  7967. var that = this;
  7968. this.instance._registerTimeout(setTimeout(function() {
  7969. that.refreshDimensions();
  7970. }, 0));
  7971. };
  7972. TextEditor.prototype.checkEditorSection = function() {
  7973. if (this.row < this.instance.getSettings().fixedRowsTop) {
  7974. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  7975. return 'corner';
  7976. } else {
  7977. return 'top';
  7978. }
  7979. } else {
  7980. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  7981. return 'left';
  7982. }
  7983. }
  7984. };
  7985. TextEditor.prototype.getEditedCell = function() {
  7986. var editorSection = this.checkEditorSection(),
  7987. editedCell;
  7988. switch (editorSection) {
  7989. case 'top':
  7990. editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
  7991. row: this.row,
  7992. col: this.col
  7993. });
  7994. this.textareaParentStyle.zIndex = 101;
  7995. break;
  7996. case 'corner':
  7997. editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
  7998. row: this.row,
  7999. col: this.col
  8000. });
  8001. this.textareaParentStyle.zIndex = 103;
  8002. break;
  8003. case 'left':
  8004. editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
  8005. row: this.row,
  8006. col: this.col
  8007. });
  8008. this.textareaParentStyle.zIndex = 102;
  8009. break;
  8010. default:
  8011. editedCell = this.instance.getCell(this.row, this.col);
  8012. this.textareaParentStyle.zIndex = "";
  8013. break;
  8014. }
  8015. return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
  8016. };
  8017. TextEditor.prototype.refreshDimensions = function() {
  8018. if (this.state !== Handsontable.EditorState.EDITING) {
  8019. return;
  8020. }
  8021. this.TD = this.getEditedCell();
  8022. if (!this.TD) {
  8023. return;
  8024. }
  8025. var currentOffset = dom.offset(this.TD),
  8026. containerOffset = dom.offset(this.instance.rootElement),
  8027. scrollableContainer = dom.getScrollableElement(this.TD),
  8028. editTop = currentOffset.top - containerOffset.top - 1 - (scrollableContainer.scrollTop || 0),
  8029. editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0),
  8030. settings = this.instance.getSettings(),
  8031. rowHeadersCount = settings.rowHeaders ? 1 : 0,
  8032. colHeadersCount = settings.colHeaders ? 1 : 0,
  8033. editorSection = this.checkEditorSection(),
  8034. backgroundColor = this.TD.style.backgroundColor,
  8035. cssTransformOffset;
  8036. switch (editorSection) {
  8037. case 'top':
  8038. cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  8039. break;
  8040. case 'left':
  8041. cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  8042. break;
  8043. case 'corner':
  8044. cssTransformOffset = dom.getCssTransform(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  8045. break;
  8046. }
  8047. if (editTop < 0) {
  8048. editTop = 0;
  8049. }
  8050. if (editLeft < 0) {
  8051. editLeft = 0;
  8052. }
  8053. if (colHeadersCount && this.instance.getSelected()[0] === 0) {
  8054. editTop += 1;
  8055. }
  8056. if (rowHeadersCount && this.instance.getSelected()[1] === 0) {
  8057. editLeft += 1;
  8058. }
  8059. if (cssTransformOffset && cssTransformOffset != -1) {
  8060. this.textareaParentStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  8061. } else {
  8062. dom.resetCssTransform(this.textareaParentStyle);
  8063. }
  8064. this.textareaParentStyle.top = editTop + 'px';
  8065. this.textareaParentStyle.left = editLeft + 'px';
  8066. var cellTopOffset = this.TD.offsetTop - this.instance.view.wt.wtOverlays.topOverlay.getScrollPosition(),
  8067. cellLeftOffset = this.TD.offsetLeft - this.instance.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  8068. var width = dom.innerWidth(this.TD) - 8,
  8069. maxWidth = this.instance.view.maximumVisibleElementWidth(cellLeftOffset) - 10,
  8070. height = this.TD.scrollHeight + 1,
  8071. maxHeight = this.instance.view.maximumVisibleElementHeight(cellTopOffset) - 2;
  8072. if (parseInt(this.TD.style.borderTopWidth, 10) > 0) {
  8073. height -= 1;
  8074. }
  8075. if (parseInt(this.TD.style.borderLeftWidth, 10) > 0) {
  8076. if (rowHeadersCount > 0) {
  8077. width -= 1;
  8078. }
  8079. }
  8080. this.TEXTAREA.style.fontSize = dom.getComputedStyle(this.TD).fontSize;
  8081. this.TEXTAREA.style.fontFamily = dom.getComputedStyle(this.TD).fontFamily;
  8082. this.TEXTAREA.style.backgroundColor = '';
  8083. this.TEXTAREA.style.backgroundColor = backgroundColor ? backgroundColor : dom.getComputedStyle(this.TEXTAREA).backgroundColor;
  8084. this.autoResize.init(this.TEXTAREA, {
  8085. minHeight: Math.min(height, maxHeight),
  8086. maxHeight: maxHeight,
  8087. minWidth: Math.min(width, maxWidth),
  8088. maxWidth: maxWidth
  8089. }, true);
  8090. this.textareaParentStyle.display = 'block';
  8091. };
  8092. TextEditor.prototype.bindEvents = function() {
  8093. var editor = this;
  8094. this.eventManager.addEventListener(this.TEXTAREA, 'cut', function(event) {
  8095. helper.stopPropagation(event);
  8096. });
  8097. this.eventManager.addEventListener(this.TEXTAREA, 'paste', function(event) {
  8098. helper.stopPropagation(event);
  8099. });
  8100. this.instance.addHook('afterScrollVertically', function() {
  8101. editor.refreshDimensions();
  8102. });
  8103. this.instance.addHook('afterColumnResize', function() {
  8104. editor.refreshDimensions();
  8105. editor.focus();
  8106. });
  8107. this.instance.addHook('afterRowResize', function() {
  8108. editor.refreshDimensions();
  8109. editor.focus();
  8110. });
  8111. this.instance.addHook('afterDestroy', function() {
  8112. editor.eventManager.clear();
  8113. });
  8114. };
  8115. TextEditor.prototype.destroy = function() {
  8116. this.eventManager.clear();
  8117. };
  8118. registerEditor('text', TextEditor);
  8119. //#
  8120. },{"./../dom.js":27,"./../editors.js":29,"./../eventManager.js":41,"./../helpers.js":42,"./_baseEditor.js":30,"autoResize":"autoResize"}],41:[function(require,module,exports){
  8121. "use strict";
  8122. Object.defineProperties(exports, {
  8123. EventManager: {get: function() {
  8124. return EventManager;
  8125. }},
  8126. eventManager: {get: function() {
  8127. return eventManager;
  8128. }},
  8129. __esModule: {value: true}
  8130. });
  8131. var $__dom_46_js__;
  8132. var dom = ($__dom_46_js__ = require("./dom.js"), $__dom_46_js__ && $__dom_46_js__.__esModule && $__dom_46_js__ || {default: $__dom_46_js__});
  8133. var EventManager = function EventManager() {
  8134. var context = arguments[0] !== (void 0) ? arguments[0] : null;
  8135. this.context = context || this;
  8136. if (!this.context.eventListeners) {
  8137. this.context.eventListeners = [];
  8138. }
  8139. };
  8140. ($traceurRuntime.createClass)(EventManager, {
  8141. addEventListener: function(element, eventName, callback) {
  8142. var $__0 = this;
  8143. var context = this.context;
  8144. function callbackProxy(event) {
  8145. if (event.target == void 0 && event.srcElement != void 0) {
  8146. if (event.definePoperty) {
  8147. event.definePoperty('target', {value: event.srcElement});
  8148. } else {
  8149. event.target = event.srcElement;
  8150. }
  8151. }
  8152. if (event.preventDefault == void 0) {
  8153. if (event.definePoperty) {
  8154. event.definePoperty('preventDefault', {value: function() {
  8155. this.returnValue = false;
  8156. }});
  8157. } else {
  8158. event.preventDefault = function() {
  8159. this.returnValue = false;
  8160. };
  8161. }
  8162. }
  8163. event = extendEvent(context, event);
  8164. callback.call(this, event);
  8165. }
  8166. this.context.eventListeners.push({
  8167. element: element,
  8168. event: eventName,
  8169. callback: callback,
  8170. callbackProxy: callbackProxy
  8171. });
  8172. if (window.addEventListener) {
  8173. element.addEventListener(eventName, callbackProxy, false);
  8174. } else {
  8175. element.attachEvent('on' + eventName, callbackProxy);
  8176. }
  8177. Handsontable.countEventManagerListeners++;
  8178. return (function() {
  8179. $__0.removeEventListener(element, eventName, callback);
  8180. });
  8181. },
  8182. removeEventListener: function(element, eventName, callback) {
  8183. var len = this.context.eventListeners.length;
  8184. var tmpEvent;
  8185. while (len--) {
  8186. tmpEvent = this.context.eventListeners[len];
  8187. if (tmpEvent.event == eventName && tmpEvent.element == element) {
  8188. if (callback && callback != tmpEvent.callback) {
  8189. continue;
  8190. }
  8191. this.context.eventListeners.splice(len, 1);
  8192. if (tmpEvent.element.removeEventListener) {
  8193. tmpEvent.element.removeEventListener(tmpEvent.event, tmpEvent.callbackProxy, false);
  8194. } else {
  8195. tmpEvent.element.detachEvent('on' + tmpEvent.event, tmpEvent.callbackProxy);
  8196. }
  8197. Handsontable.countEventManagerListeners--;
  8198. }
  8199. }
  8200. },
  8201. clearEvents: function() {
  8202. var len = this.context.eventListeners.length;
  8203. while (len--) {
  8204. var event = this.context.eventListeners[len];
  8205. if (event) {
  8206. this.removeEventListener(event.element, event.event, event.callback);
  8207. }
  8208. }
  8209. },
  8210. clear: function() {
  8211. this.clearEvents();
  8212. },
  8213. fireEvent: function(element, eventName) {
  8214. var options = {
  8215. bubbles: true,
  8216. cancelable: (eventName !== 'mousemove'),
  8217. view: window,
  8218. detail: 0,
  8219. screenX: 0,
  8220. screenY: 0,
  8221. clientX: 1,
  8222. clientY: 1,
  8223. ctrlKey: false,
  8224. altKey: false,
  8225. shiftKey: false,
  8226. metaKey: false,
  8227. button: 0,
  8228. relatedTarget: undefined
  8229. };
  8230. var event;
  8231. if (document.createEvent) {
  8232. event = document.createEvent('MouseEvents');
  8233. 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);
  8234. } else {
  8235. event = document.createEventObject();
  8236. }
  8237. if (element.dispatchEvent) {
  8238. element.dispatchEvent(event);
  8239. } else {
  8240. element.fireEvent('on' + eventName, event);
  8241. }
  8242. }
  8243. }, {});
  8244. function extendEvent(context, event) {
  8245. var componentName = 'HOT-TABLE';
  8246. var isHotTableSpotted;
  8247. var fromElement;
  8248. var realTarget;
  8249. var target;
  8250. var len;
  8251. event.isTargetWebComponent = false;
  8252. event.realTarget = event.target;
  8253. if (!Handsontable.eventManager.isHotTableEnv) {
  8254. return event;
  8255. }
  8256. event = dom.polymerWrap(event);
  8257. len = event.path ? event.path.length : 0;
  8258. while (len--) {
  8259. if (event.path[len].nodeName === componentName) {
  8260. isHotTableSpotted = true;
  8261. } else if (isHotTableSpotted && event.path[len].shadowRoot) {
  8262. target = event.path[len];
  8263. break;
  8264. }
  8265. if (len === 0 && !target) {
  8266. target = event.path[len];
  8267. }
  8268. }
  8269. if (!target) {
  8270. target = event.target;
  8271. }
  8272. event.isTargetWebComponent = true;
  8273. if (dom.isWebComponentSupportedNatively()) {
  8274. event.realTarget = event.srcElement || event.toElement;
  8275. } else if (context instanceof Handsontable.Core || context instanceof Walkontable) {
  8276. if (context instanceof Handsontable.Core) {
  8277. fromElement = context.view.wt.wtTable.TABLE;
  8278. } else if (context instanceof Walkontable) {
  8279. fromElement = context.wtTable.TABLE.parentNode.parentNode;
  8280. }
  8281. realTarget = dom.closest(event.target, [componentName], fromElement);
  8282. if (realTarget) {
  8283. event.realTarget = fromElement.querySelector(componentName) || event.target;
  8284. } else {
  8285. event.realTarget = event.target;
  8286. }
  8287. }
  8288. Object.defineProperty(event, 'target', {
  8289. get: function() {
  8290. return dom.polymerWrap(target);
  8291. },
  8292. enumerable: true,
  8293. configurable: true
  8294. });
  8295. return event;
  8296. }
  8297. ;
  8298. window.Handsontable = window.Handsontable || {};
  8299. Handsontable.countEventManagerListeners = 0;
  8300. Handsontable.eventManager = eventManager;
  8301. function eventManager(context) {
  8302. return new EventManager(context);
  8303. }
  8304. //#
  8305. },{"./dom.js":27}],42:[function(require,module,exports){
  8306. "use strict";
  8307. Object.defineProperties(exports, {
  8308. isPrintableChar: {get: function() {
  8309. return isPrintableChar;
  8310. }},
  8311. isMetaKey: {get: function() {
  8312. return isMetaKey;
  8313. }},
  8314. isCtrlKey: {get: function() {
  8315. return isCtrlKey;
  8316. }},
  8317. stringify: {get: function() {
  8318. return stringify;
  8319. }},
  8320. toUpperCaseFirst: {get: function() {
  8321. return toUpperCaseFirst;
  8322. }},
  8323. equalsIgnoreCase: {get: function() {
  8324. return equalsIgnoreCase;
  8325. }},
  8326. duckSchema: {get: function() {
  8327. return duckSchema;
  8328. }},
  8329. spreadsheetColumnLabel: {get: function() {
  8330. return spreadsheetColumnLabel;
  8331. }},
  8332. createSpreadsheetData: {get: function() {
  8333. return createSpreadsheetData;
  8334. }},
  8335. createSpreadsheetObjectData: {get: function() {
  8336. return createSpreadsheetObjectData;
  8337. }},
  8338. isNumeric: {get: function() {
  8339. return isNumeric;
  8340. }},
  8341. randomString: {get: function() {
  8342. return randomString;
  8343. }},
  8344. inherit: {get: function() {
  8345. return inherit;
  8346. }},
  8347. extend: {get: function() {
  8348. return extend;
  8349. }},
  8350. deepExtend: {get: function() {
  8351. return deepExtend;
  8352. }},
  8353. deepClone: {get: function() {
  8354. return deepClone;
  8355. }},
  8356. isObjectEquals: {get: function() {
  8357. return isObjectEquals;
  8358. }},
  8359. getPrototypeOf: {get: function() {
  8360. return getPrototypeOf;
  8361. }},
  8362. columnFactory: {get: function() {
  8363. return columnFactory;
  8364. }},
  8365. translateRowsToColumns: {get: function() {
  8366. return translateRowsToColumns;
  8367. }},
  8368. to2dArray: {get: function() {
  8369. return to2dArray;
  8370. }},
  8371. extendArray: {get: function() {
  8372. return extendArray;
  8373. }},
  8374. isInput: {get: function() {
  8375. return isInput;
  8376. }},
  8377. isOutsideInput: {get: function() {
  8378. return isOutsideInput;
  8379. }},
  8380. keyCode: {get: function() {
  8381. return keyCode;
  8382. }},
  8383. isObject: {get: function() {
  8384. return isObject;
  8385. }},
  8386. pivot: {get: function() {
  8387. return pivot;
  8388. }},
  8389. proxy: {get: function() {
  8390. return proxy;
  8391. }},
  8392. cellMethodLookupFactory: {get: function() {
  8393. return cellMethodLookupFactory;
  8394. }},
  8395. isMobileBrowser: {get: function() {
  8396. return isMobileBrowser;
  8397. }},
  8398. isTouchSupported: {get: function() {
  8399. return isTouchSupported;
  8400. }},
  8401. stopPropagation: {get: function() {
  8402. return stopPropagation;
  8403. }},
  8404. pageX: {get: function() {
  8405. return pageX;
  8406. }},
  8407. pageY: {get: function() {
  8408. return pageY;
  8409. }},
  8410. defineGetter: {get: function() {
  8411. return defineGetter;
  8412. }},
  8413. requestAnimationFrame: {get: function() {
  8414. return requestAnimationFrame;
  8415. }},
  8416. cancelAnimationFrame: {get: function() {
  8417. return cancelAnimationFrame;
  8418. }},
  8419. __esModule: {value: true}
  8420. });
  8421. var $__dom_46_js__;
  8422. var dom = ($__dom_46_js__ = require("./dom.js"), $__dom_46_js__ && $__dom_46_js__.__esModule && $__dom_46_js__ || {default: $__dom_46_js__});
  8423. function isPrintableChar(keyCode) {
  8424. 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));
  8425. }
  8426. function isMetaKey(_keyCode) {
  8427. 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];
  8428. return metaKeys.indexOf(_keyCode) != -1;
  8429. }
  8430. function isCtrlKey(_keyCode) {
  8431. return [keyCode.CONTROL_LEFT, 224, keyCode.COMMAND_LEFT, keyCode.COMMAND_RIGHT].indexOf(_keyCode) != -1;
  8432. }
  8433. function stringify(value) {
  8434. switch (typeof value) {
  8435. case 'string':
  8436. case 'number':
  8437. return value + '';
  8438. case 'object':
  8439. if (value === null) {
  8440. return '';
  8441. } else {
  8442. return value.toString();
  8443. }
  8444. break;
  8445. case 'undefined':
  8446. return '';
  8447. default:
  8448. return value.toString();
  8449. }
  8450. }
  8451. function toUpperCaseFirst(string) {
  8452. return string[0].toUpperCase() + string.substr(1);
  8453. }
  8454. function equalsIgnoreCase() {
  8455. for (var strings = [],
  8456. $__0 = 0; $__0 < arguments.length; $__0++)
  8457. strings[$__0] = arguments[$__0];
  8458. var unique = [];
  8459. var length = strings.length;
  8460. while (length--) {
  8461. var string = stringify(strings[length]).toLowerCase();
  8462. if (unique.indexOf(string) === -1) {
  8463. unique.push(string);
  8464. }
  8465. }
  8466. return unique.length === 1;
  8467. }
  8468. function duckSchema(object) {
  8469. var schema;
  8470. if (Array.isArray(object)) {
  8471. schema = [];
  8472. } else {
  8473. schema = {};
  8474. for (var i in object) {
  8475. if (object.hasOwnProperty(i)) {
  8476. if (object[i] && typeof object[i] === 'object' && !Array.isArray(object[i])) {
  8477. schema[i] = duckSchema(object[i]);
  8478. } else if (Array.isArray(object[i])) {
  8479. if (object[i].length && typeof object[i][0] === 'object' && !Array.isArray(object[i][0])) {
  8480. schema[i] = [duckSchema(object[i][0])];
  8481. } else {
  8482. schema[i] = [];
  8483. }
  8484. } else {
  8485. schema[i] = null;
  8486. }
  8487. }
  8488. }
  8489. }
  8490. return schema;
  8491. }
  8492. function spreadsheetColumnLabel(index) {
  8493. var dividend = index + 1;
  8494. var columnLabel = '';
  8495. var modulo;
  8496. while (dividend > 0) {
  8497. modulo = (dividend - 1) % 26;
  8498. columnLabel = String.fromCharCode(65 + modulo) + columnLabel;
  8499. dividend = parseInt((dividend - modulo) / 26, 10);
  8500. }
  8501. return columnLabel;
  8502. }
  8503. function createSpreadsheetData(rowCount, colCount) {
  8504. rowCount = typeof rowCount === 'number' ? rowCount : 100;
  8505. colCount = typeof colCount === 'number' ? colCount : 4;
  8506. var rows = [],
  8507. i,
  8508. j;
  8509. for (i = 0; i < rowCount; i++) {
  8510. var row = [];
  8511. for (j = 0; j < colCount; j++) {
  8512. row.push(spreadsheetColumnLabel(j) + (i + 1));
  8513. }
  8514. rows.push(row);
  8515. }
  8516. return rows;
  8517. }
  8518. function createSpreadsheetObjectData(rowCount, colCount) {
  8519. rowCount = typeof rowCount === 'number' ? rowCount : 100;
  8520. colCount = typeof colCount === 'number' ? colCount : 4;
  8521. var rows = [],
  8522. i,
  8523. j;
  8524. for (i = 0; i < rowCount; i++) {
  8525. var row = {};
  8526. for (j = 0; j < colCount; j++) {
  8527. row['prop' + j] = spreadsheetColumnLabel(j) + (i + 1);
  8528. }
  8529. rows.push(row);
  8530. }
  8531. return rows;
  8532. }
  8533. function isNumeric(n) {
  8534. var t = typeof n;
  8535. 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;
  8536. }
  8537. function randomString() {
  8538. function s4() {
  8539. return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
  8540. }
  8541. return s4() + s4() + s4() + s4();
  8542. }
  8543. function inherit(Child, Parent) {
  8544. Parent.prototype.constructor = Parent;
  8545. Child.prototype = new Parent();
  8546. Child.prototype.constructor = Child;
  8547. return Child;
  8548. }
  8549. function extend(target, extension) {
  8550. for (var i in extension) {
  8551. if (extension.hasOwnProperty(i)) {
  8552. target[i] = extension[i];
  8553. }
  8554. }
  8555. }
  8556. function deepExtend(target, extension) {
  8557. for (var key in extension) {
  8558. if (extension.hasOwnProperty(key)) {
  8559. if (extension[key] && typeof extension[key] === 'object') {
  8560. if (!target[key]) {
  8561. if (Array.isArray(extension[key])) {
  8562. target[key] = [];
  8563. } else {
  8564. target[key] = {};
  8565. }
  8566. }
  8567. deepExtend(target[key], extension[key]);
  8568. } else {
  8569. target[key] = extension[key];
  8570. }
  8571. }
  8572. }
  8573. }
  8574. function deepClone(obj) {
  8575. if (typeof obj === "object") {
  8576. return JSON.parse(JSON.stringify(obj));
  8577. } else {
  8578. return obj;
  8579. }
  8580. }
  8581. function isObjectEquals(object1, object2) {
  8582. return JSON.stringify(object1) === JSON.stringify(object2);
  8583. }
  8584. function getPrototypeOf(obj) {
  8585. var prototype;
  8586. if (typeof obj.__proto__ == "object") {
  8587. prototype = obj.__proto__;
  8588. } else {
  8589. var oldConstructor,
  8590. constructor = obj.constructor;
  8591. if (typeof obj.constructor == "function") {
  8592. oldConstructor = constructor;
  8593. if (delete obj.constructor) {
  8594. constructor = obj.constructor;
  8595. obj.constructor = oldConstructor;
  8596. }
  8597. }
  8598. prototype = constructor ? constructor.prototype : null;
  8599. }
  8600. return prototype;
  8601. }
  8602. function columnFactory(GridSettings, conflictList) {
  8603. function ColumnSettings() {}
  8604. inherit(ColumnSettings, GridSettings);
  8605. for (var i = 0,
  8606. len = conflictList.length; i < len; i++) {
  8607. ColumnSettings.prototype[conflictList[i]] = void 0;
  8608. }
  8609. return ColumnSettings;
  8610. }
  8611. function translateRowsToColumns(input) {
  8612. var i,
  8613. ilen,
  8614. j,
  8615. jlen,
  8616. output = [],
  8617. olen = 0;
  8618. for (i = 0, ilen = input.length; i < ilen; i++) {
  8619. for (j = 0, jlen = input[i].length; j < jlen; j++) {
  8620. if (j == olen) {
  8621. output.push([]);
  8622. olen++;
  8623. }
  8624. output[j].push(input[i][j]);
  8625. }
  8626. }
  8627. return output;
  8628. }
  8629. function to2dArray(arr) {
  8630. var i = 0,
  8631. ilen = arr.length;
  8632. while (i < ilen) {
  8633. arr[i] = [arr[i]];
  8634. i++;
  8635. }
  8636. }
  8637. function extendArray(arr, extension) {
  8638. var i = 0,
  8639. ilen = extension.length;
  8640. while (i < ilen) {
  8641. arr.push(extension[i]);
  8642. i++;
  8643. }
  8644. }
  8645. function isInput(element) {
  8646. var inputs = ['INPUT', 'SELECT', 'TEXTAREA'];
  8647. return inputs.indexOf(element.nodeName) > -1 || element.contentEditable === 'true';
  8648. }
  8649. function isOutsideInput(element) {
  8650. return isInput(element) && element.className.indexOf('handsontableInput') == -1 && element.className.indexOf('copyPaste') == -1;
  8651. }
  8652. var keyCode = {
  8653. MOUSE_LEFT: 1,
  8654. MOUSE_RIGHT: 3,
  8655. MOUSE_MIDDLE: 2,
  8656. BACKSPACE: 8,
  8657. COMMA: 188,
  8658. INSERT: 45,
  8659. DELETE: 46,
  8660. END: 35,
  8661. ENTER: 13,
  8662. ESCAPE: 27,
  8663. CONTROL_LEFT: 91,
  8664. COMMAND_LEFT: 17,
  8665. COMMAND_RIGHT: 93,
  8666. ALT: 18,
  8667. HOME: 36,
  8668. PAGE_DOWN: 34,
  8669. PAGE_UP: 33,
  8670. PERIOD: 190,
  8671. SPACE: 32,
  8672. SHIFT: 16,
  8673. CAPS_LOCK: 20,
  8674. TAB: 9,
  8675. ARROW_RIGHT: 39,
  8676. ARROW_LEFT: 37,
  8677. ARROW_UP: 38,
  8678. ARROW_DOWN: 40,
  8679. F1: 112,
  8680. F2: 113,
  8681. F3: 114,
  8682. F4: 115,
  8683. F5: 116,
  8684. F6: 117,
  8685. F7: 118,
  8686. F8: 119,
  8687. F9: 120,
  8688. F10: 121,
  8689. F11: 122,
  8690. F12: 123,
  8691. A: 65,
  8692. X: 88,
  8693. C: 67,
  8694. V: 86
  8695. };
  8696. function isObject(obj) {
  8697. return Object.prototype.toString.call(obj) == '[object Object]';
  8698. }
  8699. function pivot(arr) {
  8700. var pivotedArr = [];
  8701. if (!arr || arr.length === 0 || !arr[0] || arr[0].length === 0) {
  8702. return pivotedArr;
  8703. }
  8704. var rowCount = arr.length;
  8705. var colCount = arr[0].length;
  8706. for (var i = 0; i < rowCount; i++) {
  8707. for (var j = 0; j < colCount; j++) {
  8708. if (!pivotedArr[j]) {
  8709. pivotedArr[j] = [];
  8710. }
  8711. pivotedArr[j][i] = arr[i][j];
  8712. }
  8713. }
  8714. return pivotedArr;
  8715. }
  8716. function proxy(fun, context) {
  8717. return function() {
  8718. return fun.apply(context, arguments);
  8719. };
  8720. }
  8721. function cellMethodLookupFactory(methodName, allowUndefined) {
  8722. allowUndefined = typeof allowUndefined == 'undefined' ? true : allowUndefined;
  8723. return function cellMethodLookup(row, col) {
  8724. return (function getMethodFromProperties(properties) {
  8725. if (!properties) {
  8726. return;
  8727. } else if (properties.hasOwnProperty(methodName) && properties[methodName] !== void 0) {
  8728. return properties[methodName];
  8729. } else if (properties.hasOwnProperty('type') && properties.type) {
  8730. var type;
  8731. if (typeof properties.type != 'string') {
  8732. throw new Error('Cell type must be a string ');
  8733. }
  8734. type = translateTypeNameToObject(properties.type);
  8735. if (type.hasOwnProperty(methodName)) {
  8736. return type[methodName];
  8737. } else if (allowUndefined) {
  8738. return;
  8739. }
  8740. }
  8741. return getMethodFromProperties(getPrototypeOf(properties));
  8742. })(typeof row == 'number' ? this.getCellMeta(row, col) : row);
  8743. };
  8744. function translateTypeNameToObject(typeName) {
  8745. var type = Handsontable.cellTypes[typeName];
  8746. if (typeof type == 'undefined') {
  8747. 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');
  8748. }
  8749. return type;
  8750. }
  8751. }
  8752. function isMobileBrowser(userAgent) {
  8753. if (!userAgent) {
  8754. userAgent = navigator.userAgent;
  8755. }
  8756. return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent));
  8757. }
  8758. function isTouchSupported() {
  8759. return ('ontouchstart' in window);
  8760. }
  8761. function stopPropagation(event) {
  8762. if (typeof(event.stopPropagation) === 'function') {
  8763. event.stopPropagation();
  8764. } else {
  8765. event.cancelBubble = true;
  8766. }
  8767. }
  8768. function pageX(event) {
  8769. if (event.pageX) {
  8770. return event.pageX;
  8771. }
  8772. var scrollLeft = dom.getWindowScrollLeft();
  8773. var cursorX = event.clientX + scrollLeft;
  8774. return cursorX;
  8775. }
  8776. function pageY(event) {
  8777. if (event.pageY) {
  8778. return event.pageY;
  8779. }
  8780. var scrollTop = dom.getWindowScrollTop();
  8781. var cursorY = event.clientY + scrollTop;
  8782. return cursorY;
  8783. }
  8784. function defineGetter(object, property, value, options) {
  8785. options.value = value;
  8786. options.writable = options.writable === false ? false : true;
  8787. options.enumerable = options.enumerable === false ? false : true;
  8788. options.configurable = options.configurable === false ? false : true;
  8789. Object.defineProperty(object, property, options);
  8790. }
  8791. var lastTime = 0;
  8792. var vendors = ['ms', 'moz', 'webkit', 'o'];
  8793. var _requestAnimationFrame = window.requestAnimationFrame;
  8794. var _cancelAnimationFrame = window.cancelAnimationFrame;
  8795. for (var x = 0; x < vendors.length && !_requestAnimationFrame; ++x) {
  8796. _requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
  8797. _cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
  8798. }
  8799. if (!_requestAnimationFrame) {
  8800. _requestAnimationFrame = function(callback) {
  8801. var currTime = new Date().getTime();
  8802. var timeToCall = Math.max(0, 16 - (currTime - lastTime));
  8803. var id = window.setTimeout(function() {
  8804. callback(currTime + timeToCall);
  8805. }, timeToCall);
  8806. lastTime = currTime + timeToCall;
  8807. return id;
  8808. };
  8809. }
  8810. if (!_cancelAnimationFrame) {
  8811. _cancelAnimationFrame = function(id) {
  8812. clearTimeout(id);
  8813. };
  8814. }
  8815. function requestAnimationFrame(callback) {
  8816. return _requestAnimationFrame.call(window, callback);
  8817. }
  8818. function cancelAnimationFrame(id) {
  8819. _cancelAnimationFrame.call(window, id);
  8820. }
  8821. window.Handsontable = window.Handsontable || {};
  8822. Handsontable.helper = {
  8823. cancelAnimationFrame: cancelAnimationFrame,
  8824. cellMethodLookupFactory: cellMethodLookupFactory,
  8825. columnFactory: columnFactory,
  8826. createSpreadsheetData: createSpreadsheetData,
  8827. createSpreadsheetObjectData: createSpreadsheetObjectData,
  8828. deepClone: deepClone,
  8829. deepExtend: deepExtend,
  8830. defineGetter: defineGetter,
  8831. duckSchema: duckSchema,
  8832. equalsIgnoreCase: equalsIgnoreCase,
  8833. extend: extend,
  8834. extendArray: extendArray,
  8835. getPrototypeOf: getPrototypeOf,
  8836. inherit: inherit,
  8837. isCtrlKey: isCtrlKey,
  8838. isInput: isInput,
  8839. isMetaKey: isMetaKey,
  8840. isMobileBrowser: isMobileBrowser,
  8841. isNumeric: isNumeric,
  8842. isObject: isObject,
  8843. isObjectEquals: isObjectEquals,
  8844. isOutsideInput: isOutsideInput,
  8845. isPrintableChar: isPrintableChar,
  8846. isTouchSupported: isTouchSupported,
  8847. keyCode: keyCode,
  8848. pageX: pageX,
  8849. pageY: pageY,
  8850. pivot: pivot,
  8851. proxy: proxy,
  8852. randomString: randomString,
  8853. requestAnimationFrame: requestAnimationFrame,
  8854. spreadsheetColumnLabel: spreadsheetColumnLabel,
  8855. stopPropagation: stopPropagation,
  8856. stringify: stringify,
  8857. to2dArray: to2dArray,
  8858. toUpperCaseFirst: toUpperCaseFirst,
  8859. translateRowsToColumns: translateRowsToColumns
  8860. };
  8861. //#
  8862. },{"./dom.js":27}],43:[function(require,module,exports){
  8863. "use strict";
  8864. Object.defineProperties(exports, {
  8865. MultiMap: {get: function() {
  8866. return MultiMap;
  8867. }},
  8868. __esModule: {value: true}
  8869. });
  8870. ;
  8871. window.MultiMap = MultiMap;
  8872. function MultiMap() {
  8873. var map = {
  8874. arrayMap: [],
  8875. weakMap: new WeakMap()
  8876. };
  8877. return {
  8878. 'get': function(key) {
  8879. if (canBeAnArrayMapKey(key)) {
  8880. return map.arrayMap[key];
  8881. } else if (canBeAWeakMapKey(key)) {
  8882. return map.weakMap.get(key);
  8883. }
  8884. },
  8885. 'set': function(key, value) {
  8886. if (canBeAnArrayMapKey(key)) {
  8887. map.arrayMap[key] = value;
  8888. } else if (canBeAWeakMapKey(key)) {
  8889. map.weakMap.set(key, value);
  8890. } else {
  8891. throw new Error('Invalid key type');
  8892. }
  8893. },
  8894. 'delete': function(key) {
  8895. if (canBeAnArrayMapKey(key)) {
  8896. delete map.arrayMap[key];
  8897. } else if (canBeAWeakMapKey(key)) {
  8898. map.weakMap['delete'](key);
  8899. }
  8900. }
  8901. };
  8902. function canBeAnArrayMapKey(obj) {
  8903. return obj !== null && !isNaNSymbol(obj) && (typeof obj == 'string' || typeof obj == 'number');
  8904. }
  8905. function canBeAWeakMapKey(obj) {
  8906. return obj !== null && (typeof obj == 'object' || typeof obj == 'function');
  8907. }
  8908. function isNaNSymbol(obj) {
  8909. return obj !== obj;
  8910. }
  8911. }
  8912. //#
  8913. },{}],44:[function(require,module,exports){
  8914. "use strict";
  8915. Object.defineProperties(exports, {
  8916. Hooks: {get: function() {
  8917. return Hooks;
  8918. }},
  8919. __esModule: {value: true}
  8920. });
  8921. var $__eventManager_46_js__;
  8922. 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"];
  8923. var EventManager = ($__eventManager_46_js__ = require("./eventManager.js"), $__eventManager_46_js__ && $__eventManager_46_js__.__esModule && $__eventManager_46_js__ || {default: $__eventManager_46_js__}).EventManager;
  8924. var Hooks = function Hooks() {
  8925. this.globalBucket = this.createEmptyBucket();
  8926. };
  8927. ($traceurRuntime.createClass)(Hooks, {
  8928. createEmptyBucket: function() {
  8929. var handler = Object.create(null);
  8930. for (var i = 0,
  8931. len = REGISTERED_HOOKS.length; i < len; i++) {
  8932. handler[REGISTERED_HOOKS[i]] = [];
  8933. }
  8934. return handler;
  8935. },
  8936. getBucket: function() {
  8937. var context = arguments[0] !== (void 0) ? arguments[0] : null;
  8938. if (context) {
  8939. if (!context.pluginHookBucket) {
  8940. context.pluginHookBucket = this.createEmptyBucket();
  8941. }
  8942. return context.pluginHookBucket;
  8943. }
  8944. return this.globalBucket;
  8945. },
  8946. add: function(key, callback) {
  8947. var context = arguments[2] !== (void 0) ? arguments[2] : null;
  8948. if (Array.isArray(callback)) {
  8949. for (var i = 0,
  8950. len = callback.length; i < len; i++) {
  8951. this.add(key, callback[i]);
  8952. }
  8953. } else {
  8954. var bucket = this.getBucket(context);
  8955. if (typeof bucket[key] === 'undefined') {
  8956. this.register(key);
  8957. bucket[key] = [];
  8958. }
  8959. callback.skip = false;
  8960. if (bucket[key].indexOf(callback) === -1) {
  8961. bucket[key].push(callback);
  8962. }
  8963. }
  8964. return this;
  8965. },
  8966. once: function(key, callback) {
  8967. var context = arguments[2] !== (void 0) ? arguments[2] : null;
  8968. if (Array.isArray(callback)) {
  8969. for (var i = 0,
  8970. len = callback.length; i < len; i++) {
  8971. callback[i].runOnce = true;
  8972. this.add(key, callback[i], context);
  8973. }
  8974. } else {
  8975. callback.runOnce = true;
  8976. this.add(key, callback, context);
  8977. }
  8978. },
  8979. remove: function(key, callback) {
  8980. var context = arguments[2] !== (void 0) ? arguments[2] : null;
  8981. var bucket = this.getBucket(context);
  8982. if (typeof bucket[key] !== 'undefined') {
  8983. if (bucket[key].indexOf(callback) >= 0) {
  8984. callback.skip = true;
  8985. return true;
  8986. }
  8987. }
  8988. return false;
  8989. },
  8990. run: function(context, key, p1, p2, p3, p4, p5, p6) {
  8991. {
  8992. var globalHandlers = this.globalBucket[key];
  8993. var len = globalHandlers ? globalHandlers.length : 0;
  8994. for (var i = 0; i < len; i++) {
  8995. if (globalHandlers[i].skip) {
  8996. continue;
  8997. }
  8998. var res = globalHandlers[i].call(context, p1, p2, p3, p4, p5, p6);
  8999. if (res !== void 0) {
  9000. p1 = res;
  9001. }
  9002. if (globalHandlers[i].runOnce) {
  9003. this.remove(key, globalHandlers[i]);
  9004. }
  9005. }
  9006. }
  9007. {
  9008. var localHandlers = this.getBucket(context)[key];
  9009. var len$__2 = localHandlers ? localHandlers.length : 0;
  9010. for (var i$__3 = 0; i$__3 < len$__2; i$__3++) {
  9011. if (localHandlers[i$__3].skip) {
  9012. continue;
  9013. }
  9014. var res$__4 = localHandlers[i$__3].call(context, p1, p2, p3, p4, p5, p6);
  9015. if (res$__4 !== void 0) {
  9016. p1 = res$__4;
  9017. }
  9018. if (localHandlers[i$__3].runOnce) {
  9019. this.remove(key, localHandlers[i$__3], context);
  9020. }
  9021. }
  9022. }
  9023. return p1;
  9024. },
  9025. destroy: function() {
  9026. var context = arguments[0] !== (void 0) ? arguments[0] : null;
  9027. var bucket = this.getBucket(context);
  9028. for (var key in bucket) {
  9029. for (var i = 0,
  9030. len = bucket[key].length; i < len; i++) {
  9031. this.remove(key, bucket[key], context);
  9032. }
  9033. }
  9034. },
  9035. register: function(key) {
  9036. if (!this.isRegistered(key)) {
  9037. REGISTERED_HOOKS.push(key);
  9038. }
  9039. },
  9040. deregister: function(key) {
  9041. if (this.isRegistered(key)) {
  9042. REGISTERED_HOOKS.splice(REGISTERED_HOOKS.indexOf(key), 1);
  9043. }
  9044. },
  9045. isRegistered: function(key) {
  9046. return REGISTERED_HOOKS.indexOf(key) >= 0;
  9047. },
  9048. getRegistered: function() {
  9049. return REGISTERED_HOOKS;
  9050. }
  9051. }, {});
  9052. ;
  9053. //#
  9054. },{"./eventManager.js":41}],45:[function(require,module,exports){
  9055. "use strict";
  9056. Object.defineProperties(exports, {
  9057. registerPlugin: {get: function() {
  9058. return registerPlugin;
  9059. }},
  9060. getPlugin: {get: function() {
  9061. return getPlugin;
  9062. }},
  9063. __esModule: {value: true}
  9064. });
  9065. ;
  9066. var registeredPlugins = new WeakMap();
  9067. function registerPlugin(pluginName, PluginClass) {
  9068. Handsontable.hooks.add('beforeInit', function() {
  9069. var holder;
  9070. pluginName = pluginName.toLowerCase();
  9071. if (!registeredPlugins.has(this)) {
  9072. registeredPlugins.set(this, {});
  9073. }
  9074. holder = registeredPlugins.get(this);
  9075. if (!holder[pluginName]) {
  9076. holder[pluginName] = new PluginClass(this);
  9077. }
  9078. });
  9079. Handsontable.hooks.add('afterDestroy', function() {
  9080. var i,
  9081. pluginsHolder;
  9082. if (registeredPlugins.has(this)) {
  9083. pluginsHolder = registeredPlugins.get(this);
  9084. for (i in pluginsHolder) {
  9085. if (pluginsHolder.hasOwnProperty(i)) {
  9086. pluginsHolder[i].destroy();
  9087. }
  9088. }
  9089. registeredPlugins.delete(this);
  9090. }
  9091. });
  9092. }
  9093. function getPlugin(instance, pluginName) {
  9094. if (typeof pluginName != 'string') {
  9095. throw Error('Only strings can be passed as "plugin" parameter');
  9096. }
  9097. var _pluginName = pluginName.toLowerCase();
  9098. if (!registeredPlugins.has(instance) || !registeredPlugins.get(instance)[_pluginName]) {
  9099. throw Error('No plugin registered under name "' + pluginName + '"');
  9100. }
  9101. return registeredPlugins.get(instance)[_pluginName];
  9102. }
  9103. //#
  9104. },{}],46:[function(require,module,exports){
  9105. "use strict";
  9106. Object.defineProperties(exports, {
  9107. default: {get: function() {
  9108. return $__default;
  9109. }},
  9110. __esModule: {value: true}
  9111. });
  9112. var $___46__46__47_helpers_46_js__;
  9113. 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;
  9114. var BasePlugin = function BasePlugin(hotInstance) {
  9115. defineGetter(this, 'hot', hotInstance, {writable: false});
  9116. };
  9117. ($traceurRuntime.createClass)(BasePlugin, {destroy: function() {
  9118. delete this.hot;
  9119. }}, {});
  9120. var $__default = BasePlugin;
  9121. //#
  9122. },{"./../helpers.js":42}],47:[function(require,module,exports){
  9123. "use strict";
  9124. Object.defineProperties(exports, {
  9125. AutoColumnSize: {get: function() {
  9126. return AutoColumnSize;
  9127. }},
  9128. __esModule: {value: true}
  9129. });
  9130. var $___46__46__47__46__46__47_helpers_46_js__,
  9131. $___46__46__47__46__46__47_dom_46_js__,
  9132. $___46__46__47__46__46__47_plugins_46_js__;
  9133. 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__});
  9134. 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__});
  9135. 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;
  9136. ;
  9137. function AutoColumnSize() {
  9138. var plugin = this,
  9139. sampleCount = 5;
  9140. this.beforeInit = function() {
  9141. var instance = this;
  9142. instance.autoColumnWidths = [];
  9143. if (instance.getSettings().autoColumnSize !== false) {
  9144. if (!instance.autoColumnSizeTmp) {
  9145. instance.autoColumnSizeTmp = {
  9146. table: null,
  9147. tableStyle: null,
  9148. theadTh: null,
  9149. tbody: null,
  9150. container: null,
  9151. containerStyle: null,
  9152. determineBeforeNextRender: true
  9153. };
  9154. instance.addHook('beforeRender', htAutoColumnSize.determineIfChanged);
  9155. instance.addHook('modifyColWidth', htAutoColumnSize.modifyColWidth);
  9156. instance.addHook('afterDestroy', htAutoColumnSize.afterDestroy);
  9157. instance.determineColumnWidth = plugin.determineColumnWidth;
  9158. }
  9159. } else {
  9160. if (instance.autoColumnSizeTmp) {
  9161. instance.removeHook('beforeRender', htAutoColumnSize.determineIfChanged);
  9162. instance.removeHook('modifyColWidth', htAutoColumnSize.modifyColWidth);
  9163. instance.removeHook('afterDestroy', htAutoColumnSize.afterDestroy);
  9164. delete instance.determineColumnWidth;
  9165. plugin.afterDestroy.call(instance);
  9166. }
  9167. }
  9168. };
  9169. this.determineIfChanged = function(force) {
  9170. if (force) {
  9171. htAutoColumnSize.determineColumnsWidth.apply(this, arguments);
  9172. }
  9173. };
  9174. this.determineColumnWidth = function(col) {
  9175. var instance = this,
  9176. tmp = instance.autoColumnSizeTmp;
  9177. if (!tmp.container) {
  9178. createTmpContainer.call(tmp, instance);
  9179. }
  9180. tmp.container.className = instance.rootElement.className + ' htAutoColumnSize';
  9181. tmp.table.className = instance.table.className;
  9182. var rows = instance.countRows();
  9183. var samples = {};
  9184. for (var r = 0; r < rows; r++) {
  9185. var value = instance.getDataAtCell(r, col);
  9186. if (!Array.isArray(value)) {
  9187. value = helper.stringify(value);
  9188. }
  9189. var len = value.length;
  9190. if (!samples[len]) {
  9191. samples[len] = {
  9192. needed: sampleCount,
  9193. strings: []
  9194. };
  9195. }
  9196. if (samples[len].needed) {
  9197. samples[len].strings.push({
  9198. value: value,
  9199. row: r
  9200. });
  9201. samples[len].needed--;
  9202. }
  9203. }
  9204. var settings = instance.getSettings();
  9205. if (settings.colHeaders) {
  9206. instance.view.appendColHeader(col, tmp.theadTh);
  9207. }
  9208. dom.empty(tmp.tbody);
  9209. for (var i in samples) {
  9210. if (samples.hasOwnProperty(i)) {
  9211. for (var j = 0,
  9212. jlen = samples[i].strings.length; j < jlen; j++) {
  9213. var row = samples[i].strings[j].row;
  9214. var cellProperties = instance.getCellMeta(row, col);
  9215. cellProperties.col = col;
  9216. cellProperties.row = row;
  9217. var renderer = instance.getCellRenderer(cellProperties);
  9218. var tr = document.createElement('tr');
  9219. var td = document.createElement('td');
  9220. renderer(instance, td, row, col, instance.colToProp(col), samples[i].strings[j].value, cellProperties);
  9221. r++;
  9222. tr.appendChild(td);
  9223. tmp.tbody.appendChild(tr);
  9224. }
  9225. }
  9226. }
  9227. var parent = instance.rootElement.parentNode;
  9228. parent.appendChild(tmp.container);
  9229. var width = dom.outerWidth(tmp.table);
  9230. parent.removeChild(tmp.container);
  9231. return width;
  9232. };
  9233. this.determineColumnsWidth = function() {
  9234. var instance = this;
  9235. var settings = this.getSettings();
  9236. if (settings.autoColumnSize || !settings.colWidths) {
  9237. var cols = this.countCols();
  9238. for (var c = 0; c < cols; c++) {
  9239. if (!instance._getColWidthFromSettings(c)) {
  9240. this.autoColumnWidths[c] = plugin.determineColumnWidth.call(instance, c);
  9241. }
  9242. }
  9243. }
  9244. if (this.view.wt) {
  9245. this.view.wt.wtOverlays.adjustElementsSize(true);
  9246. }
  9247. };
  9248. this.modifyColWidth = function(width, col) {
  9249. if (this.autoColumnWidths[col] && this.autoColumnWidths[col] > width) {
  9250. return this.autoColumnWidths[col];
  9251. }
  9252. return width;
  9253. };
  9254. this.afterDestroy = function() {
  9255. var instance = this;
  9256. if (instance.autoColumnSizeTmp && instance.autoColumnSizeTmp.container && instance.autoColumnSizeTmp.container.parentNode) {
  9257. instance.autoColumnSizeTmp.container.parentNode.removeChild(instance.autoColumnSizeTmp.container);
  9258. }
  9259. instance.autoColumnSizeTmp = null;
  9260. };
  9261. function createTmpContainer(instance) {
  9262. var d = document,
  9263. tmp = this;
  9264. tmp.table = d.createElement('table');
  9265. tmp.theadTh = d.createElement('th');
  9266. tmp.table.appendChild(d.createElement('thead')).appendChild(d.createElement('tr')).appendChild(tmp.theadTh);
  9267. tmp.tableStyle = tmp.table.style;
  9268. tmp.tableStyle.tableLayout = 'auto';
  9269. tmp.tableStyle.width = 'auto';
  9270. tmp.tbody = d.createElement('tbody');
  9271. tmp.table.appendChild(tmp.tbody);
  9272. tmp.container = d.createElement('div');
  9273. tmp.container.className = instance.rootElement.className + ' hidden';
  9274. tmp.containerStyle = tmp.container.style;
  9275. tmp.container.appendChild(tmp.table);
  9276. }
  9277. }
  9278. var htAutoColumnSize = new AutoColumnSize();
  9279. Handsontable.hooks.add('beforeInit', htAutoColumnSize.beforeInit);
  9280. Handsontable.hooks.add('afterUpdateSettings', htAutoColumnSize.beforeInit);
  9281. //#
  9282. },{"./../../dom.js":27,"./../../helpers.js":42,"./../../plugins.js":45}],48:[function(require,module,exports){
  9283. "use strict";
  9284. Object.defineProperties(exports, {
  9285. Autofill: {get: function() {
  9286. return Autofill;
  9287. }},
  9288. __esModule: {value: true}
  9289. });
  9290. var $___46__46__47__46__46__47_dom_46_js__,
  9291. $___46__46__47__46__46__47_eventManager_46_js__,
  9292. $___46__46__47__46__46__47_plugins_46_js__,
  9293. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__;
  9294. 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__});
  9295. 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;
  9296. 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;
  9297. 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;
  9298. ;
  9299. function getDeltas(start, end, data, direction) {
  9300. var rlength = data.length,
  9301. clength = data ? data[0].length : 0,
  9302. deltas = [],
  9303. arr = [],
  9304. diffRow,
  9305. diffCol,
  9306. startValue,
  9307. endValue,
  9308. delta;
  9309. diffRow = end.row - start.row;
  9310. diffCol = end.col - start.col;
  9311. if (['down', 'up'].indexOf(direction) !== -1) {
  9312. for (var col = 0; col <= diffCol; col++) {
  9313. startValue = parseInt(data[0][col], 10);
  9314. endValue = parseInt(data[rlength - 1][col], 10);
  9315. delta = (direction === 'down' ? (endValue - startValue) : (startValue - endValue)) / (rlength - 1) || 0;
  9316. arr.push(delta);
  9317. }
  9318. deltas.push(arr);
  9319. }
  9320. if (['right', 'left'].indexOf(direction) !== -1) {
  9321. for (var row = 0; row <= diffRow; row++) {
  9322. startValue = parseInt(data[row][0], 10);
  9323. endValue = parseInt(data[row][clength - 1], 10);
  9324. delta = (direction === 'right' ? (endValue - startValue) : (startValue - endValue)) / (clength - 1) || 0;
  9325. arr = [];
  9326. arr.push(delta);
  9327. deltas.push(arr);
  9328. }
  9329. }
  9330. return deltas;
  9331. }
  9332. function Autofill(instance) {
  9333. var _this = this,
  9334. mouseDownOnCellCorner = false,
  9335. wtOnCellCornerMouseDown,
  9336. wtOnCellMouseOver,
  9337. eventManager;
  9338. this.instance = instance;
  9339. this.addingStarted = false;
  9340. eventManager = eventManagerObject(instance);
  9341. function mouseUpCallback(event) {
  9342. if (!instance.autofill) {
  9343. return true;
  9344. }
  9345. if (instance.autofill.handle && instance.autofill.handle.isDragged) {
  9346. if (instance.autofill.handle.isDragged > 1) {
  9347. instance.autofill.apply();
  9348. }
  9349. instance.autofill.handle.isDragged = 0;
  9350. mouseDownOnCellCorner = false;
  9351. }
  9352. }
  9353. function mouseMoveCallback(event) {
  9354. var tableBottom,
  9355. tableRight;
  9356. if (!_this.instance.autofill) {
  9357. return false;
  9358. }
  9359. tableBottom = dom.offset(_this.instance.table).top - (window.pageYOffset || document.documentElement.scrollTop) + dom.outerHeight(_this.instance.table);
  9360. tableRight = dom.offset(_this.instance.table).left - (window.pageXOffset || document.documentElement.scrollLeft) + dom.outerWidth(_this.instance.table);
  9361. if (_this.addingStarted === false && _this.instance.autofill.handle.isDragged > 0 && event.clientY > tableBottom && event.clientX <= tableRight) {
  9362. _this.instance.mouseDragOutside = true;
  9363. _this.addingStarted = true;
  9364. } else {
  9365. _this.instance.mouseDragOutside = false;
  9366. }
  9367. if (_this.instance.mouseDragOutside) {
  9368. setTimeout(function() {
  9369. _this.addingStarted = false;
  9370. _this.instance.alter('insert_row');
  9371. }, 200);
  9372. }
  9373. }
  9374. eventManager.addEventListener(document, 'mouseup', mouseUpCallback);
  9375. eventManager.addEventListener(document, 'mousemove', mouseMoveCallback);
  9376. wtOnCellCornerMouseDown = this.instance.view.wt.wtSettings.settings.onCellCornerMouseDown;
  9377. this.instance.view.wt.wtSettings.settings.onCellCornerMouseDown = function(event) {
  9378. instance.autofill.handle.isDragged = 1;
  9379. mouseDownOnCellCorner = true;
  9380. wtOnCellCornerMouseDown(event);
  9381. };
  9382. wtOnCellMouseOver = this.instance.view.wt.wtSettings.settings.onCellMouseOver;
  9383. this.instance.view.wt.wtSettings.settings.onCellMouseOver = function(event, coords, TD, wt) {
  9384. if (instance.autofill && mouseDownOnCellCorner && !instance.view.isMouseDown() && instance.autofill.handle && instance.autofill.handle.isDragged) {
  9385. instance.autofill.handle.isDragged++;
  9386. instance.autofill.showBorder(coords);
  9387. instance.autofill.checkIfNewRowNeeded();
  9388. }
  9389. wtOnCellMouseOver(event, coords, TD, wt);
  9390. };
  9391. this.instance.view.wt.wtSettings.settings.onCellCornerDblClick = function() {
  9392. instance.autofill.selectAdjacent();
  9393. };
  9394. }
  9395. Autofill.prototype.init = function() {
  9396. this.handle = {};
  9397. };
  9398. Autofill.prototype.disable = function() {
  9399. this.handle.disabled = true;
  9400. };
  9401. Autofill.prototype.selectAdjacent = function() {
  9402. var select,
  9403. data,
  9404. r,
  9405. maxR,
  9406. c;
  9407. if (this.instance.selection.isMultiple()) {
  9408. select = this.instance.view.wt.selections.area.getCorners();
  9409. } else {
  9410. select = this.instance.view.wt.selections.current.getCorners();
  9411. }
  9412. data = this.instance.getData();
  9413. rows: for (r = select[2] + 1; r < this.instance.countRows(); r++) {
  9414. for (c = select[1]; c <= select[3]; c++) {
  9415. if (data[r][c]) {
  9416. break rows;
  9417. }
  9418. }
  9419. if (!!data[r][select[1] - 1] || !!data[r][select[3] + 1]) {
  9420. maxR = r;
  9421. }
  9422. }
  9423. if (maxR) {
  9424. this.instance.view.wt.selections.fill.clear();
  9425. this.instance.view.wt.selections.fill.add(new WalkontableCellCoords(select[0], select[1]));
  9426. this.instance.view.wt.selections.fill.add(new WalkontableCellCoords(maxR, select[3]));
  9427. this.apply();
  9428. }
  9429. };
  9430. Autofill.prototype.apply = function() {
  9431. var drag,
  9432. select,
  9433. start,
  9434. end,
  9435. _data,
  9436. direction,
  9437. deltas,
  9438. selRange;
  9439. this.handle.isDragged = 0;
  9440. drag = this.instance.view.wt.selections.fill.getCorners();
  9441. if (!drag) {
  9442. return;
  9443. }
  9444. this.instance.view.wt.selections.fill.clear();
  9445. if (this.instance.selection.isMultiple()) {
  9446. select = this.instance.view.wt.selections.area.getCorners();
  9447. } else {
  9448. select = this.instance.view.wt.selections.current.getCorners();
  9449. }
  9450. Handsontable.hooks.run(this.instance, 'afterAutofillApplyValues', select, drag);
  9451. if (drag[0] === select[0] && drag[1] < select[1]) {
  9452. direction = 'left';
  9453. start = new WalkontableCellCoords(drag[0], drag[1]);
  9454. end = new WalkontableCellCoords(drag[2], select[1] - 1);
  9455. } else if (drag[0] === select[0] && drag[3] > select[3]) {
  9456. direction = 'right';
  9457. start = new WalkontableCellCoords(drag[0], select[3] + 1);
  9458. end = new WalkontableCellCoords(drag[2], drag[3]);
  9459. } else if (drag[0] < select[0] && drag[1] === select[1]) {
  9460. direction = 'up';
  9461. start = new WalkontableCellCoords(drag[0], drag[1]);
  9462. end = new WalkontableCellCoords(select[0] - 1, drag[3]);
  9463. } else if (drag[2] > select[2] && drag[1] === select[1]) {
  9464. direction = 'down';
  9465. start = new WalkontableCellCoords(select[2] + 1, drag[1]);
  9466. end = new WalkontableCellCoords(drag[2], drag[3]);
  9467. }
  9468. if (start && start.row > -1 && start.col > -1) {
  9469. selRange = {
  9470. from: this.instance.getSelectedRange().from,
  9471. to: this.instance.getSelectedRange().to
  9472. };
  9473. _data = this.instance.getData(selRange.from.row, selRange.from.col, selRange.to.row, selRange.to.col);
  9474. deltas = getDeltas(start, end, _data, direction);
  9475. Handsontable.hooks.run(this.instance, 'beforeAutofill', start, end, _data);
  9476. this.instance.populateFromArray(start.row, start.col, _data, end.row, end.col, 'autofill', null, direction, deltas);
  9477. this.instance.selection.setRangeStart(new WalkontableCellCoords(drag[0], drag[1]));
  9478. this.instance.selection.setRangeEnd(new WalkontableCellCoords(drag[2], drag[3]));
  9479. } else {
  9480. this.instance.selection.refreshBorders();
  9481. }
  9482. };
  9483. Autofill.prototype.showBorder = function(coords) {
  9484. var topLeft = this.instance.getSelectedRange().getTopLeftCorner(),
  9485. bottomRight = this.instance.getSelectedRange().getBottomRightCorner();
  9486. if (this.instance.getSettings().fillHandle !== 'horizontal' && (bottomRight.row < coords.row || topLeft.row > coords.row)) {
  9487. coords = new WalkontableCellCoords(coords.row, bottomRight.col);
  9488. } else if (this.instance.getSettings().fillHandle !== 'vertical') {
  9489. coords = new WalkontableCellCoords(bottomRight.row, coords.col);
  9490. } else {
  9491. return;
  9492. }
  9493. this.instance.view.wt.selections.fill.clear();
  9494. this.instance.view.wt.selections.fill.add(this.instance.getSelectedRange().from);
  9495. this.instance.view.wt.selections.fill.add(this.instance.getSelectedRange().to);
  9496. this.instance.view.wt.selections.fill.add(coords);
  9497. this.instance.view.render();
  9498. };
  9499. Autofill.prototype.checkIfNewRowNeeded = function() {
  9500. var fillCorners,
  9501. selection,
  9502. tableRows = this.instance.countRows(),
  9503. that = this;
  9504. if (this.instance.view.wt.selections.fill.cellRange && this.addingStarted === false) {
  9505. selection = this.instance.getSelected();
  9506. fillCorners = this.instance.view.wt.selections.fill.getCorners();
  9507. if (selection[2] < tableRows - 1 && fillCorners[2] === tableRows - 1) {
  9508. this.addingStarted = true;
  9509. this.instance._registerTimeout(setTimeout(function() {
  9510. that.instance.alter('insert_row');
  9511. that.addingStarted = false;
  9512. }, 200));
  9513. }
  9514. }
  9515. };
  9516. Handsontable.hooks.add('afterInit', function() {
  9517. var autofill = new Autofill(this);
  9518. if (typeof this.getSettings().fillHandle !== 'undefined') {
  9519. if (autofill.handle && this.getSettings().fillHandle === false) {
  9520. autofill.disable();
  9521. } else if (!autofill.handle && this.getSettings().fillHandle !== false) {
  9522. this.autofill = autofill;
  9523. this.autofill.init();
  9524. }
  9525. }
  9526. });
  9527. Handsontable.Autofill = Autofill;
  9528. //#
  9529. },{"./../../3rdparty/walkontable/src/cell/coords.js":5,"./../../dom.js":27,"./../../eventManager.js":41,"./../../plugins.js":45}],49:[function(require,module,exports){
  9530. "use strict";
  9531. Object.defineProperties(exports, {
  9532. default: {get: function() {
  9533. return $__default;
  9534. }},
  9535. __esModule: {value: true}
  9536. });
  9537. var $___46__46__47__46__46__47_dom_46_js__,
  9538. $___46__46__47__46__46__47_eventManager_46_js__,
  9539. $___46__46__47__95_base_46_js__,
  9540. $___46__46__47__46__46__47_plugins_46_js__;
  9541. 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__});
  9542. 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;
  9543. 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;
  9544. 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;
  9545. var ColumnSorting = function ColumnSorting(hotInstance) {
  9546. var $__3 = this;
  9547. $traceurRuntime.superConstructor($ColumnSorting).call(this, hotInstance);
  9548. var _this = this;
  9549. this.sortIndicators = [];
  9550. this.hot.addHook('afterInit', (function() {
  9551. return $__3.init.call($__3, 'afterInit');
  9552. }));
  9553. this.hot.addHook('afterUpdateSettings', (function() {
  9554. return $__3.init.call($__3, 'afterUpdateSettings');
  9555. }));
  9556. this.hot.addHook('modifyRow', function() {
  9557. return _this.translateRow.apply(_this, arguments);
  9558. });
  9559. this.hot.addHook('afterGetColHeader', function() {
  9560. return _this.getColHeader.apply(_this, arguments);
  9561. });
  9562. Handsontable.hooks.register('beforeColumnSort');
  9563. Handsontable.hooks.register('afterColumnSort');
  9564. };
  9565. var $ColumnSorting = ColumnSorting;
  9566. ($traceurRuntime.createClass)(ColumnSorting, {
  9567. init: function(source) {
  9568. var sortingSettings = this.hot.getSettings().columnSorting,
  9569. _this = this;
  9570. this.hot.sortingEnabled = !!(sortingSettings);
  9571. if (this.hot.sortingEnabled) {
  9572. this.hot.sortIndex = [];
  9573. var loadedSortingState = this.loadSortingState(),
  9574. sortingColumn,
  9575. sortingOrder;
  9576. if (typeof loadedSortingState != 'undefined') {
  9577. sortingColumn = loadedSortingState.sortColumn;
  9578. sortingOrder = loadedSortingState.sortOrder;
  9579. } else {
  9580. sortingColumn = sortingSettings.column;
  9581. sortingOrder = sortingSettings.sortOrder;
  9582. }
  9583. this.sortByColumn(sortingColumn, sortingOrder);
  9584. this.hot.sort = function() {
  9585. var args = Array.prototype.slice.call(arguments);
  9586. return _this.sortByColumn.apply(_this, args);
  9587. };
  9588. if (typeof this.hot.getSettings().observeChanges == 'undefined') {
  9589. this.enableObserveChangesPlugin();
  9590. }
  9591. if (source == 'afterInit') {
  9592. this.bindColumnSortingAfterClick();
  9593. this.hot.addHook('afterCreateRow', function() {
  9594. _this.afterCreateRow.apply(_this, arguments);
  9595. });
  9596. this.hot.addHook('afterRemoveRow', function() {
  9597. _this.afterRemoveRow.apply(_this, arguments);
  9598. });
  9599. this.hot.addHook('afterLoadData', function() {
  9600. _this.init.apply(_this, arguments);
  9601. });
  9602. }
  9603. } else {
  9604. this.hot.sort = void 0;
  9605. this.hot.removeHook('afterCreateRow', this.afterCreateRow);
  9606. this.hot.removeHook('afterRemoveRow', this.afterRemoveRow);
  9607. this.hot.removeHook('afterLoadData', this.init);
  9608. }
  9609. },
  9610. setSortingColumn: function(col, order) {
  9611. if (typeof col == 'undefined') {
  9612. this.hot.sortColumn = void 0;
  9613. this.hot.sortOrder = void 0;
  9614. return;
  9615. } else if (this.hot.sortColumn === col && typeof order == 'undefined') {
  9616. if (this.hot.sortOrder === false) {
  9617. this.hot.sortOrder = void 0;
  9618. } else {
  9619. this.hot.sortOrder = !this.hot.sortOrder;
  9620. }
  9621. } else {
  9622. this.hot.sortOrder = typeof order != 'undefined' ? order : true;
  9623. }
  9624. this.hot.sortColumn = col;
  9625. },
  9626. sortByColumn: function(col, order) {
  9627. this.setSortingColumn(col, order);
  9628. if (typeof this.hot.sortColumn == 'undefined') {
  9629. return;
  9630. }
  9631. Handsontable.hooks.run(this.hot, 'beforeColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  9632. this.sort();
  9633. this.hot.render();
  9634. this.saveSortingState();
  9635. Handsontable.hooks.run(this.hot, 'afterColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  9636. },
  9637. saveSortingState: function() {
  9638. var sortingState = {};
  9639. if (typeof this.hot.sortColumn != 'undefined') {
  9640. sortingState.sortColumn = this.hot.sortColumn;
  9641. }
  9642. if (typeof this.hot.sortOrder != 'undefined') {
  9643. sortingState.sortOrder = this.hot.sortOrder;
  9644. }
  9645. if (sortingState.hasOwnProperty('sortColumn') || sortingState.hasOwnProperty('sortOrder')) {
  9646. Handsontable.hooks.run(this.hot, 'persistentStateSave', 'columnSorting', sortingState);
  9647. }
  9648. },
  9649. loadSortingState: function() {
  9650. var storedState = {};
  9651. Handsontable.hooks.run(this.hot, 'persistentStateLoad', 'columnSorting', storedState);
  9652. return storedState.value;
  9653. },
  9654. bindColumnSortingAfterClick: function() {
  9655. var eventManager = eventManagerObject(this.hot),
  9656. _this = this;
  9657. eventManager.addEventListener(this.hot.rootElement, 'click', function(e) {
  9658. if (dom.hasClass(e.target, 'columnSorting')) {
  9659. var col = getColumn(e.target);
  9660. if (col !== this.lastSortedColumn) {
  9661. _this.sortOrderClass = 'ascending';
  9662. } else {
  9663. switch (_this.hot.sortOrder) {
  9664. case void 0:
  9665. _this.sortOrderClass = 'ascending';
  9666. break;
  9667. case true:
  9668. _this.sortOrderClass = 'descending';
  9669. break;
  9670. case false:
  9671. _this.sortOrderClass = void 0;
  9672. }
  9673. }
  9674. this.lastSortedColumn = col;
  9675. _this.sortByColumn(col);
  9676. }
  9677. });
  9678. function countRowHeaders() {
  9679. var THs = _this.hot.view.TBODY.querySelector('tr').querySelectorAll('th');
  9680. return THs.length;
  9681. }
  9682. function getColumn(target) {
  9683. var TH = dom.closest(target, 'TH');
  9684. return dom.index(TH) - countRowHeaders();
  9685. }
  9686. },
  9687. enableObserveChangesPlugin: function() {
  9688. var _this = this;
  9689. this.hot._registerTimeout(setTimeout(function() {
  9690. _this.hot.updateSettings({observeChanges: true});
  9691. }, 0));
  9692. },
  9693. defaultSort: function(sortOrder) {
  9694. return function(a, b) {
  9695. if (typeof a[1] == "string") {
  9696. a[1] = a[1].toLowerCase();
  9697. }
  9698. if (typeof b[1] == "string") {
  9699. b[1] = b[1].toLowerCase();
  9700. }
  9701. if (a[1] === b[1]) {
  9702. return 0;
  9703. }
  9704. if (a[1] === null || a[1] === "") {
  9705. return 1;
  9706. }
  9707. if (b[1] === null || b[1] === "") {
  9708. return -1;
  9709. }
  9710. if (a[1] < b[1]) {
  9711. return sortOrder ? -1 : 1;
  9712. }
  9713. if (a[1] > b[1]) {
  9714. return sortOrder ? 1 : -1;
  9715. }
  9716. return 0;
  9717. };
  9718. },
  9719. dateSort: function(sortOrder) {
  9720. return function(a, b) {
  9721. if (a[1] === b[1]) {
  9722. return 0;
  9723. }
  9724. if (a[1] === null) {
  9725. return 1;
  9726. }
  9727. if (b[1] === null) {
  9728. return -1;
  9729. }
  9730. var aDate = new Date(a[1]);
  9731. var bDate = new Date(b[1]);
  9732. if (aDate < bDate) {
  9733. return sortOrder ? -1 : 1;
  9734. }
  9735. if (aDate > bDate) {
  9736. return sortOrder ? 1 : -1;
  9737. }
  9738. return 0;
  9739. };
  9740. },
  9741. sort: function() {
  9742. if (typeof this.hot.sortOrder == 'undefined') {
  9743. return;
  9744. }
  9745. var colMeta,
  9746. sortFunction;
  9747. this.hot.sortingEnabled = false;
  9748. this.hot.sortIndex.length = 0;
  9749. var colOffset = this.hot.colOffset();
  9750. for (var i = 0,
  9751. ilen = this.hot.countRows() - this.hot.getSettings().minSpareRows; i < ilen; i++) {
  9752. this.hot.sortIndex.push([i, this.hot.getDataAtCell(i, this.hot.sortColumn + colOffset)]);
  9753. }
  9754. colMeta = this.hot.getCellMeta(0, this.hot.sortColumn);
  9755. this.sortIndicators[this.hot.sortColumn] = colMeta.sortIndicator;
  9756. switch (colMeta.type) {
  9757. case 'date':
  9758. sortFunction = this.dateSort;
  9759. break;
  9760. default:
  9761. sortFunction = this.defaultSort;
  9762. }
  9763. this.hot.sortIndex.sort(sortFunction(this.hot.sortOrder));
  9764. for (var i = this.hot.sortIndex.length; i < this.hot.countRows(); i++) {
  9765. this.hot.sortIndex.push([i, this.hot.getDataAtCell(i, this.hot.sortColumn + colOffset)]);
  9766. }
  9767. this.hot.sortingEnabled = true;
  9768. },
  9769. translateRow: function(row) {
  9770. if (this.hot.sortingEnabled && (typeof this.hot.sortOrder !== 'undefined') && this.hot.sortIndex && this.hot.sortIndex.length && this.hot.sortIndex[row]) {
  9771. return this.hot.sortIndex[row][0];
  9772. }
  9773. return row;
  9774. },
  9775. untranslateRow: function(row) {
  9776. if (this.hot.sortingEnabled && this.hot.sortIndex && this.hot.sortIndex.length) {
  9777. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  9778. if (this.hot.sortIndex[i][0] == row) {
  9779. return i;
  9780. }
  9781. }
  9782. }
  9783. },
  9784. getColHeader: function(col, TH) {
  9785. var headerLink = TH.querySelector('.colHeader');
  9786. if (this.hot.getSettings().columnSorting && col >= 0) {
  9787. dom.addClass(headerLink, 'columnSorting');
  9788. }
  9789. dom.removeClass(headerLink, 'descending');
  9790. dom.removeClass(headerLink, 'ascending');
  9791. if (this.sortIndicators[col]) {
  9792. if (col === this.hot.sortColumn) {
  9793. if (this.sortOrderClass === 'ascending') {
  9794. dom.addClass(headerLink, 'ascending');
  9795. } else if (this.sortOrderClass === 'descending') {
  9796. dom.addClass(headerLink, 'descending');
  9797. }
  9798. }
  9799. }
  9800. },
  9801. isSorted: function() {
  9802. return typeof this.hot.sortColumn != 'undefined';
  9803. },
  9804. afterCreateRow: function(index, amount) {
  9805. if (!this.isSorted()) {
  9806. return;
  9807. }
  9808. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  9809. if (this.hot.sortIndex[i][0] >= index) {
  9810. this.hot.sortIndex[i][0] += amount;
  9811. }
  9812. }
  9813. for (var i = 0; i < amount; i++) {
  9814. this.hot.sortIndex.splice(index + i, 0, [index + i, this.hot.getData()[index + i][this.hot.sortColumn + this.hot.colOffset()]]);
  9815. }
  9816. this.saveSortingState();
  9817. },
  9818. afterRemoveRow: function(index, amount) {
  9819. if (!this.isSorted()) {
  9820. return;
  9821. }
  9822. var physicalRemovedIndex = this.translateRow(index);
  9823. this.hot.sortIndex.splice(index, amount);
  9824. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  9825. if (this.hot.sortIndex[i][0] > physicalRemovedIndex) {
  9826. this.hot.sortIndex[i][0] -= amount;
  9827. }
  9828. }
  9829. this.saveSortingState();
  9830. }
  9831. }, {}, BasePlugin);
  9832. var $__default = ColumnSorting;
  9833. registerPlugin('columnSorting', ColumnSorting);
  9834. //#
  9835. },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../plugins.js":45,"./../_base.js":46}],50:[function(require,module,exports){
  9836. "use strict";
  9837. Object.defineProperties(exports, {
  9838. CommentEditor: {get: function() {
  9839. return CommentEditor;
  9840. }},
  9841. __esModule: {value: true}
  9842. });
  9843. var $___46__46__47__46__46__47_dom_46_js__;
  9844. 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__});
  9845. var CommentEditor = function CommentEditor() {
  9846. this.editor = this.createEditor();
  9847. this.editorStyle = this.editor.style;
  9848. this.editorStyle.position = 'absolute';
  9849. this.editorStyle.zIndex = 100;
  9850. this.hide();
  9851. };
  9852. var $CommentEditor = CommentEditor;
  9853. ($traceurRuntime.createClass)(CommentEditor, {
  9854. setPosition: function(x, y) {
  9855. this.editorStyle.left = x + 'px';
  9856. this.editorStyle.top = y + 'px';
  9857. },
  9858. show: function() {
  9859. this.editorStyle.display = 'block';
  9860. },
  9861. hide: function() {
  9862. this.editorStyle.display = 'none';
  9863. },
  9864. isVisible: function() {
  9865. return this.editorStyle.display === 'block';
  9866. },
  9867. setValue: function() {
  9868. var value = arguments[0] !== (void 0) ? arguments[0] : '';
  9869. value = value || '';
  9870. this.getInputElement().value = value;
  9871. },
  9872. getValue: function() {
  9873. return this.getInputElement().value;
  9874. },
  9875. isFocused: function() {
  9876. return document.activeElement === this.getInputElement();
  9877. },
  9878. focus: function() {
  9879. this.getInputElement().focus();
  9880. },
  9881. createEditor: function() {
  9882. var container = document.querySelector('.' + $CommentEditor.CLASS_EDITOR_CONTAINER);
  9883. var editor;
  9884. var textArea;
  9885. if (!container) {
  9886. container = document.createElement('div');
  9887. dom.addClass(container, $CommentEditor.CLASS_EDITOR_CONTAINER);
  9888. document.body.appendChild(container);
  9889. }
  9890. editor = document.createElement('div');
  9891. dom.addClass(editor, $CommentEditor.CLASS_EDITOR);
  9892. textArea = document.createElement('textarea');
  9893. dom.addClass(textArea, $CommentEditor.CLASS_INPUT);
  9894. editor.appendChild(textArea);
  9895. container.appendChild(editor);
  9896. return editor;
  9897. },
  9898. getInputElement: function() {
  9899. return this.editor.querySelector('.' + $CommentEditor.CLASS_INPUT);
  9900. },
  9901. destroy: function() {
  9902. this.editor.parentNode.removeChild(this.editor);
  9903. this.editor = null;
  9904. this.editorStyle = null;
  9905. }
  9906. }, {
  9907. get CLASS_EDITOR_CONTAINER() {
  9908. return 'htCommentsContainer';
  9909. },
  9910. get CLASS_EDITOR() {
  9911. return 'htComments';
  9912. },
  9913. get CLASS_INPUT() {
  9914. return 'htCommentTextArea';
  9915. },
  9916. get CLASS_CELL() {
  9917. return 'htCommentCell';
  9918. }
  9919. });
  9920. ;
  9921. //#
  9922. },{"./../../dom.js":27}],51:[function(require,module,exports){
  9923. "use strict";
  9924. Object.defineProperties(exports, {
  9925. Comments: {get: function() {
  9926. return Comments;
  9927. }},
  9928. __esModule: {value: true}
  9929. });
  9930. var $___46__46__47__46__46__47_dom_46_js__,
  9931. $___46__46__47__46__46__47_eventManager_46_js__,
  9932. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
  9933. $___46__46__47__46__46__47_plugins_46_js__,
  9934. $___46__46__47__95_base_46_js__,
  9935. $__commentEditor_46_js__;
  9936. 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__});
  9937. 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;
  9938. 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;
  9939. 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__}),
  9940. registerPlugin = $__2.registerPlugin,
  9941. getPlugin = $__2.getPlugin;
  9942. 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;
  9943. var CommentEditor = ($__commentEditor_46_js__ = require("./commentEditor.js"), $__commentEditor_46_js__ && $__commentEditor_46_js__.__esModule && $__commentEditor_46_js__ || {default: $__commentEditor_46_js__}).CommentEditor;
  9944. var Comments = function Comments(hotInstance) {
  9945. var $__5 = this;
  9946. $traceurRuntime.superConstructor($Comments).call(this, hotInstance);
  9947. if (!this.hot.getSettings().comments) {
  9948. return;
  9949. }
  9950. this.editor = new CommentEditor();
  9951. this.eventManager = new EventManager(this);
  9952. this.range = {};
  9953. this.mouseDown = false;
  9954. this.contextMenuEvent = false;
  9955. this.timer = null;
  9956. this.hot.addHook('afterInit', (function() {
  9957. return $__5.registerListeners();
  9958. }));
  9959. this.hot.addHook('afterContextMenuDefaultOptions', (function(options) {
  9960. return $__5.addToContextMenu(options);
  9961. }));
  9962. this.hot.addHook('afterRenderer', (function(TD, row, col, prop, value, cellProperties) {
  9963. return $__5.onAfterRenderer(TD, cellProperties);
  9964. }));
  9965. this.hot.addHook('afterScrollVertically', (function() {
  9966. return $__5.refreshEditorPosition();
  9967. }));
  9968. this.hot.addHook('afterColumnResize', (function() {
  9969. return $__5.refreshEditorPosition();
  9970. }));
  9971. this.hot.addHook('afterRowResize', (function() {
  9972. return $__5.refreshEditorPosition();
  9973. }));
  9974. };
  9975. var $Comments = Comments;
  9976. ($traceurRuntime.createClass)(Comments, {
  9977. registerListeners: function() {
  9978. var $__5 = this;
  9979. this.eventManager.addEventListener(document, 'mouseover', (function(event) {
  9980. return $__5.onMouseOver(event);
  9981. }));
  9982. this.eventManager.addEventListener(document, 'mousedown', (function(event) {
  9983. return $__5.onMouseDown(event);
  9984. }));
  9985. this.eventManager.addEventListener(document, 'mousemove', (function(event) {
  9986. return $__5.onMouseMove(event);
  9987. }));
  9988. this.eventManager.addEventListener(document, 'mouseup', (function(event) {
  9989. return $__5.onMouseUp(event);
  9990. }));
  9991. this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', (function(event) {
  9992. return $__5.onEditorBlur(event);
  9993. }));
  9994. },
  9995. setRange: function(range) {
  9996. this.range = range;
  9997. },
  9998. clearRange: function() {
  9999. this.range = {};
  10000. },
  10001. targetIsCellWithComment: function(event) {
  10002. return dom.hasClass(event.target, 'htCommentCell') && dom.closest(event.target, [this.hot.rootElement]) ? true : false;
  10003. },
  10004. targetIsCommentTextArea: function(event) {
  10005. return this.editor.getInputElement() === event.target;
  10006. },
  10007. saveComment: function() {
  10008. if (!this.range.from) {
  10009. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  10010. }
  10011. var comment = this.editor.getValue();
  10012. var row = this.range.from.row;
  10013. var col = this.range.from.col;
  10014. this.hot.setCellMeta(row, col, 'comment', comment);
  10015. this.hot.render();
  10016. },
  10017. saveCommentAtCell: function(row, col) {
  10018. this.setRange({from: new WalkontableCellCoords(row, col)});
  10019. this.saveComment();
  10020. },
  10021. removeComment: function() {
  10022. if (!this.range.from) {
  10023. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  10024. }
  10025. this.hot.removeCellMeta(this.range.from.row, this.range.from.col, 'comment');
  10026. this.hot.render();
  10027. this.hide();
  10028. },
  10029. removeCommentAtCell: function(row, col) {
  10030. this.setRange({from: new WalkontableCellCoords(row, col)});
  10031. this.removeComment();
  10032. },
  10033. show: function() {
  10034. if (!this.range.from) {
  10035. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  10036. }
  10037. var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
  10038. this.refreshEditorPosition(true);
  10039. this.editor.setValue(meta.comment || '');
  10040. this.editor.show();
  10041. return true;
  10042. },
  10043. showAtCell: function(row, col) {
  10044. this.setRange({from: new WalkontableCellCoords(row, col)});
  10045. return this.show();
  10046. },
  10047. hide: function() {
  10048. this.editor.hide();
  10049. },
  10050. refreshEditorPosition: function() {
  10051. var force = arguments[0] !== (void 0) ? arguments[0] : false;
  10052. if (!force && (!this.range.from || !this.editor.isVisible())) {
  10053. return;
  10054. }
  10055. var TD = this.hot.view.wt.wtTable.getCell(this.range.from);
  10056. var offset = dom.offset(TD);
  10057. var lastColWidth = this.hot.getColWidth(this.range.from.col);
  10058. var cellTopOffset = offset.top;
  10059. var cellLeftOffset = offset.left;
  10060. var verticalCompensation = 0;
  10061. var horizontalCompensation = 0;
  10062. if (this.hot.view.wt.wtViewport.hasVerticalScroll()) {
  10063. cellTopOffset = cellTopOffset - this.hot.view.wt.wtOverlays.topOverlay.getScrollPosition();
  10064. verticalCompensation = 20;
  10065. }
  10066. if (this.hot.view.wt.wtViewport.hasHorizontalScroll()) {
  10067. cellLeftOffset = cellLeftOffset - this.hot.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  10068. horizontalCompensation = 20;
  10069. }
  10070. var x = cellLeftOffset + lastColWidth;
  10071. var y = cellTopOffset;
  10072. var rect = this.hot.view.wt.wtTable.holder.getBoundingClientRect();
  10073. var holderPos = {
  10074. left: rect.left + dom.getWindowScrollLeft() + horizontalCompensation,
  10075. right: rect.right + dom.getWindowScrollLeft() - 15,
  10076. top: rect.top + dom.getWindowScrollTop() + verticalCompensation,
  10077. bottom: rect.bottom + dom.getWindowScrollTop()
  10078. };
  10079. if (x <= holderPos.left || x > holderPos.right || y <= holderPos.top || y > holderPos.bottom) {
  10080. this.hide();
  10081. } else {
  10082. this.editor.setPosition(x, y);
  10083. }
  10084. },
  10085. onMouseDown: function(event) {
  10086. this.mouseDown = true;
  10087. if (!this.hot.view || !this.hot.view.wt) {
  10088. return;
  10089. }
  10090. if (!this.contextMenuEvent && !this.targetIsCommentTextArea(event) && !this.targetIsCellWithComment(event)) {
  10091. this.hide();
  10092. }
  10093. this.contextMenuEvent = false;
  10094. },
  10095. onMouseOver: function(event) {
  10096. if (this.mouseDown || this.editor.isFocused()) {
  10097. return;
  10098. }
  10099. if (this.targetIsCellWithComment(event)) {
  10100. var coordinates = this.hot.view.wt.wtTable.getCoords(event.target);
  10101. var range = {from: new WalkontableCellCoords(coordinates.row, coordinates.col)};
  10102. this.setRange(range);
  10103. this.show();
  10104. } else if (!this.targetIsCommentTextArea(event) && !this.editor.isFocused()) {
  10105. this.hide();
  10106. }
  10107. },
  10108. onMouseMove: function(event) {
  10109. var $__5 = this;
  10110. if (this.targetIsCommentTextArea(event)) {
  10111. this.mouseDown = true;
  10112. clearTimeout(this.timer);
  10113. this.timer = setTimeout((function() {
  10114. $__5.mouseDown = false;
  10115. }), 200);
  10116. }
  10117. },
  10118. onMouseUp: function(event) {
  10119. this.mouseDown = false;
  10120. },
  10121. onAfterRenderer: function(TD, cellProperties) {
  10122. if (cellProperties.comment) {
  10123. dom.addClass(TD, cellProperties.commentedCellClassName);
  10124. }
  10125. },
  10126. onEditorBlur: function(event) {
  10127. this.saveComment();
  10128. },
  10129. checkSelectionCommentsConsistency: function() {
  10130. var hasComment = false;
  10131. var cell = this.hot.getSelectedRange().from;
  10132. if (this.hot.getCellMeta(cell.row, cell.col).comment) {
  10133. hasComment = true;
  10134. }
  10135. return hasComment;
  10136. },
  10137. onContextMenuAddComment: function() {
  10138. var $__5 = this;
  10139. var coords = this.hot.getSelectedRange();
  10140. this.contextMenuEvent = true;
  10141. this.setRange({from: coords.from});
  10142. this.show();
  10143. setTimeout((function() {
  10144. if ($__5.hot) {
  10145. $__5.hot.deselectCell();
  10146. $__5.editor.focus();
  10147. }
  10148. }), 10);
  10149. },
  10150. onContextMenuRemoveComment: function(key, selection) {
  10151. this.contextMenuEvent = true;
  10152. this.removeCommentAtCell(selection.start.row, selection.start.col);
  10153. },
  10154. addToContextMenu: function(defaultOptions) {
  10155. var $__5 = this;
  10156. defaultOptions.items.push(Handsontable.ContextMenu.SEPARATOR, {
  10157. key: 'commentsAddEdit',
  10158. name: (function() {
  10159. return $__5.checkSelectionCommentsConsistency() ? 'Edit Comment' : 'Add Comment';
  10160. }),
  10161. callback: (function() {
  10162. return $__5.onContextMenuAddComment();
  10163. }),
  10164. disabled: function() {
  10165. return false;
  10166. }
  10167. }, {
  10168. key: 'commentsRemove',
  10169. name: function() {
  10170. return 'Delete Comment';
  10171. },
  10172. callback: (function(key, selection) {
  10173. return $__5.onContextMenuRemoveComment(key, selection);
  10174. }),
  10175. disabled: (function() {
  10176. return !$__5.checkSelectionCommentsConsistency();
  10177. })
  10178. });
  10179. },
  10180. destroy: function() {
  10181. if (this.eventManager) {
  10182. this.eventManager.clear();
  10183. }
  10184. if (this.editor) {
  10185. this.editor.destroy();
  10186. }
  10187. $traceurRuntime.superGet(this, $Comments.prototype, "destroy").call(this);
  10188. }
  10189. }, {}, BasePlugin);
  10190. ;
  10191. registerPlugin('comments', Comments);
  10192. //#
  10193. },{"./../../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){
  10194. "use strict";
  10195. Object.defineProperties(exports, {
  10196. ContextMenu: {get: function() {
  10197. return ContextMenu;
  10198. }},
  10199. __esModule: {value: true}
  10200. });
  10201. var $___46__46__47__46__46__47_helpers_46_js__,
  10202. $___46__46__47__46__46__47_dom_46_js__,
  10203. $___46__46__47__46__46__47_eventManager_46_js__,
  10204. $___46__46__47__46__46__47_plugins_46_js__;
  10205. 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__});
  10206. 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__});
  10207. 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;
  10208. 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;
  10209. ;
  10210. function ContextMenu(instance, customOptions) {
  10211. this.instance = instance;
  10212. var contextMenu = this;
  10213. contextMenu.menus = [];
  10214. contextMenu.htMenus = {};
  10215. contextMenu.triggerRows = [];
  10216. contextMenu.eventManager = eventManagerObject(contextMenu);
  10217. this.enabled = true;
  10218. this.instance.addHook('afterDestroy', function() {
  10219. contextMenu.destroy();
  10220. });
  10221. this.defaultOptions = {items: [{
  10222. key: 'row_above',
  10223. name: 'Insert row above',
  10224. callback: function(key, selection) {
  10225. this.alter("insert_row", selection.start.row);
  10226. },
  10227. disabled: function() {
  10228. var selected = this.getSelected(),
  10229. entireColumnSelection = [0, selected[1], this.countRows() - 1, selected[1]],
  10230. columnSelected = entireColumnSelection.join(',') == selected.join(',');
  10231. return selected[0] < 0 || this.countRows() >= this.getSettings().maxRows || columnSelected;
  10232. }
  10233. }, {
  10234. key: 'row_below',
  10235. name: 'Insert row below',
  10236. callback: function(key, selection) {
  10237. this.alter("insert_row", selection.end.row + 1);
  10238. },
  10239. disabled: function() {
  10240. var selected = this.getSelected(),
  10241. entireColumnSelection = [0, selected[1], this.countRows() - 1, selected[1]],
  10242. columnSelected = entireColumnSelection.join(',') == selected.join(',');
  10243. return this.getSelected()[0] < 0 || this.countRows() >= this.getSettings().maxRows || columnSelected;
  10244. }
  10245. }, ContextMenu.SEPARATOR, {
  10246. key: 'col_left',
  10247. name: 'Insert column on the left',
  10248. callback: function(key, selection) {
  10249. this.alter("insert_col", selection.start.col);
  10250. },
  10251. disabled: function() {
  10252. if (!this.isColumnModificationAllowed()) {
  10253. return true;
  10254. }
  10255. var selected = this.getSelected(),
  10256. entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1],
  10257. rowSelected = entireRowSelection.join(',') == selected.join(',');
  10258. return this.getSelected()[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
  10259. }
  10260. }, {
  10261. key: 'col_right',
  10262. name: 'Insert column on the right',
  10263. callback: function(key, selection) {
  10264. this.alter("insert_col", selection.end.col + 1);
  10265. },
  10266. disabled: function() {
  10267. if (!this.isColumnModificationAllowed()) {
  10268. return true;
  10269. }
  10270. var selected = this.getSelected(),
  10271. entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1],
  10272. rowSelected = entireRowSelection.join(',') == selected.join(',');
  10273. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
  10274. }
  10275. }, ContextMenu.SEPARATOR, {
  10276. key: 'remove_row',
  10277. name: 'Remove row',
  10278. callback: function(key, selection) {
  10279. var amount = selection.end.row - selection.start.row + 1;
  10280. this.alter("remove_row", selection.start.row, amount);
  10281. },
  10282. disabled: function() {
  10283. var selected = this.getSelected(),
  10284. entireColumnSelection = [0, selected[1], this.countRows() - 1, selected[1]],
  10285. columnSelected = entireColumnSelection.join(',') == selected.join(',');
  10286. return (selected[0] < 0 || columnSelected);
  10287. }
  10288. }, {
  10289. key: 'remove_col',
  10290. name: 'Remove column',
  10291. callback: function(key, selection) {
  10292. var amount = selection.end.col - selection.start.col + 1;
  10293. this.alter("remove_col", selection.start.col, amount);
  10294. },
  10295. disabled: function() {
  10296. if (!this.isColumnModificationAllowed()) {
  10297. return true;
  10298. }
  10299. var selected = this.getSelected(),
  10300. entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1],
  10301. rowSelected = entireRowSelection.join(',') == selected.join(',');
  10302. return (selected[1] < 0 || rowSelected);
  10303. }
  10304. }, ContextMenu.SEPARATOR, {
  10305. key: 'undo',
  10306. name: 'Undo',
  10307. callback: function() {
  10308. this.undo();
  10309. },
  10310. disabled: function() {
  10311. return this.undoRedo && !this.undoRedo.isUndoAvailable();
  10312. }
  10313. }, {
  10314. key: 'redo',
  10315. name: 'Redo',
  10316. callback: function() {
  10317. this.redo();
  10318. },
  10319. disabled: function() {
  10320. return this.undoRedo && !this.undoRedo.isRedoAvailable();
  10321. }
  10322. }, ContextMenu.SEPARATOR, {
  10323. key: 'make_read_only',
  10324. name: function() {
  10325. var label = "Read only";
  10326. var atLeastOneReadOnly = contextMenu.checkSelectionReadOnlyConsistency(this);
  10327. if (atLeastOneReadOnly) {
  10328. label = contextMenu.markSelected(label);
  10329. }
  10330. return label;
  10331. },
  10332. callback: function() {
  10333. var atLeastOneReadOnly = contextMenu.checkSelectionReadOnlyConsistency(this);
  10334. var that = this;
  10335. this.getSelectedRange().forAll(function(r, c) {
  10336. that.getCellMeta(r, c).readOnly = atLeastOneReadOnly ? false : true;
  10337. });
  10338. this.render();
  10339. }
  10340. }, ContextMenu.SEPARATOR, {
  10341. key: 'alignment',
  10342. name: 'Alignment',
  10343. submenu: {items: [{
  10344. name: function() {
  10345. var label = "Left";
  10346. var hasClass = contextMenu.checkSelectionAlignment(this, 'htLeft');
  10347. if (hasClass) {
  10348. label = contextMenu.markSelected(label);
  10349. }
  10350. return label;
  10351. },
  10352. callback: function() {
  10353. align.call(this, this.getSelectedRange(), 'horizontal', 'htLeft');
  10354. },
  10355. disabled: false
  10356. }, {
  10357. name: function() {
  10358. var label = "Center";
  10359. var hasClass = contextMenu.checkSelectionAlignment(this, 'htCenter');
  10360. if (hasClass) {
  10361. label = contextMenu.markSelected(label);
  10362. }
  10363. return label;
  10364. },
  10365. callback: function() {
  10366. align.call(this, this.getSelectedRange(), 'horizontal', 'htCenter');
  10367. },
  10368. disabled: false
  10369. }, {
  10370. name: function() {
  10371. var label = "Right";
  10372. var hasClass = contextMenu.checkSelectionAlignment(this, 'htRight');
  10373. if (hasClass) {
  10374. label = contextMenu.markSelected(label);
  10375. }
  10376. return label;
  10377. },
  10378. callback: function() {
  10379. align.call(this, this.getSelectedRange(), 'horizontal', 'htRight');
  10380. },
  10381. disabled: false
  10382. }, {
  10383. name: function() {
  10384. var label = "Justify";
  10385. var hasClass = contextMenu.checkSelectionAlignment(this, 'htJustify');
  10386. if (hasClass) {
  10387. label = contextMenu.markSelected(label);
  10388. }
  10389. return label;
  10390. },
  10391. callback: function() {
  10392. align.call(this, this.getSelectedRange(), 'horizontal', 'htJustify');
  10393. },
  10394. disabled: false
  10395. }, ContextMenu.SEPARATOR, {
  10396. name: function() {
  10397. var label = "Top";
  10398. var hasClass = contextMenu.checkSelectionAlignment(this, 'htTop');
  10399. if (hasClass) {
  10400. label = contextMenu.markSelected(label);
  10401. }
  10402. return label;
  10403. },
  10404. callback: function() {
  10405. align.call(this, this.getSelectedRange(), 'vertical', 'htTop');
  10406. },
  10407. disabled: false
  10408. }, {
  10409. name: function() {
  10410. var label = "Middle";
  10411. var hasClass = contextMenu.checkSelectionAlignment(this, 'htMiddle');
  10412. if (hasClass) {
  10413. label = contextMenu.markSelected(label);
  10414. }
  10415. return label;
  10416. },
  10417. callback: function() {
  10418. align.call(this, this.getSelectedRange(), 'vertical', 'htMiddle');
  10419. },
  10420. disabled: false
  10421. }, {
  10422. name: function() {
  10423. var label = "Bottom";
  10424. var hasClass = contextMenu.checkSelectionAlignment(this, 'htBottom');
  10425. if (hasClass) {
  10426. label = contextMenu.markSelected(label);
  10427. }
  10428. return label;
  10429. },
  10430. callback: function() {
  10431. align.call(this, this.getSelectedRange(), 'vertical', 'htBottom');
  10432. },
  10433. disabled: false
  10434. }]}
  10435. }]};
  10436. contextMenu.options = {};
  10437. helper.extend(contextMenu.options, this.options);
  10438. this.bindMouseEvents();
  10439. this.markSelected = function(label) {
  10440. return "<span class='selected'>" + String.fromCharCode(10003) + "</span>" + label;
  10441. };
  10442. this.checkSelectionAlignment = function(hot, className) {
  10443. var hasAlignment = false;
  10444. hot.getSelectedRange().forAll(function(r, c) {
  10445. var metaClassName = hot.getCellMeta(r, c).className;
  10446. if (metaClassName && metaClassName.indexOf(className) != -1) {
  10447. hasAlignment = true;
  10448. return false;
  10449. }
  10450. });
  10451. return hasAlignment;
  10452. };
  10453. if (!this.instance.getSettings().allowInsertRow) {
  10454. var rowAboveIndex = findIndexByKey(this.defaultOptions.items, 'row_above');
  10455. this.defaultOptions.items.splice(rowAboveIndex, 1);
  10456. var rowBelowIndex = findIndexByKey(this.defaultOptions.items, 'row_above');
  10457. this.defaultOptions.items.splice(rowBelowIndex, 1);
  10458. this.defaultOptions.items.splice(rowBelowIndex, 1);
  10459. }
  10460. if (!this.instance.getSettings().allowInsertColumn) {
  10461. var colLeftIndex = findIndexByKey(this.defaultOptions.items, 'col_left');
  10462. this.defaultOptions.items.splice(colLeftIndex, 1);
  10463. var colRightIndex = findIndexByKey(this.defaultOptions.items, 'col_right');
  10464. this.defaultOptions.items.splice(colRightIndex, 1);
  10465. this.defaultOptions.items.splice(colRightIndex, 1);
  10466. }
  10467. var removeRow = false;
  10468. var removeCol = false;
  10469. var removeRowIndex,
  10470. removeColumnIndex;
  10471. if (!this.instance.getSettings().allowRemoveRow) {
  10472. removeRowIndex = findIndexByKey(this.defaultOptions.items, 'remove_row');
  10473. this.defaultOptions.items.splice(removeRowIndex, 1);
  10474. removeRow = true;
  10475. }
  10476. if (!this.instance.getSettings().allowRemoveColumn) {
  10477. removeColumnIndex = findIndexByKey(this.defaultOptions.items, 'remove_col');
  10478. this.defaultOptions.items.splice(removeColumnIndex, 1);
  10479. removeCol = true;
  10480. }
  10481. if (removeRow && removeCol) {
  10482. this.defaultOptions.items.splice(removeColumnIndex, 1);
  10483. }
  10484. this.checkSelectionReadOnlyConsistency = function(hot) {
  10485. var atLeastOneReadOnly = false;
  10486. hot.getSelectedRange().forAll(function(r, c) {
  10487. if (hot.getCellMeta(r, c).readOnly) {
  10488. atLeastOneReadOnly = true;
  10489. return false;
  10490. }
  10491. });
  10492. return atLeastOneReadOnly;
  10493. };
  10494. Handsontable.hooks.run(instance, 'afterContextMenuDefaultOptions', this.defaultOptions);
  10495. }
  10496. ContextMenu.prototype.createMenu = function(menuName, row) {
  10497. if (menuName) {
  10498. menuName = menuName.replace(/ /g, '_');
  10499. menuName = 'htContextSubMenu_' + menuName;
  10500. }
  10501. var menu;
  10502. if (menuName) {
  10503. menu = document.querySelector('.htContextMenu.' + menuName);
  10504. } else {
  10505. menu = document.querySelector('.htContextMenu');
  10506. }
  10507. if (!menu) {
  10508. menu = document.createElement('DIV');
  10509. dom.addClass(menu, 'htContextMenu');
  10510. if (menuName) {
  10511. dom.addClass(menu, menuName);
  10512. }
  10513. document.getElementsByTagName('body')[0].appendChild(menu);
  10514. }
  10515. if (this.menus.indexOf(menu) < 0) {
  10516. this.menus.push(menu);
  10517. row = row || 0;
  10518. this.triggerRows.push(row);
  10519. }
  10520. return menu;
  10521. };
  10522. ContextMenu.prototype.bindMouseEvents = function() {
  10523. function contextMenuOpenListener(event) {
  10524. var settings = this.instance.getSettings(),
  10525. showRowHeaders = this.instance.getSettings().rowHeaders,
  10526. showColHeaders = this.instance.getSettings().colHeaders,
  10527. containsCornerHeader,
  10528. element,
  10529. items,
  10530. menu;
  10531. function isValidElement(element) {
  10532. return element.nodeName === 'TD' || element.parentNode.nodeName === 'TD';
  10533. }
  10534. element = event.realTarget;
  10535. this.closeAll();
  10536. event.preventDefault();
  10537. helper.stopPropagation(event);
  10538. if (!(showRowHeaders || showColHeaders)) {
  10539. if (!isValidElement(element) && !(dom.hasClass(element, 'current') && dom.hasClass(element, 'wtBorder'))) {
  10540. return;
  10541. }
  10542. } else if (showRowHeaders && showColHeaders) {
  10543. containsCornerHeader = element.parentNode.querySelectorAll('.cornerHeader').length > 0;
  10544. if (containsCornerHeader) {
  10545. return;
  10546. }
  10547. }
  10548. menu = this.createMenu();
  10549. items = this.getItems(settings.contextMenu);
  10550. this.show(menu, items);
  10551. this.setMenuPosition(event, menu);
  10552. this.eventManager.addEventListener(document.documentElement, 'mousedown', helper.proxy(ContextMenu.prototype.closeAll, this));
  10553. }
  10554. var eventManager = eventManagerObject(this.instance);
  10555. eventManager.addEventListener(this.instance.rootElement, 'contextmenu', helper.proxy(contextMenuOpenListener, this));
  10556. };
  10557. ContextMenu.prototype.bindTableEvents = function() {
  10558. this._afterScrollCallback = function() {};
  10559. this.instance.addHook('afterScrollVertically', this._afterScrollCallback);
  10560. this.instance.addHook('afterScrollHorizontally', this._afterScrollCallback);
  10561. };
  10562. ContextMenu.prototype.unbindTableEvents = function() {
  10563. if (this._afterScrollCallback) {
  10564. this.instance.removeHook('afterScrollVertically', this._afterScrollCallback);
  10565. this.instance.removeHook('afterScrollHorizontally', this._afterScrollCallback);
  10566. this._afterScrollCallback = null;
  10567. }
  10568. };
  10569. ContextMenu.prototype.performAction = function(event, hot) {
  10570. var contextMenu = this;
  10571. var selectedItemIndex = hot.getSelected()[0];
  10572. var selectedItem = hot.getData()[selectedItemIndex];
  10573. if (selectedItem.disabled === true || (typeof selectedItem.disabled == 'function' && selectedItem.disabled.call(this.instance) === true)) {
  10574. return;
  10575. }
  10576. if (!selectedItem.hasOwnProperty('submenu')) {
  10577. if (typeof selectedItem.callback != 'function') {
  10578. return;
  10579. }
  10580. var selRange = this.instance.getSelectedRange();
  10581. var normalizedSelection = ContextMenu.utils.normalizeSelection(selRange);
  10582. selectedItem.callback.call(this.instance, selectedItem.key, normalizedSelection, event);
  10583. contextMenu.closeAll();
  10584. }
  10585. };
  10586. ContextMenu.prototype.unbindMouseEvents = function() {
  10587. this.eventManager.clear();
  10588. var eventManager = eventManagerObject(this.instance);
  10589. eventManager.removeEventListener(this.instance.rootElement, 'contextmenu');
  10590. };
  10591. ContextMenu.prototype.show = function(menu, items) {
  10592. var that = this;
  10593. menu.removeAttribute('style');
  10594. menu.style.display = 'block';
  10595. var settings = {
  10596. data: items,
  10597. colHeaders: false,
  10598. colWidths: [200],
  10599. readOnly: true,
  10600. copyPaste: false,
  10601. columns: [{
  10602. data: 'name',
  10603. renderer: helper.proxy(this.renderer, this)
  10604. }],
  10605. renderAllRows: true,
  10606. beforeKeyDown: function(event) {
  10607. that.onBeforeKeyDown(event, htContextMenu);
  10608. },
  10609. afterOnCellMouseOver: function(event, coords, TD) {
  10610. that.onCellMouseOver(event, coords, TD, htContextMenu);
  10611. }
  10612. };
  10613. var htContextMenu = new Handsontable(menu, settings);
  10614. htContextMenu.isHotTableEnv = this.instance.isHotTableEnv;
  10615. Handsontable.eventManager.isHotTableEnv = this.instance.isHotTableEnv;
  10616. this.eventManager.removeEventListener(menu, 'mousedown');
  10617. this.eventManager.addEventListener(menu, 'mousedown', function(event) {
  10618. that.performAction(event, htContextMenu);
  10619. });
  10620. this.bindTableEvents();
  10621. htContextMenu.listen();
  10622. this.htMenus[htContextMenu.guid] = htContextMenu;
  10623. Handsontable.hooks.run(this.instance, 'afterContextMenuShow', htContextMenu);
  10624. };
  10625. ContextMenu.prototype.close = function(menu) {
  10626. this.hide(menu);
  10627. this.eventManager.clear();
  10628. this.unbindTableEvents();
  10629. this.instance.listen();
  10630. };
  10631. ContextMenu.prototype.closeAll = function() {
  10632. while (this.menus.length > 0) {
  10633. var menu = this.menus.pop();
  10634. if (menu) {
  10635. this.close(menu);
  10636. }
  10637. }
  10638. this.triggerRows = [];
  10639. };
  10640. ContextMenu.prototype.closeLastOpenedSubMenu = function() {
  10641. var menu = this.menus.pop();
  10642. if (menu) {
  10643. this.hide(menu);
  10644. }
  10645. };
  10646. ContextMenu.prototype.hide = function(menu) {
  10647. menu.style.display = 'none';
  10648. var instance = this.htMenus[menu.id];
  10649. Handsontable.hooks.run(this.instance, 'afterContextMenuHide', instance);
  10650. instance.destroy();
  10651. delete this.htMenus[menu.id];
  10652. };
  10653. ContextMenu.prototype.renderer = function(instance, TD, row, col, prop, value) {
  10654. var contextMenu = this;
  10655. var item = instance.getData()[row];
  10656. var wrapper = document.createElement('DIV');
  10657. if (typeof value === 'function') {
  10658. value = value.call(this.instance);
  10659. }
  10660. dom.empty(TD);
  10661. TD.appendChild(wrapper);
  10662. if (itemIsSeparator(item)) {
  10663. dom.addClass(TD, 'htSeparator');
  10664. } else {
  10665. dom.fastInnerHTML(wrapper, value);
  10666. }
  10667. if (itemIsDisabled(item)) {
  10668. dom.addClass(TD, 'htDisabled');
  10669. this.eventManager.addEventListener(wrapper, 'mouseenter', function() {
  10670. instance.deselectCell();
  10671. });
  10672. } else {
  10673. if (isSubMenu(item)) {
  10674. dom.addClass(TD, 'htSubmenu');
  10675. this.eventManager.addEventListener(wrapper, 'mouseenter', function() {
  10676. instance.selectCell(row, col);
  10677. });
  10678. } else {
  10679. dom.removeClass(TD, 'htSubmenu');
  10680. dom.removeClass(TD, 'htDisabled');
  10681. this.eventManager.addEventListener(wrapper, 'mouseenter', function() {
  10682. instance.selectCell(row, col);
  10683. });
  10684. }
  10685. }
  10686. function isSubMenu(item) {
  10687. return item.hasOwnProperty('submenu');
  10688. }
  10689. function itemIsSeparator(item) {
  10690. return new RegExp(ContextMenu.SEPARATOR.name, 'i').test(item.name);
  10691. }
  10692. function itemIsDisabled(item) {
  10693. return item.disabled === true || (typeof item.disabled == 'function' && item.disabled.call(contextMenu.instance) === true);
  10694. }
  10695. };
  10696. ContextMenu.prototype.onCellMouseOver = function(event, coords, TD, hot) {
  10697. var menusLength = this.menus.length;
  10698. if (menusLength > 0) {
  10699. var lastMenu = this.menus[menusLength - 1];
  10700. if (lastMenu.id != hot.guid) {
  10701. this.closeLastOpenedSubMenu();
  10702. }
  10703. } else {
  10704. this.closeLastOpenedSubMenu();
  10705. }
  10706. if (TD.className.indexOf('htSubmenu') != -1) {
  10707. var selectedItem = hot.getData()[coords.row];
  10708. var items = this.getItems(selectedItem.submenu);
  10709. var subMenu = this.createMenu(selectedItem.name, coords.row);
  10710. var tdCoords = TD.getBoundingClientRect();
  10711. this.show(subMenu, items);
  10712. this.setSubMenuPosition(tdCoords, subMenu);
  10713. }
  10714. };
  10715. ContextMenu.prototype.onBeforeKeyDown = function(event, instance) {
  10716. dom.enableImmediatePropagation(event);
  10717. var contextMenu = this;
  10718. var selection = instance.getSelected();
  10719. switch (event.keyCode) {
  10720. case helper.keyCode.ESCAPE:
  10721. contextMenu.closeAll();
  10722. event.preventDefault();
  10723. event.stopImmediatePropagation();
  10724. break;
  10725. case helper.keyCode.ENTER:
  10726. if (selection) {
  10727. contextMenu.performAction(event, instance);
  10728. }
  10729. break;
  10730. case helper.keyCode.ARROW_DOWN:
  10731. if (!selection) {
  10732. selectFirstCell(instance, contextMenu);
  10733. } else {
  10734. selectNextCell(selection[0], selection[1], instance, contextMenu);
  10735. }
  10736. event.preventDefault();
  10737. event.stopImmediatePropagation();
  10738. break;
  10739. case helper.keyCode.ARROW_UP:
  10740. if (!selection) {
  10741. selectLastCell(instance, contextMenu);
  10742. } else {
  10743. selectPrevCell(selection[0], selection[1], instance, contextMenu);
  10744. }
  10745. event.preventDefault();
  10746. event.stopImmediatePropagation();
  10747. break;
  10748. case helper.keyCode.ARROW_RIGHT:
  10749. if (selection) {
  10750. var row = selection[0];
  10751. var cell = instance.getCell(selection[0], 0);
  10752. if (ContextMenu.utils.hasSubMenu(cell)) {
  10753. openSubMenu(instance, contextMenu, cell, row);
  10754. }
  10755. }
  10756. event.preventDefault();
  10757. event.stopImmediatePropagation();
  10758. break;
  10759. case helper.keyCode.ARROW_LEFT:
  10760. if (selection) {
  10761. if (instance.rootElement.className.indexOf('htContextSubMenu_') != -1) {
  10762. contextMenu.closeLastOpenedSubMenu();
  10763. var index = contextMenu.menus.length;
  10764. if (index > 0) {
  10765. var menu = contextMenu.menus[index - 1];
  10766. var triggerRow = contextMenu.triggerRows.pop();
  10767. instance = this.htMenus[menu.id];
  10768. instance.selectCell(triggerRow, 0);
  10769. }
  10770. }
  10771. event.preventDefault();
  10772. event.stopImmediatePropagation();
  10773. }
  10774. break;
  10775. }
  10776. function selectFirstCell(instance) {
  10777. var firstCell = instance.getCell(0, 0);
  10778. if (ContextMenu.utils.isSeparator(firstCell) || ContextMenu.utils.isDisabled(firstCell)) {
  10779. selectNextCell(0, 0, instance);
  10780. } else {
  10781. instance.selectCell(0, 0);
  10782. }
  10783. }
  10784. function selectLastCell(instance) {
  10785. var lastRow = instance.countRows() - 1;
  10786. var lastCell = instance.getCell(lastRow, 0);
  10787. if (ContextMenu.utils.isSeparator(lastCell) || ContextMenu.utils.isDisabled(lastCell)) {
  10788. selectPrevCell(lastRow, 0, instance);
  10789. } else {
  10790. instance.selectCell(lastRow, 0);
  10791. }
  10792. }
  10793. function selectNextCell(row, col, instance) {
  10794. var nextRow = row + 1;
  10795. var nextCell = nextRow < instance.countRows() ? instance.getCell(nextRow, col) : null;
  10796. if (!nextCell) {
  10797. return;
  10798. }
  10799. if (ContextMenu.utils.isSeparator(nextCell) || ContextMenu.utils.isDisabled(nextCell)) {
  10800. selectNextCell(nextRow, col, instance);
  10801. } else {
  10802. instance.selectCell(nextRow, col);
  10803. }
  10804. }
  10805. function selectPrevCell(row, col, instance) {
  10806. var prevRow = row - 1;
  10807. var prevCell = prevRow >= 0 ? instance.getCell(prevRow, col) : null;
  10808. if (!prevCell) {
  10809. return;
  10810. }
  10811. if (ContextMenu.utils.isSeparator(prevCell) || ContextMenu.utils.isDisabled(prevCell)) {
  10812. selectPrevCell(prevRow, col, instance);
  10813. } else {
  10814. instance.selectCell(prevRow, col);
  10815. }
  10816. }
  10817. function openSubMenu(instance, contextMenu, cell, row) {
  10818. var selectedItem = instance.getData()[row];
  10819. var items = contextMenu.getItems(selectedItem.submenu);
  10820. var subMenu = contextMenu.createMenu(selectedItem.name, row);
  10821. var coords = cell.getBoundingClientRect();
  10822. var subMenuInstance = contextMenu.show(subMenu, items);
  10823. contextMenu.setSubMenuPosition(coords, subMenu);
  10824. subMenuInstance.selectCell(0, 0);
  10825. }
  10826. };
  10827. function findByKey(items, key) {
  10828. for (var i = 0,
  10829. ilen = items.length; i < ilen; i++) {
  10830. if (items[i].key === key) {
  10831. return items[i];
  10832. }
  10833. }
  10834. }
  10835. function findIndexByKey(items, key) {
  10836. for (var i = 0,
  10837. ilen = items.length; i < ilen; i++) {
  10838. if (items[i].key === key) {
  10839. return i;
  10840. }
  10841. }
  10842. }
  10843. ContextMenu.prototype.getItems = function(items) {
  10844. var menu,
  10845. item;
  10846. function ContextMenuItem(rawItem) {
  10847. if (typeof rawItem == 'string') {
  10848. this.name = rawItem;
  10849. } else {
  10850. helper.extend(this, rawItem);
  10851. }
  10852. }
  10853. ContextMenuItem.prototype = items;
  10854. if (items && items.items) {
  10855. items = items.items;
  10856. }
  10857. if (items === true) {
  10858. items = this.defaultOptions.items;
  10859. }
  10860. if (1 == 1) {
  10861. menu = [];
  10862. for (var key in items) {
  10863. if (items.hasOwnProperty(key)) {
  10864. if (typeof items[key] === 'string') {
  10865. item = findByKey(this.defaultOptions.items, items[key]);
  10866. } else {
  10867. item = findByKey(this.defaultOptions.items, key);
  10868. }
  10869. if (!item) {
  10870. item = items[key];
  10871. }
  10872. item = new ContextMenuItem(item);
  10873. if (typeof items[key] === 'object') {
  10874. helper.extend(item, items[key]);
  10875. }
  10876. if (!item.key) {
  10877. item.key = key;
  10878. }
  10879. menu.push(item);
  10880. }
  10881. }
  10882. }
  10883. return menu;
  10884. };
  10885. ContextMenu.prototype.setSubMenuPosition = function(coords, menu) {
  10886. var scrollTop = dom.getWindowScrollTop();
  10887. var scrollLeft = dom.getWindowScrollLeft();
  10888. var cursor = {
  10889. top: scrollTop + coords.top,
  10890. topRelative: coords.top,
  10891. left: coords.left,
  10892. leftRelative: coords.left - scrollLeft,
  10893. scrollTop: scrollTop,
  10894. scrollLeft: scrollLeft,
  10895. cellHeight: coords.height,
  10896. cellWidth: coords.width
  10897. };
  10898. if (this.menuFitsBelowCursor(cursor, menu, document.body.clientWidth)) {
  10899. this.positionMenuBelowCursor(cursor, menu, true);
  10900. } else {
  10901. if (this.menuFitsAboveCursor(cursor, menu)) {
  10902. this.positionMenuAboveCursor(cursor, menu, true);
  10903. } else {
  10904. this.positionMenuBelowCursor(cursor, menu, true);
  10905. }
  10906. }
  10907. if (this.menuFitsOnRightOfCursor(cursor, menu, document.body.clientWidth)) {
  10908. this.positionMenuOnRightOfCursor(cursor, menu, true);
  10909. } else {
  10910. this.positionMenuOnLeftOfCursor(cursor, menu, true);
  10911. }
  10912. };
  10913. ContextMenu.prototype.setMenuPosition = function(event, menu) {
  10914. var scrollTop = dom.getWindowScrollTop();
  10915. var scrollLeft = dom.getWindowScrollLeft();
  10916. var cursorY = event.pageY || (event.clientY + scrollTop);
  10917. var cursorX = event.pageX || (event.clientX + scrollLeft);
  10918. var cursor = {
  10919. top: cursorY,
  10920. topRelative: cursorY - scrollTop,
  10921. left: cursorX,
  10922. leftRelative: cursorX - scrollLeft,
  10923. scrollTop: scrollTop,
  10924. scrollLeft: scrollLeft,
  10925. cellHeight: event.target.clientHeight,
  10926. cellWidth: event.target.clientWidth
  10927. };
  10928. if (this.menuFitsBelowCursor(cursor, menu, document.body.clientHeight)) {
  10929. this.positionMenuBelowCursor(cursor, menu);
  10930. } else {
  10931. if (this.menuFitsAboveCursor(cursor, menu)) {
  10932. this.positionMenuAboveCursor(cursor, menu);
  10933. } else {
  10934. this.positionMenuBelowCursor(cursor, menu);
  10935. }
  10936. }
  10937. if (this.menuFitsOnRightOfCursor(cursor, menu, document.body.clientWidth)) {
  10938. this.positionMenuOnRightOfCursor(cursor, menu);
  10939. } else {
  10940. this.positionMenuOnLeftOfCursor(cursor, menu);
  10941. }
  10942. };
  10943. ContextMenu.prototype.menuFitsAboveCursor = function(cursor, menu) {
  10944. return cursor.topRelative >= menu.offsetHeight;
  10945. };
  10946. ContextMenu.prototype.menuFitsBelowCursor = function(cursor, menu, viewportHeight) {
  10947. return cursor.topRelative + menu.offsetHeight <= viewportHeight;
  10948. };
  10949. ContextMenu.prototype.menuFitsOnRightOfCursor = function(cursor, menu, viewportHeight) {
  10950. return cursor.leftRelative + menu.offsetWidth <= viewportHeight;
  10951. };
  10952. ContextMenu.prototype.positionMenuBelowCursor = function(cursor, menu) {
  10953. menu.style.top = cursor.top + 'px';
  10954. };
  10955. ContextMenu.prototype.positionMenuAboveCursor = function(cursor, menu, subMenu) {
  10956. if (subMenu) {
  10957. menu.style.top = (cursor.top + cursor.cellHeight - menu.offsetHeight) + 'px';
  10958. } else {
  10959. menu.style.top = (cursor.top - menu.offsetHeight) + 'px';
  10960. }
  10961. };
  10962. ContextMenu.prototype.positionMenuOnRightOfCursor = function(cursor, menu, subMenu) {
  10963. if (subMenu) {
  10964. menu.style.left = 1 + cursor.left + cursor.cellWidth + 'px';
  10965. } else {
  10966. menu.style.left = 1 + cursor.left + 'px';
  10967. }
  10968. };
  10969. ContextMenu.prototype.positionMenuOnLeftOfCursor = function(cursor, menu, subMenu) {
  10970. if (subMenu) {
  10971. menu.style.left = (cursor.left - menu.offsetWidth) + 'px';
  10972. } else {
  10973. menu.style.left = (cursor.left - menu.offsetWidth) + 'px';
  10974. }
  10975. };
  10976. ContextMenu.utils = {};
  10977. ContextMenu.utils.normalizeSelection = function(selRange) {
  10978. return {
  10979. start: selRange.getTopLeftCorner(),
  10980. end: selRange.getBottomRightCorner()
  10981. };
  10982. };
  10983. ContextMenu.utils.isSeparator = function(cell) {
  10984. return dom.hasClass(cell, 'htSeparator');
  10985. };
  10986. ContextMenu.utils.hasSubMenu = function(cell) {
  10987. return dom.hasClass(cell, 'htSubmenu');
  10988. };
  10989. ContextMenu.utils.isDisabled = function(cell) {
  10990. return dom.hasClass(cell, 'htDisabled');
  10991. };
  10992. ContextMenu.prototype.enable = function() {
  10993. if (!this.enabled) {
  10994. this.enabled = true;
  10995. this.bindMouseEvents();
  10996. }
  10997. };
  10998. ContextMenu.prototype.disable = function() {
  10999. if (this.enabled) {
  11000. this.enabled = false;
  11001. this.closeAll();
  11002. this.unbindMouseEvents();
  11003. this.unbindTableEvents();
  11004. }
  11005. };
  11006. ContextMenu.prototype.destroy = function() {
  11007. this.closeAll();
  11008. while (this.menus.length > 0) {
  11009. var menu = this.menus.pop();
  11010. this.triggerRows.pop();
  11011. if (menu) {
  11012. this.close(menu);
  11013. if (!this.isMenuEnabledByOtherHotInstance()) {
  11014. this.removeMenu(menu);
  11015. }
  11016. }
  11017. }
  11018. this.unbindMouseEvents();
  11019. this.unbindTableEvents();
  11020. };
  11021. ContextMenu.prototype.isMenuEnabledByOtherHotInstance = function() {
  11022. var hotContainers = document.querySelectorAll('.handsontable');
  11023. var menuEnabled = false;
  11024. for (var i = 0,
  11025. len = hotContainers.length; i < len; i++) {
  11026. var instance = this.htMenus[hotContainers[i].id];
  11027. if (instance && instance.getSettings().contextMenu) {
  11028. menuEnabled = true;
  11029. break;
  11030. }
  11031. }
  11032. return menuEnabled;
  11033. };
  11034. ContextMenu.prototype.removeMenu = function(menu) {
  11035. if (menu.parentNode) {
  11036. this.menu.parentNode.removeChild(menu);
  11037. }
  11038. };
  11039. ContextMenu.prototype.align = function(range, type, alignment) {
  11040. align.call(this, range, type, alignment);
  11041. };
  11042. ContextMenu.SEPARATOR = {name: "---------"};
  11043. function updateHeight() {
  11044. if (this.rootElement.className.indexOf('htContextMenu')) {
  11045. return;
  11046. }
  11047. var realSeparatorHeight = 0,
  11048. realEntrySize = 0,
  11049. dataSize = this.getSettings().data.length,
  11050. currentHiderWidth = parseInt(this.view.wt.wtTable.hider.style.width, 10);
  11051. for (var i = 0; i < dataSize; i++) {
  11052. if (this.getSettings().data[i].name == ContextMenu.SEPARATOR.name) {
  11053. realSeparatorHeight += 1;
  11054. } else {
  11055. realEntrySize += 26;
  11056. }
  11057. }
  11058. this.view.wt.wtTable.holder.style.width = currentHiderWidth + 22 + "px";
  11059. this.view.wt.wtTable.holder.style.height = realEntrySize + realSeparatorHeight + 4 + "px";
  11060. }
  11061. function prepareVerticalAlignClass(className, alignment) {
  11062. if (className.indexOf(alignment) != -1) {
  11063. return className;
  11064. }
  11065. className = className.replace('htTop', '').replace('htMiddle', '').replace('htBottom', '').replace(' ', '');
  11066. className += " " + alignment;
  11067. return className;
  11068. }
  11069. function prepareHorizontalAlignClass(className, alignment) {
  11070. if (className.indexOf(alignment) != -1) {
  11071. return className;
  11072. }
  11073. className = className.replace('htLeft', '').replace('htCenter', '').replace('htRight', '').replace('htJustify', '').replace(' ', '');
  11074. className += " " + alignment;
  11075. return className;
  11076. }
  11077. function getAlignmentClasses(range) {
  11078. var classesArray = {};
  11079. for (var row = range.from.row; row <= range.to.row; row++) {
  11080. for (var col = range.from.col; col <= range.to.col; col++) {
  11081. if (!classesArray[row]) {
  11082. classesArray[row] = [];
  11083. }
  11084. classesArray[row][col] = this.getCellMeta(row, col).className;
  11085. }
  11086. }
  11087. return classesArray;
  11088. }
  11089. function doAlign(row, col, type, alignment) {
  11090. var cellMeta = this.getCellMeta(row, col),
  11091. className = alignment;
  11092. if (cellMeta.className) {
  11093. if (type === 'vertical') {
  11094. className = prepareVerticalAlignClass(cellMeta.className, alignment);
  11095. } else {
  11096. className = prepareHorizontalAlignClass(cellMeta.className, alignment);
  11097. }
  11098. }
  11099. this.setCellMeta(row, col, 'className', className);
  11100. }
  11101. function align(range, type, alignment) {
  11102. var stateBefore = getAlignmentClasses.call(this, range);
  11103. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  11104. if (range.from.row == range.to.row && range.from.col == range.to.col) {
  11105. doAlign.call(this, range.from.row, range.from.col, type, alignment);
  11106. } else {
  11107. for (var row = range.from.row; row <= range.to.row; row++) {
  11108. for (var col = range.from.col; col <= range.to.col; col++) {
  11109. doAlign.call(this, row, col, type, alignment);
  11110. }
  11111. }
  11112. }
  11113. this.render();
  11114. }
  11115. function init() {
  11116. var instance = this;
  11117. var contextMenuSetting = instance.getSettings().contextMenu;
  11118. var customOptions = helper.isObject(contextMenuSetting) ? contextMenuSetting : {};
  11119. if (contextMenuSetting) {
  11120. if (!instance.contextMenu) {
  11121. instance.contextMenu = new ContextMenu(instance, customOptions);
  11122. }
  11123. instance.contextMenu.enable();
  11124. } else if (instance.contextMenu) {
  11125. instance.contextMenu.destroy();
  11126. delete instance.contextMenu;
  11127. }
  11128. }
  11129. Handsontable.hooks.add('afterInit', init);
  11130. Handsontable.hooks.add('afterUpdateSettings', init);
  11131. Handsontable.hooks.add('afterInit', updateHeight);
  11132. Handsontable.hooks.register('afterContextMenuDefaultOptions');
  11133. Handsontable.hooks.register('afterContextMenuShow');
  11134. Handsontable.hooks.register('afterContextMenuHide');
  11135. Handsontable.ContextMenu = ContextMenu;
  11136. //#
  11137. },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../helpers.js":42,"./../../plugins.js":45}],53:[function(require,module,exports){
  11138. "use strict";
  11139. Object.defineProperties(exports, {
  11140. ContextMenuCopyPaste: {get: function() {
  11141. return ContextMenuCopyPaste;
  11142. }},
  11143. __esModule: {value: true}
  11144. });
  11145. var $___46__46__47__46__46__47_dom_46_js__,
  11146. $___46__46__47__46__46__47_eventManager_46_js__,
  11147. $___46__46__47__46__46__47_plugins_46_js__,
  11148. $___46__46__47__95_base_46_js__,
  11149. $__zeroclipboard__;
  11150. 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__});
  11151. 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;
  11152. 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;
  11153. 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;
  11154. var ZeroClipboard = ($__zeroclipboard__ = require("zeroclipboard"), $__zeroclipboard__ && $__zeroclipboard__.__esModule && $__zeroclipboard__ || {default: $__zeroclipboard__}).default;
  11155. var ContextMenuCopyPaste = function ContextMenuCopyPaste(hotInstance) {
  11156. var $__4 = this;
  11157. $traceurRuntime.superConstructor($ContextMenuCopyPaste).call(this, hotInstance);
  11158. this.swfPath = null;
  11159. this.hotContextMenu = null;
  11160. this.outsideClickDeselectsCache = null;
  11161. this.hot.addHook('afterContextMenuShow', (function(htContextMenu) {
  11162. return $__4.setupZeroClipboard(htContextMenu);
  11163. }));
  11164. this.hot.addHook('afterInit', (function() {
  11165. return $__4.afterInit();
  11166. }));
  11167. this.hot.addHook('afterContextMenuDefaultOptions', (function(options) {
  11168. return $__4.addToContextMenu(options);
  11169. }));
  11170. };
  11171. var $ContextMenuCopyPaste = ContextMenuCopyPaste;
  11172. ($traceurRuntime.createClass)(ContextMenuCopyPaste, {
  11173. afterInit: function() {
  11174. if (!this.hot.getSettings().contextMenuCopyPaste) {
  11175. return;
  11176. } else if (typeof this.hot.getSettings().contextMenuCopyPaste == 'object') {
  11177. this.swfPath = this.hot.getSettings().contextMenuCopyPaste.swfPath;
  11178. }
  11179. if (typeof ZeroClipboard === 'undefined') {
  11180. 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.");
  11181. }
  11182. try {
  11183. new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
  11184. } catch (exception) {
  11185. if ('undefined' == typeof navigator.mimeTypes['application/x-shockwave-flash']) {
  11186. throw new Error("To be able to use the Copy/Paste feature from the context menu, your browser needs to have Flash Plugin installed.");
  11187. }
  11188. }
  11189. this.prepareZeroClipboard();
  11190. },
  11191. prepareZeroClipboard: function() {
  11192. if (this.swfPath) {
  11193. ZeroClipboard.config({swfPath: this.swfPath});
  11194. }
  11195. },
  11196. getCopyValue: function() {
  11197. this.hot.copyPaste.setCopyableText();
  11198. return this.hot.copyPaste.copyPasteInstance.elTextarea.value;
  11199. },
  11200. addToContextMenu: function(defaultOptions) {
  11201. if (!this.hot.getSettings().contextMenuCopyPaste) {
  11202. return;
  11203. }
  11204. defaultOptions.items.unshift({
  11205. key: 'copy',
  11206. name: 'Copy'
  11207. }, {
  11208. key: 'paste',
  11209. name: 'Paste',
  11210. callback: function() {
  11211. this.copyPaste.triggerPaste();
  11212. }
  11213. }, Handsontable.ContextMenu.SEPARATOR);
  11214. },
  11215. setupZeroClipboard: function(hotContextMenu) {
  11216. var $__4 = this;
  11217. var data,
  11218. zeroClipboardInstance;
  11219. if (!this.hot.getSettings().contextMenuCopyPaste) {
  11220. return;
  11221. }
  11222. this.hotContextMenu = hotContextMenu;
  11223. data = this.hotContextMenu.getData();
  11224. for (var i = 0,
  11225. ilen = data.length; i < ilen; i++) {
  11226. if (data[i].key === 'copy') {
  11227. zeroClipboardInstance = new ZeroClipboard(this.hotContextMenu.getCell(i, 0));
  11228. zeroClipboardInstance.off();
  11229. zeroClipboardInstance.on('copy', (function(event) {
  11230. var clipboard = event.clipboardData;
  11231. clipboard.setData('text/plain', $__4.getCopyValue());
  11232. $__4.hot.getSettings().outsideClickDeselects = $__4.outsideClickDeselectsCache;
  11233. }));
  11234. this.bindEvents();
  11235. break;
  11236. }
  11237. }
  11238. },
  11239. removeCurrentClass: function() {
  11240. if (this.hotContextMenu.rootElement) {
  11241. var element = this.hotContextMenu.rootElement.querySelector('td.current');
  11242. if (element) {
  11243. dom.removeClass(element, 'current');
  11244. }
  11245. }
  11246. this.outsideClickDeselectsCache = this.hot.getSettings().outsideClickDeselects;
  11247. this.hot.getSettings().outsideClickDeselects = false;
  11248. },
  11249. removeZeroClipboardClass: function() {
  11250. if (this.hotContextMenu.rootElement) {
  11251. var element = this.hotContextMenu.rootElement.querySelector('td.zeroclipboard-is-hover');
  11252. if (element) {
  11253. dom.removeClass(element, 'zeroclipboard-is-hover');
  11254. }
  11255. }
  11256. this.hot.getSettings().outsideClickDeselects = this.outsideClickDeselectsCache;
  11257. },
  11258. bindEvents: function() {
  11259. var $__4 = this;
  11260. var eventManager = eventManagerObject(this.hotContextMenu);
  11261. eventManager.addEventListener(document, 'mouseenter', (function() {
  11262. return $__4.removeCurrentClass();
  11263. }));
  11264. eventManager.addEventListener(document, 'mouseleave', (function() {
  11265. return $__4.removeZeroClipboardClass();
  11266. }));
  11267. }
  11268. }, {}, BasePlugin);
  11269. ;
  11270. registerPlugin('contextMenuCopyPaste', ContextMenuCopyPaste);
  11271. //#
  11272. },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../plugins.js":45,"./../_base.js":46,"zeroclipboard":"zeroclipboard"}],54:[function(require,module,exports){
  11273. "use strict";
  11274. Object.defineProperties(exports, {
  11275. CopyPaste: {get: function() {
  11276. return CopyPaste;
  11277. }},
  11278. __esModule: {value: true}
  11279. });
  11280. var $___46__46__47__46__46__47_helpers_46_js__,
  11281. $__copyPaste__,
  11282. $__SheetClip__,
  11283. $___46__46__47__46__46__47_plugins_46_js__,
  11284. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
  11285. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__;
  11286. 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__});
  11287. var copyPaste = ($__copyPaste__ = require("copyPaste"), $__copyPaste__ && $__copyPaste__.__esModule && $__copyPaste__ || {default: $__copyPaste__}).default;
  11288. var SheetClip = ($__SheetClip__ = require("SheetClip"), $__SheetClip__ && $__SheetClip__.__esModule && $__SheetClip__ || {default: $__SheetClip__}).default;
  11289. 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;
  11290. 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;
  11291. 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;
  11292. ;
  11293. function CopyPastePlugin(instance) {
  11294. var _this = this;
  11295. this.copyPasteInstance = copyPaste();
  11296. this.copyPasteInstance.onCut(onCut);
  11297. this.copyPasteInstance.onPaste(onPaste);
  11298. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  11299. function onCut() {
  11300. if (!instance.isListening()) {
  11301. return;
  11302. }
  11303. instance.selection.empty();
  11304. }
  11305. function onPaste(str) {
  11306. var input,
  11307. inputArray,
  11308. selected,
  11309. coordsFrom,
  11310. coordsTo,
  11311. cellRange,
  11312. topLeftCorner,
  11313. bottomRightCorner,
  11314. areaStart,
  11315. areaEnd;
  11316. if (!instance.isListening() || !instance.selection.isSelected()) {
  11317. return;
  11318. }
  11319. input = str;
  11320. inputArray = SheetClip.parse(input);
  11321. selected = instance.getSelected();
  11322. coordsFrom = new WalkontableCellCoords(selected[0], selected[1]);
  11323. coordsTo = new WalkontableCellCoords(selected[2], selected[3]);
  11324. cellRange = new WalkontableCellRange(coordsFrom, coordsFrom, coordsTo);
  11325. topLeftCorner = cellRange.getTopLeftCorner();
  11326. bottomRightCorner = cellRange.getBottomRightCorner();
  11327. areaStart = topLeftCorner;
  11328. areaEnd = new WalkontableCellCoords(Math.max(bottomRightCorner.row, inputArray.length - 1 + topLeftCorner.row), Math.max(bottomRightCorner.col, inputArray[0].length - 1 + topLeftCorner.col));
  11329. instance.addHookOnce('afterChange', function(changes, source) {
  11330. if (changes && changes.length) {
  11331. this.selectCell(areaStart.row, areaStart.col, areaEnd.row, areaEnd.col);
  11332. }
  11333. });
  11334. instance.populateFromArray(areaStart.row, areaStart.col, inputArray, areaEnd.row, areaEnd.col, 'paste', instance.getSettings().pasteMode);
  11335. }
  11336. function onBeforeKeyDown(event) {
  11337. var ctrlDown;
  11338. if (instance.getSelected() && instance.getActiveEditor() && !instance.getActiveEditor().isOpened()) {
  11339. if (helper.isCtrlKey(event.keyCode)) {
  11340. _this.setCopyableText();
  11341. event.stopImmediatePropagation();
  11342. return;
  11343. }
  11344. ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  11345. if (event.keyCode == helper.keyCode.A && ctrlDown) {
  11346. instance._registerTimeout(setTimeout(helper.proxy(_this.setCopyableText, _this), 0));
  11347. }
  11348. }
  11349. }
  11350. this.destroy = function() {
  11351. this.copyPasteInstance.removeCallback(onCut);
  11352. this.copyPasteInstance.removeCallback(onPaste);
  11353. this.copyPasteInstance.destroy();
  11354. instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  11355. };
  11356. instance.addHook('afterDestroy', helper.proxy(this.destroy, this));
  11357. this.triggerPaste = helper.proxy(this.copyPasteInstance.triggerPaste, this.copyPasteInstance);
  11358. this.triggerCut = helper.proxy(this.copyPasteInstance.triggerCut, this.copyPasteInstance);
  11359. this.setCopyableText = function() {
  11360. var settings = instance.getSettings();
  11361. var copyRowsLimit = settings.copyRowsLimit;
  11362. var copyColsLimit = settings.copyColsLimit;
  11363. var selRange = instance.getSelectedRange();
  11364. var topLeft = selRange.getTopLeftCorner();
  11365. var bottomRight = selRange.getBottomRightCorner();
  11366. var startRow = topLeft.row;
  11367. var startCol = topLeft.col;
  11368. var endRow = bottomRight.row;
  11369. var endCol = bottomRight.col;
  11370. var finalEndRow = Math.min(endRow, startRow + copyRowsLimit - 1);
  11371. var finalEndCol = Math.min(endCol, startCol + copyColsLimit - 1);
  11372. instance.copyPaste.copyPasteInstance.copyable(instance.getCopyableData(startRow, startCol, finalEndRow, finalEndCol));
  11373. if (endRow !== finalEndRow || endCol !== finalEndCol) {
  11374. Handsontable.hooks.run(instance, "afterCopyLimit", endRow - startRow + 1, endCol - startCol + 1, copyRowsLimit, copyColsLimit);
  11375. }
  11376. };
  11377. }
  11378. function init() {
  11379. var instance = this,
  11380. pluginEnabled = instance.getSettings().copyPaste !== false;
  11381. if (pluginEnabled && !instance.copyPaste) {
  11382. instance.copyPaste = new CopyPastePlugin(instance);
  11383. } else if (!pluginEnabled && instance.copyPaste) {
  11384. instance.copyPaste.destroy();
  11385. delete instance.copyPaste;
  11386. }
  11387. }
  11388. Handsontable.hooks.add('afterInit', init);
  11389. Handsontable.hooks.add('afterUpdateSettings', init);
  11390. Handsontable.hooks.register('afterCopyLimit');
  11391. //#
  11392. },{"./../../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){
  11393. "use strict";
  11394. var $___46__46__47__46__46__47_plugins_46_js__,
  11395. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__,
  11396. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_selection_46_js__;
  11397. 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;
  11398. 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;
  11399. 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;
  11400. function CustomBorders() {}
  11401. var instance;
  11402. var checkEnable = function(customBorders) {
  11403. if (typeof customBorders === "boolean") {
  11404. if (customBorders === true) {
  11405. return true;
  11406. }
  11407. }
  11408. if (typeof customBorders === "object") {
  11409. if (customBorders.length > 0) {
  11410. return true;
  11411. }
  11412. }
  11413. return false;
  11414. };
  11415. var init = function() {
  11416. if (checkEnable(this.getSettings().customBorders)) {
  11417. if (!this.customBorders) {
  11418. instance = this;
  11419. this.customBorders = new CustomBorders();
  11420. }
  11421. }
  11422. };
  11423. var getSettingIndex = function(className) {
  11424. for (var i = 0; i < instance.view.wt.selections.length; i++) {
  11425. if (instance.view.wt.selections[i].settings.className == className) {
  11426. return i;
  11427. }
  11428. }
  11429. return -1;
  11430. };
  11431. var insertBorderIntoSettings = function(border) {
  11432. var coordinates = {
  11433. row: border.row,
  11434. col: border.col
  11435. };
  11436. var selection = new WalkontableSelection(border, new WalkontableCellRange(coordinates, coordinates, coordinates));
  11437. var index = getSettingIndex(border.className);
  11438. if (index >= 0) {
  11439. instance.view.wt.selections[index] = selection;
  11440. } else {
  11441. instance.view.wt.selections.push(selection);
  11442. }
  11443. };
  11444. var prepareBorderFromCustomAdded = function(row, col, borderObj) {
  11445. var border = createEmptyBorders(row, col);
  11446. border = extendDefaultBorder(border, borderObj);
  11447. this.setCellMeta(row, col, 'borders', border);
  11448. insertBorderIntoSettings(border);
  11449. };
  11450. var prepareBorderFromCustomAddedRange = function(rowObj) {
  11451. var range = rowObj.range;
  11452. for (var row = range.from.row; row <= range.to.row; row++) {
  11453. for (var col = range.from.col; col <= range.to.col; col++) {
  11454. var border = createEmptyBorders(row, col);
  11455. var add = 0;
  11456. if (row == range.from.row) {
  11457. add++;
  11458. if (rowObj.hasOwnProperty('top')) {
  11459. border.top = rowObj.top;
  11460. }
  11461. }
  11462. if (row == range.to.row) {
  11463. add++;
  11464. if (rowObj.hasOwnProperty('bottom')) {
  11465. border.bottom = rowObj.bottom;
  11466. }
  11467. }
  11468. if (col == range.from.col) {
  11469. add++;
  11470. if (rowObj.hasOwnProperty('left')) {
  11471. border.left = rowObj.left;
  11472. }
  11473. }
  11474. if (col == range.to.col) {
  11475. add++;
  11476. if (rowObj.hasOwnProperty('right')) {
  11477. border.right = rowObj.right;
  11478. }
  11479. }
  11480. if (add > 0) {
  11481. this.setCellMeta(row, col, 'borders', border);
  11482. insertBorderIntoSettings(border);
  11483. }
  11484. }
  11485. }
  11486. };
  11487. var createClassName = function(row, col) {
  11488. return "border_row" + row + "col" + col;
  11489. };
  11490. var createDefaultCustomBorder = function() {
  11491. return {
  11492. width: 1,
  11493. color: '#000'
  11494. };
  11495. };
  11496. var createSingleEmptyBorder = function() {
  11497. return {hide: true};
  11498. };
  11499. var createDefaultHtBorder = function() {
  11500. return {
  11501. width: 1,
  11502. color: '#000',
  11503. cornerVisible: false
  11504. };
  11505. };
  11506. var createEmptyBorders = function(row, col) {
  11507. return {
  11508. className: createClassName(row, col),
  11509. border: createDefaultHtBorder(),
  11510. row: row,
  11511. col: col,
  11512. top: createSingleEmptyBorder(),
  11513. right: createSingleEmptyBorder(),
  11514. bottom: createSingleEmptyBorder(),
  11515. left: createSingleEmptyBorder()
  11516. };
  11517. };
  11518. var extendDefaultBorder = function(defaultBorder, customBorder) {
  11519. if (customBorder.hasOwnProperty('border')) {
  11520. defaultBorder.border = customBorder.border;
  11521. }
  11522. if (customBorder.hasOwnProperty('top')) {
  11523. defaultBorder.top = customBorder.top;
  11524. }
  11525. if (customBorder.hasOwnProperty('right')) {
  11526. defaultBorder.right = customBorder.right;
  11527. }
  11528. if (customBorder.hasOwnProperty('bottom')) {
  11529. defaultBorder.bottom = customBorder.bottom;
  11530. }
  11531. if (customBorder.hasOwnProperty('left')) {
  11532. defaultBorder.left = customBorder.left;
  11533. }
  11534. return defaultBorder;
  11535. };
  11536. var removeBordersFromDom = function(borderClassName) {
  11537. var borders = document.querySelectorAll("." + borderClassName);
  11538. for (var i = 0; i < borders.length; i++) {
  11539. if (borders[i]) {
  11540. if (borders[i].nodeName != 'TD') {
  11541. var parent = borders[i].parentNode;
  11542. if (parent.parentNode) {
  11543. parent.parentNode.removeChild(parent);
  11544. }
  11545. }
  11546. }
  11547. }
  11548. };
  11549. var removeAllBorders = function(row, col) {
  11550. var borderClassName = createClassName(row, col);
  11551. removeBordersFromDom(borderClassName);
  11552. this.removeCellMeta(row, col, 'borders');
  11553. };
  11554. var setBorder = function(row, col, place, remove) {
  11555. var bordersMeta = this.getCellMeta(row, col).borders;
  11556. if (!bordersMeta || bordersMeta.border == undefined) {
  11557. bordersMeta = createEmptyBorders(row, col);
  11558. }
  11559. if (remove) {
  11560. bordersMeta[place] = createSingleEmptyBorder();
  11561. } else {
  11562. bordersMeta[place] = createDefaultCustomBorder();
  11563. }
  11564. this.setCellMeta(row, col, 'borders', bordersMeta);
  11565. var borderClassName = createClassName(row, col);
  11566. removeBordersFromDom(borderClassName);
  11567. insertBorderIntoSettings(bordersMeta);
  11568. this.render();
  11569. };
  11570. var prepareBorder = function(range, place, remove) {
  11571. if (range.from.row == range.to.row && range.from.col == range.to.col) {
  11572. if (place == "noBorders") {
  11573. removeAllBorders.call(this, range.from.row, range.from.col);
  11574. } else {
  11575. setBorder.call(this, range.from.row, range.from.col, place, remove);
  11576. }
  11577. } else {
  11578. switch (place) {
  11579. case "noBorders":
  11580. for (var column = range.from.col; column <= range.to.col; column++) {
  11581. for (var row = range.from.row; row <= range.to.row; row++) {
  11582. removeAllBorders.call(this, row, column);
  11583. }
  11584. }
  11585. break;
  11586. case "top":
  11587. for (var topCol = range.from.col; topCol <= range.to.col; topCol++) {
  11588. setBorder.call(this, range.from.row, topCol, place, remove);
  11589. }
  11590. break;
  11591. case "right":
  11592. for (var rowRight = range.from.row; rowRight <= range.to.row; rowRight++) {
  11593. setBorder.call(this, rowRight, range.to.col, place);
  11594. }
  11595. break;
  11596. case "bottom":
  11597. for (var bottomCol = range.from.col; bottomCol <= range.to.col; bottomCol++) {
  11598. setBorder.call(this, range.to.row, bottomCol, place);
  11599. }
  11600. break;
  11601. case "left":
  11602. for (var rowLeft = range.from.row; rowLeft <= range.to.row; rowLeft++) {
  11603. setBorder.call(this, rowLeft, range.from.col, place);
  11604. }
  11605. break;
  11606. }
  11607. }
  11608. };
  11609. var checkSelectionBorders = function(hot, direction) {
  11610. var atLeastOneHasBorder = false;
  11611. hot.getSelectedRange().forAll(function(r, c) {
  11612. var metaBorders = hot.getCellMeta(r, c).borders;
  11613. if (metaBorders) {
  11614. if (direction) {
  11615. if (!metaBorders[direction].hasOwnProperty('hide')) {
  11616. atLeastOneHasBorder = true;
  11617. return false;
  11618. }
  11619. } else {
  11620. atLeastOneHasBorder = true;
  11621. return false;
  11622. }
  11623. }
  11624. });
  11625. return atLeastOneHasBorder;
  11626. };
  11627. var markSelected = function(label) {
  11628. return "<span class='selected'>" + String.fromCharCode(10003) + "</span>" + label;
  11629. };
  11630. var addBordersOptionsToContextMenu = function(defaultOptions) {
  11631. if (!this.getSettings().customBorders) {
  11632. return;
  11633. }
  11634. defaultOptions.items.push(Handsontable.ContextMenu.SEPARATOR);
  11635. defaultOptions.items.push({
  11636. key: 'borders',
  11637. name: 'Borders',
  11638. submenu: {items: {
  11639. top: {
  11640. name: function() {
  11641. var label = "Top";
  11642. var hasBorder = checkSelectionBorders(this, 'top');
  11643. if (hasBorder) {
  11644. label = markSelected(label);
  11645. }
  11646. return label;
  11647. },
  11648. callback: function() {
  11649. var hasBorder = checkSelectionBorders(this, 'top');
  11650. prepareBorder.call(this, this.getSelectedRange(), 'top', hasBorder);
  11651. },
  11652. disabled: false
  11653. },
  11654. right: {
  11655. name: function() {
  11656. var label = 'Right';
  11657. var hasBorder = checkSelectionBorders(this, 'right');
  11658. if (hasBorder) {
  11659. label = markSelected(label);
  11660. }
  11661. return label;
  11662. },
  11663. callback: function() {
  11664. var hasBorder = checkSelectionBorders(this, 'right');
  11665. prepareBorder.call(this, this.getSelectedRange(), 'right', hasBorder);
  11666. },
  11667. disabled: false
  11668. },
  11669. bottom: {
  11670. name: function() {
  11671. var label = 'Bottom';
  11672. var hasBorder = checkSelectionBorders(this, 'bottom');
  11673. if (hasBorder) {
  11674. label = markSelected(label);
  11675. }
  11676. return label;
  11677. },
  11678. callback: function() {
  11679. var hasBorder = checkSelectionBorders(this, 'bottom');
  11680. prepareBorder.call(this, this.getSelectedRange(), 'bottom', hasBorder);
  11681. },
  11682. disabled: false
  11683. },
  11684. left: {
  11685. name: function() {
  11686. var label = 'Left';
  11687. var hasBorder = checkSelectionBorders(this, 'left');
  11688. if (hasBorder) {
  11689. label = markSelected(label);
  11690. }
  11691. return label;
  11692. },
  11693. callback: function() {
  11694. var hasBorder = checkSelectionBorders(this, 'left');
  11695. prepareBorder.call(this, this.getSelectedRange(), 'left', hasBorder);
  11696. },
  11697. disabled: false
  11698. },
  11699. remove: {
  11700. name: 'Remove border(s)',
  11701. callback: function() {
  11702. prepareBorder.call(this, this.getSelectedRange(), 'noBorders');
  11703. },
  11704. disabled: function() {
  11705. return !checkSelectionBorders(this);
  11706. }
  11707. }
  11708. }}
  11709. });
  11710. };
  11711. Handsontable.hooks.add('beforeInit', init);
  11712. Handsontable.hooks.add('afterContextMenuDefaultOptions', addBordersOptionsToContextMenu);
  11713. Handsontable.hooks.add('afterInit', function() {
  11714. var customBorders = this.getSettings().customBorders;
  11715. if (customBorders) {
  11716. for (var i = 0; i < customBorders.length; i++) {
  11717. if (customBorders[i].range) {
  11718. prepareBorderFromCustomAddedRange.call(this, customBorders[i]);
  11719. } else {
  11720. prepareBorderFromCustomAdded.call(this, customBorders[i].row, customBorders[i].col, customBorders[i]);
  11721. }
  11722. }
  11723. this.render();
  11724. this.view.wt.draw(true);
  11725. }
  11726. });
  11727. Handsontable.CustomBorders = CustomBorders;
  11728. //#
  11729. },{"./../../3rdparty/walkontable/src/cell/range.js":6,"./../../3rdparty/walkontable/src/selection.js":18,"./../../plugins.js":45}],56:[function(require,module,exports){
  11730. "use strict";
  11731. Object.defineProperties(exports, {
  11732. DragToScroll: {get: function() {
  11733. return DragToScroll;
  11734. }},
  11735. __esModule: {value: true}
  11736. });
  11737. var $___46__46__47__46__46__47_eventManager_46_js__,
  11738. $___46__46__47__46__46__47_plugins_46_js__;
  11739. 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;
  11740. 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;
  11741. ;
  11742. Handsontable.plugins.DragToScroll = DragToScroll;
  11743. function DragToScroll() {
  11744. this.boundaries = null;
  11745. this.callback = null;
  11746. }
  11747. DragToScroll.prototype.setBoundaries = function(boundaries) {
  11748. this.boundaries = boundaries;
  11749. };
  11750. DragToScroll.prototype.setCallback = function(callback) {
  11751. this.callback = callback;
  11752. };
  11753. DragToScroll.prototype.check = function(x, y) {
  11754. var diffX = 0;
  11755. var diffY = 0;
  11756. if (y < this.boundaries.top) {
  11757. diffY = y - this.boundaries.top;
  11758. } else if (y > this.boundaries.bottom) {
  11759. diffY = y - this.boundaries.bottom;
  11760. }
  11761. if (x < this.boundaries.left) {
  11762. diffX = x - this.boundaries.left;
  11763. } else if (x > this.boundaries.right) {
  11764. diffX = x - this.boundaries.right;
  11765. }
  11766. this.callback(diffX, diffY);
  11767. };
  11768. var dragToScroll;
  11769. var instance;
  11770. if (typeof Handsontable !== 'undefined') {
  11771. var setupListening = function(instance) {
  11772. instance.dragToScrollListening = false;
  11773. var scrollHandler = instance.view.wt.wtTable.holder;
  11774. dragToScroll = new DragToScroll();
  11775. if (scrollHandler === window) {
  11776. return;
  11777. } else {
  11778. dragToScroll.setBoundaries(scrollHandler.getBoundingClientRect());
  11779. }
  11780. dragToScroll.setCallback(function(scrollX, scrollY) {
  11781. if (scrollX < 0) {
  11782. scrollHandler.scrollLeft -= 50;
  11783. } else if (scrollX > 0) {
  11784. scrollHandler.scrollLeft += 50;
  11785. }
  11786. if (scrollY < 0) {
  11787. scrollHandler.scrollTop -= 20;
  11788. } else if (scrollY > 0) {
  11789. scrollHandler.scrollTop += 20;
  11790. }
  11791. });
  11792. instance.dragToScrollListening = true;
  11793. };
  11794. }
  11795. Handsontable.hooks.add('afterInit', function() {
  11796. var instance = this;
  11797. var eventManager = eventManagerObject(this);
  11798. eventManager.addEventListener(document, 'mouseup', function() {
  11799. instance.dragToScrollListening = false;
  11800. });
  11801. eventManager.addEventListener(document, 'mousemove', function(event) {
  11802. if (instance.dragToScrollListening) {
  11803. dragToScroll.check(event.clientX, event.clientY);
  11804. }
  11805. });
  11806. });
  11807. Handsontable.hooks.add('afterDestroy', function() {
  11808. eventManagerObject(this).clear();
  11809. });
  11810. Handsontable.hooks.add('afterOnCellMouseDown', function() {
  11811. setupListening(this);
  11812. });
  11813. Handsontable.hooks.add('afterOnCellCornerMouseDown', function() {
  11814. setupListening(this);
  11815. });
  11816. Handsontable.plugins.DragToScroll = DragToScroll;
  11817. //#
  11818. },{"./../../eventManager.js":41,"./../../plugins.js":45}],57:[function(require,module,exports){
  11819. "use strict";
  11820. var $___46__46__47__46__46__47_dom_46_js__,
  11821. $___46__46__47__46__46__47_plugins_46_js__;
  11822. 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__});
  11823. 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;
  11824. function Grouping(instance) {
  11825. var groups = [];
  11826. var item = {
  11827. id: '',
  11828. level: 0,
  11829. hidden: 0,
  11830. rows: [],
  11831. cols: []
  11832. };
  11833. var counters = {
  11834. rows: 0,
  11835. cols: 0
  11836. };
  11837. var levels = {
  11838. rows: 0,
  11839. cols: 0
  11840. };
  11841. var hiddenRows = [];
  11842. var hiddenCols = [];
  11843. var classes = {
  11844. 'groupIndicatorContainer': 'htGroupIndicatorContainer',
  11845. 'groupIndicator': function(direction) {
  11846. return 'ht' + direction + 'Group';
  11847. },
  11848. 'groupStart': 'htGroupStart',
  11849. 'collapseButton': 'htCollapseButton',
  11850. 'expandButton': 'htExpandButton',
  11851. 'collapseGroupId': function(id) {
  11852. return 'htCollapse-' + id;
  11853. },
  11854. 'collapseFromLevel': function(direction, level) {
  11855. return 'htCollapse' + direction + 'FromLevel-' + level;
  11856. },
  11857. 'clickable': 'clickable',
  11858. 'levelTrigger': 'htGroupLevelTrigger'
  11859. };
  11860. var compare = function(property, orderDirection) {
  11861. return function(item1, item2) {
  11862. return typeof(orderDirection) === 'undefined' || orderDirection === 'asc' ? item1[property] - item2[property] : item2[property] - item1[property];
  11863. };
  11864. };
  11865. var range = function(from, to) {
  11866. var arr = [];
  11867. while (from <= to) {
  11868. arr.push(from++);
  11869. }
  11870. return arr;
  11871. };
  11872. var getRangeGroups = function(dataType, from, to) {
  11873. var cells = [],
  11874. cell = {
  11875. row: null,
  11876. col: null
  11877. };
  11878. if (dataType == "cols") {
  11879. while (from <= to) {
  11880. cell = {
  11881. row: -1,
  11882. col: from++
  11883. };
  11884. cells.push(cell);
  11885. }
  11886. } else {
  11887. while (from <= to) {
  11888. cell = {
  11889. row: from++,
  11890. col: -1
  11891. };
  11892. cells.push(cell);
  11893. }
  11894. }
  11895. var cellsGroups = getCellsGroups(cells),
  11896. totalRows = 0,
  11897. totalCols = 0;
  11898. for (var i = 0; i < cellsGroups.length; i++) {
  11899. totalRows += cellsGroups[i].filter(function(item) {
  11900. return item['rows'];
  11901. }).length;
  11902. totalCols += cellsGroups[i].filter(function(item) {
  11903. return item['cols'];
  11904. }).length;
  11905. }
  11906. return {
  11907. total: {
  11908. rows: totalRows,
  11909. cols: totalCols
  11910. },
  11911. groups: cellsGroups
  11912. };
  11913. };
  11914. var getCellsGroups = function(cells) {
  11915. var _groups = [];
  11916. for (var i = 0; i < cells.length; i++) {
  11917. _groups.push(getCellGroups(cells[i]));
  11918. }
  11919. return _groups;
  11920. };
  11921. var getCellGroups = function(coords, groupLevel, groupType) {
  11922. var row = coords.row,
  11923. col = coords.col;
  11924. var tmpRow = (row === -1 ? 0 : row),
  11925. tmpCol = (col === -1 ? 0 : col);
  11926. var _groups = [];
  11927. for (var i = 0; i < groups.length; i++) {
  11928. var group = groups[i],
  11929. id = group['id'],
  11930. level = group['level'],
  11931. rows = group['rows'] || [],
  11932. cols = group['cols'] || [];
  11933. if (_groups.indexOf(id) === -1) {
  11934. if (rows.indexOf(tmpRow) !== -1 || cols.indexOf(tmpCol) !== -1) {
  11935. _groups.push(group);
  11936. }
  11937. }
  11938. }
  11939. if (col === -1) {
  11940. _groups = _groups.concat(getColGroups());
  11941. } else if (row === -1) {
  11942. _groups = _groups.concat(getRowGroups());
  11943. }
  11944. if (groupLevel) {
  11945. _groups = _groups.filter(function(item) {
  11946. return item['level'] === groupLevel;
  11947. });
  11948. }
  11949. if (groupType) {
  11950. if (groupType === 'cols') {
  11951. _groups = _groups.filter(function(item) {
  11952. return item['cols'];
  11953. });
  11954. } else if (groupType === 'rows') {
  11955. _groups = _groups.filter(function(item) {
  11956. return item['rows'];
  11957. });
  11958. }
  11959. }
  11960. var tmp = [];
  11961. return _groups.filter(function(item) {
  11962. if (tmp.indexOf(item.id) === -1) {
  11963. tmp.push(item.id);
  11964. return item;
  11965. }
  11966. });
  11967. };
  11968. var getGroupById = function(id) {
  11969. for (var i = 0,
  11970. groupsLength = groups.length; i < groupsLength; i++) {
  11971. if (groups[i].id == id) {
  11972. return groups[i];
  11973. }
  11974. }
  11975. return false;
  11976. };
  11977. var getGroupByRowAndLevel = function(row, level) {
  11978. for (var i = 0,
  11979. groupsLength = groups.length; i < groupsLength; i++) {
  11980. if (groups[i].level == level && groups[i].rows && groups[i].rows.indexOf(row) > -1) {
  11981. return groups[i];
  11982. }
  11983. }
  11984. return false;
  11985. };
  11986. var getGroupByColAndLevel = function(col, level) {
  11987. for (var i = 0,
  11988. groupsLength = groups.length; i < groupsLength; i++) {
  11989. if (groups[i].level == level && groups[i].cols && groups[i].cols.indexOf(col) > -1) {
  11990. return groups[i];
  11991. }
  11992. }
  11993. return false;
  11994. };
  11995. var getColGroups = function() {
  11996. var result = [];
  11997. for (var i = 0,
  11998. groupsLength = groups.length; i < groupsLength; i++) {
  11999. if (Array.isArray(groups[i]['cols'])) {
  12000. result.push(groups[i]);
  12001. }
  12002. }
  12003. return result;
  12004. };
  12005. var getColGroupsByLevel = function(level) {
  12006. var result = [];
  12007. for (var i = 0,
  12008. groupsLength = groups.length; i < groupsLength; i++) {
  12009. if (groups[i]['cols'] && groups[i]['level'] === level) {
  12010. result.push(groups[i]);
  12011. }
  12012. }
  12013. return result;
  12014. };
  12015. var getRowGroups = function() {
  12016. var result = [];
  12017. for (var i = 0,
  12018. groupsLength = groups.length; i < groupsLength; i++) {
  12019. if (Array.isArray(groups[i]['rows'])) {
  12020. result.push(groups[i]);
  12021. }
  12022. }
  12023. return result;
  12024. };
  12025. var getRowGroupsByLevel = function(level) {
  12026. var result = [];
  12027. for (var i = 0,
  12028. groupsLength = groups.length; i < groupsLength; i++) {
  12029. if (groups[i]['rows'] && groups[i]['level'] === level) {
  12030. result.push(groups[i]);
  12031. }
  12032. }
  12033. return result;
  12034. };
  12035. var getLastLevelColsInRange = function(rangeGroups) {
  12036. var level = 0;
  12037. if (rangeGroups.length) {
  12038. rangeGroups.forEach(function(items) {
  12039. items = items.filter(function(item) {
  12040. return item['cols'];
  12041. });
  12042. if (items.length) {
  12043. var sortedGroup = items.sort(compare('level', 'desc')),
  12044. lastLevel = sortedGroup[0].level;
  12045. if (level < lastLevel) {
  12046. level = lastLevel;
  12047. }
  12048. }
  12049. });
  12050. }
  12051. return level;
  12052. };
  12053. var getLastLevelRowsInRange = function(rangeGroups) {
  12054. var level = 0;
  12055. if (rangeGroups.length) {
  12056. rangeGroups.forEach(function(items) {
  12057. items = items.filter(function(item) {
  12058. return item['rows'];
  12059. });
  12060. if (items.length) {
  12061. var sortedGroup = items.sort(compare('level', 'desc')),
  12062. lastLevel = sortedGroup[0].level;
  12063. if (level < lastLevel) {
  12064. level = lastLevel;
  12065. }
  12066. }
  12067. });
  12068. }
  12069. return level;
  12070. };
  12071. var groupCols = function(from, to) {
  12072. var rangeGroups = getRangeGroups("cols", from, to),
  12073. lastLevel = getLastLevelColsInRange(rangeGroups.groups);
  12074. if (lastLevel === levels.cols) {
  12075. levels.cols++;
  12076. } else if (lastLevel > levels.cols) {
  12077. levels.cols = lastLevel + 1;
  12078. }
  12079. if (!counters.cols) {
  12080. counters.cols = getColGroups().length;
  12081. }
  12082. counters.cols++;
  12083. groups.push({
  12084. id: 'c' + counters.cols,
  12085. level: lastLevel + 1,
  12086. cols: range(from, to),
  12087. hidden: 0
  12088. });
  12089. };
  12090. var groupRows = function(from, to) {
  12091. var rangeGroups = getRangeGroups("rows", from, to),
  12092. lastLevel = getLastLevelRowsInRange(rangeGroups.groups);
  12093. levels.rows = Math.max(levels.rows, lastLevel + 1);
  12094. if (!counters.rows) {
  12095. counters.rows = getRowGroups().length;
  12096. }
  12097. counters.rows++;
  12098. groups.push({
  12099. id: 'r' + counters.rows,
  12100. level: lastLevel + 1,
  12101. rows: range(from, to),
  12102. hidden: 0
  12103. });
  12104. };
  12105. var showHideGroups = function(hidden, groups) {
  12106. var level;
  12107. for (var i = 0,
  12108. groupsLength = groups.length; i < groupsLength; i++) {
  12109. groups[i].hidden = hidden;
  12110. level = groups[i].level;
  12111. if (!hiddenRows[level]) {
  12112. hiddenRows[level] = [];
  12113. }
  12114. if (!hiddenCols[level]) {
  12115. hiddenCols[level] = [];
  12116. }
  12117. if (groups[i].rows) {
  12118. for (var j = 0,
  12119. rowsLength = groups[i].rows.length; j < rowsLength; j++) {
  12120. if (hidden > 0) {
  12121. hiddenRows[level][groups[i].rows[j]] = true;
  12122. } else {
  12123. hiddenRows[level][groups[i].rows[j]] = void 0;
  12124. }
  12125. }
  12126. } else if (groups[i].cols) {
  12127. for (var j = 0,
  12128. colsLength = groups[i].cols.length; j < colsLength; j++) {
  12129. if (hidden > 0) {
  12130. hiddenCols[level][groups[i].cols[j]] = true;
  12131. } else {
  12132. hiddenCols[level][groups[i].cols[j]] = void 0;
  12133. }
  12134. }
  12135. }
  12136. }
  12137. };
  12138. var nextIndexSharesLevel = function(dimension, currentPosition, level, currentGroupId) {
  12139. var nextCellGroupId,
  12140. levelsByOrder;
  12141. switch (dimension) {
  12142. case 'rows':
  12143. nextCellGroupId = getGroupByRowAndLevel(currentPosition + 1, level).id;
  12144. levelsByOrder = Handsontable.Grouping.getGroupLevelsByRows();
  12145. break;
  12146. case 'cols':
  12147. nextCellGroupId = getGroupByColAndLevel(currentPosition + 1, level).id;
  12148. levelsByOrder = Handsontable.Grouping.getGroupLevelsByCols();
  12149. break;
  12150. }
  12151. return !!(levelsByOrder[currentPosition + 1] && levelsByOrder[currentPosition + 1].indexOf(level) > -1 && currentGroupId == nextCellGroupId);
  12152. };
  12153. var previousIndexSharesLevel = function(dimension, currentPosition, level, currentGroupId) {
  12154. var previousCellGroupId,
  12155. levelsByOrder;
  12156. switch (dimension) {
  12157. case 'rows':
  12158. previousCellGroupId = getGroupByRowAndLevel(currentPosition - 1, level).id;
  12159. levelsByOrder = Handsontable.Grouping.getGroupLevelsByRows();
  12160. break;
  12161. case 'cols':
  12162. previousCellGroupId = getGroupByColAndLevel(currentPosition - 1, level).id;
  12163. levelsByOrder = Handsontable.Grouping.getGroupLevelsByCols();
  12164. break;
  12165. }
  12166. return !!(levelsByOrder[currentPosition - 1] && levelsByOrder[currentPosition - 1].indexOf(level) > -1 && currentGroupId == previousCellGroupId);
  12167. };
  12168. var isLastIndexOfTheLine = function(dimension, index, level, currentGroupId) {
  12169. if (index === 0) {
  12170. return false;
  12171. }
  12172. var levelsByOrder,
  12173. entriesLength,
  12174. previousSharesLevel = previousIndexSharesLevel(dimension, index, level, currentGroupId),
  12175. nextSharesLevel = nextIndexSharesLevel(dimension, index, level, currentGroupId),
  12176. nextIsHidden = false;
  12177. switch (dimension) {
  12178. case 'rows':
  12179. levelsByOrder = Handsontable.Grouping.getGroupLevelsByRows();
  12180. entriesLength = instance.countRows();
  12181. for (var i = 0; i <= levels.rows; i++) {
  12182. if (hiddenRows[i] && hiddenRows[i][index + 1]) {
  12183. nextIsHidden = true;
  12184. break;
  12185. }
  12186. }
  12187. break;
  12188. case 'cols':
  12189. levelsByOrder = Handsontable.Grouping.getGroupLevelsByCols();
  12190. entriesLength = instance.countCols();
  12191. for (var i = 0; i <= levels.cols; i++) {
  12192. if (hiddenCols[i] && hiddenCols[i][index + 1]) {
  12193. nextIsHidden = true;
  12194. break;
  12195. }
  12196. }
  12197. break;
  12198. }
  12199. if (previousSharesLevel) {
  12200. if (index == entriesLength - 1) {
  12201. return true;
  12202. } else if (!nextSharesLevel || (nextSharesLevel && nextIsHidden)) {
  12203. return true;
  12204. } else if (!levelsByOrder[index + 1]) {
  12205. return true;
  12206. }
  12207. }
  12208. return false;
  12209. };
  12210. var isLastHidden = function(dataType) {
  12211. var levelAmount;
  12212. switch (dataType) {
  12213. case 'rows':
  12214. levelAmount = levels.rows;
  12215. for (var j = 0; j <= levelAmount; j++) {
  12216. if (hiddenRows[j] && hiddenRows[j][instance.countRows() - 1]) {
  12217. return true;
  12218. }
  12219. }
  12220. break;
  12221. case 'cols':
  12222. levelAmount = levels.cols;
  12223. for (var j = 0; j <= levelAmount; j++) {
  12224. if (hiddenCols[j] && hiddenCols[j][instance.countCols() - 1]) {
  12225. return true;
  12226. }
  12227. }
  12228. break;
  12229. }
  12230. return false;
  12231. };
  12232. var isFirstIndexOfTheLine = function(dimension, index, level, currentGroupId) {
  12233. var levelsByOrder,
  12234. entriesLength,
  12235. currentGroup = getGroupById(currentGroupId),
  12236. previousAreHidden = false,
  12237. arePreviousHidden = function(dimension) {
  12238. var hidden = false,
  12239. hiddenArr = dimension == 'rows' ? hiddenRows : hiddenCols;
  12240. for (var i = 0; i <= levels[dimension]; i++) {
  12241. tempInd = index;
  12242. while (currentGroup[dimension].indexOf(tempInd) > -1) {
  12243. hidden = !!(hiddenArr[i] && hiddenArr[i][tempInd]);
  12244. tempInd--;
  12245. }
  12246. if (hidden) {
  12247. break;
  12248. }
  12249. }
  12250. return hidden;
  12251. },
  12252. previousSharesLevel = previousIndexSharesLevel(dimension, index, level, currentGroupId),
  12253. nextSharesLevel = nextIndexSharesLevel(dimension, index, level, currentGroupId),
  12254. tempInd;
  12255. switch (dimension) {
  12256. case 'rows':
  12257. levelsByOrder = Handsontable.Grouping.getGroupLevelsByRows();
  12258. entriesLength = instance.countRows();
  12259. previousAreHidden = arePreviousHidden(dimension);
  12260. break;
  12261. case 'cols':
  12262. levelsByOrder = Handsontable.Grouping.getGroupLevelsByCols();
  12263. entriesLength = instance.countCols();
  12264. previousAreHidden = arePreviousHidden(dimension);
  12265. break;
  12266. }
  12267. if (index == entriesLength - 1) {
  12268. return false;
  12269. } else if (index === 0) {
  12270. if (nextSharesLevel) {
  12271. return true;
  12272. }
  12273. } else if (!previousSharesLevel || (previousSharesLevel && previousAreHidden)) {
  12274. if (nextSharesLevel) {
  12275. return true;
  12276. }
  12277. } else if (!levelsByOrder[index - 1]) {
  12278. if (nextSharesLevel) {
  12279. return true;
  12280. }
  12281. }
  12282. return false;
  12283. };
  12284. var addGroupExpander = function(dataType, index, level, id, elem) {
  12285. var previousIndexGroupId;
  12286. switch (dataType) {
  12287. case 'rows':
  12288. previousIndexGroupId = getGroupByRowAndLevel(index - 1, level).id;
  12289. break;
  12290. case 'cols':
  12291. previousIndexGroupId = getGroupByColAndLevel(index - 1, level).id;
  12292. break;
  12293. }
  12294. if (!previousIndexGroupId) {
  12295. return null;
  12296. }
  12297. if (index > 0) {
  12298. if (previousIndexSharesLevel(dataType, index - 1, level, previousIndexGroupId) && previousIndexGroupId != id) {
  12299. var expanderButton = document.createElement('DIV');
  12300. dom.addClass(expanderButton, classes.expandButton);
  12301. expanderButton.id = 'htExpand-' + previousIndexGroupId;
  12302. expanderButton.appendChild(document.createTextNode('+'));
  12303. expanderButton.setAttribute('data-level', level);
  12304. expanderButton.setAttribute('data-type', dataType);
  12305. expanderButton.setAttribute('data-hidden', "1");
  12306. elem.appendChild(expanderButton);
  12307. return expanderButton;
  12308. }
  12309. }
  12310. return null;
  12311. };
  12312. var isCollapsed = function(currentPosition) {
  12313. var rowGroups = getRowGroups(),
  12314. colGroups = getColGroups();
  12315. for (var i = 0,
  12316. rowGroupsCount = rowGroups.length; i < rowGroupsCount; i++) {
  12317. if (rowGroups[i].rows.indexOf(currentPosition.row) > -1 && rowGroups[i].hidden) {
  12318. return true;
  12319. }
  12320. }
  12321. if (currentPosition.col === null) {
  12322. return false;
  12323. }
  12324. for (var i = 0,
  12325. colGroupsCount = colGroups.length; i < colGroupsCount; i++) {
  12326. if (colGroups[i].cols.indexOf(currentPosition.col) > -1 && colGroups[i].hidden) {
  12327. return true;
  12328. }
  12329. }
  12330. return false;
  12331. };
  12332. return {
  12333. getGroups: function() {
  12334. return groups;
  12335. },
  12336. getLevels: function() {
  12337. return levels;
  12338. },
  12339. instance: instance,
  12340. baseSpareRows: instance.getSettings().minSpareRows,
  12341. baseSpareCols: instance.getSettings().minSpareCols,
  12342. getRowGroups: getRowGroups,
  12343. getColGroups: getColGroups,
  12344. init: function() {
  12345. var groupsSetting = instance.getSettings().groups;
  12346. if (groupsSetting) {
  12347. if (Array.isArray(groupsSetting)) {
  12348. Handsontable.Grouping.initGroups(groupsSetting);
  12349. }
  12350. }
  12351. },
  12352. initGroups: function(initialGroups) {
  12353. var that = this;
  12354. groups = [];
  12355. initialGroups.forEach(function(item) {
  12356. var _group = [],
  12357. isRow = false,
  12358. isCol = false;
  12359. if (Array.isArray(item.rows)) {
  12360. _group = item.rows;
  12361. isRow = true;
  12362. } else if (Array.isArray(item.cols)) {
  12363. _group = item.cols;
  12364. isCol = true;
  12365. }
  12366. var from = _group[0],
  12367. to = _group[_group.length - 1];
  12368. if (isRow) {
  12369. groupRows(from, to);
  12370. } else if (isCol) {
  12371. groupCols(from, to);
  12372. }
  12373. });
  12374. },
  12375. resetGroups: function() {
  12376. groups = [];
  12377. counters = {
  12378. rows: 0,
  12379. cols: 0
  12380. };
  12381. levels = {
  12382. rows: 0,
  12383. cols: 0
  12384. };
  12385. var allOccurrences;
  12386. for (var i in classes) {
  12387. if (typeof classes[i] != 'function') {
  12388. allOccurrences = document.querySelectorAll('.' + classes[i]);
  12389. for (var j = 0,
  12390. occurrencesLength = allOccurrences.length; j < occurrencesLength; j++) {
  12391. dom.removeClass(allOccurrences[j], classes[i]);
  12392. }
  12393. }
  12394. }
  12395. var otherClasses = ['htGroupColClosest', 'htGroupCol'];
  12396. for (var i = 0,
  12397. otherClassesLength = otherClasses.length; i < otherClassesLength; i++) {
  12398. allOccurrences = document.querySelectorAll('.' + otherClasses[i]);
  12399. for (var j = 0,
  12400. occurrencesLength = allOccurrences.length; j < occurrencesLength; j++) {
  12401. dom.removeClass(allOccurrences[j], otherClasses[i]);
  12402. }
  12403. }
  12404. },
  12405. updateGroups: function() {
  12406. var groupSettings = this.getSettings().groups;
  12407. Handsontable.Grouping.resetGroups();
  12408. Handsontable.Grouping.initGroups(groupSettings);
  12409. },
  12410. afterGetRowHeader: function(row, TH) {
  12411. var currentRowHidden = false;
  12412. for (var i = 0,
  12413. levels = hiddenRows.length; i < levels; i++) {
  12414. if (hiddenRows[i] && hiddenRows[i][row] === true) {
  12415. currentRowHidden = true;
  12416. }
  12417. }
  12418. if (currentRowHidden) {
  12419. dom.addClass(TH.parentNode, 'hidden');
  12420. } else if (!currentRowHidden && dom.hasClass(TH.parentNode, 'hidden')) {
  12421. dom.removeClass(TH.parentNode, 'hidden');
  12422. }
  12423. },
  12424. afterGetColHeader: function(col, TH) {
  12425. var rowHeaders = this.view.wt.wtSettings.getSetting('rowHeaders').length,
  12426. thisColgroup = instance.rootElement.querySelectorAll('colgroup col:nth-child(' + parseInt(col + rowHeaders + 1, 10) + ')');
  12427. if (thisColgroup.length === 0) {
  12428. return;
  12429. }
  12430. var currentColHidden = false;
  12431. for (var i = 0,
  12432. levels = hiddenCols.length; i < levels; i++) {
  12433. if (hiddenCols[i] && hiddenCols[i][col] === true) {
  12434. currentColHidden = true;
  12435. }
  12436. }
  12437. if (currentColHidden) {
  12438. for (var i = 0,
  12439. colsAmount = thisColgroup.length; i < colsAmount; i++) {
  12440. dom.addClass(thisColgroup[i], 'hidden');
  12441. }
  12442. } else if (!currentColHidden && dom.hasClass(thisColgroup[0], 'hidden')) {
  12443. for (var i = 0,
  12444. colsAmount = thisColgroup.length; i < colsAmount; i++) {
  12445. dom.removeClass(thisColgroup[i], 'hidden');
  12446. }
  12447. }
  12448. },
  12449. groupIndicatorsFactory: function(renderersArr, direction) {
  12450. var groupsLevelsList,
  12451. getCurrentLevel,
  12452. getCurrentGroupId,
  12453. dataType,
  12454. getGroupByIndexAndLevel,
  12455. headersType,
  12456. currentHeaderModifier,
  12457. createLevelTriggers;
  12458. switch (direction) {
  12459. case 'horizontal':
  12460. groupsLevelsList = Handsontable.Grouping.getGroupLevelsByCols();
  12461. getCurrentLevel = function(elem) {
  12462. return Array.prototype.indexOf.call(elem.parentNode.parentNode.childNodes, elem.parentNode) + 1;
  12463. };
  12464. getCurrentGroupId = function(col, level) {
  12465. return getGroupByColAndLevel(col, level).id;
  12466. };
  12467. dataType = 'cols';
  12468. getGroupByIndexAndLevel = function(col, level) {
  12469. return getGroupByColAndLevel(col - 1, level);
  12470. };
  12471. headersType = "columnHeaders";
  12472. currentHeaderModifier = function(headerRenderers) {
  12473. if (headerRenderers.length === 1) {
  12474. var oldFn = headerRenderers[0];
  12475. headerRenderers[0] = function(index, elem, level) {
  12476. if (index < -1) {
  12477. makeGroupIndicatorsForLevel()(index, elem, level);
  12478. } else {
  12479. dom.removeClass(elem, classes.groupIndicatorContainer);
  12480. oldFn(index, elem, level);
  12481. }
  12482. };
  12483. }
  12484. return function() {
  12485. return headerRenderers;
  12486. };
  12487. };
  12488. createLevelTriggers = true;
  12489. break;
  12490. case 'vertical':
  12491. groupsLevelsList = Handsontable.Grouping.getGroupLevelsByRows();
  12492. getCurrentLevel = function(elem) {
  12493. return dom.index(elem) + 1;
  12494. };
  12495. getCurrentGroupId = function(row, level) {
  12496. return getGroupByRowAndLevel(row, level).id;
  12497. };
  12498. dataType = 'rows';
  12499. getGroupByIndexAndLevel = function(row, level) {
  12500. return getGroupByRowAndLevel(row - 1, level);
  12501. };
  12502. headersType = "rowHeaders";
  12503. currentHeaderModifier = function(headerRenderers) {
  12504. return headerRenderers;
  12505. };
  12506. break;
  12507. }
  12508. var createButton = function(parent) {
  12509. var button = document.createElement('div');
  12510. parent.appendChild(button);
  12511. return {
  12512. button: button,
  12513. addClass: function(className) {
  12514. dom.addClass(button, className);
  12515. }
  12516. };
  12517. };
  12518. var makeGroupIndicatorsForLevel = function() {
  12519. var directionClassname = direction.charAt(0).toUpperCase() + direction.slice(1);
  12520. return function(index, elem, level) {
  12521. level++;
  12522. var child,
  12523. collapseButton;
  12524. while (child = elem.lastChild) {
  12525. elem.removeChild(child);
  12526. }
  12527. dom.addClass(elem, classes.groupIndicatorContainer);
  12528. var currentGroupId = getCurrentGroupId(index, level);
  12529. if (index > -1 && (groupsLevelsList[index] && groupsLevelsList[index].indexOf(level) > -1)) {
  12530. collapseButton = createButton(elem);
  12531. collapseButton.addClass(classes.groupIndicator(directionClassname));
  12532. if (isFirstIndexOfTheLine(dataType, index, level, currentGroupId)) {
  12533. collapseButton.addClass(classes.groupStart);
  12534. }
  12535. if (isLastIndexOfTheLine(dataType, index, level, currentGroupId)) {
  12536. collapseButton.button.appendChild(document.createTextNode('-'));
  12537. collapseButton.addClass(classes.collapseButton);
  12538. collapseButton.button.id = classes.collapseGroupId(currentGroupId);
  12539. collapseButton.button.setAttribute('data-level', level);
  12540. collapseButton.button.setAttribute('data-type', dataType);
  12541. }
  12542. }
  12543. if (createLevelTriggers) {
  12544. var rowInd = dom.index(elem.parentNode);
  12545. if (index === -1 || (index < -1 && rowInd === Handsontable.Grouping.getLevels().cols + 1) || (rowInd === 0 && Handsontable.Grouping.getLevels().cols === 0)) {
  12546. collapseButton = createButton(elem);
  12547. collapseButton.addClass(classes.levelTrigger);
  12548. if (index === -1) {
  12549. collapseButton.button.id = classes.collapseFromLevel("Cols", level);
  12550. collapseButton.button.appendChild(document.createTextNode(level));
  12551. } else if (index < -1 && rowInd === Handsontable.Grouping.getLevels().cols + 1 || (rowInd === 0 && Handsontable.Grouping.getLevels().cols === 0)) {
  12552. var colInd = dom.index(elem) + 1;
  12553. collapseButton.button.id = classes.collapseFromLevel("Rows", colInd);
  12554. collapseButton.button.appendChild(document.createTextNode(colInd));
  12555. }
  12556. }
  12557. }
  12558. var expanderButton = addGroupExpander(dataType, index, level, currentGroupId, elem);
  12559. if (index > 0) {
  12560. var previousGroupObj = getGroupByIndexAndLevel(index - 1, level);
  12561. if (expanderButton && previousGroupObj.hidden) {
  12562. dom.addClass(expanderButton, classes.clickable);
  12563. }
  12564. }
  12565. updateHeaderWidths();
  12566. };
  12567. };
  12568. renderersArr = currentHeaderModifier(renderersArr);
  12569. if (counters[dataType] > 0) {
  12570. for (var i = 0; i < levels[dataType] + 1; i++) {
  12571. if (!Array.isArray(renderersArr)) {
  12572. renderersArr = typeof renderersArr === 'function' ? renderersArr() : new Array(renderersArr);
  12573. }
  12574. renderersArr.unshift(makeGroupIndicatorsForLevel());
  12575. }
  12576. }
  12577. },
  12578. getGroupLevelsByRows: function() {
  12579. var rowGroups = getRowGroups(),
  12580. result = [];
  12581. for (var i = 0,
  12582. groupsLength = rowGroups.length; i < groupsLength; i++) {
  12583. if (rowGroups[i].rows) {
  12584. for (var j = 0,
  12585. groupRowsLength = rowGroups[i].rows.length; j < groupRowsLength; j++) {
  12586. if (!result[rowGroups[i].rows[j]]) {
  12587. result[rowGroups[i].rows[j]] = [];
  12588. }
  12589. result[rowGroups[i].rows[j]].push(rowGroups[i].level);
  12590. }
  12591. }
  12592. }
  12593. return result;
  12594. },
  12595. getGroupLevelsByCols: function() {
  12596. var colGroups = getColGroups(),
  12597. result = [];
  12598. for (var i = 0,
  12599. groupsLength = colGroups.length; i < groupsLength; i++) {
  12600. if (colGroups[i].cols) {
  12601. for (var j = 0,
  12602. groupColsLength = colGroups[i].cols.length; j < groupColsLength; j++) {
  12603. if (!result[colGroups[i].cols[j]]) {
  12604. result[colGroups[i].cols[j]] = [];
  12605. }
  12606. result[colGroups[i].cols[j]].push(colGroups[i].level);
  12607. }
  12608. }
  12609. }
  12610. return result;
  12611. },
  12612. toggleGroupVisibility: function(event, coords, TD) {
  12613. if (dom.hasClass(event.target, classes.expandButton) || dom.hasClass(event.target, classes.collapseButton) || dom.hasClass(event.target, classes.levelTrigger)) {
  12614. var element = event.target,
  12615. elemIdSplit = element.id.split('-');
  12616. var groups = [],
  12617. id,
  12618. level,
  12619. type,
  12620. hidden;
  12621. var prepareGroupData = function(componentElement) {
  12622. if (componentElement) {
  12623. element = componentElement;
  12624. }
  12625. elemIdSplit = element.id.split('-');
  12626. id = elemIdSplit[1];
  12627. level = parseInt(element.getAttribute('data-level'), 10);
  12628. type = element.getAttribute('data-type');
  12629. hidden = parseInt(element.getAttribute('data-hidden'));
  12630. if (isNaN(hidden)) {
  12631. hidden = 1;
  12632. } else {
  12633. hidden = (hidden ? 0 : 1);
  12634. }
  12635. element.setAttribute('data-hidden', hidden.toString());
  12636. groups.push(getGroupById(id));
  12637. };
  12638. if (element.className.indexOf(classes.levelTrigger) > -1) {
  12639. var groupsInLevel,
  12640. groupsToExpand = [],
  12641. groupsToCollapse = [],
  12642. levelType = element.id.indexOf("Rows") > -1 ? "rows" : "cols";
  12643. for (var i = 1,
  12644. levelsCount = levels[levelType]; i <= levelsCount; i++) {
  12645. groupsInLevel = levelType == "rows" ? getRowGroupsByLevel(i) : getColGroupsByLevel(i);
  12646. if (i >= parseInt(elemIdSplit[1], 10)) {
  12647. for (var j = 0,
  12648. groupCount = groupsInLevel.length; j < groupCount; j++) {
  12649. groupsToCollapse.push(groupsInLevel[j]);
  12650. }
  12651. } else {
  12652. for (var j = 0,
  12653. groupCount = groupsInLevel.length; j < groupCount; j++) {
  12654. groupsToExpand.push(groupsInLevel[j]);
  12655. }
  12656. }
  12657. }
  12658. showHideGroups(true, groupsToCollapse);
  12659. showHideGroups(false, groupsToExpand);
  12660. } else {
  12661. prepareGroupData();
  12662. showHideGroups(hidden, groups);
  12663. }
  12664. type = type || levelType;
  12665. var lastHidden = isLastHidden(type),
  12666. typeUppercase = type.charAt(0).toUpperCase() + type.slice(1),
  12667. spareElements = Handsontable.Grouping['baseSpare' + typeUppercase];
  12668. if (lastHidden) {
  12669. if (spareElements == 0) {
  12670. instance.alter('insert_' + type.slice(0, -1), instance['count' + typeUppercase]());
  12671. Handsontable.Grouping["dummy" + type.slice(0, -1)] = true;
  12672. }
  12673. } else {
  12674. if (spareElements == 0) {
  12675. if (Handsontable.Grouping["dummy" + type.slice(0, -1)]) {
  12676. instance.alter('remove_' + type.slice(0, -1), instance['count' + typeUppercase]() - 1);
  12677. Handsontable.Grouping["dummy" + type.slice(0, -1)] = false;
  12678. }
  12679. }
  12680. }
  12681. instance.render();
  12682. event.stopImmediatePropagation();
  12683. }
  12684. },
  12685. modifySelectionFactory: function(position) {
  12686. var instance = this.instance;
  12687. var currentlySelected,
  12688. nextPosition = new WalkontableCellCoords(0, 0),
  12689. nextVisible = function(direction, currentPosition) {
  12690. var updateDelta = 0;
  12691. switch (direction) {
  12692. case 'down':
  12693. while (isCollapsed(currentPosition)) {
  12694. updateDelta++;
  12695. currentPosition.row += 1;
  12696. }
  12697. break;
  12698. case 'up':
  12699. while (isCollapsed(currentPosition)) {
  12700. updateDelta--;
  12701. currentPosition.row -= 1;
  12702. }
  12703. break;
  12704. case 'right':
  12705. while (isCollapsed(currentPosition)) {
  12706. updateDelta++;
  12707. currentPosition.col += 1;
  12708. }
  12709. break;
  12710. case 'left':
  12711. while (isCollapsed(currentPosition)) {
  12712. updateDelta--;
  12713. currentPosition.col -= 1;
  12714. }
  12715. break;
  12716. }
  12717. return updateDelta;
  12718. },
  12719. updateDelta = function(delta, nextPosition) {
  12720. if (delta.row > 0) {
  12721. if (isCollapsed(nextPosition)) {
  12722. delta.row += nextVisible('down', nextPosition);
  12723. }
  12724. } else if (delta.row < 0) {
  12725. if (isCollapsed(nextPosition)) {
  12726. delta.row += nextVisible('up', nextPosition);
  12727. }
  12728. }
  12729. if (delta.col > 0) {
  12730. if (isCollapsed(nextPosition)) {
  12731. delta.col += nextVisible('right', nextPosition);
  12732. }
  12733. } else if (delta.col < 0) {
  12734. if (isCollapsed(nextPosition)) {
  12735. delta.col += nextVisible('left', nextPosition);
  12736. }
  12737. }
  12738. };
  12739. switch (position) {
  12740. case 'start':
  12741. return function(delta) {
  12742. currentlySelected = instance.getSelected();
  12743. nextPosition.row = currentlySelected[0] + delta.row;
  12744. nextPosition.col = currentlySelected[1] + delta.col;
  12745. updateDelta(delta, nextPosition);
  12746. };
  12747. break;
  12748. case 'end':
  12749. return function(delta) {
  12750. currentlySelected = instance.getSelected();
  12751. nextPosition.row = currentlySelected[2] + delta.row;
  12752. nextPosition.col = currentlySelected[3] + delta.col;
  12753. updateDelta(delta, nextPosition);
  12754. };
  12755. break;
  12756. }
  12757. },
  12758. modifyRowHeight: function(height, row) {
  12759. if (instance.view.wt.wtTable.rowFilter && isCollapsed({
  12760. row: row,
  12761. col: null
  12762. })) {
  12763. return 0;
  12764. }
  12765. },
  12766. validateGroups: function() {
  12767. var areRangesOverlapping = function(a, b) {
  12768. 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])) {
  12769. return true;
  12770. }
  12771. };
  12772. var configGroups = instance.getSettings().groups,
  12773. cols = [],
  12774. rows = [];
  12775. for (var i = 0,
  12776. groupsLength = configGroups.length; i < groupsLength; i++) {
  12777. if (configGroups[i].rows) {
  12778. if (configGroups[i].rows.length === 1) {
  12779. throw new Error("Grouping error: Group {" + configGroups[i].rows[0] + "} is invalid. Cannot define single-entry groups.");
  12780. return false;
  12781. } else if (configGroups[i].rows.length === 0) {
  12782. throw new Error("Grouping error: Cannot define empty groups.");
  12783. return false;
  12784. }
  12785. rows.push(configGroups[i].rows);
  12786. for (var j = 0,
  12787. rowsLength = rows.length; j < rowsLength; j++) {
  12788. if (areRangesOverlapping(configGroups[i].rows, rows[j])) {
  12789. throw new Error("Grouping error: ranges {" + configGroups[i].rows[0] + ", " + configGroups[i].rows[1] + "} and {" + rows[j][0] + ", " + rows[j][1] + "} are overlapping.");
  12790. return false;
  12791. }
  12792. }
  12793. } else if (configGroups[i].cols) {
  12794. if (configGroups[i].cols.length === 1) {
  12795. throw new Error("Grouping error: Group {" + configGroups[i].cols[0] + "} is invalid. Cannot define single-entry groups.");
  12796. return false;
  12797. } else if (configGroups[i].cols.length === 0) {
  12798. throw new Error("Grouping error: Cannot define empty groups.");
  12799. return false;
  12800. }
  12801. cols.push(configGroups[i].cols);
  12802. for (var j = 0,
  12803. colsLength = cols.length; j < colsLength; j++) {
  12804. if (areRangesOverlapping(configGroups[i].cols, cols[j])) {
  12805. throw new Error("Grouping error: ranges {" + configGroups[i].cols[0] + ", " + configGroups[i].cols[1] + "} and {" + cols[j][0] + ", " + cols[j][1] + "} are overlapping.");
  12806. return false;
  12807. }
  12808. }
  12809. }
  12810. }
  12811. return true;
  12812. },
  12813. afterGetRowHeaderRenderers: function(arr) {
  12814. Handsontable.Grouping.groupIndicatorsFactory(arr, 'vertical');
  12815. },
  12816. afterGetColumnHeaderRenderers: function(arr) {
  12817. Handsontable.Grouping.groupIndicatorsFactory(arr, 'horizontal');
  12818. },
  12819. hookProxy: function(fn, arg) {
  12820. return function() {
  12821. if (instance.getSettings().groups) {
  12822. return arg ? Handsontable.Grouping[fn](arg).apply(this, arguments) : Handsontable.Grouping[fn].apply(this, arguments);
  12823. } else {
  12824. return void 0;
  12825. }
  12826. };
  12827. }
  12828. };
  12829. }
  12830. Grouping.prototype.beforeInit = function() {};
  12831. var init = function() {
  12832. var instance = this,
  12833. groupingSetting = !!(instance.getSettings().groups);
  12834. if (groupingSetting) {
  12835. var headerUpdates = {};
  12836. Handsontable.Grouping = new Grouping(instance);
  12837. if (!instance.getSettings().rowHeaders) {
  12838. headerUpdates.rowHeaders = true;
  12839. }
  12840. if (!instance.getSettings().colHeaders) {
  12841. headerUpdates.colHeaders = true;
  12842. }
  12843. if (headerUpdates.colHeaders || headerUpdates.rowHeaders) {
  12844. instance.updateSettings(headerUpdates);
  12845. }
  12846. var groupConfigValid = Handsontable.Grouping.validateGroups();
  12847. if (!groupConfigValid) {
  12848. return;
  12849. }
  12850. instance.addHook('beforeInit', Handsontable.Grouping.hookProxy('init'));
  12851. instance.addHook('afterUpdateSettings', Handsontable.Grouping.hookProxy('updateGroups'));
  12852. instance.addHook('afterGetColumnHeaderRenderers', Handsontable.Grouping.hookProxy('afterGetColumnHeaderRenderers'));
  12853. instance.addHook('afterGetRowHeaderRenderers', Handsontable.Grouping.hookProxy('afterGetRowHeaderRenderers'));
  12854. instance.addHook('afterGetRowHeader', Handsontable.Grouping.hookProxy('afterGetRowHeader'));
  12855. instance.addHook('afterGetColHeader', Handsontable.Grouping.hookProxy('afterGetColHeader'));
  12856. instance.addHook('beforeOnCellMouseDown', Handsontable.Grouping.hookProxy('toggleGroupVisibility'));
  12857. instance.addHook('modifyTransformStart', Handsontable.Grouping.hookProxy('modifySelectionFactory', 'start'));
  12858. instance.addHook('modifyTransformEnd', Handsontable.Grouping.hookProxy('modifySelectionFactory', 'end'));
  12859. instance.addHook('modifyRowHeight', Handsontable.Grouping.hookProxy('modifyRowHeight'));
  12860. }
  12861. };
  12862. var updateHeaderWidths = function() {
  12863. var colgroups = document.querySelectorAll('colgroup');
  12864. for (var i = 0,
  12865. colgroupsLength = colgroups.length; i < colgroupsLength; i++) {
  12866. var rowHeaders = colgroups[i].querySelectorAll('col.rowHeader');
  12867. if (rowHeaders.length === 0) {
  12868. return;
  12869. }
  12870. for (var j = 0,
  12871. rowHeadersLength = rowHeaders.length + 1; j < rowHeadersLength; j++) {
  12872. if (rowHeadersLength == 2) {
  12873. return;
  12874. }
  12875. if (j < Handsontable.Grouping.getLevels().rows + 1) {
  12876. if (j == Handsontable.Grouping.getLevels().rows) {
  12877. dom.addClass(rowHeaders[j], 'htGroupColClosest');
  12878. } else {
  12879. dom.addClass(rowHeaders[j], 'htGroupCol');
  12880. }
  12881. }
  12882. }
  12883. }
  12884. };
  12885. Handsontable.hooks.add('beforeInit', init);
  12886. Handsontable.hooks.add('afterUpdateSettings', function() {
  12887. if (this.getSettings().groups && !Handsontable.Grouping) {
  12888. init.call(this, arguments);
  12889. } else if (!this.getSettings().groups && Handsontable.Grouping) {
  12890. Handsontable.Grouping.resetGroups();
  12891. Handsontable.Grouping = void 0;
  12892. }
  12893. });
  12894. Handsontable.plugins.Grouping = Grouping;
  12895. //#
  12896. },{"./../../dom.js":27,"./../../plugins.js":45}],58:[function(require,module,exports){
  12897. "use strict";
  12898. Object.defineProperties(exports, {
  12899. ManualColumnFreeze: {get: function() {
  12900. return ManualColumnFreeze;
  12901. }},
  12902. __esModule: {value: true}
  12903. });
  12904. var $___46__46__47__46__46__47_plugins_46_js__;
  12905. 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;
  12906. ;
  12907. function ManualColumnFreeze(instance) {
  12908. var fixedColumnsCount = instance.getSettings().fixedColumnsLeft;
  12909. var init = function() {
  12910. if (typeof instance.manualColumnPositionsPluginUsages !== 'undefined') {
  12911. instance.manualColumnPositionsPluginUsages.push('manualColumnFreeze');
  12912. } else {
  12913. instance.manualColumnPositionsPluginUsages = ['manualColumnFreeze'];
  12914. }
  12915. bindHooks();
  12916. };
  12917. function addContextMenuEntry(defaultOptions) {
  12918. defaultOptions.items.push(Handsontable.ContextMenu.SEPARATOR, {
  12919. key: 'freeze_column',
  12920. name: function() {
  12921. var selectedColumn = instance.getSelected()[1];
  12922. if (selectedColumn > fixedColumnsCount - 1) {
  12923. return 'Freeze this column';
  12924. } else {
  12925. return 'Unfreeze this column';
  12926. }
  12927. },
  12928. disabled: function() {
  12929. var selection = instance.getSelected();
  12930. return selection[1] !== selection[3];
  12931. },
  12932. callback: function() {
  12933. var selectedColumn = instance.getSelected()[1];
  12934. if (selectedColumn > fixedColumnsCount - 1) {
  12935. freezeColumn(selectedColumn);
  12936. } else {
  12937. unfreezeColumn(selectedColumn);
  12938. }
  12939. }
  12940. });
  12941. }
  12942. function addFixedColumn() {
  12943. instance.updateSettings({fixedColumnsLeft: fixedColumnsCount + 1});
  12944. fixedColumnsCount++;
  12945. }
  12946. function removeFixedColumn() {
  12947. instance.updateSettings({fixedColumnsLeft: fixedColumnsCount - 1});
  12948. fixedColumnsCount--;
  12949. }
  12950. function checkPositionData(col) {
  12951. if (!instance.manualColumnPositions || instance.manualColumnPositions.length === 0) {
  12952. if (!instance.manualColumnPositions) {
  12953. instance.manualColumnPositions = [];
  12954. }
  12955. }
  12956. if (col) {
  12957. if (!instance.manualColumnPositions[col]) {
  12958. createPositionData(col + 1);
  12959. }
  12960. } else {
  12961. createPositionData(instance.countCols());
  12962. }
  12963. }
  12964. function createPositionData(len) {
  12965. if (instance.manualColumnPositions.length < len) {
  12966. for (var i = instance.manualColumnPositions.length; i < len; i++) {
  12967. instance.manualColumnPositions[i] = i;
  12968. }
  12969. }
  12970. }
  12971. function modifyColumnOrder(col, actualCol, returnCol, action) {
  12972. if (returnCol == null) {
  12973. returnCol = col;
  12974. }
  12975. if (action === 'freeze') {
  12976. instance.manualColumnPositions.splice(fixedColumnsCount, 0, instance.manualColumnPositions.splice(actualCol, 1)[0]);
  12977. } else if (action === 'unfreeze') {
  12978. instance.manualColumnPositions.splice(returnCol, 0, instance.manualColumnPositions.splice(actualCol, 1)[0]);
  12979. }
  12980. }
  12981. function getBestColumnReturnPosition(col) {
  12982. var i = fixedColumnsCount,
  12983. j = getModifiedColumnIndex(i),
  12984. initialCol = getModifiedColumnIndex(col);
  12985. while (j < initialCol) {
  12986. i++;
  12987. j = getModifiedColumnIndex(i);
  12988. }
  12989. return i - 1;
  12990. }
  12991. function freezeColumn(col) {
  12992. if (col <= fixedColumnsCount - 1) {
  12993. return;
  12994. }
  12995. var modifiedColumn = getModifiedColumnIndex(col) || col;
  12996. checkPositionData(modifiedColumn);
  12997. modifyColumnOrder(modifiedColumn, col, null, 'freeze');
  12998. addFixedColumn();
  12999. instance.view.wt.wtOverlays.leftOverlay.refresh();
  13000. instance.view.wt.wtOverlays.adjustElementsSize();
  13001. }
  13002. function unfreezeColumn(col) {
  13003. if (col > fixedColumnsCount - 1) {
  13004. return;
  13005. }
  13006. var returnCol = getBestColumnReturnPosition(col);
  13007. var modifiedColumn = getModifiedColumnIndex(col) || col;
  13008. checkPositionData(modifiedColumn);
  13009. modifyColumnOrder(modifiedColumn, col, returnCol, 'unfreeze');
  13010. removeFixedColumn();
  13011. instance.view.wt.wtOverlays.leftOverlay.refresh();
  13012. }
  13013. function getModifiedColumnIndex(col) {
  13014. return instance.manualColumnPositions[col];
  13015. }
  13016. function onModifyCol(col) {
  13017. if (this.manualColumnPositionsPluginUsages.length > 1) {
  13018. return col;
  13019. }
  13020. return getModifiedColumnIndex(col);
  13021. }
  13022. function bindHooks() {
  13023. instance.addHook('modifyCol', onModifyCol);
  13024. instance.addHook('afterContextMenuDefaultOptions', addContextMenuEntry);
  13025. }
  13026. return {
  13027. init: init,
  13028. freezeColumn: freezeColumn,
  13029. unfreezeColumn: unfreezeColumn,
  13030. helpers: {
  13031. addFixedColumn: addFixedColumn,
  13032. removeFixedColumn: removeFixedColumn,
  13033. checkPositionData: checkPositionData,
  13034. modifyColumnOrder: modifyColumnOrder,
  13035. getBestColumnReturnPosition: getBestColumnReturnPosition
  13036. }
  13037. };
  13038. }
  13039. var init = function init() {
  13040. if (!this.getSettings().manualColumnFreeze) {
  13041. return;
  13042. }
  13043. var mcfPlugin;
  13044. Handsontable.plugins.manualColumnFreeze = ManualColumnFreeze;
  13045. this.manualColumnFreeze = new ManualColumnFreeze(this);
  13046. mcfPlugin = this.manualColumnFreeze;
  13047. mcfPlugin.init.call(this);
  13048. };
  13049. Handsontable.hooks.add('beforeInit', init);
  13050. //#
  13051. },{"./../../plugins.js":45}],59:[function(require,module,exports){
  13052. "use strict";
  13053. Object.defineProperties(exports, {
  13054. ManualColumnMove: {get: function() {
  13055. return ManualColumnMove;
  13056. }},
  13057. __esModule: {value: true}
  13058. });
  13059. var $___46__46__47__46__46__47_helpers_46_js__,
  13060. $___46__46__47__46__46__47_dom_46_js__,
  13061. $___46__46__47__46__46__47_eventManager_46_js__,
  13062. $___46__46__47__46__46__47_plugins_46_js__;
  13063. 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__});
  13064. 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__});
  13065. 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;
  13066. 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;
  13067. ;
  13068. function ManualColumnMove() {
  13069. var startCol,
  13070. endCol,
  13071. startX,
  13072. startOffset,
  13073. currentCol,
  13074. instance,
  13075. currentTH,
  13076. handle = document.createElement('DIV'),
  13077. guide = document.createElement('DIV'),
  13078. eventManager = eventManagerObject(this);
  13079. handle.className = 'manualColumnMover';
  13080. guide.className = 'manualColumnMoverGuide';
  13081. var saveManualColumnPositions = function() {
  13082. var instance = this;
  13083. Handsontable.hooks.run(instance, 'persistentStateSave', 'manualColumnPositions', instance.manualColumnPositions);
  13084. };
  13085. var loadManualColumnPositions = function() {
  13086. var instance = this;
  13087. var storedState = {};
  13088. Handsontable.hooks.run(instance, 'persistentStateLoad', 'manualColumnPositions', storedState);
  13089. return storedState.value;
  13090. };
  13091. function setupHandlePosition(TH) {
  13092. instance = this;
  13093. currentTH = TH;
  13094. var col = this.view.wt.wtTable.getCoords(TH).col;
  13095. if (col >= 0) {
  13096. currentCol = col;
  13097. var box = currentTH.getBoundingClientRect();
  13098. startOffset = box.left;
  13099. handle.style.top = box.top + 'px';
  13100. handle.style.left = startOffset + 'px';
  13101. instance.rootElement.appendChild(handle);
  13102. }
  13103. }
  13104. function refreshHandlePosition(TH, delta) {
  13105. var box = TH.getBoundingClientRect();
  13106. var handleWidth = 6;
  13107. if (delta > 0) {
  13108. handle.style.left = (box.left + box.width - handleWidth) + 'px';
  13109. } else {
  13110. handle.style.left = box.left + 'px';
  13111. }
  13112. }
  13113. function setupGuidePosition() {
  13114. var instance = this;
  13115. dom.addClass(handle, 'active');
  13116. dom.addClass(guide, 'active');
  13117. var box = currentTH.getBoundingClientRect();
  13118. guide.style.width = box.width + 'px';
  13119. guide.style.height = instance.view.maximumVisibleElementHeight(0) + 'px';
  13120. guide.style.top = handle.style.top;
  13121. guide.style.left = startOffset + 'px';
  13122. instance.rootElement.appendChild(guide);
  13123. }
  13124. function refreshGuidePosition(diff) {
  13125. guide.style.left = startOffset + diff + 'px';
  13126. }
  13127. function hideHandleAndGuide() {
  13128. dom.removeClass(handle, 'active');
  13129. dom.removeClass(guide, 'active');
  13130. }
  13131. var checkColumnHeader = function(element) {
  13132. if (element.tagName != 'BODY') {
  13133. if (element.parentNode.tagName == 'THEAD') {
  13134. return true;
  13135. } else {
  13136. element = element.parentNode;
  13137. return checkColumnHeader(element);
  13138. }
  13139. }
  13140. return false;
  13141. };
  13142. var getTHFromTargetElement = function(element) {
  13143. if (element.tagName != 'TABLE') {
  13144. if (element.tagName == 'TH') {
  13145. return element;
  13146. } else {
  13147. return getTHFromTargetElement(element.parentNode);
  13148. }
  13149. }
  13150. return null;
  13151. };
  13152. var bindEvents = function() {
  13153. var instance = this;
  13154. var pressed;
  13155. eventManager.addEventListener(instance.rootElement, 'mouseover', function(e) {
  13156. if (checkColumnHeader(e.target)) {
  13157. var th = getTHFromTargetElement(e.target);
  13158. if (th) {
  13159. if (pressed) {
  13160. var col = instance.view.wt.wtTable.getCoords(th).col;
  13161. if (col >= 0) {
  13162. endCol = col;
  13163. refreshHandlePosition(e.target, endCol - startCol);
  13164. }
  13165. } else {
  13166. setupHandlePosition.call(instance, th);
  13167. }
  13168. }
  13169. }
  13170. });
  13171. eventManager.addEventListener(instance.rootElement, 'mousedown', function(e) {
  13172. if (dom.hasClass(e.target, 'manualColumnMover')) {
  13173. startX = helper.pageX(e);
  13174. setupGuidePosition.call(instance);
  13175. pressed = instance;
  13176. startCol = currentCol;
  13177. endCol = currentCol;
  13178. }
  13179. });
  13180. eventManager.addEventListener(window, 'mousemove', function(e) {
  13181. if (pressed) {
  13182. refreshGuidePosition(helper.pageX(e) - startX);
  13183. }
  13184. });
  13185. eventManager.addEventListener(window, 'mouseup', function(e) {
  13186. if (pressed) {
  13187. hideHandleAndGuide();
  13188. pressed = false;
  13189. createPositionData(instance.manualColumnPositions, instance.countCols());
  13190. instance.manualColumnPositions.splice(endCol, 0, instance.manualColumnPositions.splice(startCol, 1)[0]);
  13191. instance.forceFullRender = true;
  13192. instance.view.render();
  13193. saveManualColumnPositions.call(instance);
  13194. Handsontable.hooks.run(instance, 'afterColumnMove', startCol, endCol);
  13195. setupHandlePosition.call(instance, currentTH);
  13196. }
  13197. });
  13198. instance.addHook('afterDestroy', unbindEvents);
  13199. };
  13200. var unbindEvents = function() {
  13201. eventManager.clear();
  13202. };
  13203. var createPositionData = function(positionArr, len) {
  13204. if (positionArr.length < len) {
  13205. for (var i = positionArr.length; i < len; i++) {
  13206. positionArr[i] = i;
  13207. }
  13208. }
  13209. };
  13210. this.beforeInit = function() {
  13211. this.manualColumnPositions = [];
  13212. };
  13213. this.init = function(source) {
  13214. var instance = this;
  13215. var manualColMoveEnabled = !!(this.getSettings().manualColumnMove);
  13216. if (manualColMoveEnabled) {
  13217. var initialManualColumnPositions = this.getSettings().manualColumnMove;
  13218. var loadedManualColumnPositions = loadManualColumnPositions.call(instance);
  13219. if (typeof loadedManualColumnPositions != 'undefined') {
  13220. this.manualColumnPositions = loadedManualColumnPositions;
  13221. } else if (Array.isArray(initialManualColumnPositions)) {
  13222. this.manualColumnPositions = initialManualColumnPositions;
  13223. } else {
  13224. this.manualColumnPositions = [];
  13225. }
  13226. if (source == 'afterInit') {
  13227. if (typeof instance.manualColumnPositionsPluginUsages != 'undefined') {
  13228. instance.manualColumnPositionsPluginUsages.push('manualColumnMove');
  13229. } else {
  13230. instance.manualColumnPositionsPluginUsages = ['manualColumnMove'];
  13231. }
  13232. bindEvents.call(this);
  13233. if (this.manualColumnPositions.length > 0) {
  13234. this.forceFullRender = true;
  13235. this.render();
  13236. }
  13237. }
  13238. } else {
  13239. var pluginUsagesIndex = instance.manualColumnPositionsPluginUsages ? instance.manualColumnPositionsPluginUsages.indexOf('manualColumnMove') : -1;
  13240. if (pluginUsagesIndex > -1) {
  13241. unbindEvents.call(this);
  13242. this.manualColumnPositions = [];
  13243. instance.manualColumnPositionsPluginUsages[pluginUsagesIndex] = void 0;
  13244. }
  13245. }
  13246. };
  13247. this.modifyCol = function(col) {
  13248. if (this.getSettings().manualColumnMove) {
  13249. if (typeof this.manualColumnPositions[col] === 'undefined') {
  13250. createPositionData(this.manualColumnPositions, col + 1);
  13251. }
  13252. return this.manualColumnPositions[col];
  13253. }
  13254. return col;
  13255. };
  13256. this.afterRemoveCol = function(index, amount) {
  13257. if (!this.getSettings().manualColumnMove) {
  13258. return;
  13259. }
  13260. var rmindx,
  13261. colpos = this.manualColumnPositions;
  13262. rmindx = colpos.splice(index, amount);
  13263. colpos = colpos.map(function(colpos) {
  13264. var i,
  13265. newpos = colpos;
  13266. for (i = 0; i < rmindx.length; i++) {
  13267. if (colpos > rmindx[i]) {
  13268. newpos--;
  13269. }
  13270. }
  13271. return newpos;
  13272. });
  13273. this.manualColumnPositions = colpos;
  13274. };
  13275. this.afterCreateCol = function(index, amount) {
  13276. if (!this.getSettings().manualColumnMove) {
  13277. return;
  13278. }
  13279. var colpos = this.manualColumnPositions;
  13280. if (!colpos.length) {
  13281. return;
  13282. }
  13283. var addindx = [];
  13284. for (var i = 0; i < amount; i++) {
  13285. addindx.push(index + i);
  13286. }
  13287. if (index >= colpos.length) {
  13288. colpos.concat(addindx);
  13289. } else {
  13290. colpos = colpos.map(function(colpos) {
  13291. return (colpos >= index) ? (colpos + amount) : colpos;
  13292. });
  13293. colpos.splice.apply(colpos, [index, 0].concat(addindx));
  13294. }
  13295. this.manualColumnPositions = colpos;
  13296. };
  13297. }
  13298. var htManualColumnMove = new ManualColumnMove();
  13299. Handsontable.hooks.add('beforeInit', htManualColumnMove.beforeInit);
  13300. Handsontable.hooks.add('afterInit', function() {
  13301. htManualColumnMove.init.call(this, 'afterInit');
  13302. });
  13303. Handsontable.hooks.add('afterUpdateSettings', function() {
  13304. htManualColumnMove.init.call(this, 'afterUpdateSettings');
  13305. });
  13306. Handsontable.hooks.add('modifyCol', htManualColumnMove.modifyCol);
  13307. Handsontable.hooks.add('afterRemoveCol', htManualColumnMove.afterRemoveCol);
  13308. Handsontable.hooks.add('afterCreateCol', htManualColumnMove.afterCreateCol);
  13309. Handsontable.hooks.register('afterColumnMove');
  13310. //#
  13311. },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../helpers.js":42,"./../../plugins.js":45}],60:[function(require,module,exports){
  13312. "use strict";
  13313. Object.defineProperties(exports, {
  13314. ManualColumnResize: {get: function() {
  13315. return ManualColumnResize;
  13316. }},
  13317. __esModule: {value: true}
  13318. });
  13319. var $___46__46__47__46__46__47_helpers_46_js__,
  13320. $___46__46__47__46__46__47_dom_46_js__,
  13321. $___46__46__47__46__46__47_eventManager_46_js__,
  13322. $___46__46__47__46__46__47_plugins_46_js__;
  13323. 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__});
  13324. 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__});
  13325. 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;
  13326. 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;
  13327. ;
  13328. function ManualColumnResize() {
  13329. var currentTH,
  13330. currentCol,
  13331. currentWidth,
  13332. instance,
  13333. newSize,
  13334. startX,
  13335. startWidth,
  13336. startOffset,
  13337. handle = document.createElement('DIV'),
  13338. guide = document.createElement('DIV'),
  13339. eventManager = eventManagerObject(this);
  13340. handle.className = 'manualColumnResizer';
  13341. guide.className = 'manualColumnResizerGuide';
  13342. var saveManualColumnWidths = function() {
  13343. var instance = this;
  13344. Handsontable.hooks.run(instance, 'persistentStateSave', 'manualColumnWidths', instance.manualColumnWidths);
  13345. };
  13346. var loadManualColumnWidths = function() {
  13347. var instance = this;
  13348. var storedState = {};
  13349. Handsontable.hooks.run(instance, 'persistentStateLoad', 'manualColumnWidths', storedState);
  13350. return storedState.value;
  13351. };
  13352. function setupHandlePosition(TH) {
  13353. instance = this;
  13354. currentTH = TH;
  13355. var col = this.view.wt.wtTable.getCoords(TH).col;
  13356. if (col >= 0) {
  13357. currentCol = col;
  13358. var box = currentTH.getBoundingClientRect();
  13359. startOffset = box.left - 6;
  13360. startWidth = parseInt(box.width, 10);
  13361. handle.style.top = box.top + 'px';
  13362. handle.style.left = startOffset + startWidth + 'px';
  13363. instance.rootElement.appendChild(handle);
  13364. }
  13365. }
  13366. function refreshHandlePosition() {
  13367. handle.style.left = startOffset + currentWidth + 'px';
  13368. }
  13369. function setupGuidePosition() {
  13370. var instance = this;
  13371. dom.addClass(handle, 'active');
  13372. dom.addClass(guide, 'active');
  13373. guide.style.top = handle.style.top;
  13374. guide.style.left = handle.style.left;
  13375. guide.style.height = instance.view.maximumVisibleElementHeight(0) + 'px';
  13376. instance.rootElement.appendChild(guide);
  13377. }
  13378. function refreshGuidePosition() {
  13379. guide.style.left = handle.style.left;
  13380. }
  13381. function hideHandleAndGuide() {
  13382. dom.removeClass(handle, 'active');
  13383. dom.removeClass(guide, 'active');
  13384. }
  13385. var checkColumnHeader = function(element) {
  13386. if (element.tagName != 'BODY') {
  13387. if (element.parentNode.tagName == 'THEAD') {
  13388. return true;
  13389. } else {
  13390. element = element.parentNode;
  13391. return checkColumnHeader(element);
  13392. }
  13393. }
  13394. return false;
  13395. };
  13396. var getTHFromTargetElement = function(element) {
  13397. if (element.tagName != 'TABLE') {
  13398. if (element.tagName == 'TH') {
  13399. return element;
  13400. } else {
  13401. return getTHFromTargetElement(element.parentNode);
  13402. }
  13403. }
  13404. return null;
  13405. };
  13406. var bindEvents = function() {
  13407. var instance = this;
  13408. var pressed;
  13409. var dblclick = 0;
  13410. var autoresizeTimeout = null;
  13411. eventManager.addEventListener(instance.rootElement, 'mouseover', function(e) {
  13412. if (checkColumnHeader(e.target)) {
  13413. var th = getTHFromTargetElement(e.target);
  13414. if (th) {
  13415. if (!pressed) {
  13416. setupHandlePosition.call(instance, th);
  13417. }
  13418. }
  13419. }
  13420. });
  13421. eventManager.addEventListener(instance.rootElement, 'mousedown', function(e) {
  13422. if (dom.hasClass(e.target, 'manualColumnResizer')) {
  13423. setupGuidePosition.call(instance);
  13424. pressed = instance;
  13425. if (autoresizeTimeout == null) {
  13426. autoresizeTimeout = setTimeout(function() {
  13427. if (dblclick >= 2) {
  13428. newSize = instance.determineColumnWidth.call(instance, currentCol);
  13429. setManualSize(currentCol, newSize);
  13430. instance.forceFullRender = true;
  13431. instance.view.render();
  13432. Handsontable.hooks.run(instance, 'afterColumnResize', currentCol, newSize);
  13433. }
  13434. dblclick = 0;
  13435. autoresizeTimeout = null;
  13436. }, 500);
  13437. instance._registerTimeout(autoresizeTimeout);
  13438. }
  13439. dblclick++;
  13440. startX = helper.pageX(e);
  13441. newSize = startWidth;
  13442. }
  13443. });
  13444. eventManager.addEventListener(window, 'mousemove', function(e) {
  13445. if (pressed) {
  13446. currentWidth = startWidth + (helper.pageX(e) - startX);
  13447. newSize = setManualSize(currentCol, currentWidth);
  13448. refreshHandlePosition();
  13449. refreshGuidePosition();
  13450. }
  13451. });
  13452. eventManager.addEventListener(window, 'mouseup', function() {
  13453. if (pressed) {
  13454. hideHandleAndGuide();
  13455. pressed = false;
  13456. if (newSize != startWidth) {
  13457. instance.forceFullRender = true;
  13458. instance.view.render();
  13459. instance.view.wt.wtOverlays.adjustElementsSize();
  13460. saveManualColumnWidths.call(instance);
  13461. Handsontable.hooks.run(instance, 'afterColumnResize', currentCol, newSize);
  13462. }
  13463. setupHandlePosition.call(instance, currentTH);
  13464. }
  13465. });
  13466. instance.addHook('afterDestroy', unbindEvents);
  13467. };
  13468. var unbindEvents = function() {
  13469. eventManager.clear();
  13470. };
  13471. this.beforeInit = function() {
  13472. this.manualColumnWidths = [];
  13473. };
  13474. this.init = function(source) {
  13475. var instance = this;
  13476. var manualColumnWidthEnabled = !!(this.getSettings().manualColumnResize);
  13477. if (manualColumnWidthEnabled) {
  13478. var initialColumnWidths = this.getSettings().manualColumnResize;
  13479. var loadedManualColumnWidths = loadManualColumnWidths.call(instance);
  13480. if (typeof instance.manualColumnWidthsPluginUsages != 'undefined') {
  13481. instance.manualColumnWidthsPluginUsages.push('manualColumnResize');
  13482. } else {
  13483. instance.manualColumnWidthsPluginUsages = ['manualColumnResize'];
  13484. }
  13485. if (typeof loadedManualColumnWidths != 'undefined') {
  13486. this.manualColumnWidths = loadedManualColumnWidths;
  13487. } else if (Array.isArray(initialColumnWidths)) {
  13488. this.manualColumnWidths = initialColumnWidths;
  13489. } else {
  13490. this.manualColumnWidths = [];
  13491. }
  13492. if (source == 'afterInit') {
  13493. bindEvents.call(this);
  13494. if (this.manualColumnWidths.length > 0) {
  13495. this.forceFullRender = true;
  13496. this.render();
  13497. }
  13498. }
  13499. } else {
  13500. var pluginUsagesIndex = instance.manualColumnWidthsPluginUsages ? instance.manualColumnWidthsPluginUsages.indexOf('manualColumnResize') : -1;
  13501. if (pluginUsagesIndex > -1) {
  13502. unbindEvents.call(this);
  13503. this.manualColumnWidths = [];
  13504. }
  13505. }
  13506. };
  13507. var setManualSize = function(col, width) {
  13508. width = Math.max(width, 20);
  13509. col = Handsontable.hooks.run(instance, 'modifyCol', col);
  13510. instance.manualColumnWidths[col] = width;
  13511. return width;
  13512. };
  13513. this.modifyColWidth = function(width, col) {
  13514. col = this.runHooks('modifyCol', col);
  13515. if (this.getSettings().manualColumnResize && this.manualColumnWidths[col]) {
  13516. return this.manualColumnWidths[col];
  13517. }
  13518. return width;
  13519. };
  13520. }
  13521. var htManualColumnResize = new ManualColumnResize();
  13522. Handsontable.hooks.add('beforeInit', htManualColumnResize.beforeInit);
  13523. Handsontable.hooks.add('afterInit', function() {
  13524. htManualColumnResize.init.call(this, 'afterInit');
  13525. });
  13526. Handsontable.hooks.add('afterUpdateSettings', function() {
  13527. htManualColumnResize.init.call(this, 'afterUpdateSettings');
  13528. });
  13529. Handsontable.hooks.add('modifyColWidth', htManualColumnResize.modifyColWidth);
  13530. Handsontable.hooks.register('afterColumnResize');
  13531. //#
  13532. },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../helpers.js":42,"./../../plugins.js":45}],61:[function(require,module,exports){
  13533. "use strict";
  13534. Object.defineProperties(exports, {
  13535. ManualRowMove: {get: function() {
  13536. return ManualRowMove;
  13537. }},
  13538. __esModule: {value: true}
  13539. });
  13540. var $___46__46__47__46__46__47_helpers_46_js__,
  13541. $___46__46__47__46__46__47_dom_46_js__,
  13542. $___46__46__47__46__46__47_eventManager_46_js__,
  13543. $___46__46__47__46__46__47_plugins_46_js__;
  13544. 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__});
  13545. 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__});
  13546. 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;
  13547. 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;
  13548. ;
  13549. function ManualRowMove() {
  13550. var startRow,
  13551. endRow,
  13552. startY,
  13553. startOffset,
  13554. currentRow,
  13555. currentTH,
  13556. handle = document.createElement('DIV'),
  13557. guide = document.createElement('DIV'),
  13558. eventManager = eventManagerObject(this);
  13559. handle.className = 'manualRowMover';
  13560. guide.className = 'manualRowMoverGuide';
  13561. var saveManualRowPositions = function() {
  13562. var instance = this;
  13563. Handsontable.hooks.run(instance, 'persistentStateSave', 'manualRowPositions', instance.manualRowPositions);
  13564. };
  13565. var loadManualRowPositions = function() {
  13566. var instance = this,
  13567. storedState = {};
  13568. Handsontable.hooks.run(instance, 'persistentStateLoad', 'manualRowPositions', storedState);
  13569. return storedState.value;
  13570. };
  13571. function setupHandlePosition(TH) {
  13572. var instance = this;
  13573. currentTH = TH;
  13574. var row = this.view.wt.wtTable.getCoords(TH).row;
  13575. if (row >= 0) {
  13576. currentRow = row;
  13577. var box = currentTH.getBoundingClientRect();
  13578. startOffset = box.top;
  13579. handle.style.top = startOffset + 'px';
  13580. handle.style.left = box.left + 'px';
  13581. instance.rootElement.appendChild(handle);
  13582. }
  13583. }
  13584. function refreshHandlePosition(TH, delta) {
  13585. var box = TH.getBoundingClientRect();
  13586. var handleHeight = 6;
  13587. if (delta > 0) {
  13588. handle.style.top = (box.top + box.height - handleHeight) + 'px';
  13589. } else {
  13590. handle.style.top = box.top + 'px';
  13591. }
  13592. }
  13593. function setupGuidePosition() {
  13594. var instance = this;
  13595. dom.addClass(handle, 'active');
  13596. dom.addClass(guide, 'active');
  13597. var box = currentTH.getBoundingClientRect();
  13598. guide.style.width = instance.view.maximumVisibleElementWidth(0) + 'px';
  13599. guide.style.height = box.height + 'px';
  13600. guide.style.top = startOffset + 'px';
  13601. guide.style.left = handle.style.left;
  13602. instance.rootElement.appendChild(guide);
  13603. }
  13604. function refreshGuidePosition(diff) {
  13605. guide.style.top = startOffset + diff + 'px';
  13606. }
  13607. function hideHandleAndGuide() {
  13608. dom.removeClass(handle, 'active');
  13609. dom.removeClass(guide, 'active');
  13610. }
  13611. var checkRowHeader = function(element) {
  13612. if (element.tagName != 'BODY') {
  13613. if (element.parentNode.tagName == 'TBODY') {
  13614. return true;
  13615. } else {
  13616. element = element.parentNode;
  13617. return checkRowHeader(element);
  13618. }
  13619. }
  13620. return false;
  13621. };
  13622. var getTHFromTargetElement = function(element) {
  13623. if (element.tagName != 'TABLE') {
  13624. if (element.tagName == 'TH') {
  13625. return element;
  13626. } else {
  13627. return getTHFromTargetElement(element.parentNode);
  13628. }
  13629. }
  13630. return null;
  13631. };
  13632. var bindEvents = function() {
  13633. var instance = this;
  13634. var pressed;
  13635. eventManager.addEventListener(instance.rootElement, 'mouseover', function(e) {
  13636. if (checkRowHeader(e.target)) {
  13637. var th = getTHFromTargetElement(e.target);
  13638. if (th) {
  13639. if (pressed) {
  13640. endRow = instance.view.wt.wtTable.getCoords(th).row;
  13641. refreshHandlePosition(th, endRow - startRow);
  13642. } else {
  13643. setupHandlePosition.call(instance, th);
  13644. }
  13645. }
  13646. }
  13647. });
  13648. eventManager.addEventListener(instance.rootElement, 'mousedown', function(e) {
  13649. if (dom.hasClass(e.target, 'manualRowMover')) {
  13650. startY = helper.pageY(e);
  13651. setupGuidePosition.call(instance);
  13652. pressed = instance;
  13653. startRow = currentRow;
  13654. endRow = currentRow;
  13655. }
  13656. });
  13657. eventManager.addEventListener(window, 'mousemove', function(e) {
  13658. if (pressed) {
  13659. refreshGuidePosition(helper.pageY(e) - startY);
  13660. }
  13661. });
  13662. eventManager.addEventListener(window, 'mouseup', function(e) {
  13663. if (pressed) {
  13664. hideHandleAndGuide();
  13665. pressed = false;
  13666. createPositionData(instance.manualRowPositions, instance.countRows());
  13667. instance.manualRowPositions.splice(endRow, 0, instance.manualRowPositions.splice(startRow, 1)[0]);
  13668. instance.forceFullRender = true;
  13669. instance.view.render();
  13670. saveManualRowPositions.call(instance);
  13671. Handsontable.hooks.run(instance, 'afterRowMove', startRow, endRow);
  13672. setupHandlePosition.call(instance, currentTH);
  13673. }
  13674. });
  13675. instance.addHook('afterDestroy', unbindEvents);
  13676. };
  13677. var unbindEvents = function() {
  13678. eventManager.clear();
  13679. };
  13680. var createPositionData = function(positionArr, len) {
  13681. if (positionArr.length < len) {
  13682. for (var i = positionArr.length; i < len; i++) {
  13683. positionArr[i] = i;
  13684. }
  13685. }
  13686. };
  13687. this.beforeInit = function() {
  13688. this.manualRowPositions = [];
  13689. };
  13690. this.init = function(source) {
  13691. var instance = this;
  13692. var manualRowMoveEnabled = !!(instance.getSettings().manualRowMove);
  13693. if (manualRowMoveEnabled) {
  13694. var initialManualRowPositions = instance.getSettings().manualRowMove;
  13695. var loadedManualRowPostions = loadManualRowPositions.call(instance);
  13696. if (typeof instance.manualRowPositionsPluginUsages != 'undefined') {
  13697. instance.manualRowPositionsPluginUsages.push('manualColumnMove');
  13698. } else {
  13699. instance.manualRowPositionsPluginUsages = ['manualColumnMove'];
  13700. }
  13701. if (typeof loadedManualRowPostions != 'undefined') {
  13702. this.manualRowPositions = loadedManualRowPostions;
  13703. } else if (Array.isArray(initialManualRowPositions)) {
  13704. this.manualRowPositions = initialManualRowPositions;
  13705. } else {
  13706. this.manualRowPositions = [];
  13707. }
  13708. if (source === 'afterInit') {
  13709. bindEvents.call(this);
  13710. if (this.manualRowPositions.length > 0) {
  13711. instance.forceFullRender = true;
  13712. instance.render();
  13713. }
  13714. }
  13715. } else {
  13716. var pluginUsagesIndex = instance.manualRowPositionsPluginUsages ? instance.manualRowPositionsPluginUsages.indexOf('manualColumnMove') : -1;
  13717. if (pluginUsagesIndex > -1) {
  13718. unbindEvents.call(this);
  13719. instance.manualRowPositions = [];
  13720. instance.manualRowPositionsPluginUsages[pluginUsagesIndex] = void 0;
  13721. }
  13722. }
  13723. };
  13724. this.modifyRow = function(row) {
  13725. var instance = this;
  13726. if (instance.getSettings().manualRowMove) {
  13727. if (typeof instance.manualRowPositions[row] === 'undefined') {
  13728. createPositionData(this.manualRowPositions, row + 1);
  13729. }
  13730. return instance.manualRowPositions[row];
  13731. }
  13732. return row;
  13733. };
  13734. }
  13735. var htManualRowMove = new ManualRowMove();
  13736. Handsontable.hooks.add('beforeInit', htManualRowMove.beforeInit);
  13737. Handsontable.hooks.add('afterInit', function() {
  13738. htManualRowMove.init.call(this, 'afterInit');
  13739. });
  13740. Handsontable.hooks.add('afterUpdateSettings', function() {
  13741. htManualRowMove.init.call(this, 'afterUpdateSettings');
  13742. });
  13743. Handsontable.hooks.add('modifyRow', htManualRowMove.modifyRow);
  13744. Handsontable.hooks.register('afterRowMove');
  13745. //#
  13746. },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../helpers.js":42,"./../../plugins.js":45}],62:[function(require,module,exports){
  13747. "use strict";
  13748. Object.defineProperties(exports, {
  13749. ManualRowResize: {get: function() {
  13750. return ManualRowResize;
  13751. }},
  13752. __esModule: {value: true}
  13753. });
  13754. var $___46__46__47__46__46__47_helpers_46_js__,
  13755. $___46__46__47__46__46__47_dom_46_js__,
  13756. $___46__46__47__46__46__47_eventManager_46_js__,
  13757. $___46__46__47__46__46__47_plugins_46_js__;
  13758. 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__});
  13759. 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__});
  13760. 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;
  13761. 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;
  13762. ;
  13763. function ManualRowResize() {
  13764. var currentTH,
  13765. currentRow,
  13766. currentHeight,
  13767. instance,
  13768. newSize,
  13769. startY,
  13770. startHeight,
  13771. startOffset,
  13772. handle = document.createElement('DIV'),
  13773. guide = document.createElement('DIV'),
  13774. eventManager = eventManagerObject(this);
  13775. handle.className = 'manualRowResizer';
  13776. guide.className = 'manualRowResizerGuide';
  13777. var saveManualRowHeights = function() {
  13778. var instance = this;
  13779. Handsontable.hooks.run(instance, 'persistentStateSave', 'manualRowHeights', instance.manualRowHeights);
  13780. };
  13781. var loadManualRowHeights = function() {
  13782. var instance = this,
  13783. storedState = {};
  13784. Handsontable.hooks.run(instance, 'persistentStateLoad', 'manualRowHeights', storedState);
  13785. return storedState.value;
  13786. };
  13787. function setupHandlePosition(TH) {
  13788. instance = this;
  13789. currentTH = TH;
  13790. var row = this.view.wt.wtTable.getCoords(TH).row;
  13791. if (row >= 0) {
  13792. currentRow = row;
  13793. var box = currentTH.getBoundingClientRect();
  13794. startOffset = box.top - 6;
  13795. startHeight = parseInt(box.height, 10);
  13796. handle.style.left = box.left + 'px';
  13797. handle.style.top = startOffset + startHeight + 'px';
  13798. instance.rootElement.appendChild(handle);
  13799. }
  13800. }
  13801. function refreshHandlePosition() {
  13802. handle.style.top = startOffset + currentHeight + 'px';
  13803. }
  13804. function setupGuidePosition() {
  13805. var instance = this;
  13806. dom.addClass(handle, 'active');
  13807. dom.addClass(guide, 'active');
  13808. guide.style.top = handle.style.top;
  13809. guide.style.left = handle.style.left;
  13810. guide.style.width = instance.view.maximumVisibleElementWidth(0) + 'px';
  13811. instance.rootElement.appendChild(guide);
  13812. }
  13813. function refreshGuidePosition() {
  13814. guide.style.top = handle.style.top;
  13815. }
  13816. function hideHandleAndGuide() {
  13817. dom.removeClass(handle, 'active');
  13818. dom.removeClass(guide, 'active');
  13819. }
  13820. var checkRowHeader = function(element) {
  13821. if (element.tagName != 'BODY') {
  13822. if (element.parentNode.tagName == 'TBODY') {
  13823. return true;
  13824. } else {
  13825. element = element.parentNode;
  13826. return checkRowHeader(element);
  13827. }
  13828. }
  13829. return false;
  13830. };
  13831. var getTHFromTargetElement = function(element) {
  13832. if (element.tagName != 'TABLE') {
  13833. if (element.tagName == 'TH') {
  13834. return element;
  13835. } else {
  13836. return getTHFromTargetElement(element.parentNode);
  13837. }
  13838. }
  13839. return null;
  13840. };
  13841. var bindEvents = function() {
  13842. var instance = this;
  13843. var pressed;
  13844. var dblclick = 0;
  13845. var autoresizeTimeout = null;
  13846. eventManager.addEventListener(instance.rootElement, 'mouseover', function(e) {
  13847. if (checkRowHeader(e.target)) {
  13848. var th = getTHFromTargetElement(e.target);
  13849. if (th) {
  13850. if (!pressed) {
  13851. setupHandlePosition.call(instance, th);
  13852. }
  13853. }
  13854. }
  13855. });
  13856. eventManager.addEventListener(instance.rootElement, 'mousedown', function(e) {
  13857. if (dom.hasClass(e.target, 'manualRowResizer')) {
  13858. setupGuidePosition.call(instance);
  13859. pressed = instance;
  13860. if (autoresizeTimeout == null) {
  13861. autoresizeTimeout = setTimeout(function() {
  13862. if (dblclick >= 2) {
  13863. setManualSize(currentRow, null);
  13864. instance.forceFullRender = true;
  13865. instance.view.render();
  13866. Handsontable.hooks.run(instance, 'afterRowResize', currentRow, newSize);
  13867. }
  13868. dblclick = 0;
  13869. autoresizeTimeout = null;
  13870. }, 500);
  13871. instance._registerTimeout(autoresizeTimeout);
  13872. }
  13873. dblclick++;
  13874. startY = helper.pageY(e);
  13875. newSize = startHeight;
  13876. }
  13877. });
  13878. eventManager.addEventListener(window, 'mousemove', function(e) {
  13879. if (pressed) {
  13880. currentHeight = startHeight + (helper.pageY(e) - startY);
  13881. newSize = setManualSize(currentRow, currentHeight);
  13882. refreshHandlePosition();
  13883. refreshGuidePosition();
  13884. }
  13885. });
  13886. eventManager.addEventListener(window, 'mouseup', function(e) {
  13887. if (pressed) {
  13888. hideHandleAndGuide();
  13889. pressed = false;
  13890. if (newSize != startHeight) {
  13891. instance.forceFullRender = true;
  13892. instance.view.render();
  13893. saveManualRowHeights.call(instance);
  13894. Handsontable.hooks.run(instance, 'afterRowResize', currentRow, newSize);
  13895. }
  13896. setupHandlePosition.call(instance, currentTH);
  13897. }
  13898. });
  13899. instance.addHook('afterDestroy', unbindEvents);
  13900. };
  13901. var unbindEvents = function() {
  13902. eventManager.clear();
  13903. };
  13904. this.beforeInit = function() {
  13905. this.manualRowHeights = [];
  13906. };
  13907. this.init = function(source) {
  13908. var instance = this;
  13909. var manualColumnHeightEnabled = !!(this.getSettings().manualRowResize);
  13910. if (manualColumnHeightEnabled) {
  13911. var initialRowHeights = this.getSettings().manualRowResize;
  13912. var loadedManualRowHeights = loadManualRowHeights.call(instance);
  13913. if (typeof instance.manualRowHeightsPluginUsages != 'undefined') {
  13914. instance.manualRowHeightsPluginUsages.push('manualRowResize');
  13915. } else {
  13916. instance.manualRowHeightsPluginUsages = ['manualRowResize'];
  13917. }
  13918. if (typeof loadedManualRowHeights != 'undefined') {
  13919. this.manualRowHeights = loadedManualRowHeights;
  13920. } else if (Array.isArray(initialRowHeights)) {
  13921. this.manualRowHeights = initialRowHeights;
  13922. } else {
  13923. this.manualRowHeights = [];
  13924. }
  13925. if (source === 'afterInit') {
  13926. bindEvents.call(this);
  13927. if (this.manualRowHeights.length > 0) {
  13928. this.forceFullRender = true;
  13929. this.render();
  13930. }
  13931. } else {
  13932. this.forceFullRender = true;
  13933. this.render();
  13934. }
  13935. } else {
  13936. var pluginUsagesIndex = instance.manualRowHeightsPluginUsages ? instance.manualRowHeightsPluginUsages.indexOf('manualRowResize') : -1;
  13937. if (pluginUsagesIndex > -1) {
  13938. unbindEvents.call(this);
  13939. this.manualRowHeights = [];
  13940. instance.manualRowHeightsPluginUsages[pluginUsagesIndex] = void 0;
  13941. }
  13942. }
  13943. };
  13944. var setManualSize = function(row, height) {
  13945. row = Handsontable.hooks.run(instance, 'modifyRow', row);
  13946. instance.manualRowHeights[row] = height;
  13947. return height;
  13948. };
  13949. this.modifyRowHeight = function(height, row) {
  13950. if (this.getSettings().manualRowResize) {
  13951. row = this.runHooks('modifyRow', row);
  13952. if (this.manualRowHeights[row] !== void 0) {
  13953. return this.manualRowHeights[row];
  13954. }
  13955. }
  13956. return height;
  13957. };
  13958. }
  13959. var htManualRowResize = new ManualRowResize();
  13960. Handsontable.hooks.add('beforeInit', htManualRowResize.beforeInit);
  13961. Handsontable.hooks.add('afterInit', function() {
  13962. htManualRowResize.init.call(this, 'afterInit');
  13963. });
  13964. Handsontable.hooks.add('afterUpdateSettings', function() {
  13965. htManualRowResize.init.call(this, 'afterUpdateSettings');
  13966. });
  13967. Handsontable.hooks.add('modifyRowHeight', htManualRowResize.modifyRowHeight);
  13968. Handsontable.hooks.register('afterRowResize');
  13969. //#
  13970. },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../helpers.js":42,"./../../plugins.js":45}],63:[function(require,module,exports){
  13971. "use strict";
  13972. Object.defineProperties(exports, {
  13973. MergeCells: {get: function() {
  13974. return MergeCells;
  13975. }},
  13976. __esModule: {value: true}
  13977. });
  13978. var $___46__46__47__46__46__47_plugins_46_js__,
  13979. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
  13980. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_range_46_js__,
  13981. $___46__46__47__46__46__47_3rdparty_47_walkontable_47_src_47_table_46_js__;
  13982. 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;
  13983. 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;
  13984. 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;
  13985. 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;
  13986. ;
  13987. function CellInfoCollection() {
  13988. var collection = [];
  13989. collection.getInfo = function(row, col) {
  13990. for (var i = 0,
  13991. ilen = this.length; i < ilen; i++) {
  13992. 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) {
  13993. return this[i];
  13994. }
  13995. }
  13996. };
  13997. collection.setInfo = function(info) {
  13998. for (var i = 0,
  13999. ilen = this.length; i < ilen; i++) {
  14000. if (this[i].row === info.row && this[i].col === info.col) {
  14001. this[i] = info;
  14002. return;
  14003. }
  14004. }
  14005. this.push(info);
  14006. };
  14007. collection.removeInfo = function(row, col) {
  14008. for (var i = 0,
  14009. ilen = this.length; i < ilen; i++) {
  14010. if (this[i].row === row && this[i].col === col) {
  14011. this.splice(i, 1);
  14012. break;
  14013. }
  14014. }
  14015. };
  14016. return collection;
  14017. }
  14018. function MergeCells(mergeCellsSetting) {
  14019. this.mergedCellInfoCollection = new CellInfoCollection();
  14020. if (Array.isArray(mergeCellsSetting)) {
  14021. for (var i = 0,
  14022. ilen = mergeCellsSetting.length; i < ilen; i++) {
  14023. this.mergedCellInfoCollection.setInfo(mergeCellsSetting[i]);
  14024. }
  14025. }
  14026. }
  14027. MergeCells.prototype.canMergeRange = function(cellRange) {
  14028. return !cellRange.isSingle();
  14029. };
  14030. MergeCells.prototype.mergeRange = function(cellRange) {
  14031. if (!this.canMergeRange(cellRange)) {
  14032. return;
  14033. }
  14034. var topLeft = cellRange.getTopLeftCorner();
  14035. var bottomRight = cellRange.getBottomRightCorner();
  14036. var mergeParent = {};
  14037. mergeParent.row = topLeft.row;
  14038. mergeParent.col = topLeft.col;
  14039. mergeParent.rowspan = bottomRight.row - topLeft.row + 1;
  14040. mergeParent.colspan = bottomRight.col - topLeft.col + 1;
  14041. this.mergedCellInfoCollection.setInfo(mergeParent);
  14042. };
  14043. MergeCells.prototype.mergeOrUnmergeSelection = function(cellRange) {
  14044. var info = this.mergedCellInfoCollection.getInfo(cellRange.from.row, cellRange.from.col);
  14045. if (info) {
  14046. this.unmergeSelection(cellRange.from);
  14047. } else {
  14048. this.mergeSelection(cellRange);
  14049. }
  14050. };
  14051. MergeCells.prototype.mergeSelection = function(cellRange) {
  14052. this.mergeRange(cellRange);
  14053. };
  14054. MergeCells.prototype.unmergeSelection = function(cellRange) {
  14055. var info = this.mergedCellInfoCollection.getInfo(cellRange.row, cellRange.col);
  14056. this.mergedCellInfoCollection.removeInfo(info.row, info.col);
  14057. };
  14058. MergeCells.prototype.applySpanProperties = function(TD, row, col) {
  14059. var info = this.mergedCellInfoCollection.getInfo(row, col);
  14060. if (info) {
  14061. if (info.row === row && info.col === col) {
  14062. TD.setAttribute('rowspan', info.rowspan);
  14063. TD.setAttribute('colspan', info.colspan);
  14064. } else {
  14065. TD.removeAttribute('rowspan');
  14066. TD.removeAttribute('colspan');
  14067. TD.style.display = "none";
  14068. }
  14069. } else {
  14070. TD.removeAttribute('rowspan');
  14071. TD.removeAttribute('colspan');
  14072. }
  14073. };
  14074. MergeCells.prototype.modifyTransform = function(hook, currentSelectedRange, delta) {
  14075. var sameRowspan = function(merged, coords) {
  14076. if (coords.row >= merged.row && coords.row <= (merged.row + merged.rowspan - 1)) {
  14077. return true;
  14078. }
  14079. return false;
  14080. },
  14081. sameColspan = function(merged, coords) {
  14082. if (coords.col >= merged.col && coords.col <= (merged.col + merged.colspan - 1)) {
  14083. return true;
  14084. }
  14085. return false;
  14086. },
  14087. getNextPosition = function(newDelta) {
  14088. return new WalkontableCellCoords(currentSelectedRange.to.row + newDelta.row, currentSelectedRange.to.col + newDelta.col);
  14089. };
  14090. var newDelta = {
  14091. row: delta.row,
  14092. col: delta.col
  14093. };
  14094. if (hook == 'modifyTransformStart') {
  14095. if (!this.lastDesiredCoords) {
  14096. this.lastDesiredCoords = new WalkontableCellCoords(null, null);
  14097. }
  14098. var currentPosition = new WalkontableCellCoords(currentSelectedRange.highlight.row, currentSelectedRange.highlight.col),
  14099. mergedParent = this.mergedCellInfoCollection.getInfo(currentPosition.row, currentPosition.col),
  14100. currentRangeContainsMerge;
  14101. for (var i = 0,
  14102. mergesLength = this.mergedCellInfoCollection.length; i < mergesLength; i++) {
  14103. var range = this.mergedCellInfoCollection[i];
  14104. range = new WalkontableCellCoords(range.row + range.rowspan - 1, range.col + range.colspan - 1);
  14105. if (currentSelectedRange.includes(range)) {
  14106. currentRangeContainsMerge = true;
  14107. break;
  14108. }
  14109. }
  14110. if (mergedParent) {
  14111. var mergeTopLeft = new WalkontableCellCoords(mergedParent.row, mergedParent.col),
  14112. mergeBottomRight = new WalkontableCellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1),
  14113. mergeRange = new WalkontableCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
  14114. if (!mergeRange.includes(this.lastDesiredCoords)) {
  14115. this.lastDesiredCoords = new WalkontableCellCoords(null, null);
  14116. }
  14117. newDelta.row = this.lastDesiredCoords.row ? this.lastDesiredCoords.row - currentPosition.row : newDelta.row;
  14118. newDelta.col = this.lastDesiredCoords.col ? this.lastDesiredCoords.col - currentPosition.col : newDelta.col;
  14119. if (delta.row > 0) {
  14120. newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
  14121. } else if (delta.row < 0) {
  14122. newDelta.row = currentPosition.row - mergedParent.row + delta.row;
  14123. }
  14124. if (delta.col > 0) {
  14125. newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
  14126. } else if (delta.col < 0) {
  14127. newDelta.col = currentPosition.col - mergedParent.col + delta.col;
  14128. }
  14129. }
  14130. var nextPosition = new WalkontableCellCoords(currentSelectedRange.highlight.row + newDelta.row, currentSelectedRange.highlight.col + newDelta.col),
  14131. nextParentIsMerged = this.mergedCellInfoCollection.getInfo(nextPosition.row, nextPosition.col);
  14132. if (nextParentIsMerged) {
  14133. this.lastDesiredCoords = nextPosition;
  14134. newDelta = {
  14135. row: nextParentIsMerged.row - currentPosition.row,
  14136. col: nextParentIsMerged.col - currentPosition.col
  14137. };
  14138. }
  14139. } else if (hook == 'modifyTransformEnd') {
  14140. for (var i = 0,
  14141. mergesLength = this.mergedCellInfoCollection.length; i < mergesLength; i++) {
  14142. var currentMerge = this.mergedCellInfoCollection[i],
  14143. mergeTopLeft = new WalkontableCellCoords(currentMerge.row, currentMerge.col),
  14144. mergeBottomRight = new WalkontableCellCoords(currentMerge.row + currentMerge.rowspan - 1, currentMerge.col + currentMerge.colspan - 1),
  14145. mergedRange = new WalkontableCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight),
  14146. sharedBorders = currentSelectedRange.getBordersSharedWith(mergedRange);
  14147. if (mergedRange.isEqual(currentSelectedRange)) {
  14148. currentSelectedRange.setDirection("NW-SE");
  14149. } else if (sharedBorders.length > 0) {
  14150. var mergeHighlighted = (currentSelectedRange.highlight.isEqual(mergedRange.from));
  14151. if (sharedBorders.indexOf('top') > -1) {
  14152. if (currentSelectedRange.to.isSouthEastOf(mergedRange.from) && mergeHighlighted) {
  14153. currentSelectedRange.setDirection("NW-SE");
  14154. } else if (currentSelectedRange.to.isSouthWestOf(mergedRange.from) && mergeHighlighted) {
  14155. currentSelectedRange.setDirection("NE-SW");
  14156. }
  14157. } else if (sharedBorders.indexOf('bottom') > -1) {
  14158. if (currentSelectedRange.to.isNorthEastOf(mergedRange.from) && mergeHighlighted) {
  14159. currentSelectedRange.setDirection("SW-NE");
  14160. } else if (currentSelectedRange.to.isNorthWestOf(mergedRange.from) && mergeHighlighted) {
  14161. currentSelectedRange.setDirection("SE-NW");
  14162. }
  14163. }
  14164. }
  14165. var nextPosition = getNextPosition(newDelta),
  14166. withinRowspan = sameRowspan(currentMerge, nextPosition),
  14167. withinColspan = sameColspan(currentMerge, nextPosition);
  14168. if (currentSelectedRange.includesRange(mergedRange) && (mergedRange.includes(nextPosition) || withinRowspan || withinColspan)) {
  14169. if (withinRowspan) {
  14170. if (newDelta.row < 0) {
  14171. newDelta.row -= currentMerge.rowspan - 1;
  14172. } else if (newDelta.row > 0) {
  14173. newDelta.row += currentMerge.rowspan - 1;
  14174. }
  14175. }
  14176. if (withinColspan) {
  14177. if (newDelta.col < 0) {
  14178. newDelta.col -= currentMerge.colspan - 1;
  14179. } else if (newDelta.col > 0) {
  14180. newDelta.col += currentMerge.colspan - 1;
  14181. }
  14182. }
  14183. }
  14184. }
  14185. }
  14186. if (newDelta.row !== 0) {
  14187. delta.row = newDelta.row;
  14188. }
  14189. if (newDelta.col !== 0) {
  14190. delta.col = newDelta.col;
  14191. }
  14192. };
  14193. var beforeInit = function() {
  14194. var instance = this;
  14195. var mergeCellsSetting = instance.getSettings().mergeCells;
  14196. if (mergeCellsSetting) {
  14197. if (!instance.mergeCells) {
  14198. instance.mergeCells = new MergeCells(mergeCellsSetting);
  14199. }
  14200. }
  14201. };
  14202. var afterInit = function() {
  14203. var instance = this;
  14204. if (instance.mergeCells) {
  14205. instance.view.wt.wtTable.getCell = function(coords) {
  14206. if (instance.getSettings().mergeCells) {
  14207. var mergeParent = instance.mergeCells.mergedCellInfoCollection.getInfo(coords.row, coords.col);
  14208. if (mergeParent) {
  14209. coords = mergeParent;
  14210. }
  14211. }
  14212. return WalkontableTable.prototype.getCell.call(this, coords);
  14213. };
  14214. }
  14215. };
  14216. var onBeforeKeyDown = function(event) {
  14217. if (!this.mergeCells) {
  14218. return;
  14219. }
  14220. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  14221. if (ctrlDown) {
  14222. if (event.keyCode === 77) {
  14223. this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange());
  14224. this.render();
  14225. event.stopImmediatePropagation();
  14226. }
  14227. }
  14228. };
  14229. var addMergeActionsToContextMenu = function(defaultOptions) {
  14230. if (!this.getSettings().mergeCells) {
  14231. return;
  14232. }
  14233. defaultOptions.items.push(Handsontable.ContextMenu.SEPARATOR);
  14234. defaultOptions.items.push({
  14235. key: 'mergeCells',
  14236. name: function() {
  14237. var sel = this.getSelected();
  14238. var info = this.mergeCells.mergedCellInfoCollection.getInfo(sel[0], sel[1]);
  14239. if (info) {
  14240. return 'Unmerge cells';
  14241. } else {
  14242. return 'Merge cells';
  14243. }
  14244. },
  14245. callback: function() {
  14246. this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange());
  14247. this.render();
  14248. },
  14249. disabled: function() {
  14250. return false;
  14251. }
  14252. });
  14253. };
  14254. var afterRenderer = function(TD, row, col, prop, value, cellProperties) {
  14255. if (this.mergeCells) {
  14256. this.mergeCells.applySpanProperties(TD, row, col);
  14257. }
  14258. };
  14259. var modifyTransformFactory = function(hook) {
  14260. return function(delta) {
  14261. var mergeCellsSetting = this.getSettings().mergeCells;
  14262. if (mergeCellsSetting) {
  14263. var currentSelectedRange = this.getSelectedRange();
  14264. this.mergeCells.modifyTransform(hook, currentSelectedRange, delta);
  14265. if (hook === "modifyTransformEnd") {
  14266. var totalRows = this.countRows();
  14267. var totalCols = this.countCols();
  14268. if (currentSelectedRange.from.row < 0) {
  14269. currentSelectedRange.from.row = 0;
  14270. } else if (currentSelectedRange.from.row > 0 && currentSelectedRange.from.row >= totalRows) {
  14271. currentSelectedRange.from.row = currentSelectedRange.from - 1;
  14272. }
  14273. if (currentSelectedRange.from.col < 0) {
  14274. currentSelectedRange.from.col = 0;
  14275. } else if (currentSelectedRange.from.col > 0 && currentSelectedRange.from.col >= totalCols) {
  14276. currentSelectedRange.from.col = totalCols - 1;
  14277. }
  14278. }
  14279. }
  14280. };
  14281. };
  14282. var beforeSetRangeEnd = function(coords) {
  14283. this.lastDesiredCoords = null;
  14284. var mergeCellsSetting = this.getSettings().mergeCells;
  14285. if (mergeCellsSetting) {
  14286. var selRange = this.getSelectedRange();
  14287. selRange.highlight = new WalkontableCellCoords(selRange.highlight.row, selRange.highlight.col);
  14288. selRange.to = coords;
  14289. var rangeExpanded = false;
  14290. do {
  14291. rangeExpanded = false;
  14292. for (var i = 0,
  14293. ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) {
  14294. var cellInfo = this.mergeCells.mergedCellInfoCollection[i];
  14295. var mergedCellTopLeft = new WalkontableCellCoords(cellInfo.row, cellInfo.col);
  14296. var mergedCellBottomRight = new WalkontableCellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1);
  14297. var mergedCellRange = new WalkontableCellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
  14298. if (selRange.expandByRange(mergedCellRange)) {
  14299. coords.row = selRange.to.row;
  14300. coords.col = selRange.to.col;
  14301. rangeExpanded = true;
  14302. }
  14303. }
  14304. } while (rangeExpanded);
  14305. }
  14306. };
  14307. var beforeDrawAreaBorders = function(corners, className) {
  14308. if (className && className == 'area') {
  14309. var mergeCellsSetting = this.getSettings().mergeCells;
  14310. if (mergeCellsSetting) {
  14311. var selRange = this.getSelectedRange();
  14312. var startRange = new WalkontableCellRange(selRange.from, selRange.from, selRange.from);
  14313. var stopRange = new WalkontableCellRange(selRange.to, selRange.to, selRange.to);
  14314. for (var i = 0,
  14315. ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) {
  14316. var cellInfo = this.mergeCells.mergedCellInfoCollection[i];
  14317. var mergedCellTopLeft = new WalkontableCellCoords(cellInfo.row, cellInfo.col);
  14318. var mergedCellBottomRight = new WalkontableCellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1);
  14319. var mergedCellRange = new WalkontableCellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
  14320. if (startRange.expandByRange(mergedCellRange)) {
  14321. corners[0] = startRange.from.row;
  14322. corners[1] = startRange.from.col;
  14323. }
  14324. if (stopRange.expandByRange(mergedCellRange)) {
  14325. corners[2] = stopRange.from.row;
  14326. corners[3] = stopRange.from.col;
  14327. }
  14328. }
  14329. }
  14330. }
  14331. };
  14332. var afterGetCellMeta = function(row, col, cellProperties) {
  14333. var mergeCellsSetting = this.getSettings().mergeCells;
  14334. if (mergeCellsSetting) {
  14335. var mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(row, col);
  14336. if (mergeParent && (mergeParent.row != row || mergeParent.col != col)) {
  14337. cellProperties.copyable = false;
  14338. }
  14339. }
  14340. };
  14341. var afterViewportRowCalculatorOverride = function(calc) {
  14342. var mergeCellsSetting = this.getSettings().mergeCells;
  14343. if (mergeCellsSetting) {
  14344. var colCount = this.countCols();
  14345. var mergeParent;
  14346. for (var c = 0; c < colCount; c++) {
  14347. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.startRow, c);
  14348. if (mergeParent) {
  14349. if (mergeParent.row < calc.startRow) {
  14350. calc.startRow = mergeParent.row;
  14351. return afterViewportRowCalculatorOverride.call(this, calc);
  14352. }
  14353. }
  14354. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.endRow, c);
  14355. if (mergeParent) {
  14356. var mergeEnd = mergeParent.row + mergeParent.rowspan - 1;
  14357. if (mergeEnd > calc.endRow) {
  14358. calc.endRow = mergeEnd;
  14359. return afterViewportRowCalculatorOverride.call(this, calc);
  14360. }
  14361. }
  14362. }
  14363. }
  14364. };
  14365. var afterViewportColumnCalculatorOverride = function(calc) {
  14366. var mergeCellsSetting = this.getSettings().mergeCells;
  14367. if (mergeCellsSetting) {
  14368. var rowCount = this.countRows();
  14369. var mergeParent;
  14370. for (var r = 0; r < rowCount; r++) {
  14371. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.startColumn);
  14372. if (mergeParent) {
  14373. if (mergeParent.col < calc.startColumn) {
  14374. calc.startColumn = mergeParent.col;
  14375. return afterViewportColumnCalculatorOverride.call(this, calc);
  14376. }
  14377. }
  14378. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.endColumn);
  14379. if (mergeParent) {
  14380. var mergeEnd = mergeParent.col + mergeParent.colspan - 1;
  14381. if (mergeEnd > calc.endColumn) {
  14382. calc.endColumn = mergeEnd;
  14383. return afterViewportColumnCalculatorOverride.call(this, calc);
  14384. }
  14385. }
  14386. }
  14387. }
  14388. };
  14389. var isMultipleSelection = function(isMultiple) {
  14390. if (isMultiple && this.mergeCells) {
  14391. var mergedCells = this.mergeCells.mergedCellInfoCollection,
  14392. selectionRange = this.getSelectedRange();
  14393. for (var group in mergedCells) {
  14394. 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) {
  14395. return false;
  14396. }
  14397. }
  14398. }
  14399. return isMultiple;
  14400. };
  14401. function afterAutofillApplyValues(select, drag) {
  14402. var mergeCellsSetting = this.getSettings().mergeCells;
  14403. if (!mergeCellsSetting || this.selection.isMultiple()) {
  14404. return;
  14405. }
  14406. var info = this.mergeCells.mergedCellInfoCollection.getInfo(select[0], select[1]);
  14407. if (info) {
  14408. select[0] = info.row;
  14409. select[1] = info.col;
  14410. select[2] = info.row + info.rowspan - 1;
  14411. select[3] = info.col + info.colspan - 1;
  14412. }
  14413. }
  14414. Handsontable.hooks.add('beforeInit', beforeInit);
  14415. Handsontable.hooks.add('afterInit', afterInit);
  14416. Handsontable.hooks.add('beforeKeyDown', onBeforeKeyDown);
  14417. Handsontable.hooks.add('modifyTransformStart', modifyTransformFactory('modifyTransformStart'));
  14418. Handsontable.hooks.add('modifyTransformEnd', modifyTransformFactory('modifyTransformEnd'));
  14419. Handsontable.hooks.add('beforeSetRangeEnd', beforeSetRangeEnd);
  14420. Handsontable.hooks.add('beforeDrawBorders', beforeDrawAreaBorders);
  14421. Handsontable.hooks.add('afterIsMultipleSelection', isMultipleSelection);
  14422. Handsontable.hooks.add('afterRenderer', afterRenderer);
  14423. Handsontable.hooks.add('afterContextMenuDefaultOptions', addMergeActionsToContextMenu);
  14424. Handsontable.hooks.add('afterGetCellMeta', afterGetCellMeta);
  14425. Handsontable.hooks.add('afterViewportRowCalculatorOverride', afterViewportRowCalculatorOverride);
  14426. Handsontable.hooks.add('afterViewportColumnCalculatorOverride', afterViewportColumnCalculatorOverride);
  14427. Handsontable.hooks.add('afterAutofillApplyValues', afterAutofillApplyValues);
  14428. Handsontable.MergeCells = MergeCells;
  14429. //#
  14430. },{"./../../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){
  14431. "use strict";
  14432. Object.defineProperties(exports, {
  14433. default: {get: function() {
  14434. return $__default;
  14435. }},
  14436. __esModule: {value: true}
  14437. });
  14438. var $___46__46__47__46__46__47_dom_46_js__,
  14439. $___46__46__47__95_base_46_js__,
  14440. $___46__46__47__46__46__47_eventManager_46_js__,
  14441. $___46__46__47__46__46__47_plugins_46_js__;
  14442. 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__});
  14443. 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;
  14444. 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;
  14445. 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;
  14446. var MultipleSelectionHandles = function MultipleSelectionHandles(hotInstance) {
  14447. var $__3 = this;
  14448. $traceurRuntime.superConstructor($MultipleSelectionHandles).call(this, hotInstance);
  14449. this.dragged = [];
  14450. this.eventManager = eventManagerObject(this.hot);
  14451. this.bindTouchEvents();
  14452. this.hot.addHook('afterInit', (function() {
  14453. return $__3.init();
  14454. }));
  14455. };
  14456. var $MultipleSelectionHandles = MultipleSelectionHandles;
  14457. ($traceurRuntime.createClass)(MultipleSelectionHandles, {
  14458. init: function() {
  14459. this.lastSetCell = null;
  14460. Handsontable.plugins.multipleSelectionHandles = new $MultipleSelectionHandles(this.hot);
  14461. },
  14462. bindTouchEvents: function() {
  14463. var _this = this;
  14464. function removeFromDragged(query) {
  14465. if (_this.dragged.length === 1) {
  14466. _this.dragged.splice(0, _this.dragged.length);
  14467. return true;
  14468. }
  14469. var entryPosition = _this.dragged.indexOf(query);
  14470. if (entryPosition == -1) {
  14471. return false;
  14472. } else if (entryPosition === 0) {
  14473. _this.dragged = _this.dragged.slice(0, 1);
  14474. } else if (entryPosition == 1) {
  14475. _this.dragged = _this.dragged.slice(-1);
  14476. }
  14477. }
  14478. this.eventManager.addEventListener(this.hot.rootElement, 'touchstart', function(event) {
  14479. var selectedRange;
  14480. if (dom.hasClass(event.target, "topLeftSelectionHandle-HitArea")) {
  14481. selectedRange = _this.hot.getSelectedRange();
  14482. _this.dragged.push("topLeft");
  14483. _this.touchStartRange = {
  14484. width: selectedRange.getWidth(),
  14485. height: selectedRange.getHeight(),
  14486. direction: selectedRange.getDirection()
  14487. };
  14488. event.preventDefault();
  14489. return false;
  14490. } else if (dom.hasClass(event.target, "bottomRightSelectionHandle-HitArea")) {
  14491. selectedRange = _this.hot.getSelectedRange();
  14492. _this.dragged.push("bottomRight");
  14493. _this.touchStartRange = {
  14494. width: selectedRange.getWidth(),
  14495. height: selectedRange.getHeight(),
  14496. direction: selectedRange.getDirection()
  14497. };
  14498. event.preventDefault();
  14499. return false;
  14500. }
  14501. });
  14502. this.eventManager.addEventListener(this.hot.rootElement, 'touchend', function(event) {
  14503. if (dom.hasClass(event.target, "topLeftSelectionHandle-HitArea")) {
  14504. removeFromDragged.call(_this, "topLeft");
  14505. _this.touchStartRange = void 0;
  14506. event.preventDefault();
  14507. return false;
  14508. } else if (dom.hasClass(event.target, "bottomRightSelectionHandle-HitArea")) {
  14509. removeFromDragged.call(_this, "bottomRight");
  14510. _this.touchStartRange = void 0;
  14511. event.preventDefault();
  14512. return false;
  14513. }
  14514. });
  14515. this.eventManager.addEventListener(this.hot.rootElement, 'touchmove', function(event) {
  14516. var scrollTop = dom.getWindowScrollTop(),
  14517. scrollLeft = dom.getWindowScrollLeft(),
  14518. endTarget,
  14519. targetCoords,
  14520. selectedRange,
  14521. rangeWidth,
  14522. rangeHeight,
  14523. rangeDirection,
  14524. newRangeCoords;
  14525. if (_this.dragged.length === 0) {
  14526. return;
  14527. }
  14528. endTarget = document.elementFromPoint(event.touches[0].screenX - scrollLeft, event.touches[0].screenY - scrollTop);
  14529. if (!endTarget || endTarget === _this.lastSetCell) {
  14530. return;
  14531. }
  14532. if (endTarget.nodeName == "TD" || endTarget.nodeName == "TH") {
  14533. targetCoords = _this.hot.getCoords(endTarget);
  14534. if (targetCoords.col == -1) {
  14535. targetCoords.col = 0;
  14536. }
  14537. selectedRange = _this.hot.getSelectedRange();
  14538. rangeWidth = selectedRange.getWidth();
  14539. rangeHeight = selectedRange.getHeight();
  14540. rangeDirection = selectedRange.getDirection();
  14541. if (rangeWidth == 1 && rangeHeight == 1) {
  14542. _this.hot.selection.setRangeEnd(targetCoords);
  14543. }
  14544. newRangeCoords = _this.getCurrentRangeCoords(selectedRange, targetCoords, _this.touchStartRange.direction, rangeDirection, _this.dragged[0]);
  14545. if (newRangeCoords.start !== null) {
  14546. _this.hot.selection.setRangeStart(newRangeCoords.start);
  14547. }
  14548. _this.hot.selection.setRangeEnd(newRangeCoords.end);
  14549. _this.lastSetCell = endTarget;
  14550. }
  14551. event.preventDefault();
  14552. });
  14553. },
  14554. getCurrentRangeCoords: function(selectedRange, currentTouch, touchStartDirection, currentDirection, draggedHandle) {
  14555. var topLeftCorner = selectedRange.getTopLeftCorner(),
  14556. bottomRightCorner = selectedRange.getBottomRightCorner(),
  14557. bottomLeftCorner = selectedRange.getBottomLeftCorner(),
  14558. topRightCorner = selectedRange.getTopRightCorner();
  14559. var newCoords = {
  14560. start: null,
  14561. end: null
  14562. };
  14563. switch (touchStartDirection) {
  14564. case "NE-SW":
  14565. switch (currentDirection) {
  14566. case "NE-SW":
  14567. case "NW-SE":
  14568. if (draggedHandle == "topLeft") {
  14569. newCoords = {
  14570. start: new WalkontableCellCoords(currentTouch.row, selectedRange.highlight.col),
  14571. end: new WalkontableCellCoords(bottomLeftCorner.row, currentTouch.col)
  14572. };
  14573. } else {
  14574. newCoords = {
  14575. start: new WalkontableCellCoords(selectedRange.highlight.row, currentTouch.col),
  14576. end: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col)
  14577. };
  14578. }
  14579. break;
  14580. case "SE-NW":
  14581. if (draggedHandle == "bottomRight") {
  14582. newCoords = {
  14583. start: new WalkontableCellCoords(bottomRightCorner.row, currentTouch.col),
  14584. end: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col)
  14585. };
  14586. }
  14587. break;
  14588. }
  14589. break;
  14590. case "NW-SE":
  14591. switch (currentDirection) {
  14592. case "NE-SW":
  14593. if (draggedHandle == "topLeft") {
  14594. newCoords = {
  14595. start: currentTouch,
  14596. end: bottomLeftCorner
  14597. };
  14598. } else {
  14599. newCoords.end = currentTouch;
  14600. }
  14601. break;
  14602. case "NW-SE":
  14603. if (draggedHandle == "topLeft") {
  14604. newCoords = {
  14605. start: currentTouch,
  14606. end: bottomRightCorner
  14607. };
  14608. } else {
  14609. newCoords.end = currentTouch;
  14610. }
  14611. break;
  14612. case "SE-NW":
  14613. if (draggedHandle == "topLeft") {
  14614. newCoords = {
  14615. start: currentTouch,
  14616. end: topLeftCorner
  14617. };
  14618. } else {
  14619. newCoords.end = currentTouch;
  14620. }
  14621. break;
  14622. case "SW-NE":
  14623. if (draggedHandle == "topLeft") {
  14624. newCoords = {
  14625. start: currentTouch,
  14626. end: topRightCorner
  14627. };
  14628. } else {
  14629. newCoords.end = currentTouch;
  14630. }
  14631. break;
  14632. }
  14633. break;
  14634. case "SW-NE":
  14635. switch (currentDirection) {
  14636. case "NW-SE":
  14637. if (draggedHandle == "bottomRight") {
  14638. newCoords = {
  14639. start: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col),
  14640. end: new WalkontableCellCoords(bottomLeftCorner.row, currentTouch.col)
  14641. };
  14642. } else {
  14643. newCoords = {
  14644. start: new WalkontableCellCoords(topLeftCorner.row, currentTouch.col),
  14645. end: new WalkontableCellCoords(currentTouch.row, bottomRightCorner.col)
  14646. };
  14647. }
  14648. break;
  14649. case "SW-NE":
  14650. if (draggedHandle == "topLeft") {
  14651. newCoords = {
  14652. start: new WalkontableCellCoords(selectedRange.highlight.row, currentTouch.col),
  14653. end: new WalkontableCellCoords(currentTouch.row, bottomRightCorner.col)
  14654. };
  14655. } else {
  14656. newCoords = {
  14657. start: new WalkontableCellCoords(currentTouch.row, topLeftCorner.col),
  14658. end: new WalkontableCellCoords(topLeftCorner.row, currentTouch.col)
  14659. };
  14660. }
  14661. break;
  14662. case "SE-NW":
  14663. if (draggedHandle == "bottomRight") {
  14664. newCoords = {
  14665. start: new WalkontableCellCoords(currentTouch.row, topRightCorner.col),
  14666. end: new WalkontableCellCoords(topLeftCorner.row, currentTouch.col)
  14667. };
  14668. } else if (draggedHandle == "topLeft") {
  14669. newCoords = {
  14670. start: bottomLeftCorner,
  14671. end: currentTouch
  14672. };
  14673. }
  14674. break;
  14675. }
  14676. break;
  14677. case "SE-NW":
  14678. switch (currentDirection) {
  14679. case "NW-SE":
  14680. case "NE-SW":
  14681. case "SW-NE":
  14682. if (draggedHandle == "topLeft") {
  14683. newCoords.end = currentTouch;
  14684. }
  14685. break;
  14686. case "SE-NW":
  14687. if (draggedHandle == "topLeft") {
  14688. newCoords.end = currentTouch;
  14689. } else {
  14690. newCoords = {
  14691. start: currentTouch,
  14692. end: topLeftCorner
  14693. };
  14694. }
  14695. break;
  14696. }
  14697. break;
  14698. }
  14699. return newCoords;
  14700. },
  14701. isDragged: function() {
  14702. return this.dragged.length > 0;
  14703. }
  14704. }, {}, BasePlugin);
  14705. var $__default = MultipleSelectionHandles;
  14706. registerPlugin('multipleSelectionHandles', MultipleSelectionHandles);
  14707. //#
  14708. },{"./../../dom.js":27,"./../../eventManager.js":41,"./../../plugins.js":45,"./../_base.js":46}],65:[function(require,module,exports){
  14709. "use strict";
  14710. Object.defineProperties(exports, {
  14711. ObserveChanges: {get: function() {
  14712. return ObserveChanges;
  14713. }},
  14714. __esModule: {value: true}
  14715. });
  14716. var $___46__46__47__46__46__47_plugins_46_js__,
  14717. $__jsonpatch__;
  14718. 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;
  14719. var jsonpatch = ($__jsonpatch__ = require("jsonpatch"), $__jsonpatch__ && $__jsonpatch__.__esModule && $__jsonpatch__ || {default: $__jsonpatch__}).default;
  14720. ;
  14721. function ObserveChanges() {}
  14722. Handsontable.hooks.add('afterLoadData', init);
  14723. Handsontable.hooks.add('afterUpdateSettings', init);
  14724. Handsontable.hooks.register('afterChangesObserved');
  14725. function init() {
  14726. var instance = this;
  14727. var pluginEnabled = instance.getSettings().observeChanges;
  14728. if (pluginEnabled) {
  14729. if (instance.observer) {
  14730. destroy.call(instance);
  14731. }
  14732. createObserver.call(instance);
  14733. bindEvents.call(instance);
  14734. } else if (!pluginEnabled) {
  14735. destroy.call(instance);
  14736. }
  14737. }
  14738. function createObserver() {
  14739. var instance = this;
  14740. instance.observeChangesActive = true;
  14741. instance.pauseObservingChanges = function() {
  14742. instance.observeChangesActive = false;
  14743. };
  14744. instance.resumeObservingChanges = function() {
  14745. instance.observeChangesActive = true;
  14746. };
  14747. instance.observedData = instance.getData();
  14748. instance.observer = jsonpatch.observe(instance.observedData, function(patches) {
  14749. if (instance.observeChangesActive) {
  14750. runHookForOperation.call(instance, patches);
  14751. instance.render();
  14752. }
  14753. instance.runHooks('afterChangesObserved');
  14754. });
  14755. }
  14756. function runHookForOperation(rawPatches) {
  14757. var instance = this;
  14758. var patches = cleanPatches(rawPatches);
  14759. for (var i = 0,
  14760. len = patches.length; i < len; i++) {
  14761. var patch = patches[i];
  14762. var parsedPath = parsePath(patch.path);
  14763. switch (patch.op) {
  14764. case 'add':
  14765. if (isNaN(parsedPath.col)) {
  14766. instance.runHooks('afterCreateRow', parsedPath.row);
  14767. } else {
  14768. instance.runHooks('afterCreateCol', parsedPath.col);
  14769. }
  14770. break;
  14771. case 'remove':
  14772. if (isNaN(parsedPath.col)) {
  14773. instance.runHooks('afterRemoveRow', parsedPath.row, 1);
  14774. } else {
  14775. instance.runHooks('afterRemoveCol', parsedPath.col, 1);
  14776. }
  14777. break;
  14778. case 'replace':
  14779. instance.runHooks('afterChange', [parsedPath.row, parsedPath.col, null, patch.value], 'external');
  14780. break;
  14781. }
  14782. }
  14783. function cleanPatches(rawPatches) {
  14784. var patches;
  14785. patches = removeLengthRelatedPatches(rawPatches);
  14786. patches = removeMultipleAddOrRemoveColPatches(patches);
  14787. return patches;
  14788. }
  14789. function removeMultipleAddOrRemoveColPatches(rawPatches) {
  14790. var newOrRemovedColumns = [];
  14791. return rawPatches.filter(function(patch) {
  14792. var parsedPath = parsePath(patch.path);
  14793. if (['add', 'remove'].indexOf(patch.op) != -1 && !isNaN(parsedPath.col)) {
  14794. if (newOrRemovedColumns.indexOf(parsedPath.col) != -1) {
  14795. return false;
  14796. } else {
  14797. newOrRemovedColumns.push(parsedPath.col);
  14798. }
  14799. }
  14800. return true;
  14801. });
  14802. }
  14803. function removeLengthRelatedPatches(rawPatches) {
  14804. return rawPatches.filter(function(patch) {
  14805. return !/[/]length/ig.test(patch.path);
  14806. });
  14807. }
  14808. function parsePath(path) {
  14809. var match = path.match(/^\/(\d+)\/?(.*)?$/);
  14810. return {
  14811. row: parseInt(match[1], 10),
  14812. col: /^\d*$/.test(match[2]) ? parseInt(match[2], 10) : match[2]
  14813. };
  14814. }
  14815. }
  14816. function destroy() {
  14817. var instance = this;
  14818. if (instance.observer) {
  14819. destroyObserver.call(instance);
  14820. unbindEvents.call(instance);
  14821. }
  14822. }
  14823. function destroyObserver() {
  14824. var instance = this;
  14825. jsonpatch.unobserve(instance.observedData, instance.observer);
  14826. delete instance.observeChangesActive;
  14827. delete instance.pauseObservingChanges;
  14828. delete instance.resumeObservingChanges;
  14829. }
  14830. function bindEvents() {
  14831. var instance = this;
  14832. instance.addHook('afterDestroy', destroy);
  14833. instance.addHook('afterCreateRow', afterTableAlter);
  14834. instance.addHook('afterRemoveRow', afterTableAlter);
  14835. instance.addHook('afterCreateCol', afterTableAlter);
  14836. instance.addHook('afterRemoveCol', afterTableAlter);
  14837. instance.addHook('afterChange', function(changes, source) {
  14838. if (source != 'loadData') {
  14839. afterTableAlter.call(this);
  14840. }
  14841. });
  14842. }
  14843. function unbindEvents() {
  14844. var instance = this;
  14845. instance.removeHook('afterDestroy', destroy);
  14846. instance.removeHook('afterCreateRow', afterTableAlter);
  14847. instance.removeHook('afterRemoveRow', afterTableAlter);
  14848. instance.removeHook('afterCreateCol', afterTableAlter);
  14849. instance.removeHook('afterRemoveCol', afterTableAlter);
  14850. instance.removeHook('afterChange', afterTableAlter);
  14851. }
  14852. function afterTableAlter() {
  14853. var instance = this;
  14854. instance.pauseObservingChanges();
  14855. instance.addHookOnce('afterChangesObserved', function() {
  14856. instance.resumeObservingChanges();
  14857. });
  14858. }
  14859. //#
  14860. },{"./../../plugins.js":45,"jsonpatch":"jsonpatch"}],66:[function(require,module,exports){
  14861. "use strict";
  14862. Object.defineProperties(exports, {
  14863. HandsontablePersistentState: {get: function() {
  14864. return HandsontablePersistentState;
  14865. }},
  14866. __esModule: {value: true}
  14867. });
  14868. var $___46__46__47__46__46__47_plugins_46_js__;
  14869. 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;
  14870. ;
  14871. function Storage(prefix) {
  14872. var savedKeys;
  14873. var saveSavedKeys = function() {
  14874. window.localStorage[prefix + '__' + 'persistentStateKeys'] = JSON.stringify(savedKeys);
  14875. };
  14876. var loadSavedKeys = function() {
  14877. var keysJSON = window.localStorage[prefix + '__' + 'persistentStateKeys'];
  14878. var keys = typeof keysJSON == 'string' ? JSON.parse(keysJSON) : void 0;
  14879. savedKeys = keys ? keys : [];
  14880. };
  14881. var clearSavedKeys = function() {
  14882. savedKeys = [];
  14883. saveSavedKeys();
  14884. };
  14885. loadSavedKeys();
  14886. this.saveValue = function(key, value) {
  14887. window.localStorage[prefix + '_' + key] = JSON.stringify(value);
  14888. if (savedKeys.indexOf(key) == -1) {
  14889. savedKeys.push(key);
  14890. saveSavedKeys();
  14891. }
  14892. };
  14893. this.loadValue = function(key, defaultValue) {
  14894. key = typeof key != 'undefined' ? key : defaultValue;
  14895. var value = window.localStorage[prefix + '_' + key];
  14896. return typeof value == "undefined" ? void 0 : JSON.parse(value);
  14897. };
  14898. this.reset = function(key) {
  14899. window.localStorage.removeItem(prefix + '_' + key);
  14900. };
  14901. this.resetAll = function() {
  14902. for (var index = 0; index < savedKeys.length; index++) {
  14903. window.localStorage.removeItem(prefix + '_' + savedKeys[index]);
  14904. }
  14905. clearSavedKeys();
  14906. };
  14907. }
  14908. function HandsontablePersistentState() {
  14909. var plugin = this;
  14910. this.init = function() {
  14911. var instance = this,
  14912. pluginSettings = instance.getSettings().persistentState;
  14913. plugin.enabled = !!(pluginSettings);
  14914. if (!plugin.enabled) {
  14915. removeHooks.call(instance);
  14916. return;
  14917. }
  14918. if (!instance.storage) {
  14919. instance.storage = new Storage(instance.rootElement.id);
  14920. }
  14921. instance.resetState = plugin.resetValue;
  14922. addHooks.call(instance);
  14923. };
  14924. this.saveValue = function(key, value) {
  14925. var instance = this;
  14926. instance.storage.saveValue(key, value);
  14927. };
  14928. this.loadValue = function(key, saveTo) {
  14929. var instance = this;
  14930. saveTo.value = instance.storage.loadValue(key);
  14931. };
  14932. this.resetValue = function(key) {
  14933. var instance = this;
  14934. if (typeof key != 'undefined') {
  14935. instance.storage.reset(key);
  14936. } else {
  14937. instance.storage.resetAll();
  14938. }
  14939. };
  14940. var hooks = {
  14941. 'persistentStateSave': plugin.saveValue,
  14942. 'persistentStateLoad': plugin.loadValue,
  14943. 'persistentStateReset': plugin.resetValue
  14944. };
  14945. for (var hookName in hooks) {
  14946. if (hooks.hasOwnProperty(hookName)) {
  14947. Handsontable.hooks.register(hookName);
  14948. }
  14949. }
  14950. function addHooks() {
  14951. var instance = this;
  14952. for (var hookName in hooks) {
  14953. if (hooks.hasOwnProperty(hookName)) {
  14954. instance.addHook(hookName, hooks[hookName]);
  14955. }
  14956. }
  14957. }
  14958. function removeHooks() {
  14959. var instance = this;
  14960. for (var hookName in hooks) {
  14961. if (hooks.hasOwnProperty(hookName)) {
  14962. instance.removeHook(hookName, hooks[hookName]);
  14963. }
  14964. }
  14965. }
  14966. }
  14967. var htPersistentState = new HandsontablePersistentState();
  14968. Handsontable.hooks.add('beforeInit', htPersistentState.init);
  14969. Handsontable.hooks.add('afterUpdateSettings', htPersistentState.init);
  14970. //#
  14971. },{"./../../plugins.js":45}],67:[function(require,module,exports){
  14972. "use strict";
  14973. var $___46__46__47__46__46__47_dom_46_js__,
  14974. $___46__46__47__46__46__47_renderers_46_js__;
  14975. 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__});
  14976. 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__}),
  14977. registerRenderer = $__0.registerRenderer,
  14978. getRenderer = $__0.getRenderer;
  14979. Handsontable.Search = function Search(instance) {
  14980. this.query = function(queryStr, callback, queryMethod) {
  14981. var rowCount = instance.countRows();
  14982. var colCount = instance.countCols();
  14983. var queryResult = [];
  14984. if (!callback) {
  14985. callback = Handsontable.Search.global.getDefaultCallback();
  14986. }
  14987. if (!queryMethod) {
  14988. queryMethod = Handsontable.Search.global.getDefaultQueryMethod();
  14989. }
  14990. for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) {
  14991. for (var colIndex = 0; colIndex < colCount; colIndex++) {
  14992. var cellData = instance.getDataAtCell(rowIndex, colIndex);
  14993. var cellProperties = instance.getCellMeta(rowIndex, colIndex);
  14994. var cellCallback = cellProperties.search.callback || callback;
  14995. var cellQueryMethod = cellProperties.search.queryMethod || queryMethod;
  14996. var testResult = cellQueryMethod(queryStr, cellData);
  14997. if (testResult) {
  14998. var singleResult = {
  14999. row: rowIndex,
  15000. col: colIndex,
  15001. data: cellData
  15002. };
  15003. queryResult.push(singleResult);
  15004. }
  15005. if (cellCallback) {
  15006. cellCallback(instance, rowIndex, colIndex, cellData, testResult);
  15007. }
  15008. }
  15009. }
  15010. return queryResult;
  15011. };
  15012. };
  15013. Handsontable.Search.DEFAULT_CALLBACK = function(instance, row, col, data, testResult) {
  15014. instance.getCellMeta(row, col).isSearchResult = testResult;
  15015. };
  15016. Handsontable.Search.DEFAULT_QUERY_METHOD = function(query, value) {
  15017. if (typeof query == 'undefined' || query == null || !query.toLowerCase || query.length === 0) {
  15018. return false;
  15019. }
  15020. if (typeof value == 'undefined' || value == null) {
  15021. return false;
  15022. }
  15023. return value.toString().toLowerCase().indexOf(query.toLowerCase()) != -1;
  15024. };
  15025. Handsontable.Search.DEFAULT_SEARCH_RESULT_CLASS = 'htSearchResult';
  15026. Handsontable.Search.global = (function() {
  15027. var defaultCallback = Handsontable.Search.DEFAULT_CALLBACK;
  15028. var defaultQueryMethod = Handsontable.Search.DEFAULT_QUERY_METHOD;
  15029. var defaultSearchResultClass = Handsontable.Search.DEFAULT_SEARCH_RESULT_CLASS;
  15030. return {
  15031. getDefaultCallback: function() {
  15032. return defaultCallback;
  15033. },
  15034. setDefaultCallback: function(newDefaultCallback) {
  15035. defaultCallback = newDefaultCallback;
  15036. },
  15037. getDefaultQueryMethod: function() {
  15038. return defaultQueryMethod;
  15039. },
  15040. setDefaultQueryMethod: function(newDefaultQueryMethod) {
  15041. defaultQueryMethod = newDefaultQueryMethod;
  15042. },
  15043. getDefaultSearchResultClass: function() {
  15044. return defaultSearchResultClass;
  15045. },
  15046. setDefaultSearchResultClass: function(newSearchResultClass) {
  15047. defaultSearchResultClass = newSearchResultClass;
  15048. }
  15049. };
  15050. })();
  15051. Handsontable.SearchCellDecorator = function(instance, TD, row, col, prop, value, cellProperties) {
  15052. var searchResultClass = (cellProperties.search !== null && typeof cellProperties.search == 'object' && cellProperties.search.searchResultClass) || Handsontable.Search.global.getDefaultSearchResultClass();
  15053. if (cellProperties.isSearchResult) {
  15054. dom.addClass(TD, searchResultClass);
  15055. } else {
  15056. dom.removeClass(TD, searchResultClass);
  15057. }
  15058. };
  15059. var originalBaseRenderer = getRenderer('base');
  15060. registerRenderer('base', function(instance, TD, row, col, prop, value, cellProperties) {
  15061. originalBaseRenderer.apply(this, arguments);
  15062. Handsontable.SearchCellDecorator.apply(this, arguments);
  15063. });
  15064. function init() {
  15065. var instance = this;
  15066. var pluginEnabled = !!instance.getSettings().search;
  15067. if (pluginEnabled) {
  15068. instance.search = new Handsontable.Search(instance);
  15069. } else {
  15070. delete instance.search;
  15071. }
  15072. }
  15073. Handsontable.hooks.add('afterInit', init);
  15074. Handsontable.hooks.add('afterUpdateSettings', init);
  15075. //#
  15076. },{"./../../dom.js":27,"./../../renderers.js":70}],68:[function(require,module,exports){
  15077. "use strict";
  15078. Object.defineProperties(exports, {
  15079. TouchScroll: {get: function() {
  15080. return TouchScroll;
  15081. }},
  15082. __esModule: {value: true}
  15083. });
  15084. var $___46__46__47__46__46__47_dom_46_js__,
  15085. $___46__46__47__95_base_46_js__,
  15086. $___46__46__47__46__46__47_plugins_46_js__;
  15087. 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__});
  15088. 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;
  15089. 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;
  15090. var TouchScroll = function TouchScroll(hotInstance) {
  15091. var $__2 = this;
  15092. $traceurRuntime.superConstructor($TouchScroll).call(this, hotInstance);
  15093. this.hot.addHook('afterInit', (function() {
  15094. return $__2.init();
  15095. }));
  15096. this.hot.addHook('afterUpdateSettings', (function() {
  15097. return $__2.onAfterUpdateSettings();
  15098. }));
  15099. this.scrollbars = [];
  15100. this.clones = [];
  15101. };
  15102. var $TouchScroll = TouchScroll;
  15103. ($traceurRuntime.createClass)(TouchScroll, {
  15104. init: function() {
  15105. this.registerEvents();
  15106. this.onAfterUpdateSettings();
  15107. },
  15108. onAfterUpdateSettings: function() {
  15109. var _this = this;
  15110. this.hot.addHookOnce('afterRender', function() {
  15111. var wtOverlays = _this.hot.view.wt.wtOverlays;
  15112. _this.scrollbars = [];
  15113. _this.scrollbars.push(wtOverlays.topOverlay);
  15114. _this.scrollbars.push(wtOverlays.leftOverlay);
  15115. if (wtOverlays.topLeftCornerOverlay) {
  15116. _this.scrollbars.push(wtOverlays.topLeftCornerOverlay);
  15117. }
  15118. _this.clones = [];
  15119. if (wtOverlays.topOverlay.needFullRender) {
  15120. _this.clones.push(wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  15121. }
  15122. if (wtOverlays.leftOverlay.needFullRender) {
  15123. _this.clones.push(wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  15124. }
  15125. if (wtOverlays.topLeftCornerOverlay) {
  15126. _this.clones.push(wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  15127. }
  15128. });
  15129. },
  15130. registerEvents: function() {
  15131. var $__2 = this;
  15132. this.hot.addHook('beforeTouchScroll', (function() {
  15133. return $__2.onBeforeTouchScroll();
  15134. }));
  15135. this.hot.addHook('afterMomentumScroll', (function() {
  15136. return $__2.onAfterMomentumScroll();
  15137. }));
  15138. },
  15139. onBeforeTouchScroll: function() {
  15140. Handsontable.freezeOverlays = true;
  15141. for (var i = 0,
  15142. cloneCount = this.clones.length; i < cloneCount; i++) {
  15143. dom.addClass(this.clones[i], 'hide-tween');
  15144. }
  15145. },
  15146. onAfterMomentumScroll: function() {
  15147. Handsontable.freezeOverlays = false;
  15148. var _that = this;
  15149. for (var i = 0,
  15150. cloneCount = this.clones.length; i < cloneCount; i++) {
  15151. dom.removeClass(this.clones[i], 'hide-tween');
  15152. }
  15153. for (var i$__4 = 0,
  15154. cloneCount$__5 = this.clones.length; i$__4 < cloneCount$__5; i$__4++) {
  15155. dom.addClass(this.clones[i$__4], 'show-tween');
  15156. }
  15157. setTimeout(function() {
  15158. for (var i = 0,
  15159. cloneCount = _that.clones.length; i < cloneCount; i++) {
  15160. dom.removeClass(_that.clones[i], 'show-tween');
  15161. }
  15162. }, 400);
  15163. for (var i$__6 = 0,
  15164. cloneCount$__7 = this.scrollbars.length; i$__6 < cloneCount$__7; i$__6++) {
  15165. this.scrollbars[i$__6].refresh();
  15166. this.scrollbars[i$__6].resetFixedPosition();
  15167. }
  15168. this.hot.view.wt.wtOverlays.syncScrollWithMaster();
  15169. }
  15170. }, {}, BasePlugin);
  15171. ;
  15172. registerPlugin('touchScroll', TouchScroll);
  15173. //#
  15174. },{"./../../dom.js":27,"./../../plugins.js":45,"./../_base.js":46}],69:[function(require,module,exports){
  15175. "use strict";
  15176. var $___46__46__47__46__46__47_helpers_46_js__;
  15177. 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__});
  15178. Handsontable.UndoRedo = function(instance) {
  15179. var plugin = this;
  15180. this.instance = instance;
  15181. this.doneActions = [];
  15182. this.undoneActions = [];
  15183. this.ignoreNewActions = false;
  15184. instance.addHook("afterChange", function(changes, origin) {
  15185. if (changes) {
  15186. var action = new Handsontable.UndoRedo.ChangeAction(changes);
  15187. plugin.done(action);
  15188. }
  15189. });
  15190. instance.addHook("afterCreateRow", function(index, amount, createdAutomatically) {
  15191. if (createdAutomatically) {
  15192. return;
  15193. }
  15194. var action = new Handsontable.UndoRedo.CreateRowAction(index, amount);
  15195. plugin.done(action);
  15196. });
  15197. instance.addHook("beforeRemoveRow", function(index, amount) {
  15198. var originalData = plugin.instance.getData();
  15199. index = (originalData.length + index) % originalData.length;
  15200. var removedData = originalData.slice(index, index + amount);
  15201. var action = new Handsontable.UndoRedo.RemoveRowAction(index, removedData);
  15202. plugin.done(action);
  15203. });
  15204. instance.addHook("afterCreateCol", function(index, amount, createdAutomatically) {
  15205. if (createdAutomatically) {
  15206. return;
  15207. }
  15208. var action = new Handsontable.UndoRedo.CreateColumnAction(index, amount);
  15209. plugin.done(action);
  15210. });
  15211. instance.addHook("beforeRemoveCol", function(index, amount) {
  15212. var originalData = plugin.instance.getData();
  15213. index = (plugin.instance.countCols() + index) % plugin.instance.countCols();
  15214. var removedData = [];
  15215. for (var i = 0,
  15216. len = originalData.length; i < len; i++) {
  15217. removedData[i] = originalData[i].slice(index, index + amount);
  15218. }
  15219. var headers;
  15220. if (Array.isArray(instance.getSettings().colHeaders)) {
  15221. headers = instance.getSettings().colHeaders.slice(index, index + removedData.length);
  15222. }
  15223. var action = new Handsontable.UndoRedo.RemoveColumnAction(index, removedData, headers);
  15224. plugin.done(action);
  15225. });
  15226. instance.addHook("beforeCellAlignment", function(stateBefore, range, type, alignment) {
  15227. var action = new Handsontable.UndoRedo.CellAlignmentAction(stateBefore, range, type, alignment);
  15228. plugin.done(action);
  15229. });
  15230. };
  15231. Handsontable.UndoRedo.prototype.done = function(action) {
  15232. if (!this.ignoreNewActions) {
  15233. this.doneActions.push(action);
  15234. this.undoneActions.length = 0;
  15235. }
  15236. };
  15237. Handsontable.UndoRedo.prototype.undo = function() {
  15238. if (this.isUndoAvailable()) {
  15239. var action = this.doneActions.pop();
  15240. this.ignoreNewActions = true;
  15241. var that = this;
  15242. action.undo(this.instance, function() {
  15243. that.ignoreNewActions = false;
  15244. that.undoneActions.push(action);
  15245. });
  15246. }
  15247. };
  15248. Handsontable.UndoRedo.prototype.redo = function() {
  15249. if (this.isRedoAvailable()) {
  15250. var action = this.undoneActions.pop();
  15251. this.ignoreNewActions = true;
  15252. var that = this;
  15253. action.redo(this.instance, function() {
  15254. that.ignoreNewActions = false;
  15255. that.doneActions.push(action);
  15256. });
  15257. }
  15258. };
  15259. Handsontable.UndoRedo.prototype.isUndoAvailable = function() {
  15260. return this.doneActions.length > 0;
  15261. };
  15262. Handsontable.UndoRedo.prototype.isRedoAvailable = function() {
  15263. return this.undoneActions.length > 0;
  15264. };
  15265. Handsontable.UndoRedo.prototype.clear = function() {
  15266. this.doneActions.length = 0;
  15267. this.undoneActions.length = 0;
  15268. };
  15269. Handsontable.UndoRedo.Action = function() {};
  15270. Handsontable.UndoRedo.Action.prototype.undo = function() {};
  15271. Handsontable.UndoRedo.Action.prototype.redo = function() {};
  15272. Handsontable.UndoRedo.ChangeAction = function(changes) {
  15273. this.changes = changes;
  15274. };
  15275. helper.inherit(Handsontable.UndoRedo.ChangeAction, Handsontable.UndoRedo.Action);
  15276. Handsontable.UndoRedo.ChangeAction.prototype.undo = function(instance, undoneCallback) {
  15277. var data = helper.deepClone(this.changes),
  15278. emptyRowsAtTheEnd = instance.countEmptyRows(true),
  15279. emptyColsAtTheEnd = instance.countEmptyCols(true);
  15280. for (var i = 0,
  15281. len = data.length; i < len; i++) {
  15282. data[i].splice(3, 1);
  15283. }
  15284. instance.addHookOnce('afterChange', undoneCallback);
  15285. instance.setDataAtRowProp(data, null, null, 'undo');
  15286. for (var i = 0,
  15287. len = data.length; i < len; i++) {
  15288. if (instance.getSettings().minSpareRows && data[i][0] + 1 + instance.getSettings().minSpareRows === instance.countRows() && emptyRowsAtTheEnd == instance.getSettings().minSpareRows) {
  15289. instance.alter('remove_row', parseInt(data[i][0] + 1, 10), instance.getSettings().minSpareRows);
  15290. instance.undoRedo.doneActions.pop();
  15291. }
  15292. if (instance.getSettings().minSpareCols && data[i][1] + 1 + instance.getSettings().minSpareCols === instance.countCols() && emptyColsAtTheEnd == instance.getSettings().minSpareCols) {
  15293. instance.alter('remove_col', parseInt(data[i][1] + 1, 10), instance.getSettings().minSpareCols);
  15294. instance.undoRedo.doneActions.pop();
  15295. }
  15296. }
  15297. };
  15298. Handsontable.UndoRedo.ChangeAction.prototype.redo = function(instance, onFinishCallback) {
  15299. var data = helper.deepClone(this.changes);
  15300. for (var i = 0,
  15301. len = data.length; i < len; i++) {
  15302. data[i].splice(2, 1);
  15303. }
  15304. instance.addHookOnce('afterChange', onFinishCallback);
  15305. instance.setDataAtRowProp(data, null, null, 'redo');
  15306. };
  15307. Handsontable.UndoRedo.CreateRowAction = function(index, amount) {
  15308. this.index = index;
  15309. this.amount = amount;
  15310. };
  15311. helper.inherit(Handsontable.UndoRedo.CreateRowAction, Handsontable.UndoRedo.Action);
  15312. Handsontable.UndoRedo.CreateRowAction.prototype.undo = function(instance, undoneCallback) {
  15313. var rowCount = instance.countRows(),
  15314. minSpareRows = instance.getSettings().minSpareRows;
  15315. if (this.index >= rowCount && this.index - minSpareRows < rowCount) {
  15316. this.index -= minSpareRows;
  15317. }
  15318. instance.addHookOnce('afterRemoveRow', undoneCallback);
  15319. instance.alter('remove_row', this.index, this.amount);
  15320. };
  15321. Handsontable.UndoRedo.CreateRowAction.prototype.redo = function(instance, redoneCallback) {
  15322. instance.addHookOnce('afterCreateRow', redoneCallback);
  15323. instance.alter('insert_row', this.index + 1, this.amount);
  15324. };
  15325. Handsontable.UndoRedo.RemoveRowAction = function(index, data) {
  15326. this.index = index;
  15327. this.data = data;
  15328. };
  15329. helper.inherit(Handsontable.UndoRedo.RemoveRowAction, Handsontable.UndoRedo.Action);
  15330. Handsontable.UndoRedo.RemoveRowAction.prototype.undo = function(instance, undoneCallback) {
  15331. var spliceArgs = [this.index, 0];
  15332. Array.prototype.push.apply(spliceArgs, this.data);
  15333. Array.prototype.splice.apply(instance.getData(), spliceArgs);
  15334. instance.addHookOnce('afterRender', undoneCallback);
  15335. instance.render();
  15336. };
  15337. Handsontable.UndoRedo.RemoveRowAction.prototype.redo = function(instance, redoneCallback) {
  15338. instance.addHookOnce('afterRemoveRow', redoneCallback);
  15339. instance.alter('remove_row', this.index, this.data.length);
  15340. };
  15341. Handsontable.UndoRedo.CreateColumnAction = function(index, amount) {
  15342. this.index = index;
  15343. this.amount = amount;
  15344. };
  15345. helper.inherit(Handsontable.UndoRedo.CreateColumnAction, Handsontable.UndoRedo.Action);
  15346. Handsontable.UndoRedo.CreateColumnAction.prototype.undo = function(instance, undoneCallback) {
  15347. instance.addHookOnce('afterRemoveCol', undoneCallback);
  15348. instance.alter('remove_col', this.index, this.amount);
  15349. };
  15350. Handsontable.UndoRedo.CreateColumnAction.prototype.redo = function(instance, redoneCallback) {
  15351. instance.addHookOnce('afterCreateCol', redoneCallback);
  15352. instance.alter('insert_col', this.index + 1, this.amount);
  15353. };
  15354. Handsontable.UndoRedo.CellAlignmentAction = function(stateBefore, range, type, alignment) {
  15355. this.stateBefore = stateBefore;
  15356. this.range = range;
  15357. this.type = type;
  15358. this.alignment = alignment;
  15359. };
  15360. Handsontable.UndoRedo.CellAlignmentAction.prototype.undo = function(instance, undoneCallback) {
  15361. if (!instance.contextMenu) {
  15362. return;
  15363. }
  15364. for (var row = this.range.from.row; row <= this.range.to.row; row++) {
  15365. for (var col = this.range.from.col; col <= this.range.to.col; col++) {
  15366. instance.setCellMeta(row, col, 'className', this.stateBefore[row][col] || ' htLeft');
  15367. }
  15368. }
  15369. instance.addHookOnce('afterRender', undoneCallback);
  15370. instance.render();
  15371. };
  15372. Handsontable.UndoRedo.CellAlignmentAction.prototype.redo = function(instance, undoneCallback) {
  15373. if (!instance.contextMenu) {
  15374. return;
  15375. }
  15376. for (var row = this.range.from.row; row <= this.range.to.row; row++) {
  15377. for (var col = this.range.from.col; col <= this.range.to.col; col++) {
  15378. instance.contextMenu.align.call(instance, this.range, this.type, this.alignment);
  15379. }
  15380. }
  15381. instance.addHookOnce('afterRender', undoneCallback);
  15382. instance.render();
  15383. };
  15384. Handsontable.UndoRedo.RemoveColumnAction = function(index, data, headers) {
  15385. this.index = index;
  15386. this.data = data;
  15387. this.amount = this.data[0].length;
  15388. this.headers = headers;
  15389. };
  15390. helper.inherit(Handsontable.UndoRedo.RemoveColumnAction, Handsontable.UndoRedo.Action);
  15391. Handsontable.UndoRedo.RemoveColumnAction.prototype.undo = function(instance, undoneCallback) {
  15392. var row,
  15393. spliceArgs;
  15394. for (var i = 0,
  15395. len = instance.getData().length; i < len; i++) {
  15396. row = instance.getSourceDataAtRow(i);
  15397. spliceArgs = [this.index, 0];
  15398. Array.prototype.push.apply(spliceArgs, this.data[i]);
  15399. Array.prototype.splice.apply(row, spliceArgs);
  15400. }
  15401. if (typeof this.headers != 'undefined') {
  15402. spliceArgs = [this.index, 0];
  15403. Array.prototype.push.apply(spliceArgs, this.headers);
  15404. Array.prototype.splice.apply(instance.getSettings().colHeaders, spliceArgs);
  15405. }
  15406. instance.addHookOnce('afterRender', undoneCallback);
  15407. instance.render();
  15408. };
  15409. Handsontable.UndoRedo.RemoveColumnAction.prototype.redo = function(instance, redoneCallback) {
  15410. instance.addHookOnce('afterRemoveCol', redoneCallback);
  15411. instance.alter('remove_col', this.index, this.amount);
  15412. };
  15413. function init() {
  15414. var instance = this;
  15415. var pluginEnabled = typeof instance.getSettings().undo == 'undefined' || instance.getSettings().undo;
  15416. if (pluginEnabled) {
  15417. if (!instance.undoRedo) {
  15418. instance.undoRedo = new Handsontable.UndoRedo(instance);
  15419. exposeUndoRedoMethods(instance);
  15420. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  15421. instance.addHook('afterChange', onAfterChange);
  15422. }
  15423. } else {
  15424. if (instance.undoRedo) {
  15425. delete instance.undoRedo;
  15426. removeExposedUndoRedoMethods(instance);
  15427. instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  15428. instance.removeHook('afterChange', onAfterChange);
  15429. }
  15430. }
  15431. }
  15432. function onBeforeKeyDown(event) {
  15433. var instance = this;
  15434. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  15435. if (ctrlDown) {
  15436. if (event.keyCode === 89 || (event.shiftKey && event.keyCode === 90)) {
  15437. instance.undoRedo.redo();
  15438. event.stopImmediatePropagation();
  15439. } else if (event.keyCode === 90) {
  15440. instance.undoRedo.undo();
  15441. event.stopImmediatePropagation();
  15442. }
  15443. }
  15444. }
  15445. function onAfterChange(changes, source) {
  15446. var instance = this;
  15447. if (source == 'loadData') {
  15448. return instance.undoRedo.clear();
  15449. }
  15450. }
  15451. function exposeUndoRedoMethods(instance) {
  15452. instance.undo = function() {
  15453. return instance.undoRedo.undo();
  15454. };
  15455. instance.redo = function() {
  15456. return instance.undoRedo.redo();
  15457. };
  15458. instance.isUndoAvailable = function() {
  15459. return instance.undoRedo.isUndoAvailable();
  15460. };
  15461. instance.isRedoAvailable = function() {
  15462. return instance.undoRedo.isRedoAvailable();
  15463. };
  15464. instance.clearUndo = function() {
  15465. return instance.undoRedo.clear();
  15466. };
  15467. }
  15468. function removeExposedUndoRedoMethods(instance) {
  15469. delete instance.undo;
  15470. delete instance.redo;
  15471. delete instance.isUndoAvailable;
  15472. delete instance.isRedoAvailable;
  15473. delete instance.clearUndo;
  15474. }
  15475. Handsontable.hooks.add('afterInit', init);
  15476. Handsontable.hooks.add('afterUpdateSettings', init);
  15477. //#
  15478. },{"./../../helpers.js":42}],70:[function(require,module,exports){
  15479. "use strict";
  15480. Object.defineProperties(exports, {
  15481. registerRenderer: {get: function() {
  15482. return registerRenderer;
  15483. }},
  15484. getRenderer: {get: function() {
  15485. return getRenderer;
  15486. }},
  15487. hasRenderer: {get: function() {
  15488. return hasRenderer;
  15489. }},
  15490. __esModule: {value: true}
  15491. });
  15492. var $__helpers_46_js__;
  15493. var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
  15494. ;
  15495. var registeredRenderers = {};
  15496. Handsontable.renderers = Handsontable.renderers || {};
  15497. Handsontable.renderers.registerRenderer = registerRenderer;
  15498. Handsontable.renderers.getRenderer = getRenderer;
  15499. function registerRenderer(rendererName, rendererFunction) {
  15500. var registerName;
  15501. registeredRenderers[rendererName] = rendererFunction;
  15502. registerName = helper.toUpperCaseFirst(rendererName) + 'Renderer';
  15503. Handsontable.renderers[registerName] = rendererFunction;
  15504. Handsontable[registerName] = rendererFunction;
  15505. }
  15506. function getRenderer(rendererName) {
  15507. if (typeof rendererName == 'function') {
  15508. return rendererName;
  15509. }
  15510. if (typeof rendererName != 'string') {
  15511. throw Error('Only strings and functions can be passed as "renderer" parameter');
  15512. }
  15513. if (!(rendererName in registeredRenderers)) {
  15514. throw Error('No editor registered under name "' + rendererName + '"');
  15515. }
  15516. return registeredRenderers[rendererName];
  15517. }
  15518. function hasRenderer(rendererName) {
  15519. return rendererName in registeredRenderers;
  15520. }
  15521. //#
  15522. },{"./helpers.js":42}],71:[function(require,module,exports){
  15523. "use strict";
  15524. Object.defineProperties(exports, {
  15525. cellDecorator: {get: function() {
  15526. return cellDecorator;
  15527. }},
  15528. __esModule: {value: true}
  15529. });
  15530. var $___46__46__47_dom_46_js__,
  15531. $___46__46__47_renderers_46_js__;
  15532. 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__});
  15533. 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;
  15534. ;
  15535. registerRenderer('base', cellDecorator);
  15536. Handsontable.renderers.cellDecorator = cellDecorator;
  15537. function cellDecorator(instance, TD, row, col, prop, value, cellProperties) {
  15538. if (cellProperties.className) {
  15539. if (TD.className) {
  15540. TD.className = TD.className + " " + cellProperties.className;
  15541. } else {
  15542. TD.className = cellProperties.className;
  15543. }
  15544. }
  15545. if (cellProperties.readOnly) {
  15546. dom.addClass(TD, cellProperties.readOnlyCellClassName);
  15547. }
  15548. if (cellProperties.valid === false && cellProperties.invalidCellClassName) {
  15549. dom.addClass(TD, cellProperties.invalidCellClassName);
  15550. } else {
  15551. dom.removeClass(TD, cellProperties.invalidCellClassName);
  15552. }
  15553. if (cellProperties.wordWrap === false && cellProperties.noWordWrapClassName) {
  15554. dom.addClass(TD, cellProperties.noWordWrapClassName);
  15555. }
  15556. if (!value && cellProperties.placeholder) {
  15557. dom.addClass(TD, cellProperties.placeholderCellClassName);
  15558. }
  15559. }
  15560. //#
  15561. },{"./../dom.js":27,"./../renderers.js":70}],72:[function(require,module,exports){
  15562. "use strict";
  15563. Object.defineProperties(exports, {
  15564. autocompleteRenderer: {get: function() {
  15565. return autocompleteRenderer;
  15566. }},
  15567. __esModule: {value: true}
  15568. });
  15569. var $___46__46__47_dom_46_js__,
  15570. $___46__46__47_eventManager_46_js__,
  15571. $___46__46__47_renderers_46_js__,
  15572. $___46__46__47_3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__;
  15573. 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__});
  15574. 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;
  15575. 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__}),
  15576. getRenderer = $__1.getRenderer,
  15577. registerRenderer = $__1.registerRenderer;
  15578. 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;
  15579. ;
  15580. var clonableWRAPPER = document.createElement('DIV');
  15581. clonableWRAPPER.className = 'htAutocompleteWrapper';
  15582. var clonableARROW = document.createElement('DIV');
  15583. clonableARROW.className = 'htAutocompleteArrow';
  15584. clonableARROW.appendChild(document.createTextNode(String.fromCharCode(9660)));
  15585. var wrapTdContentWithWrapper = function(TD, WRAPPER) {
  15586. WRAPPER.innerHTML = TD.innerHTML;
  15587. dom.empty(TD);
  15588. TD.appendChild(WRAPPER);
  15589. };
  15590. registerRenderer('autocomplete', autocompleteRenderer);
  15591. function autocompleteRenderer(instance, TD, row, col, prop, value, cellProperties) {
  15592. var WRAPPER = clonableWRAPPER.cloneNode(true);
  15593. var ARROW = clonableARROW.cloneNode(true);
  15594. getRenderer('text')(instance, TD, row, col, prop, value, cellProperties);
  15595. TD.appendChild(ARROW);
  15596. dom.addClass(TD, 'htAutocomplete');
  15597. if (!TD.firstChild) {
  15598. TD.appendChild(document.createTextNode(String.fromCharCode(160)));
  15599. }
  15600. if (!instance.acArrowListener) {
  15601. var eventManager = eventManagerObject(instance);
  15602. instance.acArrowListener = function(event) {
  15603. if (dom.hasClass(event.target, 'htAutocompleteArrow')) {
  15604. instance.view.wt.getSetting('onCellDblClick', null, new WalkontableCellCoords(row, col), TD);
  15605. }
  15606. };
  15607. eventManager.addEventListener(instance.rootElement, 'mousedown', instance.acArrowListener);
  15608. instance.addHookOnce('afterDestroy', function() {
  15609. eventManager.clear();
  15610. });
  15611. }
  15612. }
  15613. //#
  15614. },{"./../3rdparty/walkontable/src/cell/coords.js":5,"./../dom.js":27,"./../eventManager.js":41,"./../renderers.js":70}],73:[function(require,module,exports){
  15615. "use strict";
  15616. Object.defineProperties(exports, {
  15617. checkboxRenderer: {get: function() {
  15618. return checkboxRenderer;
  15619. }},
  15620. __esModule: {value: true}
  15621. });
  15622. var $___46__46__47_dom_46_js__,
  15623. $___46__46__47_helpers_46_js__,
  15624. $___46__46__47_eventManager_46_js__,
  15625. $___46__46__47_renderers_46_js__;
  15626. 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__});
  15627. 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__});
  15628. 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;
  15629. 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__}),
  15630. getRenderer = $__1.getRenderer,
  15631. registerRenderer = $__1.registerRenderer;
  15632. var clonableINPUT = document.createElement('INPUT');
  15633. clonableINPUT.className = 'htCheckboxRendererInput';
  15634. clonableINPUT.type = 'checkbox';
  15635. clonableINPUT.setAttribute('autocomplete', 'off');
  15636. var isListeningKeyDownEvent = new WeakMap();
  15637. function checkboxRenderer(instance, TD, row, col, prop, value, cellProperties) {
  15638. var eventManager = new EventManager(instance);
  15639. var input = clonableINPUT.cloneNode(false);
  15640. if (typeof cellProperties.checkedTemplate === 'undefined') {
  15641. cellProperties.checkedTemplate = true;
  15642. }
  15643. if (typeof cellProperties.uncheckedTemplate === 'undefined') {
  15644. cellProperties.uncheckedTemplate = false;
  15645. }
  15646. dom.empty(TD);
  15647. if (value === cellProperties.checkedTemplate || helper.equalsIgnoreCase(value, cellProperties.checkedTemplate)) {
  15648. input.checked = true;
  15649. TD.appendChild(input);
  15650. } else if (value === cellProperties.uncheckedTemplate || helper.equalsIgnoreCase(value, cellProperties.uncheckedTemplate)) {
  15651. TD.appendChild(input);
  15652. } else if (value === null) {
  15653. dom.addClass(input, 'noValue');
  15654. TD.appendChild(input);
  15655. } else {
  15656. dom.fastInnerText(TD, '#bad value#');
  15657. }
  15658. if (cellProperties.readOnly) {
  15659. eventManager.addEventListener(input, 'click', preventDefault);
  15660. } else {
  15661. eventManager.addEventListener(input, 'mousedown', stopPropagation);
  15662. eventManager.addEventListener(input, 'mouseup', stopPropagation);
  15663. eventManager.addEventListener(input, 'change', (function(event) {
  15664. instance.setDataAtRowProp(row, prop, event.target.checked ? cellProperties.checkedTemplate : cellProperties.uncheckedTemplate);
  15665. }));
  15666. }
  15667. if (!isListeningKeyDownEvent.has(instance)) {
  15668. isListeningKeyDownEvent.set(instance, true);
  15669. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  15670. }
  15671. function onBeforeKeyDown(event) {
  15672. var allowedKeys = [helper.keyCode.SPACE, helper.keyCode.ENTER, helper.keyCode.DELETE, helper.keyCode.BACKSPACE];
  15673. dom.enableImmediatePropagation(event);
  15674. if (allowedKeys.indexOf(event.keyCode) !== -1 && !event.isImmediatePropagationStopped()) {
  15675. eachSelectedCheckboxCell(function() {
  15676. event.stopImmediatePropagation();
  15677. event.preventDefault();
  15678. });
  15679. }
  15680. if (event.keyCode == helper.keyCode.SPACE || event.keyCode == helper.keyCode.ENTER) {
  15681. toggleSelected();
  15682. }
  15683. if (event.keyCode == helper.keyCode.DELETE || event.keyCode == helper.keyCode.BACKSPACE) {
  15684. toggleSelected(false);
  15685. }
  15686. }
  15687. function toggleSelected() {
  15688. var checked = arguments[0] !== (void 0) ? arguments[0] : null;
  15689. eachSelectedCheckboxCell(function(checkboxes) {
  15690. for (var i = 0,
  15691. len = checkboxes.length; i < len; i++) {
  15692. toggleCheckbox(checkboxes[i], checked);
  15693. }
  15694. });
  15695. }
  15696. function toggleCheckbox(checkbox) {
  15697. var checked = arguments[1] !== (void 0) ? arguments[1] : null;
  15698. if (checked === null) {
  15699. checkbox.checked = !checkbox.checked;
  15700. } else {
  15701. checkbox.checked = checked;
  15702. }
  15703. eventManager.fireEvent(checkbox, 'change');
  15704. }
  15705. function eachSelectedCheckboxCell(callback) {
  15706. var selRange = instance.getSelectedRange();
  15707. var topLeft = selRange.getTopLeftCorner();
  15708. var bottomRight = selRange.getBottomRightCorner();
  15709. for (var row = topLeft.row; row <= bottomRight.row; row++) {
  15710. for (var col = topLeft.col; col <= bottomRight.col; col++) {
  15711. var cell = instance.getCell(row, col);
  15712. var cellProperties$__2 = instance.getCellMeta(row, col);
  15713. var checkboxes = cell.querySelectorAll('input[type=checkbox]');
  15714. if (checkboxes.length > 0 && !cellProperties$__2.readOnly) {
  15715. callback(checkboxes);
  15716. }
  15717. }
  15718. }
  15719. }
  15720. function preventDefault(event) {
  15721. event.preventDefault();
  15722. }
  15723. function stopPropagation(event) {
  15724. helper.stopPropagation(event);
  15725. }
  15726. }
  15727. ;
  15728. registerRenderer('checkbox', checkboxRenderer);
  15729. //#
  15730. },{"./../dom.js":27,"./../eventManager.js":41,"./../helpers.js":42,"./../renderers.js":70}],74:[function(require,module,exports){
  15731. "use strict";
  15732. Object.defineProperties(exports, {
  15733. htmlRenderer: {get: function() {
  15734. return htmlRenderer;
  15735. }},
  15736. __esModule: {value: true}
  15737. });
  15738. var $___46__46__47_dom_46_js__,
  15739. $___46__46__47_renderers_46_js__;
  15740. 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__});
  15741. 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__}),
  15742. getRenderer = $__0.getRenderer,
  15743. registerRenderer = $__0.registerRenderer;
  15744. ;
  15745. registerRenderer('html', htmlRenderer);
  15746. function htmlRenderer(instance, TD, row, col, prop, value, cellProperties) {
  15747. getRenderer('base').apply(this, arguments);
  15748. dom.fastInnerHTML(TD, value);
  15749. }
  15750. //#
  15751. },{"./../dom.js":27,"./../renderers.js":70}],75:[function(require,module,exports){
  15752. "use strict";
  15753. Object.defineProperties(exports, {
  15754. numericRenderer: {get: function() {
  15755. return numericRenderer;
  15756. }},
  15757. __esModule: {value: true}
  15758. });
  15759. var $___46__46__47_dom_46_js__,
  15760. $___46__46__47_helpers_46_js__,
  15761. $__numeral__,
  15762. $___46__46__47_renderers_46_js__;
  15763. 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__});
  15764. 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__});
  15765. var numeral = ($__numeral__ = require("numeral"), $__numeral__ && $__numeral__.__esModule && $__numeral__ || {default: $__numeral__}).default;
  15766. 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__}),
  15767. getRenderer = $__1.getRenderer,
  15768. registerRenderer = $__1.registerRenderer;
  15769. ;
  15770. registerRenderer('numeric', numericRenderer);
  15771. function numericRenderer(instance, TD, row, col, prop, value, cellProperties) {
  15772. if (helper.isNumeric(value)) {
  15773. if (typeof cellProperties.language !== 'undefined') {
  15774. numeral.language(cellProperties.language);
  15775. }
  15776. value = numeral(value).format(cellProperties.format || '0');
  15777. dom.addClass(TD, 'htNumeric');
  15778. }
  15779. getRenderer('text')(instance, TD, row, col, prop, value, cellProperties);
  15780. }
  15781. //#
  15782. },{"./../dom.js":27,"./../helpers.js":42,"./../renderers.js":70,"numeral":"numeral"}],76:[function(require,module,exports){
  15783. "use strict";
  15784. Object.defineProperties(exports, {
  15785. passwordRenderer: {get: function() {
  15786. return passwordRenderer;
  15787. }},
  15788. __esModule: {value: true}
  15789. });
  15790. var $___46__46__47_dom_46_js__,
  15791. $___46__46__47_renderers_46_js__;
  15792. 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__});
  15793. 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__}),
  15794. getRenderer = $__0.getRenderer,
  15795. registerRenderer = $__0.registerRenderer;
  15796. ;
  15797. registerRenderer('password', passwordRenderer);
  15798. function passwordRenderer(instance, TD, row, col, prop, value, cellProperties) {
  15799. getRenderer('text').apply(this, arguments);
  15800. value = TD.innerHTML;
  15801. var hash;
  15802. var hashLength = cellProperties.hashLength || value.length;
  15803. var hashSymbol = cellProperties.hashSymbol || '*';
  15804. for (hash = ''; hash.split(hashSymbol).length - 1 < hashLength; hash += hashSymbol) {}
  15805. dom.fastInnerHTML(TD, hash);
  15806. }
  15807. //#
  15808. },{"./../dom.js":27,"./../renderers.js":70}],77:[function(require,module,exports){
  15809. "use strict";
  15810. Object.defineProperties(exports, {
  15811. textRenderer: {get: function() {
  15812. return textRenderer;
  15813. }},
  15814. __esModule: {value: true}
  15815. });
  15816. var $___46__46__47_dom_46_js__,
  15817. $___46__46__47_helpers_46_js__,
  15818. $___46__46__47_renderers_46_js__;
  15819. 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__});
  15820. 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__});
  15821. 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__}),
  15822. getRenderer = $__0.getRenderer,
  15823. registerRenderer = $__0.registerRenderer;
  15824. ;
  15825. registerRenderer('text', textRenderer);
  15826. function textRenderer(instance, TD, row, col, prop, value, cellProperties) {
  15827. getRenderer('base').apply(this, arguments);
  15828. if (!value && cellProperties.placeholder) {
  15829. value = cellProperties.placeholder;
  15830. }
  15831. var escaped = helper.stringify(value);
  15832. if (!instance.getSettings().trimWhitespace) {
  15833. escaped = escaped.replace(/ /g, String.fromCharCode(160));
  15834. }
  15835. if (cellProperties.rendererTemplate) {
  15836. dom.empty(TD);
  15837. var TEMPLATE = document.createElement('TEMPLATE');
  15838. TEMPLATE.setAttribute('bind', '{{}}');
  15839. TEMPLATE.innerHTML = cellProperties.rendererTemplate;
  15840. HTMLTemplateElement.decorate(TEMPLATE);
  15841. TEMPLATE.model = instance.getSourceDataAtRow(row);
  15842. TD.appendChild(TEMPLATE);
  15843. } else {
  15844. dom.fastInnerText(TD, escaped);
  15845. }
  15846. }
  15847. //#
  15848. },{"./../dom.js":27,"./../helpers.js":42,"./../renderers.js":70}],78:[function(require,module,exports){
  15849. "use strict";
  15850. if (!Array.prototype.filter) {
  15851. Array.prototype.filter = function(fun, thisp) {
  15852. "use strict";
  15853. if (typeof this === "undefined" || this === null) {
  15854. throw new TypeError();
  15855. }
  15856. if (typeof fun !== "function") {
  15857. throw new TypeError();
  15858. }
  15859. thisp = thisp || this;
  15860. if (isNodeList(thisp)) {
  15861. thisp = convertNodeListToArray(thisp);
  15862. }
  15863. var len = thisp.length,
  15864. res = [],
  15865. i,
  15866. val;
  15867. for (i = 0; i < len; i += 1) {
  15868. if (thisp.hasOwnProperty(i)) {
  15869. val = thisp[i];
  15870. if (fun.call(thisp, val, i, thisp)) {
  15871. res.push(val);
  15872. }
  15873. }
  15874. }
  15875. return res;
  15876. function isNodeList(object) {
  15877. return /NodeList/i.test(object.item);
  15878. }
  15879. function convertNodeListToArray(nodeList) {
  15880. var array = [];
  15881. for (var i = 0,
  15882. len = nodeList.length; i < len; i++) {
  15883. array[i] = nodeList[i];
  15884. }
  15885. return array;
  15886. }
  15887. };
  15888. }
  15889. //#
  15890. },{}],79:[function(require,module,exports){
  15891. "use strict";
  15892. if (!Array.prototype.indexOf) {
  15893. Array.prototype.indexOf = function(elt) {
  15894. var len = this.length >>> 0;
  15895. var from = Number(arguments[1]) || 0;
  15896. from = (from < 0) ? Math.ceil(from) : Math.floor(from);
  15897. if (from < 0) {
  15898. from += len;
  15899. }
  15900. for (; from < len; from++) {
  15901. if (from in this && this[from] === elt) {
  15902. return from;
  15903. }
  15904. }
  15905. return -1;
  15906. };
  15907. }
  15908. //#
  15909. },{}],80:[function(require,module,exports){
  15910. "use strict";
  15911. if (!Array.isArray) {
  15912. Array.isArray = function(obj) {
  15913. return Object.prototype.toString.call(obj) == '[object Array]';
  15914. };
  15915. }
  15916. //#
  15917. },{}],81:[function(require,module,exports){
  15918. "use strict";
  15919. (function(global) {
  15920. 'use strict';
  15921. if (global.$traceurRuntime) {
  15922. return;
  15923. }
  15924. var $Object = Object;
  15925. var $TypeError = TypeError;
  15926. var $create = $Object.create;
  15927. var $defineProperties = $Object.defineProperties;
  15928. var $defineProperty = $Object.defineProperty;
  15929. var $freeze = $Object.freeze;
  15930. var $getOwnPropertyDescriptor = $Object.getOwnPropertyDescriptor;
  15931. var $getOwnPropertyNames = $Object.getOwnPropertyNames;
  15932. var $keys = $Object.keys;
  15933. var $hasOwnProperty = $Object.prototype.hasOwnProperty;
  15934. var $toString = $Object.prototype.toString;
  15935. var $preventExtensions = Object.preventExtensions;
  15936. var $seal = Object.seal;
  15937. var $isExtensible = Object.isExtensible;
  15938. function nonEnum(value) {
  15939. return {
  15940. configurable: true,
  15941. enumerable: false,
  15942. value: value,
  15943. writable: true
  15944. };
  15945. }
  15946. var method = nonEnum;
  15947. var counter = 0;
  15948. function newUniqueString() {
  15949. return '__$' + Math.floor(Math.random() * 1e9) + '$' + ++counter + '$__';
  15950. }
  15951. var symbolInternalProperty = newUniqueString();
  15952. var symbolDescriptionProperty = newUniqueString();
  15953. var symbolDataProperty = newUniqueString();
  15954. var symbolValues = $create(null);
  15955. var privateNames = $create(null);
  15956. function isPrivateName(s) {
  15957. return privateNames[s];
  15958. }
  15959. function createPrivateName() {
  15960. var s = newUniqueString();
  15961. privateNames[s] = true;
  15962. return s;
  15963. }
  15964. function isShimSymbol(symbol) {
  15965. return typeof symbol === 'object' && symbol instanceof SymbolValue;
  15966. }
  15967. function typeOf(v) {
  15968. if (isShimSymbol(v))
  15969. return 'symbol';
  15970. return typeof v;
  15971. }
  15972. function Symbol(description) {
  15973. var value = new SymbolValue(description);
  15974. if (!(this instanceof Symbol))
  15975. return value;
  15976. throw new TypeError('Symbol cannot be new\'ed');
  15977. }
  15978. $defineProperty(Symbol.prototype, 'constructor', nonEnum(Symbol));
  15979. $defineProperty(Symbol.prototype, 'toString', method(function() {
  15980. var symbolValue = this[symbolDataProperty];
  15981. if (!getOption('symbols'))
  15982. return symbolValue[symbolInternalProperty];
  15983. if (!symbolValue)
  15984. throw TypeError('Conversion from symbol to string');
  15985. var desc = symbolValue[symbolDescriptionProperty];
  15986. if (desc === undefined)
  15987. desc = '';
  15988. return 'Symbol(' + desc + ')';
  15989. }));
  15990. $defineProperty(Symbol.prototype, 'valueOf', method(function() {
  15991. var symbolValue = this[symbolDataProperty];
  15992. if (!symbolValue)
  15993. throw TypeError('Conversion from symbol to string');
  15994. if (!getOption('symbols'))
  15995. return symbolValue[symbolInternalProperty];
  15996. return symbolValue;
  15997. }));
  15998. function SymbolValue(description) {
  15999. var key = newUniqueString();
  16000. $defineProperty(this, symbolDataProperty, {value: this});
  16001. $defineProperty(this, symbolInternalProperty, {value: key});
  16002. $defineProperty(this, symbolDescriptionProperty, {value: description});
  16003. freeze(this);
  16004. symbolValues[key] = this;
  16005. }
  16006. $defineProperty(SymbolValue.prototype, 'constructor', nonEnum(Symbol));
  16007. $defineProperty(SymbolValue.prototype, 'toString', {
  16008. value: Symbol.prototype.toString,
  16009. enumerable: false
  16010. });
  16011. $defineProperty(SymbolValue.prototype, 'valueOf', {
  16012. value: Symbol.prototype.valueOf,
  16013. enumerable: false
  16014. });
  16015. var hashProperty = createPrivateName();
  16016. var hashPropertyDescriptor = {value: undefined};
  16017. var hashObjectProperties = {
  16018. hash: {value: undefined},
  16019. self: {value: undefined}
  16020. };
  16021. var hashCounter = 0;
  16022. function getOwnHashObject(object) {
  16023. var hashObject = object[hashProperty];
  16024. if (hashObject && hashObject.self === object)
  16025. return hashObject;
  16026. if ($isExtensible(object)) {
  16027. hashObjectProperties.hash.value = hashCounter++;
  16028. hashObjectProperties.self.value = object;
  16029. hashPropertyDescriptor.value = $create(null, hashObjectProperties);
  16030. $defineProperty(object, hashProperty, hashPropertyDescriptor);
  16031. return hashPropertyDescriptor.value;
  16032. }
  16033. return undefined;
  16034. }
  16035. function freeze(object) {
  16036. getOwnHashObject(object);
  16037. return $freeze.apply(this, arguments);
  16038. }
  16039. function preventExtensions(object) {
  16040. getOwnHashObject(object);
  16041. return $preventExtensions.apply(this, arguments);
  16042. }
  16043. function seal(object) {
  16044. getOwnHashObject(object);
  16045. return $seal.apply(this, arguments);
  16046. }
  16047. freeze(SymbolValue.prototype);
  16048. function isSymbolString(s) {
  16049. return symbolValues[s] || privateNames[s];
  16050. }
  16051. function toProperty(name) {
  16052. if (isShimSymbol(name))
  16053. return name[symbolInternalProperty];
  16054. return name;
  16055. }
  16056. function removeSymbolKeys(array) {
  16057. var rv = [];
  16058. for (var i = 0; i < array.length; i++) {
  16059. if (!isSymbolString(array[i])) {
  16060. rv.push(array[i]);
  16061. }
  16062. }
  16063. return rv;
  16064. }
  16065. function getOwnPropertyNames(object) {
  16066. return removeSymbolKeys($getOwnPropertyNames(object));
  16067. }
  16068. function keys(object) {
  16069. return removeSymbolKeys($keys(object));
  16070. }
  16071. function getOwnPropertySymbols(object) {
  16072. var rv = [];
  16073. var names = $getOwnPropertyNames(object);
  16074. for (var i = 0; i < names.length; i++) {
  16075. var symbol = symbolValues[names[i]];
  16076. if (symbol) {
  16077. rv.push(symbol);
  16078. }
  16079. }
  16080. return rv;
  16081. }
  16082. function getOwnPropertyDescriptor(object, name) {
  16083. return $getOwnPropertyDescriptor(object, toProperty(name));
  16084. }
  16085. function hasOwnProperty(name) {
  16086. return $hasOwnProperty.call(this, toProperty(name));
  16087. }
  16088. function getOption(name) {
  16089. return global.traceur && global.traceur.options[name];
  16090. }
  16091. function defineProperty(object, name, descriptor) {
  16092. if (isShimSymbol(name)) {
  16093. name = name[symbolInternalProperty];
  16094. }
  16095. $defineProperty(object, name, descriptor);
  16096. return object;
  16097. }
  16098. function polyfillObject(Object) {
  16099. $defineProperty(Object, 'defineProperty', {value: defineProperty});
  16100. $defineProperty(Object, 'getOwnPropertyNames', {value: getOwnPropertyNames});
  16101. $defineProperty(Object, 'getOwnPropertyDescriptor', {value: getOwnPropertyDescriptor});
  16102. $defineProperty(Object.prototype, 'hasOwnProperty', {value: hasOwnProperty});
  16103. $defineProperty(Object, 'freeze', {value: freeze});
  16104. $defineProperty(Object, 'preventExtensions', {value: preventExtensions});
  16105. $defineProperty(Object, 'seal', {value: seal});
  16106. $defineProperty(Object, 'keys', {value: keys});
  16107. }
  16108. function exportStar(object) {
  16109. for (var i = 1; i < arguments.length; i++) {
  16110. var names = $getOwnPropertyNames(arguments[i]);
  16111. for (var j = 0; j < names.length; j++) {
  16112. var name = names[j];
  16113. if (isSymbolString(name))
  16114. continue;
  16115. (function(mod, name) {
  16116. $defineProperty(object, name, {
  16117. get: function() {
  16118. return mod[name];
  16119. },
  16120. enumerable: true
  16121. });
  16122. })(arguments[i], names[j]);
  16123. }
  16124. }
  16125. return object;
  16126. }
  16127. function isObject(x) {
  16128. return x != null && (typeof x === 'object' || typeof x === 'function');
  16129. }
  16130. function toObject(x) {
  16131. if (x == null)
  16132. throw $TypeError();
  16133. return $Object(x);
  16134. }
  16135. function checkObjectCoercible(argument) {
  16136. if (argument == null) {
  16137. throw new TypeError('Value cannot be converted to an Object');
  16138. }
  16139. return argument;
  16140. }
  16141. function polyfillSymbol(global, Symbol) {
  16142. if (!global.Symbol) {
  16143. global.Symbol = Symbol;
  16144. Object.getOwnPropertySymbols = getOwnPropertySymbols;
  16145. }
  16146. if (!global.Symbol.iterator) {
  16147. global.Symbol.iterator = Symbol('Symbol.iterator');
  16148. }
  16149. }
  16150. function setupGlobals(global) {
  16151. polyfillSymbol(global, Symbol);
  16152. global.Reflect = global.Reflect || {};
  16153. global.Reflect.global = global.Reflect.global || global;
  16154. polyfillObject(global.Object);
  16155. }
  16156. setupGlobals(global);
  16157. global.$traceurRuntime = {
  16158. checkObjectCoercible: checkObjectCoercible,
  16159. createPrivateName: createPrivateName,
  16160. defineProperties: $defineProperties,
  16161. defineProperty: $defineProperty,
  16162. exportStar: exportStar,
  16163. getOwnHashObject: getOwnHashObject,
  16164. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  16165. getOwnPropertyNames: $getOwnPropertyNames,
  16166. isObject: isObject,
  16167. isPrivateName: isPrivateName,
  16168. isSymbolString: isSymbolString,
  16169. keys: $keys,
  16170. setupGlobals: setupGlobals,
  16171. toObject: toObject,
  16172. toProperty: toProperty,
  16173. typeof: typeOf
  16174. };
  16175. })(window);
  16176. (function() {
  16177. 'use strict';
  16178. var path;
  16179. function relativeRequire(callerPath, requiredPath) {
  16180. path = path || typeof require !== 'undefined' && require('path');
  16181. function isDirectory(path) {
  16182. return path.slice(-1) === '/';
  16183. }
  16184. function isAbsolute(path) {
  16185. return path[0] === '/';
  16186. }
  16187. function isRelative(path) {
  16188. return path[0] === '.';
  16189. }
  16190. if (isDirectory(requiredPath) || isAbsolute(requiredPath))
  16191. return;
  16192. return isRelative(requiredPath) ? require(path.resolve(path.dirname(callerPath), requiredPath)) : require(requiredPath);
  16193. }
  16194. $traceurRuntime.require = relativeRequire;
  16195. })();
  16196. (function() {
  16197. 'use strict';
  16198. function spread() {
  16199. var rv = [],
  16200. j = 0,
  16201. iterResult;
  16202. for (var i = 0; i < arguments.length; i++) {
  16203. var valueToSpread = $traceurRuntime.checkObjectCoercible(arguments[i]);
  16204. if (typeof valueToSpread[$traceurRuntime.toProperty(Symbol.iterator)] !== 'function') {
  16205. throw new TypeError('Cannot spread non-iterable object.');
  16206. }
  16207. var iter = valueToSpread[$traceurRuntime.toProperty(Symbol.iterator)]();
  16208. while (!(iterResult = iter.next()).done) {
  16209. rv[j++] = iterResult.value;
  16210. }
  16211. }
  16212. return rv;
  16213. }
  16214. $traceurRuntime.spread = spread;
  16215. })();
  16216. (function() {
  16217. 'use strict';
  16218. var $Object = Object;
  16219. var $TypeError = TypeError;
  16220. var $create = $Object.create;
  16221. var $defineProperties = $traceurRuntime.defineProperties;
  16222. var $defineProperty = $traceurRuntime.defineProperty;
  16223. var $getOwnPropertyDescriptor = $traceurRuntime.getOwnPropertyDescriptor;
  16224. var $getOwnPropertyNames = $traceurRuntime.getOwnPropertyNames;
  16225. var $getPrototypeOf = Object.getPrototypeOf;
  16226. var $__0 = Object,
  16227. getOwnPropertyNames = $__0.getOwnPropertyNames,
  16228. getOwnPropertySymbols = $__0.getOwnPropertySymbols;
  16229. function superDescriptor(homeObject, name) {
  16230. var proto = $getPrototypeOf(homeObject);
  16231. do {
  16232. var result = $getOwnPropertyDescriptor(proto, name);
  16233. if (result)
  16234. return result;
  16235. proto = $getPrototypeOf(proto);
  16236. } while (proto);
  16237. return undefined;
  16238. }
  16239. function superConstructor(ctor) {
  16240. return ctor.__proto__;
  16241. }
  16242. function superCall(self, homeObject, name, args) {
  16243. return superGet(self, homeObject, name).apply(self, args);
  16244. }
  16245. function superGet(self, homeObject, name) {
  16246. var descriptor = superDescriptor(homeObject, name);
  16247. if (descriptor) {
  16248. if (!descriptor.get)
  16249. return descriptor.value;
  16250. return descriptor.get.call(self);
  16251. }
  16252. return undefined;
  16253. }
  16254. function superSet(self, homeObject, name, value) {
  16255. var descriptor = superDescriptor(homeObject, name);
  16256. if (descriptor && descriptor.set) {
  16257. descriptor.set.call(self, value);
  16258. return value;
  16259. }
  16260. throw $TypeError(("super has no setter '" + name + "'."));
  16261. }
  16262. function getDescriptors(object) {
  16263. var descriptors = {};
  16264. var names = getOwnPropertyNames(object);
  16265. for (var i = 0; i < names.length; i++) {
  16266. var name = names[i];
  16267. descriptors[name] = $getOwnPropertyDescriptor(object, name);
  16268. }
  16269. var symbols = getOwnPropertySymbols(object);
  16270. for (var i = 0; i < symbols.length; i++) {
  16271. var symbol = symbols[i];
  16272. descriptors[$traceurRuntime.toProperty(symbol)] = $getOwnPropertyDescriptor(object, $traceurRuntime.toProperty(symbol));
  16273. }
  16274. return descriptors;
  16275. }
  16276. function createClass(ctor, object, staticObject, superClass) {
  16277. $defineProperty(object, 'constructor', {
  16278. value: ctor,
  16279. configurable: true,
  16280. enumerable: false,
  16281. writable: true
  16282. });
  16283. if (arguments.length > 3) {
  16284. if (typeof superClass === 'function')
  16285. ctor.__proto__ = superClass;
  16286. ctor.prototype = $create(getProtoParent(superClass), getDescriptors(object));
  16287. } else {
  16288. ctor.prototype = object;
  16289. }
  16290. $defineProperty(ctor, 'prototype', {
  16291. configurable: false,
  16292. writable: false
  16293. });
  16294. return $defineProperties(ctor, getDescriptors(staticObject));
  16295. }
  16296. function getProtoParent(superClass) {
  16297. if (typeof superClass === 'function') {
  16298. var prototype = superClass.prototype;
  16299. if ($Object(prototype) === prototype || prototype === null)
  16300. return superClass.prototype;
  16301. throw new $TypeError('super prototype must be an Object or null');
  16302. }
  16303. if (superClass === null)
  16304. return null;
  16305. throw new $TypeError(("Super expression must either be null or a function, not " + typeof superClass + "."));
  16306. }
  16307. function defaultSuperCall(self, homeObject, args) {
  16308. if ($getPrototypeOf(homeObject) !== null)
  16309. superCall(self, homeObject, 'constructor', args);
  16310. }
  16311. $traceurRuntime.createClass = createClass;
  16312. $traceurRuntime.defaultSuperCall = defaultSuperCall;
  16313. $traceurRuntime.superCall = superCall;
  16314. $traceurRuntime.superConstructor = superConstructor;
  16315. $traceurRuntime.superGet = superGet;
  16316. $traceurRuntime.superSet = superSet;
  16317. })();
  16318. //#
  16319. },{"path":undefined}],82:[function(require,module,exports){
  16320. "use strict";
  16321. if (!Object.keys) {
  16322. Object.keys = (function() {
  16323. 'use strict';
  16324. var hasOwnProperty = Object.prototype.hasOwnProperty,
  16325. hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
  16326. dontEnums = ['toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor'],
  16327. dontEnumsLength = dontEnums.length;
  16328. return function(obj) {
  16329. if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
  16330. throw new TypeError('Object.keys called on non-object');
  16331. }
  16332. var result = [],
  16333. prop,
  16334. i;
  16335. for (prop in obj) {
  16336. if (hasOwnProperty.call(obj, prop)) {
  16337. result.push(prop);
  16338. }
  16339. }
  16340. if (hasDontEnumBug) {
  16341. for (i = 0; i < dontEnumsLength; i++) {
  16342. if (hasOwnProperty.call(obj, dontEnums[i])) {
  16343. result.push(dontEnums[i]);
  16344. }
  16345. }
  16346. }
  16347. return result;
  16348. };
  16349. }());
  16350. }
  16351. //#
  16352. },{}],83:[function(require,module,exports){
  16353. "use strict";
  16354. if (!String.prototype.trim) {
  16355. var trimRegex = /^\s+|\s+$/g;
  16356. String.prototype.trim = function() {
  16357. return this.replace(trimRegex, '');
  16358. };
  16359. }
  16360. //#
  16361. },{}],84:[function(require,module,exports){
  16362. "use strict";
  16363. if (typeof WeakMap === 'undefined') {
  16364. (function() {
  16365. var defineProperty = Object.defineProperty;
  16366. try {
  16367. var properDefineProperty = true;
  16368. defineProperty(function() {}, 'foo', {});
  16369. } catch (e) {
  16370. properDefineProperty = false;
  16371. }
  16372. var counter = +(new Date) % 1e9;
  16373. var WeakMap = function() {
  16374. this.name = '__st' + (Math.random() * 1e9 >>> 0) + (counter++ + '__');
  16375. if (!properDefineProperty) {
  16376. this._wmCache = [];
  16377. }
  16378. };
  16379. if (properDefineProperty) {
  16380. WeakMap.prototype = {
  16381. set: function(key, value) {
  16382. var entry = key[this.name];
  16383. if (entry && entry[0] === key)
  16384. entry[1] = value;
  16385. else
  16386. defineProperty(key, this.name, {
  16387. value: [key, value],
  16388. writable: true
  16389. });
  16390. },
  16391. get: function(key) {
  16392. var entry;
  16393. return (entry = key[this.name]) && entry[0] === key ? entry[1] : undefined;
  16394. },
  16395. has: function(key) {
  16396. return this.get(key) ? true : false;
  16397. },
  16398. 'delete': function(key) {
  16399. this.set(key, undefined);
  16400. }
  16401. };
  16402. } else {
  16403. WeakMap.prototype = {
  16404. set: function(key, value) {
  16405. if (typeof key == 'undefined' || typeof value == 'undefined')
  16406. return;
  16407. for (var i = 0,
  16408. len = this._wmCache.length; i < len; i++) {
  16409. if (this._wmCache[i].key == key) {
  16410. this._wmCache[i].value = value;
  16411. return;
  16412. }
  16413. }
  16414. this._wmCache.push({
  16415. key: key,
  16416. value: value
  16417. });
  16418. },
  16419. get: function(key) {
  16420. if (typeof key == 'undefined')
  16421. return;
  16422. for (var i = 0,
  16423. len = this._wmCache.length; i < len; i++) {
  16424. if (this._wmCache[i].key == key) {
  16425. return this._wmCache[i].value;
  16426. }
  16427. }
  16428. return void 0;
  16429. },
  16430. has: function(key) {
  16431. return this.get(key) ? true : false;
  16432. },
  16433. 'delete': function(key) {
  16434. if (typeof key == 'undefined')
  16435. return;
  16436. for (var i = 0,
  16437. len = this._wmCache.length; i < len; i++) {
  16438. if (this._wmCache[i].key == key) {
  16439. Array.prototype.slice.call(this._wmCache, i, 1);
  16440. }
  16441. }
  16442. }
  16443. };
  16444. }
  16445. window.WeakMap = WeakMap;
  16446. })();
  16447. }
  16448. //#
  16449. },{}],85:[function(require,module,exports){
  16450. "use strict";
  16451. Object.defineProperties(exports, {
  16452. TableView: {get: function() {
  16453. return TableView;
  16454. }},
  16455. __esModule: {value: true}
  16456. });
  16457. var $__dom_46_js__,
  16458. $__helpers_46_js__,
  16459. $__eventManager_46_js__,
  16460. $__3rdparty_47_walkontable_47_src_47_cell_47_coords_46_js__,
  16461. $__3rdparty_47_walkontable_47_src_47_selection_46_js__,
  16462. $__3rdparty_47_walkontable_47_src_47_core_46_js__;
  16463. var dom = ($__dom_46_js__ = require("./dom.js"), $__dom_46_js__ && $__dom_46_js__.__esModule && $__dom_46_js__ || {default: $__dom_46_js__});
  16464. var helper = ($__helpers_46_js__ = require("./helpers.js"), $__helpers_46_js__ && $__helpers_46_js__.__esModule && $__helpers_46_js__ || {default: $__helpers_46_js__});
  16465. var eventManagerObject = ($__eventManager_46_js__ = require("./eventManager.js"), $__eventManager_46_js__ && $__eventManager_46_js__.__esModule && $__eventManager_46_js__ || {default: $__eventManager_46_js__}).eventManager;
  16466. 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;
  16467. 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;
  16468. 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;
  16469. Handsontable.TableView = TableView;
  16470. function TableView(instance) {
  16471. var that = this;
  16472. this.eventManager = eventManagerObject(instance);
  16473. this.instance = instance;
  16474. this.settings = instance.getSettings();
  16475. var originalStyle = instance.rootElement.getAttribute('style');
  16476. if (originalStyle) {
  16477. instance.rootElement.setAttribute('data-originalstyle', originalStyle);
  16478. }
  16479. dom.addClass(instance.rootElement, 'handsontable');
  16480. var table = document.createElement('TABLE');
  16481. table.className = 'htCore';
  16482. this.THEAD = document.createElement('THEAD');
  16483. table.appendChild(this.THEAD);
  16484. this.TBODY = document.createElement('TBODY');
  16485. table.appendChild(this.TBODY);
  16486. instance.table = table;
  16487. instance.container.insertBefore(table, instance.container.firstChild);
  16488. this.eventManager.addEventListener(instance.rootElement, 'mousedown', function(event) {
  16489. if (!that.isTextSelectionAllowed(event.target)) {
  16490. clearTextSelection();
  16491. event.preventDefault();
  16492. window.focus();
  16493. }
  16494. });
  16495. this.eventManager.addEventListener(document.documentElement, 'keyup', function(event) {
  16496. if (instance.selection.isInProgress() && !event.shiftKey) {
  16497. instance.selection.finish();
  16498. }
  16499. });
  16500. var isMouseDown;
  16501. this.isMouseDown = function() {
  16502. return isMouseDown;
  16503. };
  16504. this.eventManager.addEventListener(document.documentElement, 'mouseup', function(event) {
  16505. if (instance.selection.isInProgress() && event.which === 1) {
  16506. instance.selection.finish();
  16507. }
  16508. isMouseDown = false;
  16509. if (helper.isOutsideInput(document.activeElement)) {
  16510. instance.unlisten();
  16511. }
  16512. });
  16513. this.eventManager.addEventListener(document.documentElement, 'mousedown', function(event) {
  16514. var next = event.target;
  16515. var eventX = event.x || event.clientX;
  16516. var eventY = event.y || event.clientY;
  16517. if (isMouseDown) {
  16518. return;
  16519. }
  16520. if (next !== instance.view.wt.wtTable.holder) {
  16521. while (next !== document.documentElement) {
  16522. if (next === null) {
  16523. if (event.isTargetWebComponent) {
  16524. break;
  16525. }
  16526. return;
  16527. }
  16528. if (next === instance.rootElement) {
  16529. return;
  16530. }
  16531. next = next.parentNode;
  16532. }
  16533. } else {
  16534. var scrollbarWidth = Handsontable.Dom.getScrollbarWidth();
  16535. if (document.elementFromPoint(eventX + scrollbarWidth, eventY) !== instance.view.wt.wtTable.holder || document.elementFromPoint(eventX, eventY + scrollbarWidth) !== instance.view.wt.wtTable.holder) {
  16536. return;
  16537. }
  16538. }
  16539. if (that.settings.outsideClickDeselects) {
  16540. instance.deselectCell();
  16541. } else {
  16542. instance.destroyEditor();
  16543. }
  16544. });
  16545. this.eventManager.addEventListener(table, 'selectstart', function(event) {
  16546. if (that.settings.fragmentSelection) {
  16547. return;
  16548. }
  16549. event.preventDefault();
  16550. });
  16551. var clearTextSelection = function() {
  16552. if (window.getSelection) {
  16553. if (window.getSelection().empty) {
  16554. window.getSelection().empty();
  16555. } else if (window.getSelection().removeAllRanges) {
  16556. window.getSelection().removeAllRanges();
  16557. }
  16558. } else if (document.selection) {
  16559. document.selection.empty();
  16560. }
  16561. };
  16562. var selections = [new WalkontableSelection({
  16563. className: 'current',
  16564. border: {
  16565. width: 2,
  16566. color: '#5292F7',
  16567. cornerVisible: function() {
  16568. return that.settings.fillHandle && !that.isCellEdited() && !instance.selection.isMultiple();
  16569. },
  16570. multipleSelectionHandlesVisible: function() {
  16571. return !that.isCellEdited() && !instance.selection.isMultiple();
  16572. }
  16573. }
  16574. }), new WalkontableSelection({
  16575. className: 'area',
  16576. border: {
  16577. width: 1,
  16578. color: '#89AFF9',
  16579. cornerVisible: function() {
  16580. return that.settings.fillHandle && !that.isCellEdited() && instance.selection.isMultiple();
  16581. },
  16582. multipleSelectionHandlesVisible: function() {
  16583. return !that.isCellEdited() && instance.selection.isMultiple();
  16584. }
  16585. }
  16586. }), new WalkontableSelection({
  16587. className: 'highlight',
  16588. highlightRowClassName: that.settings.currentRowClassName,
  16589. highlightColumnClassName: that.settings.currentColClassName
  16590. }), new WalkontableSelection({
  16591. className: 'fill',
  16592. border: {
  16593. width: 1,
  16594. color: 'red'
  16595. }
  16596. })];
  16597. selections.current = selections[0];
  16598. selections.area = selections[1];
  16599. selections.highlight = selections[2];
  16600. selections.fill = selections[3];
  16601. var walkontableConfig = {
  16602. debug: function() {
  16603. return that.settings.debug;
  16604. },
  16605. table: table,
  16606. stretchH: this.settings.stretchH,
  16607. data: instance.getDataAtCell,
  16608. totalRows: instance.countRows,
  16609. totalColumns: instance.countCols,
  16610. fixedColumnsLeft: function() {
  16611. return that.settings.fixedColumnsLeft;
  16612. },
  16613. fixedRowsTop: function() {
  16614. return that.settings.fixedRowsTop;
  16615. },
  16616. renderAllRows: that.settings.renderAllRows,
  16617. rowHeaders: function() {
  16618. var arr = [];
  16619. if (instance.hasRowHeaders()) {
  16620. arr.push(function(index, TH) {
  16621. that.appendRowHeader(index, TH);
  16622. });
  16623. }
  16624. Handsontable.hooks.run(instance, 'afterGetRowHeaderRenderers', arr);
  16625. return arr;
  16626. },
  16627. columnHeaders: function() {
  16628. var arr = [];
  16629. if (instance.hasColHeaders()) {
  16630. arr.push(function(index, TH) {
  16631. that.appendColHeader(index, TH);
  16632. });
  16633. }
  16634. Handsontable.hooks.run(instance, 'afterGetColumnHeaderRenderers', arr);
  16635. return arr;
  16636. },
  16637. columnWidth: instance.getColWidth,
  16638. rowHeight: instance.getRowHeight,
  16639. cellRenderer: function(row, col, TD) {
  16640. var prop = that.instance.colToProp(col),
  16641. cellProperties = that.instance.getCellMeta(row, col),
  16642. renderer = that.instance.getCellRenderer(cellProperties);
  16643. var value = that.instance.getDataAtRowProp(row, prop);
  16644. renderer(that.instance, TD, row, col, prop, value, cellProperties);
  16645. Handsontable.hooks.run(that.instance, 'afterRenderer', TD, row, col, prop, value, cellProperties);
  16646. },
  16647. selections: selections,
  16648. hideBorderOnMouseDownOver: function() {
  16649. return that.settings.fragmentSelection;
  16650. },
  16651. onCellMouseDown: function(event, coords, TD, wt) {
  16652. instance.listen();
  16653. that.activeWt = wt;
  16654. isMouseDown = true;
  16655. dom.enableImmediatePropagation(event);
  16656. Handsontable.hooks.run(instance, 'beforeOnCellMouseDown', event, coords, TD);
  16657. if (!event.isImmediatePropagationStopped()) {
  16658. if (event.button === 2 && instance.selection.inInSelection(coords)) {} else if (event.shiftKey) {
  16659. if (coords.row >= 0 && coords.col >= 0) {
  16660. instance.selection.setRangeEnd(coords);
  16661. }
  16662. } else {
  16663. if ((coords.row < 0 || coords.col < 0) && (coords.row >= 0 || coords.col >= 0)) {
  16664. if (coords.row < 0) {
  16665. instance.selectCell(0, coords.col, instance.countRows() - 1, coords.col);
  16666. instance.selection.setSelectedHeaders(false, true);
  16667. }
  16668. if (coords.col < 0) {
  16669. instance.selectCell(coords.row, 0, coords.row, instance.countCols() - 1);
  16670. instance.selection.setSelectedHeaders(true, false);
  16671. }
  16672. } else {
  16673. coords.row = coords.row < 0 ? 0 : coords.row;
  16674. coords.col = coords.col < 0 ? 0 : coords.col;
  16675. instance.selection.setRangeStart(coords);
  16676. }
  16677. }
  16678. Handsontable.hooks.run(instance, 'afterOnCellMouseDown', event, coords, TD);
  16679. that.activeWt = that.wt;
  16680. }
  16681. },
  16682. onCellMouseOver: function(event, coords, TD, wt) {
  16683. that.activeWt = wt;
  16684. if (coords.row >= 0 && coords.col >= 0) {
  16685. if (isMouseDown) {
  16686. instance.selection.setRangeEnd(coords);
  16687. }
  16688. } else {
  16689. if (isMouseDown) {
  16690. if (coords.row < 0) {
  16691. instance.selection.setRangeEnd(new WalkontableCellCoords(instance.countRows() - 1, coords.col));
  16692. instance.selection.setSelectedHeaders(false, true);
  16693. }
  16694. if (coords.col < 0) {
  16695. instance.selection.setRangeEnd(new WalkontableCellCoords(coords.row, instance.countCols() - 1));
  16696. instance.selection.setSelectedHeaders(true, false);
  16697. }
  16698. }
  16699. }
  16700. Handsontable.hooks.run(instance, 'afterOnCellMouseOver', event, coords, TD);
  16701. that.activeWt = that.wt;
  16702. },
  16703. onCellCornerMouseDown: function(event) {
  16704. event.preventDefault();
  16705. Handsontable.hooks.run(instance, 'afterOnCellCornerMouseDown', event);
  16706. },
  16707. beforeDraw: function(force) {
  16708. that.beforeRender(force);
  16709. },
  16710. onDraw: function(force) {
  16711. that.onDraw(force);
  16712. },
  16713. onScrollVertically: function() {
  16714. instance.runHooks('afterScrollVertically');
  16715. },
  16716. onScrollHorizontally: function() {
  16717. instance.runHooks('afterScrollHorizontally');
  16718. },
  16719. onBeforeDrawBorders: function(corners, borderClassName) {
  16720. instance.runHooks('beforeDrawBorders', corners, borderClassName);
  16721. },
  16722. onBeforeTouchScroll: function() {
  16723. instance.runHooks('beforeTouchScroll');
  16724. },
  16725. onAfterMomentumScroll: function() {
  16726. instance.runHooks('afterMomentumScroll');
  16727. },
  16728. viewportRowCalculatorOverride: function(calc) {
  16729. if (that.settings.viewportRowRenderingOffset) {
  16730. calc.startRow = Math.max(calc.startRow - that.settings.viewportRowRenderingOffset, 0);
  16731. calc.endRow = Math.min(calc.endRow + that.settings.viewportRowRenderingOffset, instance.countRows() - 1);
  16732. }
  16733. instance.runHooks('afterViewportRowCalculatorOverride', calc);
  16734. },
  16735. viewportColumnCalculatorOverride: function(calc) {
  16736. if (that.settings.viewportColumnRenderingOffset) {
  16737. calc.startColumn = Math.max(calc.startColumn - that.settings.viewportColumnRenderingOffset, 0);
  16738. calc.endColumn = Math.min(calc.endColumn + that.settings.viewportColumnRenderingOffset, instance.countCols() - 1);
  16739. }
  16740. instance.runHooks('afterViewportColumnCalculatorOverride', calc);
  16741. }
  16742. };
  16743. Handsontable.hooks.run(instance, 'beforeInitWalkontable', walkontableConfig);
  16744. this.wt = new Walkontable(walkontableConfig);
  16745. this.activeWt = this.wt;
  16746. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'mousedown', function(event) {
  16747. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  16748. helper.stopPropagation(event);
  16749. }
  16750. });
  16751. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'contextmenu', function(event) {
  16752. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  16753. helper.stopPropagation(event);
  16754. }
  16755. });
  16756. this.eventManager.addEventListener(document.documentElement, 'click', function() {
  16757. if (that.settings.observeDOMVisibility) {
  16758. if (that.wt.drawInterrupted) {
  16759. that.instance.forceFullRender = true;
  16760. that.render();
  16761. }
  16762. }
  16763. });
  16764. }
  16765. TableView.prototype.isTextSelectionAllowed = function(el) {
  16766. if (helper.isInput(el)) {
  16767. return true;
  16768. }
  16769. if (this.settings.fragmentSelection && dom.isChildOf(el, this.TBODY)) {
  16770. return true;
  16771. }
  16772. return false;
  16773. };
  16774. TableView.prototype.isCellEdited = function() {
  16775. var activeEditor = this.instance.getActiveEditor();
  16776. return activeEditor && activeEditor.isOpened();
  16777. };
  16778. TableView.prototype.beforeRender = function(force) {
  16779. if (force) {
  16780. Handsontable.hooks.run(this.instance, 'beforeRender', this.instance.forceFullRender);
  16781. }
  16782. };
  16783. TableView.prototype.onDraw = function(force) {
  16784. if (force) {
  16785. Handsontable.hooks.run(this.instance, 'afterRender', this.instance.forceFullRender);
  16786. }
  16787. };
  16788. TableView.prototype.render = function() {
  16789. this.wt.draw(!this.instance.forceFullRender);
  16790. this.instance.forceFullRender = false;
  16791. };
  16792. TableView.prototype.getCellAtCoords = function(coords, topmost) {
  16793. var td = this.wt.getCell(coords, topmost);
  16794. if (td < 0) {
  16795. return null;
  16796. } else {
  16797. return td;
  16798. }
  16799. };
  16800. TableView.prototype.scrollViewport = function(coords) {
  16801. this.wt.scrollViewport(coords);
  16802. };
  16803. TableView.prototype.appendRowHeader = function(row, TH) {
  16804. if (TH.firstChild) {
  16805. var container = TH.firstChild;
  16806. if (!dom.hasClass(container, 'relative')) {
  16807. dom.empty(TH);
  16808. this.appendRowHeader(row, TH);
  16809. return;
  16810. }
  16811. this.updateCellHeader(container.firstChild, row, this.instance.getRowHeader);
  16812. } else {
  16813. var div = document.createElement('div');
  16814. var span = document.createElement('span');
  16815. div.className = 'relative';
  16816. span.className = 'colHeader';
  16817. this.updateCellHeader(span, row, this.instance.getRowHeader);
  16818. div.appendChild(span);
  16819. TH.appendChild(div);
  16820. }
  16821. Handsontable.hooks.run(this.instance, 'afterGetRowHeader', row, TH);
  16822. };
  16823. TableView.prototype.appendColHeader = function(col, TH) {
  16824. if (TH.firstChild) {
  16825. var container = TH.firstChild;
  16826. if (!dom.hasClass(container, 'relative')) {
  16827. dom.empty(TH);
  16828. this.appendRowHeader(col, TH);
  16829. return;
  16830. }
  16831. this.updateCellHeader(container.firstChild, col, this.instance.getColHeader);
  16832. } else {
  16833. var div = document.createElement('div');
  16834. var span = document.createElement('span');
  16835. div.className = 'relative';
  16836. span.className = 'colHeader';
  16837. this.updateCellHeader(span, col, this.instance.getColHeader);
  16838. div.appendChild(span);
  16839. TH.appendChild(div);
  16840. }
  16841. Handsontable.hooks.run(this.instance, 'afterGetColHeader', col, TH);
  16842. };
  16843. TableView.prototype.updateCellHeader = function(element, index, content) {
  16844. if (index > -1) {
  16845. dom.fastInnerHTML(element, content(index));
  16846. } else {
  16847. dom.fastInnerText(element, String.fromCharCode(160));
  16848. dom.addClass(element, 'cornerHeader');
  16849. }
  16850. };
  16851. TableView.prototype.maximumVisibleElementWidth = function(leftOffset) {
  16852. var workspaceWidth = this.wt.wtViewport.getWorkspaceWidth();
  16853. var maxWidth = workspaceWidth - leftOffset;
  16854. return maxWidth > 0 ? maxWidth : 0;
  16855. };
  16856. TableView.prototype.maximumVisibleElementHeight = function(topOffset) {
  16857. var workspaceHeight = this.wt.wtViewport.getWorkspaceHeight();
  16858. var maxHeight = workspaceHeight - topOffset;
  16859. return maxHeight > 0 ? maxHeight : 0;
  16860. };
  16861. TableView.prototype.mainViewIsActive = function() {
  16862. return this.wt === this.activeWt;
  16863. };
  16864. TableView.prototype.destroy = function() {
  16865. this.wt.destroy();
  16866. this.eventManager.clear();
  16867. };
  16868. ;
  16869. //#
  16870. },{"./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){
  16871. "use strict";
  16872. var process = function(value, callback) {
  16873. var originalVal = value;
  16874. var lowercaseVal = typeof originalVal === 'string' ? originalVal.toLowerCase() : null;
  16875. return function(source) {
  16876. var found = false;
  16877. for (var s = 0,
  16878. slen = source.length; s < slen; s++) {
  16879. if (originalVal === source[s]) {
  16880. found = true;
  16881. break;
  16882. } else if (lowercaseVal === Handsontable.helper.stringify(source[s]).toLowerCase()) {
  16883. found = true;
  16884. break;
  16885. }
  16886. }
  16887. callback(found);
  16888. };
  16889. };
  16890. Handsontable.AutocompleteValidator = function(value, callback) {
  16891. if (this.strict && this.source) {
  16892. if (typeof this.source === 'function') {
  16893. this.source(value, process(value, callback));
  16894. } else {
  16895. process(value, callback)(this.source);
  16896. }
  16897. } else {
  16898. callback(true);
  16899. }
  16900. };
  16901. //#
  16902. },{}],87:[function(require,module,exports){
  16903. "use strict";
  16904. var $__moment__,
  16905. $___46__46__47_editors_46_js__;
  16906. var moment = ($__moment__ = require("moment"), $__moment__ && $__moment__.__esModule && $__moment__ || {default: $__moment__}).default;
  16907. 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;
  16908. Handsontable.DateValidator = function(value, callback) {
  16909. var valid = true;
  16910. var dateEditor = getEditor('date', this.instance);
  16911. if (value === null) {
  16912. value = '';
  16913. }
  16914. var isValidDate = moment(new Date(value)).isValid();
  16915. var isValidFormat = moment(value, this.dateFormat || dateEditor.defaultDateFormat, true).isValid();
  16916. if (!isValidDate) {
  16917. valid = false;
  16918. }
  16919. if (!isValidDate && isValidFormat) {
  16920. valid = true;
  16921. }
  16922. if (isValidDate && !isValidFormat) {
  16923. if (this.correctFormat === true) {
  16924. var correctedValue = correctFormat(value, this.dateFormat);
  16925. this.instance.setDataAtCell(this.row, this.col, correctedValue, 'dateValidator');
  16926. valid = true;
  16927. } else {
  16928. valid = false;
  16929. }
  16930. }
  16931. callback(valid);
  16932. };
  16933. var correctFormat = function correctFormat(value, dateFormat) {
  16934. var date = moment(new Date(value));
  16935. if (date.format('YYYY').length > 4) {
  16936. date.year((date.year() + '').substr(0, 4));
  16937. }
  16938. return date.format(dateFormat);
  16939. };
  16940. //#
  16941. },{"./../editors.js":29,"moment":"moment"}],88:[function(require,module,exports){
  16942. "use strict";
  16943. Handsontable.NumericValidator = function(value, callback) {
  16944. if (value === null) {
  16945. value = '';
  16946. }
  16947. callback(/^-?\d*(\.|\,)?\d*$/.test(value));
  16948. };
  16949. //#
  16950. },{}],"SheetClip":[function(require,module,exports){
  16951. "use strict";
  16952. (function(global) {
  16953. "use strict";
  16954. function countQuotes(str) {
  16955. return str.split('"').length - 1;
  16956. }
  16957. var SheetClip = {
  16958. parse: function(str) {
  16959. var r,
  16960. rLen,
  16961. rows,
  16962. arr = [],
  16963. a = 0,
  16964. c,
  16965. cLen,
  16966. multiline,
  16967. last;
  16968. rows = str.split('\n');
  16969. if (rows.length > 1 && rows[rows.length - 1] === '') {
  16970. rows.pop();
  16971. }
  16972. for (r = 0, rLen = rows.length; r < rLen; r += 1) {
  16973. rows[r] = rows[r].split('\t');
  16974. for (c = 0, cLen = rows[r].length; c < cLen; c += 1) {
  16975. if (!arr[a]) {
  16976. arr[a] = [];
  16977. }
  16978. if (multiline && c === 0) {
  16979. last = arr[a].length - 1;
  16980. arr[a][last] = arr[a][last] + '\n' + rows[r][0];
  16981. if (multiline && (countQuotes(rows[r][0]) & 1)) {
  16982. multiline = false;
  16983. arr[a][last] = arr[a][last].substring(0, arr[a][last].length - 1).replace(/""/g, '"');
  16984. }
  16985. } else {
  16986. if (c === cLen - 1 && rows[r][c].indexOf('"') === 0 && (countQuotes(rows[r][c]) & 1)) {
  16987. arr[a].push(rows[r][c].substring(1).replace(/""/g, '"'));
  16988. multiline = true;
  16989. } else {
  16990. arr[a].push(rows[r][c].replace(/""/g, '"'));
  16991. multiline = false;
  16992. }
  16993. }
  16994. }
  16995. if (!multiline) {
  16996. a += 1;
  16997. }
  16998. }
  16999. return arr;
  17000. },
  17001. stringify: function(arr) {
  17002. var r,
  17003. rLen,
  17004. c,
  17005. cLen,
  17006. str = '',
  17007. val;
  17008. for (r = 0, rLen = arr.length; r < rLen; r += 1) {
  17009. cLen = arr[r].length;
  17010. for (c = 0; c < cLen; c += 1) {
  17011. if (c > 0) {
  17012. str += '\t';
  17013. }
  17014. val = arr[r][c];
  17015. if (typeof val === 'string') {
  17016. if (val.indexOf('\n') > -1) {
  17017. str += '"' + val.replace(/"/g, '""') + '"';
  17018. } else {
  17019. str += val;
  17020. }
  17021. } else if (val === null || val === void 0) {
  17022. str += '';
  17023. } else {
  17024. str += val;
  17025. }
  17026. }
  17027. str += '\n';
  17028. }
  17029. return str;
  17030. }
  17031. };
  17032. if (typeof exports !== 'undefined') {
  17033. exports.parse = SheetClip.parse;
  17034. exports.stringify = SheetClip.stringify;
  17035. } else {
  17036. global.SheetClip = SheetClip;
  17037. }
  17038. }(window));
  17039. //#
  17040. },{}],"autoResize":[function(require,module,exports){
  17041. "use strict";
  17042. function autoResize() {
  17043. var defaults = {
  17044. minHeight: 200,
  17045. maxHeight: 300,
  17046. minWidth: 100,
  17047. maxWidth: 300
  17048. },
  17049. el,
  17050. body = document.body,
  17051. text = document.createTextNode(''),
  17052. span = document.createElement('SPAN'),
  17053. observe = function(element, event, handler) {
  17054. if (window.attachEvent) {
  17055. element.attachEvent('on' + event, handler);
  17056. } else {
  17057. element.addEventListener(event, handler, false);
  17058. }
  17059. },
  17060. unObserve = function(element, event, handler) {
  17061. if (window.removeEventListener) {
  17062. element.removeEventListener(event, handler, false);
  17063. } else {
  17064. element.detachEvent('on' + event, handler);
  17065. }
  17066. },
  17067. resize = function(newChar) {
  17068. var width,
  17069. scrollHeight;
  17070. if (!newChar) {
  17071. newChar = "";
  17072. } else if (!/^[a-zA-Z \.,\\\/\|0-9]$/.test(newChar)) {
  17073. newChar = ".";
  17074. }
  17075. if (text.textContent !== void 0) {
  17076. text.textContent = el.value + newChar;
  17077. } else {
  17078. text.data = el.value + newChar;
  17079. }
  17080. span.style.fontSize = Handsontable.Dom.getComputedStyle(el).fontSize;
  17081. span.style.fontFamily = Handsontable.Dom.getComputedStyle(el).fontFamily;
  17082. span.style.whiteSpace = "pre";
  17083. body.appendChild(span);
  17084. width = span.clientWidth + 2;
  17085. body.removeChild(span);
  17086. el.style.height = defaults.minHeight + 'px';
  17087. if (defaults.minWidth > width) {
  17088. el.style.width = defaults.minWidth + 'px';
  17089. } else if (width > defaults.maxWidth) {
  17090. el.style.width = defaults.maxWidth + 'px';
  17091. } else {
  17092. el.style.width = width + 'px';
  17093. }
  17094. scrollHeight = el.scrollHeight ? el.scrollHeight - 1 : 0;
  17095. if (defaults.minHeight > scrollHeight) {
  17096. el.style.height = defaults.minHeight + 'px';
  17097. } else if (defaults.maxHeight < scrollHeight) {
  17098. el.style.height = defaults.maxHeight + 'px';
  17099. el.style.overflowY = 'visible';
  17100. } else {
  17101. el.style.height = scrollHeight + 'px';
  17102. }
  17103. },
  17104. delayedResize = function() {
  17105. window.setTimeout(resize, 0);
  17106. },
  17107. extendDefaults = function(config) {
  17108. if (config && config.minHeight) {
  17109. if (config.minHeight == 'inherit') {
  17110. defaults.minHeight = el.clientHeight;
  17111. } else {
  17112. var minHeight = parseInt(config.minHeight);
  17113. if (!isNaN(minHeight)) {
  17114. defaults.minHeight = minHeight;
  17115. }
  17116. }
  17117. }
  17118. if (config && config.maxHeight) {
  17119. if (config.maxHeight == 'inherit') {
  17120. defaults.maxHeight = el.clientHeight;
  17121. } else {
  17122. var maxHeight = parseInt(config.maxHeight);
  17123. if (!isNaN(maxHeight)) {
  17124. defaults.maxHeight = maxHeight;
  17125. }
  17126. }
  17127. }
  17128. if (config && config.minWidth) {
  17129. if (config.minWidth == 'inherit') {
  17130. defaults.minWidth = el.clientWidth;
  17131. } else {
  17132. var minWidth = parseInt(config.minWidth);
  17133. if (!isNaN(minWidth)) {
  17134. defaults.minWidth = minWidth;
  17135. }
  17136. }
  17137. }
  17138. if (config && config.maxWidth) {
  17139. if (config.maxWidth == 'inherit') {
  17140. defaults.maxWidth = el.clientWidth;
  17141. } else {
  17142. var maxWidth = parseInt(config.maxWidth);
  17143. if (!isNaN(maxWidth)) {
  17144. defaults.maxWidth = maxWidth;
  17145. }
  17146. }
  17147. }
  17148. if (!span.firstChild) {
  17149. span.className = "autoResize";
  17150. span.style.display = 'inline-block';
  17151. span.appendChild(text);
  17152. }
  17153. },
  17154. init = function(el_, config, doObserve) {
  17155. el = el_;
  17156. extendDefaults(config);
  17157. if (el.nodeName == 'TEXTAREA') {
  17158. el.style.resize = 'none';
  17159. el.style.overflowY = '';
  17160. el.style.height = defaults.minHeight + 'px';
  17161. el.style.minWidth = defaults.minWidth + 'px';
  17162. el.style.maxWidth = defaults.maxWidth + 'px';
  17163. el.style.overflowY = 'hidden';
  17164. }
  17165. if (doObserve) {
  17166. observe(el, 'change', resize);
  17167. observe(el, 'cut', delayedResize);
  17168. observe(el, 'paste', delayedResize);
  17169. observe(el, 'drop', delayedResize);
  17170. observe(el, 'keydown', delayedResize);
  17171. }
  17172. resize();
  17173. };
  17174. return {
  17175. init: function(el_, config, doObserve) {
  17176. init(el_, config, doObserve);
  17177. },
  17178. unObserve: function() {
  17179. unObserve(el, 'change', resize);
  17180. unObserve(el, 'cut', delayedResize);
  17181. unObserve(el, 'paste', delayedResize);
  17182. unObserve(el, 'drop', delayedResize);
  17183. unObserve(el, 'keydown', delayedResize);
  17184. },
  17185. resize: resize
  17186. };
  17187. }
  17188. if (typeof exports !== 'undefined') {
  17189. module.exports = autoResize;
  17190. }
  17191. //#
  17192. },{}],"copyPaste":[function(require,module,exports){
  17193. "use strict";
  17194. var instance;
  17195. function copyPaste() {
  17196. if (!instance) {
  17197. instance = new CopyPasteClass();
  17198. } else if (instance.hasBeenDestroyed()) {
  17199. instance.init();
  17200. }
  17201. instance.refCounter++;
  17202. return instance;
  17203. }
  17204. if (typeof exports !== 'undefined') {
  17205. module.exports = copyPaste;
  17206. }
  17207. function CopyPasteClass() {
  17208. this.refCounter = 0;
  17209. this.init();
  17210. }
  17211. CopyPasteClass.prototype.init = function() {
  17212. var style,
  17213. parent;
  17214. this.copyCallbacks = [];
  17215. this.cutCallbacks = [];
  17216. this.pasteCallbacks = [];
  17217. parent = document.body;
  17218. if (document.getElementById('CopyPasteDiv')) {
  17219. this.elDiv = document.getElementById('CopyPasteDiv');
  17220. this.elTextarea = this.elDiv.firstChild;
  17221. } else {
  17222. this.elDiv = document.createElement('div');
  17223. this.elDiv.id = 'CopyPasteDiv';
  17224. style = this.elDiv.style;
  17225. style.position = 'fixed';
  17226. style.top = '-10000px';
  17227. style.left = '-10000px';
  17228. parent.appendChild(this.elDiv);
  17229. this.elTextarea = document.createElement('textarea');
  17230. this.elTextarea.className = 'copyPaste';
  17231. this.elTextarea.onpaste = function(event) {
  17232. var clipboardContents,
  17233. temp;
  17234. if ('WebkitAppearance' in document.documentElement.style) {
  17235. clipboardContents = event.clipboardData.getData("Text");
  17236. if (navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1) {
  17237. temp = clipboardContents.split('\n');
  17238. temp.pop();
  17239. clipboardContents = temp.join('\n');
  17240. }
  17241. this.value = clipboardContents;
  17242. return false;
  17243. }
  17244. };
  17245. style = this.elTextarea.style;
  17246. style.width = '10000px';
  17247. style.height = '10000px';
  17248. style.overflow = 'hidden';
  17249. this.elDiv.appendChild(this.elTextarea);
  17250. if (typeof style.opacity !== 'undefined') {
  17251. style.opacity = 0;
  17252. }
  17253. }
  17254. this.onKeyDownRef = this.onKeyDown.bind(this);
  17255. document.documentElement.addEventListener('keydown', this.onKeyDownRef, false);
  17256. };
  17257. CopyPasteClass.prototype.onKeyDown = function(event) {
  17258. var _this = this,
  17259. isCtrlDown = false;
  17260. function isActiveElementEditable() {
  17261. var element = document.activeElement;
  17262. if (element.shadowRoot && element.shadowRoot.activeElement) {
  17263. element = element.shadowRoot.activeElement;
  17264. }
  17265. return ['INPUT', 'SELECT', 'TEXTAREA'].indexOf(element.nodeName) > -1 || element.contentEditable === 'true';
  17266. }
  17267. if (event.metaKey) {
  17268. isCtrlDown = true;
  17269. } else if (event.ctrlKey && navigator.userAgent.indexOf('Mac') === -1) {
  17270. isCtrlDown = true;
  17271. }
  17272. if (isCtrlDown) {
  17273. if (document.activeElement !== this.elTextarea && (this.getSelectionText() !== '' || isActiveElementEditable())) {
  17274. return;
  17275. }
  17276. this.selectNodeText(this.elTextarea);
  17277. setTimeout(function() {
  17278. if (document.activeElement !== _this.elTextarea) {
  17279. _this.selectNodeText(_this.elTextarea);
  17280. }
  17281. }, 0);
  17282. }
  17283. if (isCtrlDown && (event.keyCode === 67 || event.keyCode === 86 || event.keyCode === 88)) {
  17284. if (event.keyCode === 88) {
  17285. setTimeout(function() {
  17286. _this.triggerCut(event);
  17287. }, 0);
  17288. } else if (event.keyCode === 86) {
  17289. setTimeout(function() {
  17290. _this.triggerPaste(event);
  17291. }, 0);
  17292. }
  17293. }
  17294. };
  17295. CopyPasteClass.prototype.selectNodeText = function(element) {
  17296. if (element) {
  17297. element.select();
  17298. }
  17299. };
  17300. CopyPasteClass.prototype.getSelectionText = function() {
  17301. var text = '';
  17302. if (window.getSelection) {
  17303. text = window.getSelection().toString();
  17304. } else if (document.selection && document.selection.type !== 'Control') {
  17305. text = document.selection.createRange().text;
  17306. }
  17307. return text;
  17308. };
  17309. CopyPasteClass.prototype.copyable = function(string) {
  17310. if (typeof string !== 'string' && string.toString === void 0) {
  17311. throw new Error('copyable requires string parameter');
  17312. }
  17313. this.elTextarea.value = string;
  17314. this.selectNodeText(this.elTextarea);
  17315. };
  17316. CopyPasteClass.prototype.onCut = function(callback) {
  17317. this.cutCallbacks.push(callback);
  17318. };
  17319. CopyPasteClass.prototype.onPaste = function(callback) {
  17320. this.pasteCallbacks.push(callback);
  17321. };
  17322. CopyPasteClass.prototype.removeCallback = function(callback) {
  17323. var i,
  17324. len;
  17325. for (i = 0, len = this.copyCallbacks.length; i < len; i++) {
  17326. if (this.copyCallbacks[i] === callback) {
  17327. this.copyCallbacks.splice(i, 1);
  17328. return true;
  17329. }
  17330. }
  17331. for (i = 0, len = this.cutCallbacks.length; i < len; i++) {
  17332. if (this.cutCallbacks[i] === callback) {
  17333. this.cutCallbacks.splice(i, 1);
  17334. return true;
  17335. }
  17336. }
  17337. for (i = 0, len = this.pasteCallbacks.length; i < len; i++) {
  17338. if (this.pasteCallbacks[i] === callback) {
  17339. this.pasteCallbacks.splice(i, 1);
  17340. return true;
  17341. }
  17342. }
  17343. return false;
  17344. };
  17345. CopyPasteClass.prototype.triggerCut = function(event) {
  17346. var _this = this;
  17347. if (_this.cutCallbacks) {
  17348. setTimeout(function() {
  17349. for (var i = 0,
  17350. len = _this.cutCallbacks.length; i < len; i++) {
  17351. _this.cutCallbacks[i](event);
  17352. }
  17353. }, 50);
  17354. }
  17355. };
  17356. CopyPasteClass.prototype.triggerPaste = function(event, string) {
  17357. var _this = this;
  17358. if (_this.pasteCallbacks) {
  17359. setTimeout(function() {
  17360. var val = string || _this.elTextarea.value;
  17361. for (var i = 0,
  17362. len = _this.pasteCallbacks.length; i < len; i++) {
  17363. _this.pasteCallbacks[i](val, event);
  17364. }
  17365. }, 50);
  17366. }
  17367. };
  17368. CopyPasteClass.prototype.destroy = function() {
  17369. if (!this.hasBeenDestroyed() && --this.refCounter === 0) {
  17370. if (this.elDiv && this.elDiv.parentNode) {
  17371. this.elDiv.parentNode.removeChild(this.elDiv);
  17372. this.elDiv = null;
  17373. this.elTextarea = null;
  17374. }
  17375. document.documentElement.removeEventListener('keydown', this.onKeyDownRef);
  17376. }
  17377. };
  17378. CopyPasteClass.prototype.hasBeenDestroyed = function() {
  17379. return !this.refCounter;
  17380. };
  17381. //#
  17382. },{}],"jsonpatch":[function(require,module,exports){
  17383. "use strict";
  17384. var jsonpatch;
  17385. (function(jsonpatch) {
  17386. var objOps = {
  17387. add: function(obj, key) {
  17388. obj[key] = this.value;
  17389. return true;
  17390. },
  17391. remove: function(obj, key) {
  17392. delete obj[key];
  17393. return true;
  17394. },
  17395. replace: function(obj, key) {
  17396. obj[key] = this.value;
  17397. return true;
  17398. },
  17399. move: function(obj, key, tree) {
  17400. var temp = {
  17401. op: "_get",
  17402. path: this.from
  17403. };
  17404. apply(tree, [temp]);
  17405. apply(tree, [{
  17406. op: "remove",
  17407. path: this.from
  17408. }]);
  17409. apply(tree, [{
  17410. op: "add",
  17411. path: this.path,
  17412. value: temp.value
  17413. }]);
  17414. return true;
  17415. },
  17416. copy: function(obj, key, tree) {
  17417. var temp = {
  17418. op: "_get",
  17419. path: this.from
  17420. };
  17421. apply(tree, [temp]);
  17422. apply(tree, [{
  17423. op: "add",
  17424. path: this.path,
  17425. value: temp.value
  17426. }]);
  17427. return true;
  17428. },
  17429. test: function(obj, key) {
  17430. return (JSON.stringify(obj[key]) === JSON.stringify(this.value));
  17431. },
  17432. _get: function(obj, key) {
  17433. this.value = obj[key];
  17434. }
  17435. };
  17436. var arrOps = {
  17437. add: function(arr, i) {
  17438. arr.splice(i, 0, this.value);
  17439. return true;
  17440. },
  17441. remove: function(arr, i) {
  17442. arr.splice(i, 1);
  17443. return true;
  17444. },
  17445. replace: function(arr, i) {
  17446. arr[i] = this.value;
  17447. return true;
  17448. },
  17449. move: objOps.move,
  17450. copy: objOps.copy,
  17451. test: objOps.test,
  17452. _get: objOps._get
  17453. };
  17454. var observeOps = {
  17455. add: function(patches, path) {
  17456. var patch = {
  17457. op: "add",
  17458. path: path + escapePathComponent(this.name),
  17459. value: this.object[this.name]
  17460. };
  17461. patches.push(patch);
  17462. },
  17463. 'delete': function(patches, path) {
  17464. var patch = {
  17465. op: "remove",
  17466. path: path + escapePathComponent(this.name)
  17467. };
  17468. patches.push(patch);
  17469. },
  17470. update: function(patches, path) {
  17471. var patch = {
  17472. op: "replace",
  17473. path: path + escapePathComponent(this.name),
  17474. value: this.object[this.name]
  17475. };
  17476. patches.push(patch);
  17477. }
  17478. };
  17479. function escapePathComponent(str) {
  17480. if (str.indexOf('/') === -1 && str.indexOf('~') === -1) {
  17481. return str;
  17482. }
  17483. return str.replace(/~/g, '~0').replace(/\//g, '~1');
  17484. }
  17485. function _getPathRecursive(root, obj) {
  17486. var found;
  17487. for (var key in root) {
  17488. if (root.hasOwnProperty(key)) {
  17489. if (root[key] === obj) {
  17490. return escapePathComponent(key) + '/';
  17491. } else if (typeof root[key] === 'object') {
  17492. found = _getPathRecursive(root[key], obj);
  17493. if (found != '') {
  17494. return escapePathComponent(key) + '/' + found;
  17495. }
  17496. }
  17497. }
  17498. }
  17499. return '';
  17500. }
  17501. function getPath(root, obj) {
  17502. if (root === obj) {
  17503. return '/';
  17504. }
  17505. var path = _getPathRecursive(root, obj);
  17506. if (path === '') {
  17507. throw new Error("Object not found in root");
  17508. }
  17509. return '/' + path;
  17510. }
  17511. var beforeDict = [];
  17512. jsonpatch.intervals;
  17513. var Mirror = (function() {
  17514. function Mirror(obj) {
  17515. this.observers = [];
  17516. this.obj = obj;
  17517. }
  17518. return Mirror;
  17519. })();
  17520. var ObserverInfo = (function() {
  17521. function ObserverInfo(callback, observer) {
  17522. this.callback = callback;
  17523. this.observer = observer;
  17524. }
  17525. return ObserverInfo;
  17526. })();
  17527. function getMirror(obj) {
  17528. for (var i = 0,
  17529. ilen = beforeDict.length; i < ilen; i++) {
  17530. if (beforeDict[i].obj === obj) {
  17531. return beforeDict[i];
  17532. }
  17533. }
  17534. }
  17535. function getObserverFromMirror(mirror, callback) {
  17536. for (var j = 0,
  17537. jlen = mirror.observers.length; j < jlen; j++) {
  17538. if (mirror.observers[j].callback === callback) {
  17539. return mirror.observers[j].observer;
  17540. }
  17541. }
  17542. }
  17543. function removeObserverFromMirror(mirror, observer) {
  17544. for (var j = 0,
  17545. jlen = mirror.observers.length; j < jlen; j++) {
  17546. if (mirror.observers[j].observer === observer) {
  17547. mirror.observers.splice(j, 1);
  17548. return;
  17549. }
  17550. }
  17551. }
  17552. function unobserve(root, observer) {
  17553. generate(observer);
  17554. if (Object.observe) {
  17555. _unobserve(observer, root);
  17556. } else {
  17557. clearTimeout(observer.next);
  17558. }
  17559. var mirror = getMirror(root);
  17560. removeObserverFromMirror(mirror, observer);
  17561. }
  17562. jsonpatch.unobserve = unobserve;
  17563. function observe(obj, callback) {
  17564. var patches = [];
  17565. var root = obj;
  17566. var observer;
  17567. var mirror = getMirror(obj);
  17568. if (!mirror) {
  17569. mirror = new Mirror(obj);
  17570. beforeDict.push(mirror);
  17571. } else {
  17572. observer = getObserverFromMirror(mirror, callback);
  17573. }
  17574. if (observer) {
  17575. return observer;
  17576. }
  17577. if (Object.observe) {
  17578. observer = function(arr) {
  17579. _unobserve(observer, obj);
  17580. _observe(observer, obj);
  17581. var a = 0,
  17582. alen = arr.length;
  17583. while (a < alen) {
  17584. if (!(arr[a].name === 'length' && _isArray(arr[a].object)) && !(arr[a].name === '__Jasmine_been_here_before__')) {
  17585. var type = arr[a].type;
  17586. switch (type) {
  17587. case 'new':
  17588. type = 'add';
  17589. break;
  17590. case 'deleted':
  17591. type = 'delete';
  17592. break;
  17593. case 'updated':
  17594. type = 'update';
  17595. break;
  17596. }
  17597. observeOps[type].call(arr[a], patches, getPath(root, arr[a].object));
  17598. }
  17599. a++;
  17600. }
  17601. if (patches) {
  17602. if (callback) {
  17603. callback(patches);
  17604. }
  17605. }
  17606. observer.patches = patches;
  17607. patches = [];
  17608. };
  17609. } else {
  17610. observer = {};
  17611. mirror.value = JSON.parse(JSON.stringify(obj));
  17612. if (callback) {
  17613. observer.callback = callback;
  17614. observer.next = null;
  17615. var intervals = this.intervals || [100, 1000, 10000, 60000];
  17616. var currentInterval = 0;
  17617. var dirtyCheck = function() {
  17618. generate(observer);
  17619. };
  17620. var fastCheck = function() {
  17621. clearTimeout(observer.next);
  17622. observer.next = setTimeout(function() {
  17623. dirtyCheck();
  17624. currentInterval = 0;
  17625. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  17626. }, 0);
  17627. };
  17628. var slowCheck = function() {
  17629. dirtyCheck();
  17630. if (currentInterval == intervals.length) {
  17631. currentInterval = intervals.length - 1;
  17632. }
  17633. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  17634. };
  17635. if (typeof window !== 'undefined') {
  17636. if (window.addEventListener) {
  17637. window.addEventListener('mousedown', fastCheck);
  17638. window.addEventListener('mouseup', fastCheck);
  17639. window.addEventListener('keydown', fastCheck);
  17640. } else {
  17641. window.attachEvent('onmousedown', fastCheck);
  17642. window.attachEvent('onmouseup', fastCheck);
  17643. window.attachEvent('onkeydown', fastCheck);
  17644. }
  17645. }
  17646. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  17647. }
  17648. }
  17649. observer.patches = patches;
  17650. observer.object = obj;
  17651. mirror.observers.push(new ObserverInfo(callback, observer));
  17652. return _observe(observer, obj);
  17653. }
  17654. jsonpatch.observe = observe;
  17655. function _observe(observer, obj) {
  17656. if (Object.observe) {
  17657. Object.observe(obj, observer);
  17658. for (var key in obj) {
  17659. if (obj.hasOwnProperty(key)) {
  17660. var v = obj[key];
  17661. if (v && typeof(v) === "object") {
  17662. _observe(observer, v);
  17663. }
  17664. }
  17665. }
  17666. }
  17667. return observer;
  17668. }
  17669. function _unobserve(observer, obj) {
  17670. if (Object.observe) {
  17671. Object.unobserve(obj, observer);
  17672. for (var key in obj) {
  17673. if (obj.hasOwnProperty(key)) {
  17674. var v = obj[key];
  17675. if (v && typeof(v) === "object") {
  17676. _unobserve(observer, v);
  17677. }
  17678. }
  17679. }
  17680. }
  17681. return observer;
  17682. }
  17683. function generate(observer) {
  17684. if (Object.observe) {
  17685. Object.deliverChangeRecords(observer);
  17686. } else {
  17687. var mirror;
  17688. for (var i = 0,
  17689. ilen = beforeDict.length; i < ilen; i++) {
  17690. if (beforeDict[i].obj === observer.object) {
  17691. mirror = beforeDict[i];
  17692. break;
  17693. }
  17694. }
  17695. _generate(mirror.value, observer.object, observer.patches, "");
  17696. }
  17697. var temp = observer.patches;
  17698. if (temp.length > 0) {
  17699. observer.patches = [];
  17700. if (observer.callback) {
  17701. observer.callback(temp);
  17702. }
  17703. }
  17704. return temp;
  17705. }
  17706. jsonpatch.generate = generate;
  17707. var _objectKeys;
  17708. if (Object.keys) {
  17709. _objectKeys = Object.keys;
  17710. } else {
  17711. _objectKeys = function(obj) {
  17712. var keys = [];
  17713. for (var o in obj) {
  17714. if (obj.hasOwnProperty(o)) {
  17715. keys.push(o);
  17716. }
  17717. }
  17718. return keys;
  17719. };
  17720. }
  17721. function _generate(mirror, obj, patches, path) {
  17722. var newKeys = _objectKeys(obj);
  17723. var oldKeys = _objectKeys(mirror);
  17724. var changed = false;
  17725. var deleted = false;
  17726. for (var t = oldKeys.length - 1; t >= 0; t--) {
  17727. var key = oldKeys[t];
  17728. var oldVal = mirror[key];
  17729. if (obj.hasOwnProperty(key)) {
  17730. var newVal = obj[key];
  17731. if (oldVal instanceof Object) {
  17732. _generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key));
  17733. } else {
  17734. if (oldVal != newVal) {
  17735. changed = true;
  17736. patches.push({
  17737. op: "replace",
  17738. path: path + "/" + escapePathComponent(key),
  17739. value: newVal
  17740. });
  17741. mirror[key] = newVal;
  17742. }
  17743. }
  17744. } else {
  17745. patches.push({
  17746. op: "remove",
  17747. path: path + "/" + escapePathComponent(key)
  17748. });
  17749. delete mirror[key];
  17750. deleted = true;
  17751. }
  17752. }
  17753. if (!deleted && newKeys.length == oldKeys.length) {
  17754. return;
  17755. }
  17756. for (var t = 0; t < newKeys.length; t++) {
  17757. var key = newKeys[t];
  17758. if (!mirror.hasOwnProperty(key)) {
  17759. patches.push({
  17760. op: "add",
  17761. path: path + "/" + escapePathComponent(key),
  17762. value: obj[key]
  17763. });
  17764. mirror[key] = JSON.parse(JSON.stringify(obj[key]));
  17765. }
  17766. }
  17767. }
  17768. var _isArray;
  17769. if (Array.isArray) {
  17770. _isArray = Array.isArray;
  17771. } else {
  17772. _isArray = function(obj) {
  17773. return obj.push && typeof obj.length === 'number';
  17774. };
  17775. }
  17776. function apply(tree, patches) {
  17777. var result = false,
  17778. p = 0,
  17779. plen = patches.length,
  17780. patch;
  17781. while (p < plen) {
  17782. patch = patches[p];
  17783. var keys = patch.path.split('/');
  17784. var obj = tree;
  17785. var t = 1;
  17786. var len = keys.length;
  17787. while (true) {
  17788. if (_isArray(obj)) {
  17789. var index = parseInt(keys[t], 10);
  17790. t++;
  17791. if (t >= len) {
  17792. result = arrOps[patch.op].call(patch, obj, index, tree);
  17793. break;
  17794. }
  17795. obj = obj[index];
  17796. } else {
  17797. var key = keys[t];
  17798. if (key.indexOf('~') != -1) {
  17799. key = key.replace(/~1/g, '/').replace(/~0/g, '~');
  17800. }
  17801. t++;
  17802. if (t >= len) {
  17803. result = objOps[patch.op].call(patch, obj, key, tree);
  17804. break;
  17805. }
  17806. obj = obj[key];
  17807. }
  17808. }
  17809. p++;
  17810. }
  17811. return result;
  17812. }
  17813. jsonpatch.apply = apply;
  17814. })(jsonpatch || (jsonpatch = {}));
  17815. if (typeof exports !== "undefined") {
  17816. exports.apply = jsonpatch.apply;
  17817. exports.observe = jsonpatch.observe;
  17818. exports.unobserve = jsonpatch.unobserve;
  17819. exports.generate = jsonpatch.generate;
  17820. }
  17821. //#
  17822. },{}],"moment":[function(require,module,exports){
  17823. //! moment.js
  17824. //! version : 2.10.3
  17825. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  17826. //! license : MIT
  17827. //! momentjs.com
  17828. (function (global, factory) {
  17829. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  17830. typeof define === 'function' && define.amd ? define(factory) :
  17831. global.moment = factory()
  17832. }(this, function () { 'use strict';
  17833. var hookCallback;
  17834. function utils_hooks__hooks () {
  17835. return hookCallback.apply(null, arguments);
  17836. }
  17837. // This is done to register the method called with moment()
  17838. // without creating circular dependencies.
  17839. function setHookCallback (callback) {
  17840. hookCallback = callback;
  17841. }
  17842. function isArray(input) {
  17843. return Object.prototype.toString.call(input) === '[object Array]';
  17844. }
  17845. function isDate(input) {
  17846. return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
  17847. }
  17848. function map(arr, fn) {
  17849. var res = [], i;
  17850. for (i = 0; i < arr.length; ++i) {
  17851. res.push(fn(arr[i], i));
  17852. }
  17853. return res;
  17854. }
  17855. function hasOwnProp(a, b) {
  17856. return Object.prototype.hasOwnProperty.call(a, b);
  17857. }
  17858. function extend(a, b) {
  17859. for (var i in b) {
  17860. if (hasOwnProp(b, i)) {
  17861. a[i] = b[i];
  17862. }
  17863. }
  17864. if (hasOwnProp(b, 'toString')) {
  17865. a.toString = b.toString;
  17866. }
  17867. if (hasOwnProp(b, 'valueOf')) {
  17868. a.valueOf = b.valueOf;
  17869. }
  17870. return a;
  17871. }
  17872. function create_utc__createUTC (input, format, locale, strict) {
  17873. return createLocalOrUTC(input, format, locale, strict, true).utc();
  17874. }
  17875. function defaultParsingFlags() {
  17876. // We need to deep clone this object.
  17877. return {
  17878. empty : false,
  17879. unusedTokens : [],
  17880. unusedInput : [],
  17881. overflow : -2,
  17882. charsLeftOver : 0,
  17883. nullInput : false,
  17884. invalidMonth : null,
  17885. invalidFormat : false,
  17886. userInvalidated : false,
  17887. iso : false
  17888. };
  17889. }
  17890. function getParsingFlags(m) {
  17891. if (m._pf == null) {
  17892. m._pf = defaultParsingFlags();
  17893. }
  17894. return m._pf;
  17895. }
  17896. function valid__isValid(m) {
  17897. if (m._isValid == null) {
  17898. var flags = getParsingFlags(m);
  17899. m._isValid = !isNaN(m._d.getTime()) &&
  17900. flags.overflow < 0 &&
  17901. !flags.empty &&
  17902. !flags.invalidMonth &&
  17903. !flags.nullInput &&
  17904. !flags.invalidFormat &&
  17905. !flags.userInvalidated;
  17906. if (m._strict) {
  17907. m._isValid = m._isValid &&
  17908. flags.charsLeftOver === 0 &&
  17909. flags.unusedTokens.length === 0 &&
  17910. flags.bigHour === undefined;
  17911. }
  17912. }
  17913. return m._isValid;
  17914. }
  17915. function valid__createInvalid (flags) {
  17916. var m = create_utc__createUTC(NaN);
  17917. if (flags != null) {
  17918. extend(getParsingFlags(m), flags);
  17919. }
  17920. else {
  17921. getParsingFlags(m).userInvalidated = true;
  17922. }
  17923. return m;
  17924. }
  17925. var momentProperties = utils_hooks__hooks.momentProperties = [];
  17926. function copyConfig(to, from) {
  17927. var i, prop, val;
  17928. if (typeof from._isAMomentObject !== 'undefined') {
  17929. to._isAMomentObject = from._isAMomentObject;
  17930. }
  17931. if (typeof from._i !== 'undefined') {
  17932. to._i = from._i;
  17933. }
  17934. if (typeof from._f !== 'undefined') {
  17935. to._f = from._f;
  17936. }
  17937. if (typeof from._l !== 'undefined') {
  17938. to._l = from._l;
  17939. }
  17940. if (typeof from._strict !== 'undefined') {
  17941. to._strict = from._strict;
  17942. }
  17943. if (typeof from._tzm !== 'undefined') {
  17944. to._tzm = from._tzm;
  17945. }
  17946. if (typeof from._isUTC !== 'undefined') {
  17947. to._isUTC = from._isUTC;
  17948. }
  17949. if (typeof from._offset !== 'undefined') {
  17950. to._offset = from._offset;
  17951. }
  17952. if (typeof from._pf !== 'undefined') {
  17953. to._pf = getParsingFlags(from);
  17954. }
  17955. if (typeof from._locale !== 'undefined') {
  17956. to._locale = from._locale;
  17957. }
  17958. if (momentProperties.length > 0) {
  17959. for (i in momentProperties) {
  17960. prop = momentProperties[i];
  17961. val = from[prop];
  17962. if (typeof val !== 'undefined') {
  17963. to[prop] = val;
  17964. }
  17965. }
  17966. }
  17967. return to;
  17968. }
  17969. var updateInProgress = false;
  17970. // Moment prototype object
  17971. function Moment(config) {
  17972. copyConfig(this, config);
  17973. this._d = new Date(+config._d);
  17974. // Prevent infinite loop in case updateOffset creates new moment
  17975. // objects.
  17976. if (updateInProgress === false) {
  17977. updateInProgress = true;
  17978. utils_hooks__hooks.updateOffset(this);
  17979. updateInProgress = false;
  17980. }
  17981. }
  17982. function isMoment (obj) {
  17983. return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
  17984. }
  17985. function toInt(argumentForCoercion) {
  17986. var coercedNumber = +argumentForCoercion,
  17987. value = 0;
  17988. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  17989. if (coercedNumber >= 0) {
  17990. value = Math.floor(coercedNumber);
  17991. } else {
  17992. value = Math.ceil(coercedNumber);
  17993. }
  17994. }
  17995. return value;
  17996. }
  17997. function compareArrays(array1, array2, dontConvert) {
  17998. var len = Math.min(array1.length, array2.length),
  17999. lengthDiff = Math.abs(array1.length - array2.length),
  18000. diffs = 0,
  18001. i;
  18002. for (i = 0; i < len; i++) {
  18003. if ((dontConvert && array1[i] !== array2[i]) ||
  18004. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
  18005. diffs++;
  18006. }
  18007. }
  18008. return diffs + lengthDiff;
  18009. }
  18010. function Locale() {
  18011. }
  18012. var locales = {};
  18013. var globalLocale;
  18014. function normalizeLocale(key) {
  18015. return key ? key.toLowerCase().replace('_', '-') : key;
  18016. }
  18017. // pick the locale from the array
  18018. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  18019. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  18020. function chooseLocale(names) {
  18021. var i = 0, j, next, locale, split;
  18022. while (i < names.length) {
  18023. split = normalizeLocale(names[i]).split('-');
  18024. j = split.length;
  18025. next = normalizeLocale(names[i + 1]);
  18026. next = next ? next.split('-') : null;
  18027. while (j > 0) {
  18028. locale = loadLocale(split.slice(0, j).join('-'));
  18029. if (locale) {
  18030. return locale;
  18031. }
  18032. if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
  18033. //the next array item is better than a shallower substring of this one
  18034. break;
  18035. }
  18036. j--;
  18037. }
  18038. i++;
  18039. }
  18040. return null;
  18041. }
  18042. function loadLocale(name) {
  18043. var oldLocale = null;
  18044. // TODO: Find a better way to register and load all the locales in Node
  18045. if (!locales[name] && typeof module !== 'undefined' &&
  18046. module && module.exports) {
  18047. try {
  18048. oldLocale = globalLocale._abbr;
  18049. require('./locale/' + name);
  18050. // because defineLocale currently also sets the global locale, we
  18051. // want to undo that for lazy loaded locales
  18052. locale_locales__getSetGlobalLocale(oldLocale);
  18053. } catch (e) { }
  18054. }
  18055. return locales[name];
  18056. }
  18057. // This function will load locale and then set the global locale. If
  18058. // no arguments are passed in, it will simply return the current global
  18059. // locale key.
  18060. function locale_locales__getSetGlobalLocale (key, values) {
  18061. var data;
  18062. if (key) {
  18063. if (typeof values === 'undefined') {
  18064. data = locale_locales__getLocale(key);
  18065. }
  18066. else {
  18067. data = defineLocale(key, values);
  18068. }
  18069. if (data) {
  18070. // moment.duration._locale = moment._locale = data;
  18071. globalLocale = data;
  18072. }
  18073. }
  18074. return globalLocale._abbr;
  18075. }
  18076. function defineLocale (name, values) {
  18077. if (values !== null) {
  18078. values.abbr = name;
  18079. if (!locales[name]) {
  18080. locales[name] = new Locale();
  18081. }
  18082. locales[name].set(values);
  18083. // backwards compat for now: also set the locale
  18084. locale_locales__getSetGlobalLocale(name);
  18085. return locales[name];
  18086. } else {
  18087. // useful for testing
  18088. delete locales[name];
  18089. return null;
  18090. }
  18091. }
  18092. // returns locale data
  18093. function locale_locales__getLocale (key) {
  18094. var locale;
  18095. if (key && key._locale && key._locale._abbr) {
  18096. key = key._locale._abbr;
  18097. }
  18098. if (!key) {
  18099. return globalLocale;
  18100. }
  18101. if (!isArray(key)) {
  18102. //short-circuit everything else
  18103. locale = loadLocale(key);
  18104. if (locale) {
  18105. return locale;
  18106. }
  18107. key = [key];
  18108. }
  18109. return chooseLocale(key);
  18110. }
  18111. var aliases = {};
  18112. function addUnitAlias (unit, shorthand) {
  18113. var lowerCase = unit.toLowerCase();
  18114. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  18115. }
  18116. function normalizeUnits(units) {
  18117. return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
  18118. }
  18119. function normalizeObjectUnits(inputObject) {
  18120. var normalizedInput = {},
  18121. normalizedProp,
  18122. prop;
  18123. for (prop in inputObject) {
  18124. if (hasOwnProp(inputObject, prop)) {
  18125. normalizedProp = normalizeUnits(prop);
  18126. if (normalizedProp) {
  18127. normalizedInput[normalizedProp] = inputObject[prop];
  18128. }
  18129. }
  18130. }
  18131. return normalizedInput;
  18132. }
  18133. function makeGetSet (unit, keepTime) {
  18134. return function (value) {
  18135. if (value != null) {
  18136. get_set__set(this, unit, value);
  18137. utils_hooks__hooks.updateOffset(this, keepTime);
  18138. return this;
  18139. } else {
  18140. return get_set__get(this, unit);
  18141. }
  18142. };
  18143. }
  18144. function get_set__get (mom, unit) {
  18145. return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
  18146. }
  18147. function get_set__set (mom, unit, value) {
  18148. return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  18149. }
  18150. // MOMENTS
  18151. function getSet (units, value) {
  18152. var unit;
  18153. if (typeof units === 'object') {
  18154. for (unit in units) {
  18155. this.set(unit, units[unit]);
  18156. }
  18157. } else {
  18158. units = normalizeUnits(units);
  18159. if (typeof this[units] === 'function') {
  18160. return this[units](value);
  18161. }
  18162. }
  18163. return this;
  18164. }
  18165. function zeroFill(number, targetLength, forceSign) {
  18166. var output = '' + Math.abs(number),
  18167. sign = number >= 0;
  18168. while (output.length < targetLength) {
  18169. output = '0' + output;
  18170. }
  18171. return (sign ? (forceSign ? '+' : '') : '-') + output;
  18172. }
  18173. 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;
  18174. var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
  18175. var formatFunctions = {};
  18176. var formatTokenFunctions = {};
  18177. // token: 'M'
  18178. // padded: ['MM', 2]
  18179. // ordinal: 'Mo'
  18180. // callback: function () { this.month() + 1 }
  18181. function addFormatToken (token, padded, ordinal, callback) {
  18182. var func = callback;
  18183. if (typeof callback === 'string') {
  18184. func = function () {
  18185. return this[callback]();
  18186. };
  18187. }
  18188. if (token) {
  18189. formatTokenFunctions[token] = func;
  18190. }
  18191. if (padded) {
  18192. formatTokenFunctions[padded[0]] = function () {
  18193. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  18194. };
  18195. }
  18196. if (ordinal) {
  18197. formatTokenFunctions[ordinal] = function () {
  18198. return this.localeData().ordinal(func.apply(this, arguments), token);
  18199. };
  18200. }
  18201. }
  18202. function removeFormattingTokens(input) {
  18203. if (input.match(/\[[\s\S]/)) {
  18204. return input.replace(/^\[|\]$/g, '');
  18205. }
  18206. return input.replace(/\\/g, '');
  18207. }
  18208. function makeFormatFunction(format) {
  18209. var array = format.match(formattingTokens), i, length;
  18210. for (i = 0, length = array.length; i < length; i++) {
  18211. if (formatTokenFunctions[array[i]]) {
  18212. array[i] = formatTokenFunctions[array[i]];
  18213. } else {
  18214. array[i] = removeFormattingTokens(array[i]);
  18215. }
  18216. }
  18217. return function (mom) {
  18218. var output = '';
  18219. for (i = 0; i < length; i++) {
  18220. output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
  18221. }
  18222. return output;
  18223. };
  18224. }
  18225. // format date using native date object
  18226. function formatMoment(m, format) {
  18227. if (!m.isValid()) {
  18228. return m.localeData().invalidDate();
  18229. }
  18230. format = expandFormat(format, m.localeData());
  18231. if (!formatFunctions[format]) {
  18232. formatFunctions[format] = makeFormatFunction(format);
  18233. }
  18234. return formatFunctions[format](m);
  18235. }
  18236. function expandFormat(format, locale) {
  18237. var i = 5;
  18238. function replaceLongDateFormatTokens(input) {
  18239. return locale.longDateFormat(input) || input;
  18240. }
  18241. localFormattingTokens.lastIndex = 0;
  18242. while (i >= 0 && localFormattingTokens.test(format)) {
  18243. format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
  18244. localFormattingTokens.lastIndex = 0;
  18245. i -= 1;
  18246. }
  18247. return format;
  18248. }
  18249. var match1 = /\d/; // 0 - 9
  18250. var match2 = /\d\d/; // 00 - 99
  18251. var match3 = /\d{3}/; // 000 - 999
  18252. var match4 = /\d{4}/; // 0000 - 9999
  18253. var match6 = /[+-]?\d{6}/; // -999999 - 999999
  18254. var match1to2 = /\d\d?/; // 0 - 99
  18255. var match1to3 = /\d{1,3}/; // 0 - 999
  18256. var match1to4 = /\d{1,4}/; // 0 - 9999
  18257. var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
  18258. var matchUnsigned = /\d+/; // 0 - inf
  18259. var matchSigned = /[+-]?\d+/; // -inf - inf
  18260. var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
  18261. var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
  18262. // any word (or two) characters or numbers including two/three word month in arabic.
  18263. var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
  18264. var regexes = {};
  18265. function addRegexToken (token, regex, strictRegex) {
  18266. regexes[token] = typeof regex === 'function' ? regex : function (isStrict) {
  18267. return (isStrict && strictRegex) ? strictRegex : regex;
  18268. };
  18269. }
  18270. function getParseRegexForToken (token, config) {
  18271. if (!hasOwnProp(regexes, token)) {
  18272. return new RegExp(unescapeFormat(token));
  18273. }
  18274. return regexes[token](config._strict, config._locale);
  18275. }
  18276. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  18277. function unescapeFormat(s) {
  18278. return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
  18279. return p1 || p2 || p3 || p4;
  18280. }).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  18281. }
  18282. var tokens = {};
  18283. function addParseToken (token, callback) {
  18284. var i, func = callback;
  18285. if (typeof token === 'string') {
  18286. token = [token];
  18287. }
  18288. if (typeof callback === 'number') {
  18289. func = function (input, array) {
  18290. array[callback] = toInt(input);
  18291. };
  18292. }
  18293. for (i = 0; i < token.length; i++) {
  18294. tokens[token[i]] = func;
  18295. }
  18296. }
  18297. function addWeekParseToken (token, callback) {
  18298. addParseToken(token, function (input, array, config, token) {
  18299. config._w = config._w || {};
  18300. callback(input, config._w, config, token);
  18301. });
  18302. }
  18303. function addTimeToArrayFromToken(token, input, config) {
  18304. if (input != null && hasOwnProp(tokens, token)) {
  18305. tokens[token](input, config._a, config, token);
  18306. }
  18307. }
  18308. var YEAR = 0;
  18309. var MONTH = 1;
  18310. var DATE = 2;
  18311. var HOUR = 3;
  18312. var MINUTE = 4;
  18313. var SECOND = 5;
  18314. var MILLISECOND = 6;
  18315. function daysInMonth(year, month) {
  18316. return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
  18317. }
  18318. // FORMATTING
  18319. addFormatToken('M', ['MM', 2], 'Mo', function () {
  18320. return this.month() + 1;
  18321. });
  18322. addFormatToken('MMM', 0, 0, function (format) {
  18323. return this.localeData().monthsShort(this, format);
  18324. });
  18325. addFormatToken('MMMM', 0, 0, function (format) {
  18326. return this.localeData().months(this, format);
  18327. });
  18328. // ALIASES
  18329. addUnitAlias('month', 'M');
  18330. // PARSING
  18331. addRegexToken('M', match1to2);
  18332. addRegexToken('MM', match1to2, match2);
  18333. addRegexToken('MMM', matchWord);
  18334. addRegexToken('MMMM', matchWord);
  18335. addParseToken(['M', 'MM'], function (input, array) {
  18336. array[MONTH] = toInt(input) - 1;
  18337. });
  18338. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  18339. var month = config._locale.monthsParse(input, token, config._strict);
  18340. // if we didn't find a month name, mark the date as invalid.
  18341. if (month != null) {
  18342. array[MONTH] = month;
  18343. } else {
  18344. getParsingFlags(config).invalidMonth = input;
  18345. }
  18346. });
  18347. // LOCALES
  18348. var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
  18349. function localeMonths (m) {
  18350. return this._months[m.month()];
  18351. }
  18352. var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
  18353. function localeMonthsShort (m) {
  18354. return this._monthsShort[m.month()];
  18355. }
  18356. function localeMonthsParse (monthName, format, strict) {
  18357. var i, mom, regex;
  18358. if (!this._monthsParse) {
  18359. this._monthsParse = [];
  18360. this._longMonthsParse = [];
  18361. this._shortMonthsParse = [];
  18362. }
  18363. for (i = 0; i < 12; i++) {
  18364. // make the regex if we don't have it already
  18365. mom = create_utc__createUTC([2000, i]);
  18366. if (strict && !this._longMonthsParse[i]) {
  18367. this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
  18368. this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
  18369. }
  18370. if (!strict && !this._monthsParse[i]) {
  18371. regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  18372. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  18373. }
  18374. // test the regex
  18375. if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
  18376. return i;
  18377. } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
  18378. return i;
  18379. } else if (!strict && this._monthsParse[i].test(monthName)) {
  18380. return i;
  18381. }
  18382. }
  18383. }
  18384. // MOMENTS
  18385. function setMonth (mom, value) {
  18386. var dayOfMonth;
  18387. // TODO: Move this out of here!
  18388. if (typeof value === 'string') {
  18389. value = mom.localeData().monthsParse(value);
  18390. // TODO: Another silent failure?
  18391. if (typeof value !== 'number') {
  18392. return mom;
  18393. }
  18394. }
  18395. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  18396. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  18397. return mom;
  18398. }
  18399. function getSetMonth (value) {
  18400. if (value != null) {
  18401. setMonth(this, value);
  18402. utils_hooks__hooks.updateOffset(this, true);
  18403. return this;
  18404. } else {
  18405. return get_set__get(this, 'Month');
  18406. }
  18407. }
  18408. function getDaysInMonth () {
  18409. return daysInMonth(this.year(), this.month());
  18410. }
  18411. function checkOverflow (m) {
  18412. var overflow;
  18413. var a = m._a;
  18414. if (a && getParsingFlags(m).overflow === -2) {
  18415. overflow =
  18416. a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
  18417. a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
  18418. a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
  18419. a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
  18420. a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
  18421. a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
  18422. -1;
  18423. if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
  18424. overflow = DATE;
  18425. }
  18426. getParsingFlags(m).overflow = overflow;
  18427. }
  18428. return m;
  18429. }
  18430. function warn(msg) {
  18431. if (utils_hooks__hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
  18432. console.warn('Deprecation warning: ' + msg);
  18433. }
  18434. }
  18435. function deprecate(msg, fn) {
  18436. var firstTime = true,
  18437. msgWithStack = msg + '\n' + (new Error()).stack;
  18438. return extend(function () {
  18439. if (firstTime) {
  18440. warn(msgWithStack);
  18441. firstTime = false;
  18442. }
  18443. return fn.apply(this, arguments);
  18444. }, fn);
  18445. }
  18446. var deprecations = {};
  18447. function deprecateSimple(name, msg) {
  18448. if (!deprecations[name]) {
  18449. warn(msg);
  18450. deprecations[name] = true;
  18451. }
  18452. }
  18453. utils_hooks__hooks.suppressDeprecationWarnings = false;
  18454. 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)?)?$/;
  18455. var isoDates = [
  18456. ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
  18457. ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
  18458. ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
  18459. ['GGGG-[W]WW', /\d{4}-W\d{2}/],
  18460. ['YYYY-DDD', /\d{4}-\d{3}/]
  18461. ];
  18462. // iso time formats and regexes
  18463. var isoTimes = [
  18464. ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
  18465. ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
  18466. ['HH:mm', /(T| )\d\d:\d\d/],
  18467. ['HH', /(T| )\d\d/]
  18468. ];
  18469. var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
  18470. // date from iso format
  18471. function configFromISO(config) {
  18472. var i, l,
  18473. string = config._i,
  18474. match = from_string__isoRegex.exec(string);
  18475. if (match) {
  18476. getParsingFlags(config).iso = true;
  18477. for (i = 0, l = isoDates.length; i < l; i++) {
  18478. if (isoDates[i][1].exec(string)) {
  18479. // match[5] should be 'T' or undefined
  18480. config._f = isoDates[i][0] + (match[6] || ' ');
  18481. break;
  18482. }
  18483. }
  18484. for (i = 0, l = isoTimes.length; i < l; i++) {
  18485. if (isoTimes[i][1].exec(string)) {
  18486. config._f += isoTimes[i][0];
  18487. break;
  18488. }
  18489. }
  18490. if (string.match(matchOffset)) {
  18491. config._f += 'Z';
  18492. }
  18493. configFromStringAndFormat(config);
  18494. } else {
  18495. config._isValid = false;
  18496. }
  18497. }
  18498. // date from iso format or fallback
  18499. function configFromString(config) {
  18500. var matched = aspNetJsonRegex.exec(config._i);
  18501. if (matched !== null) {
  18502. config._d = new Date(+matched[1]);
  18503. return;
  18504. }
  18505. configFromISO(config);
  18506. if (config._isValid === false) {
  18507. delete config._isValid;
  18508. utils_hooks__hooks.createFromInputFallback(config);
  18509. }
  18510. }
  18511. utils_hooks__hooks.createFromInputFallback = deprecate(
  18512. 'moment construction falls back to js Date. This is ' +
  18513. 'discouraged and will be removed in upcoming major ' +
  18514. 'release. Please refer to ' +
  18515. 'https://github.com/moment/moment/issues/1407 for more info.',
  18516. function (config) {
  18517. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  18518. }
  18519. );
  18520. function createDate (y, m, d, h, M, s, ms) {
  18521. //can't just apply() to create a date:
  18522. //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
  18523. var date = new Date(y, m, d, h, M, s, ms);
  18524. //the date constructor doesn't accept years < 1970
  18525. if (y < 1970) {
  18526. date.setFullYear(y);
  18527. }
  18528. return date;
  18529. }
  18530. function createUTCDate (y) {
  18531. var date = new Date(Date.UTC.apply(null, arguments));
  18532. if (y < 1970) {
  18533. date.setUTCFullYear(y);
  18534. }
  18535. return date;
  18536. }
  18537. addFormatToken(0, ['YY', 2], 0, function () {
  18538. return this.year() % 100;
  18539. });
  18540. addFormatToken(0, ['YYYY', 4], 0, 'year');
  18541. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  18542. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  18543. // ALIASES
  18544. addUnitAlias('year', 'y');
  18545. // PARSING
  18546. addRegexToken('Y', matchSigned);
  18547. addRegexToken('YY', match1to2, match2);
  18548. addRegexToken('YYYY', match1to4, match4);
  18549. addRegexToken('YYYYY', match1to6, match6);
  18550. addRegexToken('YYYYYY', match1to6, match6);
  18551. addParseToken(['YYYY', 'YYYYY', 'YYYYYY'], YEAR);
  18552. addParseToken('YY', function (input, array) {
  18553. array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
  18554. });
  18555. // HELPERS
  18556. function daysInYear(year) {
  18557. return isLeapYear(year) ? 366 : 365;
  18558. }
  18559. function isLeapYear(year) {
  18560. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  18561. }
  18562. // HOOKS
  18563. utils_hooks__hooks.parseTwoDigitYear = function (input) {
  18564. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  18565. };
  18566. // MOMENTS
  18567. var getSetYear = makeGetSet('FullYear', false);
  18568. function getIsLeapYear () {
  18569. return isLeapYear(this.year());
  18570. }
  18571. addFormatToken('w', ['ww', 2], 'wo', 'week');
  18572. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  18573. // ALIASES
  18574. addUnitAlias('week', 'w');
  18575. addUnitAlias('isoWeek', 'W');
  18576. // PARSING
  18577. addRegexToken('w', match1to2);
  18578. addRegexToken('ww', match1to2, match2);
  18579. addRegexToken('W', match1to2);
  18580. addRegexToken('WW', match1to2, match2);
  18581. addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
  18582. week[token.substr(0, 1)] = toInt(input);
  18583. });
  18584. // HELPERS
  18585. // firstDayOfWeek 0 = sun, 6 = sat
  18586. // the day of the week that starts the week
  18587. // (usually sunday or monday)
  18588. // firstDayOfWeekOfYear 0 = sun, 6 = sat
  18589. // the first week is the week that contains the first
  18590. // of this day of the week
  18591. // (eg. ISO weeks use thursday (4))
  18592. function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
  18593. var end = firstDayOfWeekOfYear - firstDayOfWeek,
  18594. daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
  18595. adjustedMoment;
  18596. if (daysToDayOfWeek > end) {
  18597. daysToDayOfWeek -= 7;
  18598. }
  18599. if (daysToDayOfWeek < end - 7) {
  18600. daysToDayOfWeek += 7;
  18601. }
  18602. adjustedMoment = local__createLocal(mom).add(daysToDayOfWeek, 'd');
  18603. return {
  18604. week: Math.ceil(adjustedMoment.dayOfYear() / 7),
  18605. year: adjustedMoment.year()
  18606. };
  18607. }
  18608. // LOCALES
  18609. function localeWeek (mom) {
  18610. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  18611. }
  18612. var defaultLocaleWeek = {
  18613. dow : 0, // Sunday is the first day of the week.
  18614. doy : 6 // The week that contains Jan 1st is the first week of the year.
  18615. };
  18616. function localeFirstDayOfWeek () {
  18617. return this._week.dow;
  18618. }
  18619. function localeFirstDayOfYear () {
  18620. return this._week.doy;
  18621. }
  18622. // MOMENTS
  18623. function getSetWeek (input) {
  18624. var week = this.localeData().week(this);
  18625. return input == null ? week : this.add((input - week) * 7, 'd');
  18626. }
  18627. function getSetISOWeek (input) {
  18628. var week = weekOfYear(this, 1, 4).week;
  18629. return input == null ? week : this.add((input - week) * 7, 'd');
  18630. }
  18631. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  18632. // ALIASES
  18633. addUnitAlias('dayOfYear', 'DDD');
  18634. // PARSING
  18635. addRegexToken('DDD', match1to3);
  18636. addRegexToken('DDDD', match3);
  18637. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  18638. config._dayOfYear = toInt(input);
  18639. });
  18640. // HELPERS
  18641. //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  18642. function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
  18643. var d = createUTCDate(year, 0, 1).getUTCDay();
  18644. var daysToAdd;
  18645. var dayOfYear;
  18646. d = d === 0 ? 7 : d;
  18647. weekday = weekday != null ? weekday : firstDayOfWeek;
  18648. daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0);
  18649. dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1;
  18650. return {
  18651. year : dayOfYear > 0 ? year : year - 1,
  18652. dayOfYear : dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
  18653. };
  18654. }
  18655. // MOMENTS
  18656. function getSetDayOfYear (input) {
  18657. var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
  18658. return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
  18659. }
  18660. // Pick the first defined of two or three arguments.
  18661. function defaults(a, b, c) {
  18662. if (a != null) {
  18663. return a;
  18664. }
  18665. if (b != null) {
  18666. return b;
  18667. }
  18668. return c;
  18669. }
  18670. function currentDateArray(config) {
  18671. var now = new Date();
  18672. if (config._useUTC) {
  18673. return [now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()];
  18674. }
  18675. return [now.getFullYear(), now.getMonth(), now.getDate()];
  18676. }
  18677. // convert an array to a date.
  18678. // the array should mirror the parameters below
  18679. // note: all values past the year are optional and will default to the lowest possible value.
  18680. // [year, month, day , hour, minute, second, millisecond]
  18681. function configFromArray (config) {
  18682. var i, date, input = [], currentDate, yearToUse;
  18683. if (config._d) {
  18684. return;
  18685. }
  18686. currentDate = currentDateArray(config);
  18687. //compute day of the year from weeks and weekdays
  18688. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  18689. dayOfYearFromWeekInfo(config);
  18690. }
  18691. //if the day of the year is set, figure out what it is
  18692. if (config._dayOfYear) {
  18693. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  18694. if (config._dayOfYear > daysInYear(yearToUse)) {
  18695. getParsingFlags(config)._overflowDayOfYear = true;
  18696. }
  18697. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  18698. config._a[MONTH] = date.getUTCMonth();
  18699. config._a[DATE] = date.getUTCDate();
  18700. }
  18701. // Default to current date.
  18702. // * if no year, month, day of month are given, default to today
  18703. // * if day of month is given, default month and year
  18704. // * if month is given, default only year
  18705. // * if year is given, don't default anything
  18706. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  18707. config._a[i] = input[i] = currentDate[i];
  18708. }
  18709. // Zero out whatever was not defaulted, including time
  18710. for (; i < 7; i++) {
  18711. config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
  18712. }
  18713. // Check for 24:00:00.000
  18714. if (config._a[HOUR] === 24 &&
  18715. config._a[MINUTE] === 0 &&
  18716. config._a[SECOND] === 0 &&
  18717. config._a[MILLISECOND] === 0) {
  18718. config._nextDay = true;
  18719. config._a[HOUR] = 0;
  18720. }
  18721. config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
  18722. // Apply timezone offset from input. The actual utcOffset can be changed
  18723. // with parseZone.
  18724. if (config._tzm != null) {
  18725. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  18726. }
  18727. if (config._nextDay) {
  18728. config._a[HOUR] = 24;
  18729. }
  18730. }
  18731. function dayOfYearFromWeekInfo(config) {
  18732. var w, weekYear, week, weekday, dow, doy, temp;
  18733. w = config._w;
  18734. if (w.GG != null || w.W != null || w.E != null) {
  18735. dow = 1;
  18736. doy = 4;
  18737. // TODO: We need to take the current isoWeekYear, but that depends on
  18738. // how we interpret now (local, utc, fixed offset). So create
  18739. // a now version of current config (take local/utc/offset flags, and
  18740. // create now).
  18741. weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(local__createLocal(), 1, 4).year);
  18742. week = defaults(w.W, 1);
  18743. weekday = defaults(w.E, 1);
  18744. } else {
  18745. dow = config._locale._week.dow;
  18746. doy = config._locale._week.doy;
  18747. weekYear = defaults(w.gg, config._a[YEAR], weekOfYear(local__createLocal(), dow, doy).year);
  18748. week = defaults(w.w, 1);
  18749. if (w.d != null) {
  18750. // weekday -- low day numbers are considered next week
  18751. weekday = w.d;
  18752. if (weekday < dow) {
  18753. ++week;
  18754. }
  18755. } else if (w.e != null) {
  18756. // local weekday -- counting starts from begining of week
  18757. weekday = w.e + dow;
  18758. } else {
  18759. // default to begining of week
  18760. weekday = dow;
  18761. }
  18762. }
  18763. temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
  18764. config._a[YEAR] = temp.year;
  18765. config._dayOfYear = temp.dayOfYear;
  18766. }
  18767. utils_hooks__hooks.ISO_8601 = function () {};
  18768. // date from string and format string
  18769. function configFromStringAndFormat(config) {
  18770. // TODO: Move this to another part of the creation flow to prevent circular deps
  18771. if (config._f === utils_hooks__hooks.ISO_8601) {
  18772. configFromISO(config);
  18773. return;
  18774. }
  18775. config._a = [];
  18776. getParsingFlags(config).empty = true;
  18777. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  18778. var string = '' + config._i,
  18779. i, parsedInput, tokens, token, skipped,
  18780. stringLength = string.length,
  18781. totalParsedInputLength = 0;
  18782. tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
  18783. for (i = 0; i < tokens.length; i++) {
  18784. token = tokens[i];
  18785. parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
  18786. if (parsedInput) {
  18787. skipped = string.substr(0, string.indexOf(parsedInput));
  18788. if (skipped.length > 0) {
  18789. getParsingFlags(config).unusedInput.push(skipped);
  18790. }
  18791. string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
  18792. totalParsedInputLength += parsedInput.length;
  18793. }
  18794. // don't parse if it's not a known token
  18795. if (formatTokenFunctions[token]) {
  18796. if (parsedInput) {
  18797. getParsingFlags(config).empty = false;
  18798. }
  18799. else {
  18800. getParsingFlags(config).unusedTokens.push(token);
  18801. }
  18802. addTimeToArrayFromToken(token, parsedInput, config);
  18803. }
  18804. else if (config._strict && !parsedInput) {
  18805. getParsingFlags(config).unusedTokens.push(token);
  18806. }
  18807. }
  18808. // add remaining unparsed input length to the string
  18809. getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
  18810. if (string.length > 0) {
  18811. getParsingFlags(config).unusedInput.push(string);
  18812. }
  18813. // clear _12h flag if hour is <= 12
  18814. if (getParsingFlags(config).bigHour === true &&
  18815. config._a[HOUR] <= 12 &&
  18816. config._a[HOUR] > 0) {
  18817. getParsingFlags(config).bigHour = undefined;
  18818. }
  18819. // handle meridiem
  18820. config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
  18821. configFromArray(config);
  18822. checkOverflow(config);
  18823. }
  18824. function meridiemFixWrap (locale, hour, meridiem) {
  18825. var isPm;
  18826. if (meridiem == null) {
  18827. // nothing to do
  18828. return hour;
  18829. }
  18830. if (locale.meridiemHour != null) {
  18831. return locale.meridiemHour(hour, meridiem);
  18832. } else if (locale.isPM != null) {
  18833. // Fallback
  18834. isPm = locale.isPM(meridiem);
  18835. if (isPm && hour < 12) {
  18836. hour += 12;
  18837. }
  18838. if (!isPm && hour === 12) {
  18839. hour = 0;
  18840. }
  18841. return hour;
  18842. } else {
  18843. // this is not supposed to happen
  18844. return hour;
  18845. }
  18846. }
  18847. function configFromStringAndArray(config) {
  18848. var tempConfig,
  18849. bestMoment,
  18850. scoreToBeat,
  18851. i,
  18852. currentScore;
  18853. if (config._f.length === 0) {
  18854. getParsingFlags(config).invalidFormat = true;
  18855. config._d = new Date(NaN);
  18856. return;
  18857. }
  18858. for (i = 0; i < config._f.length; i++) {
  18859. currentScore = 0;
  18860. tempConfig = copyConfig({}, config);
  18861. if (config._useUTC != null) {
  18862. tempConfig._useUTC = config._useUTC;
  18863. }
  18864. tempConfig._f = config._f[i];
  18865. configFromStringAndFormat(tempConfig);
  18866. if (!valid__isValid(tempConfig)) {
  18867. continue;
  18868. }
  18869. // if there is any input that was not parsed add a penalty for that format
  18870. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  18871. //or tokens
  18872. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  18873. getParsingFlags(tempConfig).score = currentScore;
  18874. if (scoreToBeat == null || currentScore < scoreToBeat) {
  18875. scoreToBeat = currentScore;
  18876. bestMoment = tempConfig;
  18877. }
  18878. }
  18879. extend(config, bestMoment || tempConfig);
  18880. }
  18881. function configFromObject(config) {
  18882. if (config._d) {
  18883. return;
  18884. }
  18885. var i = normalizeObjectUnits(config._i);
  18886. config._a = [i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond];
  18887. configFromArray(config);
  18888. }
  18889. function createFromConfig (config) {
  18890. var input = config._i,
  18891. format = config._f,
  18892. res;
  18893. config._locale = config._locale || locale_locales__getLocale(config._l);
  18894. if (input === null || (format === undefined && input === '')) {
  18895. return valid__createInvalid({nullInput: true});
  18896. }
  18897. if (typeof input === 'string') {
  18898. config._i = input = config._locale.preparse(input);
  18899. }
  18900. if (isMoment(input)) {
  18901. return new Moment(checkOverflow(input));
  18902. } else if (isArray(format)) {
  18903. configFromStringAndArray(config);
  18904. } else if (format) {
  18905. configFromStringAndFormat(config);
  18906. } else if (isDate(input)) {
  18907. config._d = input;
  18908. } else {
  18909. configFromInput(config);
  18910. }
  18911. res = new Moment(checkOverflow(config));
  18912. if (res._nextDay) {
  18913. // Adding is smart enough around DST
  18914. res.add(1, 'd');
  18915. res._nextDay = undefined;
  18916. }
  18917. return res;
  18918. }
  18919. function configFromInput(config) {
  18920. var input = config._i;
  18921. if (input === undefined) {
  18922. config._d = new Date();
  18923. } else if (isDate(input)) {
  18924. config._d = new Date(+input);
  18925. } else if (typeof input === 'string') {
  18926. configFromString(config);
  18927. } else if (isArray(input)) {
  18928. config._a = map(input.slice(0), function (obj) {
  18929. return parseInt(obj, 10);
  18930. });
  18931. configFromArray(config);
  18932. } else if (typeof(input) === 'object') {
  18933. configFromObject(config);
  18934. } else if (typeof(input) === 'number') {
  18935. // from milliseconds
  18936. config._d = new Date(input);
  18937. } else {
  18938. utils_hooks__hooks.createFromInputFallback(config);
  18939. }
  18940. }
  18941. function createLocalOrUTC (input, format, locale, strict, isUTC) {
  18942. var c = {};
  18943. if (typeof(locale) === 'boolean') {
  18944. strict = locale;
  18945. locale = undefined;
  18946. }
  18947. // object construction must be done this way.
  18948. // https://github.com/moment/moment/issues/1423
  18949. c._isAMomentObject = true;
  18950. c._useUTC = c._isUTC = isUTC;
  18951. c._l = locale;
  18952. c._i = input;
  18953. c._f = format;
  18954. c._strict = strict;
  18955. return createFromConfig(c);
  18956. }
  18957. function local__createLocal (input, format, locale, strict) {
  18958. return createLocalOrUTC(input, format, locale, strict, false);
  18959. }
  18960. var prototypeMin = deprecate(
  18961. 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
  18962. function () {
  18963. var other = local__createLocal.apply(null, arguments);
  18964. return other < this ? this : other;
  18965. }
  18966. );
  18967. var prototypeMax = deprecate(
  18968. 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
  18969. function () {
  18970. var other = local__createLocal.apply(null, arguments);
  18971. return other > this ? this : other;
  18972. }
  18973. );
  18974. // Pick a moment m from moments so that m[fn](other) is true for all
  18975. // other. This relies on the function fn to be transitive.
  18976. //
  18977. // moments should either be an array of moment objects or an array, whose
  18978. // first element is an array of moment objects.
  18979. function pickBy(fn, moments) {
  18980. var res, i;
  18981. if (moments.length === 1 && isArray(moments[0])) {
  18982. moments = moments[0];
  18983. }
  18984. if (!moments.length) {
  18985. return local__createLocal();
  18986. }
  18987. res = moments[0];
  18988. for (i = 1; i < moments.length; ++i) {
  18989. if (moments[i][fn](res)) {
  18990. res = moments[i];
  18991. }
  18992. }
  18993. return res;
  18994. }
  18995. // TODO: Use [].sort instead?
  18996. function min () {
  18997. var args = [].slice.call(arguments, 0);
  18998. return pickBy('isBefore', args);
  18999. }
  19000. function max () {
  19001. var args = [].slice.call(arguments, 0);
  19002. return pickBy('isAfter', args);
  19003. }
  19004. function Duration (duration) {
  19005. var normalizedInput = normalizeObjectUnits(duration),
  19006. years = normalizedInput.year || 0,
  19007. quarters = normalizedInput.quarter || 0,
  19008. months = normalizedInput.month || 0,
  19009. weeks = normalizedInput.week || 0,
  19010. days = normalizedInput.day || 0,
  19011. hours = normalizedInput.hour || 0,
  19012. minutes = normalizedInput.minute || 0,
  19013. seconds = normalizedInput.second || 0,
  19014. milliseconds = normalizedInput.millisecond || 0;
  19015. // representation for dateAddRemove
  19016. this._milliseconds = +milliseconds +
  19017. seconds * 1e3 + // 1000
  19018. minutes * 6e4 + // 1000 * 60
  19019. hours * 36e5; // 1000 * 60 * 60
  19020. // Because of dateAddRemove treats 24 hours as different from a
  19021. // day when working around DST, we need to store them separately
  19022. this._days = +days +
  19023. weeks * 7;
  19024. // It is impossible translate months into days without knowing
  19025. // which months you are are talking about, so we have to store
  19026. // it separately.
  19027. this._months = +months +
  19028. quarters * 3 +
  19029. years * 12;
  19030. this._data = {};
  19031. this._locale = locale_locales__getLocale();
  19032. this._bubble();
  19033. }
  19034. function isDuration (obj) {
  19035. return obj instanceof Duration;
  19036. }
  19037. function offset (token, separator) {
  19038. addFormatToken(token, 0, 0, function () {
  19039. var offset = this.utcOffset();
  19040. var sign = '+';
  19041. if (offset < 0) {
  19042. offset = -offset;
  19043. sign = '-';
  19044. }
  19045. return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
  19046. });
  19047. }
  19048. offset('Z', ':');
  19049. offset('ZZ', '');
  19050. // PARSING
  19051. addRegexToken('Z', matchOffset);
  19052. addRegexToken('ZZ', matchOffset);
  19053. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  19054. config._useUTC = true;
  19055. config._tzm = offsetFromString(input);
  19056. });
  19057. // HELPERS
  19058. // timezone chunker
  19059. // '+10:00' > ['10', '00']
  19060. // '-1530' > ['-15', '30']
  19061. var chunkOffset = /([\+\-]|\d\d)/gi;
  19062. function offsetFromString(string) {
  19063. var matches = ((string || '').match(matchOffset) || []);
  19064. var chunk = matches[matches.length - 1] || [];
  19065. var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  19066. var minutes = +(parts[1] * 60) + toInt(parts[2]);
  19067. return parts[0] === '+' ? minutes : -minutes;
  19068. }
  19069. // Return a moment from input, that is local/utc/zone equivalent to model.
  19070. function cloneWithOffset(input, model) {
  19071. var res, diff;
  19072. if (model._isUTC) {
  19073. res = model.clone();
  19074. diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
  19075. // Use low-level api, because this fn is low-level api.
  19076. res._d.setTime(+res._d + diff);
  19077. utils_hooks__hooks.updateOffset(res, false);
  19078. return res;
  19079. } else {
  19080. return local__createLocal(input).local();
  19081. }
  19082. return model._isUTC ? local__createLocal(input).zone(model._offset || 0) : local__createLocal(input).local();
  19083. }
  19084. function getDateOffset (m) {
  19085. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  19086. // https://github.com/moment/moment/pull/1871
  19087. return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
  19088. }
  19089. // HOOKS
  19090. // This function will be called whenever a moment is mutated.
  19091. // It is intended to keep the offset in sync with the timezone.
  19092. utils_hooks__hooks.updateOffset = function () {};
  19093. // MOMENTS
  19094. // keepLocalTime = true means only change the timezone, without
  19095. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  19096. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  19097. // +0200, so we adjust the time as needed, to be valid.
  19098. //
  19099. // Keeping the time actually adds/subtracts (one hour)
  19100. // from the actual represented time. That is why we call updateOffset
  19101. // a second time. In case it wants us to change the offset again
  19102. // _changeInProgress == true case, then we have to adjust, because
  19103. // there is no such time in the given timezone.
  19104. function getSetOffset (input, keepLocalTime) {
  19105. var offset = this._offset || 0,
  19106. localAdjust;
  19107. if (input != null) {
  19108. if (typeof input === 'string') {
  19109. input = offsetFromString(input);
  19110. }
  19111. if (Math.abs(input) < 16) {
  19112. input = input * 60;
  19113. }
  19114. if (!this._isUTC && keepLocalTime) {
  19115. localAdjust = getDateOffset(this);
  19116. }
  19117. this._offset = input;
  19118. this._isUTC = true;
  19119. if (localAdjust != null) {
  19120. this.add(localAdjust, 'm');
  19121. }
  19122. if (offset !== input) {
  19123. if (!keepLocalTime || this._changeInProgress) {
  19124. add_subtract__addSubtract(this, create__createDuration(input - offset, 'm'), 1, false);
  19125. } else if (!this._changeInProgress) {
  19126. this._changeInProgress = true;
  19127. utils_hooks__hooks.updateOffset(this, true);
  19128. this._changeInProgress = null;
  19129. }
  19130. }
  19131. return this;
  19132. } else {
  19133. return this._isUTC ? offset : getDateOffset(this);
  19134. }
  19135. }
  19136. function getSetZone (input, keepLocalTime) {
  19137. if (input != null) {
  19138. if (typeof input !== 'string') {
  19139. input = -input;
  19140. }
  19141. this.utcOffset(input, keepLocalTime);
  19142. return this;
  19143. } else {
  19144. return -this.utcOffset();
  19145. }
  19146. }
  19147. function setOffsetToUTC (keepLocalTime) {
  19148. return this.utcOffset(0, keepLocalTime);
  19149. }
  19150. function setOffsetToLocal (keepLocalTime) {
  19151. if (this._isUTC) {
  19152. this.utcOffset(0, keepLocalTime);
  19153. this._isUTC = false;
  19154. if (keepLocalTime) {
  19155. this.subtract(getDateOffset(this), 'm');
  19156. }
  19157. }
  19158. return this;
  19159. }
  19160. function setOffsetToParsedOffset () {
  19161. if (this._tzm) {
  19162. this.utcOffset(this._tzm);
  19163. } else if (typeof this._i === 'string') {
  19164. this.utcOffset(offsetFromString(this._i));
  19165. }
  19166. return this;
  19167. }
  19168. function hasAlignedHourOffset (input) {
  19169. if (!input) {
  19170. input = 0;
  19171. }
  19172. else {
  19173. input = local__createLocal(input).utcOffset();
  19174. }
  19175. return (this.utcOffset() - input) % 60 === 0;
  19176. }
  19177. function isDaylightSavingTime () {
  19178. return (
  19179. this.utcOffset() > this.clone().month(0).utcOffset() ||
  19180. this.utcOffset() > this.clone().month(5).utcOffset()
  19181. );
  19182. }
  19183. function isDaylightSavingTimeShifted () {
  19184. if (this._a) {
  19185. var other = this._isUTC ? create_utc__createUTC(this._a) : local__createLocal(this._a);
  19186. return this.isValid() && compareArrays(this._a, other.toArray()) > 0;
  19187. }
  19188. return false;
  19189. }
  19190. function isLocal () {
  19191. return !this._isUTC;
  19192. }
  19193. function isUtcOffset () {
  19194. return this._isUTC;
  19195. }
  19196. function isUtc () {
  19197. return this._isUTC && this._offset === 0;
  19198. }
  19199. var aspNetRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
  19200. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  19201. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  19202. 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)$/;
  19203. function create__createDuration (input, key) {
  19204. var duration = input,
  19205. // matching against regexp is expensive, do it on demand
  19206. match = null,
  19207. sign,
  19208. ret,
  19209. diffRes;
  19210. if (isDuration(input)) {
  19211. duration = {
  19212. ms : input._milliseconds,
  19213. d : input._days,
  19214. M : input._months
  19215. };
  19216. } else if (typeof input === 'number') {
  19217. duration = {};
  19218. if (key) {
  19219. duration[key] = input;
  19220. } else {
  19221. duration.milliseconds = input;
  19222. }
  19223. } else if (!!(match = aspNetRegex.exec(input))) {
  19224. sign = (match[1] === '-') ? -1 : 1;
  19225. duration = {
  19226. y : 0,
  19227. d : toInt(match[DATE]) * sign,
  19228. h : toInt(match[HOUR]) * sign,
  19229. m : toInt(match[MINUTE]) * sign,
  19230. s : toInt(match[SECOND]) * sign,
  19231. ms : toInt(match[MILLISECOND]) * sign
  19232. };
  19233. } else if (!!(match = create__isoRegex.exec(input))) {
  19234. sign = (match[1] === '-') ? -1 : 1;
  19235. duration = {
  19236. y : parseIso(match[2], sign),
  19237. M : parseIso(match[3], sign),
  19238. d : parseIso(match[4], sign),
  19239. h : parseIso(match[5], sign),
  19240. m : parseIso(match[6], sign),
  19241. s : parseIso(match[7], sign),
  19242. w : parseIso(match[8], sign)
  19243. };
  19244. } else if (duration == null) {// checks for null or undefined
  19245. duration = {};
  19246. } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
  19247. diffRes = momentsDifference(local__createLocal(duration.from), local__createLocal(duration.to));
  19248. duration = {};
  19249. duration.ms = diffRes.milliseconds;
  19250. duration.M = diffRes.months;
  19251. }
  19252. ret = new Duration(duration);
  19253. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  19254. ret._locale = input._locale;
  19255. }
  19256. return ret;
  19257. }
  19258. create__createDuration.fn = Duration.prototype;
  19259. function parseIso (inp, sign) {
  19260. // We'd normally use ~~inp for this, but unfortunately it also
  19261. // converts floats to ints.
  19262. // inp may be undefined, so careful calling replace on it.
  19263. var res = inp && parseFloat(inp.replace(',', '.'));
  19264. // apply sign while we're at it
  19265. return (isNaN(res) ? 0 : res) * sign;
  19266. }
  19267. function positiveMomentsDifference(base, other) {
  19268. var res = {milliseconds: 0, months: 0};
  19269. res.months = other.month() - base.month() +
  19270. (other.year() - base.year()) * 12;
  19271. if (base.clone().add(res.months, 'M').isAfter(other)) {
  19272. --res.months;
  19273. }
  19274. res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
  19275. return res;
  19276. }
  19277. function momentsDifference(base, other) {
  19278. var res;
  19279. other = cloneWithOffset(other, base);
  19280. if (base.isBefore(other)) {
  19281. res = positiveMomentsDifference(base, other);
  19282. } else {
  19283. res = positiveMomentsDifference(other, base);
  19284. res.milliseconds = -res.milliseconds;
  19285. res.months = -res.months;
  19286. }
  19287. return res;
  19288. }
  19289. function createAdder(direction, name) {
  19290. return function (val, period) {
  19291. var dur, tmp;
  19292. //invert the arguments, but complain about it
  19293. if (period !== null && !isNaN(+period)) {
  19294. deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
  19295. tmp = val; val = period; period = tmp;
  19296. }
  19297. val = typeof val === 'string' ? +val : val;
  19298. dur = create__createDuration(val, period);
  19299. add_subtract__addSubtract(this, dur, direction);
  19300. return this;
  19301. };
  19302. }
  19303. function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) {
  19304. var milliseconds = duration._milliseconds,
  19305. days = duration._days,
  19306. months = duration._months;
  19307. updateOffset = updateOffset == null ? true : updateOffset;
  19308. if (milliseconds) {
  19309. mom._d.setTime(+mom._d + milliseconds * isAdding);
  19310. }
  19311. if (days) {
  19312. get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
  19313. }
  19314. if (months) {
  19315. setMonth(mom, get_set__get(mom, 'Month') + months * isAdding);
  19316. }
  19317. if (updateOffset) {
  19318. utils_hooks__hooks.updateOffset(mom, days || months);
  19319. }
  19320. }
  19321. var add_subtract__add = createAdder(1, 'add');
  19322. var add_subtract__subtract = createAdder(-1, 'subtract');
  19323. function moment_calendar__calendar (time) {
  19324. // We want to compare the start of today, vs this.
  19325. // Getting start-of-today depends on whether we're local/utc/offset or not.
  19326. var now = time || local__createLocal(),
  19327. sod = cloneWithOffset(now, this).startOf('day'),
  19328. diff = this.diff(sod, 'days', true),
  19329. format = diff < -6 ? 'sameElse' :
  19330. diff < -1 ? 'lastWeek' :
  19331. diff < 0 ? 'lastDay' :
  19332. diff < 1 ? 'sameDay' :
  19333. diff < 2 ? 'nextDay' :
  19334. diff < 7 ? 'nextWeek' : 'sameElse';
  19335. return this.format(this.localeData().calendar(format, this, local__createLocal(now)));
  19336. }
  19337. function clone () {
  19338. return new Moment(this);
  19339. }
  19340. function isAfter (input, units) {
  19341. var inputMs;
  19342. units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
  19343. if (units === 'millisecond') {
  19344. input = isMoment(input) ? input : local__createLocal(input);
  19345. return +this > +input;
  19346. } else {
  19347. inputMs = isMoment(input) ? +input : +local__createLocal(input);
  19348. return inputMs < +this.clone().startOf(units);
  19349. }
  19350. }
  19351. function isBefore (input, units) {
  19352. var inputMs;
  19353. units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
  19354. if (units === 'millisecond') {
  19355. input = isMoment(input) ? input : local__createLocal(input);
  19356. return +this < +input;
  19357. } else {
  19358. inputMs = isMoment(input) ? +input : +local__createLocal(input);
  19359. return +this.clone().endOf(units) < inputMs;
  19360. }
  19361. }
  19362. function isBetween (from, to, units) {
  19363. return this.isAfter(from, units) && this.isBefore(to, units);
  19364. }
  19365. function isSame (input, units) {
  19366. var inputMs;
  19367. units = normalizeUnits(units || 'millisecond');
  19368. if (units === 'millisecond') {
  19369. input = isMoment(input) ? input : local__createLocal(input);
  19370. return +this === +input;
  19371. } else {
  19372. inputMs = +local__createLocal(input);
  19373. return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
  19374. }
  19375. }
  19376. function absFloor (number) {
  19377. if (number < 0) {
  19378. return Math.ceil(number);
  19379. } else {
  19380. return Math.floor(number);
  19381. }
  19382. }
  19383. function diff (input, units, asFloat) {
  19384. var that = cloneWithOffset(input, this),
  19385. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4,
  19386. delta, output;
  19387. units = normalizeUnits(units);
  19388. if (units === 'year' || units === 'month' || units === 'quarter') {
  19389. output = monthDiff(this, that);
  19390. if (units === 'quarter') {
  19391. output = output / 3;
  19392. } else if (units === 'year') {
  19393. output = output / 12;
  19394. }
  19395. } else {
  19396. delta = this - that;
  19397. output = units === 'second' ? delta / 1e3 : // 1000
  19398. units === 'minute' ? delta / 6e4 : // 1000 * 60
  19399. units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
  19400. units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
  19401. units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
  19402. delta;
  19403. }
  19404. return asFloat ? output : absFloor(output);
  19405. }
  19406. function monthDiff (a, b) {
  19407. // difference in months
  19408. var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
  19409. // b is in (anchor - 1 month, anchor + 1 month)
  19410. anchor = a.clone().add(wholeMonthDiff, 'months'),
  19411. anchor2, adjust;
  19412. if (b - anchor < 0) {
  19413. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  19414. // linear across the month
  19415. adjust = (b - anchor) / (anchor - anchor2);
  19416. } else {
  19417. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  19418. // linear across the month
  19419. adjust = (b - anchor) / (anchor2 - anchor);
  19420. }
  19421. return -(wholeMonthDiff + adjust);
  19422. }
  19423. utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  19424. function toString () {
  19425. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  19426. }
  19427. function moment_format__toISOString () {
  19428. var m = this.clone().utc();
  19429. if (0 < m.year() && m.year() <= 9999) {
  19430. if ('function' === typeof Date.prototype.toISOString) {
  19431. // native implementation is ~50x faster, use it when we can
  19432. return this.toDate().toISOString();
  19433. } else {
  19434. return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  19435. }
  19436. } else {
  19437. return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  19438. }
  19439. }
  19440. function format (inputString) {
  19441. var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
  19442. return this.localeData().postformat(output);
  19443. }
  19444. function from (time, withoutSuffix) {
  19445. if (!this.isValid()) {
  19446. return this.localeData().invalidDate();
  19447. }
  19448. return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
  19449. }
  19450. function fromNow (withoutSuffix) {
  19451. return this.from(local__createLocal(), withoutSuffix);
  19452. }
  19453. function to (time, withoutSuffix) {
  19454. if (!this.isValid()) {
  19455. return this.localeData().invalidDate();
  19456. }
  19457. return create__createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
  19458. }
  19459. function toNow (withoutSuffix) {
  19460. return this.to(local__createLocal(), withoutSuffix);
  19461. }
  19462. function locale (key) {
  19463. var newLocaleData;
  19464. if (key === undefined) {
  19465. return this._locale._abbr;
  19466. } else {
  19467. newLocaleData = locale_locales__getLocale(key);
  19468. if (newLocaleData != null) {
  19469. this._locale = newLocaleData;
  19470. }
  19471. return this;
  19472. }
  19473. }
  19474. var lang = deprecate(
  19475. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  19476. function (key) {
  19477. if (key === undefined) {
  19478. return this.localeData();
  19479. } else {
  19480. return this.locale(key);
  19481. }
  19482. }
  19483. );
  19484. function localeData () {
  19485. return this._locale;
  19486. }
  19487. function startOf (units) {
  19488. units = normalizeUnits(units);
  19489. // the following switch intentionally omits break keywords
  19490. // to utilize falling through the cases.
  19491. switch (units) {
  19492. case 'year':
  19493. this.month(0);
  19494. /* falls through */
  19495. case 'quarter':
  19496. case 'month':
  19497. this.date(1);
  19498. /* falls through */
  19499. case 'week':
  19500. case 'isoWeek':
  19501. case 'day':
  19502. this.hours(0);
  19503. /* falls through */
  19504. case 'hour':
  19505. this.minutes(0);
  19506. /* falls through */
  19507. case 'minute':
  19508. this.seconds(0);
  19509. /* falls through */
  19510. case 'second':
  19511. this.milliseconds(0);
  19512. }
  19513. // weeks are a special case
  19514. if (units === 'week') {
  19515. this.weekday(0);
  19516. }
  19517. if (units === 'isoWeek') {
  19518. this.isoWeekday(1);
  19519. }
  19520. // quarters are also special
  19521. if (units === 'quarter') {
  19522. this.month(Math.floor(this.month() / 3) * 3);
  19523. }
  19524. return this;
  19525. }
  19526. function endOf (units) {
  19527. units = normalizeUnits(units);
  19528. if (units === undefined || units === 'millisecond') {
  19529. return this;
  19530. }
  19531. return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
  19532. }
  19533. function to_type__valueOf () {
  19534. return +this._d - ((this._offset || 0) * 60000);
  19535. }
  19536. function unix () {
  19537. return Math.floor(+this / 1000);
  19538. }
  19539. function toDate () {
  19540. return this._offset ? new Date(+this) : this._d;
  19541. }
  19542. function toArray () {
  19543. var m = this;
  19544. return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
  19545. }
  19546. function moment_valid__isValid () {
  19547. return valid__isValid(this);
  19548. }
  19549. function parsingFlags () {
  19550. return extend({}, getParsingFlags(this));
  19551. }
  19552. function invalidAt () {
  19553. return getParsingFlags(this).overflow;
  19554. }
  19555. addFormatToken(0, ['gg', 2], 0, function () {
  19556. return this.weekYear() % 100;
  19557. });
  19558. addFormatToken(0, ['GG', 2], 0, function () {
  19559. return this.isoWeekYear() % 100;
  19560. });
  19561. function addWeekYearFormatToken (token, getter) {
  19562. addFormatToken(0, [token, token.length], 0, getter);
  19563. }
  19564. addWeekYearFormatToken('gggg', 'weekYear');
  19565. addWeekYearFormatToken('ggggg', 'weekYear');
  19566. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  19567. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  19568. // ALIASES
  19569. addUnitAlias('weekYear', 'gg');
  19570. addUnitAlias('isoWeekYear', 'GG');
  19571. // PARSING
  19572. addRegexToken('G', matchSigned);
  19573. addRegexToken('g', matchSigned);
  19574. addRegexToken('GG', match1to2, match2);
  19575. addRegexToken('gg', match1to2, match2);
  19576. addRegexToken('GGGG', match1to4, match4);
  19577. addRegexToken('gggg', match1to4, match4);
  19578. addRegexToken('GGGGG', match1to6, match6);
  19579. addRegexToken('ggggg', match1to6, match6);
  19580. addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
  19581. week[token.substr(0, 2)] = toInt(input);
  19582. });
  19583. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  19584. week[token] = utils_hooks__hooks.parseTwoDigitYear(input);
  19585. });
  19586. // HELPERS
  19587. function weeksInYear(year, dow, doy) {
  19588. return weekOfYear(local__createLocal([year, 11, 31 + dow - doy]), dow, doy).week;
  19589. }
  19590. // MOMENTS
  19591. function getSetWeekYear (input) {
  19592. var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
  19593. return input == null ? year : this.add((input - year), 'y');
  19594. }
  19595. function getSetISOWeekYear (input) {
  19596. var year = weekOfYear(this, 1, 4).year;
  19597. return input == null ? year : this.add((input - year), 'y');
  19598. }
  19599. function getISOWeeksInYear () {
  19600. return weeksInYear(this.year(), 1, 4);
  19601. }
  19602. function getWeeksInYear () {
  19603. var weekInfo = this.localeData()._week;
  19604. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  19605. }
  19606. addFormatToken('Q', 0, 0, 'quarter');
  19607. // ALIASES
  19608. addUnitAlias('quarter', 'Q');
  19609. // PARSING
  19610. addRegexToken('Q', match1);
  19611. addParseToken('Q', function (input, array) {
  19612. array[MONTH] = (toInt(input) - 1) * 3;
  19613. });
  19614. // MOMENTS
  19615. function getSetQuarter (input) {
  19616. return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
  19617. }
  19618. addFormatToken('D', ['DD', 2], 'Do', 'date');
  19619. // ALIASES
  19620. addUnitAlias('date', 'D');
  19621. // PARSING
  19622. addRegexToken('D', match1to2);
  19623. addRegexToken('DD', match1to2, match2);
  19624. addRegexToken('Do', function (isStrict, locale) {
  19625. return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
  19626. });
  19627. addParseToken(['D', 'DD'], DATE);
  19628. addParseToken('Do', function (input, array) {
  19629. array[DATE] = toInt(input.match(match1to2)[0], 10);
  19630. });
  19631. // MOMENTS
  19632. var getSetDayOfMonth = makeGetSet('Date', true);
  19633. addFormatToken('d', 0, 'do', 'day');
  19634. addFormatToken('dd', 0, 0, function (format) {
  19635. return this.localeData().weekdaysMin(this, format);
  19636. });
  19637. addFormatToken('ddd', 0, 0, function (format) {
  19638. return this.localeData().weekdaysShort(this, format);
  19639. });
  19640. addFormatToken('dddd', 0, 0, function (format) {
  19641. return this.localeData().weekdays(this, format);
  19642. });
  19643. addFormatToken('e', 0, 0, 'weekday');
  19644. addFormatToken('E', 0, 0, 'isoWeekday');
  19645. // ALIASES
  19646. addUnitAlias('day', 'd');
  19647. addUnitAlias('weekday', 'e');
  19648. addUnitAlias('isoWeekday', 'E');
  19649. // PARSING
  19650. addRegexToken('d', match1to2);
  19651. addRegexToken('e', match1to2);
  19652. addRegexToken('E', match1to2);
  19653. addRegexToken('dd', matchWord);
  19654. addRegexToken('ddd', matchWord);
  19655. addRegexToken('dddd', matchWord);
  19656. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config) {
  19657. var weekday = config._locale.weekdaysParse(input);
  19658. // if we didn't get a weekday name, mark the date as invalid
  19659. if (weekday != null) {
  19660. week.d = weekday;
  19661. } else {
  19662. getParsingFlags(config).invalidWeekday = input;
  19663. }
  19664. });
  19665. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  19666. week[token] = toInt(input);
  19667. });
  19668. // HELPERS
  19669. function parseWeekday(input, locale) {
  19670. if (typeof input === 'string') {
  19671. if (!isNaN(input)) {
  19672. input = parseInt(input, 10);
  19673. }
  19674. else {
  19675. input = locale.weekdaysParse(input);
  19676. if (typeof input !== 'number') {
  19677. return null;
  19678. }
  19679. }
  19680. }
  19681. return input;
  19682. }
  19683. // LOCALES
  19684. var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
  19685. function localeWeekdays (m) {
  19686. return this._weekdays[m.day()];
  19687. }
  19688. var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
  19689. function localeWeekdaysShort (m) {
  19690. return this._weekdaysShort[m.day()];
  19691. }
  19692. var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
  19693. function localeWeekdaysMin (m) {
  19694. return this._weekdaysMin[m.day()];
  19695. }
  19696. function localeWeekdaysParse (weekdayName) {
  19697. var i, mom, regex;
  19698. if (!this._weekdaysParse) {
  19699. this._weekdaysParse = [];
  19700. }
  19701. for (i = 0; i < 7; i++) {
  19702. // make the regex if we don't have it already
  19703. if (!this._weekdaysParse[i]) {
  19704. mom = local__createLocal([2000, 1]).day(i);
  19705. regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
  19706. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  19707. }
  19708. // test the regex
  19709. if (this._weekdaysParse[i].test(weekdayName)) {
  19710. return i;
  19711. }
  19712. }
  19713. }
  19714. // MOMENTS
  19715. function getSetDayOfWeek (input) {
  19716. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  19717. if (input != null) {
  19718. input = parseWeekday(input, this.localeData());
  19719. return this.add(input - day, 'd');
  19720. } else {
  19721. return day;
  19722. }
  19723. }
  19724. function getSetLocaleDayOfWeek (input) {
  19725. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  19726. return input == null ? weekday : this.add(input - weekday, 'd');
  19727. }
  19728. function getSetISODayOfWeek (input) {
  19729. // behaves the same as moment#day except
  19730. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  19731. // as a setter, sunday should belong to the previous week.
  19732. return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
  19733. }
  19734. addFormatToken('H', ['HH', 2], 0, 'hour');
  19735. addFormatToken('h', ['hh', 2], 0, function () {
  19736. return this.hours() % 12 || 12;
  19737. });
  19738. function meridiem (token, lowercase) {
  19739. addFormatToken(token, 0, 0, function () {
  19740. return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
  19741. });
  19742. }
  19743. meridiem('a', true);
  19744. meridiem('A', false);
  19745. // ALIASES
  19746. addUnitAlias('hour', 'h');
  19747. // PARSING
  19748. function matchMeridiem (isStrict, locale) {
  19749. return locale._meridiemParse;
  19750. }
  19751. addRegexToken('a', matchMeridiem);
  19752. addRegexToken('A', matchMeridiem);
  19753. addRegexToken('H', match1to2);
  19754. addRegexToken('h', match1to2);
  19755. addRegexToken('HH', match1to2, match2);
  19756. addRegexToken('hh', match1to2, match2);
  19757. addParseToken(['H', 'HH'], HOUR);
  19758. addParseToken(['a', 'A'], function (input, array, config) {
  19759. config._isPm = config._locale.isPM(input);
  19760. config._meridiem = input;
  19761. });
  19762. addParseToken(['h', 'hh'], function (input, array, config) {
  19763. array[HOUR] = toInt(input);
  19764. getParsingFlags(config).bigHour = true;
  19765. });
  19766. // LOCALES
  19767. function localeIsPM (input) {
  19768. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  19769. // Using charAt should be more compatible.
  19770. return ((input + '').toLowerCase().charAt(0) === 'p');
  19771. }
  19772. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
  19773. function localeMeridiem (hours, minutes, isLower) {
  19774. if (hours > 11) {
  19775. return isLower ? 'pm' : 'PM';
  19776. } else {
  19777. return isLower ? 'am' : 'AM';
  19778. }
  19779. }
  19780. // MOMENTS
  19781. // Setting the hour should keep the time, because the user explicitly
  19782. // specified which hour he wants. So trying to maintain the same hour (in
  19783. // a new timezone) makes sense. Adding/subtracting hours does not follow
  19784. // this rule.
  19785. var getSetHour = makeGetSet('Hours', true);
  19786. addFormatToken('m', ['mm', 2], 0, 'minute');
  19787. // ALIASES
  19788. addUnitAlias('minute', 'm');
  19789. // PARSING
  19790. addRegexToken('m', match1to2);
  19791. addRegexToken('mm', match1to2, match2);
  19792. addParseToken(['m', 'mm'], MINUTE);
  19793. // MOMENTS
  19794. var getSetMinute = makeGetSet('Minutes', false);
  19795. addFormatToken('s', ['ss', 2], 0, 'second');
  19796. // ALIASES
  19797. addUnitAlias('second', 's');
  19798. // PARSING
  19799. addRegexToken('s', match1to2);
  19800. addRegexToken('ss', match1to2, match2);
  19801. addParseToken(['s', 'ss'], SECOND);
  19802. // MOMENTS
  19803. var getSetSecond = makeGetSet('Seconds', false);
  19804. addFormatToken('S', 0, 0, function () {
  19805. return ~~(this.millisecond() / 100);
  19806. });
  19807. addFormatToken(0, ['SS', 2], 0, function () {
  19808. return ~~(this.millisecond() / 10);
  19809. });
  19810. function millisecond__milliseconds (token) {
  19811. addFormatToken(0, [token, 3], 0, 'millisecond');
  19812. }
  19813. millisecond__milliseconds('SSS');
  19814. millisecond__milliseconds('SSSS');
  19815. // ALIASES
  19816. addUnitAlias('millisecond', 'ms');
  19817. // PARSING
  19818. addRegexToken('S', match1to3, match1);
  19819. addRegexToken('SS', match1to3, match2);
  19820. addRegexToken('SSS', match1to3, match3);
  19821. addRegexToken('SSSS', matchUnsigned);
  19822. addParseToken(['S', 'SS', 'SSS', 'SSSS'], function (input, array) {
  19823. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  19824. });
  19825. // MOMENTS
  19826. var getSetMillisecond = makeGetSet('Milliseconds', false);
  19827. addFormatToken('z', 0, 0, 'zoneAbbr');
  19828. addFormatToken('zz', 0, 0, 'zoneName');
  19829. // MOMENTS
  19830. function getZoneAbbr () {
  19831. return this._isUTC ? 'UTC' : '';
  19832. }
  19833. function getZoneName () {
  19834. return this._isUTC ? 'Coordinated Universal Time' : '';
  19835. }
  19836. var momentPrototype__proto = Moment.prototype;
  19837. momentPrototype__proto.add = add_subtract__add;
  19838. momentPrototype__proto.calendar = moment_calendar__calendar;
  19839. momentPrototype__proto.clone = clone;
  19840. momentPrototype__proto.diff = diff;
  19841. momentPrototype__proto.endOf = endOf;
  19842. momentPrototype__proto.format = format;
  19843. momentPrototype__proto.from = from;
  19844. momentPrototype__proto.fromNow = fromNow;
  19845. momentPrototype__proto.to = to;
  19846. momentPrototype__proto.toNow = toNow;
  19847. momentPrototype__proto.get = getSet;
  19848. momentPrototype__proto.invalidAt = invalidAt;
  19849. momentPrototype__proto.isAfter = isAfter;
  19850. momentPrototype__proto.isBefore = isBefore;
  19851. momentPrototype__proto.isBetween = isBetween;
  19852. momentPrototype__proto.isSame = isSame;
  19853. momentPrototype__proto.isValid = moment_valid__isValid;
  19854. momentPrototype__proto.lang = lang;
  19855. momentPrototype__proto.locale = locale;
  19856. momentPrototype__proto.localeData = localeData;
  19857. momentPrototype__proto.max = prototypeMax;
  19858. momentPrototype__proto.min = prototypeMin;
  19859. momentPrototype__proto.parsingFlags = parsingFlags;
  19860. momentPrototype__proto.set = getSet;
  19861. momentPrototype__proto.startOf = startOf;
  19862. momentPrototype__proto.subtract = add_subtract__subtract;
  19863. momentPrototype__proto.toArray = toArray;
  19864. momentPrototype__proto.toDate = toDate;
  19865. momentPrototype__proto.toISOString = moment_format__toISOString;
  19866. momentPrototype__proto.toJSON = moment_format__toISOString;
  19867. momentPrototype__proto.toString = toString;
  19868. momentPrototype__proto.unix = unix;
  19869. momentPrototype__proto.valueOf = to_type__valueOf;
  19870. // Year
  19871. momentPrototype__proto.year = getSetYear;
  19872. momentPrototype__proto.isLeapYear = getIsLeapYear;
  19873. // Week Year
  19874. momentPrototype__proto.weekYear = getSetWeekYear;
  19875. momentPrototype__proto.isoWeekYear = getSetISOWeekYear;
  19876. // Quarter
  19877. momentPrototype__proto.quarter = momentPrototype__proto.quarters = getSetQuarter;
  19878. // Month
  19879. momentPrototype__proto.month = getSetMonth;
  19880. momentPrototype__proto.daysInMonth = getDaysInMonth;
  19881. // Week
  19882. momentPrototype__proto.week = momentPrototype__proto.weeks = getSetWeek;
  19883. momentPrototype__proto.isoWeek = momentPrototype__proto.isoWeeks = getSetISOWeek;
  19884. momentPrototype__proto.weeksInYear = getWeeksInYear;
  19885. momentPrototype__proto.isoWeeksInYear = getISOWeeksInYear;
  19886. // Day
  19887. momentPrototype__proto.date = getSetDayOfMonth;
  19888. momentPrototype__proto.day = momentPrototype__proto.days = getSetDayOfWeek;
  19889. momentPrototype__proto.weekday = getSetLocaleDayOfWeek;
  19890. momentPrototype__proto.isoWeekday = getSetISODayOfWeek;
  19891. momentPrototype__proto.dayOfYear = getSetDayOfYear;
  19892. // Hour
  19893. momentPrototype__proto.hour = momentPrototype__proto.hours = getSetHour;
  19894. // Minute
  19895. momentPrototype__proto.minute = momentPrototype__proto.minutes = getSetMinute;
  19896. // Second
  19897. momentPrototype__proto.second = momentPrototype__proto.seconds = getSetSecond;
  19898. // Millisecond
  19899. momentPrototype__proto.millisecond = momentPrototype__proto.milliseconds = getSetMillisecond;
  19900. // Offset
  19901. momentPrototype__proto.utcOffset = getSetOffset;
  19902. momentPrototype__proto.utc = setOffsetToUTC;
  19903. momentPrototype__proto.local = setOffsetToLocal;
  19904. momentPrototype__proto.parseZone = setOffsetToParsedOffset;
  19905. momentPrototype__proto.hasAlignedHourOffset = hasAlignedHourOffset;
  19906. momentPrototype__proto.isDST = isDaylightSavingTime;
  19907. momentPrototype__proto.isDSTShifted = isDaylightSavingTimeShifted;
  19908. momentPrototype__proto.isLocal = isLocal;
  19909. momentPrototype__proto.isUtcOffset = isUtcOffset;
  19910. momentPrototype__proto.isUtc = isUtc;
  19911. momentPrototype__proto.isUTC = isUtc;
  19912. // Timezone
  19913. momentPrototype__proto.zoneAbbr = getZoneAbbr;
  19914. momentPrototype__proto.zoneName = getZoneName;
  19915. // Deprecations
  19916. momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
  19917. momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
  19918. momentPrototype__proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
  19919. momentPrototype__proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779', getSetZone);
  19920. var momentPrototype = momentPrototype__proto;
  19921. function moment__createUnix (input) {
  19922. return local__createLocal(input * 1000);
  19923. }
  19924. function moment__createInZone () {
  19925. return local__createLocal.apply(null, arguments).parseZone();
  19926. }
  19927. var defaultCalendar = {
  19928. sameDay : '[Today at] LT',
  19929. nextDay : '[Tomorrow at] LT',
  19930. nextWeek : 'dddd [at] LT',
  19931. lastDay : '[Yesterday at] LT',
  19932. lastWeek : '[Last] dddd [at] LT',
  19933. sameElse : 'L'
  19934. };
  19935. function locale_calendar__calendar (key, mom, now) {
  19936. var output = this._calendar[key];
  19937. return typeof output === 'function' ? output.call(mom, now) : output;
  19938. }
  19939. var defaultLongDateFormat = {
  19940. LTS : 'h:mm:ss A',
  19941. LT : 'h:mm A',
  19942. L : 'MM/DD/YYYY',
  19943. LL : 'MMMM D, YYYY',
  19944. LLL : 'MMMM D, YYYY LT',
  19945. LLLL : 'dddd, MMMM D, YYYY LT'
  19946. };
  19947. function longDateFormat (key) {
  19948. var output = this._longDateFormat[key];
  19949. if (!output && this._longDateFormat[key.toUpperCase()]) {
  19950. output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) {
  19951. return val.slice(1);
  19952. });
  19953. this._longDateFormat[key] = output;
  19954. }
  19955. return output;
  19956. }
  19957. var defaultInvalidDate = 'Invalid date';
  19958. function invalidDate () {
  19959. return this._invalidDate;
  19960. }
  19961. var defaultOrdinal = '%d';
  19962. var defaultOrdinalParse = /\d{1,2}/;
  19963. function ordinal (number) {
  19964. return this._ordinal.replace('%d', number);
  19965. }
  19966. function preParsePostFormat (string) {
  19967. return string;
  19968. }
  19969. var defaultRelativeTime = {
  19970. future : 'in %s',
  19971. past : '%s ago',
  19972. s : 'a few seconds',
  19973. m : 'a minute',
  19974. mm : '%d minutes',
  19975. h : 'an hour',
  19976. hh : '%d hours',
  19977. d : 'a day',
  19978. dd : '%d days',
  19979. M : 'a month',
  19980. MM : '%d months',
  19981. y : 'a year',
  19982. yy : '%d years'
  19983. };
  19984. function relative__relativeTime (number, withoutSuffix, string, isFuture) {
  19985. var output = this._relativeTime[string];
  19986. return (typeof output === 'function') ?
  19987. output(number, withoutSuffix, string, isFuture) :
  19988. output.replace(/%d/i, number);
  19989. }
  19990. function pastFuture (diff, output) {
  19991. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  19992. return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
  19993. }
  19994. function locale_set__set (config) {
  19995. var prop, i;
  19996. for (i in config) {
  19997. prop = config[i];
  19998. if (typeof prop === 'function') {
  19999. this[i] = prop;
  20000. } else {
  20001. this['_' + i] = prop;
  20002. }
  20003. }
  20004. // Lenient ordinal parsing accepts just a number in addition to
  20005. // number + (possibly) stuff coming from _ordinalParseLenient.
  20006. this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
  20007. }
  20008. var prototype__proto = Locale.prototype;
  20009. prototype__proto._calendar = defaultCalendar;
  20010. prototype__proto.calendar = locale_calendar__calendar;
  20011. prototype__proto._longDateFormat = defaultLongDateFormat;
  20012. prototype__proto.longDateFormat = longDateFormat;
  20013. prototype__proto._invalidDate = defaultInvalidDate;
  20014. prototype__proto.invalidDate = invalidDate;
  20015. prototype__proto._ordinal = defaultOrdinal;
  20016. prototype__proto.ordinal = ordinal;
  20017. prototype__proto._ordinalParse = defaultOrdinalParse;
  20018. prototype__proto.preparse = preParsePostFormat;
  20019. prototype__proto.postformat = preParsePostFormat;
  20020. prototype__proto._relativeTime = defaultRelativeTime;
  20021. prototype__proto.relativeTime = relative__relativeTime;
  20022. prototype__proto.pastFuture = pastFuture;
  20023. prototype__proto.set = locale_set__set;
  20024. // Month
  20025. prototype__proto.months = localeMonths;
  20026. prototype__proto._months = defaultLocaleMonths;
  20027. prototype__proto.monthsShort = localeMonthsShort;
  20028. prototype__proto._monthsShort = defaultLocaleMonthsShort;
  20029. prototype__proto.monthsParse = localeMonthsParse;
  20030. // Week
  20031. prototype__proto.week = localeWeek;
  20032. prototype__proto._week = defaultLocaleWeek;
  20033. prototype__proto.firstDayOfYear = localeFirstDayOfYear;
  20034. prototype__proto.firstDayOfWeek = localeFirstDayOfWeek;
  20035. // Day of Week
  20036. prototype__proto.weekdays = localeWeekdays;
  20037. prototype__proto._weekdays = defaultLocaleWeekdays;
  20038. prototype__proto.weekdaysMin = localeWeekdaysMin;
  20039. prototype__proto._weekdaysMin = defaultLocaleWeekdaysMin;
  20040. prototype__proto.weekdaysShort = localeWeekdaysShort;
  20041. prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
  20042. prototype__proto.weekdaysParse = localeWeekdaysParse;
  20043. // Hours
  20044. prototype__proto.isPM = localeIsPM;
  20045. prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
  20046. prototype__proto.meridiem = localeMeridiem;
  20047. function lists__get (format, index, field, setter) {
  20048. var locale = locale_locales__getLocale();
  20049. var utc = create_utc__createUTC().set(setter, index);
  20050. return locale[field](utc, format);
  20051. }
  20052. function list (format, index, field, count, setter) {
  20053. if (typeof format === 'number') {
  20054. index = format;
  20055. format = undefined;
  20056. }
  20057. format = format || '';
  20058. if (index != null) {
  20059. return lists__get(format, index, field, setter);
  20060. }
  20061. var i;
  20062. var out = [];
  20063. for (i = 0; i < count; i++) {
  20064. out[i] = lists__get(format, i, field, setter);
  20065. }
  20066. return out;
  20067. }
  20068. function lists__listMonths (format, index) {
  20069. return list(format, index, 'months', 12, 'month');
  20070. }
  20071. function lists__listMonthsShort (format, index) {
  20072. return list(format, index, 'monthsShort', 12, 'month');
  20073. }
  20074. function lists__listWeekdays (format, index) {
  20075. return list(format, index, 'weekdays', 7, 'day');
  20076. }
  20077. function lists__listWeekdaysShort (format, index) {
  20078. return list(format, index, 'weekdaysShort', 7, 'day');
  20079. }
  20080. function lists__listWeekdaysMin (format, index) {
  20081. return list(format, index, 'weekdaysMin', 7, 'day');
  20082. }
  20083. locale_locales__getSetGlobalLocale('en', {
  20084. ordinalParse: /\d{1,2}(th|st|nd|rd)/,
  20085. ordinal : function (number) {
  20086. var b = number % 10,
  20087. output = (toInt(number % 100 / 10) === 1) ? 'th' :
  20088. (b === 1) ? 'st' :
  20089. (b === 2) ? 'nd' :
  20090. (b === 3) ? 'rd' : 'th';
  20091. return number + output;
  20092. }
  20093. });
  20094. // Side effect imports
  20095. utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale);
  20096. utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale);
  20097. var mathAbs = Math.abs;
  20098. function duration_abs__abs () {
  20099. var data = this._data;
  20100. this._milliseconds = mathAbs(this._milliseconds);
  20101. this._days = mathAbs(this._days);
  20102. this._months = mathAbs(this._months);
  20103. data.milliseconds = mathAbs(data.milliseconds);
  20104. data.seconds = mathAbs(data.seconds);
  20105. data.minutes = mathAbs(data.minutes);
  20106. data.hours = mathAbs(data.hours);
  20107. data.months = mathAbs(data.months);
  20108. data.years = mathAbs(data.years);
  20109. return this;
  20110. }
  20111. function duration_add_subtract__addSubtract (duration, input, value, direction) {
  20112. var other = create__createDuration(input, value);
  20113. duration._milliseconds += direction * other._milliseconds;
  20114. duration._days += direction * other._days;
  20115. duration._months += direction * other._months;
  20116. return duration._bubble();
  20117. }
  20118. // supports only 2.0-style add(1, 's') or add(duration)
  20119. function duration_add_subtract__add (input, value) {
  20120. return duration_add_subtract__addSubtract(this, input, value, 1);
  20121. }
  20122. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  20123. function duration_add_subtract__subtract (input, value) {
  20124. return duration_add_subtract__addSubtract(this, input, value, -1);
  20125. }
  20126. function bubble () {
  20127. var milliseconds = this._milliseconds;
  20128. var days = this._days;
  20129. var months = this._months;
  20130. var data = this._data;
  20131. var seconds, minutes, hours, years = 0;
  20132. // The following code bubbles up values, see the tests for
  20133. // examples of what that means.
  20134. data.milliseconds = milliseconds % 1000;
  20135. seconds = absFloor(milliseconds / 1000);
  20136. data.seconds = seconds % 60;
  20137. minutes = absFloor(seconds / 60);
  20138. data.minutes = minutes % 60;
  20139. hours = absFloor(minutes / 60);
  20140. data.hours = hours % 24;
  20141. days += absFloor(hours / 24);
  20142. // Accurately convert days to years, assume start from year 0.
  20143. years = absFloor(daysToYears(days));
  20144. days -= absFloor(yearsToDays(years));
  20145. // 30 days to a month
  20146. // TODO (iskren): Use anchor date (like 1st Jan) to compute this.
  20147. months += absFloor(days / 30);
  20148. days %= 30;
  20149. // 12 months -> 1 year
  20150. years += absFloor(months / 12);
  20151. months %= 12;
  20152. data.days = days;
  20153. data.months = months;
  20154. data.years = years;
  20155. return this;
  20156. }
  20157. function daysToYears (days) {
  20158. // 400 years have 146097 days (taking into account leap year rules)
  20159. return days * 400 / 146097;
  20160. }
  20161. function yearsToDays (years) {
  20162. // years * 365 + absFloor(years / 4) -
  20163. // absFloor(years / 100) + absFloor(years / 400);
  20164. return years * 146097 / 400;
  20165. }
  20166. function as (units) {
  20167. var days;
  20168. var months;
  20169. var milliseconds = this._milliseconds;
  20170. units = normalizeUnits(units);
  20171. if (units === 'month' || units === 'year') {
  20172. days = this._days + milliseconds / 864e5;
  20173. months = this._months + daysToYears(days) * 12;
  20174. return units === 'month' ? months : months / 12;
  20175. } else {
  20176. // handle milliseconds separately because of floating point math errors (issue #1867)
  20177. days = this._days + Math.round(yearsToDays(this._months / 12));
  20178. switch (units) {
  20179. case 'week' : return days / 7 + milliseconds / 6048e5;
  20180. case 'day' : return days + milliseconds / 864e5;
  20181. case 'hour' : return days * 24 + milliseconds / 36e5;
  20182. case 'minute' : return days * 1440 + milliseconds / 6e4;
  20183. case 'second' : return days * 86400 + milliseconds / 1000;
  20184. // Math.floor prevents floating point math errors here
  20185. case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
  20186. default: throw new Error('Unknown unit ' + units);
  20187. }
  20188. }
  20189. }
  20190. // TODO: Use this.as('ms')?
  20191. function duration_as__valueOf () {
  20192. return (
  20193. this._milliseconds +
  20194. this._days * 864e5 +
  20195. (this._months % 12) * 2592e6 +
  20196. toInt(this._months / 12) * 31536e6
  20197. );
  20198. }
  20199. function makeAs (alias) {
  20200. return function () {
  20201. return this.as(alias);
  20202. };
  20203. }
  20204. var asMilliseconds = makeAs('ms');
  20205. var asSeconds = makeAs('s');
  20206. var asMinutes = makeAs('m');
  20207. var asHours = makeAs('h');
  20208. var asDays = makeAs('d');
  20209. var asWeeks = makeAs('w');
  20210. var asMonths = makeAs('M');
  20211. var asYears = makeAs('y');
  20212. function duration_get__get (units) {
  20213. units = normalizeUnits(units);
  20214. return this[units + 's']();
  20215. }
  20216. function makeGetter(name) {
  20217. return function () {
  20218. return this._data[name];
  20219. };
  20220. }
  20221. var duration_get__milliseconds = makeGetter('milliseconds');
  20222. var seconds = makeGetter('seconds');
  20223. var minutes = makeGetter('minutes');
  20224. var hours = makeGetter('hours');
  20225. var days = makeGetter('days');
  20226. var months = makeGetter('months');
  20227. var years = makeGetter('years');
  20228. function weeks () {
  20229. return absFloor(this.days() / 7);
  20230. }
  20231. var round = Math.round;
  20232. var thresholds = {
  20233. s: 45, // seconds to minute
  20234. m: 45, // minutes to hour
  20235. h: 22, // hours to day
  20236. d: 26, // days to month
  20237. M: 11 // months to year
  20238. };
  20239. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  20240. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  20241. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  20242. }
  20243. function duration_humanize__relativeTime (posNegDuration, withoutSuffix, locale) {
  20244. var duration = create__createDuration(posNegDuration).abs();
  20245. var seconds = round(duration.as('s'));
  20246. var minutes = round(duration.as('m'));
  20247. var hours = round(duration.as('h'));
  20248. var days = round(duration.as('d'));
  20249. var months = round(duration.as('M'));
  20250. var years = round(duration.as('y'));
  20251. var a = seconds < thresholds.s && ['s', seconds] ||
  20252. minutes === 1 && ['m'] ||
  20253. minutes < thresholds.m && ['mm', minutes] ||
  20254. hours === 1 && ['h'] ||
  20255. hours < thresholds.h && ['hh', hours] ||
  20256. days === 1 && ['d'] ||
  20257. days < thresholds.d && ['dd', days] ||
  20258. months === 1 && ['M'] ||
  20259. months < thresholds.M && ['MM', months] ||
  20260. years === 1 && ['y'] || ['yy', years];
  20261. a[2] = withoutSuffix;
  20262. a[3] = +posNegDuration > 0;
  20263. a[4] = locale;
  20264. return substituteTimeAgo.apply(null, a);
  20265. }
  20266. // This function allows you to set a threshold for relative time strings
  20267. function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {
  20268. if (thresholds[threshold] === undefined) {
  20269. return false;
  20270. }
  20271. if (limit === undefined) {
  20272. return thresholds[threshold];
  20273. }
  20274. thresholds[threshold] = limit;
  20275. return true;
  20276. }
  20277. function humanize (withSuffix) {
  20278. var locale = this.localeData();
  20279. var output = duration_humanize__relativeTime(this, !withSuffix, locale);
  20280. if (withSuffix) {
  20281. output = locale.pastFuture(+this, output);
  20282. }
  20283. return locale.postformat(output);
  20284. }
  20285. var iso_string__abs = Math.abs;
  20286. function iso_string__toISOString() {
  20287. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  20288. var Y = iso_string__abs(this.years());
  20289. var M = iso_string__abs(this.months());
  20290. var D = iso_string__abs(this.days());
  20291. var h = iso_string__abs(this.hours());
  20292. var m = iso_string__abs(this.minutes());
  20293. var s = iso_string__abs(this.seconds() + this.milliseconds() / 1000);
  20294. var total = this.asSeconds();
  20295. if (!total) {
  20296. // this is the same as C#'s (Noda) and python (isodate)...
  20297. // but not other JS (goog.date)
  20298. return 'P0D';
  20299. }
  20300. return (total < 0 ? '-' : '') +
  20301. 'P' +
  20302. (Y ? Y + 'Y' : '') +
  20303. (M ? M + 'M' : '') +
  20304. (D ? D + 'D' : '') +
  20305. ((h || m || s) ? 'T' : '') +
  20306. (h ? h + 'H' : '') +
  20307. (m ? m + 'M' : '') +
  20308. (s ? s + 'S' : '');
  20309. }
  20310. var duration_prototype__proto = Duration.prototype;
  20311. duration_prototype__proto.abs = duration_abs__abs;
  20312. duration_prototype__proto.add = duration_add_subtract__add;
  20313. duration_prototype__proto.subtract = duration_add_subtract__subtract;
  20314. duration_prototype__proto.as = as;
  20315. duration_prototype__proto.asMilliseconds = asMilliseconds;
  20316. duration_prototype__proto.asSeconds = asSeconds;
  20317. duration_prototype__proto.asMinutes = asMinutes;
  20318. duration_prototype__proto.asHours = asHours;
  20319. duration_prototype__proto.asDays = asDays;
  20320. duration_prototype__proto.asWeeks = asWeeks;
  20321. duration_prototype__proto.asMonths = asMonths;
  20322. duration_prototype__proto.asYears = asYears;
  20323. duration_prototype__proto.valueOf = duration_as__valueOf;
  20324. duration_prototype__proto._bubble = bubble;
  20325. duration_prototype__proto.get = duration_get__get;
  20326. duration_prototype__proto.milliseconds = duration_get__milliseconds;
  20327. duration_prototype__proto.seconds = seconds;
  20328. duration_prototype__proto.minutes = minutes;
  20329. duration_prototype__proto.hours = hours;
  20330. duration_prototype__proto.days = days;
  20331. duration_prototype__proto.weeks = weeks;
  20332. duration_prototype__proto.months = months;
  20333. duration_prototype__proto.years = years;
  20334. duration_prototype__proto.humanize = humanize;
  20335. duration_prototype__proto.toISOString = iso_string__toISOString;
  20336. duration_prototype__proto.toString = iso_string__toISOString;
  20337. duration_prototype__proto.toJSON = iso_string__toISOString;
  20338. duration_prototype__proto.locale = locale;
  20339. duration_prototype__proto.localeData = localeData;
  20340. // Deprecations
  20341. duration_prototype__proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', iso_string__toISOString);
  20342. duration_prototype__proto.lang = lang;
  20343. // Side effect imports
  20344. addFormatToken('X', 0, 0, 'unix');
  20345. addFormatToken('x', 0, 0, 'valueOf');
  20346. // PARSING
  20347. addRegexToken('x', matchSigned);
  20348. addRegexToken('X', matchTimestamp);
  20349. addParseToken('X', function (input, array, config) {
  20350. config._d = new Date(parseFloat(input, 10) * 1000);
  20351. });
  20352. addParseToken('x', function (input, array, config) {
  20353. config._d = new Date(toInt(input));
  20354. });
  20355. // Side effect imports
  20356. utils_hooks__hooks.version = '2.10.3';
  20357. setHookCallback(local__createLocal);
  20358. utils_hooks__hooks.fn = momentPrototype;
  20359. utils_hooks__hooks.min = min;
  20360. utils_hooks__hooks.max = max;
  20361. utils_hooks__hooks.utc = create_utc__createUTC;
  20362. utils_hooks__hooks.unix = moment__createUnix;
  20363. utils_hooks__hooks.months = lists__listMonths;
  20364. utils_hooks__hooks.isDate = isDate;
  20365. utils_hooks__hooks.locale = locale_locales__getSetGlobalLocale;
  20366. utils_hooks__hooks.invalid = valid__createInvalid;
  20367. utils_hooks__hooks.duration = create__createDuration;
  20368. utils_hooks__hooks.isMoment = isMoment;
  20369. utils_hooks__hooks.weekdays = lists__listWeekdays;
  20370. utils_hooks__hooks.parseZone = moment__createInZone;
  20371. utils_hooks__hooks.localeData = locale_locales__getLocale;
  20372. utils_hooks__hooks.isDuration = isDuration;
  20373. utils_hooks__hooks.monthsShort = lists__listMonthsShort;
  20374. utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
  20375. utils_hooks__hooks.defineLocale = defineLocale;
  20376. utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
  20377. utils_hooks__hooks.normalizeUnits = normalizeUnits;
  20378. utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
  20379. var _moment = utils_hooks__hooks;
  20380. return _moment;
  20381. }));
  20382. },{}],"numeral":[function(require,module,exports){
  20383. "use strict";
  20384. (function() {
  20385. var numeral,
  20386. VERSION = '1.5.3',
  20387. languages = {},
  20388. currentLanguage = 'en',
  20389. zeroFormat = null,
  20390. defaultFormat = '0,0',
  20391. hasModule = (typeof module !== 'undefined' && module.exports);
  20392. function Numeral(number) {
  20393. this._value = number;
  20394. }
  20395. function toFixed(value, precision, roundingFunction, optionals) {
  20396. var power = Math.pow(10, precision),
  20397. optionalsRegExp,
  20398. output;
  20399. output = (roundingFunction(value * power) / power).toFixed(precision);
  20400. if (optionals) {
  20401. optionalsRegExp = new RegExp('0{1,' + optionals + '}$');
  20402. output = output.replace(optionalsRegExp, '');
  20403. }
  20404. return output;
  20405. }
  20406. function formatNumeral(n, format, roundingFunction) {
  20407. var output;
  20408. if (format.indexOf('$') > -1) {
  20409. output = formatCurrency(n, format, roundingFunction);
  20410. } else if (format.indexOf('%') > -1) {
  20411. output = formatPercentage(n, format, roundingFunction);
  20412. } else if (format.indexOf(':') > -1) {
  20413. output = formatTime(n, format);
  20414. } else {
  20415. output = formatNumber(n._value, format, roundingFunction);
  20416. }
  20417. return output;
  20418. }
  20419. function unformatNumeral(n, string) {
  20420. var stringOriginal = string,
  20421. thousandRegExp,
  20422. millionRegExp,
  20423. billionRegExp,
  20424. trillionRegExp,
  20425. suffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
  20426. bytesMultiplier = false,
  20427. power;
  20428. if (string.indexOf(':') > -1) {
  20429. n._value = unformatTime(string);
  20430. } else {
  20431. if (string === zeroFormat) {
  20432. n._value = 0;
  20433. } else {
  20434. if (languages[currentLanguage].delimiters.decimal !== '.') {
  20435. string = string.replace(/\./g, '').replace(languages[currentLanguage].delimiters.decimal, '.');
  20436. }
  20437. thousandRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.thousand + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
  20438. millionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.million + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
  20439. billionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.billion + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
  20440. trillionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$');
  20441. for (power = 0; power <= suffixes.length; power++) {
  20442. bytesMultiplier = (string.indexOf(suffixes[power]) > -1) ? Math.pow(1024, power + 1) : false;
  20443. if (bytesMultiplier) {
  20444. break;
  20445. }
  20446. }
  20447. 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, ''));
  20448. n._value = (bytesMultiplier) ? Math.ceil(n._value) : n._value;
  20449. }
  20450. }
  20451. return n._value;
  20452. }
  20453. function formatCurrency(n, format, roundingFunction) {
  20454. var symbolIndex = format.indexOf('$'),
  20455. openParenIndex = format.indexOf('('),
  20456. minusSignIndex = format.indexOf('-'),
  20457. space = '',
  20458. spliceIndex,
  20459. output;
  20460. if (format.indexOf(' $') > -1) {
  20461. space = ' ';
  20462. format = format.replace(' $', '');
  20463. } else if (format.indexOf('$ ') > -1) {
  20464. space = ' ';
  20465. format = format.replace('$ ', '');
  20466. } else {
  20467. format = format.replace('$', '');
  20468. }
  20469. output = formatNumber(n._value, format, roundingFunction);
  20470. if (symbolIndex <= 1) {
  20471. if (output.indexOf('(') > -1 || output.indexOf('-') > -1) {
  20472. output = output.split('');
  20473. spliceIndex = 1;
  20474. if (symbolIndex < openParenIndex || symbolIndex < minusSignIndex) {
  20475. spliceIndex = 0;
  20476. }
  20477. output.splice(spliceIndex, 0, languages[currentLanguage].currency.symbol + space);
  20478. output = output.join('');
  20479. } else {
  20480. output = languages[currentLanguage].currency.symbol + space + output;
  20481. }
  20482. } else {
  20483. if (output.indexOf(')') > -1) {
  20484. output = output.split('');
  20485. output.splice(-1, 0, space + languages[currentLanguage].currency.symbol);
  20486. output = output.join('');
  20487. } else {
  20488. output = output + space + languages[currentLanguage].currency.symbol;
  20489. }
  20490. }
  20491. return output;
  20492. }
  20493. function formatPercentage(n, format, roundingFunction) {
  20494. var space = '',
  20495. output,
  20496. value = n._value * 100;
  20497. if (format.indexOf(' %') > -1) {
  20498. space = ' ';
  20499. format = format.replace(' %', '');
  20500. } else {
  20501. format = format.replace('%', '');
  20502. }
  20503. output = formatNumber(value, format, roundingFunction);
  20504. if (output.indexOf(')') > -1) {
  20505. output = output.split('');
  20506. output.splice(-1, 0, space + '%');
  20507. output = output.join('');
  20508. } else {
  20509. output = output + space + '%';
  20510. }
  20511. return output;
  20512. }
  20513. function formatTime(n) {
  20514. var hours = Math.floor(n._value / 60 / 60),
  20515. minutes = Math.floor((n._value - (hours * 60 * 60)) / 60),
  20516. seconds = Math.round(n._value - (hours * 60 * 60) - (minutes * 60));
  20517. return hours + ':' + ((minutes < 10) ? '0' + minutes : minutes) + ':' + ((seconds < 10) ? '0' + seconds : seconds);
  20518. }
  20519. function unformatTime(string) {
  20520. var timeArray = string.split(':'),
  20521. seconds = 0;
  20522. if (timeArray.length === 3) {
  20523. seconds = seconds + (Number(timeArray[0]) * 60 * 60);
  20524. seconds = seconds + (Number(timeArray[1]) * 60);
  20525. seconds = seconds + Number(timeArray[2]);
  20526. } else if (timeArray.length === 2) {
  20527. seconds = seconds + (Number(timeArray[0]) * 60);
  20528. seconds = seconds + Number(timeArray[1]);
  20529. }
  20530. return Number(seconds);
  20531. }
  20532. function formatNumber(value, format, roundingFunction) {
  20533. var negP = false,
  20534. signed = false,
  20535. optDec = false,
  20536. abbr = '',
  20537. abbrK = false,
  20538. abbrM = false,
  20539. abbrB = false,
  20540. abbrT = false,
  20541. abbrForce = false,
  20542. bytes = '',
  20543. ord = '',
  20544. abs = Math.abs(value),
  20545. suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
  20546. min,
  20547. max,
  20548. power,
  20549. w,
  20550. precision,
  20551. thousands,
  20552. d = '',
  20553. neg = false;
  20554. if (value === 0 && zeroFormat !== null) {
  20555. return zeroFormat;
  20556. } else {
  20557. if (format.indexOf('(') > -1) {
  20558. negP = true;
  20559. format = format.slice(1, -1);
  20560. } else if (format.indexOf('+') > -1) {
  20561. signed = true;
  20562. format = format.replace(/\+/g, '');
  20563. }
  20564. if (format.indexOf('a') > -1) {
  20565. abbrK = format.indexOf('aK') >= 0;
  20566. abbrM = format.indexOf('aM') >= 0;
  20567. abbrB = format.indexOf('aB') >= 0;
  20568. abbrT = format.indexOf('aT') >= 0;
  20569. abbrForce = abbrK || abbrM || abbrB || abbrT;
  20570. if (format.indexOf(' a') > -1) {
  20571. abbr = ' ';
  20572. format = format.replace(' a', '');
  20573. } else {
  20574. format = format.replace('a', '');
  20575. }
  20576. if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) {
  20577. abbr = abbr + languages[currentLanguage].abbreviations.trillion;
  20578. value = value / Math.pow(10, 12);
  20579. } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) {
  20580. abbr = abbr + languages[currentLanguage].abbreviations.billion;
  20581. value = value / Math.pow(10, 9);
  20582. } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) {
  20583. abbr = abbr + languages[currentLanguage].abbreviations.million;
  20584. value = value / Math.pow(10, 6);
  20585. } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) {
  20586. abbr = abbr + languages[currentLanguage].abbreviations.thousand;
  20587. value = value / Math.pow(10, 3);
  20588. }
  20589. }
  20590. if (format.indexOf('b') > -1) {
  20591. if (format.indexOf(' b') > -1) {
  20592. bytes = ' ';
  20593. format = format.replace(' b', '');
  20594. } else {
  20595. format = format.replace('b', '');
  20596. }
  20597. for (power = 0; power <= suffixes.length; power++) {
  20598. min = Math.pow(1024, power);
  20599. max = Math.pow(1024, power + 1);
  20600. if (value >= min && value < max) {
  20601. bytes = bytes + suffixes[power];
  20602. if (min > 0) {
  20603. value = value / min;
  20604. }
  20605. break;
  20606. }
  20607. }
  20608. }
  20609. if (format.indexOf('o') > -1) {
  20610. if (format.indexOf(' o') > -1) {
  20611. ord = ' ';
  20612. format = format.replace(' o', '');
  20613. } else {
  20614. format = format.replace('o', '');
  20615. }
  20616. ord = ord + languages[currentLanguage].ordinal(value);
  20617. }
  20618. if (format.indexOf('[.]') > -1) {
  20619. optDec = true;
  20620. format = format.replace('[.]', '.');
  20621. }
  20622. w = value.toString().split('.')[0];
  20623. precision = format.split('.')[1];
  20624. thousands = format.indexOf(',');
  20625. if (precision) {
  20626. if (precision.indexOf('[') > -1) {
  20627. precision = precision.replace(']', '');
  20628. precision = precision.split('[');
  20629. d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length);
  20630. } else {
  20631. d = toFixed(value, precision.length, roundingFunction);
  20632. }
  20633. w = d.split('.')[0];
  20634. if (d.split('.')[1].length) {
  20635. d = languages[currentLanguage].delimiters.decimal + d.split('.')[1];
  20636. } else {
  20637. d = '';
  20638. }
  20639. if (optDec && Number(d.slice(1)) === 0) {
  20640. d = '';
  20641. }
  20642. } else {
  20643. w = toFixed(value, null, roundingFunction);
  20644. }
  20645. if (w.indexOf('-') > -1) {
  20646. w = w.slice(1);
  20647. neg = true;
  20648. }
  20649. if (thousands > -1) {
  20650. w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + languages[currentLanguage].delimiters.thousands);
  20651. }
  20652. if (format.indexOf('.') === 0) {
  20653. w = '';
  20654. }
  20655. return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((ord) ? ord : '') + ((abbr) ? abbr : '') + ((bytes) ? bytes : '') + ((negP && neg) ? ')' : '');
  20656. }
  20657. }
  20658. numeral = function(input) {
  20659. if (numeral.isNumeral(input)) {
  20660. input = input.value();
  20661. } else if (input === 0 || typeof input === 'undefined') {
  20662. input = 0;
  20663. } else if (!Number(input)) {
  20664. input = numeral.fn.unformat(input);
  20665. }
  20666. return new Numeral(Number(input));
  20667. };
  20668. numeral.version = VERSION;
  20669. numeral.isNumeral = function(obj) {
  20670. return obj instanceof Numeral;
  20671. };
  20672. numeral.language = function(key, values) {
  20673. if (!key) {
  20674. return currentLanguage;
  20675. }
  20676. if (key && !values) {
  20677. if (!languages[key]) {
  20678. throw new Error('Unknown language : ' + key);
  20679. }
  20680. currentLanguage = key;
  20681. }
  20682. if (values || !languages[key]) {
  20683. loadLanguage(key, values);
  20684. }
  20685. return numeral;
  20686. };
  20687. numeral.languageData = function(key) {
  20688. if (!key) {
  20689. return languages[currentLanguage];
  20690. }
  20691. if (!languages[key]) {
  20692. throw new Error('Unknown language : ' + key);
  20693. }
  20694. return languages[key];
  20695. };
  20696. numeral.language('en', {
  20697. delimiters: {
  20698. thousands: ',',
  20699. decimal: '.'
  20700. },
  20701. abbreviations: {
  20702. thousand: 'k',
  20703. million: 'm',
  20704. billion: 'b',
  20705. trillion: 't'
  20706. },
  20707. ordinal: function(number) {
  20708. var b = number % 10;
  20709. return (~~(number % 100 / 10) === 1) ? 'th' : (b === 1) ? 'st' : (b === 2) ? 'nd' : (b === 3) ? 'rd' : 'th';
  20710. },
  20711. currency: {symbol: '$'}
  20712. });
  20713. numeral.zeroFormat = function(format) {
  20714. zeroFormat = typeof(format) === 'string' ? format : null;
  20715. };
  20716. numeral.defaultFormat = function(format) {
  20717. defaultFormat = typeof(format) === 'string' ? format : '0.0';
  20718. };
  20719. numeral.validate = function(val, culture) {
  20720. var _decimalSep,
  20721. _thousandSep,
  20722. _currSymbol,
  20723. _valArray,
  20724. _abbrObj,
  20725. _thousandRegEx,
  20726. languageData,
  20727. temp;
  20728. if (typeof val !== 'string') {
  20729. val += '';
  20730. if (console.warn) {
  20731. console.warn('Numeral.js: Value is not string. It has been co-erced to: ', val);
  20732. }
  20733. }
  20734. val = val.trim();
  20735. if (val === '') {
  20736. return false;
  20737. }
  20738. val = val.replace(/^[+-]?/, '');
  20739. try {
  20740. languageData = numeral.languageData(culture);
  20741. } catch (e) {
  20742. languageData = numeral.languageData(numeral.language());
  20743. }
  20744. _currSymbol = languageData.currency.symbol;
  20745. _abbrObj = languageData.abbreviations;
  20746. _decimalSep = languageData.delimiters.decimal;
  20747. if (languageData.delimiters.thousands === '.') {
  20748. _thousandSep = '\\.';
  20749. } else {
  20750. _thousandSep = languageData.delimiters.thousands;
  20751. }
  20752. temp = val.match(/^[^\d\.\,]+/);
  20753. if (temp !== null) {
  20754. val = val.substr(1);
  20755. if (temp[0] !== _currSymbol) {
  20756. return false;
  20757. }
  20758. }
  20759. temp = val.match(/[^\d]+$/);
  20760. if (temp !== null) {
  20761. val = val.slice(0, -1);
  20762. if (temp[0] !== _abbrObj.thousand && temp[0] !== _abbrObj.million && temp[0] !== _abbrObj.billion && temp[0] !== _abbrObj.trillion) {
  20763. return false;
  20764. }
  20765. }
  20766. if (!!val.match(/^\d+$/)) {
  20767. return true;
  20768. }
  20769. _thousandRegEx = new RegExp(_thousandSep + '{2}');
  20770. if (!val.match(/[^\d.,]/g)) {
  20771. _valArray = val.split(_decimalSep);
  20772. if (_valArray.length > 2) {
  20773. return false;
  20774. } else {
  20775. if (_valArray.length < 2) {
  20776. return (!!_valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx));
  20777. } else {
  20778. if (_valArray[0] === '') {
  20779. return (!_valArray[0].match(_thousandRegEx) && !!_valArray[1].match(/^\d+$/));
  20780. } else if (_valArray[0].length === 1) {
  20781. return (!!_valArray[0].match(/^\d+$/) && !_valArray[0].match(_thousandRegEx) && !!_valArray[1].match(/^\d+$/));
  20782. } else {
  20783. return (!!_valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx) && !!_valArray[1].match(/^\d+$/));
  20784. }
  20785. }
  20786. }
  20787. }
  20788. return false;
  20789. };
  20790. function loadLanguage(key, values) {
  20791. languages[key] = values;
  20792. }
  20793. if ('function' !== typeof Array.prototype.reduce) {
  20794. Array.prototype.reduce = function(callback, opt_initialValue) {
  20795. 'use strict';
  20796. if (null === this || 'undefined' === typeof this) {
  20797. throw new TypeError('Array.prototype.reduce called on null or undefined');
  20798. }
  20799. if ('function' !== typeof callback) {
  20800. throw new TypeError(callback + ' is not a function');
  20801. }
  20802. var index,
  20803. value,
  20804. length = this.length >>> 0,
  20805. isValueSet = false;
  20806. if (1 < arguments.length) {
  20807. value = opt_initialValue;
  20808. isValueSet = true;
  20809. }
  20810. for (index = 0; length > index; ++index) {
  20811. if (this.hasOwnProperty(index)) {
  20812. if (isValueSet) {
  20813. value = callback(value, this[index], index, this);
  20814. } else {
  20815. value = this[index];
  20816. isValueSet = true;
  20817. }
  20818. }
  20819. }
  20820. if (!isValueSet) {
  20821. throw new TypeError('Reduce of empty array with no initial value');
  20822. }
  20823. return value;
  20824. };
  20825. }
  20826. function multiplier(x) {
  20827. var parts = x.toString().split('.');
  20828. if (parts.length < 2) {
  20829. return 1;
  20830. }
  20831. return Math.pow(10, parts[1].length);
  20832. }
  20833. function correctionFactor() {
  20834. var args = Array.prototype.slice.call(arguments);
  20835. return args.reduce(function(prev, next) {
  20836. var mp = multiplier(prev),
  20837. mn = multiplier(next);
  20838. return mp > mn ? mp : mn;
  20839. }, -Infinity);
  20840. }
  20841. numeral.fn = Numeral.prototype = {
  20842. clone: function() {
  20843. return numeral(this);
  20844. },
  20845. format: function(inputString, roundingFunction) {
  20846. return formatNumeral(this, inputString ? inputString : defaultFormat, (roundingFunction !== undefined) ? roundingFunction : Math.round);
  20847. },
  20848. unformat: function(inputString) {
  20849. if (Object.prototype.toString.call(inputString) === '[object Number]') {
  20850. return inputString;
  20851. }
  20852. return unformatNumeral(this, inputString ? inputString : defaultFormat);
  20853. },
  20854. value: function() {
  20855. return this._value;
  20856. },
  20857. valueOf: function() {
  20858. return this._value;
  20859. },
  20860. set: function(value) {
  20861. this._value = Number(value);
  20862. return this;
  20863. },
  20864. add: function(value) {
  20865. var corrFactor = correctionFactor.call(null, this._value, value);
  20866. function cback(accum, curr, currI, O) {
  20867. return accum + corrFactor * curr;
  20868. }
  20869. this._value = [this._value, value].reduce(cback, 0) / corrFactor;
  20870. return this;
  20871. },
  20872. subtract: function(value) {
  20873. var corrFactor = correctionFactor.call(null, this._value, value);
  20874. function cback(accum, curr, currI, O) {
  20875. return accum - corrFactor * curr;
  20876. }
  20877. this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor;
  20878. return this;
  20879. },
  20880. multiply: function(value) {
  20881. function cback(accum, curr, currI, O) {
  20882. var corrFactor = correctionFactor(accum, curr);
  20883. return (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor);
  20884. }
  20885. this._value = [this._value, value].reduce(cback, 1);
  20886. return this;
  20887. },
  20888. divide: function(value) {
  20889. function cback(accum, curr, currI, O) {
  20890. var corrFactor = correctionFactor(accum, curr);
  20891. return (accum * corrFactor) / (curr * corrFactor);
  20892. }
  20893. this._value = [this._value, value].reduce(cback);
  20894. return this;
  20895. },
  20896. difference: function(value) {
  20897. return Math.abs(numeral(this._value).subtract(value).value());
  20898. }
  20899. };
  20900. if (hasModule) {
  20901. module.exports = numeral;
  20902. }
  20903. if (typeof ender === 'undefined') {
  20904. this['numeral'] = numeral;
  20905. }
  20906. if (typeof define === 'function' && define.amd) {
  20907. define([], function() {
  20908. return numeral;
  20909. });
  20910. }
  20911. }).call(window);
  20912. //#
  20913. },{}],"pikaday":[function(require,module,exports){
  20914. /*!
  20915. * Pikaday
  20916. *
  20917. * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
  20918. */
  20919. (function (root, factory)
  20920. {
  20921. 'use strict';
  20922. var moment;
  20923. if (typeof exports === 'object') {
  20924. // CommonJS module
  20925. // Load moment.js as an optional dependency
  20926. try { moment = require('moment'); } catch (e) {}
  20927. module.exports = factory(moment);
  20928. } else if (typeof define === 'function' && define.amd) {
  20929. // AMD. Register as an anonymous module.
  20930. define(function (req)
  20931. {
  20932. // Load moment.js as an optional dependency
  20933. var id = 'moment';
  20934. try { moment = req(id); } catch (e) {}
  20935. return factory(moment);
  20936. });
  20937. } else {
  20938. root.Pikaday = factory(root.moment);
  20939. }
  20940. }(this, function (moment)
  20941. {
  20942. 'use strict';
  20943. /**
  20944. * feature detection and helper functions
  20945. */
  20946. var hasMoment = typeof moment === 'function',
  20947. hasEventListeners = !!window.addEventListener,
  20948. document = window.document,
  20949. sto = window.setTimeout,
  20950. addEvent = function(el, e, callback, capture)
  20951. {
  20952. if (hasEventListeners) {
  20953. el.addEventListener(e, callback, !!capture);
  20954. } else {
  20955. el.attachEvent('on' + e, callback);
  20956. }
  20957. },
  20958. removeEvent = function(el, e, callback, capture)
  20959. {
  20960. if (hasEventListeners) {
  20961. el.removeEventListener(e, callback, !!capture);
  20962. } else {
  20963. el.detachEvent('on' + e, callback);
  20964. }
  20965. },
  20966. fireEvent = function(el, eventName, data)
  20967. {
  20968. var ev;
  20969. if (document.createEvent) {
  20970. ev = document.createEvent('HTMLEvents');
  20971. ev.initEvent(eventName, true, false);
  20972. ev = extend(ev, data);
  20973. el.dispatchEvent(ev);
  20974. } else if (document.createEventObject) {
  20975. ev = document.createEventObject();
  20976. ev = extend(ev, data);
  20977. el.fireEvent('on' + eventName, ev);
  20978. }
  20979. },
  20980. trim = function(str)
  20981. {
  20982. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,'');
  20983. },
  20984. hasClass = function(el, cn)
  20985. {
  20986. return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1;
  20987. },
  20988. addClass = function(el, cn)
  20989. {
  20990. if (!hasClass(el, cn)) {
  20991. el.className = (el.className === '') ? cn : el.className + ' ' + cn;
  20992. }
  20993. },
  20994. removeClass = function(el, cn)
  20995. {
  20996. el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' '));
  20997. },
  20998. isArray = function(obj)
  20999. {
  21000. return (/Array/).test(Object.prototype.toString.call(obj));
  21001. },
  21002. isDate = function(obj)
  21003. {
  21004. return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
  21005. },
  21006. isWeekend = function(date)
  21007. {
  21008. var day = date.getDay();
  21009. return day === 0 || day === 6;
  21010. },
  21011. isLeapYear = function(year)
  21012. {
  21013. // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
  21014. return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
  21015. },
  21016. getDaysInMonth = function(year, month)
  21017. {
  21018. return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
  21019. },
  21020. setToStartOfDay = function(date)
  21021. {
  21022. if (isDate(date)) date.setHours(0,0,0,0);
  21023. },
  21024. compareDates = function(a,b)
  21025. {
  21026. // weak date comparison (use setToStartOfDay(date) to ensure correct result)
  21027. return a.getTime() === b.getTime();
  21028. },
  21029. extend = function(to, from, overwrite)
  21030. {
  21031. var prop, hasProp;
  21032. for (prop in from) {
  21033. hasProp = to[prop] !== undefined;
  21034. if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) {
  21035. if (isDate(from[prop])) {
  21036. if (overwrite) {
  21037. to[prop] = new Date(from[prop].getTime());
  21038. }
  21039. }
  21040. else if (isArray(from[prop])) {
  21041. if (overwrite) {
  21042. to[prop] = from[prop].slice(0);
  21043. }
  21044. } else {
  21045. to[prop] = extend({}, from[prop], overwrite);
  21046. }
  21047. } else if (overwrite || !hasProp) {
  21048. to[prop] = from[prop];
  21049. }
  21050. }
  21051. return to;
  21052. },
  21053. adjustCalendar = function(calendar) {
  21054. if (calendar.month < 0) {
  21055. calendar.year -= Math.ceil(Math.abs(calendar.month)/12);
  21056. calendar.month += 12;
  21057. }
  21058. if (calendar.month > 11) {
  21059. calendar.year += Math.floor(Math.abs(calendar.month)/12);
  21060. calendar.month -= 12;
  21061. }
  21062. return calendar;
  21063. },
  21064. /**
  21065. * defaults and localisation
  21066. */
  21067. defaults = {
  21068. // bind the picker to a form field
  21069. field: null,
  21070. // automatically show/hide the picker on `field` focus (default `true` if `field` is set)
  21071. bound: undefined,
  21072. // position of the datepicker, relative to the field (default to bottom & left)
  21073. // ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
  21074. position: 'bottom left',
  21075. // automatically fit in the viewport even if it means repositioning from the position option
  21076. reposition: true,
  21077. // the default output format for `.toString()` and `field` value
  21078. format: 'YYYY-MM-DD',
  21079. // the initial date to view when first opened
  21080. defaultDate: null,
  21081. // make the `defaultDate` the initial selected value
  21082. setDefaultDate: false,
  21083. // first day of week (0: Sunday, 1: Monday etc)
  21084. firstDay: 0,
  21085. // the minimum/earliest date that can be selected
  21086. minDate: null,
  21087. // the maximum/latest date that can be selected
  21088. maxDate: null,
  21089. // number of years either side, or array of upper/lower range
  21090. yearRange: 10,
  21091. // show week numbers at head of row
  21092. showWeekNumber: false,
  21093. // used internally (don't config outside)
  21094. minYear: 0,
  21095. maxYear: 9999,
  21096. minMonth: undefined,
  21097. maxMonth: undefined,
  21098. isRTL: false,
  21099. // Additional text to append to the year in the calendar title
  21100. yearSuffix: '',
  21101. // Render the month after year in the calendar title
  21102. showMonthAfterYear: false,
  21103. // how many months are visible
  21104. numberOfMonths: 1,
  21105. // when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`)
  21106. // only used for the first display or when a selected date is not visible
  21107. mainCalendar: 'left',
  21108. // Specify a DOM element to render the calendar in
  21109. container: undefined,
  21110. // internationalization
  21111. i18n: {
  21112. previousMonth : 'Previous Month',
  21113. nextMonth : 'Next Month',
  21114. months : ['January','February','March','April','May','June','July','August','September','October','November','December'],
  21115. weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
  21116. weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
  21117. },
  21118. // callback function
  21119. onSelect: null,
  21120. onOpen: null,
  21121. onClose: null,
  21122. onDraw: null
  21123. },
  21124. /**
  21125. * templating functions to abstract HTML rendering
  21126. */
  21127. renderDayName = function(opts, day, abbr)
  21128. {
  21129. day += opts.firstDay;
  21130. while (day >= 7) {
  21131. day -= 7;
  21132. }
  21133. return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day];
  21134. },
  21135. renderDay = function(d, m, y, isSelected, isToday, isDisabled, isEmpty)
  21136. {
  21137. if (isEmpty) {
  21138. return '<td class="is-empty"></td>';
  21139. }
  21140. var arr = [];
  21141. if (isDisabled) {
  21142. arr.push('is-disabled');
  21143. }
  21144. if (isToday) {
  21145. arr.push('is-today');
  21146. }
  21147. if (isSelected) {
  21148. arr.push('is-selected');
  21149. }
  21150. return '<td data-day="' + d + '" class="' + arr.join(' ') + '">' +
  21151. '<button class="pika-button pika-day" type="button" ' +
  21152. 'data-pika-year="' + y + '" data-pika-month="' + m + '" data-pika-day="' + d + '">' +
  21153. d +
  21154. '</button>' +
  21155. '</td>';
  21156. },
  21157. renderWeek = function (d, m, y) {
  21158. // Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified.
  21159. var onejan = new Date(y, 0, 1),
  21160. weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay()+1)/7);
  21161. return '<td class="pika-week">' + weekNum + '</td>';
  21162. },
  21163. renderRow = function(days, isRTL)
  21164. {
  21165. return '<tr>' + (isRTL ? days.reverse() : days).join('') + '</tr>';
  21166. },
  21167. renderBody = function(rows)
  21168. {
  21169. return '<tbody>' + rows.join('') + '</tbody>';
  21170. },
  21171. renderHead = function(opts)
  21172. {
  21173. var i, arr = [];
  21174. if (opts.showWeekNumber) {
  21175. arr.push('<th></th>');
  21176. }
  21177. for (i = 0; i < 7; i++) {
  21178. arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
  21179. }
  21180. return '<thead>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</thead>';
  21181. },
  21182. renderTitle = function(instance, c, year, month, refYear)
  21183. {
  21184. var i, j, arr,
  21185. opts = instance._o,
  21186. isMinYear = year === opts.minYear,
  21187. isMaxYear = year === opts.maxYear,
  21188. html = '<div class="pika-title">',
  21189. monthHtml,
  21190. yearHtml,
  21191. prev = true,
  21192. next = true;
  21193. for (arr = [], i = 0; i < 12; i++) {
  21194. arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' +
  21195. (i === month ? ' selected': '') +
  21196. ((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled' : '') + '>' +
  21197. opts.i18n.months[i] + '</option>');
  21198. }
  21199. monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select class="pika-select pika-select-month">' + arr.join('') + '</select></div>';
  21200. if (isArray(opts.yearRange)) {
  21201. i = opts.yearRange[0];
  21202. j = opts.yearRange[1] + 1;
  21203. } else {
  21204. i = year - opts.yearRange;
  21205. j = 1 + year + opts.yearRange;
  21206. }
  21207. for (arr = []; i < j && i <= opts.maxYear; i++) {
  21208. if (i >= opts.minYear) {
  21209. arr.push('<option value="' + i + '"' + (i === year ? ' selected': '') + '>' + (i) + '</option>');
  21210. }
  21211. }
  21212. yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select class="pika-select pika-select-year">' + arr.join('') + '</select></div>';
  21213. if (opts.showMonthAfterYear) {
  21214. html += yearHtml + monthHtml;
  21215. } else {
  21216. html += monthHtml + yearHtml;
  21217. }
  21218. if (isMinYear && (month === 0 || opts.minMonth >= month)) {
  21219. prev = false;
  21220. }
  21221. if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
  21222. next = false;
  21223. }
  21224. if (c === 0) {
  21225. html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
  21226. }
  21227. if (c === (instance._o.numberOfMonths - 1) ) {
  21228. html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
  21229. }
  21230. return html += '</div>';
  21231. },
  21232. renderTable = function(opts, data)
  21233. {
  21234. return '<table cellpadding="0" cellspacing="0" class="pika-table">' + renderHead(opts) + renderBody(data) + '</table>';
  21235. },
  21236. /**
  21237. * Pikaday constructor
  21238. */
  21239. Pikaday = function(options)
  21240. {
  21241. var self = this,
  21242. opts = self.config(options);
  21243. self._onMouseDown = function(e)
  21244. {
  21245. if (!self._v) {
  21246. return;
  21247. }
  21248. e = e || window.event;
  21249. var target = e.target || e.srcElement;
  21250. if (!target) {
  21251. return;
  21252. }
  21253. if (!hasClass(target, 'is-disabled')) {
  21254. if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty')) {
  21255. self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day')));
  21256. if (opts.bound) {
  21257. sto(function() {
  21258. self.hide();
  21259. if (opts.field) {
  21260. opts.field.blur();
  21261. }
  21262. }, 100);
  21263. }
  21264. return;
  21265. }
  21266. else if (hasClass(target, 'pika-prev')) {
  21267. self.prevMonth();
  21268. }
  21269. else if (hasClass(target, 'pika-next')) {
  21270. self.nextMonth();
  21271. }
  21272. }
  21273. if (!hasClass(target, 'pika-select')) {
  21274. if (e.preventDefault) {
  21275. e.preventDefault();
  21276. } else {
  21277. e.returnValue = false;
  21278. return false;
  21279. }
  21280. } else {
  21281. self._c = true;
  21282. }
  21283. };
  21284. self._onChange = function(e)
  21285. {
  21286. e = e || window.event;
  21287. var target = e.target || e.srcElement;
  21288. if (!target) {
  21289. return;
  21290. }
  21291. if (hasClass(target, 'pika-select-month')) {
  21292. self.gotoMonth(target.value);
  21293. }
  21294. else if (hasClass(target, 'pika-select-year')) {
  21295. self.gotoYear(target.value);
  21296. }
  21297. };
  21298. self._onInputChange = function(e)
  21299. {
  21300. var date;
  21301. if (e.firedBy === self) {
  21302. return;
  21303. }
  21304. if (hasMoment) {
  21305. date = moment(opts.field.value, opts.format);
  21306. date = (date && date.isValid()) ? date.toDate() : null;
  21307. }
  21308. else {
  21309. date = new Date(Date.parse(opts.field.value));
  21310. }
  21311. self.setDate(isDate(date) ? date : null);
  21312. if (!self._v) {
  21313. self.show();
  21314. }
  21315. };
  21316. self._onInputFocus = function()
  21317. {
  21318. self.show();
  21319. };
  21320. self._onInputClick = function()
  21321. {
  21322. self.show();
  21323. };
  21324. self._onInputBlur = function()
  21325. {
  21326. // IE allows pika div to gain focus; catch blur the input field
  21327. var pEl = document.activeElement;
  21328. do {
  21329. if (hasClass(pEl, 'pika-single')) {
  21330. return;
  21331. }
  21332. }
  21333. while ((pEl = pEl.parentNode));
  21334. if (!self._c) {
  21335. self._b = sto(function() {
  21336. self.hide();
  21337. }, 50);
  21338. }
  21339. self._c = false;
  21340. };
  21341. self._onClick = function(e)
  21342. {
  21343. e = e || window.event;
  21344. var target = e.target || e.srcElement,
  21345. pEl = target;
  21346. if (!target) {
  21347. return;
  21348. }
  21349. if (!hasEventListeners && hasClass(target, 'pika-select')) {
  21350. if (!target.onchange) {
  21351. target.setAttribute('onchange', 'return;');
  21352. addEvent(target, 'change', self._onChange);
  21353. }
  21354. }
  21355. do {
  21356. if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) {
  21357. return;
  21358. }
  21359. }
  21360. while ((pEl = pEl.parentNode));
  21361. if (self._v && target !== opts.trigger && pEl !== opts.trigger) {
  21362. self.hide();
  21363. }
  21364. };
  21365. self.el = document.createElement('div');
  21366. self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '');
  21367. addEvent(self.el, 'mousedown', self._onMouseDown, true);
  21368. addEvent(self.el, 'change', self._onChange);
  21369. if (opts.field) {
  21370. if (opts.container) {
  21371. opts.container.appendChild(self.el);
  21372. } else if (opts.bound) {
  21373. document.body.appendChild(self.el);
  21374. } else {
  21375. opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling);
  21376. }
  21377. addEvent(opts.field, 'change', self._onInputChange);
  21378. if (!opts.defaultDate) {
  21379. if (hasMoment && opts.field.value) {
  21380. opts.defaultDate = moment(opts.field.value, opts.format).toDate();
  21381. } else {
  21382. opts.defaultDate = new Date(Date.parse(opts.field.value));
  21383. }
  21384. opts.setDefaultDate = true;
  21385. }
  21386. }
  21387. var defDate = opts.defaultDate;
  21388. if (isDate(defDate)) {
  21389. if (opts.setDefaultDate) {
  21390. self.setDate(defDate, true);
  21391. } else {
  21392. self.gotoDate(defDate);
  21393. }
  21394. } else {
  21395. self.gotoDate(new Date());
  21396. }
  21397. if (opts.bound) {
  21398. this.hide();
  21399. self.el.className += ' is-bound';
  21400. addEvent(opts.trigger, 'click', self._onInputClick);
  21401. addEvent(opts.trigger, 'focus', self._onInputFocus);
  21402. addEvent(opts.trigger, 'blur', self._onInputBlur);
  21403. } else {
  21404. this.show();
  21405. }
  21406. };
  21407. /**
  21408. * public Pikaday API
  21409. */
  21410. Pikaday.prototype = {
  21411. /**
  21412. * configure functionality
  21413. */
  21414. config: function(options)
  21415. {
  21416. if (!this._o) {
  21417. this._o = extend({}, defaults, true);
  21418. }
  21419. var opts = extend(this._o, options, true);
  21420. opts.isRTL = !!opts.isRTL;
  21421. opts.field = (opts.field && opts.field.nodeName) ? opts.field : null;
  21422. opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field);
  21423. opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field;
  21424. opts.disableWeekends = !!opts.disableWeekends;
  21425. opts.disableDayFn = (typeof opts.disableDayFn) == "function" ? opts.disableDayFn : null;
  21426. var nom = parseInt(opts.numberOfMonths, 10) || 1;
  21427. opts.numberOfMonths = nom > 4 ? 4 : nom;
  21428. if (!isDate(opts.minDate)) {
  21429. opts.minDate = false;
  21430. }
  21431. if (!isDate(opts.maxDate)) {
  21432. opts.maxDate = false;
  21433. }
  21434. if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) {
  21435. opts.maxDate = opts.minDate = false;
  21436. }
  21437. if (opts.minDate) {
  21438. setToStartOfDay(opts.minDate);
  21439. opts.minYear = opts.minDate.getFullYear();
  21440. opts.minMonth = opts.minDate.getMonth();
  21441. }
  21442. if (opts.maxDate) {
  21443. setToStartOfDay(opts.maxDate);
  21444. opts.maxYear = opts.maxDate.getFullYear();
  21445. opts.maxMonth = opts.maxDate.getMonth();
  21446. }
  21447. if (isArray(opts.yearRange)) {
  21448. var fallback = new Date().getFullYear() - 10;
  21449. opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback;
  21450. opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback;
  21451. } else {
  21452. opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange;
  21453. if (opts.yearRange > 100) {
  21454. opts.yearRange = 100;
  21455. }
  21456. }
  21457. return opts;
  21458. },
  21459. /**
  21460. * return a formatted string of the current selection (using Moment.js if available)
  21461. */
  21462. toString: function(format)
  21463. {
  21464. return !isDate(this._d) ? '' : hasMoment ? moment(this._d).format(format || this._o.format) : this._d.toDateString();
  21465. },
  21466. /**
  21467. * return a Moment.js object of the current selection (if available)
  21468. */
  21469. getMoment: function()
  21470. {
  21471. return hasMoment ? moment(this._d) : null;
  21472. },
  21473. /**
  21474. * set the current selection from a Moment.js object (if available)
  21475. */
  21476. setMoment: function(date, preventOnSelect)
  21477. {
  21478. if (hasMoment && moment.isMoment(date)) {
  21479. this.setDate(date.toDate(), preventOnSelect);
  21480. }
  21481. },
  21482. /**
  21483. * return a Date object of the current selection
  21484. */
  21485. getDate: function()
  21486. {
  21487. return isDate(this._d) ? new Date(this._d.getTime()) : null;
  21488. },
  21489. /**
  21490. * set the current selection
  21491. */
  21492. setDate: function(date, preventOnSelect)
  21493. {
  21494. if (!date) {
  21495. this._d = null;
  21496. if (this._o.field) {
  21497. this._o.field.value = '';
  21498. fireEvent(this._o.field, 'change', { firedBy: this });
  21499. }
  21500. return this.draw();
  21501. }
  21502. if (typeof date === 'string') {
  21503. date = new Date(Date.parse(date));
  21504. }
  21505. if (!isDate(date)) {
  21506. return;
  21507. }
  21508. var min = this._o.minDate,
  21509. max = this._o.maxDate;
  21510. if (isDate(min) && date < min) {
  21511. date = min;
  21512. } else if (isDate(max) && date > max) {
  21513. date = max;
  21514. }
  21515. this._d = new Date(date.getTime());
  21516. setToStartOfDay(this._d);
  21517. this.gotoDate(this._d);
  21518. if (this._o.field) {
  21519. this._o.field.value = this.toString();
  21520. fireEvent(this._o.field, 'change', { firedBy: this });
  21521. }
  21522. if (!preventOnSelect && typeof this._o.onSelect === 'function') {
  21523. this._o.onSelect.call(this, this.getDate());
  21524. }
  21525. },
  21526. /**
  21527. * change view to a specific date
  21528. */
  21529. gotoDate: function(date)
  21530. {
  21531. var newCalendar = true;
  21532. if (!isDate(date)) {
  21533. return;
  21534. }
  21535. if (this.calendars) {
  21536. var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1),
  21537. lastVisibleDate = new Date(this.calendars[this.calendars.length-1].year, this.calendars[this.calendars.length-1].month, 1),
  21538. visibleDate = date.getTime();
  21539. // get the end of the month
  21540. lastVisibleDate.setMonth(lastVisibleDate.getMonth()+1);
  21541. lastVisibleDate.setDate(lastVisibleDate.getDate()-1);
  21542. newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate);
  21543. }
  21544. if (newCalendar) {
  21545. this.calendars = [{
  21546. month: date.getMonth(),
  21547. year: date.getFullYear()
  21548. }];
  21549. if (this._o.mainCalendar === 'right') {
  21550. this.calendars[0].month += 1 - this._o.numberOfMonths;
  21551. }
  21552. }
  21553. this.adjustCalendars();
  21554. },
  21555. adjustCalendars: function() {
  21556. this.calendars[0] = adjustCalendar(this.calendars[0]);
  21557. for (var c = 1; c < this._o.numberOfMonths; c++) {
  21558. this.calendars[c] = adjustCalendar({
  21559. month: this.calendars[0].month + c,
  21560. year: this.calendars[0].year
  21561. });
  21562. }
  21563. this.draw();
  21564. },
  21565. gotoToday: function()
  21566. {
  21567. this.gotoDate(new Date());
  21568. },
  21569. /**
  21570. * change view to a specific month (zero-index, e.g. 0: January)
  21571. */
  21572. gotoMonth: function(month)
  21573. {
  21574. if (!isNaN(month)) {
  21575. this.calendars[0].month = parseInt(month, 10);
  21576. this.adjustCalendars();
  21577. }
  21578. },
  21579. nextMonth: function()
  21580. {
  21581. this.calendars[0].month++;
  21582. this.adjustCalendars();
  21583. },
  21584. prevMonth: function()
  21585. {
  21586. this.calendars[0].month--;
  21587. this.adjustCalendars();
  21588. },
  21589. /**
  21590. * change view to a specific full year (e.g. "2012")
  21591. */
  21592. gotoYear: function(year)
  21593. {
  21594. if (!isNaN(year)) {
  21595. this.calendars[0].year = parseInt(year, 10);
  21596. this.adjustCalendars();
  21597. }
  21598. },
  21599. /**
  21600. * change the minDate
  21601. */
  21602. setMinDate: function(value)
  21603. {
  21604. this._o.minDate = value;
  21605. },
  21606. /**
  21607. * change the maxDate
  21608. */
  21609. setMaxDate: function(value)
  21610. {
  21611. this._o.maxDate = value;
  21612. },
  21613. /**
  21614. * refresh the HTML
  21615. */
  21616. draw: function(force)
  21617. {
  21618. if (!this._v && !force) {
  21619. return;
  21620. }
  21621. var opts = this._o,
  21622. minYear = opts.minYear,
  21623. maxYear = opts.maxYear,
  21624. minMonth = opts.minMonth,
  21625. maxMonth = opts.maxMonth,
  21626. html = '';
  21627. if (this._y <= minYear) {
  21628. this._y = minYear;
  21629. if (!isNaN(minMonth) && this._m < minMonth) {
  21630. this._m = minMonth;
  21631. }
  21632. }
  21633. if (this._y >= maxYear) {
  21634. this._y = maxYear;
  21635. if (!isNaN(maxMonth) && this._m > maxMonth) {
  21636. this._m = maxMonth;
  21637. }
  21638. }
  21639. for (var c = 0; c < opts.numberOfMonths; c++) {
  21640. 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>';
  21641. }
  21642. this.el.innerHTML = html;
  21643. if (opts.bound) {
  21644. if(opts.field.type !== 'hidden') {
  21645. sto(function() {
  21646. opts.trigger.focus();
  21647. }, 1);
  21648. }
  21649. }
  21650. if (typeof this._o.onDraw === 'function') {
  21651. var self = this;
  21652. sto(function() {
  21653. self._o.onDraw.call(self);
  21654. }, 0);
  21655. }
  21656. },
  21657. adjustPosition: function()
  21658. {
  21659. if (this._o.container) return;
  21660. var field = this._o.trigger, pEl = field,
  21661. width = this.el.offsetWidth, height = this.el.offsetHeight,
  21662. viewportWidth = window.innerWidth || document.documentElement.clientWidth,
  21663. viewportHeight = window.innerHeight || document.documentElement.clientHeight,
  21664. scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop,
  21665. left, top, clientRect;
  21666. if (typeof field.getBoundingClientRect === 'function') {
  21667. clientRect = field.getBoundingClientRect();
  21668. left = clientRect.left + window.pageXOffset;
  21669. top = clientRect.bottom + window.pageYOffset;
  21670. } else {
  21671. left = pEl.offsetLeft;
  21672. top = pEl.offsetTop + pEl.offsetHeight;
  21673. while((pEl = pEl.offsetParent)) {
  21674. left += pEl.offsetLeft;
  21675. top += pEl.offsetTop;
  21676. }
  21677. }
  21678. // default position is bottom & left
  21679. if ((this._o.reposition && left + width > viewportWidth) ||
  21680. (
  21681. this._o.position.indexOf('right') > -1 &&
  21682. left - width + field.offsetWidth > 0
  21683. )
  21684. ) {
  21685. left = left - width + field.offsetWidth;
  21686. }
  21687. if ((this._o.reposition && top + height > viewportHeight + scrollTop) ||
  21688. (
  21689. this._o.position.indexOf('top') > -1 &&
  21690. top - height - field.offsetHeight > 0
  21691. )
  21692. ) {
  21693. top = top - height - field.offsetHeight;
  21694. }
  21695. this.el.style.cssText = [
  21696. 'position: absolute',
  21697. 'left: ' + left + 'px',
  21698. 'top: ' + top + 'px'
  21699. ].join(';');
  21700. },
  21701. /**
  21702. * render HTML for a particular month
  21703. */
  21704. render: function(year, month)
  21705. {
  21706. var opts = this._o,
  21707. now = new Date(),
  21708. days = getDaysInMonth(year, month),
  21709. before = new Date(year, month, 1).getDay(),
  21710. data = [],
  21711. row = [];
  21712. setToStartOfDay(now);
  21713. if (opts.firstDay > 0) {
  21714. before -= opts.firstDay;
  21715. if (before < 0) {
  21716. before += 7;
  21717. }
  21718. }
  21719. var cells = days + before,
  21720. after = cells;
  21721. while(after > 7) {
  21722. after -= 7;
  21723. }
  21724. cells += 7 - after;
  21725. for (var i = 0, r = 0; i < cells; i++)
  21726. {
  21727. var day = new Date(year, month, 1 + (i - before)),
  21728. isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
  21729. isToday = compareDates(day, now),
  21730. isEmpty = i < before || i >= (days + before),
  21731. isDisabled = (opts.minDate && day < opts.minDate) ||
  21732. (opts.maxDate && day > opts.maxDate) ||
  21733. (opts.disableWeekends && isWeekend(day)) ||
  21734. (opts.disableDayFn && opts.disableDayFn(day));
  21735. row.push(renderDay(1 + (i - before), month, year, isSelected, isToday, isDisabled, isEmpty));
  21736. if (++r === 7) {
  21737. if (opts.showWeekNumber) {
  21738. row.unshift(renderWeek(i - before, month, year));
  21739. }
  21740. data.push(renderRow(row, opts.isRTL));
  21741. row = [];
  21742. r = 0;
  21743. }
  21744. }
  21745. return renderTable(opts, data);
  21746. },
  21747. isVisible: function()
  21748. {
  21749. return this._v;
  21750. },
  21751. show: function()
  21752. {
  21753. if (!this._v) {
  21754. removeClass(this.el, 'is-hidden');
  21755. this._v = true;
  21756. this.draw();
  21757. if (this._o.bound) {
  21758. addEvent(document, 'click', this._onClick);
  21759. this.adjustPosition();
  21760. }
  21761. if (typeof this._o.onOpen === 'function') {
  21762. this._o.onOpen.call(this);
  21763. }
  21764. }
  21765. },
  21766. hide: function()
  21767. {
  21768. var v = this._v;
  21769. if (v !== false) {
  21770. if (this._o.bound) {
  21771. removeEvent(document, 'click', this._onClick);
  21772. }
  21773. this.el.style.cssText = '';
  21774. addClass(this.el, 'is-hidden');
  21775. this._v = false;
  21776. if (v !== undefined && typeof this._o.onClose === 'function') {
  21777. this._o.onClose.call(this);
  21778. }
  21779. }
  21780. },
  21781. /**
  21782. * GAME OVER
  21783. */
  21784. destroy: function()
  21785. {
  21786. this.hide();
  21787. removeEvent(this.el, 'mousedown', this._onMouseDown, true);
  21788. removeEvent(this.el, 'change', this._onChange);
  21789. if (this._o.field) {
  21790. removeEvent(this._o.field, 'change', this._onInputChange);
  21791. if (this._o.bound) {
  21792. removeEvent(this._o.trigger, 'click', this._onInputClick);
  21793. removeEvent(this._o.trigger, 'focus', this._onInputFocus);
  21794. removeEvent(this._o.trigger, 'blur', this._onInputBlur);
  21795. }
  21796. }
  21797. if (this.el.parentNode) {
  21798. this.el.parentNode.removeChild(this.el);
  21799. }
  21800. }
  21801. };
  21802. return Pikaday;
  21803. }));
  21804. },{"moment":"moment"}],"zeroclipboard":[function(require,module,exports){
  21805. /*!
  21806. * ZeroClipboard
  21807. * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
  21808. * Copyright (c) 2009-2014 Jon Rohan, James M. Greene
  21809. * Licensed MIT
  21810. * http://zeroclipboard.org/
  21811. * v2.2.0
  21812. */
  21813. (function(window, undefined) {
  21814. "use strict";
  21815. /**
  21816. * Store references to critically important global functions that may be
  21817. * overridden on certain web pages.
  21818. */
  21819. 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() {
  21820. var unwrapper = function(el) {
  21821. return el;
  21822. };
  21823. if (typeof _window.wrap === "function" && typeof _window.unwrap === "function") {
  21824. try {
  21825. var div = _document.createElement("div");
  21826. var unwrappedDiv = _window.unwrap(div);
  21827. if (div.nodeType === 1 && unwrappedDiv && unwrappedDiv.nodeType === 1) {
  21828. unwrapper = _window.unwrap;
  21829. }
  21830. } catch (e) {}
  21831. }
  21832. return unwrapper;
  21833. }();
  21834. /**
  21835. * Convert an `arguments` object into an Array.
  21836. *
  21837. * @returns The arguments as an Array
  21838. * @private
  21839. */
  21840. var _args = function(argumentsObj) {
  21841. return _slice.call(argumentsObj, 0);
  21842. };
  21843. /**
  21844. * Shallow-copy the owned, enumerable properties of one object over to another, similar to jQuery's `$.extend`.
  21845. *
  21846. * @returns The target object, augmented
  21847. * @private
  21848. */
  21849. var _extend = function() {
  21850. var i, len, arg, prop, src, copy, args = _args(arguments), target = args[0] || {};
  21851. for (i = 1, len = args.length; i < len; i++) {
  21852. if ((arg = args[i]) != null) {
  21853. for (prop in arg) {
  21854. if (_hasOwn.call(arg, prop)) {
  21855. src = target[prop];
  21856. copy = arg[prop];
  21857. if (target !== copy && copy !== undefined) {
  21858. target[prop] = copy;
  21859. }
  21860. }
  21861. }
  21862. }
  21863. }
  21864. return target;
  21865. };
  21866. /**
  21867. * Return a deep copy of the source object or array.
  21868. *
  21869. * @returns Object or Array
  21870. * @private
  21871. */
  21872. var _deepCopy = function(source) {
  21873. var copy, i, len, prop;
  21874. if (typeof source !== "object" || source == null || typeof source.nodeType === "number") {
  21875. copy = source;
  21876. } else if (typeof source.length === "number") {
  21877. copy = [];
  21878. for (i = 0, len = source.length; i < len; i++) {
  21879. if (_hasOwn.call(source, i)) {
  21880. copy[i] = _deepCopy(source[i]);
  21881. }
  21882. }
  21883. } else {
  21884. copy = {};
  21885. for (prop in source) {
  21886. if (_hasOwn.call(source, prop)) {
  21887. copy[prop] = _deepCopy(source[prop]);
  21888. }
  21889. }
  21890. }
  21891. return copy;
  21892. };
  21893. /**
  21894. * Makes a shallow copy of `obj` (like `_extend`) but filters its properties based on a list of `keys` to keep.
  21895. * The inverse of `_omit`, mostly. The big difference is that these properties do NOT need to be enumerable to
  21896. * be kept.
  21897. *
  21898. * @returns A new filtered object.
  21899. * @private
  21900. */
  21901. var _pick = function(obj, keys) {
  21902. var newObj = {};
  21903. for (var i = 0, len = keys.length; i < len; i++) {
  21904. if (keys[i] in obj) {
  21905. newObj[keys[i]] = obj[keys[i]];
  21906. }
  21907. }
  21908. return newObj;
  21909. };
  21910. /**
  21911. * Makes a shallow copy of `obj` (like `_extend`) but filters its properties based on a list of `keys` to omit.
  21912. * The inverse of `_pick`.
  21913. *
  21914. * @returns A new filtered object.
  21915. * @private
  21916. */
  21917. var _omit = function(obj, keys) {
  21918. var newObj = {};
  21919. for (var prop in obj) {
  21920. if (keys.indexOf(prop) === -1) {
  21921. newObj[prop] = obj[prop];
  21922. }
  21923. }
  21924. return newObj;
  21925. };
  21926. /**
  21927. * Remove all owned, enumerable properties from an object.
  21928. *
  21929. * @returns The original object without its owned, enumerable properties.
  21930. * @private
  21931. */
  21932. var _deleteOwnProperties = function(obj) {
  21933. if (obj) {
  21934. for (var prop in obj) {
  21935. if (_hasOwn.call(obj, prop)) {
  21936. delete obj[prop];
  21937. }
  21938. }
  21939. }
  21940. return obj;
  21941. };
  21942. /**
  21943. * Determine if an element is contained within another element.
  21944. *
  21945. * @returns Boolean
  21946. * @private
  21947. */
  21948. var _containedBy = function(el, ancestorEl) {
  21949. 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)) {
  21950. do {
  21951. if (el === ancestorEl) {
  21952. return true;
  21953. }
  21954. el = el.parentNode;
  21955. } while (el);
  21956. }
  21957. return false;
  21958. };
  21959. /**
  21960. * Get the URL path's parent directory.
  21961. *
  21962. * @returns String or `undefined`
  21963. * @private
  21964. */
  21965. var _getDirPathOfUrl = function(url) {
  21966. var dir;
  21967. if (typeof url === "string" && url) {
  21968. dir = url.split("#")[0].split("?")[0];
  21969. dir = url.slice(0, url.lastIndexOf("/") + 1);
  21970. }
  21971. return dir;
  21972. };
  21973. /**
  21974. * Get the current script's URL by throwing an `Error` and analyzing it.
  21975. *
  21976. * @returns String or `undefined`
  21977. * @private
  21978. */
  21979. var _getCurrentScriptUrlFromErrorStack = function(stack) {
  21980. var url, matches;
  21981. if (typeof stack === "string" && stack) {
  21982. matches = stack.match(/^(?:|[^:@]*@|.+\)@(?=http[s]?|file)|.+?\s+(?: at |@)(?:[^:\(]+ )*[\(]?)((?:http[s]?|file):\/\/[\/]?.+?\/[^:\)]*?)(?::\d+)(?::\d+)?/);
  21983. if (matches && matches[1]) {
  21984. url = matches[1];
  21985. } else {
  21986. matches = stack.match(/\)@((?:http[s]?|file):\/\/[\/]?.+?\/[^:\)]*?)(?::\d+)(?::\d+)?/);
  21987. if (matches && matches[1]) {
  21988. url = matches[1];
  21989. }
  21990. }
  21991. }
  21992. return url;
  21993. };
  21994. /**
  21995. * Get the current script's URL by throwing an `Error` and analyzing it.
  21996. *
  21997. * @returns String or `undefined`
  21998. * @private
  21999. */
  22000. var _getCurrentScriptUrlFromError = function() {
  22001. var url, err;
  22002. try {
  22003. throw new _Error();
  22004. } catch (e) {
  22005. err = e;
  22006. }
  22007. if (err) {
  22008. url = err.sourceURL || err.fileName || _getCurrentScriptUrlFromErrorStack(err.stack);
  22009. }
  22010. return url;
  22011. };
  22012. /**
  22013. * Get the current script's URL.
  22014. *
  22015. * @returns String or `undefined`
  22016. * @private
  22017. */
  22018. var _getCurrentScriptUrl = function() {
  22019. var jsPath, scripts, i;
  22020. if (_document.currentScript && (jsPath = _document.currentScript.src)) {
  22021. return jsPath;
  22022. }
  22023. scripts = _document.getElementsByTagName("script");
  22024. if (scripts.length === 1) {
  22025. return scripts[0].src || undefined;
  22026. }
  22027. if ("readyState" in scripts[0]) {
  22028. for (i = scripts.length; i--; ) {
  22029. if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) {
  22030. return jsPath;
  22031. }
  22032. }
  22033. }
  22034. if (_document.readyState === "loading" && (jsPath = scripts[scripts.length - 1].src)) {
  22035. return jsPath;
  22036. }
  22037. if (jsPath = _getCurrentScriptUrlFromError()) {
  22038. return jsPath;
  22039. }
  22040. return undefined;
  22041. };
  22042. /**
  22043. * Get the unanimous parent directory of ALL script tags.
  22044. * If any script tags are either (a) inline or (b) from differing parent
  22045. * directories, this method must return `undefined`.
  22046. *
  22047. * @returns String or `undefined`
  22048. * @private
  22049. */
  22050. var _getUnanimousScriptParentDir = function() {
  22051. var i, jsDir, jsPath, scripts = _document.getElementsByTagName("script");
  22052. for (i = scripts.length; i--; ) {
  22053. if (!(jsPath = scripts[i].src)) {
  22054. jsDir = null;
  22055. break;
  22056. }
  22057. jsPath = _getDirPathOfUrl(jsPath);
  22058. if (jsDir == null) {
  22059. jsDir = jsPath;
  22060. } else if (jsDir !== jsPath) {
  22061. jsDir = null;
  22062. break;
  22063. }
  22064. }
  22065. return jsDir || undefined;
  22066. };
  22067. /**
  22068. * Get the presumed location of the "ZeroClipboard.swf" file, based on the location
  22069. * of the executing JavaScript file (e.g. "ZeroClipboard.js", etc.).
  22070. *
  22071. * @returns String
  22072. * @private
  22073. */
  22074. var _getDefaultSwfPath = function() {
  22075. var jsDir = _getDirPathOfUrl(_getCurrentScriptUrl()) || _getUnanimousScriptParentDir() || "";
  22076. return jsDir + "ZeroClipboard.swf";
  22077. };
  22078. /**
  22079. * Keep track of if the page is framed (in an `iframe`). This can never change.
  22080. * @private
  22081. */
  22082. var _pageIsFramed = function() {
  22083. return window.opener == null && (!!window.top && window != window.top || !!window.parent && window != window.parent);
  22084. }();
  22085. /**
  22086. * Keep track of the state of the Flash object.
  22087. * @private
  22088. */
  22089. var _flashState = {
  22090. bridge: null,
  22091. version: "0.0.0",
  22092. pluginType: "unknown",
  22093. disabled: null,
  22094. outdated: null,
  22095. sandboxed: null,
  22096. unavailable: null,
  22097. degraded: null,
  22098. deactivated: null,
  22099. overdue: null,
  22100. ready: null
  22101. };
  22102. /**
  22103. * The minimum Flash Player version required to use ZeroClipboard completely.
  22104. * @readonly
  22105. * @private
  22106. */
  22107. var _minimumFlashVersion = "11.0.0";
  22108. /**
  22109. * The ZeroClipboard library version number, as reported by Flash, at the time the SWF was compiled.
  22110. */
  22111. var _zcSwfVersion;
  22112. /**
  22113. * Keep track of all event listener registrations.
  22114. * @private
  22115. */
  22116. var _handlers = {};
  22117. /**
  22118. * Keep track of the currently activated element.
  22119. * @private
  22120. */
  22121. var _currentElement;
  22122. /**
  22123. * Keep track of the element that was activated when a `copy` process started.
  22124. * @private
  22125. */
  22126. var _copyTarget;
  22127. /**
  22128. * Keep track of data for the pending clipboard transaction.
  22129. * @private
  22130. */
  22131. var _clipData = {};
  22132. /**
  22133. * Keep track of data formats for the pending clipboard transaction.
  22134. * @private
  22135. */
  22136. var _clipDataFormatMap = null;
  22137. /**
  22138. * Keep track of the Flash availability check timeout.
  22139. * @private
  22140. */
  22141. var _flashCheckTimeout = 0;
  22142. /**
  22143. * Keep track of SWF network errors interval polling.
  22144. * @private
  22145. */
  22146. var _swfFallbackCheckInterval = 0;
  22147. /**
  22148. * The `message` store for events
  22149. * @private
  22150. */
  22151. var _eventMessages = {
  22152. ready: "Flash communication is established",
  22153. error: {
  22154. "flash-disabled": "Flash is disabled or not installed. May also be attempting to run Flash in a sandboxed iframe, which is impossible.",
  22155. "flash-outdated": "Flash is too outdated to support ZeroClipboard",
  22156. "flash-sandboxed": "Attempting to run Flash in a sandboxed iframe, which is impossible",
  22157. "flash-unavailable": "Flash is unable to communicate bidirectionally with JavaScript",
  22158. "flash-degraded": "Flash is unable to preserve data fidelity when communicating with JavaScript",
  22159. "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.",
  22160. "flash-overdue": "Flash communication was established but NOT within the acceptable time limit",
  22161. "version-mismatch": "ZeroClipboard JS version number does not match ZeroClipboard SWF version number",
  22162. "clipboard-error": "At least one error was thrown while ZeroClipboard was attempting to inject your data into the clipboard",
  22163. "config-mismatch": "ZeroClipboard configuration does not match Flash's reality",
  22164. "swf-not-found": "The ZeroClipboard SWF object could not be loaded, so please check your `swfPath` configuration and/or network connectivity"
  22165. }
  22166. };
  22167. /**
  22168. * The `name`s of `error` events that can only occur is Flash has at least
  22169. * been able to load the SWF successfully.
  22170. * @private
  22171. */
  22172. var _errorsThatOnlyOccurAfterFlashLoads = [ "flash-unavailable", "flash-degraded", "flash-overdue", "version-mismatch", "config-mismatch", "clipboard-error" ];
  22173. /**
  22174. * The `name`s of `error` events that should likely result in the `_flashState`
  22175. * variable's property values being updated.
  22176. * @private
  22177. */
  22178. var _flashStateErrorNames = [ "flash-disabled", "flash-outdated", "flash-sandboxed", "flash-unavailable", "flash-degraded", "flash-deactivated", "flash-overdue" ];
  22179. /**
  22180. * A RegExp to match the `name` property of `error` events related to Flash.
  22181. * @private
  22182. */
  22183. var _flashStateErrorNameMatchingRegex = new RegExp("^flash-(" + _flashStateErrorNames.map(function(errorName) {
  22184. return errorName.replace(/^flash-/, "");
  22185. }).join("|") + ")$");
  22186. /**
  22187. * A RegExp to match the `name` property of `error` events related to Flash,
  22188. * which is enabled.
  22189. * @private
  22190. */
  22191. var _flashStateEnabledErrorNameMatchingRegex = new RegExp("^flash-(" + _flashStateErrorNames.slice(1).map(function(errorName) {
  22192. return errorName.replace(/^flash-/, "");
  22193. }).join("|") + ")$");
  22194. /**
  22195. * ZeroClipboard configuration defaults for the Core module.
  22196. * @private
  22197. */
  22198. var _globalConfig = {
  22199. swfPath: _getDefaultSwfPath(),
  22200. trustedDomains: window.location.host ? [ window.location.host ] : [],
  22201. cacheBust: true,
  22202. forceEnhancedClipboard: false,
  22203. flashLoadTimeout: 3e4,
  22204. autoActivate: true,
  22205. bubbleEvents: true,
  22206. containerId: "global-zeroclipboard-html-bridge",
  22207. containerClass: "global-zeroclipboard-container",
  22208. swfObjectId: "global-zeroclipboard-flash-bridge",
  22209. hoverClass: "zeroclipboard-is-hover",
  22210. activeClass: "zeroclipboard-is-active",
  22211. forceHandCursor: false,
  22212. title: null,
  22213. zIndex: 999999999
  22214. };
  22215. /**
  22216. * The underlying implementation of `ZeroClipboard.config`.
  22217. * @private
  22218. */
  22219. var _config = function(options) {
  22220. if (typeof options === "object" && options !== null) {
  22221. for (var prop in options) {
  22222. if (_hasOwn.call(options, prop)) {
  22223. if (/^(?:forceHandCursor|title|zIndex|bubbleEvents)$/.test(prop)) {
  22224. _globalConfig[prop] = options[prop];
  22225. } else if (_flashState.bridge == null) {
  22226. if (prop === "containerId" || prop === "swfObjectId") {
  22227. if (_isValidHtml4Id(options[prop])) {
  22228. _globalConfig[prop] = options[prop];
  22229. } else {
  22230. throw new Error("The specified `" + prop + "` value is not valid as an HTML4 Element ID");
  22231. }
  22232. } else {
  22233. _globalConfig[prop] = options[prop];
  22234. }
  22235. }
  22236. }
  22237. }
  22238. }
  22239. if (typeof options === "string" && options) {
  22240. if (_hasOwn.call(_globalConfig, options)) {
  22241. return _globalConfig[options];
  22242. }
  22243. return;
  22244. }
  22245. return _deepCopy(_globalConfig);
  22246. };
  22247. /**
  22248. * The underlying implementation of `ZeroClipboard.state`.
  22249. * @private
  22250. */
  22251. var _state = function() {
  22252. _detectSandbox();
  22253. return {
  22254. browser: _pick(_navigator, [ "userAgent", "platform", "appName" ]),
  22255. flash: _omit(_flashState, [ "bridge" ]),
  22256. zeroclipboard: {
  22257. version: ZeroClipboard.version,
  22258. config: ZeroClipboard.config()
  22259. }
  22260. };
  22261. };
  22262. /**
  22263. * The underlying implementation of `ZeroClipboard.isFlashUnusable`.
  22264. * @private
  22265. */
  22266. var _isFlashUnusable = function() {
  22267. return !!(_flashState.disabled || _flashState.outdated || _flashState.sandboxed || _flashState.unavailable || _flashState.degraded || _flashState.deactivated);
  22268. };
  22269. /**
  22270. * The underlying implementation of `ZeroClipboard.on`.
  22271. * @private
  22272. */
  22273. var _on = function(eventType, listener) {
  22274. var i, len, events, added = {};
  22275. if (typeof eventType === "string" && eventType) {
  22276. events = eventType.toLowerCase().split(/\s+/);
  22277. } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
  22278. for (i in eventType) {
  22279. if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
  22280. ZeroClipboard.on(i, eventType[i]);
  22281. }
  22282. }
  22283. }
  22284. if (events && events.length) {
  22285. for (i = 0, len = events.length; i < len; i++) {
  22286. eventType = events[i].replace(/^on/, "");
  22287. added[eventType] = true;
  22288. if (!_handlers[eventType]) {
  22289. _handlers[eventType] = [];
  22290. }
  22291. _handlers[eventType].push(listener);
  22292. }
  22293. if (added.ready && _flashState.ready) {
  22294. ZeroClipboard.emit({
  22295. type: "ready"
  22296. });
  22297. }
  22298. if (added.error) {
  22299. for (i = 0, len = _flashStateErrorNames.length; i < len; i++) {
  22300. if (_flashState[_flashStateErrorNames[i].replace(/^flash-/, "")] === true) {
  22301. ZeroClipboard.emit({
  22302. type: "error",
  22303. name: _flashStateErrorNames[i]
  22304. });
  22305. break;
  22306. }
  22307. }
  22308. if (_zcSwfVersion !== undefined && ZeroClipboard.version !== _zcSwfVersion) {
  22309. ZeroClipboard.emit({
  22310. type: "error",
  22311. name: "version-mismatch",
  22312. jsVersion: ZeroClipboard.version,
  22313. swfVersion: _zcSwfVersion
  22314. });
  22315. }
  22316. }
  22317. }
  22318. return ZeroClipboard;
  22319. };
  22320. /**
  22321. * The underlying implementation of `ZeroClipboard.off`.
  22322. * @private
  22323. */
  22324. var _off = function(eventType, listener) {
  22325. var i, len, foundIndex, events, perEventHandlers;
  22326. if (arguments.length === 0) {
  22327. events = _keys(_handlers);
  22328. } else if (typeof eventType === "string" && eventType) {
  22329. events = eventType.split(/\s+/);
  22330. } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
  22331. for (i in eventType) {
  22332. if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
  22333. ZeroClipboard.off(i, eventType[i]);
  22334. }
  22335. }
  22336. }
  22337. if (events && events.length) {
  22338. for (i = 0, len = events.length; i < len; i++) {
  22339. eventType = events[i].toLowerCase().replace(/^on/, "");
  22340. perEventHandlers = _handlers[eventType];
  22341. if (perEventHandlers && perEventHandlers.length) {
  22342. if (listener) {
  22343. foundIndex = perEventHandlers.indexOf(listener);
  22344. while (foundIndex !== -1) {
  22345. perEventHandlers.splice(foundIndex, 1);
  22346. foundIndex = perEventHandlers.indexOf(listener, foundIndex);
  22347. }
  22348. } else {
  22349. perEventHandlers.length = 0;
  22350. }
  22351. }
  22352. }
  22353. }
  22354. return ZeroClipboard;
  22355. };
  22356. /**
  22357. * The underlying implementation of `ZeroClipboard.handlers`.
  22358. * @private
  22359. */
  22360. var _listeners = function(eventType) {
  22361. var copy;
  22362. if (typeof eventType === "string" && eventType) {
  22363. copy = _deepCopy(_handlers[eventType]) || null;
  22364. } else {
  22365. copy = _deepCopy(_handlers);
  22366. }
  22367. return copy;
  22368. };
  22369. /**
  22370. * The underlying implementation of `ZeroClipboard.emit`.
  22371. * @private
  22372. */
  22373. var _emit = function(event) {
  22374. var eventCopy, returnVal, tmp;
  22375. event = _createEvent(event);
  22376. if (!event) {
  22377. return;
  22378. }
  22379. if (_preprocessEvent(event)) {
  22380. return;
  22381. }
  22382. if (event.type === "ready" && _flashState.overdue === true) {
  22383. return ZeroClipboard.emit({
  22384. type: "error",
  22385. name: "flash-overdue"
  22386. });
  22387. }
  22388. eventCopy = _extend({}, event);
  22389. _dispatchCallbacks.call(this, eventCopy);
  22390. if (event.type === "copy") {
  22391. tmp = _mapClipDataToFlash(_clipData);
  22392. returnVal = tmp.data;
  22393. _clipDataFormatMap = tmp.formatMap;
  22394. }
  22395. return returnVal;
  22396. };
  22397. /**
  22398. * The underlying implementation of `ZeroClipboard.create`.
  22399. * @private
  22400. */
  22401. var _create = function() {
  22402. var previousState = _flashState.sandboxed;
  22403. _detectSandbox();
  22404. if (typeof _flashState.ready !== "boolean") {
  22405. _flashState.ready = false;
  22406. }
  22407. if (_flashState.sandboxed !== previousState && _flashState.sandboxed === true) {
  22408. _flashState.ready = false;
  22409. ZeroClipboard.emit({
  22410. type: "error",
  22411. name: "flash-sandboxed"
  22412. });
  22413. } else if (!ZeroClipboard.isFlashUnusable() && _flashState.bridge === null) {
  22414. var maxWait = _globalConfig.flashLoadTimeout;
  22415. if (typeof maxWait === "number" && maxWait >= 0) {
  22416. _flashCheckTimeout = _setTimeout(function() {
  22417. if (typeof _flashState.deactivated !== "boolean") {
  22418. _flashState.deactivated = true;
  22419. }
  22420. if (_flashState.deactivated === true) {
  22421. ZeroClipboard.emit({
  22422. type: "error",
  22423. name: "flash-deactivated"
  22424. });
  22425. }
  22426. }, maxWait);
  22427. }
  22428. _flashState.overdue = false;
  22429. _embedSwf();
  22430. }
  22431. };
  22432. /**
  22433. * The underlying implementation of `ZeroClipboard.destroy`.
  22434. * @private
  22435. */
  22436. var _destroy = function() {
  22437. ZeroClipboard.clearData();
  22438. ZeroClipboard.blur();
  22439. ZeroClipboard.emit("destroy");
  22440. _unembedSwf();
  22441. ZeroClipboard.off();
  22442. };
  22443. /**
  22444. * The underlying implementation of `ZeroClipboard.setData`.
  22445. * @private
  22446. */
  22447. var _setData = function(format, data) {
  22448. var dataObj;
  22449. if (typeof format === "object" && format && typeof data === "undefined") {
  22450. dataObj = format;
  22451. ZeroClipboard.clearData();
  22452. } else if (typeof format === "string" && format) {
  22453. dataObj = {};
  22454. dataObj[format] = data;
  22455. } else {
  22456. return;
  22457. }
  22458. for (var dataFormat in dataObj) {
  22459. if (typeof dataFormat === "string" && dataFormat && _hasOwn.call(dataObj, dataFormat) && typeof dataObj[dataFormat] === "string" && dataObj[dataFormat]) {
  22460. _clipData[dataFormat] = dataObj[dataFormat];
  22461. }
  22462. }
  22463. };
  22464. /**
  22465. * The underlying implementation of `ZeroClipboard.clearData`.
  22466. * @private
  22467. */
  22468. var _clearData = function(format) {
  22469. if (typeof format === "undefined") {
  22470. _deleteOwnProperties(_clipData);
  22471. _clipDataFormatMap = null;
  22472. } else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
  22473. delete _clipData[format];
  22474. }
  22475. };
  22476. /**
  22477. * The underlying implementation of `ZeroClipboard.getData`.
  22478. * @private
  22479. */
  22480. var _getData = function(format) {
  22481. if (typeof format === "undefined") {
  22482. return _deepCopy(_clipData);
  22483. } else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
  22484. return _clipData[format];
  22485. }
  22486. };
  22487. /**
  22488. * The underlying implementation of `ZeroClipboard.focus`/`ZeroClipboard.activate`.
  22489. * @private
  22490. */
  22491. var _focus = function(element) {
  22492. if (!(element && element.nodeType === 1)) {
  22493. return;
  22494. }
  22495. if (_currentElement) {
  22496. _removeClass(_currentElement, _globalConfig.activeClass);
  22497. if (_currentElement !== element) {
  22498. _removeClass(_currentElement, _globalConfig.hoverClass);
  22499. }
  22500. }
  22501. _currentElement = element;
  22502. _addClass(element, _globalConfig.hoverClass);
  22503. var newTitle = element.getAttribute("title") || _globalConfig.title;
  22504. if (typeof newTitle === "string" && newTitle) {
  22505. var htmlBridge = _getHtmlBridge(_flashState.bridge);
  22506. if (htmlBridge) {
  22507. htmlBridge.setAttribute("title", newTitle);
  22508. }
  22509. }
  22510. var useHandCursor = _globalConfig.forceHandCursor === true || _getStyle(element, "cursor") === "pointer";
  22511. _setHandCursor(useHandCursor);
  22512. _reposition();
  22513. };
  22514. /**
  22515. * The underlying implementation of `ZeroClipboard.blur`/`ZeroClipboard.deactivate`.
  22516. * @private
  22517. */
  22518. var _blur = function() {
  22519. var htmlBridge = _getHtmlBridge(_flashState.bridge);
  22520. if (htmlBridge) {
  22521. htmlBridge.removeAttribute("title");
  22522. htmlBridge.style.left = "0px";
  22523. htmlBridge.style.top = "-9999px";
  22524. htmlBridge.style.width = "1px";
  22525. htmlBridge.style.height = "1px";
  22526. }
  22527. if (_currentElement) {
  22528. _removeClass(_currentElement, _globalConfig.hoverClass);
  22529. _removeClass(_currentElement, _globalConfig.activeClass);
  22530. _currentElement = null;
  22531. }
  22532. };
  22533. /**
  22534. * The underlying implementation of `ZeroClipboard.activeElement`.
  22535. * @private
  22536. */
  22537. var _activeElement = function() {
  22538. return _currentElement || null;
  22539. };
  22540. /**
  22541. * Check if a value is a valid HTML4 `ID` or `Name` token.
  22542. * @private
  22543. */
  22544. var _isValidHtml4Id = function(id) {
  22545. return typeof id === "string" && id && /^[A-Za-z][A-Za-z0-9_:\-\.]*$/.test(id);
  22546. };
  22547. /**
  22548. * Create or update an `event` object, based on the `eventType`.
  22549. * @private
  22550. */
  22551. var _createEvent = function(event) {
  22552. var eventType;
  22553. if (typeof event === "string" && event) {
  22554. eventType = event;
  22555. event = {};
  22556. } else if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
  22557. eventType = event.type;
  22558. }
  22559. if (!eventType) {
  22560. return;
  22561. }
  22562. eventType = eventType.toLowerCase();
  22563. if (!event.target && (/^(copy|aftercopy|_click)$/.test(eventType) || eventType === "error" && event.name === "clipboard-error")) {
  22564. event.target = _copyTarget;
  22565. }
  22566. _extend(event, {
  22567. type: eventType,
  22568. target: event.target || _currentElement || null,
  22569. relatedTarget: event.relatedTarget || null,
  22570. currentTarget: _flashState && _flashState.bridge || null,
  22571. timeStamp: event.timeStamp || _now() || null
  22572. });
  22573. var msg = _eventMessages[event.type];
  22574. if (event.type === "error" && event.name && msg) {
  22575. msg = msg[event.name];
  22576. }
  22577. if (msg) {
  22578. event.message = msg;
  22579. }
  22580. if (event.type === "ready") {
  22581. _extend(event, {
  22582. target: null,
  22583. version: _flashState.version
  22584. });
  22585. }
  22586. if (event.type === "error") {
  22587. if (_flashStateErrorNameMatchingRegex.test(event.name)) {
  22588. _extend(event, {
  22589. target: null,
  22590. minimumVersion: _minimumFlashVersion
  22591. });
  22592. }
  22593. if (_flashStateEnabledErrorNameMatchingRegex.test(event.name)) {
  22594. _extend(event, {
  22595. version: _flashState.version
  22596. });
  22597. }
  22598. }
  22599. if (event.type === "copy") {
  22600. event.clipboardData = {
  22601. setData: ZeroClipboard.setData,
  22602. clearData: ZeroClipboard.clearData
  22603. };
  22604. }
  22605. if (event.type === "aftercopy") {
  22606. event = _mapClipResultsFromFlash(event, _clipDataFormatMap);
  22607. }
  22608. if (event.target && !event.relatedTarget) {
  22609. event.relatedTarget = _getRelatedTarget(event.target);
  22610. }
  22611. return _addMouseData(event);
  22612. };
  22613. /**
  22614. * Get a relatedTarget from the target's `data-clipboard-target` attribute
  22615. * @private
  22616. */
  22617. var _getRelatedTarget = function(targetEl) {
  22618. var relatedTargetId = targetEl && targetEl.getAttribute && targetEl.getAttribute("data-clipboard-target");
  22619. return relatedTargetId ? _document.getElementById(relatedTargetId) : null;
  22620. };
  22621. /**
  22622. * Add element and position data to `MouseEvent` instances
  22623. * @private
  22624. */
  22625. var _addMouseData = function(event) {
  22626. if (event && /^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
  22627. var srcElement = event.target;
  22628. var fromElement = event.type === "_mouseover" && event.relatedTarget ? event.relatedTarget : undefined;
  22629. var toElement = event.type === "_mouseout" && event.relatedTarget ? event.relatedTarget : undefined;
  22630. var pos = _getElementPosition(srcElement);
  22631. var screenLeft = _window.screenLeft || _window.screenX || 0;
  22632. var screenTop = _window.screenTop || _window.screenY || 0;
  22633. var scrollLeft = _document.body.scrollLeft + _document.documentElement.scrollLeft;
  22634. var scrollTop = _document.body.scrollTop + _document.documentElement.scrollTop;
  22635. var pageX = pos.left + (typeof event._stageX === "number" ? event._stageX : 0);
  22636. var pageY = pos.top + (typeof event._stageY === "number" ? event._stageY : 0);
  22637. var clientX = pageX - scrollLeft;
  22638. var clientY = pageY - scrollTop;
  22639. var screenX = screenLeft + clientX;
  22640. var screenY = screenTop + clientY;
  22641. var moveX = typeof event.movementX === "number" ? event.movementX : 0;
  22642. var moveY = typeof event.movementY === "number" ? event.movementY : 0;
  22643. delete event._stageX;
  22644. delete event._stageY;
  22645. _extend(event, {
  22646. srcElement: srcElement,
  22647. fromElement: fromElement,
  22648. toElement: toElement,
  22649. screenX: screenX,
  22650. screenY: screenY,
  22651. pageX: pageX,
  22652. pageY: pageY,
  22653. clientX: clientX,
  22654. clientY: clientY,
  22655. x: clientX,
  22656. y: clientY,
  22657. movementX: moveX,
  22658. movementY: moveY,
  22659. offsetX: 0,
  22660. offsetY: 0,
  22661. layerX: 0,
  22662. layerY: 0
  22663. });
  22664. }
  22665. return event;
  22666. };
  22667. /**
  22668. * Determine if an event's registered handlers should be execute synchronously or asynchronously.
  22669. *
  22670. * @returns {boolean}
  22671. * @private
  22672. */
  22673. var _shouldPerformAsync = function(event) {
  22674. var eventType = event && typeof event.type === "string" && event.type || "";
  22675. return !/^(?:(?:before)?copy|destroy)$/.test(eventType);
  22676. };
  22677. /**
  22678. * Control if a callback should be executed asynchronously or not.
  22679. *
  22680. * @returns `undefined`
  22681. * @private
  22682. */
  22683. var _dispatchCallback = function(func, context, args, async) {
  22684. if (async) {
  22685. _setTimeout(function() {
  22686. func.apply(context, args);
  22687. }, 0);
  22688. } else {
  22689. func.apply(context, args);
  22690. }
  22691. };
  22692. /**
  22693. * Handle the actual dispatching of events to client instances.
  22694. *
  22695. * @returns `undefined`
  22696. * @private
  22697. */
  22698. var _dispatchCallbacks = function(event) {
  22699. if (!(typeof event === "object" && event && event.type)) {
  22700. return;
  22701. }
  22702. var async = _shouldPerformAsync(event);
  22703. var wildcardTypeHandlers = _handlers["*"] || [];
  22704. var specificTypeHandlers = _handlers[event.type] || [];
  22705. var handlers = wildcardTypeHandlers.concat(specificTypeHandlers);
  22706. if (handlers && handlers.length) {
  22707. var i, len, func, context, eventCopy, originalContext = this;
  22708. for (i = 0, len = handlers.length; i < len; i++) {
  22709. func = handlers[i];
  22710. context = originalContext;
  22711. if (typeof func === "string" && typeof _window[func] === "function") {
  22712. func = _window[func];
  22713. }
  22714. if (typeof func === "object" && func && typeof func.handleEvent === "function") {
  22715. context = func;
  22716. func = func.handleEvent;
  22717. }
  22718. if (typeof func === "function") {
  22719. eventCopy = _extend({}, event);
  22720. _dispatchCallback(func, context, [ eventCopy ], async);
  22721. }
  22722. }
  22723. }
  22724. return this;
  22725. };
  22726. /**
  22727. * Check an `error` event's `name` property to see if Flash has
  22728. * already loaded, which rules out possible `iframe` sandboxing.
  22729. * @private
  22730. */
  22731. var _getSandboxStatusFromErrorEvent = function(event) {
  22732. var isSandboxed = null;
  22733. if (_pageIsFramed === false || event && event.type === "error" && event.name && _errorsThatOnlyOccurAfterFlashLoads.indexOf(event.name) !== -1) {
  22734. isSandboxed = false;
  22735. }
  22736. return isSandboxed;
  22737. };
  22738. /**
  22739. * Preprocess any special behaviors, reactions, or state changes after receiving this event.
  22740. * Executes only once per event emitted, NOT once per client.
  22741. * @private
  22742. */
  22743. var _preprocessEvent = function(event) {
  22744. var element = event.target || _currentElement || null;
  22745. var sourceIsSwf = event._source === "swf";
  22746. delete event._source;
  22747. switch (event.type) {
  22748. case "error":
  22749. var isSandboxed = event.name === "flash-sandboxed" || _getSandboxStatusFromErrorEvent(event);
  22750. if (typeof isSandboxed === "boolean") {
  22751. _flashState.sandboxed = isSandboxed;
  22752. }
  22753. if (_flashStateErrorNames.indexOf(event.name) !== -1) {
  22754. _extend(_flashState, {
  22755. disabled: event.name === "flash-disabled",
  22756. outdated: event.name === "flash-outdated",
  22757. unavailable: event.name === "flash-unavailable",
  22758. degraded: event.name === "flash-degraded",
  22759. deactivated: event.name === "flash-deactivated",
  22760. overdue: event.name === "flash-overdue",
  22761. ready: false
  22762. });
  22763. } else if (event.name === "version-mismatch") {
  22764. _zcSwfVersion = event.swfVersion;
  22765. _extend(_flashState, {
  22766. disabled: false,
  22767. outdated: false,
  22768. unavailable: false,
  22769. degraded: false,
  22770. deactivated: false,
  22771. overdue: false,
  22772. ready: false
  22773. });
  22774. }
  22775. _clearTimeoutsAndPolling();
  22776. break;
  22777. case "ready":
  22778. _zcSwfVersion = event.swfVersion;
  22779. var wasDeactivated = _flashState.deactivated === true;
  22780. _extend(_flashState, {
  22781. disabled: false,
  22782. outdated: false,
  22783. sandboxed: false,
  22784. unavailable: false,
  22785. degraded: false,
  22786. deactivated: false,
  22787. overdue: wasDeactivated,
  22788. ready: !wasDeactivated
  22789. });
  22790. _clearTimeoutsAndPolling();
  22791. break;
  22792. case "beforecopy":
  22793. _copyTarget = element;
  22794. break;
  22795. case "copy":
  22796. var textContent, htmlContent, targetEl = event.relatedTarget;
  22797. if (!(_clipData["text/html"] || _clipData["text/plain"]) && targetEl && (htmlContent = targetEl.value || targetEl.outerHTML || targetEl.innerHTML) && (textContent = targetEl.value || targetEl.textContent || targetEl.innerText)) {
  22798. event.clipboardData.clearData();
  22799. event.clipboardData.setData("text/plain", textContent);
  22800. if (htmlContent !== textContent) {
  22801. event.clipboardData.setData("text/html", htmlContent);
  22802. }
  22803. } else if (!_clipData["text/plain"] && event.target && (textContent = event.target.getAttribute("data-clipboard-text"))) {
  22804. event.clipboardData.clearData();
  22805. event.clipboardData.setData("text/plain", textContent);
  22806. }
  22807. break;
  22808. case "aftercopy":
  22809. _queueEmitClipboardErrors(event);
  22810. ZeroClipboard.clearData();
  22811. if (element && element !== _safeActiveElement() && element.focus) {
  22812. element.focus();
  22813. }
  22814. break;
  22815. case "_mouseover":
  22816. ZeroClipboard.focus(element);
  22817. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  22818. if (element && element !== event.relatedTarget && !_containedBy(event.relatedTarget, element)) {
  22819. _fireMouseEvent(_extend({}, event, {
  22820. type: "mouseenter",
  22821. bubbles: false,
  22822. cancelable: false
  22823. }));
  22824. }
  22825. _fireMouseEvent(_extend({}, event, {
  22826. type: "mouseover"
  22827. }));
  22828. }
  22829. break;
  22830. case "_mouseout":
  22831. ZeroClipboard.blur();
  22832. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  22833. if (element && element !== event.relatedTarget && !_containedBy(event.relatedTarget, element)) {
  22834. _fireMouseEvent(_extend({}, event, {
  22835. type: "mouseleave",
  22836. bubbles: false,
  22837. cancelable: false
  22838. }));
  22839. }
  22840. _fireMouseEvent(_extend({}, event, {
  22841. type: "mouseout"
  22842. }));
  22843. }
  22844. break;
  22845. case "_mousedown":
  22846. _addClass(element, _globalConfig.activeClass);
  22847. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  22848. _fireMouseEvent(_extend({}, event, {
  22849. type: event.type.slice(1)
  22850. }));
  22851. }
  22852. break;
  22853. case "_mouseup":
  22854. _removeClass(element, _globalConfig.activeClass);
  22855. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  22856. _fireMouseEvent(_extend({}, event, {
  22857. type: event.type.slice(1)
  22858. }));
  22859. }
  22860. break;
  22861. case "_click":
  22862. _copyTarget = null;
  22863. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  22864. _fireMouseEvent(_extend({}, event, {
  22865. type: event.type.slice(1)
  22866. }));
  22867. }
  22868. break;
  22869. case "_mousemove":
  22870. if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
  22871. _fireMouseEvent(_extend({}, event, {
  22872. type: event.type.slice(1)
  22873. }));
  22874. }
  22875. break;
  22876. }
  22877. if (/^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
  22878. return true;
  22879. }
  22880. };
  22881. /**
  22882. * Check an "aftercopy" event for clipboard errors and emit a corresponding "error" event.
  22883. * @private
  22884. */
  22885. var _queueEmitClipboardErrors = function(aftercopyEvent) {
  22886. if (aftercopyEvent.errors && aftercopyEvent.errors.length > 0) {
  22887. var errorEvent = _deepCopy(aftercopyEvent);
  22888. _extend(errorEvent, {
  22889. type: "error",
  22890. name: "clipboard-error"
  22891. });
  22892. delete errorEvent.success;
  22893. _setTimeout(function() {
  22894. ZeroClipboard.emit(errorEvent);
  22895. }, 0);
  22896. }
  22897. };
  22898. /**
  22899. * Dispatch a synthetic MouseEvent.
  22900. *
  22901. * @returns `undefined`
  22902. * @private
  22903. */
  22904. var _fireMouseEvent = function(event) {
  22905. if (!(event && typeof event.type === "string" && event)) {
  22906. return;
  22907. }
  22908. var e, target = event.target || null, doc = target && target.ownerDocument || _document, defaults = {
  22909. view: doc.defaultView || _window,
  22910. canBubble: true,
  22911. cancelable: true,
  22912. detail: event.type === "click" ? 1 : 0,
  22913. button: typeof event.which === "number" ? event.which - 1 : typeof event.button === "number" ? event.button : doc.createEvent ? 0 : 1
  22914. }, args = _extend(defaults, event);
  22915. if (!target) {
  22916. return;
  22917. }
  22918. if (doc.createEvent && target.dispatchEvent) {
  22919. 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 ];
  22920. e = doc.createEvent("MouseEvents");
  22921. if (e.initMouseEvent) {
  22922. e.initMouseEvent.apply(e, args);
  22923. e._source = "js";
  22924. target.dispatchEvent(e);
  22925. }
  22926. }
  22927. };
  22928. /**
  22929. * Continuously poll the DOM until either:
  22930. * (a) the fallback content becomes visible, or
  22931. * (b) we receive an event from SWF (handled elsewhere)
  22932. *
  22933. * IMPORTANT:
  22934. * This is NOT a necessary check but it can result in significantly faster
  22935. * detection of bad `swfPath` configuration and/or network/server issues [in
  22936. * supported browsers] than waiting for the entire `flashLoadTimeout` duration
  22937. * to elapse before detecting that the SWF cannot be loaded. The detection
  22938. * duration can be anywhere from 10-30 times faster [in supported browsers] by
  22939. * using this approach.
  22940. *
  22941. * @returns `undefined`
  22942. * @private
  22943. */
  22944. var _watchForSwfFallbackContent = function() {
  22945. var maxWait = _globalConfig.flashLoadTimeout;
  22946. if (typeof maxWait === "number" && maxWait >= 0) {
  22947. var pollWait = Math.min(1e3, maxWait / 10);
  22948. var fallbackContentId = _globalConfig.swfObjectId + "_fallbackContent";
  22949. _swfFallbackCheckInterval = _setInterval(function() {
  22950. var el = _document.getElementById(fallbackContentId);
  22951. if (_isElementVisible(el)) {
  22952. _clearTimeoutsAndPolling();
  22953. _flashState.deactivated = null;
  22954. ZeroClipboard.emit({
  22955. type: "error",
  22956. name: "swf-not-found"
  22957. });
  22958. }
  22959. }, pollWait);
  22960. }
  22961. };
  22962. /**
  22963. * Create the HTML bridge element to embed the Flash object into.
  22964. * @private
  22965. */
  22966. var _createHtmlBridge = function() {
  22967. var container = _document.createElement("div");
  22968. container.id = _globalConfig.containerId;
  22969. container.className = _globalConfig.containerClass;
  22970. container.style.position = "absolute";
  22971. container.style.left = "0px";
  22972. container.style.top = "-9999px";
  22973. container.style.width = "1px";
  22974. container.style.height = "1px";
  22975. container.style.zIndex = "" + _getSafeZIndex(_globalConfig.zIndex);
  22976. return container;
  22977. };
  22978. /**
  22979. * Get the HTML element container that wraps the Flash bridge object/element.
  22980. * @private
  22981. */
  22982. var _getHtmlBridge = function(flashBridge) {
  22983. var htmlBridge = flashBridge && flashBridge.parentNode;
  22984. while (htmlBridge && htmlBridge.nodeName === "OBJECT" && htmlBridge.parentNode) {
  22985. htmlBridge = htmlBridge.parentNode;
  22986. }
  22987. return htmlBridge || null;
  22988. };
  22989. /**
  22990. * Create the SWF object.
  22991. *
  22992. * @returns The SWF object reference.
  22993. * @private
  22994. */
  22995. var _embedSwf = function() {
  22996. var len, flashBridge = _flashState.bridge, container = _getHtmlBridge(flashBridge);
  22997. if (!flashBridge) {
  22998. var allowScriptAccess = _determineScriptAccess(_window.location.host, _globalConfig);
  22999. var allowNetworking = allowScriptAccess === "never" ? "none" : "all";
  23000. var flashvars = _vars(_extend({
  23001. jsVersion: ZeroClipboard.version
  23002. }, _globalConfig));
  23003. var swfUrl = _globalConfig.swfPath + _cacheBust(_globalConfig.swfPath, _globalConfig);
  23004. container = _createHtmlBridge();
  23005. var divToBeReplaced = _document.createElement("div");
  23006. container.appendChild(divToBeReplaced);
  23007. _document.body.appendChild(container);
  23008. var tmpDiv = _document.createElement("div");
  23009. var usingActiveX = _flashState.pluginType === "activex";
  23010. tmpDiv.innerHTML = '<object id="' + _globalConfig.swfObjectId + '" name="' + _globalConfig.swfObjectId + '" ' + 'width="100%" height="100%" ' + (usingActiveX ? 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' : 'type="application/x-shockwave-flash" data="' + swfUrl + '"') + ">" + (usingActiveX ? '<param name="movie" value="' + swfUrl + '"/>' : "") + '<param name="allowScriptAccess" value="' + allowScriptAccess + '"/>' + '<param name="allowNetworking" value="' + allowNetworking + '"/>' + '<param name="menu" value="false"/>' + '<param name="wmode" value="transparent"/>' + '<param name="flashvars" value="' + flashvars + '"/>' + '<div id="' + _globalConfig.swfObjectId + '_fallbackContent">&nbsp;</div>' + "</object>";
  23011. flashBridge = tmpDiv.firstChild;
  23012. tmpDiv = null;
  23013. _unwrap(flashBridge).ZeroClipboard = ZeroClipboard;
  23014. container.replaceChild(flashBridge, divToBeReplaced);
  23015. _watchForSwfFallbackContent();
  23016. }
  23017. if (!flashBridge) {
  23018. flashBridge = _document[_globalConfig.swfObjectId];
  23019. if (flashBridge && (len = flashBridge.length)) {
  23020. flashBridge = flashBridge[len - 1];
  23021. }
  23022. if (!flashBridge && container) {
  23023. flashBridge = container.firstChild;
  23024. }
  23025. }
  23026. _flashState.bridge = flashBridge || null;
  23027. return flashBridge;
  23028. };
  23029. /**
  23030. * Destroy the SWF object.
  23031. * @private
  23032. */
  23033. var _unembedSwf = function() {
  23034. var flashBridge = _flashState.bridge;
  23035. if (flashBridge) {
  23036. var htmlBridge = _getHtmlBridge(flashBridge);
  23037. if (htmlBridge) {
  23038. if (_flashState.pluginType === "activex" && "readyState" in flashBridge) {
  23039. flashBridge.style.display = "none";
  23040. (function removeSwfFromIE() {
  23041. if (flashBridge.readyState === 4) {
  23042. for (var prop in flashBridge) {
  23043. if (typeof flashBridge[prop] === "function") {
  23044. flashBridge[prop] = null;
  23045. }
  23046. }
  23047. if (flashBridge.parentNode) {
  23048. flashBridge.parentNode.removeChild(flashBridge);
  23049. }
  23050. if (htmlBridge.parentNode) {
  23051. htmlBridge.parentNode.removeChild(htmlBridge);
  23052. }
  23053. } else {
  23054. _setTimeout(removeSwfFromIE, 10);
  23055. }
  23056. })();
  23057. } else {
  23058. if (flashBridge.parentNode) {
  23059. flashBridge.parentNode.removeChild(flashBridge);
  23060. }
  23061. if (htmlBridge.parentNode) {
  23062. htmlBridge.parentNode.removeChild(htmlBridge);
  23063. }
  23064. }
  23065. }
  23066. _clearTimeoutsAndPolling();
  23067. _flashState.ready = null;
  23068. _flashState.bridge = null;
  23069. _flashState.deactivated = null;
  23070. _zcSwfVersion = undefined;
  23071. }
  23072. };
  23073. /**
  23074. * Map the data format names of the "clipData" to Flash-friendly names.
  23075. *
  23076. * @returns A new transformed object.
  23077. * @private
  23078. */
  23079. var _mapClipDataToFlash = function(clipData) {
  23080. var newClipData = {}, formatMap = {};
  23081. if (!(typeof clipData === "object" && clipData)) {
  23082. return;
  23083. }
  23084. for (var dataFormat in clipData) {
  23085. if (dataFormat && _hasOwn.call(clipData, dataFormat) && typeof clipData[dataFormat] === "string" && clipData[dataFormat]) {
  23086. switch (dataFormat.toLowerCase()) {
  23087. case "text/plain":
  23088. case "text":
  23089. case "air:text":
  23090. case "flash:text":
  23091. newClipData.text = clipData[dataFormat];
  23092. formatMap.text = dataFormat;
  23093. break;
  23094. case "text/html":
  23095. case "html":
  23096. case "air:html":
  23097. case "flash:html":
  23098. newClipData.html = clipData[dataFormat];
  23099. formatMap.html = dataFormat;
  23100. break;
  23101. case "application/rtf":
  23102. case "text/rtf":
  23103. case "rtf":
  23104. case "richtext":
  23105. case "air:rtf":
  23106. case "flash:rtf":
  23107. newClipData.rtf = clipData[dataFormat];
  23108. formatMap.rtf = dataFormat;
  23109. break;
  23110. default:
  23111. break;
  23112. }
  23113. }
  23114. }
  23115. return {
  23116. data: newClipData,
  23117. formatMap: formatMap
  23118. };
  23119. };
  23120. /**
  23121. * Map the data format names from Flash-friendly names back to their original "clipData" names (via a format mapping).
  23122. *
  23123. * @returns A new transformed object.
  23124. * @private
  23125. */
  23126. var _mapClipResultsFromFlash = function(clipResults, formatMap) {
  23127. if (!(typeof clipResults === "object" && clipResults && typeof formatMap === "object" && formatMap)) {
  23128. return clipResults;
  23129. }
  23130. var newResults = {};
  23131. for (var prop in clipResults) {
  23132. if (_hasOwn.call(clipResults, prop)) {
  23133. if (prop === "errors") {
  23134. newResults[prop] = clipResults[prop] ? clipResults[prop].slice() : [];
  23135. for (var i = 0, len = newResults[prop].length; i < len; i++) {
  23136. newResults[prop][i].format = formatMap[newResults[prop][i].format];
  23137. }
  23138. } else if (prop !== "success" && prop !== "data") {
  23139. newResults[prop] = clipResults[prop];
  23140. } else {
  23141. newResults[prop] = {};
  23142. var tmpHash = clipResults[prop];
  23143. for (var dataFormat in tmpHash) {
  23144. if (dataFormat && _hasOwn.call(tmpHash, dataFormat) && _hasOwn.call(formatMap, dataFormat)) {
  23145. newResults[prop][formatMap[dataFormat]] = tmpHash[dataFormat];
  23146. }
  23147. }
  23148. }
  23149. }
  23150. }
  23151. return newResults;
  23152. };
  23153. /**
  23154. * Will look at a path, and will create a "?noCache={time}" or "&noCache={time}"
  23155. * query param string to return. Does NOT append that string to the original path.
  23156. * This is useful because ExternalInterface often breaks when a Flash SWF is cached.
  23157. *
  23158. * @returns The `noCache` query param with necessary "?"/"&" prefix.
  23159. * @private
  23160. */
  23161. var _cacheBust = function(path, options) {
  23162. var cacheBust = options == null || options && options.cacheBust === true;
  23163. if (cacheBust) {
  23164. return (path.indexOf("?") === -1 ? "?" : "&") + "noCache=" + _now();
  23165. } else {
  23166. return "";
  23167. }
  23168. };
  23169. /**
  23170. * Creates a query string for the FlashVars param.
  23171. * Does NOT include the cache-busting query param.
  23172. *
  23173. * @returns FlashVars query string
  23174. * @private
  23175. */
  23176. var _vars = function(options) {
  23177. var i, len, domain, domains, str = "", trustedOriginsExpanded = [];
  23178. if (options.trustedDomains) {
  23179. if (typeof options.trustedDomains === "string") {
  23180. domains = [ options.trustedDomains ];
  23181. } else if (typeof options.trustedDomains === "object" && "length" in options.trustedDomains) {
  23182. domains = options.trustedDomains;
  23183. }
  23184. }
  23185. if (domains && domains.length) {
  23186. for (i = 0, len = domains.length; i < len; i++) {
  23187. if (_hasOwn.call(domains, i) && domains[i] && typeof domains[i] === "string") {
  23188. domain = _extractDomain(domains[i]);
  23189. if (!domain) {
  23190. continue;
  23191. }
  23192. if (domain === "*") {
  23193. trustedOriginsExpanded.length = 0;
  23194. trustedOriginsExpanded.push(domain);
  23195. break;
  23196. }
  23197. trustedOriginsExpanded.push.apply(trustedOriginsExpanded, [ domain, "//" + domain, _window.location.protocol + "//" + domain ]);
  23198. }
  23199. }
  23200. }
  23201. if (trustedOriginsExpanded.length) {
  23202. str += "trustedOrigins=" + _encodeURIComponent(trustedOriginsExpanded.join(","));
  23203. }
  23204. if (options.forceEnhancedClipboard === true) {
  23205. str += (str ? "&" : "") + "forceEnhancedClipboard=true";
  23206. }
  23207. if (typeof options.swfObjectId === "string" && options.swfObjectId) {
  23208. str += (str ? "&" : "") + "swfObjectId=" + _encodeURIComponent(options.swfObjectId);
  23209. }
  23210. if (typeof options.jsVersion === "string" && options.jsVersion) {
  23211. str += (str ? "&" : "") + "jsVersion=" + _encodeURIComponent(options.jsVersion);
  23212. }
  23213. return str;
  23214. };
  23215. /**
  23216. * Extract the domain (e.g. "github.com") from an origin (e.g. "https://github.com") or
  23217. * URL (e.g. "https://github.com/zeroclipboard/zeroclipboard/").
  23218. *
  23219. * @returns the domain
  23220. * @private
  23221. */
  23222. var _extractDomain = function(originOrUrl) {
  23223. if (originOrUrl == null || originOrUrl === "") {
  23224. return null;
  23225. }
  23226. originOrUrl = originOrUrl.replace(/^\s+|\s+$/g, "");
  23227. if (originOrUrl === "") {
  23228. return null;
  23229. }
  23230. var protocolIndex = originOrUrl.indexOf("//");
  23231. originOrUrl = protocolIndex === -1 ? originOrUrl : originOrUrl.slice(protocolIndex + 2);
  23232. var pathIndex = originOrUrl.indexOf("/");
  23233. originOrUrl = pathIndex === -1 ? originOrUrl : protocolIndex === -1 || pathIndex === 0 ? null : originOrUrl.slice(0, pathIndex);
  23234. if (originOrUrl && originOrUrl.slice(-4).toLowerCase() === ".swf") {
  23235. return null;
  23236. }
  23237. return originOrUrl || null;
  23238. };
  23239. /**
  23240. * Set `allowScriptAccess` based on `trustedDomains` and `window.location.host` vs. `swfPath`.
  23241. *
  23242. * @returns The appropriate script access level.
  23243. * @private
  23244. */
  23245. var _determineScriptAccess = function() {
  23246. var _extractAllDomains = function(origins) {
  23247. var i, len, tmp, resultsArray = [];
  23248. if (typeof origins === "string") {
  23249. origins = [ origins ];
  23250. }
  23251. if (!(typeof origins === "object" && origins && typeof origins.length === "number")) {
  23252. return resultsArray;
  23253. }
  23254. for (i = 0, len = origins.length; i < len; i++) {
  23255. if (_hasOwn.call(origins, i) && (tmp = _extractDomain(origins[i]))) {
  23256. if (tmp === "*") {
  23257. resultsArray.length = 0;
  23258. resultsArray.push("*");
  23259. break;
  23260. }
  23261. if (resultsArray.indexOf(tmp) === -1) {
  23262. resultsArray.push(tmp);
  23263. }
  23264. }
  23265. }
  23266. return resultsArray;
  23267. };
  23268. return function(currentDomain, configOptions) {
  23269. var swfDomain = _extractDomain(configOptions.swfPath);
  23270. if (swfDomain === null) {
  23271. swfDomain = currentDomain;
  23272. }
  23273. var trustedDomains = _extractAllDomains(configOptions.trustedDomains);
  23274. var len = trustedDomains.length;
  23275. if (len > 0) {
  23276. if (len === 1 && trustedDomains[0] === "*") {
  23277. return "always";
  23278. }
  23279. if (trustedDomains.indexOf(currentDomain) !== -1) {
  23280. if (len === 1 && currentDomain === swfDomain) {
  23281. return "sameDomain";
  23282. }
  23283. return "always";
  23284. }
  23285. }
  23286. return "never";
  23287. };
  23288. }();
  23289. /**
  23290. * Get the currently active/focused DOM element.
  23291. *
  23292. * @returns the currently active/focused element, or `null`
  23293. * @private
  23294. */
  23295. var _safeActiveElement = function() {
  23296. try {
  23297. return _document.activeElement;
  23298. } catch (err) {
  23299. return null;
  23300. }
  23301. };
  23302. /**
  23303. * Add a class to an element, if it doesn't already have it.
  23304. *
  23305. * @returns The element, with its new class added.
  23306. * @private
  23307. */
  23308. var _addClass = function(element, value) {
  23309. var c, cl, className, classNames = [];
  23310. if (typeof value === "string" && value) {
  23311. classNames = value.split(/\s+/);
  23312. }
  23313. if (element && element.nodeType === 1 && classNames.length > 0) {
  23314. if (element.classList) {
  23315. for (c = 0, cl = classNames.length; c < cl; c++) {
  23316. element.classList.add(classNames[c]);
  23317. }
  23318. } else if (element.hasOwnProperty("className")) {
  23319. className = " " + element.className + " ";
  23320. for (c = 0, cl = classNames.length; c < cl; c++) {
  23321. if (className.indexOf(" " + classNames[c] + " ") === -1) {
  23322. className += classNames[c] + " ";
  23323. }
  23324. }
  23325. element.className = className.replace(/^\s+|\s+$/g, "");
  23326. }
  23327. }
  23328. return element;
  23329. };
  23330. /**
  23331. * Remove a class from an element, if it has it.
  23332. *
  23333. * @returns The element, with its class removed.
  23334. * @private
  23335. */
  23336. var _removeClass = function(element, value) {
  23337. var c, cl, className, classNames = [];
  23338. if (typeof value === "string" && value) {
  23339. classNames = value.split(/\s+/);
  23340. }
  23341. if (element && element.nodeType === 1 && classNames.length > 0) {
  23342. if (element.classList && element.classList.length > 0) {
  23343. for (c = 0, cl = classNames.length; c < cl; c++) {
  23344. element.classList.remove(classNames[c]);
  23345. }
  23346. } else if (element.className) {
  23347. className = (" " + element.className + " ").replace(/[\r\n\t]/g, " ");
  23348. for (c = 0, cl = classNames.length; c < cl; c++) {
  23349. className = className.replace(" " + classNames[c] + " ", " ");
  23350. }
  23351. element.className = className.replace(/^\s+|\s+$/g, "");
  23352. }
  23353. }
  23354. return element;
  23355. };
  23356. /**
  23357. * Attempt to interpret the element's CSS styling. If `prop` is `"cursor"`,
  23358. * then we assume that it should be a hand ("pointer") cursor if the element
  23359. * is an anchor element ("a" tag).
  23360. *
  23361. * @returns The computed style property.
  23362. * @private
  23363. */
  23364. var _getStyle = function(el, prop) {
  23365. var value = _getComputedStyle(el, null).getPropertyValue(prop);
  23366. if (prop === "cursor") {
  23367. if (!value || value === "auto") {
  23368. if (el.nodeName === "A") {
  23369. return "pointer";
  23370. }
  23371. }
  23372. }
  23373. return value;
  23374. };
  23375. /**
  23376. * Get the absolutely positioned coordinates of a DOM element.
  23377. *
  23378. * @returns Object containing the element's position, width, and height.
  23379. * @private
  23380. */
  23381. var _getElementPosition = function(el) {
  23382. var pos = {
  23383. left: 0,
  23384. top: 0,
  23385. width: 0,
  23386. height: 0
  23387. };
  23388. if (el.getBoundingClientRect) {
  23389. var elRect = el.getBoundingClientRect();
  23390. var pageXOffset = _window.pageXOffset;
  23391. var pageYOffset = _window.pageYOffset;
  23392. var leftBorderWidth = _document.documentElement.clientLeft || 0;
  23393. var topBorderWidth = _document.documentElement.clientTop || 0;
  23394. var leftBodyOffset = 0;
  23395. var topBodyOffset = 0;
  23396. if (_getStyle(_document.body, "position") === "relative") {
  23397. var bodyRect = _document.body.getBoundingClientRect();
  23398. var htmlRect = _document.documentElement.getBoundingClientRect();
  23399. leftBodyOffset = bodyRect.left - htmlRect.left || 0;
  23400. topBodyOffset = bodyRect.top - htmlRect.top || 0;
  23401. }
  23402. pos.left = elRect.left + pageXOffset - leftBorderWidth - leftBodyOffset;
  23403. pos.top = elRect.top + pageYOffset - topBorderWidth - topBodyOffset;
  23404. pos.width = "width" in elRect ? elRect.width : elRect.right - elRect.left;
  23405. pos.height = "height" in elRect ? elRect.height : elRect.bottom - elRect.top;
  23406. }
  23407. return pos;
  23408. };
  23409. /**
  23410. * Determine is an element is visible somewhere within the document (page).
  23411. *
  23412. * @returns Boolean
  23413. * @private
  23414. */
  23415. var _isElementVisible = function(el) {
  23416. if (!el) {
  23417. return false;
  23418. }
  23419. var styles = _getComputedStyle(el, null);
  23420. var hasCssHeight = _parseFloat(styles.height) > 0;
  23421. var hasCssWidth = _parseFloat(styles.width) > 0;
  23422. var hasCssTop = _parseFloat(styles.top) >= 0;
  23423. var hasCssLeft = _parseFloat(styles.left) >= 0;
  23424. var cssKnows = hasCssHeight && hasCssWidth && hasCssTop && hasCssLeft;
  23425. var rect = cssKnows ? null : _getElementPosition(el);
  23426. 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));
  23427. return isVisible;
  23428. };
  23429. /**
  23430. * Clear all existing timeouts and interval polling delegates.
  23431. *
  23432. * @returns `undefined`
  23433. * @private
  23434. */
  23435. var _clearTimeoutsAndPolling = function() {
  23436. _clearTimeout(_flashCheckTimeout);
  23437. _flashCheckTimeout = 0;
  23438. _clearInterval(_swfFallbackCheckInterval);
  23439. _swfFallbackCheckInterval = 0;
  23440. };
  23441. /**
  23442. * Reposition the Flash object to cover the currently activated element.
  23443. *
  23444. * @returns `undefined`
  23445. * @private
  23446. */
  23447. var _reposition = function() {
  23448. var htmlBridge;
  23449. if (_currentElement && (htmlBridge = _getHtmlBridge(_flashState.bridge))) {
  23450. var pos = _getElementPosition(_currentElement);
  23451. _extend(htmlBridge.style, {
  23452. width: pos.width + "px",
  23453. height: pos.height + "px",
  23454. top: pos.top + "px",
  23455. left: pos.left + "px",
  23456. zIndex: "" + _getSafeZIndex(_globalConfig.zIndex)
  23457. });
  23458. }
  23459. };
  23460. /**
  23461. * Sends a signal to the Flash object to display the hand cursor if `true`.
  23462. *
  23463. * @returns `undefined`
  23464. * @private
  23465. */
  23466. var _setHandCursor = function(enabled) {
  23467. if (_flashState.ready === true) {
  23468. if (_flashState.bridge && typeof _flashState.bridge.setHandCursor === "function") {
  23469. _flashState.bridge.setHandCursor(enabled);
  23470. } else {
  23471. _flashState.ready = false;
  23472. }
  23473. }
  23474. };
  23475. /**
  23476. * Get a safe value for `zIndex`
  23477. *
  23478. * @returns an integer, or "auto"
  23479. * @private
  23480. */
  23481. var _getSafeZIndex = function(val) {
  23482. if (/^(?:auto|inherit)$/.test(val)) {
  23483. return val;
  23484. }
  23485. var zIndex;
  23486. if (typeof val === "number" && !_isNaN(val)) {
  23487. zIndex = val;
  23488. } else if (typeof val === "string") {
  23489. zIndex = _getSafeZIndex(_parseInt(val, 10));
  23490. }
  23491. return typeof zIndex === "number" ? zIndex : "auto";
  23492. };
  23493. /**
  23494. * Attempt to detect if ZeroClipboard is executing inside of a sandboxed iframe.
  23495. * If it is, Flash Player cannot be used, so ZeroClipboard is dead in the water.
  23496. *
  23497. * @see {@link http://lists.w3.org/Archives/Public/public-whatwg-archive/2014Dec/0002.html}
  23498. * @see {@link https://github.com/zeroclipboard/zeroclipboard/issues/511}
  23499. * @see {@link http://zeroclipboard.org/test-iframes.html}
  23500. *
  23501. * @returns `true` (is sandboxed), `false` (is not sandboxed), or `null` (uncertain)
  23502. * @private
  23503. */
  23504. var _detectSandbox = function(doNotReassessFlashSupport) {
  23505. var effectiveScriptOrigin, frame, frameError, previousState = _flashState.sandboxed, isSandboxed = null;
  23506. doNotReassessFlashSupport = doNotReassessFlashSupport === true;
  23507. if (_pageIsFramed === false) {
  23508. isSandboxed = false;
  23509. } else {
  23510. try {
  23511. frame = window.frameElement || null;
  23512. } catch (e) {
  23513. frameError = {
  23514. name: e.name,
  23515. message: e.message
  23516. };
  23517. }
  23518. if (frame && frame.nodeType === 1 && frame.nodeName === "IFRAME") {
  23519. try {
  23520. isSandboxed = frame.hasAttribute("sandbox");
  23521. } catch (e) {
  23522. isSandboxed = null;
  23523. }
  23524. } else {
  23525. try {
  23526. effectiveScriptOrigin = document.domain || null;
  23527. } catch (e) {
  23528. effectiveScriptOrigin = null;
  23529. }
  23530. if (effectiveScriptOrigin === null || frameError && frameError.name === "SecurityError" && /(^|[\s\(\[@])sandbox(es|ed|ing|[\s\.,!\)\]@]|$)/.test(frameError.message.toLowerCase())) {
  23531. isSandboxed = true;
  23532. }
  23533. }
  23534. }
  23535. _flashState.sandboxed = isSandboxed;
  23536. if (previousState !== isSandboxed && !doNotReassessFlashSupport) {
  23537. _detectFlashSupport(_ActiveXObject);
  23538. }
  23539. return isSandboxed;
  23540. };
  23541. /**
  23542. * Detect the Flash Player status, version, and plugin type.
  23543. *
  23544. * @see {@link https://code.google.com/p/doctype-mirror/wiki/ArticleDetectFlash#The_code}
  23545. * @see {@link http://stackoverflow.com/questions/12866060/detecting-pepper-ppapi-flash-with-javascript}
  23546. *
  23547. * @returns `undefined`
  23548. * @private
  23549. */
  23550. var _detectFlashSupport = function(ActiveXObject) {
  23551. var plugin, ax, mimeType, hasFlash = false, isActiveX = false, isPPAPI = false, flashVersion = "";
  23552. /**
  23553. * Derived from Apple's suggested sniffer.
  23554. * @param {String} desc e.g. "Shockwave Flash 7.0 r61"
  23555. * @returns {String} "7.0.61"
  23556. * @private
  23557. */
  23558. function parseFlashVersion(desc) {
  23559. var matches = desc.match(/[\d]+/g);
  23560. matches.length = 3;
  23561. return matches.join(".");
  23562. }
  23563. function isPepperFlash(flashPlayerFileName) {
  23564. return !!flashPlayerFileName && (flashPlayerFileName = flashPlayerFileName.toLowerCase()) && (/^(pepflashplayer\.dll|libpepflashplayer\.so|pepperflashplayer\.plugin)$/.test(flashPlayerFileName) || flashPlayerFileName.slice(-13) === "chrome.plugin");
  23565. }
  23566. function inspectPlugin(plugin) {
  23567. if (plugin) {
  23568. hasFlash = true;
  23569. if (plugin.version) {
  23570. flashVersion = parseFlashVersion(plugin.version);
  23571. }
  23572. if (!flashVersion && plugin.description) {
  23573. flashVersion = parseFlashVersion(plugin.description);
  23574. }
  23575. if (plugin.filename) {
  23576. isPPAPI = isPepperFlash(plugin.filename);
  23577. }
  23578. }
  23579. }
  23580. if (_navigator.plugins && _navigator.plugins.length) {
  23581. plugin = _navigator.plugins["Shockwave Flash"];
  23582. inspectPlugin(plugin);
  23583. if (_navigator.plugins["Shockwave Flash 2.0"]) {
  23584. hasFlash = true;
  23585. flashVersion = "2.0.0.11";
  23586. }
  23587. } else if (_navigator.mimeTypes && _navigator.mimeTypes.length) {
  23588. mimeType = _navigator.mimeTypes["application/x-shockwave-flash"];
  23589. plugin = mimeType && mimeType.enabledPlugin;
  23590. inspectPlugin(plugin);
  23591. } else if (typeof ActiveXObject !== "undefined") {
  23592. isActiveX = true;
  23593. try {
  23594. ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
  23595. hasFlash = true;
  23596. flashVersion = parseFlashVersion(ax.GetVariable("$version"));
  23597. } catch (e1) {
  23598. try {
  23599. ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
  23600. hasFlash = true;
  23601. flashVersion = "6.0.21";
  23602. } catch (e2) {
  23603. try {
  23604. ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  23605. hasFlash = true;
  23606. flashVersion = parseFlashVersion(ax.GetVariable("$version"));
  23607. } catch (e3) {
  23608. isActiveX = false;
  23609. }
  23610. }
  23611. }
  23612. }
  23613. _flashState.disabled = hasFlash !== true;
  23614. _flashState.outdated = flashVersion && _parseFloat(flashVersion) < _parseFloat(_minimumFlashVersion);
  23615. _flashState.version = flashVersion || "0.0.0";
  23616. _flashState.pluginType = isPPAPI ? "pepper" : isActiveX ? "activex" : hasFlash ? "netscape" : "unknown";
  23617. };
  23618. /**
  23619. * Invoke the Flash detection algorithms immediately upon inclusion so we're not waiting later.
  23620. */
  23621. _detectFlashSupport(_ActiveXObject);
  23622. /**
  23623. * Always assess the `sandboxed` state of the page at important Flash-related moments.
  23624. */
  23625. _detectSandbox(true);
  23626. /**
  23627. * A shell constructor for `ZeroClipboard` client instances.
  23628. *
  23629. * @constructor
  23630. */
  23631. var ZeroClipboard = function() {
  23632. if (!(this instanceof ZeroClipboard)) {
  23633. return new ZeroClipboard();
  23634. }
  23635. if (typeof ZeroClipboard._createClient === "function") {
  23636. ZeroClipboard._createClient.apply(this, _args(arguments));
  23637. }
  23638. };
  23639. /**
  23640. * The ZeroClipboard library's version number.
  23641. *
  23642. * @static
  23643. * @readonly
  23644. * @property {string}
  23645. */
  23646. _defineProperty(ZeroClipboard, "version", {
  23647. value: "2.2.0",
  23648. writable: false,
  23649. configurable: true,
  23650. enumerable: true
  23651. });
  23652. /**
  23653. * Update or get a copy of the ZeroClipboard global configuration.
  23654. * Returns a copy of the current/updated configuration.
  23655. *
  23656. * @returns Object
  23657. * @static
  23658. */
  23659. ZeroClipboard.config = function() {
  23660. return _config.apply(this, _args(arguments));
  23661. };
  23662. /**
  23663. * Diagnostic method that describes the state of the browser, Flash Player, and ZeroClipboard.
  23664. *
  23665. * @returns Object
  23666. * @static
  23667. */
  23668. ZeroClipboard.state = function() {
  23669. return _state.apply(this, _args(arguments));
  23670. };
  23671. /**
  23672. * Check if Flash is unusable for any reason: disabled, outdated, deactivated, etc.
  23673. *
  23674. * @returns Boolean
  23675. * @static
  23676. */
  23677. ZeroClipboard.isFlashUnusable = function() {
  23678. return _isFlashUnusable.apply(this, _args(arguments));
  23679. };
  23680. /**
  23681. * Register an event listener.
  23682. *
  23683. * @returns `ZeroClipboard`
  23684. * @static
  23685. */
  23686. ZeroClipboard.on = function() {
  23687. return _on.apply(this, _args(arguments));
  23688. };
  23689. /**
  23690. * Unregister an event listener.
  23691. * If no `listener` function/object is provided, it will unregister all listeners for the provided `eventType`.
  23692. * If no `eventType` is provided, it will unregister all listeners for every event type.
  23693. *
  23694. * @returns `ZeroClipboard`
  23695. * @static
  23696. */
  23697. ZeroClipboard.off = function() {
  23698. return _off.apply(this, _args(arguments));
  23699. };
  23700. /**
  23701. * Retrieve event listeners for an `eventType`.
  23702. * If no `eventType` is provided, it will retrieve all listeners for every event type.
  23703. *
  23704. * @returns array of listeners for the `eventType`; if no `eventType`, then a map/hash object of listeners for all event types; or `null`
  23705. */
  23706. ZeroClipboard.handlers = function() {
  23707. return _listeners.apply(this, _args(arguments));
  23708. };
  23709. /**
  23710. * Event emission receiver from the Flash object, forwarding to any registered JavaScript event listeners.
  23711. *
  23712. * @returns For the "copy" event, returns the Flash-friendly "clipData" object; otherwise `undefined`.
  23713. * @static
  23714. */
  23715. ZeroClipboard.emit = function() {
  23716. return _emit.apply(this, _args(arguments));
  23717. };
  23718. /**
  23719. * Create and embed the Flash object.
  23720. *
  23721. * @returns The Flash object
  23722. * @static
  23723. */
  23724. ZeroClipboard.create = function() {
  23725. return _create.apply(this, _args(arguments));
  23726. };
  23727. /**
  23728. * Self-destruct and clean up everything, including the embedded Flash object.
  23729. *
  23730. * @returns `undefined`
  23731. * @static
  23732. */
  23733. ZeroClipboard.destroy = function() {
  23734. return _destroy.apply(this, _args(arguments));
  23735. };
  23736. /**
  23737. * Set the pending data for clipboard injection.
  23738. *
  23739. * @returns `undefined`
  23740. * @static
  23741. */
  23742. ZeroClipboard.setData = function() {
  23743. return _setData.apply(this, _args(arguments));
  23744. };
  23745. /**
  23746. * Clear the pending data for clipboard injection.
  23747. * If no `format` is provided, all pending data formats will be cleared.
  23748. *
  23749. * @returns `undefined`
  23750. * @static
  23751. */
  23752. ZeroClipboard.clearData = function() {
  23753. return _clearData.apply(this, _args(arguments));
  23754. };
  23755. /**
  23756. * Get a copy of the pending data for clipboard injection.
  23757. * If no `format` is provided, a copy of ALL pending data formats will be returned.
  23758. *
  23759. * @returns `String` or `Object`
  23760. * @static
  23761. */
  23762. ZeroClipboard.getData = function() {
  23763. return _getData.apply(this, _args(arguments));
  23764. };
  23765. /**
  23766. * Sets the current HTML object that the Flash object should overlay. This will put the global
  23767. * Flash object on top of the current element; depending on the setup, this may also set the
  23768. * pending clipboard text data as well as the Flash object's wrapping element's title attribute
  23769. * based on the underlying HTML element and ZeroClipboard configuration.
  23770. *
  23771. * @returns `undefined`
  23772. * @static
  23773. */
  23774. ZeroClipboard.focus = ZeroClipboard.activate = function() {
  23775. return _focus.apply(this, _args(arguments));
  23776. };
  23777. /**
  23778. * Un-overlays the Flash object. This will put the global Flash object off-screen; depending on
  23779. * the setup, this may also unset the Flash object's wrapping element's title attribute based on
  23780. * the underlying HTML element and ZeroClipboard configuration.
  23781. *
  23782. * @returns `undefined`
  23783. * @static
  23784. */
  23785. ZeroClipboard.blur = ZeroClipboard.deactivate = function() {
  23786. return _blur.apply(this, _args(arguments));
  23787. };
  23788. /**
  23789. * Returns the currently focused/"activated" HTML element that the Flash object is wrapping.
  23790. *
  23791. * @returns `HTMLElement` or `null`
  23792. * @static
  23793. */
  23794. ZeroClipboard.activeElement = function() {
  23795. return _activeElement.apply(this, _args(arguments));
  23796. };
  23797. /**
  23798. * Keep track of the ZeroClipboard client instance counter.
  23799. */
  23800. var _clientIdCounter = 0;
  23801. /**
  23802. * Keep track of the state of the client instances.
  23803. *
  23804. * Entry structure:
  23805. * _clientMeta[client.id] = {
  23806. * instance: client,
  23807. * elements: [],
  23808. * handlers: {}
  23809. * };
  23810. */
  23811. var _clientMeta = {};
  23812. /**
  23813. * Keep track of the ZeroClipboard clipped elements counter.
  23814. */
  23815. var _elementIdCounter = 0;
  23816. /**
  23817. * Keep track of the state of the clipped element relationships to clients.
  23818. *
  23819. * Entry structure:
  23820. * _elementMeta[element.zcClippingId] = [client1.id, client2.id];
  23821. */
  23822. var _elementMeta = {};
  23823. /**
  23824. * Keep track of the state of the mouse event handlers for clipped elements.
  23825. *
  23826. * Entry structure:
  23827. * _mouseHandlers[element.zcClippingId] = {
  23828. * mouseover: function(event) {},
  23829. * mouseout: function(event) {},
  23830. * mouseenter: function(event) {},
  23831. * mouseleave: function(event) {},
  23832. * mousemove: function(event) {}
  23833. * };
  23834. */
  23835. var _mouseHandlers = {};
  23836. /**
  23837. * Extending the ZeroClipboard configuration defaults for the Client module.
  23838. */
  23839. _extend(_globalConfig, {
  23840. autoActivate: true
  23841. });
  23842. /**
  23843. * The real constructor for `ZeroClipboard` client instances.
  23844. * @private
  23845. */
  23846. var _clientConstructor = function(elements) {
  23847. var client = this;
  23848. client.id = "" + _clientIdCounter++;
  23849. _clientMeta[client.id] = {
  23850. instance: client,
  23851. elements: [],
  23852. handlers: {}
  23853. };
  23854. if (elements) {
  23855. client.clip(elements);
  23856. }
  23857. ZeroClipboard.on("*", function(event) {
  23858. return client.emit(event);
  23859. });
  23860. ZeroClipboard.on("destroy", function() {
  23861. client.destroy();
  23862. });
  23863. ZeroClipboard.create();
  23864. };
  23865. /**
  23866. * The underlying implementation of `ZeroClipboard.Client.prototype.on`.
  23867. * @private
  23868. */
  23869. var _clientOn = function(eventType, listener) {
  23870. var i, len, events, added = {}, meta = _clientMeta[this.id], handlers = meta && meta.handlers;
  23871. if (!meta) {
  23872. throw new Error("Attempted to add new listener(s) to a destroyed ZeroClipboard client instance");
  23873. }
  23874. if (typeof eventType === "string" && eventType) {
  23875. events = eventType.toLowerCase().split(/\s+/);
  23876. } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
  23877. for (i in eventType) {
  23878. if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
  23879. this.on(i, eventType[i]);
  23880. }
  23881. }
  23882. }
  23883. if (events && events.length) {
  23884. for (i = 0, len = events.length; i < len; i++) {
  23885. eventType = events[i].replace(/^on/, "");
  23886. added[eventType] = true;
  23887. if (!handlers[eventType]) {
  23888. handlers[eventType] = [];
  23889. }
  23890. handlers[eventType].push(listener);
  23891. }
  23892. if (added.ready && _flashState.ready) {
  23893. this.emit({
  23894. type: "ready",
  23895. client: this
  23896. });
  23897. }
  23898. if (added.error) {
  23899. for (i = 0, len = _flashStateErrorNames.length; i < len; i++) {
  23900. if (_flashState[_flashStateErrorNames[i].replace(/^flash-/, "")]) {
  23901. this.emit({
  23902. type: "error",
  23903. name: _flashStateErrorNames[i],
  23904. client: this
  23905. });
  23906. break;
  23907. }
  23908. }
  23909. if (_zcSwfVersion !== undefined && ZeroClipboard.version !== _zcSwfVersion) {
  23910. this.emit({
  23911. type: "error",
  23912. name: "version-mismatch",
  23913. jsVersion: ZeroClipboard.version,
  23914. swfVersion: _zcSwfVersion
  23915. });
  23916. }
  23917. }
  23918. }
  23919. return this;
  23920. };
  23921. /**
  23922. * The underlying implementation of `ZeroClipboard.Client.prototype.off`.
  23923. * @private
  23924. */
  23925. var _clientOff = function(eventType, listener) {
  23926. var i, len, foundIndex, events, perEventHandlers, meta = _clientMeta[this.id], handlers = meta && meta.handlers;
  23927. if (!handlers) {
  23928. return this;
  23929. }
  23930. if (arguments.length === 0) {
  23931. events = _keys(handlers);
  23932. } else if (typeof eventType === "string" && eventType) {
  23933. events = eventType.split(/\s+/);
  23934. } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
  23935. for (i in eventType) {
  23936. if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
  23937. this.off(i, eventType[i]);
  23938. }
  23939. }
  23940. }
  23941. if (events && events.length) {
  23942. for (i = 0, len = events.length; i < len; i++) {
  23943. eventType = events[i].toLowerCase().replace(/^on/, "");
  23944. perEventHandlers = handlers[eventType];
  23945. if (perEventHandlers && perEventHandlers.length) {
  23946. if (listener) {
  23947. foundIndex = perEventHandlers.indexOf(listener);
  23948. while (foundIndex !== -1) {
  23949. perEventHandlers.splice(foundIndex, 1);
  23950. foundIndex = perEventHandlers.indexOf(listener, foundIndex);
  23951. }
  23952. } else {
  23953. perEventHandlers.length = 0;
  23954. }
  23955. }
  23956. }
  23957. }
  23958. return this;
  23959. };
  23960. /**
  23961. * The underlying implementation of `ZeroClipboard.Client.prototype.handlers`.
  23962. * @private
  23963. */
  23964. var _clientListeners = function(eventType) {
  23965. var copy = null, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
  23966. if (handlers) {
  23967. if (typeof eventType === "string" && eventType) {
  23968. copy = handlers[eventType] ? handlers[eventType].slice(0) : [];
  23969. } else {
  23970. copy = _deepCopy(handlers);
  23971. }
  23972. }
  23973. return copy;
  23974. };
  23975. /**
  23976. * The underlying implementation of `ZeroClipboard.Client.prototype.emit`.
  23977. * @private
  23978. */
  23979. var _clientEmit = function(event) {
  23980. if (_clientShouldEmit.call(this, event)) {
  23981. if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
  23982. event = _extend({}, event);
  23983. }
  23984. var eventCopy = _extend({}, _createEvent(event), {
  23985. client: this
  23986. });
  23987. _clientDispatchCallbacks.call(this, eventCopy);
  23988. }
  23989. return this;
  23990. };
  23991. /**
  23992. * The underlying implementation of `ZeroClipboard.Client.prototype.clip`.
  23993. * @private
  23994. */
  23995. var _clientClip = function(elements) {
  23996. if (!_clientMeta[this.id]) {
  23997. throw new Error("Attempted to clip element(s) to a destroyed ZeroClipboard client instance");
  23998. }
  23999. elements = _prepClip(elements);
  24000. for (var i = 0; i < elements.length; i++) {
  24001. if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
  24002. if (!elements[i].zcClippingId) {
  24003. elements[i].zcClippingId = "zcClippingId_" + _elementIdCounter++;
  24004. _elementMeta[elements[i].zcClippingId] = [ this.id ];
  24005. if (_globalConfig.autoActivate === true) {
  24006. _addMouseHandlers(elements[i]);
  24007. }
  24008. } else if (_elementMeta[elements[i].zcClippingId].indexOf(this.id) === -1) {
  24009. _elementMeta[elements[i].zcClippingId].push(this.id);
  24010. }
  24011. var clippedElements = _clientMeta[this.id] && _clientMeta[this.id].elements;
  24012. if (clippedElements.indexOf(elements[i]) === -1) {
  24013. clippedElements.push(elements[i]);
  24014. }
  24015. }
  24016. }
  24017. return this;
  24018. };
  24019. /**
  24020. * The underlying implementation of `ZeroClipboard.Client.prototype.unclip`.
  24021. * @private
  24022. */
  24023. var _clientUnclip = function(elements) {
  24024. var meta = _clientMeta[this.id];
  24025. if (!meta) {
  24026. return this;
  24027. }
  24028. var clippedElements = meta.elements;
  24029. var arrayIndex;
  24030. if (typeof elements === "undefined") {
  24031. elements = clippedElements.slice(0);
  24032. } else {
  24033. elements = _prepClip(elements);
  24034. }
  24035. for (var i = elements.length; i--; ) {
  24036. if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
  24037. arrayIndex = 0;
  24038. while ((arrayIndex = clippedElements.indexOf(elements[i], arrayIndex)) !== -1) {
  24039. clippedElements.splice(arrayIndex, 1);
  24040. }
  24041. var clientIds = _elementMeta[elements[i].zcClippingId];
  24042. if (clientIds) {
  24043. arrayIndex = 0;
  24044. while ((arrayIndex = clientIds.indexOf(this.id, arrayIndex)) !== -1) {
  24045. clientIds.splice(arrayIndex, 1);
  24046. }
  24047. if (clientIds.length === 0) {
  24048. if (_globalConfig.autoActivate === true) {
  24049. _removeMouseHandlers(elements[i]);
  24050. }
  24051. delete elements[i].zcClippingId;
  24052. }
  24053. }
  24054. }
  24055. }
  24056. return this;
  24057. };
  24058. /**
  24059. * The underlying implementation of `ZeroClipboard.Client.prototype.elements`.
  24060. * @private
  24061. */
  24062. var _clientElements = function() {
  24063. var meta = _clientMeta[this.id];
  24064. return meta && meta.elements ? meta.elements.slice(0) : [];
  24065. };
  24066. /**
  24067. * The underlying implementation of `ZeroClipboard.Client.prototype.destroy`.
  24068. * @private
  24069. */
  24070. var _clientDestroy = function() {
  24071. if (!_clientMeta[this.id]) {
  24072. return;
  24073. }
  24074. this.unclip();
  24075. this.off();
  24076. delete _clientMeta[this.id];
  24077. };
  24078. /**
  24079. * Inspect an Event to see if the Client (`this`) should honor it for emission.
  24080. * @private
  24081. */
  24082. var _clientShouldEmit = function(event) {
  24083. if (!(event && event.type)) {
  24084. return false;
  24085. }
  24086. if (event.client && event.client !== this) {
  24087. return false;
  24088. }
  24089. var meta = _clientMeta[this.id];
  24090. var clippedEls = meta && meta.elements;
  24091. var hasClippedEls = !!clippedEls && clippedEls.length > 0;
  24092. var goodTarget = !event.target || hasClippedEls && clippedEls.indexOf(event.target) !== -1;
  24093. var goodRelTarget = event.relatedTarget && hasClippedEls && clippedEls.indexOf(event.relatedTarget) !== -1;
  24094. var goodClient = event.client && event.client === this;
  24095. if (!meta || !(goodTarget || goodRelTarget || goodClient)) {
  24096. return false;
  24097. }
  24098. return true;
  24099. };
  24100. /**
  24101. * Handle the actual dispatching of events to a client instance.
  24102. *
  24103. * @returns `undefined`
  24104. * @private
  24105. */
  24106. var _clientDispatchCallbacks = function(event) {
  24107. var meta = _clientMeta[this.id];
  24108. if (!(typeof event === "object" && event && event.type && meta)) {
  24109. return;
  24110. }
  24111. var async = _shouldPerformAsync(event);
  24112. var wildcardTypeHandlers = meta && meta.handlers["*"] || [];
  24113. var specificTypeHandlers = meta && meta.handlers[event.type] || [];
  24114. var handlers = wildcardTypeHandlers.concat(specificTypeHandlers);
  24115. if (handlers && handlers.length) {
  24116. var i, len, func, context, eventCopy, originalContext = this;
  24117. for (i = 0, len = handlers.length; i < len; i++) {
  24118. func = handlers[i];
  24119. context = originalContext;
  24120. if (typeof func === "string" && typeof _window[func] === "function") {
  24121. func = _window[func];
  24122. }
  24123. if (typeof func === "object" && func && typeof func.handleEvent === "function") {
  24124. context = func;
  24125. func = func.handleEvent;
  24126. }
  24127. if (typeof func === "function") {
  24128. eventCopy = _extend({}, event);
  24129. _dispatchCallback(func, context, [ eventCopy ], async);
  24130. }
  24131. }
  24132. }
  24133. };
  24134. /**
  24135. * Prepares the elements for clipping/unclipping.
  24136. *
  24137. * @returns An Array of elements.
  24138. * @private
  24139. */
  24140. var _prepClip = function(elements) {
  24141. if (typeof elements === "string") {
  24142. elements = [];
  24143. }
  24144. return typeof elements.length !== "number" ? [ elements ] : elements;
  24145. };
  24146. /**
  24147. * Add a `mouseover` handler function for a clipped element.
  24148. *
  24149. * @returns `undefined`
  24150. * @private
  24151. */
  24152. var _addMouseHandlers = function(element) {
  24153. if (!(element && element.nodeType === 1)) {
  24154. return;
  24155. }
  24156. var _suppressMouseEvents = function(event) {
  24157. if (!(event || (event = _window.event))) {
  24158. return;
  24159. }
  24160. if (event._source !== "js") {
  24161. event.stopImmediatePropagation();
  24162. event.preventDefault();
  24163. }
  24164. delete event._source;
  24165. };
  24166. var _elementMouseOver = function(event) {
  24167. if (!(event || (event = _window.event))) {
  24168. return;
  24169. }
  24170. _suppressMouseEvents(event);
  24171. ZeroClipboard.focus(element);
  24172. };
  24173. element.addEventListener("mouseover", _elementMouseOver, false);
  24174. element.addEventListener("mouseout", _suppressMouseEvents, false);
  24175. element.addEventListener("mouseenter", _suppressMouseEvents, false);
  24176. element.addEventListener("mouseleave", _suppressMouseEvents, false);
  24177. element.addEventListener("mousemove", _suppressMouseEvents, false);
  24178. _mouseHandlers[element.zcClippingId] = {
  24179. mouseover: _elementMouseOver,
  24180. mouseout: _suppressMouseEvents,
  24181. mouseenter: _suppressMouseEvents,
  24182. mouseleave: _suppressMouseEvents,
  24183. mousemove: _suppressMouseEvents
  24184. };
  24185. };
  24186. /**
  24187. * Remove a `mouseover` handler function for a clipped element.
  24188. *
  24189. * @returns `undefined`
  24190. * @private
  24191. */
  24192. var _removeMouseHandlers = function(element) {
  24193. if (!(element && element.nodeType === 1)) {
  24194. return;
  24195. }
  24196. var mouseHandlers = _mouseHandlers[element.zcClippingId];
  24197. if (!(typeof mouseHandlers === "object" && mouseHandlers)) {
  24198. return;
  24199. }
  24200. var key, val, mouseEvents = [ "move", "leave", "enter", "out", "over" ];
  24201. for (var i = 0, len = mouseEvents.length; i < len; i++) {
  24202. key = "mouse" + mouseEvents[i];
  24203. val = mouseHandlers[key];
  24204. if (typeof val === "function") {
  24205. element.removeEventListener(key, val, false);
  24206. }
  24207. }
  24208. delete _mouseHandlers[element.zcClippingId];
  24209. };
  24210. /**
  24211. * Creates a new ZeroClipboard client instance.
  24212. * Optionally, auto-`clip` an element or collection of elements.
  24213. *
  24214. * @constructor
  24215. */
  24216. ZeroClipboard._createClient = function() {
  24217. _clientConstructor.apply(this, _args(arguments));
  24218. };
  24219. /**
  24220. * Register an event listener to the client.
  24221. *
  24222. * @returns `this`
  24223. */
  24224. ZeroClipboard.prototype.on = function() {
  24225. return _clientOn.apply(this, _args(arguments));
  24226. };
  24227. /**
  24228. * Unregister an event handler from the client.
  24229. * If no `listener` function/object is provided, it will unregister all handlers for the provided `eventType`.
  24230. * If no `eventType` is provided, it will unregister all handlers for every event type.
  24231. *
  24232. * @returns `this`
  24233. */
  24234. ZeroClipboard.prototype.off = function() {
  24235. return _clientOff.apply(this, _args(arguments));
  24236. };
  24237. /**
  24238. * Retrieve event listeners for an `eventType` from the client.
  24239. * If no `eventType` is provided, it will retrieve all listeners for every event type.
  24240. *
  24241. * @returns array of listeners for the `eventType`; if no `eventType`, then a map/hash object of listeners for all event types; or `null`
  24242. */
  24243. ZeroClipboard.prototype.handlers = function() {
  24244. return _clientListeners.apply(this, _args(arguments));
  24245. };
  24246. /**
  24247. * Event emission receiver from the Flash object for this client's registered JavaScript event listeners.
  24248. *
  24249. * @returns For the "copy" event, returns the Flash-friendly "clipData" object; otherwise `undefined`.
  24250. */
  24251. ZeroClipboard.prototype.emit = function() {
  24252. return _clientEmit.apply(this, _args(arguments));
  24253. };
  24254. /**
  24255. * Register clipboard actions for new element(s) to the client.
  24256. *
  24257. * @returns `this`
  24258. */
  24259. ZeroClipboard.prototype.clip = function() {
  24260. return _clientClip.apply(this, _args(arguments));
  24261. };
  24262. /**
  24263. * Unregister the clipboard actions of previously registered element(s) on the page.
  24264. * If no elements are provided, ALL registered elements will be unregistered.
  24265. *
  24266. * @returns `this`
  24267. */
  24268. ZeroClipboard.prototype.unclip = function() {
  24269. return _clientUnclip.apply(this, _args(arguments));
  24270. };
  24271. /**
  24272. * Get all of the elements to which this client is clipped.
  24273. *
  24274. * @returns array of clipped elements
  24275. */
  24276. ZeroClipboard.prototype.elements = function() {
  24277. return _clientElements.apply(this, _args(arguments));
  24278. };
  24279. /**
  24280. * Self-destruct and clean up everything for a single client.
  24281. * This will NOT destroy the embedded Flash object.
  24282. *
  24283. * @returns `undefined`
  24284. */
  24285. ZeroClipboard.prototype.destroy = function() {
  24286. return _clientDestroy.apply(this, _args(arguments));
  24287. };
  24288. /**
  24289. * Stores the pending plain text to inject into the clipboard.
  24290. *
  24291. * @returns `this`
  24292. */
  24293. ZeroClipboard.prototype.setText = function(text) {
  24294. if (!_clientMeta[this.id]) {
  24295. throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
  24296. }
  24297. ZeroClipboard.setData("text/plain", text);
  24298. return this;
  24299. };
  24300. /**
  24301. * Stores the pending HTML text to inject into the clipboard.
  24302. *
  24303. * @returns `this`
  24304. */
  24305. ZeroClipboard.prototype.setHtml = function(html) {
  24306. if (!_clientMeta[this.id]) {
  24307. throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
  24308. }
  24309. ZeroClipboard.setData("text/html", html);
  24310. return this;
  24311. };
  24312. /**
  24313. * Stores the pending rich text (RTF) to inject into the clipboard.
  24314. *
  24315. * @returns `this`
  24316. */
  24317. ZeroClipboard.prototype.setRichText = function(richText) {
  24318. if (!_clientMeta[this.id]) {
  24319. throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
  24320. }
  24321. ZeroClipboard.setData("application/rtf", richText);
  24322. return this;
  24323. };
  24324. /**
  24325. * Stores the pending data to inject into the clipboard.
  24326. *
  24327. * @returns `this`
  24328. */
  24329. ZeroClipboard.prototype.setData = function() {
  24330. if (!_clientMeta[this.id]) {
  24331. throw new Error("Attempted to set pending clipboard data from a destroyed ZeroClipboard client instance");
  24332. }
  24333. ZeroClipboard.setData.apply(this, _args(arguments));
  24334. return this;
  24335. };
  24336. /**
  24337. * Clears the pending data to inject into the clipboard.
  24338. * If no `format` is provided, all pending data formats will be cleared.
  24339. *
  24340. * @returns `this`
  24341. */
  24342. ZeroClipboard.prototype.clearData = function() {
  24343. if (!_clientMeta[this.id]) {
  24344. throw new Error("Attempted to clear pending clipboard data from a destroyed ZeroClipboard client instance");
  24345. }
  24346. ZeroClipboard.clearData.apply(this, _args(arguments));
  24347. return this;
  24348. };
  24349. /**
  24350. * Gets a copy of the pending data to inject into the clipboard.
  24351. * If no `format` is provided, a copy of ALL pending data formats will be returned.
  24352. *
  24353. * @returns `String` or `Object`
  24354. */
  24355. ZeroClipboard.prototype.getData = function() {
  24356. if (!_clientMeta[this.id]) {
  24357. throw new Error("Attempted to get pending clipboard data from a destroyed ZeroClipboard client instance");
  24358. }
  24359. return ZeroClipboard.getData.apply(this, _args(arguments));
  24360. };
  24361. if (typeof define === "function" && define.amd) {
  24362. define(function() {
  24363. return ZeroClipboard;
  24364. });
  24365. } else if (typeof module === "object" && module && typeof module.exports === "object" && module.exports) {
  24366. module.exports = ZeroClipboard;
  24367. } else {
  24368. window.ZeroClipboard = ZeroClipboard;
  24369. }
  24370. })(function() {
  24371. return this || window;
  24372. }());
  24373. },{}]},{},[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")
  24374. });