admin.min.js 516 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273
  1. var Grav;
  2. /******/ (() => { // webpackBootstrap
  3. /******/ var __webpack_modules__ = ({
  4. /***/ 56299:
  5. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6. "use strict";
  7. // ESM COMPAT FLAG
  8. __webpack_require__.r(__webpack_exports__);
  9. // EXPORTS
  10. __webpack_require__.d(__webpack_exports__, {
  11. "default": () => (/* binding */ main)
  12. });
  13. // EXTERNAL MODULE: ./node_modules/@babel/polyfill/lib/index.js
  14. var lib = __webpack_require__(26981);
  15. // EXTERNAL MODULE: external "jQuery"
  16. var external_jQuery_ = __webpack_require__(65311);
  17. var external_jQuery_default = /*#__PURE__*/__webpack_require__.n(external_jQuery_);
  18. ;// CONCATENATED MODULE: ./app/utils/remodal.js
  19. /* Remodal from https://github.com/vodkabears/Remodal
  20. * With Stackable option from https://github.com/antstorm/Remodal patch
  21. */
  22. !function (root, factory) {
  23. return factory(root, (external_jQuery_default()));
  24. }(undefined, function (global, $) {
  25. 'use strict';
  26. /**
  27. * Name of the plugin
  28. * @private
  29. * @const
  30. * @type {String}
  31. */
  32. var PLUGIN_NAME = 'remodal';
  33. /**
  34. * Namespace for CSS and events
  35. * @private
  36. * @const
  37. * @type {String}
  38. */
  39. var NAMESPACE = window.REMODAL_GLOBALS && window.REMODAL_GLOBALS.NAMESPACE || PLUGIN_NAME;
  40. /**
  41. * Animationstart event with vendor prefixes
  42. * @private
  43. * @const
  44. * @type {String}
  45. */
  46. var ANIMATIONSTART_EVENTS = $.map(['animationstart', 'webkitAnimationStart', 'MSAnimationStart', 'oAnimationStart'], function (eventName) {
  47. return eventName + '.' + NAMESPACE;
  48. }).join(' ');
  49. /**
  50. * Animationend event with vendor prefixes
  51. * @private
  52. * @const
  53. * @type {String}
  54. */
  55. var ANIMATIONEND_EVENTS = $.map(['animationend', 'webkitAnimationEnd', 'MSAnimationEnd', 'oAnimationEnd'], function (eventName) {
  56. return eventName + '.' + NAMESPACE;
  57. }).join(' ');
  58. /**
  59. * Default settings
  60. * @private
  61. * @const
  62. * @type {Object}
  63. */
  64. var DEFAULTS = $.extend({
  65. hashTracking: true,
  66. closeOnConfirm: true,
  67. closeOnCancel: true,
  68. closeOnEscape: true,
  69. closeOnOutsideClick: true,
  70. modifier: '',
  71. stack: false,
  72. appendTo: null
  73. }, window.REMODAL_GLOBALS && window.REMODAL_GLOBALS.DEFAULTS);
  74. /**
  75. * States of the Remodal
  76. * @private
  77. * @const
  78. * @enum {String}
  79. */
  80. var STATES = {
  81. CLOSING: 'closing',
  82. CLOSED: 'closed',
  83. OPENING: 'opening',
  84. OPENED: 'opened'
  85. };
  86. /**
  87. * Reasons of the state change.
  88. * @private
  89. * @const
  90. * @enum {String}
  91. */
  92. var STATE_CHANGE_REASONS = {
  93. CONFIRMATION: 'confirmation',
  94. CANCELLATION: 'cancellation'
  95. };
  96. /**
  97. * Is animation supported?
  98. * @private
  99. * @const
  100. * @type {Boolean}
  101. */
  102. var IS_ANIMATION = function () {
  103. var style = document.createElement('div').style;
  104. return style.animationName !== undefined || style.WebkitAnimationName !== undefined || style.MozAnimationName !== undefined || style.msAnimationName !== undefined || style.OAnimationName !== undefined;
  105. }();
  106. /**
  107. * Is iOS?
  108. * @private
  109. * @const
  110. * @type {Boolean}
  111. */
  112. var IS_IOS = /iPad|iPhone|iPod/.test(navigator.platform);
  113. /**
  114. * Current modal
  115. * @private
  116. * @type {Remodal}
  117. */
  118. var openModals = [];
  119. /**
  120. * Scrollbar position
  121. * @private
  122. * @type {Number}
  123. */
  124. var scrollTop;
  125. /**
  126. * Returns an animation duration
  127. * @private
  128. * @param {jQuery} $elem
  129. * @returns {Number}
  130. */
  131. function getAnimationDuration($elem) {
  132. if (IS_ANIMATION && $elem.css('animation-name') === 'none' && $elem.css('-webkit-animation-name') === 'none' && $elem.css('-moz-animation-name') === 'none' && $elem.css('-o-animation-name') === 'none' && $elem.css('-ms-animation-name') === 'none') {
  133. return 0;
  134. }
  135. var duration = $elem.css('animation-duration') || $elem.css('-webkit-animation-duration') || $elem.css('-moz-animation-duration') || $elem.css('-o-animation-duration') || $elem.css('-ms-animation-duration') || '0s';
  136. var delay = $elem.css('animation-delay') || $elem.css('-webkit-animation-delay') || $elem.css('-moz-animation-delay') || $elem.css('-o-animation-delay') || $elem.css('-ms-animation-delay') || '0s';
  137. var iterationCount = $elem.css('animation-iteration-count') || $elem.css('-webkit-animation-iteration-count') || $elem.css('-moz-animation-iteration-count') || $elem.css('-o-animation-iteration-count') || $elem.css('-ms-animation-iteration-count') || '1';
  138. var max;
  139. var len;
  140. var num;
  141. var i;
  142. duration = duration.split(', ');
  143. delay = delay.split(', ');
  144. iterationCount = iterationCount.split(', '); // The 'duration' size is the same as the 'delay' size
  145. for (i = 0, len = duration.length, max = Number.NEGATIVE_INFINITY; i < len; i++) {
  146. num = parseFloat(duration[i]) * parseInt(iterationCount[i], 10) + parseFloat(delay[i]);
  147. if (num > max) {
  148. max = num;
  149. }
  150. }
  151. return max;
  152. }
  153. /**
  154. * Returns a scrollbar width
  155. * @private
  156. * @returns {Number}
  157. */
  158. function getScrollbarWidth() {
  159. if ($(document).height() <= $(window).height()) {
  160. return 0;
  161. }
  162. var outer = document.createElement('div');
  163. var inner = document.createElement('div');
  164. var widthNoScroll;
  165. var widthWithScroll;
  166. outer.style.visibility = 'hidden';
  167. outer.style.width = '100px';
  168. document.body.appendChild(outer);
  169. widthNoScroll = outer.offsetWidth; // Force scrollbars
  170. outer.style.overflow = 'scroll'; // Add inner div
  171. inner.style.width = '100%';
  172. outer.appendChild(inner);
  173. widthWithScroll = inner.offsetWidth; // Remove divs
  174. outer.parentNode.removeChild(outer);
  175. return widthNoScroll - widthWithScroll;
  176. }
  177. /**
  178. * Locks the screen
  179. * @private
  180. */
  181. function lockScreen() {
  182. if (IS_IOS) {
  183. return;
  184. }
  185. var $html = $('html');
  186. var lockedClass = namespacify('is-locked');
  187. var paddingRight;
  188. var $body;
  189. if (!$html.hasClass(lockedClass)) {
  190. $body = $(document.body); // Zepto does not support '-=', '+=' in the `css` method
  191. paddingRight = parseInt($body.css('padding-right'), 10) + getScrollbarWidth();
  192. $body.css('padding-right', paddingRight + 'px');
  193. $html.addClass(lockedClass);
  194. }
  195. }
  196. /**
  197. * Unlocks the screen
  198. * @private
  199. */
  200. function unlockScreen() {
  201. if (IS_IOS) {
  202. return;
  203. }
  204. var $html = $('html');
  205. var lockedClass = namespacify('is-locked');
  206. var paddingRight;
  207. var $body;
  208. if ($html.hasClass(lockedClass)) {
  209. $body = $(document.body); // Zepto does not support '-=', '+=' in the `css` method
  210. paddingRight = parseInt($body.css('padding-right'), 10) - getScrollbarWidth();
  211. $body.css('padding-right', paddingRight + 'px');
  212. $html.removeClass(lockedClass);
  213. }
  214. }
  215. /**
  216. * Sets a state for an instance
  217. * @private
  218. * @param {Remodal} instance
  219. * @param {STATES} state
  220. * @param {Boolean} isSilent If true, Remodal does not trigger events
  221. * @param {String} Reason of a state change.
  222. */
  223. function setState(instance, state, isSilent, reason) {
  224. var newState = namespacify('is', state);
  225. var allStates = [namespacify('is', STATES.CLOSING), namespacify('is', STATES.OPENING), namespacify('is', STATES.CLOSED), namespacify('is', STATES.OPENED)].join(' ');
  226. instance.$bg.removeClass(allStates).addClass(newState);
  227. instance.$overlay.removeClass(allStates).addClass(newState);
  228. instance.$wrapper.removeClass(allStates).addClass(newState);
  229. instance.$modal.removeClass(allStates).addClass(newState);
  230. instance.state = state;
  231. !isSilent && instance.$modal.trigger({
  232. type: state,
  233. reason: reason
  234. }, [{
  235. reason: reason
  236. }]);
  237. }
  238. /**
  239. * Synchronizes with the animation
  240. * @param {Function} doBeforeAnimation
  241. * @param {Function} doAfterAnimation
  242. * @param {Remodal} instance
  243. */
  244. function syncWithAnimation(doBeforeAnimation, doAfterAnimation, instance) {
  245. var runningAnimationsCount = 0;
  246. var handleAnimationStart = function handleAnimationStart(e) {
  247. if (e.target !== this) {
  248. return;
  249. }
  250. runningAnimationsCount++;
  251. };
  252. var handleAnimationEnd = function handleAnimationEnd(e) {
  253. if (e.target !== this) {
  254. return;
  255. }
  256. if (--runningAnimationsCount === 0) {
  257. // Remove event listeners
  258. $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) {
  259. instance[elemName].off(ANIMATIONSTART_EVENTS + ' ' + ANIMATIONEND_EVENTS);
  260. });
  261. doAfterAnimation();
  262. }
  263. };
  264. $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) {
  265. instance[elemName].on(ANIMATIONSTART_EVENTS, handleAnimationStart).on(ANIMATIONEND_EVENTS, handleAnimationEnd);
  266. });
  267. doBeforeAnimation(); // If the animation is not supported by a browser or its duration is 0
  268. if (getAnimationDuration(instance.$bg) === 0 && getAnimationDuration(instance.$overlay) === 0 && getAnimationDuration(instance.$wrapper) === 0 && getAnimationDuration(instance.$modal) === 0) {
  269. // Remove event listeners
  270. $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) {
  271. instance[elemName].off(ANIMATIONSTART_EVENTS + ' ' + ANIMATIONEND_EVENTS);
  272. });
  273. doAfterAnimation();
  274. }
  275. }
  276. /**
  277. * Closes immediately
  278. * @private
  279. * @param {Remodal} instance
  280. */
  281. function halt(instance) {
  282. if (instance.state === STATES.CLOSED) {
  283. return;
  284. }
  285. $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) {
  286. instance[elemName].off(ANIMATIONSTART_EVENTS + ' ' + ANIMATIONEND_EVENTS);
  287. });
  288. removeModal(instance);
  289. instance.$bg.removeClass(instance.settings.modifier);
  290. instance.$overlay.removeClass(instance.settings.modifier).hide();
  291. instance.$wrapper.hide();
  292. if (openModals.length === 0) {
  293. unlockScreen();
  294. }
  295. setState(instance, STATES.CLOSED, true);
  296. }
  297. /**
  298. * Parses a string with options
  299. * @private
  300. * @param str
  301. * @returns {Object}
  302. */
  303. function parseOptions(str) {
  304. var obj = {};
  305. var arr;
  306. var len;
  307. var val;
  308. var i; // Remove spaces before and after delimiters
  309. str = str.replace(/\s*:\s*/g, ':').replace(/\s*,\s*/g, ','); // Parse a string
  310. arr = str.split(',');
  311. for (i = 0, len = arr.length; i < len; i++) {
  312. arr[i] = arr[i].split(':');
  313. val = arr[i][1]; // Convert a string value if it is like a boolean
  314. if (typeof val === 'string' || val instanceof String) {
  315. val = val === 'true' || (val === 'false' ? false : val);
  316. } // Convert a string value if it is like a number
  317. if (typeof val === 'string' || val instanceof String) {
  318. val = !isNaN(val) ? +val : val;
  319. }
  320. obj[arr[i][0]] = val;
  321. }
  322. return obj;
  323. }
  324. /**
  325. * Generates a string separated by dashes and prefixed with NAMESPACE
  326. * @private
  327. * @param {...String}
  328. * @returns {String}
  329. */
  330. function namespacify() {
  331. var result = NAMESPACE;
  332. for (var i = 0; i < arguments.length; ++i) {
  333. result += '-' + arguments[i];
  334. }
  335. return result;
  336. }
  337. /**
  338. * Handles the hashchange event
  339. * @private
  340. * @listens hashchange
  341. */
  342. function handleHashChangeEvent() {
  343. var id = location.hash.replace('#', '');
  344. var instance;
  345. var $elem;
  346. var current = currentModal();
  347. if (!id) {
  348. // Check if we have currently opened modal and animation was completed
  349. if (current && current.state === STATES.OPENED && current.settings.hashTracking) {
  350. current.close();
  351. }
  352. } else {
  353. if (!current || current.id !== id) {
  354. // Catch syntax error if your hash is bad
  355. try {
  356. $elem = $('[data-' + PLUGIN_NAME + '-id="' + id + '"]');
  357. } catch (err) {}
  358. if ($elem && $elem.length) {
  359. instance = $[PLUGIN_NAME].lookup[$elem.data(PLUGIN_NAME)];
  360. if (instance && instance.settings.hashTracking) {
  361. instance.open();
  362. }
  363. }
  364. }
  365. }
  366. }
  367. function currentModal() {
  368. return openModals[openModals.length - 1];
  369. }
  370. function removeModal(remodal) {
  371. var index = openModals.indexOf(remodal);
  372. if (index >= 0) {
  373. openModals.slice(index, 1);
  374. }
  375. }
  376. /**
  377. * Remodal constructor
  378. * @constructor
  379. * @param {jQuery} $modal
  380. * @param {Object} options
  381. */
  382. function Remodal($modal, options) {
  383. var $body = $(document.body);
  384. var $appendTo = $body;
  385. var remodal = this;
  386. remodal.id = $modal.attr('data-' + PLUGIN_NAME + '-id');
  387. remodal.settings = $.extend({}, DEFAULTS, options);
  388. remodal.index = $[PLUGIN_NAME].lookup.push(remodal) - 1;
  389. remodal.state = STATES.CLOSED; // remodal.$overlay = $('.' + namespacify('overlay'));
  390. if (remodal.settings.appendTo !== null && remodal.settings.appendTo.length) {
  391. $appendTo = $(remodal.settings.appendTo);
  392. }
  393. if (!remodal.$overlay) {
  394. remodal.$overlay = $('<div>').addClass(namespacify('overlay') + ' ' + namespacify('is', STATES.CLOSED)).hide();
  395. $appendTo.append(remodal.$overlay);
  396. }
  397. remodal.$bg = $('.' + namespacify('bg')).addClass(namespacify('is', STATES.CLOSED));
  398. remodal.$modal = $modal.addClass(NAMESPACE + ' ' + namespacify('is-initialized') + ' ' + remodal.settings.modifier + ' ' + namespacify('is', STATES.CLOSED)).attr('tabindex', '-1');
  399. remodal.$wrapper = $('<div>').addClass(namespacify('wrapper') + ' ' + remodal.settings.modifier + ' ' + namespacify('is', STATES.CLOSED)).hide().append(remodal.$modal);
  400. $appendTo.append(remodal.$wrapper); // Add the event listener for the close button
  401. remodal.$wrapper.on('click.' + NAMESPACE, '[data-' + PLUGIN_NAME + '-action="close"]', function (e) {
  402. e.preventDefault();
  403. remodal.close();
  404. }); // Add the event listener for the cancel button
  405. remodal.$wrapper.on('click.' + NAMESPACE, '[data-' + PLUGIN_NAME + '-action="cancel"]', function (e) {
  406. e.preventDefault();
  407. remodal.$modal.trigger(STATE_CHANGE_REASONS.CANCELLATION);
  408. if (remodal.settings.closeOnCancel) {
  409. remodal.close(STATE_CHANGE_REASONS.CANCELLATION);
  410. }
  411. }); // Add the event listener for the confirm button
  412. remodal.$wrapper.on('click.' + NAMESPACE, '[data-' + PLUGIN_NAME + '-action="confirm"]', function (e) {
  413. e.preventDefault();
  414. remodal.$modal.trigger(STATE_CHANGE_REASONS.CONFIRMATION);
  415. if (remodal.settings.closeOnConfirm) {
  416. remodal.close(STATE_CHANGE_REASONS.CONFIRMATION);
  417. }
  418. }); // Add the event listener for the overlay
  419. remodal.$wrapper.on('click.' + NAMESPACE, function (e) {
  420. var $target = $(e.target);
  421. var isWrapper = $target.hasClass(namespacify('wrapper'));
  422. var isWithin = $target.closest('.' + namespacify('is', STATES.OPENED)).length;
  423. if (!isWrapper && isWithin) {
  424. return;
  425. }
  426. if (remodal.settings.closeOnOutsideClick) {
  427. remodal.close();
  428. }
  429. });
  430. }
  431. /**
  432. * Opens a modal window
  433. * @public
  434. */
  435. Remodal.prototype.open = function () {
  436. var remodal = this;
  437. var current;
  438. var modalCount; // Check if the animation was completed
  439. if (remodal.state === STATES.OPENING || remodal.state === STATES.CLOSING) {
  440. return;
  441. } // id = remodal.$modal.attr('data-' + PLUGIN_NAME + '-id');
  442. if (remodal.id && remodal.settings.hashTracking) {
  443. scrollTop = $(window).scrollTop();
  444. location.hash = remodal.id;
  445. }
  446. if (!remodal.settings.stack) {
  447. current = currentModal();
  448. if (current && current !== remodal) {
  449. halt(current);
  450. }
  451. }
  452. modalCount = openModals.push(remodal);
  453. remodal.$overlay.css('z-index', function (_, value) {
  454. return parseInt(value, 10) + modalCount;
  455. });
  456. remodal.$wrapper.css('z-index', function (_, value) {
  457. return parseInt(value, 10) + modalCount;
  458. });
  459. lockScreen();
  460. remodal.$bg.addClass(remodal.settings.modifier);
  461. remodal.$overlay.addClass(remodal.settings.modifier).show();
  462. remodal.$wrapper.show().scrollTop(0);
  463. remodal.$modal.focus();
  464. syncWithAnimation(function () {
  465. setState(remodal, STATES.OPENING);
  466. }, function () {
  467. setState(remodal, STATES.OPENED);
  468. }, remodal);
  469. };
  470. /**
  471. * Closes a modal window
  472. * @public
  473. * @param {String} reason
  474. */
  475. Remodal.prototype.close = function (reason) {
  476. var remodal = this;
  477. var current; // Check if the animation was completed
  478. if (remodal.state === STATES.OPENING || remodal.state === STATES.CLOSING || remodal.state === STATES.CLOSED) {
  479. return;
  480. }
  481. removeModal(remodal);
  482. if (remodal.settings.hashTracking && remodal.id === location.hash.substr(1)) {
  483. current = currentModal();
  484. if (current) {
  485. location.hash = current.id;
  486. } else {
  487. location.hash = '';
  488. $(window).scrollTop(scrollTop);
  489. }
  490. }
  491. syncWithAnimation(function () {
  492. setState(remodal, STATES.CLOSING, false, reason);
  493. }, function () {
  494. remodal.$bg.removeClass(remodal.settings.modifier);
  495. remodal.$overlay.removeClass(remodal.settings.modifier).hide();
  496. remodal.$wrapper.hide();
  497. if (openModals.length === 0) {
  498. unlockScreen();
  499. }
  500. setState(remodal, STATES.CLOSED, false, reason);
  501. }, remodal);
  502. };
  503. /**
  504. * Returns a current state of a modal
  505. * @public
  506. * @returns {STATES}
  507. */
  508. Remodal.prototype.getState = function () {
  509. return this.state;
  510. };
  511. /**
  512. * Destroys a modal
  513. * @public
  514. */
  515. Remodal.prototype.destroy = function () {
  516. var lookup = $[PLUGIN_NAME].lookup;
  517. var instanceCount;
  518. halt(this);
  519. this.$wrapper.remove();
  520. delete lookup[this.index];
  521. instanceCount = $.grep(lookup, function (instance) {
  522. return !!instance;
  523. }).length;
  524. if (instanceCount === 0) {
  525. this.$overlay.remove();
  526. this.$bg.removeClass(namespacify('is', STATES.CLOSING) + ' ' + namespacify('is', STATES.OPENING) + ' ' + namespacify('is', STATES.CLOSED) + ' ' + namespacify('is', STATES.OPENED));
  527. }
  528. };
  529. /**
  530. * Special plugin object for instances
  531. * @public
  532. * @type {Object}
  533. */
  534. $[PLUGIN_NAME] = {
  535. lookup: []
  536. };
  537. /**
  538. * Plugin constructor
  539. * @constructor
  540. * @param {Object} options
  541. * @returns {JQuery}
  542. */
  543. $.fn[PLUGIN_NAME] = function (opts) {
  544. var instance;
  545. var $elem;
  546. this.each(function (index, elem) {
  547. $elem = $(elem);
  548. if ($elem.data(PLUGIN_NAME) == null) {
  549. instance = new Remodal($elem, opts);
  550. $elem.data(PLUGIN_NAME, instance.index);
  551. if (instance.settings.hashTracking && instance.id === location.hash.substr(1)) {
  552. instance.open();
  553. }
  554. } else {
  555. instance = $[PLUGIN_NAME].lookup[$elem.data(PLUGIN_NAME)];
  556. }
  557. });
  558. return instance;
  559. };
  560. $(document).ready(function () {
  561. // data-remodal-target opens a modal window with the special Id
  562. $(document).on('click', '[data-' + PLUGIN_NAME + '-target]', function (e) {
  563. e.preventDefault();
  564. var elem = e.currentTarget;
  565. var id = elem.getAttribute('data-' + PLUGIN_NAME + '-target');
  566. var $target = $('[data-' + PLUGIN_NAME + '-id="' + id + '"]');
  567. $[PLUGIN_NAME].lookup[$target.data(PLUGIN_NAME)].open();
  568. }); // Auto initialization of modal windows
  569. // They should have the 'remodal' class attribute
  570. // Also you can write the `data-remodal-options` attribute to pass params into the modal
  571. $(document).find('.' + NAMESPACE).each(function (i, container) {
  572. var $container = $(container);
  573. var options = $container.data(PLUGIN_NAME + '-options');
  574. if (!options) {
  575. options = {};
  576. } else if (typeof options === 'string' || options instanceof String) {
  577. options = parseOptions(options);
  578. }
  579. $container[PLUGIN_NAME](options);
  580. }); // Handles the keydown event
  581. $(document).on('keydown.' + NAMESPACE, function (e) {
  582. var current = currentModal();
  583. if (current && current.settings.closeOnEscape && current.state === STATES.OPENED && e.keyCode === 27) {
  584. current.close();
  585. }
  586. }); // Handles the hashchange event
  587. $(window).on('hashchange.' + NAMESPACE, handleHashChangeEvent);
  588. });
  589. });
  590. // EXTERNAL MODULE: ./node_modules/simplebar/dist/simplebar.min.js
  591. var simplebar_min = __webpack_require__(85766);
  592. // EXTERNAL MODULE: ./node_modules/dropzone/dist/dropzone.js
  593. var dist_dropzone = __webpack_require__(32025);
  594. var dropzone_default = /*#__PURE__*/__webpack_require__.n(dist_dropzone);
  595. // EXTERNAL MODULE: ./node_modules/toastr/toastr.js
  596. var toastr = __webpack_require__(8901);
  597. var toastr_default = /*#__PURE__*/__webpack_require__.n(toastr);
  598. ;// CONCATENATED MODULE: ./app/utils/toastr.js
  599. (toastr_default()).options.positionClass = 'toast-top-right';
  600. (toastr_default()).options.preventDuplicates = true;
  601. /* harmony default export */ const utils_toastr = ((toastr_default()));
  602. ;// CONCATENATED MODULE: ./app/utils/offline.js
  603. var offlineElement = external_jQuery_default()('#offline-status');
  604. external_jQuery_default()(window).on('offline', function () {
  605. offlineElement.slideDown();
  606. });
  607. external_jQuery_default()(window).on('online', function () {
  608. offlineElement.slideUp();
  609. });
  610. external_jQuery_default()(document).ready(function () {
  611. if (!offline) {
  612. offlineElement.slideDown();
  613. }
  614. }); // assume online if can't check
  615. /* harmony default export */ const offline = (typeof __webpack_require__.g.navigator.onLine !== 'undefined' ? __webpack_require__.g.navigator.onLine : true);
  616. ;// CONCATENATED MODULE: external "GravAdmin"
  617. const external_GravAdmin_namespaceObject = GravAdmin;
  618. // EXTERNAL MODULE: ./node_modules/mout/string/trim.js
  619. var trim = __webpack_require__(78579);
  620. var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
  621. ;// CONCATENATED MODULE: ./app/utils/response.js
  622. var UNLOADING = false;
  623. var error = function error(response) {
  624. var error = new Error(response.statusText || response || '');
  625. error.response = response;
  626. return error;
  627. };
  628. function parseStatus(response) {
  629. return response;
  630. /* Whoops can handle JSON responses so we don't need this for now.
  631. if (response.status >= 200 && response.status < 300) {
  632. return response;
  633. } else {
  634. throw error(response);
  635. }
  636. */
  637. }
  638. function parseJSON(response) {
  639. return response.text().then(function (text) {
  640. var parsed = text;
  641. try {
  642. parsed = JSON.parse(text);
  643. } catch (error) {
  644. var content = document.createElement('div');
  645. content.innerHTML = text;
  646. var the_error = new Error();
  647. the_error.stack = trim_default()(content.innerText);
  648. throw the_error;
  649. }
  650. return parsed;
  651. });
  652. }
  653. function userFeedback(response) {
  654. if (UNLOADING) {
  655. return true;
  656. }
  657. var status = response.status || (response.error ? 'error' : '');
  658. var message = response.message || (response.error ? response.error.message : null);
  659. var settings = response.toastr || null;
  660. var backup;
  661. switch (status) {
  662. case 'unauthenticated':
  663. document.location.href = external_GravAdmin_namespaceObject.config.base_url_relative;
  664. throw error('Logged out');
  665. case 'unauthorized':
  666. status = 'error';
  667. message = message || 'Unauthorized.';
  668. break;
  669. case 'error':
  670. status = 'error';
  671. message = message || 'Unknown error.';
  672. break;
  673. case 'success':
  674. status = 'success';
  675. message = message || '';
  676. break;
  677. default:
  678. status = 'error';
  679. message = message || 'Invalid AJAX response.';
  680. break;
  681. }
  682. if (settings) {
  683. backup = Object.assign({}, utils_toastr.options);
  684. Object.keys(settings).forEach(function (key) {
  685. utils_toastr.options[key] = settings[key];
  686. });
  687. }
  688. if (message && (offline || !offline && status !== 'error')) {
  689. utils_toastr[status === 'success' ? 'success' : 'error'](message);
  690. }
  691. if (settings) {
  692. utils_toastr.options = backup;
  693. }
  694. return response;
  695. }
  696. function userFeedbackError(error) {
  697. if (UNLOADING) {
  698. return true;
  699. }
  700. var stack = error.stack ? "<pre><code>".concat(error.stack, "</code></pre>") : '';
  701. utils_toastr.error("Fetch Failed: <br /> ".concat(error.message, " ").concat(stack));
  702. console.error("".concat(error.message, " at ").concat(error.stack));
  703. }
  704. external_jQuery_default()(__webpack_require__.g).on('beforeunload._ajax', function () {
  705. UNLOADING = true;
  706. });
  707. ;// CONCATENATED MODULE: ./app/utils/request.js
  708. var raw;
  709. var request = function request(url) {
  710. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  711. var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
  712. return true;
  713. };
  714. if (typeof options === 'function') {
  715. callback = options;
  716. options = {};
  717. }
  718. if (options.method && options.method === 'post') {
  719. var data = new FormData();
  720. options.body = Object.assign({
  721. 'admin-nonce': external_GravAdmin_namespaceObject.config.admin_nonce
  722. }, options.body || {});
  723. Object.keys(options.body).map(function (key) {
  724. return data.append(key, options.body[key]);
  725. });
  726. options.body = data;
  727. }
  728. options = Object.assign({
  729. credentials: 'same-origin',
  730. headers: {
  731. 'Accept': 'application/json'
  732. }
  733. }, options);
  734. return fetch(url, options).then(function (response) {
  735. raw = response;
  736. return response;
  737. }).then(parseStatus).then(parseJSON).then(userFeedback).then(function (response) {
  738. return callback(response, raw);
  739. })["catch"](userFeedbackError);
  740. };
  741. /* harmony default export */ const utils_request = (request);
  742. ;// CONCATENATED MODULE: ./app/forms/fields/files.js
  743. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  744. 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); } }
  745. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  746. // import EXIF from 'exif-js';
  747. // translations
  748. var Dictionary = {
  749. dictCancelUpload: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_CANCEL_UPLOAD,
  750. dictCancelUploadConfirmation: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_CANCEL_UPLOAD_CONFIRMATION,
  751. dictDefaultMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_DEFAULT_MESSAGE,
  752. dictFallbackMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FALLBACK_MESSAGE,
  753. dictFallbackText: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FALLBACK_TEXT,
  754. dictFileTooBig: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FILE_TOO_BIG,
  755. dictInvalidFileType: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_INVALID_FILE_TYPE,
  756. dictMaxFilesExceeded: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_MAX_FILES_EXCEEDED,
  757. dictRemoveFile: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_REMOVE_FILE,
  758. dictResponseError: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_RESPONSE_ERROR
  759. };
  760. (dropzone_default()).autoDiscover = false;
  761. (dropzone_default()).options.gravPageDropzone = {};
  762. (dropzone_default()).confirm = function (question, accepted, rejected) {
  763. var doc = external_jQuery_default()(document);
  764. var modalSelector = '[data-remodal-id="delete-media"]';
  765. var removeEvents = function removeEvents() {
  766. doc.off('confirmation', modalSelector, accept);
  767. doc.off('cancellation', modalSelector, reject);
  768. external_jQuery_default()(modalSelector).find('.remodal-confirm').removeClass('pointer-events-disabled');
  769. };
  770. var accept = function accept() {
  771. accepted && accepted();
  772. removeEvents();
  773. };
  774. var reject = function reject() {
  775. rejected && rejected();
  776. removeEvents();
  777. };
  778. (external_jQuery_default()).remodal.lookup[external_jQuery_default()(modalSelector).data('remodal')].open();
  779. doc.on('confirmation', modalSelector, accept);
  780. doc.on('cancellation', modalSelector, reject);
  781. };
  782. var DropzoneMediaConfig = {
  783. timeout: 0,
  784. thumbnailWidth: 200,
  785. thumbnailHeight: 150,
  786. addRemoveLinks: false,
  787. dictDefaultMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROP_FILES_HERE_TO_UPLOAD.replace(/&lt;/g, '<').replace(/&gt;/g, '>'),
  788. dictRemoveFileConfirmation: '[placeholder]',
  789. previewTemplate: "\n <div class=\"dz-preview dz-file-preview dz-no-editor\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-success-mark\"><span>\u2714</span></div>\n <div class=\"dz-error-mark\"><span>\u2718</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n <a class=\"dz-unset\" title=\"".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UNSET, "\" href=\"#\" data-dz-unset>").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UNSET, "</a>\n <a class=\"dz-remove\" title=\"").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DELETE, "\" href=\"javascript:undefined;\" data-dz-remove>").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DELETE, "</a>\n <a class=\"dz-metadata\" title=\"").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.METADATA, "\" href=\"#\" target=\"_blank\" data-dz-metadata>").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.METADATA, "</a>\n <a class=\"dz-view\" title=\"").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.VIEW, "\" href=\"#\" target=\"_blank\" data-dz-view>").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.VIEW, "</a>\n </div>").trim()
  790. }; // global.EXIF = EXIF;
  791. var ACCEPT_FUNC = function ACCEPT_FUNC(file, done, settings) {
  792. var resolution = settings.resolution;
  793. if (!resolution) return done();
  794. var reader = new FileReader();
  795. var error = '';
  796. var hasMin = resolution.min && (resolution.min.width || resolution.min.height);
  797. var hasMax = resolution.max && (resolution.max.width || resolution.max.height);
  798. if (hasMin || !(settings.resizeWidth || settings.resizeHeight) && hasMax) {
  799. reader.onload = function (event) {
  800. if (!/image\//.test(file.type)) {
  801. done();
  802. return;
  803. }
  804. var image = new Image();
  805. image.src = event.target.result;
  806. image.onerror = function () {
  807. done(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_UPLOAD);
  808. };
  809. image.onload = function () {
  810. var _this = this;
  811. if (resolution.min) {
  812. Object.keys(resolution.min).forEach(function (attr) {
  813. if (resolution.min[attr] && _this[attr] < resolution.min[attr]) {
  814. error += external_GravAdmin_namespaceObject.translations.PLUGIN_FORM.RESOLUTION_MIN.replace(/{{attr}}/g, attr).replace(/{{min}}/g, resolution.min[attr]);
  815. }
  816. });
  817. }
  818. if (!(settings.resizeWidth || settings.resizeHeight)) {
  819. if (resolution.max) {
  820. Object.keys(resolution.max).forEach(function (attr) {
  821. if (resolution.max[attr] && _this[attr] > resolution.max[attr]) {
  822. error += external_GravAdmin_namespaceObject.translations.PLUGIN_FORM.RESOLUTION_MAX.replace(/{{attr}}/g, attr).replace(/{{max}}/g, resolution.max[attr]);
  823. }
  824. });
  825. }
  826. }
  827. URL.revokeObjectURL(image.src); // release memory
  828. return error ? done(error) : done();
  829. };
  830. };
  831. reader.readAsDataURL(file);
  832. } else {
  833. return error ? done(error) : done();
  834. }
  835. };
  836. var FilesField = /*#__PURE__*/function () {
  837. function FilesField() {
  838. var _this2 = this;
  839. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  840. _ref$container = _ref.container,
  841. container = _ref$container === void 0 ? '.dropzone.files-upload' : _ref$container,
  842. _ref$options = _ref.options,
  843. options = _ref$options === void 0 ? {} : _ref$options;
  844. _classCallCheck(this, FilesField);
  845. this.container = external_jQuery_default()(container);
  846. if (!this.container.length) {
  847. return;
  848. }
  849. this.urls = {};
  850. this.customPost = this.container.data('filePostAdd') || {};
  851. this.options = Object.assign({}, Dictionary, DropzoneMediaConfig, {
  852. klass: this,
  853. url: this.container.data('file-url-add') || external_GravAdmin_namespaceObject.config.current_url,
  854. acceptedFiles: this.container.data('media-types'),
  855. init: this.initDropzone
  856. }, this.container.data('dropzone-options'), options);
  857. this.options = Object.assign({}, this.options, {
  858. accept: function accept(file, done) {
  859. ACCEPT_FUNC(file, done, this.options);
  860. }
  861. });
  862. this.dropzone = new (dropzone_default())(container, this.options);
  863. this.dropzone.on('complete', this.onDropzoneComplete.bind(this));
  864. this.dropzone.on('success', this.onDropzoneSuccess.bind(this));
  865. this.dropzone.on('addedfile', this.onDropzoneAddedFile.bind(this));
  866. this.dropzone.on('removedfile', this.onDropzoneRemovedFile.bind(this));
  867. this.dropzone.on('sending', this.onDropzoneSending.bind(this));
  868. this.dropzone.on('error', this.onDropzoneError.bind(this));
  869. this.container.on('mouseenter', '[data-dz-view]', function (e) {
  870. var value = JSON.parse(_this2.container.find('[name][type="hidden"]').val() || '{}');
  871. var target = external_jQuery_default()(e.currentTarget);
  872. var file = target.parent('.dz-preview').find('.dz-filename');
  873. var filename = encodeURI(file.text());
  874. var URL = Object.keys(value).filter(function (key) {
  875. return value[key].name === filename;
  876. }).shift();
  877. target.attr('href', "".concat(external_GravAdmin_namespaceObject.config.base_url_simple, "/").concat(URL));
  878. });
  879. }
  880. _createClass(FilesField, [{
  881. key: "initDropzone",
  882. value: function initDropzone() {
  883. var _this3 = this;
  884. var files = this.options.klass.container.find('[data-file]');
  885. var dropzone = this;
  886. if (!files.length) {
  887. return;
  888. }
  889. files.each(function (index, file) {
  890. file = external_jQuery_default()(file);
  891. var data = file.data('file');
  892. var mock = {
  893. name: data.name,
  894. size: data.size,
  895. type: data.type,
  896. status: (dropzone_default()).ADDED,
  897. accepted: true,
  898. url: _this3.options.url,
  899. removeUrl: data.remove
  900. };
  901. dropzone.files.push(mock);
  902. dropzone.options.addedfile.call(dropzone, mock);
  903. if (mock.type.match(/^image\//)) {
  904. dropzone.options.thumbnail.call(dropzone, mock, data.path);
  905. dropzone.createThumbnailFromUrl(mock, data.path);
  906. }
  907. file.remove();
  908. });
  909. }
  910. }, {
  911. key: "getURI",
  912. value: function getURI() {
  913. return this.container.data('mediaUri') || '';
  914. }
  915. }, {
  916. key: "onDropzoneSending",
  917. value: function onDropzoneSending(file, xhr, formData) {
  918. var _this4 = this;
  919. if (Object.keys(this.customPost).length) {
  920. Object.keys(this.customPost).forEach(function (key) {
  921. formData.append(key, _this4.customPost[key]);
  922. });
  923. } else {
  924. formData.append('name', this.options.dotNotation);
  925. formData.append('task', 'filesupload');
  926. formData.append('uri', this.getURI());
  927. }
  928. formData.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
  929. }
  930. }, {
  931. key: "onDropzoneSuccess",
  932. value: function onDropzoneSuccess(file, response, xhr) {
  933. response = typeof response === 'string' ? JSON.parse(response) : response;
  934. if (this.options.reloadPage) {
  935. __webpack_require__.g.location.reload();
  936. } // store params for removing file from session before it gets saved
  937. if (response.session) {
  938. file.sessionParams = response.session;
  939. file.removeUrl = this.options.url; // Touch field value to force a mutation detection
  940. var input = this.container.find('[name][type="hidden"]');
  941. var value = input.val();
  942. input.val(value + ' ');
  943. }
  944. return this.handleError({
  945. file: file,
  946. data: response,
  947. mode: 'removeFile',
  948. msg: "<p>".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_UPLOAD, " <strong>{{fileName}}</strong></p>\n <pre>").concat(response.message, "</pre>")
  949. });
  950. }
  951. }, {
  952. key: "onDropzoneComplete",
  953. value: function onDropzoneComplete(file) {
  954. if (!file.accepted && !file.rejected) {
  955. var data = {
  956. status: 'error',
  957. message: "".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_UNSUPPORTED, ": ").concat(file.name.match(/\..+/).join(''))
  958. };
  959. return this.handleError({
  960. file: file,
  961. data: data,
  962. mode: 'removeFile',
  963. msg: "<p>".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_ADD, " <strong>{{fileName}}</strong></p>\n <pre>").concat(data.message, "</pre>")
  964. });
  965. }
  966. if (this.options.reloadPage) {
  967. __webpack_require__.g.location.reload();
  968. }
  969. }
  970. }, {
  971. key: "b64_to_utf8",
  972. value: function b64_to_utf8(str) {
  973. str = str.replace(/\s/g, '');
  974. return decodeURIComponent(escape(window.atob(str)));
  975. }
  976. }, {
  977. key: "onDropzoneAddedFile",
  978. value: function onDropzoneAddedFile(file) {
  979. return this.dropzone.options.addedfile(file);
  980. }
  981. }, {
  982. key: "onDropzoneRemovedFile",
  983. value: function onDropzoneRemovedFile(file) {
  984. var _this5 = this;
  985. if (!file.accepted || file.rejected) {
  986. return;
  987. }
  988. var url = file.removeUrl || this.urls["delete"] || this.options.url;
  989. var path = (url || '').match(/path:(.*)\//);
  990. var body = {
  991. filename: file.name,
  992. uri: this.getURI()
  993. };
  994. if (file.sessionParams) {
  995. body.task = 'filessessionremove';
  996. body.session = file.sessionParams;
  997. }
  998. var customPost = this.container.data('filePostRemove') || {};
  999. if (Object.keys(customPost).length) {
  1000. body = {};
  1001. Object.keys(customPost).forEach(function (key) {
  1002. body[key] = customPost[key];
  1003. });
  1004. }
  1005. body['filename'] = file.name;
  1006. body['admin-nonce'] = external_GravAdmin_namespaceObject.config.admin_nonce;
  1007. utils_request(url, {
  1008. method: 'post',
  1009. body: body
  1010. }, function () {
  1011. if (!path) {
  1012. return;
  1013. }
  1014. path = _this5.b64_to_utf8(path[1]);
  1015. var input = _this5.container.find('[name][type="hidden"]');
  1016. var data = JSON.parse(input.val() || '{}');
  1017. delete data[path];
  1018. input.val(JSON.stringify(data));
  1019. });
  1020. }
  1021. }, {
  1022. key: "onDropzoneError",
  1023. value: function onDropzoneError(file, response, xhr) {
  1024. var message = xhr ? response.error.message : response;
  1025. external_jQuery_default()(file.previewElement).find('[data-dz-errormessage]').html(message);
  1026. return this.handleError({
  1027. file: file,
  1028. data: {
  1029. status: 'error'
  1030. },
  1031. msg: "<pre>".concat(message, "</pre>")
  1032. });
  1033. }
  1034. }, {
  1035. key: "handleError",
  1036. value: function handleError(options) {
  1037. var file = options.file,
  1038. data = options.data,
  1039. mode = options.mode,
  1040. msg = options.msg;
  1041. if (data.status !== 'error' && data.status !== 'unauthorized') {
  1042. return;
  1043. }
  1044. switch (mode) {
  1045. case 'addBack':
  1046. if (file instanceof File) {
  1047. this.dropzone.addFile.call(this.dropzone, file);
  1048. } else {
  1049. this.dropzone.files.push(file);
  1050. this.dropzone.options.addedfile.call(this.dropzone, file);
  1051. this.dropzone.options.thumbnail.call(this.dropzone, file, file.extras.url);
  1052. }
  1053. break;
  1054. case 'removeFile':
  1055. default:
  1056. if (~this.dropzone.files.indexOf(file)) {
  1057. file.rejected = true;
  1058. this.dropzone.removeFile.call(this.dropzone, file, {
  1059. silent: true
  1060. });
  1061. }
  1062. break;
  1063. }
  1064. var modal = external_jQuery_default()('[data-remodal-id="generic"]');
  1065. var cleanName = file.name.replace('<', '&lt;').replace('>', '&gt;');
  1066. modal.find('.error-content').html(msg.replace('{{fileName}}', cleanName));
  1067. (external_jQuery_default()).remodal.lookup[modal.data('remodal')].open();
  1068. }
  1069. }]);
  1070. return FilesField;
  1071. }();
  1072. function UriToMarkdown(uri) {
  1073. uri = uri.replace(/@3x|@2x|@1x/, '');
  1074. uri = uri.replace(/\(/g, '%28');
  1075. uri = uri.replace(/\)/g, '%29');
  1076. var title = uri.split('.').slice(0, -1).join('.');
  1077. return uri.match(/\.(jpe?g|png|gif|svg|webp|mp4|webm|ogv|mov)$/i) ? "![".concat(title, "](").concat(uri, " \"").concat(title, "\")") : "[".concat(decodeURI(uri), "](").concat(uri, ")");
  1078. }
  1079. var instances = [];
  1080. var cache = external_jQuery_default()();
  1081. var onAddedNodes = function onAddedNodes(event, target
  1082. /* , record, instance */
  1083. ) {
  1084. var files = external_jQuery_default()(target).find('.dropzone.files-upload');
  1085. if (!files.length) {
  1086. return;
  1087. }
  1088. files.each(function (index, file) {
  1089. file = external_jQuery_default()(file);
  1090. if (!~cache.index(file)) {
  1091. addNode(file);
  1092. }
  1093. });
  1094. };
  1095. var addNode = function addNode(container) {
  1096. container = external_jQuery_default()(container);
  1097. var input = container.find('input[type="file"]');
  1098. var settings = container.data('grav-file-settings') || {};
  1099. if (settings.accept && ~settings.accept.indexOf('*')) {
  1100. settings.accept = [''];
  1101. }
  1102. var options = {
  1103. url: container.data('file-url-add') || (container.closest('form').attr('action') || external_GravAdmin_namespaceObject.config.current_url) + '.json',
  1104. paramName: settings.paramName || 'file',
  1105. dotNotation: settings.name || 'file',
  1106. acceptedFiles: settings.accept ? settings.accept.join(',') : input.attr('accept') || container.data('media-types'),
  1107. maxFilesize: typeof settings.filesize !== 'undefined' ? settings.filesize : 256,
  1108. maxFiles: settings.limit || null,
  1109. resizeWidth: settings.resizeWidth || null,
  1110. resizeHeight: settings.resizeHeight || null,
  1111. resizeQuality: settings.resizeQuality || null,
  1112. resolution: settings.resolution || null,
  1113. accept: function accept(file, done) {
  1114. ACCEPT_FUNC(file, done, settings);
  1115. }
  1116. };
  1117. cache = cache.add(container);
  1118. container = container[0];
  1119. instances.push(new FilesField({
  1120. container: container,
  1121. options: options
  1122. }));
  1123. };
  1124. var Instance = function () {
  1125. external_jQuery_default()('.dropzone.files-upload').each(function (i, container) {
  1126. return addNode(container);
  1127. });
  1128. external_jQuery_default()('body').on('mutation._grav', onAddedNodes);
  1129. return instances;
  1130. }();
  1131. // EXTERNAL MODULE: ./node_modules/events/events.js
  1132. var events = __webpack_require__(17187);
  1133. var events_default = /*#__PURE__*/__webpack_require__.n(events);
  1134. ;// CONCATENATED MODULE: ./app/utils/gpm.js
  1135. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  1136. function gpm_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1137. function gpm_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); } }
  1138. function gpm_createClass(Constructor, protoProps, staticProps) { if (protoProps) gpm_defineProperties(Constructor.prototype, protoProps); if (staticProps) gpm_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  1139. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  1140. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  1141. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1142. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  1143. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  1144. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1145. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  1146. var GPM = /*#__PURE__*/function (_EventEmitter) {
  1147. _inherits(GPM, _EventEmitter);
  1148. var _super = _createSuper(GPM);
  1149. function GPM() {
  1150. var _this;
  1151. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'getUpdates';
  1152. gpm_classCallCheck(this, GPM);
  1153. _this = _super.call(this);
  1154. _this.payload = {};
  1155. _this.raw = {};
  1156. _this.action = action;
  1157. return _this;
  1158. }
  1159. gpm_createClass(GPM, [{
  1160. key: "setPayload",
  1161. value: function setPayload() {
  1162. var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1163. this.payload = payload;
  1164. this.emit('payload', payload);
  1165. return this;
  1166. }
  1167. }, {
  1168. key: "setAction",
  1169. value: function setAction() {
  1170. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'getUpdates';
  1171. this.action = action;
  1172. this.emit('action', action);
  1173. return this;
  1174. }
  1175. }, {
  1176. key: "fetch",
  1177. value: function (_fetch) {
  1178. function fetch() {
  1179. return _fetch.apply(this, arguments);
  1180. }
  1181. fetch.toString = function () {
  1182. return _fetch.toString();
  1183. };
  1184. return fetch;
  1185. }(function () {
  1186. var _this2 = this;
  1187. var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
  1188. return true;
  1189. };
  1190. var flush = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1191. var data = new FormData();
  1192. data.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
  1193. if (flush) {
  1194. data.append('flush', true);
  1195. }
  1196. this.emit('fetching', this);
  1197. fetch("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/update.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getUpdates"), {
  1198. credentials: 'same-origin',
  1199. method: 'post',
  1200. body: data
  1201. }).then(function (response) {
  1202. _this2.raw = response;
  1203. return response;
  1204. }).then(parseStatus).then(parseJSON).then(function (response) {
  1205. return _this2.response(response);
  1206. }).then(function (response) {
  1207. return callback(response, _this2.raw);
  1208. }).then(function (response) {
  1209. return _this2.emit('fetched', _this2.payload, _this2.raw, _this2);
  1210. })["catch"](userFeedbackError);
  1211. })
  1212. }, {
  1213. key: "response",
  1214. value: function response(_response) {
  1215. this.payload = _response;
  1216. return _response;
  1217. }
  1218. }]);
  1219. return GPM;
  1220. }((events_default()));
  1221. var gpm_Instance = new GPM();
  1222. ;// CONCATENATED MODULE: ./app/utils/keepalive.js
  1223. function keepalive_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1224. function keepalive_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); } }
  1225. function keepalive_createClass(Constructor, protoProps, staticProps) { if (protoProps) keepalive_defineProperties(Constructor.prototype, protoProps); if (staticProps) keepalive_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  1226. var MAX_SAFE_DELAY = 2147483647;
  1227. var KeepAlive = /*#__PURE__*/function () {
  1228. function KeepAlive() {
  1229. keepalive_classCallCheck(this, KeepAlive);
  1230. this.active = false;
  1231. }
  1232. keepalive_createClass(KeepAlive, [{
  1233. key: "start",
  1234. value: function start() {
  1235. var _this = this;
  1236. var timeout = external_GravAdmin_namespaceObject.config.admin_timeout / 1.5 * 1000;
  1237. this.timer = setInterval(function () {
  1238. return _this.fetch();
  1239. }, Math.min(timeout, MAX_SAFE_DELAY));
  1240. this.active = true;
  1241. }
  1242. }, {
  1243. key: "stop",
  1244. value: function stop() {
  1245. clearInterval(this.timer);
  1246. this.active = false;
  1247. }
  1248. }, {
  1249. key: "fetch",
  1250. value: function (_fetch) {
  1251. function fetch() {
  1252. return _fetch.apply(this, arguments);
  1253. }
  1254. fetch.toString = function () {
  1255. return _fetch.toString();
  1256. };
  1257. return fetch;
  1258. }(function () {
  1259. var data = new FormData();
  1260. data.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
  1261. fetch("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "keepAlive"), {
  1262. credentials: 'same-origin',
  1263. method: 'post',
  1264. body: data
  1265. })["catch"](userFeedbackError);
  1266. })
  1267. }]);
  1268. return KeepAlive;
  1269. }();
  1270. /* harmony default export */ const keepalive = (new KeepAlive());
  1271. // EXTERNAL MODULE: ./node_modules/mout/array/unique.js
  1272. var unique = __webpack_require__(79863);
  1273. var unique_default = /*#__PURE__*/__webpack_require__.n(unique);
  1274. ;// CONCATENATED MODULE: ./app/updates/notifications.js
  1275. function notifications_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1276. function notifications_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); } }
  1277. function notifications_createClass(Constructor, protoProps, staticProps) { if (protoProps) notifications_defineProperties(Constructor.prototype, protoProps); if (staticProps) notifications_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  1278. var canFetchNotifications = function canFetchNotifications() {
  1279. return external_GravAdmin_namespaceObject.config.notifications.enabled;
  1280. };
  1281. var notificationsFilters = function notificationsFilters() {
  1282. return external_GravAdmin_namespaceObject.config.notifications.filters;
  1283. };
  1284. var Notifications = /*#__PURE__*/function () {
  1285. function Notifications() {
  1286. notifications_classCallCheck(this, Notifications);
  1287. }
  1288. notifications_createClass(Notifications, [{
  1289. key: "fetch",
  1290. value: // Grav.default.Notifications.fetch()
  1291. function fetch() {
  1292. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  1293. _ref$filter = _ref.filter,
  1294. filter = _ref$filter === void 0 ? notificationsFilters() : _ref$filter,
  1295. _ref$refresh = _ref.refresh,
  1296. refresh = _ref$refresh === void 0 ? false : _ref$refresh;
  1297. if (!canFetchNotifications()) {
  1298. return false;
  1299. }
  1300. var feed = external_jQuery_default()('#notifications');
  1301. var loader = feed.find('.widget-loader');
  1302. var content = feed.find('.widget-content > ul');
  1303. loader.find('div').remove();
  1304. loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin');
  1305. loader.show();
  1306. content.hide();
  1307. var processNotifications = function processNotifications(response) {
  1308. var notifications = response.notifications;
  1309. external_jQuery_default()('#notifications').find('.widget-content > ul').empty();
  1310. if (notifications) {
  1311. Object.keys(notifications).forEach(function (location) {
  1312. return Notifications.processLocation(location, notifications[location]);
  1313. });
  1314. }
  1315. };
  1316. utils_request("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getNotifications"), {
  1317. method: 'post',
  1318. body: {
  1319. refresh: refresh,
  1320. filter: filter
  1321. }
  1322. }, function (response) {
  1323. processNotifications(response);
  1324. })["catch"](function () {
  1325. var widget = external_jQuery_default()('#notifications .widget-content');
  1326. widget.find('.widget-loader').find('div').remove();
  1327. widget.find('.widget-loader').append('<div>Failed to retrieve notifications</div>').find('.fa-spin').removeClass('fa-spin fa-refresh').addClass('fa-warning');
  1328. });
  1329. }
  1330. }], [{
  1331. key: "addShowAllInFeed",
  1332. value: function addShowAllInFeed() {
  1333. external_jQuery_default()('#notifications ul').append('<li class="show-all" data-notification-action="show-all-notifications">Show all</li>');
  1334. }
  1335. }, {
  1336. key: "showNotificationInFeed",
  1337. value: function showNotificationInFeed(notification) {
  1338. var notifications = external_jQuery_default()('#notifications').removeClass('hidden');
  1339. var loader = notifications.find('.widget-loader').hide();
  1340. var content = notifications.find('.widget-content > ul').show();
  1341. loader.find('div').remove();
  1342. loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin');
  1343. content.append(notification).find('li:nth-child(n+11)').addClass('hidden'); // hide all items > 10
  1344. if (content.find('li.hidden').length) {
  1345. Notifications.addShowAllInFeed();
  1346. }
  1347. }
  1348. }, {
  1349. key: "showNotificationInTop",
  1350. value: function showNotificationInTop(notification) {
  1351. var container = external_jQuery_default()('.top-notifications-container');
  1352. var dummy = external_jQuery_default()('<div />').html(notification);
  1353. container.removeClass('hidden').append(dummy.children());
  1354. dummy.children().slideDown(150);
  1355. }
  1356. }, {
  1357. key: "showNotificationInDashboard",
  1358. value: function showNotificationInDashboard(notification) {
  1359. var container = external_jQuery_default()('.dashboard-notifications-container');
  1360. var dummy = external_jQuery_default()('<div />').html(notification);
  1361. container.removeClass('hidden').append(dummy.children());
  1362. dummy.children().slideDown(150);
  1363. }
  1364. }, {
  1365. key: "showNotificationInPlugins",
  1366. value: function showNotificationInPlugins(notification) {
  1367. var container = external_jQuery_default()('.plugins-notifications-container');
  1368. var dummy = external_jQuery_default()('<div />').html(notification);
  1369. container.removeClass('hidden').append(dummy.children());
  1370. dummy.children().slideDown(150);
  1371. }
  1372. }, {
  1373. key: "showNotificationInThemes",
  1374. value: function showNotificationInThemes(notification) {
  1375. var container = external_jQuery_default()('.themes-notifications-container');
  1376. var dummy = external_jQuery_default()('<div />').html(notification);
  1377. container.removeClass('hidden').append(dummy.children());
  1378. dummy.children().slideDown(150);
  1379. }
  1380. }, {
  1381. key: "processLocation",
  1382. value: function processLocation(location, notification) {
  1383. switch (location) {
  1384. case 'feed':
  1385. Notifications.showNotificationInFeed(notification);
  1386. break;
  1387. case 'top':
  1388. if (!notification.read) {
  1389. Notifications.showNotificationInTop(notification);
  1390. }
  1391. break;
  1392. case 'dashboard':
  1393. if (!notification.read) {
  1394. Notifications.showNotificationInDashboard(notification);
  1395. }
  1396. break;
  1397. case 'plugins':
  1398. if (!notification.read) {
  1399. Notifications.showNotificationInPlugins(notification);
  1400. }
  1401. break;
  1402. case 'themes':
  1403. if (!notification.read) {
  1404. Notifications.showNotificationInThemes(notification);
  1405. }
  1406. break;
  1407. }
  1408. }
  1409. }]);
  1410. return Notifications;
  1411. }();
  1412. var notifications = new Notifications();
  1413. /* harmony default export */ const updates_notifications = (notifications);
  1414. if (canFetchNotifications()) {
  1415. notifications.fetch();
  1416. /* Hide a notification and store it hidden */
  1417. // <a href="#" data-notification-action="hide-notification" data-notification-id="${notification.id}" class="close hide-notification"><i class="fa fa-close"></i></a>
  1418. external_jQuery_default()(document).on('click', '[data-notification-action="hide-notification"]', function (event) {
  1419. var notification_id = external_jQuery_default()(event.target).parents('.hide-notification').data('notification-id');
  1420. var url = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/notifications.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "hideNotification/notification_id").concat(external_GravAdmin_namespaceObject.config.param_sep).concat(notification_id);
  1421. utils_request(url, {
  1422. method: 'post'
  1423. }, function () {});
  1424. external_jQuery_default()(event.target).parents('.single-notification').hide();
  1425. });
  1426. external_jQuery_default()(document).on('click', '[data-notification-action="hide-notification"]', function (event) {
  1427. var target = external_jQuery_default()(event.currentTarget);
  1428. var notification = target.parent();
  1429. notification.slideUp(function () {
  1430. return notification.remove();
  1431. });
  1432. });
  1433. external_jQuery_default()(document).on('click', '[data-notification-action="show-all-notifications"]', function (event) {
  1434. external_jQuery_default()('#notifications .show-all').hide();
  1435. external_jQuery_default()('#notifications .hidden').removeClass('hidden');
  1436. });
  1437. external_jQuery_default()(document).on('click', '[data-refresh="notifications"]', function (event) {
  1438. event.preventDefault();
  1439. notifications.fetch({
  1440. filter: ['feed'],
  1441. refresh: true
  1442. });
  1443. });
  1444. }
  1445. ;// CONCATENATED MODULE: ./app/updates/feed.js
  1446. function feed_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1447. function feed_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); } }
  1448. function feed_createClass(Constructor, protoProps, staticProps) { if (protoProps) feed_defineProperties(Constructor.prototype, protoProps); if (staticProps) feed_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  1449. var URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/ajax.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getNewsFeed");
  1450. var Feed = /*#__PURE__*/function () {
  1451. function Feed() {
  1452. feed_classCallCheck(this, Feed);
  1453. this.data = null;
  1454. }
  1455. feed_createClass(Feed, [{
  1456. key: "fetch",
  1457. value: function fetch() {
  1458. var _this = this;
  1459. var refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1460. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
  1461. utils_request(URI, {
  1462. method: 'post',
  1463. body: {
  1464. refresh: refresh
  1465. }
  1466. }, function (response) {
  1467. _this.data = response;
  1468. callback(response);
  1469. });
  1470. }
  1471. }, {
  1472. key: "refresh",
  1473. value: function refresh() {
  1474. var _refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1475. var feed = external_jQuery_default()('#news-feed .widget-content');
  1476. if (!feed.length) {
  1477. return;
  1478. }
  1479. var loader = feed.find('.widget-loader');
  1480. loader.find('div').remove();
  1481. loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin');
  1482. loader.show();
  1483. feed.find('> ul').hide();
  1484. if (!this.data || this.data.error || _refresh) {
  1485. this.fetch(_refresh, this.updateContent.bind(this));
  1486. } else {
  1487. this.updateContent();
  1488. }
  1489. }
  1490. }, {
  1491. key: "updateContent",
  1492. value: function updateContent() {
  1493. var feed = external_jQuery_default()('#news-feed .widget-content');
  1494. if (!feed.length) {
  1495. return;
  1496. }
  1497. var loader = feed.find('.widget-loader').hide();
  1498. var content = feed.find('> ul').empty().show();
  1499. if (this.data.error || this.data.status === 'error') {
  1500. loader.show().find('div').remove();
  1501. loader.find('.fa-refresh').removeClass('fa-refresh fa-spin').addClass('fa-warning');
  1502. loader.append("<div>".concat(this.data.error ? this.data.error.message : this.data.message || 'Unable to download news feed', "</div>"));
  1503. return;
  1504. }
  1505. if (this.data && this.data.feed_data) {
  1506. content.append(this.data.feed_data);
  1507. }
  1508. }
  1509. }]);
  1510. return Feed;
  1511. }();
  1512. var feed = new Feed();
  1513. external_jQuery_default()(document).ready(function () {
  1514. return feed.refresh();
  1515. });
  1516. external_jQuery_default()(document).on('click', '[data-refresh="feed"]', function (event) {
  1517. event.preventDefault();
  1518. feed.refresh(true);
  1519. });
  1520. /* harmony default export */ const updates_feed = (feed);
  1521. ;// CONCATENATED MODULE: ./app/updates/check.js
  1522. // Check for updates trigger
  1523. external_jQuery_default()('[data-gpm-checkupdates]').on('click', function () {
  1524. var element = external_jQuery_default()(this);
  1525. element.find('i').addClass('fa-spin');
  1526. gpm_Instance.fetch(function (response) {
  1527. element.find('i').removeClass('fa-spin');
  1528. var payload = response.payload;
  1529. if (!payload) {
  1530. return;
  1531. }
  1532. if (!payload.grav.isUpdatable && !payload.resources.total) {
  1533. utils_toastr.success(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.EVERYTHING_UP_TO_DATE);
  1534. } else {
  1535. var grav = payload.grav.isUpdatable ? 'Grav v' + payload.grav.available : '';
  1536. var resources = payload.resources.total ? payload.resources.total + ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATES_ARE_AVAILABLE : '';
  1537. if (!resources) {
  1538. grav += ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IS_AVAILABLE_FOR_UPDATE;
  1539. }
  1540. utils_toastr.info(grav + (grav && resources ? ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.AND + ' ' : '') + resources);
  1541. }
  1542. }, true);
  1543. });
  1544. ;// CONCATENATED MODULE: ./app/utils/formatbytes.js
  1545. var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
  1546. function formatBytes(bytes, decimals) {
  1547. if (bytes === 0) return '0 Byte';
  1548. var k = 1000;
  1549. var value = Math.floor(Math.log(bytes) / Math.log(k));
  1550. var decimal = decimals + 1 || 3;
  1551. return (bytes / Math.pow(k, value)).toPrecision(decimal) + ' ' + sizes[value];
  1552. }
  1553. ;// CONCATENATED MODULE: ./app/updates/update.js
  1554. // Dashboard update and Grav update
  1555. external_jQuery_default()(document).on('click.remodal', '[data-remodal-id="update-grav"] [data-remodal-action="confirm"]', function () {
  1556. var element = external_jQuery_default()('#grav-update-button');
  1557. element.html("".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATING_PLEASE_WAIT, " ").concat(formatBytes(updates_Instance.payload.grav.assets["grav-update"].size), ".."));
  1558. element.attr('disabled', 'disabled').find('> .fa').removeClass('fa-cloud-download').addClass('fa-refresh fa-spin');
  1559. utils_request(updates_Instance.updateURL, function (response) {
  1560. if (response.type === 'updategrav') {
  1561. external_jQuery_default()('[data-gpm-grav]').remove();
  1562. external_jQuery_default()('#footer .grav-version').html(response.version);
  1563. }
  1564. element.removeAttr('disabled').find('> .fa').removeClass('fa-refresh fa-spin').addClass('fa-cloud-download');
  1565. });
  1566. });
  1567. ;// CONCATENATED MODULE: ./app/updates/channel-switcher.js
  1568. var switcher = external_jQuery_default()('input[type="radio"][name="channel-switch"]');
  1569. if (switcher) {
  1570. switcher.on('change', function (event) {
  1571. var radio = external_jQuery_default()(event.target);
  1572. var url = "".concat(radio.parent('[data-url]').data('url'));
  1573. utils_request(url, {
  1574. method: 'post',
  1575. body: {
  1576. task: 'gpmRelease',
  1577. release: radio.val()
  1578. }
  1579. }, function (response) {
  1580. if (response.reload) {
  1581. __webpack_require__.g.location.reload();
  1582. }
  1583. });
  1584. });
  1585. }
  1586. ;// CONCATENATED MODULE: ./app/updates/index.js
  1587. function updates_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1588. function updates_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); } }
  1589. function updates_createClass(Constructor, protoProps, staticProps) { if (protoProps) updates_defineProperties(Constructor.prototype, protoProps); if (staticProps) updates_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  1590. var Updates = /*#__PURE__*/function () {
  1591. function Updates() {
  1592. var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1593. updates_classCallCheck(this, Updates);
  1594. this.setPayload(payload);
  1595. this.task = "task".concat(external_GravAdmin_namespaceObject.config.param_sep);
  1596. this.updateURL = '';
  1597. }
  1598. updates_createClass(Updates, [{
  1599. key: "setPayload",
  1600. value: function setPayload() {
  1601. var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1602. this.payload = payload;
  1603. return this;
  1604. }
  1605. }, {
  1606. key: "fetch",
  1607. value: function fetch() {
  1608. var _this = this;
  1609. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1610. gpm_Instance.fetch(function (response) {
  1611. return _this.setPayload(response);
  1612. }, force);
  1613. return this;
  1614. }
  1615. }, {
  1616. key: "maintenance",
  1617. value: function maintenance() {
  1618. var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'hide';
  1619. var element = external_jQuery_default()('#updates [data-update-packages]');
  1620. element[mode === 'show' ? 'fadeIn' : 'fadeOut']();
  1621. if (mode === 'hide') {
  1622. external_jQuery_default()('.badges.with-updates').removeClass('with-updates').find('.badge.updates').remove();
  1623. }
  1624. return this;
  1625. }
  1626. }, {
  1627. key: "grav",
  1628. value: function grav() {
  1629. var payload = this.payload.grav;
  1630. if (payload && payload.isUpdatable) {
  1631. var task = this.task;
  1632. var bar = '';
  1633. if (!payload.isSymlink) {
  1634. this.updateURL = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/update.json/").concat(task, "updategrav/admin-nonce").concat(external_GravAdmin_namespaceObject.config.param_sep).concat(external_GravAdmin_namespaceObject.config.admin_nonce);
  1635. bar += "<button data-remodal-target=\"update-grav\" class=\"button button-small secondary pointer-events-none\" id=\"grav-update-button\">".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATE_GRAV_NOW, " <span class=\"cnt-down\">(5s)</span></button>");
  1636. } else {
  1637. bar += "<span class=\"hint--left\" style=\"float: right;\" data-hint=\"".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.GRAV_SYMBOLICALLY_LINKED, "\"><i class=\"fa fa-fw fa-link\"></i></span>");
  1638. }
  1639. bar += "\n Grav <b>v".concat(payload.available, "</b> ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IS_NOW_AVAILABLE, "! <span class=\"less\">(").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.CURRENT, " v").concat(payload.version, ")</span>\n ");
  1640. var element = external_jQuery_default()('[data-gpm-grav]').removeClass('hidden');
  1641. if (element.is(':empty')) {
  1642. element.hide();
  1643. }
  1644. element.addClass('grav').html("".concat(bar)).slideDown(150, function () {
  1645. var c = 5;
  1646. var x = setInterval(function () {
  1647. c -= 1;
  1648. element.find('.pointer-events-none .cnt-down').text('(' + c + 's)');
  1649. }, 1000);
  1650. setTimeout(function () {
  1651. clearInterval(x);
  1652. element.find('.pointer-events-none .cnt-down').remove();
  1653. element.find('.pointer-events-none').removeClass('pointer-events-none');
  1654. }, 5000);
  1655. }).parent('#messages').addClass('default-box-shadow');
  1656. }
  1657. return this;
  1658. }
  1659. }, {
  1660. key: "resources",
  1661. value: function resources() {
  1662. if (!this.payload || !this.payload.resources || !this.payload.resources.total) {
  1663. return this.maintenance('hide');
  1664. }
  1665. var is_current_package_latest = true;
  1666. var map = ['plugins', 'themes'];
  1667. var singles = ['plugin', 'theme'];
  1668. var _this$payload$resourc = this.payload.resources,
  1669. plugins = _this$payload$resourc.plugins,
  1670. themes = _this$payload$resourc.themes;
  1671. if (!this.payload.resources.total) {
  1672. return this;
  1673. }
  1674. [plugins, themes].forEach(function (resources, index) {
  1675. if (!resources || Array.isArray(resources)) {
  1676. return;
  1677. }
  1678. var length = Object.keys(resources).length;
  1679. var type = map[index]; // sidebar
  1680. external_jQuery_default()("#admin-menu a[href$=\"/".concat(map[index], "\"]")).find('.badges').addClass('with-updates').find('.badge.updates').text(length);
  1681. var type_translation = ''; // update all
  1682. if (type === 'plugins') {
  1683. type_translation = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PLUGINS;
  1684. } else {
  1685. type_translation = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.THEMES;
  1686. }
  1687. var updateAll = external_jQuery_default()(".grav-update.".concat(type));
  1688. updateAll.css('display', 'block').html("\n <p>\n <a href=\"#\" class=\"button button-small secondary\" data-remodal-target=\"update-packages\" data-packages-slugs=\"".concat(Object.keys(resources).join(), "\" data-").concat(singles[index], "-action=\"start-packages-update\">").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATE, " ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ALL, " ").concat(type_translation, "</a>\n <i class=\"fa fa-bullhorn\"></i>\n ").concat(length, " ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.OF_YOUR, " ").concat(type_translation.toLowerCase(), " ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.HAVE_AN_UPDATE_AVAILABLE, "\n </p>\n "));
  1689. var existing_slugs = external_jQuery_default()('[data-update-packages]').attr('data-packages-slugs') || '';
  1690. if (existing_slugs) {
  1691. existing_slugs = existing_slugs.split(',');
  1692. } else {
  1693. existing_slugs = [];
  1694. }
  1695. var slugs = unique_default()(existing_slugs.concat(Object.keys(resources))).join();
  1696. external_jQuery_default()('[data-update-packages]').attr('data-packages-slugs', "".concat(slugs));
  1697. Object.keys(resources).forEach(function (item) {
  1698. // listing page
  1699. var container = external_jQuery_default()("[data-gpm-".concat(singles[index], "=\"").concat(item, "\"]"));
  1700. var element = container.find('.gpm-name');
  1701. var url = element.find('a');
  1702. var content_wrapper = container.parents('.content-wrapper');
  1703. if (type === 'plugins' && !element.find('.badge.update').length) {
  1704. element.append("<a class=\"plugin-update-button\" href=\"".concat(url.attr('href'), "\"><span class=\"badge update\">").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATE_AVAILABLE, "!</span></a>"));
  1705. content_wrapper.addClass('has-updates');
  1706. } else if (type === 'themes') {
  1707. element.append("<div class=\"gpm-ribbon\"><a href=\"".concat(url.attr('href'), "\">").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATE.toUpperCase(), "</a></div>"));
  1708. content_wrapper.addClass('has-updates');
  1709. } // details page
  1710. if (container.length) {
  1711. var details = external_jQuery_default()(".grav-update.".concat(singles[index]));
  1712. if (details.length) {
  1713. var releaseType = resources[item].type === 'testing' ? '<span class="gpm-testing">test release</span>' : '';
  1714. details.html("\n <p>\n <a href=\"#\" class=\"button button-small secondary\" data-remodal-target=\"update-packages\" data-packages-slugs=\"".concat(item, "\" data-").concat(singles[index], "-action=\"start-package-installation\">").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATE, " ").concat(singles[index].charAt(0).toUpperCase() + singles[index].substr(1).toLowerCase(), "</a>\n <i class=\"fa fa-bullhorn\"></i>\n <strong>v").concat(resources[item].available, "</strong> ").concat(releaseType, " ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.OF_THIS, " ").concat(singles[index], " ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IS_NOW_AVAILABLE, "!\n </p>\n ")).css('display', 'block');
  1715. is_current_package_latest = false;
  1716. }
  1717. }
  1718. });
  1719. external_jQuery_default()('[data-update-packages]').removeClass('hidden');
  1720. });
  1721. external_jQuery_default()('.content-wrapper').addClass('updates-checked');
  1722. if (!is_current_package_latest) {
  1723. external_jQuery_default()('.warning-reinstall-not-latest-release').removeClass('hidden');
  1724. }
  1725. }
  1726. }]);
  1727. return Updates;
  1728. }();
  1729. var updates_Instance = new Updates();
  1730. // automatically refresh UI for updates (graph, sidebar, plugin/themes pages) after every fetch
  1731. gpm_Instance.on('fetched', function (response, raw) {
  1732. updates_Instance.setPayload(response.payload || {});
  1733. updates_Instance.grav().resources();
  1734. });
  1735. if (external_GravAdmin_namespaceObject.config.enable_auto_updates_check === '1') {
  1736. gpm_Instance.fetch();
  1737. }
  1738. // EXTERNAL MODULE: ./node_modules/chartist/dist/chartist.js
  1739. var chartist = __webpack_require__(69259);
  1740. var chartist_default = /*#__PURE__*/__webpack_require__.n(chartist);
  1741. ;// CONCATENATED MODULE: ./app/dashboard/chart.js
  1742. function chart_typeof(obj) { "@babel/helpers - typeof"; return chart_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, chart_typeof(obj); }
  1743. function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
  1744. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = chart_getPrototypeOf(object); if (object === null) break; } return object; }
  1745. function chart_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) chart_setPrototypeOf(subClass, superClass); }
  1746. function chart_setPrototypeOf(o, p) { chart_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return chart_setPrototypeOf(o, p); }
  1747. function chart_createSuper(Derived) { var hasNativeReflectConstruct = chart_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = chart_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = chart_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return chart_possibleConstructorReturn(this, result); }; }
  1748. function chart_possibleConstructorReturn(self, call) { if (call && (chart_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return chart_assertThisInitialized(self); }
  1749. function chart_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  1750. function chart_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1751. function chart_getPrototypeOf(o) { chart_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return chart_getPrototypeOf(o); }
  1752. function chart_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1753. function chart_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); } }
  1754. function chart_createClass(Constructor, protoProps, staticProps) { if (protoProps) chart_defineProperties(Constructor.prototype, protoProps); if (staticProps) chart_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  1755. // let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  1756. var defaults = {
  1757. data: {
  1758. series: [100, 0]
  1759. },
  1760. options: {
  1761. Pie: {
  1762. donut: true,
  1763. donutWidth: 10,
  1764. startAngle: 0,
  1765. total: 100,
  1766. showLabel: false,
  1767. height: 150,
  1768. // chartPadding: !isFirefox ? 10 : 25 // workaround for older versions of firefox
  1769. chartPadding: 5
  1770. },
  1771. Bar: {
  1772. height: 164,
  1773. chartPadding: 20,
  1774. // workaround for older versions of firefox
  1775. axisX: {
  1776. showGrid: false,
  1777. labelOffset: {
  1778. x: 0,
  1779. y: 0
  1780. }
  1781. },
  1782. axisY: {
  1783. offset: 15,
  1784. showLabel: true,
  1785. showGrid: true,
  1786. labelOffset: {
  1787. x: 5,
  1788. y: 5
  1789. },
  1790. scaleMinSpace: 25
  1791. }
  1792. }
  1793. }
  1794. };
  1795. var Chart = /*#__PURE__*/function () {
  1796. function Chart(element) {
  1797. var _this = this;
  1798. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1799. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1800. chart_classCallCheck(this, Chart);
  1801. this.element = external_jQuery_default()(element) || [];
  1802. if (!this.element[0]) {
  1803. return;
  1804. }
  1805. var type = (this.element.data('chart-type') || 'pie').toLowerCase();
  1806. this.type = type.charAt(0).toUpperCase() + type.substr(1).toLowerCase();
  1807. options = Object.assign({}, defaults.options[this.type], options);
  1808. data = Object.assign({}, defaults.data, data);
  1809. Object.assign(this, {
  1810. options: options,
  1811. data: data
  1812. });
  1813. this.chart = (chartist_default())[this.type](this.element.find('.ct-chart').empty()[0], this.data, this.options);
  1814. this.chart.on('created', function () {
  1815. _this.element.find('.hidden').removeClass('hidden'); // FIX: workaround for chartist issue not allowing HTML in labels anymore
  1816. // https://github.com/gionkunz/chartist-js/issues/937
  1817. _this.element.find('.ct-label').each(function (index, label) {
  1818. label = external_jQuery_default()(label);
  1819. var text = label.html().replace('&lt;', '<').replace('&gt;', '>');
  1820. label.html(text);
  1821. });
  1822. });
  1823. }
  1824. chart_createClass(Chart, [{
  1825. key: "updateData",
  1826. value: function updateData(data) {
  1827. Object.assign(this.data, data);
  1828. this.chart.update(this.data);
  1829. }
  1830. }]);
  1831. return Chart;
  1832. }();
  1833. ;
  1834. var UpdatesChart = /*#__PURE__*/function (_Chart) {
  1835. chart_inherits(UpdatesChart, _Chart);
  1836. var _super = chart_createSuper(UpdatesChart);
  1837. function UpdatesChart(element) {
  1838. var _this2;
  1839. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1840. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1841. chart_classCallCheck(this, UpdatesChart);
  1842. _this2 = _super.call(this, element, options, data);
  1843. _this2.chart.on('draw', function (data) {
  1844. return _this2.draw(data);
  1845. });
  1846. gpm_Instance.on('fetched', function (response) {
  1847. if (!response.payload) {
  1848. return;
  1849. }
  1850. var payload = response.payload.grav;
  1851. var missing = (response.payload.resources.total + (payload.isUpdatable ? 1 : 0)) * 100 / (response.payload.installed + (payload.isUpdatable ? 1 : 0));
  1852. var updated = 100 - missing;
  1853. _this2.updateData({
  1854. series: [updated, missing]
  1855. });
  1856. if (response.payload.resources.total) {
  1857. updates_Instance.maintenance('show');
  1858. }
  1859. });
  1860. return _this2;
  1861. }
  1862. chart_createClass(UpdatesChart, [{
  1863. key: "draw",
  1864. value: function draw(data) {
  1865. if (data.index) {
  1866. return;
  1867. }
  1868. var notice = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN[data.value === 100 ? 'FULLY_UPDATED' : 'UPDATES_AVAILABLE'];
  1869. this.element.find('.numeric span').text("".concat(Math.round(data.value), "%"));
  1870. this.element.find('.js__updates-available-description').html(notice);
  1871. this.element.find('.hidden').removeClass('hidden');
  1872. }
  1873. }, {
  1874. key: "updateData",
  1875. value: function updateData(data) {
  1876. _get(chart_getPrototypeOf(UpdatesChart.prototype), "updateData", this).call(this, data); // missing updates
  1877. if (this.data.series[0] < 100) {
  1878. this.element.closest('#updates').find('[data-update-packages]').fadeIn();
  1879. }
  1880. }
  1881. }]);
  1882. return UpdatesChart;
  1883. }(Chart);
  1884. var charts = {};
  1885. external_jQuery_default()('[data-chart-name]').each(function () {
  1886. var element = external_jQuery_default()(this);
  1887. var name = element.data('chart-name') || '';
  1888. var options = element.data('chart-options') || {};
  1889. var data = element.data('chart-data') || {};
  1890. if (name === 'updates') {
  1891. charts[name] = new UpdatesChart(element, options, data);
  1892. } else {
  1893. charts[name] = new Chart(element, options, data);
  1894. }
  1895. });
  1896. var Instances = charts;
  1897. ;// CONCATENATED MODULE: ./app/dashboard/cache.js
  1898. function cache_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1899. function cache_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); } }
  1900. function cache_createClass(Constructor, protoProps, staticProps) { if (protoProps) cache_defineProperties(Constructor.prototype, protoProps); if (staticProps) cache_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  1901. var getUrl = function getUrl() {
  1902. var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  1903. if (type) {
  1904. type = "cleartype:".concat(type, "/");
  1905. }
  1906. return "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/cache.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "clearCache/").concat(type, "admin-nonce").concat(external_GravAdmin_namespaceObject.config.param_sep).concat(external_GravAdmin_namespaceObject.config.admin_nonce);
  1907. };
  1908. var Cache = /*#__PURE__*/function () {
  1909. function Cache() {
  1910. var _this = this;
  1911. cache_classCallCheck(this, Cache);
  1912. this.element = external_jQuery_default()('[data-clear-cache]');
  1913. external_jQuery_default()('body').on('click', '[data-clear-cache]', function (event) {
  1914. return _this.clear(event, event.target);
  1915. });
  1916. }
  1917. cache_createClass(Cache, [{
  1918. key: "clear",
  1919. value: function clear(event, element) {
  1920. var _this2 = this;
  1921. var type = '';
  1922. if (event && event.preventDefault) {
  1923. event.preventDefault();
  1924. }
  1925. if (typeof event === 'string') {
  1926. type = event;
  1927. }
  1928. element = element ? external_jQuery_default()(element) : external_jQuery_default()("[data-clear-cache-type=\"".concat(type, "\"]"));
  1929. type = type || external_jQuery_default()(element).data('clear-cache-type') || '';
  1930. var url = element.data('clearCache') || getUrl(type);
  1931. this.disable();
  1932. utils_request(url, function () {
  1933. return _this2.enable();
  1934. });
  1935. }
  1936. }, {
  1937. key: "enable",
  1938. value: function enable() {
  1939. this.element.removeAttr('disabled').find('> .fa').removeClass('fa-refresh fa-spin fa-retweet').addClass('fa-retweet');
  1940. }
  1941. }, {
  1942. key: "disable",
  1943. value: function disable() {
  1944. this.element.attr('disabled', 'disabled').find('> .fa').removeClass('fa-retweet').addClass('fa-refresh fa-spin');
  1945. }
  1946. }]);
  1947. return Cache;
  1948. }();
  1949. var cache_Instance = new Cache();
  1950. ;// CONCATENATED MODULE: ./app/dashboard/backup.js
  1951. external_jQuery_default()('[data-backup][data-ajax*="backup/"]').on('click', function () {
  1952. var element = external_jQuery_default()(this);
  1953. var url = element.data('ajax');
  1954. var inDropdown = element.closest('.dropdown-menu');
  1955. (inDropdown.length ? inDropdown : element).closest('.button-group').find('> button:first').attr('disabled', 'disabled').find('> .fa').removeClass('fa-life-ring').addClass('fa-spin fa-refresh');
  1956. utils_request(url, function
  1957. /* response */
  1958. () {
  1959. if (Instances && Instances.backups) {
  1960. Instances.backups.updateData({
  1961. series: [0, 100]
  1962. });
  1963. Instances.backups.element.find('.numeric').html("0 <em>".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DAYS.toLowerCase(), "</em>"));
  1964. }
  1965. (inDropdown.length ? inDropdown : element).closest('.button-group').find('> button:first').removeAttr('disabled').find('> .fa').removeClass('fa-spin fa-refresh').addClass('fa-life-ring');
  1966. });
  1967. });
  1968. external_jQuery_default()('[data-backup][data-ajax*="backupDelete"]').on('click', function () {
  1969. var element = external_jQuery_default()(this);
  1970. var url = element.data('ajax');
  1971. var tr = element.closest('tr');
  1972. tr.addClass('deleting');
  1973. utils_request(url, function (response) {
  1974. if (response.status === 'success') {
  1975. tr.remove();
  1976. } else {
  1977. tr.removeClass('deleting');
  1978. }
  1979. });
  1980. });
  1981. ;// CONCATENATED MODULE: ./app/dashboard/index.js
  1982. /* harmony default export */ const dashboard = ({
  1983. Chart: {
  1984. Chart: Chart,
  1985. UpdatesChart: UpdatesChart,
  1986. Instances: Instances
  1987. },
  1988. Cache: cache_Instance
  1989. });
  1990. // EXTERNAL MODULE: ./node_modules/sortablejs/modular/sortable.esm.js
  1991. var sortable_esm = __webpack_require__(51474);
  1992. // EXTERNAL MODULE: ./node_modules/debounce/index.js
  1993. var debounce = __webpack_require__(20296);
  1994. var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce);
  1995. // EXTERNAL MODULE: ./app/utils/storage.js
  1996. var storage = __webpack_require__(31619);
  1997. ;// CONCATENATED MODULE: ./app/pages/tree.js
  1998. function tree_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1999. function tree_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); } }
  2000. function tree_createClass(Constructor, protoProps, staticProps) { if (protoProps) tree_defineProperties(Constructor.prototype, protoProps); if (staticProps) tree_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2001. var sessionKey = 'grav:admin:pages';
  2002. if (!sessionStorage.getItem(sessionKey)) {
  2003. sessionStorage.setItem(sessionKey, '{}');
  2004. }
  2005. var PagesTree = /*#__PURE__*/function () {
  2006. function PagesTree(query) {
  2007. var _this = this;
  2008. var elements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
  2009. tree_classCallCheck(this, PagesTree);
  2010. this.query = query;
  2011. this.elements = external_jQuery_default()(elements !== undefined ? elements : this.query);
  2012. this.session = JSON.parse(sessionStorage.getItem(sessionKey) || '{}');
  2013. if (!this.elements.length) {
  2014. return;
  2015. }
  2016. this.restore();
  2017. this.elements.find('.page-icon').on('click', function (event) {
  2018. return _this.toggle(event.target);
  2019. });
  2020. this.elements.data('tree_init', 1);
  2021. external_jQuery_default()('[data-page-toggleall]').on('click', function (event) {
  2022. var element = external_jQuery_default()(event.target).closest('[data-page-toggleall]');
  2023. var action = element.data('page-toggleall');
  2024. _this[action]();
  2025. });
  2026. }
  2027. tree_createClass(PagesTree, [{
  2028. key: "reload",
  2029. value: function reload() {
  2030. var elements = external_jQuery_default()(this.query).filter(function (index, element) {
  2031. return !external_jQuery_default()(element).data('tree_init');
  2032. });
  2033. if (!elements.length) {
  2034. return;
  2035. }
  2036. this.constructor(this.query, elements);
  2037. }
  2038. }, {
  2039. key: "toggle",
  2040. value: function toggle(elements) {
  2041. var _this2 = this;
  2042. var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2043. if (typeof elements === 'string') {
  2044. elements = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]")).find('[data-toggle="children"]');
  2045. }
  2046. elements = external_jQuery_default()(elements || this.elements);
  2047. elements.each(function (index, element) {
  2048. element = external_jQuery_default()(element);
  2049. var state = _this2.getState(element.closest('[data-toggle="children"]'));
  2050. _this2[state.isOpen ? 'collapse' : 'expand'](state.id, dontStore);
  2051. });
  2052. }
  2053. }, {
  2054. key: "collapse",
  2055. value: function collapse(elements) {
  2056. var _this3 = this;
  2057. var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2058. if (typeof elements === 'string') {
  2059. elements = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]")).find('[data-toggle="children"]');
  2060. }
  2061. elements = external_jQuery_default()(elements || this.elements);
  2062. elements.each(function (index, element) {
  2063. element = external_jQuery_default()(element);
  2064. var state = _this3.getState(element);
  2065. if (state.isOpen) {
  2066. state.children.hide();
  2067. state.icon.removeClass('children-open').addClass('children-closed');
  2068. if (!dontStore) {
  2069. delete _this3.session[state.id];
  2070. }
  2071. }
  2072. });
  2073. if (!dontStore) {
  2074. this.save();
  2075. }
  2076. }
  2077. }, {
  2078. key: "expand",
  2079. value: function expand(elements) {
  2080. var _this4 = this;
  2081. var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2082. if (typeof elements === 'string') {
  2083. var element = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]"));
  2084. var parents = element.parents('[data-nav-id]'); // loop back through parents, we don't want to expand an hidden child
  2085. if (parents.length) {
  2086. parents = parents.find('[data-toggle="children"]:first');
  2087. parents = parents.add(element.find('[data-toggle="children"]:first'));
  2088. return this.expand(parents, dontStore);
  2089. }
  2090. elements = element.find('[data-toggle="children"]:first');
  2091. }
  2092. elements = external_jQuery_default()(elements || this.elements);
  2093. elements.each(function (index, element) {
  2094. element = external_jQuery_default()(element);
  2095. var state = _this4.getState(element);
  2096. if (!state.isOpen) {
  2097. state.children.show();
  2098. state.icon.removeClass('children-closed').addClass('children-open');
  2099. if (!dontStore) {
  2100. _this4.session[state.id] = 1;
  2101. }
  2102. }
  2103. });
  2104. if (!dontStore) {
  2105. this.save();
  2106. }
  2107. }
  2108. }, {
  2109. key: "restore",
  2110. value: function restore() {
  2111. var _this5 = this;
  2112. this.collapse(null, true);
  2113. Object.keys(this.session).forEach(function (key) {
  2114. _this5.expand(key, 'no-store');
  2115. });
  2116. }
  2117. }, {
  2118. key: "save",
  2119. value: function save() {
  2120. return sessionStorage.setItem(sessionKey, JSON.stringify(this.session));
  2121. }
  2122. }, {
  2123. key: "getState",
  2124. value: function getState(element) {
  2125. element = external_jQuery_default()(element);
  2126. return {
  2127. id: element.closest('[data-nav-id]').data('nav-id'),
  2128. children: element.closest('li.page-item').find('ul:first'),
  2129. icon: element.find('.page-icon'),
  2130. get isOpen() {
  2131. return this.icon.hasClass('children-open');
  2132. }
  2133. };
  2134. }
  2135. }]);
  2136. return PagesTree;
  2137. }();
  2138. var tree_Instance = new PagesTree('[data-toggle="children"]');
  2139. // EXTERNAL MODULE: ./node_modules/selectize/dist/js/selectize.js
  2140. var selectize = __webpack_require__(25703);
  2141. var selectize_default = /*#__PURE__*/__webpack_require__.n(selectize);
  2142. ;// CONCATENATED MODULE: ./app/utils/selectize-required-fix.js
  2143. /**
  2144. * This is a plugin to override the `.refreshValidityState` method of
  2145. * the Selectize library (https://selectize.github.io/selectize.js/).
  2146. * The library is not maintained anymore (as of 2017-09-13) and contains
  2147. * a bug which causes Microsoft Edge to not work with selectized [required]
  2148. * form fields. This plugin should be removed if
  2149. * https://github.com/selectize/selectize.js/pull/1320 is ever merged
  2150. * and a new version of Selectize gets released.
  2151. */
  2152. selectize_default().define('required-fix', function (options) {
  2153. var _this = this;
  2154. this.refreshValidityState = function () {
  2155. if (!_this.isRequired) return false;
  2156. var invalid = !_this.items.length;
  2157. _this.isInvalid = invalid;
  2158. if (invalid) {
  2159. _this.$control_input.attr('required', '');
  2160. _this.$input.removeAttr('required');
  2161. } else {
  2162. _this.$control_input.removeAttr('required');
  2163. _this.$input.attr('required');
  2164. }
  2165. };
  2166. });
  2167. ;// CONCATENATED MODULE: ./app/pages/filter.js
  2168. function filter_typeof(obj) { "@babel/helpers - typeof"; return filter_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, filter_typeof(obj); }
  2169. function filter_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2170. function filter_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); } }
  2171. function filter_createClass(Constructor, protoProps, staticProps) { if (protoProps) filter_defineProperties(Constructor.prototype, protoProps); if (staticProps) filter_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2172. /* @formatter:off */
  2173. /* eslint-disable */
  2174. var options = [{
  2175. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.MODULE,
  2176. key: 'Module',
  2177. cat: 'mode'
  2178. }, {
  2179. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.VISIBLE,
  2180. key: 'Visible',
  2181. cat: 'mode'
  2182. }, {
  2183. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ROUTABLE,
  2184. key: 'Routable',
  2185. cat: 'mode'
  2186. }, {
  2187. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PUBLISHED,
  2188. key: 'Published',
  2189. cat: 'mode'
  2190. }, {
  2191. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_MODULE,
  2192. key: 'NonModule',
  2193. cat: 'mode'
  2194. }, {
  2195. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_VISIBLE,
  2196. key: 'NonVisible',
  2197. cat: 'mode'
  2198. }, {
  2199. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_ROUTABLE,
  2200. key: 'NonRoutable',
  2201. cat: 'mode'
  2202. }, {
  2203. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_PUBLISHED,
  2204. key: 'NonPublished',
  2205. cat: 'mode'
  2206. }];
  2207. /* @formatter:on */
  2208. /* eslint-enable */
  2209. var PagesFilter = /*#__PURE__*/function () {
  2210. function PagesFilter(filters, search) {
  2211. var _this = this;
  2212. filter_classCallCheck(this, PagesFilter);
  2213. this.filters = external_jQuery_default()(filters);
  2214. this.search = external_jQuery_default()(search);
  2215. this.options = options;
  2216. this.tree = tree_Instance;
  2217. var storage = JSON.parse(localStorage.getItem('grav:admin:pages:filter') || '{}');
  2218. if (!this.filters.length || !this.search.length) {
  2219. return;
  2220. }
  2221. this.labels = this.filters.data('filter-labels');
  2222. this.search.on('input', debounce_default()(function () {
  2223. return _this.filter();
  2224. }, 250));
  2225. this.filters.on('change', function () {
  2226. return _this.filter();
  2227. }); // restore state
  2228. if (storage.flags || storage.query) {
  2229. this.setValues(storage);
  2230. this.filter();
  2231. }
  2232. this._initSelectize();
  2233. }
  2234. filter_createClass(PagesFilter, [{
  2235. key: "filter",
  2236. value: function filter(value) {
  2237. var _this2 = this;
  2238. var data = {
  2239. flags: '',
  2240. query: ''
  2241. };
  2242. if (filter_typeof(value) === 'object') {
  2243. Object.assign(data, value);
  2244. }
  2245. if (typeof value === 'string') {
  2246. data.query = value;
  2247. }
  2248. if (typeof value === 'undefined') {
  2249. data.flags = this.filters.val();
  2250. data.query = this.search.val();
  2251. }
  2252. if (!Object.keys(data).filter(function (key) {
  2253. return data[key] !== '';
  2254. }).length) {
  2255. this.resetValues();
  2256. return;
  2257. }
  2258. data.flags = data.flags.replace(/(\s{1,})?,(\s{1,})?/g, ',');
  2259. this.setValues({
  2260. flags: data.flags,
  2261. query: data.query
  2262. }, 'silent');
  2263. utils_request("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/pages-filter.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "filterPages"), {
  2264. method: 'post',
  2265. body: data
  2266. }, function (response) {
  2267. _this2.refreshDOM(response);
  2268. });
  2269. }
  2270. }, {
  2271. key: "refreshDOM",
  2272. value: function refreshDOM(response) {
  2273. var _this3 = this;
  2274. var items = external_jQuery_default()('[data-nav-id]');
  2275. if (!response) {
  2276. items.removeClass('search-match').show();
  2277. this.tree.restore();
  2278. return;
  2279. }
  2280. items.removeClass('search-match').hide();
  2281. response.results.forEach(function (page) {
  2282. var match = items.filter("[data-nav-id=\"".concat(page, "\"]")).addClass('search-match').show();
  2283. match.parents('[data-nav-id]').addClass('search-match').show();
  2284. _this3.tree.expand(page, 'no-store');
  2285. });
  2286. }
  2287. }, {
  2288. key: "setValues",
  2289. value: function setValues(_ref, silent) {
  2290. var _ref$flags = _ref.flags,
  2291. flags = _ref$flags === void 0 ? '' : _ref$flags,
  2292. _ref$query = _ref.query,
  2293. query = _ref$query === void 0 ? '' : _ref$query;
  2294. var flagsArray = flags.replace(/(\s{1,})?,(\s{1,})?/g, ',').split(',');
  2295. if (this.filters.val() !== flags) {
  2296. var selectize = this.filters.data('selectize');
  2297. this.filters[selectize ? 'setValue' : 'val'](flagsArray, silent);
  2298. }
  2299. if (this.search.val() !== query) {
  2300. this.search.val(query);
  2301. }
  2302. localStorage.setItem('grav:admin:pages:filter', JSON.stringify({
  2303. flags: flags,
  2304. query: query
  2305. }));
  2306. }
  2307. }, {
  2308. key: "resetValues",
  2309. value: function resetValues() {
  2310. this.setValues('', 'silent');
  2311. this.refreshDOM();
  2312. }
  2313. }, {
  2314. key: "_initSelectize",
  2315. value: function _initSelectize() {
  2316. var _this4 = this;
  2317. var extras = {
  2318. type: this.filters.data('filter-types') || {},
  2319. access: this.filters.data('filter-access-levels') || {}
  2320. };
  2321. Object.keys(extras).forEach(function (cat) {
  2322. Object.keys(extras[cat]).forEach(function (key) {
  2323. _this4.options.push({
  2324. cat: cat,
  2325. key: key,
  2326. flag: extras[cat][key]
  2327. });
  2328. });
  2329. });
  2330. this.filters.selectize({
  2331. maxItems: null,
  2332. valueField: 'key',
  2333. labelField: 'flag',
  2334. searchField: ['flag', 'key'],
  2335. options: this.options,
  2336. optgroups: this.labels,
  2337. optgroupField: 'cat',
  2338. optgroupLabelField: 'name',
  2339. optgroupValueField: 'id',
  2340. optgroupOrder: this.labels.map(function (item) {
  2341. return item.id;
  2342. }),
  2343. plugins: ['optgroup_columns', 'required-fix']
  2344. });
  2345. }
  2346. }]);
  2347. return PagesFilter;
  2348. }();
  2349. var filter_Instance = new PagesFilter('input[name="page-filter"]', 'input[name="page-search"]');
  2350. // EXTERNAL MODULE: ./node_modules/speakingurl/index.js
  2351. var speakingurl = __webpack_require__(989);
  2352. var speakingurl_default = /*#__PURE__*/__webpack_require__.n(speakingurl);
  2353. ;// CONCATENATED MODULE: ./app/utils/jquery-utils.js
  2354. var _this = undefined;
  2355. // jQuery no parents filter
  2356. (external_jQuery_default()).expr[":"].noparents = external_jQuery_default().expr.createPseudo(function (text) {
  2357. return function (element) {
  2358. return external_jQuery_default()(element).parents(text).length < 1;
  2359. };
  2360. }); // Slugify
  2361. // CommonJS and ES6 version of https://github.com/madflow/jquery-slugify
  2362. (external_jQuery_default()).fn.slugify = function (source, options) {
  2363. return _this.each(function (element) {
  2364. var target = external_jQuery_default()(element);
  2365. var source = external_jQuery_default()(source);
  2366. target.on('keyup change', function () {
  2367. target.data('locked', target.val() !== '' && target.val() !== undefined);
  2368. });
  2369. source.on('keyup change', function () {
  2370. if (target.data('locked') === true) {
  2371. return true;
  2372. }
  2373. var isInput = target.is('input') || target.is('textarea');
  2374. target[isInput ? 'val' : 'text'](external_jQuery_default().slugify(source.val(), options));
  2375. });
  2376. });
  2377. }; // Static method.
  2378. (external_jQuery_default()).slugify = function (sourceString, options) {
  2379. options = external_jQuery_default().extend({}, (external_jQuery_default()).slugify.options, options);
  2380. options.lang = options.lang || external_jQuery_default()('html').prop('lang');
  2381. if (typeof options.preSlug === 'function') {
  2382. sourceString = options.preSlug(sourceString);
  2383. }
  2384. sourceString = options.slugFunc(sourceString, options);
  2385. if (typeof options.postSlug === 'function') {
  2386. sourceString = options.postSlug(sourceString);
  2387. }
  2388. return sourceString;
  2389. }; // Default plugin options
  2390. (external_jQuery_default()).slugify.options = {
  2391. preSlug: null,
  2392. postSlug: null,
  2393. slugFunc: function slugFunc(input, opts) {
  2394. return speakingurl_default()(input, opts);
  2395. }
  2396. };
  2397. ;// CONCATENATED MODULE: ./app/pages/page/add.js
  2398. var custom = false;
  2399. var folder = external_jQuery_default()('[data-remodal-id="modal"] input[name="data[folder]"], [data-remodal-id="module"] input[name="data[folder]"], [data-remodal-id="modal-page-copy"] input[name="data[folder]"]');
  2400. var title = external_jQuery_default()('[data-remodal-id="modal"] input[name="data[title]"], [data-remodal-id="module"] input[name="data[title]"], [data-remodal-id="modal-page-copy"] input[name="data[title]"]');
  2401. var getFields = function getFields(type, target) {
  2402. target = external_jQuery_default()(target);
  2403. var query = "[data-remodal-id=\"".concat(target.closest('[data-remodal-id]').data('remodal-id'), "\"]");
  2404. return {
  2405. title: type === 'title' ? external_jQuery_default()(target) : external_jQuery_default()("".concat(query, " input[name=\"data[title]\"]")),
  2406. folder: type === 'folder' ? external_jQuery_default()(target) : external_jQuery_default()("".concat(query, " input[name=\"data[folder]\"]"))
  2407. };
  2408. };
  2409. title.on('input focus blur', function (event) {
  2410. if (custom) {
  2411. return true;
  2412. }
  2413. var elements = getFields('title', event.currentTarget);
  2414. var slug = external_jQuery_default().slugify(elements.title.val(), {
  2415. custom: {
  2416. "'": '',
  2417. '‘': '',
  2418. '’': ''
  2419. }
  2420. });
  2421. elements.folder.val(slug);
  2422. });
  2423. folder.on('input', function (event) {
  2424. var elements = getFields('folder', event.currentTarget);
  2425. var input = elements.folder.get(0);
  2426. var value = elements.folder.val();
  2427. var selection = {
  2428. start: input.selectionStart,
  2429. end: input.selectionEnd
  2430. };
  2431. value = value.toLowerCase().replace(/\s/g, '-').replace(/[^a-z0-9_\-]/g, '');
  2432. elements.folder.val(value);
  2433. custom = !!value; // restore cursor position
  2434. input.setSelectionRange(selection.start, selection.end);
  2435. });
  2436. folder.on('focus blur', function (event) {
  2437. getFields('title').title.trigger('input');
  2438. });
  2439. external_jQuery_default()(document).on('change', '[name="data[route]"]', function (event) {
  2440. var rawroute = external_jQuery_default()(event.currentTarget).val();
  2441. var pageTemplate = external_jQuery_default()('[name="data[name]"]');
  2442. var URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/ajax.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getChildTypes");
  2443. if (pageTemplate.length === 0) {
  2444. return;
  2445. }
  2446. utils_request(URI, {
  2447. method: 'post',
  2448. body: {
  2449. rawroute: rawroute
  2450. }
  2451. }, function (response) {
  2452. var type = response.child_type;
  2453. if (type !== '' && type !== 'default') {
  2454. pageTemplate.val(type);
  2455. pageTemplate.data('selectize').setValue(type);
  2456. }
  2457. });
  2458. });
  2459. ;// CONCATENATED MODULE: ./app/pages/page/move.js
  2460. external_jQuery_default()(document).on('click', '[data-page-move] button[name="task"][value="save"]', function (event) {
  2461. /* let route = $('form#blueprints:first select[name="data[route]"]');
  2462. let moveTo = $('[data-page-move] select').val();
  2463. if (route.length && route.val() !== moveTo) {
  2464. let selectize = route.data('selectize');
  2465. route.val(moveTo);
  2466. if (selectize) selectize.setValue(moveTo);
  2467. }*/
  2468. var modal = external_jQuery_default()(event.currentTarget).closest('[data-remodal-id]');
  2469. var parents = modal.data('parents') || {};
  2470. var finder = parents.finder;
  2471. if (!parents || !finder) {
  2472. return true;
  2473. }
  2474. var field = parents.field;
  2475. var parentLabel = parents.parentLabel;
  2476. var parentName = parents.parentName;
  2477. var selection = finder.findLastActive().item[0];
  2478. var value = selection._item[finder.config.valueKey];
  2479. var name = selection._item[finder.config.labelKey];
  2480. field.val(value);
  2481. parentLabel.text(value);
  2482. parentName.text(name);
  2483. finder.config.defaultPath = value;
  2484. external_jQuery_default()('<div />').css({
  2485. backgroundColor: 'rgba(255, 255, 255, 0.1)',
  2486. position: 'fixed',
  2487. top: 0,
  2488. left: 0,
  2489. width: '100vw',
  2490. height: '100vh',
  2491. zIndex: 15000
  2492. }).appendTo(external_jQuery_default()('body'));
  2493. });
  2494. /*
  2495. $(document).on('click', '[data-remodal-id="parents"] [data-parents-select]', (event) => {
  2496. const modal = $(event.currentTarget).closest('[data-remodal-id]');
  2497. const parents = modal.data('parents');
  2498. const finder = parents.finder;
  2499. const field = parents.field;
  2500. const parentLabel = parents.parentLabel;
  2501. const parentName = parents.parentName;
  2502. const selection = finder.findLastActive().item[0];
  2503. const value = selection._item[finder.config.valueKey];
  2504. const name = selection._item[finder.config.labelKey];
  2505. field.val(value);
  2506. parentLabel.text(value);
  2507. parentName.text(name);
  2508. finder.config.defaultPath = value;
  2509. const remodal = $.remodal.lookup[$(`[data-remodal-id="${modal.data('remodalId')}"]`).data('remodal')];
  2510. remodal.close();
  2511. });
  2512. */
  2513. ;// CONCATENATED MODULE: ./app/pages/page/delete.js
  2514. external_jQuery_default()(document).on('click', '[data-remodal-target="delete"]', function () {
  2515. var confirm = external_jQuery_default()('[data-remodal-id="delete"] [data-delete-action]');
  2516. var link = external_jQuery_default()(this).data('delete-url');
  2517. confirm.data('delete-action', link);
  2518. });
  2519. external_jQuery_default()(document).on('click', '[data-delete-action]', function () {
  2520. var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-remodal-id="delete"]').data('remodal')];
  2521. __webpack_require__.g.location.href = external_jQuery_default()(this).data('delete-action');
  2522. remodal.close();
  2523. });
  2524. ;// CONCATENATED MODULE: ./app/pages/page/unset.js
  2525. external_jQuery_default()(document).on('click', '.dz-unset', function () {
  2526. var file_upload = external_jQuery_default()(this).closest('.files-upload');
  2527. external_jQuery_default()(this).closest('.dz-image-preview').remove();
  2528. var unset_image = external_jQuery_default()(this).closest('.dz-image-preview').find('[data-dz-name]').text().trim();
  2529. var images = JSON.parse(file_upload.find('input[data-grav-field="hidden"]').val()) || {};
  2530. var image_array = {};
  2531. external_jQuery_default().each(images, function (ind, obj) {
  2532. if (!ind.endsWith(unset_image)) {
  2533. image_array[ind] = obj;
  2534. }
  2535. });
  2536. file_upload.find('input[data-grav-field="hidden"]').val(JSON.stringify(image_array));
  2537. });
  2538. ;// CONCATENATED MODULE: ./app/pages/page/disable-buttons.js
  2539. external_jQuery_default()('.disable-after-click').on('click', function () {
  2540. external_jQuery_default()(this).addClass('pointer-events-disabled');
  2541. });
  2542. ;// CONCATENATED MODULE: ./app/utils/cookies.js
  2543. function cookies_typeof(obj) { "@babel/helpers - typeof"; return cookies_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, cookies_typeof(obj); }
  2544. /*
  2545. * Cookies.js - 1.2.3-grav
  2546. * https://github.com/ScottHamper/Cookies
  2547. *
  2548. * With SameSite support by Grav
  2549. *
  2550. * This is free and unencumbered software released into the public domain.
  2551. */
  2552. var factory = function factory(window) {
  2553. var _arguments = arguments;
  2554. if (cookies_typeof(window.document) !== 'object') {
  2555. throw new Error('Cookies.js requires a `window` with a `document` object');
  2556. }
  2557. var Cookies = function Cookies(key, value, options) {
  2558. return _arguments.length === 1 ? Cookies.get(key) : Cookies.set(key, value, options);
  2559. }; // Allows for setter injection in unit tests
  2560. Cookies._document = window.document; // Used to ensure cookie keys do not collide with
  2561. // built-in `Object` properties
  2562. Cookies._cacheKeyPrefix = 'cookey.'; // Hurr hurr, :)
  2563. Cookies._maxExpireDate = new Date('Fri, 31 Dec 9999 23:59:59 UTC');
  2564. Cookies.defaults = {
  2565. path: '/',
  2566. secure: false,
  2567. sameSite: 'Lax'
  2568. };
  2569. Cookies.get = function (key) {
  2570. if (Cookies._cachedDocumentCookie !== Cookies._document.cookie) {
  2571. Cookies._renewCache();
  2572. }
  2573. var value = Cookies._cache[Cookies._cacheKeyPrefix + key];
  2574. return value === undefined ? undefined : decodeURIComponent(value);
  2575. };
  2576. Cookies.set = function (key, value, options) {
  2577. options = Cookies._getExtendedOptions(options);
  2578. options.expires = Cookies._getExpiresDate(value === undefined ? -1 : options.expires);
  2579. Cookies._document.cookie = Cookies._generateCookieString(key, value, options);
  2580. return Cookies;
  2581. };
  2582. Cookies.expire = function (key, options) {
  2583. return Cookies.set(key, undefined, options);
  2584. };
  2585. Cookies._getExtendedOptions = function (options) {
  2586. return {
  2587. path: options && options.path || Cookies.defaults.path,
  2588. domain: options && options.domain || Cookies.defaults.domain,
  2589. expires: options && options.expires || Cookies.defaults.expires,
  2590. secure: options && options.secure !== undefined ? options.secure : Cookies.defaults.secure,
  2591. sameSite: options && options.sameSite || Cookies.defaults.sameSite
  2592. };
  2593. };
  2594. Cookies._isValidDate = function (date) {
  2595. return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
  2596. };
  2597. Cookies._getExpiresDate = function (expires, now) {
  2598. now = now || new Date();
  2599. if (typeof expires === 'number') {
  2600. expires = expires === Infinity ? Cookies._maxExpireDate : new Date(now.getTime() + expires * 1000);
  2601. } else if (typeof expires === 'string') {
  2602. expires = new Date(expires);
  2603. }
  2604. if (expires && !Cookies._isValidDate(expires)) {
  2605. throw new Error('`expires` parameter cannot be converted to a valid Date instance');
  2606. }
  2607. return expires;
  2608. };
  2609. Cookies._generateCookieString = function (key, value, options) {
  2610. key = key.replace(/[^#$&+\^`|]/g, encodeURIComponent);
  2611. key = key.replace(/\(/g, '%28').replace(/\)/g, '%29');
  2612. value = (value + '').replace(/[^!#$&-+\--:<-\[\]-~]/g, encodeURIComponent);
  2613. options = options || {};
  2614. var cookieString = key + '=' + value;
  2615. cookieString += options.path ? ';path=' + options.path : '';
  2616. cookieString += options.domain ? ';domain=' + options.domain : '';
  2617. cookieString += options.expires ? ';expires=' + options.expires.toUTCString() : '';
  2618. cookieString += options.secure ? ';secure' : '';
  2619. cookieString += options.sameSite ? ';SameSite=' + options.sameSite : '';
  2620. return cookieString;
  2621. };
  2622. Cookies._getCacheFromString = function (documentCookie) {
  2623. var cookieCache = {};
  2624. var cookiesArray = documentCookie ? documentCookie.split('; ') : [];
  2625. for (var i = 0; i < cookiesArray.length; i++) {
  2626. var cookieKvp = Cookies._getKeyValuePairFromCookieString(cookiesArray[i]);
  2627. if (cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] === undefined) {
  2628. cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] = cookieKvp.value;
  2629. }
  2630. }
  2631. return cookieCache;
  2632. };
  2633. Cookies._getKeyValuePairFromCookieString = function (cookieString) {
  2634. // "=" is a valid character in a cookie value according to RFC6265, so cannot `split('=')`
  2635. var separatorIndex = cookieString.indexOf('='); // IE omits the "=" when the cookie value is an empty string
  2636. separatorIndex = separatorIndex < 0 ? cookieString.length : separatorIndex;
  2637. var key = cookieString.substr(0, separatorIndex);
  2638. var decodedKey;
  2639. try {
  2640. decodedKey = decodeURIComponent(key);
  2641. } catch (e) {
  2642. if (console && typeof console.error === 'function') {
  2643. console.error('Could not decode cookie with key "' + key + '"', e);
  2644. }
  2645. }
  2646. return {
  2647. key: decodedKey,
  2648. value: cookieString.substr(separatorIndex + 1) // Defer decoding value until accessed
  2649. };
  2650. };
  2651. Cookies._renewCache = function () {
  2652. Cookies._cache = Cookies._getCacheFromString(Cookies._document.cookie);
  2653. Cookies._cachedDocumentCookie = Cookies._document.cookie;
  2654. };
  2655. Cookies._areEnabled = function () {
  2656. var testKey = 'cookies.js';
  2657. var areEnabled = Cookies.set(testKey, 1).get(testKey) === '1';
  2658. Cookies.expire(testKey);
  2659. return areEnabled;
  2660. };
  2661. Cookies.enabled = Cookies._areEnabled();
  2662. return Cookies;
  2663. };
  2664. __webpack_require__.g.Cookies = __webpack_require__.g && cookies_typeof(__webpack_require__.g.document) === 'object' ? factory(__webpack_require__.g) : factory;
  2665. /* harmony default export */ const cookies = (__webpack_require__.g.Cookies);
  2666. ;// CONCATENATED MODULE: ./app/forms/fields/editor/buttons.js
  2667. var replacer = function replacer(_ref) {
  2668. var name = _ref.name,
  2669. replace = _ref.replace,
  2670. codemirror = _ref.codemirror,
  2671. button = _ref.button,
  2672. _ref$mode = _ref.mode,
  2673. mode = _ref$mode === void 0 ? 'replaceSelections' : _ref$mode,
  2674. runner = _ref.runner;
  2675. button.on("click.editor.".concat(name), function () {
  2676. strategies[mode]({
  2677. token: '$1',
  2678. template: replace,
  2679. codemirror: codemirror,
  2680. runner: runner
  2681. });
  2682. });
  2683. };
  2684. var strategies = {
  2685. replaceSelections: function replaceSelections(_ref2) {
  2686. var template = _ref2.template,
  2687. token = _ref2.token,
  2688. codemirror = _ref2.codemirror,
  2689. runner = _ref2.runner;
  2690. var replacements = [];
  2691. var ranges = [];
  2692. var selections = codemirror.getSelections();
  2693. var list = codemirror.listSelections();
  2694. var accumulator = {};
  2695. selections.forEach(function (selection, index) {
  2696. var markup = template.replace(token, selection);
  2697. var cursor = markup.indexOf('$cur');
  2698. var _list$index$anchor = list[index].anchor,
  2699. line = _list$index$anchor.line,
  2700. ch = _list$index$anchor.ch;
  2701. markup = markup.replace('$cur', '');
  2702. markup = runner ? runner(selection, markup, list) : markup;
  2703. replacements.push(markup);
  2704. if (!accumulator[line]) {
  2705. accumulator[line] = 0;
  2706. }
  2707. ch += accumulator[line] + (cursor === -1 ? markup.length : cursor);
  2708. var range = {
  2709. ch: ch,
  2710. line: line
  2711. };
  2712. ranges.push({
  2713. anchor: range,
  2714. head: range
  2715. });
  2716. accumulator[line] += markup.length - selection.length;
  2717. });
  2718. codemirror.replaceSelections(replacements);
  2719. codemirror.setSelections(ranges);
  2720. codemirror.focus();
  2721. },
  2722. replaceLine: function replaceLine(_ref3) {
  2723. var template = _ref3.template,
  2724. token = _ref3.token,
  2725. codemirror = _ref3.codemirror,
  2726. runner = _ref3.runner;
  2727. var list = codemirror.listSelections();
  2728. var range;
  2729. list.forEach(function (selection) {
  2730. var lines = {
  2731. min: Math.min(selection.anchor.line, selection.head.line),
  2732. max: Math.max(selection.anchor.line, selection.head.line)
  2733. };
  2734. codemirror.eachLine(lines.min, lines.max + 1, function (handler) {
  2735. var markup = template.replace(token, handler.text);
  2736. var line = codemirror.getLineNumber(handler);
  2737. markup = runner ? runner(handler, markup) : markup;
  2738. codemirror.replaceRange(markup, {
  2739. line: line,
  2740. ch: 0
  2741. }, {
  2742. line: line,
  2743. ch: markup.length
  2744. });
  2745. range = {
  2746. line: line,
  2747. ch: markup.length
  2748. };
  2749. });
  2750. });
  2751. codemirror.setSelection(range, range, 'end');
  2752. codemirror.focus();
  2753. },
  2754. replaceRange: function replaceRange() {}
  2755. };
  2756. var flipDisabled = function flipDisabled(codemirror, button, type) {
  2757. var hasHistory = codemirror.historySize()[type];
  2758. var element = button.find('a');
  2759. button[hasHistory ? 'removeClass' : 'addClass']('button-disabled');
  2760. if (!hasHistory) {
  2761. element.attr('title-disabled', element.attr('title'));
  2762. element.attr('data-hint-disabled', element.attr('data-hint'));
  2763. element.removeAttr('title').removeAttr('data-hint');
  2764. } else {
  2765. element.attr('title', element.attr('title-disabled'));
  2766. element.attr('data-hint', element.attr('data-hint-disabled'));
  2767. element.removeAttr('title-disabled').removeAttr('data-hint-disabled');
  2768. }
  2769. };
  2770. /* harmony default export */ const buttons = ({
  2771. navigation: [{
  2772. undo: {
  2773. identifier: 'undo',
  2774. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UNDO,
  2775. label: '<i class="fa fa-fw fa-undo"></i>',
  2776. modes: [],
  2777. action: function action(_ref4) {
  2778. var codemirror = _ref4.codemirror,
  2779. button = _ref4.button,
  2780. textarea = _ref4.textarea;
  2781. button.addClass('button-disabled');
  2782. codemirror.on('change', function () {
  2783. return flipDisabled(codemirror, button, 'undo');
  2784. });
  2785. button.on('click.editor.undo', function () {
  2786. codemirror.undo();
  2787. });
  2788. }
  2789. }
  2790. }, {
  2791. redo: {
  2792. identifier: 'redo',
  2793. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.REDO,
  2794. label: '<i class="fa fa-fw fa-repeat"></i>',
  2795. modes: [],
  2796. action: function action(_ref5) {
  2797. var codemirror = _ref5.codemirror,
  2798. button = _ref5.button,
  2799. textarea = _ref5.textarea;
  2800. button.addClass('button-disabled');
  2801. codemirror.on('change', function () {
  2802. return flipDisabled(codemirror, button, 'redo');
  2803. });
  2804. button.on('click.editor.redo', function () {
  2805. codemirror.redo();
  2806. });
  2807. }
  2808. }
  2809. }, {
  2810. headers: {
  2811. identifier: 'headers',
  2812. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.HEADERS,
  2813. label: '<i class="fa fa-fw fa-header"></i>',
  2814. modes: ['gfm', 'markdown'],
  2815. children: [{
  2816. h1: {
  2817. identifier: 'h1',
  2818. label: '<i class="fa fa-fw fa-header"></i>1',
  2819. modes: ['gfm', 'markdown'],
  2820. action: function action(_ref6) {
  2821. var codemirror = _ref6.codemirror,
  2822. button = _ref6.button,
  2823. textarea = _ref6.textarea;
  2824. replacer({
  2825. name: 'h1',
  2826. replace: '# $1',
  2827. codemirror: codemirror,
  2828. button: button,
  2829. mode: 'replaceLine'
  2830. });
  2831. }
  2832. }
  2833. }, {
  2834. h2: {
  2835. identifier: 'h2',
  2836. label: '<i class="fa fa-fw fa-header"></i>2',
  2837. modes: ['gfm', 'markdown'],
  2838. action: function action(_ref7) {
  2839. var codemirror = _ref7.codemirror,
  2840. button = _ref7.button,
  2841. textarea = _ref7.textarea;
  2842. replacer({
  2843. name: 'h2',
  2844. replace: '## $1',
  2845. codemirror: codemirror,
  2846. button: button,
  2847. mode: 'replaceLine'
  2848. });
  2849. }
  2850. }
  2851. }, {
  2852. h3: {
  2853. identifier: 'h3',
  2854. label: '<i class="fa fa-fw fa-header"></i>3',
  2855. modes: ['gfm', 'markdown'],
  2856. action: function action(_ref8) {
  2857. var codemirror = _ref8.codemirror,
  2858. button = _ref8.button,
  2859. textarea = _ref8.textarea;
  2860. replacer({
  2861. name: 'h3',
  2862. replace: '### $1',
  2863. codemirror: codemirror,
  2864. button: button,
  2865. mode: 'replaceLine'
  2866. });
  2867. }
  2868. }
  2869. }, {
  2870. h4: {
  2871. identifier: 'h4',
  2872. label: '<i class="fa fa-fw fa-header"></i>4',
  2873. modes: ['gfm', 'markdown'],
  2874. action: function action(_ref9) {
  2875. var codemirror = _ref9.codemirror,
  2876. button = _ref9.button,
  2877. textarea = _ref9.textarea;
  2878. replacer({
  2879. name: 'h4',
  2880. replace: '#### $1',
  2881. codemirror: codemirror,
  2882. button: button,
  2883. mode: 'replaceLine'
  2884. });
  2885. }
  2886. }
  2887. }, {
  2888. h5: {
  2889. identifier: 'h5',
  2890. label: '<i class="fa fa-fw fa-header"></i>5',
  2891. modes: ['gfm', 'markdown'],
  2892. action: function action(_ref10) {
  2893. var codemirror = _ref10.codemirror,
  2894. button = _ref10.button,
  2895. textarea = _ref10.textarea;
  2896. replacer({
  2897. name: 'h5',
  2898. replace: '##### $1',
  2899. codemirror: codemirror,
  2900. button: button,
  2901. mode: 'replaceLine'
  2902. });
  2903. }
  2904. }
  2905. }, {
  2906. h6: {
  2907. identifier: 'h6',
  2908. label: '<i class="fa fa-fw fa-header"></i>6',
  2909. modes: ['gfm', 'markdown'],
  2910. action: function action(_ref11) {
  2911. var codemirror = _ref11.codemirror,
  2912. button = _ref11.button,
  2913. textarea = _ref11.textarea;
  2914. replacer({
  2915. name: 'h6',
  2916. replace: '###### $1',
  2917. codemirror: codemirror,
  2918. button: button,
  2919. mode: 'replaceLine'
  2920. });
  2921. }
  2922. }
  2923. }]
  2924. }
  2925. }, {
  2926. bold: {
  2927. identifier: 'bold',
  2928. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.BOLD,
  2929. label: '<i class="fa fa-fw fa-bold"></i>',
  2930. modes: ['gfm', 'markdown'],
  2931. shortcut: ['Ctrl-B', 'Cmd-B'],
  2932. action: function action(_ref12) {
  2933. var codemirror = _ref12.codemirror,
  2934. button = _ref12.button,
  2935. textarea = _ref12.textarea;
  2936. replacer({
  2937. name: 'bold',
  2938. replace: '**$1$cur**',
  2939. codemirror: codemirror,
  2940. button: button
  2941. });
  2942. }
  2943. }
  2944. }, {
  2945. italic: {
  2946. identifier: 'italic',
  2947. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ITALIC,
  2948. label: '<i class="fa fa-fw fa-italic"></i>',
  2949. modes: ['gfm', 'markdown'],
  2950. shortcut: ['Ctrl-I', 'Cmd-I'],
  2951. action: function action(_ref13) {
  2952. var codemirror = _ref13.codemirror,
  2953. button = _ref13.button,
  2954. textarea = _ref13.textarea;
  2955. replacer({
  2956. name: 'italic',
  2957. replace: '_$1$cur_',
  2958. codemirror: codemirror,
  2959. button: button
  2960. });
  2961. }
  2962. }
  2963. }, {
  2964. strike: {
  2965. identifier: 'strike',
  2966. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.STRIKETHROUGH,
  2967. label: '<i class="fa fa-fw fa-strikethrough"></i>',
  2968. modes: ['gfm', 'markdown'],
  2969. action: function action(_ref14) {
  2970. var codemirror = _ref14.codemirror,
  2971. button = _ref14.button,
  2972. textarea = _ref14.textarea;
  2973. replacer({
  2974. name: 'strike',
  2975. replace: '~~$1$cur~~',
  2976. codemirror: codemirror,
  2977. button: button
  2978. });
  2979. }
  2980. }
  2981. }, {
  2982. delimiter: {
  2983. identifier: 'delimiter',
  2984. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.SUMMARY_DELIMITER,
  2985. label: '<i class="fa fa-fw fa-minus"></i>',
  2986. modes: ['gfm', 'markdown'],
  2987. action: function action(_ref15) {
  2988. var codemirror = _ref15.codemirror,
  2989. button = _ref15.button,
  2990. textarea = _ref15.textarea;
  2991. replacer({
  2992. name: 'delimiter',
  2993. replace: "".concat(external_GravAdmin_namespaceObject.config.site.delimiter, "$1"),
  2994. codemirror: codemirror,
  2995. button: button,
  2996. mode: 'replaceLine'
  2997. });
  2998. }
  2999. }
  3000. }, {
  3001. link: {
  3002. identifier: 'link',
  3003. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.LINK,
  3004. label: '<i class="fa fa-fw fa-link"></i>',
  3005. modes: ['gfm', 'markdown'],
  3006. shortcut: ['Ctrl-K', 'Cmd-K'],
  3007. action: function action(_ref16) {
  3008. var codemirror = _ref16.codemirror,
  3009. button = _ref16.button,
  3010. textarea = _ref16.textarea;
  3011. replacer({
  3012. name: 'link',
  3013. replace: '[$1]($cur)',
  3014. codemirror: codemirror,
  3015. button: button
  3016. });
  3017. }
  3018. }
  3019. }, {
  3020. image: {
  3021. identifier: 'image',
  3022. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IMAGE,
  3023. label: '<i class="fa fa-fw fa-picture-o"></i>',
  3024. modes: ['gfm', 'markdown'],
  3025. action: function action(_ref17) {
  3026. var codemirror = _ref17.codemirror,
  3027. button = _ref17.button,
  3028. textarea = _ref17.textarea;
  3029. replacer({
  3030. name: 'image',
  3031. replace: '![$1]($cur)',
  3032. codemirror: codemirror,
  3033. button: button
  3034. });
  3035. }
  3036. }
  3037. }, {
  3038. blockquote: {
  3039. identifier: 'blockquote',
  3040. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.BLOCKQUOTE,
  3041. label: '<i class="fa fa-fw fa-quote-right"></i>',
  3042. modes: ['gfm', 'markdown'],
  3043. action: function action(_ref18) {
  3044. var codemirror = _ref18.codemirror,
  3045. button = _ref18.button,
  3046. textarea = _ref18.textarea;
  3047. replacer({
  3048. name: 'blockquote',
  3049. replace: '> $1',
  3050. codemirror: codemirror,
  3051. button: button,
  3052. mode: 'replaceLine'
  3053. });
  3054. }
  3055. }
  3056. }, {
  3057. listUl: {
  3058. identifier: 'listUl',
  3059. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UNORDERED_LIST,
  3060. label: '<i class="fa fa-fw fa-list-ul"></i>',
  3061. modes: ['gfm', 'markdown'],
  3062. action: function action(_ref19) {
  3063. var codemirror = _ref19.codemirror,
  3064. button = _ref19.button,
  3065. textarea = _ref19.textarea;
  3066. replacer({
  3067. name: 'listUl',
  3068. replace: '* $1',
  3069. codemirror: codemirror,
  3070. button: button,
  3071. mode: 'replaceLine'
  3072. });
  3073. }
  3074. }
  3075. }, {
  3076. listOl: {
  3077. identifier: 'listOl',
  3078. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ORDERED_LIST,
  3079. label: '<i class="fa fa-fw fa-list-ol"></i>',
  3080. modes: ['gfm', 'markdown'],
  3081. action: function action(_ref20) {
  3082. var codemirror = _ref20.codemirror,
  3083. button = _ref20.button,
  3084. textarea = _ref20.textarea;
  3085. replacer({
  3086. name: 'listOl',
  3087. replace: '. $1',
  3088. codemirror: codemirror,
  3089. button: button,
  3090. mode: 'replaceLine',
  3091. runner: function runner(line, markup) {
  3092. var lineNo = codemirror.getLineNumber(line);
  3093. var previousLine = codemirror.getLine(lineNo - 1) || '';
  3094. var match = previousLine.match(/^(\d+)\./);
  3095. var prefix = 1 + (match ? Number(match[1]) : 0);
  3096. return "".concat(prefix).concat(markup);
  3097. }
  3098. });
  3099. }
  3100. }
  3101. }],
  3102. states: [{
  3103. code: {
  3104. identifier: 'editor',
  3105. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.EDITOR,
  3106. label: '<i class="fa fa-fw fa-code"></i>',
  3107. action: function action(_ref21) {
  3108. var codemirror = _ref21.codemirror,
  3109. button = _ref21.button,
  3110. textarea = _ref21.textarea,
  3111. ui = _ref21.ui;
  3112. if (textarea.data('grav-editor-mode') === 'editor') {
  3113. button.addClass('editor-active');
  3114. }
  3115. button.on('click.states.editor', function () {
  3116. button.siblings().removeClass('editor-active');
  3117. button.addClass('editor-active');
  3118. textarea.data('grav-editor-mode', 'editor');
  3119. var previewContainer = textarea.data('grav-editor-preview-container');
  3120. var content = textarea.parent('.grav-editor-content');
  3121. content.addClass('is-active');
  3122. ui.navigation.find('.grav-editor-actions').css('visibility', 'visible');
  3123. if (previewContainer) {
  3124. previewContainer.removeClass('is-active');
  3125. }
  3126. });
  3127. }
  3128. }
  3129. }, {
  3130. preview: {
  3131. identifier: 'preview',
  3132. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PREVIEW,
  3133. label: '<i class="fa fa-fw fa-eye"></i>',
  3134. modes: ['gfm', 'markdown'],
  3135. action: function action(_ref22) {
  3136. var codemirror = _ref22.codemirror,
  3137. button = _ref22.button,
  3138. textarea = _ref22.textarea,
  3139. ui = _ref22.ui;
  3140. if (textarea.data('grav-editor-mode') === 'preview') {
  3141. button.addClass('editor-active');
  3142. }
  3143. button.on('click.states.preview', function () {
  3144. var previewContainer = textarea.data('grav-editor-preview-container');
  3145. var content = textarea.parent('.grav-editor-content');
  3146. button.siblings().removeClass('editor-active');
  3147. button.addClass('editor-active');
  3148. textarea.data('grav-editor-mode', 'preview');
  3149. if (!previewContainer) {
  3150. previewContainer = external_jQuery_default()('<div class="grav-editor-preview" />');
  3151. content.after(previewContainer);
  3152. textarea.data('grav-editor-preview-container', previewContainer);
  3153. }
  3154. previewContainer.css({
  3155. height: content.height()
  3156. });
  3157. previewContainer.addClass('is-active');
  3158. content.removeClass('is-active');
  3159. ui.navigation.find('.grav-editor-actions').css('visibility', 'hidden');
  3160. var url = "".concat(textarea.data('grav-urlpreview'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "processmarkdown");
  3161. var params = textarea.closest('form').serializeArray();
  3162. var body = {};
  3163. params.map(function (obj) {
  3164. body[obj.name] = obj.value;
  3165. });
  3166. utils_request(url, {
  3167. method: 'post',
  3168. body: body
  3169. }, function (response) {
  3170. return previewContainer.html(response.preview);
  3171. });
  3172. });
  3173. }
  3174. }
  3175. }, {
  3176. fullscreen: {
  3177. identifier: 'fullscreen',
  3178. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FULLSCREEN,
  3179. label: '<i class="fa fa-fw fa-expand"></i>',
  3180. action: function action(_ref23) {
  3181. var codemirror = _ref23.codemirror,
  3182. button = _ref23.button,
  3183. textarea = _ref23.textarea;
  3184. button.on('click.editor.fullscreen', function () {
  3185. var container = textarea.closest('.grav-editor');
  3186. var wrapper = codemirror.getWrapperElement();
  3187. var contentWrapper = external_jQuery_default()('.content-wrapper');
  3188. if (!container.hasClass('grav-editor-fullscreen')) {
  3189. textarea.data('fullScreenRestore', {
  3190. scrollTop: __webpack_require__.g.pageYOffset,
  3191. scrollLeft: __webpack_require__.g.pageXOffset,
  3192. width: wrapper.style.width,
  3193. height: wrapper.style.height
  3194. });
  3195. wrapper.style.width = '';
  3196. wrapper.style.height = textarea.parent('.grav-editor-content').height() + 'px';
  3197. __webpack_require__.g.document.documentElement.style.overflow = 'hidden';
  3198. var hints = container.find('.grav-editor-toolbar .hint--top');
  3199. if (hints) {
  3200. hints.removeClass('hint--top').addClass('hint--bottom');
  3201. external_jQuery_default()(hints[hints.length - 1]).addClass('hint--bottom-left');
  3202. }
  3203. if (contentWrapper) {
  3204. contentWrapper.css('overflow', 'visible');
  3205. }
  3206. } else {
  3207. __webpack_require__.g.document.documentElement.style.overflow = '';
  3208. var state = textarea.data('fullScreenRestore');
  3209. wrapper.style.width = state.width;
  3210. wrapper.style.height = state.height;
  3211. __webpack_require__.g.scrollTo(state.scrollLeft, state.scrollTop);
  3212. var _hints = container.find('.grav-editor-toolbar .hint--bottom');
  3213. if (_hints) {
  3214. _hints.removeClass('hint--bottom').addClass('hint--top');
  3215. external_jQuery_default()(_hints[_hints.length - 1]).removeClass('hint--bottom-left');
  3216. }
  3217. if (contentWrapper) {
  3218. contentWrapper.css('overflow', 'auto');
  3219. }
  3220. }
  3221. container.toggleClass('grav-editor-fullscreen');
  3222. setTimeout(function () {
  3223. codemirror.refresh(); // this.preview.parent().css('height', this.code.height());
  3224. external_jQuery_default()(__webpack_require__.g).trigger('resize');
  3225. }, 5);
  3226. });
  3227. }
  3228. }
  3229. }]
  3230. });
  3231. // EXTERNAL MODULE: ./node_modules/codemirror/lib/codemirror.js
  3232. var codemirror = __webpack_require__(4631);
  3233. var codemirror_default = /*#__PURE__*/__webpack_require__.n(codemirror);
  3234. // EXTERNAL MODULE: ./node_modules/watchjs/src/watch.js
  3235. var watch = __webpack_require__(29950);
  3236. // EXTERNAL MODULE: ./node_modules/js-yaml/dist/js-yaml.mjs
  3237. var js_yaml = __webpack_require__(1272);
  3238. // EXTERNAL MODULE: ./node_modules/codemirror/mode/css/css.js
  3239. var css = __webpack_require__(36629);
  3240. // EXTERNAL MODULE: ./node_modules/codemirror/mode/gfm/gfm.js
  3241. var gfm = __webpack_require__(42425);
  3242. // EXTERNAL MODULE: ./node_modules/codemirror/mode/htmlmixed/htmlmixed.js
  3243. var htmlmixed = __webpack_require__(16531);
  3244. // EXTERNAL MODULE: ./node_modules/codemirror/mode/javascript/javascript.js
  3245. var javascript = __webpack_require__(96876);
  3246. // EXTERNAL MODULE: ./node_modules/codemirror/mode/markdown/markdown.js
  3247. var markdown = __webpack_require__(49047);
  3248. // EXTERNAL MODULE: ./node_modules/codemirror/mode/php/php.js
  3249. var php = __webpack_require__(36702);
  3250. // EXTERNAL MODULE: ./node_modules/codemirror/mode/sass/sass.js
  3251. var sass = __webpack_require__(81201);
  3252. // EXTERNAL MODULE: ./node_modules/codemirror/mode/twig/twig.js
  3253. var twig = __webpack_require__(54702);
  3254. // EXTERNAL MODULE: ./node_modules/codemirror/mode/xml/xml.js
  3255. var xml = __webpack_require__(29589);
  3256. // EXTERNAL MODULE: ./node_modules/codemirror/mode/yaml/yaml.js
  3257. var yaml = __webpack_require__(53631);
  3258. // EXTERNAL MODULE: ./node_modules/codemirror/addon/edit/continuelist.js
  3259. var continuelist = __webpack_require__(23350);
  3260. // EXTERNAL MODULE: ./node_modules/codemirror/addon/mode/overlay.js
  3261. var overlay = __webpack_require__(14146);
  3262. // EXTERNAL MODULE: ./node_modules/codemirror/addon/selection/active-line.js
  3263. var active_line = __webpack_require__(20017);
  3264. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/lint.js
  3265. var lint = __webpack_require__(3256);
  3266. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/lint.css
  3267. var lint_lint = __webpack_require__(46226);
  3268. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/css-lint.js
  3269. var css_lint = __webpack_require__(41423);
  3270. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/javascript-lint.js
  3271. var javascript_lint = __webpack_require__(96477);
  3272. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/json-lint.js
  3273. var json_lint = __webpack_require__(62193);
  3274. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/yaml-lint.js
  3275. var yaml_lint = __webpack_require__(82783);
  3276. ;// CONCATENATED MODULE: ./app/forms/fields/editor.js
  3277. function editor_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3278. function editor_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); } }
  3279. function editor_createClass(Constructor, protoProps, staticProps) { if (protoProps) editor_defineProperties(Constructor.prototype, protoProps); if (staticProps) editor_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  3280. __webpack_require__.g.jsyaml = js_yaml/* default */.ZP; // Modes
  3281. // Add-ons
  3282. var IS_MOUSEDOWN = false;
  3283. var ThemesMap = ['paper'];
  3284. var Defaults = {
  3285. codemirror: {
  3286. mode: 'htmlmixed',
  3287. theme: 'paper',
  3288. lineWrapping: true,
  3289. dragDrop: true,
  3290. autoCloseTags: true,
  3291. matchTags: true,
  3292. autoCloseBrackets: true,
  3293. matchBrackets: true,
  3294. indentUnit: 4,
  3295. indentWithTabs: false,
  3296. tabSize: 4,
  3297. hintOptions: {
  3298. completionSingle: false
  3299. },
  3300. extraKeys: {
  3301. 'Enter': 'newlineAndIndentContinueMarkdownList'
  3302. }
  3303. }
  3304. };
  3305. var EditorField = /*#__PURE__*/function () {
  3306. function EditorField(options) {
  3307. var _this = this;
  3308. editor_classCallCheck(this, EditorField);
  3309. var body = external_jQuery_default()('body');
  3310. this.editors = external_jQuery_default()();
  3311. this.options = Object.assign({}, Defaults, options);
  3312. this.buttons = buttons;
  3313. this.buttonStrategies = strategies;
  3314. (0,watch.watch)(buttons, function
  3315. /* key, modifier, prev, next */
  3316. () {
  3317. _this.editors.each(function (index, editor) {
  3318. return external_jQuery_default()(editor).data('toolbar').renderButtons();
  3319. });
  3320. });
  3321. external_jQuery_default()('[data-grav-editor]').each(function (index, editor) {
  3322. return _this.addEditor(editor);
  3323. });
  3324. external_jQuery_default()(function () {
  3325. body.trigger('grav-editor-ready');
  3326. });
  3327. body.on('mutation._grav', this._onAddedNodes.bind(this));
  3328. body.on('mouseup._grav', function () {
  3329. if (!IS_MOUSEDOWN) {
  3330. return true;
  3331. }
  3332. body.unbind('mousemove._grav');
  3333. IS_MOUSEDOWN = false;
  3334. });
  3335. body.on('mousedown._grav', '.grav-editor-resizer', function (event) {
  3336. event && event.preventDefault();
  3337. IS_MOUSEDOWN = true;
  3338. var target = external_jQuery_default()(event.currentTarget);
  3339. var container = target.siblings('.grav-editor-content');
  3340. var editor = container.find('.CodeMirror');
  3341. var codemirror = container.find('textarea').data('codemirror');
  3342. body.on('mousemove._grav', function (event) {
  3343. editor.css('height', Math.max(100, event.pageY - container.offset().top));
  3344. codemirror.refresh();
  3345. });
  3346. });
  3347. }
  3348. editor_createClass(EditorField, [{
  3349. key: "addButton",
  3350. value: function addButton(button, options) {
  3351. if (options && (options.before || options.after)) {
  3352. var index = this.buttons.navigation.findIndex(function (obj) {
  3353. var key = Object.keys(obj).shift();
  3354. return obj[key].identifier === (options.before || options.after);
  3355. });
  3356. if (!~index) {
  3357. options = 'end';
  3358. } else {
  3359. this.buttons.navigation.splice(options.before ? index : index + 1, 0, button);
  3360. }
  3361. }
  3362. if (options === 'start') {
  3363. this.buttons.navigation.splice(0, 0, button);
  3364. }
  3365. if (!options || options === 'end') {
  3366. this.buttons.navigation.push(button);
  3367. }
  3368. }
  3369. }, {
  3370. key: "addEditor",
  3371. value: function addEditor(textarea) {
  3372. textarea = external_jQuery_default()(textarea);
  3373. var options = Object.assign({}, this.options.codemirror, textarea.data('grav-editor').codemirror);
  3374. var theme = options.theme || 'paper';
  3375. this.editors = this.editors.add(textarea);
  3376. if (theme && !~ThemesMap.indexOf(theme)) {
  3377. ThemesMap.push(theme); // let themeCSS = `https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.12.0/theme/${theme}.min.css`;
  3378. // $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', themeCSS));
  3379. }
  3380. if (options.mode === 'yaml') {
  3381. Object.assign(options.extraKeys, {
  3382. Tab: function Tab(cm) {
  3383. cm.replaceSelection(' ', 'end');
  3384. }
  3385. });
  3386. }
  3387. var editor = codemirror_default().fromTextArea(textarea.get(0), options);
  3388. textarea.data('codemirror', editor);
  3389. textarea.data('toolbar', new Toolbar(textarea));
  3390. textarea.addClass('code-mirrored');
  3391. if (options.toolbar === false) {
  3392. textarea.data('toolbar').ui.navigation.addClass('grav-editor-hide-toolbar');
  3393. }
  3394. editor.on('change', function () {
  3395. return editor.save();
  3396. });
  3397. }
  3398. }, {
  3399. key: "_onAddedNodes",
  3400. value: function _onAddedNodes(event, target
  3401. /* , record, instance */
  3402. ) {
  3403. var _this2 = this;
  3404. var editors = external_jQuery_default()(target).find('[data-grav-editor]');
  3405. if (!editors.length) {
  3406. return;
  3407. }
  3408. editors.each(function (index, editor) {
  3409. editor = external_jQuery_default()(editor);
  3410. if (!~_this2.editors.index(editor)) {
  3411. _this2.addEditor(editor);
  3412. }
  3413. });
  3414. }
  3415. }]);
  3416. return EditorField;
  3417. }();
  3418. var Toolbar = /*#__PURE__*/function () {
  3419. function Toolbar(editor) {
  3420. editor_classCallCheck(this, Toolbar);
  3421. this.editor = external_jQuery_default()(editor);
  3422. this.codemirror = this.editor.data('codemirror');
  3423. this.buttons = buttons.navigation;
  3424. this.ui = {
  3425. navigation: external_jQuery_default()(Toolbar.templates().navigation)
  3426. };
  3427. this.editor.parent('.grav-editor-content').before(this.ui.navigation).after(this.ui.states);
  3428. this.renderButtons();
  3429. }
  3430. editor_createClass(Toolbar, [{
  3431. key: "renderButtons",
  3432. value: function renderButtons() {
  3433. var _this3 = this;
  3434. var map = {
  3435. 'actions': 'navigation',
  3436. 'modes': 'states'
  3437. };
  3438. ['actions', 'modes'].forEach(function (type) {
  3439. _this3.ui.navigation.find(".grav-editor-".concat(type)).empty().append('<ul />');
  3440. buttons[map[type]].forEach(function (button) {
  3441. return _this3.renderButton(button, type);
  3442. });
  3443. });
  3444. }
  3445. }, {
  3446. key: "renderButton",
  3447. value: function renderButton(button, type) {
  3448. var _this4 = this;
  3449. var location = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3450. Object.keys(button).forEach(function (key) {
  3451. var obj = button[key];
  3452. if (!obj.modes) {
  3453. obj.modes = [];
  3454. }
  3455. if (!~_this4.codemirror.options.ignore.indexOf(key) && (!obj.modes.length || obj.modes.indexOf(_this4.codemirror.options.mode) > -1)) {
  3456. var hint = obj.title ? "data-hint=\"".concat(obj.title, "\"") : '';
  3457. var element = external_jQuery_default()("<li class=\"grav-editor-button-".concat(key, "\"><a class=\"hint--top\" ").concat(hint, ">").concat(obj.label, "</a></li>"));
  3458. (location || _this4.ui.navigation.find(".grav-editor-".concat(type, " ul:not(.dropdown-menu)"))).append(element);
  3459. if (obj.shortcut) {
  3460. _this4.addShortcut(obj.identifier, obj.shortcut, element);
  3461. }
  3462. obj.action && obj.action.call(obj.action, {
  3463. codemirror: _this4.codemirror,
  3464. button: element,
  3465. textarea: _this4.editor,
  3466. ui: _this4.ui
  3467. });
  3468. if (obj.children) {
  3469. var childrenContainer = external_jQuery_default()('<ul class="dropdown-menu" />');
  3470. element.addClass('button-group').find('a').wrap('<div class="dropdown-toggle" data-toggle="dropdown"></div>');
  3471. element.find('a').append(' <i class="fa fa-caret-down"></i>');
  3472. element.append(childrenContainer);
  3473. obj.children.forEach(function (child) {
  3474. return _this4.renderButton(child, type, childrenContainer);
  3475. });
  3476. }
  3477. }
  3478. });
  3479. }
  3480. }, {
  3481. key: "addShortcut",
  3482. value: function addShortcut(identifier, shortcut, element) {
  3483. var _this5 = this;
  3484. var map = {};
  3485. if (!Array.isArray(shortcut)) {
  3486. shortcut = [shortcut];
  3487. }
  3488. shortcut.forEach(function (key) {
  3489. map[key] = function () {
  3490. element.trigger("click.editor.".concat(identifier), [_this5.codemirror]);
  3491. };
  3492. });
  3493. this.codemirror.addKeyMap(map);
  3494. }
  3495. }], [{
  3496. key: "templates",
  3497. value: function templates() {
  3498. return {
  3499. navigation: "\n <div class=\"grav-editor-toolbar\">\n <div class=\"grav-editor-actions\"></div>\n <div class=\"grav-editor-modes\"></div>\n </div>\n "
  3500. };
  3501. }
  3502. }]);
  3503. return Toolbar;
  3504. }();
  3505. var editor_Instance = new EditorField();
  3506. ;// CONCATENATED MODULE: ./app/pages/page/media.js
  3507. function media_typeof(obj) { "@babel/helpers - typeof"; return media_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, media_typeof(obj); }
  3508. function media_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3509. function media_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); } }
  3510. function media_createClass(Constructor, protoProps, staticProps) { if (protoProps) media_defineProperties(Constructor.prototype, protoProps); if (staticProps) media_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  3511. function media_get() { if (typeof Reflect !== "undefined" && Reflect.get) { media_get = Reflect.get; } else { media_get = function _get(target, property, receiver) { var base = media_superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return media_get.apply(this, arguments); }
  3512. function media_superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = media_getPrototypeOf(object); if (object === null) break; } return object; }
  3513. function media_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) media_setPrototypeOf(subClass, superClass); }
  3514. function media_setPrototypeOf(o, p) { media_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return media_setPrototypeOf(o, p); }
  3515. function media_createSuper(Derived) { var hasNativeReflectConstruct = media_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = media_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = media_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return media_possibleConstructorReturn(this, result); }; }
  3516. function media_possibleConstructorReturn(self, call) { if (call && (media_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return media_assertThisInitialized(self); }
  3517. function media_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3518. function media_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3519. function media_getPrototypeOf(o) { media_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return media_getPrototypeOf(o); }
  3520. var previewTemplate = "\n <div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-success-mark\"><span>\u2714</span></div>\n <div class=\"dz-error-mark\"><span>\u2718</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n <a class=\"dz-remove\" title=\"".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DELETE, "\" href=\"javascript:undefined;\" data-dz-remove>").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DELETE, "</a>\n <a class=\"dz-metadata\" title=\"").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.METADATA, "\" href=\"#\" target=\"_blank\" data-dz-metadata>").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.METADATA, "</a>\n <a class=\"dz-view\" title=\"").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.VIEW, "\" href=\"#\" target=\"_blank\" data-dz-view>").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.VIEW, "</a>\n <a class=\"dz-insert\" title=\"").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.INSERT, "\" href=\"javascript:undefined;\" data-dz-insert>").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.INSERT, "</a>\n </div>").trim();
  3521. var PageMedia = /*#__PURE__*/function (_FilesField) {
  3522. media_inherits(PageMedia, _FilesField);
  3523. var _super = media_createSuper(PageMedia);
  3524. function PageMedia() {
  3525. var _this;
  3526. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  3527. _ref$container = _ref.container,
  3528. container = _ref$container === void 0 ? '#grav-dropzone' : _ref$container,
  3529. _ref$options = _ref.options,
  3530. options = _ref$options === void 0 ? {} : _ref$options;
  3531. media_classCallCheck(this, PageMedia);
  3532. options = Object.assign(options, {
  3533. previewTemplate: previewTemplate
  3534. });
  3535. _this = _super.call(this, {
  3536. container: container,
  3537. options: options
  3538. });
  3539. if (!_this.container.length) {
  3540. return media_possibleConstructorReturn(_this);
  3541. }
  3542. _this.urls = {
  3543. fetch: "".concat(_this.container.data('media-url'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "listmedia"),
  3544. add: "".concat(_this.container.data('media-url'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "addmedia"),
  3545. "delete": "".concat(_this.container.data('media-url'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "delmedia")
  3546. };
  3547. _this.dropzone.options.url = _this.urls.add;
  3548. if (typeof _this.options.fetchMedia === 'undefined' || _this.options.fetchMedia) {
  3549. _this.fetchMedia();
  3550. }
  3551. if (typeof _this.options.attachDragDrop === 'undefined' || _this.options.attachDragDrop) {
  3552. _this.attachDragDrop();
  3553. }
  3554. var field = external_jQuery_default()("[name=\"".concat(_this.container.data('dropzone-field'), "\"]"));
  3555. if (field.length) {
  3556. _this.sortable = new sortable_esm/* default */.ZP(_this.container.get(0), {
  3557. animation: 150,
  3558. // forceFallback: true,
  3559. setData: function setData(dataTransfer, target) {
  3560. target = external_jQuery_default()(target);
  3561. var uri = encodeURI(target.find('.dz-filename').text());
  3562. var shortcode = UriToMarkdown(uri);
  3563. _this.dropzone.disable();
  3564. target.addClass('hide-backface');
  3565. dataTransfer.effectAllowed = 'copy';
  3566. dataTransfer.setData('text', shortcode);
  3567. },
  3568. onSort: function onSort() {
  3569. var names = [];
  3570. _this.container.find('[data-dz-name]').each(function (index, file) {
  3571. file = external_jQuery_default()(file);
  3572. var name = file.text().trim();
  3573. names.push(name);
  3574. });
  3575. field.val(names.join(','));
  3576. }
  3577. });
  3578. }
  3579. return _this;
  3580. }
  3581. media_createClass(PageMedia, [{
  3582. key: "fetchMedia",
  3583. value: function fetchMedia() {
  3584. var _this2 = this;
  3585. var order = this.container.closest('.form-field').find('[name="data[header][media_order]"]').val();
  3586. var body = {
  3587. uri: this.getURI(),
  3588. order: order
  3589. };
  3590. var url = this.urls.fetch;
  3591. utils_request(url, {
  3592. method: 'post',
  3593. body: body
  3594. }, function (response) {
  3595. var results = response.results;
  3596. Object.keys(results).forEach(function (name) {
  3597. var data = results[name];
  3598. var mock = {
  3599. name: name,
  3600. size: data.size,
  3601. accepted: true,
  3602. extras: data
  3603. };
  3604. _this2.dropzone.files.push(mock);
  3605. _this2.dropzone.options.addedfile.call(_this2.dropzone, mock);
  3606. _this2.dropzone.options.thumbnail.call(_this2.dropzone, mock, data.url);
  3607. });
  3608. _this2.updateThumbsSize();
  3609. _this2.container.find('.dz-preview').prop('draggable', 'true');
  3610. });
  3611. }
  3612. }, {
  3613. key: "onDropzoneSending",
  3614. value: function onDropzoneSending(file, xhr, formData) {
  3615. /*
  3616. // Cannot call super because Safari and IE API don't implement `delete`
  3617. super.onDropzoneSending(file, xhr, formData);
  3618. formData.delete('task');
  3619. */
  3620. formData.append('name', this.options.dotNotation || file.name);
  3621. formData.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
  3622. formData.append('uri', this.getURI());
  3623. }
  3624. }, {
  3625. key: "onDropzoneComplete",
  3626. value: function onDropzoneComplete(file) {
  3627. media_get(media_getPrototypeOf(PageMedia.prototype), "onDropzoneComplete", this).call(this, file);
  3628. if (this.sortable) {
  3629. this.sortable.options.onSort();
  3630. } // accepted
  3631. this.updateThumbsSize();
  3632. this.updateMediaCount();
  3633. external_jQuery_default()('.dz-preview').prop('draggable', 'true');
  3634. }
  3635. }, {
  3636. key: "onDropzoneAddedFile",
  3637. value: function onDropzoneAddedFile(file) {
  3638. for (var _len = arguments.length, extra = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  3639. extra[_key - 1] = arguments[_key];
  3640. }
  3641. media_get(media_getPrototypeOf(PageMedia.prototype), "onDropzoneAddedFile", this).call(this, file, extra);
  3642. this.updateThumbsSize();
  3643. }
  3644. }, {
  3645. key: "onDropzoneRemovedFile",
  3646. value: function onDropzoneRemovedFile(file) {
  3647. var _get2;
  3648. for (var _len2 = arguments.length, extra = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  3649. extra[_key2 - 1] = arguments[_key2];
  3650. }
  3651. (_get2 = media_get(media_getPrototypeOf(PageMedia.prototype), "onDropzoneRemovedFile", this)).call.apply(_get2, [this, file].concat(extra));
  3652. this.updateMediaCount();
  3653. if (this.sortable) {
  3654. this.sortable.options.onSort();
  3655. }
  3656. }
  3657. }, {
  3658. key: "updateThumbsSize",
  3659. value: function updateThumbsSize() {
  3660. var status = JSON.parse(cookies.get('grav-admin-pagemedia') || '{}');
  3661. if (status.width) {
  3662. var input = this.container.closest('.pagemedia-field').find('.media-resizer');
  3663. updateMediaSizes(input[0], status.width, false);
  3664. }
  3665. }
  3666. }, {
  3667. key: "updateMediaCount",
  3668. value: function updateMediaCount() {
  3669. var element = this.container.closest('.pagemedia-field').find('[data-pagemedia-count]');
  3670. element.text("(".concat(this.dropzone.files.length, ")"));
  3671. }
  3672. }, {
  3673. key: "attachDragDrop",
  3674. value: function attachDragDrop() {
  3675. var _this3 = this;
  3676. this.container.delegate('[data-dz-insert]', 'click', function (e) {
  3677. var target = external_jQuery_default()(e.currentTarget).parent('.dz-preview').find('.dz-filename');
  3678. var editor = editor_Instance.editors.filter(function (index, editor) {
  3679. return external_jQuery_default()(editor).attr('name') === 'data[content]';
  3680. });
  3681. if (editor.length) {
  3682. editor = editor.data('codemirror');
  3683. editor.focus();
  3684. var filename = encodeURI(target.text());
  3685. var shortcode = UriToMarkdown(filename);
  3686. editor.doc.replaceSelection(shortcode);
  3687. }
  3688. });
  3689. this.container.delegate('[data-dz-view]', 'mouseenter', function (e) {
  3690. var target = external_jQuery_default()(e.currentTarget);
  3691. var file = target.parent('.dz-preview').find('.dz-filename');
  3692. var filename = encodeURI(file.text());
  3693. var URL = target.closest('[data-media-path]').data('media-path');
  3694. var original = _this3.dropzone.files.filter(function (file) {
  3695. return encodeURI(file.name) === filename;
  3696. }).shift();
  3697. original = original && (original.extras && original.extras.original || encodeURI(original.name));
  3698. target.attr('href', "".concat(URL, "/").concat(original));
  3699. });
  3700. this.container.delegate('[data-dz-metadata]', 'click', function (e) {
  3701. e.preventDefault();
  3702. var target = external_jQuery_default()(e.currentTarget);
  3703. var file = target.parent('.dz-preview').find('.dz-filename');
  3704. var filename = encodeURI(file.text());
  3705. var cleanName = file.text().replace('<', '&lt;').replace('>', '&gt;');
  3706. var fileObj = _this3.dropzone.files.filter(function (file) {
  3707. return file.name === __webpack_require__.g.decodeURI(filename);
  3708. }).shift() || {};
  3709. if (!fileObj.extras) {
  3710. fileObj.extras = {
  3711. metadata: []
  3712. };
  3713. }
  3714. if (Array.isArray(fileObj.extras.metadata) && !fileObj.extras.metadata.length) {
  3715. fileObj.extras.metadata = {
  3716. '': "".concat(cleanName, ".meta.yaml doesn't exist")
  3717. };
  3718. }
  3719. fileObj = fileObj.extras;
  3720. var modal_element = external_jQuery_default()('body').find('[data-remodal-id="metadata"]');
  3721. var modal = (external_jQuery_default()).remodal.lookup[modal_element.data('remodal')];
  3722. modal_element.find('h1 strong').html(cleanName);
  3723. if (fileObj.url) {
  3724. modal_element.find('.meta-preview').html("<img src=\"".concat(fileObj.url, "\" />"));
  3725. }
  3726. var container = modal_element.find('.meta-content').html('<ul />').find('ul');
  3727. Object.keys(fileObj.metadata).forEach(function (meta) {
  3728. var cleanMeta = fileObj.metadata[meta].replace('<', '&lt;').replace('>', '&gt;');
  3729. container.append("<li><strong>".concat(meta ? meta + ':' : '', "</strong> ").concat(cleanMeta, "</li>"));
  3730. });
  3731. modal.open();
  3732. });
  3733. this.container.delegate('.dz-preview', 'dragstart', function (e) {
  3734. var target = external_jQuery_default()(e.currentTarget);
  3735. var uri = encodeURI(target.find('.dz-filename').text());
  3736. var shortcode = UriToMarkdown(uri);
  3737. _this3.dropzone.disable();
  3738. target.addClass('hide-backface');
  3739. e.originalEvent.dataTransfer.effectAllowed = 'copy';
  3740. e.originalEvent.dataTransfer.setData('text', shortcode);
  3741. });
  3742. this.container.delegate('.dz-preview', 'dragend', function (e) {
  3743. var target = external_jQuery_default()(e.currentTarget);
  3744. _this3.dropzone.enable();
  3745. target.removeClass('hide-backface');
  3746. });
  3747. }
  3748. }]);
  3749. return PageMedia;
  3750. }(FilesField);
  3751. var updateMediaSizes = function updateMediaSizes(input, width) {
  3752. var store = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3753. var storageLocation = input.dataset.storageLocation || 'grav-admin-pagemedia';
  3754. var status = JSON.parse(cookies.get(storageLocation) || '{}');
  3755. var height = 150 * width / 200;
  3756. var media = external_jQuery_default()(input).closest('.pagemedia-field').find('.dz-details, [data-dz-thumbnail]');
  3757. media.css({
  3758. width: width,
  3759. height: height
  3760. });
  3761. if (store) {
  3762. var data = Object.assign({}, status, {
  3763. width: width
  3764. });
  3765. cookies.set(storageLocation, JSON.stringify(data), {
  3766. expires: Infinity
  3767. });
  3768. }
  3769. };
  3770. var updateMediaCollapseStatus = function updateMediaCollapseStatus(element) {
  3771. var store = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  3772. var storageLocation = element.dataset.storageLocation || 'grav-admin-pagemedia';
  3773. var status = JSON.parse(cookies.get(storageLocation) || '{}');
  3774. element = external_jQuery_default()(element);
  3775. var icon = element.find('i.fa');
  3776. var container = element.closest('.pagemedia-field');
  3777. var panel = container.find('.form-data');
  3778. var slider = container.find('.media-resizer').parent();
  3779. var isCollapsed = !icon.hasClass('fa-chevron-down');
  3780. var collapsed = !isCollapsed;
  3781. icon.removeClass('fa-chevron-down fa-chevron-right').addClass(isCollapsed ? 'fa-chevron-down' : 'fa-chevron-right');
  3782. slider[isCollapsed ? 'removeClass' : 'addClass']('hidden');
  3783. panel[isCollapsed ? 'slideDown' : 'slideUp']();
  3784. if (store) {
  3785. var data = Object.assign({}, status, {
  3786. collapsed: collapsed
  3787. });
  3788. cookies.set(storageLocation, JSON.stringify(data), {
  3789. expires: Infinity
  3790. });
  3791. }
  3792. };
  3793. external_jQuery_default()(document).on('input', '.media-resizer', function (event) {
  3794. var target = external_jQuery_default()(event.currentTarget);
  3795. var width = target.val();
  3796. updateMediaSizes(event.currentTarget, width);
  3797. });
  3798. external_jQuery_default()(document).on('click', '.media-collapser', function (event) {
  3799. updateMediaCollapseStatus(event.currentTarget);
  3800. });
  3801. external_jQuery_default()(document).ready(function () {
  3802. external_jQuery_default()('.media-resizer').each(function (index, input) {
  3803. var storageLocation = input.dataset.storageLocation || 'grav-admin-pagemedia';
  3804. var status = JSON.parse(cookies.get(storageLocation) || '{}');
  3805. if (status.width) {
  3806. updateMediaSizes(input, status.width, false);
  3807. }
  3808. });
  3809. });
  3810. var media_Instance = new PageMedia();
  3811. ;// CONCATENATED MODULE: ./app/pages/page/multilang.js
  3812. external_jQuery_default()('[name="task"][value="saveas"], [name="task"][value="switchlanguage"]').on('mousedown touchstart', function (event) {
  3813. var fields = ['lang', 'redirect'];
  3814. var element = external_jQuery_default()(event.currentTarget);
  3815. var form = external_jQuery_default()("#".concat(element.attr('form')));
  3816. if (!form.length) {
  3817. return;
  3818. }
  3819. fields.forEach(function (field) {
  3820. var value = element.attr(field);
  3821. if (!value) {
  3822. return;
  3823. }
  3824. var input = form.find("[name=\"data[".concat(field, "]\"]"));
  3825. if (!input.length) {
  3826. input = external_jQuery_default()("<input type=\"hidden\" name=\"data[".concat(field, "]\" value=\"\" />"));
  3827. form.append(input);
  3828. }
  3829. input.val(value);
  3830. });
  3831. return true;
  3832. });
  3833. ;// CONCATENATED MODULE: ./app/pages/page/index.js
  3834. var page_switcher = external_jQuery_default()('input[type="radio"][name="mode-switch"]');
  3835. if (page_switcher) {
  3836. var page_link = page_switcher.closest(':checked').data('leave-url');
  3837. var fakeLink = external_jQuery_default()("<a href=\"".concat(page_link, "\" />"));
  3838. page_switcher.parent().append(fakeLink);
  3839. page_switcher.siblings('label').on('mousedown touchdown', function (event) {
  3840. event.preventDefault(); // let remodal = $.remodal.lookup[$('[data-remodal-id="changes"]').data('remodal')];
  3841. var confirm = external_jQuery_default()('[data-remodal-id="changes"] [data-leave-action="continue"]');
  3842. confirm.one('click', function () {
  3843. external_jQuery_default()(__webpack_require__.g).on('beforeunload._grav');
  3844. fakeLink.off('click._grav');
  3845. external_jQuery_default()(event.target).trigger('click');
  3846. });
  3847. fakeLink.trigger('click._grav');
  3848. });
  3849. page_switcher.on('change', function (event) {
  3850. var radio = external_jQuery_default()(event.target);
  3851. page_link = radio.data('leave-url');
  3852. setTimeout(function () {
  3853. return fakeLink.attr('href', page_link).get(0).click();
  3854. }, 5);
  3855. });
  3856. }
  3857. /* harmony default export */ const page = ({
  3858. Media: {
  3859. PageMedia: PageMedia,
  3860. PageMediaInstances: media_Instance
  3861. }
  3862. });
  3863. ;// CONCATENATED MODULE: ./app/pages/index.js
  3864. var pad = function pad(n, s) {
  3865. return "000".concat(n).substr(-s);
  3866. }; // Pages Ordering
  3867. var Ordering = null;
  3868. var orderingElement = external_jQuery_default()('#ordering');
  3869. if (orderingElement.length) {
  3870. Ordering = new sortable_esm/* default */.ZP(orderingElement.get(0), {
  3871. filter: '.ignore',
  3872. onUpdate: function onUpdate() {
  3873. /* Old single page index behavior
  3874. let item = $(event.item);
  3875. let index = orderingElement.children().index(item) + 1;
  3876. $('[data-order]').val(index);
  3877. */
  3878. var indexes = [];
  3879. var children = orderingElement.children();
  3880. var padZero = (children.length + '').split('').length;
  3881. children.each(function (index, item) {
  3882. item = external_jQuery_default()(item);
  3883. indexes.push(item.data('id'));
  3884. item.find('.page-order').text("".concat(pad(index + 1, padZero), "."));
  3885. });
  3886. external_jQuery_default()('[data-order]').val(indexes.join(','));
  3887. }
  3888. });
  3889. external_jQuery_default()(document).on('input', '[name="data[folder]"]', function (event) {
  3890. var target = external_jQuery_default()(event.currentTarget);
  3891. var activeOrder = external_jQuery_default()('[data-id][data-active-id]');
  3892. activeOrder.data('id', target.val());
  3893. Ordering.options.onUpdate();
  3894. });
  3895. }
  3896. /* harmony default export */ const pages = ({
  3897. Ordering: Ordering,
  3898. Page: page,
  3899. PageFilters: {
  3900. PageFilters: PagesFilter,
  3901. Instance: filter_Instance
  3902. }
  3903. });
  3904. // EXTERNAL MODULE: ./node_modules/immutable/dist/immutable.es.js
  3905. var immutable_es = __webpack_require__(35369);
  3906. // EXTERNAL MODULE: ./node_modules/immutablediff/src/diff.js
  3907. var src_diff = __webpack_require__(64847);
  3908. var diff_default = /*#__PURE__*/__webpack_require__.n(src_diff);
  3909. ;// CONCATENATED MODULE: ./app/forms/state.js
  3910. function state_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3911. function state_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); } }
  3912. function state_createClass(Constructor, protoProps, staticProps) { if (protoProps) state_defineProperties(Constructor.prototype, protoProps); if (staticProps) state_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  3913. var FormLoadState = {};
  3914. var DOMBehaviors = {
  3915. attach: function attach() {
  3916. this.preventUnload();
  3917. this.preventClickAway();
  3918. },
  3919. preventUnload: function preventUnload() {
  3920. var selector = '[name="task"][value^="save"], [data-delete-action], [data-flex-safe-action]';
  3921. if (external_jQuery_default()._data(window, 'events') && (external_jQuery_default()._data(window, 'events').beforeunload || []).filter(function (event) {
  3922. return event.namespace === '_grav';
  3923. }).length) {
  3924. return;
  3925. } // Allow some elements to leave the page without native confirmation
  3926. external_jQuery_default()(selector).on('click._grav', function (event) {
  3927. external_jQuery_default()(__webpack_require__.g).off('beforeunload');
  3928. }); // Catch browser uri change / refresh attempt and stop it if the form state is dirty
  3929. external_jQuery_default()(__webpack_require__.g).on('beforeunload._grav', function () {
  3930. if (state_Instance.equals() === false) {
  3931. return 'You have made changes on this page that you have not yet confirmed. If you navigate away from this page you will lose your unsaved changes.';
  3932. }
  3933. });
  3934. },
  3935. preventClickAway: function preventClickAway() {
  3936. var selector = 'a[href]:not([href^="#"]):not([target="_blank"]):not([href^="javascript:"])';
  3937. if (external_jQuery_default()._data(external_jQuery_default()(selector).get(0), 'events') && (external_jQuery_default()._data(external_jQuery_default()(selector).get(0), 'events').click || []).filter(function (event) {
  3938. return event.namespace === '_grav';
  3939. })) {
  3940. return;
  3941. } // Prevent clicking away if the form state is dirty
  3942. // instead, display a confirmation before continuing
  3943. external_jQuery_default()(selector).on('click._grav', function (event) {
  3944. var isClean = state_Instance.equals();
  3945. if (isClean === null || isClean) {
  3946. return true;
  3947. }
  3948. event.preventDefault();
  3949. var destination = external_jQuery_default()(this).attr('href');
  3950. var modal = external_jQuery_default()('[data-remodal-id="changes"]');
  3951. var lookup = (external_jQuery_default()).remodal.lookup[modal.data('remodal')];
  3952. var buttons = external_jQuery_default()('a.button', modal);
  3953. var handler = function handler(event) {
  3954. event.preventDefault();
  3955. var action = external_jQuery_default()(this).data('leave-action');
  3956. buttons.off('click', handler);
  3957. lookup.close();
  3958. if (action === 'continue') {
  3959. external_jQuery_default()(__webpack_require__.g).off('beforeunload');
  3960. __webpack_require__.g.location.href = destination;
  3961. }
  3962. };
  3963. buttons.on('click', handler);
  3964. lookup.open();
  3965. });
  3966. }
  3967. };
  3968. var FormState = /*#__PURE__*/function () {
  3969. function FormState() {
  3970. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  3971. ignore: [],
  3972. form_id: 'blueprints'
  3973. };
  3974. state_classCallCheck(this, FormState);
  3975. this.options = options;
  3976. this.refresh();
  3977. if (!this.form || !this.fields.length) {
  3978. return;
  3979. }
  3980. FormLoadState = this.collect();
  3981. this.loadState = FormLoadState;
  3982. DOMBehaviors.attach();
  3983. }
  3984. state_createClass(FormState, [{
  3985. key: "refresh",
  3986. value: function refresh() {
  3987. this.form = external_jQuery_default()("form#".concat(this.options.form_id)).filter(':noparents(.remodal)');
  3988. this.fields = external_jQuery_default()("form#".concat(this.options.form_id, " *, [form=\"").concat(this.options.form_id, "\"]")).filter(':input:not(.no-form)').filter(':noparents(.remodal)');
  3989. return this;
  3990. }
  3991. }, {
  3992. key: "collect",
  3993. value: function collect() {
  3994. var _this = this;
  3995. if (!this.form || !this.fields.length) {
  3996. return;
  3997. }
  3998. var values = {};
  3999. this.refresh().fields.each(function (index, field) {
  4000. field = external_jQuery_default()(field);
  4001. var name = field.prop('name');
  4002. var type = field.prop('type');
  4003. var tag = field.prop('tagName').toLowerCase();
  4004. var value;
  4005. if (name.startsWith('toggleable_') || name === 'data[lang]' || name === 'data[redirect]') {
  4006. return;
  4007. }
  4008. switch (type) {
  4009. case 'checkbox':
  4010. value = field.is(':checked');
  4011. break;
  4012. case 'radio':
  4013. if (!field.is(':checked')) {
  4014. return;
  4015. }
  4016. value = field.val();
  4017. break;
  4018. default:
  4019. value = field.val();
  4020. }
  4021. if (tag === 'select' && value === null) {
  4022. value = '';
  4023. }
  4024. if (Array.isArray(value)) {
  4025. value = value.join('|');
  4026. }
  4027. if (name && !~_this.options.ignore.indexOf(name)) {
  4028. values[name] = value;
  4029. }
  4030. });
  4031. return immutable_es/* default.OrderedMap */.ZP.OrderedMap(values);
  4032. }
  4033. }, {
  4034. key: "diff",
  4035. value: function diff() {
  4036. return diff_default()(FormLoadState, this.collect());
  4037. } // When the form doesn't exist or there are no fields, `equals` returns `null`
  4038. // for this reason, _NEVER_ check with !Instance.equals(), use Instance.equals() === false
  4039. }, {
  4040. key: "equals",
  4041. value: function equals() {
  4042. if (!this.form || !this.fields.length) {
  4043. return null;
  4044. }
  4045. return immutable_es/* default.is */.ZP.is(FormLoadState, this.collect());
  4046. }
  4047. }]);
  4048. return FormState;
  4049. }();
  4050. ;
  4051. var state_Instance = new FormState();
  4052. ;// CONCATENATED MODULE: ./app/forms/form.js
  4053. function form_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4054. function form_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); } }
  4055. function form_createClass(Constructor, protoProps, staticProps) { if (protoProps) form_defineProperties(Constructor.prototype, protoProps); if (staticProps) form_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4056. /* Dependencies for checking if changes happened since load on a form
  4057. import toastr from '../utils/toastr';
  4058. import { translations } from 'grav-config';
  4059. import { Instance as FormState } from './state';
  4060. */
  4061. var Form = /*#__PURE__*/function () {
  4062. function Form(form) {
  4063. var _this = this;
  4064. form_classCallCheck(this, Form);
  4065. this.form = external_jQuery_default()(form);
  4066. if (!this.form.length || this.form.prop('tagName').toLowerCase() !== 'form') {
  4067. return;
  4068. }
  4069. /* Option for not saving while nothing in a form has changed
  4070. this.form.on('submit', (event) => {
  4071. if (FormState.equals()) {
  4072. event.preventDefault();
  4073. toastr.info(translations.PLUGIN_ADMIN.NOTHING_TO_SAVE);
  4074. }
  4075. }); */
  4076. this._attachShortcuts();
  4077. this._attachToggleables();
  4078. this._attachDisabledFields();
  4079. this._submitUncheckedFields();
  4080. this.observer = new MutationObserver(this.addedNodes);
  4081. this.form.each(function (index, form) {
  4082. return _this.observer.observe(form, {
  4083. subtree: true,
  4084. childList: true
  4085. });
  4086. });
  4087. }
  4088. form_createClass(Form, [{
  4089. key: "_attachShortcuts",
  4090. value: function _attachShortcuts() {
  4091. // CTRL + S / CMD + S - shortcut for [Save] when available
  4092. var saveTask = external_jQuery_default()('#titlebar [name="task"][value="save"][form="blueprints"]');
  4093. if (saveTask.length) {
  4094. external_jQuery_default()(__webpack_require__.g).on('keydown', function (event) {
  4095. var key = String.fromCharCode(event.which).toLowerCase();
  4096. if (!event.shiftKey && (event.ctrlKey && !event.altKey || event.metaKey) && key === 's') {
  4097. event.preventDefault();
  4098. saveTask.click();
  4099. }
  4100. });
  4101. }
  4102. }
  4103. }, {
  4104. key: "_attachToggleables",
  4105. value: function _attachToggleables() {
  4106. var query = '[data-grav-field="toggleable"] input[type="checkbox"]';
  4107. this.form.on('change', query, function (event) {
  4108. var toggle = external_jQuery_default()(event.target);
  4109. var enabled = toggle.is(':checked');
  4110. var parent = toggle.closest('.form-field');
  4111. var label = parent.find('label.toggleable');
  4112. var fields = parent.find('.form-data');
  4113. var inputs = fields.find('input, select, textarea, button');
  4114. label.add(fields).css('opacity', enabled ? '' : 0.7);
  4115. inputs.map(function (index, input) {
  4116. var isSelectize = input.selectize;
  4117. input = external_jQuery_default()(input);
  4118. if (isSelectize) {
  4119. isSelectize[enabled ? 'enable' : 'disable']();
  4120. } else {
  4121. input.prop('disabled', !enabled);
  4122. }
  4123. });
  4124. });
  4125. this.form.find(query).trigger('change');
  4126. }
  4127. }, {
  4128. key: "_attachDisabledFields",
  4129. value: function _attachDisabledFields() {
  4130. var prefix = '.form-field-toggleable .form-data';
  4131. var query = [];
  4132. ['input', 'select', 'label[for]', 'textarea', '.selectize-control'].forEach(function (item) {
  4133. query.push("".concat(prefix, " ").concat(item));
  4134. });
  4135. this.form.on('mousedown', query.join(', '), function (event) {
  4136. var input = external_jQuery_default()(event.target);
  4137. var isFor = input.prop('for');
  4138. var isSelectize = (input.hasClass('selectize-control') || input.parents('.selectize-control')).length;
  4139. if (isFor) {
  4140. input = external_jQuery_default()("[id=\"".concat(isFor, "\"]"));
  4141. }
  4142. if (isSelectize) {
  4143. input = input.closest('.selectize-control').siblings('select[name]');
  4144. }
  4145. if (!input.prop('disabled')) {
  4146. return true;
  4147. }
  4148. var toggle = input.closest('.form-field').find('[data-grav-field="toggleable"] input[type="checkbox"]');
  4149. toggle.trigger('click');
  4150. });
  4151. }
  4152. }, {
  4153. key: "_submitUncheckedFields",
  4154. value: function _submitUncheckedFields() {
  4155. var submitted = false;
  4156. this.form.each(function (index, form) {
  4157. form = external_jQuery_default()(form);
  4158. form.on('submit', function () {
  4159. // workaround for MS Edge, submitting multiple forms at the same time
  4160. if (submitted) {
  4161. return false;
  4162. }
  4163. var formId = form.attr('id');
  4164. var unchecked = form.find('input[type="checkbox"]:not(:checked):not(:disabled)');
  4165. var submit = form.find('[type="submit"]').add("[form=\"".concat(formId, "\"][type=\"submit\"]"));
  4166. if (!unchecked.length) {
  4167. return true;
  4168. }
  4169. submit.addClass('pointer-events-disabled');
  4170. unchecked.each(function (index, element) {
  4171. element = external_jQuery_default()(element);
  4172. var name = element.prop('name');
  4173. var fake = external_jQuery_default()("<input type=\"hidden\" name=\"".concat(name, "\" value=\"0\" />"));
  4174. form.append(fake);
  4175. });
  4176. submitted = true;
  4177. return true;
  4178. });
  4179. });
  4180. }
  4181. }, {
  4182. key: "addedNodes",
  4183. value: function addedNodes(mutations) {
  4184. var _this2 = this;
  4185. mutations.forEach(function (mutation) {
  4186. if (mutation.type !== 'childList') {
  4187. return;
  4188. }
  4189. if (mutation.addedNodes) {
  4190. external_jQuery_default()('body').trigger('mutation._grav', mutation.target, mutation, _this2);
  4191. }
  4192. if (mutation.removedNodes) {
  4193. external_jQuery_default()('body').trigger('mutation_removed._grav', {
  4194. target: mutation.target,
  4195. mutation: mutation
  4196. }, _this2);
  4197. }
  4198. });
  4199. }
  4200. }]);
  4201. return Form;
  4202. }();
  4203. var form_Instance = new Form('form#blueprints');
  4204. ;// CONCATENATED MODULE: ./app/forms/fields/filepicker.js
  4205. function filepicker_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4206. function filepicker_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); } }
  4207. function filepicker_createClass(Constructor, protoProps, staticProps) { if (protoProps) filepicker_defineProperties(Constructor.prototype, protoProps); if (staticProps) filepicker_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4208. // const insertTextAt = (string, index, text) => [string.slice(0, index), text, string.slice(index)].join('');
  4209. var FilePickerField = /*#__PURE__*/function () {
  4210. function FilePickerField(options) {
  4211. var _this = this;
  4212. filepicker_classCallCheck(this, FilePickerField);
  4213. this.items = external_jQuery_default()();
  4214. this.options = Object.assign({}, this.defaults, options);
  4215. external_jQuery_default()('[data-grav-filepicker]').each(function (index, element) {
  4216. return _this.addItem(element);
  4217. });
  4218. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  4219. }
  4220. filepicker_createClass(FilePickerField, [{
  4221. key: "_onAddedNodes",
  4222. value: function _onAddedNodes(event, target
  4223. /* , record, instance */
  4224. ) {
  4225. var _this2 = this;
  4226. var fields = external_jQuery_default()(target).find('[data-grav-filepicker]');
  4227. if (!fields.length) {
  4228. return;
  4229. }
  4230. fields.each(function (index, field) {
  4231. field = external_jQuery_default()(field);
  4232. if (!~_this2.items.index(field)) {
  4233. _this2.addItem(field);
  4234. }
  4235. });
  4236. }
  4237. }, {
  4238. key: "addItem",
  4239. value: function addItem(element) {
  4240. element = external_jQuery_default()(element);
  4241. this.items = this.items.add(element);
  4242. var tag = element.prop('tagName').toLowerCase();
  4243. var isInput = tag === 'input' || tag === 'select';
  4244. var field = isInput ? element : element.find('input, select');
  4245. var folder = '';
  4246. var thumbs = {};
  4247. var onDemand = field.closest('[data-ondemand]').length > 0;
  4248. if (!field.length || field.get(0).selectize) {
  4249. return;
  4250. }
  4251. var getData = function getData(field, callback) {
  4252. var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
  4253. var url = external_GravAdmin_namespaceObject.config.current_url + ".json/task".concat(external_GravAdmin_namespaceObject.config.param_sep, "getFilesInFolder");
  4254. var parent = field.closest('[data-grav-filepicker]');
  4255. var name = parent.data('name');
  4256. var value = parent.data('value');
  4257. var params = JSON.stringify(external_GravAdmin_namespaceObject.uri_params || '{}');
  4258. utils_request(url, {
  4259. method: 'post',
  4260. body: {
  4261. name: name,
  4262. params: params
  4263. }
  4264. }, function (response) {
  4265. if (typeof response.files === 'undefined') {
  4266. return;
  4267. }
  4268. var data = [];
  4269. thumbs = response.thumbs || {};
  4270. for (var i = 0; i < response.files.length; i++) {
  4271. if (mode === 'selected' && response.files[i] !== value) {
  4272. continue;
  4273. }
  4274. data.push({
  4275. 'name': response.files[i],
  4276. 'status': 'available',
  4277. thumb: thumbs[response.files[i]] || ''
  4278. });
  4279. }
  4280. for (var _i = 0; _i < response.pending.length; _i++) {
  4281. if (mode === 'selected' && response.pending[_i] !== value) {
  4282. continue;
  4283. }
  4284. data.push({
  4285. 'name': response.pending[_i],
  4286. 'status': 'pending',
  4287. thumb: thumbs[response.pending[_i]] || ''
  4288. });
  4289. }
  4290. folder = response.folder;
  4291. callback(data, value);
  4292. });
  4293. };
  4294. var imagesPreview = field.closest('[data-preview-images]').length > 0;
  4295. var selectedIsRendered = false;
  4296. var renderOption = function renderOption(item, escape) {
  4297. var image = '';
  4298. if (imagesPreview && folder && (!item.status || item.status === 'available') && item.name.match(/\.(jpg|jpeg|png|gif|webp)$/i)) {
  4299. // const fallback2x = insertTextAt(`${config.base_url_relative}/../${folder}/${item.name}`, -4, '@2x');
  4300. // const fallback3x = insertTextAt(`${config.base_url_relative}/../${folder}/${item.name}`, -4, '@3x');
  4301. var source = thumbs[item.name] || "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/../").concat(folder, "/").concat(item.name); // onerror="if(this.src==='${fallback2x}'){this.src='${fallback3x}';}else{this.src='${fallback2x}'}"
  4302. image = "<img class=\"filepicker-field-image\" src=\"".concat(source, "\" />");
  4303. }
  4304. return "<div>\n <span class=\"title\">\n ".concat(image, " <span class=\"name filepicker-field-name\">").concat(escape(item.name), "</span>\n </span>\n </div>");
  4305. };
  4306. field.selectize({
  4307. plugins: ['required-fix'],
  4308. valueField: 'name',
  4309. labelField: 'name',
  4310. searchField: 'name',
  4311. optgroups: [{
  4312. $order: 1,
  4313. value: 'pending',
  4314. label: 'Pending'
  4315. }, {
  4316. $order: 2,
  4317. value: 'available',
  4318. label: 'Available'
  4319. }],
  4320. optgroupField: 'status',
  4321. // lockOptgroupOrder: true,
  4322. create: false,
  4323. preload: false,
  4324. // 'focus',
  4325. render: {
  4326. option: function option(item, escape) {
  4327. return renderOption(item, escape);
  4328. },
  4329. item: function item(_item, escape) {
  4330. return renderOption(_item, escape);
  4331. }
  4332. },
  4333. onInitialize: function onInitialize() {
  4334. if (!onDemand) {
  4335. this.load(function (callback) {
  4336. return getData(field, function (data) {
  4337. return callback(data);
  4338. }, 'selected');
  4339. });
  4340. }
  4341. },
  4342. onLoad: function
  4343. /* data */
  4344. onLoad() {
  4345. if (!selectedIsRendered) {
  4346. var name = this.getValue();
  4347. this.updateOption(name, {
  4348. name: name
  4349. });
  4350. selectedIsRendered = true;
  4351. }
  4352. },
  4353. onFocus: function onFocus() {
  4354. this.load(function (callback) {
  4355. return getData(field, function (data) {
  4356. return callback(data);
  4357. });
  4358. });
  4359. }
  4360. });
  4361. }
  4362. }]);
  4363. return FilePickerField;
  4364. }();
  4365. var filepicker_Instance = new FilePickerField();
  4366. ;// CONCATENATED MODULE: ./app/utils/selectize-option-click.js
  4367. selectize_default().define('option_click', function (options) {
  4368. var self = this;
  4369. var setup = self.setup;
  4370. this.setup = function () {
  4371. setup.apply(self, arguments);
  4372. var clicking = false; // Detect click on a .clickable
  4373. self.$dropdown_content.on('mousedown click', function (e) {
  4374. var target = external_jQuery_default()(e.target);
  4375. if (target.hasClass('clickable') || target.closest('.clickable').length) {
  4376. if (e.type === 'mousedown') {
  4377. clicking = true;
  4378. self.isFocused = false; // awful hack to defuse the document mousedown listener
  4379. } else {
  4380. self.isFocused = true;
  4381. setTimeout(function () {
  4382. clicking = false; // wait until blur has been preempted
  4383. });
  4384. }
  4385. } else {
  4386. // cleanup in case user right-clicked or dragged off the element
  4387. clicking = false;
  4388. self.isFocused = true;
  4389. }
  4390. }); // Intercept default handlers
  4391. self.$dropdown.off('mousedown click', '[data-selectable]').on('mousedown click', '[data-selectable]', function () {
  4392. if (!clicking) {
  4393. return self.onOptionSelect.apply(self, arguments);
  4394. }
  4395. });
  4396. self.$control_input.off('blur').on('blur', function () {
  4397. if (!clicking) {
  4398. return self.onBlur.apply(self, arguments);
  4399. }
  4400. });
  4401. };
  4402. });
  4403. ;// CONCATENATED MODULE: ./app/forms/fields/selectize.js
  4404. function selectize_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4405. function selectize_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); } }
  4406. function selectize_createClass(Constructor, protoProps, staticProps) { if (protoProps) selectize_defineProperties(Constructor.prototype, protoProps); if (staticProps) selectize_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4407. var PagesRoute = {
  4408. option: function option(item, escape) {
  4409. var label = escape(item.text).split(' ');
  4410. var arrows = label.shift();
  4411. var slug = label.shift();
  4412. return "<div class=\"selectize-route-option\">\n <span class=\"text-grey\">".concat(arrows, "</span>\n <span>\n <span class=\"text-update\">").concat(slug.replace('(', '/').replace(')', ''), "</span>\n <span>").concat(label.join(' '), "</span>\n </span>\n </div>");
  4413. }
  4414. };
  4415. var SelectizeField = /*#__PURE__*/function () {
  4416. function SelectizeField() {
  4417. var _this = this;
  4418. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4419. selectize_classCallCheck(this, SelectizeField);
  4420. this.options = Object.assign({}, options);
  4421. this.elements = [];
  4422. external_jQuery_default()('[data-grav-selectize]').each(function (index, element) {
  4423. return _this.add(element);
  4424. });
  4425. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  4426. }
  4427. selectize_createClass(SelectizeField, [{
  4428. key: "add",
  4429. value: function add(element) {
  4430. element = external_jQuery_default()(element);
  4431. if (element.closest('template').length) {
  4432. return false;
  4433. }
  4434. var tag = element.prop('tagName').toLowerCase();
  4435. var isInput = tag === 'input' || tag === 'select';
  4436. var data = (isInput ? element.closest('[data-grav-selectize]') : element).data('grav-selectize') || {};
  4437. var field = isInput ? element : element.find('input, select');
  4438. if (field.attr('name') === 'data[route]') {
  4439. data = external_jQuery_default().extend({}, data, {
  4440. render: PagesRoute
  4441. });
  4442. }
  4443. if (!field.length || field.get(0).selectize) {
  4444. return;
  4445. }
  4446. var plugins = external_jQuery_default().merge(data.plugins ? data.plugins : [], ['required-fix']);
  4447. field.selectize(external_jQuery_default().extend({}, data, {
  4448. plugins: plugins
  4449. }));
  4450. this.elements.push(field.data('selectize'));
  4451. }
  4452. }, {
  4453. key: "_onAddedNodes",
  4454. value: function _onAddedNodes(event, target
  4455. /* , record, instance */
  4456. ) {
  4457. var _this2 = this;
  4458. var fields = external_jQuery_default()(target).find('select.fancy, input.fancy, [data-grav-selectize]').filter(function (index, element) {
  4459. return !external_jQuery_default()(element).closest('template').length;
  4460. });
  4461. if (!fields.length) {
  4462. return;
  4463. }
  4464. fields.each(function (index, field) {
  4465. return _this2.add(field);
  4466. });
  4467. }
  4468. }]);
  4469. return SelectizeField;
  4470. }();
  4471. var selectize_Instance = new SelectizeField();
  4472. ;// CONCATENATED MODULE: ./app/forms/fields/array.js
  4473. function array_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4474. function array_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); } }
  4475. function array_createClass(Constructor, protoProps, staticProps) { if (protoProps) array_defineProperties(Constructor.prototype, protoProps); if (staticProps) array_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4476. var body = external_jQuery_default()('body');
  4477. var Template = /*#__PURE__*/function () {
  4478. function Template(container) {
  4479. array_classCallCheck(this, Template);
  4480. this.container = external_jQuery_default()(container);
  4481. if (this.getName() === undefined) {
  4482. this.container = this.container.closest('[data-grav-array-name]');
  4483. }
  4484. }
  4485. array_createClass(Template, [{
  4486. key: "getName",
  4487. value: function getName() {
  4488. return this.container.data('grav-array-name') || '';
  4489. }
  4490. }, {
  4491. key: "getKeyPlaceholder",
  4492. value: function getKeyPlaceholder() {
  4493. return this.container.data('grav-array-keyname') || 'Key';
  4494. }
  4495. }, {
  4496. key: "getValuePlaceholder",
  4497. value: function getValuePlaceholder() {
  4498. return this.container.data('grav-array-valuename') || 'Value';
  4499. }
  4500. }, {
  4501. key: "isValueOnly",
  4502. value: function isValueOnly() {
  4503. return this.container.find('[data-grav-array-mode="value_only"]:first').length || false;
  4504. }
  4505. }, {
  4506. key: "isTextArea",
  4507. value: function isTextArea() {
  4508. return this.container.data('grav-array-textarea') || false;
  4509. }
  4510. }, {
  4511. key: "shouldBeDisabled",
  4512. value: function shouldBeDisabled() {
  4513. // check for toggleables, if field is toggleable and it's not enabled, render disabled
  4514. var toggle = this.container.closest('.form-field').find('[data-grav-field="toggleable"] input[type="checkbox"]');
  4515. return toggle.length && toggle.is(':not(:checked)');
  4516. }
  4517. }, {
  4518. key: "getNewRow",
  4519. value: function getNewRow() {
  4520. var tpl = '';
  4521. var value = this.isTextArea() ? "<textarea ".concat(this.shouldBeDisabled() ? 'disabled="disabled"' : '', " data-grav-array-type=\"value\" name=\"\" placeholder=\"").concat(this.getValuePlaceholder(), "\"></textarea>") : "<input ".concat(this.shouldBeDisabled() ? 'disabled="disabled"' : '', " data-grav-array-type=\"value\" type=\"text\" name=\"\" value=\"\" placeholder=\"").concat(this.getValuePlaceholder(), "\" />");
  4522. if (this.isValueOnly()) {
  4523. tpl += "\n <div class=\"form-row array-field-value_only\" data-grav-array-type=\"row\">\n <span data-grav-array-action=\"sort\" class=\"fa fa-bars\"></span>\n ".concat(value, "\n ");
  4524. } else {
  4525. tpl += "\n <div class=\"form-row\" data-grav-array-type=\"row\">\n <span data-grav-array-action=\"sort\" class=\"fa fa-bars\"></span>\n <input ".concat(this.shouldBeDisabled() ? 'disabled="disabled"' : '', " data-grav-array-type=\"key\" type=\"text\" value=\"\" placeholder=\"").concat(this.getKeyPlaceholder(), "\" />\n ").concat(value, "\n ");
  4526. }
  4527. tpl += "\n <span data-grav-array-action=\"rem\" class=\"fa fa-minus\"></span>\n <span data-grav-array-action=\"add\" class=\"fa fa-plus\"></span>\n </div>";
  4528. return tpl;
  4529. }
  4530. }]);
  4531. return Template;
  4532. }();
  4533. var ArrayField = /*#__PURE__*/function () {
  4534. function ArrayField() {
  4535. var _this = this;
  4536. array_classCallCheck(this, ArrayField);
  4537. body.on('input', '[data-grav-array-type="key"], [data-grav-array-type="value"]', function (event) {
  4538. return _this.actionInput(event);
  4539. });
  4540. body.on('click touch', '[data-grav-array-action]:not([data-grav-array-action="sort"])', function (event) {
  4541. return _this.actionEvent(event);
  4542. });
  4543. this.arrays = external_jQuery_default()();
  4544. external_jQuery_default()('[data-grav-field="array"]').each(function (index, list) {
  4545. return _this.addArray(list);
  4546. });
  4547. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  4548. }
  4549. array_createClass(ArrayField, [{
  4550. key: "addArray",
  4551. value: function addArray(list) {
  4552. var _this2 = this;
  4553. list = external_jQuery_default()(list);
  4554. list.find('[data-grav-array-type="container"]').each(function (index, container) {
  4555. container = external_jQuery_default()(container);
  4556. if (container.data('array-sort') || container[0].hasAttribute('data-array-nosort')) {
  4557. return;
  4558. }
  4559. container.data('array-sort', new sortable_esm/* default */.ZP(container.get(0), {
  4560. handle: '.fa-bars',
  4561. animation: 150,
  4562. onUpdate: function onUpdate() {
  4563. var item = container.find('[data-grav-array-type="row"]:first');
  4564. _this2._setTemplate(item);
  4565. var template = item.data('array-template');
  4566. _this2.refreshNames(template);
  4567. }
  4568. }));
  4569. });
  4570. }
  4571. }, {
  4572. key: "actionInput",
  4573. value: function actionInput(event) {
  4574. var element = external_jQuery_default()(event.target);
  4575. var type = element.data('grav-array-type');
  4576. this._setTemplate(element);
  4577. var template = element.data('array-template');
  4578. var keyElement = type === 'key' ? element : element.siblings('[data-grav-array-type="key"]:first');
  4579. var valueElement = type === 'value' ? element : element.siblings('[data-grav-array-type="value"]:first');
  4580. var escaped_name = !template.isValueOnly() ? keyElement.val() : this.getIndexFor(element);
  4581. escaped_name = escaped_name.toString().replace(/\[/g, '%5B').replace(/]/g, '%5D');
  4582. var name = "".concat(template.getName(), "[").concat(escaped_name, "]");
  4583. if (!template.isValueOnly() && !keyElement.val() && !valueElement.val()) {
  4584. valueElement.attr('name', '');
  4585. } else {
  4586. // valueElement.attr('name', !valueElement.val() ? template.getName() : name);
  4587. valueElement.attr('name', name);
  4588. }
  4589. this.refreshNames(template);
  4590. }
  4591. }, {
  4592. key: "actionEvent",
  4593. value: function actionEvent(event) {
  4594. event && event.preventDefault();
  4595. var element = external_jQuery_default()(event.target);
  4596. var action = element.data('grav-array-action');
  4597. var container = element.parents('[data-grav-array-type="container"]');
  4598. this._setTemplate(element);
  4599. this["".concat(action, "Action")](element);
  4600. var siblings = container.find('> div');
  4601. container[siblings.length > 1 ? 'removeClass' : 'addClass']('one-child');
  4602. }
  4603. }, {
  4604. key: "addAction",
  4605. value: function addAction(element) {
  4606. var template = element.data('array-template');
  4607. var row = element.closest('[data-grav-array-type="row"]');
  4608. row.after(template.getNewRow());
  4609. }
  4610. }, {
  4611. key: "remAction",
  4612. value: function remAction(element) {
  4613. var template = element.data('array-template');
  4614. var row = element.closest('[data-grav-array-type="row"]');
  4615. var isLast = !row.siblings().length;
  4616. if (isLast) {
  4617. var newRow = external_jQuery_default()(template.getNewRow());
  4618. row.after(newRow);
  4619. newRow.find('[data-grav-array-type="value"]:last').attr('name', template.getName());
  4620. }
  4621. row.remove();
  4622. this.refreshNames(template);
  4623. }
  4624. }, {
  4625. key: "refreshNames",
  4626. value: function refreshNames(template) {
  4627. if (!template.isValueOnly()) {
  4628. return;
  4629. }
  4630. var row = template.container.find('> div > [data-grav-array-type="row"]');
  4631. var inputs = row.find('[name]:not([name=""])');
  4632. inputs.each(function (index, input) {
  4633. input = external_jQuery_default()(input);
  4634. var preserved_name = input.closest('[data-grav-array-name]');
  4635. var name = "".concat(preserved_name.attr('data-grav-array-name'), "[").concat(index, "]");
  4636. input.attr('name', name);
  4637. });
  4638. if (!inputs.length) {
  4639. row.find('[data-grav-array-type="value"]').attr('name', template.getName());
  4640. }
  4641. }
  4642. }, {
  4643. key: "getIndexFor",
  4644. value: function getIndexFor(element) {
  4645. var template = element.data('array-template');
  4646. var row = element.closest('[data-grav-array-type="row"]');
  4647. return template.container.find("".concat(template.isValueOnly() ? '> div ' : '', " > [data-grav-array-type=\"row\"]")).index(row);
  4648. }
  4649. }, {
  4650. key: "_setTemplate",
  4651. value: function _setTemplate(element) {
  4652. if (!element.data('array-template')) {
  4653. element.data('array-template', new Template(element.closest('[data-grav-array-name]')));
  4654. }
  4655. }
  4656. }, {
  4657. key: "_onAddedNodes",
  4658. value: function _onAddedNodes(event, target
  4659. /* , record, instance */
  4660. ) {
  4661. var _this3 = this;
  4662. var arrays = external_jQuery_default()(target).find('[data-grav-field="array"]');
  4663. if (!arrays.length) {
  4664. return;
  4665. }
  4666. arrays.each(function (index, list) {
  4667. list = external_jQuery_default()(list);
  4668. if (!~_this3.arrays.index(list)) {
  4669. _this3.addArray(list);
  4670. }
  4671. });
  4672. }
  4673. }]);
  4674. return ArrayField;
  4675. }();
  4676. var array_Instance = new ArrayField();
  4677. ;// CONCATENATED MODULE: ./app/forms/fields/collections.js
  4678. function collections_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4679. function collections_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); } }
  4680. function collections_createClass(Constructor, protoProps, staticProps) { if (protoProps) collections_defineProperties(Constructor.prototype, protoProps); if (staticProps) collections_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4681. var CollectionsField = /*#__PURE__*/function () {
  4682. function CollectionsField() {
  4683. var _this = this;
  4684. collections_classCallCheck(this, CollectionsField);
  4685. this.lists = external_jQuery_default()();
  4686. var body = external_jQuery_default()('body');
  4687. external_jQuery_default()('[data-type="collection"]').each(function (index, list) {
  4688. return _this.addList(list);
  4689. });
  4690. body.on('mutation._grav', this._onAddedNodes.bind(this));
  4691. body.on('click', function (event) {
  4692. var target = external_jQuery_default()(event.target);
  4693. if (!(target.is('[data-action="confirm"], [data-action="delete"]') || target.closest('[data-action="confirm"], [data-action="delete"]').length)) {
  4694. CollectionsField.closeConfirmations();
  4695. }
  4696. });
  4697. }
  4698. collections_createClass(CollectionsField, [{
  4699. key: "addList",
  4700. value: function addList(list) {
  4701. var _this2 = this;
  4702. list = external_jQuery_default()(list);
  4703. this.lists = this.lists.add(list);
  4704. list.on('click', '> .collection-actions [data-action="add"]', function (event) {
  4705. return _this2.addItem(event);
  4706. });
  4707. list.on('click', '> ul > li > .item-actions [data-action="confirm"]', function (event) {
  4708. return _this2.confirmRemove(event);
  4709. });
  4710. list.on('click', '> ul > li > .item-actions [data-action="delete"]', function (event) {
  4711. return _this2.removeItem(event);
  4712. });
  4713. list.on('click', '> ul > li > .item-actions [data-action="collapse"]', function (event) {
  4714. return _this2.collapseItem(event);
  4715. });
  4716. list.on('click', '> ul > li > .item-actions [data-action="expand"]', function (event) {
  4717. return _this2.expandItem(event);
  4718. });
  4719. list.on('click', '> .collection-actions [data-action-sort="date"]', function (event) {
  4720. return _this2.sortItems(event);
  4721. });
  4722. list.on('click', '> .collection-actions [data-action="collapse_all"]', function (event) {
  4723. return _this2.collapseItems(event);
  4724. });
  4725. list.on('click', '> .collection-actions [data-action="expand_all"]', function (event) {
  4726. return _this2.expandItems(event);
  4727. });
  4728. list.on('input change', '[data-key-observe]', function (event) {
  4729. return _this2.observeKey(event);
  4730. });
  4731. list.find('[data-collection-holder]').each(function (index, container) {
  4732. container = external_jQuery_default()(container);
  4733. if (container.data('collection-sort') || container[0].hasAttribute('data-collection-nosort')) {
  4734. return;
  4735. }
  4736. container.data('collection-sort', new sortable_esm/* default */.ZP(container.get(0), {
  4737. forceFallback: false,
  4738. handle: '.collection-sort',
  4739. animation: 150,
  4740. onUpdate: function onUpdate() {
  4741. return _this2.reindex(container);
  4742. }
  4743. }));
  4744. });
  4745. this._updateActionsStateBasedOnMinMax(list);
  4746. }
  4747. }, {
  4748. key: "addItem",
  4749. value: function addItem(event) {
  4750. var button = external_jQuery_default()(event.currentTarget);
  4751. var position = button.data('action-add') || 'bottom';
  4752. var list = external_jQuery_default()(button.closest('[data-type="collection"]'));
  4753. var template = external_jQuery_default()(list.find('> [data-collection-template="new"]').data('collection-template-html'));
  4754. this._updateActionsStateBasedOnMinMax(list);
  4755. var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4756. var maxItems = list.data('max');
  4757. if (typeof maxItems !== 'undefined' && items.length >= maxItems) {
  4758. return;
  4759. }
  4760. list.find('> [data-collection-holder]')[position === 'top' ? 'prepend' : 'append'](template);
  4761. this.reindex(list);
  4762. items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4763. var topAction = list.closest('[data-type="collection"]').find('[data-action-add="top"]');
  4764. var sortAction = list.closest('[data-type="collection"]').find('[data-action="sort"]');
  4765. if (items.length) {
  4766. if (topAction.length) {
  4767. topAction.parent().removeClass('hidden');
  4768. }
  4769. if (sortAction.length && items.length > 1) {
  4770. sortAction.removeClass('hidden');
  4771. }
  4772. } // refresh toggleables in a list
  4773. external_jQuery_default()('[data-grav-field="toggleable"] input[type="checkbox"]').trigger('change');
  4774. }
  4775. }, {
  4776. key: "confirmRemove",
  4777. value: function confirmRemove(event) {
  4778. var button = external_jQuery_default()(event.currentTarget);
  4779. var list = external_jQuery_default()(button.closest('.item-actions'));
  4780. var action = list.find('.list-confirm-deletion[data-action="delete"]');
  4781. var isHidden = action.hasClass('hidden');
  4782. CollectionsField.closeConfirmations();
  4783. action[isHidden ? 'removeClass' : 'addClass']('hidden');
  4784. }
  4785. }, {
  4786. key: "removeItem",
  4787. value: function removeItem(event) {
  4788. var button = external_jQuery_default()(event.currentTarget);
  4789. var item = button.closest('[data-collection-item]');
  4790. var list = external_jQuery_default()(button.closest('[data-type="collection"]'));
  4791. var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4792. var minItems = list.data('min');
  4793. if (typeof minItems !== 'undefined' && items.length <= minItems) {
  4794. return;
  4795. }
  4796. item.remove();
  4797. this.reindex(list);
  4798. items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4799. var topAction = list.closest('[data-type="collection"]').find('[data-action-add="top"]');
  4800. var sortAction = list.closest('[data-type="collection"]').find('[data-action="sort"]');
  4801. if (!items.length) {
  4802. if (topAction.length) {
  4803. topAction.parent().addClass('hidden');
  4804. }
  4805. }
  4806. if (sortAction.length && items.length <= 1) {
  4807. sortAction.addClass('hidden');
  4808. }
  4809. this._updateActionsStateBasedOnMinMax(list);
  4810. }
  4811. }, {
  4812. key: "collapseItems",
  4813. value: function collapseItems(event) {
  4814. var button = external_jQuery_default()(event.currentTarget);
  4815. var items = external_jQuery_default()(button.closest('[data-type="collection"]')).find('> ul > [data-collection-item] > .item-actions [data-action="collapse"]');
  4816. items.click();
  4817. }
  4818. }, {
  4819. key: "collapseItem",
  4820. value: function collapseItem(event) {
  4821. var button = external_jQuery_default()(event.currentTarget);
  4822. var item = button.closest('[data-collection-item]');
  4823. button.attr('data-action', 'expand').removeClass('fa-chevron-circle-down').addClass('fa-chevron-circle-right');
  4824. item.addClass('collection-collapsed');
  4825. }
  4826. }, {
  4827. key: "expandItems",
  4828. value: function expandItems(event) {
  4829. var button = external_jQuery_default()(event.currentTarget);
  4830. var items = external_jQuery_default()(button.closest('[data-type="collection"]')).find('> ul > [data-collection-item] > .item-actions [data-action="expand"]');
  4831. items.click();
  4832. }
  4833. }, {
  4834. key: "expandItem",
  4835. value: function expandItem(event) {
  4836. var button = external_jQuery_default()(event.currentTarget);
  4837. var item = button.closest('[data-collection-item]');
  4838. button.attr('data-action', 'collapse').removeClass('fa-chevron-circle-right').addClass('fa-chevron-circle-down');
  4839. item.removeClass('collection-collapsed');
  4840. }
  4841. }, {
  4842. key: "sortItems",
  4843. value: function sortItems(event) {
  4844. var button = external_jQuery_default()(event.currentTarget);
  4845. var sortby = button.data('action-sort');
  4846. var sortby_dir = button.data('action-sort-dir') || 'asc';
  4847. var list = external_jQuery_default()(button.closest('[data-type="collection"]'));
  4848. var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4849. items.sort(function (a, b) {
  4850. var A = external_jQuery_default()(a).find('[name$="[' + sortby + ']"]');
  4851. var B = external_jQuery_default()(b).find('[name$="[' + sortby + ']"]');
  4852. var sort;
  4853. if (sortby_dir === 'asc') {
  4854. sort = A.val() < B.val() ? -1 : A.val() > B.val() ? 1 : 0;
  4855. } else {
  4856. sort = A.val() > B.val() ? -1 : A.val() < B.val() ? 1 : 0;
  4857. }
  4858. return sort;
  4859. }).each(function (_, container) {
  4860. external_jQuery_default()(container).parent().append(container);
  4861. });
  4862. this.reindex(list);
  4863. }
  4864. }, {
  4865. key: "observeKey",
  4866. value: function observeKey(event) {
  4867. var input = external_jQuery_default()(event.target);
  4868. var value = input.val();
  4869. var item = input.closest('[data-collection-key]');
  4870. item.data('collection-key-backup', item.data('collection-key')).data('collection-key', value);
  4871. this.reindex(null, item);
  4872. }
  4873. }, {
  4874. key: "reindex",
  4875. value: function reindex(list, items) {
  4876. items = items || external_jQuery_default()(list).closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4877. items.each(function (index, item) {
  4878. item = external_jQuery_default()(item);
  4879. var observed = item.find('[data-key-observe]');
  4880. var observedValue = observed.val();
  4881. var hasCustomKey = observed.length;
  4882. var currentKey = item.data('collection-key-backup');
  4883. item.attr('data-collection-key', hasCustomKey ? observedValue : index);
  4884. ['name', 'data-grav-field-name', 'for', 'id', 'data-grav-file-settings', 'data-file-post-add', 'data-file-post-remove', 'data-grav-array-name', 'data-grav-elements'].forEach(function (prop) {
  4885. item.find('[' + prop + '], [_' + prop + ']').each(function () {
  4886. var element = external_jQuery_default()(this);
  4887. var indexes = [];
  4888. var array_index = null;
  4889. var regexps = [new RegExp('\\[(\\d+|\\*|' + currentKey + ')\\]', 'g'), new RegExp('\\.(\\d+|\\*|' + currentKey + ')\\.', 'g')]; // special case to preserve array field index keys
  4890. if (prop === 'name' && element.data('gravArrayType')) {
  4891. var match_index = element.attr(prop).match(/\[[0-9]{1,}\]$/);
  4892. var pattern = element[0].closest('[data-grav-array-name]').dataset.gravArrayName;
  4893. if (match_index && pattern) {
  4894. array_index = match_index[0];
  4895. element.attr(prop, "".concat(pattern).concat(match_index[0]));
  4896. return;
  4897. }
  4898. }
  4899. if (hasCustomKey && !observedValue) {
  4900. element.attr("_".concat(prop), element.attr(prop));
  4901. element.attr(prop, null);
  4902. return;
  4903. }
  4904. if (element.attr("_".concat(prop))) {
  4905. element.attr(prop, element.attr("_".concat(prop)));
  4906. element.attr("_".concat(prop), null);
  4907. }
  4908. element.parents('[data-collection-key]').map(function (idx, parent) {
  4909. return indexes.push(external_jQuery_default()(parent).attr('data-collection-key'));
  4910. });
  4911. indexes.reverse();
  4912. var matchedKey = currentKey;
  4913. var replaced = element.attr(prop).replace(regexps[0], function
  4914. /* str, p1, offset */
  4915. () {
  4916. var extras = '';
  4917. if (array_index) {
  4918. extras = array_index;
  4919. console.log(indexes, extras);
  4920. }
  4921. matchedKey = indexes.shift() || matchedKey;
  4922. return "[".concat(matchedKey, "]").concat(extras);
  4923. });
  4924. replaced = replaced.replace(regexps[1], function
  4925. /* str, p1, offset */
  4926. () {
  4927. matchedKey = indexes.shift() || matchedKey;
  4928. return ".".concat(matchedKey, ".");
  4929. });
  4930. element.attr(prop, replaced);
  4931. });
  4932. });
  4933. });
  4934. }
  4935. }, {
  4936. key: "_onAddedNodes",
  4937. value: function _onAddedNodes(event, target
  4938. /* , record, instance */
  4939. ) {
  4940. var _this3 = this;
  4941. var collections = external_jQuery_default()(target).find('[data-type="collection"]');
  4942. if (!collections.length) {
  4943. return;
  4944. }
  4945. collections.each(function (index, collection) {
  4946. collection = external_jQuery_default()(collection);
  4947. if (!~_this3.lists.index(collection)) {
  4948. _this3.addList(collection);
  4949. }
  4950. });
  4951. }
  4952. }, {
  4953. key: "_updateActionsStateBasedOnMinMax",
  4954. value: function _updateActionsStateBasedOnMinMax(list) {
  4955. var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4956. var minItems = list.data('min');
  4957. var maxItems = list.data('max');
  4958. list.find('> .collection-actions [data-action="add"]').attr('disabled', false);
  4959. list.find('> ul > li > .item-actions [data-action="delete"]').attr('disabled', false);
  4960. if (typeof minItems !== 'undefined' && items.length <= minItems) {
  4961. list.find('> ul > li > .item-actions [data-action="delete"]').attr('disabled', true);
  4962. }
  4963. if (typeof maxItems !== 'undefined' && items.length >= maxItems) {
  4964. list.find('> .collection-actions [data-action="add"]').attr('disabled', true);
  4965. }
  4966. }
  4967. }], [{
  4968. key: "closeConfirmations",
  4969. value: function closeConfirmations() {
  4970. external_jQuery_default()('.list-confirm-deletion[data-action="delete"]').addClass('hidden');
  4971. }
  4972. }]);
  4973. return CollectionsField;
  4974. }();
  4975. var collections_Instance = new CollectionsField();
  4976. // EXTERNAL MODULE: ./app/utils/bootstrap-datetimepicker.js
  4977. var bootstrap_datetimepicker = __webpack_require__(19912);
  4978. ;// CONCATENATED MODULE: ./app/forms/fields/datetime.js
  4979. function datetime_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4980. function datetime_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); } }
  4981. function datetime_createClass(Constructor, protoProps, staticProps) { if (protoProps) datetime_defineProperties(Constructor.prototype, protoProps); if (staticProps) datetime_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  4982. var DateTimeField = /*#__PURE__*/function () {
  4983. function DateTimeField(options) {
  4984. var _this = this;
  4985. datetime_classCallCheck(this, DateTimeField);
  4986. this.items = external_jQuery_default()();
  4987. this.options = Object.assign({}, this.defaults, options);
  4988. external_jQuery_default()('[data-grav-datetime]').each(function (index, field) {
  4989. return _this.addItem(field);
  4990. });
  4991. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  4992. }
  4993. datetime_createClass(DateTimeField, [{
  4994. key: "defaults",
  4995. get: function get() {
  4996. return {
  4997. showTodayButton: true,
  4998. showClear: true,
  4999. locale: external_GravAdmin_namespaceObject.config.language || 'en',
  5000. icons: {
  5001. time: 'fa fa-clock-o',
  5002. date: 'fa fa-calendar-o',
  5003. up: 'fa fa-chevron-up',
  5004. down: 'fa fa-chevron-down',
  5005. previous: 'fa fa-chevron-left',
  5006. next: 'fa fa-chevron-right',
  5007. today: 'fa fa-bullseye',
  5008. clear: 'fa fa-trash-o',
  5009. close: 'fa fa-remove'
  5010. }
  5011. };
  5012. }
  5013. }, {
  5014. key: "addItem",
  5015. value: function addItem(list) {
  5016. list = external_jQuery_default()(list);
  5017. this.items = this.items.add(list);
  5018. if (list.data('DateTimePicker')) {
  5019. return;
  5020. }
  5021. var options = Object.assign({}, this.options, list.data('grav-datetime') || {});
  5022. list.datetimepicker(options).on('dp.show dp.update', this._disableDecades);
  5023. list.siblings('.field-icons').on('click', function () {
  5024. return list.mousedown().focus();
  5025. });
  5026. }
  5027. }, {
  5028. key: "_onAddedNodes",
  5029. value: function _onAddedNodes(event, target
  5030. /* , record, instance */
  5031. ) {
  5032. var _this2 = this;
  5033. var fields = external_jQuery_default()(target).find('[data-grav-datetime]');
  5034. if (!fields.length) {
  5035. return;
  5036. }
  5037. fields.each(function (index, field) {
  5038. field = external_jQuery_default()(field);
  5039. if (!~_this2.items.index(field)) {
  5040. _this2.addItem(field);
  5041. }
  5042. });
  5043. }
  5044. }, {
  5045. key: "_disableDecades",
  5046. value: function _disableDecades() {
  5047. external_jQuery_default()('.datepicker-years .picker-switch').removeAttr('title').on('click', function (e) {
  5048. return e.stopPropagation();
  5049. });
  5050. }
  5051. }]);
  5052. return DateTimeField;
  5053. }();
  5054. var datetime_Instance = new DateTimeField();
  5055. // EXTERNAL MODULE: ./node_modules/mout/math/clamp.js
  5056. var clamp = __webpack_require__(19188);
  5057. var clamp_default = /*#__PURE__*/__webpack_require__.n(clamp);
  5058. // EXTERNAL MODULE: ./node_modules/mout/function/bind.js
  5059. var bind = __webpack_require__(84596);
  5060. var bind_default = /*#__PURE__*/__webpack_require__.n(bind);
  5061. ;// CONCATENATED MODULE: ./app/utils/colors.js
  5062. // Parses a string and returns a valid hex string when possible
  5063. // parseHex('#fff') => '#ffffff'
  5064. var parseHex = function parseHex(string) {
  5065. string = string.replace(/[^A-F0-9]/ig, '');
  5066. if (string.length !== 3 && string.length !== 6) return '';
  5067. if (string.length === 3) {
  5068. string = string[0] + string[0] + string[1] + string[1] + string[2] + string[2];
  5069. }
  5070. return '#' + string.toLowerCase();
  5071. }; // Converts an HSB object to an RGB object
  5072. // hsb2rgb({h: 0, s: 0, b: 100}) => {r: 255, g: 255, b: 255}
  5073. var hsb2rgb = function hsb2rgb(hsb) {
  5074. var rgb = {};
  5075. var h = Math.round(hsb.h);
  5076. var s = Math.round(hsb.s * 255 / 100);
  5077. var v = Math.round(hsb.b * 255 / 100);
  5078. if (s === 0) {
  5079. rgb.r = rgb.g = rgb.b = v;
  5080. } else {
  5081. var t1 = v;
  5082. var t2 = (255 - s) * v / 255;
  5083. var t3 = (t1 - t2) * (h % 60) / 60;
  5084. if (h === 360) h = 0;
  5085. if (h < 60) {
  5086. rgb.r = t1;
  5087. rgb.b = t2;
  5088. rgb.g = t2 + t3;
  5089. } else if (h < 120) {
  5090. rgb.g = t1;
  5091. rgb.b = t2;
  5092. rgb.r = t1 - t3;
  5093. } else if (h < 180) {
  5094. rgb.g = t1;
  5095. rgb.r = t2;
  5096. rgb.b = t2 + t3;
  5097. } else if (h < 240) {
  5098. rgb.b = t1;
  5099. rgb.r = t2;
  5100. rgb.g = t1 - t3;
  5101. } else if (h < 300) {
  5102. rgb.b = t1;
  5103. rgb.g = t2;
  5104. rgb.r = t2 + t3;
  5105. } else if (h < 360) {
  5106. rgb.r = t1;
  5107. rgb.g = t2;
  5108. rgb.b = t1 - t3;
  5109. } else {
  5110. rgb.r = 0;
  5111. rgb.g = 0;
  5112. rgb.b = 0;
  5113. }
  5114. }
  5115. return {
  5116. r: Math.round(rgb.r),
  5117. g: Math.round(rgb.g),
  5118. b: Math.round(rgb.b)
  5119. };
  5120. }; // Converts an RGB object to a HEX string
  5121. // rgb2hex({r: 255, g: 255, b: 255}) => #ffffff
  5122. var rgb2hex = function rgb2hex(rgb) {
  5123. var hex = [rgb.r.toString(16), rgb.g.toString(16), rgb.b.toString(16)];
  5124. hex.forEach(function (val, nr) {
  5125. if (val.length === 1) hex[nr] = '0' + val;
  5126. });
  5127. return '#' + hex.join('');
  5128. }; // Converts and RGB(a) string to a HEX string
  5129. // rgbstr2hex('rgba(255, 255, 255, 0.5)') => #ffffff
  5130. var rgbstr2hex = function rgbstr2hex(rgb) {
  5131. rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
  5132. return rgb && rgb.length === 4 ? '#' + ('0' + parseInt(rgb[1], 10).toString(16)).slice(-2) + ('0' + parseInt(rgb[2], 10).toString(16)).slice(-2) + ('0' + parseInt(rgb[3], 10).toString(16)).slice(-2) : '';
  5133. }; // Converts an HSB object to a HEX string
  5134. // hsb2hex({h: 0, s: 0, b: 100}) => #ffffff
  5135. var hsb2hex = function hsb2hex(hsb) {
  5136. return rgb2hex(hsb2rgb(hsb));
  5137. }; // Converts a HEX string to an HSB object
  5138. // hex2hsb('#ffffff') => {h: 0, s: 0, b: 100}
  5139. var hex2hsb = function hex2hsb(hex) {
  5140. var hsb = rgb2hsb(hex2rgb(hex));
  5141. if (hsb.s === 0) hsb.h = 360;
  5142. return hsb;
  5143. }; // Converts an RGB object to an HSB object
  5144. // rgb2hsb({r: 255, g: 255, b: 255}) => {h: 0, s: 0, b: 100}
  5145. var rgb2hsb = function rgb2hsb(rgb) {
  5146. var hsb = {
  5147. h: 0,
  5148. s: 0,
  5149. b: 0
  5150. };
  5151. var min = Math.min(rgb.r, rgb.g, rgb.b);
  5152. var max = Math.max(rgb.r, rgb.g, rgb.b);
  5153. var delta = max - min;
  5154. hsb.b = max;
  5155. hsb.s = max !== 0 ? 255 * delta / max : 0;
  5156. if (hsb.s !== 0) {
  5157. if (rgb.r === max) {
  5158. hsb.h = (rgb.g - rgb.b) / delta;
  5159. } else if (rgb.g === max) {
  5160. hsb.h = 2 + (rgb.b - rgb.r) / delta;
  5161. } else {
  5162. hsb.h = 4 + (rgb.r - rgb.g) / delta;
  5163. }
  5164. } else {
  5165. hsb.h = -1;
  5166. }
  5167. hsb.h *= 60;
  5168. if (hsb.h < 0) {
  5169. hsb.h += 360;
  5170. }
  5171. hsb.s *= 100 / 255;
  5172. hsb.b *= 100 / 255;
  5173. return hsb;
  5174. }; // Converts a HEX string to an RGB object
  5175. // hex2rgb('#ffffff') => {r: 255, g: 255, b: 255}
  5176. var hex2rgb = function hex2rgb(hex) {
  5177. hex = parseInt(hex.indexOf('#') > -1 ? hex.substring(1) : hex, 16);
  5178. return {
  5179. /* jshint ignore:start */
  5180. r: hex >> 16,
  5181. g: (hex & 0x00FF00) >> 8,
  5182. b: hex & 0x0000FF
  5183. /* jshint ignore:end */
  5184. };
  5185. };
  5186. ;// CONCATENATED MODULE: ./app/forms/fields/colorpicker.js
  5187. function colorpicker_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5188. function colorpicker_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); } }
  5189. function colorpicker_createClass(Constructor, protoProps, staticProps) { if (protoProps) colorpicker_defineProperties(Constructor.prototype, protoProps); if (staticProps) colorpicker_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  5190. var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  5191. var colorpicker_body = external_jQuery_default()('body');
  5192. var MOUSEDOWN = 'mousedown touchstart MSPointerDown pointerdown';
  5193. var MOUSEMOVE = 'mousemove touchmove MSPointerMove pointermove';
  5194. var MOUSEUP = 'mouseup touchend MSPointerUp pointerup';
  5195. var FOCUSIN = isFirefox ? 'focus' : 'focusin';
  5196. var ColorpickerField = /*#__PURE__*/function () {
  5197. function ColorpickerField(selector) {
  5198. var _this = this;
  5199. colorpicker_classCallCheck(this, ColorpickerField);
  5200. this.selector = selector;
  5201. this.field = external_jQuery_default()(this.selector);
  5202. this.options = Object.assign({}, this.field.data('grav-colorpicker'));
  5203. this.built = false;
  5204. this.attach();
  5205. if (this.options.update) {
  5206. this.field.on('change._grav_colorpicker', function (event, field, hex, opacity) {
  5207. var backgroundColor = hex;
  5208. var rgb = hex2rgb(hex);
  5209. if (opacity < 1) {
  5210. backgroundColor = 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + opacity + ')';
  5211. }
  5212. var target = field.closest(_this.options.update);
  5213. if (!target.length) {
  5214. target = field.siblings(_this.options.update);
  5215. }
  5216. if (!target.length) {
  5217. target = field.parent('.g-colorpicker').find(_this.options.update);
  5218. }
  5219. target.css({
  5220. backgroundColor: backgroundColor
  5221. });
  5222. });
  5223. }
  5224. }
  5225. colorpicker_createClass(ColorpickerField, [{
  5226. key: "attach",
  5227. value: function attach() {
  5228. var _this2 = this;
  5229. colorpicker_body.on(FOCUSIN, this.selector, function (event) {
  5230. return _this2.show(event, event.currentTarget);
  5231. });
  5232. colorpicker_body.on(MOUSEDOWN, this.selector + ' .g-colorpicker, ' + this.selector + ' .g-colorpicker i', this.bound('iconClick'));
  5233. colorpicker_body.on('keydown', this.selector, function (event) {
  5234. switch (event.keyCode) {
  5235. case 9:
  5236. // tab
  5237. _this2.hide();
  5238. break;
  5239. case 13: // enter
  5240. case 27:
  5241. // esc
  5242. _this2.hide();
  5243. event.currentTarget.blur();
  5244. break;
  5245. }
  5246. return true;
  5247. }); // Update on keyup
  5248. colorpicker_body.on('keyup', this.selector, function (event) {
  5249. _this2.updateFromInput(true, event.currentTarget);
  5250. return true;
  5251. }); // Update on paste
  5252. colorpicker_body.on('paste', this.selector, function (event) {
  5253. setTimeout(function () {
  5254. return _this2.updateFromInput(true, event.currentTarget);
  5255. }, 1);
  5256. });
  5257. }
  5258. }, {
  5259. key: "show",
  5260. value: function show(event, target) {
  5261. target = external_jQuery_default()(target);
  5262. if (!this.built) {
  5263. this.build();
  5264. }
  5265. this.element = target;
  5266. this.reposition();
  5267. this.wrapper.addClass('cp-visible');
  5268. this.updateFromInput();
  5269. this.wrapper.on(MOUSEDOWN, '.cp-grid, .cp-slider, .cp-opacity-slider', this.bound('bodyDown'));
  5270. colorpicker_body.on(MOUSEMOVE, this.bound('bodyMove'));
  5271. colorpicker_body.on(MOUSEDOWN, this.bound('bodyClick'));
  5272. colorpicker_body.on(MOUSEUP, this.bound('targetReset'));
  5273. external_jQuery_default()('#admin-main > .content-wrapper').on('scroll', this.bound('reposition'));
  5274. }
  5275. }, {
  5276. key: "hide",
  5277. value: function hide() {
  5278. if (!this.built) {
  5279. return;
  5280. }
  5281. this.wrapper.removeClass('cp-visible');
  5282. this.wrapper.undelegate(MOUSEDOWN, '.cp-grid, .cp-slider, .cp-opacity-slider', this.bound('bodyDown'));
  5283. colorpicker_body.off(MOUSEMOVE, this.bound('bodyMove'));
  5284. colorpicker_body.off(MOUSEDOWN, this.bound('bodyClick'));
  5285. colorpicker_body.off(MOUSEUP, this.bound('targetReset'));
  5286. external_jQuery_default()('#admin-main > .content-wrapper').on('scroll', this.bound('reposition'));
  5287. }
  5288. }, {
  5289. key: "build",
  5290. value: function build() {
  5291. var _this3 = this;
  5292. this.wrapper = external_jQuery_default()('<div class="cp-wrapper cp-with-opacity cp-mode-hue" />');
  5293. this.slider = external_jQuery_default()('<div class="cp-slider cp-sprite" />').appendTo(this.wrapper).append(external_jQuery_default()('<div class="cp-picker" />'));
  5294. this.opacitySlider = external_jQuery_default()('<div class="cp-opacity-slider cp-sprite" />').appendTo(this.wrapper).append(external_jQuery_default()('<div class="cp-picker" />'));
  5295. this.grid = external_jQuery_default()('<div class="cp-grid cp-sprite" />').appendTo(this.wrapper).append(external_jQuery_default()('<div class="cp-grid-inner" />')).append(external_jQuery_default()('<div class="cp-picker" />'));
  5296. external_jQuery_default()('<div />').appendTo(this.grid.find('.cp-picker'));
  5297. var tabs = external_jQuery_default()('<div class="cp-tabs" />').appendTo(this.wrapper);
  5298. this.tabs = {
  5299. hue: external_jQuery_default()('<div class="cp-tab-hue active" />').text('HUE').appendTo(tabs),
  5300. brightness: external_jQuery_default()('<div class="cp-tab-brightness" />').text('BRI').appendTo(tabs),
  5301. saturation: external_jQuery_default()('<div class="cp-tab-saturation" />').text('SAT').appendTo(tabs),
  5302. wheel: external_jQuery_default()('<div class="cp-tab-wheel" />').text('WHEEL').appendTo(tabs),
  5303. transparent: external_jQuery_default()('<div class="cp-tab-transp" />').text('TRANSPARENT').appendTo(tabs)
  5304. };
  5305. tabs.on(MOUSEDOWN, '> div', function (event) {
  5306. var element = external_jQuery_default()(event.currentTarget);
  5307. if (element.is(_this3.tabs.transparent)) {
  5308. var sliderHeight = _this3.opacitySlider.height();
  5309. _this3.opacity = 0;
  5310. _this3.opacitySlider.find('.cp-picker').css({
  5311. 'top': clamp_default()(sliderHeight - sliderHeight * _this3.opacity, 0, sliderHeight)
  5312. });
  5313. _this3.move(_this3.opacitySlider, {
  5314. manualOpacity: true
  5315. });
  5316. return;
  5317. }
  5318. var active = tabs.find('.active');
  5319. var mode = active.attr('class').replace(/\s|active|cp-tab-/g, '');
  5320. var newMode = element.attr('class').replace(/\s|active|cp-tab-/g, '');
  5321. _this3.wrapper.removeClass('cp-mode-' + mode).addClass('cp-mode-' + newMode);
  5322. active.removeClass('active');
  5323. element.addClass('active');
  5324. _this3.mode = newMode;
  5325. _this3.updateFromInput();
  5326. });
  5327. this.wrapper.appendTo('.content-wrapper');
  5328. this.built = true;
  5329. this.mode = 'hue';
  5330. }
  5331. }, {
  5332. key: "reposition",
  5333. value: function reposition() {
  5334. var ct = external_jQuery_default()('.content-wrapper')[0];
  5335. var offset = this.element[0].getBoundingClientRect();
  5336. var ctOffset = ct.getBoundingClientRect();
  5337. var delta = {
  5338. x: 0,
  5339. y: 0
  5340. };
  5341. if (this.options.offset) {
  5342. delta.x = this.options.offset.x || 0;
  5343. delta.y = this.options.offset.y || 0;
  5344. }
  5345. this.wrapper.css({
  5346. top: offset.top + offset.height + ct.scrollTop - ctOffset.top + delta.y,
  5347. left: offset.left + ct.scrollLeft - ctOffset.left + delta.x
  5348. });
  5349. }
  5350. }, {
  5351. key: "iconClick",
  5352. value: function iconClick(event) {
  5353. if (this.wrapper && this.wrapper.hasClass('cp-visible')) {
  5354. return true;
  5355. }
  5356. event && event.preventDefault();
  5357. var input = external_jQuery_default()(event.currentTarget).find('input');
  5358. setTimeout(function () {
  5359. return input.focus();
  5360. }, 50);
  5361. }
  5362. }, {
  5363. key: "bodyMove",
  5364. value: function bodyMove(event) {
  5365. event && event.preventDefault();
  5366. if (this.target) {
  5367. this.move(this.target, event);
  5368. }
  5369. }
  5370. }, {
  5371. key: "bodyClick",
  5372. value: function bodyClick(event) {
  5373. var target = external_jQuery_default()(event.target);
  5374. if (!target.closest('.cp-wrapper').length && !target.is(this.selector)) {
  5375. this.hide();
  5376. }
  5377. }
  5378. }, {
  5379. key: "bodyDown",
  5380. value: function bodyDown(event) {
  5381. event && event.preventDefault();
  5382. this.target = external_jQuery_default()(event.currentTarget);
  5383. this.move(this.target, event, true);
  5384. }
  5385. }, {
  5386. key: "targetReset",
  5387. value: function targetReset(event) {
  5388. event && event.preventDefault();
  5389. this.target = null;
  5390. }
  5391. }, {
  5392. key: "move",
  5393. value: function move(target, event) {
  5394. var input = this.element;
  5395. var picker = target.find('.cp-picker');
  5396. var clientRect = target[0].getBoundingClientRect();
  5397. var offsetX = clientRect.left + window.scrollX;
  5398. var offsetY = clientRect.top + window.scrollY;
  5399. var x = Math.round((event ? event.pageX : 0) - offsetX);
  5400. var y = Math.round((event ? event.pageY : 0) - offsetY);
  5401. var wx;
  5402. var wy;
  5403. var r;
  5404. var phi; // Touch support
  5405. var touchEvents = event.changedTouches || event.originalEvent && event.originalEvent.changedTouches;
  5406. if (event && touchEvents) {
  5407. x = (touchEvents ? touchEvents[0].pageX : 0) - offsetX;
  5408. y = (touchEvents ? touchEvents[0].pageY : 0) - offsetY;
  5409. }
  5410. if (event && event.manualOpacity) {
  5411. y = clientRect.height;
  5412. } // Constrain picker to its container
  5413. if (x < 0) x = 0;
  5414. if (y < 0) y = 0;
  5415. if (x > clientRect.width) x = clientRect.width;
  5416. if (y > clientRect.height) y = clientRect.height; // Constrain color wheel values to the wheel
  5417. if (target.parent('.cp-mode-wheel').length && picker.parent('.cp-grid').length) {
  5418. wx = 75 - x;
  5419. wy = 75 - y;
  5420. r = Math.sqrt(wx * wx + wy * wy);
  5421. phi = Math.atan2(wy, wx);
  5422. if (phi < 0) phi += Math.PI * 2;
  5423. if (r > 75) {
  5424. x = 75 - 75 * Math.cos(phi);
  5425. y = 75 - 75 * Math.sin(phi);
  5426. }
  5427. x = Math.round(x);
  5428. y = Math.round(y);
  5429. } // Move the picker
  5430. if (target.hasClass('cp-grid')) {
  5431. picker.css({
  5432. top: y,
  5433. left: x
  5434. });
  5435. this.updateFromPicker(input, target);
  5436. } else {
  5437. picker.css({
  5438. top: y
  5439. });
  5440. this.updateFromPicker(input, target);
  5441. }
  5442. }
  5443. }, {
  5444. key: "updateFromInput",
  5445. value: function updateFromInput(dontFireEvent, element) {
  5446. element = element ? external_jQuery_default()(element) : this.element;
  5447. var value = element.val();
  5448. var opacity = value.replace(/\s/g, '').match(/^rgba?\([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},(.+)\)/);
  5449. var hex;
  5450. var hsb;
  5451. value = rgbstr2hex(value) || value;
  5452. opacity = opacity ? clamp_default()(opacity[1], 0, 1) : 1;
  5453. if (!(hex = parseHex(value))) {
  5454. hex = '#ffffff';
  5455. }
  5456. hsb = hex2hsb(hex);
  5457. if (this.built) {
  5458. // opacity
  5459. this.opacity = opacity;
  5460. var sliderHeight = this.opacitySlider.height();
  5461. this.opacitySlider.find('.cp-picker').css({
  5462. 'top': clamp_default()(sliderHeight - sliderHeight * this.opacity, 0, sliderHeight)
  5463. }); // bg color
  5464. var gridHeight = this.grid.height();
  5465. var gridWidth = this.grid.width();
  5466. var r;
  5467. var phi;
  5468. var x;
  5469. var y;
  5470. sliderHeight = this.slider.height();
  5471. switch (this.mode) {
  5472. case 'wheel':
  5473. // Set grid position
  5474. r = clamp_default()(Math.ceil(hsb.s * 0.75), 0, gridHeight / 2);
  5475. phi = hsb.h * Math.PI / 180;
  5476. x = clamp_default()(75 - Math.cos(phi) * r, 0, gridWidth);
  5477. y = clamp_default()(75 - Math.sin(phi) * r, 0, gridHeight);
  5478. this.grid.css({
  5479. backgroundColor: 'transparent'
  5480. }).find('.cp-picker').css({
  5481. top: y,
  5482. left: x
  5483. }); // Set slider position
  5484. y = 150 - hsb.b / (100 / gridHeight);
  5485. if (hex === '') y = 0;
  5486. this.slider.find('.cp-picker').css({
  5487. top: y
  5488. }); // Update panel color
  5489. this.slider.css({
  5490. backgroundColor: hsb2hex({
  5491. h: hsb.h,
  5492. s: hsb.s,
  5493. b: 100
  5494. })
  5495. });
  5496. break;
  5497. case 'saturation':
  5498. // Set grid position
  5499. x = clamp_default()(5 * hsb.h / 12, 0, 150);
  5500. y = clamp_default()(gridHeight - Math.ceil(hsb.b / (100 / gridHeight)), 0, gridHeight);
  5501. this.grid.find('.cp-picker').css({
  5502. top: y,
  5503. left: x
  5504. }); // Set slider position
  5505. y = clamp_default()(sliderHeight - hsb.s * (sliderHeight / 100), 0, sliderHeight);
  5506. this.slider.find('.cp-picker').css({
  5507. top: y
  5508. }); // Update UI
  5509. this.slider.css({
  5510. backgroundColor: hsb2hex({
  5511. h: hsb.h,
  5512. s: 100,
  5513. b: hsb.b
  5514. })
  5515. });
  5516. this.grid.find('.cp-grid-inner').css({
  5517. opacity: hsb.s / 100
  5518. });
  5519. break;
  5520. case 'brightness':
  5521. // Set grid position
  5522. x = clamp_default()(5 * hsb.h / 12, 0, 150);
  5523. y = clamp_default()(gridHeight - Math.ceil(hsb.s / (100 / gridHeight)), 0, gridHeight);
  5524. this.grid.find('.cp-picker').css({
  5525. top: y,
  5526. left: x
  5527. }); // Set slider position
  5528. y = clamp_default()(sliderHeight - hsb.b * (sliderHeight / 100), 0, sliderHeight);
  5529. this.slider.find('.cp-picker').css({
  5530. top: y
  5531. }); // Update UI
  5532. this.slider.css({
  5533. backgroundColor: hsb2hex({
  5534. h: hsb.h,
  5535. s: hsb.s,
  5536. b: 100
  5537. })
  5538. });
  5539. this.grid.find('.cp-grid-inner').css({
  5540. opacity: 1 - hsb.b / 100
  5541. });
  5542. break;
  5543. case 'hue':
  5544. default:
  5545. // Set grid position
  5546. x = clamp_default()(Math.ceil(hsb.s / (100 / gridWidth)), 0, gridWidth);
  5547. y = clamp_default()(gridHeight - Math.ceil(hsb.b / (100 / gridHeight)), 0, gridHeight);
  5548. this.grid.find('.cp-picker').css({
  5549. top: y,
  5550. left: x
  5551. }); // Set slider position
  5552. y = clamp_default()(sliderHeight - hsb.h / (360 / sliderHeight), 0, sliderHeight);
  5553. this.slider.find('.cp-picker').css({
  5554. top: y
  5555. }); // Update panel color
  5556. this.grid.css({
  5557. backgroundColor: hsb2hex({
  5558. h: hsb.h,
  5559. s: 100,
  5560. b: 100
  5561. })
  5562. });
  5563. break;
  5564. }
  5565. }
  5566. if (!dontFireEvent) {
  5567. element.val(this.getValue(hex));
  5568. }
  5569. (this.element || element).trigger('change._grav_colorpicker', [element, hex, opacity]);
  5570. }
  5571. }, {
  5572. key: "updateFromPicker",
  5573. value: function updateFromPicker(input, target) {
  5574. var getCoords = function getCoords(picker, container) {
  5575. var left, top;
  5576. if (!picker.length || !container) return null;
  5577. left = picker[0].getBoundingClientRect().left;
  5578. top = picker[0].getBoundingClientRect().top;
  5579. return {
  5580. x: left - container[0].getBoundingClientRect().left + picker[0].offsetWidth / 2,
  5581. y: top - container[0].getBoundingClientRect().top + picker[0].offsetHeight / 2
  5582. };
  5583. };
  5584. var hex;
  5585. var hue;
  5586. var saturation;
  5587. var brightness;
  5588. var x;
  5589. var y;
  5590. var r;
  5591. var phi; // Panel objects
  5592. var grid = this.wrapper.find('.cp-grid');
  5593. var slider = this.wrapper.find('.cp-slider');
  5594. var opacitySlider = this.wrapper.find('.cp-opacity-slider'); // Picker objects
  5595. var gridPicker = grid.find('.cp-picker');
  5596. var sliderPicker = slider.find('.cp-picker');
  5597. var opacityPicker = opacitySlider.find('.cp-picker'); // Picker positions
  5598. var gridPos = getCoords(gridPicker, grid);
  5599. var sliderPos = getCoords(sliderPicker, slider);
  5600. var opacityPos = getCoords(opacityPicker, opacitySlider); // Sizes
  5601. var gridWidth = grid[0].getBoundingClientRect().width;
  5602. var gridHeight = grid[0].getBoundingClientRect().height;
  5603. var sliderHeight = slider[0].getBoundingClientRect().height;
  5604. var opacitySliderHeight = opacitySlider[0].getBoundingClientRect().height;
  5605. var value = this.element.val();
  5606. value = rgbstr2hex(value) || value;
  5607. if (!(hex = parseHex(value))) {
  5608. hex = '#ffffff';
  5609. } // Handle colors
  5610. if (target.hasClass('cp-grid') || target.hasClass('cp-slider')) {
  5611. // Determine HSB values
  5612. switch (this.mode) {
  5613. case 'wheel':
  5614. // Calculate hue, saturation, and brightness
  5615. x = gridWidth / 2 - gridPos.x;
  5616. y = gridHeight / 2 - gridPos.y;
  5617. r = Math.sqrt(x * x + y * y);
  5618. phi = Math.atan2(y, x);
  5619. if (phi < 0) phi += Math.PI * 2;
  5620. if (r > 75) {
  5621. r = 75;
  5622. gridPos.x = 69 - 75 * Math.cos(phi);
  5623. gridPos.y = 69 - 75 * Math.sin(phi);
  5624. }
  5625. saturation = clamp_default()(r / 0.75, 0, 100);
  5626. hue = clamp_default()(phi * 180 / Math.PI, 0, 360);
  5627. brightness = clamp_default()(100 - Math.floor(sliderPos.y * (100 / sliderHeight)), 0, 100);
  5628. hex = hsb2hex({
  5629. h: hue,
  5630. s: saturation,
  5631. b: brightness
  5632. }); // Update UI
  5633. slider.css({
  5634. backgroundColor: hsb2hex({
  5635. h: hue,
  5636. s: saturation,
  5637. b: 100
  5638. })
  5639. });
  5640. break;
  5641. case 'saturation':
  5642. // Calculate hue, saturation, and brightness
  5643. hue = clamp_default()(parseInt(gridPos.x * (360 / gridWidth), 10), 0, 360);
  5644. saturation = clamp_default()(100 - Math.floor(sliderPos.y * (100 / sliderHeight)), 0, 100);
  5645. brightness = clamp_default()(100 - Math.floor(gridPos.y * (100 / gridHeight)), 0, 100);
  5646. hex = hsb2hex({
  5647. h: hue,
  5648. s: saturation,
  5649. b: brightness
  5650. }); // Update UI
  5651. slider.css({
  5652. backgroundColor: hsb2hex({
  5653. h: hue,
  5654. s: 100,
  5655. b: brightness
  5656. })
  5657. });
  5658. grid.find('.cp-grid-inner').css({
  5659. opacity: saturation / 100
  5660. });
  5661. break;
  5662. case 'brightness':
  5663. // Calculate hue, saturation, and brightness
  5664. hue = clamp_default()(parseInt(gridPos.x * (360 / gridWidth), 10), 0, 360);
  5665. saturation = clamp_default()(100 - Math.floor(gridPos.y * (100 / gridHeight)), 0, 100);
  5666. brightness = clamp_default()(100 - Math.floor(sliderPos.y * (100 / sliderHeight)), 0, 100);
  5667. hex = hsb2hex({
  5668. h: hue,
  5669. s: saturation,
  5670. b: brightness
  5671. }); // Update UI
  5672. slider.css({
  5673. backgroundColor: hsb2hex({
  5674. h: hue,
  5675. s: saturation,
  5676. b: 100
  5677. })
  5678. });
  5679. grid.find('.cp-grid-inner').css({
  5680. opacity: 1 - brightness / 100
  5681. });
  5682. break;
  5683. default:
  5684. // Calculate hue, saturation, and brightness
  5685. hue = clamp_default()(360 - parseInt(sliderPos.y * (360 / sliderHeight), 10), 0, 360);
  5686. saturation = clamp_default()(Math.floor(gridPos.x * (100 / gridWidth)), 0, 100);
  5687. brightness = clamp_default()(100 - Math.floor(gridPos.y * (100 / gridHeight)), 0, 100);
  5688. hex = hsb2hex({
  5689. h: hue,
  5690. s: saturation,
  5691. b: brightness
  5692. }); // Update UI
  5693. grid.css({
  5694. backgroundColor: hsb2hex({
  5695. h: hue,
  5696. s: 100,
  5697. b: 100
  5698. })
  5699. });
  5700. break;
  5701. }
  5702. } // Handle opacity
  5703. if (target.hasClass('cp-opacity-slider')) {
  5704. this.opacity = parseFloat(1 - opacityPos.y / opacitySliderHeight).toFixed(2);
  5705. } // Adjust case
  5706. input.val(this.getValue(hex)); // Handle change event
  5707. this.element.trigger('change._grav_colorpicker', [this.element, hex, this.opacity]);
  5708. }
  5709. }, {
  5710. key: "getValue",
  5711. value: function getValue(hex) {
  5712. if (this.opacity === 1) {
  5713. return hex;
  5714. }
  5715. var rgb = hex2rgb(hex);
  5716. return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + this.opacity + ')';
  5717. }
  5718. }, {
  5719. key: "bound",
  5720. value: function bound(name) {
  5721. var bound = this._bound || (this._bound = {});
  5722. return bound[name] || (bound[name] = bind_default()(this[name], this));
  5723. }
  5724. }]);
  5725. return ColorpickerField;
  5726. }();
  5727. var colorpicker_Instance = new ColorpickerField('[data-grav-colorpicker]');
  5728. ;// CONCATENATED MODULE: ./app/forms/fields/folder.js
  5729. var Regenerate = function Regenerate() {
  5730. var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '[name="data[folder]"]';
  5731. var element = external_jQuery_default()(field);
  5732. var title = external_jQuery_default()('[name="data[header][title]"]');
  5733. var slug = external_jQuery_default().slugify(title.val(), {
  5734. custom: {
  5735. "'": ''
  5736. }
  5737. });
  5738. element.addClass('highlight').val(slug);
  5739. setTimeout(function () {
  5740. return element.removeClass('highlight');
  5741. }, 500);
  5742. };
  5743. external_jQuery_default()(document).on('click', '[data-regenerate]', function (event) {
  5744. var target = external_jQuery_default()(event.currentTarget);
  5745. var field = external_jQuery_default()(target.data('regenerate'));
  5746. Regenerate(field);
  5747. });
  5748. /* harmony default export */ const fields_folder = (Regenerate);
  5749. // EXTERNAL MODULE: ./node_modules/mout/object/forIn.js
  5750. var forIn = __webpack_require__(15473);
  5751. var forIn_default = /*#__PURE__*/__webpack_require__.n(forIn);
  5752. ;// CONCATENATED MODULE: ./app/forms/fields/selectunique.js
  5753. function selectunique_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5754. function selectunique_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); } }
  5755. function selectunique_createClass(Constructor, protoProps, staticProps) { if (protoProps) selectunique_defineProperties(Constructor.prototype, protoProps); if (staticProps) selectunique_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  5756. // import { config } from 'grav-config';
  5757. var Data = {};
  5758. var SelectUniqueField = /*#__PURE__*/function () {
  5759. function SelectUniqueField(options) {
  5760. var _this = this;
  5761. selectunique_classCallCheck(this, SelectUniqueField);
  5762. var body = external_jQuery_default()('body');
  5763. this.items = external_jQuery_default()();
  5764. this.options = Object.assign({}, this.defaults, options);
  5765. external_jQuery_default()('[data-select-observe]').each(function (index, element) {
  5766. return _this.addSelect(element);
  5767. }).last().trigger('change', {
  5768. load: true
  5769. });
  5770. body.on('mutation._grav', this._onAddedNodes.bind(this));
  5771. body.on('mutation_removed._grav', this._onRemovedNodes.bind(this));
  5772. }
  5773. selectunique_createClass(SelectUniqueField, [{
  5774. key: "_onAddedNodes",
  5775. value: function _onAddedNodes(event, target, record, instance) {
  5776. var _this2 = this;
  5777. var fields = external_jQuery_default()(target).find('[data-select-observe]');
  5778. if (!fields.length) {
  5779. return;
  5780. }
  5781. fields.each(function (index, field) {
  5782. field = external_jQuery_default()(field);
  5783. if (!~_this2.items.index(field)) {
  5784. _this2.addSelect(field);
  5785. }
  5786. });
  5787. }
  5788. }, {
  5789. key: "_onRemovedNodes",
  5790. value: function _onRemovedNodes(event, data
  5791. /* , instance */
  5792. ) {
  5793. var _this3 = this;
  5794. var target = external_jQuery_default()(data.target);
  5795. var holder = target.data('collectionHolder');
  5796. if (!holder) {
  5797. return false;
  5798. }
  5799. var node = external_jQuery_default()(data.mutation.removedNodes);
  5800. var value = node.find('[data-select-observe]').val();
  5801. if (value) {
  5802. Data[holder].state[value] = value;
  5803. }
  5804. target.find('[data-select-observe]').each(function (index, field) {
  5805. field = external_jQuery_default()(field);
  5806. if (field.val() !== value) {
  5807. _this3.updateOptions(field);
  5808. }
  5809. });
  5810. }
  5811. }, {
  5812. key: "addSelect",
  5813. value: function addSelect(element) {
  5814. var _this4 = this;
  5815. this.items = this.items.add(element);
  5816. element = external_jQuery_default()(element);
  5817. var value = element.attr('value');
  5818. var holder = element.closest('[data-collection-holder]').data('collectionHolder');
  5819. var options = element.closest('[data-select-unique]').data('selectUnique');
  5820. if (!Data[holder]) {
  5821. var data = {};
  5822. if (Array.isArray(options)) {
  5823. options.slice(0).map(function (item) {
  5824. data[item] = item;
  5825. });
  5826. } else {
  5827. data = Object.assign({}, options);
  5828. }
  5829. Data[holder] = {
  5830. original: null,
  5831. state: null
  5832. };
  5833. Data[holder].original = Object.assign({}, data);
  5834. Data[holder].state = Object.assign({}, data);
  5835. }
  5836. this.updateOptions(element);
  5837. element.data('originalValue', value);
  5838. element.on('change', function (event, extras) {
  5839. var target = external_jQuery_default()(event.currentTarget);
  5840. if (target.data('dummyChange')) {
  5841. target.data('dummyChange', false);
  5842. return false;
  5843. }
  5844. _this4.refreshOptions(target, extras && extras.load ? null : element.data('originalValue'));
  5845. element.data('originalValue', target.val());
  5846. });
  5847. }
  5848. }, {
  5849. key: "updateOptions",
  5850. value: function updateOptions(element) {
  5851. element = external_jQuery_default()(element);
  5852. var value = element.attr('value');
  5853. var holder = element.closest('[data-collection-holder]').data('collectionHolder');
  5854. forIn_default()(Data[holder].state, function (v, k) {
  5855. var selected = k === value ? 'selected="selected"' : '';
  5856. if (element.get(0).selectize) {
  5857. var selectize = element.data('selectize');
  5858. selectize.removeOption(k);
  5859. selectize.addOption({
  5860. value: k,
  5861. text: v
  5862. });
  5863. } else {
  5864. element.append("<option value=\"".concat(k, "\" ").concat(selected, ">").concat(v, "</option>"));
  5865. }
  5866. if (selected) {
  5867. if (element.get(0).selectize) {
  5868. var _selectize = element.data('selectize');
  5869. _selectize.setValue(k);
  5870. }
  5871. delete Data[holder].state[value];
  5872. }
  5873. });
  5874. }
  5875. }, {
  5876. key: "refreshOptions",
  5877. value: function refreshOptions(element, originalValue) {
  5878. var value = element.val();
  5879. var holder = element.closest('[data-collection-holder]').data('collectionHolder');
  5880. delete Data[holder].state[value];
  5881. if (originalValue && Data[holder].original[originalValue]) {
  5882. Data[holder].state[originalValue] = Data[holder].original[originalValue];
  5883. }
  5884. this.items.each(function (index, select) {
  5885. select = external_jQuery_default()(select);
  5886. if (select[0] === element[0]) {
  5887. return;
  5888. }
  5889. var selectedValue = select.val();
  5890. select.data('dummyChange', true);
  5891. if (select.get(0).selectize) {
  5892. var selectize = select.data('selectize');
  5893. if (selectize) {
  5894. selectize.clearOptions();
  5895. if (selectedValue) {
  5896. selectize.addOption({
  5897. value: selectedValue,
  5898. text: Data[holder].original[selectedValue] || selectedValue
  5899. });
  5900. }
  5901. forIn_default()(Data[holder].state, function (v, k) {
  5902. selectize.addOption({
  5903. value: k,
  5904. text: v
  5905. });
  5906. });
  5907. selectize.setValue(selectedValue, true);
  5908. }
  5909. } else {
  5910. select.empty();
  5911. forIn_default()(Data[holder].state, function (v, k) {
  5912. var selected = k === selectedValue ? 'selected="selected"' : '';
  5913. select.append("<option value=\"".concat(k, "\" ").concat(selected, ">").concat(v, "</option>"));
  5914. });
  5915. }
  5916. select.data('dummyChange', false);
  5917. });
  5918. }
  5919. }]);
  5920. return SelectUniqueField;
  5921. }();
  5922. var selectunique_Instance = new SelectUniqueField();
  5923. ;// CONCATENATED MODULE: ./app/forms/fields/iconpicker.js
  5924. function iconpicker_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5925. function iconpicker_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); } }
  5926. function iconpicker_createClass(Constructor, protoProps, staticProps) { if (protoProps) iconpicker_defineProperties(Constructor.prototype, protoProps); if (staticProps) iconpicker_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  5927. /* Icon Picker by QueryLoop
  5928. * Author: @eliorivero
  5929. * URL: http://queryloop.com/
  5930. * License: GPLv2
  5931. */
  5932. var iconpicker_defaults = {
  5933. 'mode': 'dialog',
  5934. // show overlay 'dialog' panel or slide down 'inline' panel
  5935. 'closeOnPick': true,
  5936. // whether to close panel after picking or 'no'
  5937. 'save': 'class',
  5938. // save icon 'class' or 'code'
  5939. 'size': '',
  5940. 'classes': {
  5941. 'launcher': '',
  5942. // extra classes for launcher buttons
  5943. 'clear': 'remove-times',
  5944. // extra classes for button that removes preview and clears field
  5945. 'highlight': '',
  5946. // extra classes when highlighting an icon
  5947. 'close': '' // extra classes for close button
  5948. },
  5949. 'iconSets': {
  5950. // example data structure. Used to specify which launchers will be created
  5951. 'genericon': 'Genericon',
  5952. // create a launcher to pick genericon icons
  5953. 'fa': 'FontAwesome' // create a launcher to pick fontawesome icons
  5954. }
  5955. };
  5956. var QL_Icon_Picker = /*#__PURE__*/function () {
  5957. function QL_Icon_Picker(element, options) {
  5958. iconpicker_classCallCheck(this, QL_Icon_Picker);
  5959. this.iconSet = '';
  5960. this.iconSetName = '';
  5961. this.$field = '';
  5962. this.element = element;
  5963. this.settings = external_jQuery_default().extend({}, iconpicker_defaults, options);
  5964. this._defaults = iconpicker_defaults;
  5965. this.init();
  5966. }
  5967. iconpicker_createClass(QL_Icon_Picker, [{
  5968. key: "init",
  5969. value: function init() {
  5970. var $brick = external_jQuery_default()(this.element);
  5971. var pickerId = $brick.data('pickerid');
  5972. var $preview = external_jQuery_default()('<div class="icon-preview icon-preview-' + pickerId + '" />');
  5973. this.$field = $brick.find('input'); // Add preview area
  5974. this.makePreview($brick, pickerId, $preview); // Make button to clear field and remove preview
  5975. this.makeClear(pickerId, $preview); // Make buttons that open the panel of icons
  5976. this.makeLaunchers($brick, pickerId); // Prepare display styles, inline and dialog
  5977. this.makeDisplay($brick);
  5978. }
  5979. }, {
  5980. key: "makePreview",
  5981. value: function makePreview($brick, pickerId, $preview) {
  5982. var $icon = external_jQuery_default()('<i />');
  5983. var iconValue = this.$field.val();
  5984. $preview.prependTo($brick);
  5985. $icon.prependTo($preview);
  5986. if (iconValue !== '') {
  5987. $preview.addClass('icon-preview-on');
  5988. $icon.addClass(iconValue);
  5989. }
  5990. }
  5991. }, {
  5992. key: "makeClear",
  5993. value: function makeClear(pickerId, $preview) {
  5994. var base = this;
  5995. var $clear = external_jQuery_default()('<a class="remove-icon ' + base.settings.classes.clear + '" />'); // Hide button to remove icon and preview and append it to preview area
  5996. $clear.hide().prependTo($preview); // If there's a icon saved in the field, show remove icon button
  5997. if (base.$field.val() !== '') {
  5998. $clear.show();
  5999. }
  6000. $preview.on('click', '.remove-icon', function (e) {
  6001. e.preventDefault();
  6002. base.$field.val('');
  6003. $preview.removeClass('icon-preview-on').find('i').removeClass();
  6004. external_jQuery_default()(this).hide();
  6005. });
  6006. }
  6007. }, {
  6008. key: "makeDisplay",
  6009. value: function makeDisplay($brick) {
  6010. var base = this;
  6011. var close = base.settings.classes.close;
  6012. var $body = external_jQuery_default()('body');
  6013. var $close = external_jQuery_default()('<a href="#" class="icon-picker-close"/>');
  6014. if (base.settings.mode === 'inline') {
  6015. $brick.find('.icon-set').append($close).removeClass('dialog').addClass('ip-inline ' + base.settings.size).parent().addClass('icon-set-wrap');
  6016. } else if (base.settings.mode === 'dialog') {
  6017. external_jQuery_default()('.icon-set').addClass('dialog ' + base.settings.size);
  6018. if (external_jQuery_default()('.icon-picker-overlay').length <= 0) {
  6019. $body.append('<div class="icon-picker-overlay"/>').append($close);
  6020. }
  6021. }
  6022. $body.on('click', '.icon-picker-close, .icon-picker-overlay', function (e) {
  6023. e.preventDefault();
  6024. base.closePicker($brick, external_jQuery_default()(base.iconSet), base.settings.mode);
  6025. }).on('mouseenter mouseleave', '.icon-picker-close', function (e) {
  6026. if (e.type === 'mouseenter') {
  6027. external_jQuery_default()(this).addClass(close);
  6028. } else {
  6029. external_jQuery_default()(this).removeClass(close);
  6030. }
  6031. });
  6032. }
  6033. }, {
  6034. key: "makeLaunchers",
  6035. value: function makeLaunchers($brick) {
  6036. var base = this;
  6037. var dataIconSets = $brick.data('iconsets');
  6038. var iconSet;
  6039. if (typeof dataIconSets === 'undefined') {
  6040. dataIconSets = base.settings.iconSets;
  6041. }
  6042. for (iconSet in dataIconSets) {
  6043. if (dataIconSets.hasOwnProperty(iconSet)) {
  6044. $brick.append('<a class="launch-icons button ' + base.settings.classes.launcher + '" data-icons="' + iconSet + '">' + dataIconSets[iconSet] + '</a>');
  6045. }
  6046. }
  6047. $brick.find('.launch-icons').on('click', function (e) {
  6048. e.preventDefault();
  6049. var $self = external_jQuery_default()(this);
  6050. var theseIcons = $self.data('icons');
  6051. base.iconSetName = theseIcons;
  6052. base.iconSet = '.' + theseIcons + '-set'; // Initialize picker
  6053. base.iconPick($brick); // Show icon picker
  6054. base.showPicker($brick, external_jQuery_default()(base.iconSet), base.settings.mode);
  6055. });
  6056. }
  6057. }, {
  6058. key: "iconPick",
  6059. value: function iconPick($brick) {
  6060. var base = this;
  6061. var highlight = 'icon-highlight ' + base.settings.classes.highlight;
  6062. external_jQuery_default()(base.iconSet).on('click', 'li', function (e) {
  6063. e.preventDefault();
  6064. var $icon = external_jQuery_default()(this);
  6065. var icon = $icon.data(base.settings.save); // Mark as selected
  6066. external_jQuery_default()('.icon-selected').removeClass('icon-selected');
  6067. $icon.addClass('icon-selected');
  6068. if (base.$field.data('format') === 'short') {
  6069. icon = icon.slice(6);
  6070. } // Save icon value to field
  6071. base.$field.val(icon); // Close icon picker
  6072. if (base.settings.closeOnPick) {
  6073. base.closePicker($brick, $icon.closest(base.iconSet), base.settings.mode);
  6074. } // Set preview
  6075. base.setPreview($icon.data('class')); // Broadcast event passing the selected icon.
  6076. external_jQuery_default()('body').trigger('iconselected.queryloop', icon);
  6077. });
  6078. external_jQuery_default()(base.iconSet).on('mouseenter mouseleave', 'li', function (e) {
  6079. if (e.type === 'mouseenter') {
  6080. external_jQuery_default()(this).addClass(highlight);
  6081. } else {
  6082. external_jQuery_default()(this).removeClass(highlight);
  6083. }
  6084. });
  6085. }
  6086. }, {
  6087. key: "showPicker",
  6088. value: function showPicker($brick, $icons, mode) {
  6089. if (mode === 'inline') {
  6090. external_jQuery_default()('.icon-set').removeClass('ip-inline-open');
  6091. $brick.find($icons).toggleClass('ip-inline-open');
  6092. } else if (mode === 'dialog') {
  6093. $brick.find('.icon-picker-close').addClass('make-visible');
  6094. $brick.find('.icon-picker-overlay').addClass('make-visible');
  6095. $icons.addClass('dialog-open');
  6096. }
  6097. $icons.find('.icon-selected').removeClass('icon-selected');
  6098. var selectedIcon = this.$field.val().replace(' ', '.');
  6099. if (selectedIcon !== '') {
  6100. if (this.settings.save === 'class') {
  6101. $icons.find('.' + selectedIcon).addClass('icon-selected');
  6102. } else {
  6103. $icons.find('[data-code="' + selectedIcon + '"]').addClass('icon-selected');
  6104. }
  6105. } // Broadcast event when the picker is shown passing the picker mode.
  6106. external_jQuery_default()('body').trigger('iconpickershow.queryloop', mode);
  6107. }
  6108. }, {
  6109. key: "closePicker",
  6110. value: function closePicker($brick, $icons, mode) {
  6111. // Remove event so they don't fire from a different picker
  6112. external_jQuery_default()(this.iconSet).off('click', 'li');
  6113. if (mode === 'inline') {
  6114. $brick.find($icons).removeClass('ip-inline-open');
  6115. } else if (mode === 'dialog') {
  6116. external_jQuery_default()('.icon-picker-close, .icon-picker-overlay').removeClass('make-visible');
  6117. } // Broadcast event when the picker is closed passing the picker mode.
  6118. external_jQuery_default()('body').trigger('iconpickerclose.queryloop', mode);
  6119. external_jQuery_default()('.icon-set').removeClass('dialog-open');
  6120. }
  6121. }, {
  6122. key: "setPreview",
  6123. value: function setPreview(preview) {
  6124. var $preview = external_jQuery_default()(this.element).find('.icon-preview');
  6125. $preview.addClass('icon-preview-on').find('i').removeClass().addClass(this.iconSetName).addClass(preview);
  6126. $preview.find('a').show();
  6127. }
  6128. }]);
  6129. return QL_Icon_Picker;
  6130. }();
  6131. /* Grav */
  6132. // extend $ with 3rd party QL Icon Picker
  6133. (external_jQuery_default()).fn.qlIconPicker = function (options) {
  6134. this.each(function () {
  6135. if (!external_jQuery_default().data(this, 'plugin_qlIconPicker')) {
  6136. external_jQuery_default().data(this, 'plugin_qlIconPicker', new QL_Icon_Picker(this, options));
  6137. }
  6138. });
  6139. return this;
  6140. };
  6141. var IconpickerField = /*#__PURE__*/function () {
  6142. function IconpickerField(options) {
  6143. var _this = this;
  6144. iconpicker_classCallCheck(this, IconpickerField);
  6145. this.items = external_jQuery_default()();
  6146. this.options = Object.assign({}, this.defaults, options);
  6147. external_jQuery_default()('[data-grav-iconpicker]').each(function (index, element) {
  6148. return _this.addItem(element);
  6149. });
  6150. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  6151. }
  6152. iconpicker_createClass(IconpickerField, [{
  6153. key: "_onAddedNodes",
  6154. value: function _onAddedNodes(event, target
  6155. /* , record, instance */
  6156. ) {
  6157. var _this2 = this;
  6158. var fields = external_jQuery_default()(target).find('[data-grav-iconpicker]');
  6159. if (!fields.length) {
  6160. return;
  6161. }
  6162. fields.each(function (index, field) {
  6163. field = external_jQuery_default()(field);
  6164. if (!~_this2.items.index(field)) {
  6165. _this2.addItem(field);
  6166. }
  6167. });
  6168. }
  6169. }, {
  6170. key: "addItem",
  6171. value: function addItem(element) {
  6172. element = external_jQuery_default()(element);
  6173. this.items = this.items.add(element);
  6174. element.find('.icon-picker').qlIconPicker({
  6175. 'save': 'class'
  6176. }); // hack to remove extra icon sets that are just copies
  6177. external_jQuery_default()('.icon-set:not(:first)').remove();
  6178. }
  6179. }]);
  6180. return IconpickerField;
  6181. }();
  6182. var iconpicker_Instance = new IconpickerField(); // Fix to close the dialog when clicking outside
  6183. external_jQuery_default()(document).on('click', function (event) {
  6184. var target = external_jQuery_default()(event.target);
  6185. var match = '.icon-set.dialog-open, .launch-icons[data-icons]';
  6186. if (!target.is(match) && !target.closest(match).length) {
  6187. var dialogs = external_jQuery_default()('.icon-set.dialog-open'); // skip if there's no dialog open
  6188. if (dialogs.length) {
  6189. dialogs.each(function (index, dialog) {
  6190. var picker = external_jQuery_default()(dialog).siblings('.icon-picker');
  6191. var data = picker.data('plugin_qlIconPicker');
  6192. data.closePicker(picker, external_jQuery_default()(data.iconSet), data.settings.mode);
  6193. });
  6194. }
  6195. }
  6196. });
  6197. ;// CONCATENATED MODULE: ./app/utils/cron-ui.js
  6198. function cron_ui_typeof(obj) { "@babel/helpers - typeof"; return cron_ui_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, cron_ui_typeof(obj); }
  6199. /* eslint-disable */
  6200. /*
  6201. * This file is part of the Arnapou jqCron package.
  6202. *
  6203. * (c) Arnaud Buathier <arnaud@arnapou.net>
  6204. *
  6205. * For the full copyright and license information, please view the LICENSE
  6206. * file that was distributed with this source code.
  6207. */
  6208. /**
  6209. * Default settings
  6210. */
  6211. var jqCronDefaultSettings = {
  6212. texts: {},
  6213. monthdays: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],
  6214. hours: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
  6215. hour_labels: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"],
  6216. minutes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59],
  6217. lang: 'en',
  6218. enabled_minute: false,
  6219. enabled_hour: true,
  6220. enabled_day: true,
  6221. enabled_week: true,
  6222. enabled_month: true,
  6223. enabled_year: true,
  6224. multiple_dom: false,
  6225. multiple_month: false,
  6226. multiple_mins: false,
  6227. multiple_dow: false,
  6228. multiple_time_hours: false,
  6229. multiple_time_minutes: false,
  6230. numeric_zero_pad: false,
  6231. default_period: 'day',
  6232. default_value: '',
  6233. no_reset_button: true,
  6234. disabled: false,
  6235. bind_to: null,
  6236. bind_method: {
  6237. set: function set($element, value) {
  6238. $element.is(':input') ? $element.val(value) : $element.data('jqCronValue', value);
  6239. },
  6240. get: function get($element) {
  6241. return $element.is(':input') ? $element.val() : $element.data('jqCronValue');
  6242. }
  6243. }
  6244. };
  6245. /**
  6246. * Custom extend of json for jqCron settings.
  6247. * We don't use jQuery.extend because simple extend does not fit our needs, and deep extend has a bad
  6248. * feature for us : it replaces keys of "Arrays" instead of replacing the full array.
  6249. */
  6250. (function ($) {
  6251. var extend = function extend(dst, src) {
  6252. for (var i in src) {
  6253. if ($.isPlainObject(src[i])) {
  6254. dst[i] = extend(dst[i] && $.isPlainObject(dst[i]) ? dst[i] : {}, src[i]);
  6255. } else if ($.isArray(src[i])) {
  6256. dst[i] = src[i].slice(0);
  6257. } else if (src[i] !== undefined) {
  6258. dst[i] = src[i];
  6259. }
  6260. }
  6261. return dst;
  6262. };
  6263. this.jqCronMergeSettings = function (obj) {
  6264. return extend(extend({}, jqCronDefaultSettings), obj || {});
  6265. };
  6266. }).call(window, (external_jQuery_default()));
  6267. /**
  6268. * Shortcut to get the instance of jqCron instance from one jquery object
  6269. */
  6270. (function ($) {
  6271. $.fn.jqCronGetInstance = function () {
  6272. return this.data('jqCron');
  6273. };
  6274. }).call(window, (external_jQuery_default()));
  6275. /**
  6276. * Main plugin
  6277. */
  6278. (function ($) {
  6279. $.fn.jqCron = function (settings) {
  6280. var saved_settings = settings;
  6281. return this.each(function () {
  6282. var cron, saved;
  6283. var $this = $(this);
  6284. var settings = jqCronMergeSettings(saved_settings); // clone settings
  6285. var translations = settings.texts[settings.lang];
  6286. if (cron_ui_typeof(translations) !== 'object' || $.isEmptyObject(translations)) {
  6287. console && console.error('Missing translations for language "' + settings.lang + '". ' + 'Please include jqCron.' + settings.lang + '.js or manually provide ' + 'the necessary translations when calling $.fn.jqCron().');
  6288. return;
  6289. }
  6290. if (!settings.jquery_container) {
  6291. if ($this.is(':container')) {
  6292. settings.jquery_element = $this.uniqueId('jqCron');
  6293. } else if ($this.is(':autoclose')) {
  6294. // delete already generated dom if exists
  6295. if ($this.next('.jqCron').length == 1) {
  6296. $this.next('.jqCron').remove();
  6297. } // generate new
  6298. settings.jquery_element = $('<span class="jqCron"></span>').uniqueId('jqCron').insertAfter($this);
  6299. } else {
  6300. console && console.error(settings.texts[settings.lang].error1.replace('%s', this.tagName));
  6301. return;
  6302. }
  6303. } // autoset bind_to if it is an input
  6304. if ($this.is(':input')) {
  6305. settings.bind_to = settings.bind_to || $this;
  6306. } // init cron object
  6307. if (settings.bind_to) {
  6308. if (settings.bind_to.is(':input')) {
  6309. // auto bind from input to object if an input, textarea ...
  6310. settings.bind_to.blur(function () {
  6311. var value = settings.bind_method.get(settings.bind_to);
  6312. $this.jqCronGetInstance().setCron(value);
  6313. });
  6314. }
  6315. saved = settings.bind_method.get(settings.bind_to);
  6316. cron = new jqCron(settings);
  6317. cron.setCron(saved);
  6318. } else {
  6319. cron = new jqCron(settings);
  6320. }
  6321. $(this).data('jqCron', cron);
  6322. });
  6323. };
  6324. }).call(window, (external_jQuery_default()));
  6325. /**
  6326. * jqCron class
  6327. */
  6328. (function ($) {
  6329. var jqCronInstances = [];
  6330. function jqCron(settings) {
  6331. var _initialized = false;
  6332. var _self = this;
  6333. var _$elt = this;
  6334. var _$obj = $('<span class="jqCron-container"></span>');
  6335. var _$blocks = $('<span class="jqCron-blocks"></span>');
  6336. var _$blockPERIOD = $('<span class="jqCron-period"></span>');
  6337. var _$blockDOM = $('<span class="jqCron-dom"></span>');
  6338. var _$blockMONTH = $('<span class="jqCron-month"></span>');
  6339. var _$blockMINS = $('<span class="jqCron-mins"></span>');
  6340. var _$blockDOW = $('<span class="jqCron-dow"></span>');
  6341. var _$blockTIME = $('<span class="jqCron-time"></span>');
  6342. var _$cross = $('<span class="jqCron-cross">&#10008;</span>');
  6343. var _selectors = [];
  6344. var _selectorPeriod, _selectorMins, _selectorTimeH, _selectorTimeM, _selectorDow, _selectorDom, _selectorMonth; // instanciate a new selector
  6345. function newSelector($block, multiple, type) {
  6346. var selector = new jqCronSelector(_self, $block, multiple, type);
  6347. selector.$.bind('selector:open', function () {
  6348. // we close all opened selectors of all other jqCron
  6349. for (var n = jqCronInstances.length; n--;) {
  6350. if (jqCronInstances[n] != _self) {
  6351. jqCronInstances[n].closeSelectors();
  6352. } else {
  6353. // we close all other opened selectors of this jqCron
  6354. for (var o = _selectors.length; o--;) {
  6355. if (_selectors[o] != selector) {
  6356. _selectors[o].close();
  6357. }
  6358. }
  6359. }
  6360. }
  6361. });
  6362. selector.$.bind('selector:change', function () {
  6363. var boundChanged = false; // don't propagate if not initialized
  6364. if (!_initialized) return; // bind data between two minute selectors (only if they have the same multiple settings)
  6365. if (settings.multiple_mins == settings.multiple_time_minutes) {
  6366. if (selector == _selectorMins) {
  6367. boundChanged = _selectorTimeM.setValue(_selectorMins.getValue());
  6368. } else if (selector == _selectorTimeM) {
  6369. boundChanged = _selectorMins.setValue(_selectorTimeM.getValue());
  6370. }
  6371. } // we propagate the change event to the main object
  6372. boundChanged || _$obj.trigger('cron:change', _self.getCron());
  6373. });
  6374. _selectors.push(selector);
  6375. return selector;
  6376. } // disable the selector
  6377. this.disable = function () {
  6378. _$obj.addClass('disable');
  6379. settings.disable = true;
  6380. _self.closeSelectors();
  6381. }; // return if the selector is disabled
  6382. this.isDisabled = function () {
  6383. return settings.disable == true;
  6384. }; // enable the selector
  6385. this.enable = function () {
  6386. _$obj.removeClass('disable');
  6387. settings.disable = false;
  6388. }; // get cron value
  6389. this.getCron = function () {
  6390. var period = _selectorPeriod.getValue();
  6391. var items = ['*', '*', '*', '*', '*'];
  6392. if (period == 'hour') {
  6393. items[0] = _selectorMins.getCronValue();
  6394. }
  6395. if (period == 'day' || period == 'week' || period == 'month' || period == 'year') {
  6396. items[0] = _selectorTimeM.getCronValue();
  6397. items[1] = _selectorTimeH.getCronValue();
  6398. }
  6399. if (period == 'month' || period == 'year') {
  6400. items[2] = _selectorDom.getCronValue();
  6401. }
  6402. if (period == 'year') {
  6403. items[3] = _selectorMonth.getCronValue();
  6404. }
  6405. if (period == 'week') {
  6406. items[4] = _selectorDow.getCronValue();
  6407. }
  6408. return items.join(' ');
  6409. }; // set cron (string like * * * * *)
  6410. this.setCron = function (str) {
  6411. if (!str) return;
  6412. try {
  6413. str = str.replace(/\s+/g, ' ').replace(/^ +/, '').replace(/ +$/, ''); // sanitize
  6414. var mask = str.replace(/[^\* ]/g, '-').replace(/-+/g, '-').replace(/ +/g, '');
  6415. var items = str.split(' ');
  6416. if (items.length != 5) _self.error(_self.getText('error2'));
  6417. if (mask == '*****') {
  6418. // 1 possibility
  6419. _selectorPeriod.setValue('minute');
  6420. } else if (mask == '-****') {
  6421. // 1 possibility
  6422. _selectorPeriod.setValue('hour');
  6423. _selectorMins.setCronValue(items[0]);
  6424. _selectorTimeM.setCronValue(items[0]);
  6425. } else if (mask.substring(2, mask.length) == '***') {
  6426. // 4 possibilities
  6427. _selectorPeriod.setValue('day');
  6428. _selectorMins.setCronValue(items[0]);
  6429. _selectorTimeM.setCronValue(items[0]);
  6430. _selectorTimeH.setCronValue(items[1]);
  6431. } else if (mask.substring(2, mask.length) == '-**') {
  6432. // 4 possibilities
  6433. _selectorPeriod.setValue('month');
  6434. _selectorMins.setCronValue(items[0]);
  6435. _selectorTimeM.setCronValue(items[0]);
  6436. _selectorTimeH.setCronValue(items[1]);
  6437. _selectorDom.setCronValue(items[2]);
  6438. } else if (mask.substring(2, mask.length) == '**-') {
  6439. // 4 possibilities
  6440. _selectorPeriod.setValue('week');
  6441. _selectorMins.setCronValue(items[0]);
  6442. _selectorTimeM.setCronValue(items[0]);
  6443. _selectorTimeH.setCronValue(items[1]);
  6444. _selectorDow.setCronValue(items[4]);
  6445. } else if (mask.substring(3, mask.length) == '-*') {
  6446. // 8 possibilities
  6447. _selectorPeriod.setValue('year');
  6448. _selectorMins.setCronValue(items[0]);
  6449. _selectorTimeM.setCronValue(items[0]);
  6450. _selectorTimeH.setCronValue(items[1]);
  6451. _selectorDom.setCronValue(items[2]);
  6452. _selectorMonth.setCronValue(items[3]);
  6453. } else {
  6454. _self.error(_self.getText('error4'));
  6455. }
  6456. _self.clearError();
  6457. } catch (e) {}
  6458. }; // close all child selectors
  6459. this.closeSelectors = function () {
  6460. for (var n = _selectors.length; n--;) {
  6461. _selectors[n].close();
  6462. }
  6463. }; // get the main element id
  6464. this.getId = function () {
  6465. return _$elt.attr('id');
  6466. }; // get the translated text
  6467. this.getText = function (key) {
  6468. var text = settings.texts[settings.lang][key] || null;
  6469. if (typeof text == "string" && text.match('<b')) {
  6470. text = text.replace(/(<b *\/>)/gi, '</span><b /><span class="jqCron-text">');
  6471. text = '<span class="jqCron-text">' + text + '</span>';
  6472. }
  6473. return text;
  6474. }; // get the human readable text
  6475. this.getHumanText = function () {
  6476. var texts = [];
  6477. _$obj.find('> span > span:visible').find('.jqCron-text, .jqCron-selector > span').each(function () {
  6478. var text = $(this).text().replace(/\s+$/g, '').replace(/^\s+/g, '');
  6479. text && texts.push(text);
  6480. });
  6481. return texts.join(' ').replace(/\s:\s/g, ':');
  6482. }; // get settings
  6483. this.getSettings = function () {
  6484. return settings;
  6485. }; // display an error
  6486. this.error = function (msg) {
  6487. console && console.error('[jqCron Error] ' + msg);
  6488. _$obj.addClass('jqCron-error').attr('title', msg);
  6489. throw msg;
  6490. }; // clear error
  6491. this.clearError = function () {
  6492. _$obj.attr('title', '').removeClass('jqCron-error');
  6493. }; // clear
  6494. this.clear = function () {
  6495. _selectorDom.setValue([]);
  6496. _selectorDow.setValue([]);
  6497. _selectorMins.setValue([]);
  6498. _selectorMonth.setValue([]);
  6499. _selectorTimeH.setValue([]);
  6500. _selectorTimeM.setValue([]);
  6501. _self.triggerChange();
  6502. }; // init (called in constructor)
  6503. this.init = function () {
  6504. var n, i, labelsList, list;
  6505. if (_initialized) return;
  6506. settings = jqCronMergeSettings(settings);
  6507. settings.jquery_element || _self.error(_self.getText('error3'));
  6508. _$elt = settings.jquery_element;
  6509. _$elt.append(_$obj);
  6510. _$obj.data('id', settings.id);
  6511. _$obj.data('jqCron', _self);
  6512. _$obj.append(_$blocks);
  6513. settings.no_reset_button || _$obj.append(_$cross);
  6514. !settings.disable || _$obj.addClass('disable');
  6515. _$blocks.append(_$blockPERIOD);
  6516. if (/^(ko)$/i.test(settings.lang)) {
  6517. _$blocks.append(_$blockMONTH, _$blockDOM);
  6518. } else {
  6519. _$blocks.append(_$blockDOM, _$blockMONTH);
  6520. }
  6521. _$blocks.append(_$blockMINS);
  6522. _$blocks.append(_$blockDOW);
  6523. _$blocks.append(_$blockTIME); // various binding
  6524. _$cross.click(function () {
  6525. _self.isDisabled() || _self.clear();
  6526. }); // binding from cron to target
  6527. _$obj.bind('cron:change', function (evt, value) {
  6528. if (!settings.bind_to) return;
  6529. settings.bind_method.set && settings.bind_method.set(settings.bind_to, value);
  6530. _self.clearError();
  6531. }); // PERIOD
  6532. _$blockPERIOD.append(_self.getText('text_period'));
  6533. _selectorPeriod = newSelector(_$blockPERIOD, false, 'period');
  6534. settings.enabled_minute && _selectorPeriod.add('minute', _self.getText('name_minute'));
  6535. settings.enabled_hour && _selectorPeriod.add('hour', _self.getText('name_hour'));
  6536. settings.enabled_day && _selectorPeriod.add('day', _self.getText('name_day'));
  6537. settings.enabled_week && _selectorPeriod.add('week', _self.getText('name_week'));
  6538. settings.enabled_month && _selectorPeriod.add('month', _self.getText('name_month'));
  6539. settings.enabled_year && _selectorPeriod.add('year', _self.getText('name_year'));
  6540. _selectorPeriod.$.bind('selector:change', function (e, value) {
  6541. _$blockDOM.hide();
  6542. _$blockMONTH.hide();
  6543. _$blockMINS.hide();
  6544. _$blockDOW.hide();
  6545. _$blockTIME.hide();
  6546. if (value == 'hour') {
  6547. _$blockMINS.show();
  6548. } else if (value == 'day') {
  6549. _$blockTIME.show();
  6550. } else if (value == 'week') {
  6551. _$blockDOW.show();
  6552. _$blockTIME.show();
  6553. } else if (value == 'month') {
  6554. _$blockDOM.show();
  6555. _$blockTIME.show();
  6556. } else if (value == 'year') {
  6557. _$blockDOM.show();
  6558. _$blockMONTH.show();
  6559. _$blockTIME.show();
  6560. }
  6561. });
  6562. _selectorPeriod.setValue(settings.default_period); // MINS (minutes)
  6563. _$blockMINS.append(_self.getText('text_mins'));
  6564. _selectorMins = newSelector(_$blockMINS, settings.multiple_mins, 'minutes');
  6565. for (i = 0, list = settings.minutes; i < list.length; i++) {
  6566. _selectorMins.add(list[i], list[i]);
  6567. } // TIME (hour:min)
  6568. _$blockTIME.append(_self.getText('text_time'));
  6569. _selectorTimeH = newSelector(_$blockTIME, settings.multiple_time_hours, 'time_hours');
  6570. for (i = 0, list = settings.hours, labelsList = settings.hour_labels; i < list.length; i++) {
  6571. _selectorTimeH.add(list[i], labelsList[i]);
  6572. }
  6573. _selectorTimeM = newSelector(_$blockTIME, settings.multiple_time_minutes, 'time_minutes');
  6574. for (i = 0, list = settings.minutes; i < list.length; i++) {
  6575. _selectorTimeM.add(list[i], list[i]);
  6576. } // DOW (day of week)
  6577. _$blockDOW.append(_self.getText('text_dow'));
  6578. _selectorDow = newSelector(_$blockDOW, settings.multiple_dow, 'day_of_week');
  6579. for (i = 0, list = _self.getText('weekdays'); i < list.length; i++) {
  6580. _selectorDow.add(i + 1, list[i]);
  6581. } // DOM (day of month)
  6582. _$blockDOM.append(_self.getText('text_dom'));
  6583. _selectorDom = newSelector(_$blockDOM, settings.multiple_dom, 'day_of_month');
  6584. for (i = 0, list = settings.monthdays; i < list.length; i++) {
  6585. _selectorDom.add(list[i], list[i]);
  6586. } // MONTH (day of week)
  6587. _$blockMONTH.append(_self.getText('text_month'));
  6588. _selectorMonth = newSelector(_$blockMONTH, settings.multiple_month, 'month');
  6589. for (i = 0, list = _self.getText('months'); i < list.length; i++) {
  6590. _selectorMonth.add(i + 1, list[i]);
  6591. } // close all selectors when we click in body
  6592. $('body').click(function () {
  6593. var i,
  6594. n = _selectors.length;
  6595. for (i = 0; i < n; i++) {
  6596. _selectors[i].close();
  6597. }
  6598. });
  6599. _initialized = true; // default value
  6600. if (settings.default_value) {
  6601. _self.setCron(settings.default_value);
  6602. }
  6603. }; // trigger a change event
  6604. this.triggerChange = function () {
  6605. _$obj.trigger('cron:change', _self.getCron());
  6606. }; // store instance in array
  6607. jqCronInstances.push(this); // expose main jquery object
  6608. this.$ = _$obj; // init
  6609. try {
  6610. this.init();
  6611. _self.triggerChange();
  6612. } catch (e) {}
  6613. }
  6614. this.jqCron = jqCron;
  6615. }).call(window, (external_jQuery_default()));
  6616. /**
  6617. * jqCronSelector class
  6618. */
  6619. (function ($) {
  6620. function jqCronSelector(_cron, _$block, _multiple, _type) {
  6621. var _self = this;
  6622. var _$list = $('<ul class="jqCron-selector-list"></ul>');
  6623. var _$title = $('<span class="jqCron-selector-title"></span>');
  6624. var _$selector = $('<span class="jqCron-selector"></span>');
  6625. var _values = {};
  6626. var _value = [];
  6627. var _hasNumericTexts = true;
  6628. var _numeric_zero_pad = _cron.getSettings().numeric_zero_pad; // return an array without doublon
  6629. function array_unique(l) {
  6630. var i = 0,
  6631. n = l.length,
  6632. k = {},
  6633. a = [];
  6634. while (i < n) {
  6635. k[l[i]] || (k[l[i]] = true && a.push(l[i]));
  6636. i++;
  6637. }
  6638. return a;
  6639. } // get the value (an array if multiple, else a single value)
  6640. this.getValue = function () {
  6641. return _multiple ? _value : _value[0];
  6642. }; // get a correct string for cron
  6643. this.getCronValue = function () {
  6644. if (_value.length == 0) return '*';
  6645. var cron = [_value[0]],
  6646. i,
  6647. s = _value[0],
  6648. c = _value[0],
  6649. n = _value.length;
  6650. for (i = 1; i < n; i++) {
  6651. if (_value[i] == c + 1) {
  6652. c = _value[i];
  6653. cron[cron.length - 1] = s + '-' + c;
  6654. } else {
  6655. s = c = _value[i];
  6656. cron.push(c);
  6657. }
  6658. }
  6659. return cron.join(',');
  6660. }; // set the cron value
  6661. this.setCronValue = function (str) {
  6662. var values = [],
  6663. m,
  6664. i,
  6665. n;
  6666. if (str !== '*') {
  6667. while (str != '') {
  6668. // test "*/n" expression
  6669. m = str.match(/^\*\/([0-9]+),?/);
  6670. if (m && m.length == 2) {
  6671. for (i = 0; i <= 59; i += m[1] | 0) {
  6672. values.push(i);
  6673. }
  6674. str = str.replace(m[0], '');
  6675. continue;
  6676. } // test "a-b/n" expression
  6677. m = str.match(/^([0-9]+)-([0-9]+)\/([0-9]+),?/);
  6678. if (m && m.length == 4) {
  6679. for (i = m[1] | 0; i <= (m[2] | 0); i += m[3] | 0) {
  6680. values.push(i);
  6681. }
  6682. str = str.replace(m[0], '');
  6683. continue;
  6684. } // test "a-b" expression
  6685. m = str.match(/^([0-9]+)-([0-9]+),?/);
  6686. if (m && m.length == 3) {
  6687. for (i = m[1] | 0; i <= (m[2] | 0); i++) {
  6688. values.push(i);
  6689. }
  6690. str = str.replace(m[0], '');
  6691. continue;
  6692. } // test "c" expression
  6693. m = str.match(/^([0-9]+),?/);
  6694. if (m && m.length == 2) {
  6695. values.push(m[1] | 0);
  6696. str = str.replace(m[0], '');
  6697. continue;
  6698. } // something goes wrong in the expression
  6699. return;
  6700. }
  6701. }
  6702. _self.setValue(values);
  6703. }; // close the selector
  6704. this.close = function () {
  6705. _$selector.trigger('selector:close');
  6706. }; // open the selector
  6707. this.open = function () {
  6708. _$selector.trigger('selector:open');
  6709. }; // whether the selector is open
  6710. this.isOpened = function () {
  6711. return _$list.is(':visible');
  6712. }; // add a selected value to the list
  6713. this.addValue = function (key) {
  6714. var values = _multiple ? _value.slice(0) : []; // clone array
  6715. values.push(key);
  6716. _self.setValue(values);
  6717. }; // remove a selected value from the list
  6718. this.removeValue = function (key) {
  6719. if (_multiple) {
  6720. var i,
  6721. newValue = [];
  6722. for (i = 0; i < _value.length; i++) {
  6723. if (key != [_value[i]]) {
  6724. newValue.push(_value[i]);
  6725. }
  6726. }
  6727. _self.setValue(newValue);
  6728. } else {
  6729. _self.clear();
  6730. }
  6731. }; // set the selected value(s) of the list
  6732. this.setValue = function (keys) {
  6733. var i,
  6734. newKeys = [],
  6735. saved = _value.join(' ');
  6736. if (!$.isArray(keys)) keys = [keys];
  6737. _$list.find('li').removeClass('selected');
  6738. keys = array_unique(keys);
  6739. keys.sort(function (a, b) {
  6740. var ta = cron_ui_typeof(a);
  6741. var tb = cron_ui_typeof(b);
  6742. if (ta == tb && ta == "number") return a - b;else return String(a) == String(b) ? 0 : String(a) < String(b) ? -1 : 1;
  6743. });
  6744. if (_multiple) {
  6745. for (i = 0; i < keys.length; i++) {
  6746. if (keys[i] in _values) {
  6747. _values[keys[i]].addClass('selected');
  6748. newKeys.push(keys[i]);
  6749. }
  6750. }
  6751. } else {
  6752. if (keys[0] in _values) {
  6753. _values[keys[0]].addClass('selected');
  6754. newKeys.push(keys[0]);
  6755. }
  6756. } // remove unallowed values
  6757. _value = newKeys;
  6758. if (saved != _value.join(' ')) {
  6759. _$selector.trigger('selector:change', _multiple ? keys : keys[0]);
  6760. return true;
  6761. }
  6762. return false;
  6763. }; // get the title text
  6764. this.getTitleText = function () {
  6765. var getValueText = function getValueText(key) {
  6766. return key in _values ? _values[key].text() : key;
  6767. };
  6768. if (_value.length == 0) {
  6769. return _cron.getText('empty_' + _type) || _cron.getText('empty');
  6770. }
  6771. var cron = [getValueText(_value[0])],
  6772. i,
  6773. s = _value[0],
  6774. c = _value[0],
  6775. n = _value.length;
  6776. for (i = 1; i < n; i++) {
  6777. if (_value[i] == c + 1) {
  6778. c = _value[i];
  6779. cron[cron.length - 1] = getValueText(s) + '-' + getValueText(c);
  6780. } else {
  6781. s = c = _value[i];
  6782. cron.push(getValueText(c));
  6783. }
  6784. }
  6785. return cron.join(',');
  6786. }; // clear list
  6787. this.clear = function () {
  6788. _values = {};
  6789. _self.setValue([]);
  6790. _$list.empty();
  6791. }; // add a (key, value) pair
  6792. this.add = function (key, value) {
  6793. if (!(value + '').match(/^[0-9]+$/)) _hasNumericTexts = false;
  6794. if (_numeric_zero_pad && _hasNumericTexts && value < 10) {
  6795. value = '0' + value;
  6796. }
  6797. var $item = $('<li>' + value + '</li>');
  6798. _$list.append($item);
  6799. _values[key] = $item;
  6800. $item.click(function () {
  6801. if (_multiple && $(this).hasClass('selected')) {
  6802. _self.removeValue(key);
  6803. } else {
  6804. _self.addValue(key);
  6805. if (!_multiple) _self.close();
  6806. }
  6807. });
  6808. }; // expose main jquery object
  6809. this.$ = _$selector; // constructor
  6810. _$block.find('b:eq(0)').after(_$selector).remove();
  6811. _$selector.addClass('jqCron-selector-' + _$block.find('.jqCron-selector').length).append(_$title).append(_$list).bind('selector:open', function () {
  6812. if (_hasNumericTexts) {
  6813. var nbcols = 1,
  6814. n = _$list.find('li').length;
  6815. if (n > 5 && n <= 16) nbcols = 2;else if (n > 16 && n <= 23) nbcols = 3;else if (n > 23 && n <= 40) nbcols = 4;else if (n > 40) nbcols = 5;
  6816. _$list.addClass('cols' + nbcols);
  6817. }
  6818. _$list.show();
  6819. }).bind('selector:close', function () {
  6820. _$list.hide();
  6821. }).bind('selector:change', function () {
  6822. _$title.html(_self.getTitleText());
  6823. }).click(function (e) {
  6824. e.stopPropagation();
  6825. }).trigger('selector:change');
  6826. $.fn.disableSelection && _$selector.disableSelection(); // only work with jQuery UI
  6827. _$title.click(function (e) {
  6828. _self.isOpened() || _cron.isDisabled() ? _self.close() : _self.open();
  6829. });
  6830. _self.close();
  6831. _self.clear();
  6832. }
  6833. this.jqCronSelector = jqCronSelector;
  6834. }).call(window, (external_jQuery_default()));
  6835. /**
  6836. * Generate unique id for each element.
  6837. * Skip elements which have already an id.
  6838. */
  6839. (function ($) {
  6840. var jqUID = 0;
  6841. var jqGetUID = function jqGetUID(prefix) {
  6842. var id;
  6843. while (1) {
  6844. jqUID++;
  6845. id = (prefix || 'JQUID') + '' + jqUID;
  6846. if (!document.getElementById(id)) return id;
  6847. }
  6848. };
  6849. $.fn.uniqueId = function (prefix) {
  6850. return this.each(function () {
  6851. if ($(this).attr('id')) return;
  6852. var id = jqGetUID(prefix);
  6853. $(this).attr('id', id);
  6854. });
  6855. };
  6856. }).call(window, (external_jQuery_default()));
  6857. /**
  6858. * Extends jQuery selectors with new block selector
  6859. */
  6860. (function ($) {
  6861. $.extend($.expr[':'], {
  6862. container: function container(a) {
  6863. return (a.tagName + '').toLowerCase() in {
  6864. a: 1,
  6865. abbr: 1,
  6866. acronym: 1,
  6867. address: 1,
  6868. b: 1,
  6869. big: 1,
  6870. blockquote: 1,
  6871. button: 1,
  6872. cite: 1,
  6873. code: 1,
  6874. dd: 1,
  6875. del: 1,
  6876. dfn: 1,
  6877. div: 1,
  6878. dt: 1,
  6879. em: 1,
  6880. fieldset: 1,
  6881. form: 1,
  6882. h1: 1,
  6883. h2: 1,
  6884. h3: 1,
  6885. h4: 1,
  6886. h5: 1,
  6887. h6: 1,
  6888. i: 1,
  6889. ins: 1,
  6890. kbd: 1,
  6891. label: 1,
  6892. li: 1,
  6893. p: 1,
  6894. pre: 1,
  6895. q: 1,
  6896. samp: 1,
  6897. small: 1,
  6898. span: 1,
  6899. strong: 1,
  6900. sub: 1,
  6901. sup: 1,
  6902. td: 1,
  6903. tt: 1
  6904. };
  6905. },
  6906. autoclose: function autoclose(a) {
  6907. return (a.tagName + '').toLowerCase() in {
  6908. area: 1,
  6909. base: 1,
  6910. basefont: 1,
  6911. br: 1,
  6912. col: 1,
  6913. frame: 1,
  6914. hr: 1,
  6915. img: 1,
  6916. input: 1,
  6917. link: 1,
  6918. meta: 1,
  6919. param: 1
  6920. };
  6921. }
  6922. });
  6923. }).call(window, (external_jQuery_default()));
  6924. ;// CONCATENATED MODULE: ./app/forms/fields/cron.js
  6925. function cron_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6926. function cron_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); } }
  6927. function cron_createClass(Constructor, protoProps, staticProps) { if (protoProps) cron_defineProperties(Constructor.prototype, protoProps); if (staticProps) cron_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  6928. var CronField = /*#__PURE__*/function () {
  6929. function CronField() {
  6930. var _this = this;
  6931. cron_classCallCheck(this, CronField);
  6932. this.items = external_jQuery_default()();
  6933. external_jQuery_default()('[data-grav-field="cron"]').each(function (index, cron) {
  6934. return _this.addCron(cron);
  6935. });
  6936. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  6937. }
  6938. cron_createClass(CronField, [{
  6939. key: "addCron",
  6940. value: function addCron(cron) {
  6941. cron = external_jQuery_default()(cron);
  6942. this.items = this.items.add(cron);
  6943. cron.find('.cron-selector').each(function (index, container) {
  6944. container = external_jQuery_default()(container);
  6945. var input = container.closest('[data-grav-field]').find('input');
  6946. container.jqCron({
  6947. numeric_zero_pad: true,
  6948. enabled_minute: true,
  6949. multiple_dom: true,
  6950. multiple_month: true,
  6951. multiple_mins: true,
  6952. multiple_dow: true,
  6953. multiple_time_hours: true,
  6954. multiple_time_minutes: true,
  6955. default_period: 'hour',
  6956. default_value: input.val() || '* * * * *',
  6957. no_reset_button: false,
  6958. bind_to: input,
  6959. bind_method: {
  6960. set: function set($element, value) {
  6961. $element.val(value);
  6962. }
  6963. },
  6964. texts: {
  6965. en: {
  6966. empty: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY"],
  6967. empty_minutes: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY"],
  6968. empty_time_hours: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_HOUR"],
  6969. empty_time_minutes: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_MINUTE"],
  6970. empty_day_of_week: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_DAY_OF_WEEK"],
  6971. empty_day_of_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_DAY_OF_MONTH"],
  6972. empty_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_MONTH"],
  6973. name_minute: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.MINUTE"],
  6974. name_hour: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.HOUR"],
  6975. name_day: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.DAY"],
  6976. name_week: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.WEEK"],
  6977. name_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.MONTH"],
  6978. name_year: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.YEAR"],
  6979. text_period: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_PERIOD"],
  6980. text_mins: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_MINS"],
  6981. text_time: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_TIME"],
  6982. text_dow: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_DOW"],
  6983. text_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_MONTH"],
  6984. text_dom: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_DOM"],
  6985. error1: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR1"],
  6986. error2: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR2"],
  6987. error3: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR3"],
  6988. error4: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR4"],
  6989. weekdays: external_GravAdmin_namespaceObject.translations.GRAV_CORE.DAYS_OF_THE_WEEK,
  6990. months: external_GravAdmin_namespaceObject.translations.GRAV_CORE.MONTHS_OF_THE_YEAR
  6991. }
  6992. }
  6993. });
  6994. });
  6995. }
  6996. }, {
  6997. key: "_onAddedNodes",
  6998. value: function _onAddedNodes(event, target
  6999. /* , record, instance */
  7000. ) {
  7001. var _this2 = this;
  7002. var crons = external_jQuery_default()(target).find('[data-grav-field="cron"]');
  7003. if (!crons.length) {
  7004. return;
  7005. }
  7006. crons.each(function (index, list) {
  7007. list = external_jQuery_default()(list);
  7008. if (!~_this2.items.index(list)) {
  7009. _this2.addCron(list);
  7010. }
  7011. });
  7012. }
  7013. }]);
  7014. return CronField;
  7015. }();
  7016. var cron_Instance = new CronField();
  7017. // EXTERNAL MODULE: ./node_modules/eventemitter3/index.js
  7018. var eventemitter3 = __webpack_require__(26729);
  7019. var eventemitter3_default = /*#__PURE__*/__webpack_require__.n(eventemitter3);
  7020. ;// CONCATENATED MODULE: ./app/utils/finderjs.js
  7021. function finderjs_typeof(obj) { "@babel/helpers - typeof"; return finderjs_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, finderjs_typeof(obj); }
  7022. function finderjs_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7023. function finderjs_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); } }
  7024. function finderjs_createClass(Constructor, protoProps, staticProps) { if (protoProps) finderjs_defineProperties(Constructor.prototype, protoProps); if (staticProps) finderjs_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  7025. /**
  7026. * (c) Trilby Media, LLC
  7027. * Author Djamil Legato
  7028. *
  7029. * Based on Mark Matyas's Finderjs
  7030. * MIT License
  7031. */
  7032. var DEFAULTS = {
  7033. labelKey: 'name',
  7034. valueKey: 'value',
  7035. // new
  7036. childKey: 'children',
  7037. iconKey: 'icon',
  7038. // new
  7039. itemKey: 'item-key',
  7040. // new
  7041. pathBar: true,
  7042. className: {
  7043. container: 'fjs-container',
  7044. pathBar: 'fjs-path-bar',
  7045. col: 'fjs-col',
  7046. list: 'fjs-list',
  7047. item: 'fjs-item',
  7048. active: 'fjs-active',
  7049. children: 'fjs-has-children',
  7050. url: 'fjs-url',
  7051. itemPrepend: 'fjs-item-prepend',
  7052. itemContent: 'fjs-item-content',
  7053. itemAppend: 'fjs-item-append'
  7054. }
  7055. };
  7056. var Finder = /*#__PURE__*/function () {
  7057. function Finder(container, data, options) {
  7058. var _this = this;
  7059. finderjs_classCallCheck(this, Finder);
  7060. this.$emitter = new (eventemitter3_default())();
  7061. this.container = external_jQuery_default()(container);
  7062. this.data = data;
  7063. this.config = external_jQuery_default().extend({}, DEFAULTS, options); // dom events
  7064. this.container.on('click', this.clickEvent.bind(this));
  7065. this.container.on('keydown', this.keydownEvent.bind(this)); // internal events
  7066. this.$emitter.on('item-selected', this.itemSelected.bind(this));
  7067. this.$emitter.on('create-column', this.addColumn.bind(this));
  7068. this.$emitter.on('navigate', this.navigate.bind(this));
  7069. this.$emitter.on('go-to', this.goTo.bind(this, this.data));
  7070. this.container.addClass(this.config.className.container).attr('tabindex', 0);
  7071. this.createColumn(this.data);
  7072. if (this.config.pathBar) {
  7073. this.pathBar = this.createPathBar();
  7074. this.pathBar.on('click', '[data-breadcrumb-node]', function (event) {
  7075. event.preventDefault();
  7076. var location = external_jQuery_default()(event.currentTarget).data('breadcrumbNode');
  7077. _this.goTo(_this.data, location);
  7078. });
  7079. } // '' is <Root>
  7080. if (this.config.defaultPath || this.config.defaultPath === '') {
  7081. this.goTo(this.data, this.config.defaultPath);
  7082. }
  7083. }
  7084. finderjs_createClass(Finder, [{
  7085. key: "reload",
  7086. value: function reload() {
  7087. var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.data;
  7088. this.createColumn(data); // '' is <Root>
  7089. if (this.config.defaultPath || this.config.defaultPath === '') {
  7090. this.goTo(data, this.config.defaultPath);
  7091. }
  7092. }
  7093. }, {
  7094. key: "createColumn",
  7095. value: function createColumn(data, parent) {
  7096. var _this2 = this;
  7097. var callback = function callback(data) {
  7098. return _this2.createColumn(data, parent);
  7099. };
  7100. if (typeof data === 'function') {
  7101. data.call(this, parent, callback);
  7102. } else if (Array.isArray(data) || finderjs_typeof(data) === 'object') {
  7103. if (finderjs_typeof(data) === 'object') {
  7104. data = Array.from(data);
  7105. }
  7106. var list = this.createList(data);
  7107. var div = external_jQuery_default()('<div />');
  7108. div.append(list).addClass(this.config.className.col);
  7109. this.$emitter.emit('create-column', div);
  7110. return div;
  7111. } else {
  7112. throw new Error('Unknown data type');
  7113. }
  7114. }
  7115. }, {
  7116. key: "createPathBar",
  7117. value: function createPathBar() {
  7118. this.container.siblings(".".concat(this.config.className.pathBar)).remove();
  7119. var pathBar = external_jQuery_default()("<div class=\"".concat(this.config.className.pathBar, "\" />"));
  7120. pathBar.insertAfter(this.container);
  7121. return pathBar;
  7122. }
  7123. }, {
  7124. key: "clickEvent",
  7125. value: function clickEvent(event) {
  7126. event.stopPropagation();
  7127. event.preventDefault();
  7128. var target = external_jQuery_default()(event.target);
  7129. var column = target.closest(".".concat(this.config.className.col));
  7130. var item = target.closest(".".concat(this.config.className.item));
  7131. if (item.length) {
  7132. this.$emitter.emit('item-selected', {
  7133. column: column,
  7134. item: item
  7135. });
  7136. }
  7137. }
  7138. }, {
  7139. key: "keydownEvent",
  7140. value: function keydownEvent(event) {
  7141. var codes = {
  7142. 37: 'left',
  7143. 38: 'up',
  7144. 39: 'right',
  7145. 40: 'down'
  7146. };
  7147. if (event.keyCode in codes) {
  7148. event.stopPropagation();
  7149. event.preventDefault();
  7150. this.$emitter.emit('navigate', {
  7151. direction: codes[event.keyCode]
  7152. });
  7153. }
  7154. }
  7155. }, {
  7156. key: "itemSelected",
  7157. value: function itemSelected(value) {
  7158. var element = value.item;
  7159. if (!element.length) {
  7160. return false;
  7161. }
  7162. var item = element[0]._item;
  7163. var column = value.column;
  7164. var data = item[this.config.childKey] || this.data;
  7165. var active = external_jQuery_default()(column).find(".".concat(this.config.className.active));
  7166. if (active.length) {
  7167. active.removeClass(this.config.className.active);
  7168. }
  7169. element.addClass(this.config.className.active);
  7170. column.nextAll().remove(); // ?!?!?
  7171. this.container[0].focus();
  7172. window.scrollTo(window.pageXOffset, window.pageYOffset);
  7173. this.updatePathBar();
  7174. var newColumn;
  7175. if (data) {
  7176. newColumn = this.createColumn(data, item);
  7177. this.$emitter.emit('interior-selected', item);
  7178. } else {
  7179. this.$emitter.emit('leaf-selected', item);
  7180. }
  7181. return newColumn;
  7182. }
  7183. }, {
  7184. key: "addColumn",
  7185. value: function addColumn(column) {
  7186. this.container.append(column);
  7187. this.$emitter.emit('column-created', column);
  7188. }
  7189. }, {
  7190. key: "navigate",
  7191. value: function navigate(value) {
  7192. var active = this.findLastActive();
  7193. var direction = value.direction;
  7194. var column;
  7195. var item;
  7196. var target;
  7197. if (active) {
  7198. item = active.item;
  7199. column = active.column;
  7200. if (direction === 'up' && item.prev().length) {
  7201. target = item.prev();
  7202. } else if (direction === 'down' && item.next().length) {
  7203. target = item.next();
  7204. } else if (direction === 'right' && column.next().length) {
  7205. column = column.next();
  7206. target = column.find(".".concat(this.config.className.item)).first();
  7207. } else if (direction === 'left' && column.prev().length) {
  7208. column = column.prev();
  7209. target = column.find(".".concat(this.config.className.active)).first() || column.find(".".concat(this.config.className.item));
  7210. }
  7211. } else {
  7212. column = this.container.find(".".concat(this.config.className.col)).first();
  7213. target = column.find(".".concat(this.config.className.item)).first();
  7214. }
  7215. if (target) {
  7216. this.$emitter.emit('item-selected', {
  7217. column: column,
  7218. item: target
  7219. });
  7220. }
  7221. }
  7222. }, {
  7223. key: "goTo",
  7224. value: function goTo(data, path) {
  7225. var _this3 = this;
  7226. path = Array.isArray(path) ? path : path.split('/').map(function (bit) {
  7227. return bit.trim();
  7228. }).filter(Boolean);
  7229. if (path.length) {
  7230. this.container.children().remove();
  7231. }
  7232. if (typeof data === 'function') {
  7233. data.call(this, null, function (data) {
  7234. return _this3.selectPath(path, data);
  7235. });
  7236. } else {
  7237. this.selectPath(path, data);
  7238. }
  7239. }
  7240. }, {
  7241. key: "selectPath",
  7242. value: function selectPath(path, data, column) {
  7243. var _this4 = this;
  7244. column = column || (path.length ? this.createColumn(data) : this.container.find("> .".concat(this.config.className.col)));
  7245. var current = path[0] || '';
  7246. var children = data.find(function (item) {
  7247. return item[_this4.config.itemKey] === current;
  7248. });
  7249. var newColumn = this.itemSelected({
  7250. column: column,
  7251. item: column.find("[data-fjs-item=\"".concat(current, "\"]")).first()
  7252. });
  7253. path.shift();
  7254. if (path.length && children) {
  7255. this.selectPath(path, children[this.config.childKey], newColumn);
  7256. }
  7257. }
  7258. }, {
  7259. key: "findLastActive",
  7260. value: function findLastActive() {
  7261. var active = this.container.find(".".concat(this.config.className.active));
  7262. if (!active.length) {
  7263. return null;
  7264. }
  7265. var item = active.last();
  7266. var column = item.closest(".".concat(this.config.className.col));
  7267. return {
  7268. item: item,
  7269. column: column
  7270. };
  7271. }
  7272. }, {
  7273. key: "createList",
  7274. value: function createList(data) {
  7275. var _this5 = this;
  7276. var list = external_jQuery_default()('<ul />');
  7277. var items = data.map(function (item) {
  7278. return _this5.createItem(item);
  7279. });
  7280. var fragments = items.reduce(function (fragment, current) {
  7281. fragment.appendChild(current[0] || current);
  7282. return fragment;
  7283. }, document.createDocumentFragment());
  7284. list.append(fragments).addClass(this.config.className.list);
  7285. return list;
  7286. }
  7287. }, {
  7288. key: "createItem",
  7289. value: function createItem(item) {
  7290. var listItem = external_jQuery_default()('<li />');
  7291. var listItemClasses = [this.config.className.item];
  7292. var link = external_jQuery_default()('<a />');
  7293. var createItemContent = this.config.createItemContent || this.createItemContent;
  7294. var fragment = createItemContent.call(this, item);
  7295. link.append(fragment).attr('href', '').attr('tabindex', -1);
  7296. if (item.url) {
  7297. link.attr('href', item.url);
  7298. listItemClasses.push(item.className);
  7299. }
  7300. if (item[this.config.childKey]) {
  7301. listItemClasses.push(this.config.className[this.config.childKey]);
  7302. }
  7303. listItemClasses.push("fjs-item-".concat(item.type));
  7304. listItem.addClass(listItemClasses.join(' '));
  7305. listItem.append(link).attr('data-fjs-item', item[this.config.itemKey]);
  7306. listItem[0]._item = item;
  7307. return listItem;
  7308. }
  7309. }, {
  7310. key: "updatePathBar",
  7311. value: function updatePathBar() {
  7312. var _this6 = this;
  7313. if (!this.config.pathBar) {
  7314. return false;
  7315. }
  7316. var activeItems = this.container.find(".".concat(this.config.className.active));
  7317. var itemKeys = '';
  7318. this.pathBar.children().empty();
  7319. activeItems.each(function (index, activeItem) {
  7320. var item = activeItem._item;
  7321. var isLast = index + 1 === activeItems.length;
  7322. itemKeys += "/".concat(item[_this6.config.itemKey]);
  7323. _this6.pathBar.append("\n <span class=\"breadcrumb-node breadcrumb-node-".concat(item.type, "\" ").concat(item.type === 'dir' ? "data-breadcrumb-node=\"".concat(itemKeys, "\"") : '', ">\n <i class=\"fa fa-fw ").concat(_this6.getIcon(item.type), "\"></i>\n <span class=\"breadcrumb-node-name\">").concat(external_jQuery_default()('<div />').html(item[_this6.config.labelKey]).html(), "</span>\n ").concat(!isLast ? '<i class="fa fa-fw fa-chevron-right"></i>' : '', "\n </span>\n "));
  7324. });
  7325. }
  7326. }, {
  7327. key: "getIcon",
  7328. value: function getIcon(type) {
  7329. switch (type) {
  7330. case 'root':
  7331. return 'fa-sitemap';
  7332. case 'file':
  7333. return 'fa-file-o';
  7334. case 'dir':
  7335. default:
  7336. return 'fa-folder';
  7337. }
  7338. }
  7339. }]);
  7340. return Finder;
  7341. }();
  7342. /* harmony default export */ const finderjs = (Finder);
  7343. ;// CONCATENATED MODULE: ./app/forms/fields/parents.js
  7344. function parents_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7345. function parents_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); } }
  7346. function parents_createClass(Constructor, protoProps, staticProps) { if (protoProps) parents_defineProperties(Constructor.prototype, protoProps); if (staticProps) parents_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  7347. var XHRUUID = 0;
  7348. var parents_Instances = {};
  7349. var Parents = /*#__PURE__*/function () {
  7350. function Parents(container, field, data) {
  7351. var _this = this;
  7352. parents_classCallCheck(this, Parents);
  7353. this.container = external_jQuery_default()(container);
  7354. this.fieldName = field.attr('name');
  7355. this.field = external_jQuery_default()("[name=\"".concat(this.fieldName, "\"]"));
  7356. this.data = data;
  7357. this.parentLabel = external_jQuery_default()("[data-parents-field-label=\"".concat(this.fieldName, "\"]"));
  7358. this.parentName = external_jQuery_default()("[data-parents-field-name=\"".concat(this.fieldName, "\"]"));
  7359. var dataLoad = this.dataLoad;
  7360. this.finder = new finderjs(this.container, function (parent, callback) {
  7361. return dataLoad.call(_this, parent, callback);
  7362. }, {
  7363. labelKey: 'name',
  7364. defaultPath: this.field.val(),
  7365. createItemContent: function createItemContent(item) {
  7366. return Parents.createItemContent(this.config, item);
  7367. }
  7368. });
  7369. /*
  7370. this.finder.$emitter.on('leaf-selected', (item) => {
  7371. console.log('selected', item);
  7372. this.finder.emit('create-column', () => this.createSimpleColumn(item));
  7373. });
  7374. this.finder.$emitter.on('item-selected', (selected) => {
  7375. console.log('selected', selected);
  7376. // for future use only - create column-card creation for file with details like in macOS finder
  7377. // this.finder.$emitter('create-column', () => this.createSimpleColumn(selected));
  7378. }); */
  7379. this.finder.$emitter.on('column-created', function () {
  7380. _this.container[0].scrollLeft = _this.container[0].scrollWidth - _this.container[0].clientWidth;
  7381. });
  7382. }
  7383. parents_createClass(Parents, [{
  7384. key: "createSimpleColumn",
  7385. value: function createSimpleColumn(item) {}
  7386. }, {
  7387. key: "dataLoad",
  7388. value: function dataLoad(parent, callback) {
  7389. var _this2 = this;
  7390. if (!parent) {
  7391. return callback(this.data);
  7392. }
  7393. if (parent.type !== 'dir' || !parent['has-children']) {
  7394. return false;
  7395. }
  7396. var UUID = ++XHRUUID;
  7397. this.startLoader();
  7398. external_jQuery_default().ajax({
  7399. url: "".concat(external_GravAdmin_namespaceObject.config.current_url),
  7400. method: 'post',
  7401. data: Object.assign({}, getExtraFormData(this.container), {
  7402. route: b64_encode_unicode(parent.value),
  7403. field: this.field.data('fieldName'),
  7404. action: 'getLevelListing',
  7405. 'admin-nonce': external_GravAdmin_namespaceObject.config.admin_nonce
  7406. }),
  7407. success: function success(response) {
  7408. _this2.stopLoader();
  7409. if (response.status === 'error') {
  7410. _this2.finder.$emitter.emit('create-column', Parents.createErrorColumn(response.message)[0]);
  7411. return false;
  7412. } // stale request
  7413. if (UUID !== XHRUUID) {
  7414. return false;
  7415. }
  7416. return callback(response.data);
  7417. }
  7418. });
  7419. }
  7420. }, {
  7421. key: "startLoader",
  7422. value: function startLoader() {
  7423. this.loadingIndicator = Parents.createLoadingColumn();
  7424. this.finder.$emitter.emit('create-column', this.loadingIndicator[0]);
  7425. return this.loadingIndicator;
  7426. }
  7427. }, {
  7428. key: "stopLoader",
  7429. value: function stopLoader() {
  7430. return this.loadingIndicator && this.loadingIndicator.remove();
  7431. }
  7432. }], [{
  7433. key: "createItemContent",
  7434. value: function createItemContent(config, item) {
  7435. var frag = document.createDocumentFragment();
  7436. var label = external_jQuery_default()("<span title=\"".concat(item[config.labelKey], "\" />"));
  7437. var infoContainer = external_jQuery_default()('<span class="info-container" />');
  7438. var iconPrepend = external_jQuery_default()('<i />');
  7439. var iconAppend = external_jQuery_default()('<i />');
  7440. var badge = external_jQuery_default()('<span class="badge" />');
  7441. var prependClasses = ['fa'];
  7442. var appendClasses = ['fa']; // prepend icon
  7443. if (item.children || item.type === 'dir') {
  7444. prependClasses.push('fa-folder');
  7445. } else if (item.type === 'root') {
  7446. prependClasses.push('fa-sitemap');
  7447. } else if (item.type === 'file') {
  7448. prependClasses.push('fa-file-o');
  7449. }
  7450. iconPrepend.addClass(prependClasses.join(' ')); // text label
  7451. label.text(item[config.labelKey]).prepend(iconPrepend);
  7452. label.appendTo(frag); // append icon
  7453. if (item.children || item['has-children']) {
  7454. appendClasses.push('fa-caret-right');
  7455. badge.text(item.size || item.count || 0);
  7456. badge.appendTo(infoContainer);
  7457. }
  7458. iconAppend.addClass(appendClasses.join(' '));
  7459. iconAppend.appendTo(infoContainer);
  7460. infoContainer.appendTo(frag);
  7461. return frag;
  7462. }
  7463. }, {
  7464. key: "createLoadingColumn",
  7465. value: function createLoadingColumn() {
  7466. return external_jQuery_default()("\n <div class=\"fjs-col leaf-col\" style=\"overflow: hidden;\">\n <div class=\"leaf-row\">\n <div class=\"grav-loading\"><div class=\"grav-loader\">Loading...</div></div>\n </div>\n </div>\n ");
  7467. }
  7468. }, {
  7469. key: "createErrorColumn",
  7470. value: function createErrorColumn(error) {
  7471. return external_jQuery_default()("\n <div class=\"fjs-col leaf-col\" style=\"overflow: hidden;\">\n <div class=\"leaf-row error\">\n <i class=\"fa fa-fw fa-warning\"></i>\n <span>".concat(error, "</span>\n </div>\n </div>\n "));
  7472. }
  7473. }]);
  7474. return Parents;
  7475. }();
  7476. var b64_encode_unicode = function b64_encode_unicode(str) {
  7477. return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) {
  7478. return String.fromCharCode('0x' + p1);
  7479. }));
  7480. };
  7481. var b64_decode_unicode = function b64_decode_unicode(str) {
  7482. return decodeURIComponent(atob(str).split('').map(function (c) {
  7483. return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
  7484. }).join(''));
  7485. };
  7486. var getExtraFormData = function getExtraFormData(container) {
  7487. var form = container.closest('form');
  7488. if (container.closest('[data-remodal-id]').length) {
  7489. form = external_jQuery_default()('form#blueprints');
  7490. }
  7491. var data = {};
  7492. var unique_id = form.find('[name="__unique_form_id__"]');
  7493. data['__form-name__'] = form.find('[name="__form-name__"]').val();
  7494. data['form-nonce'] = form.find('[name="form-nonce"]').val();
  7495. if (unique_id.length) {
  7496. data['__unique_form_id__'] = unique_id.val();
  7497. }
  7498. return data;
  7499. };
  7500. external_jQuery_default()(document).on('click', '[data-parents]', function (event) {
  7501. event.preventDefault();
  7502. event.stopPropagation();
  7503. var target = external_jQuery_default()(event.currentTarget);
  7504. var field = target.closest('.parents-wrapper').find('input[name]');
  7505. var fieldName = field.attr('name');
  7506. if (!field.length) {
  7507. fieldName = target.data('parents');
  7508. field = external_jQuery_default()("[name=\"".concat(target.data('parents'), "\"]")).first();
  7509. }
  7510. var modal = external_jQuery_default()("[data-remodal-id=\"".concat(target.data('remodalTarget') || 'parents', "\"]"));
  7511. var loader = modal.find('.grav-loading');
  7512. var content = modal.find('.parents-content');
  7513. loader.css('display', 'block');
  7514. content.html('');
  7515. external_jQuery_default().ajax({
  7516. url: "".concat(external_GravAdmin_namespaceObject.config.current_url),
  7517. method: 'post',
  7518. data: Object.assign({}, getExtraFormData(target), {
  7519. route: b64_encode_unicode(field.val()),
  7520. field: field.data('fieldName'),
  7521. action: 'getLevelListing',
  7522. 'admin-nonce': external_GravAdmin_namespaceObject.config.admin_nonce,
  7523. initial: true
  7524. }),
  7525. success: function success(response) {
  7526. loader.css('display', 'none');
  7527. if (response.status === 'error') {
  7528. content.html(response.message);
  7529. return true;
  7530. }
  7531. if (!parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))]) {
  7532. parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))] = new Parents(content, field, response.data);
  7533. } else {
  7534. parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))].finder.reload(response.data);
  7535. }
  7536. modal.data('parents', parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))]);
  7537. modal.data('parents-selectedField', field);
  7538. }
  7539. });
  7540. }); // apply finder selection to field
  7541. external_jQuery_default()(document).on('click', '[data-remodal-id].parents-container [data-parents-select]', function (event) {
  7542. var modal = external_jQuery_default()(event.currentTarget).closest('[data-remodal-id]');
  7543. var parents = modal.data('parents');
  7544. var selectedField = modal.data('parentsSelectedField');
  7545. var finder = parents.finder;
  7546. var field = parents.field;
  7547. var parentLabel = parents.parentLabel;
  7548. var parentName = parents.parentName;
  7549. var selection = finder.findLastActive().item[0];
  7550. var value = selection._item[finder.config.valueKey];
  7551. var name = selection._item[finder.config.labelKey];
  7552. if (selectedField.closest('.remodal').length) {
  7553. var index = field.index(selectedField);
  7554. selectedField.val(value);
  7555. external_jQuery_default()(parentLabel[index]).text(value);
  7556. external_jQuery_default()(parentName[index]).text(name);
  7557. } else {
  7558. field.val(value);
  7559. parentLabel.text(value);
  7560. parentName.text(name);
  7561. finder.config.defaultPath = value;
  7562. }
  7563. var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()("[data-remodal-id=\"".concat(modal.data('remodalId'), "\"]")).data('remodal')];
  7564. remodal.close();
  7565. });
  7566. ;// CONCATENATED MODULE: ./app/forms/fields/acl-picker.js
  7567. var acl_picker_body = external_jQuery_default()('body');
  7568. acl_picker_body.on('change', '[data-acl_picker] select', function (event) {
  7569. var target = external_jQuery_default()(event.currentTarget);
  7570. var value = target.val();
  7571. var item = target.closest('.permissions-item');
  7572. var inputs = item.find('input[type="checkbox"], input[type="radio"]');
  7573. var hidden = item.find('input[type="hidden"][name]');
  7574. var wrapper = target.closest('[data-acl_picker_id]');
  7575. var type = item.data('fieldType');
  7576. if (type === 'access') {
  7577. inputs.each(function (index, input) {
  7578. input = external_jQuery_default()(input);
  7579. var name = input.prop('name');
  7580. input.prop('name', name.replace(/(.*)(\[[^\]]*\])/, "$1[".concat(value, "]")));
  7581. });
  7582. } else if (type === 'permissions') {
  7583. var crudpContainer = item.find('[data-field-name]');
  7584. inputs.each(function (index, input) {
  7585. input = external_jQuery_default()(input);
  7586. var rand = Math.round(Math.random() * 500);
  7587. var name = crudpContainer.data('fieldName');
  7588. var id = input.prop('id').split('_').slice(0, -1).join('_') + "_".concat(value, "+").concat(rand); // const key = input.data('crudpKey');
  7589. hidden.prop('name', name.replace(/(.*)(\[[^\]]*\])/, "$1[".concat(value, "]")));
  7590. input.prop('id', id);
  7591. input.next('label').prop('for', id);
  7592. });
  7593. }
  7594. wrapper.find('.permissions-item .button.add-item')[!value ? 'addClass' : 'removeClass']('disabled').prop('disabled', !value ? 'disabled' : null);
  7595. });
  7596. acl_picker_body.on('input', 'input[data-crudp-key]', function (event) {
  7597. var target = external_jQuery_default()(event.currentTarget);
  7598. var container = target.closest('.crudp-container');
  7599. var hidden = container.find('input[type="hidden"][name]');
  7600. var key = target.data('crudpKey');
  7601. var json = JSON.parse(hidden.val() || '{}');
  7602. json[key] = target.val();
  7603. hidden.val(JSON.stringify(json));
  7604. });
  7605. acl_picker_body.on('click', '[data-acl_picker] .remove-item', function (event) {
  7606. event.preventDefault();
  7607. var target = external_jQuery_default()(event.currentTarget);
  7608. var container = target.closest('.permissions-item');
  7609. var wrapper = target.closest('[data-acl_picker_id]');
  7610. container.remove();
  7611. var empty = wrapper.find('.permissions-item').length === 1; // show the initial + button
  7612. if (empty) {
  7613. wrapper.find('.permissions-item.empty-list').removeClass('hidden');
  7614. }
  7615. });
  7616. acl_picker_body.on('click', '[data-acl_picker] .add-item', function (event) {
  7617. event.preventDefault();
  7618. var target = external_jQuery_default()(event.currentTarget);
  7619. var item = target.closest('.permissions-item');
  7620. var wrapper = target.closest('[data-acl_picker_id]');
  7621. var ID = wrapper.data('acl_picker_id');
  7622. var template = document.querySelector("template[data-id=\"acl_picker-".concat(ID, "\"]"));
  7623. var clone = external_jQuery_default()(template.content.firstElementChild).clone();
  7624. clone.insertAfter(item); // randomize ids
  7625. clone.find('.switch-toggle input[type="radio"]').each(function (index, input) {
  7626. input = external_jQuery_default()(input);
  7627. var id = input.prop('id');
  7628. var label = input.next('label');
  7629. var rand = (Date.now().toString(36) + Math.random().toString(36).substr(2, 5)).toLowerCase();
  7630. input.prop('id', "".concat(id).concat(rand));
  7631. label.prop('for', "".concat(id).concat(rand));
  7632. }); // hide the initial + button
  7633. wrapper.find('.permissions-item.empty-list').addClass('hidden'); // disable all + buttons until one is selected
  7634. wrapper.find('.permissions-item .button.add-item').addClass('disabled').prop('disabled', 'disabled');
  7635. });
  7636. ;// CONCATENATED MODULE: ./app/forms/fields/permissions.js
  7637. var permissions_body = external_jQuery_default()('body');
  7638. var radioSelector = '.permission-container.parent-section input[type="radio"]';
  7639. var handleParent = function handleParent(event) {
  7640. var target = external_jQuery_default()(event.currentTarget);
  7641. var value = target.val();
  7642. var container = target.closest('.parent-section');
  7643. var fieldset = container.next('fieldset');
  7644. var radios = fieldset.find("input[type=\"radio\"][value=\"".concat(value, "\"]"));
  7645. if (container.data('isLocked') !== false) {
  7646. container.data('isUpdating', true);
  7647. radios.each(function (index, radio) {
  7648. var ID = radio.id;
  7649. external_jQuery_default()(radio).siblings("[for=\"".concat(ID, "\"]")).trigger('click');
  7650. });
  7651. container.data('isUpdating', false);
  7652. }
  7653. };
  7654. var boundHandleParent = handleParent.bind(handleParent);
  7655. permissions_body.on('click', '.permission-container.parent-section label', function (event) {
  7656. var target = external_jQuery_default()(event.currentTarget);
  7657. var container = target.closest('.parent-section');
  7658. container.data('isLocked', true);
  7659. });
  7660. permissions_body.on('input', radioSelector, boundHandleParent);
  7661. permissions_body.on('input', '.permissions-container input[type="radio"][data-parent-id]', function (event) {
  7662. var target = external_jQuery_default()(event.currentTarget);
  7663. var parent = external_jQuery_default()("[for=\"".concat(target.data('parentId'), "\"]"));
  7664. var container = target.closest('fieldset').prev('.permission-container.parent-section');
  7665. if (container.data('isUpdating') === true) {
  7666. return true;
  7667. }
  7668. permissions_body.off('input', radioSelector, boundHandleParent);
  7669. container.data('isLocked', false);
  7670. parent.trigger('click');
  7671. permissions_body.on('input', radioSelector, boundHandleParent);
  7672. });
  7673. ;// CONCATENATED MODULE: ./app/forms/fields/indeterminate.js
  7674. document.addEventListener('click', function (event) {
  7675. if (document.querySelector('#pages-filters')) {
  7676. return true;
  7677. }
  7678. var wrapper = event.target.closest('.checkboxes.indeterminate');
  7679. if (wrapper) {
  7680. event.preventDefault();
  7681. var checkbox = wrapper.querySelector('input[type="checkbox"]:not([disabled])');
  7682. var checkStatus = wrapper.dataset._checkStatus;
  7683. wrapper.classList.remove('status-checked', 'status-unchecked', 'status-indeterminate');
  7684. switch (checkStatus) {
  7685. // checked, going indeterminate
  7686. case '1':
  7687. wrapper.dataset._checkStatus = '2';
  7688. checkbox.indeterminate = true;
  7689. checkbox.checked = false;
  7690. checkbox.value = 0;
  7691. wrapper.classList.add('status-indeterminate');
  7692. break;
  7693. // indeterminate, going unchecked
  7694. case '2':
  7695. wrapper.dataset._checkStatus = '0';
  7696. checkbox.indeterminate = false;
  7697. checkbox.checked = false;
  7698. checkbox.value = '';
  7699. wrapper.classList.add('status-unchecked');
  7700. break;
  7701. // unchecked, going checked
  7702. case '0':
  7703. default:
  7704. wrapper.dataset._checkStatus = '1';
  7705. checkbox.indeterminate = false;
  7706. checkbox.checked = true;
  7707. checkbox.value = 1;
  7708. wrapper.classList.add('status-checked');
  7709. break;
  7710. } // const input = new CustomEvent('input', { detail: { target: checkbox }});
  7711. // document.dispatchEvent(input);
  7712. external_jQuery_default()(checkbox).trigger('input');
  7713. }
  7714. });
  7715. (document.querySelectorAll('input[type="checkbox"][indeterminate="true"]') || []).forEach(function (input) {
  7716. input.indeterminate = true;
  7717. });
  7718. ;// CONCATENATED MODULE: ./app/forms/fields/mediapicker.js
  7719. external_jQuery_default()(function () {
  7720. var modal = '';
  7721. var body = external_jQuery_default()('body'); // Thumb Resizer
  7722. external_jQuery_default()(document).on('input change', '.media-container .media-range', function (event) {
  7723. var target = external_jQuery_default()(event.currentTarget);
  7724. var container = target.closest('.remodal');
  7725. var cards = container.find('.media-container div.card-item');
  7726. var width = target.val() + 'px';
  7727. cards.each(function () {
  7728. external_jQuery_default()(this).css('width', width);
  7729. });
  7730. });
  7731. body.on('click', '[data-mediapicker-modal-trigger]', function (event) {
  7732. var element = external_jQuery_default()(event.currentTarget);
  7733. var modal_identifier = external_jQuery_default()(this).data('grav-mediapicker-unique-identifier');
  7734. var modal_element = body.find("[data-remodal-unique-identifier=\"".concat(modal_identifier, "\"]"));
  7735. modal = (external_jQuery_default()).remodal.lookup[modal_element.data('remodal')];
  7736. if (!modal) {
  7737. modal_element.remodal();
  7738. modal = (external_jQuery_default()).remodal.lookup[modal_element.data('remodal')];
  7739. }
  7740. modal.open();
  7741. modal.dataField = element.find('input'); // load all media
  7742. modal_element.find('.js__files').trigger('fillView');
  7743. setTimeout(function () {
  7744. return tree_Instance.reload();
  7745. }, 100);
  7746. });
  7747. /* handle media modal click actions */
  7748. body.on('click', '[data-remodal-mediapicker] .media-container.in-modal .admin-media-details a', function (event) {
  7749. event.preventDefault();
  7750. event.stopPropagation();
  7751. var val = external_jQuery_default()(event.target).parents('.js__media-element').data('file-url');
  7752. var string = val.replace(/ /g, '%20');
  7753. modal.dataField.val(string);
  7754. modal.close();
  7755. });
  7756. });
  7757. ;// CONCATENATED MODULE: ./app/forms/fields/multilevel.js
  7758. external_jQuery_default()(function () {
  7759. var getField = function getField(level, name) {
  7760. var levelMargin = level * 50;
  7761. var top = level === 0 ? 'top' : '';
  7762. var the_name = 'name="' + name + '"';
  7763. if (level === 0) {
  7764. // top
  7765. the_name = 'data-attr-name="' + name + '"';
  7766. }
  7767. var marginDir = window.getComputedStyle(document.body).direction === 'ltr' ? 'margin-left' : 'margin-right';
  7768. var field = "\n <div class=\"element-wrapper\">\n <div class=\"form-row array-field-value_only js__multilevel-field ".concat(top, "\"\n data-grav-array-type=\"row\">\n <input\n type=\"text\"\n ").concat(the_name, "\n placeholder=\"Enter value\"\n style=\"").concat(marginDir, ": ").concat(levelMargin, "px\"\n value=\"\" />\n\n <span class=\"fa fa-minus js__remove-item\"></span>\n <span class=\"fa fa-plus js__add-sibling hidden\" data-level=\"").concat(level, "\" ></span>\n <span class=\"fa fa-plus-circle js__add-children hidden\" data-level=\"").concat(level, "\"></span>\n </div>\n </div>\n ");
  7769. return field;
  7770. };
  7771. var hasChildInputs = function hasChildInputs($element) {
  7772. if ($element.attr('name')) {
  7773. return false;
  7774. }
  7775. return true;
  7776. };
  7777. var getTopItems = function getTopItems(element) {
  7778. return external_jQuery_default()(element + ' .js__multilevel-field.top');
  7779. };
  7780. var refreshControls = function refreshControls(unique_identifier) {
  7781. var element = '[data-grav-multilevel-field]';
  7782. if (unique_identifier) {
  7783. element = '[data-grav-multilevel-field][data-id="' + unique_identifier + '"]';
  7784. }
  7785. var hideButtons = function hideButtons() {
  7786. external_jQuery_default()(element + ' .js__add-sibling').addClass('hidden');
  7787. external_jQuery_default()(element + ' .js__add-children').addClass('hidden');
  7788. };
  7789. var restoreAddSiblingButtons = function restoreAddSiblingButtons() {
  7790. external_jQuery_default()(element + ' .children-wrapper').each(function () {
  7791. var elements = external_jQuery_default()(this).children();
  7792. elements.last().each(function () {
  7793. var field = external_jQuery_default()(this);
  7794. if (!external_jQuery_default()(this).hasClass('js__multilevel-field')) {
  7795. field = external_jQuery_default()(this).find('.js__multilevel-field').first();
  7796. }
  7797. field.find('.js__add-sibling').removeClass('hidden');
  7798. });
  7799. }); // add sibling to the last top element
  7800. external_jQuery_default()(element + ' .js__multilevel-field.top').last().find('.js__add-sibling').removeClass('hidden');
  7801. };
  7802. var restoreAddChildrenButtons = function restoreAddChildrenButtons() {
  7803. external_jQuery_default()(element + ' .js__multilevel-field').each(function () {
  7804. if (external_jQuery_default()(this).siblings('.children-wrapper').length === 0 || external_jQuery_default()(this).siblings('.children-wrapper').find('.js__multilevel-field').length === 0) {
  7805. external_jQuery_default()(this).find('.js__add-children').removeClass('hidden');
  7806. }
  7807. });
  7808. };
  7809. var preventRemovingLastTopItem = function preventRemovingLastTopItem() {
  7810. var top_items = getTopItems(element);
  7811. if (top_items.length === 1) {
  7812. top_items.first().find('.js__remove-item').addClass('hidden');
  7813. }
  7814. };
  7815. hideButtons();
  7816. restoreAddSiblingButtons();
  7817. restoreAddChildrenButtons();
  7818. preventRemovingLastTopItem();
  7819. };
  7820. var changeAllOccurrencesInTree = function changeAllOccurrencesInTree($el, current_name, new_name) {
  7821. $el.parents('[data-grav-multilevel-field]').find('input').each(function () {
  7822. var $input = external_jQuery_default()(this);
  7823. if ($input.attr('name')) {
  7824. $input.attr('name', $input.attr('name').replace(current_name, new_name));
  7825. }
  7826. if ($input.attr('data-attr-name')) {
  7827. $input.attr('data-attr-name', $input.attr('data-attr-name').replace(current_name, new_name));
  7828. }
  7829. });
  7830. };
  7831. external_jQuery_default()(document).ready(function () {
  7832. refreshControls();
  7833. });
  7834. external_jQuery_default()(document).on('mouseleave', '[data-grav-multilevel-field]', function (event) {
  7835. var top_items = getTopItems('[data-id="' + external_jQuery_default()(this).data('id') + '"]');
  7836. var has_top_items_without_children = false;
  7837. var element_content = '';
  7838. top_items.each(function () {
  7839. var item = external_jQuery_default()(this);
  7840. if (external_jQuery_default()(item).siblings('.children-wrapper').find('input').length === 0) {
  7841. has_top_items_without_children = true;
  7842. element_content = item.find('input').val();
  7843. }
  7844. });
  7845. if (has_top_items_without_children) {
  7846. if (element_content) {
  7847. alert('Warning: if you save now, the element ' + element_content + ', without children, will be removed, because it\'s invalid YAML');
  7848. } else {
  7849. alert('Warning: if you save now, the top elements without children will be removed, because it\'s invalid YAML');
  7850. }
  7851. }
  7852. });
  7853. external_jQuery_default()(document).on('click', '[data-grav-multilevel-field] .js__add-children', function (event) {
  7854. var element = external_jQuery_default()(this);
  7855. var unique_container_id = element.closest('.js__multilevel-field').data('id');
  7856. var level = element.data('level') + 1;
  7857. var getParentOfElement = function getParentOfElement(element) {
  7858. var parent = element.closest('.js__multilevel-field').parent().first();
  7859. if (parent.find('.children-wrapper').length === 0) {
  7860. external_jQuery_default()(parent).append('<div class="children-wrapper"></div>');
  7861. }
  7862. parent = parent.find('.children-wrapper').first();
  7863. return parent;
  7864. };
  7865. var getNameFromParentInput = function getNameFromParentInput(parentInput, attr) {
  7866. if (parentInput.hasClass('children-wrapper')) {
  7867. parentInput = parentInput.siblings('.js__multilevel-field').first().find('input');
  7868. }
  7869. return parentInput.attr(attr) + '[' + parentInput.val() + ']';
  7870. };
  7871. var getInputFromChildrenWrapper = function getInputFromChildrenWrapper(parentChildrenWrapper) {
  7872. return parentChildrenWrapper.siblings('.js__multilevel-field').first().find('input');
  7873. };
  7874. var parentChildrenWrapper = getParentOfElement(element);
  7875. var parentInput = getInputFromChildrenWrapper(parentChildrenWrapper);
  7876. var attr = 'name';
  7877. if (parentInput.closest('.js__multilevel-field').hasClass('top')) {
  7878. attr = 'data-attr-name';
  7879. }
  7880. parentInput.attr(attr, parentInput.attr(attr).replace('[]', ''));
  7881. var name = getNameFromParentInput(parentInput, attr);
  7882. var field = getField(level, name);
  7883. external_jQuery_default()(parentChildrenWrapper).append(field);
  7884. refreshControls(unique_container_id);
  7885. });
  7886. external_jQuery_default()(document).on('click', '[data-grav-multilevel-field] .js__add-sibling', function (event) {
  7887. var element = external_jQuery_default()(this);
  7888. var unique_container_id = element.closest('.js__multilevel-field').data('id');
  7889. var level = element.data('level');
  7890. element.closest('.children-wrapper').find('.js__add-sibling').addClass('hidden');
  7891. var sibling = null;
  7892. var is_top = false;
  7893. if (element.closest('.js__multilevel-field').hasClass('top')) {
  7894. is_top = true;
  7895. }
  7896. if (is_top) {
  7897. sibling = element.closest('.js__multilevel-field').first().find('input').last();
  7898. } else {
  7899. sibling = element.siblings('input').first();
  7900. if (!sibling) {
  7901. sibling = element.closest('.children-wrapper').first().find('input').last();
  7902. }
  7903. }
  7904. var getParentOfElement = function getParentOfElement(element) {
  7905. var parent = element.closest('.js__multilevel-field').parent().first();
  7906. if (!parent.hasClass('element-wrapper')) {
  7907. if (parent.find('.element-wrapper').length === 0) {
  7908. external_jQuery_default()(parent).append('<div class="element-wrapper"></div>');
  7909. }
  7910. parent = parent.find('.element-wrapper').first();
  7911. }
  7912. return parent;
  7913. };
  7914. var getNameFromSibling = function getNameFromSibling(parent, sibling) {
  7915. var is_top = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7916. var name = sibling.attr('name');
  7917. if (hasChildInputs(sibling)) {
  7918. var val = sibling.data('attr-name') + '[]';
  7919. sibling.removeAttr('name');
  7920. return val;
  7921. }
  7922. var last_index = name.lastIndexOf('[');
  7923. var almost_there = name.substr(last_index + 1);
  7924. var last_tag = almost_there.substr(0, almost_there.length - 1);
  7925. if (external_jQuery_default().isNumeric(last_tag)) {
  7926. name = name.replace('[' + last_tag + ']', '[' + (parseInt(last_tag, 10) + 1) + ']');
  7927. } else {
  7928. if (is_top) {
  7929. name = name.replace('[' + last_tag + ']', '');
  7930. } else {
  7931. name = name + '[1]'; // change sibling name attr if necessary
  7932. if (sibling.attr('name').slice('-2') !== '[0]') {
  7933. changeAllOccurrencesInTree(sibling, sibling.attr('name'), sibling.attr('name') + '[0]');
  7934. }
  7935. }
  7936. }
  7937. return name;
  7938. };
  7939. var parent = getParentOfElement(element);
  7940. var name = getNameFromSibling(parent, sibling, is_top);
  7941. var field = getField(level, name);
  7942. external_jQuery_default()(field).insertAfter(parent);
  7943. refreshControls(unique_container_id);
  7944. });
  7945. external_jQuery_default()(document).on('click', '[data-grav-multilevel-field] .js__remove-item', function (event) {
  7946. external_jQuery_default()(this).parents('.element-wrapper').first().remove();
  7947. var unique_container_id = external_jQuery_default()(this).closest('.js__multilevel-field').data('id');
  7948. refreshControls(unique_container_id);
  7949. }); // Store old value before editing a field
  7950. external_jQuery_default()(document).on('focusin', '[data-grav-multilevel-field] input', function (event) {
  7951. external_jQuery_default()(this).data('current-value', external_jQuery_default()(this).val());
  7952. }); // Handle field edited event
  7953. external_jQuery_default()(document).on('change', '[data-grav-multilevel-field] input', function (event) {
  7954. var $el = external_jQuery_default()(this);
  7955. var old_value = $el.data('current-value');
  7956. var new_value = $el.val();
  7957. var full_name = $el.attr('name') || $el.attr('data-attr-name'); // first-level items have `data-attr-name` instead of `name`
  7958. var old_name_attr = full_name + '[' + old_value + ']';
  7959. var new_name_attr = full_name + '[' + new_value + ']';
  7960. changeAllOccurrencesInTree($el, old_name_attr, new_name_attr);
  7961. });
  7962. });
  7963. ;// CONCATENATED MODULE: ./app/forms/fields/text.js
  7964. external_jQuery_default()(document).ready(function () {
  7965. external_jQuery_default()('.copy-to-clipboard').click(function (event) {
  7966. var $tempElement = external_jQuery_default()('<input>');
  7967. external_jQuery_default()('body').append($tempElement);
  7968. $tempElement.val(external_jQuery_default()(this).prev('input').val()).select();
  7969. document.execCommand('Copy');
  7970. $tempElement.remove();
  7971. external_jQuery_default()(this).attr('data-hint', 'Copied to clipboard!').addClass('hint--left');
  7972. });
  7973. });
  7974. ;// CONCATENATED MODULE: ./app/forms/fields/range.js
  7975. external_jQuery_default()(document).on('input', '[type="range"].rangefield, [type="number"].rangefield', function (event) {
  7976. var target = external_jQuery_default()(event.currentTarget);
  7977. var type = target.attr('type').toLowerCase();
  7978. var sibling = type === 'range' ? 'number' : 'range';
  7979. var feedback = target.siblings("[type=\"".concat(sibling, "\"].rangefield"));
  7980. feedback.val(target.val());
  7981. });
  7982. ;// CONCATENATED MODULE: ./app/forms/fields/elements.js
  7983. external_jQuery_default()(document).on('change', '[data-grav-elements] select', function (event) {
  7984. var target = external_jQuery_default()(event.currentTarget);
  7985. var value = target.val();
  7986. var id = target.closest('[data-grav-elements]').data('gravElements');
  7987. external_jQuery_default()("[id^=\"".concat(id, "_\"]")).css('display', 'none');
  7988. external_jQuery_default()("[id=\"".concat(id, "__").concat(value, "\"]")).css('display', 'inherit');
  7989. });
  7990. external_jQuery_default()('[data-grav-elements] select').trigger('change');
  7991. ;// CONCATENATED MODULE: ./app/forms/fields/index.js
  7992. /* harmony default export */ const fields = ({
  7993. FilepickerField: {
  7994. FilepickerField: FilePickerField,
  7995. Instance: filepicker_Instance
  7996. },
  7997. SelectizeField: {
  7998. SelectizeField: SelectizeField,
  7999. Instance: selectize_Instance
  8000. },
  8001. ArrayField: {
  8002. ArrayField: ArrayField,
  8003. Instance: array_Instance
  8004. },
  8005. CollectionsField: {
  8006. CollectionsField: CollectionsField,
  8007. Instance: collections_Instance
  8008. },
  8009. DateTimeField: {
  8010. DateTimeField: DateTimeField,
  8011. Instance: datetime_Instance
  8012. },
  8013. EditorField: {
  8014. EditorField: EditorField,
  8015. Instance: editor_Instance
  8016. },
  8017. ColorpickerField: {
  8018. ColorpickerField: ColorpickerField,
  8019. Instance: colorpicker_Instance
  8020. },
  8021. FilesField: {
  8022. FilesField: FilesField,
  8023. Instance: Instance
  8024. },
  8025. FolderField: {
  8026. Regenerate: fields_folder
  8027. },
  8028. SelectUniqueField: {
  8029. SelectUniqueField: SelectUniqueField,
  8030. Instance: selectunique_Instance
  8031. },
  8032. IconpickerField: {
  8033. IconpickerField: IconpickerField,
  8034. Instance: iconpicker_Instance
  8035. },
  8036. CronField: {
  8037. CronField: CronField,
  8038. Instance: cron_Instance
  8039. },
  8040. ParentsField: {
  8041. ParentsField: Parents,
  8042. Instance: parents_Instances
  8043. }
  8044. });
  8045. ;// CONCATENATED MODULE: ./app/forms/index.js
  8046. /* harmony default export */ const app_forms = ({
  8047. Form: {
  8048. Form: Form,
  8049. Instance: form_Instance
  8050. },
  8051. Fields: fields,
  8052. FormState: {
  8053. FormState: FormState,
  8054. Instance: state_Instance
  8055. }
  8056. });
  8057. ;// CONCATENATED MODULE: ./app/utils/packages.js
  8058. function packages_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8059. function packages_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); } }
  8060. function packages_createClass(Constructor, protoProps, staticProps) { if (protoProps) packages_defineProperties(Constructor.prototype, protoProps); if (staticProps) packages_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  8061. var Sorter = /*#__PURE__*/function () {
  8062. function Sorter() {
  8063. packages_classCallCheck(this, Sorter);
  8064. }
  8065. packages_createClass(Sorter, [{
  8066. key: "getElements",
  8067. value: function getElements(elements, container) {
  8068. this.elements = elements || document.querySelectorAll('[data-gpm-plugin], [data-gpm-theme]');
  8069. this.container = container || document.querySelector('.gpm-plugins > table > tbody, .gpm-themes > .themes.card-row');
  8070. return this.elements;
  8071. }
  8072. }, {
  8073. key: "byCommon",
  8074. value: function byCommon() {
  8075. var _this = this;
  8076. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  8077. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  8078. var elements = this.getElements();
  8079. this.removeGumroad();
  8080. Array.from(elements).sort(function (a, b) {
  8081. var A = a.dataset[data].toString().toLowerCase();
  8082. var B = b.dataset[data].toString().toLowerCase();
  8083. return Sorter.sort(A, B, direction);
  8084. }).forEach(function (element) {
  8085. _this.container.appendChild(element);
  8086. });
  8087. this.addGumroad();
  8088. return this.container;
  8089. }
  8090. }, {
  8091. key: "byName",
  8092. value: function byName() {
  8093. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  8094. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmName';
  8095. return this.byCommon(direction, data);
  8096. }
  8097. }, {
  8098. key: "byAuthor",
  8099. value: function byAuthor() {
  8100. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  8101. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmAuthor';
  8102. return this.byCommon(direction, data);
  8103. }
  8104. }, {
  8105. key: "byOfficial",
  8106. value: function byOfficial() {
  8107. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  8108. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmOfficial';
  8109. return this.byCommon(direction, data);
  8110. }
  8111. }, {
  8112. key: "byPremium",
  8113. value: function byPremium() {
  8114. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  8115. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmPremium';
  8116. return this.byCommon(direction, data);
  8117. }
  8118. }, {
  8119. key: "byReleaseDate",
  8120. value: function byReleaseDate() {
  8121. var _this2 = this;
  8122. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  8123. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmReleaseDate';
  8124. var elements = this.getElements();
  8125. this.removeGumroad();
  8126. Array.from(elements).sort(function (a, b) {
  8127. var A = new Date(a.dataset[data]).getTime();
  8128. var B = new Date(b.dataset[data]).getTime();
  8129. return Sorter.sort(A, B, direction === 'asc' ? 'desc' : 'asc');
  8130. }).forEach(function (element) {
  8131. _this2.container.appendChild(element);
  8132. });
  8133. this.addGumroad();
  8134. return this.container;
  8135. }
  8136. }, {
  8137. key: "byUpdatable",
  8138. value: function byUpdatable() {
  8139. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  8140. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmUpdatable';
  8141. return this.byCommon(direction, data);
  8142. }
  8143. }, {
  8144. key: "byEnabled",
  8145. value: function byEnabled() {
  8146. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  8147. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmEnabled';
  8148. return this.byCommon(direction, data);
  8149. }
  8150. }, {
  8151. key: "byTesting",
  8152. value: function byTesting() {
  8153. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  8154. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmTesting';
  8155. return this.byCommon(direction, data);
  8156. }
  8157. }, {
  8158. key: "addGumroad",
  8159. value: function addGumroad() {
  8160. if (window.GumroadOverlay) {
  8161. window.GumroadOverlay.startNodeAdditionObserver();
  8162. }
  8163. }
  8164. }, {
  8165. key: "removeGumroad",
  8166. value: function removeGumroad() {
  8167. if (window.GumroadOverlay) {
  8168. window.GumroadOverlay.nodeAdditionObserver.disconnect();
  8169. }
  8170. }
  8171. }], [{
  8172. key: "sort",
  8173. value: function sort(A, B) {
  8174. var direction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'asc';
  8175. if (A > B) {
  8176. return direction === 'asc' ? 1 : -1;
  8177. }
  8178. if (A < B) {
  8179. return direction === 'asc' ? -1 : 1;
  8180. }
  8181. return 0;
  8182. }
  8183. }]);
  8184. return Sorter;
  8185. }();
  8186. var Packages = /*#__PURE__*/function () {
  8187. function Packages() {
  8188. packages_classCallCheck(this, Packages);
  8189. this.Sort = new Sorter();
  8190. }
  8191. packages_createClass(Packages, [{
  8192. key: "addDependenciesToList",
  8193. value: function addDependenciesToList(dependencies) {
  8194. var slug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  8195. dependencies.forEach(function (dependency) {
  8196. Packages.addDependencyToList('plugin', dependency.name || dependency, slug);
  8197. });
  8198. }
  8199. }, {
  8200. key: "removePackage",
  8201. value: function removePackage(type, slug) {
  8202. var _this3 = this;
  8203. var url = Packages.getRemovePackageUrl(type);
  8204. utils_request(url, {
  8205. method: 'post',
  8206. body: {
  8207. "package": slug
  8208. }
  8209. }, function (response) {
  8210. if (response.status === 'success') {
  8211. external_jQuery_default()('.remove-package-confirm').addClass('hidden');
  8212. if (response.dependencies && response.dependencies.length > 0) {
  8213. _this3.addDependenciesToList(response.dependencies);
  8214. external_jQuery_default()('.remove-package-dependencies').removeClass('hidden');
  8215. } else {
  8216. external_jQuery_default()('.remove-package-done').removeClass('hidden');
  8217. } // The package was removed. When the modal closes, move to the packages list
  8218. external_jQuery_default()(document).on('closing', '[data-remodal-id="remove-package"]', function () {
  8219. Packages.getBackToList(type);
  8220. });
  8221. } else {
  8222. external_jQuery_default()('.remove-package-confirm').addClass('hidden');
  8223. external_jQuery_default()('.remove-package-error').removeClass('hidden');
  8224. }
  8225. });
  8226. }
  8227. }, {
  8228. key: "reinstallPackage",
  8229. value: function reinstallPackage(type, slug, package_name, current_version) {
  8230. external_jQuery_default()('.button-bar button').addClass('hidden');
  8231. external_jQuery_default()('.button-bar .spinning-wheel').removeClass('hidden');
  8232. var url = Packages.getReinstallPackageUrl(type);
  8233. utils_request(url, {
  8234. method: 'post',
  8235. body: {
  8236. slug: slug,
  8237. type: type,
  8238. package_name: package_name,
  8239. current_version: current_version
  8240. }
  8241. }, function (response) {
  8242. if (response.status === 'success') {
  8243. external_jQuery_default()('.reinstall-package-confirm').addClass('hidden');
  8244. external_jQuery_default()('.reinstall-package-done').removeClass('hidden');
  8245. } else {
  8246. external_jQuery_default()('.reinstall-package-confirm').addClass('hidden');
  8247. external_jQuery_default()('.reinstall-package-error').removeClass('hidden');
  8248. }
  8249. window.location.reload();
  8250. });
  8251. }
  8252. }, {
  8253. key: "removeDependency",
  8254. value: function removeDependency(type, slug, button) {
  8255. var _this4 = this;
  8256. var url = Packages.getRemovePackageUrl(type);
  8257. utils_request(url, {
  8258. method: 'post',
  8259. body: {
  8260. "package": slug
  8261. }
  8262. }, function (response) {
  8263. if (response.status === 'success') {
  8264. button.removeClass('button');
  8265. button.replaceWith(external_jQuery_default()('<span>Removed successfully</span>'));
  8266. if (response.dependencies && response.dependencies.length > 0) {
  8267. _this4.addDependenciesToList(response.dependencies, slug);
  8268. }
  8269. }
  8270. });
  8271. }
  8272. }, {
  8273. key: "getPackagesDependencies",
  8274. value: function getPackagesDependencies(type, slugs, finishedLoadingCallback) {
  8275. var url = Packages.getGetPackagesDependenciesUrl(type);
  8276. utils_request(url, {
  8277. method: 'post',
  8278. body: {
  8279. packages: slugs
  8280. }
  8281. }, function (response) {
  8282. finishedLoadingCallback();
  8283. if (response.status === 'success') {
  8284. if (response.dependencies) {
  8285. var hasDependencies = false;
  8286. for (var dependency in response.dependencies) {
  8287. if (response.dependencies.hasOwnProperty(dependency)) {
  8288. if (dependency === 'grav') {
  8289. continue;
  8290. }
  8291. hasDependencies = true;
  8292. var dependencyName = dependency;
  8293. var action = response.dependencies[dependency];
  8294. Packages.addNeededDependencyToList(action, dependencyName);
  8295. }
  8296. }
  8297. if (hasDependencies) {
  8298. external_jQuery_default()('[data-packages-modal] .install-dependencies-package-container').removeClass('hidden');
  8299. } else {
  8300. external_jQuery_default()('[data-packages-modal] .install-package-container').removeClass('hidden');
  8301. }
  8302. } else {
  8303. external_jQuery_default()('[data-packages-modal] .install-package-container').removeClass('hidden');
  8304. }
  8305. } else {
  8306. external_jQuery_default()('[data-packages-modal] .install-package-error').removeClass('hidden');
  8307. }
  8308. });
  8309. }
  8310. }, {
  8311. key: "installDependenciesOfPackages",
  8312. value: function installDependenciesOfPackages(type, slugs, callbackSuccess, callbackError) {
  8313. var url = Packages.getInstallDependenciesOfPackagesUrl(type);
  8314. utils_request(url, {
  8315. method: 'post',
  8316. body: {
  8317. packages: slugs
  8318. }
  8319. }, callbackSuccess);
  8320. }
  8321. }, {
  8322. key: "installPackages",
  8323. value: function installPackages(type, slugs, callbackSuccess) {
  8324. var url = Packages.getInstallPackageUrl(type);
  8325. __webpack_require__.g.Promise.all(slugs.map(function (slug) {
  8326. return new __webpack_require__.g.Promise(function (resolve, reject) {
  8327. utils_request(url, {
  8328. method: 'post',
  8329. body: {
  8330. "package": slug,
  8331. type: type
  8332. }
  8333. }, function (response) {
  8334. resolve(response);
  8335. });
  8336. });
  8337. })).then(callbackSuccess);
  8338. }
  8339. }, {
  8340. key: "handleGettingPackageDependencies",
  8341. value: function handleGettingPackageDependencies(type, event) {
  8342. var action = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'update';
  8343. var slugs = Packages.getSlugsFromEvent(event);
  8344. if (!slugs) {
  8345. alert('No slug set');
  8346. return;
  8347. } // Cleanup
  8348. external_jQuery_default()('.packages-names-list').html('');
  8349. external_jQuery_default()('.install-dependencies-package-container li').remove();
  8350. slugs.forEach(function (slug) {
  8351. if (action === 'update') {
  8352. var current_version = '';
  8353. var available_version = '';
  8354. var _name = '';
  8355. var resources = gpm_Instance.payload.payload.resources;
  8356. if (resources.plugins[slug]) {
  8357. available_version = resources.plugins[slug].available;
  8358. current_version = resources.plugins[slug].version;
  8359. _name = resources.plugins[slug].name;
  8360. } else if (resources.themes[slug]) {
  8361. available_version = resources.themes[slug].available;
  8362. current_version = resources.themes[slug].version;
  8363. _name = resources.themes[slug].name;
  8364. }
  8365. external_jQuery_default()('.packages-names-list').append("<li>".concat(_name ? _name : slug, ", ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FROM, " v<strong>").concat(current_version, "</strong> ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.TO, " v<strong>").concat(available_version, "</strong></li>"));
  8366. } else {
  8367. external_jQuery_default()('.packages-names-list').append("<li>".concat(name ? name : slug, "</li>"));
  8368. }
  8369. });
  8370. event.preventDefault();
  8371. event.stopPropagation(); // fix mismatching types when sharing install modal between plugins/themes
  8372. var query = '[data-packages-modal] [data-theme-action], [data-packages-modal] [data-plugin-action]';
  8373. var data = external_jQuery_default()(query).data('themeAction') || external_jQuery_default()(query).data('pluginAction');
  8374. external_jQuery_default()(query).removeAttr('data-theme-action').removeAttr('data-plugin-action').attr("data-".concat(type, "-action"), data); // Restore original state
  8375. external_jQuery_default()('[data-packages-modal] .loading').removeClass('hidden');
  8376. external_jQuery_default()('[data-packages-modal] .install-dependencies-package-container').addClass('hidden');
  8377. external_jQuery_default()('[data-packages-modal] .install-package-container').addClass('hidden');
  8378. external_jQuery_default()('[data-packages-modal] .installing-dependencies').addClass('hidden');
  8379. external_jQuery_default()('[data-packages-modal] .installing-package').addClass('hidden');
  8380. external_jQuery_default()('[data-packages-modal] .installation-complete').addClass('hidden');
  8381. external_jQuery_default()('[data-packages-modal] .install-package-error').addClass('hidden');
  8382. this.getPackagesDependencies(type, slugs, function () {
  8383. var slugs_string = slugs.join();
  8384. external_jQuery_default()("[data-packages-modal] [data-".concat(type, "-action=\"install-dependencies-and-package\"]")).attr('data-packages-slugs', slugs_string);
  8385. external_jQuery_default()("[data-packages-modal] [data-".concat(type, "-action=\"install-package\"]")).attr('data-packages-slugs', slugs_string);
  8386. external_jQuery_default()('[data-packages-modal] .loading').addClass('hidden');
  8387. });
  8388. }
  8389. }, {
  8390. key: "handleInstallingDependenciesAndPackage",
  8391. value: function handleInstallingDependenciesAndPackage(type, event) {
  8392. var _this5 = this;
  8393. var slugs = Packages.getSlugsFromEvent(event);
  8394. event.preventDefault();
  8395. event.stopPropagation();
  8396. external_jQuery_default()('[data-packages-modal] .install-dependencies-package-container').addClass('hidden');
  8397. external_jQuery_default()('[data-packages-modal] .install-package-container').addClass('hidden');
  8398. external_jQuery_default()('[data-packages-modal] .installing-dependencies').removeClass('hidden');
  8399. this.installDependenciesOfPackages(type, slugs, function (response) {
  8400. external_jQuery_default()('[data-packages-modal] .installing-dependencies').addClass('hidden');
  8401. external_jQuery_default()('[data-packages-modal] .installing-package').removeClass('hidden');
  8402. _this5.installPackages(type, slugs, function () {
  8403. external_jQuery_default()('[data-packages-modal] .installing-package').addClass('hidden');
  8404. external_jQuery_default()('[data-packages-modal] .installation-complete').removeClass('hidden');
  8405. if (response.status === 'error') {
  8406. var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-packages-modal]').data('remodal')];
  8407. remodal.close();
  8408. return;
  8409. }
  8410. setTimeout(function () {
  8411. if (slugs.length === 1) {
  8412. __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s/").concat(slugs[0]);
  8413. } else {
  8414. __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s");
  8415. }
  8416. }, 1000);
  8417. });
  8418. });
  8419. }
  8420. }, {
  8421. key: "handleInstallingPackage",
  8422. value: function handleInstallingPackage(type, event) {
  8423. var slugs = Packages.getSlugsFromEvent(event);
  8424. event.preventDefault();
  8425. event.stopPropagation();
  8426. external_jQuery_default()('[data-packages-modal] .install-package-container').addClass('hidden');
  8427. external_jQuery_default()('[data-packages-modal] .installing-package').removeClass('hidden');
  8428. this.installPackages(type, slugs, function (response) {
  8429. external_jQuery_default()('[data-packages-modal] .installing-package').addClass('hidden');
  8430. external_jQuery_default()('[data-packages-modal] .installation-complete').removeClass('hidden');
  8431. var errors = Array.from(response).filter(function (r) {
  8432. return r.status === 'error';
  8433. });
  8434. if (errors && errors.length) {
  8435. var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-packages-modal].remodal-is-opened').data('remodal')];
  8436. remodal.close();
  8437. return;
  8438. }
  8439. if (slugs.length === 1) {
  8440. __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s/").concat(slugs[0]);
  8441. } else {
  8442. __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s");
  8443. }
  8444. });
  8445. }
  8446. }, {
  8447. key: "handleRemovingPackage",
  8448. value: function handleRemovingPackage(type, event) {
  8449. var slug = external_jQuery_default()(event.target).attr('data-packages-slugs');
  8450. event.preventDefault();
  8451. event.stopPropagation();
  8452. this.removePackage(type, slug);
  8453. }
  8454. }, {
  8455. key: "handleReinstallPackage",
  8456. value: function handleReinstallPackage(type, event) {
  8457. var target = external_jQuery_default()(event.target);
  8458. var slug = target.attr('data-package-slug');
  8459. var package_name = target.attr('data-package-name');
  8460. var current_version = target.attr('data-package-current-version');
  8461. event.preventDefault();
  8462. event.stopPropagation();
  8463. this.reinstallPackage(type, slug, package_name, current_version);
  8464. }
  8465. }, {
  8466. key: "handleRemovingDependency",
  8467. value: function handleRemovingDependency(type, event) {
  8468. var slug = external_jQuery_default()(event.target).attr('data-dependency-slug');
  8469. var button = external_jQuery_default()(event.target);
  8470. event.preventDefault();
  8471. event.stopPropagation();
  8472. this.removeDependency(type, slug, button);
  8473. }
  8474. }], [{
  8475. key: "getBackToList",
  8476. value: function getBackToList(type) {
  8477. __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s");
  8478. }
  8479. }, {
  8480. key: "addDependencyToList",
  8481. value: function addDependencyToList(type, dependency) {
  8482. var slug = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  8483. if (['admin', 'form', 'login', 'email', 'grav'].indexOf(dependency) !== -1) {
  8484. return;
  8485. }
  8486. var container = external_jQuery_default()('.package-dependencies-container');
  8487. var text = "".concat(dependency, " <a href=\"#\" class=\"button\" data-dependency-slug=\"").concat(dependency, "\" data-").concat(type, "-action=\"remove-dependency-package\">Remove</a>");
  8488. if (slug) {
  8489. text += " (was needed by ".concat(slug, ")");
  8490. }
  8491. container.append("<li>".concat(text, "</li>"));
  8492. }
  8493. }, {
  8494. key: "getTaskUrl",
  8495. value: function getTaskUrl(type, task) {
  8496. var url = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative);
  8497. url += "/".concat(type, "s.json");
  8498. url += "/task".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(task);
  8499. return url;
  8500. }
  8501. }, {
  8502. key: "getRemovePackageUrl",
  8503. value: function getRemovePackageUrl(type) {
  8504. return "".concat(Packages.getTaskUrl(type, 'removePackage'));
  8505. }
  8506. }, {
  8507. key: "getReinstallPackageUrl",
  8508. value: function getReinstallPackageUrl(type) {
  8509. return "".concat(Packages.getTaskUrl(type, 'reinstallPackage'));
  8510. }
  8511. }, {
  8512. key: "getGetPackagesDependenciesUrl",
  8513. value: function getGetPackagesDependenciesUrl(type) {
  8514. return "".concat(Packages.getTaskUrl(type, 'getPackagesDependencies'));
  8515. }
  8516. }, {
  8517. key: "getInstallDependenciesOfPackagesUrl",
  8518. value: function getInstallDependenciesOfPackagesUrl(type) {
  8519. return "".concat(Packages.getTaskUrl(type, 'installDependenciesOfPackages'));
  8520. }
  8521. }, {
  8522. key: "getInstallPackageUrl",
  8523. value: function getInstallPackageUrl(type) {
  8524. return "".concat(Packages.getTaskUrl(type, 'installPackage'));
  8525. }
  8526. }, {
  8527. key: "addNeededDependencyToList",
  8528. value: function addNeededDependencyToList(action, slug) {
  8529. external_jQuery_default()('.install-dependencies-package-container .type-' + action).removeClass('hidden');
  8530. var list = external_jQuery_default()('.install-dependencies-package-container .type-' + action + ' ul');
  8531. if (action !== 'install') {
  8532. var current_version = '';
  8533. var available_version = '';
  8534. var _name2 = '';
  8535. var resources = gpm_Instance.payload.payload.resources;
  8536. if (resources.plugins[slug]) {
  8537. available_version = resources.plugins[slug].available;
  8538. current_version = resources.plugins[slug].version;
  8539. _name2 = resources.plugins[slug].name;
  8540. } else if (resources.themes[slug]) {
  8541. available_version = resources.themes[slug].available;
  8542. current_version = resources.themes[slug].version;
  8543. _name2 = resources.themes[slug].name;
  8544. }
  8545. list.append("<li>".concat(_name2 ? _name2 : slug, ", ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FROM, " v<strong>").concat(current_version, "</strong> ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.TO, " v<strong>").concat(available_version, "</strong></li>"));
  8546. } else {
  8547. list.append("<li>".concat(name ? name : slug, "</li>"));
  8548. }
  8549. }
  8550. }, {
  8551. key: "getSlugsFromEvent",
  8552. value: function getSlugsFromEvent(event) {
  8553. var slugs = '';
  8554. if (external_jQuery_default()(event.target).is('[data-packages-slugs]')) {
  8555. slugs = external_jQuery_default()(event.target).attr('data-packages-slugs');
  8556. } else {
  8557. slugs = external_jQuery_default()(event.target).parent('[data-packages-slugs]').attr('data-packages-slugs');
  8558. }
  8559. if (typeof slugs === 'undefined') {
  8560. return null;
  8561. }
  8562. slugs = slugs.split(',');
  8563. return typeof slugs === 'string' ? [slugs] : slugs;
  8564. }
  8565. }]);
  8566. return Packages;
  8567. }();
  8568. /* harmony default export */ const utils_packages = (new Packages());
  8569. // EXTERNAL MODULE: ./node_modules/mout/string/camelCase.js
  8570. var camelCase = __webpack_require__(71047);
  8571. var camelCase_default = /*#__PURE__*/__webpack_require__.n(camelCase);
  8572. // EXTERNAL MODULE: ./node_modules/mout/string/contains.js
  8573. var contains = __webpack_require__(85286);
  8574. var contains_default = /*#__PURE__*/__webpack_require__.n(contains);
  8575. ;// CONCATENATED MODULE: ./app/plugins/index.js
  8576. // Plugins sliders details
  8577. external_jQuery_default()('.gpm-name, .gpm-actions').on('click', function (e) {
  8578. var element = external_jQuery_default()(this);
  8579. var target = external_jQuery_default()(e.target);
  8580. var tag = target.prop('tagName').toLowerCase();
  8581. if (tag === 'a' || element.parent('a').length || target.parent('a').length) {
  8582. return true;
  8583. }
  8584. var wrapper = element.siblings('.gpm-details').find('.table-wrapper');
  8585. wrapper.slideToggle({
  8586. duration: 350,
  8587. complete: function complete() {
  8588. var visible = wrapper.is(':visible');
  8589. wrapper.closest('tr').find('.gpm-details-expand i').removeClass('fa-chevron-' + (visible ? 'down' : 'up')).addClass('fa-chevron-' + (visible ? 'up' : 'down'));
  8590. }
  8591. });
  8592. }); // Removing plugin
  8593. external_jQuery_default()(document).on('click', '[data-plugin-action="remove-package"]', function (event) {
  8594. utils_packages.handleRemovingPackage('plugin', event);
  8595. }); // Reinstall plugin
  8596. external_jQuery_default()(document).on('click', '[data-plugin-action="reinstall-package"]', function (event) {
  8597. utils_packages.handleReinstallPackage('plugin', event);
  8598. });
  8599. external_jQuery_default()(document).on('click', '[data-plugin-action="remove-dependency-package"]', function (event) {
  8600. utils_packages.handleRemovingDependency('plugin', event);
  8601. }); // Trigger the add new plugin / update plugin modal
  8602. external_jQuery_default()(document).on('click', '[data-plugin-action="start-package-installation"]', function (event) {
  8603. utils_packages.handleGettingPackageDependencies('plugin', event, 'install');
  8604. }); // Trigger the update all plugins modal
  8605. external_jQuery_default()(document).on('click', '[data-plugin-action="start-packages-update"]', function (event) {
  8606. utils_packages.handleGettingPackageDependencies('plugin', event);
  8607. }); // Install a plugin dependencies and the plugin
  8608. external_jQuery_default()(document).on('click', '[data-plugin-action="install-dependencies-and-package"]', function (event) {
  8609. utils_packages.handleInstallingDependenciesAndPackage('plugin', event);
  8610. }); // Install a plugin
  8611. external_jQuery_default()(document).on('click', '[data-plugin-action="install-package"]', function (event) {
  8612. utils_packages.handleInstallingPackage('plugin', event);
  8613. }); // Sort plugins/themes dropdown
  8614. external_jQuery_default()(document).on('change', '.sort-actions select', function (event) {
  8615. var direction = external_jQuery_default()('.sort-actions .sort-icon .fa').hasClass('fa-sort-amount-desc') ? 'desc' : 'asc';
  8616. var sorting = external_jQuery_default()(event.currentTarget).val();
  8617. utils_packages.Sort[camelCase_default()("by-".concat(sorting))](direction);
  8618. }); // Sort plugins/themes icon
  8619. external_jQuery_default()(document).on('click', '.sort-icon', function (event) {
  8620. var icon = external_jQuery_default()(event.currentTarget).find('.fa');
  8621. var current = icon.hasClass('fa-sort-amount-asc') ? 'asc' : 'desc';
  8622. var opposite = current === 'asc' ? 'desc' : 'asc';
  8623. icon.removeClass("fa-sort-amount-".concat(current)).addClass("fa-sort-amount-".concat(opposite));
  8624. external_jQuery_default()('.sort-actions select').trigger('change');
  8625. }); // Filter plugin/theme
  8626. external_jQuery_default()(document).on('input', '[data-gpm-filter]', debounce_default()(function (event) {
  8627. var value = external_jQuery_default()(external_jQuery_default()(event.currentTarget)).val();
  8628. var items = external_jQuery_default()('[data-gpm-plugin], [data-gpm-theme]');
  8629. items.hide().filter(function (index, item) {
  8630. item = external_jQuery_default()(item);
  8631. return contains_default()(item.data('gpm-plugin'), value) || contains_default()(item.data('gpm-theme'), value) || contains_default()(item.data('gpm-name').toLowerCase(), value.toLowerCase());
  8632. }).show();
  8633. }, 250));
  8634. ;// CONCATENATED MODULE: ./app/themes/index.js
  8635. // Themes Switcher Warning
  8636. external_jQuery_default()(document).on('mousedown', '[data-remodal-target="theme-switch-warn"]', function (event) {
  8637. var name = external_jQuery_default()(event.target).closest('[data-gpm-theme]').find('.gpm-name a:first').text();
  8638. var remodal = external_jQuery_default()('.remodal.theme-switcher');
  8639. remodal.find('strong').text(name);
  8640. remodal.find('.button.continue').attr('href', external_jQuery_default()(event.target).attr('href'));
  8641. }); // Removing theme
  8642. external_jQuery_default()(document).on('click', '[data-theme-action="remove-package"]', function (event) {
  8643. utils_packages.handleRemovingPackage('theme', event);
  8644. }); // Reinstall theme
  8645. external_jQuery_default()(document).on('click', '[data-theme-action="reinstall-package"]', function (event) {
  8646. utils_packages.handleReinstallPackage('theme', event);
  8647. });
  8648. external_jQuery_default()(document).on('click', '[data-theme-action="remove-dependency-package"]', function (event) {
  8649. utils_packages.handleRemovingDependency('theme', event);
  8650. }); // Opened the add new theme / update theme modal
  8651. external_jQuery_default()(document).on('click', '[data-theme-action="start-package-installation"]', function (event) {
  8652. utils_packages.handleGettingPackageDependencies('theme', event, 'install');
  8653. }); // Trigger the update all themes modal
  8654. external_jQuery_default()(document).on('click', '[data-theme-action="start-packages-update"]', function (event) {
  8655. utils_packages.handleGettingPackageDependencies('theme', event);
  8656. }); // Install a theme dependencies and the theme
  8657. external_jQuery_default()(document).on('click', '[data-theme-action="install-dependencies-and-package"]', function (event) {
  8658. utils_packages.handleInstallingDependenciesAndPackage('theme', event);
  8659. }); // Install a theme
  8660. external_jQuery_default()(document).on('click', '[data-theme-action="install-package"]', function (event) {
  8661. utils_packages.handleInstallingPackage('theme', event);
  8662. });
  8663. ;// CONCATENATED MODULE: ./app/media/index.js
  8664. function app_media_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8665. function app_media_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); } }
  8666. function app_media_createClass(Constructor, protoProps, staticProps) { if (protoProps) app_media_defineProperties(Constructor.prototype, protoProps); if (staticProps) app_media_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  8667. var Filter = /*#__PURE__*/function () {
  8668. function Filter() {
  8669. app_media_classCallCheck(this, Filter);
  8670. this.URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/media-manager/");
  8671. }
  8672. app_media_createClass(Filter, [{
  8673. key: "filter",
  8674. value: function filter(name, value) {
  8675. var filtered = [];
  8676. var keys = Object.keys(external_GravAdmin_namespaceObject.uri_params);
  8677. if (!~keys.indexOf(name)) {
  8678. keys.push(name);
  8679. }
  8680. keys.forEach(function (key) {
  8681. var filter = Filter.cleanValue(key === name ? value : external_GravAdmin_namespaceObject.uri_params[key]);
  8682. if (filter !== '*') {
  8683. filtered.push("".concat(key).concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filter));
  8684. }
  8685. });
  8686. __webpack_require__.g.location = this.URI + filtered.join('/');
  8687. }
  8688. }], [{
  8689. key: "cleanValue",
  8690. value: function cleanValue(value) {
  8691. return encodeURIComponent(value.replace('/', '\\'));
  8692. }
  8693. }]);
  8694. return Filter;
  8695. }();
  8696. var app_media_Instance = new Filter();
  8697. var isLoading = false;
  8698. var filters = {};
  8699. var global_index = 1;
  8700. var files_ended = false;
  8701. var MEDIA_PAGINATION_INTERVAL = 20;
  8702. /* handle changing file type / date filter */
  8703. external_jQuery_default()('body').on('change', '.thumbs-list-container select.filter', function (event) {
  8704. var target = external_jQuery_default()(event.currentTarget);
  8705. var filterName = target.data('name');
  8706. var filterValue = target.val();
  8707. if (filterValue) {
  8708. filters[filterName] = filterValue;
  8709. } else {
  8710. delete filters[filterName];
  8711. }
  8712. filterFiles();
  8713. });
  8714. /* initialize media uploader */
  8715. if (external_jQuery_default()('.thumbs-list-container .dropzone')[0]) {
  8716. external_jQuery_default()('.thumbs-list-container .dropzone')[0].dropzone.on('queuecomplete', function () {
  8717. var body = {};
  8718. if (filters.page) {
  8719. body.page = filters.page;
  8720. }
  8721. if (filters.date) {
  8722. body.date = filters.date;
  8723. }
  8724. if (filters.type) {
  8725. body.type = filters.type;
  8726. }
  8727. external_jQuery_default()('.dropzone')[0].dropzone.files.forEach(function (file) {
  8728. file.previewElement.remove();
  8729. });
  8730. external_jQuery_default()('.dropzone').first().removeClass('dz-started');
  8731. utils_request("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/media-manager.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "clearMediaCache"), {
  8732. method: 'post',
  8733. body: body
  8734. }, function () {
  8735. filterFiles();
  8736. });
  8737. });
  8738. }
  8739. /* handle loading media */
  8740. var loadMedia = function loadMedia(filters, callback) {
  8741. var url = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/media.json/tmpl").concat(external_GravAdmin_namespaceObject.config.param_sep, "media-list-content/index").concat(external_GravAdmin_namespaceObject.config.param_sep).concat(global_index);
  8742. if (filters.page) {
  8743. url += "/page".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filters.page.split('/').join('%5C'));
  8744. }
  8745. if (filters.type && filters.type !== '*') {
  8746. url += "/type".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filters.type);
  8747. }
  8748. if (filters.date && filters.date !== '*') {
  8749. url += "/date".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filters.date);
  8750. }
  8751. if (!isLoading) {
  8752. isLoading = true;
  8753. external_jQuery_default()('.spinning-wheel').show();
  8754. external_jQuery_default().get(url, function (content) {
  8755. external_jQuery_default()('.js__files').append(content);
  8756. external_jQuery_default()('.spinning-wheel').hide();
  8757. external_jQuery_default()('.media-container .media-range').trigger('change');
  8758. isLoading = false;
  8759. global_index++;
  8760. callback(content);
  8761. });
  8762. }
  8763. };
  8764. var cleanFilesList = function cleanFilesList() {
  8765. external_jQuery_default()('.js__files .card-item').remove();
  8766. };
  8767. var resetActiveStateInSidebar = function resetActiveStateInSidebar() {
  8768. external_jQuery_default()('.pages-list-container .row').removeClass('active'); // clear active state in sidebar
  8769. };
  8770. var showEmptyState = function showEmptyState() {
  8771. external_jQuery_default()('.thumbs-list-container').append('<p class="card-item empty-space">No media found</p>');
  8772. };
  8773. var filterFiles = function filterFiles() {
  8774. cleanFilesList();
  8775. global_index = 0;
  8776. files_ended = false;
  8777. external_jQuery_default()('.empty-space').remove();
  8778. loadMedia(filters, function (content) {
  8779. if (!content.trim().length) {
  8780. showEmptyState();
  8781. } else {
  8782. if (!filters.page && (!filters.date || filters.date === '*') && (!filters.type || filters.type === '*')) {
  8783. external_jQuery_default()('.js__files').trigger('fillView');
  8784. }
  8785. }
  8786. });
  8787. };
  8788. /* handle changing page */
  8789. external_jQuery_default()('body').on('click', '.pages-list-container .js__page-link', function (event) {
  8790. var page = external_jQuery_default()(event.target).data('page');
  8791. filters['page'] = page;
  8792. external_jQuery_default()('.media-list-title .page-indicator').html(page); // set indication
  8793. external_jQuery_default()('.js__reset-pages-filter').removeClass('hidden'); // activate reset pages icon
  8794. resetActiveStateInSidebar();
  8795. external_jQuery_default()(event.target).parents('.row').addClass('active'); // set active state in sidebar
  8796. external_jQuery_default()('.js__file-uploader').removeClass('hidden'); // customize processing URL, as the page changes dynamically
  8797. if (external_jQuery_default()('.dropzone')[0]) {
  8798. external_jQuery_default()('.dropzone')[0].dropzone.on('processing', function (file) {
  8799. this.options.url = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/media-manager").concat(page, ".json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "addmedia");
  8800. });
  8801. }
  8802. external_jQuery_default()('.js__button-clear-media-cache').addClass('hidden');
  8803. filterFiles();
  8804. disableInfiniteScrolling(); // only infinite scroll on main list, not inside single pages
  8805. });
  8806. /* handle clearing page filter */
  8807. external_jQuery_default()('body').on('click', '.js__reset-pages-filter', function (event) {
  8808. external_jQuery_default()('.media-list-title .page-indicator').html('All Pages'); // set indication
  8809. cleanFilesList();
  8810. resetActiveStateInSidebar();
  8811. external_jQuery_default()('.js__reset-pages-filter').addClass('hidden'); // remove reset pages icon
  8812. external_jQuery_default()('.js__file-uploader').addClass('hidden');
  8813. external_jQuery_default()('.js__button-clear-media-cache').removeClass('hidden');
  8814. delete filters['page'];
  8815. filterFiles();
  8816. });
  8817. /* handle infinite loading */
  8818. var enableInfiniteScrolling = function enableInfiniteScrolling() {
  8819. external_jQuery_default()('.spinning-wheel').hide();
  8820. var view = external_jQuery_default()('.mediapicker-scroll').last();
  8821. if (!view.length) {
  8822. return;
  8823. }
  8824. external_jQuery_default()(view).on('scroll', function () {
  8825. if (external_jQuery_default()(this).scrollTop() + external_jQuery_default()(this).innerHeight() + 100 >= external_jQuery_default()(this)[0].scrollHeight) {
  8826. fillView();
  8827. }
  8828. });
  8829. };
  8830. var loadNextBatch = function loadNextBatch(callback) {
  8831. if (files_ended) {
  8832. return;
  8833. }
  8834. loadMedia({}, function (content) {
  8835. if (!external_jQuery_default()(content).length || content.split('card-item').length - 1 < MEDIA_PAGINATION_INTERVAL) {
  8836. files_ended = true;
  8837. } else {
  8838. if (callback) {
  8839. callback();
  8840. }
  8841. }
  8842. external_jQuery_default()('.media-container .media-range').trigger('input');
  8843. });
  8844. };
  8845. var fillView = function fillView() {
  8846. if (!external_jQuery_default()('.js__files').find('.card-item').last().offset()) {
  8847. setTimeout(function () {
  8848. // retry later
  8849. fillView();
  8850. }, 300);
  8851. return;
  8852. }
  8853. if (external_jQuery_default()('.js__files').find('.card-item').last().offset().top - 1 <= external_jQuery_default()('.media-container').height()) {
  8854. loadNextBatch(function () {
  8855. fillView();
  8856. });
  8857. }
  8858. };
  8859. /* disable infinite loading */
  8860. var disableInfiniteScrolling = function disableInfiniteScrolling() {
  8861. external_jQuery_default()('.spinning-wheel').hide();
  8862. external_jQuery_default()('.content-wrapper').unbind('scroll');
  8863. };
  8864. external_jQuery_default()('.js__files').on('fillView', function (event) {
  8865. // the first batch got the max number of media files, try loading more
  8866. if (external_jQuery_default()('.js__files')[0].innerHTML.split('card-item').length - 1 === MEDIA_PAGINATION_INTERVAL) {
  8867. fillView();
  8868. enableInfiniteScrolling();
  8869. }
  8870. });
  8871. ;// CONCATENATED MODULE: ./app/utils/2fa.js
  8872. var _2fa_body = external_jQuery_default()('body'); // Dashboard update and Grav update
  8873. _2fa_body.on('click', '[data-2fa-regenerate]', function (event) {
  8874. event.preventDefault();
  8875. var element = external_jQuery_default()(this);
  8876. var url = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/ajax.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "regenerate2FASecret");
  8877. element.attr('disabled', 'disabled').find('> .fa').addClass('fa-spin');
  8878. utils_request(url, {
  8879. method: 'post'
  8880. }, function (response) {
  8881. external_jQuery_default()('[data-2fa-image]').attr('src', response.image);
  8882. external_jQuery_default()('[data-2fa-secret]').text(response.secret);
  8883. external_jQuery_default()('[data-2fa-value]').val(response.secret.replace(' ', ''));
  8884. element.removeAttr('disabled').find('> .fa').removeClass('fa-spin');
  8885. });
  8886. });
  8887. var toggleSecret = function toggleSecret() {
  8888. var toggle = external_jQuery_default()('#toggle_twofa_enabled1');
  8889. var secret = external_jQuery_default()('.twofa-secret');
  8890. secret[toggle.is(':checked') ? 'addClass' : 'removeClass']('show');
  8891. };
  8892. _2fa_body.on('click', '.twofa-toggle input', toggleSecret);
  8893. toggleSecret();
  8894. // EXTERNAL MODULE: ./node_modules/mout/queryString.js
  8895. var queryString = __webpack_require__(85407);
  8896. ;// CONCATENATED MODULE: ./app/tools/logs.js
  8897. var prepareQuery = function prepareQuery(key, value) {
  8898. return (0,queryString.setParam)(__webpack_require__.g.location.href, key, value);
  8899. };
  8900. external_jQuery_default()(document).on('change', '.logs-content .block-select select[name]', function (event) {
  8901. var target = external_jQuery_default()(event.currentTarget);
  8902. var name = target.attr('name');
  8903. var value = target.val();
  8904. __webpack_require__.g.location.href = prepareQuery(name, value);
  8905. });
  8906. ;// CONCATENATED MODULE: ./app/tools/index.js
  8907. ;// CONCATENATED MODULE: ./app/whitelabel/compile.js
  8908. /* harmony default export */ const compile = (function () {
  8909. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8910. _ref$preview = _ref.preview,
  8911. preview = _ref$preview === void 0 ? false : _ref$preview,
  8912. _ref$exportScss = _ref.exportScss,
  8913. exportScss = _ref$exportScss === void 0 ? false : _ref$exportScss,
  8914. _ref$color_scheme = _ref.color_scheme,
  8915. color_scheme = _ref$color_scheme === void 0 ? {} : _ref$color_scheme,
  8916. _ref$fonts = _ref.fonts,
  8917. fonts = _ref$fonts === void 0 ? {} : _ref$fonts,
  8918. _ref$callback = _ref.callback,
  8919. callback = _ref$callback === void 0 ? function () {} : _ref$callback;
  8920. var task = exportScss ? 'exportScss' : 'compileScss'; // console.log(config);
  8921. var URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, ".json/task:").concat(task);
  8922. utils_request(URI, {
  8923. method: 'post',
  8924. body: Object.assign({}, preview ? {
  8925. preview: preview
  8926. } : null, color_scheme)
  8927. }, callback);
  8928. });
  8929. var prepareElement = function prepareElement(element) {
  8930. element.data('busy_right_now', true);
  8931. if (!element.data('current_icon')) {
  8932. element.data('current_icon', element.find('.fa').attr('class'));
  8933. }
  8934. element.find('.fa').attr('class', 'fa fa-fw fa-spin fa-refresh');
  8935. };
  8936. var resetElement = function resetElement(element) {
  8937. element.data('busy_right_now', false);
  8938. element.find('.fa').attr('class', element.data('current_icon'));
  8939. };
  8940. ;// CONCATENATED MODULE: ./app/whitelabel/presets.js
  8941. var presets_body = external_jQuery_default()('body');
  8942. var presets_fields = [];
  8943. var presets_FormState = app_forms.FormState.Instance;
  8944. var setField = function setField(field, value) {
  8945. var name = field.prop('name');
  8946. var tag = field.prop('tagName').toLowerCase();
  8947. var type = field.prop('type');
  8948. presets_fields.push(name);
  8949. switch (tag) {
  8950. case 'select':
  8951. field.val(value);
  8952. field.data('selectize').setValue(value);
  8953. field.trigger('change');
  8954. break;
  8955. case 'input':
  8956. if (type === 'radio') {
  8957. var strValue = value ? '1' : '0';
  8958. field.filter(function (index, radio) {
  8959. return external_jQuery_default()(radio).val() === strValue;
  8960. }).prop('checked', true);
  8961. break;
  8962. }
  8963. if (type === 'checkbox') {
  8964. field.prop('checked', value);
  8965. break;
  8966. }
  8967. field.val(value);
  8968. field.trigger('keyup');
  8969. }
  8970. };
  8971. presets_body.on('click', '[data-preset-values]', function (event) {
  8972. var target = external_jQuery_default()(event.currentTarget);
  8973. var data = target.data('preset-values');
  8974. Object.keys(data).forEach(function (section) {
  8975. if (typeof data[section] === 'string') {
  8976. return;
  8977. }
  8978. Object.keys(data[section]).forEach(function (key) {
  8979. var field = external_jQuery_default()("[name=\"data[whitelabel][color_scheme][".concat(section, "][").concat(key, "]\"], [name=\"data[").concat(section, "][").concat(key, "]\"]"));
  8980. var value = data[section][key];
  8981. setField(field, value);
  8982. });
  8983. });
  8984. });
  8985. presets_body.on('click', '[data-reset-scss]', function (event) {
  8986. event && event.preventDefault();
  8987. var element = external_jQuery_default()(event.currentTarget);
  8988. var links = external_jQuery_default()('link[id^=admin-pro-preview-]');
  8989. element.remove();
  8990. links.remove();
  8991. presets_fields.forEach(function (field) {
  8992. var value = presets_FormState.loadState.get(field);
  8993. setField(external_jQuery_default()("[name=\"".concat(field, "\"]")), value);
  8994. });
  8995. presets_fields = [];
  8996. }); // Horizontal Scroll Functionality
  8997. (external_jQuery_default()).fn.hscrollarrows = function () {
  8998. return this.each(function () {
  8999. var navNext = external_jQuery_default()('<a class="nav-next hide"></a>');
  9000. var navPrev = external_jQuery_default()('<a class="nav-prev hide"></a>');
  9001. var scrollTime = null;
  9002. var resizeTime = null;
  9003. var scrolling = false;
  9004. var elm_w = 0;
  9005. var elem_data_w = 0;
  9006. var max_scroll = 0;
  9007. var inc_scroll = 0;
  9008. var calcData = function calcData() {
  9009. elm_w = elem.width();
  9010. elem_data_w = elem_data.get(0).scrollWidth;
  9011. max_scroll = elem_data_w - elm_w;
  9012. inc_scroll = elm_w * 0.3; // 20%
  9013. };
  9014. var revalidate = function revalidate() {
  9015. calcData();
  9016. stateNavs();
  9017. };
  9018. var run = function run() {
  9019. calcData();
  9020. setupNavs();
  9021. };
  9022. var setupNavs = function setupNavs() {
  9023. elem.parent().prepend(navNext);
  9024. elem.parent().prepend(navPrev);
  9025. navNext.on('click', next);
  9026. navPrev.on('click', prev);
  9027. stateNavs();
  9028. external_jQuery_default()(elem).scroll(function () {
  9029. if (!scrolling) {
  9030. clearTimeout(scrollTime);
  9031. scrollTime = setTimeout(function () {
  9032. stateNavs();
  9033. }, 250);
  9034. }
  9035. });
  9036. external_jQuery_default()(window).resize(function () {
  9037. clearTimeout(resizeTime);
  9038. resizeTime = setTimeout(function () {
  9039. revalidate();
  9040. }, 250);
  9041. });
  9042. };
  9043. var stateNavs = function stateNavs() {
  9044. var current_scroll = elem.scrollLeft();
  9045. if (current_scroll < max_scroll) {
  9046. navNext.removeClass('hide');
  9047. } else {
  9048. navNext.addClass('hide');
  9049. }
  9050. if (current_scroll > 0) {
  9051. navPrev.removeClass('hide');
  9052. } else {
  9053. navPrev.addClass('hide');
  9054. }
  9055. scrolling = false;
  9056. };
  9057. var next = function next() {
  9058. var current_scroll = elem.scrollLeft();
  9059. if (current_scroll < max_scroll) {
  9060. scrolling = true;
  9061. elem.stop().animate({
  9062. scrollLeft: current_scroll + inc_scroll
  9063. }, stateNavs);
  9064. }
  9065. };
  9066. var prev = function prev() {
  9067. var current_scroll = elem.scrollLeft();
  9068. if (current_scroll > 0) {
  9069. scrolling = true;
  9070. elem.stop().animate({
  9071. scrollLeft: current_scroll - inc_scroll
  9072. }, stateNavs);
  9073. }
  9074. };
  9075. var elem = external_jQuery_default()(this);
  9076. var elem_data = external_jQuery_default()(':first-child', elem);
  9077. run();
  9078. });
  9079. };
  9080. external_jQuery_default()(document).ready(function () {
  9081. external_jQuery_default()('.jquery-horizontal-scroll').hscrollarrows();
  9082. });
  9083. ;// CONCATENATED MODULE: ./app/whitelabel/index.js
  9084. var whitelabel_body = external_jQuery_default()('body');
  9085. var whitelabel_FormState = app_forms.FormState.Instance;
  9086. var compiler = function compiler(element) {
  9087. var preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9088. var exportScss = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9089. var _callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {};
  9090. prepareElement(element);
  9091. var fields = whitelabel_FormState.collect();
  9092. compile({
  9093. preview: preview,
  9094. exportScss: exportScss,
  9095. color_scheme: !fields ? [] : fields.filter(function (value, key) {
  9096. return key.match(/^data\[whitelabel]\[color_scheme]/);
  9097. }).toJS(),
  9098. callback: function callback(response) {
  9099. _callback.call(_callback, response);
  9100. resetElement(element);
  9101. }
  9102. });
  9103. };
  9104. whitelabel_body.on('click', '[data-preview-scss]', function (event) {
  9105. event && event.preventDefault();
  9106. var element = external_jQuery_default()(event.currentTarget);
  9107. if (element.data('busy_right_now')) {
  9108. return false;
  9109. }
  9110. compiler(element, true, false, function (response) {
  9111. if (response.files) {
  9112. Object.keys(response.files).forEach(function (key) {
  9113. var file = external_jQuery_default()("#admin-pro-preview-".concat(key));
  9114. var timestamp = Date.now();
  9115. if (!file.length) {
  9116. file = external_jQuery_default()("<link id=\"admin-pro-preview-".concat(key, "\" type=\"text/css\" rel=\"stylesheet\" />"));
  9117. external_jQuery_default()('head').append(file);
  9118. if (!external_jQuery_default()('[data-reset-scss]').length) {
  9119. var reset = external_jQuery_default()('<button class="button" data-reset-scss style="margin-left: 5px;"><i class="fa fa-fw fa-history"></i> Reset</button>');
  9120. reset.insertAfter(element);
  9121. }
  9122. }
  9123. file.attr('href', "".concat(response.files[key], "?").concat(timestamp));
  9124. });
  9125. }
  9126. });
  9127. });
  9128. whitelabel_body.on('click', '[data-recompile-scss]', function (event) {
  9129. event && event.preventDefault();
  9130. var element = external_jQuery_default()(event.currentTarget);
  9131. if (element.data('busy_right_now')) {
  9132. return false;
  9133. }
  9134. compiler(element, true, false);
  9135. });
  9136. whitelabel_body.on('click', '[data-export-scss]', function (event) {
  9137. event && event.preventDefault();
  9138. var element = external_jQuery_default()(event.currentTarget);
  9139. if (element.data('busy_right_now')) {
  9140. return false;
  9141. }
  9142. compiler(element, true, true, function (response) {
  9143. if (response.files) {
  9144. Object.keys(response.files).forEach(function (key) {
  9145. if (key === 'download') {
  9146. var _element = document.createElement('a');
  9147. _element.setAttribute('href', response.files[key]);
  9148. _element.setAttribute('download', '');
  9149. _element.style.display = 'none';
  9150. document.body.appendChild(_element);
  9151. _element.click();
  9152. document.body.removeChild(_element);
  9153. }
  9154. });
  9155. }
  9156. });
  9157. });
  9158. whitelabel_body.on('change._grav_colorpicker', '[data-grav-colorpicker]', function (event, input, hex, opacity) {
  9159. var RGB = hex2rgb(hex);
  9160. var YIQ = (RGB.r * 299 + RGB.g * 587 + RGB.b * 114) / 1000;
  9161. var contrast = YIQ >= 128 || opacity <= 0.50 ? 'dark' : 'light';
  9162. input.parent().removeClass('dark-text light-text').addClass("".concat(contrast, "-text"));
  9163. });
  9164. whitelabel_body.ready(function () {
  9165. external_jQuery_default()('[data-grav-colorpicker]').trigger('keyup');
  9166. });
  9167. ;// CONCATENATED MODULE: ./app/utils/bootstrap-transition.js
  9168. +function ($) {
  9169. 'use strict'; // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  9170. // ============================================================
  9171. function transitionEnd() {
  9172. var el = document.createElement('bootstrap');
  9173. var transEndEventNames = {
  9174. WebkitTransition: 'webkitTransitionEnd',
  9175. MozTransition: 'transitionend',
  9176. OTransition: 'oTransitionEnd otransitionend',
  9177. transition: 'transitionend'
  9178. };
  9179. for (var name in transEndEventNames) {
  9180. if (el.style[name] !== undefined) {
  9181. return {
  9182. end: transEndEventNames[name]
  9183. };
  9184. }
  9185. }
  9186. return false; // explicit for ie8 ( ._.)
  9187. } // http://blog.alexmaccaw.com/css-transitions
  9188. $.fn.emulateTransitionEnd = function (duration) {
  9189. var called = false;
  9190. var $el = this;
  9191. $(this).one('bsTransitionEnd', function () {
  9192. called = true;
  9193. });
  9194. var callback = function callback() {
  9195. if (!called) $($el).trigger($.support.transition.end);
  9196. };
  9197. setTimeout(callback, duration);
  9198. return this;
  9199. };
  9200. $(function () {
  9201. $.support.transition = transitionEnd();
  9202. if (!$.support.transition) return;
  9203. $.event.special.bsTransitionEnd = {
  9204. bindType: $.support.transition.end,
  9205. delegateType: $.support.transition.end,
  9206. handle: function handle(e) {
  9207. if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments);
  9208. }
  9209. };
  9210. });
  9211. }((external_jQuery_default()));
  9212. ;// CONCATENATED MODULE: ./app/utils/bootstrap-collapse.js
  9213. function bootstrap_collapse_typeof(obj) { "@babel/helpers - typeof"; return bootstrap_collapse_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, bootstrap_collapse_typeof(obj); }
  9214. /* ========================================================================
  9215. * Bootstrap: collapse.js v3.4.0
  9216. * http://getbootstrap.com/javascript/#collapse
  9217. * ========================================================================
  9218. * Copyright 2011-2016 Twitter, Inc.
  9219. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  9220. * ======================================================================== */
  9221. /* jshint latedef: false */
  9222. +function ($) {
  9223. 'use strict'; // COLLAPSE PUBLIC CLASS DEFINITION
  9224. // ================================
  9225. var Collapse = function Collapse(element, options) {
  9226. this.$element = $(element);
  9227. this.options = $.extend({}, Collapse.DEFAULTS, options);
  9228. this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' + '[data-toggle="collapse"][data-target="#' + element.id + '"]');
  9229. this.transitioning = null;
  9230. if (this.options.parent) {
  9231. this.$parent = this.getParent();
  9232. } else {
  9233. this.addAriaAndCollapsedClass(this.$element, this.$trigger);
  9234. }
  9235. if (this.options.toggle) this.toggle();
  9236. };
  9237. Collapse.VERSION = '3.4.0';
  9238. Collapse.TRANSITION_DURATION = 350;
  9239. Collapse.DEFAULTS = {
  9240. toggle: true
  9241. };
  9242. Collapse.prototype.dimension = function () {
  9243. var hasWidth = this.$element.hasClass('width');
  9244. return hasWidth ? 'width' : 'height';
  9245. };
  9246. Collapse.prototype.show = function () {
  9247. if (this.transitioning || this.$element.hasClass('in')) return;
  9248. var activesData;
  9249. var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing');
  9250. if (actives && actives.length) {
  9251. activesData = actives.data('bs.collapse');
  9252. if (activesData && activesData.transitioning) return;
  9253. }
  9254. var startEvent = $.Event('show.bs.collapse');
  9255. this.$element.trigger(startEvent);
  9256. if (startEvent.isDefaultPrevented()) return;
  9257. if (actives && actives.length) {
  9258. Plugin.call(actives, 'hide');
  9259. activesData || actives.data('bs.collapse', null);
  9260. }
  9261. var dimension = this.dimension();
  9262. this.$element.removeClass('collapse').addClass('collapsing')[dimension](0).attr('aria-expanded', true);
  9263. this.$trigger.removeClass('collapsed').attr('aria-expanded', true);
  9264. this.transitioning = 1;
  9265. var complete = function complete() {
  9266. this.$element.removeClass('collapsing').addClass('collapse in')[dimension]('');
  9267. this.transitioning = 0;
  9268. this.$element.trigger('shown.bs.collapse');
  9269. };
  9270. if (!$.support.transition) return complete.call(this);
  9271. var scrollSize = $.camelCase(['scroll', dimension].join('-'));
  9272. this.$element.one('bsTransitionEnd', $.proxy(complete, this)).emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]);
  9273. };
  9274. Collapse.prototype.hide = function () {
  9275. if (this.transitioning || !this.$element.hasClass('in')) return;
  9276. var startEvent = $.Event('hide.bs.collapse');
  9277. this.$element.trigger(startEvent);
  9278. if (startEvent.isDefaultPrevented()) return;
  9279. var dimension = this.dimension();
  9280. this.$element[dimension](this.$element[dimension]())[0].offsetHeight;
  9281. this.$element.addClass('collapsing').removeClass('collapse in').attr('aria-expanded', false);
  9282. this.$trigger.addClass('collapsed').attr('aria-expanded', false);
  9283. this.transitioning = 1;
  9284. var complete = function complete() {
  9285. this.transitioning = 0;
  9286. this.$element.removeClass('collapsing').addClass('collapse').trigger('hidden.bs.collapse');
  9287. };
  9288. if (!$.support.transition) return complete.call(this);
  9289. this.$element[dimension](0).one('bsTransitionEnd', $.proxy(complete, this)).emulateTransitionEnd(Collapse.TRANSITION_DURATION);
  9290. };
  9291. Collapse.prototype.toggle = function () {
  9292. this[this.$element.hasClass('in') ? 'hide' : 'show']();
  9293. };
  9294. Collapse.prototype.getParent = function () {
  9295. return $(this.options.parent).find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]').each($.proxy(function (i, element) {
  9296. var $element = $(element);
  9297. this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element);
  9298. }, this)).end();
  9299. };
  9300. Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {
  9301. var isOpen = $element.hasClass('in');
  9302. $element.attr('aria-expanded', isOpen);
  9303. $trigger.toggleClass('collapsed', !isOpen).attr('aria-expanded', isOpen);
  9304. };
  9305. function getTargetFromTrigger($trigger) {
  9306. var href;
  9307. var target = $trigger.attr('data-target') || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, ''); // strip for ie7
  9308. return $(target);
  9309. } // COLLAPSE PLUGIN DEFINITION
  9310. // ==========================
  9311. function Plugin(option) {
  9312. return this.each(function () {
  9313. var $this = $(this);
  9314. var data = $this.data('bs.collapse');
  9315. var options = $.extend({}, Collapse.DEFAULTS, $this.data(), bootstrap_collapse_typeof(option) === 'object' && option);
  9316. if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false;
  9317. if (!data) $this.data('bs.collapse', data = new Collapse(this, options));
  9318. if (typeof option === 'string') data[option]();
  9319. });
  9320. }
  9321. var old = $.fn.collapse;
  9322. $.fn.collapse = Plugin;
  9323. $.fn.collapse.Constructor = Collapse; // COLLAPSE NO CONFLICT
  9324. // ====================
  9325. $.fn.collapse.noConflict = function () {
  9326. $.fn.collapse = old;
  9327. return this;
  9328. }; // COLLAPSE DATA-API
  9329. // =================
  9330. $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
  9331. var $this = $(this);
  9332. if (!$this.attr('data-target')) e.preventDefault();
  9333. var $target = getTargetFromTrigger($this);
  9334. var data = $target.data('bs.collapse');
  9335. var option = data ? 'toggle' : $this.data();
  9336. Plugin.call($target, option);
  9337. });
  9338. }((external_jQuery_default()));
  9339. ;// CONCATENATED MODULE: ./app/utils/bootstrap-dropdown.js
  9340. /* ========================================================================
  9341. * Bootstrap: dropdown.js v3.4.1
  9342. * https://getbootstrap.com/docs/3.4/javascript/#dropdowns
  9343. * ========================================================================
  9344. * Copyright 2011-2019 Twitter, Inc.
  9345. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/v3-dev/LICENSE)
  9346. * ======================================================================== */
  9347. +function ($) {
  9348. 'use strict'; // DROPDOWN CLASS DEFINITION
  9349. // =========================
  9350. var backdrop = '.dropdown-backdrop';
  9351. var toggle = '[data-toggle="dropdown"]';
  9352. var Dropdown = function Dropdown(element) {
  9353. $(element).on('click.bs.dropdown', this.toggle);
  9354. };
  9355. Dropdown.VERSION = '3.4.1';
  9356. function getParent($this) {
  9357. var selector = $this.attr('data-target');
  9358. if (!selector) {
  9359. selector = $this.attr('href');
  9360. selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, ''); // strip for ie7
  9361. }
  9362. var $parent = selector !== '#' ? $(document).find(selector) : null;
  9363. return $parent && $parent.length ? $parent : $this.parent();
  9364. }
  9365. function clearMenus(e) {
  9366. if (e && e.which === 3) {
  9367. return;
  9368. }
  9369. $(backdrop).remove();
  9370. $(toggle).each(function () {
  9371. var $this = $(this);
  9372. var $parent = getParent($this);
  9373. var relatedTarget = {
  9374. relatedTarget: this
  9375. };
  9376. if (!$parent.hasClass('open')) {
  9377. return;
  9378. }
  9379. if (e && e.type === 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) {
  9380. return;
  9381. }
  9382. $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget));
  9383. if (e.isDefaultPrevented()) {
  9384. return;
  9385. }
  9386. $this.attr('aria-expanded', 'false');
  9387. $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget));
  9388. });
  9389. }
  9390. Dropdown.prototype.toggle = function (e) {
  9391. var $this = $(this);
  9392. if ($this.is('.disabled, :disabled')) {
  9393. return;
  9394. }
  9395. var $parent = getParent($this);
  9396. var isActive = $parent.hasClass('open');
  9397. clearMenus();
  9398. if (!isActive) {
  9399. if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
  9400. // if mobile we use a backdrop because click events don't delegate
  9401. $(document.createElement('div')).addClass('dropdown-backdrop').insertAfter($(this)).on('click', clearMenus);
  9402. }
  9403. var relatedTarget = {
  9404. relatedTarget: this
  9405. };
  9406. $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget));
  9407. if (e.isDefaultPrevented()) {
  9408. return;
  9409. }
  9410. $this.trigger('focus').attr('aria-expanded', 'true');
  9411. $parent.toggleClass('open').trigger($.Event('shown.bs.dropdown', relatedTarget));
  9412. }
  9413. return false;
  9414. };
  9415. Dropdown.prototype.keydown = function (e) {
  9416. if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return;
  9417. var $this = $(this);
  9418. e.preventDefault();
  9419. e.stopPropagation();
  9420. if ($this.is('.disabled, :disabled')) {
  9421. return;
  9422. }
  9423. var $parent = getParent($this);
  9424. var isActive = $parent.hasClass('open');
  9425. if (!isActive && e.which !== 27 || isActive && e.which === 27) {
  9426. if (e.which === 27) {
  9427. $parent.find(toggle).trigger('focus');
  9428. }
  9429. return $this.trigger('click');
  9430. }
  9431. var desc = ' li:not(.disabled):visible a';
  9432. var $items = $parent.find('.dropdown-menu' + desc);
  9433. if (!$items.length) {
  9434. return;
  9435. }
  9436. var index = $items.index(e.target);
  9437. if (e.which === 38 && index > 0) {
  9438. index--;
  9439. } // up
  9440. if (e.which === 40 && index < $items.length - 1) {
  9441. index++;
  9442. } // down
  9443. if (!~index) {
  9444. index = 0;
  9445. }
  9446. $items.eq(index).trigger('focus');
  9447. }; // DROPDOWN PLUGIN DEFINITION
  9448. // ==========================
  9449. function Plugin(option) {
  9450. return this.each(function () {
  9451. var $this = $(this);
  9452. var data = $this.data('bs.dropdown');
  9453. if (!data) $this.data('bs.dropdown', data = new Dropdown(this));
  9454. if (typeof option === 'string') data[option].call($this);
  9455. });
  9456. }
  9457. var old = $.fn.dropdown;
  9458. $.fn.dropdown = Plugin;
  9459. $.fn.dropdown.Constructor = Dropdown; // DROPDOWN NO CONFLICT
  9460. // ====================
  9461. $.fn.dropdown.noConflict = function () {
  9462. $.fn.dropdown = old;
  9463. return this;
  9464. }; // APPLY TO STANDARD DROPDOWN ELEMENTS
  9465. // ===================================
  9466. $(document).on('click.bs.dropdown.data-api', clearMenus).on('click.bs.dropdown.data-api', '.dropdown form', function (e) {
  9467. e.stopPropagation();
  9468. }).on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle).on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown).on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown);
  9469. }((external_jQuery_default()));
  9470. ;// CONCATENATED MODULE: ./app/utils/tabs-memory.js
  9471. var tabs_memory_Data = JSON.parse(cookies.get('grav-tabs-state') || '{}');
  9472. external_jQuery_default()('body').on('touchstart click', '[data-tabid]', function (event) {
  9473. event && event.stopPropagation();
  9474. var target = external_jQuery_default()(event.currentTarget);
  9475. tabs_memory_Data[target.data('tabkey')] = target.data('scope');
  9476. cookies.set('grav-tabs-state', JSON.stringify(tabs_memory_Data), {
  9477. expires: Infinity
  9478. });
  9479. var panel = external_jQuery_default()("[id=\"".concat(target.data('tabid'), "\"]"));
  9480. target.siblings('[data-tabid]').removeClass('active');
  9481. target.addClass('active');
  9482. panel.siblings('[id]').removeClass('active');
  9483. panel.addClass('active');
  9484. editor_Instance.editors.each(function (index, editor) {
  9485. var codemirror = external_jQuery_default()(editor).data('codemirror');
  9486. if (!codemirror) {
  9487. return;
  9488. }
  9489. if (codemirror.display.lastWrapWidth === 0) {
  9490. codemirror.refresh();
  9491. }
  9492. });
  9493. });
  9494. ;// CONCATENATED MODULE: ./app/utils/changelog.js
  9495. /* eslint-disable */
  9496. var TRIGGER = null;
  9497. external_jQuery_default()(document).on('click', '[data-remodal-changelog]', function (event) {
  9498. TRIGGER = event.currentTarget;
  9499. });
  9500. external_jQuery_default()(document).on('opened', '[data-remodal-id="changelog"]', function () {
  9501. var instance = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-remodal-id=changelog]').data('remodal')];
  9502. instance.$modal.html('<div class="changelog-overflow center" style="padding:5rem 0;text-align:center;"><i class="fa fa-spinner fa-spin fa-3x fa-fw"></i></div>');
  9503. if (!TRIGGER) {
  9504. return true;
  9505. }
  9506. var url = external_jQuery_default()(TRIGGER).data('remodalChangelog');
  9507. external_jQuery_default().ajax({
  9508. url: url
  9509. }).done(function (data) {
  9510. instance.$modal.html(data);
  9511. });
  9512. });
  9513. external_jQuery_default()(document).on('closed', '[data-remodal-id="changelog"]', function () {
  9514. var instance = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-remodal-id=changelog]').data('remodal')];
  9515. instance.$modal.html('');
  9516. });
  9517. ;// CONCATENATED MODULE: ./app/utils/sidebar.js
  9518. function sidebar_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9519. function sidebar_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); } }
  9520. function sidebar_createClass(Constructor, protoProps, staticProps) { if (protoProps) sidebar_defineProperties(Constructor.prototype, protoProps); if (staticProps) sidebar_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  9521. var MOBILE_BREAKPOINT = 48 - 0.062;
  9522. var DESKTOP_BREAKPOINT = 75 + 0.063;
  9523. var EVENTS = 'touchstart._grav click._grav';
  9524. var TARGETS = '[data-sidebar-mobile-toggle], #overlay';
  9525. var MOBILE_QUERY = "(max-width: ".concat(MOBILE_BREAKPOINT, "em)");
  9526. var DESKTOP_QUERY = "(min-width: ".concat(DESKTOP_BREAKPOINT, "em)");
  9527. var map = new __webpack_require__.g.Map();
  9528. var Sidebar = /*#__PURE__*/function () {
  9529. function Sidebar() {
  9530. sidebar_classCallCheck(this, Sidebar);
  9531. this.timeout = null;
  9532. this.isOpen = false;
  9533. this.body = external_jQuery_default()('body');
  9534. this.matchMedia = __webpack_require__.g.matchMedia(MOBILE_QUERY);
  9535. this.enable();
  9536. }
  9537. sidebar_createClass(Sidebar, [{
  9538. key: "enable",
  9539. value: function enable() {
  9540. var sidebar = external_jQuery_default()('#admin-sidebar');
  9541. this.matchMedia.addListener(this._getBound('checkMatch'));
  9542. this.checkMatch(this.matchMedia);
  9543. this.body.on(EVENTS, '[data-sidebar-toggle]', this._getBound('toggleSidebarState'));
  9544. if (sidebar.data('quickopen')) {
  9545. sidebar.hover(this._getBound('quickOpenIn'), this._getBound('quickOpenOut'));
  9546. }
  9547. }
  9548. }, {
  9549. key: "disable",
  9550. value: function disable() {
  9551. var sidebar = external_jQuery_default()('#admin-sidebar');
  9552. this.close();
  9553. this.matchMedia.removeListener(this._getBound('checkMatch'));
  9554. this.body.off(EVENTS, '[data-sidebar-toggle]', this._getBound('toggleSidebarState'));
  9555. if (sidebar.data('quickopen')) {
  9556. sidebar.off('mouseenter mouseleave');
  9557. }
  9558. }
  9559. }, {
  9560. key: "attach",
  9561. value: function attach() {
  9562. this.body.on(EVENTS, TARGETS, this._getBound('toggle'));
  9563. }
  9564. }, {
  9565. key: "detach",
  9566. value: function detach() {
  9567. this.body.off(EVENTS, TARGETS, this._getBound('toggle'));
  9568. }
  9569. }, {
  9570. key: "quickOpenIn",
  9571. value: function
  9572. /* event */
  9573. quickOpenIn() {
  9574. var _this = this;
  9575. var isDesktop = __webpack_require__.g.matchMedia(DESKTOP_QUERY).matches;
  9576. var delay = external_jQuery_default()('#admin-sidebar').data('quickopen-delay') || 500;
  9577. if (this.body.hasClass('sidebar-mobile-open')) {
  9578. return;
  9579. }
  9580. var shouldQuickOpen = isDesktop ? this.body.hasClass('sidebar-closed') : !this.body.hasClass('sidebar-open');
  9581. if (!shouldQuickOpen && !this.body.hasClass('sidebar-quickopen')) {
  9582. return this.quickOpenOut();
  9583. }
  9584. this.timeout = setTimeout(function () {
  9585. _this.body.addClass('sidebar-open sidebar-quickopen');
  9586. external_jQuery_default()(__webpack_require__.g).trigger('sidebar_state._grav', isDesktop);
  9587. }, delay);
  9588. }
  9589. }, {
  9590. key: "quickOpenOut",
  9591. value: function
  9592. /* event */
  9593. quickOpenOut() {
  9594. clearTimeout(this.timeout);
  9595. if (this.body.hasClass('sidebar-quickopen')) {
  9596. this.body.removeClass('sidebar-open sidebar-quickopen');
  9597. }
  9598. return true;
  9599. }
  9600. }, {
  9601. key: "open",
  9602. value: function open(event) {
  9603. var _this2 = this;
  9604. var quick = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9605. if (event) {
  9606. event.preventDefault();
  9607. }
  9608. var overlay = external_jQuery_default()('#overlay');
  9609. var sidebar = external_jQuery_default()('#admin-sidebar');
  9610. this.body.addClass('sidebar-mobile-open');
  9611. overlay.css('display', 'block');
  9612. if (!quick) {
  9613. sidebar.css('display', 'block').animate({
  9614. opacity: 1
  9615. }, 200, function () {
  9616. _this2.isOpen = true;
  9617. });
  9618. } else {
  9619. sidebar.css({
  9620. display: 'block',
  9621. opacity: 1
  9622. });
  9623. this.isOpen = true;
  9624. }
  9625. }
  9626. }, {
  9627. key: "close",
  9628. value: function close(event) {
  9629. var _this3 = this;
  9630. var quick = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9631. if (event) {
  9632. event.preventDefault();
  9633. }
  9634. var overlay = external_jQuery_default()('#overlay');
  9635. var sidebar = external_jQuery_default()('#admin-sidebar');
  9636. this.body.removeClass('sidebar-mobile-open');
  9637. overlay.css('display', 'none');
  9638. if (!quick) {
  9639. sidebar.animate({
  9640. opacity: 0
  9641. }, 200, function () {
  9642. sidebar.css('display', 'none');
  9643. _this3.isOpen = false;
  9644. });
  9645. } else {
  9646. sidebar.css({
  9647. opacity: 0,
  9648. display: 'none'
  9649. });
  9650. this.isOpen = false;
  9651. }
  9652. }
  9653. }, {
  9654. key: "toggle",
  9655. value: function toggle(event) {
  9656. if (event) {
  9657. event.preventDefault();
  9658. }
  9659. return this[this.isOpen ? 'close' : 'open'](event);
  9660. }
  9661. }, {
  9662. key: "toggleSidebarState",
  9663. value: function toggleSidebarState(event) {
  9664. if (event) {
  9665. event.preventDefault();
  9666. }
  9667. clearTimeout(this.timeout);
  9668. var isDesktop = __webpack_require__.g.matchMedia(DESKTOP_QUERY).matches;
  9669. var cookie = null;
  9670. if (isDesktop) {
  9671. this.body.removeClass('sidebar-open');
  9672. }
  9673. if (!isDesktop) {
  9674. this.body.removeClass('sidebar-closed');
  9675. this.body.removeClass('sidebar-mobile-open');
  9676. }
  9677. this.body.toggleClass("sidebar-".concat(isDesktop ? 'closed' : 'open'));
  9678. external_jQuery_default()(__webpack_require__.g).trigger('sidebar_state._grav', isDesktop);
  9679. if (isDesktop) {
  9680. cookie = !this.body.hasClass('sidebar-closed');
  9681. } else {
  9682. cookie = this.body.hasClass('sidebar-open');
  9683. }
  9684. cookies.set('grav-admin-sidebar', cookie, {
  9685. expires: Infinity
  9686. });
  9687. }
  9688. }, {
  9689. key: "checkMatch",
  9690. value: function checkMatch(data) {
  9691. var sidebar = external_jQuery_default()('#admin-sidebar');
  9692. var overlay = external_jQuery_default()('#overlay');
  9693. this.isOpen = false;
  9694. overlay.css('display', 'none');
  9695. sidebar.css({
  9696. display: data.matches ? 'none' : 'inherit',
  9697. opacity: data.matches ? 0 : 1
  9698. });
  9699. if (data.matches) {
  9700. this.body.removeClass('sidebar-open sidebar-closed');
  9701. }
  9702. this[data.matches ? 'attach' : 'detach']();
  9703. }
  9704. }, {
  9705. key: "_resetMap",
  9706. value: function _resetMap() {
  9707. return map.clear();
  9708. }
  9709. }, {
  9710. key: "_getBound",
  9711. value: function _getBound(fn) {
  9712. if (map.has(fn)) {
  9713. return map.get(fn);
  9714. }
  9715. return map.set(fn, this[fn].bind(this)).get(fn);
  9716. }
  9717. }]);
  9718. return Sidebar;
  9719. }();
  9720. var sidebar_Instance = new Sidebar();
  9721. ;// CONCATENATED MODULE: ./app/main.js
  9722. // polyfills
  9723. // bootstrap jQuery extensions
  9724. // tabs memory
  9725. // changelog
  9726. // Main Sidebar
  9727. // starts the keep alive, auto runs every X seconds
  9728. keepalive.start(); // global event to catch sidebar_state changes
  9729. external_jQuery_default()(__webpack_require__.g).on('sidebar_state._grav', function () {
  9730. Object.keys(dashboard.Chart.Instances).forEach(function (chart) {
  9731. setTimeout(function () {
  9732. return dashboard.Chart.Instances[chart].chart.update();
  9733. }, 10);
  9734. });
  9735. });
  9736. /* harmony default export */ const main = ({
  9737. GPM: {
  9738. GPM: GPM,
  9739. Instance: gpm_Instance
  9740. },
  9741. KeepAlive: keepalive,
  9742. Dashboard: dashboard,
  9743. Pages: pages,
  9744. Forms: app_forms,
  9745. Updates: {
  9746. Updates: Updates,
  9747. Notifications: updates_notifications,
  9748. Feed: updates_feed,
  9749. Instance: updates_Instance
  9750. },
  9751. Sidebar: {
  9752. Sidebar: Sidebar,
  9753. Instance: sidebar_Instance
  9754. },
  9755. MediaFilter: {
  9756. MediaFilter: Filter,
  9757. Instance: app_media_Instance
  9758. },
  9759. Scrollbar: {
  9760. Scrollbar: {
  9761. deprecated: true
  9762. },
  9763. Instance: {
  9764. deprecated: true
  9765. }
  9766. },
  9767. Utils: {
  9768. request: utils_request,
  9769. toastr: utils_toastr,
  9770. Cookies: cookies,
  9771. UriToMarkdown: UriToMarkdown
  9772. }
  9773. });
  9774. /***/ }),
  9775. /***/ 19912:
  9776. /***/ ((module, exports, __webpack_require__) => {
  9777. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  9778. /*! version : 4.17.47
  9779. =========================================================
  9780. bootstrap-datetimejs
  9781. https://github.com/Eonasdan/bootstrap-datetimepicker
  9782. Copyright (c) 2015 Jonathan Peterson
  9783. =========================================================
  9784. */
  9785. /*
  9786. The MIT License (MIT)
  9787. Copyright (c) 2015 Jonathan Peterson
  9788. Permission is hereby granted, free of charge, to any person obtaining a copy
  9789. of this software and associated documentation files (the "Software"), to deal
  9790. in the Software without restriction, including without limitation the rights
  9791. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9792. copies of the Software, and to permit persons to whom the Software is
  9793. furnished to do so, subject to the following conditions:
  9794. The above copyright notice and this permission notice shall be included in
  9795. all copies or substantial portions of the Software.
  9796. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9797. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9798. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9799. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9800. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9801. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9802. THE SOFTWARE.
  9803. */
  9804. /* global define:false */
  9805. /* global jQuery:false */
  9806. /* global moment:false */
  9807. (function (factory) {
  9808. 'use strict';
  9809. if (true) {
  9810. // AMD is used - Register as an anonymous module.
  9811. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(65311), __webpack_require__(30381)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  9812. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  9813. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  9814. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  9815. } else {}
  9816. })(function ($, moment) {
  9817. 'use strict';
  9818. if (!moment) {
  9819. throw new Error('bootstrap-datetimepicker requires Moment.js to be loaded first');
  9820. }
  9821. var dateTimePicker = function dateTimePicker(element, options) {
  9822. var picker = {};
  9823. var date;
  9824. var viewDate;
  9825. var unset = true;
  9826. var input;
  9827. var component = false;
  9828. var widget = false;
  9829. var use24Hours;
  9830. var minViewModeNumber = 0;
  9831. var actualFormat;
  9832. var parseFormats;
  9833. var currentViewMode;
  9834. var datePickerModes = [{
  9835. clsName: 'days',
  9836. navFnc: 'M',
  9837. navStep: 1
  9838. }, {
  9839. clsName: 'months',
  9840. navFnc: 'y',
  9841. navStep: 1
  9842. }, {
  9843. clsName: 'years',
  9844. navFnc: 'y',
  9845. navStep: 10
  9846. }, {
  9847. clsName: 'decades',
  9848. navFnc: 'y',
  9849. navStep: 100
  9850. }];
  9851. var viewModes = ['days', 'months', 'years', 'decades'];
  9852. var verticalModes = ['top', 'bottom', 'auto'];
  9853. var horizontalModes = ['left', 'right', 'auto'];
  9854. var toolbarPlacements = ['default', 'top', 'bottom'];
  9855. var keyMap = {
  9856. 'up': 38,
  9857. 38: 'up',
  9858. 'down': 40,
  9859. 40: 'down',
  9860. 'left': 37,
  9861. 37: 'left',
  9862. 'right': 39,
  9863. 39: 'right',
  9864. 'tab': 9,
  9865. 9: 'tab',
  9866. 'escape': 27,
  9867. 27: 'escape',
  9868. 'enter': 13,
  9869. 13: 'enter',
  9870. 'pageUp': 33,
  9871. 33: 'pageUp',
  9872. 'pageDown': 34,
  9873. 34: 'pageDown',
  9874. 'shift': 16,
  9875. 16: 'shift',
  9876. 'control': 17,
  9877. 17: 'control',
  9878. 'space': 32,
  9879. 32: 'space',
  9880. 't': 84,
  9881. 84: 't',
  9882. 'delete': 46,
  9883. 46: 'delete'
  9884. };
  9885. var keyState = {};
  9886. /** ******************************************************************************
  9887. *
  9888. * Private functions
  9889. *
  9890. ********************************************************************************/
  9891. var hasTimeZone = function hasTimeZone() {
  9892. return moment.tz !== undefined && options.timeZone !== undefined && options.timeZone !== null && options.timeZone !== '';
  9893. };
  9894. var getMoment = function getMoment(d) {
  9895. var returnMoment;
  9896. if (d === undefined || d === null) {
  9897. returnMoment = moment(); // TODO should this use format? and locale?
  9898. } else if (moment.isDate(d) || moment.isMoment(d)) {
  9899. // If the date that is passed in is already a Date() or moment() object,
  9900. // pass it directly to moment.
  9901. returnMoment = moment(d);
  9902. } else if (hasTimeZone()) {
  9903. // There is a string to parse and a default time zone
  9904. // parse with the tz function which takes a default time zone if it is not in the format string
  9905. returnMoment = moment.tz(d, parseFormats, options.useStrict, options.timeZone);
  9906. } else {
  9907. returnMoment = moment(d, parseFormats, options.useStrict);
  9908. }
  9909. if (hasTimeZone()) {
  9910. returnMoment.tz(options.timeZone);
  9911. }
  9912. return returnMoment;
  9913. };
  9914. var isEnabled = function isEnabled(granularity) {
  9915. if (typeof granularity !== 'string' || granularity.length > 1) {
  9916. throw new TypeError('isEnabled expects a single character string parameter');
  9917. }
  9918. switch (granularity) {
  9919. case 'y':
  9920. return actualFormat.indexOf('Y') !== -1;
  9921. case 'M':
  9922. return actualFormat.indexOf('M') !== -1;
  9923. case 'd':
  9924. return actualFormat.toLowerCase().indexOf('d') !== -1;
  9925. case 'h':
  9926. case 'H':
  9927. return actualFormat.toLowerCase().indexOf('h') !== -1;
  9928. case 'm':
  9929. return actualFormat.indexOf('m') !== -1;
  9930. case 's':
  9931. return actualFormat.indexOf('s') !== -1;
  9932. default:
  9933. return false;
  9934. }
  9935. };
  9936. var hasTime = function hasTime() {
  9937. return isEnabled('h') || isEnabled('m') || isEnabled('s');
  9938. };
  9939. var hasDate = function hasDate() {
  9940. return isEnabled('y') || isEnabled('M') || isEnabled('d');
  9941. };
  9942. var getDatePickerTemplate = function getDatePickerTemplate() {
  9943. var headTemplate = $('<thead>').append($('<tr>').append($('<th>').addClass('prev').attr('data-action', 'previous').append($('<span>').addClass(options.icons.previous))).append($('<th>').addClass('picker-switch').attr('data-action', 'pickerSwitch').attr('colspan', options.calendarWeeks ? '6' : '5')).append($('<th>').addClass('next').attr('data-action', 'next').append($('<span>').addClass(options.icons.next))));
  9944. var contTemplate = $('<tbody>').append($('<tr>').append($('<td>').attr('colspan', options.calendarWeeks ? '8' : '7')));
  9945. return [$('<div>').addClass('datepicker-days').append($('<table>').addClass('table-condensed').append(headTemplate).append($('<tbody>'))), $('<div>').addClass('datepicker-months').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone())), $('<div>').addClass('datepicker-years').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone())), $('<div>').addClass('datepicker-decades').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone()))];
  9946. };
  9947. var getTimePickerMainTemplate = function getTimePickerMainTemplate() {
  9948. var topRow = $('<tr>');
  9949. var middleRow = $('<tr>');
  9950. var bottomRow = $('<tr>');
  9951. if (isEnabled('h')) {
  9952. topRow.append($('<td>').append($('<a>').attr({
  9953. href: '#',
  9954. tabindex: '-1',
  9955. 'title': options.tooltips.incrementHour
  9956. }).addClass('btn').attr('data-action', 'incrementHours').append($('<span>').addClass(options.icons.up))));
  9957. middleRow.append($('<td>').append($('<span>').addClass('timepicker-hour').attr({
  9958. 'data-time-component': 'hours',
  9959. 'title': options.tooltips.pickHour
  9960. }).attr('data-action', 'showHours')));
  9961. bottomRow.append($('<td>').append($('<a>').attr({
  9962. href: '#',
  9963. tabindex: '-1',
  9964. 'title': options.tooltips.decrementHour
  9965. }).addClass('btn').attr('data-action', 'decrementHours').append($('<span>').addClass(options.icons.down))));
  9966. }
  9967. if (isEnabled('m')) {
  9968. if (isEnabled('h')) {
  9969. topRow.append($('<td>').addClass('separator'));
  9970. middleRow.append($('<td>').addClass('separator').html(':'));
  9971. bottomRow.append($('<td>').addClass('separator'));
  9972. }
  9973. topRow.append($('<td>').append($('<a>').attr({
  9974. href: '#',
  9975. tabindex: '-1',
  9976. 'title': options.tooltips.incrementMinute
  9977. }).addClass('btn').attr('data-action', 'incrementMinutes').append($('<span>').addClass(options.icons.up))));
  9978. middleRow.append($('<td>').append($('<span>').addClass('timepicker-minute').attr({
  9979. 'data-time-component': 'minutes',
  9980. 'title': options.tooltips.pickMinute
  9981. }).attr('data-action', 'showMinutes')));
  9982. bottomRow.append($('<td>').append($('<a>').attr({
  9983. href: '#',
  9984. tabindex: '-1',
  9985. 'title': options.tooltips.decrementMinute
  9986. }).addClass('btn').attr('data-action', 'decrementMinutes').append($('<span>').addClass(options.icons.down))));
  9987. }
  9988. if (isEnabled('s')) {
  9989. if (isEnabled('m')) {
  9990. topRow.append($('<td>').addClass('separator'));
  9991. middleRow.append($('<td>').addClass('separator').html(':'));
  9992. bottomRow.append($('<td>').addClass('separator'));
  9993. }
  9994. topRow.append($('<td>').append($('<a>').attr({
  9995. href: '#',
  9996. tabindex: '-1',
  9997. 'title': options.tooltips.incrementSecond
  9998. }).addClass('btn').attr('data-action', 'incrementSeconds').append($('<span>').addClass(options.icons.up))));
  9999. middleRow.append($('<td>').append($('<span>').addClass('timepicker-second').attr({
  10000. 'data-time-component': 'seconds',
  10001. 'title': options.tooltips.pickSecond
  10002. }).attr('data-action', 'showSeconds')));
  10003. bottomRow.append($('<td>').append($('<a>').attr({
  10004. href: '#',
  10005. tabindex: '-1',
  10006. 'title': options.tooltips.decrementSecond
  10007. }).addClass('btn').attr('data-action', 'decrementSeconds').append($('<span>').addClass(options.icons.down))));
  10008. }
  10009. if (!use24Hours) {
  10010. topRow.append($('<td>').addClass('separator'));
  10011. middleRow.append($('<td>').append($('<button>').addClass('btn btn-primary').attr({
  10012. 'data-action': 'togglePeriod',
  10013. tabindex: '-1',
  10014. 'title': options.tooltips.togglePeriod
  10015. })));
  10016. bottomRow.append($('<td>').addClass('separator'));
  10017. }
  10018. return $('<div>').addClass('timepicker-picker').append($('<table>').addClass('table-condensed').append([topRow, middleRow, bottomRow]));
  10019. };
  10020. var getTimePickerTemplate = function getTimePickerTemplate() {
  10021. var hoursView = $('<div>').addClass('timepicker-hours').append($('<table>').addClass('table-condensed'));
  10022. var minutesView = $('<div>').addClass('timepicker-minutes').append($('<table>').addClass('table-condensed'));
  10023. var secondsView = $('<div>').addClass('timepicker-seconds').append($('<table>').addClass('table-condensed'));
  10024. var ret = [getTimePickerMainTemplate()];
  10025. if (isEnabled('h')) {
  10026. ret.push(hoursView);
  10027. }
  10028. if (isEnabled('m')) {
  10029. ret.push(minutesView);
  10030. }
  10031. if (isEnabled('s')) {
  10032. ret.push(secondsView);
  10033. }
  10034. return ret;
  10035. };
  10036. var getToolbar = function getToolbar() {
  10037. var row = [];
  10038. if (options.showTodayButton) {
  10039. row.push($('<td>').append($('<a>').attr({
  10040. 'data-action': 'today',
  10041. 'title': options.tooltips.today
  10042. }).append($('<span>').addClass(options.icons.today))));
  10043. }
  10044. if (!options.sideBySide && hasDate() && hasTime()) {
  10045. row.push($('<td>').append($('<a>').attr({
  10046. 'data-action': 'togglePicker',
  10047. 'title': options.tooltips.selectTime
  10048. }).append($('<span>').addClass(options.icons.time))));
  10049. }
  10050. if (options.showClear) {
  10051. row.push($('<td>').append($('<a>').attr({
  10052. 'data-action': 'clear',
  10053. 'title': options.tooltips.clear
  10054. }).append($('<span>').addClass(options.icons.clear))));
  10055. }
  10056. if (options.showClose) {
  10057. row.push($('<td>').append($('<a>').attr({
  10058. 'data-action': 'close',
  10059. 'title': options.tooltips.close
  10060. }).append($('<span>').addClass(options.icons.close))));
  10061. }
  10062. return $('<table>').addClass('table-condensed').append($('<tbody>').append($('<tr>').append(row)));
  10063. };
  10064. var getTemplate = function getTemplate() {
  10065. var template = $('<div>').addClass('bootstrap-datetimepicker-widget dropdown-menu');
  10066. var dateView = $('<div>').addClass('datepicker').append(getDatePickerTemplate());
  10067. var timeView = $('<div>').addClass('timepicker').append(getTimePickerTemplate());
  10068. var content = $('<ul>').addClass('list-unstyled');
  10069. var toolbar = $('<li>').addClass('picker-switch' + (options.collapse ? ' accordion-toggle' : '')).append(getToolbar());
  10070. if (options.inline) {
  10071. template.removeClass('dropdown-menu');
  10072. }
  10073. if (use24Hours) {
  10074. template.addClass('usetwentyfour');
  10075. }
  10076. if (isEnabled('s') && !use24Hours) {
  10077. template.addClass('wider');
  10078. }
  10079. if (options.sideBySide && hasDate() && hasTime()) {
  10080. template.addClass('timepicker-sbs');
  10081. if (options.toolbarPlacement === 'top') {
  10082. template.append(toolbar);
  10083. }
  10084. template.append($('<div>').addClass('row').append(dateView.addClass('col-md-6')).append(timeView.addClass('col-md-6')));
  10085. if (options.toolbarPlacement === 'bottom') {
  10086. template.append(toolbar);
  10087. }
  10088. return template;
  10089. }
  10090. if (options.toolbarPlacement === 'top') {
  10091. content.append(toolbar);
  10092. }
  10093. if (hasDate()) {
  10094. content.append($('<li>').addClass(options.collapse && hasTime() ? 'collapse in' : '').append(dateView));
  10095. }
  10096. if (options.toolbarPlacement === 'default') {
  10097. content.append(toolbar);
  10098. }
  10099. if (hasTime()) {
  10100. content.append($('<li>').addClass(options.collapse && hasDate() ? 'collapse' : '').append(timeView));
  10101. }
  10102. if (options.toolbarPlacement === 'bottom') {
  10103. content.append(toolbar);
  10104. }
  10105. return template.append(content);
  10106. };
  10107. var dataToOptions = function dataToOptions() {
  10108. var eData;
  10109. var dataOptions = {};
  10110. if (element.is('input') || options.inline) {
  10111. eData = element.data();
  10112. } else {
  10113. eData = element.find('input').data();
  10114. }
  10115. if (eData.dateOptions && eData.dateOptions instanceof Object) {
  10116. dataOptions = $.extend(true, dataOptions, eData.dateOptions);
  10117. }
  10118. $.each(options, function (key) {
  10119. var attributeName = 'date' + key.charAt(0).toUpperCase() + key.slice(1);
  10120. if (eData[attributeName] !== undefined) {
  10121. dataOptions[key] = eData[attributeName];
  10122. }
  10123. });
  10124. return dataOptions;
  10125. };
  10126. var place = function place() {
  10127. var position = (component || element).position();
  10128. var offset = (component || element).offset();
  10129. var vertical = options.widgetPositioning.vertical;
  10130. var horizontal = options.widgetPositioning.horizontal;
  10131. var parent;
  10132. if (options.widgetParent) {
  10133. parent = options.widgetParent.append(widget);
  10134. } else if (element.is('input')) {
  10135. parent = element.after(widget).parent();
  10136. } else if (options.inline) {
  10137. parent = element.append(widget);
  10138. return;
  10139. } else {
  10140. parent = element;
  10141. element.children().first().after(widget);
  10142. } // Top and bottom logic
  10143. if (vertical === 'auto') {
  10144. if (offset.top + widget.height() * 1.5 >= $(window).height() + $(window).scrollTop() && widget.height() + element.outerHeight() < offset.top) {
  10145. vertical = 'top';
  10146. } else {
  10147. vertical = 'bottom';
  10148. }
  10149. } // Left and right logic
  10150. if (horizontal === 'auto') {
  10151. if (parent.width() < offset.left + widget.outerWidth() / 2 && offset.left + widget.outerWidth() > $(window).width()) {
  10152. horizontal = 'right';
  10153. } else {
  10154. horizontal = 'left';
  10155. }
  10156. }
  10157. if (vertical === 'top') {
  10158. widget.addClass('top').removeClass('bottom');
  10159. } else {
  10160. widget.addClass('bottom').removeClass('top');
  10161. }
  10162. if (horizontal === 'right') {
  10163. widget.addClass('pull-right');
  10164. } else {
  10165. widget.removeClass('pull-right');
  10166. } // find the first parent element that has a non-static css positioning
  10167. if (parent.css('position') === 'static') {
  10168. parent = parent.parents().filter(function () {
  10169. return $(this).css('position') !== 'static';
  10170. }).first();
  10171. }
  10172. if (parent.length === 0) {
  10173. throw new Error('datetimepicker component should be placed within a non-static positioned container');
  10174. }
  10175. widget.css({
  10176. top: vertical === 'top' ? 'auto' : position.top + element.outerHeight(),
  10177. bottom: vertical === 'top' ? parent.outerHeight() - (parent === element ? 0 : position.top) : 'auto',
  10178. left: horizontal === 'left' ? parent === element ? 0 : position.left : 'auto',
  10179. right: horizontal === 'left' ? 'auto' : parent.outerWidth() - element.outerWidth() - (parent === element ? 0 : position.left)
  10180. });
  10181. };
  10182. var notifyEvent = function notifyEvent(e) {
  10183. if (e.type === 'dp.change' && (e.date && e.date.isSame(e.oldDate) || !e.date && !e.oldDate)) {
  10184. return;
  10185. }
  10186. element.trigger(e);
  10187. };
  10188. var viewUpdate = function viewUpdate(e) {
  10189. if (e === 'y') {
  10190. e = 'YYYY';
  10191. }
  10192. notifyEvent({
  10193. type: 'dp.update',
  10194. change: e,
  10195. viewDate: viewDate.clone()
  10196. });
  10197. };
  10198. var showMode = function showMode(dir) {
  10199. if (!widget) {
  10200. return;
  10201. }
  10202. if (dir) {
  10203. currentViewMode = Math.max(minViewModeNumber, Math.min(3, currentViewMode + dir));
  10204. }
  10205. widget.find('.datepicker > div').hide().filter('.datepicker-' + datePickerModes[currentViewMode].clsName).show();
  10206. };
  10207. var fillDow = function fillDow() {
  10208. var row = $('<tr>');
  10209. var currentDate = viewDate.clone().startOf('w').startOf('d');
  10210. if (options.calendarWeeks === true) {
  10211. row.append($('<th>').addClass('cw').text('#'));
  10212. }
  10213. while (currentDate.isBefore(viewDate.clone().endOf('w'))) {
  10214. row.append($('<th>').addClass('dow').text(currentDate.format('dd')));
  10215. currentDate.add(1, 'd');
  10216. }
  10217. widget.find('.datepicker-days thead').append(row);
  10218. };
  10219. var isInDisabledDates = function isInDisabledDates(testDate) {
  10220. return options.disabledDates[testDate.format('YYYY-MM-DD')] === true;
  10221. };
  10222. var isInEnabledDates = function isInEnabledDates(testDate) {
  10223. return options.enabledDates[testDate.format('YYYY-MM-DD')] === true;
  10224. };
  10225. var isInDisabledHours = function isInDisabledHours(testDate) {
  10226. return options.disabledHours[testDate.format('H')] === true;
  10227. };
  10228. var isInEnabledHours = function isInEnabledHours(testDate) {
  10229. return options.enabledHours[testDate.format('H')] === true;
  10230. };
  10231. var isValid = function isValid(targetMoment, granularity) {
  10232. if (!targetMoment.isValid()) {
  10233. return false;
  10234. }
  10235. if (options.disabledDates && granularity === 'd' && isInDisabledDates(targetMoment)) {
  10236. return false;
  10237. }
  10238. if (options.enabledDates && granularity === 'd' && !isInEnabledDates(targetMoment)) {
  10239. return false;
  10240. }
  10241. if (options.minDate && targetMoment.isBefore(options.minDate, granularity)) {
  10242. return false;
  10243. }
  10244. if (options.maxDate && targetMoment.isAfter(options.maxDate, granularity)) {
  10245. return false;
  10246. }
  10247. if (options.daysOfWeekDisabled && granularity === 'd' && options.daysOfWeekDisabled.indexOf(targetMoment.day()) !== -1) {
  10248. return false;
  10249. }
  10250. if (options.disabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && isInDisabledHours(targetMoment)) {
  10251. return false;
  10252. }
  10253. if (options.enabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && !isInEnabledHours(targetMoment)) {
  10254. return false;
  10255. }
  10256. if (options.disabledTimeIntervals && (granularity === 'h' || granularity === 'm' || granularity === 's')) {
  10257. var found = false;
  10258. $.each(options.disabledTimeIntervals, function () {
  10259. if (targetMoment.isBetween(this[0], this[1])) {
  10260. found = true;
  10261. return false;
  10262. }
  10263. });
  10264. if (found) {
  10265. return false;
  10266. }
  10267. }
  10268. return true;
  10269. };
  10270. var fillMonths = function fillMonths() {
  10271. var spans = [];
  10272. var monthsShort = viewDate.clone().startOf('y').startOf('d');
  10273. while (monthsShort.isSame(viewDate, 'y')) {
  10274. spans.push($('<span>').attr('data-action', 'selectMonth').addClass('month').text(monthsShort.format('MMM')));
  10275. monthsShort.add(1, 'M');
  10276. }
  10277. widget.find('.datepicker-months td').empty().append(spans);
  10278. };
  10279. var updateMonths = function updateMonths() {
  10280. var monthsView = widget.find('.datepicker-months');
  10281. var monthsViewHeader = monthsView.find('th');
  10282. var months = monthsView.find('tbody').find('span');
  10283. monthsViewHeader.eq(0).find('span').attr('title', options.tooltips.prevYear);
  10284. monthsViewHeader.eq(1).attr('title', options.tooltips.selectYear);
  10285. monthsViewHeader.eq(2).find('span').attr('title', options.tooltips.nextYear);
  10286. monthsView.find('.disabled').removeClass('disabled');
  10287. if (!isValid(viewDate.clone().subtract(1, 'y'), 'y')) {
  10288. monthsViewHeader.eq(0).addClass('disabled');
  10289. }
  10290. monthsViewHeader.eq(1).text(viewDate.year());
  10291. if (!isValid(viewDate.clone().add(1, 'y'), 'y')) {
  10292. monthsViewHeader.eq(2).addClass('disabled');
  10293. }
  10294. months.removeClass('active');
  10295. if (date.isSame(viewDate, 'y') && !unset) {
  10296. months.eq(date.month()).addClass('active');
  10297. }
  10298. months.each(function (index) {
  10299. if (!isValid(viewDate.clone().month(index), 'M')) {
  10300. $(this).addClass('disabled');
  10301. }
  10302. });
  10303. };
  10304. var updateYears = function updateYears() {
  10305. var yearsView = widget.find('.datepicker-years');
  10306. var yearsViewHeader = yearsView.find('th');
  10307. var startYear = viewDate.clone().subtract(5, 'y');
  10308. var endYear = viewDate.clone().add(6, 'y');
  10309. var html = '';
  10310. yearsViewHeader.eq(0).find('span').attr('title', options.tooltips.prevDecade);
  10311. yearsViewHeader.eq(1).attr('title', options.tooltips.selectDecade);
  10312. yearsViewHeader.eq(2).find('span').attr('title', options.tooltips.nextDecade);
  10313. yearsView.find('.disabled').removeClass('disabled');
  10314. if (options.minDate && options.minDate.isAfter(startYear, 'y')) {
  10315. yearsViewHeader.eq(0).addClass('disabled');
  10316. }
  10317. yearsViewHeader.eq(1).text(startYear.year() + '-' + endYear.year());
  10318. if (options.maxDate && options.maxDate.isBefore(endYear, 'y')) {
  10319. yearsViewHeader.eq(2).addClass('disabled');
  10320. }
  10321. while (!startYear.isAfter(endYear, 'y')) {
  10322. html += '<span data-action="selectYear" class="year' + (startYear.isSame(date, 'y') && !unset ? ' active' : '') + (!isValid(startYear, 'y') ? ' disabled' : '') + '">' + startYear.year() + '</span>';
  10323. startYear.add(1, 'y');
  10324. }
  10325. yearsView.find('td').html(html);
  10326. };
  10327. var updateDecades = function updateDecades() {
  10328. var decadesView = widget.find('.datepicker-decades');
  10329. var decadesViewHeader = decadesView.find('th');
  10330. var startDecade = moment({
  10331. y: viewDate.year() - viewDate.year() % 100 - 1
  10332. });
  10333. var endDecade = startDecade.clone().add(100, 'y');
  10334. var startedAt = startDecade.clone();
  10335. var minDateDecade = false;
  10336. var maxDateDecade = false;
  10337. var endDecadeYear;
  10338. var html = '';
  10339. decadesViewHeader.eq(0).find('span').attr('title', options.tooltips.prevCentury);
  10340. decadesViewHeader.eq(2).find('span').attr('title', options.tooltips.nextCentury);
  10341. decadesView.find('.disabled').removeClass('disabled');
  10342. if (startDecade.isSame(moment({
  10343. y: 1900
  10344. })) || options.minDate && options.minDate.isAfter(startDecade, 'y')) {
  10345. decadesViewHeader.eq(0).addClass('disabled');
  10346. }
  10347. decadesViewHeader.eq(1).text(startDecade.year() + '-' + endDecade.year());
  10348. if (startDecade.isSame(moment({
  10349. y: 2000
  10350. })) || options.maxDate && options.maxDate.isBefore(endDecade, 'y')) {
  10351. decadesViewHeader.eq(2).addClass('disabled');
  10352. }
  10353. while (!startDecade.isAfter(endDecade, 'y')) {
  10354. endDecadeYear = startDecade.year() + 12;
  10355. minDateDecade = options.minDate && options.minDate.isAfter(startDecade, 'y') && options.minDate.year() <= endDecadeYear;
  10356. maxDateDecade = options.maxDate && options.maxDate.isAfter(startDecade, 'y') && options.maxDate.year() <= endDecadeYear;
  10357. html += '<span data-action="selectDecade" class="decade' + (date.isAfter(startDecade) && date.year() <= endDecadeYear ? ' active' : '') + (!isValid(startDecade, 'y') && !minDateDecade && !maxDateDecade ? ' disabled' : '') + '" data-selection="' + (startDecade.year() + 6) + '">' + (startDecade.year() + 1) + ' - ' + (startDecade.year() + 12) + '</span>';
  10358. startDecade.add(12, 'y');
  10359. }
  10360. html += '<span></span><span></span><span></span>'; // push the dangling block over, at least this way it's even
  10361. decadesView.find('td').html(html);
  10362. decadesViewHeader.eq(1).text(startedAt.year() + 1 + '-' + startDecade.year());
  10363. };
  10364. var fillDate = function fillDate() {
  10365. var daysView = widget.find('.datepicker-days');
  10366. var daysViewHeader = daysView.find('th');
  10367. var currentDate;
  10368. var html = [];
  10369. var row;
  10370. var clsNames = [];
  10371. var i;
  10372. if (!hasDate()) {
  10373. return;
  10374. }
  10375. daysViewHeader.eq(0).find('span').attr('title', options.tooltips.prevMonth);
  10376. daysViewHeader.eq(1).attr('title', options.tooltips.selectMonth);
  10377. daysViewHeader.eq(2).find('span').attr('title', options.tooltips.nextMonth);
  10378. daysView.find('.disabled').removeClass('disabled');
  10379. daysViewHeader.eq(1).text(viewDate.format(options.dayViewHeaderFormat));
  10380. if (!isValid(viewDate.clone().subtract(1, 'M'), 'M')) {
  10381. daysViewHeader.eq(0).addClass('disabled');
  10382. }
  10383. if (!isValid(viewDate.clone().add(1, 'M'), 'M')) {
  10384. daysViewHeader.eq(2).addClass('disabled');
  10385. }
  10386. currentDate = viewDate.clone().startOf('M').startOf('w').startOf('d');
  10387. for (i = 0; i < 42; i++) {
  10388. // always display 42 days (should show 6 weeks)
  10389. if (currentDate.weekday() === 0) {
  10390. row = $('<tr>');
  10391. if (options.calendarWeeks) {
  10392. row.append('<td class="cw">' + currentDate.week() + '</td>');
  10393. }
  10394. html.push(row);
  10395. }
  10396. clsNames = ['day'];
  10397. if (currentDate.isBefore(viewDate, 'M')) {
  10398. clsNames.push('old');
  10399. }
  10400. if (currentDate.isAfter(viewDate, 'M')) {
  10401. clsNames.push('new');
  10402. }
  10403. if (currentDate.isSame(date, 'd') && !unset) {
  10404. clsNames.push('active');
  10405. }
  10406. if (!isValid(currentDate, 'd')) {
  10407. clsNames.push('disabled');
  10408. }
  10409. if (currentDate.isSame(getMoment(), 'd')) {
  10410. clsNames.push('today');
  10411. }
  10412. if (currentDate.day() === 0 || currentDate.day() === 6) {
  10413. clsNames.push('weekend');
  10414. }
  10415. notifyEvent({
  10416. type: 'dp.classify',
  10417. date: currentDate,
  10418. classNames: clsNames
  10419. });
  10420. row.append('<td data-action="selectDay" data-day="' + currentDate.format('L') + '" class="' + clsNames.join(' ') + '">' + currentDate.date() + '</td>');
  10421. currentDate.add(1, 'd');
  10422. }
  10423. daysView.find('tbody').empty().append(html);
  10424. updateMonths();
  10425. updateYears();
  10426. updateDecades();
  10427. };
  10428. var fillHours = function fillHours() {
  10429. var table = widget.find('.timepicker-hours table');
  10430. var currentHour = viewDate.clone().startOf('d');
  10431. var html = [];
  10432. var row = $('<tr>');
  10433. if (viewDate.hour() > 11 && !use24Hours) {
  10434. currentHour.hour(12);
  10435. }
  10436. while (currentHour.isSame(viewDate, 'd') && (use24Hours || viewDate.hour() < 12 && currentHour.hour() < 12 || viewDate.hour() > 11)) {
  10437. if (currentHour.hour() % 4 === 0) {
  10438. row = $('<tr>');
  10439. html.push(row);
  10440. }
  10441. row.append('<td data-action="selectHour" class="hour' + (!isValid(currentHour, 'h') ? ' disabled' : '') + '">' + currentHour.format(use24Hours ? 'HH' : 'hh') + '</td>');
  10442. currentHour.add(1, 'h');
  10443. }
  10444. table.empty().append(html);
  10445. };
  10446. var fillMinutes = function fillMinutes() {
  10447. var table = widget.find('.timepicker-minutes table');
  10448. var currentMinute = viewDate.clone().startOf('h');
  10449. var html = [];
  10450. var row = $('<tr>');
  10451. var step = options.stepping === 1 ? 5 : options.stepping;
  10452. while (viewDate.isSame(currentMinute, 'h')) {
  10453. if (currentMinute.minute() % (step * 4) === 0) {
  10454. row = $('<tr>');
  10455. html.push(row);
  10456. }
  10457. row.append('<td data-action="selectMinute" class="minute' + (!isValid(currentMinute, 'm') ? ' disabled' : '') + '">' + currentMinute.format('mm') + '</td>');
  10458. currentMinute.add(step, 'm');
  10459. }
  10460. table.empty().append(html);
  10461. };
  10462. var fillSeconds = function fillSeconds() {
  10463. var table = widget.find('.timepicker-seconds table');
  10464. var currentSecond = viewDate.clone().startOf('m');
  10465. var html = [];
  10466. var row = $('<tr>');
  10467. while (viewDate.isSame(currentSecond, 'm')) {
  10468. if (currentSecond.second() % 20 === 0) {
  10469. row = $('<tr>');
  10470. html.push(row);
  10471. }
  10472. row.append('<td data-action="selectSecond" class="second' + (!isValid(currentSecond, 's') ? ' disabled' : '') + '">' + currentSecond.format('ss') + '</td>');
  10473. currentSecond.add(5, 's');
  10474. }
  10475. table.empty().append(html);
  10476. };
  10477. var fillTime = function fillTime() {
  10478. var toggle;
  10479. var newDate;
  10480. var timeComponents = widget.find('.timepicker span[data-time-component]');
  10481. if (!use24Hours) {
  10482. toggle = widget.find('.timepicker [data-action=togglePeriod]');
  10483. newDate = date.clone().add(date.hours() >= 12 ? -12 : 12, 'h');
  10484. toggle.text(date.format('A'));
  10485. if (isValid(newDate, 'h')) {
  10486. toggle.removeClass('disabled');
  10487. } else {
  10488. toggle.addClass('disabled');
  10489. }
  10490. }
  10491. timeComponents.filter('[data-time-component=hours]').text(date.format(use24Hours ? 'HH' : 'hh'));
  10492. timeComponents.filter('[data-time-component=minutes]').text(date.format('mm'));
  10493. timeComponents.filter('[data-time-component=seconds]').text(date.format('ss'));
  10494. fillHours();
  10495. fillMinutes();
  10496. fillSeconds();
  10497. };
  10498. var update = function update() {
  10499. if (!widget) {
  10500. return;
  10501. }
  10502. fillDate();
  10503. fillTime();
  10504. };
  10505. var setValue = function setValue(targetMoment) {
  10506. var oldDate = unset ? null : date; // case of calling setValue(null or false)
  10507. if (!targetMoment) {
  10508. unset = true;
  10509. input.val('');
  10510. element.data('date', '');
  10511. notifyEvent({
  10512. type: 'dp.change',
  10513. date: false,
  10514. oldDate: oldDate
  10515. });
  10516. update();
  10517. return;
  10518. }
  10519. targetMoment = targetMoment.clone().locale(options.locale);
  10520. if (hasTimeZone()) {
  10521. targetMoment.tz(options.timeZone);
  10522. }
  10523. if (options.stepping !== 1) {
  10524. targetMoment.minutes(Math.round(targetMoment.minutes() / options.stepping) * options.stepping).seconds(0);
  10525. while (options.minDate && targetMoment.isBefore(options.minDate)) {
  10526. targetMoment.add(options.stepping, 'minutes');
  10527. }
  10528. }
  10529. if (isValid(targetMoment)) {
  10530. date = targetMoment;
  10531. viewDate = date.clone();
  10532. input.val(date.format(actualFormat));
  10533. element.data('date', date.format(actualFormat));
  10534. unset = false;
  10535. update();
  10536. notifyEvent({
  10537. type: 'dp.change',
  10538. date: date.clone(),
  10539. oldDate: oldDate
  10540. });
  10541. } else {
  10542. if (!options.keepInvalid) {
  10543. input.val(unset ? '' : date.format(actualFormat));
  10544. } else {
  10545. notifyEvent({
  10546. type: 'dp.change',
  10547. date: targetMoment,
  10548. oldDate: oldDate
  10549. });
  10550. }
  10551. notifyEvent({
  10552. type: 'dp.error',
  10553. date: targetMoment,
  10554. oldDate: oldDate
  10555. });
  10556. }
  10557. };
  10558. /**
  10559. * Hides the widget. Possibly will emit dp.hide
  10560. */
  10561. var hide = function hide() {
  10562. var transitioning = false;
  10563. if (!widget) {
  10564. return picker;
  10565. } // Ignore event if in the middle of a picker transition
  10566. widget.find('.collapse').each(function () {
  10567. var collapseData = $(this).data('collapse');
  10568. if (collapseData && collapseData.transitioning) {
  10569. transitioning = true;
  10570. return false;
  10571. }
  10572. return true;
  10573. });
  10574. if (transitioning) {
  10575. return picker;
  10576. }
  10577. if (component && component.hasClass('btn')) {
  10578. component.toggleClass('active');
  10579. }
  10580. widget.hide();
  10581. $(window).off('resize', place);
  10582. widget.off('click', '[data-action]');
  10583. widget.off('mousedown', false);
  10584. widget.remove();
  10585. widget = false;
  10586. notifyEvent({
  10587. type: 'dp.hide',
  10588. date: date.clone()
  10589. });
  10590. input.blur();
  10591. viewDate = date.clone();
  10592. return picker;
  10593. };
  10594. var clear = function clear() {
  10595. setValue(null);
  10596. };
  10597. var parseInputDate = function parseInputDate(inputDate) {
  10598. if (options.parseInputDate === undefined) {
  10599. if (!moment.isMoment(inputDate) || inputDate instanceof Date) {
  10600. inputDate = getMoment(inputDate);
  10601. }
  10602. } else {
  10603. inputDate = options.parseInputDate(inputDate);
  10604. } // inputDate.locale(options.locale);
  10605. return inputDate;
  10606. };
  10607. /** ******************************************************************************
  10608. *
  10609. * Widget UI interaction functions
  10610. *
  10611. ********************************************************************************/
  10612. var actions = {
  10613. next: function next() {
  10614. var navFnc = datePickerModes[currentViewMode].navFnc;
  10615. viewDate.add(datePickerModes[currentViewMode].navStep, navFnc);
  10616. fillDate();
  10617. viewUpdate(navFnc);
  10618. },
  10619. previous: function previous() {
  10620. var navFnc = datePickerModes[currentViewMode].navFnc;
  10621. viewDate.subtract(datePickerModes[currentViewMode].navStep, navFnc);
  10622. fillDate();
  10623. viewUpdate(navFnc);
  10624. },
  10625. pickerSwitch: function pickerSwitch() {
  10626. showMode(1);
  10627. },
  10628. selectMonth: function selectMonth(e) {
  10629. var month = $(e.target).closest('tbody').find('span').index($(e.target));
  10630. viewDate.month(month);
  10631. if (currentViewMode === minViewModeNumber) {
  10632. setValue(date.clone().year(viewDate.year()).month(viewDate.month()));
  10633. if (!options.inline) {
  10634. hide();
  10635. }
  10636. } else {
  10637. showMode(-1);
  10638. fillDate();
  10639. }
  10640. viewUpdate('M');
  10641. },
  10642. selectYear: function selectYear(e) {
  10643. var year = parseInt($(e.target).text(), 10) || 0;
  10644. viewDate.year(year);
  10645. if (currentViewMode === minViewModeNumber) {
  10646. setValue(date.clone().year(viewDate.year()));
  10647. if (!options.inline) {
  10648. hide();
  10649. }
  10650. } else {
  10651. showMode(-1);
  10652. fillDate();
  10653. }
  10654. viewUpdate('YYYY');
  10655. },
  10656. selectDecade: function selectDecade(e) {
  10657. var year = parseInt($(e.target).data('selection'), 10) || 0;
  10658. viewDate.year(year);
  10659. if (currentViewMode === minViewModeNumber) {
  10660. setValue(date.clone().year(viewDate.year()));
  10661. if (!options.inline) {
  10662. hide();
  10663. }
  10664. } else {
  10665. showMode(-1);
  10666. fillDate();
  10667. }
  10668. viewUpdate('YYYY');
  10669. },
  10670. selectDay: function selectDay(e) {
  10671. var day = viewDate.clone();
  10672. if ($(e.target).is('.old')) {
  10673. day.subtract(1, 'M');
  10674. }
  10675. if ($(e.target).is('.new')) {
  10676. day.add(1, 'M');
  10677. }
  10678. setValue(day.date(parseInt($(e.target).text(), 10)));
  10679. if (!hasTime() && !options.keepOpen && !options.inline) {
  10680. hide();
  10681. }
  10682. },
  10683. incrementHours: function incrementHours() {
  10684. var newDate = date.clone().add(1, 'h');
  10685. if (isValid(newDate, 'h')) {
  10686. setValue(newDate);
  10687. }
  10688. },
  10689. incrementMinutes: function incrementMinutes() {
  10690. var newDate = date.clone().add(options.stepping, 'm');
  10691. if (isValid(newDate, 'm')) {
  10692. setValue(newDate);
  10693. }
  10694. },
  10695. incrementSeconds: function incrementSeconds() {
  10696. var newDate = date.clone().add(1, 's');
  10697. if (isValid(newDate, 's')) {
  10698. setValue(newDate);
  10699. }
  10700. },
  10701. decrementHours: function decrementHours() {
  10702. var newDate = date.clone().subtract(1, 'h');
  10703. if (isValid(newDate, 'h')) {
  10704. setValue(newDate);
  10705. }
  10706. },
  10707. decrementMinutes: function decrementMinutes() {
  10708. var newDate = date.clone().subtract(options.stepping, 'm');
  10709. if (isValid(newDate, 'm')) {
  10710. setValue(newDate);
  10711. }
  10712. },
  10713. decrementSeconds: function decrementSeconds() {
  10714. var newDate = date.clone().subtract(1, 's');
  10715. if (isValid(newDate, 's')) {
  10716. setValue(newDate);
  10717. }
  10718. },
  10719. togglePeriod: function togglePeriod() {
  10720. setValue(date.clone().add(date.hours() >= 12 ? -12 : 12, 'h'));
  10721. },
  10722. togglePicker: function togglePicker(e) {
  10723. var $this = $(e.target);
  10724. var $parent = $this.closest('ul');
  10725. var expanded = $parent.find('.in');
  10726. var closed = $parent.find('.collapse:not(.in)');
  10727. var collapseData;
  10728. if (expanded && expanded.length) {
  10729. collapseData = expanded.data('collapse');
  10730. if (collapseData && collapseData.transitioning) {
  10731. return;
  10732. }
  10733. if (expanded.collapse) {
  10734. // if collapse plugin is available through bootstrap.js then use it
  10735. expanded.collapse('hide');
  10736. closed.collapse('show');
  10737. } else {
  10738. // otherwise just toggle in class on the two views
  10739. expanded.removeClass('in');
  10740. closed.addClass('in');
  10741. }
  10742. if ($this.is('span')) {
  10743. $this.toggleClass(options.icons.time + ' ' + options.icons.date);
  10744. } else {
  10745. $this.find('span').toggleClass(options.icons.time + ' ' + options.icons.date);
  10746. } // NOTE: uncomment if toggled state will be restored in show()
  10747. // if (component) {
  10748. // component.find('span').toggleClass(options.icons.time + ' ' + options.icons.date);
  10749. // }
  10750. }
  10751. },
  10752. showPicker: function showPicker() {
  10753. widget.find('.timepicker > div:not(.timepicker-picker)').hide();
  10754. widget.find('.timepicker .timepicker-picker').show();
  10755. },
  10756. showHours: function showHours() {
  10757. widget.find('.timepicker .timepicker-picker').hide();
  10758. widget.find('.timepicker .timepicker-hours').show();
  10759. },
  10760. showMinutes: function showMinutes() {
  10761. widget.find('.timepicker .timepicker-picker').hide();
  10762. widget.find('.timepicker .timepicker-minutes').show();
  10763. },
  10764. showSeconds: function showSeconds() {
  10765. widget.find('.timepicker .timepicker-picker').hide();
  10766. widget.find('.timepicker .timepicker-seconds').show();
  10767. },
  10768. selectHour: function selectHour(e) {
  10769. var hour = parseInt($(e.target).text(), 10);
  10770. if (!use24Hours) {
  10771. if (date.hours() >= 12) {
  10772. if (hour !== 12) {
  10773. hour += 12;
  10774. }
  10775. } else {
  10776. if (hour === 12) {
  10777. hour = 0;
  10778. }
  10779. }
  10780. }
  10781. setValue(date.clone().hours(hour));
  10782. actions.showPicker.call(picker);
  10783. },
  10784. selectMinute: function selectMinute(e) {
  10785. setValue(date.clone().minutes(parseInt($(e.target).text(), 10)));
  10786. actions.showPicker.call(picker);
  10787. },
  10788. selectSecond: function selectSecond(e) {
  10789. setValue(date.clone().seconds(parseInt($(e.target).text(), 10)));
  10790. actions.showPicker.call(picker);
  10791. },
  10792. clear: clear,
  10793. today: function today() {
  10794. var todaysDate = getMoment();
  10795. if (isValid(todaysDate, 'd')) {
  10796. setValue(todaysDate);
  10797. }
  10798. },
  10799. close: hide
  10800. };
  10801. var doAction = function doAction(e) {
  10802. if ($(e.currentTarget).is('.disabled')) {
  10803. return false;
  10804. }
  10805. actions[$(e.currentTarget).data('action')].apply(picker, arguments);
  10806. return false;
  10807. };
  10808. /**
  10809. * Shows the widget. Possibly will emit dp.show and dp.change
  10810. */
  10811. var show = function show() {
  10812. var currentMoment;
  10813. var useCurrentGranularity = {
  10814. 'year': function year(m) {
  10815. return m.month(0).date(1).hours(0).seconds(0).minutes(0);
  10816. },
  10817. 'month': function month(m) {
  10818. return m.date(1).hours(0).seconds(0).minutes(0);
  10819. },
  10820. 'day': function day(m) {
  10821. return m.hours(0).seconds(0).minutes(0);
  10822. },
  10823. 'hour': function hour(m) {
  10824. return m.seconds(0).minutes(0);
  10825. },
  10826. 'minute': function minute(m) {
  10827. return m.seconds(0);
  10828. }
  10829. };
  10830. if (input.prop('disabled') || !options.ignoreReadonly && input.prop('readonly') || widget) {
  10831. return picker;
  10832. }
  10833. if (input.val() !== undefined && input.val().trim().length !== 0) {
  10834. setValue(parseInputDate(input.val().trim()));
  10835. } else if (unset && options.useCurrent && (options.inline || input.is('input') && input.val().trim().length === 0)) {
  10836. currentMoment = getMoment();
  10837. if (typeof options.useCurrent === 'string') {
  10838. currentMoment = useCurrentGranularity[options.useCurrent](currentMoment);
  10839. }
  10840. setValue(currentMoment);
  10841. }
  10842. widget = getTemplate();
  10843. fillDow();
  10844. fillMonths();
  10845. widget.find('.timepicker-hours').hide();
  10846. widget.find('.timepicker-minutes').hide();
  10847. widget.find('.timepicker-seconds').hide();
  10848. update();
  10849. showMode();
  10850. $(window).on('resize', place);
  10851. widget.on('click', '[data-action]', doAction); // this handles clicks on the widget
  10852. widget.on('mousedown', false);
  10853. if (component && component.hasClass('btn')) {
  10854. component.toggleClass('active');
  10855. }
  10856. place();
  10857. widget.show();
  10858. if (options.focusOnShow && !input.is(':focus')) {
  10859. input.focus();
  10860. }
  10861. notifyEvent({
  10862. type: 'dp.show'
  10863. });
  10864. return picker;
  10865. };
  10866. /**
  10867. * Shows or hides the widget
  10868. */
  10869. var toggle = function toggle() {
  10870. return widget ? hide() : show();
  10871. };
  10872. var keydown = function keydown(e) {
  10873. var handler = null;
  10874. var index;
  10875. var index2;
  10876. var pressedKeys = [];
  10877. var pressedModifiers = {};
  10878. var currentKey = e.which;
  10879. var keyBindKeys;
  10880. var allModifiersPressed;
  10881. var pressed = 'p';
  10882. keyState[currentKey] = pressed;
  10883. for (index in keyState) {
  10884. if (keyState.hasOwnProperty(index) && keyState[index] === pressed) {
  10885. pressedKeys.push(index);
  10886. if (parseInt(index, 10) !== currentKey) {
  10887. pressedModifiers[index] = true;
  10888. }
  10889. }
  10890. }
  10891. for (index in options.keyBinds) {
  10892. if (options.keyBinds.hasOwnProperty(index) && typeof options.keyBinds[index] === 'function') {
  10893. keyBindKeys = index.split(' ');
  10894. if (keyBindKeys.length === pressedKeys.length && keyMap[currentKey] === keyBindKeys[keyBindKeys.length - 1]) {
  10895. allModifiersPressed = true;
  10896. for (index2 = keyBindKeys.length - 2; index2 >= 0; index2--) {
  10897. if (!(keyMap[keyBindKeys[index2]] in pressedModifiers)) {
  10898. allModifiersPressed = false;
  10899. break;
  10900. }
  10901. }
  10902. if (allModifiersPressed) {
  10903. handler = options.keyBinds[index];
  10904. break;
  10905. }
  10906. }
  10907. }
  10908. }
  10909. if (handler) {
  10910. handler.call(picker, widget);
  10911. e.stopPropagation();
  10912. e.preventDefault();
  10913. }
  10914. };
  10915. var keyup = function keyup(e) {
  10916. keyState[e.which] = 'r';
  10917. e.stopPropagation();
  10918. e.preventDefault();
  10919. };
  10920. var change = function change(e) {
  10921. var val = $(e.target).val().trim();
  10922. var parsedDate = val ? parseInputDate(val) : null;
  10923. setValue(parsedDate);
  10924. e.stopImmediatePropagation();
  10925. return false;
  10926. };
  10927. var attachDatePickerElementEvents = function attachDatePickerElementEvents() {
  10928. input.on({
  10929. 'change': change,
  10930. 'blur': options.debug ? '' : hide,
  10931. 'keydown': keydown,
  10932. 'keyup': keyup,
  10933. 'focus': options.allowInputToggle ? show : ''
  10934. });
  10935. if (element.is('input')) {
  10936. input.on({
  10937. 'focus': show
  10938. });
  10939. } else if (component) {
  10940. component.on('click', toggle);
  10941. component.on('mousedown', false);
  10942. }
  10943. };
  10944. var detachDatePickerElementEvents = function detachDatePickerElementEvents() {
  10945. input.off({
  10946. 'change': change,
  10947. 'blur': blur,
  10948. 'keydown': keydown,
  10949. 'keyup': keyup,
  10950. 'focus': options.allowInputToggle ? hide : ''
  10951. });
  10952. if (element.is('input')) {
  10953. input.off({
  10954. 'focus': show
  10955. });
  10956. } else if (component) {
  10957. component.off('click', toggle);
  10958. component.off('mousedown', false);
  10959. }
  10960. };
  10961. var indexGivenDates = function indexGivenDates(givenDatesArray) {
  10962. // Store given enabledDates and disabledDates as keys.
  10963. // This way we can check their existence in O(1) time instead of looping through whole array.
  10964. // (for example: options.enabledDates['2014-02-27'] === true)
  10965. var givenDatesIndexed = {};
  10966. $.each(givenDatesArray, function () {
  10967. var dDate = parseInputDate(this);
  10968. if (dDate.isValid()) {
  10969. givenDatesIndexed[dDate.format('YYYY-MM-DD')] = true;
  10970. }
  10971. });
  10972. return Object.keys(givenDatesIndexed).length ? givenDatesIndexed : false;
  10973. };
  10974. var indexGivenHours = function indexGivenHours(givenHoursArray) {
  10975. // Store given enabledHours and disabledHours as keys.
  10976. // This way we can check their existence in O(1) time instead of looping through whole array.
  10977. // (for example: options.enabledHours['2014-02-27'] === true)
  10978. var givenHoursIndexed = {};
  10979. $.each(givenHoursArray, function () {
  10980. givenHoursIndexed[this] = true;
  10981. });
  10982. return Object.keys(givenHoursIndexed).length ? givenHoursIndexed : false;
  10983. };
  10984. var initFormatting = function initFormatting() {
  10985. var format = options.format || 'L LT';
  10986. actualFormat = format.replace(/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, function (formatInput) {
  10987. var newinput = date.localeData().longDateFormat(formatInput) || formatInput;
  10988. return newinput.replace(/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, function (formatInput2) {
  10989. // temp fix for #740
  10990. return date.localeData().longDateFormat(formatInput2) || formatInput2;
  10991. });
  10992. });
  10993. parseFormats = options.extraFormats ? options.extraFormats.slice() : [];
  10994. if (parseFormats.indexOf(format) < 0 && parseFormats.indexOf(actualFormat) < 0) {
  10995. parseFormats.push(actualFormat);
  10996. }
  10997. use24Hours = actualFormat.toLowerCase().indexOf('a') < 1 && actualFormat.replace(/\[.*?\]/g, '').indexOf('h') < 1;
  10998. if (isEnabled('y')) {
  10999. minViewModeNumber = 2;
  11000. }
  11001. if (isEnabled('M')) {
  11002. minViewModeNumber = 1;
  11003. }
  11004. if (isEnabled('d')) {
  11005. minViewModeNumber = 0;
  11006. }
  11007. currentViewMode = Math.max(minViewModeNumber, currentViewMode);
  11008. if (!unset) {
  11009. setValue(date);
  11010. }
  11011. };
  11012. /** ******************************************************************************
  11013. *
  11014. * Public API functions
  11015. * =====================
  11016. *
  11017. * Important: Do not expose direct references to private objects or the options
  11018. * object to the outer world. Always return a clone when returning values or make
  11019. * a clone when setting a private variable.
  11020. *
  11021. ********************************************************************************/
  11022. picker.destroy = function () {
  11023. // /<summary>Destroys the widget and removes all attached event listeners</summary>
  11024. hide();
  11025. detachDatePickerElementEvents();
  11026. element.removeData('DateTimePicker');
  11027. element.removeData('date');
  11028. };
  11029. picker.toggle = toggle;
  11030. picker.show = show;
  11031. picker.hide = hide;
  11032. picker.disable = function () {
  11033. // /<summary>Disables the input element, the component is attached to, by adding a disabled="true" attribute to it.
  11034. // /If the widget was visible before that call it is hidden. Possibly emits dp.hide</summary>
  11035. hide();
  11036. if (component && component.hasClass('btn')) {
  11037. component.addClass('disabled');
  11038. }
  11039. input.prop('disabled', true);
  11040. return picker;
  11041. };
  11042. picker.enable = function () {
  11043. // /<summary>Enables the input element, the component is attached to, by removing disabled attribute from it.</summary>
  11044. if (component && component.hasClass('btn')) {
  11045. component.removeClass('disabled');
  11046. }
  11047. input.prop('disabled', false);
  11048. return picker;
  11049. };
  11050. picker.ignoreReadonly = function (ignoreReadonly) {
  11051. if (arguments.length === 0) {
  11052. return options.ignoreReadonly;
  11053. }
  11054. if (typeof ignoreReadonly !== 'boolean') {
  11055. throw new TypeError('ignoreReadonly () expects a boolean parameter');
  11056. }
  11057. options.ignoreReadonly = ignoreReadonly;
  11058. return picker;
  11059. };
  11060. picker.options = function (newOptions) {
  11061. if (arguments.length === 0) {
  11062. return $.extend(true, {}, options);
  11063. }
  11064. if (!(newOptions instanceof Object)) {
  11065. throw new TypeError('options() options parameter should be an object');
  11066. }
  11067. $.extend(true, options, newOptions);
  11068. $.each(options, function (key, value) {
  11069. if (picker[key] !== undefined) {
  11070. picker[key](value);
  11071. } else {
  11072. throw new TypeError('option ' + key + ' is not recognized!');
  11073. }
  11074. });
  11075. return picker;
  11076. };
  11077. picker.date = function (newDate) {
  11078. // /<signature helpKeyword="$.fn.datetimepicker.date">
  11079. // /<summary>Returns the component's model current date, a moment object or null if not set.</summary>
  11080. // /<returns type="Moment">date.clone()</returns>
  11081. // /</signature>
  11082. // /<signature>
  11083. // /<summary>Sets the components model current moment to it. Passing a null value unsets the components model current moment. Parsing of the newDate parameter is made using moment library with the options.format and options.useStrict components configuration.</summary>
  11084. // /<param name="newDate" locid="$.fn.datetimepicker.date_p:newDate">Takes string, Date, moment, null parameter.</param>
  11085. // /</signature>
  11086. if (arguments.length === 0) {
  11087. if (unset) {
  11088. return null;
  11089. }
  11090. return date.clone();
  11091. }
  11092. if (newDate !== null && typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
  11093. throw new TypeError('date() parameter must be one of [null, string, moment or Date]');
  11094. }
  11095. setValue(newDate === null ? null : parseInputDate(newDate));
  11096. return picker;
  11097. };
  11098. picker.format = function (newFormat) {
  11099. // /<summary>test su</summary>
  11100. // /<param name="newFormat">info about para</param>
  11101. // /<returns type="string|boolean">returns foo</returns>
  11102. if (arguments.length === 0) {
  11103. return options.format;
  11104. }
  11105. if (typeof newFormat !== 'string' && (typeof newFormat !== 'boolean' || newFormat !== false)) {
  11106. throw new TypeError('format() expects a string or boolean:false parameter ' + newFormat);
  11107. }
  11108. options.format = newFormat;
  11109. if (actualFormat) {
  11110. initFormatting(); // reinit formatting
  11111. }
  11112. return picker;
  11113. };
  11114. picker.timeZone = function (newZone) {
  11115. if (arguments.length === 0) {
  11116. return options.timeZone;
  11117. }
  11118. if (typeof newZone !== 'string') {
  11119. throw new TypeError('newZone() expects a string parameter');
  11120. }
  11121. options.timeZone = newZone;
  11122. return picker;
  11123. };
  11124. picker.dayViewHeaderFormat = function (newFormat) {
  11125. if (arguments.length === 0) {
  11126. return options.dayViewHeaderFormat;
  11127. }
  11128. if (typeof newFormat !== 'string') {
  11129. throw new TypeError('dayViewHeaderFormat() expects a string parameter');
  11130. }
  11131. options.dayViewHeaderFormat = newFormat;
  11132. return picker;
  11133. };
  11134. picker.extraFormats = function (formats) {
  11135. if (arguments.length === 0) {
  11136. return options.extraFormats;
  11137. }
  11138. if (formats !== false && !(formats instanceof Array)) {
  11139. throw new TypeError('extraFormats() expects an array or false parameter');
  11140. }
  11141. options.extraFormats = formats;
  11142. if (parseFormats) {
  11143. initFormatting(); // reinit formatting
  11144. }
  11145. return picker;
  11146. };
  11147. picker.disabledDates = function (dates) {
  11148. // /<signature helpKeyword="$.fn.datetimepicker.disabledDates">
  11149. // /<summary>Returns an array with the currently set disabled dates on the component.</summary>
  11150. // /<returns type="array">options.disabledDates</returns>
  11151. // /</signature>
  11152. // /<signature>
  11153. // /<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
  11154. // /options.enabledDates if such exist.</summary>
  11155. // /<param name="dates" locid="$.fn.datetimepicker.disabledDates_p:dates">Takes an [ string or Date or moment ] of values and allows the user to select only from those days.</param>
  11156. // /</signature>
  11157. if (arguments.length === 0) {
  11158. return options.disabledDates ? $.extend({}, options.disabledDates) : options.disabledDates;
  11159. }
  11160. if (!dates) {
  11161. options.disabledDates = false;
  11162. update();
  11163. return picker;
  11164. }
  11165. if (!(dates instanceof Array)) {
  11166. throw new TypeError('disabledDates() expects an array parameter');
  11167. }
  11168. options.disabledDates = indexGivenDates(dates);
  11169. options.enabledDates = false;
  11170. update();
  11171. return picker;
  11172. };
  11173. picker.enabledDates = function (dates) {
  11174. // /<signature helpKeyword="$.fn.datetimepicker.enabledDates">
  11175. // /<summary>Returns an array with the currently set enabled dates on the component.</summary>
  11176. // /<returns type="array">options.enabledDates</returns>
  11177. // /</signature>
  11178. // /<signature>
  11179. // /<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of options.disabledDates if such exist.</summary>
  11180. // /<param name="dates" locid="$.fn.datetimepicker.enabledDates_p:dates">Takes an [ string or Date or moment ] of values and allows the user to select only from those days.</param>
  11181. // /</signature>
  11182. if (arguments.length === 0) {
  11183. return options.enabledDates ? $.extend({}, options.enabledDates) : options.enabledDates;
  11184. }
  11185. if (!dates) {
  11186. options.enabledDates = false;
  11187. update();
  11188. return picker;
  11189. }
  11190. if (!(dates instanceof Array)) {
  11191. throw new TypeError('enabledDates() expects an array parameter');
  11192. }
  11193. options.enabledDates = indexGivenDates(dates);
  11194. options.disabledDates = false;
  11195. update();
  11196. return picker;
  11197. };
  11198. picker.daysOfWeekDisabled = function (daysOfWeekDisabled) {
  11199. if (arguments.length === 0) {
  11200. return options.daysOfWeekDisabled.splice(0);
  11201. }
  11202. if (typeof daysOfWeekDisabled === 'boolean' && !daysOfWeekDisabled) {
  11203. options.daysOfWeekDisabled = false;
  11204. update();
  11205. return picker;
  11206. }
  11207. if (!(daysOfWeekDisabled instanceof Array)) {
  11208. throw new TypeError('daysOfWeekDisabled() expects an array parameter');
  11209. }
  11210. options.daysOfWeekDisabled = daysOfWeekDisabled.reduce(function (previousValue, currentValue) {
  11211. currentValue = parseInt(currentValue, 10);
  11212. if (currentValue > 6 || currentValue < 0 || isNaN(currentValue)) {
  11213. return previousValue;
  11214. }
  11215. if (previousValue.indexOf(currentValue) === -1) {
  11216. previousValue.push(currentValue);
  11217. }
  11218. return previousValue;
  11219. }, []).sort();
  11220. if (options.useCurrent && !options.keepInvalid) {
  11221. var tries = 0;
  11222. while (!isValid(date, 'd')) {
  11223. date.add(1, 'd');
  11224. if (tries === 31) {
  11225. throw new Error('Tried 31 times to find a valid date');
  11226. }
  11227. tries++;
  11228. }
  11229. setValue(date);
  11230. }
  11231. update();
  11232. return picker;
  11233. };
  11234. picker.maxDate = function (maxDate) {
  11235. if (arguments.length === 0) {
  11236. return options.maxDate ? options.maxDate.clone() : options.maxDate;
  11237. }
  11238. if (typeof maxDate === 'boolean' && maxDate === false) {
  11239. options.maxDate = false;
  11240. update();
  11241. return picker;
  11242. }
  11243. if (typeof maxDate === 'string') {
  11244. if (maxDate === 'now' || maxDate === 'moment') {
  11245. maxDate = getMoment();
  11246. }
  11247. }
  11248. var parsedDate = parseInputDate(maxDate);
  11249. if (!parsedDate.isValid()) {
  11250. throw new TypeError('maxDate() Could not parse date parameter: ' + maxDate);
  11251. }
  11252. if (options.minDate && parsedDate.isBefore(options.minDate)) {
  11253. throw new TypeError('maxDate() date parameter is before options.minDate: ' + parsedDate.format(actualFormat));
  11254. }
  11255. options.maxDate = parsedDate;
  11256. if (options.useCurrent && !options.keepInvalid && date.isAfter(maxDate)) {
  11257. setValue(options.maxDate);
  11258. }
  11259. if (viewDate.isAfter(parsedDate)) {
  11260. viewDate = parsedDate.clone().subtract(options.stepping, 'm');
  11261. }
  11262. update();
  11263. return picker;
  11264. };
  11265. picker.minDate = function (minDate) {
  11266. if (arguments.length === 0) {
  11267. return options.minDate ? options.minDate.clone() : options.minDate;
  11268. }
  11269. if (typeof minDate === 'boolean' && minDate === false) {
  11270. options.minDate = false;
  11271. update();
  11272. return picker;
  11273. }
  11274. if (typeof minDate === 'string') {
  11275. if (minDate === 'now' || minDate === 'moment') {
  11276. minDate = getMoment();
  11277. }
  11278. }
  11279. var parsedDate = parseInputDate(minDate);
  11280. if (!parsedDate.isValid()) {
  11281. throw new TypeError('minDate() Could not parse date parameter: ' + minDate);
  11282. }
  11283. if (options.maxDate && parsedDate.isAfter(options.maxDate)) {
  11284. throw new TypeError('minDate() date parameter is after options.maxDate: ' + parsedDate.format(actualFormat));
  11285. }
  11286. options.minDate = parsedDate;
  11287. if (options.useCurrent && !options.keepInvalid && date.isBefore(minDate)) {
  11288. setValue(options.minDate);
  11289. }
  11290. if (viewDate.isBefore(parsedDate)) {
  11291. viewDate = parsedDate.clone().add(options.stepping, 'm');
  11292. }
  11293. update();
  11294. return picker;
  11295. };
  11296. picker.defaultDate = function (defaultDate) {
  11297. // /<signature helpKeyword="$.fn.datetimepicker.defaultDate">
  11298. // /<summary>Returns a moment with the options.defaultDate option configuration or false if not set</summary>
  11299. // /<returns type="Moment">date.clone()</returns>
  11300. // /</signature>
  11301. // /<signature>
  11302. // /<summary>Will set the picker's inital date. If a boolean:false value is passed the options.defaultDate parameter is cleared.</summary>
  11303. // /<param name="defaultDate" locid="$.fn.datetimepicker.defaultDate_p:defaultDate">Takes a string, Date, moment, boolean:false</param>
  11304. // /</signature>
  11305. if (arguments.length === 0) {
  11306. return options.defaultDate ? options.defaultDate.clone() : options.defaultDate;
  11307. }
  11308. if (!defaultDate) {
  11309. options.defaultDate = false;
  11310. return picker;
  11311. }
  11312. if (typeof defaultDate === 'string') {
  11313. if (defaultDate === 'now' || defaultDate === 'moment') {
  11314. defaultDate = getMoment();
  11315. } else {
  11316. defaultDate = getMoment(defaultDate);
  11317. }
  11318. }
  11319. var parsedDate = parseInputDate(defaultDate);
  11320. if (!parsedDate.isValid()) {
  11321. throw new TypeError('defaultDate() Could not parse date parameter: ' + defaultDate);
  11322. }
  11323. if (!isValid(parsedDate)) {
  11324. throw new TypeError('defaultDate() date passed is invalid according to component setup validations');
  11325. }
  11326. options.defaultDate = parsedDate;
  11327. if (options.defaultDate && options.inline || input.val().trim() === '') {
  11328. setValue(options.defaultDate);
  11329. }
  11330. return picker;
  11331. };
  11332. picker.locale = function (locale) {
  11333. if (arguments.length === 0) {
  11334. return options.locale;
  11335. }
  11336. if (!moment.localeData(locale)) {
  11337. throw new TypeError('locale() locale ' + locale + ' is not loaded from moment locales!');
  11338. }
  11339. options.locale = locale;
  11340. date.locale(options.locale);
  11341. viewDate.locale(options.locale);
  11342. if (actualFormat) {
  11343. initFormatting(); // reinit formatting
  11344. }
  11345. if (widget) {
  11346. hide();
  11347. show();
  11348. }
  11349. return picker;
  11350. };
  11351. picker.stepping = function (stepping) {
  11352. if (arguments.length === 0) {
  11353. return options.stepping;
  11354. }
  11355. stepping = parseInt(stepping, 10);
  11356. if (isNaN(stepping) || stepping < 1) {
  11357. stepping = 1;
  11358. }
  11359. options.stepping = stepping;
  11360. return picker;
  11361. };
  11362. picker.useCurrent = function (useCurrent) {
  11363. var useCurrentOptions = ['year', 'month', 'day', 'hour', 'minute'];
  11364. if (arguments.length === 0) {
  11365. return options.useCurrent;
  11366. }
  11367. if (typeof useCurrent !== 'boolean' && typeof useCurrent !== 'string') {
  11368. throw new TypeError('useCurrent() expects a boolean or string parameter');
  11369. }
  11370. if (typeof useCurrent === 'string' && useCurrentOptions.indexOf(useCurrent.toLowerCase()) === -1) {
  11371. throw new TypeError('useCurrent() expects a string parameter of ' + useCurrentOptions.join(', '));
  11372. }
  11373. options.useCurrent = useCurrent;
  11374. return picker;
  11375. };
  11376. picker.collapse = function (collapse) {
  11377. if (arguments.length === 0) {
  11378. return options.collapse;
  11379. }
  11380. if (typeof collapse !== 'boolean') {
  11381. throw new TypeError('collapse() expects a boolean parameter');
  11382. }
  11383. if (options.collapse === collapse) {
  11384. return picker;
  11385. }
  11386. options.collapse = collapse;
  11387. if (widget) {
  11388. hide();
  11389. show();
  11390. }
  11391. return picker;
  11392. };
  11393. picker.icons = function (icons) {
  11394. if (arguments.length === 0) {
  11395. return $.extend({}, options.icons);
  11396. }
  11397. if (!(icons instanceof Object)) {
  11398. throw new TypeError('icons() expects parameter to be an Object');
  11399. }
  11400. $.extend(options.icons, icons);
  11401. if (widget) {
  11402. hide();
  11403. show();
  11404. }
  11405. return picker;
  11406. };
  11407. picker.tooltips = function (tooltips) {
  11408. if (arguments.length === 0) {
  11409. return $.extend({}, options.tooltips);
  11410. }
  11411. if (!(tooltips instanceof Object)) {
  11412. throw new TypeError('tooltips() expects parameter to be an Object');
  11413. }
  11414. $.extend(options.tooltips, tooltips);
  11415. if (widget) {
  11416. hide();
  11417. show();
  11418. }
  11419. return picker;
  11420. };
  11421. picker.useStrict = function (useStrict) {
  11422. if (arguments.length === 0) {
  11423. return options.useStrict;
  11424. }
  11425. if (typeof useStrict !== 'boolean') {
  11426. throw new TypeError('useStrict() expects a boolean parameter');
  11427. }
  11428. options.useStrict = useStrict;
  11429. return picker;
  11430. };
  11431. picker.sideBySide = function (sideBySide) {
  11432. if (arguments.length === 0) {
  11433. return options.sideBySide;
  11434. }
  11435. if (typeof sideBySide !== 'boolean') {
  11436. throw new TypeError('sideBySide() expects a boolean parameter');
  11437. }
  11438. options.sideBySide = sideBySide;
  11439. if (widget) {
  11440. hide();
  11441. show();
  11442. }
  11443. return picker;
  11444. };
  11445. picker.viewMode = function (viewMode) {
  11446. if (arguments.length === 0) {
  11447. return options.viewMode;
  11448. }
  11449. if (typeof viewMode !== 'string') {
  11450. throw new TypeError('viewMode() expects a string parameter');
  11451. }
  11452. if (viewModes.indexOf(viewMode) === -1) {
  11453. throw new TypeError('viewMode() parameter must be one of (' + viewModes.join(', ') + ') value');
  11454. }
  11455. options.viewMode = viewMode;
  11456. currentViewMode = Math.max(viewModes.indexOf(viewMode), minViewModeNumber);
  11457. showMode();
  11458. return picker;
  11459. };
  11460. picker.toolbarPlacement = function (toolbarPlacement) {
  11461. if (arguments.length === 0) {
  11462. return options.toolbarPlacement;
  11463. }
  11464. if (typeof toolbarPlacement !== 'string') {
  11465. throw new TypeError('toolbarPlacement() expects a string parameter');
  11466. }
  11467. if (toolbarPlacements.indexOf(toolbarPlacement) === -1) {
  11468. throw new TypeError('toolbarPlacement() parameter must be one of (' + toolbarPlacements.join(', ') + ') value');
  11469. }
  11470. options.toolbarPlacement = toolbarPlacement;
  11471. if (widget) {
  11472. hide();
  11473. show();
  11474. }
  11475. return picker;
  11476. };
  11477. picker.widgetPositioning = function (widgetPositioning) {
  11478. if (arguments.length === 0) {
  11479. return $.extend({}, options.widgetPositioning);
  11480. }
  11481. if ({}.toString.call(widgetPositioning) !== '[object Object]') {
  11482. throw new TypeError('widgetPositioning() expects an object variable');
  11483. }
  11484. if (widgetPositioning.horizontal) {
  11485. if (typeof widgetPositioning.horizontal !== 'string') {
  11486. throw new TypeError('widgetPositioning() horizontal variable must be a string');
  11487. }
  11488. widgetPositioning.horizontal = widgetPositioning.horizontal.toLowerCase();
  11489. if (horizontalModes.indexOf(widgetPositioning.horizontal) === -1) {
  11490. throw new TypeError('widgetPositioning() expects horizontal parameter to be one of (' + horizontalModes.join(', ') + ')');
  11491. }
  11492. options.widgetPositioning.horizontal = widgetPositioning.horizontal;
  11493. }
  11494. if (widgetPositioning.vertical) {
  11495. if (typeof widgetPositioning.vertical !== 'string') {
  11496. throw new TypeError('widgetPositioning() vertical variable must be a string');
  11497. }
  11498. widgetPositioning.vertical = widgetPositioning.vertical.toLowerCase();
  11499. if (verticalModes.indexOf(widgetPositioning.vertical) === -1) {
  11500. throw new TypeError('widgetPositioning() expects vertical parameter to be one of (' + verticalModes.join(', ') + ')');
  11501. }
  11502. options.widgetPositioning.vertical = widgetPositioning.vertical;
  11503. }
  11504. update();
  11505. return picker;
  11506. };
  11507. picker.calendarWeeks = function (calendarWeeks) {
  11508. if (arguments.length === 0) {
  11509. return options.calendarWeeks;
  11510. }
  11511. if (typeof calendarWeeks !== 'boolean') {
  11512. throw new TypeError('calendarWeeks() expects parameter to be a boolean value');
  11513. }
  11514. options.calendarWeeks = calendarWeeks;
  11515. update();
  11516. return picker;
  11517. };
  11518. picker.showTodayButton = function (showTodayButton) {
  11519. if (arguments.length === 0) {
  11520. return options.showTodayButton;
  11521. }
  11522. if (typeof showTodayButton !== 'boolean') {
  11523. throw new TypeError('showTodayButton() expects a boolean parameter');
  11524. }
  11525. options.showTodayButton = showTodayButton;
  11526. if (widget) {
  11527. hide();
  11528. show();
  11529. }
  11530. return picker;
  11531. };
  11532. picker.showClear = function (showClear) {
  11533. if (arguments.length === 0) {
  11534. return options.showClear;
  11535. }
  11536. if (typeof showClear !== 'boolean') {
  11537. throw new TypeError('showClear() expects a boolean parameter');
  11538. }
  11539. options.showClear = showClear;
  11540. if (widget) {
  11541. hide();
  11542. show();
  11543. }
  11544. return picker;
  11545. };
  11546. picker.widgetParent = function (widgetParent) {
  11547. if (arguments.length === 0) {
  11548. return options.widgetParent;
  11549. }
  11550. if (typeof widgetParent === 'string') {
  11551. widgetParent = $(widgetParent);
  11552. }
  11553. if (widgetParent !== null && typeof widgetParent !== 'string' && !(widgetParent instanceof $)) {
  11554. throw new TypeError('widgetParent() expects a string or a jQuery object parameter');
  11555. }
  11556. options.widgetParent = widgetParent;
  11557. if (widget) {
  11558. hide();
  11559. show();
  11560. }
  11561. return picker;
  11562. };
  11563. picker.keepOpen = function (keepOpen) {
  11564. if (arguments.length === 0) {
  11565. return options.keepOpen;
  11566. }
  11567. if (typeof keepOpen !== 'boolean') {
  11568. throw new TypeError('keepOpen() expects a boolean parameter');
  11569. }
  11570. options.keepOpen = keepOpen;
  11571. return picker;
  11572. };
  11573. picker.focusOnShow = function (focusOnShow) {
  11574. if (arguments.length === 0) {
  11575. return options.focusOnShow;
  11576. }
  11577. if (typeof focusOnShow !== 'boolean') {
  11578. throw new TypeError('focusOnShow() expects a boolean parameter');
  11579. }
  11580. options.focusOnShow = focusOnShow;
  11581. return picker;
  11582. };
  11583. picker.inline = function (inline) {
  11584. if (arguments.length === 0) {
  11585. return options.inline;
  11586. }
  11587. if (typeof inline !== 'boolean') {
  11588. throw new TypeError('inline() expects a boolean parameter');
  11589. }
  11590. options.inline = inline;
  11591. return picker;
  11592. };
  11593. picker.clear = function () {
  11594. clear();
  11595. return picker;
  11596. };
  11597. picker.keyBinds = function (keyBinds) {
  11598. if (arguments.length === 0) {
  11599. return options.keyBinds;
  11600. }
  11601. options.keyBinds = keyBinds;
  11602. return picker;
  11603. };
  11604. picker.getMoment = function (d) {
  11605. return getMoment(d);
  11606. };
  11607. picker.debug = function (debug) {
  11608. if (typeof debug !== 'boolean') {
  11609. throw new TypeError('debug() expects a boolean parameter');
  11610. }
  11611. options.debug = debug;
  11612. return picker;
  11613. };
  11614. picker.allowInputToggle = function (allowInputToggle) {
  11615. if (arguments.length === 0) {
  11616. return options.allowInputToggle;
  11617. }
  11618. if (typeof allowInputToggle !== 'boolean') {
  11619. throw new TypeError('allowInputToggle() expects a boolean parameter');
  11620. }
  11621. options.allowInputToggle = allowInputToggle;
  11622. return picker;
  11623. };
  11624. picker.showClose = function (showClose) {
  11625. if (arguments.length === 0) {
  11626. return options.showClose;
  11627. }
  11628. if (typeof showClose !== 'boolean') {
  11629. throw new TypeError('showClose() expects a boolean parameter');
  11630. }
  11631. options.showClose = showClose;
  11632. return picker;
  11633. };
  11634. picker.keepInvalid = function (keepInvalid) {
  11635. if (arguments.length === 0) {
  11636. return options.keepInvalid;
  11637. }
  11638. if (typeof keepInvalid !== 'boolean') {
  11639. throw new TypeError('keepInvalid() expects a boolean parameter');
  11640. }
  11641. options.keepInvalid = keepInvalid;
  11642. return picker;
  11643. };
  11644. picker.datepickerInput = function (datepickerInput) {
  11645. if (arguments.length === 0) {
  11646. return options.datepickerInput;
  11647. }
  11648. if (typeof datepickerInput !== 'string') {
  11649. throw new TypeError('datepickerInput() expects a string parameter');
  11650. }
  11651. options.datepickerInput = datepickerInput;
  11652. return picker;
  11653. };
  11654. picker.parseInputDate = function (parseInputDate) {
  11655. if (arguments.length === 0) {
  11656. return options.parseInputDate;
  11657. }
  11658. if (typeof parseInputDate !== 'function') {
  11659. throw new TypeError('parseInputDate() sholud be as function');
  11660. }
  11661. options.parseInputDate = parseInputDate;
  11662. return picker;
  11663. };
  11664. picker.disabledTimeIntervals = function (disabledTimeIntervals) {
  11665. // /<signature helpKeyword="$.fn.datetimepicker.disabledTimeIntervals">
  11666. // /<summary>Returns an array with the currently set disabled dates on the component.</summary>
  11667. // /<returns type="array">options.disabledTimeIntervals</returns>
  11668. // /</signature>
  11669. // /<signature>
  11670. // /<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
  11671. // /options.enabledDates if such exist.</summary>
  11672. // /<param name="dates" locid="$.fn.datetimepicker.disabledTimeIntervals_p:dates">Takes an [ string or Date or moment ] of values and allows the user to select only from those days.</param>
  11673. // /</signature>
  11674. if (arguments.length === 0) {
  11675. return options.disabledTimeIntervals ? $.extend({}, options.disabledTimeIntervals) : options.disabledTimeIntervals;
  11676. }
  11677. if (!disabledTimeIntervals) {
  11678. options.disabledTimeIntervals = false;
  11679. update();
  11680. return picker;
  11681. }
  11682. if (!(disabledTimeIntervals instanceof Array)) {
  11683. throw new TypeError('disabledTimeIntervals() expects an array parameter');
  11684. }
  11685. options.disabledTimeIntervals = disabledTimeIntervals;
  11686. update();
  11687. return picker;
  11688. };
  11689. picker.disabledHours = function (hours) {
  11690. // /<signature helpKeyword="$.fn.datetimepicker.disabledHours">
  11691. // /<summary>Returns an array with the currently set disabled hours on the component.</summary>
  11692. // /<returns type="array">options.disabledHours</returns>
  11693. // /</signature>
  11694. // /<signature>
  11695. // /<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
  11696. // /options.enabledHours if such exist.</summary>
  11697. // /<param name="hours" locid="$.fn.datetimepicker.disabledHours_p:hours">Takes an [ int ] of values and disallows the user to select only from those hours.</param>
  11698. // /</signature>
  11699. if (arguments.length === 0) {
  11700. return options.disabledHours ? $.extend({}, options.disabledHours) : options.disabledHours;
  11701. }
  11702. if (!hours) {
  11703. options.disabledHours = false;
  11704. update();
  11705. return picker;
  11706. }
  11707. if (!(hours instanceof Array)) {
  11708. throw new TypeError('disabledHours() expects an array parameter');
  11709. }
  11710. options.disabledHours = indexGivenHours(hours);
  11711. options.enabledHours = false;
  11712. if (options.useCurrent && !options.keepInvalid) {
  11713. var tries = 0;
  11714. while (!isValid(date, 'h')) {
  11715. date.add(1, 'h');
  11716. if (tries === 24) {
  11717. throw new Error('Tried 24 times to find a valid date');
  11718. }
  11719. tries++;
  11720. }
  11721. setValue(date);
  11722. }
  11723. update();
  11724. return picker;
  11725. };
  11726. picker.enabledHours = function (hours) {
  11727. // /<signature helpKeyword="$.fn.datetimepicker.enabledHours">
  11728. // /<summary>Returns an array with the currently set enabled hours on the component.</summary>
  11729. // /<returns type="array">options.enabledHours</returns>
  11730. // /</signature>
  11731. // /<signature>
  11732. // /<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of options.disabledHours if such exist.</summary>
  11733. // /<param name="hours" locid="$.fn.datetimepicker.enabledHours_p:hours">Takes an [ int ] of values and allows the user to select only from those hours.</param>
  11734. // /</signature>
  11735. if (arguments.length === 0) {
  11736. return options.enabledHours ? $.extend({}, options.enabledHours) : options.enabledHours;
  11737. }
  11738. if (!hours) {
  11739. options.enabledHours = false;
  11740. update();
  11741. return picker;
  11742. }
  11743. if (!(hours instanceof Array)) {
  11744. throw new TypeError('enabledHours() expects an array parameter');
  11745. }
  11746. options.enabledHours = indexGivenHours(hours);
  11747. options.disabledHours = false;
  11748. if (options.useCurrent && !options.keepInvalid) {
  11749. var tries = 0;
  11750. while (!isValid(date, 'h')) {
  11751. date.add(1, 'h');
  11752. if (tries === 24) {
  11753. throw new Error('Tried 24 times to find a valid date');
  11754. }
  11755. tries++;
  11756. }
  11757. setValue(date);
  11758. }
  11759. update();
  11760. return picker;
  11761. };
  11762. /**
  11763. * Returns the component's model current viewDate, a moment object or null if not set. Passing a null value unsets the components model current moment. Parsing of the newDate parameter is made using moment library with the options.format and options.useStrict components configuration.
  11764. * @param {Takes string, viewDate, moment, null parameter.} newDate
  11765. * @returns {viewDate.clone()}
  11766. */
  11767. picker.viewDate = function (newDate) {
  11768. if (arguments.length === 0) {
  11769. return viewDate.clone();
  11770. }
  11771. if (!newDate) {
  11772. viewDate = date.clone();
  11773. return picker;
  11774. }
  11775. if (typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
  11776. throw new TypeError('viewDate() parameter must be one of [string, moment or Date]');
  11777. }
  11778. viewDate = parseInputDate(newDate);
  11779. viewUpdate();
  11780. return picker;
  11781. }; // initializing element and component attributes
  11782. if (element.is('input')) {
  11783. input = element;
  11784. } else {
  11785. input = element.find(options.datepickerInput);
  11786. if (input.length === 0) {
  11787. input = element.find('input');
  11788. } else if (!input.is('input')) {
  11789. throw new Error('CSS class "' + options.datepickerInput + '" cannot be applied to non input element');
  11790. }
  11791. }
  11792. if (element.hasClass('input-group')) {
  11793. // in case there is more then one 'input-group-addon' Issue #48
  11794. if (element.find('.datepickerbutton').length === 0) {
  11795. component = element.find('.input-group-addon');
  11796. } else {
  11797. component = element.find('.datepickerbutton');
  11798. }
  11799. }
  11800. if (!options.inline && !input.is('input')) {
  11801. throw new Error('Could not initialize DateTimePicker without an input element');
  11802. } // Set defaults for date here now instead of in var declaration
  11803. date = getMoment();
  11804. viewDate = date.clone();
  11805. $.extend(true, options, dataToOptions());
  11806. picker.options(options);
  11807. initFormatting();
  11808. attachDatePickerElementEvents();
  11809. if (input.prop('disabled')) {
  11810. picker.disable();
  11811. }
  11812. if (input.is('input') && input.val().trim().length !== 0) {
  11813. setValue(parseInputDate(input.val().trim()));
  11814. } else if (options.defaultDate && input.attr('placeholder') === undefined) {
  11815. setValue(options.defaultDate);
  11816. }
  11817. if (options.inline) {
  11818. show();
  11819. }
  11820. return picker;
  11821. };
  11822. /** ******************************************************************************
  11823. *
  11824. * jQuery plugin constructor and defaults object
  11825. *
  11826. ********************************************************************************/
  11827. /**
  11828. * See (http://jquery.com/).
  11829. * @name jQuery
  11830. * @class
  11831. * See the jQuery Library (http://jquery.com/) for full details. This just
  11832. * documents the function and classes that are added to jQuery by this plug-in.
  11833. */
  11834. /**
  11835. * See (http://jquery.com/)
  11836. * @name fn
  11837. * @class
  11838. * See the jQuery Library (http://jquery.com/) for full details. This just
  11839. * documents the function and classes that are added to jQuery by this plug-in.
  11840. * @memberOf jQuery
  11841. */
  11842. /**
  11843. * Show comments
  11844. * @class datetimepicker
  11845. * @memberOf jQuery.fn
  11846. */
  11847. $.fn.datetimepicker = function (options) {
  11848. options = options || {};
  11849. var args = Array.prototype.slice.call(arguments, 1);
  11850. var isInstance = true;
  11851. var thisMethods = ['destroy', 'hide', 'show', 'toggle'];
  11852. var returnValue;
  11853. if (_typeof(options) === 'object') {
  11854. return this.each(function () {
  11855. var $this = $(this);
  11856. var _options;
  11857. if (!$this.data('DateTimePicker')) {
  11858. // create a private copy of the defaults object
  11859. _options = $.extend(true, {}, $.fn.datetimepicker.defaults, options);
  11860. $this.data('DateTimePicker', dateTimePicker($this, _options));
  11861. }
  11862. });
  11863. } else if (typeof options === 'string') {
  11864. this.each(function () {
  11865. var $this = $(this);
  11866. var instance = $this.data('DateTimePicker');
  11867. if (!instance) {
  11868. throw new Error('bootstrap-datetimepicker("' + options + '") method was called on an element that is not using DateTimePicker');
  11869. }
  11870. returnValue = instance[options].apply(instance, args);
  11871. isInstance = returnValue === instance;
  11872. });
  11873. if (isInstance || $.inArray(options, thisMethods) > -1) {
  11874. return this;
  11875. }
  11876. return returnValue;
  11877. }
  11878. throw new TypeError('Invalid arguments for DateTimePicker: ' + options);
  11879. };
  11880. $.fn.datetimepicker.defaults = {
  11881. timeZone: '',
  11882. format: false,
  11883. dayViewHeaderFormat: 'MMMM YYYY',
  11884. extraFormats: false,
  11885. stepping: 1,
  11886. minDate: false,
  11887. maxDate: false,
  11888. useCurrent: true,
  11889. collapse: true,
  11890. locale: moment.locale(),
  11891. defaultDate: false,
  11892. disabledDates: false,
  11893. enabledDates: false,
  11894. icons: {
  11895. time: 'glyphicon glyphicon-time',
  11896. date: 'glyphicon glyphicon-calendar',
  11897. up: 'glyphicon glyphicon-chevron-up',
  11898. down: 'glyphicon glyphicon-chevron-down',
  11899. previous: 'glyphicon glyphicon-chevron-left',
  11900. next: 'glyphicon glyphicon-chevron-right',
  11901. today: 'glyphicon glyphicon-screenshot',
  11902. clear: 'glyphicon glyphicon-trash',
  11903. close: 'glyphicon glyphicon-remove'
  11904. },
  11905. tooltips: {
  11906. today: 'Go to today',
  11907. clear: 'Clear selection',
  11908. close: 'Close the picker',
  11909. selectMonth: 'Select Month',
  11910. prevMonth: 'Previous Month',
  11911. nextMonth: 'Next Month',
  11912. selectYear: 'Select Year',
  11913. prevYear: 'Previous Year',
  11914. nextYear: 'Next Year',
  11915. selectDecade: 'Select Decade',
  11916. prevDecade: 'Previous Decade',
  11917. nextDecade: 'Next Decade',
  11918. prevCentury: 'Previous Century',
  11919. nextCentury: 'Next Century',
  11920. pickHour: 'Pick Hour',
  11921. incrementHour: 'Increment Hour',
  11922. decrementHour: 'Decrement Hour',
  11923. pickMinute: 'Pick Minute',
  11924. incrementMinute: 'Increment Minute',
  11925. decrementMinute: 'Decrement Minute',
  11926. pickSecond: 'Pick Second',
  11927. incrementSecond: 'Increment Second',
  11928. decrementSecond: 'Decrement Second',
  11929. togglePeriod: 'Toggle Period',
  11930. selectTime: 'Select Time'
  11931. },
  11932. useStrict: false,
  11933. sideBySide: false,
  11934. daysOfWeekDisabled: false,
  11935. calendarWeeks: false,
  11936. viewMode: 'days',
  11937. toolbarPlacement: 'default',
  11938. showTodayButton: false,
  11939. showClear: false,
  11940. showClose: false,
  11941. widgetPositioning: {
  11942. horizontal: 'auto',
  11943. vertical: 'auto'
  11944. },
  11945. widgetParent: null,
  11946. ignoreReadonly: false,
  11947. keepOpen: false,
  11948. focusOnShow: true,
  11949. inline: false,
  11950. keepInvalid: false,
  11951. datepickerInput: '.datepickerinput',
  11952. keyBinds: {
  11953. up: function up(widget) {
  11954. if (!widget) {
  11955. return;
  11956. }
  11957. var d = this.date() || this.getMoment();
  11958. if (widget.find('.datepicker').is(':visible')) {
  11959. this.date(d.clone().subtract(7, 'd'));
  11960. } else {
  11961. this.date(d.clone().add(this.stepping(), 'm'));
  11962. }
  11963. },
  11964. down: function down(widget) {
  11965. if (!widget) {
  11966. this.show();
  11967. return;
  11968. }
  11969. var d = this.date() || this.getMoment();
  11970. if (widget.find('.datepicker').is(':visible')) {
  11971. this.date(d.clone().add(7, 'd'));
  11972. } else {
  11973. this.date(d.clone().subtract(this.stepping(), 'm'));
  11974. }
  11975. },
  11976. 'control up': function controlUp(widget) {
  11977. if (!widget) {
  11978. return;
  11979. }
  11980. var d = this.date() || this.getMoment();
  11981. if (widget.find('.datepicker').is(':visible')) {
  11982. this.date(d.clone().subtract(1, 'y'));
  11983. } else {
  11984. this.date(d.clone().add(1, 'h'));
  11985. }
  11986. },
  11987. 'control down': function controlDown(widget) {
  11988. if (!widget) {
  11989. return;
  11990. }
  11991. var d = this.date() || this.getMoment();
  11992. if (widget.find('.datepicker').is(':visible')) {
  11993. this.date(d.clone().add(1, 'y'));
  11994. } else {
  11995. this.date(d.clone().subtract(1, 'h'));
  11996. }
  11997. },
  11998. left: function left(widget) {
  11999. if (!widget) {
  12000. return;
  12001. }
  12002. var d = this.date() || this.getMoment();
  12003. if (widget.find('.datepicker').is(':visible')) {
  12004. this.date(d.clone().subtract(1, 'd'));
  12005. }
  12006. },
  12007. right: function right(widget) {
  12008. if (!widget) {
  12009. return;
  12010. }
  12011. var d = this.date() || this.getMoment();
  12012. if (widget.find('.datepicker').is(':visible')) {
  12013. this.date(d.clone().add(1, 'd'));
  12014. }
  12015. },
  12016. pageUp: function pageUp(widget) {
  12017. if (!widget) {
  12018. return;
  12019. }
  12020. var d = this.date() || this.getMoment();
  12021. if (widget.find('.datepicker').is(':visible')) {
  12022. this.date(d.clone().subtract(1, 'M'));
  12023. }
  12024. },
  12025. pageDown: function pageDown(widget) {
  12026. if (!widget) {
  12027. return;
  12028. }
  12029. var d = this.date() || this.getMoment();
  12030. if (widget.find('.datepicker').is(':visible')) {
  12031. this.date(d.clone().add(1, 'M'));
  12032. }
  12033. },
  12034. enter: function enter() {
  12035. this.hide();
  12036. },
  12037. escape: function escape() {
  12038. this.hide();
  12039. },
  12040. // tab: function (widget) { //this break the flow of the form. disabling for now
  12041. // var toggle = widget.find('.picker-switch a[data-action="togglePicker"]');
  12042. // if(toggle.length > 0) toggle.click();
  12043. // },
  12044. 'control space': function controlSpace(widget) {
  12045. if (!widget) {
  12046. return;
  12047. }
  12048. if (widget.find('.timepicker').is(':visible')) {
  12049. widget.find('.btn[data-action="togglePeriod"]').click();
  12050. }
  12051. },
  12052. t: function t() {
  12053. this.date(this.getMoment());
  12054. },
  12055. 'delete': function _delete() {
  12056. this.clear();
  12057. }
  12058. },
  12059. debug: false,
  12060. allowInputToggle: false,
  12061. disabledTimeIntervals: false,
  12062. disabledHours: false,
  12063. enabledHours: false,
  12064. viewDate: false
  12065. };
  12066. return $.fn.datetimepicker;
  12067. });
  12068. /***/ }),
  12069. /***/ 31619:
  12070. /***/ (() => {
  12071. // localStorage
  12072. (function () {
  12073. function isSupported() {
  12074. var item = 'localStoragePollyfill';
  12075. try {
  12076. localStorage.setItem(item, item);
  12077. localStorage.removeItem(item);
  12078. sessionStorage.setItem(item, item);
  12079. sessionStorage.removeItem(item);
  12080. return true;
  12081. } catch (e) {
  12082. return false;
  12083. }
  12084. }
  12085. if (!isSupported()) {
  12086. try {
  12087. Storage.prototype._data = {};
  12088. Storage.prototype.setItem = function (id, val) {
  12089. this._data[id] = String(val);
  12090. return this._data[id];
  12091. };
  12092. Storage.prototype.getItem = function (id) {
  12093. return this._data.hasOwnProperty(id) ? this._data[id] : undefined;
  12094. };
  12095. Storage.prototype.removeItem = function (id) {
  12096. return delete this._data[id];
  12097. };
  12098. Storage.prototype.clear = function () {
  12099. this._data = {};
  12100. return this._data;
  12101. };
  12102. } catch (e) {
  12103. console.error('localStorage pollyfill error: ', e);
  12104. }
  12105. }
  12106. })();
  12107. /***/ }),
  12108. /***/ 46700:
  12109. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  12110. var map = {
  12111. "./af": 42786,
  12112. "./af.js": 42786,
  12113. "./ar": 30867,
  12114. "./ar-dz": 14130,
  12115. "./ar-dz.js": 14130,
  12116. "./ar-kw": 96135,
  12117. "./ar-kw.js": 96135,
  12118. "./ar-ly": 56440,
  12119. "./ar-ly.js": 56440,
  12120. "./ar-ma": 47702,
  12121. "./ar-ma.js": 47702,
  12122. "./ar-sa": 16040,
  12123. "./ar-sa.js": 16040,
  12124. "./ar-tn": 37100,
  12125. "./ar-tn.js": 37100,
  12126. "./ar.js": 30867,
  12127. "./az": 31083,
  12128. "./az.js": 31083,
  12129. "./be": 9808,
  12130. "./be.js": 9808,
  12131. "./bg": 68338,
  12132. "./bg.js": 68338,
  12133. "./bm": 67438,
  12134. "./bm.js": 67438,
  12135. "./bn": 8905,
  12136. "./bn-bd": 76225,
  12137. "./bn-bd.js": 76225,
  12138. "./bn.js": 8905,
  12139. "./bo": 11560,
  12140. "./bo.js": 11560,
  12141. "./br": 1278,
  12142. "./br.js": 1278,
  12143. "./bs": 80622,
  12144. "./bs.js": 80622,
  12145. "./ca": 2468,
  12146. "./ca.js": 2468,
  12147. "./cs": 5822,
  12148. "./cs.js": 5822,
  12149. "./cv": 50877,
  12150. "./cv.js": 50877,
  12151. "./cy": 47373,
  12152. "./cy.js": 47373,
  12153. "./da": 24780,
  12154. "./da.js": 24780,
  12155. "./de": 59740,
  12156. "./de-at": 60217,
  12157. "./de-at.js": 60217,
  12158. "./de-ch": 60894,
  12159. "./de-ch.js": 60894,
  12160. "./de.js": 59740,
  12161. "./dv": 5300,
  12162. "./dv.js": 5300,
  12163. "./el": 50837,
  12164. "./el.js": 50837,
  12165. "./en-au": 78348,
  12166. "./en-au.js": 78348,
  12167. "./en-ca": 77925,
  12168. "./en-ca.js": 77925,
  12169. "./en-gb": 22243,
  12170. "./en-gb.js": 22243,
  12171. "./en-ie": 46436,
  12172. "./en-ie.js": 46436,
  12173. "./en-il": 47207,
  12174. "./en-il.js": 47207,
  12175. "./en-in": 44175,
  12176. "./en-in.js": 44175,
  12177. "./en-nz": 76319,
  12178. "./en-nz.js": 76319,
  12179. "./en-sg": 31662,
  12180. "./en-sg.js": 31662,
  12181. "./eo": 92915,
  12182. "./eo.js": 92915,
  12183. "./es": 55655,
  12184. "./es-do": 55251,
  12185. "./es-do.js": 55251,
  12186. "./es-mx": 96112,
  12187. "./es-mx.js": 96112,
  12188. "./es-us": 71146,
  12189. "./es-us.js": 71146,
  12190. "./es.js": 55655,
  12191. "./et": 5603,
  12192. "./et.js": 5603,
  12193. "./eu": 77763,
  12194. "./eu.js": 77763,
  12195. "./fa": 76959,
  12196. "./fa.js": 76959,
  12197. "./fi": 11897,
  12198. "./fi.js": 11897,
  12199. "./fil": 42549,
  12200. "./fil.js": 42549,
  12201. "./fo": 94694,
  12202. "./fo.js": 94694,
  12203. "./fr": 94470,
  12204. "./fr-ca": 63049,
  12205. "./fr-ca.js": 63049,
  12206. "./fr-ch": 52330,
  12207. "./fr-ch.js": 52330,
  12208. "./fr.js": 94470,
  12209. "./fy": 5044,
  12210. "./fy.js": 5044,
  12211. "./ga": 29295,
  12212. "./ga.js": 29295,
  12213. "./gd": 2101,
  12214. "./gd.js": 2101,
  12215. "./gl": 38794,
  12216. "./gl.js": 38794,
  12217. "./gom-deva": 27884,
  12218. "./gom-deva.js": 27884,
  12219. "./gom-latn": 23168,
  12220. "./gom-latn.js": 23168,
  12221. "./gu": 95349,
  12222. "./gu.js": 95349,
  12223. "./he": 24206,
  12224. "./he.js": 24206,
  12225. "./hi": 30094,
  12226. "./hi.js": 30094,
  12227. "./hr": 30316,
  12228. "./hr.js": 30316,
  12229. "./hu": 22138,
  12230. "./hu.js": 22138,
  12231. "./hy-am": 11423,
  12232. "./hy-am.js": 11423,
  12233. "./id": 29218,
  12234. "./id.js": 29218,
  12235. "./is": 90135,
  12236. "./is.js": 90135,
  12237. "./it": 90626,
  12238. "./it-ch": 10150,
  12239. "./it-ch.js": 10150,
  12240. "./it.js": 90626,
  12241. "./ja": 39183,
  12242. "./ja.js": 39183,
  12243. "./jv": 24286,
  12244. "./jv.js": 24286,
  12245. "./ka": 12105,
  12246. "./ka.js": 12105,
  12247. "./kk": 47772,
  12248. "./kk.js": 47772,
  12249. "./km": 18758,
  12250. "./km.js": 18758,
  12251. "./kn": 79282,
  12252. "./kn.js": 79282,
  12253. "./ko": 33730,
  12254. "./ko.js": 33730,
  12255. "./ku": 1408,
  12256. "./ku.js": 1408,
  12257. "./ky": 33291,
  12258. "./ky.js": 33291,
  12259. "./lb": 36841,
  12260. "./lb.js": 36841,
  12261. "./lo": 55466,
  12262. "./lo.js": 55466,
  12263. "./lt": 57010,
  12264. "./lt.js": 57010,
  12265. "./lv": 37595,
  12266. "./lv.js": 37595,
  12267. "./me": 39861,
  12268. "./me.js": 39861,
  12269. "./mi": 35493,
  12270. "./mi.js": 35493,
  12271. "./mk": 95966,
  12272. "./mk.js": 95966,
  12273. "./ml": 87341,
  12274. "./ml.js": 87341,
  12275. "./mn": 5115,
  12276. "./mn.js": 5115,
  12277. "./mr": 10370,
  12278. "./mr.js": 10370,
  12279. "./ms": 9847,
  12280. "./ms-my": 41237,
  12281. "./ms-my.js": 41237,
  12282. "./ms.js": 9847,
  12283. "./mt": 72126,
  12284. "./mt.js": 72126,
  12285. "./my": 56165,
  12286. "./my.js": 56165,
  12287. "./nb": 64924,
  12288. "./nb.js": 64924,
  12289. "./ne": 16744,
  12290. "./ne.js": 16744,
  12291. "./nl": 93901,
  12292. "./nl-be": 59814,
  12293. "./nl-be.js": 59814,
  12294. "./nl.js": 93901,
  12295. "./nn": 83877,
  12296. "./nn.js": 83877,
  12297. "./oc-lnc": 92135,
  12298. "./oc-lnc.js": 92135,
  12299. "./pa-in": 15858,
  12300. "./pa-in.js": 15858,
  12301. "./pl": 64495,
  12302. "./pl.js": 64495,
  12303. "./pt": 89520,
  12304. "./pt-br": 57971,
  12305. "./pt-br.js": 57971,
  12306. "./pt.js": 89520,
  12307. "./ro": 96459,
  12308. "./ro.js": 96459,
  12309. "./ru": 21793,
  12310. "./ru.js": 21793,
  12311. "./sd": 40950,
  12312. "./sd.js": 40950,
  12313. "./se": 10490,
  12314. "./se.js": 10490,
  12315. "./si": 90124,
  12316. "./si.js": 90124,
  12317. "./sk": 64249,
  12318. "./sk.js": 64249,
  12319. "./sl": 14985,
  12320. "./sl.js": 14985,
  12321. "./sq": 51104,
  12322. "./sq.js": 51104,
  12323. "./sr": 49131,
  12324. "./sr-cyrl": 79915,
  12325. "./sr-cyrl.js": 79915,
  12326. "./sr.js": 49131,
  12327. "./ss": 85893,
  12328. "./ss.js": 85893,
  12329. "./sv": 98760,
  12330. "./sv.js": 98760,
  12331. "./sw": 91172,
  12332. "./sw.js": 91172,
  12333. "./ta": 27333,
  12334. "./ta.js": 27333,
  12335. "./te": 23110,
  12336. "./te.js": 23110,
  12337. "./tet": 52095,
  12338. "./tet.js": 52095,
  12339. "./tg": 27321,
  12340. "./tg.js": 27321,
  12341. "./th": 9041,
  12342. "./th.js": 9041,
  12343. "./tk": 19005,
  12344. "./tk.js": 19005,
  12345. "./tl-ph": 75768,
  12346. "./tl-ph.js": 75768,
  12347. "./tlh": 89444,
  12348. "./tlh.js": 89444,
  12349. "./tr": 72397,
  12350. "./tr.js": 72397,
  12351. "./tzl": 28254,
  12352. "./tzl.js": 28254,
  12353. "./tzm": 51106,
  12354. "./tzm-latn": 30699,
  12355. "./tzm-latn.js": 30699,
  12356. "./tzm.js": 51106,
  12357. "./ug-cn": 9288,
  12358. "./ug-cn.js": 9288,
  12359. "./uk": 67691,
  12360. "./uk.js": 67691,
  12361. "./ur": 13795,
  12362. "./ur.js": 13795,
  12363. "./uz": 6791,
  12364. "./uz-latn": 60588,
  12365. "./uz-latn.js": 60588,
  12366. "./uz.js": 6791,
  12367. "./vi": 65666,
  12368. "./vi.js": 65666,
  12369. "./x-pseudo": 14378,
  12370. "./x-pseudo.js": 14378,
  12371. "./yo": 75805,
  12372. "./yo.js": 75805,
  12373. "./zh-cn": 83839,
  12374. "./zh-cn.js": 83839,
  12375. "./zh-hk": 55726,
  12376. "./zh-hk.js": 55726,
  12377. "./zh-mo": 99807,
  12378. "./zh-mo.js": 99807,
  12379. "./zh-tw": 74152,
  12380. "./zh-tw.js": 74152
  12381. };
  12382. function webpackContext(req) {
  12383. var id = webpackContextResolve(req);
  12384. return __webpack_require__(id);
  12385. }
  12386. function webpackContextResolve(req) {
  12387. if(!__webpack_require__.o(map, req)) {
  12388. var e = new Error("Cannot find module '" + req + "'");
  12389. e.code = 'MODULE_NOT_FOUND';
  12390. throw e;
  12391. }
  12392. return map[req];
  12393. }
  12394. webpackContext.keys = function webpackContextKeys() {
  12395. return Object.keys(map);
  12396. };
  12397. webpackContext.resolve = webpackContextResolve;
  12398. module.exports = webpackContext;
  12399. webpackContext.id = 46700;
  12400. /***/ }),
  12401. /***/ 56089:
  12402. /***/ ((module) => {
  12403. "use strict";
  12404. module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==";
  12405. /***/ }),
  12406. /***/ 17735:
  12407. /***/ ((module) => {
  12408. "use strict";
  12409. module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=";
  12410. /***/ }),
  12411. /***/ 96192:
  12412. /***/ ((module) => {
  12413. "use strict";
  12414. module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC";
  12415. /***/ }),
  12416. /***/ 71090:
  12417. /***/ ((module) => {
  12418. "use strict";
  12419. module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=";
  12420. /***/ }),
  12421. /***/ 46050:
  12422. /***/ ((module) => {
  12423. "use strict";
  12424. module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=";
  12425. /***/ }),
  12426. /***/ 65311:
  12427. /***/ ((module) => {
  12428. "use strict";
  12429. module.exports = jQuery;
  12430. /***/ })
  12431. /******/ });
  12432. /************************************************************************/
  12433. /******/ // The module cache
  12434. /******/ var __webpack_module_cache__ = {};
  12435. /******/
  12436. /******/ // The require function
  12437. /******/ function __webpack_require__(moduleId) {
  12438. /******/ // Check if module is in cache
  12439. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  12440. /******/ if (cachedModule !== undefined) {
  12441. /******/ return cachedModule.exports;
  12442. /******/ }
  12443. /******/ // Create a new module (and put it into the cache)
  12444. /******/ var module = __webpack_module_cache__[moduleId] = {
  12445. /******/ id: moduleId,
  12446. /******/ loaded: false,
  12447. /******/ exports: {}
  12448. /******/ };
  12449. /******/
  12450. /******/ // Execute the module function
  12451. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  12452. /******/
  12453. /******/ // Flag the module as loaded
  12454. /******/ module.loaded = true;
  12455. /******/
  12456. /******/ // Return the exports of the module
  12457. /******/ return module.exports;
  12458. /******/ }
  12459. /******/
  12460. /******/ // expose the modules object (__webpack_modules__)
  12461. /******/ __webpack_require__.m = __webpack_modules__;
  12462. /******/
  12463. /************************************************************************/
  12464. /******/ /* webpack/runtime/amd define */
  12465. /******/ (() => {
  12466. /******/ __webpack_require__.amdD = function () {
  12467. /******/ throw new Error('define cannot be used indirect');
  12468. /******/ };
  12469. /******/ })();
  12470. /******/
  12471. /******/ /* webpack/runtime/chunk loaded */
  12472. /******/ (() => {
  12473. /******/ var deferred = [];
  12474. /******/ __webpack_require__.O = (result, chunkIds, fn, priority) => {
  12475. /******/ if(chunkIds) {
  12476. /******/ priority = priority || 0;
  12477. /******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
  12478. /******/ deferred[i] = [chunkIds, fn, priority];
  12479. /******/ return;
  12480. /******/ }
  12481. /******/ var notFulfilled = Infinity;
  12482. /******/ for (var i = 0; i < deferred.length; i++) {
  12483. /******/ var [chunkIds, fn, priority] = deferred[i];
  12484. /******/ var fulfilled = true;
  12485. /******/ for (var j = 0; j < chunkIds.length; j++) {
  12486. /******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
  12487. /******/ chunkIds.splice(j--, 1);
  12488. /******/ } else {
  12489. /******/ fulfilled = false;
  12490. /******/ if(priority < notFulfilled) notFulfilled = priority;
  12491. /******/ }
  12492. /******/ }
  12493. /******/ if(fulfilled) {
  12494. /******/ deferred.splice(i--, 1)
  12495. /******/ var r = fn();
  12496. /******/ if (r !== undefined) result = r;
  12497. /******/ }
  12498. /******/ }
  12499. /******/ return result;
  12500. /******/ };
  12501. /******/ })();
  12502. /******/
  12503. /******/ /* webpack/runtime/compat get default export */
  12504. /******/ (() => {
  12505. /******/ // getDefaultExport function for compatibility with non-harmony modules
  12506. /******/ __webpack_require__.n = (module) => {
  12507. /******/ var getter = module && module.__esModule ?
  12508. /******/ () => (module['default']) :
  12509. /******/ () => (module);
  12510. /******/ __webpack_require__.d(getter, { a: getter });
  12511. /******/ return getter;
  12512. /******/ };
  12513. /******/ })();
  12514. /******/
  12515. /******/ /* webpack/runtime/define property getters */
  12516. /******/ (() => {
  12517. /******/ // define getter functions for harmony exports
  12518. /******/ __webpack_require__.d = (exports, definition) => {
  12519. /******/ for(var key in definition) {
  12520. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  12521. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  12522. /******/ }
  12523. /******/ }
  12524. /******/ };
  12525. /******/ })();
  12526. /******/
  12527. /******/ /* webpack/runtime/global */
  12528. /******/ (() => {
  12529. /******/ __webpack_require__.g = (function() {
  12530. /******/ if (typeof globalThis === 'object') return globalThis;
  12531. /******/ try {
  12532. /******/ return this || new Function('return this')();
  12533. /******/ } catch (e) {
  12534. /******/ if (typeof window === 'object') return window;
  12535. /******/ }
  12536. /******/ })();
  12537. /******/ })();
  12538. /******/
  12539. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  12540. /******/ (() => {
  12541. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  12542. /******/ })();
  12543. /******/
  12544. /******/ /* webpack/runtime/make namespace object */
  12545. /******/ (() => {
  12546. /******/ // define __esModule on exports
  12547. /******/ __webpack_require__.r = (exports) => {
  12548. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  12549. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  12550. /******/ }
  12551. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  12552. /******/ };
  12553. /******/ })();
  12554. /******/
  12555. /******/ /* webpack/runtime/node module decorator */
  12556. /******/ (() => {
  12557. /******/ __webpack_require__.nmd = (module) => {
  12558. /******/ module.paths = [];
  12559. /******/ if (!module.children) module.children = [];
  12560. /******/ return module;
  12561. /******/ };
  12562. /******/ })();
  12563. /******/
  12564. /******/ /* webpack/runtime/jsonp chunk loading */
  12565. /******/ (() => {
  12566. /******/ __webpack_require__.b = document.baseURI || self.location.href;
  12567. /******/
  12568. /******/ // object to store loaded and loading chunks
  12569. /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
  12570. /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
  12571. /******/ var installedChunks = {
  12572. /******/ 328: 0
  12573. /******/ };
  12574. /******/
  12575. /******/ // no chunk on demand loading
  12576. /******/
  12577. /******/ // no prefetching
  12578. /******/
  12579. /******/ // no preloaded
  12580. /******/
  12581. /******/ // no HMR
  12582. /******/
  12583. /******/ // no HMR manifest
  12584. /******/
  12585. /******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
  12586. /******/
  12587. /******/ // install a JSONP callback for chunk loading
  12588. /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
  12589. /******/ var [chunkIds, moreModules, runtime] = data;
  12590. /******/ // add "moreModules" to the modules object,
  12591. /******/ // then flag all "chunkIds" as loaded and fire callback
  12592. /******/ var moduleId, chunkId, i = 0;
  12593. /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
  12594. /******/ for(moduleId in moreModules) {
  12595. /******/ if(__webpack_require__.o(moreModules, moduleId)) {
  12596. /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
  12597. /******/ }
  12598. /******/ }
  12599. /******/ if(runtime) var result = runtime(__webpack_require__);
  12600. /******/ }
  12601. /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
  12602. /******/ for(;i < chunkIds.length; i++) {
  12603. /******/ chunkId = chunkIds[i];
  12604. /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
  12605. /******/ installedChunks[chunkId][0]();
  12606. /******/ }
  12607. /******/ installedChunks[chunkId] = 0;
  12608. /******/ }
  12609. /******/ return __webpack_require__.O(result);
  12610. /******/ }
  12611. /******/
  12612. /******/ var chunkLoadingGlobal = self["webpackChunkGrav"] = self["webpackChunkGrav"] || [];
  12613. /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
  12614. /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
  12615. /******/ })();
  12616. /******/
  12617. /************************************************************************/
  12618. /******/
  12619. /******/ // startup
  12620. /******/ // Load entry module and return exports
  12621. /******/ // This entry module depends on other loaded chunks and execution need to be delayed
  12622. /******/ var __webpack_exports__ = __webpack_require__.O(undefined, [736], () => (__webpack_require__(56299)))
  12623. /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
  12624. /******/ Grav = __webpack_exports__;
  12625. /******/
  12626. /******/ })()
  12627. ;