bootstrap-colorpicker.js 158 KB

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