bootstrap-colorpicker.js 160 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252
  1. /*!
  2. * Bootstrap Colorpicker - Bootstrap Colorpicker is a modular color picker plugin for Bootstrap 4.
  3. * @package bootstrap-colorpicker
  4. * @version v3.2.0
  5. * @license MIT
  6. * @link https://itsjavi.com/bootstrap-colorpicker/
  7. * @link https://github.com/itsjavi/bootstrap-colorpicker.git
  8. */
  9. (function webpackUniversalModuleDefinition(root, factory) {
  10. if(typeof exports === 'object' && typeof module === 'object')
  11. module.exports = factory(require("jquery"));
  12. else if(typeof define === 'function' && define.amd)
  13. define("bootstrap-colorpicker", ["jquery"], factory);
  14. else if(typeof exports === 'object')
  15. exports["bootstrap-colorpicker"] = factory(require("jquery"));
  16. else
  17. root["bootstrap-colorpicker"] = factory(root["jQuery"]);
  18. })(window, function(__WEBPACK_EXTERNAL_MODULE__0__) {
  19. return /******/ (function(modules) { // webpackBootstrap
  20. /******/ // The module cache
  21. /******/ var installedModules = {};
  22. /******/
  23. /******/ // The require function
  24. /******/ function __webpack_require__(moduleId) {
  25. /******/
  26. /******/ // Check if module is in cache
  27. /******/ if(installedModules[moduleId]) {
  28. /******/ return installedModules[moduleId].exports;
  29. /******/ }
  30. /******/ // Create a new module (and put it into the cache)
  31. /******/ var module = installedModules[moduleId] = {
  32. /******/ i: moduleId,
  33. /******/ l: false,
  34. /******/ exports: {}
  35. /******/ };
  36. /******/
  37. /******/ // Execute the module function
  38. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  39. /******/
  40. /******/ // Flag the module as loaded
  41. /******/ module.l = true;
  42. /******/
  43. /******/ // Return the exports of the module
  44. /******/ return module.exports;
  45. /******/ }
  46. /******/
  47. /******/
  48. /******/ // expose the modules object (__webpack_modules__)
  49. /******/ __webpack_require__.m = modules;
  50. /******/
  51. /******/ // expose the module cache
  52. /******/ __webpack_require__.c = installedModules;
  53. /******/
  54. /******/ // define getter function for harmony exports
  55. /******/ __webpack_require__.d = function(exports, name, getter) {
  56. /******/ if(!__webpack_require__.o(exports, name)) {
  57. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  58. /******/ }
  59. /******/ };
  60. /******/
  61. /******/ // define __esModule on exports
  62. /******/ __webpack_require__.r = function(exports) {
  63. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  64. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  65. /******/ }
  66. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  67. /******/ };
  68. /******/
  69. /******/ // create a fake namespace object
  70. /******/ // mode & 1: value is a module id, require it
  71. /******/ // mode & 2: merge all properties of value into the ns
  72. /******/ // mode & 4: return value when already ns object
  73. /******/ // mode & 8|1: behave like require
  74. /******/ __webpack_require__.t = function(value, mode) {
  75. /******/ if(mode & 1) value = __webpack_require__(value);
  76. /******/ if(mode & 8) return value;
  77. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  78. /******/ var ns = Object.create(null);
  79. /******/ __webpack_require__.r(ns);
  80. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  81. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  82. /******/ return ns;
  83. /******/ };
  84. /******/
  85. /******/ // getDefaultExport function for compatibility with non-harmony modules
  86. /******/ __webpack_require__.n = function(module) {
  87. /******/ var getter = module && module.__esModule ?
  88. /******/ function getDefault() { return module['default']; } :
  89. /******/ function getModuleExports() { return module; };
  90. /******/ __webpack_require__.d(getter, 'a', getter);
  91. /******/ return getter;
  92. /******/ };
  93. /******/
  94. /******/ // Object.prototype.hasOwnProperty.call
  95. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  96. /******/
  97. /******/ // __webpack_public_path__
  98. /******/ __webpack_require__.p = "";
  99. /******/
  100. /******/
  101. /******/ // Load entry module and return exports
  102. /******/ return __webpack_require__(__webpack_require__.s = 7);
  103. /******/ })
  104. /************************************************************************/
  105. /******/ ([
  106. /* 0 */
  107. /***/ (function(module, exports) {
  108. module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
  109. /***/ }),
  110. /* 1 */
  111. /***/ (function(module, exports, __webpack_require__) {
  112. "use strict";
  113. Object.defineProperty(exports, "__esModule", {
  114. value: true
  115. });
  116. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  117. var _jquery = __webpack_require__(0);
  118. var _jquery2 = _interopRequireDefault(_jquery);
  119. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  120. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  121. /**
  122. * Colorpicker extension class.
  123. */
  124. var Extension = function () {
  125. /**
  126. * @param {Colorpicker} colorpicker
  127. * @param {Object} options
  128. */
  129. function Extension(colorpicker) {
  130. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  131. _classCallCheck(this, Extension);
  132. /**
  133. * The colorpicker instance
  134. * @type {Colorpicker}
  135. */
  136. this.colorpicker = colorpicker;
  137. /**
  138. * Extension options
  139. *
  140. * @type {Object}
  141. */
  142. this.options = options;
  143. if (!(this.colorpicker.element && this.colorpicker.element.length)) {
  144. throw new Error('Extension: this.colorpicker.element is not valid');
  145. }
  146. this.colorpicker.element.on('colorpickerCreate.colorpicker-ext', _jquery2.default.proxy(this.onCreate, this));
  147. this.colorpicker.element.on('colorpickerDestroy.colorpicker-ext', _jquery2.default.proxy(this.onDestroy, this));
  148. this.colorpicker.element.on('colorpickerUpdate.colorpicker-ext', _jquery2.default.proxy(this.onUpdate, this));
  149. this.colorpicker.element.on('colorpickerChange.colorpicker-ext', _jquery2.default.proxy(this.onChange, this));
  150. this.colorpicker.element.on('colorpickerInvalid.colorpicker-ext', _jquery2.default.proxy(this.onInvalid, this));
  151. this.colorpicker.element.on('colorpickerShow.colorpicker-ext', _jquery2.default.proxy(this.onShow, this));
  152. this.colorpicker.element.on('colorpickerHide.colorpicker-ext', _jquery2.default.proxy(this.onHide, this));
  153. this.colorpicker.element.on('colorpickerEnable.colorpicker-ext', _jquery2.default.proxy(this.onEnable, this));
  154. this.colorpicker.element.on('colorpickerDisable.colorpicker-ext', _jquery2.default.proxy(this.onDisable, this));
  155. }
  156. /**
  157. * Function called every time a new color needs to be created.
  158. * Return false to skip this resolver and continue with other extensions' ones
  159. * or return anything else to consider the color resolved.
  160. *
  161. * @param {ColorItem|String|*} color
  162. * @param {boolean} realColor if true, the color should resolve into a real (not named) color code
  163. * @return {ColorItem|String|*}
  164. */
  165. _createClass(Extension, [{
  166. key: 'resolveColor',
  167. value: function resolveColor(color) {
  168. var realColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  169. return false;
  170. }
  171. /**
  172. * Method called after the colorpicker is created
  173. *
  174. * @listens Colorpicker#colorpickerCreate
  175. * @param {Event} event
  176. */
  177. }, {
  178. key: 'onCreate',
  179. value: function onCreate(event) {}
  180. // to be extended
  181. /**
  182. * Method called after the colorpicker is destroyed
  183. *
  184. * @listens Colorpicker#colorpickerDestroy
  185. * @param {Event} event
  186. */
  187. }, {
  188. key: 'onDestroy',
  189. value: function onDestroy(event) {
  190. this.colorpicker.element.off('.colorpicker-ext');
  191. }
  192. /**
  193. * Method called after the colorpicker is updated
  194. *
  195. * @listens Colorpicker#colorpickerUpdate
  196. * @param {Event} event
  197. */
  198. }, {
  199. key: 'onUpdate',
  200. value: function onUpdate(event) {}
  201. // to be extended
  202. /**
  203. * Method called after the colorpicker color is changed
  204. *
  205. * @listens Colorpicker#colorpickerChange
  206. * @param {Event} event
  207. */
  208. }, {
  209. key: 'onChange',
  210. value: function onChange(event) {}
  211. // to be extended
  212. /**
  213. * Method called when the colorpicker color is invalid
  214. *
  215. * @listens Colorpicker#colorpickerInvalid
  216. * @param {Event} event
  217. */
  218. }, {
  219. key: 'onInvalid',
  220. value: function onInvalid(event) {}
  221. // to be extended
  222. /**
  223. * Method called after the colorpicker is hidden
  224. *
  225. * @listens Colorpicker#colorpickerHide
  226. * @param {Event} event
  227. */
  228. }, {
  229. key: 'onHide',
  230. value: function onHide(event) {}
  231. // to be extended
  232. /**
  233. * Method called after the colorpicker is shown
  234. *
  235. * @listens Colorpicker#colorpickerShow
  236. * @param {Event} event
  237. */
  238. }, {
  239. key: 'onShow',
  240. value: function onShow(event) {}
  241. // to be extended
  242. /**
  243. * Method called after the colorpicker is disabled
  244. *
  245. * @listens Colorpicker#colorpickerDisable
  246. * @param {Event} event
  247. */
  248. }, {
  249. key: 'onDisable',
  250. value: function onDisable(event) {}
  251. // to be extended
  252. /**
  253. * Method called after the colorpicker is enabled
  254. *
  255. * @listens Colorpicker#colorpickerEnable
  256. * @param {Event} event
  257. */
  258. }, {
  259. key: 'onEnable',
  260. value: function onEnable(event) {
  261. // to be extended
  262. }
  263. }]);
  264. return Extension;
  265. }();
  266. exports.default = Extension;
  267. module.exports = exports.default;
  268. /***/ }),
  269. /* 2 */
  270. /***/ (function(module, exports, __webpack_require__) {
  271. "use strict";
  272. Object.defineProperty(exports, "__esModule", {
  273. value: true
  274. });
  275. exports.ColorItem = exports.HSVAColor = undefined;
  276. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
  277. * Color manipulation class, specific for Bootstrap Colorpicker
  278. */
  279. var _color = __webpack_require__(16);
  280. var _color2 = _interopRequireDefault(_color);
  281. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  282. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  283. /**
  284. * HSVA color data class, containing the hue, saturation, value and alpha
  285. * information.
  286. */
  287. var HSVAColor = function () {
  288. /**
  289. * @param {number|int} h
  290. * @param {number|int} s
  291. * @param {number|int} v
  292. * @param {number|int} a
  293. */
  294. function HSVAColor(h, s, v, a) {
  295. _classCallCheck(this, HSVAColor);
  296. this.h = isNaN(h) ? 0 : h;
  297. this.s = isNaN(s) ? 0 : s;
  298. this.v = isNaN(v) ? 0 : v;
  299. this.a = isNaN(h) ? 1 : a;
  300. }
  301. _createClass(HSVAColor, [{
  302. key: 'toString',
  303. value: function toString() {
  304. return this.h + ', ' + this.s + '%, ' + this.v + '%, ' + this.a;
  305. }
  306. }]);
  307. return HSVAColor;
  308. }();
  309. /**
  310. * HSVA color manipulation
  311. */
  312. var ColorItem = function () {
  313. _createClass(ColorItem, [{
  314. key: 'api',
  315. /**
  316. * Applies a method of the QixColor API and returns a new Color object or
  317. * the return value of the method call.
  318. *
  319. * If no argument is provided, the internal QixColor object is returned.
  320. *
  321. * @param {String} fn QixColor function name
  322. * @param args QixColor function arguments
  323. * @example let darkerColor = color.api('darken', 0.25);
  324. * @example let luminosity = color.api('luminosity');
  325. * @example color = color.api('negate');
  326. * @example let qColor = color.api().negate();
  327. * @returns {ColorItem|QixColor|*}
  328. */
  329. value: function api(fn) {
  330. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  331. args[_key - 1] = arguments[_key];
  332. }
  333. if (arguments.length === 0) {
  334. return this._color;
  335. }
  336. var result = this._color[fn].apply(this._color, args);
  337. if (!(result instanceof _color2.default)) {
  338. // return result of the method call
  339. return result;
  340. }
  341. return new ColorItem(result, this.format);
  342. }
  343. /**
  344. * Returns the original ColorItem constructor data,
  345. * plus a 'valid' flag to know if it's valid or not.
  346. *
  347. * @returns {{color: *, format: String, valid: boolean}}
  348. */
  349. }, {
  350. key: 'original',
  351. get: function get() {
  352. return this._original;
  353. }
  354. /**
  355. * @param {ColorItem|HSVAColor|QixColor|String|*|null} color Color data
  356. * @param {String|null} format Color model to convert to by default. Supported: 'rgb', 'hsl', 'hex'.
  357. */
  358. }], [{
  359. key: 'HSVAColor',
  360. /**
  361. * Returns the HSVAColor class
  362. *
  363. * @static
  364. * @example let colorData = new ColorItem.HSVAColor(360, 100, 100, 1);
  365. * @returns {HSVAColor}
  366. */
  367. get: function get() {
  368. return HSVAColor;
  369. }
  370. }]);
  371. function ColorItem() {
  372. var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  373. var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  374. _classCallCheck(this, ColorItem);
  375. this.replace(color, format);
  376. }
  377. /**
  378. * Replaces the internal QixColor object with a new one.
  379. * This also replaces the internal original color data.
  380. *
  381. * @param {ColorItem|HSVAColor|QixColor|String|*|null} color Color data to be parsed (if needed)
  382. * @param {String|null} format Color model to convert to by default. Supported: 'rgb', 'hsl', 'hex'.
  383. * @example color.replace('rgb(255,0,0)', 'hsl');
  384. * @example color.replace(hsvaColorData);
  385. */
  386. _createClass(ColorItem, [{
  387. key: 'replace',
  388. value: function replace(color) {
  389. var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  390. format = ColorItem.sanitizeFormat(format);
  391. /**
  392. * @type {{color: *, format: String}}
  393. * @private
  394. */
  395. this._original = {
  396. color: color,
  397. format: format,
  398. valid: true
  399. };
  400. /**
  401. * @type {QixColor}
  402. * @private
  403. */
  404. this._color = ColorItem.parse(color);
  405. if (this._color === null) {
  406. this._color = (0, _color2.default)();
  407. this._original.valid = false;
  408. return;
  409. }
  410. /**
  411. * @type {*|string}
  412. * @private
  413. */
  414. this._format = format ? format : ColorItem.isHex(color) ? 'hex' : this._color.model;
  415. }
  416. /**
  417. * Parses the color returning a Qix Color object or null if cannot be
  418. * parsed.
  419. *
  420. * @param {ColorItem|HSVAColor|QixColor|String|*|null} color Color data
  421. * @example let qColor = ColorItem.parse('rgb(255,0,0)');
  422. * @static
  423. * @returns {QixColor|null}
  424. */
  425. }, {
  426. key: 'isValid',
  427. /**
  428. * Returns true if the color is valid, false if not.
  429. *
  430. * @returns {boolean}
  431. */
  432. value: function isValid() {
  433. return this._original.valid === true;
  434. }
  435. /**
  436. * Hue value from 0 to 360
  437. *
  438. * @returns {int}
  439. */
  440. }, {
  441. key: 'setHueRatio',
  442. /**
  443. * Sets the hue ratio, where 1.0 is 0, 0.5 is 180 and 0.0 is 360.
  444. *
  445. * @ignore
  446. * @param {number} h Ratio from 1.0 to 0.0
  447. */
  448. value: function setHueRatio(h) {
  449. this.hue = (1 - h) * 360;
  450. }
  451. /**
  452. * Sets the saturation value
  453. *
  454. * @param {int} value Integer from 0 to 100
  455. */
  456. }, {
  457. key: 'setSaturationRatio',
  458. /**
  459. * Sets the saturation ratio, where 1.0 is 100 and 0.0 is 0.
  460. *
  461. * @ignore
  462. * @param {number} s Ratio from 0.0 to 1.0
  463. */
  464. value: function setSaturationRatio(s) {
  465. this.saturation = s * 100;
  466. }
  467. /**
  468. * Sets the 'value' channel value
  469. *
  470. * @param {int} value Integer from 0 to 100
  471. */
  472. }, {
  473. key: 'setValueRatio',
  474. /**
  475. * Sets the value ratio, where 1.0 is 0 and 0.0 is 100.
  476. *
  477. * @ignore
  478. * @param {number} v Ratio from 1.0 to 0.0
  479. */
  480. value: function setValueRatio(v) {
  481. this.value = (1 - v) * 100;
  482. }
  483. /**
  484. * Sets the alpha value. It will be rounded to 2 decimals.
  485. *
  486. * @param {int} value Float from 0.0 to 1.0
  487. */
  488. }, {
  489. key: 'setAlphaRatio',
  490. /**
  491. * Sets the alpha ratio, where 1.0 is 0.0 and 0.0 is 1.0.
  492. *
  493. * @ignore
  494. * @param {number} a Ratio from 1.0 to 0.0
  495. */
  496. value: function setAlphaRatio(a) {
  497. this.alpha = 1 - a;
  498. }
  499. /**
  500. * Sets the default color format
  501. *
  502. * @param {String} value Supported: 'rgb', 'hsl', 'hex'
  503. */
  504. }, {
  505. key: 'isDesaturated',
  506. /**
  507. * Returns true if the saturation value is zero, false otherwise
  508. *
  509. * @returns {boolean}
  510. */
  511. value: function isDesaturated() {
  512. return this.saturation === 0;
  513. }
  514. /**
  515. * Returns true if the alpha value is zero, false otherwise
  516. *
  517. * @returns {boolean}
  518. */
  519. }, {
  520. key: 'isTransparent',
  521. value: function isTransparent() {
  522. return this.alpha === 0;
  523. }
  524. /**
  525. * Returns true if the alpha value is numeric and less than 1, false otherwise
  526. *
  527. * @returns {boolean}
  528. */
  529. }, {
  530. key: 'hasTransparency',
  531. value: function hasTransparency() {
  532. return this.hasAlpha() && this.alpha < 1;
  533. }
  534. /**
  535. * Returns true if the alpha value is numeric, false otherwise
  536. *
  537. * @returns {boolean}
  538. */
  539. }, {
  540. key: 'hasAlpha',
  541. value: function hasAlpha() {
  542. return !isNaN(this.alpha);
  543. }
  544. /**
  545. * Returns a new HSVAColor object, based on the current color
  546. *
  547. * @returns {HSVAColor}
  548. */
  549. }, {
  550. key: 'toObject',
  551. value: function toObject() {
  552. return new HSVAColor(this.hue, this.saturation, this.value, this.alpha);
  553. }
  554. /**
  555. * Alias of toObject()
  556. *
  557. * @returns {HSVAColor}
  558. */
  559. }, {
  560. key: 'toHsva',
  561. value: function toHsva() {
  562. return this.toObject();
  563. }
  564. /**
  565. * Returns a new HSVAColor object with the ratio values (from 0.0 to 1.0),
  566. * based on the current color.
  567. *
  568. * @ignore
  569. * @returns {HSVAColor}
  570. */
  571. }, {
  572. key: 'toHsvaRatio',
  573. value: function toHsvaRatio() {
  574. return new HSVAColor(this.hue / 360, this.saturation / 100, this.value / 100, this.alpha);
  575. }
  576. /**
  577. * Converts the current color to its string representation,
  578. * using the internal format of this instance.
  579. *
  580. * @returns {String}
  581. */
  582. }, {
  583. key: 'toString',
  584. value: function toString() {
  585. return this.string();
  586. }
  587. /**
  588. * Converts the current color to its string representation,
  589. * using the given format.
  590. *
  591. * @param {String|null} format Format to convert to. If empty or null, the internal format will be used.
  592. * @returns {String}
  593. */
  594. }, {
  595. key: 'string',
  596. value: function string() {
  597. var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  598. format = ColorItem.sanitizeFormat(format ? format : this.format);
  599. if (!format) {
  600. return this._color.round().string();
  601. }
  602. if (this._color[format] === undefined) {
  603. throw new Error('Unsupported color format: \'' + format + '\'');
  604. }
  605. var str = this._color[format]();
  606. return str.round ? str.round().string() : str;
  607. }
  608. /**
  609. * Returns true if the given color values equals this one, false otherwise.
  610. * The format is not compared.
  611. * If any of the colors is invalid, the result will be false.
  612. *
  613. * @param {ColorItem|HSVAColor|QixColor|String|*|null} color Color data
  614. *
  615. * @returns {boolean}
  616. */
  617. }, {
  618. key: 'equals',
  619. value: function equals(color) {
  620. color = color instanceof ColorItem ? color : new ColorItem(color);
  621. if (!color.isValid() || !this.isValid()) {
  622. return false;
  623. }
  624. return this.hue === color.hue && this.saturation === color.saturation && this.value === color.value && this.alpha === color.alpha;
  625. }
  626. /**
  627. * Creates a copy of this instance
  628. *
  629. * @returns {ColorItem}
  630. */
  631. }, {
  632. key: 'getClone',
  633. value: function getClone() {
  634. return new ColorItem(this._color, this.format);
  635. }
  636. /**
  637. * Creates a copy of this instance, only copying the hue value,
  638. * and setting the others to its max value.
  639. *
  640. * @returns {ColorItem}
  641. */
  642. }, {
  643. key: 'getCloneHueOnly',
  644. value: function getCloneHueOnly() {
  645. return new ColorItem([this.hue, 100, 100, 1], this.format);
  646. }
  647. /**
  648. * Creates a copy of this instance setting the alpha to the max.
  649. *
  650. * @returns {ColorItem}
  651. */
  652. }, {
  653. key: 'getCloneOpaque',
  654. value: function getCloneOpaque() {
  655. return new ColorItem(this._color.alpha(1), this.format);
  656. }
  657. /**
  658. * Converts the color to a RGB string
  659. *
  660. * @returns {String}
  661. */
  662. }, {
  663. key: 'toRgbString',
  664. value: function toRgbString() {
  665. return this.string('rgb');
  666. }
  667. /**
  668. * Converts the color to a Hexadecimal string
  669. *
  670. * @returns {String}
  671. */
  672. }, {
  673. key: 'toHexString',
  674. value: function toHexString() {
  675. return this.string('hex');
  676. }
  677. /**
  678. * Converts the color to a HSL string
  679. *
  680. * @returns {String}
  681. */
  682. }, {
  683. key: 'toHslString',
  684. value: function toHslString() {
  685. return this.string('hsl');
  686. }
  687. /**
  688. * Returns true if the color is dark, false otherwhise.
  689. * This is useful to decide a text color.
  690. *
  691. * @returns {boolean}
  692. */
  693. }, {
  694. key: 'isDark',
  695. value: function isDark() {
  696. return this._color.isDark();
  697. }
  698. /**
  699. * Returns true if the color is light, false otherwhise.
  700. * This is useful to decide a text color.
  701. *
  702. * @returns {boolean}
  703. */
  704. }, {
  705. key: 'isLight',
  706. value: function isLight() {
  707. return this._color.isLight();
  708. }
  709. /**
  710. * Generates a list of colors using the given hue-based formula or the given array of hue values.
  711. * Hue formulas can be extended using ColorItem.colorFormulas static property.
  712. *
  713. * @param {String|Number[]} formula Examples: 'complementary', 'triad', 'tetrad', 'splitcomplement', [180, 270]
  714. * @example let colors = color.generate('triad');
  715. * @example let colors = color.generate([45, 80, 112, 200]);
  716. * @returns {ColorItem[]}
  717. */
  718. }, {
  719. key: 'generate',
  720. value: function generate(formula) {
  721. var hues = [];
  722. if (Array.isArray(formula)) {
  723. hues = formula;
  724. } else if (!ColorItem.colorFormulas.hasOwnProperty(formula)) {
  725. throw new Error('No color formula found with the name \'' + formula + '\'.');
  726. } else {
  727. hues = ColorItem.colorFormulas[formula];
  728. }
  729. var colors = [],
  730. mainColor = this._color,
  731. format = this.format;
  732. hues.forEach(function (hue) {
  733. var levels = [hue ? (mainColor.hue() + hue) % 360 : mainColor.hue(), mainColor.saturationv(), mainColor.value(), mainColor.alpha()];
  734. colors.push(new ColorItem(levels, format));
  735. });
  736. return colors;
  737. }
  738. }, {
  739. key: 'hue',
  740. get: function get() {
  741. return this._color.hue();
  742. }
  743. /**
  744. * Saturation value from 0 to 100
  745. *
  746. * @returns {int}
  747. */
  748. ,
  749. /**
  750. * Sets the hue value
  751. *
  752. * @param {int} value Integer from 0 to 360
  753. */
  754. set: function set(value) {
  755. this._color = this._color.hue(value);
  756. }
  757. }, {
  758. key: 'saturation',
  759. get: function get() {
  760. return this._color.saturationv();
  761. }
  762. /**
  763. * Value channel value from 0 to 100
  764. *
  765. * @returns {int}
  766. */
  767. ,
  768. set: function set(value) {
  769. this._color = this._color.saturationv(value);
  770. }
  771. }, {
  772. key: 'value',
  773. get: function get() {
  774. return this._color.value();
  775. }
  776. /**
  777. * Alpha value from 0.0 to 1.0
  778. *
  779. * @returns {number}
  780. */
  781. ,
  782. set: function set(value) {
  783. this._color = this._color.value(value);
  784. }
  785. }, {
  786. key: 'alpha',
  787. get: function get() {
  788. var a = this._color.alpha();
  789. return isNaN(a) ? 1 : a;
  790. }
  791. /**
  792. * Default color format to convert to when calling toString() or string()
  793. *
  794. * @returns {String} 'rgb', 'hsl', 'hex' or ''
  795. */
  796. ,
  797. set: function set(value) {
  798. // 2 decimals max
  799. this._color = this._color.alpha(Math.round(value * 100) / 100);
  800. }
  801. }, {
  802. key: 'format',
  803. get: function get() {
  804. return this._format ? this._format : this._color.model;
  805. },
  806. set: function set(value) {
  807. this._format = ColorItem.sanitizeFormat(value);
  808. }
  809. }], [{
  810. key: 'parse',
  811. value: function parse(color) {
  812. if (color instanceof _color2.default) {
  813. return color;
  814. }
  815. if (color instanceof ColorItem) {
  816. return color._color;
  817. }
  818. var format = null;
  819. if (color instanceof HSVAColor) {
  820. color = [color.h, color.s, color.v, isNaN(color.a) ? 1 : color.a];
  821. } else {
  822. color = ColorItem.sanitizeString(color);
  823. }
  824. if (color === null) {
  825. return null;
  826. }
  827. if (Array.isArray(color)) {
  828. format = 'hsv';
  829. }
  830. try {
  831. return (0, _color2.default)(color, format);
  832. } catch (e) {
  833. return null;
  834. }
  835. }
  836. /**
  837. * Sanitizes a color string, adding missing hash to hexadecimal colors
  838. * and converting 'transparent' to a color code.
  839. *
  840. * @param {String|*} str Color string
  841. * @example let colorStr = ColorItem.sanitizeString('ffaa00');
  842. * @static
  843. * @returns {String|*}
  844. */
  845. }, {
  846. key: 'sanitizeString',
  847. value: function sanitizeString(str) {
  848. if (!(typeof str === 'string' || str instanceof String)) {
  849. return str;
  850. }
  851. if (str.match(/^[0-9a-f]{2,}$/i)) {
  852. return '#' + str;
  853. }
  854. if (str.toLowerCase() === 'transparent') {
  855. return '#FFFFFF00';
  856. }
  857. return str;
  858. }
  859. /**
  860. * Detects if a value is a string and a color in hexadecimal format (in any variant).
  861. *
  862. * @param {String} str
  863. * @example ColorItem.isHex('rgba(0,0,0)'); // false
  864. * @example ColorItem.isHex('ffaa00'); // true
  865. * @example ColorItem.isHex('#ffaa00'); // true
  866. * @static
  867. * @returns {boolean}
  868. */
  869. }, {
  870. key: 'isHex',
  871. value: function isHex(str) {
  872. if (!(typeof str === 'string' || str instanceof String)) {
  873. return false;
  874. }
  875. return !!str.match(/^#?[0-9a-f]{2,}$/i);
  876. }
  877. /**
  878. * Sanitizes a color format to one supported by web browsers.
  879. * Returns an empty string of the format can't be recognised.
  880. *
  881. * @param {String|*} format
  882. * @example ColorItem.sanitizeFormat('rgba'); // 'rgb'
  883. * @example ColorItem.isHex('hex8'); // 'hex'
  884. * @example ColorItem.isHex('invalid'); // ''
  885. * @static
  886. * @returns {String} 'rgb', 'hsl', 'hex' or ''.
  887. */
  888. }, {
  889. key: 'sanitizeFormat',
  890. value: function sanitizeFormat(format) {
  891. switch (format) {
  892. case 'hex':
  893. case 'hex3':
  894. case 'hex4':
  895. case 'hex6':
  896. case 'hex8':
  897. return 'hex';
  898. case 'rgb':
  899. case 'rgba':
  900. case 'keyword':
  901. case 'name':
  902. return 'rgb';
  903. case 'hsl':
  904. case 'hsla':
  905. case 'hsv':
  906. case 'hsva':
  907. case 'hwb': // HWB this is supported by Qix Color, but not by browsers
  908. case 'hwba':
  909. return 'hsl';
  910. default:
  911. return '';
  912. }
  913. }
  914. }]);
  915. return ColorItem;
  916. }();
  917. /**
  918. * List of hue-based color formulas used by ColorItem.prototype.generate()
  919. *
  920. * @static
  921. * @type {{complementary: number[], triad: number[], tetrad: number[], splitcomplement: number[]}}
  922. */
  923. ColorItem.colorFormulas = {
  924. complementary: [180],
  925. triad: [0, 120, 240],
  926. tetrad: [0, 90, 180, 270],
  927. splitcomplement: [0, 72, 216]
  928. };
  929. exports.default = ColorItem;
  930. exports.HSVAColor = HSVAColor;
  931. exports.ColorItem = ColorItem;
  932. /***/ }),
  933. /* 3 */
  934. /***/ (function(module, exports, __webpack_require__) {
  935. "use strict";
  936. /**
  937. * @module
  938. */
  939. // adjust these values accordingly to the sass vars
  940. Object.defineProperty(exports, "__esModule", {
  941. value: true
  942. });
  943. var sassVars = {
  944. 'bar_size_short': 16,
  945. 'base_margin': 6,
  946. 'columns': 6
  947. };
  948. var sliderSize = sassVars.bar_size_short * sassVars.columns + sassVars.base_margin * (sassVars.columns - 1);
  949. /**
  950. * Colorpicker default options
  951. */
  952. exports.default = {
  953. /**
  954. * Custom class to be added to the `.colorpicker-element` element
  955. *
  956. * @type {String|null}
  957. * @default null
  958. */
  959. customClass: null,
  960. /**
  961. * Sets a initial color, ignoring the one from the element/input value or the data-color attribute.
  962. *
  963. * @type {(String|ColorItem|boolean)}
  964. * @default false
  965. */
  966. color: false,
  967. /**
  968. * Fallback color to use when the given color is invalid.
  969. * If false, the latest valid color will be used as a fallback.
  970. *
  971. * @type {String|ColorItem|boolean}
  972. * @default false
  973. */
  974. fallbackColor: false,
  975. /**
  976. * Forces an specific color format. If 'auto', it will be automatically detected the first time only,
  977. * but if null it will be always recalculated.
  978. *
  979. * Note that the ending 'a' of the format meaning "alpha" has currently no effect, meaning that rgb is the same as
  980. * rgba excepting if the alpha channel is disabled (see useAlpha).
  981. *
  982. * @type {('rgb'|'hex'|'hsl'|'auto'|null)}
  983. * @default 'auto'
  984. */
  985. format: 'auto',
  986. /**
  987. * Horizontal mode layout.
  988. *
  989. * If true, the hue and alpha channel bars will be rendered horizontally, above the saturation selector.
  990. *
  991. * @type {boolean}
  992. * @default false
  993. */
  994. horizontal: false,
  995. /**
  996. * Forces to show the colorpicker as an inline element.
  997. *
  998. * Note that if there is no container specified, the inline element
  999. * will be added to the body, so you may want to set the container option.
  1000. *
  1001. * @type {boolean}
  1002. * @default false
  1003. */
  1004. inline: false,
  1005. /**
  1006. * Container where the colorpicker is appended to in the DOM.
  1007. *
  1008. * If is a string (CSS selector), the colorpicker will be placed inside this container.
  1009. * If true, the `.colorpicker-element` element itself will be used as the container.
  1010. * If false, the document body is used as the container, unless it is a popover (in this case it is appended to the
  1011. * popover body instead).
  1012. *
  1013. * @type {String|boolean}
  1014. * @default false
  1015. */
  1016. container: false,
  1017. /**
  1018. * Bootstrap Popover options.
  1019. * The trigger, content and html options are always ignored.
  1020. *
  1021. * @type {boolean}
  1022. * @default Object
  1023. */
  1024. popover: {
  1025. animation: true,
  1026. placement: 'bottom',
  1027. fallbackPlacement: 'flip'
  1028. },
  1029. /**
  1030. * If true, loads the 'debugger' extension automatically, which logs the events in the console
  1031. * @type {boolean}
  1032. * @default false
  1033. */
  1034. debug: false,
  1035. /**
  1036. * Child CSS selector for the colorpicker input.
  1037. *
  1038. * @type {String}
  1039. * @default 'input'
  1040. */
  1041. input: 'input',
  1042. /**
  1043. * Child CSS selector for the colorpicker addon.
  1044. * If it exists, the child <i> element background will be changed on color change.
  1045. *
  1046. * @type {String}
  1047. * @default '.colorpicker-trigger, .colorpicker-input-addon'
  1048. */
  1049. addon: '.colorpicker-input-addon',
  1050. /**
  1051. * If true, the input content will be replaced always with a valid color,
  1052. * if false, the invalid color will be left in the input,
  1053. * while the internal color object will still resolve into a valid one.
  1054. *
  1055. * @type {boolean}
  1056. * @default true
  1057. */
  1058. autoInputFallback: true,
  1059. /**
  1060. * If true a hash will be prepended to hexadecimal colors.
  1061. * If false, the hash will be removed.
  1062. * This only affects the input values in hexadecimal format.
  1063. *
  1064. * @type {boolean}
  1065. * @default true
  1066. */
  1067. useHashPrefix: true,
  1068. /**
  1069. * If true, the alpha channel bar will be displayed no matter what.
  1070. *
  1071. * If false, it will be always hidden and alpha channel will be disabled also programmatically, meaning that
  1072. * the selected or typed color will be always opaque.
  1073. *
  1074. * If null, the alpha channel will be automatically disabled/enabled depending if the initial color format supports
  1075. * alpha or not.
  1076. *
  1077. * @type {boolean}
  1078. * @default true
  1079. */
  1080. useAlpha: true,
  1081. /**
  1082. * Colorpicker widget template
  1083. * @type {String}
  1084. * @example
  1085. * <!-- This is the default template: -->
  1086. * <div class="colorpicker">
  1087. * <div class="colorpicker-saturation"><i class="colorpicker-guide"></i></div>
  1088. * <div class="colorpicker-hue"><i class="colorpicker-guide"></i></div>
  1089. * <div class="colorpicker-alpha">
  1090. * <div class="colorpicker-alpha-color"></div>
  1091. * <i class="colorpicker-guide"></i>
  1092. * </div>
  1093. * </div>
  1094. */
  1095. template: '<div class="colorpicker">\n <div class="colorpicker-saturation"><i class="colorpicker-guide"></i></div>\n <div class="colorpicker-hue"><i class="colorpicker-guide"></i></div>\n <div class="colorpicker-alpha">\n <div class="colorpicker-alpha-color"></div>\n <i class="colorpicker-guide"></i>\n </div>\n </div>',
  1096. /**
  1097. *
  1098. * Associative object with the extension class name and its config.
  1099. * Colorpicker comes with many bundled extensions: debugger, palette, preview and swatches (a superset of palette).
  1100. *
  1101. * @type {Object[]}
  1102. * @example
  1103. * extensions: [
  1104. * {
  1105. * name: 'swatches'
  1106. * options: {
  1107. * colors: {
  1108. * 'primary': '#337ab7',
  1109. * 'success': '#5cb85c',
  1110. * 'info': '#5bc0de',
  1111. * 'warning': '#f0ad4e',
  1112. * 'danger': '#d9534f'
  1113. * },
  1114. * namesAsValues: true
  1115. * }
  1116. * }
  1117. * ]
  1118. */
  1119. extensions: [{
  1120. name: 'preview',
  1121. options: {
  1122. showText: true
  1123. }
  1124. }],
  1125. /**
  1126. * Vertical sliders configuration
  1127. * @type {Object}
  1128. */
  1129. sliders: {
  1130. saturation: {
  1131. selector: '.colorpicker-saturation',
  1132. maxLeft: sliderSize,
  1133. maxTop: sliderSize,
  1134. callLeft: 'setSaturationRatio',
  1135. callTop: 'setValueRatio'
  1136. },
  1137. hue: {
  1138. selector: '.colorpicker-hue',
  1139. maxLeft: 0,
  1140. maxTop: sliderSize,
  1141. callLeft: false,
  1142. callTop: 'setHueRatio'
  1143. },
  1144. alpha: {
  1145. selector: '.colorpicker-alpha',
  1146. childSelector: '.colorpicker-alpha-color',
  1147. maxLeft: 0,
  1148. maxTop: sliderSize,
  1149. callLeft: false,
  1150. callTop: 'setAlphaRatio'
  1151. }
  1152. },
  1153. /**
  1154. * Horizontal sliders configuration
  1155. * @type {Object}
  1156. */
  1157. slidersHorz: {
  1158. saturation: {
  1159. selector: '.colorpicker-saturation',
  1160. maxLeft: sliderSize,
  1161. maxTop: sliderSize,
  1162. callLeft: 'setSaturationRatio',
  1163. callTop: 'setValueRatio'
  1164. },
  1165. hue: {
  1166. selector: '.colorpicker-hue',
  1167. maxLeft: sliderSize,
  1168. maxTop: 0,
  1169. callLeft: 'setHueRatio',
  1170. callTop: false
  1171. },
  1172. alpha: {
  1173. selector: '.colorpicker-alpha',
  1174. childSelector: '.colorpicker-alpha-color',
  1175. maxLeft: sliderSize,
  1176. maxTop: 0,
  1177. callLeft: 'setAlphaRatio',
  1178. callTop: false
  1179. }
  1180. }
  1181. };
  1182. module.exports = exports.default;
  1183. /***/ }),
  1184. /* 4 */
  1185. /***/ (function(module, exports, __webpack_require__) {
  1186. "use strict";
  1187. Object.defineProperty(exports, "__esModule", {
  1188. value: true
  1189. });
  1190. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  1191. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1192. var _Extension2 = __webpack_require__(1);
  1193. var _Extension3 = _interopRequireDefault(_Extension2);
  1194. var _jquery = __webpack_require__(0);
  1195. var _jquery2 = _interopRequireDefault(_jquery);
  1196. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1197. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1198. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1199. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1200. var defaults = {
  1201. /**
  1202. * Key-value pairs defining a color alias and its CSS color representation.
  1203. *
  1204. * They can also be just an array of values. In that case, no special names are used, only the real colors.
  1205. *
  1206. * @type {Object|Array}
  1207. * @default null
  1208. * @example
  1209. * {
  1210. * 'black': '#000000',
  1211. * 'white': '#ffffff',
  1212. * 'red': '#FF0000',
  1213. * 'default': '#777777',
  1214. * 'primary': '#337ab7',
  1215. * 'success': '#5cb85c',
  1216. * 'info': '#5bc0de',
  1217. * 'warning': '#f0ad4e',
  1218. * 'danger': '#d9534f'
  1219. * }
  1220. *
  1221. * @example ['#f0ad4e', '#337ab7', '#5cb85c']
  1222. */
  1223. colors: null,
  1224. /**
  1225. * If true, when a color swatch is selected the name (alias) will be used as input value,
  1226. * otherwise the swatch real color value will be used.
  1227. *
  1228. * @type {boolean}
  1229. * @default true
  1230. */
  1231. namesAsValues: true
  1232. };
  1233. /**
  1234. * Palette extension
  1235. * @ignore
  1236. */
  1237. var Palette = function (_Extension) {
  1238. _inherits(Palette, _Extension);
  1239. _createClass(Palette, [{
  1240. key: 'colors',
  1241. /**
  1242. * @returns {Object|Array}
  1243. */
  1244. get: function get() {
  1245. return this.options.colors;
  1246. }
  1247. }]);
  1248. function Palette(colorpicker) {
  1249. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1250. _classCallCheck(this, Palette);
  1251. var _this = _possibleConstructorReturn(this, (Palette.__proto__ || Object.getPrototypeOf(Palette)).call(this, colorpicker, _jquery2.default.extend(true, {}, defaults, options)));
  1252. if (!Array.isArray(_this.options.colors) && _typeof(_this.options.colors) !== 'object') {
  1253. _this.options.colors = null;
  1254. }
  1255. return _this;
  1256. }
  1257. /**
  1258. * @returns {int}
  1259. */
  1260. _createClass(Palette, [{
  1261. key: 'getLength',
  1262. value: function getLength() {
  1263. if (!this.options.colors) {
  1264. return 0;
  1265. }
  1266. if (Array.isArray(this.options.colors)) {
  1267. return this.options.colors.length;
  1268. }
  1269. if (_typeof(this.options.colors) === 'object') {
  1270. return Object.keys(this.options.colors).length;
  1271. }
  1272. return 0;
  1273. }
  1274. }, {
  1275. key: 'resolveColor',
  1276. value: function resolveColor(color) {
  1277. var realColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  1278. if (this.getLength() <= 0) {
  1279. return false;
  1280. }
  1281. // Array of colors
  1282. if (Array.isArray(this.options.colors)) {
  1283. if (this.options.colors.indexOf(color) >= 0) {
  1284. return color;
  1285. }
  1286. if (this.options.colors.indexOf(color.toUpperCase()) >= 0) {
  1287. return color.toUpperCase();
  1288. }
  1289. if (this.options.colors.indexOf(color.toLowerCase()) >= 0) {
  1290. return color.toLowerCase();
  1291. }
  1292. return false;
  1293. }
  1294. if (_typeof(this.options.colors) !== 'object') {
  1295. return false;
  1296. }
  1297. // Map of objects
  1298. if (!this.options.namesAsValues || realColor) {
  1299. return this.getValue(color, false);
  1300. }
  1301. return this.getName(color, this.getName('#' + color));
  1302. }
  1303. /**
  1304. * Given a color value, returns the corresponding color name or defaultValue.
  1305. *
  1306. * @param {String} value
  1307. * @param {*} defaultValue
  1308. * @returns {*}
  1309. */
  1310. }, {
  1311. key: 'getName',
  1312. value: function getName(value) {
  1313. var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1314. if (!(typeof value === 'string') || !this.options.colors) {
  1315. return defaultValue;
  1316. }
  1317. for (var name in this.options.colors) {
  1318. if (!this.options.colors.hasOwnProperty(name)) {
  1319. continue;
  1320. }
  1321. if (this.options.colors[name].toLowerCase() === value.toLowerCase()) {
  1322. return name;
  1323. }
  1324. }
  1325. return defaultValue;
  1326. }
  1327. /**
  1328. * Given a color name, returns the corresponding color value or defaultValue.
  1329. *
  1330. * @param {String} name
  1331. * @param {*} defaultValue
  1332. * @returns {*}
  1333. */
  1334. }, {
  1335. key: 'getValue',
  1336. value: function getValue(name) {
  1337. var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1338. if (!(typeof name === 'string') || !this.options.colors) {
  1339. return defaultValue;
  1340. }
  1341. if (this.options.colors.hasOwnProperty(name)) {
  1342. return this.options.colors[name];
  1343. }
  1344. return defaultValue;
  1345. }
  1346. }]);
  1347. return Palette;
  1348. }(_Extension3.default);
  1349. exports.default = Palette;
  1350. module.exports = exports.default;
  1351. /***/ }),
  1352. /* 5 */
  1353. /***/ (function(module, exports, __webpack_require__) {
  1354. "use strict";
  1355. module.exports = {
  1356. "aliceblue": [240, 248, 255],
  1357. "antiquewhite": [250, 235, 215],
  1358. "aqua": [0, 255, 255],
  1359. "aquamarine": [127, 255, 212],
  1360. "azure": [240, 255, 255],
  1361. "beige": [245, 245, 220],
  1362. "bisque": [255, 228, 196],
  1363. "black": [0, 0, 0],
  1364. "blanchedalmond": [255, 235, 205],
  1365. "blue": [0, 0, 255],
  1366. "blueviolet": [138, 43, 226],
  1367. "brown": [165, 42, 42],
  1368. "burlywood": [222, 184, 135],
  1369. "cadetblue": [95, 158, 160],
  1370. "chartreuse": [127, 255, 0],
  1371. "chocolate": [210, 105, 30],
  1372. "coral": [255, 127, 80],
  1373. "cornflowerblue": [100, 149, 237],
  1374. "cornsilk": [255, 248, 220],
  1375. "crimson": [220, 20, 60],
  1376. "cyan": [0, 255, 255],
  1377. "darkblue": [0, 0, 139],
  1378. "darkcyan": [0, 139, 139],
  1379. "darkgoldenrod": [184, 134, 11],
  1380. "darkgray": [169, 169, 169],
  1381. "darkgreen": [0, 100, 0],
  1382. "darkgrey": [169, 169, 169],
  1383. "darkkhaki": [189, 183, 107],
  1384. "darkmagenta": [139, 0, 139],
  1385. "darkolivegreen": [85, 107, 47],
  1386. "darkorange": [255, 140, 0],
  1387. "darkorchid": [153, 50, 204],
  1388. "darkred": [139, 0, 0],
  1389. "darksalmon": [233, 150, 122],
  1390. "darkseagreen": [143, 188, 143],
  1391. "darkslateblue": [72, 61, 139],
  1392. "darkslategray": [47, 79, 79],
  1393. "darkslategrey": [47, 79, 79],
  1394. "darkturquoise": [0, 206, 209],
  1395. "darkviolet": [148, 0, 211],
  1396. "deeppink": [255, 20, 147],
  1397. "deepskyblue": [0, 191, 255],
  1398. "dimgray": [105, 105, 105],
  1399. "dimgrey": [105, 105, 105],
  1400. "dodgerblue": [30, 144, 255],
  1401. "firebrick": [178, 34, 34],
  1402. "floralwhite": [255, 250, 240],
  1403. "forestgreen": [34, 139, 34],
  1404. "fuchsia": [255, 0, 255],
  1405. "gainsboro": [220, 220, 220],
  1406. "ghostwhite": [248, 248, 255],
  1407. "gold": [255, 215, 0],
  1408. "goldenrod": [218, 165, 32],
  1409. "gray": [128, 128, 128],
  1410. "green": [0, 128, 0],
  1411. "greenyellow": [173, 255, 47],
  1412. "grey": [128, 128, 128],
  1413. "honeydew": [240, 255, 240],
  1414. "hotpink": [255, 105, 180],
  1415. "indianred": [205, 92, 92],
  1416. "indigo": [75, 0, 130],
  1417. "ivory": [255, 255, 240],
  1418. "khaki": [240, 230, 140],
  1419. "lavender": [230, 230, 250],
  1420. "lavenderblush": [255, 240, 245],
  1421. "lawngreen": [124, 252, 0],
  1422. "lemonchiffon": [255, 250, 205],
  1423. "lightblue": [173, 216, 230],
  1424. "lightcoral": [240, 128, 128],
  1425. "lightcyan": [224, 255, 255],
  1426. "lightgoldenrodyellow": [250, 250, 210],
  1427. "lightgray": [211, 211, 211],
  1428. "lightgreen": [144, 238, 144],
  1429. "lightgrey": [211, 211, 211],
  1430. "lightpink": [255, 182, 193],
  1431. "lightsalmon": [255, 160, 122],
  1432. "lightseagreen": [32, 178, 170],
  1433. "lightskyblue": [135, 206, 250],
  1434. "lightslategray": [119, 136, 153],
  1435. "lightslategrey": [119, 136, 153],
  1436. "lightsteelblue": [176, 196, 222],
  1437. "lightyellow": [255, 255, 224],
  1438. "lime": [0, 255, 0],
  1439. "limegreen": [50, 205, 50],
  1440. "linen": [250, 240, 230],
  1441. "magenta": [255, 0, 255],
  1442. "maroon": [128, 0, 0],
  1443. "mediumaquamarine": [102, 205, 170],
  1444. "mediumblue": [0, 0, 205],
  1445. "mediumorchid": [186, 85, 211],
  1446. "mediumpurple": [147, 112, 219],
  1447. "mediumseagreen": [60, 179, 113],
  1448. "mediumslateblue": [123, 104, 238],
  1449. "mediumspringgreen": [0, 250, 154],
  1450. "mediumturquoise": [72, 209, 204],
  1451. "mediumvioletred": [199, 21, 133],
  1452. "midnightblue": [25, 25, 112],
  1453. "mintcream": [245, 255, 250],
  1454. "mistyrose": [255, 228, 225],
  1455. "moccasin": [255, 228, 181],
  1456. "navajowhite": [255, 222, 173],
  1457. "navy": [0, 0, 128],
  1458. "oldlace": [253, 245, 230],
  1459. "olive": [128, 128, 0],
  1460. "olivedrab": [107, 142, 35],
  1461. "orange": [255, 165, 0],
  1462. "orangered": [255, 69, 0],
  1463. "orchid": [218, 112, 214],
  1464. "palegoldenrod": [238, 232, 170],
  1465. "palegreen": [152, 251, 152],
  1466. "paleturquoise": [175, 238, 238],
  1467. "palevioletred": [219, 112, 147],
  1468. "papayawhip": [255, 239, 213],
  1469. "peachpuff": [255, 218, 185],
  1470. "peru": [205, 133, 63],
  1471. "pink": [255, 192, 203],
  1472. "plum": [221, 160, 221],
  1473. "powderblue": [176, 224, 230],
  1474. "purple": [128, 0, 128],
  1475. "rebeccapurple": [102, 51, 153],
  1476. "red": [255, 0, 0],
  1477. "rosybrown": [188, 143, 143],
  1478. "royalblue": [65, 105, 225],
  1479. "saddlebrown": [139, 69, 19],
  1480. "salmon": [250, 128, 114],
  1481. "sandybrown": [244, 164, 96],
  1482. "seagreen": [46, 139, 87],
  1483. "seashell": [255, 245, 238],
  1484. "sienna": [160, 82, 45],
  1485. "silver": [192, 192, 192],
  1486. "skyblue": [135, 206, 235],
  1487. "slateblue": [106, 90, 205],
  1488. "slategray": [112, 128, 144],
  1489. "slategrey": [112, 128, 144],
  1490. "snow": [255, 250, 250],
  1491. "springgreen": [0, 255, 127],
  1492. "steelblue": [70, 130, 180],
  1493. "tan": [210, 180, 140],
  1494. "teal": [0, 128, 128],
  1495. "thistle": [216, 191, 216],
  1496. "tomato": [255, 99, 71],
  1497. "turquoise": [64, 224, 208],
  1498. "violet": [238, 130, 238],
  1499. "wheat": [245, 222, 179],
  1500. "white": [255, 255, 255],
  1501. "whitesmoke": [245, 245, 245],
  1502. "yellow": [255, 255, 0],
  1503. "yellowgreen": [154, 205, 50]
  1504. };
  1505. /***/ }),
  1506. /* 6 */
  1507. /***/ (function(module, exports, __webpack_require__) {
  1508. /* MIT license */
  1509. var cssKeywords = __webpack_require__(5);
  1510. // NOTE: conversions should only return primitive values (i.e. arrays, or
  1511. // values that give correct `typeof` results).
  1512. // do not use box values types (i.e. Number(), String(), etc.)
  1513. var reverseKeywords = {};
  1514. for (var key in cssKeywords) {
  1515. if (cssKeywords.hasOwnProperty(key)) {
  1516. reverseKeywords[cssKeywords[key]] = key;
  1517. }
  1518. }
  1519. var convert = module.exports = {
  1520. rgb: {channels: 3, labels: 'rgb'},
  1521. hsl: {channels: 3, labels: 'hsl'},
  1522. hsv: {channels: 3, labels: 'hsv'},
  1523. hwb: {channels: 3, labels: 'hwb'},
  1524. cmyk: {channels: 4, labels: 'cmyk'},
  1525. xyz: {channels: 3, labels: 'xyz'},
  1526. lab: {channels: 3, labels: 'lab'},
  1527. lch: {channels: 3, labels: 'lch'},
  1528. hex: {channels: 1, labels: ['hex']},
  1529. keyword: {channels: 1, labels: ['keyword']},
  1530. ansi16: {channels: 1, labels: ['ansi16']},
  1531. ansi256: {channels: 1, labels: ['ansi256']},
  1532. hcg: {channels: 3, labels: ['h', 'c', 'g']},
  1533. apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
  1534. gray: {channels: 1, labels: ['gray']}
  1535. };
  1536. // hide .channels and .labels properties
  1537. for (var model in convert) {
  1538. if (convert.hasOwnProperty(model)) {
  1539. if (!('channels' in convert[model])) {
  1540. throw new Error('missing channels property: ' + model);
  1541. }
  1542. if (!('labels' in convert[model])) {
  1543. throw new Error('missing channel labels property: ' + model);
  1544. }
  1545. if (convert[model].labels.length !== convert[model].channels) {
  1546. throw new Error('channel and label counts mismatch: ' + model);
  1547. }
  1548. var channels = convert[model].channels;
  1549. var labels = convert[model].labels;
  1550. delete convert[model].channels;
  1551. delete convert[model].labels;
  1552. Object.defineProperty(convert[model], 'channels', {value: channels});
  1553. Object.defineProperty(convert[model], 'labels', {value: labels});
  1554. }
  1555. }
  1556. convert.rgb.hsl = function (rgb) {
  1557. var r = rgb[0] / 255;
  1558. var g = rgb[1] / 255;
  1559. var b = rgb[2] / 255;
  1560. var min = Math.min(r, g, b);
  1561. var max = Math.max(r, g, b);
  1562. var delta = max - min;
  1563. var h;
  1564. var s;
  1565. var l;
  1566. if (max === min) {
  1567. h = 0;
  1568. } else if (r === max) {
  1569. h = (g - b) / delta;
  1570. } else if (g === max) {
  1571. h = 2 + (b - r) / delta;
  1572. } else if (b === max) {
  1573. h = 4 + (r - g) / delta;
  1574. }
  1575. h = Math.min(h * 60, 360);
  1576. if (h < 0) {
  1577. h += 360;
  1578. }
  1579. l = (min + max) / 2;
  1580. if (max === min) {
  1581. s = 0;
  1582. } else if (l <= 0.5) {
  1583. s = delta / (max + min);
  1584. } else {
  1585. s = delta / (2 - max - min);
  1586. }
  1587. return [h, s * 100, l * 100];
  1588. };
  1589. convert.rgb.hsv = function (rgb) {
  1590. var rdif;
  1591. var gdif;
  1592. var bdif;
  1593. var h;
  1594. var s;
  1595. var r = rgb[0] / 255;
  1596. var g = rgb[1] / 255;
  1597. var b = rgb[2] / 255;
  1598. var v = Math.max(r, g, b);
  1599. var diff = v - Math.min(r, g, b);
  1600. var diffc = function (c) {
  1601. return (v - c) / 6 / diff + 1 / 2;
  1602. };
  1603. if (diff === 0) {
  1604. h = s = 0;
  1605. } else {
  1606. s = diff / v;
  1607. rdif = diffc(r);
  1608. gdif = diffc(g);
  1609. bdif = diffc(b);
  1610. if (r === v) {
  1611. h = bdif - gdif;
  1612. } else if (g === v) {
  1613. h = (1 / 3) + rdif - bdif;
  1614. } else if (b === v) {
  1615. h = (2 / 3) + gdif - rdif;
  1616. }
  1617. if (h < 0) {
  1618. h += 1;
  1619. } else if (h > 1) {
  1620. h -= 1;
  1621. }
  1622. }
  1623. return [
  1624. h * 360,
  1625. s * 100,
  1626. v * 100
  1627. ];
  1628. };
  1629. convert.rgb.hwb = function (rgb) {
  1630. var r = rgb[0];
  1631. var g = rgb[1];
  1632. var b = rgb[2];
  1633. var h = convert.rgb.hsl(rgb)[0];
  1634. var w = 1 / 255 * Math.min(r, Math.min(g, b));
  1635. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  1636. return [h, w * 100, b * 100];
  1637. };
  1638. convert.rgb.cmyk = function (rgb) {
  1639. var r = rgb[0] / 255;
  1640. var g = rgb[1] / 255;
  1641. var b = rgb[2] / 255;
  1642. var c;
  1643. var m;
  1644. var y;
  1645. var k;
  1646. k = Math.min(1 - r, 1 - g, 1 - b);
  1647. c = (1 - r - k) / (1 - k) || 0;
  1648. m = (1 - g - k) / (1 - k) || 0;
  1649. y = (1 - b - k) / (1 - k) || 0;
  1650. return [c * 100, m * 100, y * 100, k * 100];
  1651. };
  1652. /**
  1653. * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  1654. * */
  1655. function comparativeDistance(x, y) {
  1656. return (
  1657. Math.pow(x[0] - y[0], 2) +
  1658. Math.pow(x[1] - y[1], 2) +
  1659. Math.pow(x[2] - y[2], 2)
  1660. );
  1661. }
  1662. convert.rgb.keyword = function (rgb) {
  1663. var reversed = reverseKeywords[rgb];
  1664. if (reversed) {
  1665. return reversed;
  1666. }
  1667. var currentClosestDistance = Infinity;
  1668. var currentClosestKeyword;
  1669. for (var keyword in cssKeywords) {
  1670. if (cssKeywords.hasOwnProperty(keyword)) {
  1671. var value = cssKeywords[keyword];
  1672. // Compute comparative distance
  1673. var distance = comparativeDistance(rgb, value);
  1674. // Check if its less, if so set as closest
  1675. if (distance < currentClosestDistance) {
  1676. currentClosestDistance = distance;
  1677. currentClosestKeyword = keyword;
  1678. }
  1679. }
  1680. }
  1681. return currentClosestKeyword;
  1682. };
  1683. convert.keyword.rgb = function (keyword) {
  1684. return cssKeywords[keyword];
  1685. };
  1686. convert.rgb.xyz = function (rgb) {
  1687. var r = rgb[0] / 255;
  1688. var g = rgb[1] / 255;
  1689. var b = rgb[2] / 255;
  1690. // assume sRGB
  1691. r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
  1692. g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
  1693. b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
  1694. var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
  1695. var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
  1696. var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
  1697. return [x * 100, y * 100, z * 100];
  1698. };
  1699. convert.rgb.lab = function (rgb) {
  1700. var xyz = convert.rgb.xyz(rgb);
  1701. var x = xyz[0];
  1702. var y = xyz[1];
  1703. var z = xyz[2];
  1704. var l;
  1705. var a;
  1706. var b;
  1707. x /= 95.047;
  1708. y /= 100;
  1709. z /= 108.883;
  1710. x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
  1711. y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
  1712. z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
  1713. l = (116 * y) - 16;
  1714. a = 500 * (x - y);
  1715. b = 200 * (y - z);
  1716. return [l, a, b];
  1717. };
  1718. convert.hsl.rgb = function (hsl) {
  1719. var h = hsl[0] / 360;
  1720. var s = hsl[1] / 100;
  1721. var l = hsl[2] / 100;
  1722. var t1;
  1723. var t2;
  1724. var t3;
  1725. var rgb;
  1726. var val;
  1727. if (s === 0) {
  1728. val = l * 255;
  1729. return [val, val, val];
  1730. }
  1731. if (l < 0.5) {
  1732. t2 = l * (1 + s);
  1733. } else {
  1734. t2 = l + s - l * s;
  1735. }
  1736. t1 = 2 * l - t2;
  1737. rgb = [0, 0, 0];
  1738. for (var i = 0; i < 3; i++) {
  1739. t3 = h + 1 / 3 * -(i - 1);
  1740. if (t3 < 0) {
  1741. t3++;
  1742. }
  1743. if (t3 > 1) {
  1744. t3--;
  1745. }
  1746. if (6 * t3 < 1) {
  1747. val = t1 + (t2 - t1) * 6 * t3;
  1748. } else if (2 * t3 < 1) {
  1749. val = t2;
  1750. } else if (3 * t3 < 2) {
  1751. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  1752. } else {
  1753. val = t1;
  1754. }
  1755. rgb[i] = val * 255;
  1756. }
  1757. return rgb;
  1758. };
  1759. convert.hsl.hsv = function (hsl) {
  1760. var h = hsl[0];
  1761. var s = hsl[1] / 100;
  1762. var l = hsl[2] / 100;
  1763. var smin = s;
  1764. var lmin = Math.max(l, 0.01);
  1765. var sv;
  1766. var v;
  1767. l *= 2;
  1768. s *= (l <= 1) ? l : 2 - l;
  1769. smin *= lmin <= 1 ? lmin : 2 - lmin;
  1770. v = (l + s) / 2;
  1771. sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
  1772. return [h, sv * 100, v * 100];
  1773. };
  1774. convert.hsv.rgb = function (hsv) {
  1775. var h = hsv[0] / 60;
  1776. var s = hsv[1] / 100;
  1777. var v = hsv[2] / 100;
  1778. var hi = Math.floor(h) % 6;
  1779. var f = h - Math.floor(h);
  1780. var p = 255 * v * (1 - s);
  1781. var q = 255 * v * (1 - (s * f));
  1782. var t = 255 * v * (1 - (s * (1 - f)));
  1783. v *= 255;
  1784. switch (hi) {
  1785. case 0:
  1786. return [v, t, p];
  1787. case 1:
  1788. return [q, v, p];
  1789. case 2:
  1790. return [p, v, t];
  1791. case 3:
  1792. return [p, q, v];
  1793. case 4:
  1794. return [t, p, v];
  1795. case 5:
  1796. return [v, p, q];
  1797. }
  1798. };
  1799. convert.hsv.hsl = function (hsv) {
  1800. var h = hsv[0];
  1801. var s = hsv[1] / 100;
  1802. var v = hsv[2] / 100;
  1803. var vmin = Math.max(v, 0.01);
  1804. var lmin;
  1805. var sl;
  1806. var l;
  1807. l = (2 - s) * v;
  1808. lmin = (2 - s) * vmin;
  1809. sl = s * vmin;
  1810. sl /= (lmin <= 1) ? lmin : 2 - lmin;
  1811. sl = sl || 0;
  1812. l /= 2;
  1813. return [h, sl * 100, l * 100];
  1814. };
  1815. // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  1816. convert.hwb.rgb = function (hwb) {
  1817. var h = hwb[0] / 360;
  1818. var wh = hwb[1] / 100;
  1819. var bl = hwb[2] / 100;
  1820. var ratio = wh + bl;
  1821. var i;
  1822. var v;
  1823. var f;
  1824. var n;
  1825. // wh + bl cant be > 1
  1826. if (ratio > 1) {
  1827. wh /= ratio;
  1828. bl /= ratio;
  1829. }
  1830. i = Math.floor(6 * h);
  1831. v = 1 - bl;
  1832. f = 6 * h - i;
  1833. if ((i & 0x01) !== 0) {
  1834. f = 1 - f;
  1835. }
  1836. n = wh + f * (v - wh); // linear interpolation
  1837. var r;
  1838. var g;
  1839. var b;
  1840. switch (i) {
  1841. default:
  1842. case 6:
  1843. case 0: r = v; g = n; b = wh; break;
  1844. case 1: r = n; g = v; b = wh; break;
  1845. case 2: r = wh; g = v; b = n; break;
  1846. case 3: r = wh; g = n; b = v; break;
  1847. case 4: r = n; g = wh; b = v; break;
  1848. case 5: r = v; g = wh; b = n; break;
  1849. }
  1850. return [r * 255, g * 255, b * 255];
  1851. };
  1852. convert.cmyk.rgb = function (cmyk) {
  1853. var c = cmyk[0] / 100;
  1854. var m = cmyk[1] / 100;
  1855. var y = cmyk[2] / 100;
  1856. var k = cmyk[3] / 100;
  1857. var r;
  1858. var g;
  1859. var b;
  1860. r = 1 - Math.min(1, c * (1 - k) + k);
  1861. g = 1 - Math.min(1, m * (1 - k) + k);
  1862. b = 1 - Math.min(1, y * (1 - k) + k);
  1863. return [r * 255, g * 255, b * 255];
  1864. };
  1865. convert.xyz.rgb = function (xyz) {
  1866. var x = xyz[0] / 100;
  1867. var y = xyz[1] / 100;
  1868. var z = xyz[2] / 100;
  1869. var r;
  1870. var g;
  1871. var b;
  1872. r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
  1873. g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
  1874. b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
  1875. // assume sRGB
  1876. r = r > 0.0031308
  1877. ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
  1878. : r * 12.92;
  1879. g = g > 0.0031308
  1880. ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
  1881. : g * 12.92;
  1882. b = b > 0.0031308
  1883. ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
  1884. : b * 12.92;
  1885. r = Math.min(Math.max(0, r), 1);
  1886. g = Math.min(Math.max(0, g), 1);
  1887. b = Math.min(Math.max(0, b), 1);
  1888. return [r * 255, g * 255, b * 255];
  1889. };
  1890. convert.xyz.lab = function (xyz) {
  1891. var x = xyz[0];
  1892. var y = xyz[1];
  1893. var z = xyz[2];
  1894. var l;
  1895. var a;
  1896. var b;
  1897. x /= 95.047;
  1898. y /= 100;
  1899. z /= 108.883;
  1900. x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
  1901. y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
  1902. z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
  1903. l = (116 * y) - 16;
  1904. a = 500 * (x - y);
  1905. b = 200 * (y - z);
  1906. return [l, a, b];
  1907. };
  1908. convert.lab.xyz = function (lab) {
  1909. var l = lab[0];
  1910. var a = lab[1];
  1911. var b = lab[2];
  1912. var x;
  1913. var y;
  1914. var z;
  1915. y = (l + 16) / 116;
  1916. x = a / 500 + y;
  1917. z = y - b / 200;
  1918. var y2 = Math.pow(y, 3);
  1919. var x2 = Math.pow(x, 3);
  1920. var z2 = Math.pow(z, 3);
  1921. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  1922. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  1923. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  1924. x *= 95.047;
  1925. y *= 100;
  1926. z *= 108.883;
  1927. return [x, y, z];
  1928. };
  1929. convert.lab.lch = function (lab) {
  1930. var l = lab[0];
  1931. var a = lab[1];
  1932. var b = lab[2];
  1933. var hr;
  1934. var h;
  1935. var c;
  1936. hr = Math.atan2(b, a);
  1937. h = hr * 360 / 2 / Math.PI;
  1938. if (h < 0) {
  1939. h += 360;
  1940. }
  1941. c = Math.sqrt(a * a + b * b);
  1942. return [l, c, h];
  1943. };
  1944. convert.lch.lab = function (lch) {
  1945. var l = lch[0];
  1946. var c = lch[1];
  1947. var h = lch[2];
  1948. var a;
  1949. var b;
  1950. var hr;
  1951. hr = h / 360 * 2 * Math.PI;
  1952. a = c * Math.cos(hr);
  1953. b = c * Math.sin(hr);
  1954. return [l, a, b];
  1955. };
  1956. convert.rgb.ansi16 = function (args) {
  1957. var r = args[0];
  1958. var g = args[1];
  1959. var b = args[2];
  1960. var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
  1961. value = Math.round(value / 50);
  1962. if (value === 0) {
  1963. return 30;
  1964. }
  1965. var ansi = 30
  1966. + ((Math.round(b / 255) << 2)
  1967. | (Math.round(g / 255) << 1)
  1968. | Math.round(r / 255));
  1969. if (value === 2) {
  1970. ansi += 60;
  1971. }
  1972. return ansi;
  1973. };
  1974. convert.hsv.ansi16 = function (args) {
  1975. // optimization here; we already know the value and don't need to get
  1976. // it converted for us.
  1977. return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
  1978. };
  1979. convert.rgb.ansi256 = function (args) {
  1980. var r = args[0];
  1981. var g = args[1];
  1982. var b = args[2];
  1983. // we use the extended greyscale palette here, with the exception of
  1984. // black and white. normal palette only has 4 greyscale shades.
  1985. if (r === g && g === b) {
  1986. if (r < 8) {
  1987. return 16;
  1988. }
  1989. if (r > 248) {
  1990. return 231;
  1991. }
  1992. return Math.round(((r - 8) / 247) * 24) + 232;
  1993. }
  1994. var ansi = 16
  1995. + (36 * Math.round(r / 255 * 5))
  1996. + (6 * Math.round(g / 255 * 5))
  1997. + Math.round(b / 255 * 5);
  1998. return ansi;
  1999. };
  2000. convert.ansi16.rgb = function (args) {
  2001. var color = args % 10;
  2002. // handle greyscale
  2003. if (color === 0 || color === 7) {
  2004. if (args > 50) {
  2005. color += 3.5;
  2006. }
  2007. color = color / 10.5 * 255;
  2008. return [color, color, color];
  2009. }
  2010. var mult = (~~(args > 50) + 1) * 0.5;
  2011. var r = ((color & 1) * mult) * 255;
  2012. var g = (((color >> 1) & 1) * mult) * 255;
  2013. var b = (((color >> 2) & 1) * mult) * 255;
  2014. return [r, g, b];
  2015. };
  2016. convert.ansi256.rgb = function (args) {
  2017. // handle greyscale
  2018. if (args >= 232) {
  2019. var c = (args - 232) * 10 + 8;
  2020. return [c, c, c];
  2021. }
  2022. args -= 16;
  2023. var rem;
  2024. var r = Math.floor(args / 36) / 5 * 255;
  2025. var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  2026. var b = (rem % 6) / 5 * 255;
  2027. return [r, g, b];
  2028. };
  2029. convert.rgb.hex = function (args) {
  2030. var integer = ((Math.round(args[0]) & 0xFF) << 16)
  2031. + ((Math.round(args[1]) & 0xFF) << 8)
  2032. + (Math.round(args[2]) & 0xFF);
  2033. var string = integer.toString(16).toUpperCase();
  2034. return '000000'.substring(string.length) + string;
  2035. };
  2036. convert.hex.rgb = function (args) {
  2037. var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  2038. if (!match) {
  2039. return [0, 0, 0];
  2040. }
  2041. var colorString = match[0];
  2042. if (match[0].length === 3) {
  2043. colorString = colorString.split('').map(function (char) {
  2044. return char + char;
  2045. }).join('');
  2046. }
  2047. var integer = parseInt(colorString, 16);
  2048. var r = (integer >> 16) & 0xFF;
  2049. var g = (integer >> 8) & 0xFF;
  2050. var b = integer & 0xFF;
  2051. return [r, g, b];
  2052. };
  2053. convert.rgb.hcg = function (rgb) {
  2054. var r = rgb[0] / 255;
  2055. var g = rgb[1] / 255;
  2056. var b = rgb[2] / 255;
  2057. var max = Math.max(Math.max(r, g), b);
  2058. var min = Math.min(Math.min(r, g), b);
  2059. var chroma = (max - min);
  2060. var grayscale;
  2061. var hue;
  2062. if (chroma < 1) {
  2063. grayscale = min / (1 - chroma);
  2064. } else {
  2065. grayscale = 0;
  2066. }
  2067. if (chroma <= 0) {
  2068. hue = 0;
  2069. } else
  2070. if (max === r) {
  2071. hue = ((g - b) / chroma) % 6;
  2072. } else
  2073. if (max === g) {
  2074. hue = 2 + (b - r) / chroma;
  2075. } else {
  2076. hue = 4 + (r - g) / chroma + 4;
  2077. }
  2078. hue /= 6;
  2079. hue %= 1;
  2080. return [hue * 360, chroma * 100, grayscale * 100];
  2081. };
  2082. convert.hsl.hcg = function (hsl) {
  2083. var s = hsl[1] / 100;
  2084. var l = hsl[2] / 100;
  2085. var c = 1;
  2086. var f = 0;
  2087. if (l < 0.5) {
  2088. c = 2.0 * s * l;
  2089. } else {
  2090. c = 2.0 * s * (1.0 - l);
  2091. }
  2092. if (c < 1.0) {
  2093. f = (l - 0.5 * c) / (1.0 - c);
  2094. }
  2095. return [hsl[0], c * 100, f * 100];
  2096. };
  2097. convert.hsv.hcg = function (hsv) {
  2098. var s = hsv[1] / 100;
  2099. var v = hsv[2] / 100;
  2100. var c = s * v;
  2101. var f = 0;
  2102. if (c < 1.0) {
  2103. f = (v - c) / (1 - c);
  2104. }
  2105. return [hsv[0], c * 100, f * 100];
  2106. };
  2107. convert.hcg.rgb = function (hcg) {
  2108. var h = hcg[0] / 360;
  2109. var c = hcg[1] / 100;
  2110. var g = hcg[2] / 100;
  2111. if (c === 0.0) {
  2112. return [g * 255, g * 255, g * 255];
  2113. }
  2114. var pure = [0, 0, 0];
  2115. var hi = (h % 1) * 6;
  2116. var v = hi % 1;
  2117. var w = 1 - v;
  2118. var mg = 0;
  2119. switch (Math.floor(hi)) {
  2120. case 0:
  2121. pure[0] = 1; pure[1] = v; pure[2] = 0; break;
  2122. case 1:
  2123. pure[0] = w; pure[1] = 1; pure[2] = 0; break;
  2124. case 2:
  2125. pure[0] = 0; pure[1] = 1; pure[2] = v; break;
  2126. case 3:
  2127. pure[0] = 0; pure[1] = w; pure[2] = 1; break;
  2128. case 4:
  2129. pure[0] = v; pure[1] = 0; pure[2] = 1; break;
  2130. default:
  2131. pure[0] = 1; pure[1] = 0; pure[2] = w;
  2132. }
  2133. mg = (1.0 - c) * g;
  2134. return [
  2135. (c * pure[0] + mg) * 255,
  2136. (c * pure[1] + mg) * 255,
  2137. (c * pure[2] + mg) * 255
  2138. ];
  2139. };
  2140. convert.hcg.hsv = function (hcg) {
  2141. var c = hcg[1] / 100;
  2142. var g = hcg[2] / 100;
  2143. var v = c + g * (1.0 - c);
  2144. var f = 0;
  2145. if (v > 0.0) {
  2146. f = c / v;
  2147. }
  2148. return [hcg[0], f * 100, v * 100];
  2149. };
  2150. convert.hcg.hsl = function (hcg) {
  2151. var c = hcg[1] / 100;
  2152. var g = hcg[2] / 100;
  2153. var l = g * (1.0 - c) + 0.5 * c;
  2154. var s = 0;
  2155. if (l > 0.0 && l < 0.5) {
  2156. s = c / (2 * l);
  2157. } else
  2158. if (l >= 0.5 && l < 1.0) {
  2159. s = c / (2 * (1 - l));
  2160. }
  2161. return [hcg[0], s * 100, l * 100];
  2162. };
  2163. convert.hcg.hwb = function (hcg) {
  2164. var c = hcg[1] / 100;
  2165. var g = hcg[2] / 100;
  2166. var v = c + g * (1.0 - c);
  2167. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  2168. };
  2169. convert.hwb.hcg = function (hwb) {
  2170. var w = hwb[1] / 100;
  2171. var b = hwb[2] / 100;
  2172. var v = 1 - b;
  2173. var c = v - w;
  2174. var g = 0;
  2175. if (c < 1) {
  2176. g = (v - c) / (1 - c);
  2177. }
  2178. return [hwb[0], c * 100, g * 100];
  2179. };
  2180. convert.apple.rgb = function (apple) {
  2181. return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
  2182. };
  2183. convert.rgb.apple = function (rgb) {
  2184. return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
  2185. };
  2186. convert.gray.rgb = function (args) {
  2187. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  2188. };
  2189. convert.gray.hsl = convert.gray.hsv = function (args) {
  2190. return [0, 0, args[0]];
  2191. };
  2192. convert.gray.hwb = function (gray) {
  2193. return [0, 100, gray[0]];
  2194. };
  2195. convert.gray.cmyk = function (gray) {
  2196. return [0, 0, 0, gray[0]];
  2197. };
  2198. convert.gray.lab = function (gray) {
  2199. return [gray[0], 0, 0];
  2200. };
  2201. convert.gray.hex = function (gray) {
  2202. var val = Math.round(gray[0] / 100 * 255) & 0xFF;
  2203. var integer = (val << 16) + (val << 8) + val;
  2204. var string = integer.toString(16).toUpperCase();
  2205. return '000000'.substring(string.length) + string;
  2206. };
  2207. convert.rgb.gray = function (rgb) {
  2208. var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  2209. return [val / 255 * 100];
  2210. };
  2211. /***/ }),
  2212. /* 7 */
  2213. /***/ (function(module, exports, __webpack_require__) {
  2214. "use strict";
  2215. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  2216. var _Colorpicker = __webpack_require__(8);
  2217. var _Colorpicker2 = _interopRequireDefault(_Colorpicker);
  2218. var _jquery = __webpack_require__(0);
  2219. var _jquery2 = _interopRequireDefault(_jquery);
  2220. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2221. var plugin = 'colorpicker';
  2222. _jquery2.default[plugin] = _Colorpicker2.default;
  2223. // Colorpicker jQuery Plugin API
  2224. _jquery2.default.fn[plugin] = function (option) {
  2225. var fnArgs = Array.prototype.slice.call(arguments, 1),
  2226. isSingleElement = this.length === 1,
  2227. returnValue = null;
  2228. var $elements = this.each(function () {
  2229. var $this = (0, _jquery2.default)(this),
  2230. inst = $this.data(plugin),
  2231. options = (typeof option === 'undefined' ? 'undefined' : _typeof(option)) === 'object' ? option : {};
  2232. // Create instance if does not exist
  2233. if (!inst) {
  2234. inst = new _Colorpicker2.default(this, options);
  2235. $this.data(plugin, inst);
  2236. }
  2237. if (!isSingleElement) {
  2238. return;
  2239. }
  2240. returnValue = $this;
  2241. if (typeof option === 'string') {
  2242. if (option === 'colorpicker') {
  2243. // Return colorpicker instance: e.g. .colorpicker('colorpicker')
  2244. returnValue = inst;
  2245. } else if (_jquery2.default.isFunction(inst[option])) {
  2246. // Return method call return value: e.g. .colorpicker('isEnabled')
  2247. returnValue = inst[option].apply(inst, fnArgs);
  2248. } else {
  2249. // Return property value: e.g. .colorpicker('element')
  2250. returnValue = inst[option];
  2251. }
  2252. }
  2253. });
  2254. return isSingleElement ? returnValue : $elements;
  2255. };
  2256. _jquery2.default.fn[plugin].constructor = _Colorpicker2.default;
  2257. /***/ }),
  2258. /* 8 */
  2259. /***/ (function(module, exports, __webpack_require__) {
  2260. "use strict";
  2261. Object.defineProperty(exports, "__esModule", {
  2262. value: true
  2263. });
  2264. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2265. var _Extension = __webpack_require__(1);
  2266. var _Extension2 = _interopRequireDefault(_Extension);
  2267. var _options = __webpack_require__(3);
  2268. var _options2 = _interopRequireDefault(_options);
  2269. var _extensions = __webpack_require__(9);
  2270. var _extensions2 = _interopRequireDefault(_extensions);
  2271. var _jquery = __webpack_require__(0);
  2272. var _jquery2 = _interopRequireDefault(_jquery);
  2273. var _SliderHandler = __webpack_require__(13);
  2274. var _SliderHandler2 = _interopRequireDefault(_SliderHandler);
  2275. var _PopupHandler = __webpack_require__(14);
  2276. var _PopupHandler2 = _interopRequireDefault(_PopupHandler);
  2277. var _InputHandler = __webpack_require__(15);
  2278. var _InputHandler2 = _interopRequireDefault(_InputHandler);
  2279. var _ColorHandler = __webpack_require__(22);
  2280. var _ColorHandler2 = _interopRequireDefault(_ColorHandler);
  2281. var _PickerHandler = __webpack_require__(23);
  2282. var _PickerHandler2 = _interopRequireDefault(_PickerHandler);
  2283. var _AddonHandler = __webpack_require__(24);
  2284. var _AddonHandler2 = _interopRequireDefault(_AddonHandler);
  2285. var _ColorItem = __webpack_require__(2);
  2286. var _ColorItem2 = _interopRequireDefault(_ColorItem);
  2287. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2288. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2289. var colorPickerIdCounter = 0;
  2290. var root = typeof self !== 'undefined' ? self : undefined; // window
  2291. /**
  2292. * Colorpicker widget class
  2293. */
  2294. var Colorpicker = function () {
  2295. _createClass(Colorpicker, [{
  2296. key: 'color',
  2297. /**
  2298. * Internal color object
  2299. *
  2300. * @type {Color|null}
  2301. */
  2302. get: function get() {
  2303. return this.colorHandler.color;
  2304. }
  2305. /**
  2306. * Internal color format
  2307. *
  2308. * @type {String|null}
  2309. */
  2310. }, {
  2311. key: 'format',
  2312. get: function get() {
  2313. return this.colorHandler.format;
  2314. }
  2315. /**
  2316. * Getter of the picker element
  2317. *
  2318. * @returns {jQuery|HTMLElement}
  2319. */
  2320. }, {
  2321. key: 'picker',
  2322. get: function get() {
  2323. return this.pickerHandler.picker;
  2324. }
  2325. /**
  2326. * @fires Colorpicker#colorpickerCreate
  2327. * @param {Object|String} element
  2328. * @param {Object} options
  2329. * @constructor
  2330. */
  2331. }], [{
  2332. key: 'Color',
  2333. /**
  2334. * Color class
  2335. *
  2336. * @static
  2337. * @type {Color}
  2338. */
  2339. get: function get() {
  2340. return _ColorItem2.default;
  2341. }
  2342. /**
  2343. * Extension class
  2344. *
  2345. * @static
  2346. * @type {Extension}
  2347. */
  2348. }, {
  2349. key: 'Extension',
  2350. get: function get() {
  2351. return _Extension2.default;
  2352. }
  2353. }]);
  2354. function Colorpicker(element, options) {
  2355. _classCallCheck(this, Colorpicker);
  2356. colorPickerIdCounter += 1;
  2357. /**
  2358. * The colorpicker instance number
  2359. * @type {number}
  2360. */
  2361. this.id = colorPickerIdCounter;
  2362. /**
  2363. * Latest colorpicker event
  2364. *
  2365. * @type {{name: String, e: *}}
  2366. */
  2367. this.lastEvent = {
  2368. alias: null,
  2369. e: null
  2370. };
  2371. /**
  2372. * The element that the colorpicker is bound to
  2373. *
  2374. * @type {*|jQuery}
  2375. */
  2376. this.element = (0, _jquery2.default)(element).addClass('colorpicker-element').attr('data-colorpicker-id', this.id);
  2377. /**
  2378. * @type {defaults}
  2379. */
  2380. this.options = _jquery2.default.extend(true, {}, _options2.default, options, this.element.data());
  2381. /**
  2382. * @type {boolean}
  2383. * @private
  2384. */
  2385. this.disabled = false;
  2386. /**
  2387. * Extensions added to this instance
  2388. *
  2389. * @type {Extension[]}
  2390. */
  2391. this.extensions = [];
  2392. /**
  2393. * The element where the
  2394. * @type {*|jQuery}
  2395. */
  2396. this.container = this.options.container === true || this.options.container !== true && this.options.inline === true ? this.element : this.options.container;
  2397. this.container = this.container !== false ? (0, _jquery2.default)(this.container) : false;
  2398. /**
  2399. * @type {InputHandler}
  2400. */
  2401. this.inputHandler = new _InputHandler2.default(this);
  2402. /**
  2403. * @type {ColorHandler}
  2404. */
  2405. this.colorHandler = new _ColorHandler2.default(this);
  2406. /**
  2407. * @type {SliderHandler}
  2408. */
  2409. this.sliderHandler = new _SliderHandler2.default(this);
  2410. /**
  2411. * @type {PopupHandler}
  2412. */
  2413. this.popupHandler = new _PopupHandler2.default(this, root);
  2414. /**
  2415. * @type {PickerHandler}
  2416. */
  2417. this.pickerHandler = new _PickerHandler2.default(this);
  2418. /**
  2419. * @type {AddonHandler}
  2420. */
  2421. this.addonHandler = new _AddonHandler2.default(this);
  2422. this.init();
  2423. // Emit a create event
  2424. (0, _jquery2.default)(_jquery2.default.proxy(function () {
  2425. /**
  2426. * (Colorpicker) When the Colorpicker instance has been created and the DOM is ready.
  2427. *
  2428. * @event Colorpicker#colorpickerCreate
  2429. */
  2430. this.trigger('colorpickerCreate');
  2431. }, this));
  2432. }
  2433. /**
  2434. * Initializes the plugin
  2435. * @private
  2436. */
  2437. _createClass(Colorpicker, [{
  2438. key: 'init',
  2439. value: function init() {
  2440. // Init addon
  2441. this.addonHandler.bind();
  2442. // Init input
  2443. this.inputHandler.bind();
  2444. // Init extensions (before initializing the color)
  2445. this.initExtensions();
  2446. // Init color
  2447. this.colorHandler.bind();
  2448. // Init picker
  2449. this.pickerHandler.bind();
  2450. // Init sliders and popup
  2451. this.sliderHandler.bind();
  2452. this.popupHandler.bind();
  2453. // Inject into the DOM (this may make it visible)
  2454. this.pickerHandler.attach();
  2455. // Update all components
  2456. this.update();
  2457. if (this.inputHandler.isDisabled()) {
  2458. this.disable();
  2459. }
  2460. }
  2461. /**
  2462. * Initializes the plugin extensions
  2463. * @private
  2464. */
  2465. }, {
  2466. key: 'initExtensions',
  2467. value: function initExtensions() {
  2468. var _this = this;
  2469. if (!Array.isArray(this.options.extensions)) {
  2470. this.options.extensions = [];
  2471. }
  2472. if (this.options.debug) {
  2473. this.options.extensions.push({ name: 'debugger' });
  2474. }
  2475. // Register and instantiate extensions
  2476. this.options.extensions.forEach(function (ext) {
  2477. _this.registerExtension(Colorpicker.extensions[ext.name.toLowerCase()], ext.options || {});
  2478. });
  2479. }
  2480. /**
  2481. * Creates and registers the given extension
  2482. *
  2483. * @param {Extension} ExtensionClass The extension class to instantiate
  2484. * @param {Object} [config] Extension configuration
  2485. * @returns {Extension}
  2486. */
  2487. }, {
  2488. key: 'registerExtension',
  2489. value: function registerExtension(ExtensionClass) {
  2490. var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2491. var ext = new ExtensionClass(this, config);
  2492. this.extensions.push(ext);
  2493. return ext;
  2494. }
  2495. /**
  2496. * Destroys the current instance
  2497. *
  2498. * @fires Colorpicker#colorpickerDestroy
  2499. */
  2500. }, {
  2501. key: 'destroy',
  2502. value: function destroy() {
  2503. var color = this.color;
  2504. this.sliderHandler.unbind();
  2505. this.inputHandler.unbind();
  2506. this.popupHandler.unbind();
  2507. this.colorHandler.unbind();
  2508. this.addonHandler.unbind();
  2509. this.pickerHandler.unbind();
  2510. this.element.removeClass('colorpicker-element').removeData('colorpicker', 'color').off('.colorpicker');
  2511. /**
  2512. * (Colorpicker) When the instance is destroyed with all events unbound.
  2513. *
  2514. * @event Colorpicker#colorpickerDestroy
  2515. */
  2516. this.trigger('colorpickerDestroy', color);
  2517. }
  2518. /**
  2519. * Shows the colorpicker widget if hidden.
  2520. * If the colorpicker is disabled this call will be ignored.
  2521. *
  2522. * @fires Colorpicker#colorpickerShow
  2523. * @param {Event} [e]
  2524. */
  2525. }, {
  2526. key: 'show',
  2527. value: function show(e) {
  2528. this.popupHandler.show(e);
  2529. }
  2530. /**
  2531. * Hides the colorpicker widget.
  2532. *
  2533. * @fires Colorpicker#colorpickerHide
  2534. * @param {Event} [e]
  2535. */
  2536. }, {
  2537. key: 'hide',
  2538. value: function hide(e) {
  2539. this.popupHandler.hide(e);
  2540. }
  2541. /**
  2542. * Toggles the colorpicker between visible and hidden.
  2543. *
  2544. * @fires Colorpicker#colorpickerShow
  2545. * @fires Colorpicker#colorpickerHide
  2546. * @param {Event} [e]
  2547. */
  2548. }, {
  2549. key: 'toggle',
  2550. value: function toggle(e) {
  2551. this.popupHandler.toggle(e);
  2552. }
  2553. /**
  2554. * Returns the current color value as string
  2555. *
  2556. * @param {String|*} [defaultValue]
  2557. * @returns {String|*}
  2558. */
  2559. }, {
  2560. key: 'getValue',
  2561. value: function getValue() {
  2562. var defaultValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  2563. var val = this.colorHandler.color;
  2564. val = val instanceof _ColorItem2.default ? val : defaultValue;
  2565. if (val instanceof _ColorItem2.default) {
  2566. return val.string(this.format);
  2567. }
  2568. return val;
  2569. }
  2570. /**
  2571. * Sets the color manually
  2572. *
  2573. * @fires Colorpicker#colorpickerChange
  2574. * @param {String|Color} val
  2575. */
  2576. }, {
  2577. key: 'setValue',
  2578. value: function setValue(val) {
  2579. if (this.isDisabled()) {
  2580. return;
  2581. }
  2582. var ch = this.colorHandler;
  2583. if (ch.hasColor() && !!val && ch.color.equals(val) || !ch.hasColor() && !val) {
  2584. // same color or still empty
  2585. return;
  2586. }
  2587. ch.color = val ? ch.createColor(val, this.options.autoInputFallback) : null;
  2588. /**
  2589. * (Colorpicker) When the color is set programmatically with setValue().
  2590. *
  2591. * @event Colorpicker#colorpickerChange
  2592. */
  2593. this.trigger('colorpickerChange', ch.color, val);
  2594. // force update if color has changed to empty
  2595. this.update();
  2596. }
  2597. /**
  2598. * Updates the UI and the input color according to the internal color.
  2599. *
  2600. * @fires Colorpicker#colorpickerUpdate
  2601. */
  2602. }, {
  2603. key: 'update',
  2604. value: function update() {
  2605. if (this.colorHandler.hasColor()) {
  2606. this.inputHandler.update();
  2607. } else {
  2608. this.colorHandler.assureColor();
  2609. }
  2610. this.addonHandler.update();
  2611. this.pickerHandler.update();
  2612. /**
  2613. * (Colorpicker) Fired when the widget is updated.
  2614. *
  2615. * @event Colorpicker#colorpickerUpdate
  2616. */
  2617. this.trigger('colorpickerUpdate');
  2618. }
  2619. /**
  2620. * Enables the widget and the input if any
  2621. *
  2622. * @fires Colorpicker#colorpickerEnable
  2623. * @returns {boolean}
  2624. */
  2625. }, {
  2626. key: 'enable',
  2627. value: function enable() {
  2628. this.inputHandler.enable();
  2629. this.disabled = false;
  2630. this.picker.removeClass('colorpicker-disabled');
  2631. /**
  2632. * (Colorpicker) When the widget has been enabled.
  2633. *
  2634. * @event Colorpicker#colorpickerEnable
  2635. */
  2636. this.trigger('colorpickerEnable');
  2637. return true;
  2638. }
  2639. /**
  2640. * Disables the widget and the input if any
  2641. *
  2642. * @fires Colorpicker#colorpickerDisable
  2643. * @returns {boolean}
  2644. */
  2645. }, {
  2646. key: 'disable',
  2647. value: function disable() {
  2648. this.inputHandler.disable();
  2649. this.disabled = true;
  2650. this.picker.addClass('colorpicker-disabled');
  2651. /**
  2652. * (Colorpicker) When the widget has been disabled.
  2653. *
  2654. * @event Colorpicker#colorpickerDisable
  2655. */
  2656. this.trigger('colorpickerDisable');
  2657. return true;
  2658. }
  2659. /**
  2660. * Returns true if this instance is enabled
  2661. * @returns {boolean}
  2662. */
  2663. }, {
  2664. key: 'isEnabled',
  2665. value: function isEnabled() {
  2666. return !this.isDisabled();
  2667. }
  2668. /**
  2669. * Returns true if this instance is disabled
  2670. * @returns {boolean}
  2671. */
  2672. }, {
  2673. key: 'isDisabled',
  2674. value: function isDisabled() {
  2675. return this.disabled === true;
  2676. }
  2677. /**
  2678. * Triggers a Colorpicker event.
  2679. *
  2680. * @param eventName
  2681. * @param color
  2682. * @param value
  2683. */
  2684. }, {
  2685. key: 'trigger',
  2686. value: function trigger(eventName) {
  2687. var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2688. var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  2689. this.element.trigger({
  2690. type: eventName,
  2691. colorpicker: this,
  2692. color: color ? color : this.color,
  2693. value: value ? value : this.getValue()
  2694. });
  2695. }
  2696. }]);
  2697. return Colorpicker;
  2698. }();
  2699. /**
  2700. * Colorpicker extension classes, indexed by extension name
  2701. *
  2702. * @static
  2703. * @type {Object} a map between the extension name and its class
  2704. */
  2705. Colorpicker.extensions = _extensions2.default;
  2706. exports.default = Colorpicker;
  2707. module.exports = exports.default;
  2708. /***/ }),
  2709. /* 9 */
  2710. /***/ (function(module, exports, __webpack_require__) {
  2711. "use strict";
  2712. Object.defineProperty(exports, "__esModule", {
  2713. value: true
  2714. });
  2715. exports.Palette = exports.Swatches = exports.Preview = exports.Debugger = undefined;
  2716. var _Debugger = __webpack_require__(10);
  2717. var _Debugger2 = _interopRequireDefault(_Debugger);
  2718. var _Preview = __webpack_require__(11);
  2719. var _Preview2 = _interopRequireDefault(_Preview);
  2720. var _Swatches = __webpack_require__(12);
  2721. var _Swatches2 = _interopRequireDefault(_Swatches);
  2722. var _Palette = __webpack_require__(4);
  2723. var _Palette2 = _interopRequireDefault(_Palette);
  2724. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2725. exports.Debugger = _Debugger2.default;
  2726. exports.Preview = _Preview2.default;
  2727. exports.Swatches = _Swatches2.default;
  2728. exports.Palette = _Palette2.default;
  2729. exports.default = {
  2730. 'debugger': _Debugger2.default,
  2731. 'preview': _Preview2.default,
  2732. 'swatches': _Swatches2.default,
  2733. 'palette': _Palette2.default
  2734. };
  2735. /***/ }),
  2736. /* 10 */
  2737. /***/ (function(module, exports, __webpack_require__) {
  2738. "use strict";
  2739. Object.defineProperty(exports, "__esModule", {
  2740. value: true
  2741. });
  2742. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2743. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  2744. var _Extension2 = __webpack_require__(1);
  2745. var _Extension3 = _interopRequireDefault(_Extension2);
  2746. var _jquery = __webpack_require__(0);
  2747. var _jquery2 = _interopRequireDefault(_jquery);
  2748. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2749. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2750. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  2751. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  2752. /**
  2753. * Debugger extension class
  2754. * @alias DebuggerExtension
  2755. * @ignore
  2756. */
  2757. var Debugger = function (_Extension) {
  2758. _inherits(Debugger, _Extension);
  2759. function Debugger(colorpicker) {
  2760. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2761. _classCallCheck(this, Debugger);
  2762. /**
  2763. * @type {number}
  2764. */
  2765. var _this = _possibleConstructorReturn(this, (Debugger.__proto__ || Object.getPrototypeOf(Debugger)).call(this, colorpicker, options));
  2766. _this.eventCounter = 0;
  2767. if (_this.colorpicker.inputHandler.hasInput()) {
  2768. _this.colorpicker.inputHandler.input.on('change.colorpicker-ext', _jquery2.default.proxy(_this.onChangeInput, _this));
  2769. }
  2770. return _this;
  2771. }
  2772. /**
  2773. * @fires DebuggerExtension#colorpickerDebug
  2774. * @param {string} eventName
  2775. * @param {*} args
  2776. */
  2777. _createClass(Debugger, [{
  2778. key: 'log',
  2779. value: function log(eventName) {
  2780. var _console;
  2781. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  2782. args[_key - 1] = arguments[_key];
  2783. }
  2784. this.eventCounter += 1;
  2785. var logMessage = '#' + this.eventCounter + ': Colorpicker#' + this.colorpicker.id + ' [' + eventName + ']';
  2786. (_console = console).debug.apply(_console, [logMessage].concat(args));
  2787. /**
  2788. * Whenever the debugger logs an event, this other event is emitted.
  2789. *
  2790. * @event DebuggerExtension#colorpickerDebug
  2791. * @type {object} The event object
  2792. * @property {Colorpicker} colorpicker The Colorpicker instance
  2793. * @property {ColorItem} color The color instance
  2794. * @property {{debugger: DebuggerExtension, eventName: String, logArgs: Array, logMessage: String}} debug
  2795. * The debug info
  2796. */
  2797. this.colorpicker.element.trigger({
  2798. type: 'colorpickerDebug',
  2799. colorpicker: this.colorpicker,
  2800. color: this.color,
  2801. value: null,
  2802. debug: {
  2803. debugger: this,
  2804. eventName: eventName,
  2805. logArgs: args,
  2806. logMessage: logMessage
  2807. }
  2808. });
  2809. }
  2810. }, {
  2811. key: 'resolveColor',
  2812. value: function resolveColor(color) {
  2813. var realColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  2814. this.log('resolveColor()', color, realColor);
  2815. return false;
  2816. }
  2817. }, {
  2818. key: 'onCreate',
  2819. value: function onCreate(event) {
  2820. this.log('colorpickerCreate');
  2821. return _get(Debugger.prototype.__proto__ || Object.getPrototypeOf(Debugger.prototype), 'onCreate', this).call(this, event);
  2822. }
  2823. }, {
  2824. key: 'onDestroy',
  2825. value: function onDestroy(event) {
  2826. this.log('colorpickerDestroy');
  2827. this.eventCounter = 0;
  2828. if (this.colorpicker.inputHandler.hasInput()) {
  2829. this.colorpicker.inputHandler.input.off('.colorpicker-ext');
  2830. }
  2831. return _get(Debugger.prototype.__proto__ || Object.getPrototypeOf(Debugger.prototype), 'onDestroy', this).call(this, event);
  2832. }
  2833. }, {
  2834. key: 'onUpdate',
  2835. value: function onUpdate(event) {
  2836. this.log('colorpickerUpdate');
  2837. }
  2838. /**
  2839. * @listens Colorpicker#change
  2840. * @param {Event} event
  2841. */
  2842. }, {
  2843. key: 'onChangeInput',
  2844. value: function onChangeInput(event) {
  2845. this.log('input:change.colorpicker', event.value, event.color);
  2846. }
  2847. }, {
  2848. key: 'onChange',
  2849. value: function onChange(event) {
  2850. this.log('colorpickerChange', event.value, event.color);
  2851. }
  2852. }, {
  2853. key: 'onInvalid',
  2854. value: function onInvalid(event) {
  2855. this.log('colorpickerInvalid', event.value, event.color);
  2856. }
  2857. }, {
  2858. key: 'onHide',
  2859. value: function onHide(event) {
  2860. this.log('colorpickerHide');
  2861. this.eventCounter = 0;
  2862. }
  2863. }, {
  2864. key: 'onShow',
  2865. value: function onShow(event) {
  2866. this.log('colorpickerShow');
  2867. }
  2868. }, {
  2869. key: 'onDisable',
  2870. value: function onDisable(event) {
  2871. this.log('colorpickerDisable');
  2872. }
  2873. }, {
  2874. key: 'onEnable',
  2875. value: function onEnable(event) {
  2876. this.log('colorpickerEnable');
  2877. }
  2878. }]);
  2879. return Debugger;
  2880. }(_Extension3.default);
  2881. exports.default = Debugger;
  2882. module.exports = exports.default;
  2883. /***/ }),
  2884. /* 11 */
  2885. /***/ (function(module, exports, __webpack_require__) {
  2886. "use strict";
  2887. Object.defineProperty(exports, "__esModule", {
  2888. value: true
  2889. });
  2890. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2891. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  2892. var _Extension2 = __webpack_require__(1);
  2893. var _Extension3 = _interopRequireDefault(_Extension2);
  2894. var _jquery = __webpack_require__(0);
  2895. var _jquery2 = _interopRequireDefault(_jquery);
  2896. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2897. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2898. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  2899. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  2900. /**
  2901. * Color preview extension
  2902. * @ignore
  2903. */
  2904. var Preview = function (_Extension) {
  2905. _inherits(Preview, _Extension);
  2906. function Preview(colorpicker) {
  2907. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2908. _classCallCheck(this, Preview);
  2909. var _this = _possibleConstructorReturn(this, (Preview.__proto__ || Object.getPrototypeOf(Preview)).call(this, colorpicker, _jquery2.default.extend(true, {}, {
  2910. template: '<div class="colorpicker-bar colorpicker-preview"><div /></div>',
  2911. showText: true,
  2912. format: colorpicker.format
  2913. }, options)));
  2914. _this.element = (0, _jquery2.default)(_this.options.template);
  2915. _this.elementInner = _this.element.find('div');
  2916. return _this;
  2917. }
  2918. _createClass(Preview, [{
  2919. key: 'onCreate',
  2920. value: function onCreate(event) {
  2921. _get(Preview.prototype.__proto__ || Object.getPrototypeOf(Preview.prototype), 'onCreate', this).call(this, event);
  2922. this.colorpicker.picker.append(this.element);
  2923. }
  2924. }, {
  2925. key: 'onUpdate',
  2926. value: function onUpdate(event) {
  2927. _get(Preview.prototype.__proto__ || Object.getPrototypeOf(Preview.prototype), 'onUpdate', this).call(this, event);
  2928. if (!event.color) {
  2929. this.elementInner.css('backgroundColor', null).css('color', null).html('');
  2930. return;
  2931. }
  2932. this.elementInner.css('backgroundColor', event.color.toRgbString());
  2933. if (this.options.showText) {
  2934. this.elementInner.html(event.color.string(this.options.format || this.colorpicker.format));
  2935. if (event.color.isDark() && event.color.alpha > 0.5) {
  2936. this.elementInner.css('color', 'white');
  2937. } else {
  2938. this.elementInner.css('color', 'black');
  2939. }
  2940. }
  2941. }
  2942. }]);
  2943. return Preview;
  2944. }(_Extension3.default);
  2945. exports.default = Preview;
  2946. module.exports = exports.default;
  2947. /***/ }),
  2948. /* 12 */
  2949. /***/ (function(module, exports, __webpack_require__) {
  2950. "use strict";
  2951. Object.defineProperty(exports, "__esModule", {
  2952. value: true
  2953. });
  2954. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2955. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  2956. var _Palette2 = __webpack_require__(4);
  2957. var _Palette3 = _interopRequireDefault(_Palette2);
  2958. var _jquery = __webpack_require__(0);
  2959. var _jquery2 = _interopRequireDefault(_jquery);
  2960. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2961. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2962. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  2963. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  2964. var defaults = {
  2965. barTemplate: '<div class="colorpicker-bar colorpicker-swatches">\n <div class="colorpicker-swatches--inner"></div>\n </div>',
  2966. swatchTemplate: '<i class="colorpicker-swatch"><i class="colorpicker-swatch--inner"></i></i>'
  2967. };
  2968. /**
  2969. * Color swatches extension
  2970. * @ignore
  2971. */
  2972. var Swatches = function (_Palette) {
  2973. _inherits(Swatches, _Palette);
  2974. function Swatches(colorpicker) {
  2975. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2976. _classCallCheck(this, Swatches);
  2977. var _this = _possibleConstructorReturn(this, (Swatches.__proto__ || Object.getPrototypeOf(Swatches)).call(this, colorpicker, _jquery2.default.extend(true, {}, defaults, options)));
  2978. _this.element = null;
  2979. return _this;
  2980. }
  2981. _createClass(Swatches, [{
  2982. key: 'isEnabled',
  2983. value: function isEnabled() {
  2984. return this.getLength() > 0;
  2985. }
  2986. }, {
  2987. key: 'onCreate',
  2988. value: function onCreate(event) {
  2989. _get(Swatches.prototype.__proto__ || Object.getPrototypeOf(Swatches.prototype), 'onCreate', this).call(this, event);
  2990. if (!this.isEnabled()) {
  2991. return;
  2992. }
  2993. this.element = (0, _jquery2.default)(this.options.barTemplate);
  2994. this.load();
  2995. this.colorpicker.picker.append(this.element);
  2996. }
  2997. }, {
  2998. key: 'load',
  2999. value: function load() {
  3000. var _this2 = this;
  3001. var colorpicker = this.colorpicker,
  3002. swatchContainer = this.element.find('.colorpicker-swatches--inner'),
  3003. isAliased = this.options.namesAsValues === true && !Array.isArray(this.colors);
  3004. swatchContainer.empty();
  3005. _jquery2.default.each(this.colors, function (name, value) {
  3006. var $swatch = (0, _jquery2.default)(_this2.options.swatchTemplate).attr('data-name', name).attr('data-value', value).attr('title', isAliased ? name + ': ' + value : value).on('mousedown.colorpicker touchstart.colorpicker', function (e) {
  3007. var $sw = (0, _jquery2.default)(this);
  3008. // e.preventDefault();
  3009. colorpicker.setValue(isAliased ? $sw.attr('data-name') : $sw.attr('data-value'));
  3010. });
  3011. $swatch.find('.colorpicker-swatch--inner').css('background-color', value);
  3012. swatchContainer.append($swatch);
  3013. });
  3014. swatchContainer.append((0, _jquery2.default)('<i class="colorpicker-clear"></i>'));
  3015. }
  3016. }]);
  3017. return Swatches;
  3018. }(_Palette3.default);
  3019. exports.default = Swatches;
  3020. module.exports = exports.default;
  3021. /***/ }),
  3022. /* 13 */
  3023. /***/ (function(module, exports, __webpack_require__) {
  3024. "use strict";
  3025. Object.defineProperty(exports, "__esModule", {
  3026. value: true
  3027. });
  3028. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3029. var _jquery = __webpack_require__(0);
  3030. var _jquery2 = _interopRequireDefault(_jquery);
  3031. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3032. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3033. /**
  3034. * Class that handles all configured sliders on mouse or touch events.
  3035. * @ignore
  3036. */
  3037. var SliderHandler = function () {
  3038. /**
  3039. * @param {Colorpicker} colorpicker
  3040. */
  3041. function SliderHandler(colorpicker) {
  3042. _classCallCheck(this, SliderHandler);
  3043. /**
  3044. * @type {Colorpicker}
  3045. */
  3046. this.colorpicker = colorpicker;
  3047. /**
  3048. * @type {*|String}
  3049. * @private
  3050. */
  3051. this.currentSlider = null;
  3052. /**
  3053. * @type {{left: number, top: number}}
  3054. * @private
  3055. */
  3056. this.mousePointer = {
  3057. left: 0,
  3058. top: 0
  3059. };
  3060. /**
  3061. * @type {Function}
  3062. */
  3063. this.onMove = _jquery2.default.proxy(this.defaultOnMove, this);
  3064. }
  3065. /**
  3066. * This function is called every time a slider guide is moved
  3067. * The scope of "this" is the SliderHandler object.
  3068. *
  3069. * @param {int} top
  3070. * @param {int} left
  3071. */
  3072. _createClass(SliderHandler, [{
  3073. key: 'defaultOnMove',
  3074. value: function defaultOnMove(top, left) {
  3075. if (!this.currentSlider) {
  3076. return;
  3077. }
  3078. var slider = this.currentSlider,
  3079. cp = this.colorpicker,
  3080. ch = cp.colorHandler;
  3081. // Create a color object
  3082. var color = !ch.hasColor() ? ch.getFallbackColor() : ch.color.getClone();
  3083. // Adjust the guide position
  3084. slider.guideStyle.left = left + 'px';
  3085. slider.guideStyle.top = top + 'px';
  3086. // Adjust the color
  3087. if (slider.callLeft) {
  3088. color[slider.callLeft](left / slider.maxLeft);
  3089. }
  3090. if (slider.callTop) {
  3091. color[slider.callTop](top / slider.maxTop);
  3092. }
  3093. // Set the new color
  3094. cp.setValue(color);
  3095. cp.popupHandler.focus();
  3096. }
  3097. /**
  3098. * Binds the colorpicker sliders to the mouse/touch events
  3099. */
  3100. }, {
  3101. key: 'bind',
  3102. value: function bind() {
  3103. var sliders = this.colorpicker.options.horizontal ? this.colorpicker.options.slidersHorz : this.colorpicker.options.sliders;
  3104. var sliderClasses = [];
  3105. for (var sliderName in sliders) {
  3106. if (!sliders.hasOwnProperty(sliderName)) {
  3107. continue;
  3108. }
  3109. sliderClasses.push(sliders[sliderName].selector);
  3110. }
  3111. this.colorpicker.picker.find(sliderClasses.join(', ')).on('mousedown.colorpicker touchstart.colorpicker', _jquery2.default.proxy(this.pressed, this));
  3112. }
  3113. /**
  3114. * Unbinds any event bound by this handler
  3115. */
  3116. }, {
  3117. key: 'unbind',
  3118. value: function unbind() {
  3119. (0, _jquery2.default)(this.colorpicker.picker).off({
  3120. 'mousemove.colorpicker': _jquery2.default.proxy(this.moved, this),
  3121. 'touchmove.colorpicker': _jquery2.default.proxy(this.moved, this),
  3122. 'mouseup.colorpicker': _jquery2.default.proxy(this.released, this),
  3123. 'touchend.colorpicker': _jquery2.default.proxy(this.released, this)
  3124. });
  3125. }
  3126. /**
  3127. * Function triggered when clicking in one of the color adjustment bars
  3128. *
  3129. * @private
  3130. * @fires Colorpicker#mousemove
  3131. * @param {Event} e
  3132. */
  3133. }, {
  3134. key: 'pressed',
  3135. value: function pressed(e) {
  3136. if (this.colorpicker.isDisabled()) {
  3137. return;
  3138. }
  3139. this.colorpicker.lastEvent.alias = 'pressed';
  3140. this.colorpicker.lastEvent.e = e;
  3141. if (!e.pageX && !e.pageY && e.originalEvent && e.originalEvent.touches) {
  3142. e.pageX = e.originalEvent.touches[0].pageX;
  3143. e.pageY = e.originalEvent.touches[0].pageY;
  3144. }
  3145. // e.stopPropagation();
  3146. // e.preventDefault();
  3147. var target = (0, _jquery2.default)(e.target);
  3148. // detect the slider and set the limits and callbacks
  3149. var zone = target.closest('div');
  3150. var sliders = this.colorpicker.options.horizontal ? this.colorpicker.options.slidersHorz : this.colorpicker.options.sliders;
  3151. if (zone.is('.colorpicker')) {
  3152. return;
  3153. }
  3154. this.currentSlider = null;
  3155. for (var sliderName in sliders) {
  3156. if (!sliders.hasOwnProperty(sliderName)) {
  3157. continue;
  3158. }
  3159. var slider = sliders[sliderName];
  3160. if (zone.is(slider.selector)) {
  3161. this.currentSlider = _jquery2.default.extend({}, slider, { name: sliderName });
  3162. break;
  3163. } else if (slider.childSelector !== undefined && zone.is(slider.childSelector)) {
  3164. this.currentSlider = _jquery2.default.extend({}, slider, { name: sliderName });
  3165. zone = zone.parent(); // zone.parents(slider.selector).first() ?
  3166. break;
  3167. }
  3168. }
  3169. var guide = zone.find('.colorpicker-guide').get(0);
  3170. if (this.currentSlider === null || guide === null) {
  3171. return;
  3172. }
  3173. var offset = zone.offset();
  3174. // reference to guide's style
  3175. this.currentSlider.guideStyle = guide.style;
  3176. this.currentSlider.left = e.pageX - offset.left;
  3177. this.currentSlider.top = e.pageY - offset.top;
  3178. this.mousePointer = {
  3179. left: e.pageX,
  3180. top: e.pageY
  3181. };
  3182. // TODO: fix moving outside the picker makes the guides to keep moving. The event needs to be bound to the window.
  3183. /**
  3184. * (window.document) Triggered on mousedown for the document object,
  3185. * so the color adjustment guide is moved to the clicked position.
  3186. *
  3187. * @event Colorpicker#mousemove
  3188. */
  3189. (0, _jquery2.default)(this.colorpicker.picker).on({
  3190. 'mousemove.colorpicker': _jquery2.default.proxy(this.moved, this),
  3191. 'touchmove.colorpicker': _jquery2.default.proxy(this.moved, this),
  3192. 'mouseup.colorpicker': _jquery2.default.proxy(this.released, this),
  3193. 'touchend.colorpicker': _jquery2.default.proxy(this.released, this)
  3194. }).trigger('mousemove');
  3195. }
  3196. /**
  3197. * Function triggered when dragging a guide inside one of the color adjustment bars.
  3198. *
  3199. * @private
  3200. * @param {Event} e
  3201. */
  3202. }, {
  3203. key: 'moved',
  3204. value: function moved(e) {
  3205. this.colorpicker.lastEvent.alias = 'moved';
  3206. this.colorpicker.lastEvent.e = e;
  3207. if (!e.pageX && !e.pageY && e.originalEvent && e.originalEvent.touches) {
  3208. e.pageX = e.originalEvent.touches[0].pageX;
  3209. e.pageY = e.originalEvent.touches[0].pageY;
  3210. }
  3211. // e.stopPropagation();
  3212. e.preventDefault(); // prevents scrolling on mobile
  3213. var left = Math.max(0, Math.min(this.currentSlider.maxLeft, this.currentSlider.left + ((e.pageX || this.mousePointer.left) - this.mousePointer.left)));
  3214. var top = Math.max(0, Math.min(this.currentSlider.maxTop, this.currentSlider.top + ((e.pageY || this.mousePointer.top) - this.mousePointer.top)));
  3215. this.onMove(top, left);
  3216. }
  3217. /**
  3218. * Function triggered when releasing the click in one of the color adjustment bars.
  3219. *
  3220. * @private
  3221. * @param {Event} e
  3222. */
  3223. }, {
  3224. key: 'released',
  3225. value: function released(e) {
  3226. this.colorpicker.lastEvent.alias = 'released';
  3227. this.colorpicker.lastEvent.e = e;
  3228. // e.stopPropagation();
  3229. // e.preventDefault();
  3230. (0, _jquery2.default)(this.colorpicker.picker).off({
  3231. 'mousemove.colorpicker': this.moved,
  3232. 'touchmove.colorpicker': this.moved,
  3233. 'mouseup.colorpicker': this.released,
  3234. 'touchend.colorpicker': this.released
  3235. });
  3236. }
  3237. }]);
  3238. return SliderHandler;
  3239. }();
  3240. exports.default = SliderHandler;
  3241. module.exports = exports.default;
  3242. /***/ }),
  3243. /* 14 */
  3244. /***/ (function(module, exports, __webpack_require__) {
  3245. "use strict";
  3246. Object.defineProperty(exports, "__esModule", {
  3247. value: true
  3248. });
  3249. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3250. var _jquery = __webpack_require__(0);
  3251. var _jquery2 = _interopRequireDefault(_jquery);
  3252. var _options = __webpack_require__(3);
  3253. var _options2 = _interopRequireDefault(_options);
  3254. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3255. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3256. /**
  3257. * Handles everything related to the UI of the colorpicker popup: show, hide, position,...
  3258. * @ignore
  3259. */
  3260. var PopupHandler = function () {
  3261. /**
  3262. * @param {Colorpicker} colorpicker
  3263. * @param {Window} root
  3264. */
  3265. function PopupHandler(colorpicker, root) {
  3266. _classCallCheck(this, PopupHandler);
  3267. /**
  3268. * @type {Window}
  3269. */
  3270. this.root = root;
  3271. /**
  3272. * @type {Colorpicker}
  3273. */
  3274. this.colorpicker = colorpicker;
  3275. /**
  3276. * @type {jQuery}
  3277. */
  3278. this.popoverTarget = null;
  3279. /**
  3280. * @type {jQuery}
  3281. */
  3282. this.popoverTip = null;
  3283. /**
  3284. * If true, the latest click was inside the popover
  3285. * @type {boolean}
  3286. */
  3287. this.clicking = false;
  3288. /**
  3289. * @type {boolean}
  3290. */
  3291. this.hidding = false;
  3292. /**
  3293. * @type {boolean}
  3294. */
  3295. this.showing = false;
  3296. }
  3297. /**
  3298. * @private
  3299. * @returns {jQuery|false}
  3300. */
  3301. _createClass(PopupHandler, [{
  3302. key: 'bind',
  3303. /**
  3304. * Binds the different colorpicker elements to the focus/mouse/touch events so it reacts in order to show or
  3305. * hide the colorpicker popup accordingly. It also adds the proper classes.
  3306. */
  3307. value: function bind() {
  3308. var cp = this.colorpicker;
  3309. if (cp.options.inline) {
  3310. cp.picker.addClass('colorpicker-inline colorpicker-visible');
  3311. return; // no need to bind show/hide events for inline elements
  3312. }
  3313. cp.picker.addClass('colorpicker-popup colorpicker-hidden');
  3314. // there is no input or addon
  3315. if (!this.hasInput && !this.hasAddon) {
  3316. return;
  3317. }
  3318. // create Bootstrap 4 popover
  3319. if (cp.options.popover) {
  3320. this.createPopover();
  3321. }
  3322. // bind addon show/hide events
  3323. if (this.hasAddon) {
  3324. // enable focus on addons
  3325. if (!this.addon.attr('tabindex')) {
  3326. this.addon.attr('tabindex', 0);
  3327. }
  3328. this.addon.on({
  3329. 'mousedown.colorpicker touchstart.colorpicker': _jquery2.default.proxy(this.toggle, this)
  3330. });
  3331. this.addon.on({
  3332. 'focus.colorpicker': _jquery2.default.proxy(this.show, this)
  3333. });
  3334. this.addon.on({
  3335. 'focusout.colorpicker': _jquery2.default.proxy(this.hide, this)
  3336. });
  3337. }
  3338. // bind input show/hide events
  3339. if (this.hasInput && !this.hasAddon) {
  3340. this.input.on({
  3341. 'mousedown.colorpicker touchstart.colorpicker': _jquery2.default.proxy(this.show, this),
  3342. 'focus.colorpicker': _jquery2.default.proxy(this.show, this)
  3343. });
  3344. this.input.on({
  3345. 'focusout.colorpicker': _jquery2.default.proxy(this.hide, this)
  3346. });
  3347. }
  3348. // reposition popup on window resize
  3349. (0, _jquery2.default)(this.root).on('resize.colorpicker', _jquery2.default.proxy(this.reposition, this));
  3350. }
  3351. /**
  3352. * Unbinds any event bound by this handler
  3353. */
  3354. }, {
  3355. key: 'unbind',
  3356. value: function unbind() {
  3357. if (this.hasInput) {
  3358. this.input.off({
  3359. 'mousedown.colorpicker touchstart.colorpicker': _jquery2.default.proxy(this.show, this),
  3360. 'focus.colorpicker': _jquery2.default.proxy(this.show, this)
  3361. });
  3362. this.input.off({
  3363. 'focusout.colorpicker': _jquery2.default.proxy(this.hide, this)
  3364. });
  3365. }
  3366. if (this.hasAddon) {
  3367. this.addon.off({
  3368. 'mousedown.colorpicker touchstart.colorpicker': _jquery2.default.proxy(this.toggle, this)
  3369. });
  3370. this.addon.off({
  3371. 'focus.colorpicker': _jquery2.default.proxy(this.show, this)
  3372. });
  3373. this.addon.off({
  3374. 'focusout.colorpicker': _jquery2.default.proxy(this.hide, this)
  3375. });
  3376. }
  3377. if (this.popoverTarget) {
  3378. this.popoverTarget.popover('dispose');
  3379. }
  3380. (0, _jquery2.default)(this.root).off('resize.colorpicker', _jquery2.default.proxy(this.reposition, this));
  3381. (0, _jquery2.default)(this.root.document).off('mousedown.colorpicker touchstart.colorpicker', _jquery2.default.proxy(this.hide, this));
  3382. (0, _jquery2.default)(this.root.document).off('mousedown.colorpicker touchstart.colorpicker', _jquery2.default.proxy(this.onClickingInside, this));
  3383. }
  3384. }, {
  3385. key: 'isClickingInside',
  3386. value: function isClickingInside(e) {
  3387. if (!e) {
  3388. return false;
  3389. }
  3390. return this.isOrIsInside(this.popoverTip, e.currentTarget) || this.isOrIsInside(this.popoverTip, e.target) || this.isOrIsInside(this.colorpicker.picker, e.currentTarget) || this.isOrIsInside(this.colorpicker.picker, e.target);
  3391. }
  3392. }, {
  3393. key: 'isOrIsInside',
  3394. value: function isOrIsInside(container, element) {
  3395. if (!container || !element) {
  3396. return false;
  3397. }
  3398. element = (0, _jquery2.default)(element);
  3399. return element.is(container) || container.find(element).length > 0;
  3400. }
  3401. }, {
  3402. key: 'onClickingInside',
  3403. value: function onClickingInside(e) {
  3404. this.clicking = this.isClickingInside(e);
  3405. }
  3406. }, {
  3407. key: 'createPopover',
  3408. value: function createPopover() {
  3409. var cp = this.colorpicker;
  3410. this.popoverTarget = this.hasAddon ? this.addon : this.input;
  3411. cp.picker.addClass('colorpicker-bs-popover-content');
  3412. this.popoverTarget.popover(_jquery2.default.extend(true, {}, _options2.default.popover, cp.options.popover, { trigger: 'manual', content: cp.picker, html: true }));
  3413. this.popoverTip = (0, _jquery2.default)(this.popoverTarget.popover('getTipElement').data('bs.popover').tip);
  3414. this.popoverTip.addClass('colorpicker-bs-popover');
  3415. this.popoverTarget.on('shown.bs.popover', _jquery2.default.proxy(this.fireShow, this));
  3416. this.popoverTarget.on('hidden.bs.popover', _jquery2.default.proxy(this.fireHide, this));
  3417. }
  3418. /**
  3419. * If the widget is not inside a container or inline, rearranges its position relative to its element offset.
  3420. *
  3421. * @param {Event} [e]
  3422. * @private
  3423. */
  3424. }, {
  3425. key: 'reposition',
  3426. value: function reposition(e) {
  3427. if (this.popoverTarget && this.isVisible()) {
  3428. this.popoverTarget.popover('update');
  3429. }
  3430. }
  3431. /**
  3432. * Toggles the colorpicker between visible or hidden
  3433. *
  3434. * @fires Colorpicker#colorpickerShow
  3435. * @fires Colorpicker#colorpickerHide
  3436. * @param {Event} [e]
  3437. */
  3438. }, {
  3439. key: 'toggle',
  3440. value: function toggle(e) {
  3441. if (this.isVisible()) {
  3442. this.hide(e);
  3443. } else {
  3444. this.show(e);
  3445. }
  3446. }
  3447. /**
  3448. * Shows the colorpicker widget if hidden.
  3449. *
  3450. * @fires Colorpicker#colorpickerShow
  3451. * @param {Event} [e]
  3452. */
  3453. }, {
  3454. key: 'show',
  3455. value: function show(e) {
  3456. if (this.isVisible() || this.showing || this.hidding) {
  3457. return;
  3458. }
  3459. this.showing = true;
  3460. this.hidding = false;
  3461. this.clicking = false;
  3462. var cp = this.colorpicker;
  3463. cp.lastEvent.alias = 'show';
  3464. cp.lastEvent.e = e;
  3465. // Prevent showing browser native HTML5 colorpicker
  3466. if (e && (!this.hasInput || this.input.attr('type') === 'color') && e && e.preventDefault) {
  3467. e.stopPropagation();
  3468. e.preventDefault();
  3469. }
  3470. // If it's a popover, add event to the document to hide the picker when clicking outside of it
  3471. if (this.isPopover) {
  3472. (0, _jquery2.default)(this.root).on('resize.colorpicker', _jquery2.default.proxy(this.reposition, this));
  3473. }
  3474. // add visible class before popover is shown
  3475. cp.picker.addClass('colorpicker-visible').removeClass('colorpicker-hidden');
  3476. if (this.popoverTarget) {
  3477. this.popoverTarget.popover('show');
  3478. } else {
  3479. this.fireShow();
  3480. }
  3481. }
  3482. }, {
  3483. key: 'fireShow',
  3484. value: function fireShow() {
  3485. this.hidding = false;
  3486. this.showing = false;
  3487. if (this.isPopover) {
  3488. // Add event to hide on outside click
  3489. (0, _jquery2.default)(this.root.document).on('mousedown.colorpicker touchstart.colorpicker', _jquery2.default.proxy(this.hide, this));
  3490. (0, _jquery2.default)(this.root.document).on('mousedown.colorpicker touchstart.colorpicker', _jquery2.default.proxy(this.onClickingInside, this));
  3491. }
  3492. /**
  3493. * (Colorpicker) When show() is called and the widget can be shown.
  3494. *
  3495. * @event Colorpicker#colorpickerShow
  3496. */
  3497. this.colorpicker.trigger('colorpickerShow');
  3498. }
  3499. /**
  3500. * Hides the colorpicker widget.
  3501. * Hide is prevented when it is triggered by an event whose target element has been clicked/touched.
  3502. *
  3503. * @fires Colorpicker#colorpickerHide
  3504. * @param {Event} [e]
  3505. */
  3506. }, {
  3507. key: 'hide',
  3508. value: function hide(e) {
  3509. if (this.isHidden() || this.showing || this.hidding) {
  3510. return;
  3511. }
  3512. var cp = this.colorpicker,
  3513. clicking = this.clicking || this.isClickingInside(e);
  3514. this.hidding = true;
  3515. this.showing = false;
  3516. this.clicking = false;
  3517. cp.lastEvent.alias = 'hide';
  3518. cp.lastEvent.e = e;
  3519. // TODO: fix having to click twice outside when losing focus and last 2 clicks where inside the colorpicker
  3520. // Prevent hide if triggered by an event and an element inside the colorpicker has been clicked/touched
  3521. if (clicking) {
  3522. this.hidding = false;
  3523. return;
  3524. }
  3525. if (this.popoverTarget) {
  3526. this.popoverTarget.popover('hide');
  3527. } else {
  3528. this.fireHide();
  3529. }
  3530. }
  3531. }, {
  3532. key: 'fireHide',
  3533. value: function fireHide() {
  3534. this.hidding = false;
  3535. this.showing = false;
  3536. var cp = this.colorpicker;
  3537. // add hidden class after popover is hidden
  3538. cp.picker.addClass('colorpicker-hidden').removeClass('colorpicker-visible');
  3539. // Unbind window and document events, since there is no need to keep them while the popup is hidden
  3540. (0, _jquery2.default)(this.root).off('resize.colorpicker', _jquery2.default.proxy(this.reposition, this));
  3541. (0, _jquery2.default)(this.root.document).off('mousedown.colorpicker touchstart.colorpicker', _jquery2.default.proxy(this.hide, this));
  3542. (0, _jquery2.default)(this.root.document).off('mousedown.colorpicker touchstart.colorpicker', _jquery2.default.proxy(this.onClickingInside, this));
  3543. /**
  3544. * (Colorpicker) When hide() is called and the widget can be hidden.
  3545. *
  3546. * @event Colorpicker#colorpickerHide
  3547. */
  3548. cp.trigger('colorpickerHide');
  3549. }
  3550. }, {
  3551. key: 'focus',
  3552. value: function focus() {
  3553. if (this.hasAddon) {
  3554. return this.addon.focus();
  3555. }
  3556. if (this.hasInput) {
  3557. return this.input.focus();
  3558. }
  3559. return false;
  3560. }
  3561. /**
  3562. * Returns true if the colorpicker element has the colorpicker-visible class and not the colorpicker-hidden one.
  3563. * False otherwise.
  3564. *
  3565. * @returns {boolean}
  3566. */
  3567. }, {
  3568. key: 'isVisible',
  3569. value: function isVisible() {
  3570. return this.colorpicker.picker.hasClass('colorpicker-visible') && !this.colorpicker.picker.hasClass('colorpicker-hidden');
  3571. }
  3572. /**
  3573. * Returns true if the colorpicker element has the colorpicker-hidden class and not the colorpicker-visible one.
  3574. * False otherwise.
  3575. *
  3576. * @returns {boolean}
  3577. */
  3578. }, {
  3579. key: 'isHidden',
  3580. value: function isHidden() {
  3581. return this.colorpicker.picker.hasClass('colorpicker-hidden') && !this.colorpicker.picker.hasClass('colorpicker-visible');
  3582. }
  3583. }, {
  3584. key: 'input',
  3585. get: function get() {
  3586. return this.colorpicker.inputHandler.input;
  3587. }
  3588. /**
  3589. * @private
  3590. * @returns {boolean}
  3591. */
  3592. }, {
  3593. key: 'hasInput',
  3594. get: function get() {
  3595. return this.colorpicker.inputHandler.hasInput();
  3596. }
  3597. /**
  3598. * @private
  3599. * @returns {jQuery|false}
  3600. */
  3601. }, {
  3602. key: 'addon',
  3603. get: function get() {
  3604. return this.colorpicker.addonHandler.addon;
  3605. }
  3606. /**
  3607. * @private
  3608. * @returns {boolean}
  3609. */
  3610. }, {
  3611. key: 'hasAddon',
  3612. get: function get() {
  3613. return this.colorpicker.addonHandler.hasAddon();
  3614. }
  3615. /**
  3616. * @private
  3617. * @returns {boolean}
  3618. */
  3619. }, {
  3620. key: 'isPopover',
  3621. get: function get() {
  3622. return !this.colorpicker.options.inline && !!this.popoverTip;
  3623. }
  3624. }]);
  3625. return PopupHandler;
  3626. }();
  3627. exports.default = PopupHandler;
  3628. module.exports = exports.default;
  3629. /***/ }),
  3630. /* 15 */
  3631. /***/ (function(module, exports, __webpack_require__) {
  3632. "use strict";
  3633. Object.defineProperty(exports, "__esModule", {
  3634. value: true
  3635. });
  3636. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3637. var _jquery = __webpack_require__(0);
  3638. var _jquery2 = _interopRequireDefault(_jquery);
  3639. var _ColorItem = __webpack_require__(2);
  3640. var _ColorItem2 = _interopRequireDefault(_ColorItem);
  3641. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3642. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3643. /**
  3644. * Handles everything related to the colorpicker input
  3645. * @ignore
  3646. */
  3647. var InputHandler = function () {
  3648. /**
  3649. * @param {Colorpicker} colorpicker
  3650. */
  3651. function InputHandler(colorpicker) {
  3652. _classCallCheck(this, InputHandler);
  3653. /**
  3654. * @type {Colorpicker}
  3655. */
  3656. this.colorpicker = colorpicker;
  3657. /**
  3658. * @type {jQuery|false}
  3659. */
  3660. this.input = this.colorpicker.element.is('input') ? this.colorpicker.element : this.colorpicker.options.input ? this.colorpicker.element.find(this.colorpicker.options.input) : false;
  3661. if (this.input && this.input.length === 0) {
  3662. this.input = false;
  3663. }
  3664. this._initValue();
  3665. }
  3666. _createClass(InputHandler, [{
  3667. key: 'bind',
  3668. value: function bind() {
  3669. if (!this.hasInput()) {
  3670. return;
  3671. }
  3672. this.input.on({
  3673. 'keyup.colorpicker': _jquery2.default.proxy(this.onkeyup, this)
  3674. });
  3675. this.input.on({
  3676. 'change.colorpicker': _jquery2.default.proxy(this.onchange, this)
  3677. });
  3678. }
  3679. }, {
  3680. key: 'unbind',
  3681. value: function unbind() {
  3682. if (!this.hasInput()) {
  3683. return;
  3684. }
  3685. this.input.off('.colorpicker');
  3686. }
  3687. }, {
  3688. key: '_initValue',
  3689. value: function _initValue() {
  3690. if (!this.hasInput()) {
  3691. return;
  3692. }
  3693. var val = '';
  3694. [
  3695. // candidates:
  3696. this.input.val(), this.input.data('color'), this.input.attr('data-color')].map(function (item) {
  3697. if (item && val === '') {
  3698. val = item;
  3699. }
  3700. });
  3701. if (val instanceof _ColorItem2.default) {
  3702. val = this.getFormattedColor(val.string(this.colorpicker.format));
  3703. } else if (!(typeof val === 'string' || val instanceof String)) {
  3704. val = '';
  3705. }
  3706. this.input.prop('value', val);
  3707. }
  3708. /**
  3709. * Returns the color string from the input value.
  3710. * If there is no input the return value is false.
  3711. *
  3712. * @returns {String|boolean}
  3713. */
  3714. }, {
  3715. key: 'getValue',
  3716. value: function getValue() {
  3717. if (!this.hasInput()) {
  3718. return false;
  3719. }
  3720. return this.input.val();
  3721. }
  3722. /**
  3723. * If the input element is present, it updates the value with the current color object color string.
  3724. * If the value is changed, this method fires a "change" event on the input element.
  3725. *
  3726. * @param {String} val
  3727. *
  3728. * @fires Colorpicker#change
  3729. */
  3730. }, {
  3731. key: 'setValue',
  3732. value: function setValue(val) {
  3733. if (!this.hasInput()) {
  3734. return;
  3735. }
  3736. var inputVal = this.input.prop('value');
  3737. val = val ? val : '';
  3738. if (val === (inputVal ? inputVal : '')) {
  3739. // No need to set value or trigger any event if nothing changed
  3740. return;
  3741. }
  3742. this.input.prop('value', val);
  3743. /**
  3744. * (Input) Triggered on the input element when a new color is selected.
  3745. *
  3746. * @event Colorpicker#change
  3747. */
  3748. this.input.trigger({
  3749. type: 'change',
  3750. colorpicker: this.colorpicker,
  3751. color: this.colorpicker.color,
  3752. value: val
  3753. });
  3754. }
  3755. /**
  3756. * Returns the formatted color string, with the formatting options applied
  3757. * (e.g. useHashPrefix)
  3758. *
  3759. * @param {String|null} val
  3760. *
  3761. * @returns {String}
  3762. */
  3763. }, {
  3764. key: 'getFormattedColor',
  3765. value: function getFormattedColor() {
  3766. var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  3767. val = val ? val : this.colorpicker.colorHandler.getColorString();
  3768. if (!val) {
  3769. return '';
  3770. }
  3771. val = this.colorpicker.colorHandler.resolveColorDelegate(val, false);
  3772. if (this.colorpicker.options.useHashPrefix === false) {
  3773. val = val.replace(/^#/g, '');
  3774. }
  3775. return val;
  3776. }
  3777. /**
  3778. * Returns true if the widget has an associated input element, false otherwise
  3779. * @returns {boolean}
  3780. */
  3781. }, {
  3782. key: 'hasInput',
  3783. value: function hasInput() {
  3784. return this.input !== false;
  3785. }
  3786. /**
  3787. * Returns true if the input exists and is disabled
  3788. * @returns {boolean}
  3789. */
  3790. }, {
  3791. key: 'isEnabled',
  3792. value: function isEnabled() {
  3793. return this.hasInput() && !this.isDisabled();
  3794. }
  3795. /**
  3796. * Returns true if the input exists and is disabled
  3797. * @returns {boolean}
  3798. */
  3799. }, {
  3800. key: 'isDisabled',
  3801. value: function isDisabled() {
  3802. return this.hasInput() && this.input.prop('disabled') === true;
  3803. }
  3804. /**
  3805. * Disables the input if any
  3806. *
  3807. * @fires Colorpicker#colorpickerDisable
  3808. * @returns {boolean}
  3809. */
  3810. }, {
  3811. key: 'disable',
  3812. value: function disable() {
  3813. if (this.hasInput()) {
  3814. this.input.prop('disabled', true);
  3815. }
  3816. }
  3817. /**
  3818. * Enables the input if any
  3819. *
  3820. * @fires Colorpicker#colorpickerEnable
  3821. * @returns {boolean}
  3822. */
  3823. }, {
  3824. key: 'enable',
  3825. value: function enable() {
  3826. if (this.hasInput()) {
  3827. this.input.prop('disabled', false);
  3828. }
  3829. }
  3830. /**
  3831. * Calls setValue with the current internal color value
  3832. *
  3833. * @fires Colorpicker#change
  3834. */
  3835. }, {
  3836. key: 'update',
  3837. value: function update() {
  3838. if (!this.hasInput()) {
  3839. return;
  3840. }
  3841. if (this.colorpicker.options.autoInputFallback === false && this.colorpicker.colorHandler.isInvalidColor()) {
  3842. // prevent update if color is invalid, autoInputFallback is disabled and the last event is keyup.
  3843. return;
  3844. }
  3845. this.setValue(this.getFormattedColor());
  3846. }
  3847. /**
  3848. * Function triggered when the input has changed, so the colorpicker gets updated.
  3849. *
  3850. * @private
  3851. * @param {Event} e
  3852. * @returns {boolean}
  3853. */
  3854. }, {
  3855. key: 'onchange',
  3856. value: function onchange(e) {
  3857. this.colorpicker.lastEvent.alias = 'input.change';
  3858. this.colorpicker.lastEvent.e = e;
  3859. var val = this.getValue();
  3860. if (val !== e.value) {
  3861. this.colorpicker.setValue(val);
  3862. }
  3863. }
  3864. /**
  3865. * Function triggered after a keyboard key has been released.
  3866. *
  3867. * @private
  3868. * @param {Event} e
  3869. * @returns {boolean}
  3870. */
  3871. }, {
  3872. key: 'onkeyup',
  3873. value: function onkeyup(e) {
  3874. this.colorpicker.lastEvent.alias = 'input.keyup';
  3875. this.colorpicker.lastEvent.e = e;
  3876. var val = this.getValue();
  3877. if (val !== e.value) {
  3878. this.colorpicker.setValue(val);
  3879. }
  3880. }
  3881. }]);
  3882. return InputHandler;
  3883. }();
  3884. exports.default = InputHandler;
  3885. module.exports = exports.default;
  3886. /***/ }),
  3887. /* 16 */
  3888. /***/ (function(module, exports, __webpack_require__) {
  3889. "use strict";
  3890. var colorString = __webpack_require__(17);
  3891. var convert = __webpack_require__(20);
  3892. var _slice = [].slice;
  3893. var skippedModels = [
  3894. // to be honest, I don't really feel like keyword belongs in color convert, but eh.
  3895. 'keyword',
  3896. // gray conflicts with some method names, and has its own method defined.
  3897. 'gray',
  3898. // shouldn't really be in color-convert either...
  3899. 'hex'
  3900. ];
  3901. var hashedModelKeys = {};
  3902. Object.keys(convert).forEach(function (model) {
  3903. hashedModelKeys[_slice.call(convert[model].labels).sort().join('')] = model;
  3904. });
  3905. var limiters = {};
  3906. function Color(obj, model) {
  3907. if (!(this instanceof Color)) {
  3908. return new Color(obj, model);
  3909. }
  3910. if (model && model in skippedModels) {
  3911. model = null;
  3912. }
  3913. if (model && !(model in convert)) {
  3914. throw new Error('Unknown model: ' + model);
  3915. }
  3916. var i;
  3917. var channels;
  3918. if (obj == null) { // eslint-disable-line no-eq-null,eqeqeq
  3919. this.model = 'rgb';
  3920. this.color = [0, 0, 0];
  3921. this.valpha = 1;
  3922. } else if (obj instanceof Color) {
  3923. this.model = obj.model;
  3924. this.color = obj.color.slice();
  3925. this.valpha = obj.valpha;
  3926. } else if (typeof obj === 'string') {
  3927. var result = colorString.get(obj);
  3928. if (result === null) {
  3929. throw new Error('Unable to parse color from string: ' + obj);
  3930. }
  3931. this.model = result.model;
  3932. channels = convert[this.model].channels;
  3933. this.color = result.value.slice(0, channels);
  3934. this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;
  3935. } else if (obj.length) {
  3936. this.model = model || 'rgb';
  3937. channels = convert[this.model].channels;
  3938. var newArr = _slice.call(obj, 0, channels);
  3939. this.color = zeroArray(newArr, channels);
  3940. this.valpha = typeof obj[channels] === 'number' ? obj[channels] : 1;
  3941. } else if (typeof obj === 'number') {
  3942. // this is always RGB - can be converted later on.
  3943. obj &= 0xFFFFFF;
  3944. this.model = 'rgb';
  3945. this.color = [
  3946. (obj >> 16) & 0xFF,
  3947. (obj >> 8) & 0xFF,
  3948. obj & 0xFF
  3949. ];
  3950. this.valpha = 1;
  3951. } else {
  3952. this.valpha = 1;
  3953. var keys = Object.keys(obj);
  3954. if ('alpha' in obj) {
  3955. keys.splice(keys.indexOf('alpha'), 1);
  3956. this.valpha = typeof obj.alpha === 'number' ? obj.alpha : 0;
  3957. }
  3958. var hashedKeys = keys.sort().join('');
  3959. if (!(hashedKeys in hashedModelKeys)) {
  3960. throw new Error('Unable to parse color from object: ' + JSON.stringify(obj));
  3961. }
  3962. this.model = hashedModelKeys[hashedKeys];
  3963. var labels = convert[this.model].labels;
  3964. var color = [];
  3965. for (i = 0; i < labels.length; i++) {
  3966. color.push(obj[labels[i]]);
  3967. }
  3968. this.color = zeroArray(color);
  3969. }
  3970. // perform limitations (clamping, etc.)
  3971. if (limiters[this.model]) {
  3972. channels = convert[this.model].channels;
  3973. for (i = 0; i < channels; i++) {
  3974. var limit = limiters[this.model][i];
  3975. if (limit) {
  3976. this.color[i] = limit(this.color[i]);
  3977. }
  3978. }
  3979. }
  3980. this.valpha = Math.max(0, Math.min(1, this.valpha));
  3981. if (Object.freeze) {
  3982. Object.freeze(this);
  3983. }
  3984. }
  3985. Color.prototype = {
  3986. toString: function () {
  3987. return this.string();
  3988. },
  3989. toJSON: function () {
  3990. return this[this.model]();
  3991. },
  3992. string: function (places) {
  3993. var self = this.model in colorString.to ? this : this.rgb();
  3994. self = self.round(typeof places === 'number' ? places : 1);
  3995. var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
  3996. return colorString.to[self.model](args);
  3997. },
  3998. percentString: function (places) {
  3999. var self = this.rgb().round(typeof places === 'number' ? places : 1);
  4000. var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
  4001. return colorString.to.rgb.percent(args);
  4002. },
  4003. array: function () {
  4004. return this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);
  4005. },
  4006. object: function () {
  4007. var result = {};
  4008. var channels = convert[this.model].channels;
  4009. var labels = convert[this.model].labels;
  4010. for (var i = 0; i < channels; i++) {
  4011. result[labels[i]] = this.color[i];
  4012. }
  4013. if (this.valpha !== 1) {
  4014. result.alpha = this.valpha;
  4015. }
  4016. return result;
  4017. },
  4018. unitArray: function () {
  4019. var rgb = this.rgb().color;
  4020. rgb[0] /= 255;
  4021. rgb[1] /= 255;
  4022. rgb[2] /= 255;
  4023. if (this.valpha !== 1) {
  4024. rgb.push(this.valpha);
  4025. }
  4026. return rgb;
  4027. },
  4028. unitObject: function () {
  4029. var rgb = this.rgb().object();
  4030. rgb.r /= 255;
  4031. rgb.g /= 255;
  4032. rgb.b /= 255;
  4033. if (this.valpha !== 1) {
  4034. rgb.alpha = this.valpha;
  4035. }
  4036. return rgb;
  4037. },
  4038. round: function (places) {
  4039. places = Math.max(places || 0, 0);
  4040. return new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model);
  4041. },
  4042. alpha: function (val) {
  4043. if (arguments.length) {
  4044. return new Color(this.color.concat(Math.max(0, Math.min(1, val))), this.model);
  4045. }
  4046. return this.valpha;
  4047. },
  4048. // rgb
  4049. red: getset('rgb', 0, maxfn(255)),
  4050. green: getset('rgb', 1, maxfn(255)),
  4051. blue: getset('rgb', 2, maxfn(255)),
  4052. hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, function (val) { return ((val % 360) + 360) % 360; }), // eslint-disable-line brace-style
  4053. saturationl: getset('hsl', 1, maxfn(100)),
  4054. lightness: getset('hsl', 2, maxfn(100)),
  4055. saturationv: getset('hsv', 1, maxfn(100)),
  4056. value: getset('hsv', 2, maxfn(100)),
  4057. chroma: getset('hcg', 1, maxfn(100)),
  4058. gray: getset('hcg', 2, maxfn(100)),
  4059. white: getset('hwb', 1, maxfn(100)),
  4060. wblack: getset('hwb', 2, maxfn(100)),
  4061. cyan: getset('cmyk', 0, maxfn(100)),
  4062. magenta: getset('cmyk', 1, maxfn(100)),
  4063. yellow: getset('cmyk', 2, maxfn(100)),
  4064. black: getset('cmyk', 3, maxfn(100)),
  4065. x: getset('xyz', 0, maxfn(100)),
  4066. y: getset('xyz', 1, maxfn(100)),
  4067. z: getset('xyz', 2, maxfn(100)),
  4068. l: getset('lab', 0, maxfn(100)),
  4069. a: getset('lab', 1),
  4070. b: getset('lab', 2),
  4071. keyword: function (val) {
  4072. if (arguments.length) {
  4073. return new Color(val);
  4074. }
  4075. return convert[this.model].keyword(this.color);
  4076. },
  4077. hex: function (val) {
  4078. if (arguments.length) {
  4079. return new Color(val);
  4080. }
  4081. return colorString.to.hex(this.rgb().round().color);
  4082. },
  4083. rgbNumber: function () {
  4084. var rgb = this.rgb().color;
  4085. return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);
  4086. },
  4087. luminosity: function () {
  4088. // http://www.w3.org/TR/WCAG20/#relativeluminancedef
  4089. var rgb = this.rgb().color;
  4090. var lum = [];
  4091. for (var i = 0; i < rgb.length; i++) {
  4092. var chan = rgb[i] / 255;
  4093. lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);
  4094. }
  4095. return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
  4096. },
  4097. contrast: function (color2) {
  4098. // http://www.w3.org/TR/WCAG20/#contrast-ratiodef
  4099. var lum1 = this.luminosity();
  4100. var lum2 = color2.luminosity();
  4101. if (lum1 > lum2) {
  4102. return (lum1 + 0.05) / (lum2 + 0.05);
  4103. }
  4104. return (lum2 + 0.05) / (lum1 + 0.05);
  4105. },
  4106. level: function (color2) {
  4107. var contrastRatio = this.contrast(color2);
  4108. if (contrastRatio >= 7.1) {
  4109. return 'AAA';
  4110. }
  4111. return (contrastRatio >= 4.5) ? 'AA' : '';
  4112. },
  4113. isDark: function () {
  4114. // YIQ equation from http://24ways.org/2010/calculating-color-contrast
  4115. var rgb = this.rgb().color;
  4116. var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
  4117. return yiq < 128;
  4118. },
  4119. isLight: function () {
  4120. return !this.isDark();
  4121. },
  4122. negate: function () {
  4123. var rgb = this.rgb();
  4124. for (var i = 0; i < 3; i++) {
  4125. rgb.color[i] = 255 - rgb.color[i];
  4126. }
  4127. return rgb;
  4128. },
  4129. lighten: function (ratio) {
  4130. var hsl = this.hsl();
  4131. hsl.color[2] += hsl.color[2] * ratio;
  4132. return hsl;
  4133. },
  4134. darken: function (ratio) {
  4135. var hsl = this.hsl();
  4136. hsl.color[2] -= hsl.color[2] * ratio;
  4137. return hsl;
  4138. },
  4139. saturate: function (ratio) {
  4140. var hsl = this.hsl();
  4141. hsl.color[1] += hsl.color[1] * ratio;
  4142. return hsl;
  4143. },
  4144. desaturate: function (ratio) {
  4145. var hsl = this.hsl();
  4146. hsl.color[1] -= hsl.color[1] * ratio;
  4147. return hsl;
  4148. },
  4149. whiten: function (ratio) {
  4150. var hwb = this.hwb();
  4151. hwb.color[1] += hwb.color[1] * ratio;
  4152. return hwb;
  4153. },
  4154. blacken: function (ratio) {
  4155. var hwb = this.hwb();
  4156. hwb.color[2] += hwb.color[2] * ratio;
  4157. return hwb;
  4158. },
  4159. grayscale: function () {
  4160. // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
  4161. var rgb = this.rgb().color;
  4162. var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
  4163. return Color.rgb(val, val, val);
  4164. },
  4165. fade: function (ratio) {
  4166. return this.alpha(this.valpha - (this.valpha * ratio));
  4167. },
  4168. opaquer: function (ratio) {
  4169. return this.alpha(this.valpha + (this.valpha * ratio));
  4170. },
  4171. rotate: function (degrees) {
  4172. var hsl = this.hsl();
  4173. var hue = hsl.color[0];
  4174. hue = (hue + degrees) % 360;
  4175. hue = hue < 0 ? 360 + hue : hue;
  4176. hsl.color[0] = hue;
  4177. return hsl;
  4178. },
  4179. mix: function (mixinColor, weight) {
  4180. // ported from sass implementation in C
  4181. // https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
  4182. if (!mixinColor || !mixinColor.rgb) {
  4183. throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
  4184. }
  4185. var color1 = mixinColor.rgb();
  4186. var color2 = this.rgb();
  4187. var p = weight === undefined ? 0.5 : weight;
  4188. var w = 2 * p - 1;
  4189. var a = color1.alpha() - color2.alpha();
  4190. var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
  4191. var w2 = 1 - w1;
  4192. return Color.rgb(
  4193. w1 * color1.red() + w2 * color2.red(),
  4194. w1 * color1.green() + w2 * color2.green(),
  4195. w1 * color1.blue() + w2 * color2.blue(),
  4196. color1.alpha() * p + color2.alpha() * (1 - p));
  4197. }
  4198. };
  4199. // model conversion methods and static constructors
  4200. Object.keys(convert).forEach(function (model) {
  4201. if (skippedModels.indexOf(model) !== -1) {
  4202. return;
  4203. }
  4204. var channels = convert[model].channels;
  4205. // conversion methods
  4206. Color.prototype[model] = function () {
  4207. if (this.model === model) {
  4208. return new Color(this);
  4209. }
  4210. if (arguments.length) {
  4211. return new Color(arguments, model);
  4212. }
  4213. var newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha;
  4214. return new Color(assertArray(convert[this.model][model].raw(this.color)).concat(newAlpha), model);
  4215. };
  4216. // 'static' construction methods
  4217. Color[model] = function (color) {
  4218. if (typeof color === 'number') {
  4219. color = zeroArray(_slice.call(arguments), channels);
  4220. }
  4221. return new Color(color, model);
  4222. };
  4223. });
  4224. function roundTo(num, places) {
  4225. return Number(num.toFixed(places));
  4226. }
  4227. function roundToPlace(places) {
  4228. return function (num) {
  4229. return roundTo(num, places);
  4230. };
  4231. }
  4232. function getset(model, channel, modifier) {
  4233. model = Array.isArray(model) ? model : [model];
  4234. model.forEach(function (m) {
  4235. (limiters[m] || (limiters[m] = []))[channel] = modifier;
  4236. });
  4237. model = model[0];
  4238. return function (val) {
  4239. var result;
  4240. if (arguments.length) {
  4241. if (modifier) {
  4242. val = modifier(val);
  4243. }
  4244. result = this[model]();
  4245. result.color[channel] = val;
  4246. return result;
  4247. }
  4248. result = this[model]().color[channel];
  4249. if (modifier) {
  4250. result = modifier(result);
  4251. }
  4252. return result;
  4253. };
  4254. }
  4255. function maxfn(max) {
  4256. return function (v) {
  4257. return Math.max(0, Math.min(max, v));
  4258. };
  4259. }
  4260. function assertArray(val) {
  4261. return Array.isArray(val) ? val : [val];
  4262. }
  4263. function zeroArray(arr, length) {
  4264. for (var i = 0; i < length; i++) {
  4265. if (typeof arr[i] !== 'number') {
  4266. arr[i] = 0;
  4267. }
  4268. }
  4269. return arr;
  4270. }
  4271. module.exports = Color;
  4272. /***/ }),
  4273. /* 17 */
  4274. /***/ (function(module, exports, __webpack_require__) {
  4275. /* MIT license */
  4276. var colorNames = __webpack_require__(5);
  4277. var swizzle = __webpack_require__(18);
  4278. var reverseNames = {};
  4279. // create a list of reverse color names
  4280. for (var name in colorNames) {
  4281. if (colorNames.hasOwnProperty(name)) {
  4282. reverseNames[colorNames[name]] = name;
  4283. }
  4284. }
  4285. var cs = module.exports = {
  4286. to: {},
  4287. get: {}
  4288. };
  4289. cs.get = function (string) {
  4290. var prefix = string.substring(0, 3).toLowerCase();
  4291. var val;
  4292. var model;
  4293. switch (prefix) {
  4294. case 'hsl':
  4295. val = cs.get.hsl(string);
  4296. model = 'hsl';
  4297. break;
  4298. case 'hwb':
  4299. val = cs.get.hwb(string);
  4300. model = 'hwb';
  4301. break;
  4302. default:
  4303. val = cs.get.rgb(string);
  4304. model = 'rgb';
  4305. break;
  4306. }
  4307. if (!val) {
  4308. return null;
  4309. }
  4310. return {model: model, value: val};
  4311. };
  4312. cs.get.rgb = function (string) {
  4313. if (!string) {
  4314. return null;
  4315. }
  4316. var abbr = /^#([a-f0-9]{3,4})$/i;
  4317. var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
  4318. var rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
  4319. var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
  4320. var keyword = /(\D+)/;
  4321. var rgb = [0, 0, 0, 1];
  4322. var match;
  4323. var i;
  4324. var hexAlpha;
  4325. if (match = string.match(hex)) {
  4326. hexAlpha = match[2];
  4327. match = match[1];
  4328. for (i = 0; i < 3; i++) {
  4329. // https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
  4330. var i2 = i * 2;
  4331. rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
  4332. }
  4333. if (hexAlpha) {
  4334. rgb[3] = Math.round((parseInt(hexAlpha, 16) / 255) * 100) / 100;
  4335. }
  4336. } else if (match = string.match(abbr)) {
  4337. match = match[1];
  4338. hexAlpha = match[3];
  4339. for (i = 0; i < 3; i++) {
  4340. rgb[i] = parseInt(match[i] + match[i], 16);
  4341. }
  4342. if (hexAlpha) {
  4343. rgb[3] = Math.round((parseInt(hexAlpha + hexAlpha, 16) / 255) * 100) / 100;
  4344. }
  4345. } else if (match = string.match(rgba)) {
  4346. for (i = 0; i < 3; i++) {
  4347. rgb[i] = parseInt(match[i + 1], 0);
  4348. }
  4349. if (match[4]) {
  4350. rgb[3] = parseFloat(match[4]);
  4351. }
  4352. } else if (match = string.match(per)) {
  4353. for (i = 0; i < 3; i++) {
  4354. rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
  4355. }
  4356. if (match[4]) {
  4357. rgb[3] = parseFloat(match[4]);
  4358. }
  4359. } else if (match = string.match(keyword)) {
  4360. if (match[1] === 'transparent') {
  4361. return [0, 0, 0, 0];
  4362. }
  4363. rgb = colorNames[match[1]];
  4364. if (!rgb) {
  4365. return null;
  4366. }
  4367. rgb[3] = 1;
  4368. return rgb;
  4369. } else {
  4370. return null;
  4371. }
  4372. for (i = 0; i < 3; i++) {
  4373. rgb[i] = clamp(rgb[i], 0, 255);
  4374. }
  4375. rgb[3] = clamp(rgb[3], 0, 1);
  4376. return rgb;
  4377. };
  4378. cs.get.hsl = function (string) {
  4379. if (!string) {
  4380. return null;
  4381. }
  4382. var hsl = /^hsla?\(\s*([+-]?(?:\d*\.)?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
  4383. var match = string.match(hsl);
  4384. if (match) {
  4385. var alpha = parseFloat(match[4]);
  4386. var h = (parseFloat(match[1]) + 360) % 360;
  4387. var s = clamp(parseFloat(match[2]), 0, 100);
  4388. var l = clamp(parseFloat(match[3]), 0, 100);
  4389. var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
  4390. return [h, s, l, a];
  4391. }
  4392. return null;
  4393. };
  4394. cs.get.hwb = function (string) {
  4395. if (!string) {
  4396. return null;
  4397. }
  4398. var hwb = /^hwb\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
  4399. var match = string.match(hwb);
  4400. if (match) {
  4401. var alpha = parseFloat(match[4]);
  4402. var h = ((parseFloat(match[1]) % 360) + 360) % 360;
  4403. var w = clamp(parseFloat(match[2]), 0, 100);
  4404. var b = clamp(parseFloat(match[3]), 0, 100);
  4405. var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
  4406. return [h, w, b, a];
  4407. }
  4408. return null;
  4409. };
  4410. cs.to.hex = function () {
  4411. var rgba = swizzle(arguments);
  4412. return (
  4413. '#' +
  4414. hexDouble(rgba[0]) +
  4415. hexDouble(rgba[1]) +
  4416. hexDouble(rgba[2]) +
  4417. (rgba[3] < 1
  4418. ? (hexDouble(Math.round(rgba[3] * 255)))
  4419. : '')
  4420. );
  4421. };
  4422. cs.to.rgb = function () {
  4423. var rgba = swizzle(arguments);
  4424. return rgba.length < 4 || rgba[3] === 1
  4425. ? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
  4426. : 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
  4427. };
  4428. cs.to.rgb.percent = function () {
  4429. var rgba = swizzle(arguments);
  4430. var r = Math.round(rgba[0] / 255 * 100);
  4431. var g = Math.round(rgba[1] / 255 * 100);
  4432. var b = Math.round(rgba[2] / 255 * 100);
  4433. return rgba.length < 4 || rgba[3] === 1
  4434. ? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
  4435. : 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
  4436. };
  4437. cs.to.hsl = function () {
  4438. var hsla = swizzle(arguments);
  4439. return hsla.length < 4 || hsla[3] === 1
  4440. ? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
  4441. : 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
  4442. };
  4443. // hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
  4444. // (hwb have alpha optional & 1 is default value)
  4445. cs.to.hwb = function () {
  4446. var hwba = swizzle(arguments);
  4447. var a = '';
  4448. if (hwba.length >= 4 && hwba[3] !== 1) {
  4449. a = ', ' + hwba[3];
  4450. }
  4451. return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
  4452. };
  4453. cs.to.keyword = function (rgb) {
  4454. return reverseNames[rgb.slice(0, 3)];
  4455. };
  4456. // helpers
  4457. function clamp(num, min, max) {
  4458. return Math.min(Math.max(min, num), max);
  4459. }
  4460. function hexDouble(num) {
  4461. var str = num.toString(16).toUpperCase();
  4462. return (str.length < 2) ? '0' + str : str;
  4463. }
  4464. /***/ }),
  4465. /* 18 */
  4466. /***/ (function(module, exports, __webpack_require__) {
  4467. "use strict";
  4468. var isArrayish = __webpack_require__(19);
  4469. var concat = Array.prototype.concat;
  4470. var slice = Array.prototype.slice;
  4471. var swizzle = module.exports = function swizzle(args) {
  4472. var results = [];
  4473. for (var i = 0, len = args.length; i < len; i++) {
  4474. var arg = args[i];
  4475. if (isArrayish(arg)) {
  4476. // http://jsperf.com/javascript-array-concat-vs-push/98
  4477. results = concat.call(results, slice.call(arg));
  4478. } else {
  4479. results.push(arg);
  4480. }
  4481. }
  4482. return results;
  4483. };
  4484. swizzle.wrap = function (fn) {
  4485. return function () {
  4486. return fn(swizzle(arguments));
  4487. };
  4488. };
  4489. /***/ }),
  4490. /* 19 */
  4491. /***/ (function(module, exports, __webpack_require__) {
  4492. "use strict";
  4493. module.exports = function isArrayish(obj) {
  4494. if (!obj) {
  4495. return false;
  4496. }
  4497. return obj instanceof Array || Array.isArray(obj) ||
  4498. (obj.length >= 0 && obj.splice instanceof Function);
  4499. };
  4500. /***/ }),
  4501. /* 20 */
  4502. /***/ (function(module, exports, __webpack_require__) {
  4503. var conversions = __webpack_require__(6);
  4504. var route = __webpack_require__(21);
  4505. var convert = {};
  4506. var models = Object.keys(conversions);
  4507. function wrapRaw(fn) {
  4508. var wrappedFn = function (args) {
  4509. if (args === undefined || args === null) {
  4510. return args;
  4511. }
  4512. if (arguments.length > 1) {
  4513. args = Array.prototype.slice.call(arguments);
  4514. }
  4515. return fn(args);
  4516. };
  4517. // preserve .conversion property if there is one
  4518. if ('conversion' in fn) {
  4519. wrappedFn.conversion = fn.conversion;
  4520. }
  4521. return wrappedFn;
  4522. }
  4523. function wrapRounded(fn) {
  4524. var wrappedFn = function (args) {
  4525. if (args === undefined || args === null) {
  4526. return args;
  4527. }
  4528. if (arguments.length > 1) {
  4529. args = Array.prototype.slice.call(arguments);
  4530. }
  4531. var result = fn(args);
  4532. // we're assuming the result is an array here.
  4533. // see notice in conversions.js; don't use box types
  4534. // in conversion functions.
  4535. if (typeof result === 'object') {
  4536. for (var len = result.length, i = 0; i < len; i++) {
  4537. result[i] = Math.round(result[i]);
  4538. }
  4539. }
  4540. return result;
  4541. };
  4542. // preserve .conversion property if there is one
  4543. if ('conversion' in fn) {
  4544. wrappedFn.conversion = fn.conversion;
  4545. }
  4546. return wrappedFn;
  4547. }
  4548. models.forEach(function (fromModel) {
  4549. convert[fromModel] = {};
  4550. Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
  4551. Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
  4552. var routes = route(fromModel);
  4553. var routeModels = Object.keys(routes);
  4554. routeModels.forEach(function (toModel) {
  4555. var fn = routes[toModel];
  4556. convert[fromModel][toModel] = wrapRounded(fn);
  4557. convert[fromModel][toModel].raw = wrapRaw(fn);
  4558. });
  4559. });
  4560. module.exports = convert;
  4561. /***/ }),
  4562. /* 21 */
  4563. /***/ (function(module, exports, __webpack_require__) {
  4564. var conversions = __webpack_require__(6);
  4565. /*
  4566. this function routes a model to all other models.
  4567. all functions that are routed have a property `.conversion` attached
  4568. to the returned synthetic function. This property is an array
  4569. of strings, each with the steps in between the 'from' and 'to'
  4570. color models (inclusive).
  4571. conversions that are not possible simply are not included.
  4572. */
  4573. function buildGraph() {
  4574. var graph = {};
  4575. // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  4576. var models = Object.keys(conversions);
  4577. for (var len = models.length, i = 0; i < len; i++) {
  4578. graph[models[i]] = {
  4579. // http://jsperf.com/1-vs-infinity
  4580. // micro-opt, but this is simple.
  4581. distance: -1,
  4582. parent: null
  4583. };
  4584. }
  4585. return graph;
  4586. }
  4587. // https://en.wikipedia.org/wiki/Breadth-first_search
  4588. function deriveBFS(fromModel) {
  4589. var graph = buildGraph();
  4590. var queue = [fromModel]; // unshift -> queue -> pop
  4591. graph[fromModel].distance = 0;
  4592. while (queue.length) {
  4593. var current = queue.pop();
  4594. var adjacents = Object.keys(conversions[current]);
  4595. for (var len = adjacents.length, i = 0; i < len; i++) {
  4596. var adjacent = adjacents[i];
  4597. var node = graph[adjacent];
  4598. if (node.distance === -1) {
  4599. node.distance = graph[current].distance + 1;
  4600. node.parent = current;
  4601. queue.unshift(adjacent);
  4602. }
  4603. }
  4604. }
  4605. return graph;
  4606. }
  4607. function link(from, to) {
  4608. return function (args) {
  4609. return to(from(args));
  4610. };
  4611. }
  4612. function wrapConversion(toModel, graph) {
  4613. var path = [graph[toModel].parent, toModel];
  4614. var fn = conversions[graph[toModel].parent][toModel];
  4615. var cur = graph[toModel].parent;
  4616. while (graph[cur].parent) {
  4617. path.unshift(graph[cur].parent);
  4618. fn = link(conversions[graph[cur].parent][cur], fn);
  4619. cur = graph[cur].parent;
  4620. }
  4621. fn.conversion = path;
  4622. return fn;
  4623. }
  4624. module.exports = function (fromModel) {
  4625. var graph = deriveBFS(fromModel);
  4626. var conversion = {};
  4627. var models = Object.keys(graph);
  4628. for (var len = models.length, i = 0; i < len; i++) {
  4629. var toModel = models[i];
  4630. var node = graph[toModel];
  4631. if (node.parent === null) {
  4632. // no possible conversion, or this node is the source model.
  4633. continue;
  4634. }
  4635. conversion[toModel] = wrapConversion(toModel, graph);
  4636. }
  4637. return conversion;
  4638. };
  4639. /***/ }),
  4640. /* 22 */
  4641. /***/ (function(module, exports, __webpack_require__) {
  4642. "use strict";
  4643. Object.defineProperty(exports, "__esModule", {
  4644. value: true
  4645. });
  4646. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4647. var _jquery = __webpack_require__(0);
  4648. var _jquery2 = _interopRequireDefault(_jquery);
  4649. var _ColorItem = __webpack_require__(2);
  4650. var _ColorItem2 = _interopRequireDefault(_ColorItem);
  4651. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4652. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4653. /**
  4654. * Handles everything related to the colorpicker color
  4655. * @ignore
  4656. */
  4657. var ColorHandler = function () {
  4658. /**
  4659. * @param {Colorpicker} colorpicker
  4660. */
  4661. function ColorHandler(colorpicker) {
  4662. _classCallCheck(this, ColorHandler);
  4663. /**
  4664. * @type {Colorpicker}
  4665. */
  4666. this.colorpicker = colorpicker;
  4667. }
  4668. /**
  4669. * @returns {*|String|ColorItem}
  4670. */
  4671. _createClass(ColorHandler, [{
  4672. key: 'bind',
  4673. value: function bind() {
  4674. // if the color option is set
  4675. if (this.colorpicker.options.color) {
  4676. this.color = this.createColor(this.colorpicker.options.color);
  4677. return;
  4678. }
  4679. // if element[color] is empty and the input has a value
  4680. if (!this.color && !!this.colorpicker.inputHandler.getValue()) {
  4681. this.color = this.createColor(this.colorpicker.inputHandler.getValue(), this.colorpicker.options.autoInputFallback);
  4682. }
  4683. }
  4684. }, {
  4685. key: 'unbind',
  4686. value: function unbind() {
  4687. this.colorpicker.element.removeData('color');
  4688. }
  4689. /**
  4690. * Returns the color string from the input value or the 'data-color' attribute of the input or element.
  4691. * If empty, it returns the defaultValue parameter.
  4692. *
  4693. * @returns {String|*}
  4694. */
  4695. }, {
  4696. key: 'getColorString',
  4697. value: function getColorString() {
  4698. if (!this.hasColor()) {
  4699. return '';
  4700. }
  4701. return this.color.string(this.format);
  4702. }
  4703. /**
  4704. * Sets the color value
  4705. *
  4706. * @param {String|ColorItem} val
  4707. */
  4708. }, {
  4709. key: 'setColorString',
  4710. value: function setColorString(val) {
  4711. var color = val ? this.createColor(val) : null;
  4712. this.color = color ? color : null;
  4713. }
  4714. /**
  4715. * Creates a new color using the widget instance options (fallbackColor, format).
  4716. *
  4717. * @fires Colorpicker#colorpickerInvalid
  4718. * @param {*} val
  4719. * @param {boolean} fallbackOnInvalid
  4720. * @returns {ColorItem}
  4721. */
  4722. }, {
  4723. key: 'createColor',
  4724. value: function createColor(val) {
  4725. var fallbackOnInvalid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  4726. var color = new _ColorItem2.default(this.resolveColorDelegate(val), this.format);
  4727. if (!color.isValid()) {
  4728. if (fallbackOnInvalid) {
  4729. color = this.getFallbackColor();
  4730. }
  4731. /**
  4732. * (Colorpicker) Fired when the color is invalid and the fallback color is going to be used.
  4733. *
  4734. * @event Colorpicker#colorpickerInvalid
  4735. */
  4736. this.colorpicker.trigger('colorpickerInvalid', color, val);
  4737. }
  4738. if (!this.isAlphaEnabled()) {
  4739. // Alpha is disabled
  4740. color.alpha = 1;
  4741. }
  4742. return color;
  4743. }
  4744. }, {
  4745. key: 'getFallbackColor',
  4746. value: function getFallbackColor() {
  4747. if (this.fallback && this.fallback === this.color) {
  4748. return this.color;
  4749. }
  4750. var fallback = this.resolveColorDelegate(this.fallback);
  4751. var color = new _ColorItem2.default(fallback, this.format);
  4752. if (!color.isValid()) {
  4753. console.warn('The fallback color is invalid. Falling back to the previous color or black if any.');
  4754. return this.color ? this.color : new _ColorItem2.default('#000000', this.format);
  4755. }
  4756. return color;
  4757. }
  4758. /**
  4759. * @returns {ColorItem}
  4760. */
  4761. }, {
  4762. key: 'assureColor',
  4763. value: function assureColor() {
  4764. if (!this.hasColor()) {
  4765. this.color = this.getFallbackColor();
  4766. }
  4767. return this.color;
  4768. }
  4769. /**
  4770. * Delegates the color resolution to the colorpicker extensions.
  4771. *
  4772. * @param {String|*} color
  4773. * @param {boolean} realColor if true, the color should resolve into a real (not named) color code
  4774. * @returns {ColorItem|String|*|null}
  4775. */
  4776. }, {
  4777. key: 'resolveColorDelegate',
  4778. value: function resolveColorDelegate(color) {
  4779. var realColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  4780. var extResolvedColor = false;
  4781. _jquery2.default.each(this.colorpicker.extensions, function (name, ext) {
  4782. if (extResolvedColor !== false) {
  4783. // skip if resolved
  4784. return;
  4785. }
  4786. extResolvedColor = ext.resolveColor(color, realColor);
  4787. });
  4788. return extResolvedColor ? extResolvedColor : color;
  4789. }
  4790. /**
  4791. * Checks if there is a color object, that it is valid and it is not a fallback
  4792. * @returns {boolean}
  4793. */
  4794. }, {
  4795. key: 'isInvalidColor',
  4796. value: function isInvalidColor() {
  4797. return !this.hasColor() || !this.color.isValid();
  4798. }
  4799. /**
  4800. * Returns true if the useAlpha option is exactly true, false otherwise
  4801. * @returns {boolean}
  4802. */
  4803. }, {
  4804. key: 'isAlphaEnabled',
  4805. value: function isAlphaEnabled() {
  4806. return this.colorpicker.options.useAlpha !== false;
  4807. }
  4808. /**
  4809. * Returns true if the current color object is an instance of Color, false otherwise.
  4810. * @returns {boolean}
  4811. */
  4812. }, {
  4813. key: 'hasColor',
  4814. value: function hasColor() {
  4815. return this.color instanceof _ColorItem2.default;
  4816. }
  4817. }, {
  4818. key: 'fallback',
  4819. get: function get() {
  4820. return this.colorpicker.options.fallbackColor ? this.colorpicker.options.fallbackColor : this.hasColor() ? this.color : null;
  4821. }
  4822. /**
  4823. * @returns {String|null}
  4824. */
  4825. }, {
  4826. key: 'format',
  4827. get: function get() {
  4828. if (this.colorpicker.options.format) {
  4829. return this.colorpicker.options.format;
  4830. }
  4831. if (this.hasColor() && this.color.hasTransparency() && this.color.format.match(/^hex/)) {
  4832. return this.isAlphaEnabled() ? 'rgba' : 'hex';
  4833. }
  4834. if (this.hasColor()) {
  4835. return this.color.format;
  4836. }
  4837. return 'rgb';
  4838. }
  4839. /**
  4840. * Internal color getter
  4841. *
  4842. * @type {ColorItem|null}
  4843. */
  4844. }, {
  4845. key: 'color',
  4846. get: function get() {
  4847. return this.colorpicker.element.data('color');
  4848. }
  4849. /**
  4850. * Internal color setter
  4851. *
  4852. * @ignore
  4853. * @param {ColorItem|null} value
  4854. */
  4855. ,
  4856. set: function set(value) {
  4857. this.colorpicker.element.data('color', value);
  4858. if (value instanceof _ColorItem2.default && this.colorpicker.options.format === 'auto') {
  4859. // If format is 'auto', use the first parsed one from now on
  4860. this.colorpicker.options.format = this.color.format;
  4861. }
  4862. }
  4863. }]);
  4864. return ColorHandler;
  4865. }();
  4866. exports.default = ColorHandler;
  4867. module.exports = exports.default;
  4868. /***/ }),
  4869. /* 23 */
  4870. /***/ (function(module, exports, __webpack_require__) {
  4871. "use strict";
  4872. Object.defineProperty(exports, "__esModule", {
  4873. value: true
  4874. });
  4875. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4876. var _jquery = __webpack_require__(0);
  4877. var _jquery2 = _interopRequireDefault(_jquery);
  4878. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4879. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4880. /**
  4881. * Handles everything related to the colorpicker UI
  4882. * @ignore
  4883. */
  4884. var PickerHandler = function () {
  4885. /**
  4886. * @param {Colorpicker} colorpicker
  4887. */
  4888. function PickerHandler(colorpicker) {
  4889. _classCallCheck(this, PickerHandler);
  4890. /**
  4891. * @type {Colorpicker}
  4892. */
  4893. this.colorpicker = colorpicker;
  4894. /**
  4895. * @type {jQuery}
  4896. */
  4897. this.picker = null;
  4898. }
  4899. _createClass(PickerHandler, [{
  4900. key: 'bind',
  4901. value: function bind() {
  4902. /**
  4903. * @type {jQuery|HTMLElement}
  4904. */
  4905. var picker = this.picker = (0, _jquery2.default)(this.options.template);
  4906. if (this.options.customClass) {
  4907. picker.addClass(this.options.customClass);
  4908. }
  4909. if (this.options.horizontal) {
  4910. picker.addClass('colorpicker-horizontal');
  4911. }
  4912. if (this._supportsAlphaBar()) {
  4913. this.options.useAlpha = true;
  4914. picker.addClass('colorpicker-with-alpha');
  4915. } else {
  4916. this.options.useAlpha = false;
  4917. }
  4918. }
  4919. }, {
  4920. key: 'attach',
  4921. value: function attach() {
  4922. // Inject the colorpicker element into the DOM
  4923. var pickerParent = this.colorpicker.container ? this.colorpicker.container : null;
  4924. if (pickerParent) {
  4925. this.picker.appendTo(pickerParent);
  4926. }
  4927. }
  4928. }, {
  4929. key: 'unbind',
  4930. value: function unbind() {
  4931. this.picker.remove();
  4932. }
  4933. }, {
  4934. key: '_supportsAlphaBar',
  4935. value: function _supportsAlphaBar() {
  4936. return (this.options.useAlpha || this.colorpicker.colorHandler.hasColor() && this.color.hasTransparency()) && this.options.useAlpha !== false && (!this.options.format || this.options.format && !this.options.format.match(/^hex([36])?$/i));
  4937. }
  4938. /**
  4939. * Changes the color adjustment bars using the current color object information.
  4940. */
  4941. }, {
  4942. key: 'update',
  4943. value: function update() {
  4944. if (!this.colorpicker.colorHandler.hasColor()) {
  4945. return;
  4946. }
  4947. var vertical = this.options.horizontal !== true,
  4948. slider = vertical ? this.options.sliders : this.options.slidersHorz;
  4949. var saturationGuide = this.picker.find('.colorpicker-saturation .colorpicker-guide'),
  4950. hueGuide = this.picker.find('.colorpicker-hue .colorpicker-guide'),
  4951. alphaGuide = this.picker.find('.colorpicker-alpha .colorpicker-guide');
  4952. var hsva = this.color.toHsvaRatio();
  4953. // Set guides position
  4954. if (hueGuide.length) {
  4955. hueGuide.css(vertical ? 'top' : 'left', (vertical ? slider.hue.maxTop : slider.hue.maxLeft) * (1 - hsva.h));
  4956. }
  4957. if (alphaGuide.length) {
  4958. alphaGuide.css(vertical ? 'top' : 'left', (vertical ? slider.alpha.maxTop : slider.alpha.maxLeft) * (1 - hsva.a));
  4959. }
  4960. if (saturationGuide.length) {
  4961. saturationGuide.css({
  4962. 'top': slider.saturation.maxTop - hsva.v * slider.saturation.maxTop,
  4963. 'left': hsva.s * slider.saturation.maxLeft
  4964. });
  4965. }
  4966. // Set saturation hue background
  4967. this.picker.find('.colorpicker-saturation').css('backgroundColor', this.color.getCloneHueOnly().toHexString()); // we only need hue
  4968. // Set alpha color gradient
  4969. var hexColor = this.color.toHexString();
  4970. var alphaBg = '';
  4971. if (this.options.horizontal) {
  4972. alphaBg = 'linear-gradient(to right, ' + hexColor + ' 0%, transparent 100%)';
  4973. } else {
  4974. alphaBg = 'linear-gradient(to bottom, ' + hexColor + ' 0%, transparent 100%)';
  4975. }
  4976. this.picker.find('.colorpicker-alpha-color').css('background', alphaBg);
  4977. }
  4978. }, {
  4979. key: 'options',
  4980. get: function get() {
  4981. return this.colorpicker.options;
  4982. }
  4983. }, {
  4984. key: 'color',
  4985. get: function get() {
  4986. return this.colorpicker.colorHandler.color;
  4987. }
  4988. }]);
  4989. return PickerHandler;
  4990. }();
  4991. exports.default = PickerHandler;
  4992. module.exports = exports.default;
  4993. /***/ }),
  4994. /* 24 */
  4995. /***/ (function(module, exports, __webpack_require__) {
  4996. "use strict";
  4997. /**
  4998. * Handles everything related to the colorpicker addon
  4999. * @ignore
  5000. */
  5001. Object.defineProperty(exports, "__esModule", {
  5002. value: true
  5003. });
  5004. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5005. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5006. var AddonHandler = function () {
  5007. /**
  5008. * @param {Colorpicker} colorpicker
  5009. */
  5010. function AddonHandler(colorpicker) {
  5011. _classCallCheck(this, AddonHandler);
  5012. /**
  5013. * @type {Colorpicker}
  5014. */
  5015. this.colorpicker = colorpicker;
  5016. /**
  5017. * @type {jQuery}
  5018. */
  5019. this.addon = null;
  5020. }
  5021. _createClass(AddonHandler, [{
  5022. key: 'hasAddon',
  5023. value: function hasAddon() {
  5024. return !!this.addon;
  5025. }
  5026. }, {
  5027. key: 'bind',
  5028. value: function bind() {
  5029. /**
  5030. * @type {*|jQuery}
  5031. */
  5032. this.addon = this.colorpicker.options.addon ? this.colorpicker.element.find(this.colorpicker.options.addon) : null;
  5033. if (this.addon && this.addon.length === 0) {
  5034. // not found
  5035. this.addon = null;
  5036. }
  5037. }
  5038. }, {
  5039. key: 'unbind',
  5040. value: function unbind() {
  5041. if (this.hasAddon()) {
  5042. this.addon.off('.colorpicker');
  5043. }
  5044. }
  5045. /**
  5046. * If the addon element is present, its background color is updated
  5047. */
  5048. }, {
  5049. key: 'update',
  5050. value: function update() {
  5051. if (!this.colorpicker.colorHandler.hasColor() || !this.hasAddon()) {
  5052. return;
  5053. }
  5054. var colorStr = this.colorpicker.colorHandler.getColorString();
  5055. var styles = { 'background': colorStr };
  5056. var icn = this.addon.find('i').eq(0);
  5057. if (icn.length > 0) {
  5058. icn.css(styles);
  5059. } else {
  5060. this.addon.css(styles);
  5061. }
  5062. }
  5063. }]);
  5064. return AddonHandler;
  5065. }();
  5066. exports.default = AddonHandler;
  5067. module.exports = exports.default;
  5068. /***/ })
  5069. /******/ ]);
  5070. });
  5071. //# sourceMappingURL=bootstrap-colorpicker.js.map